tweak-ui 0.4.3 → 0.5.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/LICENSE +7 -7
- package/README.md +32 -32
- package/dist/lib/builder.d.ts +166 -162
- package/dist/lib/builder.d.ts.map +1 -1
- package/dist/lib/builder.js +250 -0
- package/dist/lib/builder.js.map +1 -0
- package/dist/lib/color-formats/array-format.d.ts +8 -8
- package/dist/lib/color-formats/array-format.js +18 -0
- package/dist/lib/color-formats/array-format.js.map +1 -0
- package/dist/lib/color-formats/converter.d.ts +18 -18
- package/dist/lib/color-formats/converter.js +85 -0
- package/dist/lib/color-formats/converter.js.map +1 -0
- package/dist/lib/color-formats/css-string-format.d.ts +7 -7
- package/dist/lib/color-formats/css-string-format.js +28 -0
- package/dist/lib/color-formats/css-string-format.js.map +1 -0
- package/dist/lib/color-formats/formatter.d.ts +8 -8
- package/dist/lib/color-formats/formatter.js +35 -0
- package/dist/lib/color-formats/formatter.js.map +1 -0
- package/dist/lib/color-formats/hex-string-format.d.ts +7 -7
- package/dist/lib/color-formats/hex-string-format.js +28 -0
- package/dist/lib/color-formats/hex-string-format.js.map +1 -0
- package/dist/lib/color-formats/index.d.ts +3 -3
- package/dist/lib/color-formats/index.js +4 -0
- package/dist/lib/color-formats/index.js.map +1 -0
- package/dist/lib/color-formats/number-format.d.ts +8 -8
- package/dist/lib/color-formats/number-format.js +23 -0
- package/dist/lib/color-formats/number-format.js.map +1 -0
- package/dist/lib/color-formats/object-format.d.ts +14 -14
- package/dist/lib/color-formats/object-format.js +23 -0
- package/dist/lib/color-formats/object-format.js.map +1 -0
- package/dist/lib/color-formats/types.d.ts +101 -101
- package/dist/lib/color-formats/types.js +2 -0
- package/dist/lib/color-formats/types.js.map +1 -0
- package/dist/lib/components/button.d.ts +28 -28
- package/dist/lib/components/button.d.ts.map +1 -1
- package/dist/lib/components/button.js +15 -0
- package/dist/lib/components/button.js.map +1 -0
- package/dist/lib/components/content.d.ts +21 -21
- package/dist/lib/components/content.d.ts.map +1 -1
- package/dist/lib/components/content.js +10 -0
- package/dist/lib/components/content.js.map +1 -0
- package/dist/lib/components/controls/angle.d.ts +51 -51
- package/dist/lib/components/controls/angle.d.ts.map +1 -1
- package/dist/lib/components/controls/angle.js +201 -0
- package/dist/lib/components/controls/angle.js.map +1 -0
- package/dist/lib/components/controls/checkbox.d.ts +28 -28
- package/dist/lib/components/controls/checkbox.d.ts.map +1 -1
- package/dist/lib/components/controls/checkbox.js +31 -0
- package/dist/lib/components/controls/checkbox.js.map +1 -0
- package/dist/lib/components/controls/color-picker.d.ts +56 -56
- package/dist/lib/components/controls/color-picker.d.ts.map +1 -1
- package/dist/lib/components/controls/color-picker.js +267 -0
- package/dist/lib/components/controls/color-picker.js.map +1 -0
- package/dist/lib/components/controls/color.d.ts +51 -51
- package/dist/lib/components/controls/color.d.ts.map +1 -1
- package/dist/lib/components/controls/color.js +77 -0
- package/dist/lib/components/controls/color.js.map +1 -0
- package/dist/lib/components/controls/index.d.ts +10 -10
- package/dist/lib/components/controls/index.js +11 -0
- package/dist/lib/components/controls/index.js.map +1 -0
- package/dist/lib/components/controls/number.d.ts +47 -47
- package/dist/lib/components/controls/number.d.ts.map +1 -1
- package/dist/lib/components/controls/number.js +142 -0
- package/dist/lib/components/controls/number.js.map +1 -0
- package/dist/lib/components/controls/point.d.ts +47 -47
- package/dist/lib/components/controls/point.d.ts.map +1 -1
- package/dist/lib/components/controls/point.js +137 -0
- package/dist/lib/components/controls/point.js.map +1 -0
- package/dist/lib/components/controls/position.d.ts +55 -55
- package/dist/lib/components/controls/position.d.ts.map +1 -1
- package/dist/lib/components/controls/position.js +36 -0
- package/dist/lib/components/controls/position.js.map +1 -0
- package/dist/lib/components/controls/select.d.ts +59 -59
- package/dist/lib/components/controls/select.d.ts.map +1 -1
- package/dist/lib/components/controls/select.js +132 -0
- package/dist/lib/components/controls/select.js.map +1 -0
- package/dist/lib/components/controls/spherical.d.ts +74 -74
- package/dist/lib/components/controls/spherical.d.ts.map +1 -1
- package/dist/lib/components/controls/spherical.js +302 -0
- package/dist/lib/components/controls/spherical.js.map +1 -0
- package/dist/lib/components/controls/text.d.ts +35 -35
- package/dist/lib/components/controls/text.d.ts.map +1 -1
- package/dist/lib/components/controls/text.js +24 -0
- package/dist/lib/components/controls/text.js.map +1 -0
- package/dist/lib/components/groups/accordion.d.ts +21 -21
- package/dist/lib/components/groups/accordion.d.ts.map +1 -1
- package/dist/lib/components/groups/accordion.js +34 -0
- package/dist/lib/components/groups/accordion.js.map +1 -0
- package/dist/lib/components/groups/container.d.ts +24 -24
- package/dist/lib/components/groups/container.d.ts.map +1 -1
- package/dist/lib/components/groups/container.js +19 -0
- package/dist/lib/components/groups/container.js.map +1 -0
- package/dist/lib/components/groups/group.d.ts +48 -48
- package/dist/lib/components/groups/group.d.ts.map +1 -1
- package/dist/lib/components/groups/group.js +50 -0
- package/dist/lib/components/groups/group.js.map +1 -0
- package/dist/lib/components/groups/index.d.ts +4 -4
- package/dist/lib/components/groups/index.js +5 -0
- package/dist/lib/components/groups/index.js.map +1 -0
- package/dist/lib/components/groups/tabs.d.ts +21 -21
- package/dist/lib/components/groups/tabs.d.ts.map +1 -1
- package/dist/lib/components/groups/tabs.js +31 -0
- package/dist/lib/components/groups/tabs.js.map +1 -0
- package/dist/lib/components/image.d.ts +36 -36
- package/dist/lib/components/image.d.ts.map +1 -1
- package/dist/lib/components/image.js +46 -0
- package/dist/lib/components/image.js.map +1 -0
- package/dist/lib/components/index.d.ts +5 -5
- package/dist/lib/components/index.js +6 -0
- package/dist/lib/components/index.js.map +1 -0
- package/dist/lib/core/index.d.ts +4 -4
- package/dist/lib/core/index.js +5 -0
- package/dist/lib/core/index.js.map +1 -0
- package/dist/lib/core/registry.d.ts +17 -17
- package/dist/lib/core/registry.js +30 -0
- package/dist/lib/core/registry.js.map +1 -0
- package/dist/lib/core/render.d.ts +9 -9
- package/dist/lib/core/render.d.ts.map +1 -1
- package/dist/lib/core/render.js +19 -0
- package/dist/lib/core/render.js.map +1 -0
- package/dist/lib/core/types.d.ts +87 -87
- package/dist/lib/core/types.d.ts.map +1 -1
- package/dist/lib/core/types.js +2 -0
- package/dist/lib/core/types.js.map +1 -0
- package/dist/lib/core/utils.d.ts +93 -93
- package/dist/lib/core/utils.d.ts.map +1 -1
- package/dist/lib/core/utils.js +193 -0
- package/dist/lib/core/utils.js.map +1 -0
- package/dist/lib/core/value-accessor.d.ts +17 -17
- package/dist/lib/core/value-accessor.js +52 -0
- package/dist/lib/core/value-accessor.js.map +1 -0
- package/dist/lib/index.d.ts +21 -27
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +29 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/mount.d.ts +45 -45
- package/dist/lib/mount.js +85 -0
- package/dist/lib/mount.js.map +1 -0
- package/dist/tweak-ui.css +133 -138
- package/dist/tweak-ui.css.map +1 -1
- package/dist/tweak-ui.min.css +1 -1
- package/dist/tweak-ui.min.css.map +1 -1
- package/dist/tweak-ui.module.js +2733 -2396
- package/dist/tweak-ui.module.js.map +1 -1
- package/dist/tweak-ui.umd.js +1 -4419
- package/dist/tweak-ui.umd.js.map +1 -1
- package/package.json +25 -42
- package/dist/index.html +0 -1063
- package/dist/lib/color-formats/array-format.spec.d.ts +0 -2
- package/dist/lib/color-formats/array-format.spec.d.ts.map +0 -1
- package/dist/lib/color-formats/converter.spec.d.ts +0 -2
- package/dist/lib/color-formats/converter.spec.d.ts.map +0 -1
- package/dist/lib/color-formats/css-string-format.spec.d.ts +0 -2
- package/dist/lib/color-formats/css-string-format.spec.d.ts.map +0 -1
- package/dist/lib/color-formats/formatter.spec.d.ts +0 -2
- package/dist/lib/color-formats/formatter.spec.d.ts.map +0 -1
- package/dist/lib/color-formats/hex-string-format.spec.d.ts +0 -2
- package/dist/lib/color-formats/hex-string-format.spec.d.ts.map +0 -1
- package/dist/lib/color-formats/number-format.spec.d.ts +0 -2
- package/dist/lib/color-formats/number-format.spec.d.ts.map +0 -1
- package/dist/lib/color-formats/object-format.spec.d.ts +0 -2
- package/dist/lib/color-formats/object-format.spec.d.ts.map +0 -1
- package/dist/scss/_style.scss +0 -120
- package/dist/scss/_themes.scss +0 -23
- package/dist/scss/_utils.scss +0 -24
- package/dist/scss/_variables.scss +0 -30
- package/dist/scss/controls/_angle.scss +0 -64
- package/dist/scss/controls/_button.scss +0 -0
- package/dist/scss/controls/_checkbox.scss +0 -19
- package/dist/scss/controls/_color-picker.scss +0 -124
- package/dist/scss/controls/_color.scss +0 -14
- package/dist/scss/controls/_container.scss +0 -13
- package/dist/scss/controls/_group.scss +0 -69
- package/dist/scss/controls/_image.scss +0 -27
- package/dist/scss/controls/_number.scss +0 -38
- package/dist/scss/controls/_point.scss +0 -36
- package/dist/scss/controls/_position.scss +0 -9
- package/dist/scss/controls/_select.scss +0 -0
- package/dist/scss/controls/_spherical.scss +0 -87
- package/dist/scss/controls/_tabs.scss +0 -38
- package/dist/scss/controls/_text.scss +0 -0
- package/dist/scss/index.scss +0 -21
- package/dist/tweak-ui.umd.min.js +0 -17
- package/dist/tweak-ui.umd.min.js.map +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets a value of a view model
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
* @param model - The model of a component
|
|
6
|
+
*/
|
|
7
|
+
export function getValue(model) {
|
|
8
|
+
return decode(model, readValue(model));
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Sets a value on a view model
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
* @param model - The model of a component
|
|
15
|
+
* @param value - The value for the component
|
|
16
|
+
* @returns the encoded value as it was written to the model
|
|
17
|
+
*/
|
|
18
|
+
export function setValue(model, value) {
|
|
19
|
+
const encoded = encode(model, value);
|
|
20
|
+
writeValue(model, encoded);
|
|
21
|
+
return encoded;
|
|
22
|
+
}
|
|
23
|
+
function readValue(model) {
|
|
24
|
+
if ('target' in model &&
|
|
25
|
+
model.target &&
|
|
26
|
+
model.property != null &&
|
|
27
|
+
model.property in model.target) {
|
|
28
|
+
return model.target[model.property];
|
|
29
|
+
}
|
|
30
|
+
if ('value' in model) {
|
|
31
|
+
return model.value;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function writeValue(model, value) {
|
|
35
|
+
if ('target' in model && model.target && model.property != null) {
|
|
36
|
+
model.target[model.property] = value;
|
|
37
|
+
}
|
|
38
|
+
else if (isWriteable(model, 'value')) {
|
|
39
|
+
model.value = value;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function isWriteable(obj, key) {
|
|
43
|
+
const desc = Object.getOwnPropertyDescriptor(obj, key);
|
|
44
|
+
return !desc || !!desc.writable || !!desc.set;
|
|
45
|
+
}
|
|
46
|
+
function encode(source, value) {
|
|
47
|
+
return 'codec' in source && source.codec ? source.codec.encode(value) : value;
|
|
48
|
+
}
|
|
49
|
+
function decode(source, value) {
|
|
50
|
+
return 'codec' in source && source.codec ? source.codec.decode(value) : value;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=value-accessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-accessor.js","sourceRoot":"","sources":["../../../src/lib/core/value-accessor.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAI,KAA0B;IACpD,OAAO,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,CAAM,CAAA;AAC7C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAI,KAA0B,EAAE,KAAQ;IAC9D,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IACpC,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IAC1B,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAS,SAAS,CAAC,KAA4B;IAC7C,IACE,QA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,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;AAC/E,CAAC","sourcesContent":["import type { ValueSource } from './types'\r\nimport { call } from './utils'\r\n\r\n/**\r\n * Gets a value of a view model\r\n *\r\n * @public\r\n * @param model - The model of a component\r\n */\r\nexport function getValue<V>(model: ValueSource<any, V>): V {\r\n return decode(model, readValue(model)) as V\r\n}\r\n\r\n/**\r\n * Sets a value on a view model\r\n *\r\n * @public\r\n * @param model - The model of a component\r\n * @param value - The value for the component\r\n * @returns the encoded value as it was written to the model\r\n */\r\nexport function setValue<V>(model: ValueSource<any, V>, value: V): unknown {\r\n const encoded = encode(model, value)\r\n writeValue(model, encoded)\r\n return encoded\r\n}\r\n\r\nfunction readValue(model: ValueSource<any, any>) {\r\n if (\r\n 'target' in model &&\r\n model.target &&\r\n model.property != null &&\r\n model.property in model.target\r\n ) {\r\n return model.target[model.property]\r\n }\r\n if ('value' in model) {\r\n return model.value\r\n }\r\n}\r\n\r\nfunction writeValue<V>(model: ValueSource<any, V>, value: V): void {\r\n if ('target' in model && model.target && model.property != null) {\r\n model.target[model.property] = value\r\n } else if (isWriteable(model, 'value')) {\r\n model.value = value\r\n }\r\n}\r\n\r\nfunction isWriteable<T>(obj: T, key: keyof T): boolean {\r\n const desc = Object.getOwnPropertyDescriptor(obj, key)\r\n return !desc || !!desc.writable || !!desc.set\r\n}\r\n\r\nfunction encode<V>(source: ValueSource<any, V>, value: V) {\r\n return 'codec' in source && source.codec ? source.codec.encode(value) : value\r\n}\r\nfunction decode<V>(source: ValueSource<any, V>, value: V) {\r\n return 'codec' in source && source.codec ? source.codec.decode(value) : value\r\n}\r\n"]}
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tweak UI is a lightweight js library for building input controls with data binding
|
|
3
|
-
*
|
|
4
|
-
* @remarks
|
|
5
|
-
* The library provides a set of common ui components built with mithriljs. The main objective
|
|
6
|
-
* is to allow a developer to rapidly scaffold input interfaces for manipulating javascript objects
|
|
7
|
-
* at runtime.
|
|
8
|
-
*
|
|
9
|
-
* Similar projects are:
|
|
10
|
-
* {@link https://github.com/dataarts/dat.gui | dat.GUI}
|
|
11
|
-
* {@link https://github.com/automat/controlkit.js | controlkit}
|
|
12
|
-
* {@link https://github.com/colejd/guify | guify}
|
|
13
|
-
*
|
|
14
|
-
* @packageDocumentation
|
|
15
|
-
*/
|
|
16
|
-
import './components';
|
|
17
|
-
export * from './builder';
|
|
18
|
-
export * from './color-formats';
|
|
19
|
-
export * from './components';
|
|
20
|
-
export * from './core';
|
|
21
|
-
export * from './mount';
|
|
22
|
-
/**
|
|
23
|
-
* The version string
|
|
24
|
-
*
|
|
25
|
-
* @public
|
|
26
|
-
*/
|
|
27
|
-
export declare const VERSION: string;
|
|
1
|
+
/**
|
|
2
|
+
* Tweak UI is a lightweight js library for building input controls with data binding
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* The library provides a set of common ui components built with mithriljs. The main objective
|
|
6
|
+
* is to allow a developer to rapidly scaffold input interfaces for manipulating javascript objects
|
|
7
|
+
* at runtime.
|
|
8
|
+
*
|
|
9
|
+
* Similar projects are:
|
|
10
|
+
* {@link https://github.com/dataarts/dat.gui | dat.GUI}
|
|
11
|
+
* {@link https://github.com/automat/controlkit.js | controlkit}
|
|
12
|
+
* {@link https://github.com/colejd/guify | guify}
|
|
13
|
+
*
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
*/
|
|
16
|
+
import './components';
|
|
17
|
+
export * from './builder';
|
|
18
|
+
export * from './color-formats';
|
|
19
|
+
export * from './components';
|
|
20
|
+
export * from './core';
|
|
21
|
+
export * from './mount';
|
|
28
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,cAAc,CAAA;AAErB,cAAc,WAAW,CAAA;AACzB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,cAAc,CAAA;AAErB,cAAc,WAAW,CAAA;AACzB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tweak UI is a lightweight js library for building input controls with data binding
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* The library provides a set of common ui components built with mithriljs. The main objective
|
|
6
|
+
* is to allow a developer to rapidly scaffold input interfaces for manipulating javascript objects
|
|
7
|
+
* at runtime.
|
|
8
|
+
*
|
|
9
|
+
* Similar projects are:
|
|
10
|
+
* {@link https://github.com/dataarts/dat.gui | dat.GUI}
|
|
11
|
+
* {@link https://github.com/automat/controlkit.js | controlkit}
|
|
12
|
+
* {@link https://github.com/colejd/guify | guify}
|
|
13
|
+
*
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
*/
|
|
16
|
+
import './components';
|
|
17
|
+
export * from './builder';
|
|
18
|
+
export * from './color-formats';
|
|
19
|
+
export * from './components';
|
|
20
|
+
export * from './core';
|
|
21
|
+
export * from './mount';
|
|
22
|
+
// declare const VERSION_STRING: string
|
|
23
|
+
// /**
|
|
24
|
+
// * The version string
|
|
25
|
+
// *
|
|
26
|
+
// * @public
|
|
27
|
+
// */
|
|
28
|
+
// export const VERSION = VERSION_STRING
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,cAAc,CAAA;AAErB,cAAc,WAAW,CAAA;AACzB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AAEvB,uCAAuC;AAEvC,MAAM;AACN,wBAAwB;AACxB,KAAK;AACL,aAAa;AACb,MAAM;AACN,wCAAwC","sourcesContent":["/**\n * Tweak UI is a lightweight js library for building input controls with data binding\n *\n * @remarks\n * The library provides a set of common ui components built with mithriljs. The main objective\n * is to allow a developer to rapidly scaffold input interfaces for manipulating javascript objects\n * at runtime.\n *\n * Similar projects are:\n * {@link https://github.com/dataarts/dat.gui | dat.GUI}\n * {@link https://github.com/automat/controlkit.js | controlkit}\n * {@link https://github.com/colejd/guify | guify}\n *\n * @packageDocumentation\n */\n\nimport './components'\n\nexport * from './builder'\nexport * from './color-formats'\nexport * from './components'\nexport * from './core'\nexport * from './mount'\n\n// declare const VERSION_STRING: string\n\n// /**\n// * The version string\n// *\n// * @public\n// */\n// export const VERSION = VERSION_STRING\n"]}
|
package/dist/lib/mount.d.ts
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import type { ComponentModel } from './core/types';
|
|
2
|
-
import { default as m } from 'mithril';
|
|
3
|
-
import { BuilderFn } from './builder';
|
|
4
|
-
/**
|
|
5
|
-
* Mithril's hyperscript function.
|
|
6
|
-
*
|
|
7
|
-
* @public
|
|
8
|
-
* @remarks
|
|
9
|
-
* Useful to create custom components
|
|
10
|
-
*/
|
|
11
|
-
export declare const h: m.Static;
|
|
12
|
-
/**
|
|
13
|
-
* Runs the function through a builder system and returns the created controls
|
|
14
|
-
*
|
|
15
|
-
* @param fn - The builder function
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
export declare function build(fn: BuilderFn): ComponentModel[];
|
|
19
|
-
/**
|
|
20
|
-
* Mounts a ui to the given element
|
|
21
|
-
*
|
|
22
|
-
* @public
|
|
23
|
-
* @param el - The ui host element
|
|
24
|
-
* @param data - The ui definition object
|
|
25
|
-
*/
|
|
26
|
-
export declare function mount<T extends ComponentModel>(el: Element | string, data: T | Array<T> | BuilderFn): void;
|
|
27
|
-
/**
|
|
28
|
-
* Unmounts the ui from given host element
|
|
29
|
-
*
|
|
30
|
-
* @public
|
|
31
|
-
* @param el - The ui host element
|
|
32
|
-
*/
|
|
33
|
-
export declare function unmount(el: Element | string): void;
|
|
34
|
-
/**
|
|
35
|
-
* Redraws the ui
|
|
36
|
-
*
|
|
37
|
-
* @public
|
|
38
|
-
* @remarks
|
|
39
|
-
* When changing the ui description object qui callbacks (e.g. `onInput` or `onChange`)
|
|
40
|
-
* the ui will redraw automatically.
|
|
41
|
-
*
|
|
42
|
-
* However if the ui description object is changed from outside the qui callback
|
|
43
|
-
* then this method must be called in order to update the visual state.
|
|
44
|
-
*/
|
|
45
|
-
export declare function redraw(): void;
|
|
1
|
+
import type { ComponentModel } from './core/types';
|
|
2
|
+
import { default as m } from 'mithril';
|
|
3
|
+
import { BuilderFn } from './builder';
|
|
4
|
+
/**
|
|
5
|
+
* Mithril's hyperscript function.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
* @remarks
|
|
9
|
+
* Useful to create custom components
|
|
10
|
+
*/
|
|
11
|
+
export declare const h: m.Static;
|
|
12
|
+
/**
|
|
13
|
+
* Runs the function through a builder system and returns the created controls
|
|
14
|
+
*
|
|
15
|
+
* @param fn - The builder function
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
export declare function build(fn: BuilderFn): ComponentModel[];
|
|
19
|
+
/**
|
|
20
|
+
* Mounts a ui to the given element
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
* @param el - The ui host element
|
|
24
|
+
* @param data - The ui definition object
|
|
25
|
+
*/
|
|
26
|
+
export declare function mount<T extends ComponentModel>(el: Element | string, data: T | Array<T> | BuilderFn): void;
|
|
27
|
+
/**
|
|
28
|
+
* Unmounts the ui from given host element
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
* @param el - The ui host element
|
|
32
|
+
*/
|
|
33
|
+
export declare function unmount(el: Element | string): void;
|
|
34
|
+
/**
|
|
35
|
+
* Redraws the ui
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
* @remarks
|
|
39
|
+
* When changing the ui description object qui callbacks (e.g. `onInput` or `onChange`)
|
|
40
|
+
* the ui will redraw automatically.
|
|
41
|
+
*
|
|
42
|
+
* However if the ui description object is changed from outside the qui callback
|
|
43
|
+
* then this method must be called in order to update the visual state.
|
|
44
|
+
*/
|
|
45
|
+
export declare function redraw(): void;
|
|
46
46
|
//# sourceMappingURL=mount.d.ts.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { default as m } from 'mithril';
|
|
2
|
+
import { Builder } from './builder';
|
|
3
|
+
import { isFunction } from './core/utils';
|
|
4
|
+
import { renderModel } from './core';
|
|
5
|
+
/**
|
|
6
|
+
* Mithril's hyperscript function.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
* @remarks
|
|
10
|
+
* Useful to create custom components
|
|
11
|
+
*/
|
|
12
|
+
export const h = m;
|
|
13
|
+
/**
|
|
14
|
+
* Runs the function through a builder system and returns the created controls
|
|
15
|
+
*
|
|
16
|
+
* @param fn - The builder function
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
export function build(fn) {
|
|
20
|
+
const builder = new Builder();
|
|
21
|
+
fn(builder);
|
|
22
|
+
return builder.controls;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Mounts a ui to the given element
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
* @param el - The ui host element
|
|
29
|
+
* @param data - The ui definition object
|
|
30
|
+
*/
|
|
31
|
+
export function mount(el, data) {
|
|
32
|
+
el = typeof el === 'string' ? document.querySelector(el) : el;
|
|
33
|
+
el.classList.add('twui-root');
|
|
34
|
+
if (!data) {
|
|
35
|
+
m.mount(el, null);
|
|
36
|
+
}
|
|
37
|
+
else if (Array.isArray(data)) {
|
|
38
|
+
m.mount(el, {
|
|
39
|
+
view: () => renderModel({
|
|
40
|
+
type: 'group',
|
|
41
|
+
children: data,
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else if (isFunction(data)) {
|
|
46
|
+
const builder = new Builder();
|
|
47
|
+
data(builder);
|
|
48
|
+
m.mount(el, {
|
|
49
|
+
view: () => renderModel({
|
|
50
|
+
type: 'group',
|
|
51
|
+
children: builder.controls,
|
|
52
|
+
}),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
m.mount(el, {
|
|
57
|
+
view: () => renderModel(data),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Unmounts the ui from given host element
|
|
63
|
+
*
|
|
64
|
+
* @public
|
|
65
|
+
* @param el - The ui host element
|
|
66
|
+
*/
|
|
67
|
+
export function unmount(el) {
|
|
68
|
+
el = typeof el === 'string' ? document.querySelector(el) : el;
|
|
69
|
+
m.mount(el, null);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Redraws the ui
|
|
73
|
+
*
|
|
74
|
+
* @public
|
|
75
|
+
* @remarks
|
|
76
|
+
* When changing the ui description object qui callbacks (e.g. `onInput` or `onChange`)
|
|
77
|
+
* the ui will redraw automatically.
|
|
78
|
+
*
|
|
79
|
+
* However if the ui description object is changed from outside the qui callback
|
|
80
|
+
* then this method must be called in order to update the visual state.
|
|
81
|
+
*/
|
|
82
|
+
export function redraw() {
|
|
83
|
+
m.redraw();
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=mount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount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O,CAAC,CAAA;QACb,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE;YACV,IAAI,EAAE,GAAG,EAAE,CACT,WAAW,CAAa;gBACtB,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,OAAO,CAAC,QAAQ;aAC3B,CAAC;SACL,CAAC,CAAA;IACJ,CAAC;SAAM,CAAC;QACN,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE;YACV,IAAI,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC;SAC9B,CAAC,CAAA;IACJ,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,EAAoB;IAC1C,EAAE,GAAG,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAC7D,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;AACnB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,MAAM;IACpB,CAAC,CAAC,MAAM,EAAE,CAAA;AACZ,CAAC","sourcesContent":["import type { ComponentModel } from './core/types'\nimport { default as m } from 'mithril'\nimport { Builder, BuilderFn } from './builder'\nimport { isFunction } from './core/utils'\nimport { renderModel } from './core'\nimport { GroupModel } from './components'\n\n/**\n * Mithril's hyperscript function.\n *\n * @public\n * @remarks\n * Useful to create custom components\n */\nexport const h = m\n\n/**\n * Runs the function through a builder system and returns the created controls\n *\n * @param fn - The builder function\n * @returns\n */\nexport function build(fn: BuilderFn) {\n const builder = new Builder()\n fn(builder)\n return builder.controls\n}\n\n/**\n * Mounts a ui to the given element\n *\n * @public\n * @param el - The ui host element\n * @param data - The ui definition object\n */\nexport function mount<T extends ComponentModel>(el: Element | string, data: T | Array<T> | BuilderFn) {\n el = typeof el === 'string' ? document.querySelector(el) : el\n el.classList.add('twui-root')\n if (!data) {\n m.mount(el, null)\n } else if (Array.isArray(data)) {\n m.mount(el, {\n view: () =>\n renderModel<GroupModel>({\n type: 'group',\n children: data,\n }),\n })\n } else if (isFunction(data)) {\n const builder = new Builder()\n data(builder)\n m.mount(el, {\n view: () =>\n renderModel<GroupModel>({\n type: 'group',\n children: builder.controls,\n }),\n })\n } else {\n m.mount(el, {\n view: () => renderModel(data),\n })\n }\n}\n\n/**\n * Unmounts the ui from given host element\n *\n * @public\n * @param el - The ui host element\n */\nexport function unmount(el: Element | string) {\n el = typeof el === 'string' ? document.querySelector(el) : el\n m.mount(el, null)\n}\n\n/**\n * Redraws the ui\n *\n * @public\n * @remarks\n * When changing the ui description object qui callbacks (e.g. `onInput` or `onChange`)\n * the ui will redraw automatically.\n *\n * However if the ui description object is changed from outside the qui callback\n * then this method must be called in order to update the visual state.\n */\nexport function redraw() {\n m.redraw()\n}\n"]}
|