cx 26.1.13 → 26.2.1

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 (130) hide show
  1. package/build/charts/Marker.d.ts +1 -1
  2. package/build/charts/Marker.d.ts.map +1 -1
  3. package/build/charts/Marker.js +16 -6
  4. package/build/charts/MouseTracker.d.ts +2 -0
  5. package/build/charts/MouseTracker.d.ts.map +1 -1
  6. package/build/charts/helpers/PointReducer.d.ts +2 -2
  7. package/build/charts/helpers/PointReducer.d.ts.map +1 -1
  8. package/build/data/View.d.ts +5 -3
  9. package/build/data/View.d.ts.map +1 -1
  10. package/build/data/View.js +3 -1
  11. package/build/data/ops/findTreeNode.d.ts +20 -1
  12. package/build/data/ops/findTreeNode.d.ts.map +1 -1
  13. package/build/data/ops/findTreeNode.js +19 -0
  14. package/build/data/ops/findTreePath.d.ts +1 -1
  15. package/build/data/ops/findTreePath.d.ts.map +1 -1
  16. package/build/data/ops/findTreePath.js +1 -1
  17. package/build/data/ops/removeTreeNodes.d.ts +14 -1
  18. package/build/data/ops/removeTreeNodes.d.ts.map +1 -1
  19. package/build/data/ops/removeTreeNodes.js +13 -0
  20. package/build/data/ops/updateArray.d.ts +1 -1
  21. package/build/data/ops/updateArray.d.ts.map +1 -1
  22. package/build/data/ops/updateArray.js +1 -1
  23. package/build/data/ops/updateTree.d.ts +20 -1
  24. package/build/data/ops/updateTree.d.ts.map +1 -1
  25. package/build/data/ops/updateTree.js +19 -0
  26. package/build/jsx-runtime.d.ts +1 -0
  27. package/build/jsx-runtime.d.ts.map +1 -1
  28. package/build/jsx-runtime.js +3 -1
  29. package/build/svg/Rectangle.d.ts +6 -4
  30. package/build/svg/Rectangle.d.ts.map +1 -1
  31. package/build/svg/Rectangle.js +9 -7
  32. package/build/ui/Instance.d.ts +1 -1
  33. package/build/ui/Instance.d.ts.map +1 -1
  34. package/build/ui/Instance.js +18 -8
  35. package/build/ui/IsolatedScope.d.ts +2 -1
  36. package/build/ui/IsolatedScope.d.ts.map +1 -1
  37. package/build/ui/Prop.d.ts +1 -1
  38. package/build/ui/Prop.d.ts.map +1 -1
  39. package/build/ui/Widget.d.ts +2 -0
  40. package/build/ui/Widget.d.ts.map +1 -1
  41. package/build/ui/Widget.js +4 -0
  42. package/build/ui/adapter/GroupAdapter.d.ts +4 -4
  43. package/build/ui/adapter/GroupAdapter.d.ts.map +1 -1
  44. package/build/ui/adapter/GroupAdapter.js +4 -4
  45. package/build/ui/adapter/TreeAdapter.d.ts +5 -3
  46. package/build/ui/adapter/TreeAdapter.d.ts.map +1 -1
  47. package/build/ui/adapter/TreeAdapter.js +12 -5
  48. package/build/ui/app/startAppLoop.d.ts +2 -2
  49. package/build/ui/app/startAppLoop.d.ts.map +1 -1
  50. package/build/ui/app/startHotAppLoop.d.ts +4 -4
  51. package/build/ui/app/startHotAppLoop.d.ts.map +1 -1
  52. package/build/ui/app/startHotAppLoop.js +1 -1
  53. package/build/ui/batchUpdates.d.ts.map +1 -1
  54. package/build/ui/batchUpdates.js +3 -4
  55. package/build/widgets/Button.d.ts +0 -7
  56. package/build/widgets/Button.d.ts.map +1 -1
  57. package/build/widgets/HtmlElement.d.ts +2 -2
  58. package/build/widgets/HtmlElement.d.ts.map +1 -1
  59. package/build/widgets/form/Checkbox.d.ts +3 -3
  60. package/build/widgets/form/Checkbox.d.ts.map +1 -1
  61. package/build/widgets/form/Checkbox.js +11 -6
  62. package/build/widgets/form/DateTimeField.d.ts +4 -0
  63. package/build/widgets/form/DateTimeField.d.ts.map +1 -1
  64. package/build/widgets/form/LookupField.d.ts +14 -27
  65. package/build/widgets/form/LookupField.d.ts.map +1 -1
  66. package/build/widgets/form/TextField.d.ts +2 -2
  67. package/build/widgets/form/TextField.d.ts.map +1 -1
  68. package/build/widgets/grid/Grid.d.ts +20 -16
  69. package/build/widgets/grid/Grid.d.ts.map +1 -1
  70. package/build/widgets/grid/Grid.js +200 -86
  71. package/build/widgets/nav/Menu.d.ts +2 -0
  72. package/build/widgets/nav/Menu.d.ts.map +1 -1
  73. package/build/widgets/nav/Route.js +1 -1
  74. package/build/widgets/overlay/FlyweightTooltipTracker.d.ts +6 -4
  75. package/build/widgets/overlay/FlyweightTooltipTracker.d.ts.map +1 -1
  76. package/build/widgets/overlay/FlyweightTooltipTracker.js +3 -0
  77. package/build/widgets/overlay/Overlay.d.ts +2 -2
  78. package/build/widgets/overlay/Overlay.d.ts.map +1 -1
  79. package/dist/data.js +52 -1
  80. package/dist/jsx-runtime.js +4 -2
  81. package/dist/manifest.js +879 -873
  82. package/dist/svg.js +3 -0
  83. package/dist/ui.js +1548 -1544
  84. package/dist/widgets.css +1 -1
  85. package/dist/widgets.js +395 -4
  86. package/package.json +2 -2
  87. package/src/charts/Marker.tsx +448 -394
  88. package/src/charts/MouseTracker.tsx +3 -0
  89. package/src/charts/helpers/PointReducer.ts +2 -2
  90. package/src/data/View.ts +76 -19
  91. package/src/data/ops/findTreeNode.ts +20 -1
  92. package/src/data/ops/findTreePath.ts +7 -2
  93. package/src/data/ops/removeTreeNodes.ts +14 -1
  94. package/src/data/ops/updateArray.ts +4 -4
  95. package/src/data/ops/updateTree.ts +32 -6
  96. package/src/index.scss +6 -6
  97. package/src/jsx-runtime.spec.tsx +40 -0
  98. package/src/jsx-runtime.ts +87 -84
  99. package/src/svg/Rectangle.tsx +80 -73
  100. package/src/ui/DataProxy.ts +55 -55
  101. package/src/ui/Instance.ts +142 -45
  102. package/src/ui/IsolatedScope.ts +4 -2
  103. package/src/ui/Prop.ts +141 -141
  104. package/src/ui/Rescope.ts +50 -50
  105. package/src/ui/Widget.tsx +292 -234
  106. package/src/ui/adapter/ArrayAdapter.ts +229 -229
  107. package/src/ui/adapter/GroupAdapter.ts +8 -10
  108. package/src/ui/adapter/TreeAdapter.ts +75 -15
  109. package/src/ui/app/Url.spec.ts +1 -1
  110. package/src/ui/app/startAppLoop.tsx +56 -45
  111. package/src/ui/app/startHotAppLoop.ts +4 -4
  112. package/src/ui/batchUpdates.ts +16 -21
  113. package/src/ui/exprHelpers.ts +96 -96
  114. package/src/widgets/Button.tsx +0 -8
  115. package/src/widgets/HtmlElement.spec.tsx +100 -72
  116. package/src/widgets/HtmlElement.tsx +11 -10
  117. package/src/widgets/Sandbox.ts +104 -104
  118. package/src/widgets/Section.scss +55 -55
  119. package/src/widgets/drag-drop/DropZone.scss +74 -74
  120. package/src/widgets/form/Checkbox.tsx +296 -243
  121. package/src/widgets/form/DateTimeField.tsx +6 -0
  122. package/src/widgets/form/LookupField.tsx +70 -73
  123. package/src/widgets/form/TextField.tsx +2 -2
  124. package/src/widgets/grid/Grid.scss +43 -10
  125. package/src/widgets/grid/Grid.tsx +4401 -3848
  126. package/src/widgets/nav/Menu.tsx +3 -0
  127. package/src/widgets/nav/Route.ts +1 -1
  128. package/src/widgets/overlay/FlyweightTooltipTracker.ts +15 -4
  129. package/src/widgets/overlay/Overlay.tsx +2 -1
  130. package/src/widgets/overlay/index.d.ts +11 -11
