cx 26.7.4 → 26.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/widgets.js CHANGED
@@ -1,81 +1,60 @@
1
1
  import {
2
- FocusManager,
3
- Instance,
4
- StyledContainerBase,
5
- Url,
6
- VDOM,
7
- Widget,
8
- createFunctionalComponent,
9
- flattenProps,
10
- preventFocus,
11
- getContentArray,
12
- GroupAdapter,
13
- Selection,
14
- getContent,
15
- Container,
16
- offFocusOut,
17
- preventFocusOnTouch,
18
- batchUpdates,
19
- oneFocusOut,
20
- PureContainerBase,
21
- ContainerBase,
22
- ZIndexManager,
23
- startAppLoop,
24
- ResizeManager,
25
- Localization,
26
- RenderingContext,
27
- ContentPlaceholder,
28
- Text,
29
- History,
30
- Cx,
31
- registerKeyboardShortcut,
32
- unfocusElement,
33
- Culture,
34
- bind,
35
- Format,
36
- enableCultureSensitiveFormatting,
37
- ContentResolver,
38
- DataProxy,
39
- KeySelection,
40
- PureContainer,
41
- ArrayAdapter,
42
- InstanceCache,
43
- StaticText,
44
- } from "cx/ui";
45
- export {
46
- ArrayAdapter,
47
- Content,
48
- ContentPlaceholder,
49
- ContentPlaceholderScope,
50
- ContentResolver,
51
- DataAdapter,
52
- DataProxy,
53
- DetachedScope,
54
- GroupAdapter,
55
- IsolatedScope,
56
- LabelsLeftLayout,
57
- LabelsTopLayout,
58
- LabelsTopLayoutCell,
59
- PrivateStore,
60
- PureContainer,
61
- Repeater,
62
- Rescope,
63
- Restate,
64
- StaticText,
65
- Text,
66
- TreeAdapter,
67
- Widget,
68
- } from "cx/ui";
69
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ computable,
3
+ StoreProxy,
4
+ isAccessorChain,
5
+ StructuredSelector,
6
+ invalidateExpressionCache,
7
+ invalidateStringTemplateCache,
8
+ defaultCompare,
9
+ getSelector,
10
+ SubscribableView,
11
+ Store,
12
+ Binding,
13
+ NestedDataView,
14
+ ZoomIntoPropertyView,
15
+ getAccessor,
16
+ ArrayElementView,
17
+ ReadOnlyDataView,
18
+ sorter,
19
+ ExposedValueView,
20
+ isBinding,
21
+ isBindingObject,
22
+ isSelector,
23
+ StringTemplate,
24
+ enableFatArrowExpansion,
25
+ } from "cx/data";
70
26
  import {
71
- isTouchEvent,
27
+ isArray,
28
+ parseStyle,
29
+ SubscriberList,
30
+ Component,
31
+ isFunction,
32
+ isNonEmptyArray,
33
+ GlobalCacheIdentifier,
34
+ debug,
35
+ processDataFlag,
36
+ renderFlag,
37
+ destroyFlag,
38
+ validatedDebounce,
39
+ throttle,
72
40
  isUndefined,
73
41
  isString,
74
42
  isDefined,
75
- isArray,
76
- debug,
77
- isFunction,
43
+ isObject,
44
+ Console,
45
+ innerTextTrim,
46
+ TraversalStack,
47
+ reverseSlice,
48
+ appDataFlag,
49
+ onIdleCallback,
50
+ shallowEquals,
51
+ now,
52
+ Timing,
53
+ vdomRenderFlag,
54
+ appLoopFlag,
78
55
  isNumber,
56
+ isPromise,
57
+ isTouchEvent,
79
58
  isComponentFactory,
80
59
  createComponentFactory,
81
60
  deprecatedFlag,
@@ -83,15 +62,10 @@ import {
83
62
  addEventListenerWithOptions,
84
63
  scrollElementIntoView,
85
64
  KeyCode,
86
- parseStyle,
87
65
  getParentFrameBoundingClientRect,
88
66
  getSearchQueryHighlighter,
89
- isNonEmptyArray,
90
67
  getTopLevelBoundingClientRect,
91
- isObject,
92
- Console,
93
68
  getScrollerBoundingClientRect,
94
- SubscriberList,
95
69
  isDataRecord,
96
70
  isSelfOrDescendant,
97
71
  getActiveElement,
@@ -102,7 +76,6 @@ import {
102
76
  isFocusable,
103
77
  closestParent,
104
78
  tooltipsFlag,
105
- shallowEquals,
106
79
  stopPropagation,
107
80
  routeAppend,
108
81
  menuFlag,
@@ -111,7 +84,6 @@ import {
111
84
  isFocused,
112
85
  isFocusedDeep,
113
86
  getFocusedElement,
114
- isPromise,
115
87
  preventDefault,
116
88
  parseDateInvariant,
117
89
  zeroTime,
@@ -132,22 +104,2817 @@ import {
132
104
  debounce,
133
105
  findScrollableParent,
134
106
  } from "cx/util";
107
+ import { VDOM as VDOM$1 } from "cx-react";
108
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
109
+ import { NumberCulture, DateTimeCulture } from "intl-io";
135
110
  import {
136
- getAccessor,
137
- Binding,
138
- ExposedValueView,
139
- isBinding,
140
- isBindingObject,
141
- ReadOnlyDataView,
142
- isSelector,
143
- Store,
144
- StringTemplate,
145
- isAccessorChain,
146
- getSelector,
147
- enableFatArrowExpansion,
148
- } from "cx/data";
111
+ FocusManager,
112
+ Instance as Instance$1,
113
+ StyledContainerBase as StyledContainerBase$1,
114
+ Url,
115
+ VDOM as VDOM$2,
116
+ Widget as Widget$1,
117
+ createFunctionalComponent,
118
+ flattenProps,
119
+ preventFocus,
120
+ getContentArray as getContentArray$1,
121
+ GroupAdapter,
122
+ Selection,
123
+ getContent as getContent$1,
124
+ Container as Container$1,
125
+ offFocusOut,
126
+ preventFocusOnTouch,
127
+ batchUpdates as batchUpdates$1,
128
+ oneFocusOut,
129
+ PureContainerBase as PureContainerBase$1,
130
+ ContainerBase as ContainerBase$1,
131
+ ZIndexManager,
132
+ startAppLoop,
133
+ ResizeManager,
134
+ Localization as Localization$1,
135
+ RenderingContext as RenderingContext$1,
136
+ ContentPlaceholder as ContentPlaceholder$1,
137
+ Text as Text$1,
138
+ History,
139
+ Cx as Cx$1,
140
+ registerKeyboardShortcut,
141
+ unfocusElement,
142
+ Culture as Culture$1,
143
+ bind,
144
+ Format,
145
+ enableCultureSensitiveFormatting,
146
+ ContentResolver as ContentResolver$1,
147
+ DataProxy as DataProxy$1,
148
+ KeySelection,
149
+ PureContainer as PureContainer$1,
150
+ ArrayAdapter as ArrayAdapter$1,
151
+ InstanceCache as InstanceCache$1,
152
+ StaticText as StaticText$1,
153
+ } from "cx/ui";
154
+ export { ArrayAdapter, DataAdapter, GroupAdapter, TreeAdapter } from "cx/ui";
149
155
  import { jsx as jsx$1, jsxs as jsxs$1 } from "cx/jsx-runtime";
150
156
 
157
+ var cssHelperCache = {};
158
+ class CSSHelper {
159
+ static get(code) {
160
+ var helper = cssHelperCache[code];
161
+ if (!helper) throw new Error(`Unknown CSS helper '${code}'.`);
162
+ return helper;
163
+ }
164
+ static register(code, helper) {
165
+ cssHelperCache[code] = helper;
166
+ }
167
+ static alias(code, helper) {
168
+ cssHelperCache[code] = helper;
169
+ }
170
+ }
171
+
172
+ function push(list, item) {
173
+ if (!item) return list || [];
174
+ if (!list) list = [];
175
+ list.push(item);
176
+ return list;
177
+ }
178
+ function pushMore(list, itemArray) {
179
+ if (!itemArray || itemArray.length == 0) return list || [];
180
+ if (!list) list = [];
181
+ list.push.apply(list, itemArray);
182
+ return list;
183
+ }
184
+ function pushMap(list, itemArray, mapF) {
185
+ return itemArray ? pushMore(list, itemArray.map(mapF)) : list;
186
+ }
187
+ function join(list) {
188
+ return list ? list.join(" ") : undefined;
189
+ }
190
+ class CSS {
191
+ static classPrefix;
192
+ static resolve(...args) {
193
+ let list = undefined,
194
+ type,
195
+ arg,
196
+ i,
197
+ key;
198
+ for (i = 0; i < args.length; i++) {
199
+ arg = args[i];
200
+ if (arg) {
201
+ type = typeof arg;
202
+ if (type == "string") list = push(list, arg);
203
+ else if (type == "object") {
204
+ if (isArray(arg)) list = pushMore(list, this.resolve(...arg));
205
+ else for (key in arg) if (arg[key]) list = push(list, key);
206
+ }
207
+ }
208
+ }
209
+ return list || [];
210
+ }
211
+ static block(baseClass, styleModifiers, stateModifiers) {
212
+ let list;
213
+ if (baseClass) list = push(list, this.classPrefix + "b-" + baseClass);
214
+ list = pushMap(list, this.resolve(styleModifiers), (m) => this.classPrefix + "m-" + m);
215
+ list = pushMap(list, this.resolve(stateModifiers), (m) => this.classPrefix + "s-" + m);
216
+ return join(list);
217
+ }
218
+ static element(baseClass, elementClass, stateModifiers) {
219
+ let list;
220
+ if (baseClass && elementClass) list = push(list, this.classPrefix + "e-" + baseClass + "-" + elementClass);
221
+ list = pushMap(list, this.resolve(stateModifiers), (m) => this.classPrefix + "s-" + m);
222
+ return join(list);
223
+ }
224
+ static state(stateModifiers) {
225
+ return join(pushMap(undefined, this.resolve(stateModifiers), (m) => this.classPrefix + "s-" + m));
226
+ }
227
+ static mod(mods) {
228
+ return join(pushMap(undefined, this.resolve(mods), (m) => this.classPrefix + "m-" + m));
229
+ }
230
+ static expand(...args) {
231
+ return join(this.resolve(...args));
232
+ }
233
+ static parseStyle(str) {
234
+ return parseStyle(str);
235
+ }
236
+ }
237
+ CSS.classPrefix = "cx";
238
+ CSSHelper.alias("cx", CSS);
239
+
240
+ let isBatching = 0;
241
+ let updateSequence = 0;
242
+ let promiseSubscribers = new SubscriberList();
243
+ function batchUpdates(callback) {
244
+ if (VDOM$1.DOM.unstable_batchedUpdates)
245
+ VDOM$1.DOM.unstable_batchedUpdates(() => {
246
+ isBatching++;
247
+ try {
248
+ callback();
249
+ } finally {
250
+ isBatching--;
251
+ }
252
+ });
253
+ else callback();
254
+ }
255
+ function isBatchingUpdates() {
256
+ return isBatching > 0;
257
+ }
258
+ // Returns a sequence number identifying the update; pass it to notifyBatchedUpdateCompleted once the
259
+ // update is rendered.
260
+ function notifyBatchedUpdateStarting() {
261
+ let seq = ++updateSequence;
262
+ promiseSubscribers.execute((x) => {
263
+ x.pending++;
264
+ });
265
+ return seq;
266
+ }
267
+ function notifyBatchedUpdateCompleted(seq) {
268
+ promiseSubscribers.execute((x) => {
269
+ let cb = x;
270
+ // ignore updates that started before this subscriber attached -- counting them would let the notify
271
+ // callback fire before the updates the subscriber is actually waiting on are rendered
272
+ if (seq <= cb.watermark) return;
273
+ cb.finished++;
274
+ if (cb.finished >= cb.pending) cb.complete(true);
275
+ });
276
+ }
277
+
278
+ const computablePrefix = "computable-";
279
+ const triggerPrefix = "trigger-";
280
+ class Controller extends Component {
281
+ initialized;
282
+ computables;
283
+ constructor(config) {
284
+ super(config);
285
+ }
286
+ init(context) {
287
+ if (!this.initialized) {
288
+ this.initialized = true;
289
+ if (this.onInit && context) this.onInit(context);
290
+ }
291
+ }
292
+ explore(context) {
293
+ let { store } = this.instance;
294
+ this.store = store; //in rare cases instance may change its store
295
+ if (!this.initialized) {
296
+ this.init(context);
297
+ //forgive if the developer forgets to call super.init()
298
+ this.initialized = true;
299
+ }
300
+ if (this.computables) {
301
+ for (let key in this.computables) {
302
+ let x = this.computables[key];
303
+ let v = x.selector(store.getData());
304
+ if (x.type == "computable") store.set(x.name, v);
305
+ }
306
+ }
307
+ if (this.onExplore) {
308
+ this.onExplore(context);
309
+ }
310
+ }
311
+ prepare(context) {
312
+ if (this.onPrepare) {
313
+ this.onPrepare(context);
314
+ }
315
+ }
316
+ cleanup(context) {
317
+ if (this.onCleanup) {
318
+ this.onCleanup(context);
319
+ }
320
+ }
321
+ addComputable(name, args, callback) {
322
+ if (!isArray(args)) throw new Error("Second argument to the addComputable method should be an array.");
323
+ let selector = computable(...args, callback).memoize();
324
+ if (!this.computables) this.computables = {};
325
+ let nameStr = String(name);
326
+ this.computables[computablePrefix + nameStr] = {
327
+ name: nameStr,
328
+ selector,
329
+ type: "computable",
330
+ };
331
+ }
332
+ addTrigger(name, args, callback, autoRun) {
333
+ if (!isArray(args)) throw new Error("Second argument to the addTrigger method should be an array.");
334
+ let selector = computable(...args, callback).memoize(!autoRun && this.store.getData());
335
+ if (!this.computables) this.computables = {};
336
+ this.computables[triggerPrefix + name] = {
337
+ name,
338
+ selector,
339
+ type: "trigger",
340
+ };
341
+ }
342
+ removeTrigger(name) {
343
+ if (this.computables) delete this.computables[triggerPrefix + name];
344
+ }
345
+ removeComputable(name) {
346
+ if (this.computables) delete this.computables[computablePrefix + name];
347
+ }
348
+ invokeParentMethod(methodName, ...args) {
349
+ let parent = this.instance.parent;
350
+ if (!parent) throw new Error("Cannot invoke a parent controller method as the instance does not have a parent.");
351
+ return parent.invokeControllerMethod(methodName, ...args);
352
+ }
353
+ invokeMethod(methodName, ...args) {
354
+ return this.instance.invokeControllerMethod(methodName, ...args);
355
+ }
356
+ getParentControllerByType(type) {
357
+ return this.instance.getControllerByType(type);
358
+ }
359
+ }
360
+ Controller.namespace = "ui.controller.";
361
+ Controller.factory = function (alias, config, more) {
362
+ if (isFunction(alias)) {
363
+ let cfg = {
364
+ ...config,
365
+ ...more,
366
+ };
367
+ if (cfg.instance) {
368
+ //in rare cases instance.store may change, so we cannot rely on the store passed through configuration
369
+ cfg.store = new StoreProxy(() => cfg.instance.store);
370
+ Object.assign(cfg, cfg.store.getMethods());
371
+ }
372
+ let result = alias(cfg);
373
+ if (result instanceof Controller) return result;
374
+ return Controller.create({
375
+ ...config,
376
+ ...more,
377
+ ...result,
378
+ });
379
+ }
380
+ return Controller.create({
381
+ ...config,
382
+ ...more,
383
+ });
384
+ };
385
+
386
+ let instanceId = 1000;
387
+ /**
388
+ * Base Instance class
389
+ */
390
+ class Instance {
391
+ // Selectors
392
+ dataSelector;
393
+ // Lifecycle flags
394
+ initialized;
395
+ destroySubscriptions;
396
+ helpers;
397
+ components;
398
+ constructor(widget, key, parent, parentStore) {
399
+ this.widget = widget;
400
+ this.key = key;
401
+ this.id = String(++instanceId);
402
+ this.cached = {};
403
+ this.parent = parent;
404
+ this.parentStore = parentStore ?? parent?.store;
405
+ if (this.parentStore == null) throw new Error("Cannot create instance without a parent store.");
406
+ }
407
+ setParentStore(parentStore) {
408
+ this.parentStore = parentStore;
409
+ this.widget.applyParentStore(this);
410
+ }
411
+ init(context) {
412
+ // widget is initialized when the first instance is initialized
413
+ if (!this.widget.initialized) {
414
+ this.widget.init();
415
+ this.widget.initialized = true;
416
+ }
417
+ if (!this.dataSelector) {
418
+ this.widget.selector.init(this.parentStore);
419
+ this.dataSelector = this.widget.selector.createStoreSelector();
420
+ }
421
+ // init instance might change the store, so this must go before the controller initialization
422
+ this.widget.initInstance(context, this);
423
+ // initInstance can set the store, otherwise use parent store
424
+ if (!this.store) this.store = this.parentStore;
425
+ if (this.widget.onInit) this.widget.onInit(context, this);
426
+ this.widget.initState(context, this);
427
+ if (this.widget.controller)
428
+ this.controller = Controller.create(this.widget.controller, {
429
+ widget: this.widget,
430
+ instance: this,
431
+ store: this.store,
432
+ });
433
+ if (
434
+ this.widget.exploreCleanup ||
435
+ this.widget.outerLayout ||
436
+ this.widget.isContent ||
437
+ this.widget.controller ||
438
+ this.widget.prepareCleanup
439
+ )
440
+ this.needsExploreCleanup = true;
441
+ if (this.widget.prepare || this.widget.controller) this.needsPrepare = true;
442
+ if (this.widget.cleanup || this.widget.controller) this.needsCleanup = true;
443
+ this.initialized = true;
444
+ }
445
+ checkVisible(context) {
446
+ if (!this.initialized) this.init(context);
447
+ const wasVisible = this.visible;
448
+ this.rawData = this.dataSelector(this.store);
449
+ this.visible = this.widget.checkVisible(context, this, this.rawData);
450
+ if (this.visible && !this.detached) this.parent.instanceCache.addChild(this);
451
+ this.explored = false;
452
+ this.prepared = false;
453
+ if (!this.visible && wasVisible) this.destroy();
454
+ return this.visible;
455
+ }
456
+ scheduleExploreIfVisible(context) {
457
+ if (this.checkVisible(context)) {
458
+ context.exploreStack.push(this);
459
+ if (this.needsExploreCleanup) context.exploreStack.push(this);
460
+ return true;
461
+ }
462
+ return false;
463
+ }
464
+ cache(key, value) {
465
+ const oldValue = this.cached[key];
466
+ if (oldValue === value) return false;
467
+ if (!this.cacheList) this.cacheList = {};
468
+ this.cacheList[key] = value;
469
+ return true;
470
+ }
471
+ markShouldUpdate(context) {
472
+ let ins = this;
473
+ let renderList = this.renderList;
474
+ renderList.markReverseIndex();
475
+ //notify all parents that child state changed to bust up caching
476
+ while (ins && !ins.shouldUpdate && ins.explored) {
477
+ if (ins.renderList !== renderList) {
478
+ renderList.reverse();
479
+ renderList = ins.renderList;
480
+ renderList.markReverseIndex();
481
+ }
482
+ ins.shouldUpdate = true;
483
+ renderList.data.push(ins);
484
+ ins = ins.widget.isContent
485
+ ? ins.contentPlaceholder
486
+ : ins.parent?.outerLayout === ins
487
+ ? ins.parent?.parent
488
+ : ins.parent;
489
+ }
490
+ renderList.reverse();
491
+ }
492
+ explore(context) {
493
+ if (!this.visible) throw new Error("Explore invisible!");
494
+ if (this.explored) {
495
+ if (this.widget.prepareCleanup) context.prepareList.push(this);
496
+ if (this.widget.exploreCleanup) this.widget.exploreCleanup(context, this);
497
+ if (this.parent?.outerLayout === this) context.popNamedValue("content", "body");
498
+ if (this.widget.controller) context.pop("controller");
499
+ return;
500
+ }
501
+ this.explored = true;
502
+ if (this.needsPrepare) context.prepareList.push(this);
503
+ else this.prepared = true;
504
+ if (this.needsCleanup) context.cleanupList.push(this);
505
+ if (this.instanceCache) this.instanceCache.mark();
506
+ //controller may reconfigure the widget and need to go before shouldUpdate calculation
507
+ this.parentOptions = context.parentOptions;
508
+ if (!this.controller) {
509
+ if (context.controller) this.controller = context.controller;
510
+ else if (this.parent?.controller) this.controller = this.parent?.controller;
511
+ }
512
+ this.destroyTracked = false;
513
+ if (this.controller) {
514
+ if (this.widget.controller) {
515
+ if (!this.controller.initialized) {
516
+ this.controller.init(context);
517
+ this.controller.initialized = true;
518
+ }
519
+ context.push("controller", this.controller);
520
+ this.controller.explore(context);
521
+ if (this.controller.onDestroy && this.controller.widget == this.widget) this.trackDestroy();
522
+ }
523
+ }
524
+ if (this.widget.onDestroy || isNonEmptyArray(this.destroySubscriptions)) this.trackDestroy();
525
+ this.renderList = this.assignedRenderList || this.parent?.renderList || context.getRootRenderList();
526
+ let shouldUpdate =
527
+ this.rawData !== this.cached.rawData ||
528
+ this.state !== this.cached.state ||
529
+ this.widget.version !== this.cached.widgetVersion ||
530
+ this.cached.globalCacheIdentifier !== GlobalCacheIdentifier.get();
531
+ if (shouldUpdate) {
532
+ this.data = {
533
+ ...this.rawData,
534
+ };
535
+ this.widget.prepareData(context, this);
536
+ debug(processDataFlag, this.widget);
537
+ }
538
+ //onExplore might set the outer layout
539
+ if (this.widget.onExplore) this.widget.onExplore(context, this);
540
+ if (this.parent?.outerLayout === this) {
541
+ this.renderList = this.renderList.insertRight();
542
+ context.pushNamedValue("content", "body", this.parent);
543
+ }
544
+ if (this.widget.outerLayout) {
545
+ this.outerLayout = this.getChild(context, this.widget.outerLayout, null, this.store);
546
+ this.outerLayout.scheduleExploreIfVisible(context);
547
+ this.renderList = this.renderList.insertLeft();
548
+ }
549
+ if (this.widget.isContent) {
550
+ this.contentPlaceholder = context.contentPlaceholder && context.contentPlaceholder[this.widget.putInto];
551
+ if (this.contentPlaceholder) context.contentPlaceholder[this.widget.putInto](this);
552
+ else {
553
+ this.renderList = this.renderList.insertLeft();
554
+ context.pushNamedValue("content", this.widget.putInto, this);
555
+ if (!context.contentList) context.contentList = {};
556
+ let list = context.contentList[this.widget.putInto];
557
+ if (!list) list = context.contentList[this.widget.putInto] = [];
558
+ list.push(this);
559
+ }
560
+ }
561
+ this.shouldUpdate = false;
562
+ if (shouldUpdate || this.childStateDirty || !this.widget.memoize) this.markShouldUpdate(context);
563
+ context.exploreStack.hop();
564
+ if (this.widget.helpers) {
565
+ this.helpers = {};
566
+ for (let cmp in this.widget.helpers) {
567
+ let helper = this.widget.helpers[cmp];
568
+ if (helper) {
569
+ let ins = this.getChild(context, helper);
570
+ if (ins.scheduleExploreIfVisible(context)) this.helpers[cmp] = ins;
571
+ }
572
+ }
573
+ }
574
+ //TODO: check do we need to pass data here?
575
+ this.widget.explore(context, this, this.data);
576
+ }
577
+ prepare(context) {
578
+ if (!this.visible) throw new Error("Prepare invisible!");
579
+ if (this.prepared) {
580
+ if (this.widget.prepareCleanup) this.widget.prepareCleanup(context, this);
581
+ return;
582
+ }
583
+ this.prepared = true;
584
+ if (this.widget.prepare) this.widget.prepare(context, this);
585
+ if (this.widget.controller && this.controller?.prepare) this.controller.prepare(context);
586
+ }
587
+ render(context) {
588
+ if (!this.visible) throw new Error("Render invisible!");
589
+ if (this.shouldUpdate) {
590
+ debug(renderFlag, this.widget, this.key);
591
+ const vdom = renderResultFix(this.widget.render(context, this, this.key));
592
+ if (this.widget.isContent || this.outerLayout) this.contentVDOM = vdom;
593
+ else this.vdom = vdom;
594
+ }
595
+ if (this.cacheList) {
596
+ for (const key in this.cacheList) {
597
+ this.cached[key] = this.cacheList[key];
598
+ }
599
+ }
600
+ this.cacheList = null;
601
+ this.cached.rawData = this.rawData;
602
+ this.cached.data = this.data;
603
+ this.cached.state = this.state;
604
+ this.cached.widgetVersion = this.widget.version;
605
+ this.cached.globalCacheIdentifier = GlobalCacheIdentifier.get();
606
+ this.childStateDirty = false;
607
+ if (this.instanceCache) this.instanceCache.sweep();
608
+ if (this.parent?.outerLayout === this) {
609
+ //if outer layouts are chained we need to find the originating element (last element with OL set)
610
+ let parent = this.parent;
611
+ while (parent.parent?.outerLayout == parent) parent = parent.parent;
612
+ parent.vdom = this.vdom;
613
+ }
614
+ return this.vdom;
615
+ }
616
+ cleanup(context) {
617
+ if (this.widget.controller && this.controller?.cleanup) this.controller.cleanup(context);
618
+ if (this.widget.cleanup) this.widget.cleanup(context, this);
619
+ }
620
+ trackDestroy() {
621
+ if (!this.destroyTracked) {
622
+ this.destroyTracked = true;
623
+ if (this.parent && !this.detached) this.parent.trackDestroyableChild(this);
624
+ }
625
+ }
626
+ trackDestroyableChild(child) {
627
+ this.instanceCache.trackDestroy(child);
628
+ this.trackDestroy();
629
+ }
630
+ subscribeOnDestroy(callback) {
631
+ if (!this.destroySubscriptions) this.destroySubscriptions = [];
632
+ this.destroySubscriptions.push(callback);
633
+ this.trackDestroy();
634
+ return () => {
635
+ if (this.destroySubscriptions) {
636
+ this.destroySubscriptions = this.destroySubscriptions.filter((cb) => cb !== callback);
637
+ }
638
+ };
639
+ }
640
+ destroy() {
641
+ if (this.instanceCache) {
642
+ this.instanceCache.destroy();
643
+ this.instanceCache = null;
644
+ }
645
+ if (this.destroySubscriptions) {
646
+ this.destroySubscriptions.forEach((cb) => cb());
647
+ this.destroySubscriptions = null;
648
+ }
649
+ if (this.destroyTracked) {
650
+ debug(destroyFlag, this);
651
+ if (this.widget.onDestroy) this.widget.onDestroy(this);
652
+ if (
653
+ this.widget.controller &&
654
+ this.controller &&
655
+ this.controller.onDestroy &&
656
+ this.controller.widget == this.widget
657
+ )
658
+ this.controller.onDestroy();
659
+ this.destroyTracked = false;
660
+ }
661
+ }
662
+ setState(state) {
663
+ let skip = !!this.state;
664
+ if (this.state) {
665
+ for (const k in state) {
666
+ if (this.state[k] !== state[k]) {
667
+ skip = false;
668
+ break;
669
+ }
670
+ }
671
+ }
672
+ if (skip) return;
673
+ this.state = Object.assign({}, this.state, state);
674
+ let parent = this.parent;
675
+ //notify all parents that child state change to bust up caching
676
+ while (parent) {
677
+ parent.childStateDirty = true;
678
+ parent = parent.parent;
679
+ }
680
+ batchUpdates(() => {
681
+ this.store.notify();
682
+ });
683
+ }
684
+ set(prop, value, options = {}) {
685
+ //skip re-rendering (used for reading state from uncontrolled components)
686
+ if (options.internal && this.rawData) {
687
+ this.rawData[prop] = value;
688
+ this.data[prop] = value;
689
+ }
690
+ const setter = this.setters && this.setters[prop];
691
+ if (setter) {
692
+ if (options.immediate && isFunction(setter.reset)) setter.reset(value);
693
+ else setter(value);
694
+ return true;
695
+ }
696
+ const p = this.widget[prop];
697
+ if (p && typeof p == "object") {
698
+ if (p.debounce) {
699
+ this.definePropertySetter(
700
+ prop,
701
+ validatedDebounce(
702
+ (value) => this.doSet(prop, value),
703
+ () => this.dataSelector(this.store)[prop],
704
+ p.debounce,
705
+ ),
706
+ );
707
+ this.set(prop, value, options);
708
+ return true;
709
+ }
710
+ if (p.throttle) {
711
+ this.definePropertySetter(
712
+ prop,
713
+ throttle((value) => this.doSet(prop, value), p.throttle),
714
+ );
715
+ this.set(prop, value, options);
716
+ return true;
717
+ }
718
+ }
719
+ return this.doSet(prop, value);
720
+ }
721
+ definePropertySetter(prop, setter) {
722
+ if (!this.setters) this.setters = {};
723
+ this.setters[prop] = setter;
724
+ }
725
+ doSet(prop, value) {
726
+ let changed = false;
727
+ batchUpdates(() => {
728
+ const p = this.widget[prop];
729
+ if (isObject(p)) {
730
+ const pObj = p;
731
+ if (pObj.set) {
732
+ if (isFunction(pObj.set)) {
733
+ pObj.set(value, this);
734
+ changed = true;
735
+ } else if (isString(pObj.set)) {
736
+ this.controller?.[pObj.set](value, this);
737
+ changed = true;
738
+ }
739
+ } else if (pObj.action) {
740
+ const action = pObj.action(value, this);
741
+ this.store.dispatch(action);
742
+ changed = true;
743
+ } else if (isString(pObj.bind) || isAccessorChain(pObj.bind)) {
744
+ changed = this.store.set(pObj.bind, value);
745
+ }
746
+ } else if (isAccessorChain(p)) {
747
+ changed = this.store.set(p.toString(), value);
748
+ }
749
+ });
750
+ return changed;
751
+ }
752
+ nestedDataSet(key, value, dataConfig, useParentStore) {
753
+ let config = dataConfig[key];
754
+ if (!config)
755
+ throw new Error(`Unknown nested data key ${key}. Known keys are ${Object.keys(dataConfig).join(", ")}.`);
756
+ if (isAccessorChain(config))
757
+ config = {
758
+ bind: config.toString(),
759
+ };
760
+ if (config.bind) {
761
+ let store = this.store;
762
+ //in case of Rescope or DataProxy, bindings point to the data in the parent store
763
+ if (useParentStore && store.store) store = store.store;
764
+ return isUndefined(value) ? store.deleteItem(config.bind) : store.setItem(config.bind, value);
765
+ }
766
+ if (!config.set)
767
+ throw new Error(
768
+ `Cannot change nested data value for ${key} as it's read-only. Either define it as a binding or define a set function.`,
769
+ );
770
+ if (isString(config.set)) this.getControllerMethod(config.set)(value, this);
771
+ else if (isFunction(config.set)) config.set(value, this);
772
+ else
773
+ throw new Error(
774
+ `Cannot change nested data value for ${key} the defined setter is neither a function nor a controller method.`,
775
+ );
776
+ return true;
777
+ }
778
+ replaceState(state) {
779
+ this.cached.state = this.state;
780
+ this.state = state;
781
+ this.store.notify();
782
+ }
783
+ getInstanceCache() {
784
+ if (!this.instanceCache)
785
+ this.instanceCache = new InstanceCache(this, this.widget.isPureContainer ? this.key : null);
786
+ return this.instanceCache;
787
+ }
788
+ clearChildrenCache() {
789
+ if (this.instanceCache) this.instanceCache.destroy();
790
+ }
791
+ getChild(context, widget, key, store) {
792
+ return this.getInstanceCache().getChild(widget, store ?? this.store, key);
793
+ }
794
+ getDetachedChild(widget, key, store) {
795
+ const child = widget.createInstance(key, this, store ?? this.store);
796
+ child.detached = true;
797
+ return child;
798
+ }
799
+ prepareRenderCleanupChild(widget, store, keyPrefix, options) {
800
+ return widget.prepareRenderCleanup(store ?? this.store, options, keyPrefix, this);
801
+ }
802
+ getJsxEventProps() {
803
+ const { widget } = this;
804
+ if (!isArray(widget.jsxAttributes)) return null;
805
+ const props = {};
806
+ widget.jsxAttributes.forEach((attr) => {
807
+ if (attr.indexOf("on") == 0 && attr.length > 2) {
808
+ props[attr] = (e) => this.invoke(attr, e, this);
809
+ }
810
+ });
811
+ return props;
812
+ }
813
+ getCallback(methodName) {
814
+ const scope = this.widget;
815
+ const callback = scope[methodName];
816
+ if (typeof callback === "string") return this.getControllerMethod(callback);
817
+ if (typeof callback !== "function")
818
+ throw new Error(`Cannot invoke callback method ${methodName} as assigned value is not a function.`);
819
+ return callback.bind(scope);
820
+ }
821
+ /**
822
+ * Finds the first controller in the instance tree matching the predicate
823
+ * @param predicate Function to test each controller
824
+ * @returns The matching controller or undefined
825
+ */
826
+ findController(predicate) {
827
+ let at = this;
828
+ while (at?.controller != null) {
829
+ if (predicate(at.controller)) {
830
+ return at.controller;
831
+ }
832
+ at = at.parent;
833
+ }
834
+ return undefined;
835
+ }
836
+ /**
837
+ * Finds a controller of the specified type in the instance tree
838
+ * @param type Controller class/constructor to find
839
+ * @returns The matching controller cast to the specified type, or undefined
840
+ */
841
+ findControllerByType(type) {
842
+ return this.findController((c) => c instanceof type);
843
+ }
844
+ /**
845
+ * Gets the first controller in the instance tree matching the predicate
846
+ * @param predicate Function to test each controller
847
+ * @returns The matching controller
848
+ * @throws Error if no matching controller is found
849
+ */
850
+ getController(predicate) {
851
+ const controller = this.findController(predicate);
852
+ if (!controller) throw new Error("Cannot find a controller matching the given predicate in the instance tree.");
853
+ return controller;
854
+ }
855
+ /**
856
+ * Gets a controller of the specified type in the instance tree
857
+ * @param type Controller class/constructor to find
858
+ * @returns The matching controller cast to the specified type
859
+ * @throws Error if no controller of the specified type is found
860
+ */
861
+ getControllerByType(type) {
862
+ const controller = this.findControllerByType(type);
863
+ if (!controller) throw new Error(`Cannot find a controller of type "${type.name}" in the instance tree.`);
864
+ return controller;
865
+ }
866
+ getControllerMethod(methodName) {
867
+ if (!this.controller)
868
+ throw new Error(`Cannot invoke controller method "${methodName}" as controller is not assigned to the widget.`);
869
+ const controller = this.findController((c) => !!c[methodName]);
870
+ if (!controller)
871
+ throw new Error(
872
+ `Cannot invoke controller method "${methodName}". The method cannot be found in any of the assigned controllers.`,
873
+ );
874
+ return controller[methodName].bind(controller);
875
+ }
876
+ invoke(methodName, ...args) {
877
+ return this.getCallback(methodName).apply(null, args);
878
+ }
879
+ invokeControllerMethod(methodName, ...args) {
880
+ return this.getControllerMethod(methodName).apply(null, args);
881
+ }
882
+ }
883
+ function renderResultFix(res) {
884
+ return res != null && isDefined(res.content)
885
+ ? res
886
+ : {
887
+ content: res,
888
+ };
889
+ }
890
+ class InstanceCache {
891
+ constructor(parent, keyPrefix) {
892
+ this.children = {};
893
+ this.parent = parent;
894
+ this.marked = {};
895
+ this.monitored = null;
896
+ this.keyPrefix = keyPrefix != null ? keyPrefix + "-" : "";
897
+ }
898
+ getChild(widget, parentStore, key) {
899
+ const k = this.keyPrefix + (key != null ? key : widget.vdomKey || widget.widgetId);
900
+ let instance = this.children[k];
901
+ if (
902
+ !instance ||
903
+ instance.widget !== widget ||
904
+ (!instance.visible && (instance.widget.controller || instance.widget.onInit))
905
+ ) {
906
+ instance = widget.createInstance(k, this.parent, parentStore);
907
+ this.children[k] = instance;
908
+ } else if (instance.parentStore !== parentStore) {
909
+ instance.setParentStore(parentStore);
910
+ }
911
+ return instance;
912
+ }
913
+ addChild(instance) {
914
+ this.marked[instance.key] = instance;
915
+ }
916
+ mark() {
917
+ this.marked = {};
918
+ }
919
+ trackDestroy(instance) {
920
+ if (!this.monitored) this.monitored = {};
921
+ this.monitored[instance.key] = instance;
922
+ }
923
+ destroy() {
924
+ this.children = {};
925
+ this.marked = {};
926
+ if (!this.monitored) return;
927
+ for (const key in this.monitored) {
928
+ this.monitored[key].destroy();
929
+ }
930
+ this.monitored = null;
931
+ }
932
+ sweep() {
933
+ this.children = this.marked;
934
+ if (!this.monitored) return;
935
+ let activeCount = 0;
936
+ for (const key in this.monitored) {
937
+ const monitoredChild = this.monitored[key];
938
+ const child = this.children[key];
939
+ if (child !== monitoredChild || !monitoredChild.visible) {
940
+ monitoredChild.destroy();
941
+ delete this.monitored[key];
942
+ if (child === monitoredChild) delete this.children[key];
943
+ } else activeCount++;
944
+ }
945
+ if (activeCount === 0) this.monitored = null;
946
+ }
947
+ }
948
+
949
+ const VDOM = VDOM$1;
950
+ let widgetId = 100;
951
+ class Widget extends Component {
952
+ // runtime values
953
+ widgetId;
954
+ initialized;
955
+ components;
956
+ helpers;
957
+ selector;
958
+ nameMap;
959
+ version;
960
+ static optimizePrepare;
961
+ constructor(config) {
962
+ super(config);
963
+ this.widgetId = widgetId++;
964
+ if (isArray(this.jsxSpread)) {
965
+ if (!this.jsxAttributes) this.jsxAttributes = [];
966
+ this.jsxSpread.forEach((spread) => {
967
+ for (const key in spread) {
968
+ this[key] = spread[key];
969
+ this.jsxAttributes.push(key);
970
+ }
971
+ });
972
+ }
973
+ }
974
+ init() {
975
+ if (this.styles) this.style = this.styles;
976
+ if (this.styled) this.style = parseStyle(this.style);
977
+ if (typeof this.if !== "undefined") this.visible = this.if;
978
+ this.declareData();
979
+ if (this.outerLayout) {
980
+ if (isArray(this.outerLayout)) throw new Error("Only single element outer layout is supported.");
981
+ //TODO: better handle the case when outer layout is an array. How to get around circular dependency to PureContainer
982
+ this.outerLayout = Widget.create(this.outerLayout, {});
983
+ }
984
+ if (this.contentFor) this.putInto = this.contentFor;
985
+ if (this.putInto) this.isContent = true;
986
+ if (isString(this.CSS)) this.CSS = CSSHelper.get(this.CSS);
987
+ this.initHelpers();
988
+ this.initComponents();
989
+ this.initialized = true;
990
+ }
991
+ initComponents(...args) {
992
+ if (args.length > 0) {
993
+ this.components = Object.assign({}, ...args);
994
+ for (const k in this.components) {
995
+ if (!this.components[k]) delete this.components[k];
996
+ }
997
+ }
998
+ }
999
+ initHelpers(...args) {
1000
+ if (args.length > 0) {
1001
+ this.helpers = Object.assign({}, ...args);
1002
+ }
1003
+ }
1004
+ declareData(...args) {
1005
+ const options = {};
1006
+ if (this.styled) {
1007
+ options.class =
1008
+ options.className =
1009
+ options.style =
1010
+ {
1011
+ structured: true,
1012
+ };
1013
+ }
1014
+ const props = {
1015
+ visible: undefined,
1016
+ mod: {
1017
+ structured: true,
1018
+ },
1019
+ ...options,
1020
+ };
1021
+ Object.assign(props, ...args);
1022
+ this.selector = new StructuredSelector({
1023
+ props: props,
1024
+ values: this,
1025
+ });
1026
+ this.nameMap = this.selector.nameMap;
1027
+ }
1028
+ prepareCSS(_context, { data }) {
1029
+ data.classNames = this.CSS.expand(
1030
+ this.CSS.block(this.baseClass, data.mod, data.stateMods),
1031
+ data.class,
1032
+ data.className,
1033
+ );
1034
+ data.style = parseStyle(data.style);
1035
+ }
1036
+ prepareData(context, instance) {
1037
+ if (this.styled) this.prepareCSS(context, instance);
1038
+ }
1039
+ createInstance(key, parent, parentStore) {
1040
+ return new Instance(this, key, parent, parentStore);
1041
+ }
1042
+ initInstance(_context, _instance) {}
1043
+ initState(_context, _instance) {}
1044
+ checkVisible(_context, _instance, data) {
1045
+ return data.visible;
1046
+ }
1047
+ explore(context, instance, data) {
1048
+ if (this.components) {
1049
+ instance.components = {};
1050
+ for (const cmp in this.components) {
1051
+ const ins = instance.getChild(context, this.components[cmp], "cmp-" + cmp, instance.store);
1052
+ if (ins.scheduleExploreIfVisible(context)) instance.components[cmp] = ins;
1053
+ }
1054
+ }
1055
+ }
1056
+ render(context, instance, key) {
1057
+ Console.log(this);
1058
+ throw new Error(
1059
+ '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.',
1060
+ );
1061
+ }
1062
+ update() {
1063
+ this.version = (this.version || 0) + 1;
1064
+ }
1065
+ applyParentStore(instance) {
1066
+ instance.store = instance.parentStore;
1067
+ // check when this is actually needed, perhaps this is needed only for tables and repeated elements
1068
+ // if (instance.cached) delete instance.cached.rawData; // force prepareData to execute again
1069
+ }
1070
+ static resetCounter() {
1071
+ widgetId = 100;
1072
+ }
1073
+ }
1074
+ Widget.prototype.visible = true;
1075
+ Widget.prototype.memoize = true; //cache rendered content and use it if possible
1076
+ Widget.prototype.CSS = CSS;
1077
+ Widget.prototype.styled = false;
1078
+ Widget.namespace = "ui.";
1079
+ Widget.optimizePrepare = true;
1080
+ Widget.factory = (type, _config, _more) => {
1081
+ throw new Error(`Invalid widget type: ${type}.`);
1082
+ };
1083
+ function contentAppend(result, w, prependSpace) {
1084
+ if (w == null || w === false) return false;
1085
+ if (isArray(w)) w.forEach((c) => contentAppend(result, c));
1086
+ else if (isDefined(w.content) && !w.atomic) return contentAppend(result, w.content, false);
1087
+ else {
1088
+ if (prependSpace) result.push(" ");
1089
+ result.push(w);
1090
+ }
1091
+ return true;
1092
+ }
1093
+ function getContentArray(x) {
1094
+ let result = [];
1095
+ contentAppend(result, x, false);
1096
+ return result;
1097
+ }
1098
+ function getContent(x) {
1099
+ let result = getContentArray(x);
1100
+ if (result.length == 0) return null;
1101
+ if (result.length == 1) return result[0];
1102
+ return result;
1103
+ }
1104
+
1105
+ class Text extends Widget {
1106
+ constructor(config) {
1107
+ super(config);
1108
+ }
1109
+ init() {
1110
+ if (!this.value && (this.tpl || this.expr || this.bind))
1111
+ this.value = {
1112
+ tpl: this.tpl,
1113
+ expr: this.expr,
1114
+ bind: this.bind,
1115
+ };
1116
+ super.init();
1117
+ }
1118
+ declareData(...args) {
1119
+ super.declareData(
1120
+ {
1121
+ value: undefined,
1122
+ },
1123
+ ...args,
1124
+ );
1125
+ }
1126
+ render(context, { data }, key) {
1127
+ return data.value != null ? data.value : "";
1128
+ }
1129
+ }
1130
+ Widget.alias("text", Text);
1131
+
1132
+ class StaticText extends Widget {
1133
+ render() {
1134
+ return this.text;
1135
+ }
1136
+ }
1137
+ Widget.alias("static-text", StaticText);
1138
+
1139
+ function exploreChildren(context, instance, children, previousResult, key, store) {
1140
+ let newChildren = previousResult || [];
1141
+ let oldChildren = previousResult || newChildren;
1142
+ let identical = previousResult ? 0 : -1;
1143
+ for (let c = 0; c < children.length; c++) {
1144
+ let cell = instance.getChild(context, children[c], key, store);
1145
+ if (cell.checkVisible(context)) {
1146
+ if (identical >= 0) {
1147
+ if (cell == oldChildren[identical]) identical++;
1148
+ else {
1149
+ newChildren = newChildren.slice(0, identical);
1150
+ identical = -1;
1151
+ newChildren.push(cell);
1152
+ }
1153
+ } else newChildren.push(cell);
1154
+ context.exploreStack.push(cell);
1155
+ if (cell.needsExploreCleanup) context.exploreStack.push(cell);
1156
+ }
1157
+ }
1158
+ if (identical >= 0 && identical != newChildren.length) newChildren = newChildren.slice(0, identical);
1159
+ return newChildren;
1160
+ }
1161
+
1162
+ // Base class for extending with custom Config types
1163
+ class ContainerBase extends Widget {
1164
+ init(context) {
1165
+ if (typeof this.ws !== "undefined") this.preserveWhitespace = this.ws;
1166
+ if (this.preserveWhitespace) this.trimWhitespace = false;
1167
+ let items = this.items || this.children || [];
1168
+ delete this.children;
1169
+ this.items = [];
1170
+ if (this.layout) {
1171
+ let layout = Container.create(this.layout, {
1172
+ items,
1173
+ });
1174
+ layout.init(context);
1175
+ this.layout = null;
1176
+ if ("noLayout" in layout && layout.noLayout) {
1177
+ this.useParentLayout = true;
1178
+ this.add(items);
1179
+ } else {
1180
+ this.add(layout);
1181
+ this.layout = layout;
1182
+ }
1183
+ } else {
1184
+ this.add(items);
1185
+ }
1186
+ super.init();
1187
+ }
1188
+ exploreItems(context, instance, items) {
1189
+ instance.children = exploreChildren(context, instance, items, instance.cached.children, null, instance.store);
1190
+ if (instance.cache("children", instance.children)) instance.markShouldUpdate(context);
1191
+ }
1192
+ explore(context, instance) {
1193
+ super.explore(context, instance);
1194
+ this.exploreItems(context, instance, this.items);
1195
+ }
1196
+ render(context, instance, key) {
1197
+ return this.renderChildren(context, instance, key);
1198
+ }
1199
+ renderChildren(_context, instance, key) {
1200
+ let preserveComplexContent = this.useParentLayout;
1201
+ function append(result, r) {
1202
+ if (r == null) return;
1203
+ //react element
1204
+ if (!r.hasOwnProperty("content")) {
1205
+ contentAppend(result, r);
1206
+ return;
1207
+ }
1208
+ if (r.useParentLayout) return r.content.forEach((x) => append(result, x));
1209
+ if (r.atomic || preserveComplexContent) {
1210
+ result.push(r);
1211
+ } else {
1212
+ let first = true;
1213
+ for (let k in r) if (contentAppend(result, r[k], !first)) first = false;
1214
+ }
1215
+ }
1216
+ let result = [];
1217
+ for (let i = 0; i < instance.children.length; i++) {
1218
+ append(result, instance.children[i].vdom);
1219
+ }
1220
+ if (this.useParentLayout)
1221
+ return {
1222
+ useParentLayout: true,
1223
+ content: result,
1224
+ };
1225
+ return result;
1226
+ }
1227
+ clear() {
1228
+ if (this.layout) this.layout.clear();
1229
+ else this.items = [];
1230
+ }
1231
+ add(...args) {
1232
+ if (this.layout) return this.layout.add(...args);
1233
+ for (let a of args) {
1234
+ if (!a) continue;
1235
+ if (isArray(a)) {
1236
+ for (let c of a) this.add(c);
1237
+ } else if (isString(a)) {
1238
+ if (this.trimWhitespace) a = innerTextTrim(a);
1239
+ if (a) this.addText(a);
1240
+ } else if (a.isComponent) this.items.push(this.wrapItem(a));
1241
+ else {
1242
+ this.add(Widget.create(a, this.itemDefaults, {}));
1243
+ }
1244
+ }
1245
+ }
1246
+ wrapItem(item) {
1247
+ return item;
1248
+ }
1249
+ addText(text) {
1250
+ if (this.plainText || text.indexOf("{") == -1 || text.indexOf("}") == -1)
1251
+ this.add(
1252
+ Widget.create(
1253
+ StaticText,
1254
+ {
1255
+ text: text,
1256
+ },
1257
+ {},
1258
+ ),
1259
+ );
1260
+ else
1261
+ this.add(
1262
+ Widget.create(
1263
+ Text,
1264
+ {
1265
+ text: {
1266
+ tpl: text,
1267
+ },
1268
+ },
1269
+ {},
1270
+ ),
1271
+ );
1272
+ }
1273
+ find(filter, options) {
1274
+ if (!options) options = {};
1275
+ if (!filter || !this.items) return [];
1276
+ let alias = filter;
1277
+ if (isString(filter)) filter = (w) => w.componentAlias == alias;
1278
+ if (filter.isComponentType) filter = (w) => w instanceof alias;
1279
+ let results = [];
1280
+ for (let i = 0; i < this.items.length; i++) {
1281
+ let w = this.items[i];
1282
+ if (w && !w.initialized) w.init();
1283
+ if (filter(w)) {
1284
+ results.push(w);
1285
+ if (options.first) break;
1286
+ }
1287
+ if (w && w.find) results.push(...w.find(filter, options));
1288
+ }
1289
+ return results;
1290
+ }
1291
+ findFirst(filter, options) {
1292
+ return this.find(filter, {
1293
+ ...options,
1294
+ first: true,
1295
+ })[0];
1296
+ }
1297
+ }
1298
+ ContainerBase.prototype.trimWhitespace = true;
1299
+ ContainerBase.prototype.plainText = true;
1300
+ ContainerBase.prototype.styled = false;
1301
+ // Closed type for direct usage - preserves ControllerProp ThisType
1302
+ class Container extends ContainerBase {}
1303
+ // Base class for styled containers with custom Config types
1304
+ class StyledContainerBase extends ContainerBase {}
1305
+ StyledContainerBase.prototype.styled = true;
1306
+
1307
+ // Base class for extending with custom Config types
1308
+ class PureContainerBase extends ContainerBase {}
1309
+ PureContainerBase.prototype.isPureContainer = true;
1310
+ // Closed type for direct usage - preserves ControllerProp ThisType
1311
+ class PureContainer extends PureContainerBase {}
1312
+ PureContainer.alias("pure-container", PureContainer);
1313
+
1314
+ class IsolatedScope extends PureContainerBase {
1315
+ declareData(...args) {
1316
+ return super.declareData(...args, {
1317
+ data: {
1318
+ structured: true,
1319
+ },
1320
+ });
1321
+ }
1322
+ init() {
1323
+ if (typeof this.bind === "string")
1324
+ this.data = {
1325
+ bind: this.bind,
1326
+ };
1327
+ else if (isArray(this.bind)) {
1328
+ let data = {};
1329
+ this.bind.forEach((x, i) => {
1330
+ data[String(i)] = {
1331
+ bind: x,
1332
+ };
1333
+ });
1334
+ this.data = data;
1335
+ }
1336
+ super.init();
1337
+ }
1338
+ explore(context, instance) {
1339
+ if (instance.shouldUpdate) {
1340
+ super.explore(context, instance);
1341
+ } else if (instance.children) {
1342
+ // mark children to prevent sweeping them away
1343
+ for (let i = 0; i < instance.children.length; i++) instance.instanceCache.addChild(instance.children[i]);
1344
+ }
1345
+ }
1346
+ }
1347
+
1348
+ class RenderingContext {
1349
+ options;
1350
+ exploreStack;
1351
+ prepareList;
1352
+ cleanupList;
1353
+ stacks;
1354
+ renderList;
1355
+ constructor(options) {
1356
+ this.options = options || {};
1357
+ this.exploreStack = new TraversalStack();
1358
+ this.prepareList = [];
1359
+ this.cleanupList = [];
1360
+ this.stacks = {};
1361
+ this.renderList = new LinkedListsNode();
1362
+ }
1363
+ getStack(key) {
1364
+ let stack = this.stacks[key];
1365
+ if (!stack) stack = this.stacks[key] = [];
1366
+ return stack;
1367
+ }
1368
+ push(key, value) {
1369
+ let stack = this.getStack(key);
1370
+ stack.push(this[key]);
1371
+ return (this[key] = value);
1372
+ }
1373
+ pop(key) {
1374
+ let stack = this.getStack(key);
1375
+ return (this[key] = stack.pop());
1376
+ }
1377
+ pushNamedValue(key, name, value) {
1378
+ let stack = this.getStack(`${key}:${name}`);
1379
+ if (!this[key]) this[key] = {};
1380
+ stack.push(this[key][name]);
1381
+ return (this[key][name] = value);
1382
+ }
1383
+ popNamedValue(key, name) {
1384
+ let stack = this.getStack(`${key}:${name}`);
1385
+ return (this[key][name] = stack.pop());
1386
+ }
1387
+ get(key) {
1388
+ return this[key];
1389
+ }
1390
+ getRootRenderList() {
1391
+ let rl = this.renderList;
1392
+ while (rl.left) rl = rl.left;
1393
+ return rl;
1394
+ }
1395
+ }
1396
+ class LinkedListsNode {
1397
+ left;
1398
+ right;
1399
+ data;
1400
+ reverseIndex;
1401
+ constructor(left, right) {
1402
+ this.left = left;
1403
+ this.right = right;
1404
+ this.data = [];
1405
+ }
1406
+ insertLeft() {
1407
+ let node = new LinkedListsNode(this.left, this);
1408
+ if (this.left) this.left.right = node;
1409
+ this.left = node;
1410
+ return node;
1411
+ }
1412
+ insertRight() {
1413
+ let node = new LinkedListsNode(this, this.right);
1414
+ if (this.right) this.right.left = node;
1415
+ this.right = node;
1416
+ return node;
1417
+ }
1418
+ markReverseIndex() {
1419
+ this.reverseIndex = this.data.length;
1420
+ }
1421
+ reverse() {
1422
+ reverseSlice(this.data, this.reverseIndex);
1423
+ }
1424
+ }
1425
+
1426
+ let contents = {};
1427
+ let localizations = {};
1428
+ let overrides = {};
1429
+ let defaults = {};
1430
+ let trackDefaults = false;
1431
+ class Localization {
1432
+ static register(key) {
1433
+ return (type) => {
1434
+ this.registerPrototype(key, type);
1435
+ return type;
1436
+ };
1437
+ }
1438
+ static registerPrototype(key, type) {
1439
+ contents[key] = type.prototype;
1440
+ if (overrides[key]) this.override(key, overrides[key]);
1441
+ }
1442
+ static trackDefaults() {
1443
+ trackDefaults = true;
1444
+ }
1445
+ static restoreDefaults() {
1446
+ for (let type in defaults) {
1447
+ let proto = contents[type];
1448
+ if (!proto) continue;
1449
+ let d = defaults[type];
1450
+ for (let key in d) proto[key] = d[key];
1451
+ }
1452
+ defaults = {};
1453
+ }
1454
+ static override(key, values) {
1455
+ overrides[key] = values;
1456
+ let p = contents[key];
1457
+ if (p) {
1458
+ if (trackDefaults && !defaults[key]) {
1459
+ let d = (defaults[key] = {});
1460
+ for (let key in values) d[key] = p[key];
1461
+ }
1462
+ Object.assign(p, values);
1463
+ }
1464
+ }
1465
+ static localize(culture, key, values) {
1466
+ let l = localizations[culture];
1467
+ if (!l) l = localizations[culture] = {};
1468
+ l[key] = {
1469
+ ...l[key],
1470
+ ...values,
1471
+ };
1472
+ }
1473
+ static setCulture(culture) {
1474
+ var l = localizations[culture];
1475
+ if (l) {
1476
+ for (var key in l) {
1477
+ var content = contents[key];
1478
+ if (content) Object.assign(content, l[key]);
1479
+ }
1480
+ }
1481
+ }
1482
+ }
1483
+
1484
+ // @ts-expect-error
1485
+ let stack = [
1486
+ {
1487
+ culture: "en",
1488
+ numberCulture: null,
1489
+ dateTimeCulture: null,
1490
+ cache: {},
1491
+ defaultCurrency: "USD",
1492
+ dateEncoding: (date) => date.toISOString(),
1493
+ timezone: null,
1494
+ },
1495
+ ];
1496
+ function getDefaultCulture() {
1497
+ return stack[0];
1498
+ }
1499
+ function getCurrentCulture() {
1500
+ return stack[stack.length - 1];
1501
+ }
1502
+ function pushCulture(cultureInfo) {
1503
+ stack.push(cultureInfo);
1504
+ }
1505
+ function popCulture(cultureSpecs) {
1506
+ if (stack.length == 1) throw new Error("Cannot pop the last culture object.");
1507
+ if (cultureSpecs && stack[stack.length - 1] !== cultureSpecs) {
1508
+ Console.warn("Popped culture object does not match the current one.");
1509
+ }
1510
+ return stack.pop();
1511
+ }
1512
+ class Culture {
1513
+ static setCulture(cultureCode) {
1514
+ let cultureSpecs = getDefaultCulture();
1515
+ cultureSpecs.culture = cultureCode;
1516
+ cultureSpecs.cache = {};
1517
+ Localization.setCulture(cultureCode);
1518
+ this.invalidateCache();
1519
+ }
1520
+ static setNumberCulture(cultureCode) {
1521
+ let cultureSpecs = getDefaultCulture();
1522
+ cultureSpecs.numberCulture = cultureCode;
1523
+ delete cultureSpecs.cache.numberCulture;
1524
+ this.invalidateCache();
1525
+ }
1526
+ static setDateTimeCulture(cultureCode) {
1527
+ let cultureSpecs = getDefaultCulture();
1528
+ cultureSpecs.dateTimeCulture = cultureCode;
1529
+ delete cultureSpecs.cache.dateTimeCulture;
1530
+ this.invalidateCache();
1531
+ }
1532
+ static setDefaultCurrency(currencyCode) {
1533
+ let cultureSpecs = getDefaultCulture();
1534
+ cultureSpecs.defaultCurrency = currencyCode;
1535
+ this.invalidateCache();
1536
+ }
1537
+ static setDefaultTimezone(timezone) {
1538
+ let cultureSpecs = getDefaultCulture();
1539
+ cultureSpecs.timezone = timezone;
1540
+ this.invalidateCache();
1541
+ }
1542
+ static setDefaultDateEncoding(encoding) {
1543
+ let cultureSpecs = getDefaultCulture();
1544
+ cultureSpecs.dateEncoding = encoding;
1545
+ this.invalidateCache();
1546
+ }
1547
+ static invalidateCache() {
1548
+ GlobalCacheIdentifier.change();
1549
+ invalidateExpressionCache();
1550
+ invalidateStringTemplateCache();
1551
+ }
1552
+ static get defaultCurrency() {
1553
+ return getCurrentCulture().defaultCurrency;
1554
+ }
1555
+ static get culture() {
1556
+ return getCurrentCulture().culture;
1557
+ }
1558
+ static getNumberCulture() {
1559
+ let { cache, numberCulture, culture } = getCurrentCulture();
1560
+ if (!cache.numberCulture) cache.numberCulture = new NumberCulture(numberCulture ?? culture);
1561
+ return cache.numberCulture;
1562
+ }
1563
+ static getDateTimeCulture() {
1564
+ let { cache, dateTimeCulture, culture, timezone } = getCurrentCulture();
1565
+ if (!cache.dateTimeCulture)
1566
+ cache.dateTimeCulture = new DateTimeCulture(dateTimeCulture ?? culture, {
1567
+ defaultTimezone: timezone,
1568
+ });
1569
+ return cache.dateTimeCulture;
1570
+ }
1571
+ static getDefaultDateEncoding() {
1572
+ return getCurrentCulture().dateEncoding;
1573
+ }
1574
+ static getComparer(options) {
1575
+ let { culture } = getCurrentCulture();
1576
+ if (typeof Intl.Collator != "undefined") return new Intl.Collator(culture, options).compare;
1577
+ return defaultCompare;
1578
+ }
1579
+ }
1580
+
1581
+ // On by default. Once a synchronous update burst grows deep, Cx starts issuing updates from microtasks
1582
+ // so React's global nested-update counter resets before continuing -- preventing "Maximum update depth
1583
+ // exceeded" on large renders that write to the store while they render (e.g. a several-hundred-page
1584
+ // report). For updates that settle in a single render -- virtually all of them -- this is equivalent to
1585
+ // rendering synchronously; it only diverges under a deep re-entrant render burst. If you suspect it
1586
+ // causes trouble, opt out at app startup with disableSyncUpdateCoalescing() -- and please report the
1587
+ // issue so it can be fixed.
1588
+ // Synchronous updates allowed within one burst before Cx switches to issuing updates from a microtask.
1589
+ // Kept under React's ~50 nested-update limit (which is global to the root, not per component); the
1590
+ // default trades a little initial-render time for a safety margin. Override via
1591
+ // enableSyncUpdateCoalescing(limit) if needed.
1592
+ const defaultSyncBurstLimit = 35;
1593
+ let syncBurstLimit = defaultSyncBurstLimit;
1594
+ // Microtask-issued updates allowed within one burst before Cx escalates to setTimeout. Deep enough that
1595
+ // only a store that never converges reaches it; timeouts let the event loop turn, so the page stays
1596
+ // responsive and batchUpdatesAndNotify fallback timers can fire instead of the tab hanging.
1597
+ let microtaskBurstLimit = 1000;
1598
+ // Module-global because React's nested-update limit is global to the root, not per component. The burst
1599
+ // counter resets only when all notifications settle (see completeNotification) -- tying the burst
1600
+ // window to unsettled work makes it immune to how React schedules the flushes. Legacy React chains
1601
+ // re-entrant updates synchronously within one task, but React 19 may run each round from its own
1602
+ // microtask, so no task/microtask boundary is a reliable reset point.
1603
+ let syncBurstRounds = 0; // updates issued in the current burst
1604
+ let outstandingNotifications = 0; // reported notifications not yet rendered, across all Cx instances
1605
+ class Cx extends VDOM.Component {
1606
+ widget;
1607
+ store;
1608
+ parentInstance;
1609
+ instance;
1610
+ flags;
1611
+ renderCount;
1612
+ unsubscribe;
1613
+ forceUpdateCallback;
1614
+ deferCounter;
1615
+ pendingUpdateTimer;
1616
+ unsubscribeIdleRequest;
1617
+ // store notifications reported to batchUpdatesAndNotify subscribers but not yet rendered and completed
1618
+ owedNotifications = new Set();
1619
+ // setState is not allowed before the component mounts; pre-mount notifications set flags.dirty instead
1620
+ // and componentDidMount picks them up (see update())
1621
+ mounted = false;
1622
+ // true once this instance has contributed to syncBurstRounds for the current render round; cleared on
1623
+ // render, so bursts are counted per round rather than per notification (see update())
1624
+ burstRoundCounted = false;
1625
+ constructor(props) {
1626
+ super(props);
1627
+ if (props.instance) {
1628
+ this.widget = props.instance.widget;
1629
+ this.store = props.instance.store;
1630
+ } else {
1631
+ this.widget = PureContainer.create({
1632
+ items: props.widget || props.items,
1633
+ });
1634
+ if (props.parentInstance) {
1635
+ this.parentInstance = props.parentInstance;
1636
+ this.store = props.store || this.parentInstance.store;
1637
+ } else {
1638
+ this.parentInstance = new Instance(this.widget, "0", undefined, props.store);
1639
+ this.store = props.store;
1640
+ }
1641
+ if (!this.store) throw new Error("Cx component requires a store.");
1642
+ }
1643
+ this.state = {
1644
+ deferToken: 0,
1645
+ data: props.subscribe ? this.store.getData() : null,
1646
+ };
1647
+ if (props.subscribe) {
1648
+ this.unsubscribe = this.store.subscribe(this.update.bind(this));
1649
+ }
1650
+ this.flags = {};
1651
+ this.renderCount = 0;
1652
+ this.forceUpdateCallback = this.forceUpdate.bind(this);
1653
+ // deferredUntilIdle content stays hidden until the idle callback scheduled on mount bumps the token
1654
+ this.deferCounter = props.deferredUntilIdle ? 1 : 0;
1655
+ }
1656
+ UNSAFE_componentWillReceiveProps(props) {
1657
+ let newStore = props.instance ? props.instance.store : props.store ? props.store : props.parentInstance.store;
1658
+ if (newStore != this.store) {
1659
+ this.store = newStore;
1660
+ if (this.unsubscribe) this.unsubscribe();
1661
+ if (props.subscribe) this.unsubscribe = this.store.subscribe(this.update.bind(this));
1662
+ }
1663
+ if (props.subscribe) {
1664
+ let data = this.store.getData();
1665
+ if (data !== this.state.data) {
1666
+ this.waitForIdle();
1667
+ this.setState({
1668
+ data,
1669
+ });
1670
+ }
1671
+ }
1672
+ }
1673
+ getInstance() {
1674
+ if (this.props.instance) return this.props.instance;
1675
+ if (this.instance && this.instance.widget === this.widget) {
1676
+ if (this.instance.parentStore != this.store) this.instance.setParentStore(this.store);
1677
+ return this.instance;
1678
+ }
1679
+ if (this.widget && this.parentInstance)
1680
+ return (this.instance = this.parentInstance.getDetachedChild(this.widget, "0", this.store));
1681
+ throw new Error("Could not resolve a widget instance in the Cx component.");
1682
+ }
1683
+ render() {
1684
+ this.burstRoundCounted = false;
1685
+ // an error was captured and is being dispatched to the onError callback (see componentDidCatch);
1686
+ // render nothing until the callback repairs the state
1687
+ if (this.state.error) return null;
1688
+ if (this.props.deferredUntilIdle && this.state.deferToken < this.deferCounter) return null;
1689
+ let cultureInfo = this.props.cultureInfo ?? getCurrentCulture();
1690
+ return jsx(CxContext, {
1691
+ instance: this.getInstance(),
1692
+ flags: this.flags,
1693
+ options: this.props.options,
1694
+ buster: ++this.renderCount,
1695
+ contentFactory: this.props.contentFactory,
1696
+ forceUpdate: this.forceUpdateCallback,
1697
+ cultureInfo: cultureInfo,
1698
+ });
1699
+ }
1700
+ componentDidMount() {
1701
+ this.mounted = true;
1702
+ // schedule the deferredUntilIdle reveal here rather than in the constructor -- the idle callback
1703
+ // could otherwise fire before the component mounts and issue a setState React does not allow yet
1704
+ this.waitForIdle();
1705
+ this.componentDidUpdate();
1706
+ if (this.props.options && this.props.options.onPipeUpdate) this.props.options.onPipeUpdate(this.update.bind(this));
1707
+ }
1708
+ componentDidUpdate() {
1709
+ if (this.flags.dirty) {
1710
+ this.update();
1711
+ }
1712
+ }
1713
+ update() {
1714
+ let data = this.store.getData();
1715
+ debug(appDataFlag, data);
1716
+ if (this.flags.preparing || !this.mounted) this.flags.dirty = true;
1717
+ // Synchronous path: while batching (incl. batchUpdatesAndNotify, which page-breaking relies on) or for
1718
+ // `immediate` instances.
1719
+ else if (this.props.immediate || isBatchingUpdates()) {
1720
+ // Every notification is reported to batchUpdatesAndNotify subscribers up front and completed only
1721
+ // once the setState that renders it commits, so notify callbacks never fire before the DOM reflects
1722
+ // the change. Each notification always gets its own setState; only its timing escalates as the
1723
+ // burst grows: synchronous at first, then from a microtask (lets React's commit finish so its
1724
+ // global nested-update counter resets instead of tripping "Maximum update depth exceeded"), and
1725
+ // finally from a timeout (lets the event loop turn, so a store that never converges degrades to a
1726
+ // responsive page instead of a frozen tab).
1727
+ let seq = notifyBatchedUpdateStarting();
1728
+ this.owedNotifications.add(seq);
1729
+ outstandingNotifications++;
1730
+ // Count render rounds rather than notifications: only the first notification an instance
1731
+ // receives per render round bumps the shared depth (the flag clears on render). This tracks
1732
+ // React's nested-commit count -- the thing the escalation must stay under -- so a round that
1733
+ // writes many values doesn't burn through the budget in one go.
1734
+ if (!this.burstRoundCounted) {
1735
+ this.burstRoundCounted = true;
1736
+ ++syncBurstRounds;
1737
+ if (process.env.NODE_ENV !== "production" && syncBurstRounds === microtaskBurstLimit + 1)
1738
+ console.error(
1739
+ "Cx: store updates are not converging after " +
1740
+ microtaskBurstLimit +
1741
+ " render rounds -- possible update loop. Updates are now issued from timeouts to keep the page responsive. Look for code that writes a new value to the store on every render.",
1742
+ );
1743
+ }
1744
+ if (syncBurstRounds <= syncBurstLimit) this.issueStateUpdate(seq);
1745
+ else if (syncBurstRounds <= microtaskBurstLimit) queueMicrotask(() => this.issueStateUpdate(seq));
1746
+ else setTimeout(() => this.issueStateUpdate(seq), 0);
1747
+ } else {
1748
+ // standard mode: coalesce sequential store commands into a single deferred update
1749
+ this.scheduleStateUpdate();
1750
+ }
1751
+ }
1752
+ // Render the latest store data and report the notification completed once the commit is done, so
1753
+ // batchUpdatesAndNotify resolves only when the DOM reflects the store.
1754
+ issueStateUpdate(seq) {
1755
+ // skip notifications no longer owed -- unmount may have already released them
1756
+ if (!this.owedNotifications.has(seq)) return;
1757
+ this.setState(
1758
+ {
1759
+ data: this.store.getData(),
1760
+ },
1761
+ () => this.completeNotification(seq),
1762
+ );
1763
+ }
1764
+ completeNotification(seq) {
1765
+ // skip notifications no longer owed -- unmount may have already released them
1766
+ if (!this.owedNotifications.delete(seq)) return;
1767
+ outstandingNotifications--;
1768
+ notifyBatchedUpdateCompleted(seq);
1769
+ // everything settled -- the next burst starts fresh, and so does React's nested-update counter
1770
+ // (the commit that settled the last notification ends without scheduling further synchronous work)
1771
+ if (outstandingNotifications === 0) syncBurstRounds = 0;
1772
+ }
1773
+ scheduleStateUpdate() {
1774
+ if (!this.pendingUpdateTimer) {
1775
+ let seq = notifyBatchedUpdateStarting();
1776
+ this.owedNotifications.add(seq);
1777
+ outstandingNotifications++;
1778
+ this.pendingUpdateTimer = setTimeout(() => {
1779
+ delete this.pendingUpdateTimer;
1780
+ // read fresh data at fire time so the coalesced update renders the latest store state
1781
+ this.setState(
1782
+ {
1783
+ data: this.store.getData(),
1784
+ },
1785
+ () => this.completeNotification(seq),
1786
+ );
1787
+ }, 0);
1788
+ }
1789
+ }
1790
+ waitForIdle() {
1791
+ if (!this.props.deferredUntilIdle) return;
1792
+ if (this.unsubscribeIdleRequest) this.unsubscribeIdleRequest();
1793
+ let token = ++this.deferCounter;
1794
+ this.unsubscribeIdleRequest = onIdleCallback(
1795
+ () => {
1796
+ this.setState({
1797
+ deferToken: token,
1798
+ });
1799
+ },
1800
+ {
1801
+ timeout: this.props.idleTimeout || 30000,
1802
+ },
1803
+ );
1804
+ }
1805
+ componentWillUnmount() {
1806
+ // Release notifications that will never render so a waiting batchUpdatesAndNotify can settle instead
1807
+ // of waiting out its fallback timeout.
1808
+ for (let seq of this.owedNotifications) this.completeNotification(seq);
1809
+ if (this.pendingUpdateTimer) clearTimeout(this.pendingUpdateTimer);
1810
+ if (this.unsubscribeIdleRequest) this.unsubscribeIdleRequest();
1811
+ if (this.unsubscribe) this.unsubscribe();
1812
+ if (this.props.options && this.props.options.onPipeUpdate) this.props.options.onPipeUpdate(null);
1813
+ }
1814
+ shouldComponentUpdate(props, state) {
1815
+ if (props.deferredUntilIdle && state.deferToken != this.deferCounter) return false;
1816
+ return (
1817
+ state !== this.state ||
1818
+ !props.params ||
1819
+ !shallowEquals(props.params, this.props.params) ||
1820
+ props.instance !== this.props.instance ||
1821
+ props.widget !== this.props.widget ||
1822
+ props.store !== this.props.store ||
1823
+ props.parentInstance !== this.props.parentInstance ||
1824
+ props.cultureInfo !== this.props.cultureInfo
1825
+ );
1826
+ }
1827
+ // Render null for the failed subtree while the error is dispatched to componentDidCatch below --
1828
+ // returning a state update here is what React expects of an error boundary (rendering the broken
1829
+ // children again would just rethrow).
1830
+ static getDerivedStateFromError() {
1831
+ return {
1832
+ error: true,
1833
+ };
1834
+ }
1835
+ componentDidCatch(error, info) {
1836
+ this.flags.preparing = false;
1837
+ // without an onError callback this instance is not an error boundary -- rethrow so the error
1838
+ // reaches the nearest ancestor boundary, matching the behavior before getDerivedStateFromError
1839
+ // was introduced
1840
+ if (!this.props.onError) throw error;
1841
+ this.props.onError(error, this.getInstance(), info);
1842
+ // the callback had a chance to repair the state (e.g. replace the failing content) -- resume rendering
1843
+ this.setState({
1844
+ error: false,
1845
+ });
1846
+ }
1847
+ }
1848
+ class CxContext extends VDOM.Component {
1849
+ renderCount;
1850
+ timings;
1851
+ content;
1852
+ renderingContext;
1853
+ constructor(props) {
1854
+ super(props);
1855
+ this.renderCount = 0;
1856
+ this.UNSAFE_componentWillReceiveProps(props);
1857
+ }
1858
+ UNSAFE_componentWillReceiveProps(props) {
1859
+ this.timings = {
1860
+ start: now(),
1861
+ };
1862
+ let { instance, options, contentFactory } = props;
1863
+ let count = 0,
1864
+ visible,
1865
+ context,
1866
+ forceContinue;
1867
+ //should not be tracked by parents for destroy
1868
+ if (!instance.detached)
1869
+ throw new Error("The instance passed to a Cx component should be detached from its parent.");
1870
+ if (this.props.instance !== instance && this.props.instance.destroyTracked) this.props.instance.destroy();
1871
+ this.props.flags.preparing = true;
1872
+ if (this.props.cultureInfo) pushCulture(this.props.cultureInfo);
1873
+ try {
1874
+ do {
1875
+ count++;
1876
+ forceContinue = false;
1877
+ context = new RenderingContext(options);
1878
+ context.forceUpdate = this.props.forceUpdate;
1879
+ this.props.flags.dirty = false;
1880
+ instance.assignedRenderList = context.getRootRenderList();
1881
+ visible = instance.scheduleExploreIfVisible(context);
1882
+ if (visible) {
1883
+ while (!context.exploreStack.empty()) {
1884
+ let inst = context.exploreStack.pop();
1885
+ //console.log("EXPLORE", inst.widget.constructor.name, inst.widget.tag, inst.widget.widgetId);
1886
+ inst.explore(context);
1887
+ }
1888
+ } else if (instance.destroyTracked) {
1889
+ instance.destroy();
1890
+ }
1891
+ if (this.props.flags.dirty && count <= 3 && Widget.optimizePrepare && now() - this.timings.start < 8) {
1892
+ forceContinue = true;
1893
+ continue;
1894
+ }
1895
+ if (visible) {
1896
+ this.timings.afterExplore = now();
1897
+ for (let i = 0; i < context.prepareList.length; i++) context.prepareList[i].prepare(context);
1898
+ this.timings.afterPrepare = now();
1899
+ }
1900
+ } while (
1901
+ forceContinue ||
1902
+ (this.props.flags.dirty && count <= 3 && Widget.optimizePrepare && now() - this.timings.start < 8)
1903
+ );
1904
+ if (visible) {
1905
+ //walk in reverse order so children get rendered first
1906
+ let renderList = context.getRootRenderList();
1907
+ while (renderList) {
1908
+ for (let i = renderList.data.length - 1; i >= 0; i--) {
1909
+ renderList.data[i].render(context);
1910
+ }
1911
+ renderList = renderList.right;
1912
+ }
1913
+ this.content = getContent(instance.vdom);
1914
+ if (contentFactory)
1915
+ this.content = contentFactory({
1916
+ children: this.content,
1917
+ });
1918
+ this.timings.afterRender = now();
1919
+ for (let i = 0; i < context.cleanupList.length; i++) context.cleanupList[i].cleanup(context);
1920
+ } else {
1921
+ this.content = null;
1922
+ this.timings.afterExplore = this.timings.afterPrepare = this.timings.afterRender = now();
1923
+ }
1924
+ } finally {
1925
+ if (this.props.cultureInfo) popCulture(this.props.cultureInfo);
1926
+ }
1927
+ this.timings.beforeVDOMRender = now();
1928
+ this.props.flags.preparing = false;
1929
+ this.props.flags.rendering = true;
1930
+ this.renderingContext = context;
1931
+ }
1932
+ render() {
1933
+ return this.content;
1934
+ }
1935
+ componentDidMount() {
1936
+ this.componentDidUpdate();
1937
+ }
1938
+ componentDidUpdate() {
1939
+ this.props.flags.rendering = false;
1940
+ this.timings.afterVDOMRender = now();
1941
+ //let {instance} = this.props;
1942
+ //instance.cleanup(this.renderingContext);
1943
+ this.timings.afterCleanup = now();
1944
+ this.renderCount++;
1945
+ if (process.env.NODE_ENV !== "production") {
1946
+ let { start, beforeVDOMRender, afterVDOMRender, afterPrepare, afterExplore, afterRender, afterCleanup } =
1947
+ this.timings;
1948
+ Timing.log(
1949
+ vdomRenderFlag,
1950
+ this.renderCount,
1951
+ "cx",
1952
+ (beforeVDOMRender - start + afterCleanup - afterVDOMRender).toFixed(2) + "ms",
1953
+ "vdom",
1954
+ (afterVDOMRender - beforeVDOMRender).toFixed(2) + "ms",
1955
+ );
1956
+ Timing.log(
1957
+ appLoopFlag,
1958
+ this.renderCount,
1959
+ this.renderingContext.options.name || "main",
1960
+ "total",
1961
+ (afterCleanup - start).toFixed(1) + "ms",
1962
+ "explore",
1963
+ (afterExplore - start).toFixed(1) + "ms",
1964
+ "prepare",
1965
+ (afterPrepare - afterExplore).toFixed(1),
1966
+ "render",
1967
+ (afterRender - afterPrepare).toFixed(1),
1968
+ "vdom",
1969
+ (afterVDOMRender - beforeVDOMRender).toFixed(1),
1970
+ "cleanup",
1971
+ (afterCleanup - afterVDOMRender).toFixed(1),
1972
+ );
1973
+ }
1974
+ }
1975
+ componentWillUnmount() {
1976
+ let { instance } = this.props;
1977
+ if (instance.destroyTracked) instance.destroy();
1978
+ }
1979
+ }
1980
+
1981
+ class ContainmentStore extends SubscribableView {
1982
+ constructor(config) {
1983
+ super(config);
1984
+ this.selector = config.selector;
1985
+ }
1986
+ getData() {
1987
+ return this.store.getData();
1988
+ }
1989
+ setItem(path, value) {
1990
+ return this.wrapper(() => {
1991
+ this.store.setItem(path, value);
1992
+ });
1993
+ }
1994
+ deleteItem(path) {
1995
+ return this.wrapper(() => {
1996
+ this.store.deleteItem(path);
1997
+ });
1998
+ }
1999
+ wrapper(callback) {
2000
+ if (this.store.silently(callback)) {
2001
+ let data = this.getData();
2002
+ let containedData = this.selector(data);
2003
+ if (containedData === this.cache.containedData) {
2004
+ this.store.notify();
2005
+ } else {
2006
+ this.cache.containedData = containedData;
2007
+ this.notify(undefined);
2008
+ }
2009
+ return true;
2010
+ }
2011
+ return false;
2012
+ }
2013
+ }
2014
+ class DetachedScope extends IsolatedScope {
2015
+ declareData(...args) {
2016
+ return super.declareData(...args, {
2017
+ exclusiveData: {
2018
+ structured: true,
2019
+ },
2020
+ });
2021
+ }
2022
+ init() {
2023
+ if (typeof this.exclusive === "string")
2024
+ this.exclusiveData = {
2025
+ bind: this.exclusive,
2026
+ };
2027
+ if (Array.isArray(this.exclusive)) {
2028
+ this.exclusiveData = {};
2029
+ this.exclusive.forEach((x, i) => {
2030
+ this.exclusiveData[String(i)] = {
2031
+ bind: x,
2032
+ };
2033
+ });
2034
+ }
2035
+ this.container = PureContainer.create({
2036
+ type: PureContainer,
2037
+ items: this.children || this.items,
2038
+ });
2039
+ delete this.children;
2040
+ this.items = [];
2041
+ if (this.name)
2042
+ this.options = {
2043
+ ...this.options,
2044
+ name: this.name,
2045
+ };
2046
+ super.init();
2047
+ }
2048
+ initInstance(context, instance) {
2049
+ const config = {
2050
+ store: instance.parentStore,
2051
+ selector: getSelector(this.exclusiveData || this.data),
2052
+ };
2053
+ instance.subStore = new ContainmentStore(config);
2054
+ }
2055
+ applyParentStore(instance) {
2056
+ instance.store = instance.parentStore;
2057
+ instance.subStore.setStore(instance.parentStore);
2058
+ }
2059
+ render(context, instance, key) {
2060
+ return jsx(
2061
+ Cx,
2062
+ {
2063
+ widget: this.container,
2064
+ store: instance.subStore,
2065
+ parentInstance: instance,
2066
+ subscribe: true,
2067
+ options: this.options,
2068
+ onError: this.onError,
2069
+ },
2070
+ key,
2071
+ );
2072
+ }
2073
+ }
2074
+
2075
+ let persistenceCache = {};
2076
+ class Restate extends PureContainerBase {
2077
+ declareData(...args) {
2078
+ return super.declareData(...args, {
2079
+ deferredUntilIdle: undefined,
2080
+ idleTimeout: undefined,
2081
+ cacheKey: undefined,
2082
+ });
2083
+ }
2084
+ init() {
2085
+ this.container = PureContainer.create({
2086
+ items: this.children || this.items,
2087
+ layout: this.layout,
2088
+ controller: this.controller,
2089
+ outerLayout: this.outerLayout,
2090
+ useParentLayout: !this.detached,
2091
+ ws: this.ws,
2092
+ });
2093
+ this.privateDataSelector = new StructuredSelector({
2094
+ props: this.data || {},
2095
+ values: this.data,
2096
+ });
2097
+ this.items = [];
2098
+ delete this.children;
2099
+ delete this.controller;
2100
+ delete this.outerLayout;
2101
+ delete this.layout;
2102
+ if (this.useParentLayout == null) this.useParentLayout = !this.detached;
2103
+ super.init();
2104
+ }
2105
+ initSubStore(context, instance) {
2106
+ let { cacheKey } = instance.data;
2107
+ this.privateDataSelector.init(instance.store);
2108
+ instance.subStore = new RestateStore({
2109
+ store: instance.store,
2110
+ detached: this.detached,
2111
+ privateData: this.data || {},
2112
+ data: cacheKey ? persistenceCache[cacheKey] || {} : {},
2113
+ dataSelector: this.privateDataSelector.create(),
2114
+ onSet: (path, value) => instance.nestedDataSet(path, value, this.data),
2115
+ });
2116
+ if (cacheKey) {
2117
+ instance.subscribeOnDestroy(() => {
2118
+ persistenceCache[cacheKey] = instance.subStore.getData();
2119
+ });
2120
+ }
2121
+ }
2122
+ applyParentStore(instance) {
2123
+ if (instance.subStore) instance.subStore.setStore(instance.parentStore);
2124
+ }
2125
+ explore(context, instance) {
2126
+ if (!instance.subStore) this.initSubStore(context, instance);
2127
+ if (instance.subStore.parentDataCheck()) instance.markShouldUpdate();
2128
+ instance.cultureInfo = this.culture ?? getCurrentCulture();
2129
+ if (instance.cache("cultureInfo", instance.culture)) instance.markShouldUpdate();
2130
+ super.explore(context, instance);
2131
+ }
2132
+ exploreItems(context, instance, items) {
2133
+ if (!this.detached) {
2134
+ instance.container = instance.getChild(context, this.container, "container", instance.subStore);
2135
+ instance.container.scheduleExploreIfVisible(context);
2136
+ instance.children = [instance.container];
2137
+ }
2138
+ }
2139
+ render(context, instance, key) {
2140
+ if (!this.detached) return instance.container.render(context);
2141
+ return jsx(
2142
+ Cx,
2143
+ {
2144
+ widget: this.container,
2145
+ parentInstance: instance,
2146
+ store: instance.subStore,
2147
+ subscribe: true,
2148
+ options: this.options,
2149
+ onError: this.onError,
2150
+ deferredUntilIdle: instance.data.deferredUntilIdle,
2151
+ idleTimeout: instance.data.idleTimeout,
2152
+ immediate: this.immediate,
2153
+ cultureInfo: instance.cultureInfo,
2154
+ },
2155
+ key,
2156
+ );
2157
+ }
2158
+ }
2159
+ Restate.prototype.detached = false;
2160
+ Restate.prototype.waitForIdle = false;
2161
+ Restate.prototype.immediate = false;
2162
+ Restate.prototype.culture = null;
2163
+ const PrivateStore = Restate;
2164
+ class RestateStore extends Store {
2165
+ constructor(config) {
2166
+ super(config);
2167
+ this.parentDataVersion = -1;
2168
+ }
2169
+ getData() {
2170
+ this.silently(() => {
2171
+ this.parentDataCheck();
2172
+ });
2173
+ return super.getData();
2174
+ }
2175
+ parentDataCheck() {
2176
+ if (this.parentDataVersion == this.store.meta.version) return false;
2177
+ this.parentDataVersion = this.store.meta.version;
2178
+ this.parentData = this.dataSelector(this.store.getData());
2179
+ return this.batch(() => {
2180
+ for (let key in this.parentData) {
2181
+ super.setItem(key, this.parentData[key]);
2182
+ }
2183
+ });
2184
+ }
2185
+ setItem(path, value) {
2186
+ let binding = Binding.get(path);
2187
+ let bindingRoot = binding.parts[0];
2188
+ if (!isObject(this.privateData) || !this.privateData.hasOwnProperty(bindingRoot)) {
2189
+ let changed = isUndefined(value) ? super.deleteItem(path) : super.setItem(path, value);
2190
+ return changed;
2191
+ }
2192
+ let newValue = value;
2193
+ if (binding.parts.length > 1) newValue = binding.set(this.getData(), value)[bindingRoot];
2194
+ this.onSet(bindingRoot, newValue);
2195
+ this.batch(() => {
2196
+ super.setItem(bindingRoot, newValue);
2197
+ this.parentDataCheck();
2198
+ });
2199
+ return true;
2200
+ }
2201
+ deleteItem(path) {
2202
+ return this.setItem(path, undefined);
2203
+ }
2204
+ doNotify() {
2205
+ if (!this.detached) this.store.notify(undefined);
2206
+ super.doNotify(undefined);
2207
+ }
2208
+ // override the default implementation to avoid meta overwrites
2209
+ setStore(store) {
2210
+ this.store = store;
2211
+ }
2212
+ }
2213
+
2214
+ class StructuredInstanceDataAccessor {
2215
+ instance;
2216
+ dataConfig;
2217
+ useParentStore;
2218
+ dataSelector;
2219
+ constructor(config) {
2220
+ this.instance = config.instance;
2221
+ this.dataConfig = config.data;
2222
+ this.useParentStore = config.useParentStore;
2223
+ this.dataSelector = getSelector(config.data);
2224
+ if (this.dataSelector.memoize) this.dataSelector = this.dataSelector.memoize();
2225
+ }
2226
+ getSelector() {
2227
+ return this.dataSelector;
2228
+ }
2229
+ get() {
2230
+ return this.dataSelector.get(this.instance.store.getData());
2231
+ }
2232
+ setItem(key, value) {
2233
+ return this.instance.nestedDataSet(key, value, this.dataConfig, this.useParentStore);
2234
+ }
2235
+ containsKey(key) {
2236
+ return this.dataConfig.hasOwnProperty(key);
2237
+ }
2238
+ getKeys() {
2239
+ return Object.keys(this.dataConfig);
2240
+ }
2241
+ }
2242
+
2243
+ class DataProxy extends PureContainerBase {
2244
+ init() {
2245
+ if (!this.data) this.data = {};
2246
+ if (this.alias) this.data[this.alias] = this.value;
2247
+ super.init();
2248
+ }
2249
+ initInstance(context, instance) {
2250
+ instance.store = new NestedDataView({
2251
+ store: instance.parentStore,
2252
+ nestedData: new StructuredInstanceDataAccessor({
2253
+ instance,
2254
+ data: this.data,
2255
+ useParentStore: true,
2256
+ }),
2257
+ immutable: this.immutable,
2258
+ sealed: this.sealed,
2259
+ });
2260
+ super.initInstance(context, instance);
2261
+ }
2262
+ applyParentStore(instance) {
2263
+ instance.store.setStore(instance.parentStore);
2264
+ }
2265
+ }
2266
+ DataProxy.prototype.immutable = false;
2267
+ DataProxy.prototype.sealed = false;
2268
+
2269
+ class Content extends PureContainerBase {
2270
+ constructor(config) {
2271
+ super(config);
2272
+ }
2273
+ init() {
2274
+ super.init();
2275
+ if (!this.putInto) this.putInto = this.for || this.name;
2276
+ }
2277
+ }
2278
+ Content.prototype.name = "body";
2279
+ Content.prototype.isContent = true;
2280
+ Widget.alias("content", Content);
2281
+
2282
+ class ContentPlaceholder extends PureContainerBase {
2283
+ declareData(...args) {
2284
+ super.declareData(...args, {
2285
+ name: undefined,
2286
+ });
2287
+ }
2288
+ explore(context, instance) {
2289
+ instance.content = null;
2290
+ let { data } = instance;
2291
+ if (this.allowMultiple) {
2292
+ const contentList = context.contentList && context.contentList[data.name];
2293
+ if (isNonEmptyArray(contentList) && !this.scoped)
2294
+ for (let i = 0; i < contentList.length; i++) this.setContent(context, instance, contentList[i]);
2295
+ // in multi mode register a callback to allow for more entries to be added
2296
+ context.pushNamedValue("contentPlaceholder", data.name, (content) => {
2297
+ this.setContent(context, instance, content);
2298
+ });
2299
+ } else {
2300
+ const content = context.content && context.content[data.name];
2301
+ if (content && !this.scoped) this.setContent(context, instance, content);
2302
+ else
2303
+ context.pushNamedValue("contentPlaceholder", data.name, (content) => {
2304
+ this.setContent(context, instance, content);
2305
+ });
2306
+ }
2307
+ if (this.scoped)
2308
+ instance.unregisterContentPlaceholder = () => {
2309
+ context.popNamedValue("contentPlaceholder", data.name);
2310
+ };
2311
+ super.explore(context, instance);
2312
+ }
2313
+ prepare(context, instance) {
2314
+ let { content } = instance;
2315
+ if (this.allowMultiple) {
2316
+ let contentId = "";
2317
+ let shouldUpdate = false;
2318
+ if (content) {
2319
+ for (let i = 0; i < content.length; i++) {
2320
+ let c = content[i];
2321
+ contentId += c.id + "+";
2322
+ shouldUpdate = shouldUpdate || c.shouldUpdate;
2323
+ }
2324
+ }
2325
+ if (instance.cache("content", contentId) || shouldUpdate) instance.markShouldUpdate(context);
2326
+ } else if (instance.cache("content", content) || (content && content.shouldUpdate))
2327
+ instance.markShouldUpdate(context);
2328
+ }
2329
+ setContent(context, instance, content) {
2330
+ if (this.allowMultiple) {
2331
+ if (instance.content == null) instance.content = [];
2332
+ instance.content.push(content);
2333
+ } else instance.content = content;
2334
+ content.contentPlaceholder = instance;
2335
+ }
2336
+ render(context, instance, key) {
2337
+ const { content } = instance;
2338
+ if (!content) return super.render(context, instance, key);
2339
+ if (this.allowMultiple) return content.map((x) => x.contentVDOM);
2340
+ return content.contentVDOM;
2341
+ }
2342
+ }
2343
+ ContentPlaceholder.prototype.name = "body";
2344
+ ContentPlaceholder.prototype.scoped = false;
2345
+ ContentPlaceholder.prototype.allowMultiple = false;
2346
+ Widget.alias("content-placeholder", ContentPlaceholder);
2347
+ class ContentPlaceholderScope extends PureContainerBase {
2348
+ init() {
2349
+ super.init();
2350
+ if (isString(this.name)) this.name = [this.name];
2351
+ }
2352
+ explore(context, instance) {
2353
+ this.name.forEach((name) => {
2354
+ context.pushNamedValue("contentPlaceholder", name, null);
2355
+ context.pushNamedValue("content", name, null);
2356
+ context.pushNamedValue("contentList", name, []);
2357
+ });
2358
+ super.explore(context, instance);
2359
+ }
2360
+ exploreCleanup(context, instance) {
2361
+ this.name.forEach((name) => {
2362
+ context.popNamedValue("contentPlaceholder", name);
2363
+ context.popNamedValue("content", name);
2364
+ context.popNamedValue("contentList", name);
2365
+ });
2366
+ }
2367
+ }
2368
+
2369
+ function validContent$1(r) {
2370
+ let content = [];
2371
+ for (let key in r) if (key != "label") contentAppend(content, r[key]);
2372
+ return content;
2373
+ }
2374
+ class LabelsTopLayout extends StyledContainerBase {
2375
+ constructor(config) {
2376
+ super(config);
2377
+ }
2378
+ init() {
2379
+ if (this.vertical && isUndefined(this.columns)) this.columns = 1;
2380
+ super.init();
2381
+ }
2382
+ render(context, instance, key) {
2383
+ let { children, data } = instance;
2384
+ let state = {
2385
+ rows: [],
2386
+ currentRow: 0,
2387
+ labelCells: [],
2388
+ fieldCells: [],
2389
+ rowCapacities: [this.columns],
2390
+ };
2391
+ const processContent = (r) => {
2392
+ if (!r) return;
2393
+ if (isArray(r.content) && r.useParentLayout) r.content.forEach((x) => processContent(x));
2394
+ else if (r.atomic && r.type == "layout-cell")
2395
+ this.addItem(state, isArray(r.content) && r.content.length == 1 ? r.content[0] : r.content, r.data);
2396
+ else this.addItem(state, r, {});
2397
+ };
2398
+ children.forEach((item) => processContent(item.vdom));
2399
+ this.addRow(state);
2400
+ return jsx(
2401
+ "table",
2402
+ {
2403
+ className: data.classNames,
2404
+ style: data.style,
2405
+ children: jsx("tbody", {
2406
+ children: state.rows,
2407
+ }),
2408
+ },
2409
+ key,
2410
+ );
2411
+ }
2412
+ addRow(state) {
2413
+ if (state.labelCells.length > 0)
2414
+ state.rows.push(
2415
+ jsx(
2416
+ "tr",
2417
+ {
2418
+ children: state.labelCells,
2419
+ },
2420
+ state.rows.length,
2421
+ ),
2422
+ );
2423
+ if (state.fieldCells.length > 0)
2424
+ state.rows.push(
2425
+ jsx(
2426
+ "tr",
2427
+ {
2428
+ children: state.fieldCells,
2429
+ },
2430
+ state.rows.length,
2431
+ ),
2432
+ );
2433
+ state.labelCells = [];
2434
+ state.fieldCells = [];
2435
+ state.currentRow++;
2436
+ if (state.currentRow == state.rowCapacities.length) state.rowCapacities.push(this.columns);
2437
+ }
2438
+ addItem(state, item, data) {
2439
+ while (state.labelCells.length == state.rowCapacities[state.currentRow]) this.addRow(state);
2440
+ if (data.rowSpan > 1) {
2441
+ for (let row = state.currentRow + 1; row < state.currentRow + data.rowSpan; row++) {
2442
+ if (row == state.rowCapacities.length) state.rowCapacities.push(this.columns);
2443
+ state.rowCapacities[row] -= data.colSpan || 1;
2444
+ }
2445
+ }
2446
+ if (data.colSpan > 1) state.rowCapacities[state.currentRow] -= data.colSpan - 1;
2447
+ state.labelCells.push(
2448
+ jsx(
2449
+ "td",
2450
+ {
2451
+ className: this.CSS.element(this.baseClass, "label"),
2452
+ colSpan: data.colSpan,
2453
+ children: getContent(item.label),
2454
+ },
2455
+ state.labelCells.length,
2456
+ ),
2457
+ );
2458
+ state.fieldCells.push(
2459
+ jsx(
2460
+ "td",
2461
+ {
2462
+ className: this.CSS.element(this.baseClass, "field"),
2463
+ colSpan: data.colSpan,
2464
+ rowSpan: isNumber(data.rowSpan) ? 2 * data.rowSpan - 1 : undefined,
2465
+ style: data.style,
2466
+ children: validContent$1(item),
2467
+ },
2468
+ state.fieldCells.length,
2469
+ ),
2470
+ );
2471
+ }
2472
+ }
2473
+ LabelsTopLayout.prototype.baseClass = "labelstoplayout";
2474
+ LabelsTopLayout.prototype.vertical = false;
2475
+ LabelsTopLayout.prototype.columns = undefined;
2476
+ class LabelsTopLayoutCell extends StyledContainerBase {
2477
+ constructor(config) {
2478
+ super(config);
2479
+ }
2480
+ declareData(...args) {
2481
+ super.declareData(...args, {
2482
+ colSpan: undefined,
2483
+ rowSpan: undefined,
2484
+ });
2485
+ }
2486
+ render(context, instance, key) {
2487
+ let { content } = this.renderChildren(context, instance);
2488
+ return {
2489
+ atomic: true,
2490
+ type: "layout-cell",
2491
+ data: instance.data,
2492
+ content,
2493
+ };
2494
+ }
2495
+ }
2496
+ LabelsTopLayoutCell.prototype.useParentLayout = true;
2497
+
2498
+ function validContent(r) {
2499
+ if (!r.hasOwnProperty("content")) return r;
2500
+ let content = [];
2501
+ for (let key in r) if (key != "label") contentAppend(content, r[key]);
2502
+ return content;
2503
+ }
2504
+ class LabelsLeftLayout extends StyledContainerBase {
2505
+ constructor(config) {
2506
+ super(config);
2507
+ }
2508
+ init() {
2509
+ this.labelStyle = parseStyle(this.labelStyle);
2510
+ super.init();
2511
+ }
2512
+ declareData(...args) {
2513
+ return super.declareData(...args, {
2514
+ labelStyle: {
2515
+ structured: true,
2516
+ },
2517
+ labelClass: {
2518
+ structured: true,
2519
+ },
2520
+ });
2521
+ }
2522
+ render(context, instance, key) {
2523
+ let result = [];
2524
+ let { children, data } = instance;
2525
+ let { CSS, baseClass } = this;
2526
+ let labelClass = CSS.expand(CSS.element(baseClass, "label"), data.labelClass);
2527
+ const addItem = (r, key) => {
2528
+ if (!r) return;
2529
+ if (r.useParentLayout && isArray(r.content)) r.content.forEach((x, i) => addItem(x, key + "-" + i));
2530
+ else {
2531
+ result.push(
2532
+ jsxs(
2533
+ "tr",
2534
+ {
2535
+ children: [
2536
+ jsx("td", {
2537
+ className: labelClass,
2538
+ style: data.labelStyle,
2539
+ children: getContent(r.label),
2540
+ }),
2541
+ jsx("td", {
2542
+ className: CSS.element(baseClass, "field"),
2543
+ children: validContent(r),
2544
+ }),
2545
+ ],
2546
+ },
2547
+ key,
2548
+ ),
2549
+ );
2550
+ }
2551
+ };
2552
+ children.forEach((c) => {
2553
+ addItem(c.vdom, c.key);
2554
+ });
2555
+ return jsx(
2556
+ "table",
2557
+ {
2558
+ className: data.classNames,
2559
+ style: data.style,
2560
+ children: jsx("tbody", {
2561
+ children: result,
2562
+ }),
2563
+ },
2564
+ key,
2565
+ );
2566
+ }
2567
+ }
2568
+ LabelsLeftLayout.prototype.baseClass = "labelsleftlayout";
2569
+
2570
+ class ContentResolver extends PureContainerBase {
2571
+ constructor(config) {
2572
+ super(config);
2573
+ }
2574
+ declareData(...args) {
2575
+ super.declareData(...args, {
2576
+ params: {
2577
+ structured: true,
2578
+ },
2579
+ loading: undefined,
2580
+ });
2581
+ }
2582
+ init() {
2583
+ super.init();
2584
+ this.initialItems = this.layout ? this.layout.items : this.items;
2585
+ this.clear();
2586
+ }
2587
+ initInstance(context, instance) {
2588
+ instance.content = this.initialItems;
2589
+ instance.cachedParams = {}; //unique value which will never pass the equality check
2590
+ }
2591
+ prepareData(context, instance) {
2592
+ let { data } = instance;
2593
+ if (data.params !== instance.cachedParams && this.onResolve) {
2594
+ instance.cachedParams = data.params;
2595
+ let content = instance.invoke("onResolve", data.params, instance);
2596
+ if (isPromise(content)) {
2597
+ instance.set("loading", true);
2598
+ this.setContent(instance, null);
2599
+ content.then((cnt) => {
2600
+ this.setContent(instance, cnt);
2601
+ instance.setState({
2602
+ cacheBuster: {},
2603
+ });
2604
+ instance.set("loading", false);
2605
+ });
2606
+ } else this.setContent(instance, content);
2607
+ }
2608
+ }
2609
+ setContent(instance, content) {
2610
+ if (content) {
2611
+ this.clear();
2612
+ switch (this.mode) {
2613
+ case "prepend":
2614
+ this.add(content);
2615
+ this.add(this.initialItems);
2616
+ break;
2617
+ case "append":
2618
+ this.add(this.initialItems);
2619
+ this.add(content);
2620
+ break;
2621
+ case "replace":
2622
+ this.add(content);
2623
+ break;
2624
+ }
2625
+ instance.content = this.layout ? this.layout.items : this.items;
2626
+ this.clear();
2627
+ } else instance.content = this.initialItems;
2628
+ }
2629
+ explore(context, instance) {
2630
+ //a little bit hacky
2631
+ if (this.layout) this.layout.items = instance.content;
2632
+ else this.items = instance.content;
2633
+ super.explore(context, instance);
2634
+ }
2635
+ }
2636
+ ContentResolver.prototype.mode = "replace";
2637
+
2638
+ class Rescope extends PureContainerBase {
2639
+ init() {
2640
+ this.binding = Binding.get(this.bind);
2641
+ if (this.rootAlias) this.rootName = this.rootAlias;
2642
+ super.init();
2643
+ }
2644
+ initInstance(context, instance) {
2645
+ instance.store = new ZoomIntoPropertyView({
2646
+ store: instance.parentStore,
2647
+ binding: this.binding,
2648
+ rootName: this.rootName,
2649
+ nestedData: isObject(this.data)
2650
+ ? new StructuredInstanceDataAccessor({
2651
+ instance,
2652
+ data: this.data,
2653
+ useParentStore: true,
2654
+ })
2655
+ : undefined,
2656
+ });
2657
+ super.initInstance(context, instance);
2658
+ }
2659
+ applyParentStore(instance) {
2660
+ instance.store.setStore(instance.parentStore);
2661
+ }
2662
+ }
2663
+ Rescope.prototype.bind = "$page";
2664
+ Rescope.prototype.rootName = "$root";
2665
+ Widget.alias("rescope", Rescope);
2666
+
2667
+ class DataAdapter extends Component {
2668
+ constructor(config) {
2669
+ super(config);
2670
+ }
2671
+ setFilter(filterFn) {
2672
+ this.filterFn = filterFn;
2673
+ }
2674
+ sort(sorters) {}
2675
+ }
2676
+ DataAdapter.prototype.recordName = "$record";
2677
+ DataAdapter.prototype.indexName = "$index";
2678
+ DataAdapter.prototype.immutable = false;
2679
+
2680
+ class ArrayAdapter extends DataAdapter {
2681
+ constructor(config) {
2682
+ super(config);
2683
+ }
2684
+ init() {
2685
+ this.recordsAccessor = this.recordsBinding ? getAccessor(this.recordsBinding) : getAccessor(this.recordsAccessor);
2686
+ this.recordName = this.recordName?.toString() || "$record";
2687
+ this.indexName = this.indexName?.toString() || "$index";
2688
+ }
2689
+ initInstance(context, instance) {
2690
+ if (!instance.recordStoreCache) {
2691
+ instance.recordStoreCache = new WeakMap();
2692
+ instance.cacheByKey = {};
2693
+ }
2694
+ if (!instance.recordsAccessor && this.recordsAccessor) {
2695
+ instance.recordsAccessor = this.recordsAccessor.bindInstance
2696
+ ? this.recordsAccessor.bindInstance(instance)
2697
+ : this.recordsAccessor;
2698
+ }
2699
+ }
2700
+ getRecords(context, instance, records, parentStore) {
2701
+ if (!instance.recordStoreCache) {
2702
+ this.initInstance(context, instance);
2703
+ }
2704
+ return this.mapRecords(context, instance, records, parentStore, instance.recordsAccessor);
2705
+ }
2706
+ mapRecords(context, instance, records, parentStore, recordsAccessor) {
2707
+ let result = [];
2708
+ if (!instance.recordStoreCache) {
2709
+ this.initInstance(context, instance);
2710
+ }
2711
+ if (isArray(records)) {
2712
+ records.forEach((data, index) => {
2713
+ if (this.filterFn && !this.filterFn(data)) return;
2714
+ const record = this.mapRecord(context, instance, data, parentStore, recordsAccessor, index);
2715
+ result.push(record);
2716
+ });
2717
+ }
2718
+ if (this.sorter && !this.preserveOrder) {
2719
+ result = this.sorter(result);
2720
+ }
2721
+ return result;
2722
+ }
2723
+ mapRecord(context, instance, data, parentStore, recordsAccessor, index) {
2724
+ const key = this.cacheByKeyField && this.keyField && isObject(data) ? data[this.keyField] : null;
2725
+ let recordStore = key != null ? instance.cacheByKey[key] : instance.recordStoreCache.get(data);
2726
+ if (recordsAccessor) {
2727
+ if (!recordStore) {
2728
+ recordStore = new ArrayElementView({
2729
+ store: parentStore,
2730
+ arrayAccessor: recordsAccessor,
2731
+ itemIndex: index,
2732
+ recordAlias: this.recordName,
2733
+ indexAlias: this.indexName,
2734
+ immutable: this.immutable,
2735
+ sealed: this.sealed,
2736
+ });
2737
+ } else {
2738
+ recordStore.setStore(parentStore);
2739
+ recordStore.setIndex(index);
2740
+ }
2741
+ } else {
2742
+ if (!recordStore) {
2743
+ recordStore = new ReadOnlyDataView({
2744
+ store: parentStore,
2745
+ data: {
2746
+ [this.recordName]: data,
2747
+ [this.indexName]: index,
2748
+ },
2749
+ immutable: this.immutable,
2750
+ sealed: this.sealed,
2751
+ });
2752
+ } else {
2753
+ recordStore.setStore(parentStore);
2754
+ recordStore.setData({
2755
+ [this.recordName]: data,
2756
+ [this.indexName]: index,
2757
+ });
2758
+ }
2759
+ }
2760
+ if (key != null) {
2761
+ instance.cacheByKey[key] = recordStore;
2762
+ } else if (isObject(data)) {
2763
+ instance.recordStoreCache.set(data, recordStore);
2764
+ }
2765
+ return {
2766
+ store: recordStore,
2767
+ index: index,
2768
+ data: data,
2769
+ type: "data",
2770
+ key: this.keyField && isObject(data) ? data[this.keyField] : index,
2771
+ };
2772
+ }
2773
+ setFilter(filterFn) {
2774
+ this.filterFn = filterFn;
2775
+ }
2776
+ getComparer(sortOptions) {
2777
+ return sortOptions ? Culture.getComparer(sortOptions) : undefined;
2778
+ }
2779
+ buildSorter(sorters) {
2780
+ if (isArray(sorters) && sorters.length > 0) {
2781
+ let dataAccessor;
2782
+ let fieldValueMapper;
2783
+ if (sorters.every((x) => x.field && x.value == null)) {
2784
+ dataAccessor = (x) => x.data;
2785
+ fieldValueMapper = (x) => ({
2786
+ bind: x.field,
2787
+ });
2788
+ } else {
2789
+ dataAccessor = (x) => x.store.getData();
2790
+ fieldValueMapper = (x) => ({
2791
+ bind: this.recordName + "." + x.field,
2792
+ });
2793
+ }
2794
+ this.sorter = sorter(
2795
+ sorters.map((x) => {
2796
+ const s = Object.assign({}, x);
2797
+ if (s.field && s.value == null) {
2798
+ s.value = fieldValueMapper(s);
2799
+ }
2800
+ if (!s.comparer) {
2801
+ s.comparer = this.getComparer(isDefined(s.sortOptions) ? s.sortOptions : this.sortOptions);
2802
+ }
2803
+ return s;
2804
+ }),
2805
+ dataAccessor,
2806
+ );
2807
+ } else {
2808
+ this.sorter = undefined;
2809
+ }
2810
+ }
2811
+ sort(sorters) {
2812
+ if (sorters) {
2813
+ this.buildSorter(sorters);
2814
+ }
2815
+ }
2816
+ }
2817
+ ArrayAdapter.prototype.immutable = false;
2818
+ ArrayAdapter.prototype.sealed = false;
2819
+ ArrayAdapter.prototype.keyField = null;
2820
+ ArrayAdapter.prototype.cacheByKeyField = true;
2821
+ ArrayAdapter.prototype.isTreeAdapter = false;
2822
+ ArrayAdapter.autoInit = true;
2823
+
2824
+ class UseParentLayout extends PureContainer {}
2825
+ UseParentLayout.prototype.noLayout = true;
2826
+ UseParentLayout.prototype.useParentLayout = true;
2827
+
2828
+ class Repeater extends ContainerBase {
2829
+ recordsAccessor;
2830
+ item;
2831
+ filter;
2832
+ declareData(...args) {
2833
+ super.declareData(
2834
+ {
2835
+ records: undefined,
2836
+ sorters: undefined,
2837
+ sortField: undefined,
2838
+ sortDirection: undefined,
2839
+ filterParams: {
2840
+ structured: true,
2841
+ },
2842
+ },
2843
+ ...args,
2844
+ );
2845
+ }
2846
+ init() {
2847
+ this.recordsAccessor = getAccessor(this.records);
2848
+ if (this.recordAlias) this.recordName = this.recordAlias;
2849
+ if (this.indexAlias) this.indexName = this.indexAlias;
2850
+ this.dataAdapter = ArrayAdapter.create({
2851
+ ...this.dataAdapter,
2852
+ recordName: this.recordName,
2853
+ indexName: this.indexName,
2854
+ keyField: this.keyField,
2855
+ immutable: this.immutable,
2856
+ sealed: this.sealed,
2857
+ recordsAccessor: this.recordsAccessor,
2858
+ sortOptions: this.sortOptions,
2859
+ });
2860
+ this.item = PureContainer.create({
2861
+ children: this.items || this.children,
2862
+ layout: UseParentLayout,
2863
+ });
2864
+ delete this.children;
2865
+ this.items = [];
2866
+ super.init();
2867
+ }
2868
+ initInstance(context, instance) {
2869
+ this.dataAdapter.initInstance(context, instance);
2870
+ }
2871
+ applyParentStore(instance) {
2872
+ super.applyParentStore(instance);
2873
+ // force prepareData to execute again and propagate the store change to the records
2874
+ if (instance.cached) delete instance.cached.rawData;
2875
+ }
2876
+ prepareData(context, instance) {
2877
+ let { data } = instance;
2878
+ if (data.sortField)
2879
+ data.sorters = [
2880
+ {
2881
+ field: data.sortField,
2882
+ direction: data.sortDirection || "ASC",
2883
+ },
2884
+ ];
2885
+ this.dataAdapter.sort(data.sorters);
2886
+ let filter = null;
2887
+ if (this.onCreateFilter) filter = instance.invoke("onCreateFilter", data.filterParams, instance);
2888
+ else if (this.filter) filter = (item) => this.filter(item, data.filterParams);
2889
+ this.dataAdapter.setFilter(filter);
2890
+ instance.mappedRecords = this.dataAdapter.getRecords(context, instance, data.records, instance.store);
2891
+ if (this.onTrackMappedRecords) {
2892
+ instance.invoke("onTrackMappedRecords", instance.mappedRecords, instance);
2893
+ }
2894
+ super.prepareData(context, instance);
2895
+ }
2896
+ explore(context, instance, data) {
2897
+ let instances = [];
2898
+ instance.mappedRecords.forEach((record) => {
2899
+ let subInstance = instance.getChild(context, this.item, record.key, record.store);
2900
+ let changed = subInstance.cache("recordData", record.data) || subInstance.cache("key", record.key);
2901
+ subInstance.record = record;
2902
+ if (this.cached && !changed && subInstance.visible && !subInstance.childStateDirty) {
2903
+ instances.push(subInstance);
2904
+ subInstance.shouldUpdate = false;
2905
+ } else if (subInstance.scheduleExploreIfVisible(context)) instances.push(subInstance);
2906
+ });
2907
+ instance.children = instances;
2908
+ }
2909
+ }
2910
+ Repeater.prototype.recordName = "$record";
2911
+ Repeater.prototype.indexName = "$index";
2912
+ Repeater.prototype.cached = false;
2913
+ Repeater.prototype.immutable = false;
2914
+ Repeater.prototype.sealed = false;
2915
+ Repeater.prototype.isPureContainer = true;
2916
+ Widget.alias("repeater", Repeater);
2917
+
151
2918
  function autoFocus(el, component) {
152
2919
  let data = component.props.data || component.props.instance.data;
153
2920
  let autoFocusValue = el && data.autoFocus;
@@ -196,10 +2963,10 @@ let urlAttributes = {
196
2963
  "img.src": true,
197
2964
  "iframe.src": true,
198
2965
  };
199
- class HtmlElementInstance extends Instance {
2966
+ class HtmlElementInstance extends Instance$1 {
200
2967
  events;
201
2968
  }
202
- class HtmlElement extends StyledContainerBase {
2969
+ class HtmlElement extends StyledContainerBase$1 {
203
2970
  constructor(config) {
204
2971
  super(config);
205
2972
  if (isUndefined(this.jsxAttributes) && config)
@@ -361,11 +3128,11 @@ class HtmlElement extends StyledContainerBase {
361
3128
  },
362
3129
  key,
363
3130
  );
364
- return VDOM.createElement(this.tag, props, props.children);
3131
+ return VDOM$2.createElement(this.tag, props, props.children);
365
3132
  }
366
3133
  }
367
3134
  HtmlElement.prototype.tag = "div";
368
- class ContainerComponent extends VDOM.Component {
3135
+ class ContainerComponent extends VDOM$2.Component {
369
3136
  el = null;
370
3137
  constructor(props) {
371
3138
  super(props);
@@ -393,7 +3160,7 @@ class ContainerComponent extends VDOM.Component {
393
3160
  if (onMouseMove) onMouseMove(e);
394
3161
  };
395
3162
  }
396
- return VDOM.createElement(tag, props, children);
3163
+ return VDOM$2.createElement(tag, props, children);
397
3164
  }
398
3165
  componentWillUnmount() {
399
3166
  tooltipParentWillUnmount$1(this.props.instance);
@@ -419,9 +3186,9 @@ class ContainerComponent extends VDOM.Component {
419
3186
  autoFocus(this.el, this);
420
3187
  }
421
3188
  }
422
- const originalWidgetFactory = Widget.factory;
3189
+ const originalWidgetFactory = Widget$1.factory;
423
3190
  //support for React components
424
- Widget.factory = function (type, config, more) {
3191
+ Widget$1.factory = function (type, config, more) {
425
3192
  const typeType = typeof type;
426
3193
  if (typeType === "undefined") {
427
3194
  debug("Creating a widget of unknown type.", config, more);
@@ -435,9 +3202,9 @@ Widget.factory = function (type, config, more) {
435
3202
  },
436
3203
  config,
437
3204
  );
438
- return originalWidgetFactory.call(Widget, type, config, more);
3205
+ return originalWidgetFactory.call(Widget$1, type, config, more);
439
3206
  };
440
- Widget.alias("html-element", HtmlElement);
3207
+ Widget$1.alias("html-element", HtmlElement);
441
3208
 
442
3209
  let htmlFactoryCache = {};
443
3210
  function getHtmlElementFactory(tagName) {
@@ -476,12 +3243,12 @@ function cx(typeName, props, ...children) {
476
3243
  };
477
3244
  }
478
3245
  function react(config) {
479
- if (!config || isString(config) || isNumber(config) || VDOM.isValidElement(config)) return config;
3246
+ if (!config || isString(config) || isNumber(config) || VDOM$2.isValidElement(config)) return config;
480
3247
  if (isArray(config)) return config.map(react);
481
3248
  let type = config.$type;
482
3249
  if (isComponentFactory(type) && type.$meta && type.$meta.tag) type = type.$meta.tag;
483
- if (isArray(config.children)) return VDOM.createElement(type, config.$props, ...config.children.map(react));
484
- return VDOM.createElement(type, config.$props, react(config.children));
3250
+ if (isArray(config.children)) return VDOM$2.createElement(type, config.$props, ...config.children.map(react));
3251
+ return VDOM$2.createElement(type, config.$props, react(config.children));
485
3252
  }
486
3253
 
487
3254
  function getMessage(options) {
@@ -939,7 +3706,7 @@ registerIcon(
939
3706
  true,
940
3707
  );
941
3708
 
942
- class Icon extends Widget {
3709
+ class Icon extends Widget$1 {
943
3710
  declareData(...args) {
944
3711
  super.declareData(...args, {
945
3712
  name: undefined,
@@ -974,7 +3741,7 @@ class Icon extends Widget {
974
3741
  }
975
3742
  Icon.prototype.baseClass = "icon";
976
3743
  Icon.prototype.styled = true;
977
- Widget.alias("icon", Icon);
3744
+ Widget$1.alias("icon", Icon);
978
3745
 
979
3746
  class Button extends HtmlElement {
980
3747
  constructor(config) {
@@ -1052,7 +3819,7 @@ class Button extends HtmlElement {
1052
3819
  key: "icon",
1053
3820
  className: this.CSS.element(this.baseClass, "icon"),
1054
3821
  });
1055
- const children = getContentArray(props.children);
3822
+ const children = getContentArray$1(props.children);
1056
3823
  props.children = [icon, ...children];
1057
3824
  props.className = this.CSS.expand(
1058
3825
  props.className,
@@ -1079,9 +3846,9 @@ Button.prototype.baseClass = "button";
1079
3846
  Button.prototype.icon = false;
1080
3847
  Button.prototype.focusOnMouseDown = false;
1081
3848
  Button.prototype.submit = false;
1082
- Widget.alias("button", Button);
3849
+ Widget$1.alias("button", Button);
1083
3850
 
1084
- class DocumentTitle extends Widget {
3851
+ class DocumentTitle extends Widget$1 {
1085
3852
  constructor(config) {
1086
3853
  super(config);
1087
3854
  }
@@ -1133,7 +3900,7 @@ class DocumentTitle extends Widget {
1133
3900
  }
1134
3901
  DocumentTitle.prototype.action = "append";
1135
3902
  DocumentTitle.prototype.separator = "";
1136
- Widget.alias("document-title", DocumentTitle);
3903
+ Widget$1.alias("document-title", DocumentTitle);
1137
3904
 
1138
3905
  /*
1139
3906
  - renders list of items
@@ -1141,7 +3908,7 @@ Widget.alias("document-title", DocumentTitle);
1141
3908
  - selection
1142
3909
  - fake focus - list appears focused and receives keyboard inputs redirected from other control (dropdown scenario)
1143
3910
  */
1144
- class List extends StyledContainerBase {
3911
+ class List extends StyledContainerBase$1 {
1145
3912
  constructor(config) {
1146
3913
  super(config);
1147
3914
  }
@@ -1257,7 +4024,7 @@ class List extends StyledContainerBase {
1257
4024
  instance: x,
1258
4025
  key: x.record.key,
1259
4026
  type: x.record.type,
1260
- content: getContent(x.render(context)),
4027
+ content: getContent$1(x.render(context)),
1261
4028
  }));
1262
4029
  return jsx(
1263
4030
  ListComponent,
@@ -1287,8 +4054,8 @@ class List extends StyledContainerBase {
1287
4054
  // Clone to avoid mutating the original config
1288
4055
  return {
1289
4056
  ...g,
1290
- header: g.header ? Widget.create(g.header) : undefined,
1291
- footer: g.footer ? Widget.create(g.footer) : undefined,
4057
+ header: g.header ? Widget$1.create(g.header) : undefined,
4058
+ footer: g.footer ? Widget$1.create(g.footer) : undefined,
1292
4059
  };
1293
4060
  });
1294
4061
  this.adapter.groupBy(normalized);
@@ -1306,8 +4073,8 @@ List.prototype.styled = true;
1306
4073
  List.prototype.scrollSelectionIntoView = false;
1307
4074
  List.prototype.selectMode = false;
1308
4075
  List.prototype.selectOnTab = false;
1309
- Widget.alias("list", List);
1310
- class ListComponent extends VDOM.Component {
4076
+ Widget$1.alias("list", List);
4077
+ class ListComponent extends VDOM$2.Component {
1311
4078
  cursorChildIndex = [];
1312
4079
  unsubscribeScroll;
1313
4080
  onKeyDown;
@@ -1495,7 +4262,7 @@ class ListComponent extends VDOM.Component {
1495
4262
  //ignore mouse enter/leave events (support with a flag if a feature request comes)
1496
4263
  if (!hover) newState.cursor = index;
1497
4264
  //batch updates to avoid flickering between selection and cursor changes
1498
- batchUpdates(() => {
4265
+ batchUpdates$1(() => {
1499
4266
  if (select || widget.selectMode) {
1500
4267
  let start =
1501
4268
  selectRange && this.state.selectionStart !== undefined && this.state.selectionStart >= 0
@@ -1639,7 +4406,7 @@ class ListComponent extends VDOM.Component {
1639
4406
  }
1640
4407
  }
1641
4408
  }
1642
- class ListItem extends Container {
4409
+ class ListItem extends Container$1 {
1643
4410
  declareData(...args) {
1644
4411
  super.declareData(...args, {
1645
4412
  disabled: undefined,
@@ -1656,7 +4423,7 @@ function isItemDisabled(item) {
1656
4423
  return item?.instance.data.disabled;
1657
4424
  }
1658
4425
 
1659
- class Sandbox extends PureContainerBase {
4426
+ class Sandbox extends PureContainerBase$1 {
1660
4427
  init() {
1661
4428
  if (this.recordAlias) this.recordName = this.recordAlias;
1662
4429
  if (this.accessKey) this.key = this.accessKey;
@@ -1706,7 +4473,7 @@ class Sandbox extends PureContainerBase {
1706
4473
  Sandbox.prototype.recordName = "$page";
1707
4474
  Sandbox.prototype.immutable = false;
1708
4475
  Sandbox.prototype.sealed = false;
1709
- Widget.alias("sandbox", Sandbox);
4476
+ Widget$1.alias("sandbox", Sandbox);
1710
4477
 
1711
4478
  class CxCredit extends HtmlElement {
1712
4479
  constructor(config) {
@@ -1741,7 +4508,7 @@ class CxCredit extends HtmlElement {
1741
4508
  }
1742
4509
  CxCredit.prototype.baseClass = "cxcredit";
1743
4510
  CxCredit.prototype.tag = "div";
1744
- Widget.alias("cx-credit", CxCredit);
4511
+ Widget$1.alias("cx-credit", CxCredit);
1745
4512
 
1746
4513
  class Heading extends HtmlElement {
1747
4514
  init() {
@@ -1768,7 +4535,7 @@ class Heading extends HtmlElement {
1768
4535
  Heading.prototype.level = 3;
1769
4536
  Heading.prototype.baseClass = "heading";
1770
4537
 
1771
- class Section extends ContainerBase {
4538
+ class Section extends ContainerBase$1 {
1772
4539
  init() {
1773
4540
  if (isString(this.headerStyle)) this.headerStyle = parseStyle(this.headerStyle);
1774
4541
  if (isString(this.footerStyle)) this.footerStyle = parseStyle(this.footerStyle);
@@ -1819,7 +4586,7 @@ class Section extends ContainerBase {
1819
4586
  }
1820
4587
  getHeader() {
1821
4588
  if (this.title)
1822
- return Widget.create(Heading, {
4589
+ return Widget$1.create(Heading, {
1823
4590
  text: this.title,
1824
4591
  level: this.hLevel,
1825
4592
  });
@@ -1827,7 +4594,7 @@ class Section extends ContainerBase {
1827
4594
  return null;
1828
4595
  }
1829
4596
  getFooter() {
1830
- if (this.footer) return Widget.create(this.footer);
4597
+ if (this.footer) return Widget$1.create(this.footer);
1831
4598
  return null;
1832
4599
  }
1833
4600
  prepareData(context, instance) {
@@ -1851,14 +4618,14 @@ class Section extends ContainerBase {
1851
4618
  header = jsx("header", {
1852
4619
  className: CSS.expand(CSS.element(baseClass, "header"), data.headerClass),
1853
4620
  style: data.headerStyle,
1854
- children: getContent(components.header.render(context)),
4621
+ children: getContent$1(components.header.render(context)),
1855
4622
  });
1856
4623
  }
1857
4624
  if (components?.footer) {
1858
4625
  footer = jsx("footer", {
1859
4626
  className: CSS.expand(CSS.element(baseClass, "footer"), data.footerClass),
1860
4627
  style: data.footerStyle,
1861
- children: getContent(components.footer.render(context)),
4628
+ children: getContent$1(components.footer.render(context)),
1862
4629
  });
1863
4630
  }
1864
4631
  return jsxs(
@@ -1887,7 +4654,7 @@ Section.prototype.pad = true;
1887
4654
  Section.prototype.baseClass = "section";
1888
4655
  Section.prototype.hLevel = 3;
1889
4656
 
1890
- class FlexBox extends ContainerBase {
4657
+ class FlexBox extends ContainerBase$1 {
1891
4658
  constructor(config) {
1892
4659
  super(config);
1893
4660
  }
@@ -1965,7 +4732,7 @@ class FlexRow extends FlexBox {}
1965
4732
  class FlexCol extends FlexBox {}
1966
4733
  FlexCol.prototype.direction = "column";
1967
4734
 
1968
- class ProgressBar extends Widget {
4735
+ class ProgressBar extends Widget$1 {
1969
4736
  constructor(config) {
1970
4737
  super(config);
1971
4738
  }
@@ -2059,7 +4826,7 @@ function captureMouse2(e, options) {
2059
4826
  }
2060
4827
  //if mouse moves double clicking is off
2061
4828
  options.onDblClick = undefined;
2062
- batchUpdates(() => {
4829
+ batchUpdates$1(() => {
2063
4830
  if (options.onMouseMove) options.onMouseMove(e, options.captureData);
2064
4831
  e.stopPropagation();
2065
4832
  e.preventDefault(); //disable text selection
@@ -2067,7 +4834,7 @@ function captureMouse2(e, options) {
2067
4834
  }
2068
4835
  function end(e) {
2069
4836
  active = false;
2070
- batchUpdates(() => {
4837
+ batchUpdates$1(() => {
2071
4838
  // if (surface.releaseCapture)
2072
4839
  // surface.releaseCapture();
2073
4840
  if (!options.onDblClick) surface.style.display = "none";
@@ -2091,13 +4858,13 @@ function captureMouseOrTouch2(e, options) {
2091
4858
  if (e.type.indexOf("touch") == 0) {
2092
4859
  let el = e.currentTarget;
2093
4860
  let move = (e) => {
2094
- batchUpdates(() => {
4861
+ batchUpdates$1(() => {
2095
4862
  if (options.onMouseMove) options.onMouseMove(e, options.captureData);
2096
4863
  e.preventDefault();
2097
4864
  });
2098
4865
  };
2099
4866
  let end = (e) => {
2100
- batchUpdates(() => {
4867
+ batchUpdates$1(() => {
2101
4868
  el.removeEventListener("touchmove", move);
2102
4869
  el.removeEventListener("touchend", end);
2103
4870
  if (options.onMouseUp) options.onMouseUp(e);
@@ -2159,7 +4926,7 @@ function getCursorPos(e) {
2159
4926
  };
2160
4927
  }
2161
4928
 
2162
- class Resizer extends Widget {
4929
+ class Resizer extends Widget$1 {
2163
4930
  constructor(config) {
2164
4931
  super(config);
2165
4932
  }
@@ -2190,7 +4957,7 @@ Resizer.prototype.forNextElement = false;
2190
4957
  Resizer.prototype.defaultSize = null;
2191
4958
  Resizer.prototype.minSize = 0;
2192
4959
  Resizer.prototype.maxSize = 1e6;
2193
- class ResizerCmp extends VDOM.Component {
4960
+ class ResizerCmp extends VDOM$2.Component {
2194
4961
  constructor(props) {
2195
4962
  super(props);
2196
4963
  this.state = {
@@ -2303,7 +5070,7 @@ class ResizerCmp extends VDOM.Component {
2303
5070
  }
2304
5071
  }
2305
5072
 
2306
- class HighlightedSearchText extends Widget {
5073
+ class HighlightedSearchText extends Widget$1 {
2307
5074
  constructor(config) {
2308
5075
  super(config);
2309
5076
  }
@@ -2341,7 +5108,7 @@ class HighlightedSearchText extends Widget {
2341
5108
  HighlightedSearchText.prototype.styled = true;
2342
5109
  HighlightedSearchText.prototype.baseClass = "highlightedsearchtext";
2343
5110
 
2344
- class ReactElementWrapper extends ContainerBase {
5111
+ class ReactElementWrapper extends ContainerBase$1 {
2345
5112
  init() {
2346
5113
  // Collect all props to pass to the React component
2347
5114
  this.props = {};
@@ -2397,7 +5164,7 @@ class ReactElementWrapper extends ContainerBase {
2397
5164
  ...instance.events,
2398
5165
  children,
2399
5166
  };
2400
- return VDOM.createElement(this.componentType, props);
5167
+ return VDOM$2.createElement(this.componentType, props);
2401
5168
  }
2402
5169
  }
2403
5170
 
@@ -2701,12 +5468,12 @@ function ddHandle(e) {
2701
5468
  function isDragHandleEvent(e) {
2702
5469
  return lastDragHandle && (e.target == lastDragHandle || lastDragHandle.contains(e.target));
2703
5470
  }
2704
- const DragDropContext = VDOM.createContext
2705
- ? VDOM.createContext({
5471
+ const DragDropContext = VDOM$2.createContext
5472
+ ? VDOM$2.createContext({
2706
5473
  disabled: false,
2707
5474
  })
2708
5475
  : ({ children }) => children;
2709
- class ContextWrap extends Container {
5476
+ class ContextWrap extends Container$1 {
2710
5477
  render(context, instance, key) {
2711
5478
  return jsx(
2712
5479
  DragDropContext.Provider,
@@ -2719,10 +5486,10 @@ class ContextWrap extends Container {
2719
5486
  }
2720
5487
  }
2721
5488
 
2722
- class OverlayInstance extends Instance {
5489
+ class OverlayInstance extends Instance$1 {
2723
5490
  onBeforeDismiss;
2724
5491
  }
2725
- class OverlayBase extends ContainerBase {
5492
+ class OverlayBase extends ContainerBase$1 {
2726
5493
  static configureOverlayContainer;
2727
5494
  init() {
2728
5495
  if (this.center) this.centerX = this.centerY = this.center;
@@ -2928,9 +5695,9 @@ OverlayBase.prototype.dismissOnPopState = false;
2928
5695
  OverlayBase.prototype.closeOnEscape = false;
2929
5696
  OverlayBase.prototype.needsBeacon = false;
2930
5697
  class Overlay extends OverlayBase {}
2931
- Widget.alias("overlay", Overlay);
5698
+ Widget$1.alias("overlay", Overlay);
2932
5699
  //TODO: all el related logic should be moved here
2933
- class OverlayContent extends VDOM.Component {
5700
+ class OverlayContent extends VDOM$2.Component {
2934
5701
  render() {
2935
5702
  return jsx("div", {
2936
5703
  ref: this.props.onRef,
@@ -2958,7 +5725,7 @@ class OverlayContent extends VDOM.Component {
2958
5725
  }
2959
5726
  }
2960
5727
  //TODO: This should be called OverlayPortal
2961
- class OverlayComponent extends VDOM.Component {
5728
+ class OverlayComponent extends VDOM$2.Component {
2962
5729
  onOverlayRef;
2963
5730
  onPopState;
2964
5731
  unsubscribeWheelBlock;
@@ -2978,7 +5745,7 @@ class OverlayComponent extends VDOM.Component {
2978
5745
  this.containerEl = this.ownedEl;
2979
5746
  }
2980
5747
  // content is rendered in componentDidUpdate if portals are not supported
2981
- return VDOM.DOM.createPortal ? VDOM.DOM.createPortal(this.renderOverlay(), this.containerEl) : null;
5748
+ return VDOM$2.DOM.createPortal ? VDOM$2.DOM.createPortal(this.renderOverlay(), this.containerEl) : null;
2982
5749
  }
2983
5750
  renderOverlay() {
2984
5751
  let { widget, data } = this.props.instance;
@@ -3353,14 +6120,14 @@ class OverlayComponent extends VDOM.Component {
3353
6120
  }
3354
6121
  }
3355
6122
  componentDidUpdate() {
3356
- if (this.containerEl && !VDOM.DOM.createPortal) {
3357
- this.root = VDOM.DOM.createRoot(this.containerEl);
6123
+ if (this.containerEl && !VDOM$2.DOM.createPortal) {
6124
+ this.root = VDOM$2.DOM.createRoot(this.containerEl);
3358
6125
  this.root.render(this.renderOverlay());
3359
6126
  }
3360
6127
  this.overlayDidUpdate();
3361
6128
  }
3362
6129
  }
3363
- class OverlayBeacon extends VDOM.Component {
6130
+ class OverlayBeacon extends VDOM$2.Component {
3364
6131
  el;
3365
6132
  render() {
3366
6133
  return jsxs(Fragment, {
@@ -3949,8 +6716,8 @@ DropdownBase.prototype.firstChildDefinesHeight = false;
3949
6716
  DropdownBase.prototype.firstChildDefinesWidth = false;
3950
6717
  DropdownBase.prototype.cover = false;
3951
6718
  class Dropdown extends DropdownBase {}
3952
- Widget.alias("dropdown", Dropdown);
3953
- Localization.registerPrototype("cx/widgets/Dropdown", Dropdown);
6719
+ Widget$1.alias("dropdown", Dropdown);
6720
+ Localization$1.registerPrototype("cx/widgets/Dropdown", Dropdown);
3954
6721
  function getViewportRect(padding = 0) {
3955
6722
  return {
3956
6723
  left: padding,
@@ -4097,7 +6864,7 @@ TooltipBase.prototype.arrow = true;
4097
6864
  TooltipBase.prototype.alwaysVisible = false;
4098
6865
  TooltipBase.prototype.globalMouseTracking = false;
4099
6866
  class Tooltip extends TooltipBase {}
4100
- Widget.alias("tooltip", Tooltip);
6867
+ Widget$1.alias("tooltip", Tooltip);
4101
6868
  function getTooltipInstance(e, parentInstance, tooltip, options = {}) {
4102
6869
  let target = options.target || (e instanceof Element ? e : e?.currentTarget) || e;
4103
6870
  debug(tooltipsFlag, "mouse-move", target, parentInstance);
@@ -4139,7 +6906,7 @@ function getTooltipInstance(e, parentInstance, tooltip, options = {}) {
4139
6906
  tooltipInstance = parentInstance.tooltips[name] = parentInstance.getDetachedChild(tooltipWidget, name, store);
4140
6907
  tooltipInstance.config = config;
4141
6908
  tooltipInstance.tooltipName = name;
4142
- tooltipInstance.init(new RenderingContext());
6909
+ tooltipInstance.init(new RenderingContext$1());
4143
6910
  if (config.alwaysVisible || config.trackMouse || config.trackMouseX || config.trackMouseY) {
4144
6911
  tooltipInstance.data = tooltipInstance.dataSelector(store);
4145
6912
  }
@@ -4284,16 +7051,16 @@ class Window extends OverlayBase {
4284
7051
  }
4285
7052
  initHelpers(...args) {
4286
7053
  return super.initHelpers(...args, {
4287
- header: Widget.create(
7054
+ header: Widget$1.create(
4288
7055
  this.header || {
4289
- type: ContentPlaceholder,
7056
+ type: ContentPlaceholder$1,
4290
7057
  name: "header",
4291
7058
  scoped: true,
4292
7059
  },
4293
7060
  ),
4294
- footer: Widget.create(
7061
+ footer: Widget$1.create(
4295
7062
  this.footer || {
4296
- type: ContentPlaceholder,
7063
+ type: ContentPlaceholder$1,
4297
7064
  name: "footer",
4298
7065
  scoped: true,
4299
7066
  },
@@ -4323,14 +7090,14 @@ class Window extends OverlayBase {
4323
7090
  let result = [];
4324
7091
  if (data.title) result.push(data.title);
4325
7092
  if (instance.helpers) {
4326
- let header = getContent(instance.helpers.header && instance.helpers.header.render(context));
7093
+ let header = getContent$1(instance.helpers.header && instance.helpers.header.render(context));
4327
7094
  if (header) result.push(header);
4328
- if (data.closable && instance.helpers.close) result.push(getContent(instance.helpers.close.render(context)));
7095
+ if (data.closable && instance.helpers.close) result.push(getContent$1(instance.helpers.close.render(context)));
4329
7096
  }
4330
7097
  return result;
4331
7098
  }
4332
7099
  renderFooter(context, instance, key) {
4333
- return getContent(instance.helpers && instance.helpers.footer && instance.helpers.footer.render(context));
7100
+ return getContent$1(instance.helpers && instance.helpers.footer && instance.helpers.footer.render(context));
4334
7101
  }
4335
7102
  render(context, instance, key) {
4336
7103
  var header = this.renderHeader(context, instance, "header");
@@ -4361,8 +7128,8 @@ Window.prototype.autoFocus = true;
4361
7128
  Window.prototype.focusable = true;
4362
7129
  Window.prototype.pad = true;
4363
7130
  Window.prototype.needsBeacon = true;
4364
- Widget.alias("window", Window);
4365
- Localization.registerPrototype("cx/widgets/Window", Window);
7131
+ Widget$1.alias("window", Window);
7132
+ Localization$1.registerPrototype("cx/widgets/Window", Window);
4366
7133
  class WindowComponent extends OverlayComponent {
4367
7134
  headerEl;
4368
7135
  footerEl;
@@ -4571,7 +7338,7 @@ MsgBox.prototype.footerDirection = "row";
4571
7338
  MsgBox.prototype.footerJustify = "center";
4572
7339
  MsgBox.prototype.yesText = "Yes";
4573
7340
  MsgBox.prototype.noText = "No";
4574
- Localization.registerPrototype("cx/widgets/MsgBox", MsgBox);
7341
+ Localization$1.registerPrototype("cx/widgets/MsgBox", MsgBox);
4575
7342
  function enableMsgBoxAlerts() {
4576
7343
  registerAlertImpl({
4577
7344
  yesNo: MsgBox.yesNo.bind(MsgBox),
@@ -4583,7 +7350,7 @@ class Toast extends OverlayBase {
4583
7350
  init() {
4584
7351
  if (this.message)
4585
7352
  this.items = {
4586
- type: Text,
7353
+ type: Text$1,
4587
7354
  value: this.message,
4588
7355
  };
4589
7356
  super.init();
@@ -4671,7 +7438,7 @@ ContextMenu.prototype.autoFocus = true;
4671
7438
  ContextMenu.prototype.autoFocusFirstChild = false;
4672
7439
  ContextMenu.prototype.focusable = true;
4673
7440
  ContextMenu.prototype.alignArrow = true;
4674
- Localization.registerPrototype("cx/widgets/ContextMenu", ContextMenu);
7441
+ Localization$1.registerPrototype("cx/widgets/ContextMenu", ContextMenu);
4675
7442
  const openContextMenu = (e, content, storeOrInstance, options) => {
4676
7443
  e.preventDefault();
4677
7444
  e.stopPropagation();
@@ -4688,8 +7455,8 @@ const openContextMenu = (e, content, storeOrInstance, options) => {
4688
7455
  return menu.open(storeOrInstance, options);
4689
7456
  };
4690
7457
 
4691
- class FlyweightTooltipTrackerInstance extends Instance {}
4692
- class FlyweightTooltipTracker extends Widget {
7458
+ class FlyweightTooltipTrackerInstance extends Instance$1 {}
7459
+ class FlyweightTooltipTracker extends Widget$1 {
4693
7460
  constructor(config) {
4694
7461
  super(config);
4695
7462
  }
@@ -5233,7 +8000,7 @@ Route$1.prototype = Object.create(Object.prototype);
5233
8000
  Route$1.prototype.constructor = Route$1;
5234
8001
 
5235
8002
  // Base class for extending with custom Config types
5236
- class RouteBase extends PureContainerBase {
8003
+ class RouteBase extends PureContainerBase$1 {
5237
8004
  init() {
5238
8005
  if (this.path) this.route = this.path;
5239
8006
  super.init();
@@ -5315,7 +8082,7 @@ RouteBase.prototype.recordName = "$route";
5315
8082
  RouteBase.prototype.prefix = false;
5316
8083
  // Closed type for direct usage
5317
8084
  class Route extends RouteBase {}
5318
- Widget.alias("route", Route);
8085
+ Widget$1.alias("route", Route);
5319
8086
 
5320
8087
  class RedirectRoute extends RouteBase {
5321
8088
  checkVisible(context, instance, data) {
@@ -5337,7 +8104,7 @@ class RedirectRoute extends RouteBase {
5337
8104
  else instance.set("url", data.redirect);
5338
8105
  }
5339
8106
  }
5340
- Widget.alias("redirect-route", RedirectRoute);
8107
+ Widget$1.alias("redirect-route", RedirectRoute);
5341
8108
 
5342
8109
  class Tab extends HtmlElement {
5343
8110
  declareData() {
@@ -5402,7 +8169,7 @@ Tab.prototype.baseClass = "tab";
5402
8169
  Tab.prototype.tag = "a";
5403
8170
  Tab.prototype.focusOnMouseDown = false;
5404
8171
  Tab.prototype.default = false;
5405
- Widget.alias("tab", Tab);
8172
+ Widget$1.alias("tab", Tab);
5406
8173
 
5407
8174
  class LinkButton extends Button {
5408
8175
  constructor(config) {
@@ -5506,11 +8273,11 @@ class LinkButton extends Button {
5506
8273
  }
5507
8274
  LinkButton.prototype.match = "equal";
5508
8275
  LinkButton.prototype.tag = "a";
5509
- Widget.alias("link-button", LinkButton);
8276
+ Widget$1.alias("link-button", LinkButton);
5510
8277
 
5511
8278
  class Link extends LinkButton {}
5512
8279
  Link.prototype.baseClass = "link";
5513
- Widget.alias("link", Link);
8280
+ Widget$1.alias("link", Link);
5514
8281
 
5515
8282
  class MenuItemInstance extends HtmlElementInstance {}
5516
8283
  class MenuItem extends HtmlElement {
@@ -5591,9 +8358,9 @@ MenuItem.prototype.checkedIcon = "check";
5591
8358
  MenuItem.prototype.uncheckedIcon = "dummy";
5592
8359
  MenuItem.prototype.keyboardShortcut = false;
5593
8360
  MenuItem.prototype.openOnFocus = true;
5594
- Widget.alias("submenu", MenuItem);
5595
- Localization.registerPrototype("cx/widgets/MenuItem", MenuItem);
5596
- let MenuItemComponent$1 = class MenuItemComponent extends VDOM.Component {
8361
+ Widget$1.alias("submenu", MenuItem);
8362
+ Localization$1.registerPrototype("cx/widgets/MenuItem", MenuItem);
8363
+ let MenuItemComponent$1 = class MenuItemComponent extends VDOM$2.Component {
5597
8364
  validateDropdownPosition;
5598
8365
  unregisterKeyboardShortcut;
5599
8366
  offParentPositionChange;
@@ -5611,7 +8378,7 @@ let MenuItemComponent$1 = class MenuItemComponent extends VDOM.Component {
5611
8378
  getDropdown() {
5612
8379
  let { horizontal, widget, parentPositionChangeEvent } = this.props.instance;
5613
8380
  if (!this.dropdown && widget.dropdown) {
5614
- this.dropdown = Widget.create(Dropdown, {
8381
+ this.dropdown = Widget$1.create(Dropdown, {
5615
8382
  matchWidth: false,
5616
8383
  placementOrder: widget.placementOrder || this.getDefaultPlacementOrder(horizontal),
5617
8384
  trackScroll: true,
@@ -5641,7 +8408,7 @@ let MenuItemComponent$1 = class MenuItemComponent extends VDOM.Component {
5641
8408
  let { CSS, baseClass } = widget;
5642
8409
  let dropdown =
5643
8410
  this.state.dropdownOpen &&
5644
- jsx(Cx, {
8411
+ jsx(Cx$1, {
5645
8412
  widget: this.getDropdown(),
5646
8413
  options: {
5647
8414
  name: "submenu",
@@ -5892,7 +8659,7 @@ let MenuItemComponent$1 = class MenuItemComponent extends VDOM.Component {
5892
8659
  }
5893
8660
  };
5894
8661
 
5895
- class MenuSpacer extends Widget {
8662
+ class MenuSpacer extends Widget$1 {
5896
8663
  render(context, instance, key) {
5897
8664
  return {
5898
8665
  key: true,
@@ -5988,7 +8755,7 @@ Menu.prototype.overflowIcon = "drop-down";
5988
8755
  Menu.Item = MenuItem;
5989
8756
  Menu.Spacer = MenuSpacer;
5990
8757
  class MenuInstance extends HtmlElementInstance {}
5991
- class MenuComponent extends VDOM.Component {
8758
+ class MenuComponent extends VDOM$2.Component {
5992
8759
  el = null;
5993
8760
  isMeasureOverflowDisabled = false;
5994
8761
  unsubscribeFocusOut;
@@ -6189,8 +8956,8 @@ class MenuComponent extends VDOM.Component {
6189
8956
  }
6190
8957
  Menu.prototype.baseClass = "menu";
6191
8958
  Menu.prototype.tag = "ul";
6192
- Widget.alias("menu", Menu);
6193
- class MenuItemComponent extends VDOM.Component {
8959
+ Widget$1.alias("menu", Menu);
8960
+ class MenuItemComponent extends VDOM$2.Component {
6194
8961
  el = null;
6195
8962
  constructor(props) {
6196
8963
  super(props);
@@ -6270,7 +9037,7 @@ class MenuItemComponent extends VDOM.Component {
6270
9037
 
6271
9038
  class Submenu extends MenuItem {}
6272
9039
 
6273
- class Scroller extends StyledContainerBase {
9040
+ class Scroller extends StyledContainerBase$1 {
6274
9041
  constructor(config) {
6275
9042
  super(config);
6276
9043
  }
@@ -6296,7 +9063,7 @@ class Scroller extends StyledContainerBase {
6296
9063
  }
6297
9064
  }
6298
9065
  Scroller.prototype.baseClass = "scroller";
6299
- class HScrollerComponent extends VDOM.Component {
9066
+ class HScrollerComponent extends VDOM$2.Component {
6300
9067
  unsubscribeResize;
6301
9068
  stopScrolling;
6302
9069
  scrollLeft;
@@ -6462,7 +9229,7 @@ HScroller.prototype.horizontal = true;
6462
9229
  class VScroller extends Scroller {}
6463
9230
  VScroller.prototype.vertical = true;
6464
9231
 
6465
- class FieldIcon extends Widget {
9232
+ class FieldIcon extends Widget$1 {
6466
9233
  declareData(...args) {
6467
9234
  super.declareData(...args, {
6468
9235
  name: undefined,
@@ -6504,7 +9271,7 @@ class HelpText extends HtmlElement {
6504
9271
  }
6505
9272
  HelpText.prototype.tag = "span";
6506
9273
  HelpText.prototype.baseClass = "helptext";
6507
- Widget.alias("help-text", HelpText);
9274
+ Widget$1.alias("help-text", HelpText);
6508
9275
 
6509
9276
  class Label extends HtmlElement {
6510
9277
  constructor(config) {
@@ -6584,7 +9351,7 @@ Label.prototype.baseClass = "label";
6584
9351
  Label.prototype.tag = "label";
6585
9352
  Label.prototype.asterisk = false;
6586
9353
 
6587
- class ValidationError extends Widget {
9354
+ class ValidationError extends Widget$1 {
6588
9355
  constructor(config) {
6589
9356
  super(config);
6590
9357
  }
@@ -6628,10 +9395,10 @@ class ValidationError extends Widget {
6628
9395
  }
6629
9396
  ValidationError.prototype.baseClass = "validationerror";
6630
9397
  ValidationError.prototype.styled = true;
6631
- Widget.alias("validation-error", ValidationError);
9398
+ Widget$1.alias("validation-error", ValidationError);
6632
9399
 
6633
- class FieldInstance extends Instance {}
6634
- class Field extends PureContainerBase {
9400
+ class FieldInstance extends Instance$1 {}
9401
+ class Field extends PureContainerBase$1 {
6635
9402
  declareData(...args) {
6636
9403
  super.declareData(
6637
9404
  {
@@ -6897,16 +9664,16 @@ class Field extends PureContainerBase {
6897
9664
  }
6898
9665
  }
6899
9666
  renderLabel(context, instance, key) {
6900
- if (instance.components?.label) return getContent(instance.components.label.vdom);
9667
+ if (instance.components?.label) return getContent$1(instance.components.label.vdom);
6901
9668
  }
6902
9669
  renderInput(context, instance, key) {
6903
9670
  throw new Error("Not implemented.");
6904
9671
  }
6905
9672
  renderHelp(context, instance, key) {
6906
- if (instance.components?.help) return getContent(instance.components.help.render(context));
9673
+ if (instance.components?.help) return getContent$1(instance.components.help.render(context));
6907
9674
  }
6908
9675
  renderIcon(context, instance, key) {
6909
- if (instance.components?.icon) return getContent(instance.components.icon.render(context));
9676
+ if (instance.components?.icon) return getContent$1(instance.components.icon.render(context));
6910
9677
  }
6911
9678
  formatValue(context, { data }) {
6912
9679
  return data.text || data.value;
@@ -7004,7 +9771,7 @@ Field.prototype.styled = true;
7004
9771
  //Field.prototype.disabled = null;
7005
9772
  //Field.prototype.readOnly = null;
7006
9773
  //Field.prototype.viewMode = null;
7007
- Localization.registerPrototype("cx/widgets/Field", Field);
9774
+ Localization$1.registerPrototype("cx/widgets/Field", Field);
7008
9775
  function getFieldTooltip(instance) {
7009
9776
  let { widget, data, state } = instance;
7010
9777
  if (widget.errorTooltip && data.error && (!state || state.visited || !widget.suppressErrorsUntilVisited))
@@ -7049,8 +9816,8 @@ class TextField extends Field {
7049
9816
  {
7050
9817
  instance: instance,
7051
9818
  data: instance.data,
7052
- label: this.labelPlacement && getContent(this.renderLabel(context, instance, "label")),
7053
- help: this.helpPlacement && getContent(this.renderHelp(context, instance, "help")),
9819
+ label: this.labelPlacement && getContent$1(this.renderLabel(context, instance, "label")),
9820
+ help: this.helpPlacement && getContent$1(this.renderHelp(context, instance, "help")),
7054
9821
  icon: this.renderIcon(context, instance, "icon"),
7055
9822
  },
7056
9823
  key,
@@ -7081,8 +9848,8 @@ TextField.prototype.showClear = false;
7081
9848
  TextField.prototype.alwaysShowClear = false;
7082
9849
  TextField.prototype.keyboardShortcut = "false";
7083
9850
  TextField.prototype.trim = false;
7084
- Localization.registerPrototype("cx/widgets/TextField", TextField);
7085
- let Input$2 = class Input extends VDOM.Component {
9851
+ Localization$1.registerPrototype("cx/widgets/TextField", TextField);
9852
+ let Input$2 = class Input extends VDOM$2.Component {
7086
9853
  input;
7087
9854
  constructor(props) {
7088
9855
  super(props);
@@ -7273,7 +10040,7 @@ let Input$2 = class Input extends VDOM.Component {
7273
10040
  return value;
7274
10041
  }
7275
10042
  };
7276
- Widget.alias("textfield", TextField);
10043
+ Widget$1.alias("textfield", TextField);
7277
10044
 
7278
10045
  var SquareIcon = registerIcon(
7279
10046
  "square",
@@ -7346,7 +10113,7 @@ class Checkbox extends Field {
7346
10113
  this.handleClick(e, instance);
7347
10114
  },
7348
10115
  style: data.style,
7349
- children: [content, this.labelPlacement && getContent(this.renderLabel(context, instance, "label"))],
10116
+ children: [content, this.labelPlacement && getContent$1(this.renderLabel(context, instance, "label"))],
7350
10117
  },
7351
10118
  key,
7352
10119
  );
@@ -7444,8 +10211,8 @@ Checkbox.prototype.baseClass = "checkbox";
7444
10211
  Checkbox.prototype.native = false;
7445
10212
  Checkbox.prototype.indeterminate = false;
7446
10213
  Checkbox.prototype.unfocusable = false;
7447
- Widget.alias("checkbox", Checkbox);
7448
- class CheckboxCmp extends VDOM.Component {
10214
+ Widget$1.alias("checkbox", Checkbox);
10215
+ class CheckboxCmp extends VDOM$2.Component {
7449
10216
  constructor(props) {
7450
10217
  super(props);
7451
10218
  this.state = {
@@ -7567,7 +10334,7 @@ class Radio extends Field {
7567
10334
  this.handleClick(e, instance);
7568
10335
  },
7569
10336
  htmlFor: data.id,
7570
- children: [content, this.labelPlacement && getContent(this.renderLabel(context, instance, "label"))],
10337
+ children: [content, this.labelPlacement && getContent$1(this.renderLabel(context, instance, "label"))],
7571
10338
  },
7572
10339
  key,
7573
10340
  );
@@ -7645,8 +10412,8 @@ class Radio extends Field {
7645
10412
  Radio.prototype.baseClass = "radio";
7646
10413
  Radio.prototype.native = false;
7647
10414
  Radio.prototype.default = false;
7648
- Widget.alias("radio", Radio);
7649
- class RadioCmp extends VDOM.Component {
10415
+ Widget$1.alias("radio", Radio);
10416
+ class RadioCmp extends VDOM$2.Component {
7650
10417
  constructor(props) {
7651
10418
  super(props);
7652
10419
  this.state = {
@@ -7724,8 +10491,8 @@ class Select extends Field {
7724
10491
  instance: instance,
7725
10492
  multiple: this.multiple,
7726
10493
  select: (v) => this.select(v, instance),
7727
- label: this.labelPlacement && getContent(this.renderLabel(context, instance, "label")),
7728
- help: this.helpPlacement && getContent(this.renderHelp(context, instance, "help")),
10494
+ label: this.labelPlacement && getContent$1(this.renderLabel(context, instance, "label")),
10495
+ help: this.helpPlacement && getContent$1(this.renderHelp(context, instance, "help")),
7729
10496
  icon: this.renderIcon(context, instance, "icon"),
7730
10497
  children: this.renderChildren(context, instance),
7731
10498
  },
@@ -7757,9 +10524,9 @@ Select.prototype.suppressErrorsUntilVisited = true;
7757
10524
  Select.prototype.showClear = true;
7758
10525
  Select.prototype.alwaysShowClear = false;
7759
10526
  Select.prototype.icon = null;
7760
- Widget.alias("select", Select);
7761
- Localization.registerPrototype("cx/widgets/Select", Select);
7762
- class SelectComponent extends VDOM.Component {
10527
+ Widget$1.alias("select", Select);
10528
+ Localization$1.registerPrototype("cx/widgets/Select", Select);
10529
+ class SelectComponent extends VDOM$2.Component {
7763
10530
  select = null;
7764
10531
  constructor(props) {
7765
10532
  super(props);
@@ -7941,7 +10708,7 @@ class Option extends HtmlElement {
7941
10708
  );
7942
10709
  }
7943
10710
  }
7944
- Widget.alias("option", Option);
10711
+ Widget$1.alias("option", Option);
7945
10712
 
7946
10713
  var ForwardIcon = registerIcon(
7947
10714
  "forward",
@@ -8068,7 +10835,7 @@ class Calendar extends Field {
8068
10835
  date = mixed;
8069
10836
  }
8070
10837
  }
8071
- let encode = calendarWidget.encoding || Culture.getDefaultDateEncoding();
10838
+ let encode = calendarWidget.encoding || Culture$1.getDefaultDateEncoding();
8072
10839
  instance.set("value", encode(date));
8073
10840
  if (this.onSelect) instance.invoke("onSelect", e, instance, date);
8074
10841
  }
@@ -8085,7 +10852,7 @@ Calendar.prototype.showTodayButton = false;
8085
10852
  Calendar.prototype.todayButtonText = "Today";
8086
10853
  Calendar.prototype.startWithMonday = false;
8087
10854
  Calendar.prototype.focusable = true;
8088
- Localization.registerPrototype("cx/widgets/Calendar", Calendar);
10855
+ Localization$1.registerPrototype("cx/widgets/Calendar", Calendar);
8089
10856
  const validationCheck = (date, data, disabledDaysOfWeek) => {
8090
10857
  if (data.maxValue && !upperBoundCheck(date, data.maxValue, data.maxExclusive)) return false;
8091
10858
  if (data.minValue && !lowerBoundCheck(date, data.minValue, data.minExclusive)) return false;
@@ -8096,7 +10863,7 @@ const validationCheck = (date, data, disabledDaysOfWeek) => {
8096
10863
  }
8097
10864
  return true;
8098
10865
  };
8099
- class CalendarCmp extends VDOM.Component {
10866
+ class CalendarCmp extends VDOM$2.Component {
8100
10867
  el = null;
8101
10868
  unsubscribeWheel;
8102
10869
  constructor(props) {
@@ -8436,7 +11203,7 @@ class CalendarCmp extends VDOM.Component {
8436
11203
  ),
8437
11204
  );
8438
11205
  }
8439
- let culture = Culture.getDateTimeCulture();
11206
+ let culture = Culture$1.getDateTimeCulture();
8440
11207
  let monthNames = culture.getMonthNames("long");
8441
11208
  let dayNames = culture.getWeekdayNames("short").map((x) => x.substr(0, 2));
8442
11209
  if (startWithMonday) dayNames = [...dayNames.slice(1), dayNames[0]];
@@ -8562,7 +11329,7 @@ class CalendarCmp extends VDOM.Component {
8562
11329
  }
8563
11330
  }
8564
11331
  const readDate = (ds) => new Date(Number(ds.year), Number(ds.month) - 1, Number(ds.date));
8565
- Widget.alias("calendar", Calendar);
11332
+ Widget$1.alias("calendar", Calendar);
8566
11333
 
8567
11334
  class LookupField extends Field {
8568
11335
  declareData(...args) {
@@ -8731,8 +11498,8 @@ class LookupField extends Field {
8731
11498
  itemConfig: this.itemConfig,
8732
11499
  bindings: this.bindings,
8733
11500
  baseClass: this.baseClass,
8734
- label: this.labelPlacement && getContent(this.renderLabel(context, instance, "label")),
8735
- help: this.helpPlacement && getContent(this.renderHelp(context, instance, "help")),
11501
+ label: this.labelPlacement && getContent$1(this.renderLabel(context, instance, "label")),
11502
+ help: this.helpPlacement && getContent$1(this.renderHelp(context, instance, "help")),
8736
11503
  forceUpdate: context.forceUpdate,
8737
11504
  icon: this.renderIcon(context, instance, "icon"),
8738
11505
  },
@@ -8809,8 +11576,8 @@ LookupField.prototype.pageSize = 100;
8809
11576
  LookupField.prototype.infinite = false;
8810
11577
  LookupField.prototype.quickSelectAll = false;
8811
11578
  LookupField.prototype.onGetRecordDisplayText = null;
8812
- Localization.registerPrototype("cx/widgets/LookupField", LookupField);
8813
- Widget.alias("lookupfield", LookupField);
11579
+ Localization$1.registerPrototype("cx/widgets/LookupField", LookupField);
11580
+ Widget$1.alias("lookupfield", LookupField);
8814
11581
  function getOptionKey(bindings, data) {
8815
11582
  return bindings.filter((a) => a.key).map((b) => Binding.get(b.remote).value(data));
8816
11583
  }
@@ -8842,7 +11609,7 @@ class SelectionDelegate extends Selection {
8842
11609
  return false;
8843
11610
  }
8844
11611
  }
8845
- class LookupComponent extends VDOM.Component {
11612
+ class LookupComponent extends VDOM$2.Component {
8846
11613
  dom = {};
8847
11614
  itemStore;
8848
11615
  dropdown;
@@ -8891,7 +11658,7 @@ class LookupComponent extends VDOM.Component {
8891
11658
  if (this.dropdown) return this.dropdown;
8892
11659
  let { widget } = this.props.instance;
8893
11660
  let { lastDropdown } = this.props.instance;
8894
- this.list = Widget.create({
11661
+ this.list = Widget$1.create({
8895
11662
  type: List,
8896
11663
  sortField: widget.sort && widget.optionTextField,
8897
11664
  sortDirection: "ASC",
@@ -8948,7 +11715,7 @@ class LookupComponent extends VDOM.Component {
8948
11715
  return false;
8949
11716
  },
8950
11717
  };
8951
- return (this.dropdown = Widget.create(dropdown));
11718
+ return (this.dropdown = Widget$1.create(dropdown));
8952
11719
  }
8953
11720
  renderDropdownContents() {
8954
11721
  let content;
@@ -9005,7 +11772,7 @@ class LookupComponent extends VDOM.Component {
9005
11772
  this.subscribeListOnScroll(el);
9006
11773
  },
9007
11774
  className: CSS.element(baseClass, "scroll-container"),
9008
- children: jsx(Cx, {
11775
+ children: jsx(Cx$1, {
9009
11776
  widget: this.list,
9010
11777
  store: this.itemStore,
9011
11778
  options: {
@@ -9110,7 +11877,7 @@ class LookupComponent extends VDOM.Component {
9110
11877
  $options: this.state.options,
9111
11878
  $query: this.lastQuery,
9112
11879
  });
9113
- dropdown = jsx(Cx, {
11880
+ dropdown = jsx(Cx$1, {
9114
11881
  widget: this.getDropdown(),
9115
11882
  store: this.itemStore,
9116
11883
  options: {
@@ -9722,7 +12489,7 @@ class NumberField extends Field {
9722
12489
  let result = instance.invoke("onParseInput", value, instance);
9723
12490
  if (result !== undefined) return result;
9724
12491
  }
9725
- return Culture.getNumberCulture().parse(value);
12492
+ return Culture$1.getNumberCulture().parse(value);
9726
12493
  }
9727
12494
  validate(context, instance) {
9728
12495
  super.validate(context, instance);
@@ -9748,8 +12515,8 @@ class NumberField extends Field {
9748
12515
  {
9749
12516
  data: instance.data,
9750
12517
  instance: instance,
9751
- label: this.labelPlacement && getContent(this.renderLabel(context, instance, "label")),
9752
- help: this.helpPlacement && getContent(this.renderHelp(context, instance, "help")),
12518
+ label: this.labelPlacement && getContent$1(this.renderLabel(context, instance, "label")),
12519
+ help: this.helpPlacement && getContent$1(this.renderHelp(context, instance, "help")),
9753
12520
  icon: this.renderIcon(context, instance, "icon"),
9754
12521
  },
9755
12522
  key,
@@ -9776,9 +12543,9 @@ NumberField.prototype.snapToIncrement = true;
9776
12543
  NumberField.prototype.icon = null;
9777
12544
  NumberField.prototype.showClear = false;
9778
12545
  NumberField.prototype.alwaysShowClear = false;
9779
- Widget.alias("numberfield", NumberField);
9780
- Localization.registerPrototype("cx/widgets/NumberField", NumberField);
9781
- let Input$1 = class Input extends VDOM.Component {
12546
+ Widget$1.alias("numberfield", NumberField);
12547
+ Localization$1.registerPrototype("cx/widgets/NumberField", NumberField);
12548
+ let Input$1 = class Input extends VDOM$2.Component {
9782
12549
  input;
9783
12550
  unsubscribeOnWheel;
9784
12551
  constructor(props) {
@@ -10116,8 +12883,8 @@ class TextArea extends TextField {
10116
12883
  {
10117
12884
  data: instance.data,
10118
12885
  instance: instance,
10119
- label: this.labelPlacement && getContent(this.renderLabel(context, instance, "label")),
10120
- help: this.helpPlacement && getContent(this.renderHelp(context, instance, "help")),
12886
+ label: this.labelPlacement && getContent$1(this.renderLabel(context, instance, "label")),
12887
+ help: this.helpPlacement && getContent$1(this.renderHelp(context, instance, "help")),
10121
12888
  },
10122
12889
  key,
10123
12890
  );
@@ -10129,7 +12896,7 @@ class TextArea extends TextField {
10129
12896
  TextArea.prototype.baseClass = "textarea";
10130
12897
  TextArea.prototype.reactOn = "blur";
10131
12898
  TextArea.prototype.suppressErrorsUntilVisited = true;
10132
- class Input extends VDOM.Component {
12899
+ class Input extends VDOM$2.Component {
10133
12900
  input;
10134
12901
  constructor(props) {
10135
12902
  super(props);
@@ -10255,9 +13022,9 @@ class Input extends VDOM.Component {
10255
13022
  this.onChange(e.target.value, "blur");
10256
13023
  }
10257
13024
  }
10258
- Widget.alias("textarea", TextArea);
13025
+ Widget$1.alias("textarea", TextArea);
10259
13026
 
10260
- class ValidationGroup extends PureContainerBase {
13027
+ class ValidationGroup extends PureContainerBase$1 {
10261
13028
  declareData(...args) {
10262
13029
  super.declareData(...args, {
10263
13030
  errors: undefined,
@@ -10308,10 +13075,10 @@ class ValidationGroup extends PureContainerBase {
10308
13075
  }
10309
13076
  }
10310
13077
  ValidationGroup.prototype.isolated = false;
10311
- Widget.alias("validation-group", ValidationGroup);
13078
+ Widget$1.alias("validation-group", ValidationGroup);
10312
13079
 
10313
13080
  class FieldGroup extends ValidationGroup {}
10314
- Widget.alias("field-group", FieldGroup);
13081
+ Widget$1.alias("field-group", FieldGroup);
10315
13082
 
10316
13083
  class LabeledContainer extends FieldGroup {
10317
13084
  declareData(...args) {
@@ -10331,7 +13098,7 @@ class LabeledContainer extends FieldGroup {
10331
13098
  if (this.label.isComponentType) labelConfig = this.label;
10332
13099
  else if (isSelector(this.label)) labelConfig.text = this.label;
10333
13100
  else Object.assign(labelConfig, this.label);
10334
- this.label = Widget.create(labelConfig);
13101
+ this.label = Widget$1.create(labelConfig);
10335
13102
  }
10336
13103
  super.init();
10337
13104
  }
@@ -10352,7 +13119,7 @@ class LabeledContainer extends FieldGroup {
10352
13119
  }
10353
13120
  }
10354
13121
  LabeledContainer.prototype.styled = true;
10355
- Widget.alias("labeled-container", LabeledContainer);
13122
+ Widget$1.alias("labeled-container", LabeledContainer);
10356
13123
 
10357
13124
  enableCultureSensitiveFormatting();
10358
13125
  class MonthPickerInstance extends FieldInstance {
@@ -10452,7 +13219,7 @@ class MonthPicker extends Field {
10452
13219
  }
10453
13220
  handleSelect(e, instance, date1, date2) {
10454
13221
  let { data, widget, isMonthDateSelectable } = instance;
10455
- let encode = widget.encoding || Culture.getDefaultDateEncoding();
13222
+ let encode = widget.encoding || Culture$1.getDefaultDateEncoding();
10456
13223
  if (data.disabled) return;
10457
13224
  if (isMonthDateSelectable && !isMonthDateSelectable(date1)) return;
10458
13225
  if (!dateSelectableCheck(date1, data)) return;
@@ -10478,8 +13245,8 @@ MonthPicker.prototype.maxExclusiveErrorText = "Select a date before {0:d}.";
10478
13245
  MonthPicker.prototype.minValueErrorText = "Select {0:d} or later.";
10479
13246
  MonthPicker.prototype.minExclusiveErrorText = "Select a date after {0:d}.";
10480
13247
  MonthPicker.prototype.inclusiveTo = false;
10481
- Localization.registerPrototype("cx/widgets/MonthPicker", MonthPicker);
10482
- Widget.alias("month-picker", MonthPicker);
13248
+ Localization$1.registerPrototype("cx/widgets/MonthPicker", MonthPicker);
13249
+ Widget$1.alias("month-picker", MonthPicker);
10483
13250
  const dateSelectableCheck = (date, data) => {
10484
13251
  if (data.maxValue && !upperBoundCheck(date, data.maxValue, data.maxExclusive)) return false;
10485
13252
  if (data.minValue && !lowerBoundCheck(date, data.minValue, data.minExclusive)) return false;
@@ -10488,7 +13255,7 @@ const dateSelectableCheck = (date, data) => {
10488
13255
  const monthNumber = (date) => {
10489
13256
  return date.getFullYear() * 12 + date.getMonth();
10490
13257
  };
10491
- class MonthPickerComponent extends VDOM.Component {
13258
+ class MonthPickerComponent extends VDOM$2.Component {
10492
13259
  dom = {};
10493
13260
  dragStartDates;
10494
13261
  constructor(props) {
@@ -10914,7 +13681,7 @@ class MonthPickerComponent extends VDOM.Component {
10914
13681
  to = Math.max(a, b);
10915
13682
  }
10916
13683
  }
10917
- let monthNames = Culture.getDateTimeCulture().getMonthNames("short");
13684
+ let monthNames = Culture$1.getDateTimeCulture().getMonthNames("short");
10918
13685
  let showCursor = this.state.focused;
10919
13686
  for (let y = start; y <= end; y++) {
10920
13687
  let selectableMonths = 0b111111111111;
@@ -11203,8 +13970,8 @@ class ColorPicker extends Field {
11203
13970
  ColorPicker.prototype.baseClass = "colorpicker";
11204
13971
  ColorPicker.prototype.reportOn = "blur change";
11205
13972
  ColorPicker.prototype.format = "rgba";
11206
- Widget.alias("color-picker", ColorPicker);
11207
- class ColorPickerComponent extends VDOM.Component {
13973
+ Widget$1.alias("color-picker", ColorPicker);
13974
+ class ColorPickerComponent extends VDOM$2.Component {
11208
13975
  data;
11209
13976
  constructor(props) {
11210
13977
  super(props);
@@ -11696,7 +14463,7 @@ class MonthField extends Field {
11696
14463
  return this.range ? data.from == null : data.value == null;
11697
14464
  }
11698
14465
  init() {
11699
- if (!this.culture) this.culture = Culture.getDateTimeCulture();
14466
+ if (!this.culture) this.culture = Culture$1.getDateTimeCulture();
11700
14467
  if (isDefined(this.hideClear)) this.showClear = !this.hideClear;
11701
14468
  if (this.alwaysShowClear) this.showClear = true;
11702
14469
  super.init();
@@ -11772,8 +14539,8 @@ class MonthField extends Field {
11772
14539
  minValueErrorText: this.minValueErrorText,
11773
14540
  minExclusiveErrorText: this.minExclusiveErrorText,
11774
14541
  },
11775
- label: this.labelPlacement && getContent(this.renderLabel(context, instance, "label")),
11776
- help: this.helpPlacement && getContent(this.renderHelp(context, instance, "help")),
14542
+ label: this.labelPlacement && getContent$1(this.renderLabel(context, instance, "label")),
14543
+ help: this.helpPlacement && getContent$1(this.renderHelp(context, instance, "help")),
11777
14544
  icon: this.renderIcon(context, instance, "icon"),
11778
14545
  },
11779
14546
  key,
@@ -11792,7 +14559,7 @@ class MonthField extends Field {
11792
14559
  }
11793
14560
  handleSelect(instance, date1, date2) {
11794
14561
  let { widget } = instance;
11795
- let encode = widget.encoding ?? Culture.getDefaultDateEncoding();
14562
+ let encode = widget.encoding ?? Culture$1.getDefaultDateEncoding();
11796
14563
  instance.setState({
11797
14564
  inputError: false,
11798
14565
  });
@@ -11825,9 +14592,9 @@ MonthField.prototype.alwaysShowClear = false;
11825
14592
  MonthField.prototype.range = false;
11826
14593
  MonthField.prototype.reactOn = "enter blur";
11827
14594
  MonthField.prototype.inclusiveTo = false;
11828
- Localization.registerPrototype("cx/widgets/MonthField", MonthField);
11829
- Widget.alias("monthfield", MonthField);
11830
- class MonthInput extends VDOM.Component {
14595
+ Localization$1.registerPrototype("cx/widgets/MonthField", MonthField);
14596
+ Widget$1.alias("monthfield", MonthField);
14597
+ class MonthInput extends VDOM$2.Component {
11831
14598
  input;
11832
14599
  dropdown;
11833
14600
  openDropdownOnFocus = false;
@@ -11872,7 +14639,7 @@ class MonthInput extends VDOM.Component {
11872
14639
  constrain: true,
11873
14640
  firstChildDefinesWidth: true,
11874
14641
  };
11875
- return (this.dropdown = Widget.create(dropdown));
14642
+ return (this.dropdown = Widget$1.create(dropdown));
11876
14643
  }
11877
14644
  render() {
11878
14645
  const { instance, label, help, data, icon: iconVDOM } = this.props;
@@ -11913,7 +14680,7 @@ class MonthInput extends VDOM.Component {
11913
14680
  }
11914
14681
  var dropdown = false;
11915
14682
  if (this.state.dropdownOpen)
11916
- dropdown = jsx(Cx, {
14683
+ dropdown = jsx(Cx$1, {
11917
14684
  widget: this.getDropdown(),
11918
14685
  parentInstance: instance,
11919
14686
  options: {
@@ -12158,8 +14925,8 @@ class ColorField extends Field {
12158
14925
  value: this.value,
12159
14926
  format: this.format,
12160
14927
  },
12161
- label: this.labelPlacement && getContent(this.renderLabel(context, instance, "label")),
12162
- help: this.helpPlacement && getContent(this.renderHelp(context, instance, "help")),
14928
+ label: this.labelPlacement && getContent$1(this.renderLabel(context, instance, "label")),
14929
+ help: this.helpPlacement && getContent$1(this.renderHelp(context, instance, "help")),
12163
14930
  },
12164
14931
  key,
12165
14932
  );
@@ -12170,9 +14937,9 @@ ColorField.prototype.format = "rgba";
12170
14937
  ColorField.prototype.suppressErrorsUntilVisited = true;
12171
14938
  ColorField.prototype.showClear = true;
12172
14939
  ColorField.prototype.alwaysShowClear = false;
12173
- Widget.alias("color-field", ColorField);
12174
- Localization.registerPrototype("cx/widgets/ColorField", ColorField);
12175
- class ColorInput extends VDOM.Component {
14940
+ Widget$1.alias("color-field", ColorField);
14941
+ Localization$1.registerPrototype("cx/widgets/ColorField", ColorField);
14942
+ class ColorInput extends VDOM$2.Component {
12176
14943
  data;
12177
14944
  dropdown;
12178
14945
  input;
@@ -12226,7 +14993,7 @@ class ColorInput extends VDOM.Component {
12226
14993
  firstChildDefinesHeight: true,
12227
14994
  firstChildDefinesWidth: true,
12228
14995
  };
12229
- return (this.dropdown = Widget.create(dropdown));
14996
+ return (this.dropdown = Widget$1.create(dropdown));
12230
14997
  }
12231
14998
  render() {
12232
14999
  let { instance, label, help, data } = this.props;
@@ -12266,7 +15033,7 @@ class ColorInput extends VDOM.Component {
12266
15033
  });
12267
15034
  let dropdown = false;
12268
15035
  if (this.state.dropdownOpen)
12269
- dropdown = jsx(Cx, {
15036
+ dropdown = jsx(Cx$1, {
12270
15037
  widget: this.getDropdown(),
12271
15038
  parentInstance: instance,
12272
15039
  options: {
@@ -12508,8 +15275,8 @@ UploadButton.prototype.multiple = false;
12508
15275
  UploadButton.prototype.method = "POST";
12509
15276
  UploadButton.prototype.abortOnDestroy = false;
12510
15277
  UploadButton.prototype.uploadInProgressText = "Upload is in progress.";
12511
- Localization.registerPrototype("cx/widgets/UploadButton", UploadButton);
12512
- class UploadButtonComponent extends VDOM.Component {
15278
+ Localization$1.registerPrototype("cx/widgets/UploadButton", UploadButton);
15279
+ class UploadButtonComponent extends VDOM$2.Component {
12513
15280
  uploads;
12514
15281
  el;
12515
15282
  constructor(props) {
@@ -12664,7 +15431,7 @@ class UploadButtonComponent extends VDOM.Component {
12664
15431
  });
12665
15432
  }
12666
15433
  }
12667
- Widget.alias("upload-button", UploadButton);
15434
+ Widget$1.alias("upload-button", UploadButton);
12668
15435
 
12669
15436
  class Slider extends Field {
12670
15437
  declareData(...args) {
@@ -12719,7 +15486,7 @@ class Slider extends Field {
12719
15486
  {
12720
15487
  instance: instance,
12721
15488
  data: instance.data,
12722
- label: this.labelPlacement && getContent(this.renderLabel(context, instance, "label")),
15489
+ label: this.labelPlacement && getContent$1(this.renderLabel(context, instance, "label")),
12723
15490
  },
12724
15491
  key,
12725
15492
  );
@@ -12732,8 +15499,8 @@ Slider.prototype.vertical = false;
12732
15499
  Slider.prototype.incrementPercentage = 0.01;
12733
15500
  Slider.prototype.wheel = false;
12734
15501
  Slider.prototype.invert = false;
12735
- Widget.alias("slider", Slider);
12736
- class SliderComponent extends VDOM.Component {
15502
+ Widget$1.alias("slider", Slider);
15503
+ class SliderComponent extends VDOM$2.Component {
12737
15504
  dom;
12738
15505
  unsubscribeOnWheel;
12739
15506
  constructor(props) {
@@ -13123,7 +15890,7 @@ class Switch extends Field {
13123
15890
  }
13124
15891
  },
13125
15892
  children: [
13126
- this.labelPlacement && getContent(this.renderLabel(context, instance, "label")),
15893
+ this.labelPlacement && getContent$1(this.renderLabel(context, instance, "label")),
13127
15894
  "\u00A0",
13128
15895
  jsxs("div", {
13129
15896
  className: CSS.element(baseClass, "axis"),
@@ -13166,9 +15933,9 @@ class Switch extends Field {
13166
15933
  }
13167
15934
  Switch.prototype.baseClass = "switch";
13168
15935
  Switch.prototype.focusOnMouseDown = false;
13169
- Widget.alias("switch", Switch);
15936
+ Widget$1.alias("switch", Switch);
13170
15937
 
13171
- class Wheel extends PureContainerBase {
15938
+ class Wheel extends PureContainerBase$1 {
13172
15939
  declareData(...args) {
13173
15940
  return super.declareData(...args, {
13174
15941
  value: undefined,
@@ -13214,7 +15981,7 @@ Wheel.prototype.styled = true;
13214
15981
  /** A cyclic wheel renders its option list this many times, leaving scroll
13215
15982
  * headroom on both sides of the centre copy. */
13216
15983
  const WHEEL_BUFFER_COPIES = 3;
13217
- class WheelComponent extends VDOM.Component {
15984
+ class WheelComponent extends VDOM$2.Component {
13218
15985
  index;
13219
15986
  wheelEl;
13220
15987
  scrollEl;
@@ -13452,7 +16219,7 @@ class WheelComponent extends VDOM.Component {
13452
16219
  }
13453
16220
 
13454
16221
  enableCultureSensitiveFormatting();
13455
- class DateTimePicker extends Widget {
16222
+ class DateTimePicker extends Widget$1 {
13456
16223
  declareData(...args) {
13457
16224
  return super.declareData(...args, {
13458
16225
  value: undefined,
@@ -13495,7 +16262,7 @@ function buildNumberWheel(range, startAt) {
13495
16262
  ),
13496
16263
  );
13497
16264
  }
13498
- class DateTimePickerComponent extends VDOM.Component {
16265
+ class DateTimePickerComponent extends VDOM$2.Component {
13499
16266
  el;
13500
16267
  keyDownPipes;
13501
16268
  constructor(props) {
@@ -13559,7 +16326,7 @@ class DateTimePickerComponent extends VDOM.Component {
13559
16326
  handleChange() {
13560
16327
  let { widget } = this.props.instance;
13561
16328
  let pickerWidget = widget;
13562
- let encode = pickerWidget.encoding || Culture.getDefaultDateEncoding();
16329
+ let encode = pickerWidget.encoding || Culture$1.getDefaultDateEncoding();
13563
16330
  this.props.instance.set("value", encode(this.state.date));
13564
16331
  }
13565
16332
  render() {
@@ -13567,7 +16334,7 @@ class DateTimePickerComponent extends VDOM.Component {
13567
16334
  let { widget } = instance;
13568
16335
  let { CSS, baseClass } = widget;
13569
16336
  let date = this.state.date;
13570
- let culture = Culture.getDateTimeCulture();
16337
+ let culture = Culture$1.getDateTimeCulture();
13571
16338
  let monthNames = culture.getMonthNames("short");
13572
16339
  // Years: a window spanning the current century, rebuilt when it changes.
13573
16340
  let currentCentury = (date.getFullYear() / 100) | 0;
@@ -13906,7 +16673,7 @@ class DateTimePickerComponent extends VDOM.Component {
13906
16673
 
13907
16674
  const TimeList = createFunctionalComponent(({ value, step, format, encoding, onSelect, ...props }) =>
13908
16675
  jsx$1("cx", {
13909
- children: jsx$1(ContentResolver, {
16676
+ children: jsx$1(ContentResolver$1, {
13910
16677
  params: {
13911
16678
  step,
13912
16679
  format,
@@ -13927,12 +16694,12 @@ const TimeList = createFunctionalComponent(({ value, step, format, encoding, onS
13927
16694
  }
13928
16695
  let stepMs = step * 60 * 1000;
13929
16696
  return jsx$1("cx", {
13930
- children: jsx$1(DataProxy, {
16697
+ children: jsx$1(DataProxy$1, {
13931
16698
  data: {
13932
16699
  $value: value,
13933
16700
  },
13934
16701
  immutable: true,
13935
- children: jsx$1(DataProxy, {
16702
+ children: jsx$1(DataProxy$1, {
13936
16703
  data: {
13937
16704
  $selection: {
13938
16705
  get: ({ $value }) => {
@@ -13951,7 +16718,7 @@ const TimeList = createFunctionalComponent(({ value, step, format, encoding, onS
13951
16718
  copy.setMinutes(date.getMinutes());
13952
16719
  copy.setSeconds(date.getSeconds());
13953
16720
  copy.setMilliseconds(0);
13954
- let encode = encoding || Culture.getDefaultDateEncoding();
16721
+ let encode = encoding || Culture$1.getDefaultDateEncoding();
13955
16722
  store.set("$value", encode(copy));
13956
16723
  },
13957
16724
  },
@@ -14092,9 +16859,9 @@ class DateTimeField extends Field {
14092
16859
  minValueErrorText: this.minValueErrorText,
14093
16860
  minExclusiveErrorText: this.minExclusiveErrorText,
14094
16861
  },
14095
- label: this.labelPlacement && getContent(this.renderLabel(context, instance, "label")),
14096
- help: this.helpPlacement && getContent(this.renderHelp(context, instance, "help")),
14097
- icon: getContent(this.renderIcon(context, instance, "icon")),
16862
+ label: this.labelPlacement && getContent$1(this.renderLabel(context, instance, "label")),
16863
+ help: this.helpPlacement && getContent$1(this.renderHelp(context, instance, "help")),
16864
+ icon: getContent$1(this.renderIcon(context, instance, "icon")),
14098
16865
  },
14099
16866
  key,
14100
16867
  );
@@ -14109,7 +16876,7 @@ class DateTimeField extends Field {
14109
16876
  let result = instance.invoke("onParseInput", date, instance);
14110
16877
  if (result !== undefined) return result;
14111
16878
  }
14112
- date = Culture.getDateTimeCulture().parse(date, {
16879
+ date = Culture$1.getDateTimeCulture().parse(date, {
14113
16880
  useCurrentDateForDefaults: true,
14114
16881
  });
14115
16882
  return date;
@@ -14131,9 +16898,9 @@ DateTimeField.prototype.segment = "datetime";
14131
16898
  DateTimeField.prototype.picker = "auto";
14132
16899
  DateTimeField.prototype.disabledDaysOfWeek = null;
14133
16900
  DateTimeField.prototype.focusInputFirst = false;
14134
- Widget.alias("datetimefield", DateTimeField);
14135
- Localization.registerPrototype("cx/widgets/DateTimeField", DateTimeField);
14136
- class DateTimeInput extends VDOM.Component {
16901
+ Widget$1.alias("datetimefield", DateTimeField);
16902
+ Localization$1.registerPrototype("cx/widgets/DateTimeField", DateTimeField);
16903
+ class DateTimeInput extends VDOM$2.Component {
14137
16904
  input;
14138
16905
  dropdown;
14139
16906
  scrollableParents;
@@ -14223,7 +16990,7 @@ class DateTimeInput extends VDOM.Component {
14223
16990
  },
14224
16991
  },
14225
16992
  };
14226
- return (this.dropdown = Widget.create(dropdown));
16993
+ return (this.dropdown = Widget$1.create(dropdown));
14227
16994
  }
14228
16995
  render() {
14229
16996
  let { instance, label, help, icon: iconVDOM } = this.props;
@@ -14259,7 +17026,7 @@ class DateTimeInput extends VDOM.Component {
14259
17026
  }
14260
17027
  let dropdown;
14261
17028
  if (this.state.dropdownOpen)
14262
- dropdown = jsx(Cx, {
17029
+ dropdown = jsx(Cx$1, {
14263
17030
  widget: this.getDropdown(),
14264
17031
  parentInstance: instance,
14265
17032
  options: {
@@ -14480,7 +17247,7 @@ class DateTimeInput extends VDOM.Component {
14480
17247
  }
14481
17248
  date = mixed;
14482
17249
  }
14483
- let encode = dateTimeWidget.encoding || Culture.getDefaultDateEncoding();
17250
+ let encode = dateTimeWidget.encoding || Culture$1.getDefaultDateEncoding();
14484
17251
  let value = date ? encode(date) : dateTimeWidget.emptyValue;
14485
17252
  if (!instance.set("value", value)) this.input.value = value ? Format$1.value(date, data.format) : "";
14486
17253
  }
@@ -14494,13 +17261,13 @@ class DateField extends DateTimeField {
14494
17261
  }
14495
17262
  DateField.prototype.picker = "calendar";
14496
17263
  DateField.prototype.segment = "date";
14497
- Widget.alias("datefield", DateField);
14498
- Localization.registerPrototype("cx/widgets/DateField", DateField);
17264
+ Widget$1.alias("datefield", DateField);
17265
+ Localization$1.registerPrototype("cx/widgets/DateField", DateField);
14499
17266
 
14500
17267
  class TimeField extends DateTimeField {}
14501
17268
  TimeField.prototype.segment = "time";
14502
- Widget.alias("timefield", TimeField);
14503
- Localization.registerPrototype("cx/widgets/TimeField", TimeField);
17269
+ Widget$1.alias("timefield", TimeField);
17270
+ Localization$1.registerPrototype("cx/widgets/TimeField", TimeField);
14504
17271
 
14505
17272
  class Validator extends Field {
14506
17273
  constructor(config) {
@@ -14542,7 +17309,7 @@ var DropDownIcon = registerIcon(
14542
17309
  true,
14543
17310
  );
14544
17311
 
14545
- class GridCellEditor extends ContainerBase {
17312
+ class GridCellEditor extends ContainerBase$1 {
14546
17313
  constructor(config) {
14547
17314
  super(config);
14548
17315
  }
@@ -14560,7 +17327,7 @@ class GridCellEditor extends ContainerBase {
14560
17327
  }
14561
17328
  }
14562
17329
  GridCellEditor.prototype.styled = true;
14563
- class GridCellEditorCmp extends VDOM.Component {
17330
+ class GridCellEditorCmp extends VDOM$2.Component {
14564
17331
  el = null;
14565
17332
  render() {
14566
17333
  let { className, style, children } = this.props;
@@ -14592,7 +17359,7 @@ function createGridCellEditor(className, style, valid, columnEditor) {
14592
17359
  });
14593
17360
  }
14594
17361
 
14595
- class GridCell extends StyledContainerBase {
17362
+ class GridCell extends StyledContainerBase$1 {
14596
17363
  constructor(config) {
14597
17364
  super(config);
14598
17365
  }
@@ -14654,12 +17421,12 @@ GridCell.prototype.pad = true;
14654
17421
  GridCell.prototype.fixed = false;
14655
17422
  GridCell.prototype.merged = false;
14656
17423
 
14657
- class GridRowLine extends Container {
17424
+ class GridRowLine extends Container$1 {
14658
17425
  constructor(config) {
14659
17426
  super(config);
14660
17427
  }
14661
17428
  init() {
14662
- this.items = Widget.create(GridCell, this.columns || [], {
17429
+ this.items = Widget$1.create(GridCell, this.columns || [], {
14663
17430
  recordName: this.recordName,
14664
17431
  });
14665
17432
  super.init();
@@ -14705,7 +17472,7 @@ class GridRow extends ValidationGroup {
14705
17472
  }
14706
17473
  }
14707
17474
  GridRow.prototype.styled = true; //styles used on the wrapper component
14708
- class GridRowComponent extends VDOM.Component {
17475
+ class GridRowComponent extends VDOM$2.Component {
14709
17476
  onDoubleClick;
14710
17477
  onRowContextMenu;
14711
17478
  unsubscribeHoverSync;
@@ -14746,7 +17513,7 @@ class GridRowComponent extends VDOM.Component {
14746
17513
  leave = this.onMouseLeave;
14747
17514
  }
14748
17515
  if (this.props.grid.widget.onRowClick) keyDown = this.onKeyDown;
14749
- return VDOM.createElement(
17516
+ return VDOM$2.createElement(
14750
17517
  useTrTag ? "tr" : "tbody",
14751
17518
  {
14752
17519
  className: CSS.expand(data.classNames, className, this.state && this.state.hover && CSS.state("hover")),
@@ -14867,14 +17634,14 @@ class GridRowComponent extends VDOM.Component {
14867
17634
  }
14868
17635
  }
14869
17636
 
14870
- class GridInstance extends Instance {
17637
+ class GridInstance extends Instance$1 {
14871
17638
  resetColumnWidths() {
14872
17639
  this.setState({
14873
17640
  colWidth: {},
14874
17641
  });
14875
17642
  }
14876
17643
  }
14877
- class Grid extends ContainerBase {
17644
+ class Grid extends ContainerBase$1 {
14878
17645
  constructor(config) {
14879
17646
  super(config);
14880
17647
  }
@@ -14989,7 +17756,7 @@ class Grid extends ContainerBase {
14989
17756
  lines.push(l);
14990
17757
  }
14991
17758
  }
14992
- row.header = PureContainer.create({
17759
+ row.header = PureContainer$1.create({
14993
17760
  items: GridColumnHeaderLine.create(lines),
14994
17761
  });
14995
17762
  row.header.items.forEach((line) => {
@@ -15057,7 +17824,7 @@ class Grid extends ContainerBase {
15057
17824
  );
15058
17825
  }
15059
17826
  instance.dataAdapter =
15060
- this.dataAdapter instanceof ArrayAdapter
17827
+ this.dataAdapter instanceof ArrayAdapter$1
15061
17828
  ? this.dataAdapter
15062
17829
  : GroupAdapter.create(
15063
17830
  {
@@ -15074,7 +17841,7 @@ class Grid extends ContainerBase {
15074
17841
  this.dataAdapter,
15075
17842
  );
15076
17843
  instance.dataAdapter.initInstance(context, instance);
15077
- return Widget.create(GridRow, {
17844
+ return Widget$1.create(GridRow, {
15078
17845
  class: this.CSS.element(this.baseClass, "data"),
15079
17846
  className: this.rowClass,
15080
17847
  style: this.rowStyle,
@@ -15109,10 +17876,13 @@ class Grid extends ContainerBase {
15109
17876
  if (!isArray(data.records)) data.records = [];
15110
17877
  if (state.sorters && !isDefined(this.sorters)) data.sorters = state.sorters;
15111
17878
  let sortField = null;
15112
- if (isDefined(this.sortField) && isDefined(this.sortDirection)) {
17879
+ // rebuild sorters from the sortField/sortDirection bindings only if a sort field
17880
+ // is actually set; sorts identified by a value selector (columns without a field)
17881
+ // live in data.sorters/state.sorters and cannot round-trip through a field name
17882
+ if (isDefined(this.sortField) && isDefined(this.sortDirection) && data.sortField) {
15113
17883
  let sorter = {
15114
17884
  field: data.sortField,
15115
- direction: data.sortDirection,
17885
+ direction: data.sortDirection || "ASC",
15116
17886
  };
15117
17887
  sortField = data.sortField;
15118
17888
  data.sorters = [sorter];
@@ -15127,11 +17897,11 @@ class Grid extends ContainerBase {
15127
17897
  data.sorters = [sorter];
15128
17898
  }
15129
17899
  if (sortField) {
15130
- for (let l = 1; l < 10; l++) {
17900
+ for (let l = 0; l < 10; l++) {
15131
17901
  let line = instance.row[`line${l}`];
15132
- let sortColumn = line && line.columns && line.columns.find((c) => c.field == sortField);
17902
+ let sortColumn = line && line.columns && line.columns.find((c) => (c.sortField || c.field) == sortField);
15133
17903
  if (sortColumn) {
15134
- data.sorters[0].value = sortColumn.sortValue || sortColumn.value;
17904
+ data.sorters[0].value = isDefined(sortColumn.sortValue) ? sortColumn.sortValue : sortColumn.value;
15135
17905
  data.sorters[0].comparer = sortColumn.comparer;
15136
17906
  data.sorters[0].sortOptions = sortColumn.sortOptions;
15137
17907
  break;
@@ -15437,8 +18207,18 @@ class Grid extends ContainerBase {
15437
18207
  else if (hdwidget.align) mods.push("aligned-" + hdwidget.align);
15438
18208
  if (hdwidget.sortable && header.widget.allowSorting) {
15439
18209
  mods.push("sortable");
15440
- if (data.sorters && data.sorters[0].field == (hdwidget.sortField || hdwidget.field)) {
15441
- mods.push("sorted-" + data.sorters[0].direction.toLowerCase());
18210
+ let sorter = data.sorters && data.sorters[0];
18211
+ let sortColumnField = hdwidget.sortField || hdwidget.field;
18212
+ let sortColumnValue = isDefined(hdwidget.sortValue) ? hdwidget.sortValue : hdwidget.value;
18213
+ // a sort is identified by its (field, value selector) pair, so columns
18214
+ // sorting by the same field through different value selectors don't both match
18215
+ let sorted =
18216
+ sorter &&
18217
+ !!sorter.direction &&
18218
+ (sortColumnField ? sorter.field == sortColumnField : !sorter.field && isDefined(sortColumnValue)) &&
18219
+ sorter.value === sortColumnValue;
18220
+ if (sorted) {
18221
+ mods.push("sorted-" + sorter.direction.toLowerCase());
15442
18222
  sortIcon = jsx(DropDownIcon, {
15443
18223
  className: CSS.element(baseClass, "column-sort-icon"),
15444
18224
  });
@@ -15467,7 +18247,7 @@ class Grid extends ContainerBase {
15467
18247
  if (header.components && header.components.tool) {
15468
18248
  tool = jsx("div", {
15469
18249
  className: CSS.element(baseClass, "col-header-tool"),
15470
- children: getContent(header.components.tool.render(context)),
18250
+ children: getContent$1(header.components.tool.render(context)),
15471
18251
  });
15472
18252
  mods.push("tool");
15473
18253
  }
@@ -15510,7 +18290,7 @@ class Grid extends ContainerBase {
15510
18290
  onClick: (e) => this.onHeaderClick(e, hdwidget, instance, l),
15511
18291
  onContextMenu: onContextMenu,
15512
18292
  "data-unique-col-id": colSpan > 1 ? null : hdwidget.uniqueColumnId,
15513
- children: [getContent(content), sortIcon, tool, prevColumnResizer, resizer],
18293
+ children: [getContent$1(content), sortIcon, tool, prevColumnResizer, resizer],
15514
18294
  },
15515
18295
  colIndex,
15516
18296
  ),
@@ -15606,16 +18386,15 @@ class Grid extends ContainerBase {
15606
18386
  let { data } = instance;
15607
18387
  let header = column.components[`header${headerLine + 1}`];
15608
18388
  let field = column.sortField || column.field;
15609
- let value = column.sortValue || column.value;
18389
+ let value = isDefined(column.sortValue) ? column.sortValue : column.value;
15610
18390
  let comparer = column.comparer;
15611
18391
  let sortOptions = column.sortOptions;
15612
- if (header && header.allowSorting && column.sortable && (field || value || data.sortField)) {
18392
+ if (header && header.allowSorting && column.sortable && (field || isDefined(value))) {
15613
18393
  let direction = column.primarySortDirection ?? "ASC";
15614
- if (
15615
- isNonEmptyArray(data.sorters) &&
15616
- ((!!data.sorters[0].field && data.sorters[0].field == (field || data.sortField)) ||
15617
- (!!value && data.sorters[0].value == value))
15618
- ) {
18394
+ // the column matches the active sorter only if both the field and the value
18395
+ // selector are the same; two columns may sort by the same field through
18396
+ // different value selectors and represent different sorts
18397
+ if (isNonEmptyArray(data.sorters) && data.sorters[0].field == field && data.sorters[0].value === value) {
15619
18398
  if (data.sorters[0].direction == "ASC" && (!this.clearableSort || direction == "ASC")) direction = "DESC";
15620
18399
  else if (data.sorters[0].direction == "DESC" && (!this.clearableSort || direction == "DESC")) direction = "ASC";
15621
18400
  else {
@@ -15682,7 +18461,7 @@ class Grid extends ContainerBase {
15682
18461
  style = null;
15683
18462
  if (c.caption) {
15684
18463
  if (c.caption.children)
15685
- v = jsx(Cx, {
18464
+ v = jsx(Cx$1, {
15686
18465
  widget: c.caption.children,
15687
18466
  store: store,
15688
18467
  parentInstance: instance,
@@ -16016,9 +18795,9 @@ Grid.prototype.focusable = null; // automatically resolved
16016
18795
  Grid.prototype.allowsFileDrops = false;
16017
18796
  Grid.prototype.preserveGroupOrder = false;
16018
18797
  Grid.prototype.sortGroups = false;
16019
- Widget.alias("grid", Grid);
16020
- Localization.registerPrototype("cx/widgets/Grid", Grid);
16021
- class GridComponent extends VDOM.Component {
18798
+ Widget$1.alias("grid", Grid);
18799
+ Localization$1.registerPrototype("cx/widgets/Grid", Grid);
18800
+ class GridComponent extends VDOM$2.Component {
16022
18801
  dom;
16023
18802
  syncBuffering = false;
16024
18803
  scrollerRef;
@@ -16088,7 +18867,7 @@ class GridComponent extends VDOM.Component {
16088
18867
  "td",
16089
18868
  {
16090
18869
  className: CSS.element(baseClass, "cell-editor"),
16091
- children: jsx(Cx, {
18870
+ children: jsx(Cx$1, {
16092
18871
  parentInstance: instance,
16093
18872
  subscribe: true,
16094
18873
  widget: editor,
@@ -16201,7 +18980,7 @@ class GridComponent extends VDOM.Component {
16201
18980
  };
16202
18981
  if (!standalone) return wrap(record.vdom);
16203
18982
  return jsx(
16204
- Cx,
18983
+ Cx$1,
16205
18984
  {
16206
18985
  instance: record.row,
16207
18986
  parentInstance: instance,
@@ -16248,11 +19027,11 @@ class GridComponent extends VDOM.Component {
16248
19027
  record.row.shouldUpdate = false;
16249
19028
  };
16250
19029
  if (widget.buffered) {
16251
- let context = new RenderingContext();
19030
+ let context = new RenderingContext$1();
16252
19031
  let dummyDataClass = CSS.element(baseClass, "data", {
16253
19032
  dummy: true,
16254
19033
  });
16255
- if (!instance.recordInstanceCache) instance.recordInstanceCache = new InstanceCache(instance);
19034
+ if (!instance.recordInstanceCache) instance.recordInstanceCache = new InstanceCache$1(instance);
16256
19035
  instance.recordInstanceCache.mark();
16257
19036
  this.getRecordsSlice(start, end).forEach((r, i) => {
16258
19037
  if (r == null) {
@@ -17305,7 +20084,7 @@ class GridComponent extends VDOM.Component {
17305
20084
  newState.cursor = index;
17306
20085
  newState.cellEdit = false;
17307
20086
  }
17308
- batchUpdates(() => {
20087
+ batchUpdates$1(() => {
17309
20088
  if (select) {
17310
20089
  let start =
17311
20090
  selectRange && this.state.selectionStart != null && this.state.selectionStart >= 0
@@ -17651,7 +20430,7 @@ class GridComponent extends VDOM.Component {
17651
20430
  if (selected.length == 0) add(record, record.data, record.index, true);
17652
20431
  let renderRow = this.createRowRenderer(false);
17653
20432
  let contents = selected.map((record, i) => ({
17654
- type: StaticText,
20433
+ type: StaticText$1,
17655
20434
  text: renderRow(record, i, true, false),
17656
20435
  }));
17657
20436
  initiateDragDrop(
@@ -17739,14 +20518,14 @@ class GridComponent extends VDOM.Component {
17739
20518
  }
17740
20519
  }
17741
20520
  }
17742
- class GridColumnHeaderLine extends PureContainerBase {
20521
+ class GridColumnHeaderLine extends PureContainerBase$1 {
17743
20522
  declareData() {
17744
20523
  return super.declareData(...arguments, {
17745
20524
  showHeader: undefined,
17746
20525
  });
17747
20526
  }
17748
20527
  init() {
17749
- this.items = Widget.create(GridColumnHeader, this.columns || []);
20528
+ this.items = Widget$1.create(GridColumnHeader, this.columns || []);
17750
20529
  this.visible = this.showHeader;
17751
20530
  this.style = this.headerStyle;
17752
20531
  this.className = this.headerClass;
@@ -17770,7 +20549,7 @@ GridColumnHeaderLine.prototype.isPureContainer = false;
17770
20549
  GridColumnHeaderLine.prototype.styled = true;
17771
20550
  GridColumnHeaderLine.prototype.showHeader = true;
17772
20551
  GridColumnHeaderLine.autoInit = true;
17773
- class GridColumnHeader extends Widget {
20552
+ class GridColumnHeader extends Widget$1 {
17774
20553
  declareData() {
17775
20554
  return super.declareData(...arguments, {
17776
20555
  format: undefined,
@@ -17827,7 +20606,7 @@ class GridColumnHeader extends Widget {
17827
20606
  let children = this.caption.children || this.caption.items;
17828
20607
  if (children) {
17829
20608
  delete this.caption.items;
17830
- this.caption.children = Widget.create(children);
20609
+ this.caption.children = Widget$1.create(children);
17831
20610
  } else {
17832
20611
  this.caption.value = getSelector(this.caption.value);
17833
20612
  this.caption.format = getSelector(this.caption.format);
@@ -17849,7 +20628,7 @@ class GridColumnHeader extends Widget {
17849
20628
  }
17850
20629
  }
17851
20630
  GridColumnHeader.autoInit = true;
17852
- class GridColumnHeaderCell extends PureContainerBase {
20631
+ class GridColumnHeaderCell extends PureContainerBase$1 {
17853
20632
  declareData() {
17854
20633
  return super.declareData(...arguments, {
17855
20634
  text: undefined,
@@ -17864,7 +20643,7 @@ class GridColumnHeaderCell extends PureContainerBase {
17864
20643
  }
17865
20644
  initComponents() {
17866
20645
  return super.initComponents(...arguments, {
17867
- tool: this.tool && Widget.create(this.tool),
20646
+ tool: this.tool && Widget$1.create(this.tool),
17868
20647
  });
17869
20648
  }
17870
20649
  render(context, instance, key) {
@@ -18007,7 +20786,7 @@ function getDragDropEvent(ev, store, type) {
18007
20786
  };
18008
20787
  }
18009
20788
 
18010
- class TreeNode extends ContainerBase {
20789
+ class TreeNode extends ContainerBase$1 {
18011
20790
  constructor(config) {
18012
20791
  super(config);
18013
20792
  }
@@ -18109,9 +20888,9 @@ TreeNode.prototype.openFolderIcon = "folder-open";
18109
20888
  TreeNode.prototype.arrowIcon = "drop-down";
18110
20889
  TreeNode.prototype.styled = true;
18111
20890
  TreeNode.prototype.hideIcon = false;
18112
- Widget.alias("treenode", TreeNode);
20891
+ Widget$1.alias("treenode", TreeNode);
18113
20892
 
18114
- class Pagination extends Widget {
20893
+ class Pagination extends Widget$1 {
18115
20894
  constructor(config) {
18116
20895
  super(config);
18117
20896
  }
@@ -18202,9 +20981,9 @@ class Pagination extends Widget {
18202
20981
  Pagination.prototype.baseClass = "pagination";
18203
20982
  Pagination.prototype.length = 5;
18204
20983
  Pagination.prototype.styled = true;
18205
- Widget.alias("pagination", Pagination);
20984
+ Widget$1.alias("pagination", Pagination);
18206
20985
 
18207
- class DragSource extends StyledContainerBase {
20986
+ class DragSource extends StyledContainerBase$1 {
18208
20987
  constructor(config) {
18209
20988
  super(config);
18210
20989
  }
@@ -18255,8 +21034,8 @@ class DragSource extends StyledContainerBase {
18255
21034
  DragSource.prototype.baseClass = "dragsource";
18256
21035
  DragSource.prototype.hideOnDrag = false;
18257
21036
  DragSource.prototype.handled = false;
18258
- Widget.alias("dragsource", DragSource);
18259
- class DragSourceComponent extends VDOM.Component {
21037
+ Widget$1.alias("dragsource", DragSource);
21038
+ class DragSourceComponent extends VDOM$2.Component {
18260
21039
  constructor(props) {
18261
21040
  super(props);
18262
21041
  this.state = {
@@ -18359,7 +21138,7 @@ class DragSourceComponent extends VDOM.Component {
18359
21138
  }
18360
21139
  }
18361
21140
 
18362
- class DragHandle extends StyledContainerBase {
21141
+ class DragHandle extends StyledContainerBase$1 {
18363
21142
  constructor(config) {
18364
21143
  super(config);
18365
21144
  }
@@ -18388,9 +21167,9 @@ class DragHandle extends StyledContainerBase {
18388
21167
  }
18389
21168
  DragHandle.prototype.styled = true;
18390
21169
  DragHandle.prototype.baseClass = "draghandle";
18391
- Widget.alias("draghandle", DragHandle);
21170
+ Widget$1.alias("draghandle", DragHandle);
18392
21171
 
18393
- class DropZone extends StyledContainerBase {
21172
+ class DropZone extends StyledContainerBase$1 {
18394
21173
  constructor(config) {
18395
21174
  super(config);
18396
21175
  }
@@ -18444,8 +21223,8 @@ DropZone.prototype.nearDistance = 0;
18444
21223
  DropZone.prototype.hinflate = 0;
18445
21224
  DropZone.prototype.vinflate = 0;
18446
21225
  DropZone.prototype.baseClass = "dropzone";
18447
- Widget.alias("dropzone", DropZone);
18448
- class DropZoneComponent extends VDOM.Component {
21226
+ Widget$1.alias("dropzone", DropZone);
21227
+ class DropZoneComponent extends VDOM$2.Component {
18449
21228
  el = null;
18450
21229
  unregister;
18451
21230
  constructor(props) {
@@ -18599,11 +21378,17 @@ export {
18599
21378
  ColorField,
18600
21379
  ColorFieldInstance,
18601
21380
  ColorPicker,
21381
+ Content,
21382
+ ContentPlaceholder,
21383
+ ContentPlaceholderScope,
21384
+ ContentResolver,
18602
21385
  ContextMenu,
18603
21386
  CxCredit,
21387
+ DataProxy,
18604
21388
  DateField,
18605
21389
  DateTimeField,
18606
21390
  DateTimePicker,
21391
+ DetachedScope,
18607
21392
  DocumentTitle,
18608
21393
  DragDropContext,
18609
21394
  DragHandle,
@@ -18633,8 +21418,12 @@ export {
18633
21418
  HtmlElement,
18634
21419
  HtmlElementInstance,
18635
21420
  Icon,
21421
+ IsolatedScope,
18636
21422
  Label,
18637
21423
  LabeledContainer,
21424
+ LabelsLeftLayout,
21425
+ LabelsTopLayout,
21426
+ LabelsTopLayoutCell,
18638
21427
  Link,
18639
21428
  LinkButton,
18640
21429
  List,
@@ -18658,11 +21447,16 @@ export {
18658
21447
  OverlayComponent,
18659
21448
  OverlayInstance,
18660
21449
  Pagination,
21450
+ PrivateStore,
18661
21451
  ProgressBar,
21452
+ PureContainer,
18662
21453
  Radio,
18663
21454
  ReactElementWrapper,
18664
21455
  RedirectRoute,
21456
+ Repeater,
21457
+ Rescope,
18665
21458
  Resizer,
21459
+ Restate,
18666
21460
  Route,
18667
21461
  RouteBase,
18668
21462
  Sandbox,
@@ -18670,9 +21464,11 @@ export {
18670
21464
  Section,
18671
21465
  Select,
18672
21466
  Slider,
21467
+ StaticText,
18673
21468
  Submenu,
18674
21469
  Switch,
18675
21470
  Tab,
21471
+ Text,
18676
21472
  TextArea,
18677
21473
  TextField,
18678
21474
  TimeField,
@@ -18689,6 +21485,7 @@ export {
18689
21485
  WHEEL_BUFFER_COPIES,
18690
21486
  Wheel,
18691
21487
  WheelComponent,
21488
+ Widget,
18692
21489
  Window,
18693
21490
  WindowInstance,
18694
21491
  autoFocus,