cx 26.0.9 → 26.0.11

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 (238) hide show
  1. package/build/jsx-dev-runtime.d.ts +3 -0
  2. package/build/jsx-dev-runtime.js +3 -0
  3. package/build/ui/Controller.d.ts +2 -2
  4. package/build/ui/index.d.ts +2 -1
  5. package/build/ui/index.js +2 -1
  6. package/build.js +133 -133
  7. package/dist/manifest.js +887 -990
  8. package/dist/ui.js +1 -1
  9. package/package.json +4 -4
  10. package/src/jsx-dev-runtime.ts +4 -0
  11. package/src/ui/Controller.ts +2 -2
  12. package/src/ui/index.ts +2 -1
  13. package/src/widgets/HtmlElement.spec.tsx +8 -6
  14. package/build/charts/Bar.scss +0 -29
  15. package/build/charts/BarGraph.scss +0 -29
  16. package/build/charts/BubbleGraph.scss +0 -32
  17. package/build/charts/Column.scss +0 -29
  18. package/build/charts/ColumnGraph.scss +0 -30
  19. package/build/charts/Gridlines.scss +0 -25
  20. package/build/charts/Legend.scss +0 -50
  21. package/build/charts/LegendEntry.scss +0 -29
  22. package/build/charts/LineGraph.scss +0 -25
  23. package/build/charts/Marker.scss +0 -44
  24. package/build/charts/MarkerLine.scss +0 -20
  25. package/build/charts/PieChart.scss +0 -29
  26. package/build/charts/Range.scss +0 -20
  27. package/build/charts/RangeMarker.scss +0 -17
  28. package/build/charts/ScatterGraph.scss +0 -24
  29. package/build/charts/Swimlane.scss +0 -16
  30. package/build/charts/Swimlanes.scss +0 -16
  31. package/build/charts/axis/Axis.scss +0 -23
  32. package/build/charts/axis/CategoryAxis.scss +0 -35
  33. package/build/charts/axis/NumericAxis.scss +0 -35
  34. package/build/charts/axis/TimeAxis.scss +0 -34
  35. package/build/charts/axis/index.scss +0 -5
  36. package/build/charts/axis/variables.scss +0 -3
  37. package/build/charts/index.scss +0 -22
  38. package/build/charts/palette.scss +0 -97
  39. package/build/charts/variables.scss +0 -22
  40. package/build/data/ArrayElementView.spec.d.ts +0 -1
  41. package/build/data/ArrayElementView.spec.js +0 -81
  42. package/build/data/Binding.spec.d.ts +0 -1
  43. package/build/data/Binding.spec.js +0 -61
  44. package/build/data/Expression.spec.d.ts +0 -1
  45. package/build/data/Expression.spec.js +0 -196
  46. package/build/data/Grouper.spec.d.ts +0 -1
  47. package/build/data/Grouper.spec.js +0 -48
  48. package/build/data/Ref.spec.d.ts +0 -1
  49. package/build/data/Ref.spec.js +0 -72
  50. package/build/data/Store.spec.d.ts +0 -1
  51. package/build/data/Store.spec.js +0 -19
  52. package/build/data/StoreRef.spec.d.ts +0 -1
  53. package/build/data/StoreRef.spec.js +0 -22
  54. package/build/data/StringTemplate.spec.d.ts +0 -1
  55. package/build/data/StringTemplate.spec.js +0 -112
  56. package/build/data/StructuredSelector.spec.d.ts +0 -1
  57. package/build/data/StructuredSelector.spec.js +0 -102
  58. package/build/data/View.spec.d.ts +0 -1
  59. package/build/data/View.spec.js +0 -44
  60. package/build/data/ZoomIntoPropertyView.spec.d.ts +0 -1
  61. package/build/data/ZoomIntoPropertyView.spec.js +0 -54
  62. package/build/data/comparer.spec.d.ts +0 -1
  63. package/build/data/comparer.spec.js +0 -50
  64. package/build/data/computable.spec.d.ts +0 -1
  65. package/build/data/computable.spec.js +0 -56
  66. package/build/data/createAccessorModelProxy.spec.d.ts +0 -1
  67. package/build/data/createAccessorModelProxy.spec.js +0 -30
  68. package/build/data/createStructuredSelector.spec.d.ts +0 -1
  69. package/build/data/createStructuredSelector.spec.js +0 -42
  70. package/build/data/diff/diffs.spec.d.ts +0 -1
  71. package/build/data/diff/diffs.spec.js +0 -45
  72. package/build/data/getAccessor.spec.d.ts +0 -1
  73. package/build/data/getAccessor.spec.js +0 -10
  74. package/build/data/getSelector.spec.d.ts +0 -1
  75. package/build/data/getSelector.spec.js +0 -36
  76. package/build/data/ops/append.spec.d.ts +0 -1
  77. package/build/data/ops/append.spec.js +0 -24
  78. package/build/data/ops/filter.spec.d.ts +0 -1
  79. package/build/data/ops/filter.spec.js +0 -25
  80. package/build/data/ops/findTreeNode.spec.d.ts +0 -1
  81. package/build/data/ops/findTreeNode.spec.js +0 -20
  82. package/build/data/ops/merge.spec.d.ts +0 -1
  83. package/build/data/ops/merge.spec.js +0 -23
  84. package/build/data/ops/removeTreeNodes.spec.d.ts +0 -1
  85. package/build/data/ops/removeTreeNodes.spec.js +0 -35
  86. package/build/data/ops/updateArray.spec.d.ts +0 -1
  87. package/build/data/ops/updateArray.spec.js +0 -33
  88. package/build/data/ops/updateTree.spec.d.ts +0 -1
  89. package/build/data/ops/updateTree.spec.js +0 -44
  90. package/build/global.scss +0 -14
  91. package/build/hooks/invokeCallback.spec.d.ts +0 -1
  92. package/build/hooks/invokeCallback.spec.js +0 -44
  93. package/build/hooks/resolveCallback.spec.d.ts +0 -1
  94. package/build/hooks/resolveCallback.spec.js +0 -35
  95. package/build/hooks/store.spec.d.ts +0 -1
  96. package/build/hooks/store.spec.js +0 -48
  97. package/build/hooks/useTrigger.spec.d.ts +0 -1
  98. package/build/hooks/useTrigger.spec.js +0 -59
  99. package/build/index.scss +0 -6
  100. package/build/svg/Svg.scss +0 -28
  101. package/build/svg/index.scss +0 -9
  102. package/build/ui/Controller.spec.d.ts +0 -1
  103. package/build/ui/Controller.spec.js +0 -251
  104. package/build/ui/Cx.spec.d.ts +0 -1
  105. package/build/ui/Cx.spec.js +0 -153
  106. package/build/ui/DataProxy.spec.d.ts +0 -1
  107. package/build/ui/DataProxy.spec.js +0 -208
  108. package/build/ui/IsolatedScope.spec.d.ts +0 -1
  109. package/build/ui/IsolatedScope.spec.js +0 -42
  110. package/build/ui/Repeater.spec.d.ts +0 -1
  111. package/build/ui/Repeater.spec.js +0 -109
  112. package/build/ui/Rescope.spec.d.ts +0 -1
  113. package/build/ui/Rescope.spec.js +0 -134
  114. package/build/ui/Restate.spec.d.ts +0 -1
  115. package/build/ui/Restate.spec.js +0 -257
  116. package/build/ui/adapter/ArrayAdapter.spec.d.ts +0 -1
  117. package/build/ui/adapter/ArrayAdapter.spec.js +0 -44
  118. package/build/ui/adapter/TreeAdapter.spec.d.ts +0 -1
  119. package/build/ui/adapter/TreeAdapter.spec.js +0 -71
  120. package/build/ui/app/Url.spec.d.ts +0 -1
  121. package/build/ui/app/Url.spec.js +0 -43
  122. package/build/ui/createFunctionalComponent.spec.d.ts +0 -1
  123. package/build/ui/createFunctionalComponent.spec.js +0 -272
  124. package/build/ui/index.scss +0 -2
  125. package/build/ui/layout/ContentPlaceholder.spec.d.ts +0 -1
  126. package/build/ui/layout/ContentPlaceholder.spec.js +0 -333
  127. package/build/ui/layout/FirstVisibleChildLayout.spec.d.ts +0 -1
  128. package/build/ui/layout/FirstVisibleChildLayout.spec.js +0 -101
  129. package/build/ui/layout/LabelsLeftLayout.scss +0 -47
  130. package/build/ui/layout/LabelsTopLayout.scss +0 -65
  131. package/build/ui/layout/index.scss +0 -3
  132. package/build/ui/layout/variables.scss +0 -2
  133. package/build/ui/variables.scss +0 -2
  134. package/build/util/Format.spec.d.ts +0 -1
  135. package/build/util/Format.spec.js +0 -58
  136. package/build/util/TraversalStack.spec.d.ts +0 -1
  137. package/build/util/TraversalStack.spec.js +0 -43
  138. package/build/util/call-once.scss +0 -7
  139. package/build/util/date/upperBoundCheck.spec.d.ts +0 -1
  140. package/build/util/date/upperBoundCheck.spec.js +0 -22
  141. package/build/util/getSearchQueryPredicate.spec.d.ts +0 -1
  142. package/build/util/getSearchQueryPredicate.spec.js +0 -33
  143. package/build/util/index.scss +0 -11
  144. package/build/util/isValidIdentifierName.spec.d.ts +0 -1
  145. package/build/util/isValidIdentifierName.spec.js +0 -28
  146. package/build/util/routeAppend.spec.d.ts +0 -1
  147. package/build/util/routeAppend.spec.js +0 -14
  148. package/build/util/scss/add-rules.scss +0 -40
  149. package/build/util/scss/calc.scss +0 -45
  150. package/build/util/scss/call-once.scss +0 -13
  151. package/build/util/scss/clockwise.scss +0 -49
  152. package/build/util/scss/colors.scss +0 -10
  153. package/build/util/scss/deep-get.scss +0 -12
  154. package/build/util/scss/deep-merge.scss +0 -21
  155. package/build/util/scss/divide.scss +0 -3
  156. package/build/util/scss/include.scss +0 -48
  157. package/build/util/scss/index.scss +0 -9
  158. package/build/variables.scss +0 -217
  159. package/build/widgets/AccessorBindings.spec.d.ts +0 -1
  160. package/build/widgets/AccessorBindings.spec.js +0 -40
  161. package/build/widgets/Button.scss +0 -119
  162. package/build/widgets/Button.variables.scss +0 -117
  163. package/build/widgets/CxCredit.scss +0 -39
  164. package/build/widgets/FlexBox.scss +0 -148
  165. package/build/widgets/Heading.scss +0 -40
  166. package/build/widgets/HighlightedSearchText.scss +0 -20
  167. package/build/widgets/HtmlElement.spec.d.ts +0 -1
  168. package/build/widgets/HtmlElement.spec.js +0 -38
  169. package/build/widgets/Icon.scss +0 -22
  170. package/build/widgets/List.scss +0 -93
  171. package/build/widgets/ProgressBar.scss +0 -51
  172. package/build/widgets/Resizer.scss +0 -44
  173. package/build/widgets/Section.scss +0 -56
  174. package/build/widgets/animations.scss +0 -11
  175. package/build/widgets/drag-drop/DragClone.scss +0 -36
  176. package/build/widgets/drag-drop/DragHandle.scss +0 -19
  177. package/build/widgets/drag-drop/DragSource.scss +0 -27
  178. package/build/widgets/drag-drop/DropZone.scss +0 -77
  179. package/build/widgets/drag-drop/index.scss +0 -4
  180. package/build/widgets/drag-drop/variables.scss +0 -15
  181. package/build/widgets/form/Calendar.scss +0 -199
  182. package/build/widgets/form/Calendar.variables.scss +0 -64
  183. package/build/widgets/form/Checkbox.scss +0 -129
  184. package/build/widgets/form/Checkbox.variables.scss +0 -40
  185. package/build/widgets/form/ColorField.scss +0 -98
  186. package/build/widgets/form/ColorPicker.scss +0 -285
  187. package/build/widgets/form/ColorPicker.variables.scss +0 -22
  188. package/build/widgets/form/DateTimeField.scss +0 -92
  189. package/build/widgets/form/DateTimePicker.scss +0 -47
  190. package/build/widgets/form/Field.scss +0 -164
  191. package/build/widgets/form/HelpText.scss +0 -24
  192. package/build/widgets/form/Label.scss +0 -38
  193. package/build/widgets/form/LookupField.scss +0 -221
  194. package/build/widgets/form/MonthField.scss +0 -100
  195. package/build/widgets/form/MonthPicker.scss +0 -125
  196. package/build/widgets/form/NumberField.scss +0 -63
  197. package/build/widgets/form/Radio.scss +0 -123
  198. package/build/widgets/form/Radio.variables.scss +0 -46
  199. package/build/widgets/form/Select.scss +0 -101
  200. package/build/widgets/form/Slider.scss +0 -121
  201. package/build/widgets/form/Switch.scss +0 -142
  202. package/build/widgets/form/TextArea.scss +0 -45
  203. package/build/widgets/form/TextField.scss +0 -57
  204. package/build/widgets/form/UploadButton.scss +0 -49
  205. package/build/widgets/form/ValidationError.scss +0 -23
  206. package/build/widgets/form/ValidationGroup.spec.d.ts +0 -1
  207. package/build/widgets/form/ValidationGroup.spec.js +0 -62
  208. package/build/widgets/form/Wheel.scss +0 -152
  209. package/build/widgets/form/index.scss +0 -24
  210. package/build/widgets/form/variables.scss +0 -355
  211. package/build/widgets/grid/Grid.scss +0 -640
  212. package/build/widgets/grid/Pagination.scss +0 -115
  213. package/build/widgets/grid/TreeNode.scss +0 -90
  214. package/build/widgets/grid/index.scss +0 -4
  215. package/build/widgets/grid/variables.scss +0 -137
  216. package/build/widgets/index.scss +0 -16
  217. package/build/widgets/nav/Link.scss +0 -20
  218. package/build/widgets/nav/Menu.scss +0 -76
  219. package/build/widgets/nav/Menu.variables.scss +0 -25
  220. package/build/widgets/nav/MenuItem.scss +0 -130
  221. package/build/widgets/nav/Route.spec.d.ts +0 -1
  222. package/build/widgets/nav/Route.spec.js +0 -15
  223. package/build/widgets/nav/Scroller.scss +0 -148
  224. package/build/widgets/nav/Tab.scss +0 -82
  225. package/build/widgets/nav/Tab.variables.scss +0 -84
  226. package/build/widgets/nav/cover.scss +0 -22
  227. package/build/widgets/nav/index.scss +0 -6
  228. package/build/widgets/nav/variables.scss +0 -27
  229. package/build/widgets/overlay/Dropdown.scss +0 -186
  230. package/build/widgets/overlay/Overlay.scss +0 -68
  231. package/build/widgets/overlay/Toast.scss +0 -164
  232. package/build/widgets/overlay/Tooltip.scss +0 -177
  233. package/build/widgets/overlay/Window.scss +0 -129
  234. package/build/widgets/overlay/Window.variables.scss +0 -62
  235. package/build/widgets/overlay/captureMouse.scss +0 -13
  236. package/build/widgets/overlay/index.scss +0 -15
  237. package/build/widgets/overlay/variables.scss +0 -85
  238. package/build/widgets/variables.scss +0 -146