package/src/ui/Widget.tsx CHANGED
@@ -8,11 +8,16 @@ import { parseStyle } from "../util/parseStyle";
8
8
  import { CSS } from "./CSS";
9
9
  import { CSSHelper } from "./CSSHelper";
10
10
  import { RenderingContext } from "./RenderingContext";
11
- import type { Controller, ControllerConfig, ControllerFactory } from "./Controller";
11
+ import type {
12
+ Controller,
13
+ ControllerConfig,
14
+ ControllerFactory,
15
+ } from "./Controller";
12
16
 
13
17
  import { BooleanProp, ClassProp, ModProp, StyleProp } from "./Prop";
14
18
  import { Instance } from "./Instance";
15
19
  import { VDOM as vdom } from "./VDOM";
20
+ import { View } from "../data/View";
16
21
 
17
22
  export const VDOM = vdom;
18
23
 
@@ -21,247 +26,295 @@ let widgetId = 100;
21
26
  // Controller property accepts: class, config object with type/$type, inline config, or factory function
22
27
  // ControllerConfig is intersected with { type?: never; $type?: never } to ensure objects with type/$type match CreateConfig
23
28
  export type ControllerProp =
24
- | CreateConfig<typeof Controller>
25
- | (ControllerConfig & { type?: never; $type?: never })
26
- | ControllerFactory;
29
+ | CreateConfig<typeof Controller>
30
+ | (ControllerConfig & { type?: never; $type?: never })
31
+ | ControllerFactory;
27
32
 
