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.
Files changed (184) hide show
  1. package/LICENSE +7 -7
  2. package/README.md +32 -32
  3. package/dist/lib/builder.d.ts +166 -162
  4. package/dist/lib/builder.d.ts.map +1 -1
  5. package/dist/lib/builder.js +250 -0
  6. package/dist/lib/builder.js.map +1 -0
  7. package/dist/lib/color-formats/array-format.d.ts +8 -8
  8. package/dist/lib/color-formats/array-format.js +18 -0
  9. package/dist/lib/color-formats/array-format.js.map +1 -0
  10. package/dist/lib/color-formats/converter.d.ts +18 -18
  11. package/dist/lib/color-formats/converter.js +85 -0
  12. package/dist/lib/color-formats/converter.js.map +1 -0
  13. package/dist/lib/color-formats/css-string-format.d.ts +7 -7
  14. package/dist/lib/color-formats/css-string-format.js +28 -0
  15. package/dist/lib/color-formats/css-string-format.js.map +1 -0
  16. package/dist/lib/color-formats/formatter.d.ts +8 -8
  17. package/dist/lib/color-formats/formatter.js +35 -0
  18. package/dist/lib/color-formats/formatter.js.map +1 -0
  19. package/dist/lib/color-formats/hex-string-format.d.ts +7 -7
  20. package/dist/lib/color-formats/hex-string-format.js +28 -0
  21. package/dist/lib/color-formats/hex-string-format.js.map +1 -0
  22. package/dist/lib/color-formats/index.d.ts +3 -3
  23. package/dist/lib/color-formats/index.js +4 -0
  24. package/dist/lib/color-formats/index.js.map +1 -0
  25. package/dist/lib/color-formats/number-format.d.ts +8 -8
  26. package/dist/lib/color-formats/number-format.js +23 -0
  27. package/dist/lib/color-formats/number-format.js.map +1 -0
  28. package/dist/lib/color-formats/object-format.d.ts +14 -14
  29. package/dist/lib/color-formats/object-format.js +23 -0
  30. package/dist/lib/color-formats/object-format.js.map +1 -0
  31. package/dist/lib/color-formats/types.d.ts +101 -101
  32. package/dist/lib/color-formats/types.js +2 -0
  33. package/dist/lib/color-formats/types.js.map +1 -0
  34. package/dist/lib/components/button.d.ts +28 -28
  35. package/dist/lib/components/button.d.ts.map +1 -1
  36. package/dist/lib/components/button.js +15 -0
  37. package/dist/lib/components/button.js.map +1 -0
  38. package/dist/lib/components/content.d.ts +21 -21
  39. package/dist/lib/components/content.d.ts.map +1 -1
  40. package/dist/lib/components/content.js +10 -0
  41. package/dist/lib/components/content.js.map +1 -0
  42. package/dist/lib/components/controls/angle.d.ts +51 -51
  43. package/dist/lib/components/controls/angle.d.ts.map +1 -1
  44. package/dist/lib/components/controls/angle.js +201 -0
  45. package/dist/lib/components/controls/angle.js.map +1 -0
  46. package/dist/lib/components/controls/checkbox.d.ts +28 -28
  47. package/dist/lib/components/controls/checkbox.d.ts.map +1 -1
  48. package/dist/lib/components/controls/checkbox.js +31 -0
  49. package/dist/lib/components/controls/checkbox.js.map +1 -0
  50. package/dist/lib/components/controls/color-picker.d.ts +56 -56
  51. package/dist/lib/components/controls/color-picker.d.ts.map +1 -1
  52. package/dist/lib/components/controls/color-picker.js +267 -0
  53. package/dist/lib/components/controls/color-picker.js.map +1 -0
  54. package/dist/lib/components/controls/color.d.ts +51 -51
  55. package/dist/lib/components/controls/color.d.ts.map +1 -1
  56. package/dist/lib/components/controls/color.js +77 -0
  57. package/dist/lib/components/controls/color.js.map +1 -0
  58. package/dist/lib/components/controls/index.d.ts +10 -10
  59. package/dist/lib/components/controls/index.js +11 -0
  60. package/dist/lib/components/controls/index.js.map +1 -0
  61. package/dist/lib/components/controls/number.d.ts +47 -47
  62. package/dist/lib/components/controls/number.d.ts.map +1 -1
  63. package/dist/lib/components/controls/number.js +142 -0
  64. package/dist/lib/components/controls/number.js.map +1 -0
  65. package/dist/lib/components/controls/point.d.ts +47 -47
  66. package/dist/lib/components/controls/point.d.ts.map +1 -1
  67. package/dist/lib/components/controls/point.js +137 -0
  68. package/dist/lib/components/controls/point.js.map +1 -0
  69. package/dist/lib/components/controls/position.d.ts +55 -55
  70. package/dist/lib/components/controls/position.d.ts.map +1 -1
  71. package/dist/lib/components/controls/position.js +36 -0
  72. package/dist/lib/components/controls/position.js.map +1 -0
  73. package/dist/lib/components/controls/select.d.ts +59 -59
  74. package/dist/lib/components/controls/select.d.ts.map +1 -1
  75. package/dist/lib/components/controls/select.js +132 -0
  76. package/dist/lib/components/controls/select.js.map +1 -0
  77. package/dist/lib/components/controls/spherical.d.ts +74 -74
  78. package/dist/lib/components/controls/spherical.d.ts.map +1 -1
  79. package/dist/lib/components/controls/spherical.js +302 -0
  80. package/dist/lib/components/controls/spherical.js.map +1 -0
  81. package/dist/lib/components/controls/text.d.ts +35 -35
  82. package/dist/lib/components/controls/text.d.ts.map +1 -1
  83. package/dist/lib/components/controls/text.js +24 -0
  84. package/dist/lib/components/controls/text.js.map +1 -0
  85. package/dist/lib/components/groups/accordion.d.ts +21 -21
  86. package/dist/lib/components/groups/accordion.d.ts.map +1 -1
  87. package/dist/lib/components/groups/accordion.js +34 -0
  88. package/dist/lib/components/groups/accordion.js.map +1 -0
  89. package/dist/lib/components/groups/container.d.ts +24 -24
  90. package/dist/lib/components/groups/container.d.ts.map +1 -1
  91. package/dist/lib/components/groups/container.js +19 -0
  92. package/dist/lib/components/groups/container.js.map +1 -0
  93. package/dist/lib/components/groups/group.d.ts +48 -48
  94. package/dist/lib/components/groups/group.d.ts.map +1 -1
  95. package/dist/lib/components/groups/group.js +50 -0
  96. package/dist/lib/components/groups/group.js.map +1 -0
  97. package/dist/lib/components/groups/index.d.ts +4 -4
  98. package/dist/lib/components/groups/index.js +5 -0
  99. package/dist/lib/components/groups/index.js.map +1 -0
  100. package/dist/lib/components/groups/tabs.d.ts +21 -21
  101. package/dist/lib/components/groups/tabs.d.ts.map +1 -1
  102. package/dist/lib/components/groups/tabs.js +31 -0
  103. package/dist/lib/components/groups/tabs.js.map +1 -0
  104. package/dist/lib/components/image.d.ts +36 -36
  105. package/dist/lib/components/image.d.ts.map +1 -1
  106. package/dist/lib/components/image.js +46 -0
  107. package/dist/lib/components/image.js.map +1 -0
  108. package/dist/lib/components/index.d.ts +5 -5
  109. package/dist/lib/components/index.js +6 -0
  110. package/dist/lib/components/index.js.map +1 -0
  111. package/dist/lib/core/index.d.ts +4 -4
  112. package/dist/lib/core/index.js +5 -0
  113. package/dist/lib/core/index.js.map +1 -0
  114. package/dist/lib/core/registry.d.ts +17 -17
  115. package/dist/lib/core/registry.js +30 -0
  116. package/dist/lib/core/registry.js.map +1 -0
  117. package/dist/lib/core/render.d.ts +9 -9
  118. package/dist/lib/core/render.d.ts.map +1 -1
  119. package/dist/lib/core/render.js +19 -0
  120. package/dist/lib/core/render.js.map +1 -0
  121. package/dist/lib/core/types.d.ts +87 -87
  122. package/dist/lib/core/types.d.ts.map +1 -1
  123. package/dist/lib/core/types.js +2 -0
  124. package/dist/lib/core/types.js.map +1 -0
  125. package/dist/lib/core/utils.d.ts +93 -93
  126. package/dist/lib/core/utils.d.ts.map +1 -1
  127. package/dist/lib/core/utils.js +193 -0
  128. package/dist/lib/core/utils.js.map +1 -0
  129. package/dist/lib/core/value-accessor.d.ts +17 -17
  130. package/dist/lib/core/value-accessor.js +52 -0
  131. package/dist/lib/core/value-accessor.js.map +1 -0
  132. package/dist/lib/index.d.ts +21 -27
  133. package/dist/lib/index.d.ts.map +1 -1
  134. package/dist/lib/index.js +29 -0
  135. package/dist/lib/index.js.map +1 -0
  136. package/dist/lib/mount.d.ts +45 -45
  137. package/dist/lib/mount.js +85 -0
  138. package/dist/lib/mount.js.map +1 -0
  139. package/dist/tweak-ui.css +133 -138
  140. package/dist/tweak-ui.css.map +1 -1
  141. package/dist/tweak-ui.min.css +1 -1
  142. package/dist/tweak-ui.min.css.map +1 -1
  143. package/dist/tweak-ui.module.js +2733 -2380
  144. package/dist/tweak-ui.module.js.map +1 -1
  145. package/dist/tweak-ui.umd.js +1 -4403
  146. package/dist/tweak-ui.umd.js.map +1 -1
  147. package/package.json +25 -42
  148. package/dist/index.html +0 -1061
  149. package/dist/lib/color-formats/array-format.spec.d.ts +0 -2
  150. package/dist/lib/color-formats/array-format.spec.d.ts.map +0 -1
  151. package/dist/lib/color-formats/converter.spec.d.ts +0 -2
  152. package/dist/lib/color-formats/converter.spec.d.ts.map +0 -1
  153. package/dist/lib/color-formats/css-string-format.spec.d.ts +0 -2
  154. package/dist/lib/color-formats/css-string-format.spec.d.ts.map +0 -1
  155. package/dist/lib/color-formats/formatter.spec.d.ts +0 -2
  156. package/dist/lib/color-formats/formatter.spec.d.ts.map +0 -1
  157. package/dist/lib/color-formats/hex-string-format.spec.d.ts +0 -2
  158. package/dist/lib/color-formats/hex-string-format.spec.d.ts.map +0 -1
  159. package/dist/lib/color-formats/number-format.spec.d.ts +0 -2
  160. package/dist/lib/color-formats/number-format.spec.d.ts.map +0 -1
  161. package/dist/lib/color-formats/object-format.spec.d.ts +0 -2
  162. package/dist/lib/color-formats/object-format.spec.d.ts.map +0 -1
  163. package/dist/scss/_style.scss +0 -120
  164. package/dist/scss/_themes.scss +0 -23
  165. package/dist/scss/_utils.scss +0 -24
  166. package/dist/scss/_variables.scss +0 -30
  167. package/dist/scss/controls/_angle.scss +0 -64
  168. package/dist/scss/controls/_button.scss +0 -0
  169. package/dist/scss/controls/_checkbox.scss +0 -19
  170. package/dist/scss/controls/_color-picker.scss +0 -124
  171. package/dist/scss/controls/_color.scss +0 -14
  172. package/dist/scss/controls/_container.scss +0 -13
  173. package/dist/scss/controls/_group.scss +0 -69
  174. package/dist/scss/controls/_image.scss +0 -27
  175. package/dist/scss/controls/_number.scss +0 -38
  176. package/dist/scss/controls/_point.scss +0 -36
  177. package/dist/scss/controls/_position.scss +0 -9
  178. package/dist/scss/controls/_select.scss +0 -0
  179. package/dist/scss/controls/_spherical.scss +0 -87
  180. package/dist/scss/controls/_tabs.scss +0 -38
  181. package/dist/scss/controls/_text.scss +0 -0
  182. package/dist/scss/index.scss +0 -21
  183. package/dist/tweak-ui.umd.min.js +0 -17
  184. package/dist/tweak-ui.umd.min.js.map +0 -1
