npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

semantic-ui-redux-form-fields

v1.0.1

Published

Semantic UI Fields integration with Redux From

Downloads

47

Readme

Semantic UI React Redux Form Fields

npm npm wercker status David

This React component library is designed to help you easily integrate Semantic UI React with Redux Form. The components come all pre-hooked-up so you don't have to worry about error reporting or the presentation logic since everything works right out of the box. Included is the big five form components Checkbox Dropdown, Input, Radio, and TextArea as well as fieldEnhance a higher order component that gives you the flexibility to extend and customize.

Install

Package Manager

# yarn
yarn add semantic-ui-redux-form-fields
# npm
npm install semantic-ui-redux-form-fields

Github

In the dist/ directory contains a pre-build Node, Browser, and Browser minified version. However, I strongly recommend you use yarn or npm.

Prerequisites

  1. Install and Config Redux
  2. Install and Config Redux Form
  3. Install and Config React Semantic UI
    • The assumption is you are using Semantic UI. And while you can "technically" use these components as standalones it would not make much sense. Furthermore, the Semantic UI css styles are not included in this package to allow for easier style customizations with Semantic themes and such.

Props

  • All the default Semantic UI props for each component can be passed just like you would expect.
  • currentValue → Is the value for all components. It's critically important that you use currentValue and not value otherwise the component will not work.
  • topLabel → A Semantic UI label that's positioned above the field (top-right).
  • Events → In all likelihood you'll need to implement custom events, and while you can use a non-append prop like onChange you won't have access to the redux-form input methods. However, by using these {*}Custom appended props input is passed as the first argument.
    • onBlurCustom(input, event, newValue, previousValue)
    • onChangeCustom(input, event, newValue, previousValue)
    • onDragStartCustom(input, event)
    • onDropCustom(input, event, newValue, previousValue)
    • onFocusCustom(input, event)

Imports

import {
  Checkbox,
  Dropdown,
  fieldEnhance,
  Input,
  Radio,
  TextArea,
} from 'semantic-ui-redux-form-fields';

Field HOC

All the fields are created through the fieldEnhance higher order component which mentioned above gives you the ability to extend and customize. t handles the Form.Field presentational logic which includes error reporting and a top label. For example, it allows you to easily hook-up and use React TimePicker. Check out __tests__/fieldEnhance.HOC.spec.js for an example how to use fieldEnhance with React TimePicker.

Field Examples

Here's a few examples, and need be there's more examples in __tests__. Also check out the __tests__/fieldEnhance.HOC.spec.js

Checkbox

import React from 'react';
import { Field, reduxForm } from 'redux-form';
import { Checkbox } from 'semantic-ui-redux-form-fields';

const SemanticFormCheckbox = (props) => {
  const { currentValue, handleSubmit, pristine, submitting } = props;
  return (
    <form onSubmit={handleSubmit}>
      <Field
        component={Checkbox}
        currentValue={currentValue}
        name='my-Checkbox'
        placeholder='My Checkbox'
        required={true}
        topLabel='My Checkbox'
      />

      <div>
        <button type='submit' disabled={pristine || submitting}>
          Submit
        </button>
      </div>
    </form>
  );
};

export default reduxForm({
  // a unique identifier for this form
  form: 'Semantic_Checkbox_Form'
})(SemanticFormCheckbox);

Input

import React from 'react';
import { Field, reduxForm } from 'redux-form';
import { Input } from 'semantic-ui-redux-form-fields';


const SemanticFormInput = (props) => {
  const { currentValue, handleSubmit, pristine, submitting } = props;
  return (
    <form onSubmit={handleSubmit}>
      <Field
        component={Input}
        currentValue={currentValue}
        name='my-Input'
        placeholder='My Input'
        required={true}
        topLabel='My Input'
      />

      <div>
        <button type='submit' disabled={pristine || submitting}>
          Submit
        </button>
      </div>
    </form>
  );
};

export default reduxForm({
  // a unique identifier for this form
  form: 'Semantic_Input_Form'
})(SemanticFormInput);

Dropdown

import React from 'react';
import { Field, reduxForm } from 'redux-form';
import { Dropdown } from 'semantic-ui-redux-form-fields';

const checkboxOptions = [{
  value: 'one', text: 'one', key: 'one',
}, {
  value: 'two', text: 'two', key: 'two',
}, {
  value: 'three', text: 'three', key: 'three',
}];

const SemanticFormDropdown = (props) => {
  const { currentValue, handleSubmit, pristine, submitting } = props;
  return (
    <form onSubmit={handleSubmit}>
      <Field
        component={Dropdown}
        currentValue={currentValue}
        name='my-Dropdown'
        options={checkboxOptions}
        placeholder='My Dropdown'
        required={true}
        topLabel='My Dropdown'
      />

      <div>
        <button type='submit' disabled={pristine || submitting}>
          Submit
        </button>
      </div>
    </form>
  );
};

export default reduxForm({
  // a unique identifier for this form
  form: 'Semantic_Dropdown_Form'
})(SemanticFormDropdown);

Best, te