28
33
  export interface WidgetConfig {
29
- /** Visibility of the widget. Defaults to `true`. */
30
- visible?: BooleanProp;
34
+ /** Visibility of the widget. Defaults to `true`. */
35
+ visible?: BooleanProp;
31
36
 
32
- /** Visibility of the widget. Defaults to `true`. */
33
- if?: BooleanProp;
37
+ /** Visibility of the widget. Defaults to `true`. */
38
+ if?: BooleanProp;
34
39
 
35
- /** Outer (wrapper) layout used to display the widget in. */
36
- outerLayout?: unknown;
40
+ /** Outer (wrapper) layout used to display the widget in. */
41
+ outerLayout?: unknown;
37
42
 
38
- /** Inner layout used to display children inside the widget. */
39
- layout?: unknown;
43
+ /** Inner layout used to display children inside the widget. */
44
+ layout?: unknown;
40
45
 
41
- /** Name of the ContentPlaceholder that should be used to display the widget. */
42
- contentFor?: string;
46
+ /** Name of the ContentPlaceholder that should be used to display the widget. */
47
+ contentFor?: string;
43
48
 
44
- /** Name of the ContentPlaceholder that should be used to display the widget. */
45
- putInto?: string;
49
+ /** Name of the ContentPlaceholder that should be used to display the widget. */
50
+ putInto?: string;
46
51
 
47
- /** Key that will be used as the key when rendering the React component. */
48
- vdomKey?: string;
52
+ /** Key that will be used as the key when rendering the React component. */
53
+ vdomKey?: string;
49
54
 
50
- /** Controller. */
51
- controller?: ControllerProp;
55
+ /** Controller. */
56
+ controller?: ControllerProp;
52
57
 
53
- onInit?(context: RenderingContext): void;
54
- onExplore?(context: RenderingContext, instance: Instance): void;
55
- onPrepare?(context: RenderingContext, instance: Instance): void;
56
- onCleanup?(context: RenderingContext, instance: Instance): void;
57
- onDestroy?(instance: Instance): void;
58
+ onInit?(context: RenderingContext): void;
59
+ onExplore?(context: RenderingContext, instance: Instance): void;
60
+ onPrepare?(context: RenderingContext, instance: Instance): void;
61
+ onCleanup?(context: RenderingContext, instance: Instance): void;
62
+ onDestroy?(instance: Instance): void;
58
63
  }