@@ -1,19 +0,0 @@
1
- import assert from 'assert';
2
- import { Store } from './Store';
3
- describe('Store', () => {
4
- const getStore = () => {
5
- return new Store({
6
- data: {
7
- a: 3,
8
- item: {
9
- firstName: 'Jack'
10
- }
11
- }
12
- });
13
- };
14
- it('changes version on each update', () => {
15
- let store = getStore();
16
- store.set('a', 4);
17
- assert.equal(store.getMeta().version, 1);
18
- });
19
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,22 +0,0 @@
1
- //@ts-nocheck
2
- import assert from "assert";
3
- import { Store } from "./Store";
4
- const getStore = () => {
5
- return new Store({
6
- data: {
7
- person: {
8
- name: "Jack",
9
- },
10
- },
11
- });
12
- };
13
- describe("StoreRef", () => {
14
- it("can access child refs", () => {
15
- let store = getStore();
16
- let person = store.ref("person");
17
- let name = person.ref("name");
18
- assert.equal(name.get("person"), "Jack");
19
- name.set("John");
20
- assert.equal(name.get("person"), "John");
21
- });
22
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,112 +0,0 @@
1
- import { StringTemplate } from "./StringTemplate";
2
- import assert from "assert";
3
- describe("StringTemplate", function () {
4
- describe("#compile()", function () {
5
- it("returns a selector", function () {
6
- var e = StringTemplate.compile("Hello {person.name}");
7
- var state = {
8
- person: {
9
- name: "Jim",
10
- },
11
- };
12
- assert.equal(e(state), "Hello Jim");
13
- });
14
- it("allows empty strings", function () {
15
- let e = StringTemplate.compile("");
16
- assert.equal(e({}), "");
17
- });
18
- it("properly encodes ' and \"", function () {
19
- var e = StringTemplate.compile('It\'s "working"!');
20
- assert.equal(e({}), 'It\'s "working"!');
21
- });
22
- it("allows \\ before a binding", function () {
23
- var e = StringTemplate.compile("t\\{person.name}");
24
- assert.equal(e({ person: { name: "Ogi" } }), "t\\Ogi");
25
- });
26
- it("supports multi-line strings", function () {
27
- var e = StringTemplate.compile("a\nb");
28
- assert.equal(e({}), "a\nb");
29
- var e = StringTemplate.compile("a\r\nb");
30
- assert.equal(e({}), "a\r\nb");
31
- });
32
- });
33
- describe("double brackets are used to escape brackets", function () {
34
- it("double brackets are preserved", function () {
35
- var e = StringTemplate.compile("Hello {{person.name}}");
36
- var state = {
37
- person: {
38
- name: "Jim",
39
- },
40
- };
41
- assert.equal(e(state), "Hello {person.name}");
42
- });
43
- it("triple brackets are converted to single brackets and a binding", function () {
44
- var e = StringTemplate.compile("Hello {{{person.name}}}");
45
- var state = {
46
- person: {
47
- name: "Jim",
48
- },
49
- };
50
- assert.equal(e(state), "Hello {Jim}");
51
- });
52
- it("open brackets are ignored", function () {
53
- var e = StringTemplate.compile("B { A");
54
- assert.equal(e({}), "B { A");
55
- });
56
- });
57
- describe("supports formatting", function () {
58
- it("with colon", function () {
59
- var e = StringTemplate.compile("{str:suffix;kg}");
60
- assert.equal(e({ str: "5" }), "5kg");
61
- });
62
- it("with multiple formats", function () {
63
- var e = StringTemplate.compile("{str:suffix;kg:wrap;(;)}");
64
- assert.equal(e({ str: "5" }), "(5kg)");
65
- });
66
- it("with null values", function () {
67
- var e = StringTemplate.compile("{str:suffix;kg:|N/A}");
68
- assert.equal(e({ str: null }), "N/A");
69
- });
70
- it("of null values", function () {
71
- var e = StringTemplate.compile("{str|N/A}");
72
- assert.equal(e({ str: null }), "N/A");
73
- });
74
- });
75
- describe("properly handles backslashes", function () {
76
- it("in a string", function () {
77
- var e = StringTemplate.compile("a\\b");
78
- assert.equal(e({}), "a\\b");
79
- });
80
- it("before a special character", function () {
81
- var e = StringTemplate.compile("\\t");
82
- assert.equal(e({}), "\\t");
83
- });
84
- });
85
- describe("supports expressions", function () {
86
- it("using []", function () {
87
- var e = StringTemplate.compile("1 + 2 = {[1+2]}");
88
- assert.equal(e({}), "1 + 2 = 3");
89
- });
90
- it("using %", function () {
91
- var e = StringTemplate.compile("1 + 2 = %{1+2}");
92
- assert.equal(e({}), "1 + 2 = 3");
93
- });
94
- it("with subexpressions", function () {
95
- var e = StringTemplate.compile("1 + 2 = {[%{1+2}]}");
96
- assert.equal(e({}), "1 + 2 = 3");
97
- });
98
- it("with a conditional operator", function () {
99
- var e = StringTemplate.compile("1 + 2 = {[true ? 3 : 2]:s}");
100
- assert.equal(e({}), "1 + 2 = 3");
101
- });
102
- it("with sub-expression formatting", function () {
103
- var e = StringTemplate.compile("{[!!{person.age} ? {person.age:suffix; years old} : 'Age unknown']}");
104
- var state = {
105
- person: {
106
- age: 32,
107
- },
108
- };
109
- assert.equal(e(state), "32 years old");
110
- });
111
- });
112
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,102 +0,0 @@
1
- //@ts-nocheck
2
- import { StructuredSelector } from "./StructuredSelector";
3
- import assert from "assert";
4
- import { createAccessorModelProxy } from "./createAccessorModelProxy";
5
- describe("StructuredSelector", function () {
6
- describe("#create()", function () {
7
- it("constants", function () {
8
- var x = {};
9
- var s = new StructuredSelector({
10
- props: {
11
- a: undefined,
12
- b: undefined,
13
- },
14
- values: {
15
- a: 1,
16
- b: 2,
17
- },
18
- }).create(x);
19
- assert.deepEqual(s(x), { a: 1, b: 2 });
20
- });
21
- it("bindings", function () {
22
- var x = { a: 1, b: 2 };
23
- var s = new StructuredSelector({
24
- props: {
25
- a: undefined,
26
- b: undefined,
27
- },
28
- values: {
29
- a: { bind: "b" },
30
- b: { bind: "a" },
31
- },
32
- }).create(x);
33
- assert.deepEqual(s(x), { a: 2, b: 1 });
34
- });
35
- it("templates", function () {
36
- var x = { a: 1, b: 2 };
37
- var s = new StructuredSelector({
38
- props: {
39
- a: undefined,
40
- b: undefined,
41
- },
42
- values: {
43
- a: { tpl: "b{a}" },
44
- b: { tpl: "a{b}" },
45
- },
46
- }).create(x);
47
- assert.deepEqual(s(x), { a: "b1", b: "a2" });
48
- });
49
- it("structured", function () {
50
- var x = { a: 1, b: 2 };
51
- var s = new StructuredSelector({
52
- props: {
53
- a: {
54
- structured: true,
55
- },
56
- b: undefined,
57
- },
58
- values: {
59
- a: {
60
- x: { expr: "{a} == 1" },
61
- y: { expr: "{b} == 1" },
62
- },
63
- b: { tpl: "a{b}" },
64
- },
65
- }).create(x);
66
- assert.deepEqual(s(x), { a: { x: true, y: false }, b: "a2" });
67
- });
68
- });
69
- it("structures do not change if data doesn't change", function () {
70
- var x = { a: 1, b: 2 };
71
- var s = new StructuredSelector({
72
- props: {
73
- a: {
74
- structured: true,
75
- },
76
- },
77
- values: {
78
- a: {
79
- x: { expr: "{a} == 1" },
80
- y: { expr: "{b} == 1" },
81
- },
82
- b: { tpl: "a{b}" },
83
- },
84
- }).create(x);
85
- let r1 = s(x);
86
- let r2 = s(x);
87
- assert.equal(r1, r2);
88
- });
89
- it("structures do not change if data doesn't change", function () {
90
- var x = { a: { b: 2 } };
91
- var m = createAccessorModelProxy();
92
- var s = new StructuredSelector({
93
- props: {
94
- b: undefined,
95
- },
96
- values: {
97
- b: m.a.b,
98
- },
99
- }).create(x);
100
- assert.deepEqual(s(x), { b: 2 });
101
- });
102
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,44 +0,0 @@
1
- //@ts-nocheck
2
- import assert from 'assert';
3
- import { Store } from './Store';
4
- describe('View', () => {
5
- const getStore = () => {
6
- return new Store({
7
- data: {
8
- a: 3,
9
- item: {
10
- firstName: 'Jack'
11
- }
12
- }
13
- });
14
- };
15
- describe('.get', () => {
16
- it('retrieves a value pointed by a selector path', () => {
17
- let store = getStore();
18
- assert.equal(store.get('item.firstName'), 'Jack');
19
- });
20
- it('will return an array if multiple arguments are passed', () => {
21
- let store = getStore();
22
- assert.deepEqual(store.get('a', 'item.firstName'), [3, 'Jack']);
23
- });
24
- it('will return an array if array is passed', () => {
25
- let store = getStore();
26
- assert.deepEqual(store.get(['a', 'item.firstName']), [3, 'Jack']);
27
- });
28
- });
29
- describe('.set', () => {
30
- it('supports deep selectors', () => {
31
- let store = getStore();
32
- store.set('item.firstName', 'Jill');
33
- assert.equal(store.get('item.firstName'), 'Jill');
34
- });
35
- it('supports setting multiple items through an object', () => {
36
- let store = getStore();
37
- store.set({
38
- 'b': 4,
39
- 'item.firstName': 'Jill'
40
- });
41
- assert.deepEqual(store.get(['b', 'item.firstName']), [4, 'Jill']);
42
- });
43
- });
44
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,54 +0,0 @@
1
- import assert from "assert";
2
- import { Binding } from "./Binding";
3
- import { Store } from "./Store";
4
- import { ZoomIntoPropertyView } from "./ZoomIntoPropertyView";
5
- describe("ZoomIntoPropertyView", () => {
6
- const getZoom = () => {
7
- let store = new Store({
8
- data: {
9
- a: 3,
10
- item: {
11
- firstName: "Jack",
12
- },
13
- },
14
- });
15
- return new ZoomIntoPropertyView({
16
- store: store,
17
- binding: Binding.get("item"),
18
- });
19
- };
20
- it("allows direct access to properties of zoomed object", () => {
21
- let zoom = getZoom();
22
- assert.equal(zoom.get("firstName"), "Jack");
23
- });
24
- it("allows access to outside data through $root", () => {
25
- let zoom = getZoom();
26
- assert.equal(zoom.get("$root.a"), 3);
27
- });
28
- it("correctly sets zoomed object", () => {
29
- let zoom = getZoom();
30
- zoom.set("firstName", "Joe");
31
- assert.equal(zoom.get("firstName"), "Joe");
32
- });
33
- it("correctly sets zoomed values", () => {
34
- let zoom = getZoom();
35
- zoom.set("firstName", "Joe");
36
- assert.equal(zoom.get("firstName"), "Joe");
37
- assert.equal(zoom.get("$root.item.firstName"), "Joe");
38
- });
39
- it("correctly sets outside values", () => {
40
- let zoom = getZoom();
41
- zoom.set("$root.a", 6);
42
- assert.equal(zoom.get("$root.a"), 6);
43
- });
44
- it("correctly deletes zoomed values", () => {
45
- let zoom = getZoom();
46
- zoom.delete("firstName");
47
- assert.equal(zoom.get("firstName"), undefined);
48
- });
49
- it("correctly deletes outside values", () => {
50
- let zoom = getZoom();
51
- zoom.delete("$root.a");
52
- assert.equal(zoom.get("$root.a"), undefined);
53
- });
54
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,50 +0,0 @@
1
- import { sorter } from "./comparer";
2
- import assert from "assert";
3
- describe("comparer", function () {
4
- describe("sorter", function () {
5
- it("orders by numeric values ASC", function () {
6
- let records = [
7
- { value: 3, id: 1 },
8
- { value: -1, id: 2 },
9
- { value: 2, id: 3 },
10
- { value: null, id: 4 },
11
- { value: null, id: 5 },
12
- ];
13
- let sort = sorter([{ value: { bind: "value" }, direction: "ASC" }]);
14
- let sorted = sort(records);
15
- assert.equal(sorted[0].value, -1);
16
- assert.equal(sorted[1].value, 2);
17
- assert.equal(sorted[2].value, 3);
18
- assert.equal(sorted[3].value, null);
19
- assert.equal(sorted[4].value, null);
20
- });
21
- it("orders by numeric values DESC", function () {
22
- let records = [
23
- { value: 3, id: 1 },
24
- { value: 1, id: 2 },
25
- { value: -2, id: 3 },
26
- { value: null, id: 4 },
27
- { value: null, id: 5 },
28
- ];
29
- let sort = sorter([{ value: { bind: "value" }, direction: "DESC" }]);
30
- let sorted = sort(records);
31
- assert.equal(sorted[0].value, 3);
32
- assert.equal(sorted[1].value, 1);
33
- assert.equal(sorted[2].value, -2);
34
- assert.equal(sorted[3].value, null);
35
- assert.equal(sorted[4].value, null);
36
- });
37
- it("supports field", function () {
38
- let records = [
39
- { value: 3, id: 1 },
40
- { value: 1, id: 2 },
41
- { value: 2, id: 3 },
42
- ];
43
- let sort = sorter([{ field: "value", direction: "ASC" }]);
44
- let sorted = sort(records);
45
- assert.equal(sorted[0].value, 1);
46
- assert.equal(sorted[1].value, 2);
47
- assert.equal(sorted[2].value, 3);
48
- });
49
- });
50
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,56 +0,0 @@
1
- import { computable } from "./computable";
2
- import assert from "assert";
3
- import { createAccessorModelProxy } from "./createAccessorModelProxy";
4
- describe("computable", function () {
5
- it("creates a selector", function () {
6
- let state = { person: { name: "Joe" } };
7
- let nameLength = computable("person.name", (name) => name.length);
8
- assert.equal(nameLength(state), 3);
9
- });
10
- it("fires every time if not memoized", function () {
11
- let state = { person: { name: "Joe" } };
12
- let fired = 0;
13
- let nameLength = computable("person.name", (name) => {
14
- fired++;
15
- return name.length;
16
- });
17
- assert.equal(nameLength(state), 3);
18
- assert.equal(nameLength(state), 3);
19
- assert.equal(fired, 2);
20
- });
21
- it("fires once if memoized and data has not changed", function () {
22
- let state = { person: { name: "Joe" } };
23
- let fired = 0;
24
- let nameLength = computable("person.name", (name) => {
25
- fired++;
26
- return name.length;
27
- }).memoize();
28
- assert.equal(nameLength(state), 3);
29
- assert.equal(nameLength(state), 3);
30
- assert.equal(fired, 1);
31
- });
32
- //weird but that's how triggers work and
33
- it("memoize with warmup data will not call compute", function () {
34
- let state = { person: { name: "Joe" } };
35
- let fired = 0;
36
- let nameLength = computable("person.name", (name) => {
37
- fired++;
38
- return name.length;
39
- }).memoize(state);
40
- assert.equal(nameLength(state), undefined);
41
- assert.equal(nameLength(state), undefined);
42
- assert.equal(fired, 0);
43
- });
44
- it("works with accessors", function () {
45
- var m = createAccessorModelProxy();
46
- let state = { person: { name: "Joe" } };
47
- let nameLength = computable(m.person.name, (name) => name.length);
48
- assert.equal(nameLength(state), 3);
49
- });
50
- it("works with array length accessor", function () {
51
- var m = createAccessorModelProxy();
52
- let state = { items: ["a", "b", "c"] };
53
- let itemCount = computable(m.items.length, (length) => length);
54
- assert.equal(itemCount(state), 3);
55
- });
56
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,30 +0,0 @@
1
- import { createAccessorModelProxy } from "./createAccessorModelProxy";
2
- import assert from "assert";
3
- describe("createAccessorModelProxy", () => {
4
- it("generates correct paths", () => {
5
- let model = createAccessorModelProxy();
6
- assert.strictEqual(model.firstName.toString(), "firstName");
7
- assert.strictEqual(model.address.toString(), "address");
8
- assert.strictEqual(model.address.city.toString(), "address.city");
9
- });
10
- it("can be used in string templates", () => {
11
- let model = createAccessorModelProxy();
12
- assert.strictEqual("address.city", `${model.address.city}`);
13
- assert.strictEqual("address.city", "" + model.address.city);
14
- assert.strictEqual("address.city.suffix", model.address.city + ".suffix");
15
- });
16
- it("nameOf returns name of the last prop ", () => {
17
- let model = createAccessorModelProxy();
18
- assert.strictEqual(model.firstName.nameOf(), "firstName");
19
- assert.strictEqual(model.address.nameOf(), "address");
20
- assert.strictEqual(model.address.city.nameOf(), "city");
21
- assert.strictEqual(model.address.nameOf(), "address");
22
- let { streetNumber, city } = model.address;
23
- assert.strictEqual(streetNumber.nameOf(), "streetNumber");
24
- assert.strictEqual(city.nameOf(), "city");
25
- });
26
- it("allows non-standard property identifiers ", () => {
27
- let model = createAccessorModelProxy();
28
- assert.strictEqual(model["@crazy"].nameOf(), "@crazy");
29
- });
30
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,42 +0,0 @@
1
- import { createStructuredSelector } from "./createStructuredSelector";
2
- import assert from "assert";
3
- import { getSelector } from "./getSelector";
4
- import { computable } from "./computable";
5
- describe("createStructuredSelector", function () {
6
- it("works", function () {
7
- let structure = {
8
- name: getSelector({ bind: "name" }),
9
- };
10
- let state = { name: "Joe" };
11
- let selector = createStructuredSelector(structure);
12
- assert.deepEqual(selector(state), { name: "Joe" });
13
- });
14
- it("does not memoize by default", function () {
15
- let computes = 0;
16
- let structure = {
17
- name: computable("name", (name) => {
18
- computes++;
19
- return name;
20
- }),
21
- };
22
- let state = { name: "Joe" };
23
- let selector = createStructuredSelector(structure);
24
- assert.deepEqual(selector(state), { name: "Joe" });
25
- selector(state);
26
- assert.deepEqual(computes, 2);
27
- });
28
- it("supports memoize", function () {
29
- let computes = 0;
30
- let structure = {
31
- name: computable("name", (name) => {
32
- computes++;
33
- return name;
34
- }),
35
- };
36
- let state = { name: "Joe" };
37
- let selector = createStructuredSelector(structure).memoize();
38
- assert.deepEqual(selector(state), { name: "Joe" });
39
- selector(state);
40
- assert.deepEqual(computes, 1);
41
- });
42
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,45 +0,0 @@
1
- //@ts-nocheck
2
- import assert from 'assert';
3
- import { diffArrays } from './diffArrays';
4
- describe('diffArrays', function () {
5
- it('should detect new elements', function () {
6
- var a = [];
7
- var b = [{ k: 1 }, { k: 2 }];
8
- var d = diffArrays(a, b);
9
- assert.deepEqual(d, {
10
- added: [{ k: 1 }, { k: 2 }],
11
- removed: [],
12
- unchanged: [],
13
- changed: []
14
- });
15
- });
16
- it('should detect removed elements', function () {
17
- var a = [];
18
- var b = [{ k: 1 }, { k: 2 }];
19
- var d = diffArrays(b, a);
20
- assert.deepEqual(d, {
21
- removed: [{ k: 1 }, { k: 2 }],
22
- added: [],
23
- unchanged: [],
24
- changed: []
25
- });
26
- });
27
- it('should detect changed elements', function () {
28
- var a = [{ k: 1, v: 2 }];
29
- var b = [{ k: 1 }, { k: 2 }];
30
- var d = diffArrays(a, b, x => x.k);
31
- assert.deepEqual(d, {
32
- added: [{ k: 2 }],
33
- removed: [],
34
- unchanged: [],
35
- changed: [{
36
- after: {
37
- k: 1
38
- },
39
- before: {
40
- k: 1, v: 2
41
- }
42
- }]
43
- });
44
- });
45
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- import assert from "assert";
2
- import { createAccessorModelProxy } from "./createAccessorModelProxy";
3
- import { getAccessor } from "./getAccessor";
4
- describe("getAccessor", function () {
5
- it("works with accessor chains", function () {
6
- let m = createAccessorModelProxy();
7
- let accessor = getAccessor(m.a.b);
8
- assert(typeof accessor.set == "function");
9
- });
10
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,36 +0,0 @@
1
- import { getSelector } from "./getSelector";
2
- import assert from "assert";
3
- import { createAccessorModelProxy } from "./createAccessorModelProxy";
4
- describe("getSelector", function () {
5
- it("array of selectors converts each element into a selector", function () {
6
- let arraySelector = [{ bind: "name" }, { expr: "{name}" }];
7
- let state = { name: "Joe" };
8
- let selector = getSelector(arraySelector);
9
- assert.deepEqual(selector(state), ["Joe", "Joe"]);
10
- });
11
- it("get can be used for selectors that have set defined too ", function () {
12
- let selector = getSelector({ get: (data) => data.name, set: () => { } });
13
- assert.deepEqual(selector({ name: "Jack" }), "Jack");
14
- });
15
- it("0 is a valid selector", function () {
16
- let selector = getSelector(0);
17
- assert.deepEqual(selector({}), 0);
18
- });
19
- it("false is a valid selector", function () {
20
- let selector = getSelector(false);
21
- assert.deepEqual(selector({}), false);
22
- });
23
- it("undefined is a valid selector", function () {
24
- let selector = getSelector(undefined);
25
- assert(selector({}) === undefined);
26
- });
27
- it("null is a valid selector", function () {
28
- let selector = getSelector(null);
29
- assert(selector({}) === null);
30
- });
31
- it("works with accessor chains", function () {
32
- let m = createAccessorModelProxy();
33
- let selector = getSelector(m.a.b);
34
- assert(selector({ a: { b: 1 } }) === 1);
35
- });
36
- });