@componyx/ui 0.0.0-stage → 1.0.3
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.
- package/AppSkin/AppSkin.css +1268 -0
- package/AppSkin/AppSkin.js +2748 -0
- package/AppSkin/Themes/Default.css +241 -0
- package/Base/Base.js +3407 -0
- package/Base/ComponentIcons.css +66 -0
- package/Base/Font/ComponentIcons.woff +0 -0
- package/Base/Font/UI.woff +0 -0
- package/Base/Library.js +8432 -0
- package/Base/NavigationManager.js +462 -0
- package/Base/ResponsiveTemplates.js +371 -0
- package/Base/Sanitizer.js +288 -0
- package/Base/Themes/Default.css +255 -0
- package/Base/UI.css +618 -0
- package/Base/UIResourcePath.js +6 -0
- package/Bindary/Bindary.js +2011 -0
- package/Bindary/Modules/Connection.js +216 -0
- package/Bindary/Modules/Core.js +854 -0
- package/Bindary/Modules/DataUpdater.js +351 -0
- package/Bindary/Modules/ExpressionEngine.js +347 -0
- package/Bindary/Modules/ProxyManager.js +482 -0
- package/Bindary/Modules/Renderer.js +605 -0
- package/Bindary/Modules/Router.js +291 -0
- package/Bindary/Modules/Scroller.js +89 -0
- package/Bindary/Modules/Template.js +1273 -0
- package/BookmarkSpy/BookmarkSpy.js +430 -0
- package/Box/Box.css +36 -0
- package/Box/Box.js +1685 -0
- package/Button/Button.css +470 -0
- package/Button/Button.js +1398 -0
- package/Button/Themes/Default.css +200 -0
- package/Carousel/Carousel.css +273 -0
- package/Carousel/Carousel.js +607 -0
- package/ColorButton/ColorButton.css +39 -0
- package/ColorButton/ColorButton.js +336 -0
- package/ColorPicker/ColorPicker.css +359 -0
- package/ColorPicker/ColorPicker.js +972 -0
- package/ComboBox/ComboBox.css +357 -0
- package/ComboBox/ComboBox.js +2342 -0
- package/ComboBox/Themes/Default.css +23 -0
- package/DataPager/DataPager.css +72 -0
- package/DataPager/DataPager.js +674 -0
- package/DatePicker/DatePicker.css +227 -0
- package/DatePicker/DatePicker.js +1531 -0
- package/DatePicker/Themes/Default.css +26 -0
- package/Dialog/Dialog.css +106 -0
- package/Dialog/Dialog.js +572 -0
- package/Dialog/Themes/Default.css +10 -0
- package/Editor/Data/Emoji.json +8285 -0
- package/Editor/Data/Special.json +1042 -0
- package/Editor/Editor.css +1562 -0
- package/Editor/Editor.js +4058 -0
- package/Editor/Font/Editor.woff +0 -0
- package/Editor/Modules/ComponentFactory.js +565 -0
- package/Editor/Modules/ContentManager.js +748 -0
- package/Editor/Modules/DialogManager.js +1234 -0
- package/Editor/Modules/EventManager.js +458 -0
- package/Editor/Modules/Format.js +950 -0
- package/Editor/Modules/History.js +191 -0
- package/Editor/Modules/LayoutState.js +379 -0
- package/Editor/Modules/ListManager.js +296 -0
- package/Editor/Modules/MenuManager.js +388 -0
- package/Editor/Modules/NodeManager.js +681 -0
- package/Editor/Modules/ParagraphButtons.js +122 -0
- package/Editor/Modules/Resizer.js +176 -0
- package/Editor/Modules/SelectionRange.js +564 -0
- package/Editor/Modules/SourceViewBuilder.js +212 -0
- package/Editor/Modules/SymbolPicker.js +208 -0
- package/Editor/Modules/Table.js +2327 -0
- package/Editor/Modules/TableDialog.js +757 -0
- package/Editor/Modules/Toolbar.js +375 -0
- package/Editor/Modules/TooltipMenu.js +125 -0
- package/Editor/Modules/Utility.js +131 -0
- package/Editor/Themes/Default.css +204 -0
- package/FileUpload/FileUpload.css +156 -0
- package/FileUpload/FileUpload.js +898 -0
- package/FileUpload/Themes/Default.css +17 -0
- package/Form/Form.css +1934 -0
- package/Form/Form.js +4943 -0
- package/Form/Modules/ActionManager.js +368 -0
- package/Form/Modules/BuildPanelManager.js +319 -0
- package/Form/Modules/ComponentFactory.js +468 -0
- package/Form/Modules/ComponentPanel.js +265 -0
- package/Form/Modules/ConfigPanelManager.js +685 -0
- package/Form/Modules/DataObserver.js +717 -0
- package/Form/Modules/Databinder.js +602 -0
- package/Form/Modules/Draggable.js +756 -0
- package/Form/Modules/OptionsPanel.js +342 -0
- package/Form/Modules/Renderer.js +1889 -0
- package/Form/Modules/RuleEngine.js +585 -0
- package/Form/Modules/RulesPanel.js +1158 -0
- package/Form/Modules/Types.js +1709 -0
- package/Form/Modules/ValidationManager.js +194 -0
- package/Form/Themes/Default.css +216 -0
- package/FormField/FormField.css +468 -0
- package/FormField/FormField.js +576 -0
- package/FormField/Themes/Default.css +99 -0
- package/Grid/Grid.css +544 -0
- package/Grid/Grid.js +3761 -0
- package/Grid/Themes/Default.css +43 -0
- package/LICENSE +126 -0
- package/MaskedTextBox/MaskedTextBox.css +28 -0
- package/MaskedTextBox/MaskedTextBox.js +642 -0
- package/MaskedTextBox/Themes/Default.css +6 -0
- package/Menu/Menu.css +328 -0
- package/Menu/Menu.js +2386 -0
- package/Menu/Themes/Default.css +24 -0
- package/NumericBox/NumericBox.css +120 -0
- package/NumericBox/NumericBox.js +984 -0
- package/PanelBar/PanelBar.css +123 -0
- package/PanelBar/PanelBar.js +505 -0
- package/PanelBar/Themes/Default.css +51 -0
- package/PieChart/PieChart.css +95 -0
- package/PieChart/PieChart.js +820 -0
- package/PieChart/Themes/Default.css +9 -0
- package/README.md +178 -3
- package/Slider/Slider.css +348 -0
- package/Slider/Slider.js +1306 -0
- package/Slider/Themes/Default.css +44 -0
- package/TabStrip/TabStrip.css +52 -0
- package/TabStrip/TabStrip.js +362 -0
- package/TabStrip/Themes/Default.css +35 -0
- package/TimePicker/Themes/Default.css +30 -0
- package/TimePicker/TimePicker.css +253 -0
- package/TimePicker/TimePicker.js +1485 -0
- package/TooltipManager/Themes/Default.css +21 -0
- package/TooltipManager/TooltipManager.css +227 -0
- package/TooltipManager/TooltipManager.js +791 -0
- package/Validator/Validator.css +54 -0
- package/Validator/Validator.js +2508 -0
- package/componyx.html-data.json +619 -0
- package/index.js +27 -0
- package/package.json +43 -4
- package/types/AppSkin.d.ts +842 -0
- package/types/Base.d.ts +1034 -0
- package/types/Bindary.d.ts +1196 -0
- package/types/BookmarkSpy.d.ts +112 -0
- package/types/Box.d.ts +374 -0
- package/types/Button.d.ts +455 -0
- package/types/Carousel.d.ts +136 -0
- package/types/ColorButton.d.ts +120 -0
- package/types/ColorPicker.d.ts +225 -0
- package/types/ComboBox.d.ts +507 -0
- package/types/DataPager.d.ts +152 -0
- package/types/DatePicker.d.ts +354 -0
- package/types/Dialog.d.ts +160 -0
- package/types/Editor.d.ts +1289 -0
- package/types/FileUpload.d.ts +206 -0
- package/types/Form.d.ts +3078 -0
- package/types/FormField.d.ts +204 -0
- package/types/Grid.d.ts +911 -0
- package/types/Library.d.ts +1899 -0
- package/types/MaskedTextBox.d.ts +91 -0
- package/types/Menu.d.ts +577 -0
- package/types/NumericBox.d.ts +310 -0
- package/types/PanelBar.d.ts +223 -0
- package/types/PieChart.d.ts +224 -0
- package/types/ResponsiveTemplates.d.ts +108 -0
- package/types/Slider.d.ts +227 -0
- package/types/TabStrip.d.ts +185 -0
- package/types/TimePicker.d.ts +265 -0
- package/types/TooltipManager.d.ts +178 -0
- package/types/UI.d.ts +29 -0
- package/types/Validator.d.ts +653 -0
- package/types/index.d.ts +59 -0
- package/ui.css +11783 -0
- package/ui.js +79477 -0
- package/ui.min.css +138 -0
- package/ui.min.js +264 -0
- package/ui.min.js.map +1 -0
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
/*! Componyx.UI | (c) E.H. Daanen / Componyx | BUSL-1.1 | componyx.com/license */
|
|
2
|
+
await (async function ()
|
|
3
|
+
{
|
|
4
|
+
await import(`${$UI.getScriptResourcePath('Base.Bindary.Core')}`);
|
|
5
|
+
const core = componyx.bindary_modules.core;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @namespace proxyManager
|
|
9
|
+
* @protected
|
|
10
|
+
*/
|
|
11
|
+
const proxyManager = componyx.bindary_modules.proxyManager =
|
|
12
|
+
{
|
|
13
|
+
/**
|
|
14
|
+
* WeakMap mapping the original value to a Map of dataKey->proxy.
|
|
15
|
+
* @type {WeakMap<Object, Map<string, Object>>}
|
|
16
|
+
* @protected
|
|
17
|
+
*/
|
|
18
|
+
proxyMap: new WeakMap(),
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* WeakMap mapping proxy objects to a Set of dataKey paths.
|
|
22
|
+
* @type {WeakMap<Object, Set<string>>}
|
|
23
|
+
* @protected
|
|
24
|
+
*/
|
|
25
|
+
proxyDataKeys: new WeakMap(),
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Symbol to store the original target value on a proxy.
|
|
29
|
+
* @type {Symbol}
|
|
30
|
+
* @protected
|
|
31
|
+
*/
|
|
32
|
+
targetSymbol: Symbol('target'),
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Determines if the given object is a proxy managed by proxyManager.
|
|
36
|
+
* @param {Object} proxy - The object to test.
|
|
37
|
+
* @returns {boolean} True if the object is a proxy, false otherwise.
|
|
38
|
+
*/
|
|
39
|
+
isProxy(proxy)
|
|
40
|
+
{
|
|
41
|
+
return !!(proxy && proxy[proxyManager.targetSymbol]);
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Gets the original target object behind a proxy.
|
|
46
|
+
* @param {Object} proxy - The proxy object.
|
|
47
|
+
* @returns {Object|null} The underlying target object, or null if none.
|
|
48
|
+
*/
|
|
49
|
+
getTarget(proxy)
|
|
50
|
+
{
|
|
51
|
+
return proxy ? proxy[proxyManager.targetSymbol] : null;
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @protected
|
|
56
|
+
* Handles invoking data change events for a target and its additional dataKey paths.
|
|
57
|
+
*
|
|
58
|
+
* @param {Object} target - The parent object on which data changed.
|
|
59
|
+
* @param {Object} value - The new value (may be a proxy). When item is deleted, this value is undefined.
|
|
60
|
+
* @param {Object} oldValue - The old value (may be a proxy).
|
|
61
|
+
* @param {string} dataKey - The primary data key for the change.
|
|
62
|
+
* @param {Object} data - Additional data (e.g. keys info).
|
|
63
|
+
* @param {Object} settings - Settings for the change event.
|
|
64
|
+
* @param {string[]} additionalDataKeys - Extra dataKey paths to trigger change events for based on the target, which may be added to if the value is a proxy with associated dataKeys.
|
|
65
|
+
*/
|
|
66
|
+
handleDataChange(target, value, oldValue, dataKey, data, settings, additionalDataKeys = [])
|
|
67
|
+
{
|
|
68
|
+
let checkValue = (value === undefined && data && data.removeCount) ? oldValue : value;
|
|
69
|
+
|
|
70
|
+
if (checkValue && proxyManager.isProxy(checkValue)) // check if there are additional dataKeys associated with the proxy.
|
|
71
|
+
{
|
|
72
|
+
let dataKeysSet = proxyManager.proxyDataKeys.get(checkValue) || new Set(),
|
|
73
|
+
dataKeys = Array.from(dataKeysSet);
|
|
74
|
+
|
|
75
|
+
additionalDataKeys.push(...dataKeys.filter(k => k !== dataKey && !additionalDataKeys.includes(k))); // filter out the current dataKey and any extraDataKeys to avoid duplicates
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
proxyManager.setDataChange(dataKey, data, target, value, oldValue, additionalDataKeys, settings);
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @protected
|
|
83
|
+
* Fires a data change event for the given binding path.
|
|
84
|
+
*
|
|
85
|
+
* @param {string} dataKey - The primary data key.
|
|
86
|
+
* @param {Object} data - Additional change data.
|
|
87
|
+
* @param {Object} target - The parent object where the change occurred.
|
|
88
|
+
* @param {Object} value - The new value that was set or undefined if the object key was removed.
|
|
89
|
+
* @param {Object} oldValue - The old value.
|
|
90
|
+
* @param {string[]} additionalDataKeys - Additional dataKey paths to update.
|
|
91
|
+
* @param {Object} [settings={}] - Settings for the data change (e.g., event).
|
|
92
|
+
*/
|
|
93
|
+
setDataChange(dataKey, data, target, value, oldValue, additionalDataKeys, settings = {})
|
|
94
|
+
{
|
|
95
|
+
if (!dataKey)
|
|
96
|
+
return;
|
|
97
|
+
|
|
98
|
+
let viewTree = settings.viewTree,
|
|
99
|
+
event = (typeof settings.createEvent === 'function') ? settings.createEvent() : settings.event,
|
|
100
|
+
containerKey = dataKey.split('.').slice(0, -1).join('.'),
|
|
101
|
+
targetProxy = proxyManager.proxyMap.get(target)?.get(containerKey);
|
|
102
|
+
|
|
103
|
+
if (viewTree)
|
|
104
|
+
{
|
|
105
|
+
$lib.each(settings.treeState, (state, index) =>
|
|
106
|
+
{
|
|
107
|
+
viewTree[index].restoreContext(state);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (event)
|
|
112
|
+
{
|
|
113
|
+
let element = settings.element || document,
|
|
114
|
+
detail = event.detail;
|
|
115
|
+
|
|
116
|
+
if (detail)
|
|
117
|
+
{
|
|
118
|
+
Object.assign(detail, {
|
|
119
|
+
dataKey,
|
|
120
|
+
additionalDataKeys,
|
|
121
|
+
target,
|
|
122
|
+
targetProxy,
|
|
123
|
+
eventPayload: settings.eventPayload,
|
|
124
|
+
data,
|
|
125
|
+
value,
|
|
126
|
+
oldValue
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
let canceled = !element.dispatchEvent(event);
|
|
131
|
+
if (canceled)
|
|
132
|
+
{
|
|
133
|
+
core.observed = true; // event is deliberately canceled, so set observed to true, otherwise it will still trigger a data change in the dataBind event handler
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (detail.viewTree)
|
|
138
|
+
viewTree = detail.viewTree;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (data && $lib.isArray(target)) // for an array the data will hold the info about the key/index
|
|
142
|
+
{
|
|
143
|
+
let k = dataKey.split('.');
|
|
144
|
+
k.pop();
|
|
145
|
+
dataKey = k.join('.');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
core.observed = true;
|
|
149
|
+
$bindary.dataChange(dataKey, null, data, false);
|
|
150
|
+
|
|
151
|
+
if (additionalDataKeys.length > 0)
|
|
152
|
+
{
|
|
153
|
+
additionalDataKeys.forEach(dataKey => $bindary.dataChange(dataKey, null, data, false));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (core.autoUpdateView && $bindary.autoUpdateView)
|
|
157
|
+
{
|
|
158
|
+
$bindary.updateViewDelayed(false, null, viewTree);
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @protected
|
|
164
|
+
* Composes a data key string by appending a property name to an existing data key.
|
|
165
|
+
* @param {string} dataKey - The base data key.
|
|
166
|
+
* @param {string} name - The property name to append.
|
|
167
|
+
* @param {boolean} isArray - True if the parent is an array.
|
|
168
|
+
* @returns {string|undefined} The composed data key, or undefined for invalid array names.
|
|
169
|
+
*/
|
|
170
|
+
getKey(dataKey, name, isArray)
|
|
171
|
+
{
|
|
172
|
+
if (isArray && window.isNaN(name))
|
|
173
|
+
return;
|
|
174
|
+
|
|
175
|
+
return $lib.format('{0}{1}{2}', dataKey || '', dataKey ? '.' : '', name || '');
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* @protected
|
|
180
|
+
* Creates a proxy for the given value (if valid) based on the provided dataKey.
|
|
181
|
+
* If reuseProxy is enabled (default) and a proxy already exists for this value, it reuses it and adds the new dataKey path.
|
|
182
|
+
* @param {Object} value - The value to proxy.
|
|
183
|
+
* @param {string} dataKey - The binding path for the value.
|
|
184
|
+
* @param {Object} settings - Settings to apply to the proxy.
|
|
185
|
+
* @returns {Object} The proxy object representing the value.
|
|
186
|
+
*/
|
|
187
|
+
createProxy(value, dataKey, settings)
|
|
188
|
+
{
|
|
189
|
+
if (!proxyManager.isValidProxyObject(value))
|
|
190
|
+
return value;
|
|
191
|
+
|
|
192
|
+
if (value[proxyManager.targetSymbol])
|
|
193
|
+
value = value[proxyManager.targetSymbol];
|
|
194
|
+
|
|
195
|
+
let entry = proxyManager.proxyMap.get(value),
|
|
196
|
+
storageKey = (settings?.reuseProxy === false) ? ('!' + dataKey) : dataKey; // use unique key to store non-reusable proxy in case a proxy already exists for the data-key
|
|
197
|
+
|
|
198
|
+
if (!entry)
|
|
199
|
+
{
|
|
200
|
+
entry = new Map();
|
|
201
|
+
proxyManager.proxyMap.set(value, entry);
|
|
202
|
+
}
|
|
203
|
+
else if (entry.size > 0 && settings?.reuseProxy !== false)
|
|
204
|
+
{
|
|
205
|
+
let proxy = entry.values().next().value,
|
|
206
|
+
paths = proxyManager.proxyDataKeys.get(proxy);
|
|
207
|
+
|
|
208
|
+
if (!paths)
|
|
209
|
+
{
|
|
210
|
+
paths = new Set();
|
|
211
|
+
proxyManager.proxyDataKeys.set(proxy, paths);
|
|
212
|
+
}
|
|
213
|
+
paths.add(dataKey);
|
|
214
|
+
|
|
215
|
+
return proxy;
|
|
216
|
+
|
|
217
|
+
}
|
|
218
|
+
else if (entry.has(storageKey))
|
|
219
|
+
{
|
|
220
|
+
return entry.get(storageKey);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
let handler = Object.create(proxyManager.proxyHandler),
|
|
224
|
+
proxy = (handler.proxy = new Proxy(value, handler));
|
|
225
|
+
|
|
226
|
+
handler.settings = settings;
|
|
227
|
+
handler.dataKey = dataKey;
|
|
228
|
+
proxy[proxyManager.targetSymbol] = value;
|
|
229
|
+
|
|
230
|
+
entry.set(storageKey, proxy);
|
|
231
|
+
proxyManager.proxyDataKeys.set(proxy, new Set([dataKey]));
|
|
232
|
+
return proxy;
|
|
233
|
+
},
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* @protected
|
|
237
|
+
* Checks whether the provided object is valid for proxying (i.e., a plain object or array).
|
|
238
|
+
* @param {Object} obj - The object to check.
|
|
239
|
+
* @returns {boolean} True if the object is valid for proxying, false otherwise.
|
|
240
|
+
*/
|
|
241
|
+
isValidProxyObject(obj)
|
|
242
|
+
{
|
|
243
|
+
return obj != null && ($lib.isPlainObject(obj) || $lib.isArray(obj));
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* @protected
|
|
248
|
+
* The proxy handler that defines traps for get, set, defineProperty, and deleteProperty.
|
|
249
|
+
* @type {Object}
|
|
250
|
+
*/
|
|
251
|
+
proxyHandler: {
|
|
252
|
+
/**
|
|
253
|
+
* @protected
|
|
254
|
+
* The proxy instance managed by this handler.
|
|
255
|
+
* @type {Object}
|
|
256
|
+
*/
|
|
257
|
+
proxy: null,
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* @protected
|
|
261
|
+
* The current dataKey for this proxy context.
|
|
262
|
+
* @type {string}
|
|
263
|
+
*/
|
|
264
|
+
dataKey: null,
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* @protected
|
|
268
|
+
* The settings passed to this proxy.
|
|
269
|
+
* @type {Object}
|
|
270
|
+
*/
|
|
271
|
+
settings: null,
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Trap for property access.
|
|
275
|
+
* @param {Object} target - The original target object.
|
|
276
|
+
* @param {string|symbol} key - The property key being accessed.
|
|
277
|
+
* @returns {*} The value of the property, potentially proxied.
|
|
278
|
+
* @protected
|
|
279
|
+
*/
|
|
280
|
+
get(target, key)
|
|
281
|
+
{
|
|
282
|
+
if (typeof key === 'symbol')
|
|
283
|
+
return target[key];
|
|
284
|
+
|
|
285
|
+
if (key === 'prototype')
|
|
286
|
+
return Object.getPrototypeOf(target);
|
|
287
|
+
|
|
288
|
+
if (key in target)
|
|
289
|
+
{
|
|
290
|
+
let dataKey = proxyManager.getKey(this.dataKey, key),
|
|
291
|
+
obj = target[key],
|
|
292
|
+
f = 'function';
|
|
293
|
+
|
|
294
|
+
if (proxyManager.isValidProxyObject(obj))
|
|
295
|
+
{
|
|
296
|
+
const proxy = proxyManager.createProxy(obj, dataKey, this.settings),
|
|
297
|
+
parentPaths = proxyManager.proxyDataKeys.get(this.proxy);
|
|
298
|
+
|
|
299
|
+
if (parentPaths && parentPaths.size > 1)
|
|
300
|
+
{
|
|
301
|
+
const childPaths = proxyManager.proxyDataKeys.get(proxy);
|
|
302
|
+
if (childPaths)
|
|
303
|
+
{
|
|
304
|
+
// Circular reference check: if any childPath is a prefix of any parentPath, the object we just accessed is already an ancestor in the chain → skip propagation.
|
|
305
|
+
// e.g. childPath='form.fieldSets.0', parentPath='form.fieldSets.0.fields.0', 'form.fieldSets.0.fields.0'.startsWith('form.fieldSets.0.') → true → circular
|
|
306
|
+
const isCircular = Array.from(childPaths).some(childPath =>
|
|
307
|
+
Array.from(parentPaths).some(parentPath =>
|
|
308
|
+
parentPath.startsWith(childPath + '.')
|
|
309
|
+
)
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
if (!isCircular)
|
|
313
|
+
{
|
|
314
|
+
// Safely propagate alternate parent paths down to this child proxy. Only runs when the parent has more than one known path (i.e. an alias exists).
|
|
315
|
+
parentPaths.forEach(parentPath =>
|
|
316
|
+
{
|
|
317
|
+
if (parentPath !== this.dataKey)
|
|
318
|
+
{
|
|
319
|
+
const altPath = proxyManager.getKey(parentPath, key);
|
|
320
|
+
if (altPath) childPaths.add(altPath);
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (Reflect.set(target, key, proxy))
|
|
328
|
+
{
|
|
329
|
+
return proxy; // Successfully set
|
|
330
|
+
}
|
|
331
|
+
else
|
|
332
|
+
{
|
|
333
|
+
return obj; // Read-only, return original
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
else if (!$lib.isArray(target) && typeof obj == f && typeof target != f && !(obj.prototype && obj.prototype.constructor === obj))
|
|
337
|
+
{
|
|
338
|
+
return obj.bind(target);
|
|
339
|
+
}
|
|
340
|
+
else
|
|
341
|
+
{
|
|
342
|
+
return obj;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return undefined;
|
|
346
|
+
},
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Trap for property assignment.
|
|
350
|
+
* @param {Object} target - The original target object.
|
|
351
|
+
* @param {string|symbol} key - The property key being set.
|
|
352
|
+
* @param {*} value - The new value.
|
|
353
|
+
* @returns {boolean} True if the property was set successfully.
|
|
354
|
+
* @protected
|
|
355
|
+
*/
|
|
356
|
+
set(target, key, value)
|
|
357
|
+
{
|
|
358
|
+
let isArray = $lib.isArray(target),
|
|
359
|
+
dataKey = (typeof key !== 'symbol') ? proxyManager.getKey(this.dataKey, key, isArray) : undefined,
|
|
360
|
+
oldValue = target[key],
|
|
361
|
+
hadValue = Object.prototype.hasOwnProperty.call(target, key),
|
|
362
|
+
change = target[key] !== value,
|
|
363
|
+
trackChange = ((!core.busy || $bindary.observeDuringRender) && core.observing),
|
|
364
|
+
settings = this.settings;
|
|
365
|
+
|
|
366
|
+
if (typeof key === 'symbol')
|
|
367
|
+
{
|
|
368
|
+
return Reflect.set(target, key, value);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// Evict the stale dataKey from the old value's path set before overwriting
|
|
372
|
+
if (hadValue && change && dataKey && proxyManager.isProxy(oldValue))
|
|
373
|
+
{
|
|
374
|
+
let paths = proxyManager.proxyDataKeys.get(oldValue);
|
|
375
|
+
if (paths)
|
|
376
|
+
{
|
|
377
|
+
paths.delete(dataKey);
|
|
378
|
+
if (paths.size === 0)
|
|
379
|
+
proxyManager.proxyDataKeys.delete(oldValue);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
value = proxyManager.createProxy(value, dataKey, settings);
|
|
384
|
+
const success = Reflect.set(target, key, value);
|
|
385
|
+
|
|
386
|
+
if (success && dataKey && trackChange && change)
|
|
387
|
+
{
|
|
388
|
+
let allDataKeys = Array.from(proxyManager.proxyDataKeys.get(this.proxy) || [this.dataKey]),
|
|
389
|
+
targetExtraDataKeys = allDataKeys
|
|
390
|
+
.filter(dk => dk !== this.dataKey)
|
|
391
|
+
.map(dk => proxyManager.getKey(dk, key, isArray))
|
|
392
|
+
.filter(Boolean);
|
|
393
|
+
|
|
394
|
+
proxyManager.handleDataChange(
|
|
395
|
+
target,
|
|
396
|
+
value,
|
|
397
|
+
oldValue,
|
|
398
|
+
dataKey,
|
|
399
|
+
isArray ? { keys: [key], hadValue } : { hadValue },
|
|
400
|
+
settings,
|
|
401
|
+
targetExtraDataKeys
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
return success;
|
|
406
|
+
},
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Trap for defining a property.
|
|
410
|
+
* @param {Object} target - The original target object.
|
|
411
|
+
* @param {string|symbol} key - The property key.
|
|
412
|
+
* @param {PropertyDescriptor} descriptor - The property descriptor.
|
|
413
|
+
* @returns {boolean} True if the property was defined successfully.
|
|
414
|
+
* @protected
|
|
415
|
+
*/
|
|
416
|
+
defineProperty(target, key, descriptor)
|
|
417
|
+
{
|
|
418
|
+
if (descriptor && descriptor.value !== undefined)
|
|
419
|
+
{
|
|
420
|
+
this.set(target, key, descriptor.value);
|
|
421
|
+
}
|
|
422
|
+
return Reflect.defineProperty(target, key, descriptor);
|
|
423
|
+
},
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Trap for deleting a property.
|
|
427
|
+
* @param {Object} target - The original target object.
|
|
428
|
+
* @param {string|symbol} key - The property key to delete.
|
|
429
|
+
* @returns {boolean} True if the property was deleted successfully.
|
|
430
|
+
* @protected
|
|
431
|
+
*/
|
|
432
|
+
deleteProperty(target, key)
|
|
433
|
+
{
|
|
434
|
+
let settings = this.settings;
|
|
435
|
+
|
|
436
|
+
if (key in target)
|
|
437
|
+
{
|
|
438
|
+
let value = target[key],
|
|
439
|
+
isArray = $lib.isArray(target),
|
|
440
|
+
data = isArray ? { removeIndex: parseInt(key), removeCount: 1 } : { removeCount: 1 },
|
|
441
|
+
dataKey = (typeof key !== 'symbol') ? proxyManager.getKey(this.dataKey, key, isArray) : undefined,
|
|
442
|
+
trackChange = ((!core.busy || $bindary.observeDuringRender) && core.observing);
|
|
443
|
+
|
|
444
|
+
const success = Reflect.deleteProperty(target, key);
|
|
445
|
+
|
|
446
|
+
if (typeof key === 'symbol')
|
|
447
|
+
return success;
|
|
448
|
+
|
|
449
|
+
// Evict the stale dataKey from the removed value's path set
|
|
450
|
+
if (success && dataKey && proxyManager.isProxy(value))
|
|
451
|
+
{
|
|
452
|
+
let paths = proxyManager.proxyDataKeys.get(value);
|
|
453
|
+
if (paths)
|
|
454
|
+
{
|
|
455
|
+
paths.delete(dataKey);
|
|
456
|
+
if (paths.size === 0)
|
|
457
|
+
proxyManager.proxyDataKeys.delete(value);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
if (success && dataKey && trackChange)
|
|
462
|
+
{
|
|
463
|
+
let allDataKeys = Array.from(proxyManager.proxyDataKeys.get(this.proxy) || [this.dataKey]),
|
|
464
|
+
targetExtraDataKeys = allDataKeys
|
|
465
|
+
.filter(dk => dk !== this.dataKey)
|
|
466
|
+
.map(dk => proxyManager.getKey(dk, key, isArray))
|
|
467
|
+
.filter(Boolean);
|
|
468
|
+
|
|
469
|
+
proxyManager.handleDataChange(target, undefined, value, dataKey, data, settings, targetExtraDataKeys);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
return success;
|
|
473
|
+
}
|
|
474
|
+
return true;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
})();
|
|
479
|
+
|
|
480
|
+
var ProxyManager = componyx.bindary_modules.proxyManager;
|
|
481
|
+
|
|
482
|
+
export { ProxyManager as default };
|