cx 26.1.0 → 26.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/build/ui/Widget.js +0 -5
  2. package/build/util/Component.js +5 -0
  3. package/build/util/test/createTestRenderer.d.ts +3 -1
  4. package/build/util/test/createTestRenderer.js +8 -2
  5. package/build/widgets/icons/calendar.js +4 -3
  6. package/build/widgets/icons/check.js +2 -2
  7. package/build/widgets/icons/clear.js +2 -2
  8. package/build/widgets/icons/close.js +2 -2
  9. package/build/widgets/icons/cx.js +2 -2
  10. package/build/widgets/icons/drop-down.js +2 -2
  11. package/build/widgets/icons/file.js +2 -2
  12. package/build/widgets/icons/folder-open.js +2 -2
  13. package/build/widgets/icons/folder.js +2 -2
  14. package/build/widgets/icons/forward.js +2 -2
  15. package/build/widgets/icons/loading.js +2 -2
  16. package/build/widgets/icons/menu.js +2 -2
  17. package/build/widgets/icons/pixel-picker.js +2 -2
  18. package/build/widgets/icons/search.js +2 -2
  19. package/build/widgets/icons/sort-asc.js +2 -2
  20. package/build/widgets/icons/square.js +2 -2
  21. package/dist/manifest.js +896 -896
  22. package/dist/ui.js +1 -8
  23. package/dist/util.js +4 -0
  24. package/dist/widgets.js +377 -313
  25. package/package.json +3 -1
  26. package/src/core.d.ts +182 -182
  27. package/src/data/ArrayElementView.ts +90 -90
  28. package/src/data/AugmentedViewBase.ts +88 -88
  29. package/src/data/Binding.ts +104 -104
  30. package/src/data/ExposedRecordView.ts +95 -95
  31. package/src/data/ExposedValueView.ts +89 -89
  32. package/src/data/Grouper.spec.ts +57 -57
  33. package/src/data/NestedDataView.ts +43 -43
  34. package/src/data/ReadOnlyDataView.ts +39 -39
  35. package/src/data/Ref.ts +104 -104
  36. package/src/data/Store.ts +52 -52
  37. package/src/data/StoreProxy.ts +19 -19
  38. package/src/data/StoreRef.ts +66 -66
  39. package/src/data/StringTemplate.ts +93 -93
  40. package/src/data/StructuredSelector.spec.ts +113 -113
  41. package/src/data/SubscribableView.ts +63 -63
  42. package/src/data/ZoomIntoPropertyView.ts +45 -45
  43. package/src/data/comparer.ts +78 -78
  44. package/src/data/ops/updateArray.ts +31 -31
  45. package/src/hooks/invokeCallback.spec.tsx +4 -4
  46. package/src/hooks/resolveCallback.spec.tsx +4 -4
  47. package/src/hooks/store.spec.tsx +15 -15
  48. package/src/hooks/useTrigger.spec.tsx +16 -10
  49. package/src/jsx-dev-runtime.ts +4 -4
  50. package/src/jsx-runtime.ts +79 -79
  51. package/src/ui/CSS.ts +87 -87
  52. package/src/ui/ContentResolver.spec.tsx +31 -29
  53. package/src/ui/Controller.spec.tsx +47 -39
  54. package/src/ui/Cx.spec.tsx +10 -8
  55. package/src/ui/DataProxy.spec.tsx +18 -18
  56. package/src/ui/DataProxy.ts +55 -55
  57. package/src/ui/FocusManager.ts +171 -171
  58. package/src/ui/IsolatedScope.spec.tsx +16 -9
  59. package/src/ui/PureContainer.spec.tsx +20 -18
  60. package/src/ui/Repeater.spec.tsx +8 -6
  61. package/src/ui/Rescope.spec.tsx +13 -13
  62. package/src/ui/Rescope.ts +49 -49
  63. package/src/ui/Restate.spec.tsx +31 -27
  64. package/src/ui/VDOM.ts +1 -1
  65. package/src/ui/Widget.tsx +0 -7
  66. package/src/ui/adapter/ArrayAdapter.spec.ts +55 -55
  67. package/src/ui/createFunctionalComponent.spec.tsx +20 -18
  68. package/src/ui/layout/Content.ts +30 -30
  69. package/src/ui/layout/ContentPlaceholder.spec.tsx +46 -34
  70. package/src/ui/layout/FirstVisibleChildLayout.spec.tsx +31 -19
  71. package/src/ui/selection/PropertySelection.ts +87 -87
  72. package/src/util/Component.spec.ts +30 -0
  73. package/src/util/Component.ts +301 -296
  74. package/src/util/DOM.ts +88 -88
  75. package/src/util/Format.spec.ts +69 -69
  76. package/src/util/Format.ts +267 -267
  77. package/src/util/addEventListenerWithOptions.ts +41 -41
  78. package/src/util/browserSupportsPassiveEventHandlers.ts +20 -20
  79. package/src/util/color/rgbToHsl.ts +35 -35
  80. package/src/util/getActiveElement.ts +4 -4
  81. package/src/util/innerTextTrim.ts +10 -10
  82. package/src/util/isDataRecord.ts +5 -5
  83. package/src/util/test/createTestRenderer.tsx +9 -2
  84. package/src/widgets/AccessorBindings.spec.tsx +4 -4
  85. package/src/widgets/HtmlElement.spec.tsx +6 -6
  86. package/src/widgets/ReactElementWrapper.spec.tsx +37 -37
  87. package/src/widgets/Sandbox.ts +103 -103
  88. package/src/widgets/form/ValidationGroup.spec.tsx +12 -12
  89. package/src/widgets/grid/GridCell.ts +143 -143
  90. package/src/widgets/icons/calendar.tsx +22 -17
  91. package/src/widgets/icons/check.tsx +14 -13
  92. package/src/widgets/icons/clear.tsx +16 -15
  93. package/src/widgets/icons/close.tsx +20 -20
  94. package/src/widgets/icons/cx.tsx +39 -38
  95. package/src/widgets/icons/drop-down.tsx +16 -15
  96. package/src/widgets/icons/file.tsx +14 -13
  97. package/src/widgets/icons/folder-open.tsx +16 -15
  98. package/src/widgets/icons/folder.tsx +14 -13
  99. package/src/widgets/icons/forward.tsx +23 -22
  100. package/src/widgets/icons/loading.tsx +25 -24
  101. package/src/widgets/icons/menu.tsx +18 -17
  102. package/src/widgets/icons/pixel-picker.tsx +18 -18
  103. package/src/widgets/icons/search.tsx +14 -13
  104. package/src/widgets/icons/sort-asc.tsx +15 -14
  105. package/src/widgets/icons/square.tsx +19 -18
  106. package/src/widgets/nav/Route.spec.tsx +2 -2
  107. package/src/widgets/nav/Route.ts +142 -142
  108. package/src/widgets/overlay/Dropdown.tsx +762 -762
  109. package/src/widgets/overlay/MsgBox.tsx +141 -141
  110. package/src/widgets/overlay/Toast.ts +111 -111
  111. package/src/widgets/overlay/Window.tsx +299 -299
  112. package/src/widgets/overlay/alerts.ts +46 -46
  113. package/src/widgets/overlay/index.ts +11 -11
