cx 26.0.4 → 26.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) 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 +6 -2
  5. package/build/ui/app/startAppLoop.d.ts +3 -2
  6. package/build/ui/app/startHotAppLoop.d.ts +3 -2
  7. package/build/ui/layout/ContentPlaceholder.spec.js +12 -12
  8. package/build.js +129 -129
  9. package/dist/manifest.js +844 -844
  10. package/package.json +3 -2
  11. package/src/charts/Chart.ts +108 -108
  12. package/src/data/ArrayElementView.ts +90 -90
  13. package/src/data/AugmentedViewBase.ts +88 -88
  14. package/src/data/Binding.ts +104 -104
  15. package/src/data/ExposedRecordView.ts +95 -95
  16. package/src/data/ExposedValueView.ts +89 -89
  17. package/src/data/Expression.spec.ts +229 -229
  18. package/src/data/Expression.ts +233 -233
  19. package/src/data/Grouper.spec.ts +57 -57
  20. package/src/data/Grouper.ts +158 -158
  21. package/src/data/NestedDataView.ts +43 -43
  22. package/src/data/ReadOnlyDataView.ts +39 -39
  23. package/src/data/Ref.ts +104 -104
  24. package/src/data/Selector.ts +10 -10
  25. package/src/data/Store.ts +52 -52
  26. package/src/data/StoreProxy.ts +19 -19
  27. package/src/data/StoreRef.ts +66 -66
  28. package/src/data/StringTemplate.spec.ts +132 -132
  29. package/src/data/StringTemplate.ts +93 -93
  30. package/src/data/StructuredSelector.spec.ts +113 -113
  31. package/src/data/StructuredSelector.ts +146 -146
  32. package/src/data/SubscribableView.ts +63 -63
  33. package/src/data/ZoomIntoPropertyView.spec.ts +64 -64
  34. package/src/data/ZoomIntoPropertyView.ts +45 -45
  35. package/src/data/computable.spec.ts +62 -62
  36. package/src/data/createAccessorModelProxy.ts +60 -60
  37. package/src/data/createStructuredSelector.ts +62 -62
  38. package/src/data/getAccessor.spec.ts +11 -11
  39. package/src/data/getAccessor.ts +74 -74
  40. package/src/data/getSelector.spec.ts +43 -43
  41. package/src/data/getSelector.ts +66 -66
  42. package/src/data/ops/filter.spec.ts +35 -35
  43. package/src/data/ops/filter.ts +9 -9
  44. package/src/data/ops/merge.ts +13 -13
  45. package/src/data/ops/removeTreeNodes.spec.ts +37 -37
  46. package/src/data/ops/removeTreeNodes.ts +15 -15
  47. package/src/data/ops/updateArray.spec.ts +69 -69
  48. package/src/data/ops/updateArray.ts +31 -31
  49. package/src/data/ops/updateTree.ts +23 -23
  50. package/src/data/test-types.ts +7 -7
  51. package/src/hooks/useTrigger.ts +26 -26
  52. package/src/index.scss +6 -6
  53. package/src/jsx-runtime.ts +72 -72
  54. package/src/svg/BoundedObject.ts +101 -101
  55. package/src/ui/CSSHelper.ts +17 -17
  56. package/src/ui/ContentResolver.ts +124 -124
  57. package/src/ui/Controller.ts +189 -189
  58. package/src/ui/Culture.ts +159 -159
  59. package/src/ui/DataProxy.ts +55 -55
  60. package/src/ui/FocusManager.ts +171 -171
  61. package/src/ui/Instance.ts +868 -868
  62. package/src/ui/RenderingContext.ts +99 -99
  63. package/src/ui/Rescope.ts +49 -49
  64. package/src/ui/StructuredInstanceDataAccessor.ts +32 -32
  65. package/src/ui/VDOM.ts +34 -34
  66. package/src/ui/adapter/ArrayAdapter.spec.ts +55 -55
  67. package/src/ui/adapter/ArrayAdapter.ts +226 -226
  68. package/src/ui/adapter/TreeAdapter.spec.ts +76 -76
  69. package/src/ui/adapter/TreeAdapter.ts +185 -185
  70. package/src/ui/app/History.ts +133 -133
  71. package/src/ui/app/Url.spec.ts +50 -50
  72. package/src/ui/app/startAppLoop.tsx +2 -1
  73. package/src/ui/app/startHotAppLoop.ts +2 -1
  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/drag-drop/ops.tsx +1 -1
  96. package/src/widgets/grid/GridCell.ts +143 -143
  97. package/src/widgets/icons/calendar.tsx +17 -17
  98. package/src/widgets/icons/check.tsx +13 -13
  99. package/src/widgets/icons/clear.tsx +15 -15
  100. package/src/widgets/icons/close.tsx +20 -20
  101. package/src/widgets/icons/cx.tsx +38 -38
  102. package/src/widgets/icons/drop-down.tsx +15 -15
  103. package/src/widgets/icons/file.tsx +13 -13
  104. package/src/widgets/icons/folder-open.tsx +15 -15
  105. package/src/widgets/icons/folder.tsx +13 -13
  106. package/src/widgets/icons/forward.tsx +22 -22
  107. package/src/widgets/icons/loading.tsx +24 -24
  108. package/src/widgets/icons/menu.tsx +17 -17
  109. package/src/widgets/icons/pixel-picker.tsx +18 -18
  110. package/src/widgets/icons/search.tsx +13 -13
  111. package/src/widgets/icons/sort-asc.tsx +14 -14
  112. package/src/widgets/icons/square.tsx +18 -18
  113. package/src/widgets/nav/Route.ts +142 -142
  114. package/src/widgets/overlay/ContextMenu.ts +42 -42
  115. package/src/widgets/overlay/Dropdown.tsx +762 -762
  116. package/src/widgets/overlay/MsgBox.tsx +141 -141
  117. package/src/widgets/overlay/Toast.ts +111 -111
  118. package/src/widgets/overlay/Window.tsx +299 -299
  119. package/src/widgets/overlay/alerts.ts +46 -46
  120. package/src/widgets/overlay/captureMouse.ts +195 -195
  121. package/src/widgets/overlay/createHotPromiseWindowFactory.ts +72 -72
  122. package/src/widgets/overlay/index.d.ts +11 -11
  123. package/src/widgets/overlay/index.ts +11 -11
  124. package/src/widgets/overlay/tooltip-ops.ts +173 -173
  125. package/build/ui/PureContainer.spec.d.ts +0 -1
  126. package/build/ui/PureContainer.spec.js +0 -149
  127. package/dist/manifest.d.ts +0 -1443
