cx 26.1.13 → 26.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/build/charts/Marker.d.ts +1 -1
  2. package/build/charts/Marker.d.ts.map +1 -1
  3. package/build/charts/Marker.js +16 -6
  4. package/build/charts/MouseTracker.d.ts +2 -0
  5. package/build/charts/MouseTracker.d.ts.map +1 -1
  6. package/build/charts/helpers/PointReducer.d.ts +2 -2
  7. package/build/charts/helpers/PointReducer.d.ts.map +1 -1
  8. package/build/data/View.d.ts +5 -3
  9. package/build/data/View.d.ts.map +1 -1
  10. package/build/data/View.js +3 -1
  11. package/build/data/ops/findTreeNode.d.ts +20 -1
  12. package/build/data/ops/findTreeNode.d.ts.map +1 -1
  13. package/build/data/ops/findTreeNode.js +19 -0
  14. package/build/data/ops/findTreePath.d.ts +1 -1
  15. package/build/data/ops/findTreePath.d.ts.map +1 -1
  16. package/build/data/ops/findTreePath.js +1 -1
  17. package/build/data/ops/removeTreeNodes.d.ts +14 -1
  18. package/build/data/ops/removeTreeNodes.d.ts.map +1 -1
  19. package/build/data/ops/removeTreeNodes.js +13 -0
  20. package/build/data/ops/updateArray.d.ts +1 -1
  21. package/build/data/ops/updateArray.d.ts.map +1 -1
  22. package/build/data/ops/updateArray.js +1 -1
  23. package/build/data/ops/updateTree.d.ts +20 -1
  24. package/build/data/ops/updateTree.d.ts.map +1 -1
  25. package/build/data/ops/updateTree.js +19 -0
  26. package/build/jsx-runtime.d.ts +1 -0
  27. package/build/jsx-runtime.d.ts.map +1 -1
  28. package/build/jsx-runtime.js +3 -1
  29. package/build/svg/Rectangle.d.ts +6 -4
  30. package/build/svg/Rectangle.d.ts.map +1 -1
  31. package/build/svg/Rectangle.js +9 -7
  32. package/build/ui/Instance.d.ts +1 -1
  33. package/build/ui/Instance.d.ts.map +1 -1
  34. package/build/ui/Instance.js +18 -8
  35. package/build/ui/IsolatedScope.d.ts +2 -1
  36. package/build/ui/IsolatedScope.d.ts.map +1 -1
  37. package/build/ui/Prop.d.ts +1 -1
  38. package/build/ui/Prop.d.ts.map +1 -1
  39. package/build/ui/Widget.d.ts +2 -0
  40. package/build/ui/Widget.d.ts.map +1 -1
  41. package/build/ui/Widget.js +4 -0
  42. package/build/ui/adapter/GroupAdapter.d.ts +4 -4
  43. package/build/ui/adapter/GroupAdapter.d.ts.map +1 -1
  44. package/build/ui/adapter/GroupAdapter.js +4 -4
  45. package/build/ui/adapter/TreeAdapter.d.ts +5 -3
  46. package/build/ui/adapter/TreeAdapter.d.ts.map +1 -1
  47. package/build/ui/adapter/TreeAdapter.js +12 -5
  48. package/build/ui/app/startAppLoop.d.ts +2 -2
  49. package/build/ui/app/startAppLoop.d.ts.map +1 -1
  50. package/build/ui/app/startHotAppLoop.d.ts +4 -4
  51. package/build/ui/app/startHotAppLoop.d.ts.map +1 -1
  52. package/build/ui/app/startHotAppLoop.js +1 -1
  53. package/build/ui/batchUpdates.d.ts.map +1 -1
  54. package/build/ui/batchUpdates.js +3 -4
  55. package/build/widgets/Button.d.ts +0 -7
  56. package/build/widgets/Button.d.ts.map +1 -1
  57. package/build/widgets/HtmlElement.d.ts +2 -2
  58. package/build/widgets/HtmlElement.d.ts.map +1 -1
  59. package/build/widgets/form/Checkbox.d.ts +3 -3
  60. package/build/widgets/form/Checkbox.d.ts.map +1 -1
  61. package/build/widgets/form/Checkbox.js +11 -6
  62. package/build/widgets/form/DateTimeField.d.ts +4 -0
  63. package/build/widgets/form/DateTimeField.d.ts.map +1 -1
  64. package/build/widgets/form/TextField.d.ts +2 -2
  65. package/build/widgets/form/TextField.d.ts.map +1 -1
  66. package/build/widgets/grid/Grid.d.ts +20 -16
  67. package/build/widgets/grid/Grid.d.ts.map +1 -1
  68. package/build/widgets/grid/Grid.js +200 -86
  69. package/build/widgets/nav/Menu.d.ts +2 -0
  70. package/build/widgets/nav/Menu.d.ts.map +1 -1
  71. package/build/widgets/nav/Route.js +1 -1
  72. package/build/widgets/overlay/FlyweightTooltipTracker.d.ts +6 -4
  73. package/build/widgets/overlay/FlyweightTooltipTracker.d.ts.map +1 -1
  74. package/build/widgets/overlay/FlyweightTooltipTracker.js +3 -0
  75. package/build/widgets/overlay/Overlay.d.ts +2 -2
  76. package/build/widgets/overlay/Overlay.d.ts.map +1 -1
  77. package/dist/data.js +52 -1
  78. package/dist/jsx-runtime.js +4 -2
  79. package/dist/manifest.js +910 -904
  80. package/dist/svg.js +3 -0
  81. package/dist/ui.js +1548 -1544
  82. package/dist/widgets.css +1 -1
  83. package/dist/widgets.js +395 -4
  84. package/package.json +2 -2
  85. package/src/charts/Marker.tsx +448 -394
  86. package/src/charts/MouseTracker.tsx +3 -0
  87. package/src/charts/helpers/PointReducer.ts +2 -2
  88. package/src/data/View.ts +76 -19
  89. package/src/data/ops/findTreeNode.ts +20 -1
  90. package/src/data/ops/findTreePath.ts +7 -2
  91. package/src/data/ops/removeTreeNodes.ts +14 -1
  92. package/src/data/ops/updateArray.ts +4 -4
  93. package/src/data/ops/updateTree.ts +32 -6
  94. package/src/index.scss +6 -6
  95. package/src/jsx-runtime.spec.tsx +40 -0
  96. package/src/jsx-runtime.ts +87 -84
  97. package/src/svg/Rectangle.tsx +80 -73
  98. package/src/ui/DataProxy.ts +55 -55
  99. package/src/ui/Instance.ts +142 -45
  100. package/src/ui/IsolatedScope.ts +4 -2
  101. package/src/ui/Prop.ts +141 -141
  102. package/src/ui/Rescope.ts +50 -50
  103. package/src/ui/Widget.tsx +292 -234
  104. package/src/ui/adapter/ArrayAdapter.ts +229 -229
  105. package/src/ui/adapter/GroupAdapter.ts +8 -10
  106. package/src/ui/adapter/TreeAdapter.ts +75 -15
  107. package/src/ui/app/Url.spec.ts +1 -1
  108. package/src/ui/app/startAppLoop.tsx +56 -45
  109. package/src/ui/app/startHotAppLoop.ts +4 -4
  110. package/src/ui/batchUpdates.ts +16 -21
  111. package/src/ui/exprHelpers.ts +96 -96
  112. package/src/widgets/Button.tsx +0 -8
  113. package/src/widgets/HtmlElement.spec.tsx +100 -72
  114. package/src/widgets/HtmlElement.tsx +11 -10
  115. package/src/widgets/Sandbox.ts +104 -104
  116. package/src/widgets/Section.scss +55 -55
  117. package/src/widgets/drag-drop/DropZone.scss +74 -74
  118. package/src/widgets/form/Checkbox.tsx +296 -243
  119. package/src/widgets/form/DateTimeField.tsx +6 -0
  120. package/src/widgets/form/TextField.tsx +2 -2
  121. package/src/widgets/grid/Grid.scss +43 -10
  122. package/src/widgets/grid/Grid.tsx +4401 -3848
  123. package/src/widgets/nav/Menu.tsx +3 -0
  124. package/src/widgets/nav/Route.ts +1 -1
  125. package/src/widgets/overlay/FlyweightTooltipTracker.ts +15 -4
  126. package/src/widgets/overlay/Overlay.tsx +2 -1
  127. package/src/widgets/overlay/index.d.ts +11 -11
@@ -19,7 +19,13 @@ import type { Widget } from "./Widget";
19
19
  /**
20
20
  * Serializable value types that can be safely passed through the framework
21
21
  */
22
- export type SerializableValue = string | number | boolean | object | null | undefined;
22
+ export type SerializableValue =
23
+ | string
24
+ | number
25
+ | boolean
26
+ | object
27
+ | null
28
+ | undefined;
23
29
 
24
30
  /**
25
31
  * Core instance data structure used by widgets
@@ -190,7 +196,12 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
190
196
  declare public instances?: Instance[];
191
197
  declare public selected?: boolean;
192
198
 
193
- constructor(widget: WidgetType, key: string, parent?: Instance, parentStore?: any) {
199
+ constructor(
200
+ widget: WidgetType,
201
+ key: string,
202
+ parent?: Instance,
203
+ parentStore?: any,
204
+ ) {
194
205
  this.widget = widget;
195
206
  this.key = key;
196
207
  this.id = String(++instanceId);
@@ -198,7 +209,8 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
198
209
  this.parent = parent;
199
210
  this.parentStore = parentStore ?? parent?.store;
200
211
 
201
- if (this.parentStore == null) throw new Error("Cannot create instance without a parent store.");
212
+ if (this.parentStore == null)
213
+ throw new Error("Cannot create instance without a parent store.");
202
214
  }
203
215
 
204
216
  public setParentStore(parentStore: any): void {
@@ -242,8 +254,10 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
242
254
  this.widget.prepareCleanup
243
255
  )
244
256
  this.needsExploreCleanup = true;
245
- if (this.widget.prepare || this.widget.controller) this.needsPrepare = true;
246
- if (this.widget.cleanup || this.widget.controller) this.needsCleanup = true;
257
+ if (this.widget.prepare || this.widget.controller)
258
+ this.needsPrepare = true;
259
+ if (this.widget.cleanup || this.widget.controller)
260
+ this.needsCleanup = true;
247
261
  this.initialized = true;
248
262
  }
249
263
 
@@ -253,7 +267,8 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
253
267
  const wasVisible = this.visible;
254
268
  this.rawData = this.dataSelector!(this.store);
255
269
  this.visible = this.widget.checkVisible(context, this, this.rawData);
256
- if (this.visible && !this.detached) this.parent!.instanceCache!.addChild(this);
270
+ if (this.visible && !this.detached)
271
+ this.parent!.instanceCache!.addChild(this);
257
272
  this.explored = false;
258
273
  this.prepared = false;
259
274
 
@@ -311,9 +326,11 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
311
326
  if (this.explored) {
312
327
  if (this.widget.prepareCleanup) context.prepareList.push(this);
313
328
 
314
- if (this.widget.exploreCleanup) this.widget.exploreCleanup(context, this);
329
+ if (this.widget.exploreCleanup)
330
+ this.widget.exploreCleanup(context, this);
315
331
 
316
- if (this.parent?.outerLayout === this) context.popNamedValue("content", "body");
332
+ if (this.parent?.outerLayout === this)
333
+ context.popNamedValue("content", "body");
317
334
 
318
335
  if (this.widget.controller) context.pop("controller");
319
336
 
@@ -334,7 +351,8 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
334
351
 
335
352
  if (!this.controller) {
336
353
  if (context.controller) this.controller = context.controller;
337
- else if (this.parent?.controller) this.controller = this.parent?.controller;
354
+ else if (this.parent?.controller)
355
+ this.controller = this.parent?.controller;
338
356
  }
339
357
 
340
358
  this.destroyTracked = false;
@@ -347,13 +365,21 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
347
365
  }
348
366
  context.push("controller", this.controller);
349
367
  this.controller.explore(context);
350
- if (this.controller.onDestroy && this.controller.widget == this.widget) this.trackDestroy();
368
+ if (
369
+ this.controller.onDestroy &&
370
+ this.controller.widget == this.widget
371
+ )
372
+ this.trackDestroy();
351
373
  }
352
374
  }
353
375
 
354
- if (this.widget.onDestroy || isNonEmptyArray(this.destroySubscriptions)) this.trackDestroy();
376
+ if (this.widget.onDestroy || isNonEmptyArray(this.destroySubscriptions))
377
+ this.trackDestroy();
355
378
 
356
- this.renderList = this.assignedRenderList || this.parent?.renderList || context.getRootRenderList();
379
+ this.renderList =
380
+ this.assignedRenderList ||
381
+ this.parent?.renderList ||
382
+ context.getRootRenderList();
357
383
 
358
384
  let shouldUpdate =
359
385
  this.rawData !== this.cached.rawData ||
@@ -376,14 +402,22 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
376
402
  }
377
403
 
378
404
  if (this.widget.outerLayout) {
379
- this.outerLayout = this.getChild(context, this.widget.outerLayout, null, this.store);
405
+ this.outerLayout = this.getChild(
406
+ context,
407
+ this.widget.outerLayout,
408
+ null,
409
+ this.store,
410
+ );
380
411
  this.outerLayout.scheduleExploreIfVisible(context);
381
412
  this.renderList = this.renderList.insertLeft();
382
413
  }
383
414
 
384
415
  if (this.widget.isContent) {
385
- this.contentPlaceholder = context.contentPlaceholder && context.contentPlaceholder[this.widget.putInto!];
386
- if (this.contentPlaceholder) context.contentPlaceholder[this.widget.putInto!](this);
416
+ this.contentPlaceholder =
417
+ context.contentPlaceholder &&
418
+ context.contentPlaceholder[this.widget.putInto!];
419
+ if (this.contentPlaceholder)
420
+ context.contentPlaceholder[this.widget.putInto!](this);
387
421
  else {
388
422
  this.renderList = this.renderList.insertLeft();
389
423
  context.pushNamedValue("content", this.widget.putInto!, this);
@@ -395,7 +429,8 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
395
429
  }
396
430
 
397
431
  this.shouldUpdate = false;
398
- if (shouldUpdate || this.childStateDirty || !this.widget.memoize) this.markShouldUpdate(context);
432
+ if (shouldUpdate || this.childStateDirty || !this.widget.memoize)
433
+ this.markShouldUpdate(context);
399
434
 
400
435
  context.exploreStack.hop();
401
436
 
@@ -405,7 +440,8 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
405
440
  let helper = this.widget.helpers[cmp];
406
441
  if (helper) {
407
442
  let ins = this.getChild(context, helper);
408
- if (ins.scheduleExploreIfVisible(context)) this.helpers[cmp] = ins;
443
+ if (ins.scheduleExploreIfVisible(context))
444
+ this.helpers[cmp] = ins;
409
445
  }
410
446
  }
411
447
  }
@@ -418,22 +454,28 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
418
454
  if (!this.visible) throw new Error("Prepare invisible!");
419
455
 
420
456
  if (this.prepared) {
421
- if (this.widget.prepareCleanup) this.widget.prepareCleanup(context, this);
457
+ if (this.widget.prepareCleanup)
458
+ this.widget.prepareCleanup(context, this);
422
459
  return;
423
460
  }
424
461
 
425
462
  this.prepared = true;
426
463
  if (this.widget.prepare) this.widget.prepare(context, this);
427
464
 
428
- if (this.widget.controller && this.controller?.prepare) this.controller.prepare(context);
465
+ if (this.widget.controller && this.controller?.prepare)
466
+ this.controller.prepare(context);
429
467
  }
430
468
 
431
- public render(context: RenderingContext): null | Record<string, React.ReactNode> | React.ReactNode[] {
469
+ public render(
470
+ context: RenderingContext,
471
+ ): null | Record<string, React.ReactNode> | React.ReactNode[] {
432
472
  if (!this.visible) throw new Error("Render invisible!");
433
473
 
434
474
  if (this.shouldUpdate) {
435
475
  debug(renderFlag, this.widget, this.key);
436
- const vdom = renderResultFix(this.widget.render(context, this, this.key));
476
+ const vdom = renderResultFix(
477
+ this.widget.render(context, this, this.key),
478
+ );
437
479
  if (this.widget.isContent || this.outerLayout) this.contentVDOM = vdom;
438
480
  else this.vdom = vdom;
439
481
  }
@@ -466,7 +508,8 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
466
508
  }
467
509
 
468
510
  public cleanup(context: RenderingContext): void {
469
- if (this.widget.controller && this.controller?.cleanup) this.controller.cleanup(context);
511
+ if (this.widget.controller && this.controller?.cleanup)
512
+ this.controller.cleanup(context);
470
513
 
471
514
  if (this.widget.cleanup) this.widget.cleanup(context, this);
472
515
  }
@@ -474,7 +517,8 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
474
517
  private trackDestroy(): void {
475
518
  if (!this.destroyTracked) {
476
519
  this.destroyTracked = true;
477
- if (this.parent && !this.detached) this.parent.trackDestroyableChild(this);
520
+ if (this.parent && !this.detached)
521
+ this.parent.trackDestroyableChild(this);
478
522
  }
479
523
  }
480
524
 
@@ -489,7 +533,9 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
489
533
  this.trackDestroy();
490
534
  return () => {
491
535
  if (this.destroySubscriptions) {
492
- this.destroySubscriptions = this.destroySubscriptions.filter((cb) => cb !== callback);
536
+ this.destroySubscriptions = this.destroySubscriptions.filter(
537
+ (cb) => cb !== callback,
538
+ );
493
539
  }
494
540
  };
495
541
  }
@@ -547,7 +593,11 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
547
593
  });
548
594
  }
549
595
 
550
- public set(prop: string, value: any, options: { internal?: boolean; immediate?: boolean } = {}): boolean {
596
+ public set(
597
+ prop: string,
598
+ value: any,
599
+ options: { internal?: boolean; immediate?: boolean } = {},
600
+ ): boolean {
551
601
  //skip re-rendering (used for reading state from uncontrolled components)
552
602
  if (options.internal && this.rawData) {
553
603
  this.rawData[prop] = value;
@@ -622,10 +672,17 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
622
672
  return changed;
623
673
  }
624
674
 
625
- public nestedDataSet(key: string, value: any, dataConfig: Record<string, any>, useParentStore?: boolean): boolean {
675
+ public nestedDataSet(
676
+ key: string,
677
+ value: any,
678
+ dataConfig: Record<string, any>,
679
+ useParentStore?: boolean,
680
+ ): boolean {
626
681
  let config = dataConfig[key];
627
682
  if (!config)
628
- throw new Error(`Unknown nested data key ${key}. Known keys are ${Object.keys(dataConfig).join(", ")}.`);
683
+ throw new Error(
684
+ `Unknown nested data key ${key}. Known keys are ${Object.keys(dataConfig).join(", ")}.`,
685
+ );
629
686
 
630
687
  if (isAccessorChain(config)) config = { bind: config.toString() };
631
688
 
@@ -633,14 +690,17 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
633
690
  let store = this.store;
634
691
  //in case of Rescope or DataProxy, bindings point to the data in the parent store
635
692
  if (useParentStore && store.store) store = store.store;
636
- return isUndefined(value) ? store.deleteItem(config.bind) : store.setItem(config.bind, value);
693
+ return isUndefined(value)
694
+ ? store.deleteItem(config.bind)
695
+ : store.setItem(config.bind, value);
637
696
  }
638
697
 
639
698
  if (!config.set)
640
699
  throw new Error(
641
700
  `Cannot change nested data value for ${key} as it's read-only. Either define it as a binding or define a set function.`,
642
701
  );
643
- if (isString(config.set)) this.getControllerMethod(config.set)(value, this);
702
+ if (isString(config.set))
703
+ this.getControllerMethod(config.set)(value, this);
644
704
  else if (isFunction(config.set)) config.set(value, this);
645
705
  else
646
706
  throw new Error(
@@ -658,7 +718,10 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
658
718
 
659
719
  public getInstanceCache(): InstanceCache {
660
720
  if (!this.instanceCache)
661
- this.instanceCache = new InstanceCache(this, this.widget.isPureContainer ? this.key : null);
721
+ this.instanceCache = new InstanceCache(
722
+ this,
723
+ this.widget.isPureContainer ? this.key : null,
724
+ );
662
725
  return this.instanceCache;
663
726
  }
664
727
 
@@ -676,13 +739,23 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
676
739
  }
677
740
 
678
741
  public getDetachedChild(widget: Widget, key: string, store?: any): Instance {
679
- const child = new Instance(widget, key, this, store ?? this.store);
742
+ const child = widget.createInstance(key, this, store ?? this.store);
680
743
  child.detached = true;
681
744
  return child;
682
745
  }
683
746
 
684
- public prepareRenderCleanupChild(widget: any, store?: any, keyPrefix?: string, options?: any): any {
685
- return widget.prepareRenderCleanup(store ?? this.store, options, keyPrefix, this);
747
+ public prepareRenderCleanupChild(
748
+ widget: any,
749
+ store?: any,
750
+ keyPrefix?: string,
751
+ options?: any,
752
+ ): any {
753
+ return widget.prepareRenderCleanup(
754
+ store ?? this.store,
755
+ options,
756
+ keyPrefix,
757
+ this,
758
+ );
686
759
  }
687
760
 
688
761
  public getJsxEventProps(): Record<string, any> | null {
@@ -703,10 +776,13 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
703
776
  const scope = this.widget as any;
704
777
  const callback = scope[methodName];
705
778
 
706
- if (typeof callback === "string") return this.getControllerMethod(callback);
779
+ if (typeof callback === "string")
780
+ return this.getControllerMethod(callback);
707
781
 
708
782
  if (typeof callback !== "function")
709
- throw new Error(`Cannot invoke callback method ${methodName} as assigned value is not a function.`);
783
+ throw new Error(
784
+ `Cannot invoke callback method ${methodName} as assigned value is not a function.`,
785
+ );
710
786
 
711
787
  return callback.bind(scope);
712
788
  }
@@ -716,7 +792,9 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
716
792
  * @param predicate Function to test each controller
717
793
  * @returns The matching controller or undefined
718
794
  */
719
- public findController(predicate: (controller: Controller) => boolean): Controller | undefined {
795
+ public findController(
796
+ predicate: (controller: Controller) => boolean,
797
+ ): Controller | undefined {
720
798
  let at: Instance | undefined = this;
721
799
  while (at?.controller != null) {
722
800
  if (predicate(at.controller)) {
@@ -732,7 +810,9 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
732
810
  * @param type Controller class/constructor to find
733
811
  * @returns The matching controller cast to the specified type, or undefined
734
812
  */
735
- public findControllerByType<T extends Controller>(type: new (...args: any[]) => T): T | undefined {
813
+ public findControllerByType<T extends Controller>(
814
+ type: new (...args: any[]) => T,
815
+ ): T | undefined {
736
816
  return this.findController((c) => c instanceof type) as T | undefined;
737
817
  }
738
818
 
@@ -742,9 +822,14 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
742
822
  * @returns The matching controller
743
823
  * @throws Error if no matching controller is found
744
824
  */
745
- public getController(predicate: (controller: Controller) => boolean): Controller {
825
+ public getController(
826
+ predicate: (controller: Controller) => boolean,
827
+ ): Controller {
746
828
  const controller = this.findController(predicate);
747
- if (!controller) throw new Error("Cannot find a controller matching the given predicate in the instance tree.");
829
+ if (!controller)
830
+ throw new Error(
831
+ "Cannot find a controller matching the given predicate in the instance tree.",
832
+ );
748
833
  return controller;
749
834
  }
750
835
 
@@ -754,9 +839,14 @@ export class Instance<WidgetType extends Widget<any, any> = Widget<any, any>> {
754
839
  * @returns The matching controller cast to the specified type
755
840
  * @throws Error if no controller of the specified type is found
756
841
  */
757
- public getControllerByType<T extends Controller>(type: new (...args: any[]) => T): T {
842
+ public getControllerByType<T extends Controller>(
843
+ type: new (...args: any[]) => T,
844
+ ): T {
758
845
  const controller = this.findControllerByType(type);
759
- if (!controller) throw new Error(`Cannot find a controller of type "${type.name}" in the instance tree.`);
846
+ if (!controller)
847
+ throw new Error(
848
+ `Cannot find a controller of type "${type.name}" in the instance tree.`,
849
+ );
760
850
  return controller;
761
851
  }
762
852
 
@@ -804,16 +894,23 @@ export class InstanceCache {
804
894
  this.keyPrefix = keyPrefix != null ? keyPrefix + "-" : "";
805
895
  }
806
896
 
807
- public getChild(widget: Widget, parentStore: any, key?: string | number | null): Instance {
808
- const k = this.keyPrefix + (key != null ? key : widget.vdomKey || widget.widgetId);
897
+ public getChild(
898
+ widget: Widget,
899
+ parentStore: View,
900
+ key?: string | number | null,
901
+ ): Instance {
902
+ const k =
903
+ this.keyPrefix +
904
+ (key != null ? key : widget.vdomKey || widget.widgetId);
809
905
  let instance = this.children[k];
810
906
 
811
907
  if (
812
908
  !instance ||
813
909
  instance.widget !== widget ||
814
- (!instance.visible && (instance.widget.controller || instance.widget.onInit))
910
+ (!instance.visible &&
911
+ (instance.widget.controller || instance.widget.onInit))
815
912
  ) {
816
- instance = new Instance(widget, k, this.parent, parentStore);
913
+ instance = widget.createInstance(k, this.parent, parentStore);
817
914
  this.children[k] = instance;
818
915
  } else if (instance.parentStore !== parentStore) {
819
916
  instance.setParentStore(parentStore);
@@ -2,13 +2,14 @@ import { PureContainerBase, PureContainerConfig } from "./PureContainer";
2
2
  import { isArray } from "../util/isArray";
3
3
  import { Instance } from "./Instance";
4
4
  import { StructuredProp } from "./Prop";
5
+ import { AccessorChain } from "../data";
5
6
 
6
7
  export interface IsolatedScopeConfig extends PureContainerConfig {
7
8
  /**
8
9
  * A single binding path or a list of paths to be monitored for changes.
9
10
  * Use `bind` as a shorthand for defining the `data` object.
10
11
  */
11
- bind?: string | string[];
12
+ bind?: string | string[] | AccessorChain<any>;
12
13
 
13
14
  /** Data object selector. The children will update only if `data` change. */
14
15
  data?: StructuredProp;
@@ -44,7 +45,8 @@ export class IsolatedScope<
44
45
  super.explore(context, instance);
45
46
  } else if (instance.children) {
46
47
  // mark children to prevent sweeping them away
47
- for (let i = 0; i < instance.children.length; i++) instance.instanceCache.addChild(instance.children[i]);
48
+ for (let i = 0; i < instance.children.length; i++)
49
+ instance.instanceCache.addChild(instance.children[i]);
48
50
  }
49
51
  }
50
52
  }