1.1.46 • Published 4 months ago

@sierralabs/forms-ui v1.1.46

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
4 months ago

Sierra Labs Forms UI

Sierra Labs Forms React UI Library for managing form schemas, form templates, and form data capture.

Getting Started

Install the @sierralabs/forms-ui package along with peer dependencies

# for npm
$ npm install @sierralabs/core @sierralabs/forms-core @sierralabs/track-changes @sierralabs/state-machine @sierralabs/react-material-ui @sierralabs/react-material-ui-formik @sierralabs/forms-ui

# or for yarn
$ yarn add @sierralabs/core @sierralabs/forms-core @sierralabs/track-changes @sierralabs/state-machine @sierralabs/react-material-ui @sierralabs/react-material-ui-formik @sierralabs/forms-ui

# forms-ui is also dependent on react, material-ui, date-fns, js-cookie, styled-components, formik, yup, use-query-arams, react-router-dom, react-number-format, @tinymce/tinymce-react, react-beautiful-dnd

$ yarn add @material-ui/core @material-ui/icons @material-ui/lab @material-ui/pickers @tinymce/tinymce-react date-fns formik js-cookie react-beautiful-dnd react-number-format react-router-dom styled-components use-query-params yup # or npm install

Form Schema and Template Editors

Add the following Routes to your project for the form schema and form template editors. These components integrate with the @sierralabs/forms-api provided endpoints.

<Switch>
  <Route
    exact
    path='/portal/admin/form-templates'
    component={FormTemplateListPage}
  />
  <Route
    path='/portal/admin/form-templates/:formTemplateId'
    component={FormTemplateDetailPage}
  />
</Switch>

Form Component

You can integrate the Form component into your project and build custom logic around handling of form data captured through the UI.

const CustomForm: React.FC = () => {
  // Pass in the form Entity Schema JSON definiition
  const entitySchema = {...};
  // Pass in the form template JSON definition
  const formStateNode = {...};
  return (
    <FormProvider
      entitySchema={entitySchema}
      formStateNode={formStateNode}
      onChange={values => {
        /* when form data is entered `values` contains the user data */
      }}
    >
      // Render the form UI
      <Form />
    </FormProvider>
  )
};

TODO: Document Form component configurations (i.e. appendSectionControls, etc.)

Form Hooks

The following are Form related hooks to interface with the @sierralabs/forms-api:

  • useFindFormSchemas - Get a list of form schemas
  • useFindFormSchemaDeltas - Get history of form schema changes
  • useApplyFormSchemaDelta - Apply a change to the form schema
  • useCreateFormTemplate- Create a form template
  • useUpdateFormTemplate - Update a form template
  • useUpdateFormTemplateConfig - Updating a Form Template config
  • usePublishFormTemplate - Publish a form template version
  • useFindFormTemplates - Get a list of form templates
  • useFindFormTemplate - Get a single form template and its config
  • useGetFormTemplateVersions - Get all published versions for a form template

Development & Contributing

For fast development leveraging React's fast refresh capabilities you can develop using the forms-ui-example project located in the "examples" folder.

# Start the @sierralabs/forms-ui in watch mode
forms-ui $ yarn start

# Start the forms example project
forms-ui-example $ yarn start

# Now all changes in @sierralabs/forms-ui will get automatically compiled and leverage React's fast browser refresh capabilities.

Development from an outside project

To develop and contribute to the @sierralabs/forms-ui project from another project that has a dependency on this module you can use Yalc. Yalc works better then yarn/npm link due to node_module dependency issues with symlinking that impact modules like react.

# Install yalc if you don't already have it installed
$ npm install -g yalc

# Publish `@sierralabs/forms-ui` into your local yalc repo
$ yalc publish

# On the project that is using `@sierralabs/forms-api` run
dependent-project $ yalc link @sierralabs/forms-api

# Now back on the `@sierralabs/forms-ui` folder you can make code changes and push changes to the linked projects by
$ yalc push

# Lastly, to undo the yalc link reference, you'll need to force the package install on the dependent project
dependent-project $ yarn install --force
1.1.46

4 months ago

1.1.45

6 months ago

1.2.31

6 months ago

1.1.44

6 months ago

1.1.43

7 months ago

1.2.30

7 months ago

1.2.29

8 months ago

1.1.42

8 months ago

1.2.28

8 months ago

1.2.27

8 months ago

1.1.41

8 months ago

1.2.26

9 months ago

1.1.40

9 months ago

1.1.38

12 months ago

1.1.37

1 year ago

1.1.36

1 year ago

1.1.35

1 year ago

1.1.39

10 months ago

1.2.24

1 year ago

1.2.25

12 months ago

1.1.34

1 year ago

1.1.33

1 year ago

1.1.32

1 year ago

1.2.23

1 year ago

1.1.31

1 year ago

1.2.22

1 year ago

1.1.30

1 year ago

1.1.29

1 year ago

1.1.28

1 year ago

1.2.21

1 year ago

1.1.27

1 year ago

1.1.26

2 years ago

1.1.25

2 years ago

1.1.24

2 years ago

1.1.23

2 years ago

1.1.22

2 years ago

1.2.20

2 years ago

1.1.21

2 years ago

1.1.20

2 years ago

1.1.19

2 years ago

1.1.18

2 years ago

1.2.19

2 years ago

1.1.17

2 years ago

1.1.16

2 years ago

1.2.18

2 years ago

1.1.15

2 years ago

1.2.17

2 years ago

1.1.14

2 years ago

1.1.13

2 years ago

1.2.16

2 years ago

1.2.15

2 years ago

1.2.14

2 years ago

1.1.12

2 years ago

1.2.13

2 years ago

1.2.12

2 years ago

1.2.11

2 years ago

0.2.5

2 years ago

1.2.10

2 years ago

1.1.11

2 years ago

1.2.9

2 years ago

1.2.8

2 years ago

1.1.10

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.2.4

2 years ago

1.1.5

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.10

3 years ago

0.3.9

3 years ago

0.3.8

3 years ago

0.3.7

3 years ago

0.3.6

3 years ago

0.3.5

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.3.0

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.1.12

3 years ago

0.1.11

3 years ago

0.1.9

3 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago