tweak-ui 0.4.2 → 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 -2380
- package/dist/tweak-ui.module.js.map +1 -1
- package/dist/tweak-ui.umd.js +1 -4403
- package/dist/tweak-ui.umd.js.map +1 -1
- package/package.json +25 -42
- package/dist/index.html +0 -1061
- 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
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { ComponentGroupModel, ComponentAttrs, ComponentModel } from '../../core';
|
|
2
|
-
/**
|
|
3
|
-
* Group component attributes
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export
|
|
7
|
-
/**
|
|
8
|
-
* Group component model
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
export interface GroupModel extends ComponentGroupModel<ComponentModel> {
|
|
12
|
-
/**
|
|
13
|
-
* Component type name
|
|
14
|
-
*/
|
|
15
|
-
type: 'group';
|
|
16
|
-
/**
|
|
17
|
-
* Group title
|
|
18
|
-
*/
|
|
19
|
-
title?: string;
|
|
20
|
-
/**
|
|
21
|
-
* Group CSS Style
|
|
22
|
-
*/
|
|
23
|
-
style?: Partial<CSSStyleDeclaration>;
|
|
24
|
-
/**
|
|
25
|
-
* Whether the child elements can be collapsed
|
|
26
|
-
*/
|
|
27
|
-
collapsible?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Whether the child elements are collapsed
|
|
30
|
-
*/
|
|
31
|
-
collapsed?: boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Adds an offset to the left side
|
|
34
|
-
*/
|
|
35
|
-
inset?: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Is called when this Group has been collapsed or expanded
|
|
38
|
-
*/
|
|
39
|
-
onToggle?: (group: GroupModel) => void;
|
|
40
|
-
/**
|
|
41
|
-
* Is called when this Group has been expanded
|
|
42
|
-
*/
|
|
43
|
-
onExpand?: (group: GroupModel) => void;
|
|
44
|
-
/**
|
|
45
|
-
* Is called when this Group has been collapsed
|
|
46
|
-
*/
|
|
47
|
-
onCollapse?: (group: GroupModel) => void;
|
|
48
|
-
}
|
|
1
|
+
import { ComponentGroupModel, ComponentAttrs, ComponentModel } from '../../core';
|
|
2
|
+
/**
|
|
3
|
+
* Group component attributes
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export type GroupAttrs = ComponentAttrs<GroupModel>;
|
|
7
|
+
/**
|
|
8
|
+
* Group component model
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export interface GroupModel extends ComponentGroupModel<ComponentModel> {
|
|
12
|
+
/**
|
|
13
|
+
* Component type name
|
|
14
|
+
*/
|
|
15
|
+
type: 'group';
|
|
16
|
+
/**
|
|
17
|
+
* Group title
|
|
18
|
+
*/
|
|
19
|
+
title?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Group CSS Style
|
|
22
|
+
*/
|
|
23
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the child elements can be collapsed
|
|
26
|
+
*/
|
|
27
|
+
collapsible?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the child elements are collapsed
|
|
30
|
+
*/
|
|
31
|
+
collapsed?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Adds an offset to the left side
|
|
34
|
+
*/
|
|
35
|
+
inset?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Is called when this Group has been collapsed or expanded
|
|
38
|
+
*/
|
|
39
|
+
onToggle?: (group: GroupModel) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Is called when this Group has been expanded
|
|
42
|
+
*/
|
|
43
|
+
onExpand?: (group: GroupModel) => void;
|
|
44
|
+
/**
|
|
45
|
+
* Is called when this Group has been collapsed
|
|
46
|
+
*/
|
|
47
|
+
onCollapse?: (group: GroupModel) => void;
|
|
48
|
+
}
|
|
49
49
|
//# sourceMappingURL=group.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/groups/group.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,mBAAmB,EACnB,cAAc,EACd,cAAc,EACf,MAAM,YAAY,CAAA;AAGnB;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/groups/group.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,mBAAmB,EACnB,cAAc,EACd,cAAc,EACf,MAAM,YAAY,CAAA;AAGnB;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,CAAA;AAEnD;;;GAGG;AACH,MAAM,WAAW,UAAW,SAAQ,mBAAmB,CAAC,cAAc,CAAC;IACrE;;OAEG;IACH,IAAI,EAAE,OAAO,CAAA;IACb;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAA;IACpC;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;IACtC;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;IACtC;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;CACzC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import m from 'mithril';
|
|
2
|
+
import { component, renderModel, } from '../../core';
|
|
3
|
+
import { twuiClass, viewFn, isString, use, call, cssClass } from '../../core/utils';
|
|
4
|
+
const TYPE = 'group';
|
|
5
|
+
component(TYPE, (node) => {
|
|
6
|
+
function onClick(e) {
|
|
7
|
+
use(node.attrs.data, (data) => {
|
|
8
|
+
data.collapsed = !data.collapsed;
|
|
9
|
+
call(data.onToggle, data);
|
|
10
|
+
if (data.collapsed) {
|
|
11
|
+
call(data.onCollapse, data);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
call(data.onExpand, data);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function title(data) {
|
|
19
|
+
if (!data.title && !data.collapsible) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return m('div', {
|
|
23
|
+
class: twuiClass(TYPE, 'title'),
|
|
24
|
+
onclick: data.collapsible ? onClick : null,
|
|
25
|
+
}, data.title);
|
|
26
|
+
}
|
|
27
|
+
function children(data) {
|
|
28
|
+
var _a;
|
|
29
|
+
if (data.collapsed || !data.children) {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
return (_a = data.children) === null || _a === void 0 ? void 0 : _a.map((it) => {
|
|
33
|
+
if (isString(it.label)) {
|
|
34
|
+
return m('div', { class: twuiClass(TYPE, 'control') }, m('label', it.label), m('section', renderModel(it)));
|
|
35
|
+
}
|
|
36
|
+
return renderModel(it);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
view: viewFn((data) => m('div', {
|
|
41
|
+
class: cssClass({
|
|
42
|
+
[twuiClass(TYPE)]: true,
|
|
43
|
+
[twuiClass(TYPE, 'collapsible')]: data.collapsible,
|
|
44
|
+
[twuiClass(TYPE, 'collapsed')]: data.collapsed,
|
|
45
|
+
}),
|
|
46
|
+
style: data.style,
|
|
47
|
+
}, m.fragment({}, [title(data)]), m.fragment({}, [children(data)]))),
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;SAC3C,EACD,IAAI,CAAC,KAAK,CACX,CAAA;IACH,CAAC;IACD,SAAS,QAAQ,CAAC,IAAgB;;QAChC,IAAI,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACrC,OAAO,EAAE,CAAA;QACX,CAAC;QACD,OAAO,MAAA,IAAI,CAAC,QAAQ,0CAAE,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;YAC/B,IAAI,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;gBACvB,OAAO,CAAC,CACN,KAAK,EACL,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,EACrC,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,CAAC,EACpB,CAAC,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC,CAC9B,CAAA;YACH,CAAC;YACD,OAAO,WAAW,CAAC,EAAE,CAAC,CAAA;QACxB,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CACpB,CAAC,CACC,KAAK,EACL;YACE,KAAK,EAAE,QAAQ,CAAC;gBACd,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI;gBACvB,CAAC,SAAS,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,WAAW;gBAClD,CAAC,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS;aAC/C,CAAC;YACF,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,EACD,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAC7B,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,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,5 +1,5 @@
|
|
|
1
|
-
export * from './accordion';
|
|
2
|
-
export * from './container';
|
|
3
|
-
export * from './group';
|
|
4
|
-
export * from './tabs';
|
|
1
|
+
export * from './accordion';
|
|
2
|
+
export * from './container';
|
|
3
|
+
export * from './group';
|
|
4
|
+
export * from './tabs';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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 +1,22 @@
|
|
|
1
|
-
import { ComponentAttrs, ComponentGroupModel } from '../../core';
|
|
2
|
-
import { GroupModel } from './group';
|
|
3
|
-
/**
|
|
4
|
-
* Tabs component attributes
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
export
|
|
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
|
-
}
|
|
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
22
|
//# sourceMappingURL=tabs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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"}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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 +1,37 @@
|
|
|
1
|
-
import { ComponentModel, ComponentAttrs } from '../core';
|
|
2
|
-
/**
|
|
3
|
-
* Image component attrs
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export
|
|
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
|
-
}
|
|
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
37
|
//# sourceMappingURL=image.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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;YACV,OAAO,IAAI,CAAA;QACb,CAAC;QACD,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QACrD,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,CAAA;QACpC,OAAO,GAAG,OAAO,GAAG,CAAA;IACtB,CAAC;IACD,SAAS,KAAK,CAAC,IAAgB;QAC7B,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,GAAG,IAAI,CAAC,KAAK,IAAI,CAAA;QAC1B,CAAC;QACD,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC,KAAK,CAAA;QACnB,CAAC;IACH,CAAC;IACD,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;YACpB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;gBACnE,OAAO,CAAC,CACN,SAAS,EACT;oBACE,KAAK,EAAE,QAAQ,CAAC;wBACd,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI;wBACvB,CAAC,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM;qBAC3C,CAAC;oBACF,KAAK,EAAE;wBACL,eAAe,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;wBACpC,YAAY,EAAE,IAAI,CAAC,GAAG,IAAI,KAAK;wBAC/B,KAAK,EAAE,KAAK,CAAC,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,6 +1,6 @@
|
|
|
1
|
-
export * from './controls';
|
|
2
|
-
export * from './groups';
|
|
3
|
-
export * from './button';
|
|
4
|
-
export * from './content';
|
|
5
|
-
export * from './image';
|
|
1
|
+
export * from './controls';
|
|
2
|
+
export * from './groups';
|
|
3
|
+
export * from './button';
|
|
4
|
+
export * from './content';
|
|
5
|
+
export * from './image';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './registry';
|
|
2
|
-
export * from './render';
|
|
3
|
-
export * from './value-accessor';
|
|
4
|
-
export * from './types';
|
|
1
|
+
export * from './registry';
|
|
2
|
+
export * from './render';
|
|
3
|
+
export * from './value-accessor';
|
|
4
|
+
export * from './types';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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 +1,18 @@
|
|
|
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;
|
|
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
18
|
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ComponentModel } from './types';
|
|
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 declare function renderModel<T extends ComponentModel>(model: T): m.Vnode<import("./types").ComponentAttrs<any>,
|
|
1
|
+
import type { ComponentModel } from './types';
|
|
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 declare function renderModel<T extends ComponentModel>(model: T): m.Vnode<import("./types").ComponentAttrs<any>, unknown>;
|
|
10
10
|
//# sourceMappingURL=render.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/lib/core/render.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,EAAE,OAAO,IAAI,CAAC,EAAE,MAAM,SAAS,CAAA;AAEtC;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,cAAc,EAAE,KAAK,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/lib/core/render.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,EAAE,OAAO,IAAI,CAAC,EAAE,MAAM,SAAS,CAAA;AAEtC;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,cAAc,EAAE,KAAK,EAAE,CAAC,2DAS7D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|