@@ -1,88 +1,88 @@
1
- import type { FactoryComponent, ClassComponent } from 'mithril';
2
- /**
3
- * @public
4
- */
5
- export declare type ComponentType<T = any> = FactoryComponent<T> | ClassComponent<T>;
6
- /**
7
- * Base model for a component with children
8
- *
9
- * @public
10
- */
11
- export interface ComponentGroupModel<T extends ComponentModel = ComponentModel> extends ComponentModel {
12
- /**
13
- * Collection of child components
14
- */
15
- children?: T[];
16
- }
17
- /**
18
- * Base model for a component
19
- *
20
- * @public
21
- */
22
- export interface ComponentModel {
23
- /**
24
- * The type name of the component
25
- */
26
- type: string;
27
- /**
28
- * If true, the component will not be rendered
29
- *
30
- * @remarks
31
- * This is a convenience property that allows to hide a component
32
- * without removing it from the component data model.
33
- */
34
- hidden?: boolean | (() => boolean);
35
- /**
36
- * The label for this component when rendered as a control
37
- *
38
- * @remarks
39
- * This is only evaluated when rendered as a child of a panel component
40
- */
41
- label?: string;
42
- }
43
- /**
44
- * Common component attributes
45
- *
46
- * @public
47
- */
48
- export declare type ComponentAttrs<T extends ComponentModel> = {
49
- data: T;
50
- };
51
- export declare type KeyMatchingType<T, V> = {
52
- [K in keyof T]: T[K] extends V ? K : never;
53
- }[keyof T];
54
- /**
55
- * Utility to convert a value type
56
- *
57
- * @public
58
- */
59
- export declare type ValueCodec<Encoded, Decoded> = {
60
- decode: (value: Encoded) => Decoded;
61
- encode: (value: Decoded) => Encoded;
62
- };
63
- export declare type ValueSource<T, V, I = unknown> = {
64
- /**
65
- * The object which is holding a control value
66
- *
67
- * @remarks
68
- * Requires the `property` option to be set.
69
- */
70
- target?: T;
71
- /**
72
- * The property name in `target` where the control value is stored
73
- *
74
- * @remarks
75
- * Requires the `target` option to be set.
76
- */
77
- property?: keyof T;
78
- /**
79
- * If `target` and `property` are not set, then this is used as the control value
80
- */
81
- value?: V | I;
82
- codec?: ValueCodec<I, V>;
83
- };
84
- /**
85
- * @public
86
- */
87
- export declare type ArrayOrSingleOf<T> = T | T[];
1
+ import type { FactoryComponent, ClassComponent } from 'mithril';
2
+ /**
3
+ * @public
4
+ */
5
+ export type ComponentType<T = any> = FactoryComponent<T> | ClassComponent<T>;
6
+ /**
7
+ * Base model for a component with children
8
+ *
9
+ * @public
10
+ */
11
+ export interface ComponentGroupModel<T extends ComponentModel = ComponentModel> extends ComponentModel {
12
+ /**
13
+ * Collection of child components
14
+ */
15
+ children?: T[];
16
+ }
17
+ /**
18
+ * Base model for a component
19
+ *
20
+ * @public
21
+ */
22
+ export interface ComponentModel {
23
+ /**
24
+ * The type name of the component
25
+ */
26
+ type: string;
27
+ /**
28
+ * If true, the component will not be rendered
29
+ *
30
+ * @remarks
31
+ * This is a convenience property that allows to hide a component
32
+ * without removing it from the component data model.
33
+ */
34
+ hidden?: boolean | (() => boolean);
35
+ /**
36
+ * The label for this component when rendered as a control
37
+ *
38
+ * @remarks
39
+ * This is only evaluated when rendered as a child of a panel component
40
+ */
41
+ label?: string;
42
+ }
43
+ /**
44
+ * Common component attributes
45
+ *
46
+ * @public
47
+ */
48
+ export type ComponentAttrs<T extends ComponentModel> = {
49
+ data: T;
50
+ };
51
+ export type KeyMatchingType<T, V> = {
52
+ [K in keyof T]: T[K] extends V ? K : never;
53
+ }[keyof T];
54
+ /**
55
+ * Utility to convert a value type
56
+ *
57
+ * @public
58
+ */
59
+ export type ValueCodec<Encoded, Decoded> = {
60
+ decode: (value: Encoded) => Decoded;
61
+ encode: (value: Decoded) => Encoded;
62
+ };
63
+ export type ValueSource<T, V, I = unknown> = {
64
+ /**
65
+ * The object which is holding a control value
66
+ *
67
+ * @remarks
68
+ * Requires the `property` option to be set.
69
+ */
70
+ target?: T;
71
+ /**
72
+ * The property name in `target` where the control value is stored
73
+ *
74
+ * @remarks
75
+ * Requires the `target` option to be set.
76
+ */
77
+ property?: keyof T;
78
+ /**
79
+ * If `target` and `property` are not set, then this is used as the control value
80
+ */
81
+ value?: V | I;
82
+ codec?: ValueCodec<I, V>;
83
+ };
84
+ /**
85
+ * @public
86
+ */
87
+ export type ArrayOrSingleOf<T> = T | T[];
88
88
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 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CAAC,CAAA;AAE3F;;;;GAIG;AACH,MAAM,MAAM,UAAU,CAAC,OAAO,EAAE,OAAO,IAAI;IACzC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAA;IACnC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAA;CACpC,CAAA;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,IAAI;IAC3C;;;;;OAKG;IACH,MAAM,CAAC,EAAE,CAAC,CAAA;IACV;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAA;IAClB;;OAEG;IACH,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;IACb,KAAK,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAC1B,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
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"]}
@@ -1,94 +1,94 @@
1
- import type { ArrayOrSingleOf, ComponentAttrs, ComponentModel } from './types';
2
- import type { Children, Vnode } from 'mithril';
3
- /**
4
- * Checks if value is a string
5
- * @internal
6
- */
7
- export declare function isString(v: any): v is string;
8
- /**
9
- * Checks if value is a number
10
- * @internal
11
- */
12
- export declare function isNumber(v: any): v is number;
13
- /**
14
- * Checks if value is a function
15
- * @internal
16
- */
17
- export declare function isFunction(v: any): v is (...args: any[]) => any;
18
- /**
19
- * Checks if value is an array
20
- * @internal
21
- */
22
- export declare function isArray(v: any): v is any[];
23
- /**
24
- * Checks if value is an object
25
- * @internal
26
- */
27
- export declare function isObject(v: any): v is object;
28
- /**
29
- * Calls a function if it is not null
30
- * @internal
31
- */
32
- export declare function call<T extends (...args: any) => any>(cb: T, ...args: Parameters<T>): any;
33
- /**
34
- * Resolves a property to its value
35
- * @param value - the function or value to resolve
36
- */
37
- export declare function resolve<T>(value: (() => T) | T): T;
38
- /**
39
- * Calls the callback of object is not null
40
- * @internal
41
- */
42
- export declare function use<T, R>(obj: T | null, cb: (it: T) => R): R | null;
43
- /**
44
- * Clamps a number value
45
- * @internal
46
- */
47
- export declare function clamp(v: number, min: number, max: number): number;
48
- /**
49
- * Builds a css class from various argument types
50
- * @param exp
51
- */
52
- export declare function cssClass(exp: ArrayOrSingleOf<string | {
53
- [k: string]: boolean | (() => boolean);
54
- }>): string;
55
- /**
56
- * Pads a string
57
- * @internal
58
- */
59
- export declare function padLeft(value: string, length: number, char: string): string;
60
- /**
61
- * @internal
62
- */
63
- export declare function twuiClass(name: string, variation?: string): string;
64
- /**
65
- * Gets current mouse coordinates from mouse or touch event
66
- * @internal
67
- */
68
- export declare function getMouseXY(e: MouseEvent | TouchEvent): number[];
69
- export declare function getTouchPosition(target: HTMLElement, e: MouseEvent): {
70
- width: number;
71
- height: number;
72
- x: number;
73
- y: number;
74
- normalizedX: number;
75
- normalizedY: number;
76
- };
77
- /**
78
- * @internal
79
- */
80
- export declare function viewFn<T extends ComponentModel>(fn: (data: T, node: Vnode<ComponentAttrs<T>>) => Children): (node: Vnode<ComponentAttrs<T>>) => Children;
81
- export declare function dataFn<T extends ComponentModel, R>(node: Vnode<ComponentAttrs<T>>, fn: (data: T, node: Vnode<ComponentAttrs<T>>) => R): () => R;
82
- export declare function dragUtil({ onStart, onMove, onEnd, }: {
83
- onStart?: (e: MouseEvent) => void;
84
- onMove?: (e: MouseEvent) => void;
85
- onEnd?: (e: MouseEvent) => void;
86
- }): {
87
- target: HTMLElement;
88
- activate: (e: MouseEvent) => void;
89
- deactivate: () => void;
90
- onStart: (e: MouseEvent) => void;
91
- onMove: (e: MouseEvent) => void;
92
- onEnd: (e: MouseEvent) => void;
93
- };
1
+ import type { ArrayOrSingleOf, ComponentAttrs, ComponentModel } from './types';
2
+ import type { Children, Vnode } from 'mithril';
3
+ /**
4
+ * Checks if value is a string
5
+ * @internal
6
+ */
7
+ export declare function isString(v: any): v is string;
8
+ /**
9
+ * Checks if value is a number
10
+ * @internal
11
+ */
12
+ export declare function isNumber(v: any): v is number;
13
+ /**
14
+ * Checks if value is a function
15
+ * @internal
16
+ */
17
+ export declare function isFunction(v: any): v is (...args: any[]) => any;
18
+ /**
19
+ * Checks if value is an array
20
+ * @internal
21
+ */
22
+ export declare function isArray(v: any): v is any[];
23
+ /**
24
+ * Checks if value is an object
25
+ * @internal
26
+ */
27
+ export declare function isObject(v: any): v is object;
28
+ /**
29
+ * Calls a function if it is not null
30
+ * @internal
31
+ */
32
+ export declare function call<T extends (...args: any) => any>(cb: T, ...args: Parameters<T>): any;
33
+ /**
34
+ * Resolves a property to its value
35
+ * @param value - the function or value to resolve
36
+ */
37
+ export declare function resolve<T>(value: (() => T) | T): T;
38
+ /**
39
+ * Calls the callback of object is not null
40
+ * @internal
41
+ */
42
+ export declare function use<T, R>(obj: T | null, cb: (it: T) => R): R | null;
43
+ /**
44
+ * Clamps a number value
45
+ * @internal
46
+ */
47
+ export declare function clamp(v: number, min: number, max: number): number;
48
+ /**
49
+ * Builds a css class from various argument types
50
+ * @param exp
51
+ */
52
+ export declare function cssClass(exp: ArrayOrSingleOf<string | {
53
+ [k: string]: boolean | (() => boolean);
54
+ }>): string;
55
+ /**
56
+ * Pads a string
57
+ * @internal
58
+ */
59
+ export declare function padLeft(value: string, length: number, char: string): string;
60
+ /**
61
+ * @internal
62
+ */
63
+ export declare function twuiClass(name: string, variation?: string): string;
64
+ /**
65
+ * Gets current mouse coordinates from mouse or touch event
66
+ * @internal
67
+ */
68
+ export declare function getTouchPoint(e: MouseEvent | TouchEvent): [number, number];
69
+ export declare function getTouchInTarget(e: MouseEvent, target?: HTMLElement, offset?: [number, number]): {
70
+ width: number;
71
+ height: number;
72
+ x: number;
73
+ y: number;
74
+ normalizedX: number;
75
+ normalizedY: number;
76
+ };
77
+ /**
78
+ * @internal
79
+ */
80
+ export declare function viewFn<T extends ComponentModel>(fn: (data: T, node: Vnode<ComponentAttrs<T>>) => Children): (node: Vnode<ComponentAttrs<T>>) => Children;
81
+ export declare function dataFn<T extends ComponentModel, R>(node: Vnode<ComponentAttrs<T>>, fn: (data: T, node: Vnode<ComponentAttrs<T>>) => R): () => R;
82
+ export declare function dragUtil({ onStart, onMove, onEnd, }: {
83
+ onStart?: (e: MouseEvent) => void;
84
+ onMove?: (e: MouseEvent) => void;
85
+ onEnd?: (e: MouseEvent) => void;
86
+ }): {
87
+ target: HTMLElement;
88
+ activate: (e: MouseEvent) => void;
89
+ deactivate: () => void;
90
+ onStart: (e: MouseEvent) => void;
91
+ onMove: (e: MouseEvent) => void;
92
+ onEnd: (e: MouseEvent) => void;
93
+ };
94
94
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/core/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAC9E,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE9C;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,MAAM,CAE5C;AACD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,MAAM,CAE5C;AACD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAE/D;AACD;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,GAAG,EAAE,CAE1C;AACD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC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ks 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
@@ -0,0 +1 @@
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;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,CAAM;IAC/B,OAAO,OAAO,CAAC,KAAK,UAAU,CAAA;AAChC,CAAC;AACD;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,CAAM;IAC5B,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AACzB,CAAC;AACD;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,CAAM;IAC7B,OAAO,CAAC,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AAC1D,CAAC;AACD;;;GAGG;AACH,MAAM,UAAU,IAAI,CAAkC,EAAK,EAAE,GAAG,IAAmB;IACjF,OAAO,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAC5C,CAAC;AACD;;;GAGG;AACH,MAAM,UAAU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,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 +1,18 @@
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;
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
18
  //# sourceMappingURL=value-accessor.d.ts.map