59
64
 
60
65
  /** Style-related config properties for widgets that support styling. */
61
66
  export interface WidgetStyleConfig {
62
- /**
63
- * Additional CSS classes to be applied to the element.
64
- * If an object is provided, all keys with a "truthy" value will be added to the CSS class list.
65
- */
66
- class?: ClassProp;
67
+ /**
68
+ * Additional CSS classes to be applied to the element.
69
+ * If an object is provided, all keys with a "truthy" value will be added to the CSS class list.
70
+ */
71
+ class?: ClassProp;
67
72
 
68
- /**
69
- * Additional CSS classes to be applied to the element.
70
- * If an object is provided, all keys with a "truthy" value will be added to the CSS class list.
71
- */
72
- className?: ClassProp;
73
+ /**
74
+ * Additional CSS classes to be applied to the element.
75
+ * If an object is provided, all keys with a "truthy" value will be added to the CSS class list.
76
+ */
77
+ className?: ClassProp;
73
78
 
74
- /** Style object applied to the element. */
75
- style?: StyleProp;
79
+ /** Style object applied to the element. */
80
+ style?: StyleProp;
76
81
 
77
- /** Style object applied to the element. */
78
- styles?: StyleProp;
82
+ /** Style object applied to the element. */
83
+ styles?: StyleProp;
79
84
 
80
- /** Base CSS class to be applied to the element. For example, value 'button' will add a class 'cxb-button' to the element. */
81
- baseClass?: string;
85
+ /** Base CSS class to be applied to the element. For example, value 'button' will add a class 'cxb-button' to the element. */
86
+ baseClass?: string;
82
87
 
83
- /** Appearance modifier. For example, mod="big" will add the CSS class .cxm-big to the block element. */
84
- mod?: ModProp;
88
+ /** Appearance modifier. For example, mod="big" will add the CSS class .cxm-big to the block element. */
89
+ mod?: ModProp;
85
90
  }
86
91
 
87
92
  export abstract class Widget<
