tweak-ui 0.5.0 → 0.8.2
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/.assetsignore +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/lib/builder.d.ts +78 -140
- package/dist/lib/builder.d.ts.map +1 -1
- package/dist/lib/color/adapter.d.ts +7 -0
- package/dist/lib/color/adapter.d.ts.map +1 -0
- package/dist/lib/color/array-format.d.ts +9 -0
- package/dist/lib/color/array-format.d.ts.map +1 -0
- package/dist/lib/color/converter.d.ts.map +1 -0
- package/dist/lib/color/css-string-format.d.ts +8 -0
- package/dist/lib/color/css-string-format.d.ts.map +1 -0
- package/dist/lib/color/formatter.d.ts +9 -0
- package/dist/lib/color/formatter.d.ts.map +1 -0
- package/dist/lib/color/hex-string-format.d.ts +9 -0
- package/dist/lib/color/hex-string-format.d.ts.map +1 -0
- package/dist/lib/color/index.d.ts.map +1 -0
- package/dist/lib/color/number-format.d.ts +9 -0
- package/dist/lib/color/number-format.d.ts.map +1 -0
- package/dist/lib/{color-formats → color}/object-format.d.ts +4 -4
- package/dist/lib/color/object-format.d.ts.map +1 -0
- package/dist/lib/{color-formats → color}/types.d.ts +15 -9
- package/dist/lib/color/types.d.ts.map +1 -0
- package/dist/lib/components/container/bar.d.ts +28 -0
- package/dist/lib/components/container/bar.d.ts.map +1 -0
- package/dist/lib/components/container/dialog.d.ts +14 -0
- package/dist/lib/components/container/dialog.d.ts.map +1 -0
- package/dist/lib/components/container/grid.d.ts +22 -0
- package/dist/lib/components/container/grid.d.ts.map +1 -0
- package/dist/lib/components/container/group.d.ts +55 -0
- package/dist/lib/components/container/group.d.ts.map +1 -0
- package/dist/lib/components/container/index.d.ts +10 -0
- package/dist/lib/components/container/index.d.ts.map +1 -0
- package/dist/lib/components/container/list.d.ts +25 -0
- package/dist/lib/components/container/list.d.ts.map +1 -0
- package/dist/lib/components/container/section.d.ts +28 -0
- package/dist/lib/components/container/section.d.ts.map +1 -0
- package/dist/lib/components/container/split.d.ts +40 -0
- package/dist/lib/components/container/split.d.ts.map +1 -0
- package/dist/lib/components/container/tabs.d.ts +23 -0
- package/dist/lib/components/container/tabs.d.ts.map +1 -0
- package/dist/lib/components/container/tree.d.ts +25 -0
- package/dist/lib/components/container/tree.d.ts.map +1 -0
- package/dist/lib/components/controls/angle.d.ts +29 -33
- package/dist/lib/components/controls/angle.d.ts.map +1 -1
- package/dist/lib/components/controls/bitmask.d.ts +41 -0
- package/dist/lib/components/controls/bitmask.d.ts.map +1 -0
- package/dist/lib/components/controls/bool.d.ts +52 -0
- package/dist/lib/components/controls/bool.d.ts.map +1 -0
- package/dist/lib/components/controls/color-picker.d.ts +12 -27
- package/dist/lib/components/controls/color-picker.d.ts.map +1 -1
- package/dist/lib/components/controls/color.d.ts +12 -26
- package/dist/lib/components/controls/color.d.ts.map +1 -1
- package/dist/lib/components/controls/index.d.ts +9 -5
- package/dist/lib/components/controls/index.d.ts.map +1 -1
- package/dist/lib/components/controls/input.d.ts +44 -0
- package/dist/lib/components/controls/input.d.ts.map +1 -0
- package/dist/lib/components/controls/matrix.d.ts +58 -0
- package/dist/lib/components/controls/matrix.d.ts.map +1 -0
- package/dist/lib/components/controls/point.d.ts +15 -16
- package/dist/lib/components/controls/point.d.ts.map +1 -1
- package/dist/lib/components/controls/poll.d.ts +12 -0
- package/dist/lib/components/controls/poll.d.ts.map +1 -0
- package/dist/lib/components/controls/scalar.d.ts +67 -0
- package/dist/lib/components/controls/scalar.d.ts.map +1 -0
- package/dist/lib/components/controls/select.d.ts +8 -14
- package/dist/lib/components/controls/select.d.ts.map +1 -1
- package/dist/lib/components/controls/spherical.d.ts +23 -55
- package/dist/lib/components/controls/spherical.d.ts.map +1 -1
- package/dist/lib/components/controls/string.d.ts +46 -0
- package/dist/lib/components/controls/string.d.ts.map +1 -0
- package/dist/lib/components/controls/vector.d.ts +54 -0
- package/dist/lib/components/controls/vector.d.ts.map +1 -0
- package/dist/lib/components/elements/button.d.ts +36 -0
- package/dist/lib/components/elements/button.d.ts.map +1 -0
- package/dist/lib/components/elements/divider.d.ts +4 -0
- package/dist/lib/components/elements/divider.d.ts.map +1 -0
- package/dist/lib/components/elements/graph.d.ts +8 -0
- package/dist/lib/components/elements/graph.d.ts.map +1 -0
- package/dist/lib/components/elements/image.d.ts +33 -0
- package/dist/lib/components/elements/image.d.ts.map +1 -0
- package/dist/lib/components/elements/index.d.ts +6 -0
- package/dist/lib/components/elements/index.d.ts.map +1 -0
- package/dist/lib/components/elements/widget.d.ts +31 -0
- package/dist/lib/components/elements/widget.d.ts.map +1 -0
- package/dist/lib/components/index.d.ts +2 -4
- package/dist/lib/components/index.d.ts.map +1 -1
- package/dist/lib/core/control.d.ts +20 -0
- package/dist/lib/core/control.d.ts.map +1 -0
- package/dist/lib/core/index.d.ts +1 -2
- package/dist/lib/core/index.d.ts.map +1 -1
- package/dist/lib/core/render.d.ts +7 -9
- package/dist/lib/core/render.d.ts.map +1 -1
- package/dist/lib/core/types.d.ts +46 -60
- package/dist/lib/core/types.d.ts.map +1 -1
- package/dist/lib/core/utils.d.ts +19 -33
- package/dist/lib/core/utils.d.ts.map +1 -1
- package/dist/lib/index.d.ts +2 -2
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/mount.d.ts +6 -16
- package/dist/lib/mount.d.ts.map +1 -1
- package/dist/lib/stats/index.d.ts +2 -0
- package/dist/lib/stats/index.d.ts.map +1 -0
- package/dist/lib/stats/sampler.d.ts +66 -0
- package/dist/lib/stats/sampler.d.ts.map +1 -0
- package/dist/lib/stats/stats-renderer.d.ts +16 -0
- package/dist/lib/stats/stats-renderer.d.ts.map +1 -0
- package/dist/style.css +1 -0
- package/dist/style.d.ts +4 -0
- package/dist/tweak-ui.module.js +2959 -2738
- package/dist/tweak-ui.module.js.map +1 -1
- package/dist/tweak-ui.umd.js +33 -2
- package/dist/tweak-ui.umd.js.map +1 -1
- package/dist/wrangler.json +1 -0
- package/package.json +34 -23
- package/dist/lib/builder.js +0 -250
- package/dist/lib/builder.js.map +0 -1
- package/dist/lib/color-formats/array-format.d.ts +0 -9
- package/dist/lib/color-formats/array-format.d.ts.map +0 -1
- package/dist/lib/color-formats/array-format.js +0 -18
- package/dist/lib/color-formats/array-format.js.map +0 -1
- package/dist/lib/color-formats/converter.d.ts.map +0 -1
- package/dist/lib/color-formats/converter.js +0 -85
- package/dist/lib/color-formats/converter.js.map +0 -1
- package/dist/lib/color-formats/css-string-format.d.ts +0 -8
- package/dist/lib/color-formats/css-string-format.d.ts.map +0 -1
- package/dist/lib/color-formats/css-string-format.js +0 -28
- package/dist/lib/color-formats/css-string-format.js.map +0 -1
- package/dist/lib/color-formats/formatter.d.ts +0 -9
- package/dist/lib/color-formats/formatter.d.ts.map +0 -1
- package/dist/lib/color-formats/formatter.js +0 -35
- package/dist/lib/color-formats/formatter.js.map +0 -1
- package/dist/lib/color-formats/hex-string-format.d.ts +0 -8
- package/dist/lib/color-formats/hex-string-format.d.ts.map +0 -1
- package/dist/lib/color-formats/hex-string-format.js +0 -28
- package/dist/lib/color-formats/hex-string-format.js.map +0 -1
- package/dist/lib/color-formats/index.d.ts.map +0 -1
- package/dist/lib/color-formats/index.js +0 -4
- package/dist/lib/color-formats/index.js.map +0 -1
- package/dist/lib/color-formats/number-format.d.ts +0 -9
- package/dist/lib/color-formats/number-format.d.ts.map +0 -1
- package/dist/lib/color-formats/number-format.js +0 -23
- package/dist/lib/color-formats/number-format.js.map +0 -1
- package/dist/lib/color-formats/object-format.d.ts.map +0 -1
- package/dist/lib/color-formats/object-format.js +0 -23
- package/dist/lib/color-formats/object-format.js.map +0 -1
- package/dist/lib/color-formats/types.d.ts.map +0 -1
- package/dist/lib/color-formats/types.js +0 -2
- package/dist/lib/color-formats/types.js.map +0 -1
- package/dist/lib/components/button.d.ts +0 -29
- package/dist/lib/components/button.d.ts.map +0 -1
- package/dist/lib/components/button.js +0 -15
- package/dist/lib/components/button.js.map +0 -1
- package/dist/lib/components/content.d.ts +0 -22
- package/dist/lib/components/content.d.ts.map +0 -1
- package/dist/lib/components/content.js +0 -10
- package/dist/lib/components/content.js.map +0 -1
- package/dist/lib/components/controls/angle.js +0 -201
- package/dist/lib/components/controls/angle.js.map +0 -1
- package/dist/lib/components/controls/checkbox.d.ts +0 -29
- package/dist/lib/components/controls/checkbox.d.ts.map +0 -1
- package/dist/lib/components/controls/checkbox.js +0 -31
- package/dist/lib/components/controls/checkbox.js.map +0 -1
- package/dist/lib/components/controls/color-picker.js +0 -267
- package/dist/lib/components/controls/color-picker.js.map +0 -1
- package/dist/lib/components/controls/color.js +0 -77
- package/dist/lib/components/controls/color.js.map +0 -1
- package/dist/lib/components/controls/index.js +0 -11
- package/dist/lib/components/controls/index.js.map +0 -1
- package/dist/lib/components/controls/number.d.ts +0 -48
- package/dist/lib/components/controls/number.d.ts.map +0 -1
- package/dist/lib/components/controls/number.js +0 -142
- package/dist/lib/components/controls/number.js.map +0 -1
- package/dist/lib/components/controls/point.js +0 -137
- package/dist/lib/components/controls/point.js.map +0 -1
- package/dist/lib/components/controls/position.d.ts +0 -56
- package/dist/lib/components/controls/position.d.ts.map +0 -1
- package/dist/lib/components/controls/position.js +0 -36
- package/dist/lib/components/controls/position.js.map +0 -1
- package/dist/lib/components/controls/select.js +0 -132
- package/dist/lib/components/controls/select.js.map +0 -1
- package/dist/lib/components/controls/spherical.js +0 -302
- package/dist/lib/components/controls/spherical.js.map +0 -1
- package/dist/lib/components/controls/text.d.ts +0 -36
- package/dist/lib/components/controls/text.d.ts.map +0 -1
- package/dist/lib/components/controls/text.js +0 -24
- package/dist/lib/components/controls/text.js.map +0 -1
- package/dist/lib/components/groups/accordion.d.ts +0 -22
- package/dist/lib/components/groups/accordion.d.ts.map +0 -1
- package/dist/lib/components/groups/accordion.js +0 -34
- package/dist/lib/components/groups/accordion.js.map +0 -1
- package/dist/lib/components/groups/container.d.ts +0 -25
- package/dist/lib/components/groups/container.d.ts.map +0 -1
- package/dist/lib/components/groups/container.js +0 -19
- package/dist/lib/components/groups/container.js.map +0 -1
- package/dist/lib/components/groups/group.d.ts +0 -49
- package/dist/lib/components/groups/group.d.ts.map +0 -1
- package/dist/lib/components/groups/group.js +0 -50
- package/dist/lib/components/groups/group.js.map +0 -1
- package/dist/lib/components/groups/index.d.ts +0 -5
- package/dist/lib/components/groups/index.d.ts.map +0 -1
- package/dist/lib/components/groups/index.js +0 -5
- package/dist/lib/components/groups/index.js.map +0 -1
- package/dist/lib/components/groups/tabs.d.ts +0 -22
- package/dist/lib/components/groups/tabs.d.ts.map +0 -1
- package/dist/lib/components/groups/tabs.js +0 -31
- package/dist/lib/components/groups/tabs.js.map +0 -1
- package/dist/lib/components/image.d.ts +0 -37
- package/dist/lib/components/image.d.ts.map +0 -1
- package/dist/lib/components/image.js +0 -46
- package/dist/lib/components/image.js.map +0 -1
- package/dist/lib/components/index.js +0 -6
- package/dist/lib/components/index.js.map +0 -1
- package/dist/lib/core/index.js +0 -5
- package/dist/lib/core/index.js.map +0 -1
- package/dist/lib/core/registry.d.ts +0 -18
- package/dist/lib/core/registry.d.ts.map +0 -1
- package/dist/lib/core/registry.js +0 -30
- package/dist/lib/core/registry.js.map +0 -1
- package/dist/lib/core/render.js +0 -19
- package/dist/lib/core/render.js.map +0 -1
- package/dist/lib/core/types.js +0 -2
- package/dist/lib/core/types.js.map +0 -1
- package/dist/lib/core/utils.js +0 -193
- package/dist/lib/core/utils.js.map +0 -1
- package/dist/lib/core/value-accessor.d.ts +0 -18
- package/dist/lib/core/value-accessor.d.ts.map +0 -1
- package/dist/lib/core/value-accessor.js +0 -52
- package/dist/lib/core/value-accessor.js.map +0 -1
- package/dist/lib/index.js +0 -29
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/mount.js +0 -85
- package/dist/lib/mount.js.map +0 -1
- package/dist/tweak-ui.css +0 -648
- package/dist/tweak-ui.css.map +0 -1
- package/dist/tweak-ui.min.css +0 -1
- package/dist/tweak-ui.min.css.map +0 -1
- /package/dist/lib/{color-formats → color}/converter.d.ts +0 -0
- /package/dist/lib/{color-formats → color}/index.d.ts +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"group.js","sourceRoot":"","sources":["../../../../src/lib/components/groups/group.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,SAAS,CAAA;AAEvB,OAAO,EACL,SAAS,EACT,WAAW,GAIZ,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAmDnF,MAAM,IAAI,GAAG,OAAO,CAAA;AACpB,SAAS,CAAa,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;IACnC,SAAS,OAAO,CAAC,CAAa;QAC5B,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;YAC5B,IAAI,CAAC,SAAS,GAAG,CAAC,IAAI,CAAC,SAAS,CAAA;YAChC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;YACzB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBACnB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;YAC7B,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;YAC3B,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IACD,SAAS,KAAK,CAAC,IAAgB;QAC7B,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACrC,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,CAAC,CACN,KAAK,EACL;YACE,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC;YAC/B,OAAO,EAAE,IAAI,CAAC,WAAW,C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I,CAAC,CAAC,CAAC,CACjC,CACF;KACF,CAAA;AACH,CAAC,CAAC,CAAA","sourcesContent":["import m from 'mithril'\r\n\r\nimport {\r\n component,\r\n renderModel,\r\n ComponentGroupModel,\r\n ComponentAttrs,\r\n ComponentModel,\r\n} from '../../core'\r\nimport { twuiClass, viewFn, isString, use, call, cssClass } from '../../core/utils'\r\n\r\n/**\r\n * Group component attributes\r\n * @public\r\n */\r\nexport type GroupAttrs = ComponentAttrs<GroupModel>\r\n\r\n/**\r\n * Group component model\r\n * @public\r\n */\r\nexport interface GroupModel extends ComponentGroupModel<ComponentModel> {\r\n /**\r\n * Component type name\r\n */\r\n type: 'group'\r\n /**\r\n * Group title\r\n */\r\n title?: string\r\n /**\r\n * Group CSS Style\r\n */\r\n style?: Partial<CSSStyleDeclaration>\r\n /**\r\n * Whether the child elements can be collapsed\r\n */\r\n collapsible?: boolean\r\n /**\r\n * Whether the child elements are collapsed\r\n */\r\n collapsed?: boolean\r\n /**\r\n * Adds an offset to the left side\r\n */\r\n inset?: boolean\r\n /**\r\n * Is called when this Group has been collapsed or expanded\r\n */\r\n onToggle?: (group: GroupModel) => void\r\n /**\r\n * Is called when this Group has been expanded\r\n */\r\n onExpand?: (group: GroupModel) => void\r\n /**\r\n * Is called when this Group has been collapsed\r\n */\r\n onCollapse?: (group: GroupModel) => void\r\n}\r\n\r\nconst TYPE = 'group'\r\ncomponent<GroupAttrs>(TYPE, (node) => {\r\n function onClick(e: MouseEvent) {\r\n use(node.attrs.data, (data) => {\r\n data.collapsed = !data.collapsed\r\n call(data.onToggle, data)\r\n if (data.collapsed) {\r\n call(data.onCollapse, data)\r\n } else {\r\n call(data.onExpand, data)\r\n }\r\n })\r\n }\r\n function title(data: GroupModel) {\r\n if (!data.title && !data.collapsible) {\r\n return null\r\n }\r\n return m(\r\n 'div',\r\n {\r\n class: twuiClass(TYPE, 'title'),\r\n onclick: data.collapsible ? onClick : null,\r\n },\r\n data.title,\r\n )\r\n }\r\n function children(data: GroupModel) {\r\n if (data.collapsed || !data.children) {\r\n return []\r\n }\r\n return data.children?.map((it) => {\r\n if (isString(it.label)) {\r\n return m(\r\n 'div',\r\n { class: twuiClass(TYPE, 'control') },\r\n m('label', it.label),\r\n m('section', renderModel(it)),\r\n )\r\n }\r\n return renderModel(it)\r\n })\r\n }\r\n\r\n return {\r\n view: viewFn((data) =>\r\n m(\r\n 'div',\r\n {\r\n class: cssClass({\r\n [twuiClass(TYPE)]: true,\r\n [twuiClass(TYPE, 'collapsible')]: data.collapsible,\r\n [twuiClass(TYPE, 'collapsed')]: data.collapsed,\r\n }) ,\r\n style: data.style,\r\n },\r\n m.fragment({}, [title(data)]),\r\n m.fragment({}, [children(data)]),\r\n ),\r\n ),\r\n }\r\n})\r\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/groups/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/components/groups/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA","sourcesContent":["export * from './accordion'\r\nexport * from './container'\r\nexport * from './group'\r\nexport * from './tabs'\r\n"]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ComponentAttrs, ComponentGroupModel } from '../../core';
|
|
2
|
-
import { GroupModel } from './group';
|
|
3
|
-
/**
|
|
4
|
-
* Tabs component attributes
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
export type TabsAtts = ComponentAttrs<TabsModel>;
|
|
8
|
-
/**
|
|
9
|
-
* Tabs component model
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
export interface TabsModel extends ComponentGroupModel<GroupModel> {
|
|
13
|
-
/**
|
|
14
|
-
* The type name of the control
|
|
15
|
-
*/
|
|
16
|
-
type: 'tabs';
|
|
17
|
-
/**
|
|
18
|
-
* The index of the opened tab
|
|
19
|
-
*/
|
|
20
|
-
active: number;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=tabs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/groups/tabs.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,cAAc,EACd,mBAAmB,EACpB,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEpC;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,cAAc,CAAC,SAAS,CAAC,CAAA;AAEhD;;;GAGG;AACH,MAAM,WAAW,SAAU,SAAQ,mBAAmB,CAAC,UAAU,CAAC;IAChE;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;CACf"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import m from 'mithril';
|
|
2
|
-
import { component, renderModel, } from '../../core';
|
|
3
|
-
import { clamp, twuiClass, viewFn } from '../../core/utils';
|
|
4
|
-
component('tabs', () => {
|
|
5
|
-
return {
|
|
6
|
-
view: viewFn((data) => {
|
|
7
|
-
const tabs = data.children || [];
|
|
8
|
-
const active = clamp(data.active || 0, 0, tabs.length - 1);
|
|
9
|
-
const tab = tabs[active];
|
|
10
|
-
return m('div', {
|
|
11
|
-
class: twuiClass(data.type),
|
|
12
|
-
}, m('div', {
|
|
13
|
-
key: `${data.type}-list`,
|
|
14
|
-
class: twuiClass(`${data.type}-list`),
|
|
15
|
-
}, tabs.map((it, index) => {
|
|
16
|
-
return m("button[type='button']", {
|
|
17
|
-
key: `${data.type}-${index}`,
|
|
18
|
-
onclick: () => (data.active = index),
|
|
19
|
-
class: active === index ? 'is-active' : '',
|
|
20
|
-
}, it.label || it.title);
|
|
21
|
-
})), m.fragment({ key: `panel-${data.active}` }, [
|
|
22
|
-
renderModel({
|
|
23
|
-
type: 'group',
|
|
24
|
-
children: tab.children,
|
|
25
|
-
style: tab.style,
|
|
26
|
-
}),
|
|
27
|
-
]));
|
|
28
|
-
}),
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
//# sourceMappingURL=tabs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.js","sourceRoot":"","sources":["../../../../src/lib/components/groups/tabs.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,SAAS,CAAA;AAEvB,OAAO,EACL,SAAS,EACT,WAAW,GAGZ,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAwB3D,SAAS,CAAW,MAAM,EAAE,GAAG,EAAE;IAC/B,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;YACpB,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAA;YAChC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;YAC1D,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,CAAA;YACxB,OAAO,CAAC,CACN,KAAK,EACL;gBACE,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;aAC5B,EACD,CAAC,CACC,KAAK,EACL;gBACE,GAAG,EAAE,GAAG,IAAI,CAAC,IAAI,OAAO;gBACxB,KAAK,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,IAAI,OAAO,CAAC;aACtC,EACD,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE;gBACrB,OAAO,CAAC,CACN,uBAAuB,EACvB;oBACE,GAAG,EAAE,GAAG,IAAI,CAAC,IAAI,IAAI,KAAK,EAAE;oBAC5B,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;oBACpC,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE;iBAC3C,EACD,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CACrB,CAAA;YACH,CAAC,CAAC,CACH,EACD,CAAC,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,SAAS,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE;gBAC1C,WAAW,CAAa;oBACtB,IAAI,EAAE,OAAO;oBACb,QAAQ,EAAE,GAAG,CAAC,QAAQ;oBACtB,KAAK,EAAE,GAAG,CAAC,KAAK;iBACjB,CAAC;aACH,CAAC,CACH,CAAA;QACH,CAAC,CAAC;KACH,CAAA;AACH,CAAC,CAAC,CAAA","sourcesContent":["import m from 'mithril'\r\n\r\nimport {\r\n component,\r\n renderModel,\r\n ComponentAttrs,\r\n ComponentGroupModel,\r\n} from '../../core'\r\nimport { clamp, twuiClass, viewFn } from '../../core/utils'\r\nimport { GroupModel } from './group'\r\n\r\n/**\r\n * Tabs component attributes\r\n * @public\r\n */\r\nexport type TabsAtts = ComponentAttrs<TabsModel>\r\n\r\n/**\r\n * Tabs component model\r\n * @public\r\n */\r\nexport interface TabsModel extends ComponentGroupModel<GroupModel> {\r\n /**\r\n * The type name of the control\r\n */\r\n type: 'tabs'\r\n /**\r\n * The index of the opened tab\r\n */\r\n active: number\r\n}\r\n\r\ncomponent<TabsAtts>('tabs', () => {\r\n return {\r\n view: viewFn((data) => {\r\n const tabs = data.children || []\r\n const active = clamp(data.active || 0, 0, tabs.length - 1)\r\n const tab = tabs[active]\r\n return m(\r\n 'div',\r\n {\r\n class: twuiClass(data.type),\r\n },\r\n m(\r\n 'div',\r\n {\r\n key: `${data.type}-list`,\r\n class: twuiClass(`${data.type}-list`),\r\n },\r\n tabs.map((it, index) => {\r\n return m(\r\n \"button[type='button']\",\r\n {\r\n key: `${data.type}-${index}`,\r\n onclick: () => (data.active = index),\r\n class: active === index ? 'is-active' : '',\r\n },\r\n it.label || it.title,\r\n )\r\n }),\r\n ),\r\n m.fragment({ key: `panel-${data.active}` }, [\r\n renderModel<GroupModel>({\r\n type: 'group',\r\n children: tab.children,\r\n style: tab.style,\r\n }),\r\n ]),\r\n )\r\n }),\r\n }\r\n})\r\n"]}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { ComponentModel, ComponentAttrs } from '../core';
|
|
2
|
-
/**
|
|
3
|
-
* Image component attrs
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export type ImageAttrs = ComponentAttrs<ImageModel>;
|
|
7
|
-
/**
|
|
8
|
-
* Image component model
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
export interface ImageModel extends ComponentModel {
|
|
12
|
-
/**
|
|
13
|
-
* The type name of the control
|
|
14
|
-
*/
|
|
15
|
-
type: 'image';
|
|
16
|
-
/**
|
|
17
|
-
* The image source url
|
|
18
|
-
*/
|
|
19
|
-
src?: string | string[];
|
|
20
|
-
/**
|
|
21
|
-
* Aspect ratio of the picture container
|
|
22
|
-
*/
|
|
23
|
-
aspect?: string;
|
|
24
|
-
/**
|
|
25
|
-
* A fixed width
|
|
26
|
-
*/
|
|
27
|
-
width?: number | string;
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
fit?: 'contain' | 'cover' | 'fill';
|
|
32
|
-
/**
|
|
33
|
-
* This is callend when the control is clicked
|
|
34
|
-
*/
|
|
35
|
-
onClick?: (ctrl: ImageModel) => void;
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=image.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/lib/components/image.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAGnE;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,CAAA;AAEnD;;;GAGG;AACH,MAAM,WAAW,UAAW,SAAQ,cAAc;IAChD;;OAEG;IACH,IAAI,EAAE,OAAO,CAAA;IACb;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACvB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB;;OAEG;IACH,GAAG,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,CAAA;IAClC;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAA;CACrC"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import m from 'mithril';
|
|
2
|
-
import { component } from '../core';
|
|
3
|
-
import { call, use, twuiClass, viewFn, isNumber, isString, cssClass } from '../core/utils';
|
|
4
|
-
const TYPE = 'image';
|
|
5
|
-
component('image', (node) => {
|
|
6
|
-
const onClick = () => {
|
|
7
|
-
use(node.attrs.data, (data) => call(data.onClick, data));
|
|
8
|
-
};
|
|
9
|
-
function aspect(spec) {
|
|
10
|
-
if (!spec) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
const [x, y] = (spec || '1x1').split('x').map(Number);
|
|
14
|
-
const padding = ((y / x) || 1) * 100;
|
|
15
|
-
return `${padding}%`;
|
|
16
|
-
}
|
|
17
|
-
function width(data) {
|
|
18
|
-
if (isNumber(data.width)) {
|
|
19
|
-
return `${data.width}px`;
|
|
20
|
-
}
|
|
21
|
-
if (isString(data.width)) {
|
|
22
|
-
return data.width;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return {
|
|
26
|
-
view: viewFn((data) => {
|
|
27
|
-
return (Array.isArray(data.src) ? data.src : [data.src]).map((src) => {
|
|
28
|
-
return m('picture', {
|
|
29
|
-
class: cssClass({
|
|
30
|
-
[twuiClass(TYPE)]: true,
|
|
31
|
-
[twuiClass(TYPE, 'aspect')]: !!data.aspect,
|
|
32
|
-
}),
|
|
33
|
-
style: {
|
|
34
|
-
'--twui-aspect': aspect(data.aspect),
|
|
35
|
-
'--twui-fit': data.fit || 'fit',
|
|
36
|
-
width: width(data),
|
|
37
|
-
},
|
|
38
|
-
}, m('img', {
|
|
39
|
-
src: src,
|
|
40
|
-
onclick: onClick,
|
|
41
|
-
}));
|
|
42
|
-
});
|
|
43
|
-
}),
|
|
44
|
-
};
|
|
45
|
-
});
|
|
46
|
-
//# sourceMappingURL=image.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"image.js","sourceRoot":"","sources":["../../../src/lib/components/image.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,SAAS,CAAA;AAEvB,OAAO,EAAE,SAAS,EAAkC,MAAM,SAAS,CAAA;AACnE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAuC1F,MAAM,IAAI,GAAG,OAAO,CAAA;AACpB,SAAS,CAAa,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;IACtC,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;IAC1D,CAAC,CAAA;IACD,SAAS,MAAM,CAAC,IAAY;QAC1B,IAAI,CAAC,IAAI,EAAE,CAAC;Y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AAC,IAAI,CAAC;qBACnB;iBACF,EACD,CAAC,CAAC,KAAK,EAAE;oBACP,GAAG,EAAE,GAAG;oBACR,OAAO,EAAE,OAAO;iBACjB,CAAC,CACH,CAAA;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC;KACH,CAAA;AACH,CAAC,CAAC,CAAA","sourcesContent":["import m from 'mithril'\r\n\r\nimport { component, ComponentModel, ComponentAttrs } from '../core'\r\nimport { call, use, twuiClass, viewFn, isNumber, isString, cssClass } from '../core/utils'\r\n\r\n/**\r\n * Image component attrs\r\n * @public\r\n */\r\nexport type ImageAttrs = ComponentAttrs<ImageModel>\r\n\r\n/**\r\n * Image component model\r\n * @public\r\n */\r\nexport interface ImageModel extends ComponentModel {\r\n /**\r\n * The type name of the control\r\n */\r\n type: 'image'\r\n /**\r\n * The image source url\r\n */\r\n src?: string | string[]\r\n /**\r\n * Aspect ratio of the picture container\r\n */\r\n aspect?: string\r\n /**\r\n * A fixed width\r\n */\r\n width?: number | string\r\n /**\r\n *\r\n */\r\n fit?: 'contain' | 'cover' | 'fill'\r\n /**\r\n * This is callend when the control is clicked\r\n */\r\n onClick?: (ctrl: ImageModel) => void\r\n}\r\n\r\nconst TYPE = 'image'\r\ncomponent<ImageAttrs>('image', (node) => {\r\n const onClick = () => {\r\n use(node.attrs.data, (data) => call(data.onClick, data))\r\n }\r\n function aspect(spec: string) {\r\n if (!spec) {\r\n return null\r\n }\r\n const [x, y] = (spec || '1x1').split('x').map(Number)\r\n const padding = ((y / x) || 1) * 100\r\n return `${padding}%`\r\n }\r\n function width(data: ImageModel) {\r\n if (isNumber(data.width)) {\r\n return `${data.width}px`\r\n }\r\n if (isString(data.width)) {\r\n return data.width\r\n }\r\n }\r\n return {\r\n view: viewFn((data) => {\r\n return (Array.isArray(data.src) ? data.src : [data.src]).map((src) => {\r\n return m(\r\n 'picture',\r\n {\r\n class: cssClass({\r\n [twuiClass(TYPE)]: true,\r\n [twuiClass(TYPE, 'aspect')]: !!data.aspect,\r\n }),\r\n style: {\r\n '--twui-aspect': aspect(data.aspect),\r\n '--twui-fit': data.fit || 'fit',\r\n width: width(data),\r\n },\r\n },\r\n m('img', {\r\n src: src,\r\n onclick: onClick,\r\n }),\r\n )\r\n })\r\n }),\r\n }\r\n})\r\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA","sourcesContent":["export * from './controls'\r\nexport * from './groups'\r\nexport * from './button'\r\nexport * from './content'\r\nexport * from './image'\r\n"]}
|
package/dist/lib/core/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,kBAAkB,CAAA;AAChC,cAAc,SAAS,CAAA","sourcesContent":["export * from './registry'\r\nexport * from './render'\r\nexport * from './value-accessor'\r\nexport * from './types'\r\n"]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ComponentAttrs, ComponentType } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Gets a registered component for a given type name
|
|
4
|
-
*
|
|
5
|
-
* @public
|
|
6
|
-
* @param type - The component type
|
|
7
|
-
*/
|
|
8
|
-
export declare function getComponent<T extends ComponentAttrs<any>>(type: string): ComponentType<T>;
|
|
9
|
-
/**
|
|
10
|
-
* Registers a component
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
* @param type - The component type name
|
|
14
|
-
* @param comp - The component
|
|
15
|
-
* @param override - Allows to override an already registered component
|
|
16
|
-
*/
|
|
17
|
-
export declare function component<T>(type: string, comp: ComponentType<T>, override?: boolean): void;
|
|
18
|
-
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/lib/core/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAM5D;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,cAAc,CAAC,GAAG,CAAC,EACxD,IAAI,EAAE,MAAM,GACX,aAAa,CAAC,CAAC,CAAC,CAKlB;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,CAAC,EACzB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EACtB,QAAQ,GAAE,OAAe,QAO1B"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const registry = {};
|
|
2
|
-
/**
|
|
3
|
-
* Gets a registered component for a given type name
|
|
4
|
-
*
|
|
5
|
-
* @public
|
|
6
|
-
* @param type - The component type
|
|
7
|
-
*/
|
|
8
|
-
export function getComponent(type) {
|
|
9
|
-
if (registry[type]) {
|
|
10
|
-
return registry[type];
|
|
11
|
-
}
|
|
12
|
-
throw new Error(`Component of type '${type}' was not found`);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Registers a component
|
|
16
|
-
*
|
|
17
|
-
* @public
|
|
18
|
-
* @param type - The component type name
|
|
19
|
-
* @param comp - The component
|
|
20
|
-
* @param override - Allows to override an already registered component
|
|
21
|
-
*/
|
|
22
|
-
export function component(type, comp, override = false) {
|
|
23
|
-
if (registry[type] && !override) {
|
|
24
|
-
console.warn(`Component ignored. Name '${type}' is already registered.`);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
registry[type] = comp;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/lib/core/registry.ts"],"names":[],"mappings":"AAEA,MAAM,QAAQ,GAEV,EAAE,CAAA;AAEN;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAC1B,IAAY;IAEZ,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACnB,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,iBAAiB,CAAC,CAAA;AAC9D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CACvB,IAAY,EACZ,IAAsB,EACtB,WAAoB,KAAK;IAEzB,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChC,OAAO,CAAC,IAAI,CAAC,4BAA4B,IAAI,0BAA0B,CAAC,CAAA;IAC1E,CAAC;SAAM,CAAC;QACN,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACvB,CAAC;AACH,CAAC","sourcesContent":["import type { ComponentAttrs, ComponentType } from './types'\r\n\r\nconst registry: {\r\n [key: string]: ComponentType<any>\r\n} = {}\r\n\r\n/**\r\n * Gets a registered component for a given type name\r\n *\r\n * @public\r\n * @param type - The component type\r\n */\r\nexport function getComponent<T extends ComponentAttrs<any>>(\r\n type: string,\r\n): ComponentType<T> {\r\n if (registry[type]) {\r\n return registry[type]\r\n }\r\n throw new Error(`Component of type '${type}' was not found`)\r\n}\r\n\r\n/**\r\n * Registers a component\r\n *\r\n * @public\r\n * @param type - The component type name\r\n * @param comp - The component\r\n * @param override - Allows to override an already registered component\r\n */\r\nexport function component<T>(\r\n type: string,\r\n comp: ComponentType<T>,\r\n override: boolean = false,\r\n) {\r\n if (registry[type] && !override) {\r\n console.warn(`Component ignored. Name '${type}' is already registered.`)\r\n } else {\r\n registry[type] = comp\r\n }\r\n}\r\n"]}
|
package/dist/lib/core/render.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { getComponent } from './registry';
|
|
2
|
-
import { default as m } from 'mithril';
|
|
3
|
-
/**
|
|
4
|
-
* Renders a registered component using the model
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
* @param model - The model
|
|
8
|
-
*/
|
|
9
|
-
export function renderModel(model) {
|
|
10
|
-
if (!model.type) {
|
|
11
|
-
console.error(new Error('Given data is missing the .type property. Component can resolve the component'), model);
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
if (model.hidden) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
return m(getComponent(model.type), { data: model });
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=render.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/lib/core/render.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,OAAO,IAAI,CAAC,EAAE,MAAM,SAAS,CAAA;AAEtC;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAA2B,KAAQ;IAC5D,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,+EAA+E,CAAC,EAAE,KAAK,CAAC,CAAA;QAChH,OAAO,IAAI,CAAA;IACb,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QACjB,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;AACrD,CAAC","sourcesContent":["\r\nimport type { ComponentModel } from './types'\r\nimport { getComponent } from './registry'\r\nimport { default as m } from 'mithril'\r\n\r\n/**\r\n * Renders a registered component using the model\r\n *\r\n * @public\r\n * @param model - The model\r\n */\r\nexport function renderModel<T extends ComponentModel>(model: T) {\r\n if (!model.type) {\r\n console.error(new Error('Given data is missing the .type property. Component can resolve the component'), model)\r\n return null\r\n }\r\n if (model.hidden) {\r\n return null\r\n }\r\n return m(getComponent(model.type), { data: model })\r\n}\r\n"]}
|
package/dist/lib/core/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/core/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { FactoryComponent, ClassComponent } from 'mithril'\r\n\r\n/**\r\n * @public\r\n */\r\nexport type ComponentType<T = any> = FactoryComponent<T> | ClassComponent<T>\r\n\r\n/**\r\n * Base model for a component with children\r\n *\r\n * @public\r\n */\r\nexport interface ComponentGroupModel<T extends ComponentModel = ComponentModel>\r\n extends ComponentModel {\r\n /**\r\n * Collection of child components\r\n */\r\n children?: T[]\r\n}\r\n\r\n/**\r\n * Base model for a component\r\n *\r\n * @public\r\n */\r\nexport interface ComponentModel {\r\n /**\r\n * The type name of the component\r\n */\r\n type: string\r\n /**\r\n * If true, the component will not be rendered\r\n *\r\n * @remarks\r\n * This is a convenience property that allows to hide a component\r\n * without removing it from the component data model.\r\n */\r\n hidden?: boolean | (() => boolean)\r\n /**\r\n * The label for this component when rendered as a control\r\n *\r\n * @remarks\r\n * This is only evaluated when rendered as a child of a panel component\r\n */\r\n label?: string\r\n}\r\n\r\n/**\r\n * Common component attributes\r\n *\r\n * @public\r\n */\r\nexport type ComponentAttrs<T extends ComponentModel> = {\r\n data: T\r\n}\r\n\r\nexport type KeyMatchingType<T, V> = { [K in keyof T]: T[K] extends V ? K : never }[keyof T]\r\n\r\n/**\r\n * Utility to convert a value type\r\n *\r\n * @public\r\n */\r\nexport type ValueCodec<Encoded, Decoded> = {\r\n decode: (value: Encoded) => Decoded\r\n encode: (value: Decoded) => Encoded\r\n}\r\n\r\nexport type ValueSource<T, V, I = unknown> = {\r\n /**\r\n * The object which is holding a control value\r\n *\r\n * @remarks\r\n * Requires the `property` option to be set.\r\n */\r\n target?: T\r\n /**\r\n * The property name in `target` where the control value is stored\r\n *\r\n * @remarks\r\n * Requires the `target` option to be set.\r\n */\r\n property?: keyof T\r\n /**\r\n * If `target` and `property` are not set, then this is used as the control value\r\n */\r\n value?: V | I\r\n codec?: ValueCodec<I, V>,\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport type ArrayOrSingleOf<T> = T | T[]\r\n"]}
|
package/dist/lib/core/utils.js
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if value is a string
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export function isString(v) {
|
|
6
|
-
return typeof v === 'string';
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Checks if value is a number
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
export function isNumber(v) {
|
|
13
|
-
return typeof v === 'number';
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Checks if value is a function
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
export function isFunction(v) {
|
|
20
|
-
return typeof v === 'function';
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Checks if value is an array
|
|
24
|
-
* @internal
|
|
25
|
-
*/
|
|
26
|
-
export function isArray(v) {
|
|
27
|
-
return Array.isArray(v);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Checks if value is an object
|
|
31
|
-
* @internal
|
|
32
|
-
*/
|
|
33
|
-
export function isObject(v) {
|
|
34
|
-
return v != null && typeof v === 'object' && !isArray(v);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Calls a function if it is not null
|
|
38
|
-
* @internal
|
|
39
|
-
*/
|
|
40
|
-
export function call(cb, ...args) {
|
|
41
|
-
return isFunction(cb) ? cb(...args) : null;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Resolves a property to its value
|
|
45
|
-
* @param value - the function or value to resolve
|
|
46
|
-
*/
|
|
47
|
-
export function resolve(value) {
|
|
48
|
-
return isFunction(value) ? value() : value;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Calls the callback of object is not null
|
|
52
|
-
* @internal
|
|
53
|
-
*/
|
|
54
|
-
export function use(obj, cb) {
|
|
55
|
-
return obj == null ? null : cb(obj);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Clamps a number value
|
|
59
|
-
* @internal
|
|
60
|
-
*/
|
|
61
|
-
export function clamp(v, min, max) {
|
|
62
|
-
if (v != null) {
|
|
63
|
-
if (min != null && v < min) {
|
|
64
|
-
return min;
|
|
65
|
-
}
|
|
66
|
-
if (max != null && v > max) {
|
|
67
|
-
return max;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return v;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Builds a css class from various argument types
|
|
74
|
-
* @param exp
|
|
75
|
-
*/
|
|
76
|
-
export function cssClass(exp) {
|
|
77
|
-
if (!exp) {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
if (isString(exp)) {
|
|
81
|
-
return exp;
|
|
82
|
-
}
|
|
83
|
-
if (isArray(exp)) {
|
|
84
|
-
return exp.map(cssClass).join(' ');
|
|
85
|
-
}
|
|
86
|
-
return Object.keys(exp)
|
|
87
|
-
.filter((it) => resolve(exp[it]))
|
|
88
|
-
.filter((it) => isString(it) && !!it)
|
|
89
|
-
.join(' ');
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Pads a string
|
|
93
|
-
* @internal
|
|
94
|
-
*/
|
|
95
|
-
export function padLeft(value, length, char) {
|
|
96
|
-
while (value.length < length) {
|
|
97
|
-
value = `${char}${value}`;
|
|
98
|
-
}
|
|
99
|
-
return value;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* @internal
|
|
103
|
-
*/
|
|
104
|
-
export function twuiClass(name, variation) {
|
|
105
|
-
return `twui-${name}` + (variation ? `-${variation}` : '');
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Gets current mouse coordinates from mouse or touch event
|
|
109
|
-
* @internal
|
|
110
|
-
*/
|
|
111
|
-
export function getTouchPoint(e) {
|
|
112
|
-
let cx = 0;
|
|
113
|
-
let cy = 0;
|
|
114
|
-
if ('touches' in e) {
|
|
115
|
-
cx = e.touches.item(0).pageX;
|
|
116
|
-
cy = e.touches.item(0).pageY;
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
cx = e.pageX;
|
|
120
|
-
cy = e.pageY;
|
|
121
|
-
}
|
|
122
|
-
return [cx, cy];
|
|
123
|
-
}
|
|
124
|
-
export function getTouchInTarget(e, target, offset) {
|
|
125
|
-
target = target || e.target;
|
|
126
|
-
const rect = target.getBoundingClientRect();
|
|
127
|
-
const tx = window.pageXOffset || document.documentElement.scrollLeft;
|
|
128
|
-
const ty = window.pageYOffset || document.documentElement.scrollTop;
|
|
129
|
-
const cw = target.clientWidth;
|
|
130
|
-
const ch = target.clientHeight;
|
|
131
|
-
let [cx, cy] = getTouchPoint(e);
|
|
132
|
-
if (offset) {
|
|
133
|
-
cx += offset[0];
|
|
134
|
-
cy += offset[1];
|
|
135
|
-
}
|
|
136
|
-
const x = cx - tx - rect.left;
|
|
137
|
-
const y = cy - ty - rect.top;
|
|
138
|
-
return {
|
|
139
|
-
width: cw,
|
|
140
|
-
height: ch,
|
|
141
|
-
x: x,
|
|
142
|
-
y: y,
|
|
143
|
-
normalizedX: x / cw,
|
|
144
|
-
normalizedY: y / ch,
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* @internal
|
|
149
|
-
*/
|
|
150
|
-
export function viewFn(fn) {
|
|
151
|
-
return (node) => use(node.attrs.data, (data) => fn(data, node));
|
|
152
|
-
}
|
|
153
|
-
export function dataFn(node, fn) {
|
|
154
|
-
return () => fn(node.attrs.data, node);
|
|
155
|
-
}
|
|
156
|
-
export function dragUtil({ onStart, onMove, onEnd, }) {
|
|
157
|
-
const util = {
|
|
158
|
-
target: null,
|
|
159
|
-
activate: (e) => {
|
|
160
|
-
util.deactivate();
|
|
161
|
-
util.target = e.target;
|
|
162
|
-
if (onStart) {
|
|
163
|
-
onStart(e);
|
|
164
|
-
}
|
|
165
|
-
if (onMove) {
|
|
166
|
-
document.addEventListener('mousemove', onMove, { passive: false });
|
|
167
|
-
document.addEventListener('touchmove', onMove, { passive: false });
|
|
168
|
-
}
|
|
169
|
-
if (onEnd) {
|
|
170
|
-
document.addEventListener('mouseup', onEnd);
|
|
171
|
-
document.addEventListener('touchend', onEnd);
|
|
172
|
-
document.addEventListener('touchcancel', onEnd);
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
deactivate: () => {
|
|
176
|
-
util.target = null;
|
|
177
|
-
if (onMove) {
|
|
178
|
-
document.removeEventListener('mousemove', onMove);
|
|
179
|
-
document.removeEventListener('touchmove', onMove);
|
|
180
|
-
}
|
|
181
|
-
if (onEnd) {
|
|
182
|
-
document.removeEventListener('mouseup', onEnd);
|
|
183
|
-
document.removeEventListener('touchend', onEnd);
|
|
184
|
-
document.removeEventListener('touchcancel', onEnd);
|
|
185
|
-
}
|
|
186
|
-
},
|
|
187
|
-
onStart,
|
|
188
|
-
onMove,
|
|
189
|
-
onEnd,
|
|
190
|
-
};
|
|
191
|
-
return util;
|
|
192
|
-
}
|
|
193
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/lib/core/utils.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,CAAM;IAC7B,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAA;AAC9B,CAAC;AACD;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,CAAM;IAC7B,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAA;AAC9B,CAAC;AACD;;;G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AQ,CAAC,gBAAgB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;gBAC5C,QAAQ,CAAC,gBAAgB,CAAC,aAAa,EAAE,KAAK,CAAC,CAAA;YACjD,CAAC;QACH,CAAC;QACD,UAAU,EAAE,GAAG,EAAE;YACf,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;YAClB,IAAI,MAAM,EAAE,CAAC;gBACX,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;gBACjD,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;YACnD,CAAC;YACD,IAAI,KAAK,EAAE,CAAC;gBACV,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;gBAC9C,QAAQ,CAAC,mBAAmB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;gBAC/C,QAAQ,CAAC,mBAAmB,CAAC,aAAa,EAAE,KAAK,CAAC,CAAA;YACpD,CAAC;QACH,CAAC;QACD,OAAO;QACP,MAAM;QACN,KAAK;KACN,CAAA;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import type { ArrayOrSingleOf, ComponentAttrs, ComponentModel } from './types'\r\nimport type { Children, Vnode } from 'mithril'\r\n\r\n/**\r\n * Checks if value is a string\r\n * @internal\r\n */\r\nexport function isString(v: any): v is string {\r\n return typeof v === 'string'\r\n}\r\n/**\r\n * Checks if value is a number\r\n * @internal\r\n */\r\nexport function isNumber(v: any): v is number {\r\n return typeof v === 'number'\r\n}\r\n/**\r\n * Checks if value is a function\r\n * @internal\r\n */\r\nexport function isFunction(v: any): v is (...args: any[]) => any {\r\n return typeof v === 'function'\r\n}\r\n/**\r\n * Checks if value is an array\r\n * @internal\r\n */\r\nexport function isArray(v: any): v is any[] {\r\n return Array.isArray(v)\r\n}\r\n/**\r\n * Checks if value is an object\r\n * @internal\r\n */\r\nexport function isObject(v: any): v is object {\r\n return v != null && typeof v === 'object' && !isArray(v)\r\n}\r\n/**\r\n * Calls a function if it is not null\r\n * @internal\r\n */\r\nexport function call<T extends (...args: any) => any>(cb: T, ...args: Parameters<T>) {\r\n return isFunction(cb) ? cb(...args) : null\r\n}\r\n/**\r\n * Resolves a property to its value\r\n * @param value - the function or value to resolve\r\n */\r\nexport function resolve<T>(value: (() => T) | T) {\r\n return isFunction(value) ? value() : value\r\n}\r\n/**\r\n * Calls the callback of object is not null\r\n * @internal\r\n */\r\nexport function use<T, R>(obj: T | null, cb: (it: T) => R): R | null {\r\n return obj == null ? null : cb(obj)\r\n}\r\n\r\n/**\r\n * Clamps a number value\r\n * @internal\r\n */\r\nexport function clamp(v: number, min: number, max: number) {\r\n if (v != null) {\r\n if (min != null && v < min) {\r\n return min\r\n }\r\n if (max != null && v > max) {\r\n return max\r\n }\r\n }\r\n return v\r\n}\r\n/**\r\n * Builds a css class from various argument types\r\n * @param exp\r\n */\r\nexport function cssClass(\r\n exp: ArrayOrSingleOf<string | { [k: string]: boolean | (() => boolean) }>,\r\n): string {\r\n if (!exp) {\r\n return null\r\n }\r\n if (isString(exp)) {\r\n return exp\r\n }\r\n if (isArray(exp)) {\r\n return exp.map(cssClass).join(' ')\r\n }\r\n return Object.keys(exp)\r\n .filter((it) => resolve(exp[it]))\r\n .filter((it) => isString(it) && !!it)\r\n .join(' ')\r\n}\r\n\r\n/**\r\n * Pads a string\r\n * @internal\r\n */\r\nexport function padLeft(value: string, length: number, char: string) {\r\n while (value.length < length) {\r\n value = `${char}${value}`\r\n }\r\n return value\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function twuiClass(name: string, variation?: string) {\r\n return `twui-${name}` + (variation ? `-${variation}` : '')\r\n}\r\n\r\n/**\r\n * Gets current mouse coordinates from mouse or touch event\r\n * @internal\r\n */\r\nexport function getTouchPoint(e: MouseEvent | TouchEvent): [number, number] {\r\n let cx = 0\r\n let cy = 0\r\n if ('touches' in e) {\r\n cx = e.touches.item(0).pageX\r\n cy = e.touches.item(0).pageY\r\n } else {\r\n cx = e.pageX\r\n cy = e.pageY\r\n }\r\n return [cx, cy]\r\n}\r\n\r\nexport function getTouchInTarget(e: MouseEvent, target?: HTMLElement, offset?: [number, number]) {\r\n target = target || e.target as HTMLElement\r\n const rect = target.getBoundingClientRect()\r\n const tx = window.pageXOffset || document.documentElement.scrollLeft\r\n const ty = window.pageYOffset || document.documentElement.scrollTop\r\n\r\n const cw = target.clientWidth\r\n const ch = target.clientHeight\r\n let [cx, cy] = getTouchPoint(e)\r\n if (offset) {\r\n cx += offset[0]\r\n cy += offset[1]\r\n }\r\n const x = cx - tx - rect.left\r\n const y = cy - ty - rect.top\r\n return {\r\n width: cw,\r\n height: ch,\r\n x: x,\r\n y: y,\r\n normalizedX: x / cw,\r\n normalizedY: y / ch,\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function viewFn<T extends ComponentModel>(\r\n fn: (data: T, node: Vnode<ComponentAttrs<T>>) => Children,\r\n) {\r\n return (node: Vnode<ComponentAttrs<T>>): Children =>\r\n use(node.attrs.data, (data) => fn(data, node))\r\n}\r\n\r\nexport function dataFn<T extends ComponentModel, R>(\r\n node: Vnode<ComponentAttrs<T>>,\r\n fn: (data: T, node: Vnode<ComponentAttrs<T>>) => R,\r\n) {\r\n return () => fn(node.attrs.data, node)\r\n}\r\n\r\nexport function dragUtil({\r\n onStart,\r\n onMove,\r\n onEnd,\r\n}: {\r\n onStart?: (e: MouseEvent) => void\r\n onMove?: (e: MouseEvent) => void\r\n onEnd?: (e: MouseEvent) => void\r\n}) {\r\n const util = {\r\n target: null as HTMLElement,\r\n activate: (e: MouseEvent) => {\r\n util.deactivate()\r\n util.target = e.target as HTMLElement\r\n if (onStart) {\r\n onStart(e)\r\n }\r\n if (onMove) {\r\n document.addEventListener('mousemove', onMove, { passive: false })\r\n document.addEventListener('touchmove', onMove, { passive: false })\r\n }\r\n if (onEnd) {\r\n document.addEventListener('mouseup', onEnd)\r\n document.addEventListener('touchend', onEnd)\r\n document.addEventListener('touchcancel', onEnd)\r\n }\r\n },\r\n deactivate: () => {\r\n util.target = null\r\n if (onMove) {\r\n document.removeEventListener('mousemove', onMove)\r\n document.removeEventListener('touchmove', onMove)\r\n }\r\n if (onEnd) {\r\n document.removeEventListener('mouseup', onEnd)\r\n document.removeEventListener('touchend', onEnd)\r\n document.removeEventListener('touchcancel', onEnd)\r\n }\r\n },\r\n onStart,\r\n onMove,\r\n onEnd,\r\n }\r\n return util\r\n}\r\n"]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ValueSource } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Gets a value of a view model
|
|
4
|
-
*
|
|
5
|
-
* @public
|
|
6
|
-
* @param model - The model of a component
|
|
7
|
-
*/
|
|
8
|
-
export declare function getValue<V>(model: ValueSource<any, V>): V;
|
|
9
|
-
/**
|
|
10
|
-
* Sets a value on a view model
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
* @param model - The model of a component
|
|
14
|
-
* @param value - The value for the component
|
|
15
|
-
* @returns the encoded value as it was written to the model
|
|
16
|
-
*/
|
|
17
|
-
export declare function setValue<V>(model: ValueSource<any, V>, value: V): unknown;
|
|
18
|
-
//# sourceMappingURL=value-accessor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"value-accessor.d.ts","sourceRoot":"","sources":["../../../src/lib/core/value-accessor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG1C;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,CAEzD;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAIzE"}
|
|
@@ -1,52 +0,0 @@
|
|
|
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
|
|
@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1C,MAAM,IAAI,GAAG,MAAM,CAAC,wBAAwB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IACtD,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAA;AAC/C,CAAC;AAED,SAAS,MAAM,CAAI,MAA2B,EAAE,KAAQ;IACtD,OAAO,OAAO,IAAI,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;AAC/E,CAAC;AACD,SAAS,MAAM,CAAI,MAA2B,EAAE,KAAQ;IACtD,OAAO,OAAO,IAAI,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,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"]}
|