package/src/data/Store.ts CHANGED
@@ -1,52 +1,52 @@
1
- import { Binding } from "./Binding";
2
- import { SubscribableView, SubscribableViewConfig } from "./SubscribableView";
3
-
4
- export interface StoreConfig<D = any> extends Omit<SubscribableViewConfig, "store"> {
5
- data?: D;
6
- }
7
-
8
- export class Store<D extends Record<string, any> = any> extends SubscribableView<D> {
9
- data: D;
10
-
11
- constructor(config: StoreConfig<D> = {}) {
12
- super(config);
13
- this.data = config.data ?? ({} as D);
14
- this.meta = {
15
- version: 0,
16
- };
17
- }
18
-
19
- getData(): D {
20
- return this.data;
21
- }
22
-
23
- setItem(path: string, value: any): boolean {
24
- let next = Binding.get(path).set(this.data, value);
25
- if (next != this.data) {
26
- this.data = next;
27
- this.meta.version++;
28
- this.notify(path);
29
- return true;
30
- }
31
- return false;
32
- }
33
-
34
- deleteItem(path: string): boolean {
35
- let next = Binding.get(path).delete(this.data);
36
- if (next != this.data) {
37
- this.data = next;
38
- this.meta.version++;
39
- this.notify(path);
40
- return true;
41
- }
42
- return false;
43
- }
44
-
45
- clear(): void {
46
- this.data = {} as D;
47
- this.meta.version++;
48
- this.notify();
49
- }
50
- }
51
-
52
- Store.prototype.async = false;
1
+ import { Binding } from "./Binding";
2
+ import { SubscribableView, SubscribableViewConfig } from "./SubscribableView";
3
+
4
+ export interface StoreConfig<D = any> extends Omit<SubscribableViewConfig, "store"> {
5
+ data?: D;
6
+ }
7
+
8
+ export class Store<D extends Record<string, any> = any> extends SubscribableView<D> {
9
+ data: D;
10
+
11
+ constructor(config: StoreConfig<D> = {}) {
12
+ super(config);
13
+ this.data = config.data ?? ({} as D);
14
+ this.meta = {
15
+ version: 0,
16
+ };
17
+ }
18
+
19
+ getData(): D {
20
+ return this.data;
21
+ }
22
+
23
+ setItem(path: string, value: any): boolean {
24
+ let next = Binding.get(path).set(this.data, value);
25
+ if (next != this.data) {
26
+ this.data = next;
27
+ this.meta.version++;
28
+ this.notify(path);
29
+ return true;
30
+ }
31
+ return false;
32
+ }
33
+
34
+ deleteItem(path: string): boolean {
35
+ let next = Binding.get(path).delete(this.data);
36
+ if (next != this.data) {
37
+ this.data = next;
38
+ this.meta.version++;
39
+ this.notify(path);
40
+ return true;
41
+ }
42
+ return false;
43
+ }
44
+
45
+ clear(): void {
46
+ this.data = {} as D;
47
+ this.meta.version++;
48
+ this.notify();
49
+ }
50
+ }
51
+
52
+ Store.prototype.async = false;
@@ -1,19 +1,19 @@
1
- import { View } from "./View";
2
-
3
- export class StoreProxy extends View {
4
- declare store: View;
5
-
6
- constructor(getStore: () => View) {
7
- super({
8
- store: getStore(),
9
- });
10
-
11
- Object.defineProperty(this, "store", {
12
- get: getStore,
13
- });
14
- }
15
-
16
- getData(): any {
17
- return this.store.getData();
18
- }
19
- }
1
+ import { View } from "./View";
2
+
3
+ export class StoreProxy extends View {
4
+ declare store: View;
5
+
6
+ constructor(getStore: () => View) {
7
+ super({
8
+ store: getStore(),
9
+ });
10
+
11
+ Object.defineProperty(this, "store", {
12
+ get: getStore,
13
+ });
14
+ }
15
+
16
+ getData(): any {
17
+ return this.store.getData();
18
+ }
19
+ }
@@ -1,66 +1,66 @@
1
- import { isAccessorChain } from "./createAccessorModelProxy";
2
- import { Ref, RefConfig } from "./Ref";
3
- import { View } from "./View";
4
-
5
- interface StoreRefConfig<T> extends RefConfig<T> {
6
- store: View;
7
- path: string;
8
- }
9
-
10
- export class StoreRef<T = any> extends Ref<T> {
11
- declare store: View;
12
- declare path: string;
13
-
14
- constructor(config: StoreRefConfig<T>) {
15
- super(config);
16
- if (isAccessorChain(this.path)) this.path = this.path.toString();
17
- }
18
-
19
- get() {
20
- return this.store.get(this.path);
21
- }
22
-
23
- set(value: T): boolean {
24
- return this.store.set(this.path, value);
25
- }
26
-
27
- init(): void;
28
- init(value: T): boolean;
29
- init(value?: T): boolean | void {
30
- if (value === undefined) return;
31
- return this.store.init(this.path, value);
32
- }
33
-
34
- toggle() {
35
- return this.store.toggle(this.path);
36
- }
37
-
38
- delete() {
39
- return this.store.delete(this.path);
40
- }
41
-
42
- update(cb: (currentValue: T, ...args: any[]) => T, ...args: any[]): boolean {
43
- return this.store.update(this.path, cb, ...args);
44
- }
45
-
46
- //allows the function to be passed as a selector, e.g. to computable or addTrigger
47
- memoize() {
48
- return this.get;
49
- }
50
-
51
- ref<ST = any>(path: string): StoreRef<ST> {
52
- return new StoreRef<ST>({
53
- path: `${this.path}.${path}`,
54
- store: this.store,
55
- });
56
- }
57
-
58
- as(config: RefConfig<T>) {
59
- return StoreRef.create(config, {
60
- path: this.path,
61
- store: this.store,
62
- get: this.get,
63
- set: this.set,
64
- });
65
- }
66
- }
1
+ import { isAccessorChain } from "./createAccessorModelProxy";
2
+ import { Ref, RefConfig } from "./Ref";
3
+ import { View } from "./View";
4
+
5
+ interface StoreRefConfig<T> extends RefConfig<T> {
6
+ store: View;
7
+ path: string;
8
+ }
9
+
10
+ export class StoreRef<T = any> extends Ref<T> {
11
+ declare store: View;
12
+ declare path: string;
13
+
14
+ constructor(config: StoreRefConfig<T>) {
15
+ super(config);
16
+ if (isAccessorChain(this.path)) this.path = this.path.toString();
17
+ }
18
+
19
+ get() {
20
+ return this.store.get(this.path);
21
+ }
22
+
23
+ set(value: T): boolean {
24
+ return this.store.set(this.path, value);
25
+ }
26
+
27
+ init(): void;
28
+ init(value: T): boolean;
29
+ init(value?: T): boolean | void {
30
+ if (value === undefined) return;
31
+ return this.store.init(this.path, value);
32
+ }
33
+
34
+ toggle() {
35
+ return this.store.toggle(this.path);
36
+ }
37
+
38
+ delete() {
39
+ return this.store.delete(this.path);
40
+ }
41
+
42
+ update(cb: (currentValue: T, ...args: any[]) => T, ...args: any[]): boolean {
43
+ return this.store.update(this.path, cb, ...args);
44
+ }
45
+
46
+ //allows the function to be passed as a selector, e.g. to computable or addTrigger
47
+ memoize() {
48
+ return this.get;
49
+ }
50
+
51
+ ref<ST = any>(path: string): StoreRef<ST> {
52
+ return new StoreRef<ST>({
53
+ path: `${this.path}.${path}`,
54
+ store: this.store,
55
+ });
56
+ }
57
+
58
+ as(config: RefConfig<T>) {
59
+ return StoreRef.create(config, {
60
+ path: this.path,
61
+ store: this.store,
62
+ get: this.get,
63
+ set: this.set,
64
+ });
65
+ }
66
+ }
@@ -1,93 +1,93 @@
1
- import { expression } from "./Expression";
2
- import { MemoSelector } from "./Selector";
3
-
4
- import { quoteStr } from "../util/quote";
5
-
6
- function plus(str: string) {
7
- return str.length ? str + " + " : str;
8
- }
9
-
10
- export function stringTemplate(str: string): MemoSelector<string> {
11
- let tplCache = getTplCache();
12
- let cached = tplCache[str];
13
- if (cached) return cached;
14
-
15
- let expr = "";
16
-
17
- let termStart = -1,
18
- quoteStart = 0,
19
- term: string,
20
- bracketsOpen = 0,
21
- percentSign: boolean = false;
22
-
23
- for (let i = 0; i < str.length; i++) {
24
- switch (str[i]) {
25
- case "{":
26
- if (termStart < 0) {
27
- if (str[i + 1] == "{" && str[i - 1] != "%") {
28
- expr = plus(expr) + quoteStr(str.substring(quoteStart, i) + "{");
29
- i++;
30
- quoteStart = i + 1;
31
- } else {
32
- termStart = i + 1;
33
- percentSign = str[i - 1] == "%";
34
- if (i > quoteStart) expr = plus(expr) + quoteStr(str.substring(quoteStart, percentSign ? i - 1 : i));
35
- bracketsOpen = 1;
36
- quoteStart = i; // for the case where the brackets are not closed
37
- }
38
- } else bracketsOpen++;
39
- break;
40
-
41
- case "}":
42
- if (termStart >= 0) {
43
- if (--bracketsOpen == 0) {
44
- term = str.substring(termStart, i);
45
- if (term.indexOf(":") == -1) {
46
- let nullSepIndex = term.indexOf("|");
47
- if (nullSepIndex == -1) term += ":s";
48
- else term = term.substring(0, nullSepIndex) + ":s" + term.substring(nullSepIndex);
49
- }
50
- expr = plus(expr) + (percentSign ? "%{" : "{") + term + "}";
51
- termStart = -1;
52
- quoteStart = i + 1;
53
- bracketsOpen = 0;
54
- }
55
- } else if (str[i + 1] == "}") {
56
- expr = plus(expr) + quoteStr(str.substring(quoteStart, i) + "}");
57
- i++;
58
- quoteStart = i + 1;
59
- }
60
- break;
61
- }
62
- }
63
-
64
- if (quoteStart < str.length || expr.length == 0) expr = plus(expr) + quoteStr(str.substring(quoteStart));
65
-
66
- return (tplCache[str] = expression(expr));
67
- }
68
-
69
- export const StringTemplate = {
70
- get: function (str: string) {
71
- return stringTemplate(str);
72
- },
73
-
74
- compile: function (str: string) {
75
- return stringTemplate(str).memoize();
76
- },
77
-
78
- format: function (format: string, ...args: any[]) {
79
- return stringTemplate(format)(args);
80
- },
81
- };
82
-
83
- let tplCache: Record<string, MemoSelector> = {};
84
-
85
- let getTplCache = () => tplCache;
86
-
87
- export function invalidateStringTemplateCache() {
88
- tplCache = {};
89
- }
90
-
91
- export function setGetStringTemplateCacheCallback(callback: () => Record<string, MemoSelector>) {
92
- getTplCache = callback;
93
- }
1
+ import { expression } from "./Expression";
2
+ import { MemoSelector } from "./Selector";
3
+
4
+ import { quoteStr } from "../util/quote";
5
+
6
+ function plus(str: string) {
7
+ return str.length ? str + " + " : str;
8
+ }
9
+
10
+ export function stringTemplate(str: string): MemoSelector<string> {
11
+ let tplCache = getTplCache();
12
+ let cached = tplCache[str];
13
+ if (cached) return cached;
14
+
15
+ let expr = "";
16
+
17
+ let termStart = -1,
18
+ quoteStart = 0,
19
+ term: string,
20
+ bracketsOpen = 0,
21
+ percentSign: boolean = false;
22
+
23
+ for (let i = 0; i < str.length; i++) {
24
+ switch (str[i]) {
25
+ case "{":
26
+ if (termStart < 0) {
27
+ if (str[i + 1] == "{" && str[i - 1] != "%") {
28
+ expr = plus(expr) + quoteStr(str.substring(quoteStart, i) + "{");
29
+ i++;
30
+ quoteStart = i + 1;
31
+ } else {
32
+ termStart = i + 1;
33
+ percentSign = str[i - 1] == "%";
34
+ if (i > quoteStart) expr = plus(expr) + quoteStr(str.substring(quoteStart, percentSign ? i - 1 : i));
35
+ bracketsOpen = 1;
36
+ quoteStart = i; // for the case where the brackets are not closed
37
+ }
38
+ } else bracketsOpen++;
39
+ break;
40
+
41
+ case "}":
42
+ if (termStart >= 0) {
43
+ if (--bracketsOpen == 0) {
44
+ term = str.substring(termStart, i);
45
+ if (term.indexOf(":") == -1) {
46
+ let nullSepIndex = term.indexOf("|");
47
+ if (nullSepIndex == -1) term += ":s";
48
+ else term = term.substring(0, nullSepIndex) + ":s" + term.substring(nullSepIndex);
49
+ }
50
+ expr = plus(expr) + (percentSign ? "%{" : "{") + term + "}";
51
+ termStart = -1;
52
+ quoteStart = i + 1;
53
+ bracketsOpen = 0;
54
+ }
55
+ } else if (str[i + 1] == "}") {
56
+ expr = plus(expr) + quoteStr(str.substring(quoteStart, i) + "}");
57
+ i++;
58
+ quoteStart = i + 1;
59
+ }
60
+ break;
61
+ }
62
+ }
63
+
64
+ if (quoteStart < str.length || expr.length == 0) expr = plus(expr) + quoteStr(str.substring(quoteStart));
65
+
66
+ return (tplCache[str] = expression(expr));
67
+ }
68
+
69
+ export const StringTemplate = {
70
+ get: function (str: string) {
71
+ return stringTemplate(str);
72
+ },
73
+
74
+ compile: function (str: string) {
75
+ return stringTemplate(str).memoize();
76
+ },
77
+
78
+ format: function (format: string, ...args: any[]) {
79
+ return stringTemplate(format)(args);
80
+ },
81
+ };
82
+
83
+ let tplCache: Record<string, MemoSelector> = {};
84
+
85
+ let getTplCache = () => tplCache;
86
+
87
+ export function invalidateStringTemplateCache() {
88
+ tplCache = {};
89
+ }
90
+
91
+ export function setGetStringTemplateCacheCallback(callback: () => Record<string, MemoSelector>) {
92
+ getTplCache = callback;
93
+ }