88
- Config extends WidgetConfig = WidgetConfig,
89
- InstanceType extends Instance = Instance,
93
+ Config extends WidgetConfig = WidgetConfig,
94
+ InstanceType extends Instance = Instance,
90
95
  > extends Component {
91
- // config props
92
- declare public vdomKey?: string | number;
93
- declare public jsxSpread?: Record<string, any>[];
94
- declare public jsxAttributes?: string[];
95
- declare public styles?: any;
96
- declare public style?: any;
97
- declare public styled: boolean;
98
- declare public if?: any;
99
- declare public visible: boolean;
100
- declare public outerLayout?: Widget;
101
- declare public contentFor?: string;
102
- declare public putInto?: string;
103
- declare public isContent?: boolean;
104
- declare public CSS: typeof CSS;
105
- declare public baseClass?: string;
106
- declare public memoize: boolean;
107
- declare public controller?: Controller;
108
- declare public isPureContainer?: boolean;
109
- declare public useParentLayout?: boolean;
110
-
111
- // runtime values
112
- public widgetId?: number;
113
- public initialized?: boolean;
114
- public components?: Record<string, any>;
115
- public helpers?: Record<string, any>;
116
- public selector?: StructuredSelector;
117
- public nameMap?: any;
118
- public version?: number;
119
-
120
- // Lifecycle hooks - callbacks that can be set in configuration
121
- declare public onInit?: (context: RenderingContext, instance: Instance) => void;
122
- declare public onExplore?: (context: RenderingContext, instance: Instance) => void;
123
- declare public onPrepare?: (context: RenderingContext, instance: Instance) => void;
124
- declare public onCleanup?: (context: RenderingContext, instance: Instance) => void;
125
- declare public onDestroy?: (instance: Instance) => void;
126
-
127
- // Lifecycle methods that can be overridden by subclasses
128
- public exploreCleanup?(context: RenderingContext, instance: InstanceType): void;
129
- public prepareCleanup?(context: RenderingContext, instance: InstanceType): void;
130
- public cleanup?(context: RenderingContext, instance: InstanceType): void;
131
- public prepare?(context: RenderingContext, instance: InstanceType): void;
132
-
133
- public static optimizePrepare?: boolean;
134
-
135
- constructor(config?: Config) {
136
- super(config);
137
- this.widgetId = widgetId++;
138
-
139
- if (isArray(this.jsxSpread)) {
140
- if (!this.jsxAttributes) this.jsxAttributes = [];
141
-
142
- this.jsxSpread.forEach((spread: Record<string, any>) => {
143
- for (const key in spread) {
144
- (this as any)[key] = spread[key];
145
- this.jsxAttributes!.push(key);
146
- }
147
- });
96
+ // config props
97
+ declare public vdomKey?: string | number;
98
+ declare public jsxSpread?: Record<string, any>[];
99
+ declare public jsxAttributes?: string[];
100
+ declare public styles?: any;
101
+ declare public style?: any;
102
+ declare public styled: boolean;
103
+ declare public if?: any;
104
+ declare public visible: boolean;
105
+ declare public outerLayout?: Widget;
106
+ declare public contentFor?: string;
107
+ declare public putInto?: string;
108
+ declare public isContent?: boolean;
109
+ declare public CSS: typeof CSS;
110
+ declare public baseClass?: string;
111
+ declare public memoize: boolean;
112
+ declare public controller?: Controller;
113
+ declare public isPureContainer?: boolean;
114
+ declare public useParentLayout?: boolean;
115
+
116
+ // runtime values
117
+ public widgetId?: number;
118
+ public initialized?: boolean;
119
+ public components?: Record<string, any>;
120
+ public helpers?: Record<string, any>;
121
+ public selector?: StructuredSelector;
122
+ public nameMap?: any;
123
+ public version?: number;
124
+
125
+ // Lifecycle hooks - callbacks that can be set in configuration
126
+ declare public onInit?: (
127
+ context: RenderingContext,
128
+ instance: Instance,
129
+ ) => void;
130
+ declare public onExplore?: (
131
+ context: RenderingContext,
132
+ instance: Instance,
133
+ ) => void;
134
+ declare public onPrepare?: (
135
+ context: RenderingContext,
136
+ instance: Instance,
137
+ ) => void;
138
+ declare public onCleanup?: (
139
+ context: RenderingContext,
140
+ instance: Instance,
141
+ ) => void;
142
+ declare public onDestroy?: (instance: Instance) => void;
143
+
144
+ // Lifecycle methods that can be overridden by subclasses
145
+ public exploreCleanup?(
146
+ context: RenderingContext,
147
+ instance: InstanceType,
148
+ ): void;
149
+ public prepareCleanup?(
150
+ context: RenderingContext,
151
+ instance: InstanceType,
152
+ ): void;
153
+ public cleanup?(context: RenderingContext, instance: InstanceType): void;
154
+ public prepare?(context: RenderingContext, instance: InstanceType): void;
155
+
156
+ public static optimizePrepare?: boolean;
157
+
158
+ constructor(config?: Config) {
159
+ super(config);
160
+ this.widgetId = widgetId++;
161
+
162
+ if (isArray(this.jsxSpread)) {
163
+ if (!this.jsxAttributes) this.jsxAttributes = [];
164
+
165
+ this.jsxSpread.forEach((spread: Record<string, any>) => {
166
+ for (const key in spread) {
167
+ (this as any)[key] = spread[key];
168
+ this.jsxAttributes!.push(key);
169
+ }
170
+ });
171
+ }
172
+ }
173
+
174
+ public init(): void {
175
+ if (this.styles) this.style = this.styles;
176
+
177
+ if (this.styled) this.style = parseStyle(this.style);
178
+
179
+ if (typeof this.if !== "undefined") this.visible = this.if;
180
+
181
+ this.declareData();
182
+
183
+ if (this.outerLayout) {
184
+ if (isArray(this.outerLayout))
185
+ throw new Error("Only single element outer layout is supported.");
186
+ //TODO: better handle the case when outer layout is an array. How to get around circular dependency to PureContainer
187
+ this.outerLayout = Widget.create(this.outerLayout, {});
188
+ }
189
+
190
+ if (this.contentFor) this.putInto = this.contentFor;
191
+
192
+ if (this.putInto) this.isContent = true;
193
+
194
+ if (isString(this.CSS)) this.CSS = CSSHelper.get(this.CSS);
195
+
196
+ this.initHelpers();
197
+ this.initComponents();
198
+
199
+ this.initialized = true;
200
+ }
201
+
202
+ protected initComponents(...args: Record<string, any>[]): void {
203
+ if (args.length > 0) {
204
+ this.components = Object.assign({}, ...args);
205
+ for (const k in this.components) {
206
+ if (!this.components[k]) delete this.components[k];
148
207
  }
149
- }
150
-
151
- public init(): void {
152
- if (this.styles) this.style = this.styles;
153
-
154
- if (this.styled) this.style = parseStyle(this.style);
155
-
156
- if (typeof this.if !== "undefined") this.visible = this.if;
157
-
158
- this.declareData();
159
-
160
- if (this.outerLayout) {
161
- if (isArray(this.outerLayout)) throw new Error("Only single element outer layout is supported.");
162
- //TODO: better handle the case when outer layout is an array. How to get around circular dependency to PureContainer
163
- this.outerLayout = Widget.create(this.outerLayout, {});
164
- }
165
-
166
- if (this.contentFor) this.putInto = this.contentFor;
167
-
168
- if (this.putInto) this.isContent = true;
169
-
170
- if (isString(this.CSS)) this.CSS = CSSHelper.get(this.CSS);
171
-
172
- this.initHelpers();
173
- this.initComponents();
174
-
175
- this.initialized = true;
176
- }
177
-
178
- protected initComponents(...args: Record<string, any>[]): void {
179
- if (args.length > 0) {
180
- this.components = Object.assign({}, ...args);
181
- for (const k in this.components) {
182
- if (!this.components[k]) delete this.components[k];
183
- }
208
+ }
209
+ }
210
+
211
+ protected initHelpers(...args: Record<string, any>[]): void {
212
+ if (args.length > 0) {
213
+ this.helpers = Object.assign({}, ...args);
214
+ }
215
+ }
216
+
217
+ protected declareData(...args: Record<string, any>[]): void {
218
+ const options: Record<string, any> = {};
219
+
220
+ if (this.styled) {
221
+ options.class = options.className = options.style = { structured: true };
222
+ }
223
+
224
+ const props = {
225
+ visible: undefined,
226
+ mod: {
227
+ structured: true,
228
+ },
229
+ ...options,
230
+ };
231
+
232
+ Object.assign(props, ...args);
233
+ this.selector = new StructuredSelector({ props: props, values: this });
234
+ this.nameMap = this.selector.nameMap;
235
+ }
236
+
237
+ protected prepareCSS(_context: RenderingContext, { data }: any): void {
238
+ data.classNames = this.CSS.expand(
239
+ this.CSS.block(this.baseClass!, data.mod, data.stateMods),
240
+ data.class,
241
+ data.className,
242
+ );
243
+ data.style = parseStyle(data.style);
244
+ }
245
+
246
+ public prepareData(context: RenderingContext, instance: InstanceType): void {
247
+ if (this.styled) this.prepareCSS(context, instance);
248
+ }
249
+
250
+ public createInstance(
251
+ key: string,
252
+ parent: Instance,
253
+ parentStore?: View,
254
+ ): Instance {
255
+ return new Instance(this, key, parent, parentStore);
256
+ }
257
+
258
+ public initInstance(
259
+ _context: RenderingContext,
260
+ _instance: InstanceType,
261
+ ): void {}
262
+
263
+ public initState(_context: RenderingContext, _instance: InstanceType): void {}
264
+
265
+ public checkVisible(
266
+ _context: RenderingContext,
267
+ _instance: InstanceType,
268
+ data: any,
269
+ ): boolean {
270
+ return data.visible;
271
+ }
272
+
273
+ public explore(
274
+ context: RenderingContext,
275
+ instance: InstanceType,
276
+ data?: any,
277
+ ): void {
278
+ if (this.components) {
279
+ instance.components = {};
280
+ for (const cmp in this.components) {
281
+ const ins = instance.getChild(
282
+ context,
283
+ this.components[cmp],
284
+ "cmp-" + cmp,
285
+ instance.store,
286
+ );
287
+ if (ins.scheduleExploreIfVisible(context))
288
+ instance.components[cmp] = ins;
184
289
  }
185
- }
186
-
187
- protected initHelpers(...args: Record<string, any>[]): void {
188
- if (args.length > 0) {
189
- this.helpers = Object.assign({}, ...args);
190
- }
191
- }
192
-
193
- protected declareData(...args: Record<string, any>[]): void {
194
- const options: Record<string, any> = {};
195
-
196
- if (this.styled) {
197
- options.class = options.className = options.style = { structured: true };
198
- }
199
-
200
- const props = {
201
- visible: undefined,
202
- mod: {
203
- structured: true,
204
- },
205
- ...options,
206
- };
207
-
208
- Object.assign(props, ...args);
209
- this.selector = new StructuredSelector({ props: props, values: this });
210
- this.nameMap = this.selector.nameMap;
211
- }
212
-
213
- protected prepareCSS(_context: RenderingContext, { data }: any): void {
214
- data.classNames = this.CSS.expand(
215
- this.CSS.block(this.baseClass!, data.mod, data.stateMods),
216
- data.class,
217
- data.className,
218
- );
219
- data.style = parseStyle(data.style);
220
- }
221
-
222
- public prepareData(context: RenderingContext, instance: InstanceType): void {
223
- if (this.styled) this.prepareCSS(context, instance);
224
- }
225
-
226
- public initInstance(_context: RenderingContext, _instance: InstanceType): void {}
227
-
228
- public initState(_context: RenderingContext, _instance: InstanceType): void {}
229
-
230
- public checkVisible(_context: RenderingContext, _instance: InstanceType, data: any): boolean {
231
- return data.visible;
232
- }
233
-
234
- public explore(context: RenderingContext, instance: InstanceType, data?: any): void {
235
- if (this.components) {
236
- instance.components = {};
237
- for (const cmp in this.components) {
238
- const ins = instance.getChild(context, this.components[cmp], "cmp-" + cmp, instance.store);
239
- if (ins.scheduleExploreIfVisible(context)) instance.components[cmp] = ins;
240
- }
241
- }
242
- }
243
-
244
- public render(context: RenderingContext, instance: InstanceType, key: string): any {
245
- Console.log(this);
246
- throw new Error(
247
- 'Widget\'s render method should be overridden. This error usually happens if with incorrect imports, i.e. import { TextField } from "cx/data". Please check the console for details about the component configuration.',
248
- );
249
- }
250
-
251
- public update(): void {
252
- this.version = (this.version || 0) + 1;
253
- }
254
-
255
- public applyParentStore(instance: any): void {
256
- instance.store = instance.parentStore;
257
-
258
- // check when this is actually needed, perhaps this is needed only for tables and repeated elements
259
- // if (instance.cached) delete instance.cached.rawData; // force prepareData to execute again
260
- }
261
-
262
- public static resetCounter(): void {
263
- widgetId = 100;
264
- }
290
+ }
291
+ }
292
+
293
+ public render(
294
+ context: RenderingContext,
295
+ instance: InstanceType,
296
+ key: string,
297
+ ): any {
298
+ Console.log(this);
299
+ throw new Error(
300
+ 'Widget\'s render method should be overridden. This error usually happens if with incorrect imports, i.e. import { TextField } from "cx/data". Please check the console for details about the component configuration.',
301
+ );
302
+ }
303
+
304
+ public update(): void {
305
+ this.version = (this.version || 0) + 1;
306
+ }
307
+
308
+ public applyParentStore(instance: any): void {
309
+ instance.store = instance.parentStore;
310
+
311
+ // check when this is actually needed, perhaps this is needed only for tables and repeated elements
312
+ // if (instance.cached) delete instance.cached.rawData; // force prepareData to execute again
313
+ }
314
+
315
+ public static resetCounter(): void {
316
+ widgetId = 100;
317
+ }
265
318
  }
266
319
 
267
320
  Widget.prototype.visible = true;
@@ -273,29 +326,34 @@ Widget.namespace = "ui.";
273
326
  Widget.optimizePrepare = true;
274
327
 
275
328
  Widget.factory = (type: string, _config?: any, _more?: any) => {
276
- throw new Error(`Invalid widget type: ${type}.`);
329
+ throw new Error(`Invalid widget type: ${type}.`);
277
330
  };
278
331
 
279
- export function contentAppend(result: any[], w: any, prependSpace?: boolean): boolean {
280
- if (w == null || w === false) return false;
281
- if (isArray(w)) w.forEach((c: any) => contentAppend(result, c));
282
- else if (isDefined(w.content) && !w.atomic) return contentAppend(result, w.content, false);
283
- else {
284
- if (prependSpace) result.push(" ");
285
- result.push(w);
286
- }
287
- return true;
332
+ export function contentAppend(
333
+ result: any[],
334
+ w: any,
335
+ prependSpace?: boolean,
336
+ ): boolean {
337
+ if (w == null || w === false) return false;
338
+ if (isArray(w)) w.forEach((c: any) => contentAppend(result, c));
339
+ else if (isDefined(w.content) && !w.atomic)
340
+ return contentAppend(result, w.content, false);
341
+ else {
342
+ if (prependSpace) result.push(" ");
343
+ result.push(w);
344
+ }
345
+ return true;
288
346
  }
289
347
 
290
348
  export function getContentArray(x: any): any[] {
291
- let result: any[] = [];
292
- contentAppend(result, x, false);
293
- return result;
349
+ let result: any[] = [];
350
+ contentAppend(result, x, false);
351
+ return result;
294
352
  }
295
353
 
296
354
  export function getContent(x: any): any {
297
- let result = getContentArray(x);
298
- if (result.length == 0) return null;
299
- if (result.length == 1) return result[0];
300
- return result;
355
+ let result = getContentArray(x);
356
+ if (result.length == 0) return null;
357
+ if (result.length == 1) return result[0];
358
+ return result;
301
359
  }