mithril-materialized 0.19.4 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/option.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Vnode, FactoryComponent, Attributes } from 'mithril';
1
+ import m, { Vnode, FactoryComponent, Attributes, Component } from 'mithril';
2
2
  export interface IInputCheckbox extends Attributes {
3
3
  /** Optional event handler when a checkbox is clicked */
4
4
  onchange?: (checked: boolean) => void;
@@ -11,30 +11,32 @@ export interface IInputCheckbox extends Attributes {
11
11
  }
12
12
  /** Component to show a check box */
13
13
  export declare const InputCheckbox: FactoryComponent<IInputCheckbox>;
14
- export interface IInputOption {
14
+ export interface IInputOption<T extends string | number> {
15
15
  /** Option ID */
16
- id: string | number;
17
- /** Title or label */
16
+ id: T;
17
+ /** Displayed label */
18
18
  label: string;
19
+ /** Optional title, often used to display a tooltip - will only work when choosing browser-defaults */
20
+ title?: string;
19
21
  /** Is the option disabled? */
20
22
  disabled?: boolean;
21
23
  }
22
- export interface IOptions extends Attributes {
24
+ export interface IOptions<T extends string | number> extends Attributes {
23
25
  /** Element ID */
24
26
  id?: string;
25
27
  /** Optional title or label */
26
28
  label?: string;
27
29
  /** The options that you have */
28
- options: IInputOption[];
30
+ options: IInputOption<T>[];
29
31
  /** Event handler that is called when an option is changed */
30
- onchange?: (checkedId: Array<string | number>) => void;
32
+ onchange?: (checkedId: T[]) => void;
31
33
  /**
32
34
  * Selected id or ids (in case of multiple options)
33
35
  * @deprecated Please use initialValue instead
34
36
  */
35
- checkedId?: string | number | Array<string | number>;
37
+ checkedId?: T | T[];
36
38
  /** Selected id or ids (in case of multiple options) */
37
- initialValue?: string | number | Array<string | number>;
39
+ initialValue?: T | T[];
38
40
  /** Optional description */
39
41
  description?: string;
40
42
  /** Optional CSS that is added to the input checkbox, e.g. if you add col s4, the items will be put inline */
@@ -47,4 +49,4 @@ export interface IOptions extends Attributes {
47
49
  disabled?: boolean;
48
50
  }
49
51
  /** A list of checkboxes */
50
- export declare const Options: FactoryComponent<IOptions>;
52
+ export declare const Options: <T extends string | number>() => m.Component<IOptions<T>, {}>;
package/dist/pickers.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  /// <reference types="materialize-css" />
2
+ /// <reference types="materialize-css" />
2
3
  import { FactoryComponent } from 'mithril';
3
4
  import { IInputOptions } from './input-options';
4
5
  /** Component to pick a date */
package/dist/radio.d.ts CHANGED
@@ -1,18 +1,18 @@
1
- import { FactoryComponent, Attributes } from 'mithril';
1
+ import m, { Attributes, Component } from 'mithril';
2
2
  import { IInputOption } from './option';
3
- export interface IRadioButtons extends Attributes {
3
+ export interface IRadioButtons<T extends string | number> extends Attributes {
4
4
  /** Element ID */
5
5
  id?: string;
6
6
  /** Optional title or label */
7
7
  label?: string;
8
8
  /** The options that you have */
9
- options: IInputOption[];
9
+ options: IInputOption<T>[];
10
10
  /** Event handler that is called when an option is changed */
11
- onchange: (id: string | number) => void;
11
+ onchange: (id: T) => void;
12
12
  /** Selected id (in oninit lifecycle) */
13
- initialValue?: string | number;
13
+ initialValue?: T;
14
14
  /** Selected id (in oninit and onupdate lifecycle) */
15
- checkedId?: string | number;
15
+ checkedId?: T;
16
16
  /** Optional description */
17
17
  description?: string;
18
18
  /** If true, start on a new row */
@@ -24,14 +24,14 @@ export interface IRadioButtons extends Attributes {
24
24
  /** Disable the button */
25
25
  disabled?: boolean;
26
26
  }
27
- /** Component to show a list of radio buttons, from which you can choose one. */
28
- export declare const RadioButtons: FactoryComponent<IRadioButtons>;
29
- export interface IRadioButton extends Attributes {
30
- id: string | number;
27
+ export interface IRadioButton<T extends string | number> extends Attributes {
28
+ id: T;
31
29
  checked?: boolean;
32
- onchange: (id: string | number) => void;
30
+ onchange: (id: T) => void;
33
31
  label: string;
34
32
  groupId: string;
35
33
  disabled?: boolean;
36
34
  }
37
- export declare const RadioButton: FactoryComponent<IRadioButton>;
35
+ export declare const RadioButton: <T extends string | number>() => m.Component<IRadioButton<T>, {}>;
36
+ /** Component to show a list of radio buttons, from which you can choose one. */
37
+ export declare const RadioButtons: <T extends string | number>() => m.Component<IRadioButtons<T>, {}>;
package/dist/select.d.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  /// <reference types="materialize-css" />
2
- import { FactoryComponent, Attributes } from 'mithril';
2
+ import m, { Attributes, Component } from 'mithril';
3
3
  import { IInputOption } from './option';
4
- export interface ISelectOptions extends Attributes, Partial<M.FormSelectOptions> {
4
+ export interface ISelectOptions<T extends string | number> extends Attributes, Partial<M.FormSelectOptions> {
5
5
  /** Options to select from */
6
- options: IInputOption[];
6
+ options: IInputOption<T>[];
7
7
  /** Called when the value is changed, either contains a single or all selected (checked) ids */
8
- onchange: (checkedIds: Array<string | number>) => void;
8
+ onchange: (checkedIds: T[]) => void;
9
9
  /**
10
10
  * Selected id or ids (in case of multiple options). Processed in the oninit and onupdate lifecycle.
11
11
  * When the checkedId property changes (using a shallow compare), the selections are updated accordingly.
12
12
  */
13
- checkedId?: string | number | Array<string | number>;
13
+ checkedId?: T | T[];
14
14
  /** Selected id or ids (in case of multiple options). Only processed in the oninit lifecycle. */
15
- initialValue?: string | number | Array<string | number>;
15
+ initialValue?: T | T[];
16
16
  /** Select a single option or multiple options */
17
17
  multiple?: boolean;
18
18
  /** Optional label. */
@@ -42,4 +42,4 @@ export interface ISelectOptions extends Attributes, Partial<M.FormSelectOptions>
42
42
  required?: boolean;
43
43
  }
44
44
  /** Component to select from a list of values in a dropdowns */
45
- export declare const Select: FactoryComponent<ISelectOptions>;
45
+ export declare const Select: <T extends string | number>() => m.Component<ISelectOptions<T>, {}>;
package/package.json CHANGED
@@ -1,50 +1,50 @@
1
- {
2
- "name": "mithril-materialized",
3
- "version": "0.19.4",
4
- "description": "A materialize library for mithril.",
5
- "main": "dist/index.js",
6
- "module": "dist/index.esm.js",
7
- "exports": {
8
- ".": "./dist/index.modern.js",
9
- "./index.css": "./dist/index.css"
10
- },
11
- "unpkg": "dist/index.umd.js",
12
- "types": "dist/index.d.ts",
13
- "scripts": {
14
- "build": "microbundle ./src/index.ts",
15
- "dev": "microbundle watch ./src/index.ts",
16
- "start": "npm run dev",
17
- "clean": "rimraf dist node_modules/.cache",
18
- "link:old": "pnpm link",
19
- "typedoc": "typedoc --out ../../docs/typedoc src",
20
- "build:domain": "npm run clean && npm run build && typedoc --out ../../docs/typedoc src",
21
- "dry-run": "npm publish --dry-run",
22
- "patch-release": "npm run clean && npm run build && npm version patch --force -m \"Patch release\" && npm publish && git push --follow-tags",
23
- "minor-release": "npm run clean && npm run build && npm version minor --force -m \"Minor release\" && npm publish && git push --follow-tags",
24
- "major-release": "npm run clean && npm run build && npm version major --force -m \"Major release\" && npm publish && git push --follow-tags"
25
- },
26
- "repository": {
27
- "type": "git",
28
- "url": "git://github.com/erikvullings/mithril-materialized.git"
29
- },
30
- "keywords": [
31
- "mithril",
32
- "materialize-css"
33
- ],
34
- "author": "Erik Vullings <erik.vullings@gmail.com> (http://www.tno.nl)",
35
- "license": "MIT",
36
- "devDependencies": {
37
- "@types/materialize-css": "^1.0.11",
38
- "@types/mithril": "^2.0.8",
39
- "js-yaml": "^4.1.0",
40
- "microbundle": "^0.14.1",
41
- "rimraf": "^3.0.2",
42
- "tslib": "^2.3.1",
43
- "typedoc": "^0.22.6",
44
- "typescript": "^4.4.4"
45
- },
46
- "dependencies": {
47
- "materialize-css": "^1.0.0",
48
- "mithril": "^2.0.4"
49
- }
50
- }
1
+ {
2
+ "name": "mithril-materialized",
3
+ "version": "1.0.0",
4
+ "description": "A materialize library for mithril.",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.esm.js",
7
+ "exports": {
8
+ ".": "./dist/index.modern.js",
9
+ "./index.css": "./dist/index.css"
10
+ },
11
+ "unpkg": "dist/index.umd.js",
12
+ "types": "dist/index.d.ts",
13
+ "scripts": {
14
+ "build": "microbundle ./src/index.ts",
15
+ "dev": "microbundle watch ./src/index.ts",
16
+ "start": "npm run dev",
17
+ "clean": "rimraf dist node_modules/.cache",
18
+ "link:old": "pnpm link",
19
+ "typedoc": "typedoc --out ../../docs/typedoc src",
20
+ "build:domain": "npm run clean && npm run build && typedoc --out ../../docs/typedoc src",
21
+ "dry-run": "npm publish --dry-run",
22
+ "patch-release": "npm run clean && npm run build && npm version patch --force -m \"Patch release\" && npm publish && git push --follow-tags",
23
+ "minor-release": "npm run clean && npm run build && npm version minor --force -m \"Minor release\" && npm publish && git push --follow-tags",
24
+ "major-release": "npm run clean && npm run build && npm version major --force -m \"Major release\" && npm publish && git push --follow-tags"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git://github.com/erikvullings/mithril-materialized.git"
29
+ },
30
+ "keywords": [
31
+ "mithril",
32
+ "materialize-css"
33
+ ],
34
+ "author": "Erik Vullings <erik.vullings@gmail.com> (http://www.tno.nl)",
35
+ "license": "MIT",
36
+ "dependencies": {
37
+ "mithril": "^2.2.2",
38
+ "materialize-css": "^1.0.0"
39
+ },
40
+ "devDependencies": {
41
+ "@types/materialize-css": "^1.0.11",
42
+ "@types/mithril": "^2.0.11",
43
+ "js-yaml": "^4.1.0",
44
+ "microbundle": "^0.15.0",
45
+ "rimraf": "^3.0.2",
46
+ "tslib": "^2.4.0",
47
+ "typedoc": "^0.22.18",
48
+ "typescript": "^4.7.4"
49
+ }
50
+ }
package/dist/kanban.d.ts DELETED
@@ -1,47 +0,0 @@
1
- import m, { Component, Attributes } from 'mithril';
2
- import { IModelField, IConvertibleType } from './layout-form-generator';
3
- import './styles/kanban.css';
4
- export interface IKanbanI18n {
5
- newItem: string;
6
- modalDeleteItem: string;
7
- modalCreateNewItem: string;
8
- modalEditNewItem: string;
9
- }
10
- export interface IKanban<T> extends Attributes {
11
- /**
12
- * Label for creating a new item
13
- * @deprecated Use i18n instead
14
- */
15
- label?: string;
16
- /** Label for creating a new item */
17
- i18n?: IKanbanI18n;
18
- /** The model representing the item's fields */
19
- model: IModelField[];
20
- /** The items that we want to show */
21
- items?: T[];
22
- /** Notify of changes */
23
- onchange?: (items: T[]) => void;
24
- /** If true, use a modal for editing with a fixed footer */
25
- fixedFooter?: boolean;
26
- /** Can we create and edit new items: default true */
27
- canEdit?: boolean;
28
- /** Can we sort items: default true */
29
- canSort?: boolean;
30
- /** Can we drag items - in this case, sorting is disabled: default false */
31
- canDrag?: boolean;
32
- /**
33
- * Can we move items between lists (based on the same model): default false.
34
- * Must be enabled on both lists in order to work.
35
- */
36
- moveBetweenList?: boolean;
37
- /** Sort direction */
38
- sortDirection?: 'asc' | 'desc';
39
- /** Properties to sort */
40
- sortProperties?: string[];
41
- /** Property IDs which can always be edited, e.g. also in the list view */
42
- editableIds?: string[];
43
- /** If true, disable the item */
44
- disabled?: boolean;
45
- }
46
- /** A flexible list of items, supporting drag-n-drop */
47
- export declare const Kanban: <T extends IConvertibleType>() => m.Component<Partial<IKanban<T>>, {}>;
@@ -1,74 +0,0 @@
1
- /// <reference types="materialize-css" />
2
- import 'tslib';
3
- import m, { Component } from 'mithril';
4
- import { IInputOption } from './option';
5
- /** List of components that can be used for generating a form */
6
- export declare type ComponentType = 'text' | 'number' | 'url' | 'email' | 'date' | 'time' | 'checkbox' | 'select' | 'options' | 'radios';
7
- /** Generic description of a form field, based on a union of the individual component options */
8
- export interface IModelField {
9
- /** Name of the property in the generated object */
10
- id: string;
11
- /** Type of component to use for rendering the field. If empty, field will not be rendered. */
12
- component?: ComponentType;
13
- /** Label to display */
14
- label?: string;
15
- /** Optional class to append to the field */
16
- className?: string;
17
- /** Optional icon to display on the element, based on the materializecss.com/icons */
18
- iconName?: string;
19
- /** Optional class for the icon, e.g. to make it smaller or bigger */
20
- iconClass?: string;
21
- /** For text, may it have multiple lines */
22
- multiline?: boolean;
23
- /** If true, the item is required */
24
- required?: boolean;
25
- /** If true, the item is disabled */
26
- disabled?: boolean;
27
- /** Optional placeholder */
28
- placeholder?: string;
29
- /** Optional helper text */
30
- helperText?: string;
31
- /** Start a new row after this field */
32
- newRow?: boolean;
33
- /** Options for radios, options (checkboxes), and selections */
34
- options?: IInputOption[];
35
- /** If true, draw the radio buttons inline */
36
- inline?: boolean;
37
- /**
38
- * If specified, generate a value automatically, e.g. to set an ID, or to use a GUID.
39
- * Possible options are `guid` to generate a GUID, or 'id' to generate an `idXXXX`.
40
- */
41
- autogenerate?: 'guid' | 'id';
42
- }
43
- /** A data object that can be created */
44
- export interface IConvertibleType {
45
- id: string | number;
46
- [key: string]: undefined | string | number | boolean | Date | Array<string | number>;
47
- }
48
- /**
49
- * Convert a model field to a component.
50
- *
51
- * @param model Model properties
52
- * @param value Initial value of the property item
53
- * @param options Component options
54
- */
55
- export declare const fieldToComponent: ({ component, required: isMandatory, options: selectOptions, autogenerate, ...props }: IModelField, value?: string | number | boolean | Date | (string | number)[] | undefined, options?: {
56
- onchange?: ((v: string | number | boolean | Date | Array<string | number>, overwrite?: boolean | undefined) => void) | undefined;
57
- containerId?: string | undefined;
58
- autofocus?: boolean | undefined;
59
- disabled?: boolean | undefined;
60
- multiline?: boolean | undefined;
61
- key?: string | number | undefined;
62
- }) => m.Vnode<import("./input-options").IInputOptions<string>, unknown> | m.Vnode<import("./input-options").IInputOptions<number>, unknown> | m.Vnode<import("./option").IInputCheckbox, unknown> | m.Vnode<import("./select").ISelectOptions, unknown> | m.Vnode<import("./option").IOptions, unknown> | m.Vnode<import("./radio").IRadioButtons, unknown> | m.Vnode<import("./input-options").IInputOptions<Date> & Partial<M.DatepickerOptions>, unknown> | m.Vnode<import("./input-options").IInputOptions<string> & Partial<M.TimepickerOptions>, unknown> | undefined;
63
- /**
64
- * Generate a new group or form based on an object's model description, where a model consists of multiple fields.
65
- */
66
- export declare const LayoutForm: <T extends IConvertibleType>() => m.Component<{
67
- el?: string | undefined;
68
- model: IModelField[];
69
- item: T;
70
- containerId?: string | undefined;
71
- disabled?: boolean | undefined;
72
- editableIds?: (keyof T)[] | undefined;
73
- onchange?: ((valid: boolean) => void) | undefined;
74
- }, {}>;