0.6.2 • Published 7 months ago

mithril-ui-form-plugin v0.6.2

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Type definitions for a Mithril-ui-form plugin

Mithril-ui-form is a declarative framwork to create forms using the front-end Mithril framework and mithril-materialized components using the materialize-css design theme.

There were two main reasons to convert the existing mithril-ui-form to a framework supporting plugins:

  • The Leaflet map component was included by default, and you needed to import them even when not using a map. Recent versions (v1.0.0+) have removed support for the leaflet map component, so you need to include it manually yourself
import { leafletPlugin } from 'mithril-ui-form-leaflet-plugin';

...

registerPlugin('map', leafletPlugin);
  • You could not add your own types, e.g. to create a questionnaire, I needed a (no-star-based) rating component, and that was not easy to integrate into a form. Now, you can just register it yourself.
registerPlugin('rating', myRatingPlugin, myReadonlyRatingPlugin);

Since each plugin is a Mithril FactoryComponent, i.e. a function that returns a Component object with a view method, it is very easy to roll your own.

import { FactoryComponent } from 'mithril';

export type PluginType = FactoryComponent<{
  /** Initial value, typically a string, number or boolean */
  iv: any;
  /** Original properties of the form field */
  field: Record<string, any>;
  /** Partially converted properties, e.g. the ones containing placeholders for other variables, e.g. label, description, etc. */
  props: Record<string, any>;
  /** Label, raw version of props.label */
  label?: string;
  /** Only present when component is not readonly */
  onchange?: (value: string | number | Array<string | number | Record<string, any>> | Date | boolean) => Promise<void>;
}>;
0.6.2

7 months ago

0.5.2-next.0

11 months ago

0.6.1

10 months ago

0.6.0

10 months ago

0.5.0

2 years ago

0.5.1

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.9

2 years ago

0.3.11

2 years ago

0.3.10

2 years ago

0.3.8

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.7

2 years ago

0.3.4

2 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.3

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago