cx 26.0.2 → 26.0.4

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 (123) hide show
  1. package/build/data/ArrayElementView.spec.js +1 -1
  2. package/build/hooks/store.spec.js +1 -1
  3. package/build/hooks/useTrigger.spec.js +1 -1
  4. package/build/ui/Controller.spec.js +2 -6
  5. package/build/ui/PureContainer.spec.d.ts +1 -0
  6. package/build/ui/PureContainer.spec.js +149 -0
  7. package/build/ui/layout/ContentPlaceholder.spec.js +12 -12
  8. package/build.js +129 -129
  9. package/dist/manifest.d.ts +1443 -0
  10. package/dist/manifest.js +826 -826
  11. package/package.json +4 -3
  12. package/src/charts/Chart.ts +108 -108
  13. package/src/data/ArrayElementView.ts +90 -90
  14. package/src/data/AugmentedViewBase.ts +88 -88
  15. package/src/data/Binding.ts +104 -104
  16. package/src/data/ExposedRecordView.ts +95 -95
  17. package/src/data/ExposedValueView.ts +89 -89
  18. package/src/data/Expression.spec.ts +229 -229
  19. package/src/data/Expression.ts +233 -233
  20. package/src/data/Grouper.spec.ts +57 -57
  21. package/src/data/Grouper.ts +158 -158
  22. package/src/data/NestedDataView.ts +43 -43
  23. package/src/data/ReadOnlyDataView.ts +39 -39
  24. package/src/data/Ref.ts +104 -104
  25. package/src/data/Selector.ts +10 -10
  26. package/src/data/Store.ts +52 -52
  27. package/src/data/StoreProxy.ts +19 -19
  28. package/src/data/StoreRef.ts +66 -66
  29. package/src/data/StringTemplate.spec.ts +132 -132
  30. package/src/data/StringTemplate.ts +93 -93
  31. package/src/data/StructuredSelector.spec.ts +113 -113
  32. package/src/data/StructuredSelector.ts +146 -146
  33. package/src/data/SubscribableView.ts +63 -63
  34. package/src/data/ZoomIntoPropertyView.spec.ts +64 -64
  35. package/src/data/ZoomIntoPropertyView.ts +45 -45
  36. package/src/data/computable.spec.ts +62 -62
  37. package/src/data/createAccessorModelProxy.ts +60 -60
  38. package/src/data/createStructuredSelector.ts +62 -62
  39. package/src/data/getAccessor.spec.ts +11 -11
  40. package/src/data/getAccessor.ts +74 -74
  41. package/src/data/getSelector.spec.ts +43 -43
  42. package/src/data/getSelector.ts +66 -66
  43. package/src/data/ops/filter.spec.ts +35 -35
  44. package/src/data/ops/filter.ts +9 -9
  45. package/src/data/ops/merge.ts +13 -13
  46. package/src/data/ops/removeTreeNodes.spec.ts +37 -37
  47. package/src/data/ops/removeTreeNodes.ts +15 -15
  48. package/src/data/ops/updateArray.spec.ts +69 -69
  49. package/src/data/ops/updateArray.ts +31 -31
  50. package/src/data/ops/updateTree.ts +23 -23
  51. package/src/data/test-types.ts +7 -7
  52. package/src/hooks/useTrigger.ts +26 -26
  53. package/src/index.scss +6 -6
  54. package/src/jsx-runtime.ts +72 -72
  55. package/src/svg/BoundedObject.ts +101 -101
  56. package/src/ui/CSSHelper.ts +17 -17
  57. package/src/ui/ContentResolver.ts +124 -124
  58. package/src/ui/Controller.ts +189 -189
  59. package/src/ui/Culture.ts +159 -159
  60. package/src/ui/DataProxy.ts +55 -55
  61. package/src/ui/FocusManager.ts +171 -171
  62. package/src/ui/Instance.ts +868 -868
  63. package/src/ui/RenderingContext.ts +99 -99
  64. package/src/ui/Rescope.ts +49 -49
  65. package/src/ui/StructuredInstanceDataAccessor.ts +32 -32
  66. package/src/ui/VDOM.ts +34 -34
  67. package/src/ui/adapter/ArrayAdapter.spec.ts +55 -55
  68. package/src/ui/adapter/ArrayAdapter.ts +226 -226
  69. package/src/ui/adapter/TreeAdapter.spec.ts +76 -76
  70. package/src/ui/adapter/TreeAdapter.ts +185 -185
  71. package/src/ui/app/History.ts +133 -133
  72. package/src/ui/app/Url.spec.ts +50 -50
  73. package/src/ui/app/startHotAppLoop.ts +40 -40
  74. package/src/ui/createFunctionalComponent.ts +65 -65
  75. package/src/ui/index.ts +45 -45
  76. package/src/ui/layout/Content.ts +30 -30
  77. package/src/ui/layout/FirstVisibleChildLayout.ts +60 -60
  78. package/src/ui/selection/KeySelection.ts +165 -165
  79. package/src/ui/selection/PropertySelection.ts +87 -87
  80. package/src/ui/selection/Selection.ts +118 -118
  81. package/src/util/Format.ts +267 -267
  82. package/src/util/browserSupportsPassiveEventHandlers.ts +20 -20
  83. package/src/util/color/rgbToHsl.ts +35 -35
  84. package/src/util/getActiveElement.ts +4 -4
  85. package/src/util/hasKey.ts +18 -18
  86. package/src/util/index.ts +55 -55
  87. package/src/util/innerTextTrim.ts +10 -10
  88. package/src/util/isArray.ts +3 -3
  89. package/src/util/isDataRecord.ts +5 -5
  90. package/src/util/isDefined.ts +3 -3
  91. package/src/util/isString.ts +3 -3
  92. package/src/widgets/Sandbox.ts +103 -103
  93. package/src/widgets/autoFocus.ts +9 -9
  94. package/src/widgets/cx.ts +63 -63
  95. package/src/widgets/grid/GridCell.ts +143 -143
  96. package/src/widgets/icons/calendar.tsx +17 -17
  97. package/src/widgets/icons/check.tsx +13 -13
  98. package/src/widgets/icons/clear.tsx +15 -15
  99. package/src/widgets/icons/close.tsx +20 -20
  100. package/src/widgets/icons/cx.tsx +38 -38
  101. package/src/widgets/icons/drop-down.tsx +15 -15
  102. package/src/widgets/icons/file.tsx +13 -13
  103. package/src/widgets/icons/folder-open.tsx +15 -15
  104. package/src/widgets/icons/folder.tsx +13 -13
  105. package/src/widgets/icons/forward.tsx +22 -22
  106. package/src/widgets/icons/loading.tsx +24 -24
  107. package/src/widgets/icons/menu.tsx +17 -17
  108. package/src/widgets/icons/pixel-picker.tsx +18 -18
  109. package/src/widgets/icons/search.tsx +13 -13
  110. package/src/widgets/icons/sort-asc.tsx +14 -14
  111. package/src/widgets/icons/square.tsx +18 -18
  112. package/src/widgets/nav/Route.ts +142 -142
  113. package/src/widgets/overlay/ContextMenu.ts +42 -42
  114. package/src/widgets/overlay/Dropdown.tsx +762 -762
  115. package/src/widgets/overlay/MsgBox.tsx +141 -141
  116. package/src/widgets/overlay/Toast.ts +111 -111
  117. package/src/widgets/overlay/Window.tsx +299 -299
  118. package/src/widgets/overlay/alerts.ts +46 -46
  119. package/src/widgets/overlay/captureMouse.ts +195 -195
  120. package/src/widgets/overlay/createHotPromiseWindowFactory.ts +72 -72
  121. package/src/widgets/overlay/index.d.ts +11 -11
  122. package/src/widgets/overlay/index.ts +11 -11
  123. package/src/widgets/overlay/tooltip-ops.ts +173 -173
@@ -1,99 +1,99 @@
1
- import { TraversalStack } from "../util/TraversalStack";
2
- import { reverseSlice } from "../util/reverseSlice";
3
- import { Widget } from "./Widget";
4
-
5
- export type CxChild = Record<string, any> | React.ReactElement | Widget | CxChild[] | null | undefined;
6
-
7
- export class RenderingContext {
8
- options: any;
9
- exploreStack: any;
10
- prepareList: any[];
11
- cleanupList: any[];
12
- stacks: any;
13
- renderList: any;
14
-
15
- [key: string]: any;
16
-
17
- constructor(options?: any) {
18
- this.options = options || {};
19
- this.exploreStack = new TraversalStack();
20
- this.prepareList = [];
21
- this.cleanupList = [];
22
- this.stacks = {};
23
- this.renderList = new LinkedListsNode();
24
- }
25
-
26
- getStack(key: string) {
27
- let stack = this.stacks[key];
28
- if (!stack) stack = this.stacks[key] = [];
29
- return stack;
30
- }
31
-
32
- push(key: string, value: any) {
33
- let stack = this.getStack(key);
34
- stack.push(this[key]);
35
- return (this[key] = value);
36
- }
37
-
38
- pop(key: string) {
39
- let stack = this.getStack(key);
40
- return (this[key] = stack.pop());
41
- }
42
-
43
- pushNamedValue(key: string, name: string, value: any) {
44
- let stack = this.getStack(`${key}:${name}`);
45
- if (!this[key]) this[key] = {};
46
- stack.push(this[key][name]);
47
- return (this[key][name] = value);
48
- }
49
-
50
- popNamedValue(key: string, name: string) {
51
- let stack = this.getStack(`${key}:${name}`);
52
- return (this[key][name] = stack.pop());
53
- }
54
-
55
- get(key: string) {
56
- return this[key];
57
- }
58
-
59
- getRootRenderList() {
60
- let rl = this.renderList;
61
- while (rl.left) rl = rl.left;
62
- return rl;
63
- }
64
- }
65
-
66
- class LinkedListsNode {
67
- left?: LinkedListsNode;
68
- right?: LinkedListsNode;
69
- data: any[];
70
- reverseIndex?: number;
71
-
72
- constructor(left?: LinkedListsNode, right?: LinkedListsNode) {
73
- this.left = left;
74
- this.right = right;
75
- this.data = [];
76
- }
77
-
78
- insertLeft() {
79
- let node = new LinkedListsNode(this.left, this);
80
- if (this.left) this.left.right = node;
81
- this.left = node;
82
- return node;
83
- }
84
-
85
- insertRight() {
86
- let node = new LinkedListsNode(this, this.right);
87
- if (this.right) this.right.left = node;
88
- this.right = node;
89
- return node;
90
- }
91
-
92
- markReverseIndex() {
93
- this.reverseIndex = this.data.length;
94
- }
95
-
96
- reverse() {
97
- reverseSlice(this.data, this.reverseIndex!);
98
- }
99
- }
1
+ import { TraversalStack } from "../util/TraversalStack";
2
+ import { reverseSlice } from "../util/reverseSlice";
3
+ import { Widget } from "./Widget";
4
+
5
+ export type CxChild = Record<string, any> | React.ReactElement | Widget | CxChild[] | null | undefined;
6
+
7
+ export class RenderingContext {
8
+ options: any;
9
+ exploreStack: any;
10
+ prepareList: any[];
11
+ cleanupList: any[];
12
+ stacks: any;
13
+ renderList: any;
14
+
15
+ [key: string]: any;
16
+
17
+ constructor(options?: any) {
18
+ this.options = options || {};
19
+ this.exploreStack = new TraversalStack();
20
+ this.prepareList = [];
21
+ this.cleanupList = [];
22
+ this.stacks = {};
23
+ this.renderList = new LinkedListsNode();
24
+ }
25
+
26
+ getStack(key: string) {
27
+ let stack = this.stacks[key];
28
+ if (!stack) stack = this.stacks[key] = [];
29
+ return stack;
30
+ }
31
+
32
+ push(key: string, value: any) {
33
+ let stack = this.getStack(key);
34
+ stack.push(this[key]);
35
+ return (this[key] = value);
36
+ }
37
+
38
+ pop(key: string) {
39
+ let stack = this.getStack(key);
40
+ return (this[key] = stack.pop());
41
+ }
42
+
43
+ pushNamedValue(key: string, name: string, value: any) {
44
+ let stack = this.getStack(`${key}:${name}`);
45
+ if (!this[key]) this[key] = {};
46
+ stack.push(this[key][name]);
47
+ return (this[key][name] = value);
48
+ }
49
+
50
+ popNamedValue(key: string, name: string) {
51
+ let stack = this.getStack(`${key}:${name}`);
52
+ return (this[key][name] = stack.pop());
53
+ }
54
+
55
+ get(key: string) {
56
+ return this[key];
57
+ }
58
+
59
+ getRootRenderList() {
60
+ let rl = this.renderList;
61
+ while (rl.left) rl = rl.left;
62
+ return rl;
63
+ }
64
+ }
65
+
66
+ class LinkedListsNode {
67
+ left?: LinkedListsNode;
68
+ right?: LinkedListsNode;
69
+ data: any[];
70
+ reverseIndex?: number;
71
+
72
+ constructor(left?: LinkedListsNode, right?: LinkedListsNode) {
73
+ this.left = left;
74
+ this.right = right;
75
+ this.data = [];
76
+ }
77
+
78
+ insertLeft() {
79
+ let node = new LinkedListsNode(this.left, this);
80
+ if (this.left) this.left.right = node;
81
+ this.left = node;
82
+ return node;
83
+ }
84
+
85
+ insertRight() {
86
+ let node = new LinkedListsNode(this, this.right);
87
+ if (this.right) this.right.left = node;
88
+ this.right = node;
89
+ return node;
90
+ }
91
+
92
+ markReverseIndex() {
93
+ this.reverseIndex = this.data.length;
94
+ }
95
+
96
+ reverse() {
97
+ reverseSlice(this.data, this.reverseIndex!);
98
+ }
99
+ }
package/src/ui/Rescope.ts CHANGED
@@ -1,49 +1,49 @@
1
- import { Widget } from "./Widget";
2
- import { PureContainerBase, PureContainerConfig } from "./PureContainer";
3
- import { Binding } from "../data/Binding";
4
- import { ZoomIntoPropertyView } from "../data/ZoomIntoPropertyView";
5
- import { StructuredInstanceDataAccessor } from "./StructuredInstanceDataAccessor";
6
- import { isObject } from "../util/isObject";
7
- import { StructuredProp } from "./Prop";
8
-
9
- export interface RescopeConfig extends PureContainerConfig {
10
- bind: string;
11
- rootName?: string;
12
- rootAlias?: string;
13
- data?: StructuredProp;
14
- }
15
-
16
- export class Rescope extends PureContainerBase<RescopeConfig> {
17
- declare bind: string;
18
- declare binding: any;
19
- declare rootAlias?: string;
20
- declare rootName: string;
21
- declare data?: any;
22
-
23
- init() {
24
- this.binding = Binding.get(this.bind);
25
- if (this.rootAlias) this.rootName = this.rootAlias;
26
- super.init();
27
- }
28
-
29
- initInstance(context: any, instance: any) {
30
- instance.store = new ZoomIntoPropertyView({
31
- store: instance.parentStore,
32
- binding: this.binding,
33
- rootName: this.rootName,
34
- nestedData: isObject(this.data)
35
- ? new StructuredInstanceDataAccessor({ instance, data: this.data, useParentStore: true })
36
- : undefined,
37
- });
38
- super.initInstance(context, instance);
39
- }
40
-
41
- applyParentStore(instance: any) {
42
- instance.store.setStore(instance.parentStore);
43
- }
44
- }
45
-
46
- Rescope.prototype.bind = "$page";
47
- Rescope.prototype.rootName = "$root";
48
-
49
- Widget.alias("rescope", Rescope);
1
+ import { Widget } from "./Widget";
2
+ import { PureContainerBase, PureContainerConfig } from "./PureContainer";
3
+ import { Binding } from "../data/Binding";
4
+ import { ZoomIntoPropertyView } from "../data/ZoomIntoPropertyView";
5
+ import { StructuredInstanceDataAccessor } from "./StructuredInstanceDataAccessor";
6
+ import { isObject } from "../util/isObject";
7
+ import { StructuredProp } from "./Prop";
8
+
9
+ export interface RescopeConfig extends PureContainerConfig {
10
+ bind: string;
11
+ rootName?: string;
12
+ rootAlias?: string;
13
+ data?: StructuredProp;
14
+ }
15
+
16
+ export class Rescope extends PureContainerBase<RescopeConfig> {
17
+ declare bind: string;
18
+ declare binding: any;
19
+ declare rootAlias?: string;
20
+ declare rootName: string;
21
+ declare data?: any;
22
+
23
+ init() {
24
+ this.binding = Binding.get(this.bind);
25
+ if (this.rootAlias) this.rootName = this.rootAlias;
26
+ super.init();
27
+ }
28
+
29
+ initInstance(context: any, instance: any) {
30
+ instance.store = new ZoomIntoPropertyView({
31
+ store: instance.parentStore,
32
+ binding: this.binding,
33
+ rootName: this.rootName,
34
+ nestedData: isObject(this.data)
35
+ ? new StructuredInstanceDataAccessor({ instance, data: this.data, useParentStore: true })
36
+ : undefined,
37
+ });
38
+ super.initInstance(context, instance);
39
+ }
40
+
41
+ applyParentStore(instance: any) {
42
+ instance.store.setStore(instance.parentStore);
43
+ }
44
+ }
45
+
46
+ Rescope.prototype.bind = "$page";
47
+ Rescope.prototype.rootName = "$root";
48
+
49
+ Widget.alias("rescope", Rescope);
@@ -1,32 +1,32 @@
1
- import { getSelector } from "../data/getSelector";
2
- import { StructuredDataAccessor } from "../data/NestedDataView";
3
-
4
- export class StructuredInstanceDataAccessor implements StructuredDataAccessor {
5
- instance: any;
6
- dataConfig: any;
7
- useParentStore: any;
8
- dataSelector: any;
9
-
10
- constructor(config: any) {
11
- this.instance = config.instance;
12
- this.dataConfig = config.data;
13
- this.useParentStore = config.useParentStore;
14
- this.dataSelector = getSelector(config.data);
15
- if (this.dataSelector.memoize) this.dataSelector = this.dataSelector.memoize();
16
- }
17
- getSelector() {
18
- return this.dataSelector;
19
- }
20
- get() {
21
- return this.dataSelector.get(this.instance.store.getData());
22
- }
23
- setItem(key: string, value: any): boolean {
24
- return this.instance.nestedDataSet(key, value, this.dataConfig, this.useParentStore);
25
- }
26
- containsKey(key: string) {
27
- return this.dataConfig.hasOwnProperty(key);
28
- }
29
- getKeys() {
30
- return Object.keys(this.dataConfig);
31
- }
32
- }
1
+ import { getSelector } from "../data/getSelector";
2
+ import { StructuredDataAccessor } from "../data/NestedDataView";
3
+
4
+ export class StructuredInstanceDataAccessor implements StructuredDataAccessor {
5
+ instance: any;
6
+ dataConfig: any;
7
+ useParentStore: any;
8
+ dataSelector: any;
9
+
10
+ constructor(config: any) {
11
+ this.instance = config.instance;
12
+ this.dataConfig = config.data;
13
+ this.useParentStore = config.useParentStore;
14
+ this.dataSelector = getSelector(config.data);
15
+ if (this.dataSelector.memoize) this.dataSelector = this.dataSelector.memoize();
16
+ }
17
+ getSelector() {
18
+ return this.dataSelector;
19
+ }
20
+ get() {
21
+ return this.dataSelector.get(this.instance.store.getData());
22
+ }
23
+ setItem(key: string, value: any): boolean {
24
+ return this.instance.nestedDataSet(key, value, this.dataConfig, this.useParentStore);
25
+ }
26
+ containsKey(key: string) {
27
+ return this.dataConfig.hasOwnProperty(key);
28
+ }
29
+ getKeys() {
30
+ return Object.keys(this.dataConfig);
31
+ }
32
+ }
package/src/ui/VDOM.ts CHANGED
@@ -1,34 +1,34 @@
1
- // @ts-expect-error
2
- import { VDOM as vdom } from "cx-react";
3
-
4
- import type * as React from "react";
5
- import type { Component } from "react";
6
- import type {
7
- unstable_batchedUpdates,
8
- render,
9
- findDOMNode,
10
- createPortal,
11
- unstable_renderSubtreeIntoContainer,
12
- hydrate,
13
- unmountComponentAtNode,
14
- } from "react-dom";
15
- import type { createRoot, hydrateRoot, Root } from "react-dom/client";
16
-
17
- export interface VDOMType extends Omit<typeof React, "default"> {
18
- allowRenderOutputCaching?: boolean;
19
- Component: typeof Component;
20
-
21
- DOM: {
22
- unstable_batchedUpdates: typeof unstable_batchedUpdates;
23
- render: typeof render;
24
- findDOMNode: typeof findDOMNode;
25
- createPortal: typeof createPortal;
26
- createRoot: typeof createRoot;
27
- hydrateRoot: typeof hydrateRoot;
28
- hydrate: typeof hydrate;
29
- unmountComponentAtNode: typeof unmountComponentAtNode;
30
- unstable_renderSubtreeIntoContainer: typeof unstable_renderSubtreeIntoContainer;
31
- };
32
- }
33
-
34
- export const VDOM = vdom as VDOMType;
1
+ // @ts-expect-error
2
+ import { VDOM as vdom } from "cx-react";
3
+
4
+ import type * as React from "react";
5
+ import type { Component } from "react";
6
+ import type {
7
+ unstable_batchedUpdates,
8
+ render,
9
+ findDOMNode,
10
+ createPortal,
11
+ unstable_renderSubtreeIntoContainer,
12
+ hydrate,
13
+ unmountComponentAtNode,
14
+ } from "react-dom";
15
+ import type { createRoot, hydrateRoot, Root } from "react-dom/client";
16
+
17
+ export interface VDOMType extends Omit<typeof React, "default"> {
18
+ allowRenderOutputCaching?: boolean;
19
+ Component: typeof Component;
20
+
21
+ DOM: {
22
+ unstable_batchedUpdates: typeof unstable_batchedUpdates;
23
+ render: typeof render;
24
+ findDOMNode: typeof findDOMNode;
25
+ createPortal: typeof createPortal;
26
+ createRoot: typeof createRoot;
27
+ hydrateRoot: typeof hydrateRoot;
28
+ hydrate: typeof hydrate;
29
+ unmountComponentAtNode: typeof unmountComponentAtNode;
30
+ unstable_renderSubtreeIntoContainer: typeof unstable_renderSubtreeIntoContainer;
31
+ };
32
+ }
33
+
34
+ export const VDOM = vdom as VDOMType;
@@ -1,55 +1,55 @@
1
- import { RenderingContext } from "../RenderingContext";
2
- import { Instance } from "../Instance";
3
- import { TreeAdapter } from "./TreeAdapter";
4
- import assert from "assert";
5
- import { Store } from "../../data";
6
- import { ArrayAdapter } from "./ArrayAdapter";
7
-
8
- describe("ArrayAdapter", () => {
9
- it("maps data into records", () => {
10
- let adapter = new ArrayAdapter();
11
- let data = [
12
- {
13
- id: 1,
14
- text: "1",
15
- },
16
- {
17
- id: 2,
18
- text: "2",
19
- },
20
- ];
21
-
22
- let store = new Store();
23
-
24
- let records = adapter.mapRecords(new RenderingContext(), new Instance(null!, "1", null!, store), data, store);
25
-
26
- assert.equal(records.length, 2);
27
- assert.equal(records[0].data, records[0].store.get("$record"));
28
- assert.equal(records[1].data, records[1].store.get("$record"));
29
- });
30
-
31
- it("can sort data", () => {
32
- let adapter = new ArrayAdapter();
33
-
34
- adapter.sort([{ field: "id", direction: "DESC" }]);
35
-
36
- let data = [
37
- {
38
- id: 1,
39
- text: "1",
40
- },
41
- {
42
- id: 2,
43
- text: "2",
44
- },
45
- ];
46
-
47
- let store = new Store();
48
-
49
- let records = adapter.mapRecords(new RenderingContext(), new Instance(null!, "1", null!, store), data, store);
50
-
51
- assert.equal(records.length, 2);
52
- assert.equal(data[1], records[0].store.get("$record"));
53
- assert.equal(data[0], records[1].store.get("$record"));
54
- });
55
- });
1
+ import { RenderingContext } from "../RenderingContext";
2
+ import { Instance } from "../Instance";
3
+ import { TreeAdapter } from "./TreeAdapter";
4
+ import assert from "assert";
5
+ import { Store } from "../../data";
6
+ import { ArrayAdapter } from "./ArrayAdapter";
7
+
8
+ describe("ArrayAdapter", () => {
9
+ it("maps data into records", () => {
10
+ let adapter = new ArrayAdapter();
11
+ let data = [
12
+ {
13
+ id: 1,
14
+ text: "1",
15
+ },
16
+ {
17
+ id: 2,
18
+ text: "2",
19
+ },
20
+ ];
21
+
22
+ let store = new Store();
23
+
24
+ let records = adapter.mapRecords(new RenderingContext(), new Instance(null!, "1", null!, store), data, store);
25
+
26
+ assert.equal(records.length, 2);
27
+ assert.equal(records[0].data, records[0].store.get("$record"));
28
+ assert.equal(records[1].data, records[1].store.get("$record"));
29
+ });
30
+
31
+ it("can sort data", () => {
32
+ let adapter = new ArrayAdapter();
33
+
34
+ adapter.sort([{ field: "id", direction: "DESC" }]);
35
+
36
+ let data = [
37
+ {
38
+ id: 1,
39
+ text: "1",
40
+ },
41
+ {
42
+ id: 2,
43
+ text: "2",
44
+ },
45
+ ];
46
+
47
+ let store = new Store();
48
+
49
+ let records = adapter.mapRecords(new RenderingContext(), new Instance(null!, "1", null!, store), data, store);
50
+
51
+ assert.equal(records.length, 2);
52
+ assert.equal(data[1], records[0].store.get("$record"));
53
+ assert.equal(data[0], records[1].store.get("$record"));
54
+ });
55
+ });