package/src/ui/Culture.ts CHANGED
@@ -1,159 +1,159 @@
1
- // @ts-expect-error
2
- import { NumberCulture, DateTimeCulture } from "intl-io";
3
- import { Localization } from "./Localization";
4
- import { GlobalCacheIdentifier } from "../util/GlobalCacheIdentifier";
5
- import { invalidateExpressionCache } from "../data/Expression";
6
- import { invalidateStringTemplateCache } from "../data/StringTemplate";
7
- import { defaultCompare } from "../data/defaultCompare";
8
- import { Console } from "../util/Console";
9
-
10
- export interface CultureInfo {
11
- culture?: string;
12
- numberCulture?: string | null;
13
- dateTimeCulture?: string | null;
14
- defaultCurrency?: string;
15
- dateEncoding?: (date: Date) => string;
16
- timezone?: string | null;
17
- }
18
-
19
- export interface ResolvedCultureInfo {
20
- culture: string;
21
- numberCulture?: string | null;
22
- dateTimeCulture?: string | null;
23
- cache: any;
24
- defaultCurrency: string;
25
- dateEncoding: (date: Date) => string;
26
- timezone?: string | null;
27
- }
28
-
29
- let stack: ResolvedCultureInfo[] = [
30
- {
31
- culture: "en",
32
- numberCulture: null,
33
- dateTimeCulture: null,
34
- cache: {},
35
- defaultCurrency: "USD",
36
- dateEncoding: (date: Date) => date.toISOString(),
37
- timezone: null,
38
- },
39
- ];
40
-
41
- export function getDefaultCulture(): ResolvedCultureInfo {
42
- return stack[0];
43
- }
44
-
45
- export function getCurrentCulture(): ResolvedCultureInfo {
46
- return stack[stack.length - 1];
47
- }
48
-
49
- export function getCurrentCultureCache(): any {
50
- return getCurrentCulture().cache;
51
- }
52
-
53
- export function pushCulture(cultureInfo: ResolvedCultureInfo): void {
54
- stack.push(cultureInfo);
55
- }
56
-
57
- export function createCulture(cultureSpecs: Partial<CultureInfo>): ResolvedCultureInfo {
58
- let current = getCurrentCulture();
59
- let info: ResolvedCultureInfo = {
60
- culture: current.culture,
61
- dateEncoding: current.dateEncoding,
62
- defaultCurrency: current.defaultCurrency,
63
- cache: {},
64
- };
65
- for (let key in cultureSpecs) {
66
- if (!(cultureSpecs as any)[key]) continue;
67
- (info as any)[key] = (cultureSpecs as any)[key];
68
- }
69
- return info;
70
- }
71
-
72
- export function popCulture(cultureSpecs?: CultureInfo): CultureInfo | undefined {
73
- if (stack.length == 1) throw new Error("Cannot pop the last culture object.");
74
- if (cultureSpecs && stack[stack.length - 1] !== cultureSpecs) {
75
- Console.warn("Popped culture object does not match the current one.");
76
- }
77
- return stack.pop();
78
- }
79
-
80
- export class Culture {
81
- static setCulture(cultureCode: string): void {
82
- let cultureSpecs = getDefaultCulture();
83
- cultureSpecs.culture = cultureCode;
84
- cultureSpecs.cache = {};
85
- Localization.setCulture(cultureCode);
86
- this.invalidateCache();
87
- }
88
-
89
- static setNumberCulture(cultureCode: string): void {
90
- let cultureSpecs = getDefaultCulture();
91
- cultureSpecs.numberCulture = cultureCode;
92
- delete cultureSpecs.cache.numberCulture;
93
- this.invalidateCache();
94
- }
95
-
96
- static setDateTimeCulture(cultureCode: string): void {
97
- let cultureSpecs = getDefaultCulture();
98
- cultureSpecs.dateTimeCulture = cultureCode;
99
- delete cultureSpecs.cache.dateTimeCulture;
100
- this.invalidateCache();
101
- }
102
-
103
- static setDefaultCurrency(currencyCode: string): void {
104
- let cultureSpecs = getDefaultCulture();
105
- cultureSpecs.defaultCurrency = currencyCode;
106
- this.invalidateCache();
107
- }
108
-
109
- static setDefaultTimezone(timezone: string): void {
110
- let cultureSpecs = getDefaultCulture();
111
- cultureSpecs.timezone = timezone;
112
- this.invalidateCache();
113
- }
114
-
115
- static setDefaultDateEncoding(encoding: (date: Date) => string): void {
116
- let cultureSpecs = getDefaultCulture();
117
- cultureSpecs.dateEncoding = encoding;
118
- this.invalidateCache();
119
- }
120
-
121
- static invalidateCache(): void {
122
- GlobalCacheIdentifier.change();
123
- invalidateExpressionCache();
124
- invalidateStringTemplateCache();
125
- }
126
-
127
- static get defaultCurrency(): string | undefined {
128
- return getCurrentCulture().defaultCurrency;
129
- }
130
-
131
- static get culture(): string | undefined {
132
- return getCurrentCulture().culture;
133
- }
134
-
135
- static getNumberCulture(): NumberCulture {
136
- let { cache, numberCulture, culture } = getCurrentCulture();
137
- if (!cache!.numberCulture) cache!.numberCulture = new NumberCulture(numberCulture ?? culture);
138
- return cache!.numberCulture;
139
- }
140
-
141
- static getDateTimeCulture(): DateTimeCulture {
142
- let { cache, dateTimeCulture, culture, timezone } = getCurrentCulture();
143
- if (!cache!.dateTimeCulture)
144
- cache!.dateTimeCulture = new DateTimeCulture(dateTimeCulture ?? culture, {
145
- defaultTimezone: timezone,
146
- });
147
- return cache!.dateTimeCulture;
148
- }
149
-
150
- static getDefaultDateEncoding(): (date: Date) => string {
151
- return getCurrentCulture().dateEncoding;
152
- }
153
-
154
- static getComparer(options?: Intl.CollatorOptions): (a: any, b: any) => number {
155
- let { culture } = getCurrentCulture();
156
- if (typeof Intl.Collator != "undefined") return new Intl.Collator(culture, options).compare;
157
- return defaultCompare;
158
- }
159
- }
1
+ // @ts-expect-error
2
+ import { NumberCulture, DateTimeCulture } from "intl-io";
3
+ import { Localization } from "./Localization";
4
+ import { GlobalCacheIdentifier } from "../util/GlobalCacheIdentifier";
5
+ import { invalidateExpressionCache } from "../data/Expression";
6
+ import { invalidateStringTemplateCache } from "../data/StringTemplate";
7
+ import { defaultCompare } from "../data/defaultCompare";
8
+ import { Console } from "../util/Console";
9
+
10
+ export interface CultureInfo {
11
+ culture?: string;
12
+ numberCulture?: string | null;
13
+ dateTimeCulture?: string | null;
14
+ defaultCurrency?: string;
15
+ dateEncoding?: (date: Date) => string;
16
+ timezone?: string | null;
17
+ }
18
+
19
+ export interface ResolvedCultureInfo {
20
+ culture: string;
21
+ numberCulture?: string | null;
22
+ dateTimeCulture?: string | null;
23
+ cache: any;
24
+ defaultCurrency: string;
25
+ dateEncoding: (date: Date) => string;
26
+ timezone?: string | null;
27
+ }
28
+
29
+ let stack: ResolvedCultureInfo[] = [
30
+ {
31
+ culture: "en",
32
+ numberCulture: null,
33
+ dateTimeCulture: null,
34
+ cache: {},
35
+ defaultCurrency: "USD",
36
+ dateEncoding: (date: Date) => date.toISOString(),
37
+ timezone: null,
38
+ },
39
+ ];
40
+
41
+ export function getDefaultCulture(): ResolvedCultureInfo {
42
+ return stack[0];
43
+ }
44
+
45
+ export function getCurrentCulture(): ResolvedCultureInfo {
46
+ return stack[stack.length - 1];
47
+ }
48
+
49
+ export function getCurrentCultureCache(): any {
50
+ return getCurrentCulture().cache;
51
+ }
52
+
53
+ export function pushCulture(cultureInfo: ResolvedCultureInfo): void {
54
+ stack.push(cultureInfo);
55
+ }
56
+
57
+ export function createCulture(cultureSpecs: Partial<CultureInfo>): ResolvedCultureInfo {
58
+ let current = getCurrentCulture();
59
+ let info: ResolvedCultureInfo = {
60
+ culture: current.culture,
61
+ dateEncoding: current.dateEncoding,
62
+ defaultCurrency: current.defaultCurrency,
63
+ cache: {},
64
+ };
65
+ for (let key in cultureSpecs) {
66
+ if (!(cultureSpecs as any)[key]) continue;
67
+ (info as any)[key] = (cultureSpecs as any)[key];
68
+ }
69
+ return info;
70
+ }
71
+
72
+ export function popCulture(cultureSpecs?: CultureInfo): CultureInfo | undefined {
73
+ if (stack.length == 1) throw new Error("Cannot pop the last culture object.");
74
+ if (cultureSpecs && stack[stack.length - 1] !== cultureSpecs) {
75
+ Console.warn("Popped culture object does not match the current one.");
76
+ }
77
+ return stack.pop();
78
+ }
79
+
80
+ export class Culture {
81
+ static setCulture(cultureCode: string): void {
82
+ let cultureSpecs = getDefaultCulture();
83
+ cultureSpecs.culture = cultureCode;
84
+ cultureSpecs.cache = {};
85
+ Localization.setCulture(cultureCode);
86
+ this.invalidateCache();
87
+ }
88
+
89
+ static setNumberCulture(cultureCode: string): void {
90
+ let cultureSpecs = getDefaultCulture();
91
+ cultureSpecs.numberCulture = cultureCode;
92
+ delete cultureSpecs.cache.numberCulture;
93
+ this.invalidateCache();
94
+ }
95
+
96
+ static setDateTimeCulture(cultureCode: string): void {
97
+ let cultureSpecs = getDefaultCulture();
98
+ cultureSpecs.dateTimeCulture = cultureCode;
99
+ delete cultureSpecs.cache.dateTimeCulture;
100
+ this.invalidateCache();
101
+ }
102
+
103
+ static setDefaultCurrency(currencyCode: string): void {
104
+ let cultureSpecs = getDefaultCulture();
105
+ cultureSpecs.defaultCurrency = currencyCode;
106
+ this.invalidateCache();
107
+ }
108
+
109
+ static setDefaultTimezone(timezone: string): void {
110
+ let cultureSpecs = getDefaultCulture();
111
+ cultureSpecs.timezone = timezone;
112
+ this.invalidateCache();
113
+ }
114
+
115
+ static setDefaultDateEncoding(encoding: (date: Date) => string): void {
116
+ let cultureSpecs = getDefaultCulture();
117
+ cultureSpecs.dateEncoding = encoding;
118
+ this.invalidateCache();
119
+ }
120
+
121
+ static invalidateCache(): void {
122
+ GlobalCacheIdentifier.change();
123
+ invalidateExpressionCache();
124
+ invalidateStringTemplateCache();
125
+ }
126
+
127
+ static get defaultCurrency(): string | undefined {
128
+ return getCurrentCulture().defaultCurrency;
129
+ }
130
+
131
+ static get culture(): string | undefined {
132
+ return getCurrentCulture().culture;
133
+ }
134
+
135
+ static getNumberCulture(): NumberCulture {
136
+ let { cache, numberCulture, culture } = getCurrentCulture();
137
+ if (!cache!.numberCulture) cache!.numberCulture = new NumberCulture(numberCulture ?? culture);
138
+ return cache!.numberCulture;
139
+ }
140
+
141
+ static getDateTimeCulture(): DateTimeCulture {
142
+ let { cache, dateTimeCulture, culture, timezone } = getCurrentCulture();
143
+ if (!cache!.dateTimeCulture)
144
+ cache!.dateTimeCulture = new DateTimeCulture(dateTimeCulture ?? culture, {
145
+ defaultTimezone: timezone,
146
+ });
147
+ return cache!.dateTimeCulture;
148
+ }
149
+
150
+ static getDefaultDateEncoding(): (date: Date) => string {
151
+ return getCurrentCulture().dateEncoding;
152
+ }
153
+
154
+ static getComparer(options?: Intl.CollatorOptions): (a: any, b: any) => number {
155
+ let { culture } = getCurrentCulture();
156
+ if (typeof Intl.Collator != "undefined") return new Intl.Collator(culture, options).compare;
157
+ return defaultCompare;
158
+ }
159
+ }
@@ -1,55 +1,55 @@
1
- import { NestedDataView } from "../data/NestedDataView";
2
- import { UseParentLayout } from "../ui/layout/UseParentLayout";
3
- import { PureContainerBase, PureContainerConfig } from "./PureContainer";
4
- import { StructuredInstanceDataAccessor } from "./StructuredInstanceDataAccessor";
5
- import { StructuredProp, Bind } from "./Prop";
6
-
7
- export interface DataProxyConfig extends PureContainerConfig {
8
- /** Data object with computed values to be exposed in the local store. */
9
- data?: StructuredProp;
10
-
11
- /** Binding to a value to be exposed under the `alias` name. */
12
- value?: Bind;
13
-
14
- /** Alias name under which `value` is exposed in the local store. */
15
- alias?: string;
16
-
17
- /** Indicate that parent store data should not be mutated. */
18
- immutable?: boolean;
19
-
20
- /** Indicate that local store data should not be mutated. */
21
- sealed?: boolean;
22
- }
23
-
24
- export class DataProxy extends PureContainerBase<DataProxyConfig> {
25
- declare data?: any;
26
- declare alias?: string;
27
- declare value?: any;
28
- declare immutable: boolean;
29
- declare sealed: boolean;
30
-
31
- init() {
32
- if (!this.data) this.data = {};
33
-
34
- if (this.alias) this.data[this.alias] = this.value;
35
-
36
- super.init();
37
- }
38
-
39
- initInstance(context: any, instance: any) {
40
- instance.store = new NestedDataView({
41
- store: instance.parentStore,
42
- nestedData: new StructuredInstanceDataAccessor({ instance, data: this.data, useParentStore: true }),
43
- immutable: this.immutable,
44
- sealed: this.sealed,
45
- });
46
- super.initInstance(context, instance);
47
- }
48
-
49
- applyParentStore(instance: any) {
50
- instance.store.setStore(instance.parentStore);
51
- }
52
- }
53
-
54
- DataProxy.prototype.immutable = false;
55
- DataProxy.prototype.sealed = false;
1
+ import { NestedDataView } from "../data/NestedDataView";
2
+ import { UseParentLayout } from "../ui/layout/UseParentLayout";
3
+ import { PureContainerBase, PureContainerConfig } from "./PureContainer";
4
+ import { StructuredInstanceDataAccessor } from "./StructuredInstanceDataAccessor";
5
+ import { StructuredProp, Bind } from "./Prop";
6
+
7
+ export interface DataProxyConfig extends PureContainerConfig {
8
+ /** Data object with computed values to be exposed in the local store. */
9
+ data?: StructuredProp;
10
+
11
+ /** Binding to a value to be exposed under the `alias` name. */
12
+ value?: Bind;
13
+
14
+ /** Alias name under which `value` is exposed in the local store. */
15
+ alias?: string;
16
+
17
+ /** Indicate that parent store data should not be mutated. */
18
+ immutable?: boolean;
19
+
20
+ /** Indicate that local store data should not be mutated. */
21
+ sealed?: boolean;
22
+ }
23
+
24
+ export class DataProxy extends PureContainerBase<DataProxyConfig> {
25
+ declare data?: any;
26
+ declare alias?: string;
27
+ declare value?: any;
28
+ declare immutable: boolean;
29
+ declare sealed: boolean;
30
+
31
+ init() {
32
+ if (!this.data) this.data = {};
33
+
34
+ if (this.alias) this.data[this.alias] = this.value;
35
+
36
+ super.init();
37
+ }
38
+
39
+ initInstance(context: any, instance: any) {
40
+ instance.store = new NestedDataView({
41
+ store: instance.parentStore,
42
+ nestedData: new StructuredInstanceDataAccessor({ instance, data: this.data, useParentStore: true }),
43
+ immutable: this.immutable,
44
+ sealed: this.sealed,
45
+ });
46
+ super.initInstance(context, instance);
47
+ }
48
+
49
+ applyParentStore(instance: any) {
50
+ instance.store.setStore(instance.parentStore);
51
+ }
52
+ }
53
+
54
+ DataProxy.prototype.immutable = false;
55
+ DataProxy.prototype.sealed = false;