cx 23.4.3 → 23.4.5
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/dist/charts.css +649 -0
- package/dist/charts.js +4811 -0
- package/dist/data.js +2102 -0
- package/dist/hooks.js +146 -0
- package/dist/manifest.js +1373 -0
- package/dist/reset.css +89 -0
- package/dist/svg.css +19 -0
- package/dist/svg.js +807 -0
- package/dist/ui.js +4456 -0
- package/dist/util.js +1538 -0
- package/dist/widgets.css +5242 -0
- package/dist/widgets.js +19438 -0
- package/package.json +1 -1
- package/src/data/Binding.js +2 -12
- package/src/data/Binding.spec.js +48 -38
- package/src/data/createAccessorModelProxy.spec.tsx +6 -0
- package/src/ui/Restate.js +158 -158
- package/src/widgets/grid/Grid.js +22 -11
package/dist/ui.js
ADDED
|
@@ -0,0 +1,4456 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computable,
|
|
3
|
+
StoreProxy,
|
|
4
|
+
StructuredSelector,
|
|
5
|
+
invalidateExpressionCache,
|
|
6
|
+
invalidateStringTemplateCache,
|
|
7
|
+
defaultCompare,
|
|
8
|
+
getAccessor,
|
|
9
|
+
ArrayElementView,
|
|
10
|
+
ReadOnlyDataView,
|
|
11
|
+
sorter,
|
|
12
|
+
getSelector,
|
|
13
|
+
Binding,
|
|
14
|
+
ZoomIntoPropertyView,
|
|
15
|
+
isAccessorChain,
|
|
16
|
+
SubscribableView,
|
|
17
|
+
Store,
|
|
18
|
+
NestedDataView,
|
|
19
|
+
Grouper,
|
|
20
|
+
getComparer,
|
|
21
|
+
} from "cx/data";
|
|
22
|
+
export { computable } from "cx/data";
|
|
23
|
+
import {
|
|
24
|
+
isArray,
|
|
25
|
+
Component,
|
|
26
|
+
isFunction,
|
|
27
|
+
parseStyle,
|
|
28
|
+
Console,
|
|
29
|
+
isString,
|
|
30
|
+
isDefined,
|
|
31
|
+
innerTextTrim,
|
|
32
|
+
GlobalCacheIdentifier,
|
|
33
|
+
isObject,
|
|
34
|
+
SubscriberList,
|
|
35
|
+
isSelfOrDescendant,
|
|
36
|
+
getActiveElement,
|
|
37
|
+
findFirst,
|
|
38
|
+
isFocusable,
|
|
39
|
+
findFirstChild,
|
|
40
|
+
isTouchEvent,
|
|
41
|
+
closestParent,
|
|
42
|
+
Format as Format$1,
|
|
43
|
+
resolveMinMaxFractionDigits,
|
|
44
|
+
isNonEmptyArray,
|
|
45
|
+
debug,
|
|
46
|
+
processDataFlag,
|
|
47
|
+
renderFlag,
|
|
48
|
+
destroyFlag,
|
|
49
|
+
validatedDebounce,
|
|
50
|
+
throttle,
|
|
51
|
+
isUndefined,
|
|
52
|
+
TraversalStack,
|
|
53
|
+
reverseSlice,
|
|
54
|
+
appDataFlag,
|
|
55
|
+
onIdleCallback,
|
|
56
|
+
shallowEquals,
|
|
57
|
+
now,
|
|
58
|
+
Timing,
|
|
59
|
+
vdomRenderFlag,
|
|
60
|
+
appLoopFlag,
|
|
61
|
+
isPromise,
|
|
62
|
+
dummyCallback,
|
|
63
|
+
isComponentFactory,
|
|
64
|
+
createComponentFactory,
|
|
65
|
+
isNumber,
|
|
66
|
+
} from "cx/util";
|
|
67
|
+
import { VDOM as VDOM$2 } from "cx-react";
|
|
68
|
+
import { NumberCulture, DateTimeCulture } from "intl-io";
|
|
69
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
70
|
+
|
|
71
|
+
function ownKeys(object, enumerableOnly) {
|
|
72
|
+
var keys = Object.keys(object);
|
|
73
|
+
if (Object.getOwnPropertySymbols) {
|
|
74
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
75
|
+
enumerableOnly &&
|
|
76
|
+
(symbols = symbols.filter(function (sym) {
|
|
77
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
78
|
+
})),
|
|
79
|
+
keys.push.apply(keys, symbols);
|
|
80
|
+
}
|
|
81
|
+
return keys;
|
|
82
|
+
}
|
|
83
|
+
function _objectSpread2(target) {
|
|
84
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
85
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
86
|
+
i % 2
|
|
87
|
+
? ownKeys(Object(source), !0).forEach(function (key) {
|
|
88
|
+
_defineProperty(target, key, source[key]);
|
|
89
|
+
})
|
|
90
|
+
: Object.getOwnPropertyDescriptors
|
|
91
|
+
? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source))
|
|
92
|
+
: ownKeys(Object(source)).forEach(function (key) {
|
|
93
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return target;
|
|
97
|
+
}
|
|
98
|
+
function _defineProperties(target, props) {
|
|
99
|
+
for (var i = 0; i < props.length; i++) {
|
|
100
|
+
var descriptor = props[i];
|
|
101
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
102
|
+
descriptor.configurable = true;
|
|
103
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
104
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
108
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
109
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
110
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
111
|
+
writable: false,
|
|
112
|
+
});
|
|
113
|
+
return Constructor;
|
|
114
|
+
}
|
|
115
|
+
function _defineProperty(obj, key, value) {
|
|
116
|
+
key = _toPropertyKey(key);
|
|
117
|
+
if (key in obj) {
|
|
118
|
+
Object.defineProperty(obj, key, {
|
|
119
|
+
value: value,
|
|
120
|
+
enumerable: true,
|
|
121
|
+
configurable: true,
|
|
122
|
+
writable: true,
|
|
123
|
+
});
|
|
124
|
+
} else {
|
|
125
|
+
obj[key] = value;
|
|
126
|
+
}
|
|
127
|
+
return obj;
|
|
128
|
+
}
|
|
129
|
+
function _inheritsLoose(subClass, superClass) {
|
|
130
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
131
|
+
subClass.prototype.constructor = subClass;
|
|
132
|
+
_setPrototypeOf(subClass, superClass);
|
|
133
|
+
}
|
|
134
|
+
function _setPrototypeOf(o, p) {
|
|
135
|
+
_setPrototypeOf = Object.setPrototypeOf
|
|
136
|
+
? Object.setPrototypeOf.bind()
|
|
137
|
+
: function _setPrototypeOf(o, p) {
|
|
138
|
+
o.__proto__ = p;
|
|
139
|
+
return o;
|
|
140
|
+
};
|
|
141
|
+
return _setPrototypeOf(o, p);
|
|
142
|
+
}
|
|
143
|
+
function _assertThisInitialized(self) {
|
|
144
|
+
if (self === void 0) {
|
|
145
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
146
|
+
}
|
|
147
|
+
return self;
|
|
148
|
+
}
|
|
149
|
+
function _toPrimitive(input, hint) {
|
|
150
|
+
if (typeof input !== "object" || input === null) return input;
|
|
151
|
+
var prim = input[Symbol.toPrimitive];
|
|
152
|
+
if (prim !== undefined) {
|
|
153
|
+
var res = prim.call(input, hint || "default");
|
|
154
|
+
if (typeof res !== "object") return res;
|
|
155
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
156
|
+
}
|
|
157
|
+
return (hint === "string" ? String : Number)(input);
|
|
158
|
+
}
|
|
159
|
+
function _toPropertyKey(arg) {
|
|
160
|
+
var key = _toPrimitive(arg, "string");
|
|
161
|
+
return typeof key === "symbol" ? key : String(key);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
var computablePrefix = "computable-";
|
|
165
|
+
var triggerPrefix = "trigger-";
|
|
166
|
+
var Controller = /*#__PURE__*/ (function (_Component) {
|
|
167
|
+
_inheritsLoose(Controller, _Component);
|
|
168
|
+
function Controller() {
|
|
169
|
+
return _Component.apply(this, arguments) || this;
|
|
170
|
+
}
|
|
171
|
+
var _proto = Controller.prototype;
|
|
172
|
+
_proto.init = function init(context) {
|
|
173
|
+
if (!this.initialized) {
|
|
174
|
+
this.initialized = true;
|
|
175
|
+
if (this.onInit) this.onInit(context);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
_proto.explore = function explore(context) {
|
|
179
|
+
var store = this.instance.store;
|
|
180
|
+
this.store = store; //in rare cases instance may change its store
|
|
181
|
+
|
|
182
|
+
if (!this.initialized) {
|
|
183
|
+
this.init(context);
|
|
184
|
+
//forgive if the developer forgets to call super.init()
|
|
185
|
+
this.initialized = true;
|
|
186
|
+
}
|
|
187
|
+
if (this.computables) {
|
|
188
|
+
for (var key in this.computables) {
|
|
189
|
+
var x = this.computables[key];
|
|
190
|
+
var v = x.selector(store.getData());
|
|
191
|
+
if (x.type == "computable") store.set(x.name, v);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (this.onExplore) {
|
|
195
|
+
this.onExplore(context);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
_proto.prepare = function prepare(context) {
|
|
199
|
+
if (this.onPrepare) {
|
|
200
|
+
this.onPrepare(context);
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
_proto.cleanup = function cleanup(context) {
|
|
204
|
+
if (this.onCleanup) {
|
|
205
|
+
this.onCleanup(context);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
_proto.addComputable = function addComputable(name, args, callback) {
|
|
209
|
+
if (!isArray(args)) throw new Error("Second argument to the addComputable method should be an array.");
|
|
210
|
+
var selector = computable.apply(void 0, args.concat([callback])).memoize();
|
|
211
|
+
if (!this.computables) this.computables = {};
|
|
212
|
+
this.computables[computablePrefix + name] = {
|
|
213
|
+
name: name,
|
|
214
|
+
selector: selector,
|
|
215
|
+
type: "computable",
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
_proto.addTrigger = function addTrigger(name, args, callback, autoRun) {
|
|
219
|
+
if (!isArray(args)) throw new Error("Second argument to the addTrigger method should be an array.");
|
|
220
|
+
var selector = computable.apply(void 0, args.concat([callback])).memoize(!autoRun && this.store.getData());
|
|
221
|
+
if (!this.computables) this.computables = {};
|
|
222
|
+
this.computables[triggerPrefix + name] = {
|
|
223
|
+
name: name,
|
|
224
|
+
selector: selector,
|
|
225
|
+
type: "trigger",
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
_proto.removeTrigger = function removeTrigger(name) {
|
|
229
|
+
if (this.computables) delete this.computables[triggerPrefix + name];
|
|
230
|
+
};
|
|
231
|
+
_proto.removeComputable = function removeComputable(name) {
|
|
232
|
+
if (this.computables) delete this.computables[computablePrefix + name];
|
|
233
|
+
};
|
|
234
|
+
_proto.invokeParentMethod = function invokeParentMethod(methodName) {
|
|
235
|
+
var parent = this.instance.parent;
|
|
236
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
237
|
+
args[_key - 1] = arguments[_key];
|
|
238
|
+
}
|
|
239
|
+
return parent.invokeControllerMethod.apply(parent, [methodName].concat(args));
|
|
240
|
+
};
|
|
241
|
+
_proto.invokeMethod = function invokeMethod(methodName) {
|
|
242
|
+
var _this$instance;
|
|
243
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
244
|
+
args[_key2 - 1] = arguments[_key2];
|
|
245
|
+
}
|
|
246
|
+
return (_this$instance = this.instance).invokeControllerMethod.apply(_this$instance, [methodName].concat(args));
|
|
247
|
+
};
|
|
248
|
+
return Controller;
|
|
249
|
+
})(Component);
|
|
250
|
+
Controller.namespace = "ui.controller.";
|
|
251
|
+
Controller.factory = function (alias, config, more) {
|
|
252
|
+
if (isFunction(alias)) {
|
|
253
|
+
var cfg = _objectSpread2(_objectSpread2({}, config), more);
|
|
254
|
+
if (cfg.instance) {
|
|
255
|
+
//in rare cases instance.store may change, so we cannot rely on the store passed through configuration
|
|
256
|
+
cfg.store = new StoreProxy(function () {
|
|
257
|
+
return cfg.instance.store;
|
|
258
|
+
});
|
|
259
|
+
Object.assign(cfg, cfg.store.getMethods());
|
|
260
|
+
}
|
|
261
|
+
var result = alias(cfg);
|
|
262
|
+
if (result instanceof Controller) return result;
|
|
263
|
+
return Controller.create(_objectSpread2(_objectSpread2(_objectSpread2({}, config), more), result));
|
|
264
|
+
}
|
|
265
|
+
return Controller.create(_objectSpread2(_objectSpread2({}, config), more));
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
var cssHelperCache = {};
|
|
269
|
+
var CSSHelper = /*#__PURE__*/ (function () {
|
|
270
|
+
function CSSHelper() {}
|
|
271
|
+
CSSHelper.get = function get(code) {
|
|
272
|
+
var helper = cssHelperCache[code];
|
|
273
|
+
if (!helper) throw new Error("Unknown CSS helper '" + code + "'.");
|
|
274
|
+
return helper;
|
|
275
|
+
};
|
|
276
|
+
CSSHelper.register = function register(code, helper) {
|
|
277
|
+
cssHelperCache[code] = helper;
|
|
278
|
+
};
|
|
279
|
+
CSSHelper.alias = function alias(code, helper) {
|
|
280
|
+
cssHelperCache[code] = helper;
|
|
281
|
+
};
|
|
282
|
+
return CSSHelper;
|
|
283
|
+
})();
|
|
284
|
+
|
|
285
|
+
function push(list, item) {
|
|
286
|
+
if (!item) return list;
|
|
287
|
+
if (!list) list = [];
|
|
288
|
+
list.push(item);
|
|
289
|
+
return list;
|
|
290
|
+
}
|
|
291
|
+
function pushMore(list, itemArray) {
|
|
292
|
+
if (!itemArray || itemArray.length == 0) return list;
|
|
293
|
+
if (!list) list = [];
|
|
294
|
+
list.push.apply(list, itemArray);
|
|
295
|
+
return list;
|
|
296
|
+
}
|
|
297
|
+
function pushMap(list, itemArray, mapF) {
|
|
298
|
+
return itemArray ? pushMore(list, itemArray.map(mapF)) : list;
|
|
299
|
+
}
|
|
300
|
+
function join(list) {
|
|
301
|
+
return list ? list.join(" ") : null;
|
|
302
|
+
}
|
|
303
|
+
var CSS = /*#__PURE__*/ (function () {
|
|
304
|
+
function CSS() {}
|
|
305
|
+
CSS.resolve = function resolve() {
|
|
306
|
+
var list, type, arg, i, key;
|
|
307
|
+
for (i = 0; i < arguments.length; i++) {
|
|
308
|
+
arg = arguments[i];
|
|
309
|
+
if (arg) {
|
|
310
|
+
type = typeof arg;
|
|
311
|
+
if (type == "string") list = push(list, arg);
|
|
312
|
+
else if (type == "object") {
|
|
313
|
+
if (isArray(arg)) list = pushMore(list, this.resolve.apply(this, arg));
|
|
314
|
+
else for (key in arg) if (arg[key]) list = push(list, key);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return list;
|
|
319
|
+
};
|
|
320
|
+
CSS.block = function block(baseClass, styleModifiers, stateModifiers) {
|
|
321
|
+
var _this = this;
|
|
322
|
+
var list;
|
|
323
|
+
if (baseClass) list = push(list, this.classPrefix + "b-" + baseClass);
|
|
324
|
+
list = pushMap(list, this.resolve(styleModifiers), function (m) {
|
|
325
|
+
return _this.classPrefix + "m-" + m;
|
|
326
|
+
});
|
|
327
|
+
list = pushMap(list, this.resolve(stateModifiers), function (m) {
|
|
328
|
+
return _this.classPrefix + "s-" + m;
|
|
329
|
+
});
|
|
330
|
+
return join(list);
|
|
331
|
+
};
|
|
332
|
+
CSS.element = function element(baseClass, elementClass, stateModifiers) {
|
|
333
|
+
var _this2 = this;
|
|
334
|
+
var list;
|
|
335
|
+
if (baseClass && elementClass) list = push(list, this.classPrefix + "e-" + baseClass + "-" + elementClass);
|
|
336
|
+
list = pushMap(list, this.resolve(stateModifiers), function (m) {
|
|
337
|
+
return _this2.classPrefix + "s-" + m;
|
|
338
|
+
});
|
|
339
|
+
return join(list);
|
|
340
|
+
};
|
|
341
|
+
CSS.state = function state(stateModifiers) {
|
|
342
|
+
var _this3 = this;
|
|
343
|
+
return join(
|
|
344
|
+
pushMap(null, this.resolve(stateModifiers), function (m) {
|
|
345
|
+
return _this3.classPrefix + "s-" + m;
|
|
346
|
+
})
|
|
347
|
+
);
|
|
348
|
+
};
|
|
349
|
+
CSS.mod = function mod(mods) {
|
|
350
|
+
var _this4 = this;
|
|
351
|
+
return join(
|
|
352
|
+
pushMap(null, this.resolve(mods), function (m) {
|
|
353
|
+
return _this4.classPrefix + "m-" + m;
|
|
354
|
+
})
|
|
355
|
+
);
|
|
356
|
+
};
|
|
357
|
+
CSS.expand = function expand() {
|
|
358
|
+
return join(this.resolve.apply(this, arguments));
|
|
359
|
+
};
|
|
360
|
+
CSS.parseStyle = function parseStyle$1(str) {
|
|
361
|
+
return parseStyle(str);
|
|
362
|
+
};
|
|
363
|
+
return CSS;
|
|
364
|
+
})();
|
|
365
|
+
CSS.classPrefix = "cx";
|
|
366
|
+
CSSHelper.alias("cx", CSS);
|
|
367
|
+
|
|
368
|
+
var VDOM$1 = VDOM$2;
|
|
369
|
+
|
|
370
|
+
var VDOM = VDOM$1;
|
|
371
|
+
var widgetId = 100;
|
|
372
|
+
var Widget = /*#__PURE__*/ (function (_Component) {
|
|
373
|
+
_inheritsLoose(Widget, _Component);
|
|
374
|
+
function Widget(config) {
|
|
375
|
+
var _this;
|
|
376
|
+
_this = _Component.call(this, config) || this;
|
|
377
|
+
_this.widgetId = widgetId++;
|
|
378
|
+
if (isArray(_this.jsxSpread)) {
|
|
379
|
+
if (!_this.jsxAttributes) _this.jsxAttributes = [];
|
|
380
|
+
_this.jsxSpread.forEach(function (spread) {
|
|
381
|
+
for (var key in spread) {
|
|
382
|
+
_this[key] = spread[key];
|
|
383
|
+
_this.jsxAttributes.push(key);
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
return _this;
|
|
388
|
+
}
|
|
389
|
+
var _proto = Widget.prototype;
|
|
390
|
+
_proto.init = function init() {
|
|
391
|
+
if (this.styles) this.style = this.styles;
|
|
392
|
+
if (this.styled) this.style = parseStyle(this.style);
|
|
393
|
+
else if (this.style) {
|
|
394
|
+
Console.warn(
|
|
395
|
+
"Components that allow use of the style attribute should set styled = true on their prototype. This will be an error in future versions."
|
|
396
|
+
);
|
|
397
|
+
this.style = parseStyle(this.style);
|
|
398
|
+
this.styled = true;
|
|
399
|
+
}
|
|
400
|
+
if (typeof this["if"] !== "undefined") this.visible = this["if"];
|
|
401
|
+
this.declareData();
|
|
402
|
+
if (this.outerLayout) {
|
|
403
|
+
if (isArray(this.outerLayout)) throw new Error("Only single element outer layout is supported.");
|
|
404
|
+
//TODO: better handle the case when outer layout is an array. How to get around circular dependency to PureContainer
|
|
405
|
+
this.outerLayout = Widget.create(this.outerLayout);
|
|
406
|
+
}
|
|
407
|
+
if (this.contentFor) this.putInto = this.contentFor;
|
|
408
|
+
if (this.putInto) this.isContent = true;
|
|
409
|
+
if (isString(this.CSS)) this.CSS = CSSHelper.get(this.CSS);
|
|
410
|
+
this.initHelpers();
|
|
411
|
+
this.initComponents();
|
|
412
|
+
this.initialized = true;
|
|
413
|
+
};
|
|
414
|
+
_proto.initComponents = function initComponents() {
|
|
415
|
+
if (arguments.length > 0) {
|
|
416
|
+
this.components = Object.assign.apply(Object, arguments);
|
|
417
|
+
for (var k in this.components) if (!this.components[k]) delete this.components[k];
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
_proto.initHelpers = function initHelpers() {
|
|
421
|
+
if (arguments.length > 0) {
|
|
422
|
+
this.helpers = Object.assign.apply(Object, arguments);
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
_proto.declareData = function declareData() {
|
|
426
|
+
var options = {};
|
|
427
|
+
if (this.styled)
|
|
428
|
+
options["class"] =
|
|
429
|
+
options.className =
|
|
430
|
+
options.style =
|
|
431
|
+
{
|
|
432
|
+
structured: true,
|
|
433
|
+
};
|
|
434
|
+
var props = _objectSpread2(
|
|
435
|
+
{
|
|
436
|
+
visible: undefined,
|
|
437
|
+
mod: {
|
|
438
|
+
structured: true,
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
options
|
|
442
|
+
);
|
|
443
|
+
Object.assign.apply(Object, [props].concat(Array.prototype.slice.call(arguments)));
|
|
444
|
+
this.selector = new StructuredSelector({
|
|
445
|
+
props: props,
|
|
446
|
+
values: this,
|
|
447
|
+
});
|
|
448
|
+
this.nameMap = this.selector.nameMap;
|
|
449
|
+
};
|
|
450
|
+
_proto.prepareCSS = function prepareCSS(context, _ref) {
|
|
451
|
+
var data = _ref.data;
|
|
452
|
+
data.classNames = this.CSS.expand(
|
|
453
|
+
this.CSS.block(this.baseClass, data.mod, data.stateMods),
|
|
454
|
+
data["class"],
|
|
455
|
+
data.className
|
|
456
|
+
);
|
|
457
|
+
data.style = parseStyle(data.style);
|
|
458
|
+
};
|
|
459
|
+
_proto.prepareData = function prepareData(context, instance) {
|
|
460
|
+
if (this.styled) this.prepareCSS(context, instance);
|
|
461
|
+
};
|
|
462
|
+
_proto.initInstance = function initInstance(context, instance) {
|
|
463
|
+
if (this.onInit) this.onInit(context, instance);
|
|
464
|
+
};
|
|
465
|
+
_proto.initState = function initState(context, instance) {};
|
|
466
|
+
_proto.checkVisible = function checkVisible(context, instance, data) {
|
|
467
|
+
return data.visible;
|
|
468
|
+
};
|
|
469
|
+
_proto.explore = function explore(context, instance) {
|
|
470
|
+
if (this.components) instance.components = {};
|
|
471
|
+
for (var cmp in this.components) {
|
|
472
|
+
var ins = instance.getChild(context, this.components[cmp], "cmp-" + cmp, instance.store);
|
|
473
|
+
if (ins.scheduleExploreIfVisible(context)) instance.components[cmp] = ins;
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
_proto.render = function render(context, instance, key) {
|
|
477
|
+
Console.log(this);
|
|
478
|
+
throw new Error(
|
|
479
|
+
'Widget\'s render method should be overridden. This error usually happens if with incorrect imports, i.e. import { TextField } from "cx/data". Please check the console for details about the component configuration.'
|
|
480
|
+
);
|
|
481
|
+
};
|
|
482
|
+
_proto.update = function update() {
|
|
483
|
+
this.version = (this.version || 0) + 1;
|
|
484
|
+
};
|
|
485
|
+
Widget.resetCounter = function resetCounter() {
|
|
486
|
+
widgetId = 100;
|
|
487
|
+
};
|
|
488
|
+
return Widget;
|
|
489
|
+
})(Component);
|
|
490
|
+
Widget.prototype.visible = true;
|
|
491
|
+
Widget.prototype.memoize = true; //cache rendered content and use it if possible
|
|
492
|
+
Widget.prototype.CSS = "cx";
|
|
493
|
+
Widget.prototype.styled = false;
|
|
494
|
+
Widget.namespace = "ui.";
|
|
495
|
+
Widget.optimizePrepare = true;
|
|
496
|
+
Widget.factory = function (type, config, more) {
|
|
497
|
+
throw new Error("Invalid widget type: " + type + ".");
|
|
498
|
+
};
|
|
499
|
+
function contentAppend(result, w, prependSpace) {
|
|
500
|
+
if (w == null || w === false) return false;
|
|
501
|
+
if (isArray(w))
|
|
502
|
+
w.forEach(function (c) {
|
|
503
|
+
return contentAppend(result, c);
|
|
504
|
+
});
|
|
505
|
+
else if (isDefined(w.content) && !w.atomic) return contentAppend(result, w.content);
|
|
506
|
+
else {
|
|
507
|
+
if (prependSpace) result.push(" ");
|
|
508
|
+
result.push(w);
|
|
509
|
+
}
|
|
510
|
+
return true;
|
|
511
|
+
}
|
|
512
|
+
function getContentArray(x) {
|
|
513
|
+
var result = [];
|
|
514
|
+
contentAppend(result, x);
|
|
515
|
+
return result;
|
|
516
|
+
}
|
|
517
|
+
function getContent(x) {
|
|
518
|
+
var result = getContentArray(x);
|
|
519
|
+
if (result.length == 0) return null;
|
|
520
|
+
if (result.length == 1) return result[0];
|
|
521
|
+
return result;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
var StaticText = /*#__PURE__*/ (function (_Widget) {
|
|
525
|
+
_inheritsLoose(StaticText, _Widget);
|
|
526
|
+
function StaticText() {
|
|
527
|
+
return _Widget.apply(this, arguments) || this;
|
|
528
|
+
}
|
|
529
|
+
var _proto = StaticText.prototype;
|
|
530
|
+
_proto.render = function render() {
|
|
531
|
+
return this.text;
|
|
532
|
+
};
|
|
533
|
+
return StaticText;
|
|
534
|
+
})(Widget);
|
|
535
|
+
Widget.alias("static-text", StaticText);
|
|
536
|
+
|
|
537
|
+
var Text = /*#__PURE__*/ (function (_Widget) {
|
|
538
|
+
_inheritsLoose(Text, _Widget);
|
|
539
|
+
function Text() {
|
|
540
|
+
return _Widget.apply(this, arguments) || this;
|
|
541
|
+
}
|
|
542
|
+
var _proto = Text.prototype;
|
|
543
|
+
_proto.init = function init() {
|
|
544
|
+
if (!this.value && (this.tpl || this.expr || this.bind))
|
|
545
|
+
this.value = {
|
|
546
|
+
tpl: this.tpl,
|
|
547
|
+
expr: this.expr,
|
|
548
|
+
bind: this.bind,
|
|
549
|
+
};
|
|
550
|
+
_Widget.prototype.init.call(this);
|
|
551
|
+
};
|
|
552
|
+
_proto.declareData = function declareData() {
|
|
553
|
+
var _Widget$prototype$dec;
|
|
554
|
+
(_Widget$prototype$dec = _Widget.prototype.declareData).call.apply(
|
|
555
|
+
_Widget$prototype$dec,
|
|
556
|
+
[
|
|
557
|
+
this,
|
|
558
|
+
{
|
|
559
|
+
value: undefined,
|
|
560
|
+
},
|
|
561
|
+
].concat(Array.prototype.slice.call(arguments))
|
|
562
|
+
);
|
|
563
|
+
};
|
|
564
|
+
_proto.render = function render(context, _ref, key) {
|
|
565
|
+
var data = _ref.data;
|
|
566
|
+
return data.value != null ? data.value : "";
|
|
567
|
+
};
|
|
568
|
+
return Text;
|
|
569
|
+
})(Widget);
|
|
570
|
+
Widget.alias("text", Text);
|
|
571
|
+
|
|
572
|
+
function exploreChildren(context, instance, children, previousResult, key, store, beforeCallback, afterCallback) {
|
|
573
|
+
var newChildren = previousResult || [];
|
|
574
|
+
var oldChildren = previousResult || newChildren;
|
|
575
|
+
var identical = previousResult ? 0 : -1;
|
|
576
|
+
|
|
577
|
+
// if (children.length)
|
|
578
|
+
// context.exploreStack.hop();
|
|
579
|
+
|
|
580
|
+
for (var c = 0; c < children.length; c++) {
|
|
581
|
+
var cell = instance.getChild(context, children[c], key, store);
|
|
582
|
+
|
|
583
|
+
// if (beforeCallback)
|
|
584
|
+
// beforeCallback(cell);
|
|
585
|
+
|
|
586
|
+
if (cell.checkVisible(context)) {
|
|
587
|
+
if (identical >= 0) {
|
|
588
|
+
if (cell == oldChildren[identical]) identical++;
|
|
589
|
+
else {
|
|
590
|
+
newChildren = newChildren.slice(0, identical);
|
|
591
|
+
identical = -1;
|
|
592
|
+
newChildren.push(cell);
|
|
593
|
+
}
|
|
594
|
+
} else newChildren.push(cell);
|
|
595
|
+
context.exploreStack.push(cell);
|
|
596
|
+
if (cell.needsExploreCleanup) context.exploreStack.push(cell);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
if (identical >= 0 && identical != newChildren.length) newChildren = newChildren.slice(0, identical);
|
|
600
|
+
return newChildren;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
var Container = /*#__PURE__*/ (function (_Widget) {
|
|
604
|
+
_inheritsLoose(Container, _Widget);
|
|
605
|
+
function Container() {
|
|
606
|
+
return _Widget.apply(this, arguments) || this;
|
|
607
|
+
}
|
|
608
|
+
var _proto = Container.prototype;
|
|
609
|
+
_proto.init = function init(context) {
|
|
610
|
+
if (typeof this.ws !== "undefined") this.preserveWhitespace = this.ws;
|
|
611
|
+
if (this.preserveWhitespace) this.trimWhitespace = false;
|
|
612
|
+
var items = this.items || this.children || [];
|
|
613
|
+
delete this.children;
|
|
614
|
+
this.items = [];
|
|
615
|
+
if (this.layout) {
|
|
616
|
+
var layout = Widget.create({
|
|
617
|
+
type: this.layout,
|
|
618
|
+
items: items,
|
|
619
|
+
});
|
|
620
|
+
layout.init(context);
|
|
621
|
+
this.layout = null;
|
|
622
|
+
if (layout.noLayout) {
|
|
623
|
+
this.useParentLayout = true;
|
|
624
|
+
this.add(items);
|
|
625
|
+
} else {
|
|
626
|
+
this.add(layout);
|
|
627
|
+
this.layout = layout;
|
|
628
|
+
}
|
|
629
|
+
} else {
|
|
630
|
+
this.add(items);
|
|
631
|
+
}
|
|
632
|
+
_Widget.prototype.init.call(this, context);
|
|
633
|
+
};
|
|
634
|
+
_proto.exploreItems = function exploreItems(context, instance, items) {
|
|
635
|
+
instance.children = exploreChildren(context, instance, items, instance.cached.children);
|
|
636
|
+
if (instance.cache("children", instance.children)) instance.markShouldUpdate(context);
|
|
637
|
+
};
|
|
638
|
+
_proto.explore = function explore(context, instance) {
|
|
639
|
+
_Widget.prototype.explore.call(this, context, instance);
|
|
640
|
+
this.exploreItems(context, instance, this.items);
|
|
641
|
+
};
|
|
642
|
+
_proto.render = function render(context, instance) {
|
|
643
|
+
return this.renderChildren(context, instance);
|
|
644
|
+
};
|
|
645
|
+
_proto.renderChildren = function renderChildren(context, instance) {
|
|
646
|
+
var preserveComplexContent = this.useParentLayout;
|
|
647
|
+
function append(result, r) {
|
|
648
|
+
if (r == null) return;
|
|
649
|
+
|
|
650
|
+
//react element
|
|
651
|
+
if (!r.hasOwnProperty("content")) {
|
|
652
|
+
contentAppend(result, r);
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
if (r.useParentLayout)
|
|
656
|
+
return r.content.forEach(function (x) {
|
|
657
|
+
return append(result, x);
|
|
658
|
+
});
|
|
659
|
+
if (r.atomic || preserveComplexContent) {
|
|
660
|
+
result.push(r);
|
|
661
|
+
} else {
|
|
662
|
+
var first = true;
|
|
663
|
+
for (var k in r) if (contentAppend(result, r[k], !first)) first = false;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
var result = [];
|
|
667
|
+
for (var i = 0; i < instance.children.length; i++) {
|
|
668
|
+
append(result, instance.children[i].vdom);
|
|
669
|
+
}
|
|
670
|
+
if (this.useParentLayout)
|
|
671
|
+
return {
|
|
672
|
+
useParentLayout: true,
|
|
673
|
+
content: result,
|
|
674
|
+
};
|
|
675
|
+
return result;
|
|
676
|
+
};
|
|
677
|
+
_proto.clear = function clear() {
|
|
678
|
+
if (this.layout) this.layout.clear();
|
|
679
|
+
else this.items = [];
|
|
680
|
+
};
|
|
681
|
+
_proto.add = function add() {
|
|
682
|
+
var _this$layout,
|
|
683
|
+
_this = this;
|
|
684
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
685
|
+
args[_key] = arguments[_key];
|
|
686
|
+
}
|
|
687
|
+
if (this.layout) return (_this$layout = this.layout).add.apply(_this$layout, args);
|
|
688
|
+
args.forEach(function (a) {
|
|
689
|
+
if (!a) return;
|
|
690
|
+
if (isArray(a))
|
|
691
|
+
a.forEach(function (c) {
|
|
692
|
+
return _this.add(c);
|
|
693
|
+
});
|
|
694
|
+
else if (isString(a)) {
|
|
695
|
+
if (_this.trimWhitespace) a = innerTextTrim(a);
|
|
696
|
+
if (a) _this.addText(a);
|
|
697
|
+
} else if (a.isComponent) _this.items.push(_this.wrapItem(a));
|
|
698
|
+
else {
|
|
699
|
+
_this.add(Widget.create(a, _this.itemDefaults));
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
};
|
|
703
|
+
_proto.wrapItem = function wrapItem(item) {
|
|
704
|
+
return item;
|
|
705
|
+
};
|
|
706
|
+
_proto.addText = function addText(text) {
|
|
707
|
+
if (this.plainText || text.indexOf("{") == -1 || text.indexOf("}") == -1)
|
|
708
|
+
this.add(
|
|
709
|
+
Widget.create(StaticText, {
|
|
710
|
+
text: text,
|
|
711
|
+
})
|
|
712
|
+
);
|
|
713
|
+
else
|
|
714
|
+
this.add(
|
|
715
|
+
Widget.create(Text, {
|
|
716
|
+
text: {
|
|
717
|
+
tpl: text,
|
|
718
|
+
},
|
|
719
|
+
})
|
|
720
|
+
);
|
|
721
|
+
};
|
|
722
|
+
_proto.find = function find(filter, options) {
|
|
723
|
+
if (!options) options = {};
|
|
724
|
+
if (!filter || !this.items) return [];
|
|
725
|
+
var alias = filter;
|
|
726
|
+
if (isString(filter))
|
|
727
|
+
filter = function filter(w) {
|
|
728
|
+
return w.componentAlias == alias;
|
|
729
|
+
};
|
|
730
|
+
if (filter.isComponentType)
|
|
731
|
+
filter = function filter(w) {
|
|
732
|
+
return w instanceof alias;
|
|
733
|
+
};
|
|
734
|
+
var results = [];
|
|
735
|
+
for (var i = 0; i < this.items.length; i++) {
|
|
736
|
+
var w = this.items[i];
|
|
737
|
+
if (!w.initialized) w.init();
|
|
738
|
+
if (filter(w)) {
|
|
739
|
+
results.push(w);
|
|
740
|
+
if (options.first) break;
|
|
741
|
+
}
|
|
742
|
+
if (w.find) results.push.apply(results, w.find(filter, options));
|
|
743
|
+
}
|
|
744
|
+
return results;
|
|
745
|
+
};
|
|
746
|
+
_proto.findFirst = function findFirst(filter, options) {
|
|
747
|
+
return this.find(
|
|
748
|
+
filter,
|
|
749
|
+
_objectSpread2(
|
|
750
|
+
_objectSpread2({}, options),
|
|
751
|
+
{},
|
|
752
|
+
{
|
|
753
|
+
first: true,
|
|
754
|
+
}
|
|
755
|
+
)
|
|
756
|
+
)[0];
|
|
757
|
+
};
|
|
758
|
+
return Container;
|
|
759
|
+
})(Widget);
|
|
760
|
+
Container.prototype.trimWhitespace = true;
|
|
761
|
+
Container.prototype.plainText = true;
|
|
762
|
+
Container.prototype.styled = false;
|
|
763
|
+
|
|
764
|
+
var PureContainer = /*#__PURE__*/ (function (_Container) {
|
|
765
|
+
_inheritsLoose(PureContainer, _Container);
|
|
766
|
+
function PureContainer() {
|
|
767
|
+
return _Container.apply(this, arguments) || this;
|
|
768
|
+
}
|
|
769
|
+
return PureContainer;
|
|
770
|
+
})(Container);
|
|
771
|
+
PureContainer.prototype.isPureContainer = true;
|
|
772
|
+
PureContainer.alias("pure-container", PureContainer);
|
|
773
|
+
|
|
774
|
+
var DataAdapter = /*#__PURE__*/ (function (_Component) {
|
|
775
|
+
_inheritsLoose(DataAdapter, _Component);
|
|
776
|
+
function DataAdapter() {
|
|
777
|
+
return _Component.apply(this, arguments) || this;
|
|
778
|
+
}
|
|
779
|
+
var _proto = DataAdapter.prototype;
|
|
780
|
+
_proto.getRecords = function getRecords() {
|
|
781
|
+
throw new Error("Abstract method");
|
|
782
|
+
};
|
|
783
|
+
_proto.setFilter = function setFilter() {};
|
|
784
|
+
_proto.sort = function sort() {};
|
|
785
|
+
return DataAdapter;
|
|
786
|
+
})(Component);
|
|
787
|
+
DataAdapter.prototype.recordName = "$record";
|
|
788
|
+
DataAdapter.prototype.indexName = "$index";
|
|
789
|
+
DataAdapter.prototype.immutable = false;
|
|
790
|
+
|
|
791
|
+
var contents = {};
|
|
792
|
+
var localizations = {};
|
|
793
|
+
var overrides = {};
|
|
794
|
+
var defaults = {};
|
|
795
|
+
var _trackDefaults = false;
|
|
796
|
+
var Localization = /*#__PURE__*/ (function () {
|
|
797
|
+
function Localization() {}
|
|
798
|
+
Localization.register = function register(key) {
|
|
799
|
+
var _this = this;
|
|
800
|
+
return function (type) {
|
|
801
|
+
_this.registerPrototype(key, type);
|
|
802
|
+
return type;
|
|
803
|
+
};
|
|
804
|
+
};
|
|
805
|
+
Localization.registerPrototype = function registerPrototype(key, type) {
|
|
806
|
+
contents[key] = type.prototype;
|
|
807
|
+
if (overrides[key]) this.override(key, overrides[key]);
|
|
808
|
+
};
|
|
809
|
+
Localization.trackDefaults = function trackDefaults() {
|
|
810
|
+
_trackDefaults = true;
|
|
811
|
+
};
|
|
812
|
+
Localization.restoreDefaults = function restoreDefaults() {
|
|
813
|
+
for (var type in defaults) {
|
|
814
|
+
var proto = contents[type];
|
|
815
|
+
if (!proto) continue;
|
|
816
|
+
var d = defaults[type];
|
|
817
|
+
for (var key in d) proto[key] = d[key];
|
|
818
|
+
}
|
|
819
|
+
defaults = {};
|
|
820
|
+
};
|
|
821
|
+
Localization.override = function override(key, values) {
|
|
822
|
+
overrides[key] = values;
|
|
823
|
+
var p = contents[key];
|
|
824
|
+
if (p) {
|
|
825
|
+
if (_trackDefaults && !defaults[key]) {
|
|
826
|
+
var d = (defaults[key] = {});
|
|
827
|
+
for (var _key in values) d[_key] = p[_key];
|
|
828
|
+
}
|
|
829
|
+
Object.assign(p, values);
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
Localization.localize = function localize(culture, key, values) {
|
|
833
|
+
var l = localizations[culture];
|
|
834
|
+
if (!l) l = localizations[culture] = {};
|
|
835
|
+
l[key] = _objectSpread2(_objectSpread2({}, l[key]), values);
|
|
836
|
+
};
|
|
837
|
+
Localization.setCulture = function setCulture(culture) {
|
|
838
|
+
var l = localizations[culture];
|
|
839
|
+
if (l) {
|
|
840
|
+
for (var key in l) {
|
|
841
|
+
var content = contents[key];
|
|
842
|
+
if (content) Object.assign(content, l[key]);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
};
|
|
846
|
+
return Localization;
|
|
847
|
+
})();
|
|
848
|
+
|
|
849
|
+
var culture = "en";
|
|
850
|
+
var cultureCache = {};
|
|
851
|
+
var defaultCurrency = "USD";
|
|
852
|
+
var dateEncoding = function dateEncoding(date) {
|
|
853
|
+
return date.toISOString();
|
|
854
|
+
};
|
|
855
|
+
var Culture = /*#__PURE__*/ (function () {
|
|
856
|
+
function Culture() {}
|
|
857
|
+
Culture.setCulture = function setCulture(cultureCode) {
|
|
858
|
+
culture = cultureCode;
|
|
859
|
+
cultureCache = {};
|
|
860
|
+
Localization.setCulture(cultureCode);
|
|
861
|
+
this.invalidateCache();
|
|
862
|
+
};
|
|
863
|
+
Culture.setDefaultCurrency = function setDefaultCurrency(currencyCode) {
|
|
864
|
+
defaultCurrency = currencyCode;
|
|
865
|
+
this.invalidateCache();
|
|
866
|
+
};
|
|
867
|
+
Culture.invalidateCache = function invalidateCache() {
|
|
868
|
+
GlobalCacheIdentifier.change();
|
|
869
|
+
invalidateExpressionCache();
|
|
870
|
+
invalidateStringTemplateCache();
|
|
871
|
+
};
|
|
872
|
+
Culture.getNumberCulture = function getNumberCulture() {
|
|
873
|
+
if (!cultureCache.numberCulture) cultureCache.numberCulture = new NumberCulture(culture);
|
|
874
|
+
return cultureCache.numberCulture;
|
|
875
|
+
};
|
|
876
|
+
Culture.getDateTimeCulture = function getDateTimeCulture() {
|
|
877
|
+
if (!cultureCache.dateCulture) cultureCache.dateCulture = new DateTimeCulture(culture);
|
|
878
|
+
return cultureCache.dateCulture;
|
|
879
|
+
};
|
|
880
|
+
Culture.getDefaultDateEncoding = function getDefaultDateEncoding() {
|
|
881
|
+
return dateEncoding;
|
|
882
|
+
};
|
|
883
|
+
Culture.setDefaultDateEncoding = function setDefaultDateEncoding(encoding) {
|
|
884
|
+
dateEncoding = encoding;
|
|
885
|
+
};
|
|
886
|
+
Culture.getComparer = function getComparer(options) {
|
|
887
|
+
if (typeof Intl.Collator != "undefined") return new Intl.Collator(culture, options).compare;
|
|
888
|
+
return defaultCompare;
|
|
889
|
+
};
|
|
890
|
+
_createClass(Culture, null, [
|
|
891
|
+
{
|
|
892
|
+
key: "defaultCurrency",
|
|
893
|
+
get: function get() {
|
|
894
|
+
return defaultCurrency;
|
|
895
|
+
},
|
|
896
|
+
},
|
|
897
|
+
{
|
|
898
|
+
key: "culture",
|
|
899
|
+
get: function get() {
|
|
900
|
+
return culture;
|
|
901
|
+
},
|
|
902
|
+
},
|
|
903
|
+
]);
|
|
904
|
+
return Culture;
|
|
905
|
+
})();
|
|
906
|
+
|
|
907
|
+
var ArrayAdapter = /*#__PURE__*/ (function (_DataAdapter) {
|
|
908
|
+
_inheritsLoose(ArrayAdapter, _DataAdapter);
|
|
909
|
+
function ArrayAdapter() {
|
|
910
|
+
return _DataAdapter.apply(this, arguments) || this;
|
|
911
|
+
}
|
|
912
|
+
var _proto = ArrayAdapter.prototype;
|
|
913
|
+
_proto.init = function init() {
|
|
914
|
+
this.recordsAccessor = getAccessor(this.recordsBinding ? this.recordsBinding : this.recordsAccessor);
|
|
915
|
+
|
|
916
|
+
//resolve accessor chains
|
|
917
|
+
this.recordName = this.recordName.toString();
|
|
918
|
+
this.indexName = this.indexName.toString();
|
|
919
|
+
};
|
|
920
|
+
_proto.initInstance = function initInstance(context, instance) {
|
|
921
|
+
if (!instance.recordStoreCache) instance.recordStoreCache = new WeakMap();
|
|
922
|
+
if (!instance.recordsAccessor && this.recordsAccessor) {
|
|
923
|
+
instance.recordsAccessor = this.recordsAccessor.bindInstance
|
|
924
|
+
? this.recordsAccessor.bindInstance(instance)
|
|
925
|
+
: this.recordsAccessor;
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
_proto.getRecords = function getRecords(context, instance, records, parentStore) {
|
|
929
|
+
if (!instance.recordStoreCache) this.initInstance(context, instance);
|
|
930
|
+
return this.mapRecords(context, instance, records, parentStore, instance.recordsAccessor);
|
|
931
|
+
};
|
|
932
|
+
_proto.mapRecords = function mapRecords(context, instance, records, parentStore, recordsAccessor) {
|
|
933
|
+
var _this = this;
|
|
934
|
+
var result = [];
|
|
935
|
+
if (!instance.recordStoreCache) this.initInstance(context, instance);
|
|
936
|
+
if (isArray(records))
|
|
937
|
+
records.forEach(function (data, index) {
|
|
938
|
+
if (_this.filterFn && !_this.filterFn(data)) return;
|
|
939
|
+
var record = _this.mapRecord(context, instance, data, parentStore, recordsAccessor, index);
|
|
940
|
+
result.push(record);
|
|
941
|
+
});
|
|
942
|
+
if (this.sorter) result = this.sorter(result);
|
|
943
|
+
return result;
|
|
944
|
+
};
|
|
945
|
+
_proto.mapRecord = function mapRecord(context, instance, data, parentStore, recordsAccessor, index) {
|
|
946
|
+
var recordStore = instance.recordStoreCache.get(data);
|
|
947
|
+
if (recordsAccessor) {
|
|
948
|
+
if (!recordStore)
|
|
949
|
+
recordStore = new ArrayElementView({
|
|
950
|
+
store: parentStore,
|
|
951
|
+
arrayAccessor: recordsAccessor,
|
|
952
|
+
itemIndex: index,
|
|
953
|
+
recordAlias: this.recordName,
|
|
954
|
+
indexAlias: this.indexName,
|
|
955
|
+
immutable: this.immutable,
|
|
956
|
+
sealed: this.sealed,
|
|
957
|
+
});
|
|
958
|
+
else {
|
|
959
|
+
recordStore.setStore(parentStore);
|
|
960
|
+
recordStore.setIndex(index);
|
|
961
|
+
}
|
|
962
|
+
} else {
|
|
963
|
+
var _data;
|
|
964
|
+
if (!recordStore)
|
|
965
|
+
recordStore = new ReadOnlyDataView({
|
|
966
|
+
store: parentStore,
|
|
967
|
+
data: ((_data = {}), (_data[this.recordName] = data), (_data[this.indexName] = index), _data),
|
|
968
|
+
immutable: this.immutable,
|
|
969
|
+
sealed: this.sealed,
|
|
970
|
+
});
|
|
971
|
+
else {
|
|
972
|
+
recordStore.setStore(parentStore);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
if (typeof data == "object") instance.recordStoreCache.set(data, recordStore);
|
|
976
|
+
return {
|
|
977
|
+
store: recordStore,
|
|
978
|
+
index: index,
|
|
979
|
+
data: data,
|
|
980
|
+
type: "data",
|
|
981
|
+
key: this.keyField ? data[this.keyField] : index,
|
|
982
|
+
};
|
|
983
|
+
};
|
|
984
|
+
_proto.setFilter = function setFilter(filterFn) {
|
|
985
|
+
this.filterFn = filterFn;
|
|
986
|
+
};
|
|
987
|
+
_proto.getComparer = function getComparer(sortOptions) {
|
|
988
|
+
return sortOptions ? Culture.getComparer(sortOptions) : null;
|
|
989
|
+
};
|
|
990
|
+
_proto.buildSorter = function buildSorter(sorters) {
|
|
991
|
+
var _this2 = this;
|
|
992
|
+
if (isArray(sorters) && sorters.length > 0) {
|
|
993
|
+
var fieldValueMapper;
|
|
994
|
+
var dataAccessor;
|
|
995
|
+
|
|
996
|
+
//if all sorters are based on record fields access data directly (faster)
|
|
997
|
+
if (
|
|
998
|
+
sorters.every(function (x) {
|
|
999
|
+
return x.field && x.value == null;
|
|
1000
|
+
})
|
|
1001
|
+
) {
|
|
1002
|
+
dataAccessor = function dataAccessor(x) {
|
|
1003
|
+
return x.data;
|
|
1004
|
+
};
|
|
1005
|
+
fieldValueMapper = function fieldValueMapper(x) {
|
|
1006
|
+
return {
|
|
1007
|
+
bind: x.field,
|
|
1008
|
+
};
|
|
1009
|
+
};
|
|
1010
|
+
} else {
|
|
1011
|
+
dataAccessor = function dataAccessor(x) {
|
|
1012
|
+
return x.store.getData();
|
|
1013
|
+
};
|
|
1014
|
+
fieldValueMapper = function fieldValueMapper(x) {
|
|
1015
|
+
return {
|
|
1016
|
+
bind: _this2.recordName + "." + x.field,
|
|
1017
|
+
};
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1020
|
+
this.sorter = sorter(
|
|
1021
|
+
sorters.map(function (x) {
|
|
1022
|
+
var s = Object.assign({}, x);
|
|
1023
|
+
if (s.field && s.value == null) s.value = fieldValueMapper(s);
|
|
1024
|
+
if (!s.comparer)
|
|
1025
|
+
s.comparer = _this2.getComparer(isDefined(s.sortOptions) ? s.sortOptions : _this2.sortOptions);
|
|
1026
|
+
return s;
|
|
1027
|
+
}),
|
|
1028
|
+
dataAccessor
|
|
1029
|
+
);
|
|
1030
|
+
} else {
|
|
1031
|
+
this.sorter = null;
|
|
1032
|
+
}
|
|
1033
|
+
};
|
|
1034
|
+
_proto.sort = function sort(sorters) {
|
|
1035
|
+
this.buildSorter(sorters);
|
|
1036
|
+
};
|
|
1037
|
+
return ArrayAdapter;
|
|
1038
|
+
})(DataAdapter);
|
|
1039
|
+
ArrayAdapter.prototype.immutable = false;
|
|
1040
|
+
ArrayAdapter.prototype.sealed = false;
|
|
1041
|
+
ArrayAdapter.autoInit = true;
|
|
1042
|
+
|
|
1043
|
+
var UseParentLayout = /*#__PURE__*/ (function (_PureContainer) {
|
|
1044
|
+
_inheritsLoose(UseParentLayout, _PureContainer);
|
|
1045
|
+
function UseParentLayout() {
|
|
1046
|
+
return _PureContainer.apply(this, arguments) || this;
|
|
1047
|
+
}
|
|
1048
|
+
return UseParentLayout;
|
|
1049
|
+
})(PureContainer);
|
|
1050
|
+
UseParentLayout.prototype.noLayout = true;
|
|
1051
|
+
UseParentLayout.prototype.useParentLayout = true;
|
|
1052
|
+
|
|
1053
|
+
var Repeater = /*#__PURE__*/ (function (_Container) {
|
|
1054
|
+
_inheritsLoose(Repeater, _Container);
|
|
1055
|
+
function Repeater() {
|
|
1056
|
+
return _Container.apply(this, arguments) || this;
|
|
1057
|
+
}
|
|
1058
|
+
var _proto = Repeater.prototype;
|
|
1059
|
+
_proto.declareData = function declareData() {
|
|
1060
|
+
var _Container$prototype$;
|
|
1061
|
+
(_Container$prototype$ = _Container.prototype.declareData).call.apply(
|
|
1062
|
+
_Container$prototype$,
|
|
1063
|
+
[
|
|
1064
|
+
this,
|
|
1065
|
+
{
|
|
1066
|
+
records: undefined,
|
|
1067
|
+
sorters: undefined,
|
|
1068
|
+
sortField: undefined,
|
|
1069
|
+
sortDirection: undefined,
|
|
1070
|
+
filterParams: {
|
|
1071
|
+
structured: true,
|
|
1072
|
+
},
|
|
1073
|
+
},
|
|
1074
|
+
].concat(Array.prototype.slice.call(arguments))
|
|
1075
|
+
);
|
|
1076
|
+
};
|
|
1077
|
+
_proto.init = function init() {
|
|
1078
|
+
this.recordsAccessor = getAccessor(this.records);
|
|
1079
|
+
if (this.recordAlias) this.recordName = this.recordAlias;
|
|
1080
|
+
if (this.indexAlias) this.indexName = this.indexAlias;
|
|
1081
|
+
this.dataAdapter = ArrayAdapter.create(
|
|
1082
|
+
_objectSpread2(
|
|
1083
|
+
_objectSpread2({}, this.dataAdapter),
|
|
1084
|
+
{},
|
|
1085
|
+
{
|
|
1086
|
+
recordName: this.recordName,
|
|
1087
|
+
indexName: this.indexName,
|
|
1088
|
+
keyField: this.keyField,
|
|
1089
|
+
immutable: this.immutable,
|
|
1090
|
+
sealed: this.sealed,
|
|
1091
|
+
recordsAccessor: this.recordsAccessor,
|
|
1092
|
+
sortOptions: this.sortOptions,
|
|
1093
|
+
}
|
|
1094
|
+
)
|
|
1095
|
+
);
|
|
1096
|
+
this.item = PureContainer.create({
|
|
1097
|
+
children: this.items || this.children,
|
|
1098
|
+
layout: UseParentLayout,
|
|
1099
|
+
});
|
|
1100
|
+
delete this.children;
|
|
1101
|
+
delete this.items;
|
|
1102
|
+
_Container.prototype.init.call(this);
|
|
1103
|
+
};
|
|
1104
|
+
_proto.initInstance = function initInstance(context, instance) {
|
|
1105
|
+
this.dataAdapter.initInstance(context, instance);
|
|
1106
|
+
};
|
|
1107
|
+
_proto.prepareData = function prepareData(context, instance) {
|
|
1108
|
+
var _this = this;
|
|
1109
|
+
var data = instance.data;
|
|
1110
|
+
if (data.sortField)
|
|
1111
|
+
data.sorters = [
|
|
1112
|
+
{
|
|
1113
|
+
field: data.sortField,
|
|
1114
|
+
direction: data.sortDirection || "ASC",
|
|
1115
|
+
},
|
|
1116
|
+
];
|
|
1117
|
+
this.dataAdapter.sort(data.sorters);
|
|
1118
|
+
var filter = null;
|
|
1119
|
+
if (this.onCreateFilter) filter = instance.invoke("onCreateFilter", data.filterParams, instance);
|
|
1120
|
+
else if (this.filter)
|
|
1121
|
+
filter = function filter(item) {
|
|
1122
|
+
return _this.filter(item, data.filterParams);
|
|
1123
|
+
};
|
|
1124
|
+
this.dataAdapter.setFilter(filter);
|
|
1125
|
+
instance.mappedRecords = this.dataAdapter.getRecords(context, instance, data.records, instance.store);
|
|
1126
|
+
_Container.prototype.prepareData.call(this, context, instance);
|
|
1127
|
+
};
|
|
1128
|
+
_proto.explore = function explore(context, instance, data) {
|
|
1129
|
+
var _this2 = this;
|
|
1130
|
+
var instances = [];
|
|
1131
|
+
instance.mappedRecords.forEach(function (record) {
|
|
1132
|
+
var subInstance = instance.getChild(context, _this2.item, record.key, record.store);
|
|
1133
|
+
var changed = subInstance.cache("recordData", record.data) || subInstance.cache("key", record.key);
|
|
1134
|
+
subInstance.record = record;
|
|
1135
|
+
if (_this2.cached && !changed && subInstance.visible && !subInstance.childStateDirty) {
|
|
1136
|
+
instances.push(subInstance);
|
|
1137
|
+
subInstance.shouldUpdate = false;
|
|
1138
|
+
} else if (subInstance.scheduleExploreIfVisible(context)) instances.push(subInstance);
|
|
1139
|
+
});
|
|
1140
|
+
instance.children = instances;
|
|
1141
|
+
};
|
|
1142
|
+
return Repeater;
|
|
1143
|
+
})(Container);
|
|
1144
|
+
Repeater.prototype.recordName = "$record";
|
|
1145
|
+
Repeater.prototype.indexName = "$index";
|
|
1146
|
+
Repeater.prototype.cached = false;
|
|
1147
|
+
Repeater.prototype.immutable = false;
|
|
1148
|
+
Repeater.prototype.sealed = false;
|
|
1149
|
+
Repeater.prototype.isPureContainer = true;
|
|
1150
|
+
Widget.alias("repeater", Repeater);
|
|
1151
|
+
|
|
1152
|
+
var StructuredInstanceDataAccessor = /*#__PURE__*/ (function () {
|
|
1153
|
+
function StructuredInstanceDataAccessor(config) {
|
|
1154
|
+
this.instance = config.instance;
|
|
1155
|
+
this.dataConfig = config.data;
|
|
1156
|
+
this.useParentStore = config.useParentStore;
|
|
1157
|
+
this.dataSelector = getSelector(config.data);
|
|
1158
|
+
if (this.dataSelector.memoize) this.dataSelector = this.dataSelector.memoize();
|
|
1159
|
+
}
|
|
1160
|
+
var _proto = StructuredInstanceDataAccessor.prototype;
|
|
1161
|
+
_proto.getSelector = function getSelector() {
|
|
1162
|
+
return this.dataSelector;
|
|
1163
|
+
};
|
|
1164
|
+
_proto.get = function get() {
|
|
1165
|
+
return this.dataSelector.get(this.instance.store.getData());
|
|
1166
|
+
};
|
|
1167
|
+
_proto.setItem = function setItem(key, value) {
|
|
1168
|
+
this.instance.nestedDataSet(key, value, this.dataConfig, this.useParentStore);
|
|
1169
|
+
};
|
|
1170
|
+
_proto.containsKey = function containsKey(key) {
|
|
1171
|
+
return this.dataConfig.hasOwnProperty(key);
|
|
1172
|
+
};
|
|
1173
|
+
_proto.getKeys = function getKeys() {
|
|
1174
|
+
return Object.keys(this.dataConfig);
|
|
1175
|
+
};
|
|
1176
|
+
return StructuredInstanceDataAccessor;
|
|
1177
|
+
})();
|
|
1178
|
+
|
|
1179
|
+
var Rescope = /*#__PURE__*/ (function (_PureContainer) {
|
|
1180
|
+
_inheritsLoose(Rescope, _PureContainer);
|
|
1181
|
+
function Rescope() {
|
|
1182
|
+
return _PureContainer.apply(this, arguments) || this;
|
|
1183
|
+
}
|
|
1184
|
+
var _proto = Rescope.prototype;
|
|
1185
|
+
_proto.init = function init() {
|
|
1186
|
+
this.binding = Binding.get(this.bind);
|
|
1187
|
+
if (this.rootAlias) this.rootName = this.rootAlias;
|
|
1188
|
+
_PureContainer.prototype.init.call(this);
|
|
1189
|
+
};
|
|
1190
|
+
_proto.initInstance = function initInstance(context, instance) {
|
|
1191
|
+
instance.store = new ZoomIntoPropertyView({
|
|
1192
|
+
store: instance.store,
|
|
1193
|
+
binding: this.binding,
|
|
1194
|
+
rootName: this.rootName,
|
|
1195
|
+
nestedData: isObject(this.data)
|
|
1196
|
+
? new StructuredInstanceDataAccessor({
|
|
1197
|
+
instance: instance,
|
|
1198
|
+
data: this.data,
|
|
1199
|
+
useParentStore: true,
|
|
1200
|
+
})
|
|
1201
|
+
: null,
|
|
1202
|
+
});
|
|
1203
|
+
instance.setStore = function (store) {
|
|
1204
|
+
instance.store.setStore(store);
|
|
1205
|
+
};
|
|
1206
|
+
};
|
|
1207
|
+
return Rescope;
|
|
1208
|
+
})(PureContainer);
|
|
1209
|
+
Rescope.prototype.bind = "$page";
|
|
1210
|
+
Rescope.prototype.rootName = "$root";
|
|
1211
|
+
Widget.alias("rescope", Rescope);
|
|
1212
|
+
|
|
1213
|
+
var isBatching = 0;
|
|
1214
|
+
var promiseSubscribers = new SubscriberList();
|
|
1215
|
+
function batchUpdates(callback) {
|
|
1216
|
+
if (VDOM.DOM.unstable_batchedUpdates)
|
|
1217
|
+
VDOM.DOM.unstable_batchedUpdates(function () {
|
|
1218
|
+
isBatching++;
|
|
1219
|
+
try {
|
|
1220
|
+
callback();
|
|
1221
|
+
} finally {
|
|
1222
|
+
isBatching--;
|
|
1223
|
+
}
|
|
1224
|
+
});
|
|
1225
|
+
else callback();
|
|
1226
|
+
}
|
|
1227
|
+
function isBatchingUpdates() {
|
|
1228
|
+
return isBatching > 0;
|
|
1229
|
+
}
|
|
1230
|
+
function notifyBatchedUpdateStarting() {
|
|
1231
|
+
promiseSubscribers.execute(function (x) {
|
|
1232
|
+
x.pending++;
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
function notifyBatchedUpdateCompleted() {
|
|
1236
|
+
promiseSubscribers.execute(function (x) {
|
|
1237
|
+
x.finished++;
|
|
1238
|
+
if (x.finished >= x.pending) x.complete(true);
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
var updateId = 0;
|
|
1242
|
+
function batchUpdatesAndNotify(callback, notifyCallback, timeout) {
|
|
1243
|
+
if (timeout === void 0) {
|
|
1244
|
+
timeout = 1000;
|
|
1245
|
+
}
|
|
1246
|
+
var update = {
|
|
1247
|
+
id: ++updateId,
|
|
1248
|
+
pending: 0,
|
|
1249
|
+
finished: 0,
|
|
1250
|
+
done: false,
|
|
1251
|
+
};
|
|
1252
|
+
update.unsubscribe = promiseSubscribers.subscribe(update);
|
|
1253
|
+
update.complete = function (success) {
|
|
1254
|
+
if (!update.done) {
|
|
1255
|
+
update.done = true;
|
|
1256
|
+
if (update.timer) clearInterval(update.timer);
|
|
1257
|
+
update.unsubscribe();
|
|
1258
|
+
notifyCallback(!!success);
|
|
1259
|
+
}
|
|
1260
|
+
};
|
|
1261
|
+
batchUpdates(callback);
|
|
1262
|
+
if (update.pending <= update.finished) update.complete(true);
|
|
1263
|
+
else update.timer = setTimeout(update.complete, timeout);
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
/*
|
|
1267
|
+
* Purpose of FocusManager is to provide focusout notifications.
|
|
1268
|
+
* IE and Firefox do not provide relatedTarget info in blur events which makes it impossible
|
|
1269
|
+
* to determine if focus went outside or stayed inside the component.
|
|
1270
|
+
*/
|
|
1271
|
+
|
|
1272
|
+
var subscribers$3 = new SubscriberList(),
|
|
1273
|
+
timerInterval = 300,
|
|
1274
|
+
timerId = null;
|
|
1275
|
+
var lastActiveElement = null;
|
|
1276
|
+
var pending = false;
|
|
1277
|
+
var FocusManager = /*#__PURE__*/ (function () {
|
|
1278
|
+
function FocusManager() {}
|
|
1279
|
+
FocusManager.subscribe = function subscribe(callback) {
|
|
1280
|
+
var unsubscribe = subscribers$3.subscribe(callback);
|
|
1281
|
+
checkTimer();
|
|
1282
|
+
return unsubscribe;
|
|
1283
|
+
};
|
|
1284
|
+
FocusManager.onFocusOut = function onFocusOut(el, callback) {
|
|
1285
|
+
var active = isSelfOrDescendant(el, getActiveElement());
|
|
1286
|
+
return this.subscribe(function (focusedEl) {
|
|
1287
|
+
if (!active) active = isSelfOrDescendant(el, getActiveElement());
|
|
1288
|
+
else if (!isSelfOrDescendant(el, focusedEl)) {
|
|
1289
|
+
active = false;
|
|
1290
|
+
callback(focusedEl);
|
|
1291
|
+
}
|
|
1292
|
+
});
|
|
1293
|
+
};
|
|
1294
|
+
FocusManager.oneFocusOut = function oneFocusOut(el, callback) {
|
|
1295
|
+
this.nudge();
|
|
1296
|
+
var off = this.subscribe(function (focusedEl) {
|
|
1297
|
+
if (!isSelfOrDescendant(el, focusedEl)) {
|
|
1298
|
+
callback(focusedEl);
|
|
1299
|
+
off();
|
|
1300
|
+
}
|
|
1301
|
+
});
|
|
1302
|
+
return off;
|
|
1303
|
+
};
|
|
1304
|
+
FocusManager.nudge = function nudge() {
|
|
1305
|
+
if (typeof document !== "undefined" && getActiveElement() !== lastActiveElement) {
|
|
1306
|
+
if (!pending) {
|
|
1307
|
+
pending = true;
|
|
1308
|
+
setTimeout(function () {
|
|
1309
|
+
pending = false;
|
|
1310
|
+
if (getActiveElement() !== lastActiveElement) {
|
|
1311
|
+
lastActiveElement = getActiveElement();
|
|
1312
|
+
batchUpdates(function () {
|
|
1313
|
+
subscribers$3.notify(lastActiveElement);
|
|
1314
|
+
});
|
|
1315
|
+
checkTimer();
|
|
1316
|
+
}
|
|
1317
|
+
}, 0);
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
};
|
|
1321
|
+
FocusManager.focus = function focus(el) {
|
|
1322
|
+
el.focus();
|
|
1323
|
+
this.nudge();
|
|
1324
|
+
};
|
|
1325
|
+
FocusManager.focusFirst = function focusFirst(el) {
|
|
1326
|
+
var focusable = findFirst(el, isFocusable);
|
|
1327
|
+
if (focusable) this.focus(focusable);
|
|
1328
|
+
return focusable;
|
|
1329
|
+
};
|
|
1330
|
+
FocusManager.focusFirstChild = function focusFirstChild(el) {
|
|
1331
|
+
var focusable = findFirstChild(el, isFocusable);
|
|
1332
|
+
if (focusable) this.focus(focusable);
|
|
1333
|
+
return focusable;
|
|
1334
|
+
};
|
|
1335
|
+
FocusManager.focusNext = function focusNext(el) {
|
|
1336
|
+
var next = el,
|
|
1337
|
+
skip = true;
|
|
1338
|
+
do {
|
|
1339
|
+
if (!skip) {
|
|
1340
|
+
var focusable = this.focusFirst(next);
|
|
1341
|
+
if (focusable) return focusable;
|
|
1342
|
+
}
|
|
1343
|
+
if (next.nextSibling) {
|
|
1344
|
+
next = next.nextSibling;
|
|
1345
|
+
skip = false;
|
|
1346
|
+
} else {
|
|
1347
|
+
next = next.parentNode;
|
|
1348
|
+
skip = true;
|
|
1349
|
+
}
|
|
1350
|
+
} while (next);
|
|
1351
|
+
};
|
|
1352
|
+
FocusManager.setInterval = function setInterval(interval) {
|
|
1353
|
+
timerInterval = interval;
|
|
1354
|
+
checkTimer();
|
|
1355
|
+
};
|
|
1356
|
+
return FocusManager;
|
|
1357
|
+
})();
|
|
1358
|
+
function oneFocusOut(component, el, callback) {
|
|
1359
|
+
if (!component.oneFocusOut)
|
|
1360
|
+
component.oneFocusOut = FocusManager.oneFocusOut(el, function (focus) {
|
|
1361
|
+
delete component.oneFocusOut;
|
|
1362
|
+
callback(focus);
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
function offFocusOut(component) {
|
|
1366
|
+
if (component.oneFocusOut) {
|
|
1367
|
+
component.oneFocusOut();
|
|
1368
|
+
delete component.oneFocusOut;
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
function preventFocus(e) {
|
|
1372
|
+
//Focus can be prevented only on mousedown event. On touchstart this will not work
|
|
1373
|
+
//preventDefault cannot be used as it prevents scrolling
|
|
1374
|
+
if (e.type !== "mousedown") return;
|
|
1375
|
+
e.preventDefault();
|
|
1376
|
+
unfocusElement(e.currentTarget, false);
|
|
1377
|
+
}
|
|
1378
|
+
function checkTimer() {
|
|
1379
|
+
var shouldRun = !subscribers$3.isEmpty();
|
|
1380
|
+
if (shouldRun && !timerId)
|
|
1381
|
+
timerId = setInterval(function () {
|
|
1382
|
+
FocusManager.nudge();
|
|
1383
|
+
}, timerInterval);
|
|
1384
|
+
if (!shouldRun && timerId) {
|
|
1385
|
+
clearInterval(timerId);
|
|
1386
|
+
timerId = null;
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
function preventFocusOnTouch(e, force) {
|
|
1390
|
+
if (force === void 0) {
|
|
1391
|
+
force = false;
|
|
1392
|
+
}
|
|
1393
|
+
if (force || isTouchEvent()) preventFocus(e);
|
|
1394
|
+
}
|
|
1395
|
+
function unfocusElement(target, unfocusParentOverlay) {
|
|
1396
|
+
if (target === void 0) {
|
|
1397
|
+
target = null;
|
|
1398
|
+
}
|
|
1399
|
+
if (unfocusParentOverlay === void 0) {
|
|
1400
|
+
unfocusParentOverlay = true;
|
|
1401
|
+
}
|
|
1402
|
+
var activeElement = getActiveElement();
|
|
1403
|
+
if (!target) target = activeElement;
|
|
1404
|
+
if (unfocusParentOverlay) {
|
|
1405
|
+
var focusableOverlayContainer = closestParent(target, function (el) {
|
|
1406
|
+
return el.dataset.focusableOverlayContainer;
|
|
1407
|
+
});
|
|
1408
|
+
if (focusableOverlayContainer) target = focusableOverlayContainer;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
//find the closest focusable parent of the target element and focus it instead
|
|
1412
|
+
var focusableParent = closestParent(target, function (el) {
|
|
1413
|
+
return isFocusable(el) && (!unfocusParentOverlay || el.dataset.focusableOverlayContainer);
|
|
1414
|
+
});
|
|
1415
|
+
if (focusableParent && focusableParent !== document.body) focusableParent.focus();
|
|
1416
|
+
else activeElement.blur();
|
|
1417
|
+
FocusManager.nudge();
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
var subscribers$2 = new SubscriberList();
|
|
1421
|
+
var ResizeManager = /*#__PURE__*/ (function () {
|
|
1422
|
+
function ResizeManager() {}
|
|
1423
|
+
ResizeManager.subscribe = function subscribe(callback) {
|
|
1424
|
+
return subscribers$2.subscribe(callback);
|
|
1425
|
+
};
|
|
1426
|
+
ResizeManager.notify = function notify() {
|
|
1427
|
+
batchUpdates(function () {
|
|
1428
|
+
subscribers$2.notify();
|
|
1429
|
+
});
|
|
1430
|
+
};
|
|
1431
|
+
ResizeManager.trackElement = function trackElement(el, callback) {
|
|
1432
|
+
if (typeof ResizeObserver !== "function") return this.subscribe(callback);
|
|
1433
|
+
var obs = new ResizeObserver(callback);
|
|
1434
|
+
obs.observe(el);
|
|
1435
|
+
return function () {
|
|
1436
|
+
obs.disconnect();
|
|
1437
|
+
};
|
|
1438
|
+
};
|
|
1439
|
+
return ResizeManager;
|
|
1440
|
+
})();
|
|
1441
|
+
if (typeof window != "undefined")
|
|
1442
|
+
window.addEventListener("resize", function () {
|
|
1443
|
+
return ResizeManager.notify();
|
|
1444
|
+
});
|
|
1445
|
+
|
|
1446
|
+
var lastZIndex = 10000;
|
|
1447
|
+
var ZIndexManager = /*#__PURE__*/ (function () {
|
|
1448
|
+
function ZIndexManager() {}
|
|
1449
|
+
ZIndexManager.next = function next() {
|
|
1450
|
+
return ++lastZIndex;
|
|
1451
|
+
};
|
|
1452
|
+
ZIndexManager.reset = function reset(zIndex) {
|
|
1453
|
+
lastZIndex = zIndex;
|
|
1454
|
+
};
|
|
1455
|
+
return ZIndexManager;
|
|
1456
|
+
})();
|
|
1457
|
+
|
|
1458
|
+
var Format = Format$1;
|
|
1459
|
+
var cultureSensitiveFormatsRegistered = false;
|
|
1460
|
+
function enableCultureSensitiveFormatting() {
|
|
1461
|
+
if (cultureSensitiveFormatsRegistered) return;
|
|
1462
|
+
cultureSensitiveFormatsRegistered = true;
|
|
1463
|
+
Format$1.registerFactory(["number", "n"], function (format, minimumFractionDigits, maximumFractionDigits) {
|
|
1464
|
+
var culture = Culture.getNumberCulture();
|
|
1465
|
+
var formatter = culture.getFormatter(resolveMinMaxFractionDigits(minimumFractionDigits, maximumFractionDigits));
|
|
1466
|
+
return function (value) {
|
|
1467
|
+
return formatter.format(value);
|
|
1468
|
+
};
|
|
1469
|
+
});
|
|
1470
|
+
Format$1.registerFactory("currency", function (format, currency, minimumFractionDigits, maximumFractionDigits) {
|
|
1471
|
+
var culture = Culture.getNumberCulture();
|
|
1472
|
+
currency = currency || Culture.defaultCurrency;
|
|
1473
|
+
var formatter = culture.getFormatter(
|
|
1474
|
+
_objectSpread2(
|
|
1475
|
+
{
|
|
1476
|
+
style: "currency",
|
|
1477
|
+
currency: currency,
|
|
1478
|
+
},
|
|
1479
|
+
resolveMinMaxFractionDigits(minimumFractionDigits, maximumFractionDigits)
|
|
1480
|
+
)
|
|
1481
|
+
);
|
|
1482
|
+
return function (value) {
|
|
1483
|
+
return formatter.format(value);
|
|
1484
|
+
};
|
|
1485
|
+
});
|
|
1486
|
+
Format$1.registerFactory(["percentage", "p", "%"], function (format, minimumFractionDigits, maximumFractionDigits) {
|
|
1487
|
+
var culture = Culture.getNumberCulture();
|
|
1488
|
+
var formatter = culture.getFormatter(
|
|
1489
|
+
_objectSpread2(
|
|
1490
|
+
{
|
|
1491
|
+
style: "percent",
|
|
1492
|
+
},
|
|
1493
|
+
resolveMinMaxFractionDigits(minimumFractionDigits, maximumFractionDigits)
|
|
1494
|
+
)
|
|
1495
|
+
);
|
|
1496
|
+
return function (value) {
|
|
1497
|
+
return formatter.format(value);
|
|
1498
|
+
};
|
|
1499
|
+
});
|
|
1500
|
+
Format$1.registerFactory(["percentSign", "ps"], function (format, minimumFractionDigits, maximumFractionDigits) {
|
|
1501
|
+
var culture = Culture.getNumberCulture();
|
|
1502
|
+
var formatter = culture.getFormatter(
|
|
1503
|
+
_objectSpread2(
|
|
1504
|
+
{
|
|
1505
|
+
style: "percent",
|
|
1506
|
+
},
|
|
1507
|
+
resolveMinMaxFractionDigits(minimumFractionDigits, maximumFractionDigits)
|
|
1508
|
+
)
|
|
1509
|
+
);
|
|
1510
|
+
return function (value) {
|
|
1511
|
+
return formatter.format(value / 100);
|
|
1512
|
+
};
|
|
1513
|
+
});
|
|
1514
|
+
Format$1.registerFactory(["date", "d"], function (fmt, format) {
|
|
1515
|
+
if (format === void 0) {
|
|
1516
|
+
format = "yyyyMMdd";
|
|
1517
|
+
}
|
|
1518
|
+
var culture = Culture.getDateTimeCulture();
|
|
1519
|
+
var formatter = culture.getFormatter(format);
|
|
1520
|
+
return function (value) {
|
|
1521
|
+
return formatter.format(new Date(value));
|
|
1522
|
+
};
|
|
1523
|
+
});
|
|
1524
|
+
Format$1.registerFactory(["time", "t"], function (fmt, format) {
|
|
1525
|
+
if (format === void 0) {
|
|
1526
|
+
format = "hhmmss";
|
|
1527
|
+
}
|
|
1528
|
+
var culture = Culture.getDateTimeCulture();
|
|
1529
|
+
var formatter = culture.getFormatter(format);
|
|
1530
|
+
return function (value) {
|
|
1531
|
+
return formatter.format(new Date(value));
|
|
1532
|
+
};
|
|
1533
|
+
});
|
|
1534
|
+
Format$1.registerFactory(["datetime", "dt"], function (fmt, format) {
|
|
1535
|
+
if (format === void 0) {
|
|
1536
|
+
format = "yyyyMd hhmm";
|
|
1537
|
+
}
|
|
1538
|
+
var culture = Culture.getDateTimeCulture();
|
|
1539
|
+
var formatter = culture.getFormatter(format);
|
|
1540
|
+
return function (value) {
|
|
1541
|
+
return formatter.format(new Date(value));
|
|
1542
|
+
};
|
|
1543
|
+
});
|
|
1544
|
+
GlobalCacheIdentifier.change();
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
var instanceId = 1000;
|
|
1548
|
+
var Instance = /*#__PURE__*/ (function () {
|
|
1549
|
+
function Instance(widget, key, parent, store) {
|
|
1550
|
+
this.widget = widget;
|
|
1551
|
+
this.key = key;
|
|
1552
|
+
this.id = String(++instanceId);
|
|
1553
|
+
this.cached = {};
|
|
1554
|
+
this.parent = parent;
|
|
1555
|
+
this.store = store;
|
|
1556
|
+
}
|
|
1557
|
+
var _proto = Instance.prototype;
|
|
1558
|
+
_proto.setStore = function setStore(store) {
|
|
1559
|
+
this.store = store;
|
|
1560
|
+
};
|
|
1561
|
+
_proto.init = function init(context) {
|
|
1562
|
+
//widget is initialized when first instance is initialized
|
|
1563
|
+
if (!this.widget.initialized) {
|
|
1564
|
+
this.widget.init(context);
|
|
1565
|
+
this.widget.initialized = true;
|
|
1566
|
+
}
|
|
1567
|
+
if (!this.dataSelector) {
|
|
1568
|
+
this.widget.selector.init(this.store);
|
|
1569
|
+
this.dataSelector = this.widget.selector.createStoreSelector();
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
//init instance might change the store, so it must go before the controller
|
|
1573
|
+
this.widget.initInstance(context, this);
|
|
1574
|
+
this.widget.initState(context, this);
|
|
1575
|
+
if (this.widget.controller)
|
|
1576
|
+
this.controller = Controller.create(this.widget.controller, {
|
|
1577
|
+
widget: this.widget,
|
|
1578
|
+
instance: this,
|
|
1579
|
+
store: this.store,
|
|
1580
|
+
});
|
|
1581
|
+
if (
|
|
1582
|
+
this.widget.exploreCleanup ||
|
|
1583
|
+
this.widget.outerLayout ||
|
|
1584
|
+
this.widget.isContent ||
|
|
1585
|
+
this.widget.controller ||
|
|
1586
|
+
this.widget.prepareCleanup
|
|
1587
|
+
)
|
|
1588
|
+
this.needsExploreCleanup = true;
|
|
1589
|
+
if (this.widget.prepare || this.widget.controller) this.needsPrepare = true;
|
|
1590
|
+
if (this.widget.cleanup || this.widget.controller) this.needsCleanup = true;
|
|
1591
|
+
this.initialized = true;
|
|
1592
|
+
};
|
|
1593
|
+
_proto.checkVisible = function checkVisible(context) {
|
|
1594
|
+
if (!this.initialized) this.init(context);
|
|
1595
|
+
var wasVisible = this.visible;
|
|
1596
|
+
this.rawData = this.dataSelector(this.store);
|
|
1597
|
+
this.visible = this.widget.checkVisible(context, this, this.rawData);
|
|
1598
|
+
if (this.visible && !this.detached) this.parent.instanceCache.addChild(this);
|
|
1599
|
+
this.explored = false;
|
|
1600
|
+
this.prepared = false;
|
|
1601
|
+
if (!this.visible && wasVisible) this.destroy();
|
|
1602
|
+
return this.visible;
|
|
1603
|
+
};
|
|
1604
|
+
_proto.scheduleExploreIfVisible = function scheduleExploreIfVisible(context) {
|
|
1605
|
+
if (this.checkVisible(context)) {
|
|
1606
|
+
context.exploreStack.push(this);
|
|
1607
|
+
if (this.needsExploreCleanup) context.exploreStack.push(this);
|
|
1608
|
+
return true;
|
|
1609
|
+
}
|
|
1610
|
+
return false;
|
|
1611
|
+
};
|
|
1612
|
+
_proto.cache = function cache(key, value) {
|
|
1613
|
+
var oldValue = this.cached[key];
|
|
1614
|
+
if (oldValue === value) return false;
|
|
1615
|
+
if (!this.cacheList) this.cacheList = {};
|
|
1616
|
+
this.cacheList[key] = value;
|
|
1617
|
+
return true;
|
|
1618
|
+
};
|
|
1619
|
+
_proto.markShouldUpdate = function markShouldUpdate(context) {
|
|
1620
|
+
var ins = this;
|
|
1621
|
+
var renderList = this.renderList;
|
|
1622
|
+
renderList.markReverseIndex();
|
|
1623
|
+
|
|
1624
|
+
//notify all parents that child state changed to bust up caching
|
|
1625
|
+
while (ins && !ins.shouldUpdate && ins.explored) {
|
|
1626
|
+
if (ins.renderList !== renderList) {
|
|
1627
|
+
renderList.reverse();
|
|
1628
|
+
renderList = ins.renderList;
|
|
1629
|
+
renderList.markReverseIndex();
|
|
1630
|
+
}
|
|
1631
|
+
ins.shouldUpdate = true;
|
|
1632
|
+
renderList.data.push(ins);
|
|
1633
|
+
ins = ins.widget.isContent
|
|
1634
|
+
? ins.contentPlaceholder
|
|
1635
|
+
: ins.parent.outerLayout === ins
|
|
1636
|
+
? ins.parent.parent
|
|
1637
|
+
: ins.parent;
|
|
1638
|
+
}
|
|
1639
|
+
renderList.reverse();
|
|
1640
|
+
};
|
|
1641
|
+
_proto.explore = function explore(context) {
|
|
1642
|
+
if (!this.visible) throw new Error("Explore invisible!");
|
|
1643
|
+
if (this.explored) {
|
|
1644
|
+
if (this.widget.prepareCleanup) context.prepareList.push(this);
|
|
1645
|
+
if (this.widget.exploreCleanup) this.widget.exploreCleanup(context, this);
|
|
1646
|
+
if (this.parent.outerLayout === this) context.popNamedValue("content", "body");
|
|
1647
|
+
if (this.widget.controller) context.pop("controller");
|
|
1648
|
+
return;
|
|
1649
|
+
}
|
|
1650
|
+
this.explored = true;
|
|
1651
|
+
if (this.needsPrepare) context.prepareList.push(this);
|
|
1652
|
+
else this.prepared = true;
|
|
1653
|
+
if (this.needsCleanup) context.cleanupList.push(this);
|
|
1654
|
+
if (this.instanceCache) this.instanceCache.mark();
|
|
1655
|
+
|
|
1656
|
+
//controller may reconfigure the widget and need to go before shouldUpdate calculation
|
|
1657
|
+
this.parentOptions = context.parentOptions;
|
|
1658
|
+
if (!this.controller) {
|
|
1659
|
+
if (context.controller) this.controller = context.controller;
|
|
1660
|
+
else if (this.parent.controller) this.controller = this.parent.controller;
|
|
1661
|
+
}
|
|
1662
|
+
this.destroyTracked = false;
|
|
1663
|
+
if (this.controller) {
|
|
1664
|
+
if (this.widget.controller) {
|
|
1665
|
+
if (!this.controller.initialized) {
|
|
1666
|
+
this.controller.init(context);
|
|
1667
|
+
this.controller.initialized = true;
|
|
1668
|
+
}
|
|
1669
|
+
context.push("controller", this.controller);
|
|
1670
|
+
this.controller.explore(context);
|
|
1671
|
+
if (this.controller.onDestroy && this.controller.widget == this.widget) this.trackDestroy();
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
if (this.widget.onDestroy || isNonEmptyArray(this.destroySubscriptions)) this.trackDestroy();
|
|
1675
|
+
this.renderList = this.assignedRenderList || this.parent.renderList || context.getRootRenderList();
|
|
1676
|
+
var shouldUpdate =
|
|
1677
|
+
this.rawData !== this.cached.rawData ||
|
|
1678
|
+
this.state !== this.cached.state ||
|
|
1679
|
+
this.widget.version !== this.cached.widgetVersion ||
|
|
1680
|
+
this.cached.globalCacheIdentifier !== GlobalCacheIdentifier.get();
|
|
1681
|
+
if (shouldUpdate) {
|
|
1682
|
+
this.data = _objectSpread2({}, this.rawData);
|
|
1683
|
+
this.widget.prepareData(context, this);
|
|
1684
|
+
debug(processDataFlag, this.widget);
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
//onExplore might set the outer layout
|
|
1688
|
+
if (this.widget.onExplore) this.widget.onExplore(context, this);
|
|
1689
|
+
if (this.parent.outerLayout === this) {
|
|
1690
|
+
this.renderList = this.renderList.insertRight();
|
|
1691
|
+
context.pushNamedValue("content", "body", this.parent);
|
|
1692
|
+
}
|
|
1693
|
+
if (this.widget.outerLayout) {
|
|
1694
|
+
this.outerLayout = this.getChild(context, this.widget.outerLayout, null, this.store);
|
|
1695
|
+
this.outerLayout.scheduleExploreIfVisible(context);
|
|
1696
|
+
this.renderList = this.renderList.insertLeft();
|
|
1697
|
+
}
|
|
1698
|
+
if (this.widget.isContent) {
|
|
1699
|
+
this.contentPlaceholder = context.contentPlaceholder && context.contentPlaceholder[this.widget.putInto];
|
|
1700
|
+
if (this.contentPlaceholder) context.contentPlaceholder[this.widget.putInto](this);
|
|
1701
|
+
else {
|
|
1702
|
+
this.renderList = this.renderList.insertLeft();
|
|
1703
|
+
context.pushNamedValue("content", this.widget.putInto, this);
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
this.shouldUpdate = false;
|
|
1707
|
+
if (shouldUpdate || this.childStateDirty || !this.widget.memoize) this.markShouldUpdate(context);
|
|
1708
|
+
context.exploreStack.hop();
|
|
1709
|
+
if (this.widget.helpers) {
|
|
1710
|
+
this.helpers = {};
|
|
1711
|
+
for (var cmp in this.widget.helpers) {
|
|
1712
|
+
var helper = this.widget.helpers[cmp];
|
|
1713
|
+
if (helper) {
|
|
1714
|
+
var ins = this.getChild(context, helper);
|
|
1715
|
+
if (ins.scheduleExploreIfVisible(context)) this.helpers[cmp] = ins;
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
this.widget.explore(context, this, this.data);
|
|
1720
|
+
};
|
|
1721
|
+
_proto.prepare = function prepare(context) {
|
|
1722
|
+
if (!this.visible) throw new Error("Prepare invisible!");
|
|
1723
|
+
if (this.prepared) {
|
|
1724
|
+
if (this.widget.prepareCleanup) this.widget.prepareCleanup(context, this);
|
|
1725
|
+
return;
|
|
1726
|
+
}
|
|
1727
|
+
this.prepared = true;
|
|
1728
|
+
if (this.widget.prepare) this.widget.prepare(context, this);
|
|
1729
|
+
if (this.widget.controller && this.controller.prepare) this.controller.prepare(context);
|
|
1730
|
+
};
|
|
1731
|
+
_proto.render = function render(context) {
|
|
1732
|
+
if (!this.visible) throw new Error("Render invisible!");
|
|
1733
|
+
if (this.shouldUpdate) {
|
|
1734
|
+
debug(renderFlag, this.widget, this.key);
|
|
1735
|
+
var vdom = renderResultFix(this.widget.render(context, this, this.key));
|
|
1736
|
+
if (this.widget.isContent || this.outerLayout) this.contentVDOM = vdom;
|
|
1737
|
+
else this.vdom = vdom;
|
|
1738
|
+
}
|
|
1739
|
+
if (this.cacheList) for (var key in this.cacheList) this.cached[key] = this.cacheList[key];
|
|
1740
|
+
this.cacheList = null;
|
|
1741
|
+
this.cached.rawData = this.rawData;
|
|
1742
|
+
this.cached.data = this.data;
|
|
1743
|
+
this.cached.state = this.state;
|
|
1744
|
+
this.cached.widgetVersion = this.widget.version;
|
|
1745
|
+
this.cached.globalCacheIdentifier = GlobalCacheIdentifier.get();
|
|
1746
|
+
this.childStateDirty = false;
|
|
1747
|
+
if (this.instanceCache) this.instanceCache.sweep();
|
|
1748
|
+
if (this.parent.outerLayout === this) {
|
|
1749
|
+
//if outer layouts are chained we need to find the originating element (last element with OL set)
|
|
1750
|
+
var parent = this.parent;
|
|
1751
|
+
while (parent.parent.outerLayout == parent) parent = parent.parent;
|
|
1752
|
+
parent.vdom = this.vdom;
|
|
1753
|
+
}
|
|
1754
|
+
return this.vdom;
|
|
1755
|
+
};
|
|
1756
|
+
_proto.cleanup = function cleanup(context) {
|
|
1757
|
+
if (this.widget.controller && this.controller.cleanup) this.controller.cleanup(context);
|
|
1758
|
+
if (this.widget.cleanup) this.widget.cleanup(context, this);
|
|
1759
|
+
};
|
|
1760
|
+
_proto.trackDestroy = function trackDestroy() {
|
|
1761
|
+
if (!this.destroyTracked) {
|
|
1762
|
+
this.destroyTracked = true;
|
|
1763
|
+
if (this.parent && !this.detached) this.parent.trackDestroyableChild(this);
|
|
1764
|
+
}
|
|
1765
|
+
};
|
|
1766
|
+
_proto.trackDestroyableChild = function trackDestroyableChild(child) {
|
|
1767
|
+
this.instanceCache.trackDestroy(child);
|
|
1768
|
+
this.trackDestroy();
|
|
1769
|
+
};
|
|
1770
|
+
_proto.subscribeOnDestroy = function subscribeOnDestroy(callback) {
|
|
1771
|
+
var _this = this;
|
|
1772
|
+
if (!this.destroySubscriptions) this.destroySubscriptions = [];
|
|
1773
|
+
this.destroySubscriptions.push(callback);
|
|
1774
|
+
this.trackDestroy();
|
|
1775
|
+
return function () {
|
|
1776
|
+
_this.destroySubscriptions &&
|
|
1777
|
+
_this.destroySubscriptions.filter(function (cb) {
|
|
1778
|
+
return cb != callback;
|
|
1779
|
+
});
|
|
1780
|
+
};
|
|
1781
|
+
};
|
|
1782
|
+
_proto.destroy = function destroy() {
|
|
1783
|
+
if (this.instanceCache) {
|
|
1784
|
+
this.instanceCache.destroy();
|
|
1785
|
+
this.instanceCache = null;
|
|
1786
|
+
}
|
|
1787
|
+
if (this.destroySubscriptions) {
|
|
1788
|
+
this.destroySubscriptions.forEach(function (cb) {
|
|
1789
|
+
return cb();
|
|
1790
|
+
});
|
|
1791
|
+
this.destroySubscriptions = null;
|
|
1792
|
+
}
|
|
1793
|
+
if (this.destroyTracked) {
|
|
1794
|
+
debug(destroyFlag, this);
|
|
1795
|
+
if (this.widget.onDestroy) this.widget.onDestroy(this);
|
|
1796
|
+
if (
|
|
1797
|
+
this.widget.controller &&
|
|
1798
|
+
this.controller &&
|
|
1799
|
+
this.controller.onDestroy &&
|
|
1800
|
+
this.controller.widget == this.widget
|
|
1801
|
+
)
|
|
1802
|
+
this.controller.onDestroy();
|
|
1803
|
+
this.destroyTracked = false;
|
|
1804
|
+
}
|
|
1805
|
+
};
|
|
1806
|
+
_proto.setState = function setState(state) {
|
|
1807
|
+
var _this2 = this;
|
|
1808
|
+
var skip = !!this.state;
|
|
1809
|
+
if (this.state)
|
|
1810
|
+
for (var k in state) {
|
|
1811
|
+
if (this.state[k] !== state[k]) {
|
|
1812
|
+
skip = false;
|
|
1813
|
+
break;
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
if (skip) return;
|
|
1817
|
+
this.state = Object.assign({}, this.state, state);
|
|
1818
|
+
var parent = this.parent;
|
|
1819
|
+
//notify all parents that child state change to bust up caching
|
|
1820
|
+
while (parent) {
|
|
1821
|
+
parent.childStateDirty = true;
|
|
1822
|
+
parent = parent.parent;
|
|
1823
|
+
}
|
|
1824
|
+
batchUpdates(function () {
|
|
1825
|
+
_this2.store.notify();
|
|
1826
|
+
});
|
|
1827
|
+
};
|
|
1828
|
+
_proto.set = function set(prop, value, options) {
|
|
1829
|
+
var _this3 = this;
|
|
1830
|
+
if (options === void 0) {
|
|
1831
|
+
options = {};
|
|
1832
|
+
}
|
|
1833
|
+
//skip re-rendering (used for reading state from uncontrolled components)
|
|
1834
|
+
if (options.internal && this.rawData) {
|
|
1835
|
+
this.rawData[prop] = value;
|
|
1836
|
+
this.data[prop] = value;
|
|
1837
|
+
}
|
|
1838
|
+
var setter = this.setters && this.setters[prop];
|
|
1839
|
+
if (setter) {
|
|
1840
|
+
if (options.immediate && isFunction(setter.reset)) setter.reset(value);
|
|
1841
|
+
else setter(value);
|
|
1842
|
+
return true;
|
|
1843
|
+
}
|
|
1844
|
+
var p = this.widget[prop];
|
|
1845
|
+
if (p && typeof p == "object") {
|
|
1846
|
+
if (p.debounce) {
|
|
1847
|
+
this.definePropertySetter(
|
|
1848
|
+
prop,
|
|
1849
|
+
validatedDebounce(
|
|
1850
|
+
function (value) {
|
|
1851
|
+
return _this3.doSet(prop, value);
|
|
1852
|
+
},
|
|
1853
|
+
function () {
|
|
1854
|
+
return _this3.dataSelector(_this3.store)[prop];
|
|
1855
|
+
},
|
|
1856
|
+
p.debounce
|
|
1857
|
+
)
|
|
1858
|
+
);
|
|
1859
|
+
this.set(prop, value, options);
|
|
1860
|
+
return true;
|
|
1861
|
+
}
|
|
1862
|
+
if (p.throttle) {
|
|
1863
|
+
this.definePropertySetter(
|
|
1864
|
+
prop,
|
|
1865
|
+
throttle(function (value) {
|
|
1866
|
+
return _this3.doSet(prop, value);
|
|
1867
|
+
}, p.throttle)
|
|
1868
|
+
);
|
|
1869
|
+
this.set(prop, value, options);
|
|
1870
|
+
return true;
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
return this.doSet(prop, value);
|
|
1874
|
+
};
|
|
1875
|
+
_proto.definePropertySetter = function definePropertySetter(prop, setter) {
|
|
1876
|
+
if (!this.setters) this.setters = {};
|
|
1877
|
+
this.setters[prop] = setter;
|
|
1878
|
+
};
|
|
1879
|
+
_proto.doSet = function doSet(prop, value) {
|
|
1880
|
+
var _this4 = this;
|
|
1881
|
+
var changed = false;
|
|
1882
|
+
batchUpdates(function () {
|
|
1883
|
+
var p = _this4.widget[prop];
|
|
1884
|
+
if (isObject(p)) {
|
|
1885
|
+
if (p.set) {
|
|
1886
|
+
if (isFunction(p.set)) {
|
|
1887
|
+
p.set(value, _this4);
|
|
1888
|
+
changed = true;
|
|
1889
|
+
} else if (isString(p.set)) {
|
|
1890
|
+
_this4.controller[p.set](value, _this4);
|
|
1891
|
+
changed = true;
|
|
1892
|
+
}
|
|
1893
|
+
} else if (p.action) {
|
|
1894
|
+
var action = p.action(value, _this4);
|
|
1895
|
+
_this4.store.dispatch(action);
|
|
1896
|
+
changed = true;
|
|
1897
|
+
} else if (isString(p.bind) || isAccessorChain(p.bind)) {
|
|
1898
|
+
changed = _this4.store.set(p.bind, value);
|
|
1899
|
+
}
|
|
1900
|
+
} else if (isAccessorChain(p)) changed = _this4.store.set(p.toString(), value);
|
|
1901
|
+
});
|
|
1902
|
+
return changed;
|
|
1903
|
+
};
|
|
1904
|
+
_proto.nestedDataSet = function nestedDataSet(key, value, dataConfig, useParentStore) {
|
|
1905
|
+
var config = dataConfig[key];
|
|
1906
|
+
if (!config)
|
|
1907
|
+
throw new Error(
|
|
1908
|
+
"Unknown nested data key " + key + ". Known keys are " + Object.keys(dataConfig).join(", ") + "."
|
|
1909
|
+
);
|
|
1910
|
+
if (isAccessorChain(config))
|
|
1911
|
+
config = {
|
|
1912
|
+
bind: config.toString(),
|
|
1913
|
+
};
|
|
1914
|
+
if (config.bind) {
|
|
1915
|
+
var store = this.store;
|
|
1916
|
+
//in case of Rescope or DataProxy, bindings point to the data in the parent store
|
|
1917
|
+
if (useParentStore && store.store) store = store.store;
|
|
1918
|
+
return isUndefined(value) ? store.deleteItem(config.bind) : store.setItem(config.bind, value);
|
|
1919
|
+
}
|
|
1920
|
+
if (!config.set)
|
|
1921
|
+
throw new Error(
|
|
1922
|
+
"Cannot change nested data value for " +
|
|
1923
|
+
key +
|
|
1924
|
+
" as it's read-only. Either define it as a binding or define a set function."
|
|
1925
|
+
);
|
|
1926
|
+
if (isString(config.set)) this.getControllerMethod(config.set)(value, this);
|
|
1927
|
+
else if (isFunction(config.set)) config.set(value, this);
|
|
1928
|
+
else
|
|
1929
|
+
throw new Error(
|
|
1930
|
+
"Cannot change nested data value for " +
|
|
1931
|
+
key +
|
|
1932
|
+
" the defined setter is neither a function nor a controller method."
|
|
1933
|
+
);
|
|
1934
|
+
return true;
|
|
1935
|
+
};
|
|
1936
|
+
_proto.replaceState = function replaceState(state) {
|
|
1937
|
+
this.cached.state = this.state;
|
|
1938
|
+
this.state = state;
|
|
1939
|
+
this.store.notify();
|
|
1940
|
+
};
|
|
1941
|
+
_proto.getInstanceCache = function getInstanceCache() {
|
|
1942
|
+
if (!this.instanceCache)
|
|
1943
|
+
this.instanceCache = new InstanceCache(this, this.widget.isPureContainer ? this.key : null);
|
|
1944
|
+
return this.instanceCache;
|
|
1945
|
+
};
|
|
1946
|
+
_proto.clearChildrenCache = function clearChildrenCache() {
|
|
1947
|
+
if (this.instanceCache) this.instanceCache.destroy();
|
|
1948
|
+
};
|
|
1949
|
+
_proto.getChild = function getChild(context, widget, key, store) {
|
|
1950
|
+
return this.getInstanceCache().getChild(widget, store || this.store, key);
|
|
1951
|
+
};
|
|
1952
|
+
_proto.getDetachedChild = function getDetachedChild(widget, key, store) {
|
|
1953
|
+
var child = new Instance(widget, key, this, store || this.store);
|
|
1954
|
+
child.detached = true;
|
|
1955
|
+
return child;
|
|
1956
|
+
};
|
|
1957
|
+
_proto.prepareRenderCleanupChild = function prepareRenderCleanupChild(widget, store, keyPrefix, options) {
|
|
1958
|
+
return widget.prepareRenderCleanup(store || this.store, options, keyPrefix, this);
|
|
1959
|
+
};
|
|
1960
|
+
_proto.getJsxEventProps = function getJsxEventProps() {
|
|
1961
|
+
var _this5 = this;
|
|
1962
|
+
var widget = this.widget;
|
|
1963
|
+
if (!isArray(widget.jsxAttributes)) return null;
|
|
1964
|
+
var props = {};
|
|
1965
|
+
widget.jsxAttributes.forEach(function (attr) {
|
|
1966
|
+
if (attr.indexOf("on") == 0 && attr.length > 2)
|
|
1967
|
+
props[attr] = function (e) {
|
|
1968
|
+
return _this5.invoke(attr, e, _this5);
|
|
1969
|
+
};
|
|
1970
|
+
});
|
|
1971
|
+
return props;
|
|
1972
|
+
};
|
|
1973
|
+
_proto.getCallback = function getCallback(methodName) {
|
|
1974
|
+
var scope = this.widget;
|
|
1975
|
+
var callback = scope[methodName];
|
|
1976
|
+
if (typeof callback === "string") return this.getControllerMethod(callback);
|
|
1977
|
+
if (typeof callback !== "function")
|
|
1978
|
+
throw new Error("Cannot invoke callback method " + methodName + " as assigned value is not a function.");
|
|
1979
|
+
return callback.bind(scope);
|
|
1980
|
+
};
|
|
1981
|
+
_proto.getControllerMethod = function getControllerMethod(methodName) {
|
|
1982
|
+
if (!this.controller)
|
|
1983
|
+
throw new Error(
|
|
1984
|
+
'Cannot invoke controller method "' + methodName + '" as controller is not assigned to the widget.'
|
|
1985
|
+
);
|
|
1986
|
+
var at = this;
|
|
1987
|
+
while (at != null && at.controller && !at.controller[methodName]) at = at.parent;
|
|
1988
|
+
if (!at || !at.controller || !at.controller[methodName])
|
|
1989
|
+
throw new Error(
|
|
1990
|
+
'Cannot invoke controller method "' +
|
|
1991
|
+
methodName +
|
|
1992
|
+
'". The method cannot be found in any of the assigned controllers.'
|
|
1993
|
+
);
|
|
1994
|
+
return at.controller[methodName].bind(at.controller);
|
|
1995
|
+
};
|
|
1996
|
+
_proto.invoke = function invoke(methodName) {
|
|
1997
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1998
|
+
args[_key - 1] = arguments[_key];
|
|
1999
|
+
}
|
|
2000
|
+
return this.getCallback(methodName).apply(null, args);
|
|
2001
|
+
};
|
|
2002
|
+
_proto.invokeControllerMethod = function invokeControllerMethod(methodName) {
|
|
2003
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
2004
|
+
args[_key2 - 1] = arguments[_key2];
|
|
2005
|
+
}
|
|
2006
|
+
return this.getControllerMethod(methodName).apply(null, args);
|
|
2007
|
+
};
|
|
2008
|
+
return Instance;
|
|
2009
|
+
})();
|
|
2010
|
+
function renderResultFix(res) {
|
|
2011
|
+
return res != null && isDefined(res.content)
|
|
2012
|
+
? res
|
|
2013
|
+
: {
|
|
2014
|
+
content: res,
|
|
2015
|
+
};
|
|
2016
|
+
}
|
|
2017
|
+
var InstanceCache = /*#__PURE__*/ (function () {
|
|
2018
|
+
function InstanceCache(parent, keyPrefix) {
|
|
2019
|
+
this.children = {};
|
|
2020
|
+
this.parent = parent;
|
|
2021
|
+
this.marked = {};
|
|
2022
|
+
this.monitored = null;
|
|
2023
|
+
this.keyPrefix = keyPrefix != null ? keyPrefix + "-" : "";
|
|
2024
|
+
}
|
|
2025
|
+
var _proto2 = InstanceCache.prototype;
|
|
2026
|
+
_proto2.getChild = function getChild(widget, store, key) {
|
|
2027
|
+
var k = this.keyPrefix + (key != null ? key : widget.vdomKey || widget.widgetId);
|
|
2028
|
+
var instance = this.children[k];
|
|
2029
|
+
if (
|
|
2030
|
+
!instance ||
|
|
2031
|
+
instance.widget !== widget ||
|
|
2032
|
+
(!instance.visible && (instance.widget.controller || instance.widget.onInit))
|
|
2033
|
+
) {
|
|
2034
|
+
instance = new Instance(widget, k, this.parent);
|
|
2035
|
+
this.children[k] = instance;
|
|
2036
|
+
}
|
|
2037
|
+
if (instance.store !== store) {
|
|
2038
|
+
instance.setStore(store);
|
|
2039
|
+
if (instance.cached) delete instance.cached.rawData; // force prepareData to execute again
|
|
2040
|
+
}
|
|
2041
|
+
|
|
2042
|
+
return instance;
|
|
2043
|
+
};
|
|
2044
|
+
_proto2.addChild = function addChild(instance) {
|
|
2045
|
+
this.marked[instance.key] = instance;
|
|
2046
|
+
};
|
|
2047
|
+
_proto2.mark = function mark() {
|
|
2048
|
+
this.marked = {};
|
|
2049
|
+
};
|
|
2050
|
+
_proto2.trackDestroy = function trackDestroy(instance) {
|
|
2051
|
+
if (!this.monitored) this.monitored = {};
|
|
2052
|
+
this.monitored[instance.key] = instance;
|
|
2053
|
+
};
|
|
2054
|
+
_proto2.destroy = function destroy() {
|
|
2055
|
+
this.children = {};
|
|
2056
|
+
this.marked = {};
|
|
2057
|
+
if (!this.monitored) return;
|
|
2058
|
+
for (var key in this.monitored) {
|
|
2059
|
+
this.monitored[key].destroy();
|
|
2060
|
+
}
|
|
2061
|
+
this.monitored = null;
|
|
2062
|
+
};
|
|
2063
|
+
_proto2.sweep = function sweep() {
|
|
2064
|
+
this.children = this.marked;
|
|
2065
|
+
if (!this.monitored) return;
|
|
2066
|
+
var activeCount = 0;
|
|
2067
|
+
for (var key in this.monitored) {
|
|
2068
|
+
var monitoredChild = this.monitored[key];
|
|
2069
|
+
var child = this.children[key];
|
|
2070
|
+
if (child !== monitoredChild || !monitoredChild.visible) {
|
|
2071
|
+
monitoredChild.destroy();
|
|
2072
|
+
delete this.monitored[key];
|
|
2073
|
+
if (child === monitoredChild) delete this.children[key];
|
|
2074
|
+
} else activeCount++;
|
|
2075
|
+
}
|
|
2076
|
+
if (activeCount === 0) this.monitored = null;
|
|
2077
|
+
};
|
|
2078
|
+
return InstanceCache;
|
|
2079
|
+
})();
|
|
2080
|
+
|
|
2081
|
+
var RenderingContext = /*#__PURE__*/ (function () {
|
|
2082
|
+
function RenderingContext(options) {
|
|
2083
|
+
this.options = options || {};
|
|
2084
|
+
this.exploreStack = new TraversalStack();
|
|
2085
|
+
this.prepareList = [];
|
|
2086
|
+
this.cleanupList = [];
|
|
2087
|
+
this.stacks = {};
|
|
2088
|
+
this.renderList = new LinkedListsNode();
|
|
2089
|
+
}
|
|
2090
|
+
var _proto = RenderingContext.prototype;
|
|
2091
|
+
_proto.getStack = function getStack(key) {
|
|
2092
|
+
var stack = this.stacks[key];
|
|
2093
|
+
if (!stack) stack = this.stacks[key] = [];
|
|
2094
|
+
return stack;
|
|
2095
|
+
};
|
|
2096
|
+
_proto.push = function push(key, value) {
|
|
2097
|
+
var stack = this.getStack(key);
|
|
2098
|
+
stack.push(this[key]);
|
|
2099
|
+
return (this[key] = value);
|
|
2100
|
+
};
|
|
2101
|
+
_proto.pop = function pop(key) {
|
|
2102
|
+
var stack = this.getStack(key);
|
|
2103
|
+
return (this[key] = stack.pop());
|
|
2104
|
+
};
|
|
2105
|
+
_proto.pushNamedValue = function pushNamedValue(key, name, value) {
|
|
2106
|
+
var stack = this.getStack(key + ":" + name);
|
|
2107
|
+
if (!this[key]) this[key] = {};
|
|
2108
|
+
stack.push(this[key][name]);
|
|
2109
|
+
return (this[key][name] = value);
|
|
2110
|
+
};
|
|
2111
|
+
_proto.popNamedValue = function popNamedValue(key, name) {
|
|
2112
|
+
var stack = this.getStack(key + ":" + name);
|
|
2113
|
+
return (this[key][name] = stack.pop());
|
|
2114
|
+
};
|
|
2115
|
+
_proto.get = function get(key) {
|
|
2116
|
+
return this[key];
|
|
2117
|
+
};
|
|
2118
|
+
_proto.getRootRenderList = function getRootRenderList() {
|
|
2119
|
+
var rl = this.renderList;
|
|
2120
|
+
while (rl.left) rl = rl.left;
|
|
2121
|
+
return rl;
|
|
2122
|
+
};
|
|
2123
|
+
return RenderingContext;
|
|
2124
|
+
})();
|
|
2125
|
+
var LinkedListsNode = /*#__PURE__*/ (function () {
|
|
2126
|
+
function LinkedListsNode(left, right) {
|
|
2127
|
+
this.left = left;
|
|
2128
|
+
this.right = right;
|
|
2129
|
+
this.data = [];
|
|
2130
|
+
}
|
|
2131
|
+
var _proto2 = LinkedListsNode.prototype;
|
|
2132
|
+
_proto2.insertLeft = function insertLeft() {
|
|
2133
|
+
var node = new LinkedListsNode(this.left, this);
|
|
2134
|
+
if (this.left) this.left.right = node;
|
|
2135
|
+
this.left = node;
|
|
2136
|
+
return node;
|
|
2137
|
+
};
|
|
2138
|
+
_proto2.insertRight = function insertRight() {
|
|
2139
|
+
var node = new LinkedListsNode(this, this.right);
|
|
2140
|
+
if (this.right) this.right.left = node;
|
|
2141
|
+
this.right = node;
|
|
2142
|
+
return node;
|
|
2143
|
+
};
|
|
2144
|
+
_proto2.markReverseIndex = function markReverseIndex() {
|
|
2145
|
+
this.reverseIndex = this.data.length;
|
|
2146
|
+
};
|
|
2147
|
+
_proto2.reverse = function reverse() {
|
|
2148
|
+
reverseSlice(this.data, this.reverseIndex);
|
|
2149
|
+
};
|
|
2150
|
+
return LinkedListsNode;
|
|
2151
|
+
})();
|
|
2152
|
+
|
|
2153
|
+
var Cx = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
2154
|
+
_inheritsLoose(Cx, _VDOM$Component);
|
|
2155
|
+
function Cx(props) {
|
|
2156
|
+
var _this;
|
|
2157
|
+
_this = _VDOM$Component.call(this, props) || this;
|
|
2158
|
+
if (props.instance) {
|
|
2159
|
+
_this.widget = props.instance.widget;
|
|
2160
|
+
_this.store = props.instance.store;
|
|
2161
|
+
} else {
|
|
2162
|
+
_this.widget = PureContainer.create({
|
|
2163
|
+
items: props.widget || props.items,
|
|
2164
|
+
});
|
|
2165
|
+
if (props.parentInstance) {
|
|
2166
|
+
_this.parentInstance = props.parentInstance;
|
|
2167
|
+
_this.store = props.store || _this.parentInstance.store;
|
|
2168
|
+
} else {
|
|
2169
|
+
_this.parentInstance = new Instance(_this.widget, 0);
|
|
2170
|
+
_this.store = props.store;
|
|
2171
|
+
}
|
|
2172
|
+
if (!_this.store) throw new Error("Cx component requires store.");
|
|
2173
|
+
}
|
|
2174
|
+
_this.state = {
|
|
2175
|
+
deferToken: 0,
|
|
2176
|
+
};
|
|
2177
|
+
if (props.subscribe) {
|
|
2178
|
+
_this.unsubscribe = _this.store.subscribe(_this.update.bind(_assertThisInitialized(_this)));
|
|
2179
|
+
_this.state.data = _this.store.getData();
|
|
2180
|
+
}
|
|
2181
|
+
_this.flags = {};
|
|
2182
|
+
_this.renderCount = 0;
|
|
2183
|
+
if (props.onError) _this.componentDidCatch = _this.componentDidCatchHandler.bind(_assertThisInitialized(_this));
|
|
2184
|
+
_this.forceUpdateCallback = _this.forceUpdate.bind(_assertThisInitialized(_this));
|
|
2185
|
+
_this.deferCounter = 0;
|
|
2186
|
+
_this.waitForIdle();
|
|
2187
|
+
return _this;
|
|
2188
|
+
}
|
|
2189
|
+
var _proto = Cx.prototype;
|
|
2190
|
+
_proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(props) {
|
|
2191
|
+
var newStore = props.instance ? props.instance.store : props.store ? props.store : props.parentInstance.store;
|
|
2192
|
+
if (newStore != this.store) {
|
|
2193
|
+
this.store = newStore;
|
|
2194
|
+
if (this.unsubscribe) this.unsubscribe();
|
|
2195
|
+
if (props.subscribe) this.unsubscribe = this.store.subscribe(this.update.bind(this));
|
|
2196
|
+
}
|
|
2197
|
+
if (props.subscribe) {
|
|
2198
|
+
var data = this.store.getData();
|
|
2199
|
+
if (data !== this.state.data) {
|
|
2200
|
+
this.waitForIdle();
|
|
2201
|
+
this.setState({
|
|
2202
|
+
data: data,
|
|
2203
|
+
});
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
};
|
|
2207
|
+
_proto.getInstance = function getInstance() {
|
|
2208
|
+
if (this.props.instance) return this.props.instance;
|
|
2209
|
+
if (this.instance && this.instance.widget === this.widget) {
|
|
2210
|
+
if (this.instance.store != this.store) this.instance.setStore(this.store);
|
|
2211
|
+
return this.instance;
|
|
2212
|
+
}
|
|
2213
|
+
if (this.widget && this.parentInstance)
|
|
2214
|
+
return (this.instance = this.parentInstance.getDetachedChild(this.widget, 0, this.store));
|
|
2215
|
+
throw new Error("Could not resolve a widget instance in the Cx component.");
|
|
2216
|
+
};
|
|
2217
|
+
_proto.render = function render() {
|
|
2218
|
+
if (this.props.deferredUntilIdle && this.state.deferToken < this.deferCounter) return null;
|
|
2219
|
+
return /*#__PURE__*/ jsx(CxContext, {
|
|
2220
|
+
instance: this.getInstance(),
|
|
2221
|
+
flags: this.flags,
|
|
2222
|
+
options: this.props.options,
|
|
2223
|
+
buster: ++this.renderCount,
|
|
2224
|
+
contentFactory: this.props.contentFactory,
|
|
2225
|
+
forceUpdate: this.forceUpdateCallback,
|
|
2226
|
+
});
|
|
2227
|
+
};
|
|
2228
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
2229
|
+
this.componentDidUpdate();
|
|
2230
|
+
if (this.props.options && this.props.options.onPipeUpdate) this.props.options.onPipeUpdate(this.update.bind(this));
|
|
2231
|
+
};
|
|
2232
|
+
_proto.componentDidUpdate = function componentDidUpdate() {
|
|
2233
|
+
if (this.flags.dirty) {
|
|
2234
|
+
this.update();
|
|
2235
|
+
}
|
|
2236
|
+
};
|
|
2237
|
+
_proto.update = function update() {
|
|
2238
|
+
var _this2 = this;
|
|
2239
|
+
var data = this.store.getData();
|
|
2240
|
+
debug(appDataFlag, data);
|
|
2241
|
+
if (this.flags.preparing) this.flags.dirty = true;
|
|
2242
|
+
else if (isBatchingUpdates() || this.props.immediate) {
|
|
2243
|
+
notifyBatchedUpdateStarting();
|
|
2244
|
+
this.setState(
|
|
2245
|
+
{
|
|
2246
|
+
data: data,
|
|
2247
|
+
},
|
|
2248
|
+
notifyBatchedUpdateCompleted
|
|
2249
|
+
);
|
|
2250
|
+
} else {
|
|
2251
|
+
//in standard mode sequential store commands are batched
|
|
2252
|
+
if (!this.pendingUpdateTimer) {
|
|
2253
|
+
notifyBatchedUpdateStarting();
|
|
2254
|
+
this.pendingUpdateTimer = setTimeout(function () {
|
|
2255
|
+
delete _this2.pendingUpdateTimer;
|
|
2256
|
+
_this2.setState(
|
|
2257
|
+
{
|
|
2258
|
+
data: data,
|
|
2259
|
+
},
|
|
2260
|
+
notifyBatchedUpdateCompleted
|
|
2261
|
+
);
|
|
2262
|
+
}, 0);
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2265
|
+
};
|
|
2266
|
+
_proto.waitForIdle = function waitForIdle() {
|
|
2267
|
+
var _this3 = this;
|
|
2268
|
+
if (!this.props.deferredUntilIdle) return;
|
|
2269
|
+
if (this.unsubscribeIdleRequest) this.unsubscribeIdleRequest();
|
|
2270
|
+
var token = ++this.deferCounter;
|
|
2271
|
+
this.unsubscribeIdleRequest = onIdleCallback(
|
|
2272
|
+
function () {
|
|
2273
|
+
_this3.setState({
|
|
2274
|
+
deferToken: token,
|
|
2275
|
+
});
|
|
2276
|
+
},
|
|
2277
|
+
{
|
|
2278
|
+
timeout: this.props.idleTimeout || 30000,
|
|
2279
|
+
}
|
|
2280
|
+
);
|
|
2281
|
+
};
|
|
2282
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
2283
|
+
if (this.pendingUpdateTimer) clearTimeout(this.pendingUpdateTimer);
|
|
2284
|
+
if (this.unsubscribeIdleRequest) this.unsubscribeIdleRequest();
|
|
2285
|
+
if (this.unsubscribe) this.unsubscribe();
|
|
2286
|
+
if (this.props.options && this.props.options.onPipeUpdate) this.props.options.onPipeUpdate(null);
|
|
2287
|
+
};
|
|
2288
|
+
_proto.shouldComponentUpdate = function shouldComponentUpdate(props, state) {
|
|
2289
|
+
if (props.deferredUntilIdle && state.deferToken != this.deferCounter) return false;
|
|
2290
|
+
return (
|
|
2291
|
+
state !== this.state ||
|
|
2292
|
+
!props.params ||
|
|
2293
|
+
!shallowEquals(props.params, this.props.params) ||
|
|
2294
|
+
props.instance !== this.props.instance ||
|
|
2295
|
+
props.widget !== this.props.widget ||
|
|
2296
|
+
props.store !== this.props.store ||
|
|
2297
|
+
props.parentInstance !== this.props.parentInstance
|
|
2298
|
+
);
|
|
2299
|
+
};
|
|
2300
|
+
_proto.componentDidCatchHandler = function componentDidCatchHandler(error, info) {
|
|
2301
|
+
this.flags.preparing = false;
|
|
2302
|
+
this.props.onError(error, this.getInstance(), info);
|
|
2303
|
+
};
|
|
2304
|
+
return Cx;
|
|
2305
|
+
})(VDOM.Component);
|
|
2306
|
+
var CxContext = /*#__PURE__*/ (function (_VDOM$Component2) {
|
|
2307
|
+
_inheritsLoose(CxContext, _VDOM$Component2);
|
|
2308
|
+
function CxContext(props) {
|
|
2309
|
+
var _this4;
|
|
2310
|
+
_this4 = _VDOM$Component2.call(this, props) || this;
|
|
2311
|
+
_this4.renderCount = 0;
|
|
2312
|
+
_this4.UNSAFE_componentWillReceiveProps(props);
|
|
2313
|
+
return _this4;
|
|
2314
|
+
}
|
|
2315
|
+
var _proto2 = CxContext.prototype;
|
|
2316
|
+
_proto2.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(props) {
|
|
2317
|
+
this.timings = {
|
|
2318
|
+
start: now(),
|
|
2319
|
+
};
|
|
2320
|
+
var instance = props.instance,
|
|
2321
|
+
options = props.options,
|
|
2322
|
+
contentFactory = props.contentFactory;
|
|
2323
|
+
var count = 0,
|
|
2324
|
+
visible,
|
|
2325
|
+
context;
|
|
2326
|
+
|
|
2327
|
+
//should not be tracked by parents for destroy
|
|
2328
|
+
if (!instance.detached)
|
|
2329
|
+
throw new Error("The instance passed to a Cx component should be detached from its parent.");
|
|
2330
|
+
if (this.props.instance !== instance && this.props.instance.destroyTracked) this.props.instance.destroy();
|
|
2331
|
+
this.props.flags.preparing = true;
|
|
2332
|
+
do {
|
|
2333
|
+
context = new RenderingContext(options);
|
|
2334
|
+
context.forceUpdate = this.props.forceUpdate;
|
|
2335
|
+
this.props.flags.dirty = false;
|
|
2336
|
+
instance.assignedRenderList = context.getRootRenderList();
|
|
2337
|
+
visible = instance.scheduleExploreIfVisible(context);
|
|
2338
|
+
if (visible) {
|
|
2339
|
+
while (!context.exploreStack.empty()) {
|
|
2340
|
+
var inst = context.exploreStack.pop();
|
|
2341
|
+
//console.log("EXPLORE", inst.widget.constructor.name, inst.widget.tag, inst.widget.widgetId);
|
|
2342
|
+
inst.explore(context);
|
|
2343
|
+
}
|
|
2344
|
+
} else if (instance.destroyTracked) {
|
|
2345
|
+
instance.destroy();
|
|
2346
|
+
break;
|
|
2347
|
+
}
|
|
2348
|
+
} while (this.props.flags.dirty && ++count <= 3 && Widget.optimizePrepare && now() - this.timings.start < 8);
|
|
2349
|
+
if (visible) {
|
|
2350
|
+
this.timings.afterExplore = now();
|
|
2351
|
+
for (var i = 0; i < context.prepareList.length; i++) context.prepareList[i].prepare(context);
|
|
2352
|
+
this.timings.afterPrepare = now();
|
|
2353
|
+
|
|
2354
|
+
//walk in reverse order so children get rendered first
|
|
2355
|
+
var renderList = context.getRootRenderList();
|
|
2356
|
+
while (renderList) {
|
|
2357
|
+
for (var _i = renderList.data.length - 1; _i >= 0; _i--) {
|
|
2358
|
+
renderList.data[_i].render(context);
|
|
2359
|
+
}
|
|
2360
|
+
renderList = renderList.right;
|
|
2361
|
+
}
|
|
2362
|
+
this.content = getContent(instance.vdom);
|
|
2363
|
+
if (contentFactory)
|
|
2364
|
+
this.content = contentFactory({
|
|
2365
|
+
children: this.content,
|
|
2366
|
+
});
|
|
2367
|
+
this.timings.afterRender = now();
|
|
2368
|
+
for (var _i2 = 0; _i2 < context.cleanupList.length; _i2++) context.cleanupList[_i2].cleanup(context);
|
|
2369
|
+
} else {
|
|
2370
|
+
this.content = null;
|
|
2371
|
+
this.timings.afterExplore = this.timings.afterPrepare = this.timings.afterRender = now();
|
|
2372
|
+
}
|
|
2373
|
+
this.timings.beforeVDOMRender = now();
|
|
2374
|
+
this.props.flags.preparing = false;
|
|
2375
|
+
this.props.flags.rendering = true;
|
|
2376
|
+
this.renderingContext = context;
|
|
2377
|
+
};
|
|
2378
|
+
_proto2.render = function render() {
|
|
2379
|
+
return this.content;
|
|
2380
|
+
};
|
|
2381
|
+
_proto2.componentDidMount = function componentDidMount() {
|
|
2382
|
+
this.componentDidUpdate();
|
|
2383
|
+
};
|
|
2384
|
+
_proto2.componentDidUpdate = function componentDidUpdate() {
|
|
2385
|
+
this.props.flags.rendering = false;
|
|
2386
|
+
this.timings.afterVDOMRender = now();
|
|
2387
|
+
|
|
2388
|
+
//let {instance} = this.props;
|
|
2389
|
+
//instance.cleanup(this.renderingContext);
|
|
2390
|
+
|
|
2391
|
+
this.timings.afterCleanup = now();
|
|
2392
|
+
this.renderCount++;
|
|
2393
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2394
|
+
var _this$timings = this.timings,
|
|
2395
|
+
start = _this$timings.start,
|
|
2396
|
+
beforeVDOMRender = _this$timings.beforeVDOMRender,
|
|
2397
|
+
afterVDOMRender = _this$timings.afterVDOMRender,
|
|
2398
|
+
afterPrepare = _this$timings.afterPrepare,
|
|
2399
|
+
afterExplore = _this$timings.afterExplore,
|
|
2400
|
+
afterRender = _this$timings.afterRender,
|
|
2401
|
+
afterCleanup = _this$timings.afterCleanup;
|
|
2402
|
+
Timing.log(
|
|
2403
|
+
vdomRenderFlag,
|
|
2404
|
+
this.renderCount,
|
|
2405
|
+
"cx",
|
|
2406
|
+
(beforeVDOMRender - start + afterCleanup - afterVDOMRender).toFixed(2) + "ms",
|
|
2407
|
+
"vdom",
|
|
2408
|
+
(afterVDOMRender - beforeVDOMRender).toFixed(2) + "ms"
|
|
2409
|
+
);
|
|
2410
|
+
Timing.log(
|
|
2411
|
+
appLoopFlag,
|
|
2412
|
+
this.renderCount,
|
|
2413
|
+
this.renderingContext.options.name || "main",
|
|
2414
|
+
"total",
|
|
2415
|
+
(afterCleanup - start).toFixed(1) + "ms",
|
|
2416
|
+
"explore",
|
|
2417
|
+
(afterExplore - start).toFixed(1) + "ms",
|
|
2418
|
+
"prepare",
|
|
2419
|
+
(afterPrepare - afterExplore).toFixed(1),
|
|
2420
|
+
"render",
|
|
2421
|
+
(afterRender - afterPrepare).toFixed(1),
|
|
2422
|
+
"vdom",
|
|
2423
|
+
(afterVDOMRender - beforeVDOMRender).toFixed(1),
|
|
2424
|
+
"cleanup",
|
|
2425
|
+
(afterCleanup - afterVDOMRender).toFixed(1)
|
|
2426
|
+
);
|
|
2427
|
+
}
|
|
2428
|
+
};
|
|
2429
|
+
_proto2.componentWillUnmount = function componentWillUnmount() {
|
|
2430
|
+
var instance = this.props.instance;
|
|
2431
|
+
if (instance.destroyTracked) instance.destroy();
|
|
2432
|
+
};
|
|
2433
|
+
return CxContext;
|
|
2434
|
+
})(VDOM.Component);
|
|
2435
|
+
|
|
2436
|
+
var ContentResolver = /*#__PURE__*/ (function (_PureContainer) {
|
|
2437
|
+
_inheritsLoose(ContentResolver, _PureContainer);
|
|
2438
|
+
function ContentResolver() {
|
|
2439
|
+
return _PureContainer.apply(this, arguments) || this;
|
|
2440
|
+
}
|
|
2441
|
+
var _proto = ContentResolver.prototype;
|
|
2442
|
+
_proto.declareData = function declareData() {
|
|
2443
|
+
var _PureContainer$protot;
|
|
2444
|
+
return (_PureContainer$protot = _PureContainer.prototype.declareData).call.apply(
|
|
2445
|
+
_PureContainer$protot,
|
|
2446
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
2447
|
+
{
|
|
2448
|
+
params: {
|
|
2449
|
+
structured: true,
|
|
2450
|
+
},
|
|
2451
|
+
loading: undefined,
|
|
2452
|
+
},
|
|
2453
|
+
])
|
|
2454
|
+
);
|
|
2455
|
+
};
|
|
2456
|
+
_proto.init = function init() {
|
|
2457
|
+
_PureContainer.prototype.init.call(this);
|
|
2458
|
+
this.initialItems = this.layout ? this.layout.items : this.items;
|
|
2459
|
+
this.clear();
|
|
2460
|
+
};
|
|
2461
|
+
_proto.initInstance = function initInstance(context, instance) {
|
|
2462
|
+
instance.content = this.initialItems;
|
|
2463
|
+
instance.cachedParams = {}; //unique value which will never pass the equality check
|
|
2464
|
+
};
|
|
2465
|
+
_proto.prepareData = function prepareData(context, instance) {
|
|
2466
|
+
var _this = this;
|
|
2467
|
+
var data = instance.data;
|
|
2468
|
+
if (data.params !== instance.cachedParams && this.onResolve) {
|
|
2469
|
+
instance.cachedParams = data.params;
|
|
2470
|
+
var content = instance.invoke("onResolve", data.params, instance);
|
|
2471
|
+
if (isPromise(content)) {
|
|
2472
|
+
instance.set("loading", true);
|
|
2473
|
+
this.setContent(instance, null);
|
|
2474
|
+
content.then(function (cnt) {
|
|
2475
|
+
_this.setContent(instance, cnt);
|
|
2476
|
+
instance.setState({
|
|
2477
|
+
cacheBuster: {},
|
|
2478
|
+
});
|
|
2479
|
+
instance.set("loading", false);
|
|
2480
|
+
});
|
|
2481
|
+
} else this.setContent(instance, content);
|
|
2482
|
+
}
|
|
2483
|
+
};
|
|
2484
|
+
_proto.setContent = function setContent(instance, content) {
|
|
2485
|
+
if (content) {
|
|
2486
|
+
this.clear();
|
|
2487
|
+
switch (this.mode) {
|
|
2488
|
+
case "prepend":
|
|
2489
|
+
this.add(content);
|
|
2490
|
+
this.add(this.initialItems);
|
|
2491
|
+
break;
|
|
2492
|
+
case "append":
|
|
2493
|
+
this.add(this.initialItems);
|
|
2494
|
+
this.add(content);
|
|
2495
|
+
break;
|
|
2496
|
+
case "replace":
|
|
2497
|
+
this.add(content);
|
|
2498
|
+
break;
|
|
2499
|
+
}
|
|
2500
|
+
instance.content = this.layout ? this.layout.items : this.items;
|
|
2501
|
+
this.clear();
|
|
2502
|
+
} else instance.content = this.initialItems;
|
|
2503
|
+
};
|
|
2504
|
+
_proto.explore = function explore(context, instance) {
|
|
2505
|
+
//a little bit hacky
|
|
2506
|
+
if (this.layout) this.layout.items = instance.content;
|
|
2507
|
+
else this.items = instance.content;
|
|
2508
|
+
_PureContainer.prototype.explore.call(this, context, instance);
|
|
2509
|
+
};
|
|
2510
|
+
return ContentResolver;
|
|
2511
|
+
})(PureContainer);
|
|
2512
|
+
ContentResolver.prototype.mode = "replace";
|
|
2513
|
+
|
|
2514
|
+
var IsolatedScope = /*#__PURE__*/ (function (_PureContainer) {
|
|
2515
|
+
_inheritsLoose(IsolatedScope, _PureContainer);
|
|
2516
|
+
function IsolatedScope() {
|
|
2517
|
+
return _PureContainer.apply(this, arguments) || this;
|
|
2518
|
+
}
|
|
2519
|
+
var _proto = IsolatedScope.prototype;
|
|
2520
|
+
_proto.declareData = function declareData() {
|
|
2521
|
+
var _PureContainer$protot;
|
|
2522
|
+
return (_PureContainer$protot = _PureContainer.prototype.declareData).call.apply(
|
|
2523
|
+
_PureContainer$protot,
|
|
2524
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
2525
|
+
{
|
|
2526
|
+
data: {
|
|
2527
|
+
structured: true,
|
|
2528
|
+
},
|
|
2529
|
+
},
|
|
2530
|
+
])
|
|
2531
|
+
);
|
|
2532
|
+
};
|
|
2533
|
+
_proto.init = function init() {
|
|
2534
|
+
var _this = this;
|
|
2535
|
+
if (typeof this.bind === "string")
|
|
2536
|
+
this.data = {
|
|
2537
|
+
bind: this.bind,
|
|
2538
|
+
};
|
|
2539
|
+
else if (isArray(this.bind)) {
|
|
2540
|
+
this.data = {};
|
|
2541
|
+
this.bind.forEach(function (x, i) {
|
|
2542
|
+
_this.data[String(i)] = {
|
|
2543
|
+
bind: x,
|
|
2544
|
+
};
|
|
2545
|
+
});
|
|
2546
|
+
}
|
|
2547
|
+
_PureContainer.prototype.init.call(this);
|
|
2548
|
+
};
|
|
2549
|
+
_proto.explore = function explore(context, instance) {
|
|
2550
|
+
if (instance.shouldUpdate) {
|
|
2551
|
+
_PureContainer.prototype.explore.call(this, context, instance);
|
|
2552
|
+
}
|
|
2553
|
+
};
|
|
2554
|
+
return IsolatedScope;
|
|
2555
|
+
})(PureContainer);
|
|
2556
|
+
|
|
2557
|
+
var DetachedScope = /*#__PURE__*/ (function (_IsolatedScope) {
|
|
2558
|
+
_inheritsLoose(DetachedScope, _IsolatedScope);
|
|
2559
|
+
function DetachedScope() {
|
|
2560
|
+
return _IsolatedScope.apply(this, arguments) || this;
|
|
2561
|
+
}
|
|
2562
|
+
var _proto = DetachedScope.prototype;
|
|
2563
|
+
_proto.declareData = function declareData() {
|
|
2564
|
+
var _IsolatedScope$protot;
|
|
2565
|
+
return (_IsolatedScope$protot = _IsolatedScope.prototype.declareData).call.apply(
|
|
2566
|
+
_IsolatedScope$protot,
|
|
2567
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
2568
|
+
{
|
|
2569
|
+
exclusiveData: {
|
|
2570
|
+
structured: true,
|
|
2571
|
+
},
|
|
2572
|
+
},
|
|
2573
|
+
])
|
|
2574
|
+
);
|
|
2575
|
+
};
|
|
2576
|
+
_proto.init = function init() {
|
|
2577
|
+
var _this = this;
|
|
2578
|
+
if (typeof this.exclusive === "string")
|
|
2579
|
+
this.exclusiveData = {
|
|
2580
|
+
bind: this.exclusive,
|
|
2581
|
+
};
|
|
2582
|
+
if (Array.isArray(this.exclusive)) {
|
|
2583
|
+
this.exclusiveData = {};
|
|
2584
|
+
this.exclusive.forEach(function (x, i) {
|
|
2585
|
+
_this.exclusiveData[String(i)] = {
|
|
2586
|
+
bind: x,
|
|
2587
|
+
};
|
|
2588
|
+
});
|
|
2589
|
+
}
|
|
2590
|
+
this.container = PureContainer.create({
|
|
2591
|
+
type: PureContainer,
|
|
2592
|
+
items: this.children || this.items,
|
|
2593
|
+
});
|
|
2594
|
+
delete this.items;
|
|
2595
|
+
delete this.children;
|
|
2596
|
+
if (this.name)
|
|
2597
|
+
this.options = _objectSpread2(
|
|
2598
|
+
_objectSpread2({}, this.options),
|
|
2599
|
+
{},
|
|
2600
|
+
{
|
|
2601
|
+
name: this.name,
|
|
2602
|
+
}
|
|
2603
|
+
);
|
|
2604
|
+
_IsolatedScope.prototype.init.call(this);
|
|
2605
|
+
};
|
|
2606
|
+
_proto.initInstance = function initInstance(context, instance) {
|
|
2607
|
+
instance.subStore = new ContainmentStore({
|
|
2608
|
+
store: instance.store,
|
|
2609
|
+
selector: getSelector(this.exclusiveData || this.data),
|
|
2610
|
+
});
|
|
2611
|
+
};
|
|
2612
|
+
_proto.render = function render(context, instance, key) {
|
|
2613
|
+
return /*#__PURE__*/ jsx(
|
|
2614
|
+
Cx,
|
|
2615
|
+
{
|
|
2616
|
+
widget: this.container,
|
|
2617
|
+
store: instance.subStore,
|
|
2618
|
+
parentInstance: instance,
|
|
2619
|
+
subscribe: true,
|
|
2620
|
+
options: this.options,
|
|
2621
|
+
onError: this.onError,
|
|
2622
|
+
},
|
|
2623
|
+
key
|
|
2624
|
+
);
|
|
2625
|
+
};
|
|
2626
|
+
return DetachedScope;
|
|
2627
|
+
})(IsolatedScope);
|
|
2628
|
+
var ContainmentStore = /*#__PURE__*/ (function (_SubscribableView) {
|
|
2629
|
+
_inheritsLoose(ContainmentStore, _SubscribableView);
|
|
2630
|
+
function ContainmentStore() {
|
|
2631
|
+
return _SubscribableView.apply(this, arguments) || this;
|
|
2632
|
+
}
|
|
2633
|
+
var _proto2 = ContainmentStore.prototype;
|
|
2634
|
+
_proto2.getData = function getData() {
|
|
2635
|
+
return this.store.getData();
|
|
2636
|
+
};
|
|
2637
|
+
_proto2.setItem = function setItem() {
|
|
2638
|
+
var _this2 = this;
|
|
2639
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2640
|
+
args[_key] = arguments[_key];
|
|
2641
|
+
}
|
|
2642
|
+
return this.wrapper(function () {
|
|
2643
|
+
var _this2$store;
|
|
2644
|
+
(_this2$store = _this2.store).setItem.apply(_this2$store, args);
|
|
2645
|
+
});
|
|
2646
|
+
};
|
|
2647
|
+
_proto2.deleteItem = function deleteItem() {
|
|
2648
|
+
var _this3 = this;
|
|
2649
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
2650
|
+
args[_key2] = arguments[_key2];
|
|
2651
|
+
}
|
|
2652
|
+
return this.wrapper(function () {
|
|
2653
|
+
var _this3$store;
|
|
2654
|
+
(_this3$store = _this3.store).deleteItem.apply(_this3$store, args);
|
|
2655
|
+
});
|
|
2656
|
+
};
|
|
2657
|
+
_proto2.wrapper = function wrapper(callback) {
|
|
2658
|
+
if (this.store.silently(callback)) {
|
|
2659
|
+
var data = this.getData();
|
|
2660
|
+
var containedData = this.selector(data);
|
|
2661
|
+
if (containedData === this.cache.containedData) {
|
|
2662
|
+
this.store.notify();
|
|
2663
|
+
} else {
|
|
2664
|
+
this.cache.containedData = containedData;
|
|
2665
|
+
this.notify();
|
|
2666
|
+
}
|
|
2667
|
+
return true;
|
|
2668
|
+
}
|
|
2669
|
+
return false;
|
|
2670
|
+
};
|
|
2671
|
+
return ContainmentStore;
|
|
2672
|
+
})(SubscribableView);
|
|
2673
|
+
|
|
2674
|
+
var persistenceCache = {};
|
|
2675
|
+
var Restate = /*#__PURE__*/ (function (_PureContainer) {
|
|
2676
|
+
_inheritsLoose(Restate, _PureContainer);
|
|
2677
|
+
function Restate() {
|
|
2678
|
+
return _PureContainer.apply(this, arguments) || this;
|
|
2679
|
+
}
|
|
2680
|
+
var _proto = Restate.prototype;
|
|
2681
|
+
_proto.declareData = function declareData() {
|
|
2682
|
+
var _PureContainer$protot;
|
|
2683
|
+
return (_PureContainer$protot = _PureContainer.prototype.declareData).call.apply(
|
|
2684
|
+
_PureContainer$protot,
|
|
2685
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
2686
|
+
{
|
|
2687
|
+
deferredUntilIdle: undefined,
|
|
2688
|
+
idleTimeout: undefined,
|
|
2689
|
+
cacheKey: undefined,
|
|
2690
|
+
},
|
|
2691
|
+
])
|
|
2692
|
+
);
|
|
2693
|
+
};
|
|
2694
|
+
_proto.init = function init() {
|
|
2695
|
+
this.container = PureContainer.create({
|
|
2696
|
+
type: PureContainer,
|
|
2697
|
+
items: this.children || this.items,
|
|
2698
|
+
layout: this.layout,
|
|
2699
|
+
controller: this.controller,
|
|
2700
|
+
outerLayout: this.outerLayout,
|
|
2701
|
+
useParentLayout: !this.detached,
|
|
2702
|
+
ws: this.ws,
|
|
2703
|
+
});
|
|
2704
|
+
this.privateDataSelector = new StructuredSelector({
|
|
2705
|
+
props: this.data || {},
|
|
2706
|
+
values: this.data,
|
|
2707
|
+
});
|
|
2708
|
+
delete this.items;
|
|
2709
|
+
delete this.children;
|
|
2710
|
+
delete this.controller;
|
|
2711
|
+
delete this.outerLayout;
|
|
2712
|
+
delete this.layout;
|
|
2713
|
+
if (this.useParentLayout == null) this.useParentLayout = !this.detached;
|
|
2714
|
+
_PureContainer.prototype.init.call(this);
|
|
2715
|
+
};
|
|
2716
|
+
_proto.initSubStore = function initSubStore(context, instance) {
|
|
2717
|
+
var _this = this;
|
|
2718
|
+
var cacheKey = instance.data.cacheKey;
|
|
2719
|
+
this.privateDataSelector.init(instance.store);
|
|
2720
|
+
instance.subStore = new RestateStore({
|
|
2721
|
+
store: instance.store,
|
|
2722
|
+
detached: this.detached,
|
|
2723
|
+
privateData: this.data || {},
|
|
2724
|
+
data: cacheKey ? persistenceCache[cacheKey] || {} : {},
|
|
2725
|
+
dataSelector: this.privateDataSelector.create(),
|
|
2726
|
+
onSet: function onSet(path, value) {
|
|
2727
|
+
return instance.nestedDataSet(path, value, _this.data);
|
|
2728
|
+
},
|
|
2729
|
+
});
|
|
2730
|
+
instance.setStore = function (store) {
|
|
2731
|
+
instance.store = store;
|
|
2732
|
+
instance.subStore.setStore(store);
|
|
2733
|
+
};
|
|
2734
|
+
if (cacheKey) {
|
|
2735
|
+
instance.subscribeOnDestroy(function () {
|
|
2736
|
+
persistenceCache[cacheKey] = instance.subStore.getData();
|
|
2737
|
+
});
|
|
2738
|
+
}
|
|
2739
|
+
};
|
|
2740
|
+
_proto.explore = function explore(context, instance) {
|
|
2741
|
+
if (!instance.subStore) this.initSubStore(context, instance);
|
|
2742
|
+
if (instance.subStore.parentDataCheck()) instance.markShouldUpdate();
|
|
2743
|
+
_PureContainer.prototype.explore.call(this, context, instance);
|
|
2744
|
+
};
|
|
2745
|
+
_proto.exploreItems = function exploreItems(context, instance, items) {
|
|
2746
|
+
if (!this.detached) {
|
|
2747
|
+
instance.container = instance.getChild(context, this.container, "container", instance.subStore);
|
|
2748
|
+
instance.container.scheduleExploreIfVisible(context);
|
|
2749
|
+
instance.children = [instance.container];
|
|
2750
|
+
}
|
|
2751
|
+
};
|
|
2752
|
+
_proto.render = function render(context, instance, key) {
|
|
2753
|
+
if (!this.detached) return instance.container.render(context);
|
|
2754
|
+
return /*#__PURE__*/ jsx(
|
|
2755
|
+
Cx,
|
|
2756
|
+
{
|
|
2757
|
+
widget: this.container,
|
|
2758
|
+
parentInstance: instance,
|
|
2759
|
+
store: instance.subStore,
|
|
2760
|
+
subscribe: true,
|
|
2761
|
+
options: this.options,
|
|
2762
|
+
onError: this.onError,
|
|
2763
|
+
deferredUntilIdle: instance.data.deferredUntilIdle,
|
|
2764
|
+
idleTimeout: instance.data.idleTimeout,
|
|
2765
|
+
},
|
|
2766
|
+
key
|
|
2767
|
+
);
|
|
2768
|
+
};
|
|
2769
|
+
return Restate;
|
|
2770
|
+
})(PureContainer);
|
|
2771
|
+
Restate.prototype.detached = false;
|
|
2772
|
+
Restate.prototype.waitForIdle = false;
|
|
2773
|
+
var PrivateStore = Restate;
|
|
2774
|
+
var RestateStore = /*#__PURE__*/ (function (_Store) {
|
|
2775
|
+
_inheritsLoose(RestateStore, _Store);
|
|
2776
|
+
function RestateStore(config) {
|
|
2777
|
+
var _this2;
|
|
2778
|
+
_this2 = _Store.call(this, config) || this;
|
|
2779
|
+
_this2.parentDataVersion = -1;
|
|
2780
|
+
return _this2;
|
|
2781
|
+
}
|
|
2782
|
+
var _proto2 = RestateStore.prototype;
|
|
2783
|
+
_proto2.getData = function getData() {
|
|
2784
|
+
var _this3 = this;
|
|
2785
|
+
this.silently(function () {
|
|
2786
|
+
_this3.parentDataCheck();
|
|
2787
|
+
});
|
|
2788
|
+
return _Store.prototype.getData.call(this);
|
|
2789
|
+
};
|
|
2790
|
+
_proto2.parentDataCheck = function parentDataCheck() {
|
|
2791
|
+
var _this4 = this;
|
|
2792
|
+
if (this.parentDataVersion == this.store.meta.version) return false;
|
|
2793
|
+
this.parentDataVersion = this.store.meta.version;
|
|
2794
|
+
this.parentData = this.dataSelector(this.store.getData());
|
|
2795
|
+
return this.batch(function () {
|
|
2796
|
+
for (var key in _this4.parentData) {
|
|
2797
|
+
_Store.prototype.setItem.call(_this4, key, _this4.parentData[key]);
|
|
2798
|
+
}
|
|
2799
|
+
});
|
|
2800
|
+
};
|
|
2801
|
+
_proto2.setItem = function setItem(path, value) {
|
|
2802
|
+
var _this5 = this;
|
|
2803
|
+
var binding = Binding.get(path);
|
|
2804
|
+
var bindingRoot = binding.parts[0];
|
|
2805
|
+
if (!isObject(this.privateData) || !this.privateData.hasOwnProperty(bindingRoot)) {
|
|
2806
|
+
var changed = isUndefined(value)
|
|
2807
|
+
? _Store.prototype.deleteItem.call(this, path)
|
|
2808
|
+
: _Store.prototype.setItem.call(this, path, value);
|
|
2809
|
+
return changed;
|
|
2810
|
+
}
|
|
2811
|
+
var newValue = value;
|
|
2812
|
+
if (binding.parts.length > 1) newValue = binding.set(this.getData(), value)[bindingRoot];
|
|
2813
|
+
this.onSet(bindingRoot, newValue);
|
|
2814
|
+
this.batch(function () {
|
|
2815
|
+
_Store.prototype.setItem.call(_this5, bindingRoot, newValue);
|
|
2816
|
+
_this5.parentDataCheck();
|
|
2817
|
+
});
|
|
2818
|
+
return true;
|
|
2819
|
+
};
|
|
2820
|
+
_proto2.deleteItem = function deleteItem(path) {
|
|
2821
|
+
return this.setItem(path, undefined);
|
|
2822
|
+
};
|
|
2823
|
+
_proto2.doNotify = function doNotify() {
|
|
2824
|
+
if (!this.detached) this.store.notify();
|
|
2825
|
+
_Store.prototype.doNotify.call(this);
|
|
2826
|
+
};
|
|
2827
|
+
return RestateStore;
|
|
2828
|
+
})(Store);
|
|
2829
|
+
|
|
2830
|
+
var DataProxy = /*#__PURE__*/ (function (_PureContainer) {
|
|
2831
|
+
_inheritsLoose(DataProxy, _PureContainer);
|
|
2832
|
+
function DataProxy() {
|
|
2833
|
+
return _PureContainer.apply(this, arguments) || this;
|
|
2834
|
+
}
|
|
2835
|
+
var _proto = DataProxy.prototype;
|
|
2836
|
+
_proto.init = function init() {
|
|
2837
|
+
if (!this.data) this.data = {};
|
|
2838
|
+
if (this.alias) this.data[this.alias] = this.value;
|
|
2839
|
+
|
|
2840
|
+
//not sure why nesting is needed, commenting for now
|
|
2841
|
+
// this.container = PureContainer.create({
|
|
2842
|
+
// type: PureContainer,
|
|
2843
|
+
// items: this.children || this.items,
|
|
2844
|
+
// layout: this.layout,
|
|
2845
|
+
// controller: this.controller,
|
|
2846
|
+
// outerLayout: this.outerLayout,
|
|
2847
|
+
// ws: this.ws,
|
|
2848
|
+
// });
|
|
2849
|
+
// this.children = [this.container];
|
|
2850
|
+
// delete this.items;
|
|
2851
|
+
// delete this.controller;
|
|
2852
|
+
// delete this.outerLayout;
|
|
2853
|
+
// this.layout = UseParentLayout;
|
|
2854
|
+
_PureContainer.prototype.init.call(this);
|
|
2855
|
+
};
|
|
2856
|
+
_proto.initInstance = function initInstance(context, instance) {
|
|
2857
|
+
instance.store = new NestedDataView({
|
|
2858
|
+
store: instance.store,
|
|
2859
|
+
nestedData: new StructuredInstanceDataAccessor({
|
|
2860
|
+
instance: instance,
|
|
2861
|
+
data: this.data,
|
|
2862
|
+
useParentStore: true,
|
|
2863
|
+
}),
|
|
2864
|
+
immutable: this.immutable,
|
|
2865
|
+
sealed: this.sealed,
|
|
2866
|
+
});
|
|
2867
|
+
instance.setStore = function (store) {
|
|
2868
|
+
instance.store.setStore(store);
|
|
2869
|
+
};
|
|
2870
|
+
};
|
|
2871
|
+
return DataProxy;
|
|
2872
|
+
})(PureContainer);
|
|
2873
|
+
DataProxy.prototype.immutable = false;
|
|
2874
|
+
DataProxy.prototype.sealed = false;
|
|
2875
|
+
|
|
2876
|
+
var subscribers$1,
|
|
2877
|
+
eventBan = 0;
|
|
2878
|
+
function executeKeyboardShortcuts(e) {
|
|
2879
|
+
if (Date.now() < eventBan) return;
|
|
2880
|
+
//Avoid duplicate executions as event.stopPropagation() for React events does not stop native events
|
|
2881
|
+
eventBan = Date.now() + 5;
|
|
2882
|
+
subscribers$1 && subscribers$1.notify(e);
|
|
2883
|
+
}
|
|
2884
|
+
function registerKeyboardShortcut(key, callback) {
|
|
2885
|
+
var keyCode = isObject(key) ? key.keyCode : key;
|
|
2886
|
+
var shiftKey = isObject(key) ? key.shiftKey : false;
|
|
2887
|
+
var ctrlKey = isObject(key) ? key.ctrlKey : false;
|
|
2888
|
+
var altKey = isObject(key) ? key.altKey : false;
|
|
2889
|
+
if (!subscribers$1) {
|
|
2890
|
+
subscribers$1 = new SubscriberList();
|
|
2891
|
+
document.addEventListener("keydown", function (e) {
|
|
2892
|
+
if (e.target == document.body) executeKeyboardShortcuts(e);
|
|
2893
|
+
});
|
|
2894
|
+
}
|
|
2895
|
+
return subscribers$1.subscribe(function (e) {
|
|
2896
|
+
if (e.keyCode == keyCode && (!shiftKey || e.shiftKey) && (!ctrlKey || e.ctrlKey) && (!altKey || e.altKey))
|
|
2897
|
+
callback(e);
|
|
2898
|
+
});
|
|
2899
|
+
}
|
|
2900
|
+
|
|
2901
|
+
var HoverSync = /*#__PURE__*/ (function (_PureContainer) {
|
|
2902
|
+
_inheritsLoose(HoverSync, _PureContainer);
|
|
2903
|
+
function HoverSync() {
|
|
2904
|
+
return _PureContainer.apply(this, arguments) || this;
|
|
2905
|
+
}
|
|
2906
|
+
var _proto = HoverSync.prototype;
|
|
2907
|
+
_proto.initInstance = function initInstance(context, instance) {
|
|
2908
|
+
var channels = {};
|
|
2909
|
+
instance.hoverSync = {
|
|
2910
|
+
report: function report(channel, hoverId, active) {
|
|
2911
|
+
var ch = channels[channel];
|
|
2912
|
+
if (!ch) return;
|
|
2913
|
+
var state = active && hoverId;
|
|
2914
|
+
if (ch.state !== state && (ch.state === hoverId || active)) {
|
|
2915
|
+
ch.state = state;
|
|
2916
|
+
ch.subscribers.notify(state);
|
|
2917
|
+
}
|
|
2918
|
+
},
|
|
2919
|
+
subscribe: function subscribe(channel, callback) {
|
|
2920
|
+
var ch = channels[channel];
|
|
2921
|
+
if (!ch)
|
|
2922
|
+
ch = channels[channel] = {
|
|
2923
|
+
subscribers: new SubscriberList(),
|
|
2924
|
+
state: false,
|
|
2925
|
+
};
|
|
2926
|
+
return ch.subscribers.subscribe(callback);
|
|
2927
|
+
},
|
|
2928
|
+
};
|
|
2929
|
+
};
|
|
2930
|
+
_proto.explore = function explore(context, instance) {
|
|
2931
|
+
context.push("hoverSync", instance.hoverSync);
|
|
2932
|
+
_PureContainer.prototype.explore.call(this, context, instance);
|
|
2933
|
+
};
|
|
2934
|
+
_proto.exploreCleanup = function exploreCleanup(context, instance) {
|
|
2935
|
+
context.pop("hoverSync");
|
|
2936
|
+
};
|
|
2937
|
+
return HoverSync;
|
|
2938
|
+
})(PureContainer);
|
|
2939
|
+
var HoverSyncChild = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
2940
|
+
_inheritsLoose(HoverSyncChild, _VDOM$Component);
|
|
2941
|
+
function HoverSyncChild(props) {
|
|
2942
|
+
var _this;
|
|
2943
|
+
_this = _VDOM$Component.call(this, props) || this;
|
|
2944
|
+
_this.state = {
|
|
2945
|
+
hover: false,
|
|
2946
|
+
};
|
|
2947
|
+
_this.onMouseMove = _this.onMouseMove.bind(_assertThisInitialized(_this));
|
|
2948
|
+
_this.onMouseLeave = _this.onMouseLeave.bind(_assertThisInitialized(_this));
|
|
2949
|
+
return _this;
|
|
2950
|
+
}
|
|
2951
|
+
var _proto2 = HoverSyncChild.prototype;
|
|
2952
|
+
_proto2.onMouseMove = function onMouseMove() {
|
|
2953
|
+
this.props.hoverSync.report(this.props.hoverChannel, this.props.hoverId, true);
|
|
2954
|
+
};
|
|
2955
|
+
_proto2.onMouseLeave = function onMouseLeave() {
|
|
2956
|
+
this.props.hoverSync.report(this.props.hoverChannel, this.props.hoverId, false);
|
|
2957
|
+
};
|
|
2958
|
+
_proto2.compontentWillUnmount = function compontentWillUnmount() {
|
|
2959
|
+
this.unsubscribe();
|
|
2960
|
+
};
|
|
2961
|
+
_proto2.componentDidMount = function componentDidMount() {
|
|
2962
|
+
var _this2 = this;
|
|
2963
|
+
this.unsubscribe = this.props.hoverSync.subscribe(this.props.hoverChannel, function (hoverId) {
|
|
2964
|
+
var hover = hoverId === _this2.props.hoverId;
|
|
2965
|
+
if (hover !== _this2.state.hover)
|
|
2966
|
+
_this2.setState({
|
|
2967
|
+
hover: hover,
|
|
2968
|
+
});
|
|
2969
|
+
});
|
|
2970
|
+
};
|
|
2971
|
+
_proto2.render = function render() {
|
|
2972
|
+
return this.props.render({
|
|
2973
|
+
hover: this.state.hover,
|
|
2974
|
+
onMouseLeave: this.onMouseLeave,
|
|
2975
|
+
onMouseMove: this.onMouseMove,
|
|
2976
|
+
key: "child",
|
|
2977
|
+
});
|
|
2978
|
+
};
|
|
2979
|
+
return HoverSyncChild;
|
|
2980
|
+
})(VDOM$1.Component);
|
|
2981
|
+
function withHoverSync(key, hoverSync, hoverChannel, hoverId, render) {
|
|
2982
|
+
if (!hoverSync || !hoverChannel || hoverId == null)
|
|
2983
|
+
return render({
|
|
2984
|
+
key: key,
|
|
2985
|
+
hover: false,
|
|
2986
|
+
onMouseLeave: dummyCallback,
|
|
2987
|
+
onMouseMove: dummyCallback,
|
|
2988
|
+
});
|
|
2989
|
+
return /*#__PURE__*/ jsx(
|
|
2990
|
+
HoverSyncChild,
|
|
2991
|
+
{
|
|
2992
|
+
hoverSync: hoverSync,
|
|
2993
|
+
hoverChannel: hoverChannel,
|
|
2994
|
+
hoverId: hoverId,
|
|
2995
|
+
render: render,
|
|
2996
|
+
},
|
|
2997
|
+
key
|
|
2998
|
+
);
|
|
2999
|
+
}
|
|
3000
|
+
var HoverSyncElement = /*#__PURE__*/ (function (_Container) {
|
|
3001
|
+
_inheritsLoose(HoverSyncElement, _Container);
|
|
3002
|
+
function HoverSyncElement() {
|
|
3003
|
+
return _Container.apply(this, arguments) || this;
|
|
3004
|
+
}
|
|
3005
|
+
var _proto3 = HoverSyncElement.prototype;
|
|
3006
|
+
_proto3.declareData = function declareData() {
|
|
3007
|
+
var _Container$prototype$;
|
|
3008
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3009
|
+
args[_key] = arguments[_key];
|
|
3010
|
+
}
|
|
3011
|
+
(_Container$prototype$ = _Container.prototype.declareData).call.apply(
|
|
3012
|
+
_Container$prototype$,
|
|
3013
|
+
[this].concat(args, [
|
|
3014
|
+
{
|
|
3015
|
+
hoverId: undefined,
|
|
3016
|
+
hoverClass: {
|
|
3017
|
+
structured: true,
|
|
3018
|
+
},
|
|
3019
|
+
hoverStyle: {
|
|
3020
|
+
structured: true,
|
|
3021
|
+
},
|
|
3022
|
+
},
|
|
3023
|
+
])
|
|
3024
|
+
);
|
|
3025
|
+
};
|
|
3026
|
+
_proto3.prepareData = function prepareData(context, instance) {
|
|
3027
|
+
instance.hoverSync = context.hoverSync;
|
|
3028
|
+
instance.inSvg = !!context.inSvg;
|
|
3029
|
+
var data = instance.data;
|
|
3030
|
+
data.hoverStyle = parseStyle(data.hoverStyle);
|
|
3031
|
+
_Container.prototype.prepareData.call(this, context, instance);
|
|
3032
|
+
};
|
|
3033
|
+
_proto3.render = function render(context, instance, key) {
|
|
3034
|
+
var data = instance.data,
|
|
3035
|
+
inSvg = instance.inSvg;
|
|
3036
|
+
var CSS = this.CSS;
|
|
3037
|
+
var children = this.renderChildren(context, instance);
|
|
3038
|
+
var eventHandlers = instance.getJsxEventProps();
|
|
3039
|
+
return withHoverSync(key, instance.hoverSync, this.hoverChannel, data.hoverId, function (_ref) {
|
|
3040
|
+
var hover = _ref.hover,
|
|
3041
|
+
onMouseMove = _ref.onMouseMove,
|
|
3042
|
+
onMouseLeave = _ref.onMouseLeave,
|
|
3043
|
+
key = _ref.key;
|
|
3044
|
+
var style = _objectSpread2(_objectSpread2({}, data.style), hover && data.hoverStyle);
|
|
3045
|
+
return VDOM$1.createElement(
|
|
3046
|
+
inSvg ? "g" : "div",
|
|
3047
|
+
_objectSpread2(
|
|
3048
|
+
_objectSpread2(
|
|
3049
|
+
{
|
|
3050
|
+
key: key,
|
|
3051
|
+
className: CSS.expand(
|
|
3052
|
+
data.classNames,
|
|
3053
|
+
CSS.state({
|
|
3054
|
+
hover: hover,
|
|
3055
|
+
}),
|
|
3056
|
+
hover && data.hoverClass
|
|
3057
|
+
),
|
|
3058
|
+
style: style,
|
|
3059
|
+
},
|
|
3060
|
+
eventHandlers
|
|
3061
|
+
),
|
|
3062
|
+
{},
|
|
3063
|
+
{
|
|
3064
|
+
onMouseLeave: onMouseLeave,
|
|
3065
|
+
onMouseMove: onMouseMove,
|
|
3066
|
+
}
|
|
3067
|
+
),
|
|
3068
|
+
children
|
|
3069
|
+
);
|
|
3070
|
+
});
|
|
3071
|
+
};
|
|
3072
|
+
return HoverSyncElement;
|
|
3073
|
+
})(Container);
|
|
3074
|
+
HoverSyncElement.prototype.baseClass = "hoversyncelement";
|
|
3075
|
+
HoverSyncElement.prototype.styled = true;
|
|
3076
|
+
HoverSyncElement.prototype.hoverChannel = "default";
|
|
3077
|
+
|
|
3078
|
+
var flattenProps = function flattenProps(props) {
|
|
3079
|
+
if (!props) return {};
|
|
3080
|
+
if (props.jsxSpread) {
|
|
3081
|
+
props = _objectSpread2(
|
|
3082
|
+
_objectSpread2({}, props),
|
|
3083
|
+
props.jsxSpread.reduce(function (acc, prop) {
|
|
3084
|
+
return Object.assign(acc, prop);
|
|
3085
|
+
}, {})
|
|
3086
|
+
);
|
|
3087
|
+
}
|
|
3088
|
+
if (props.$props !== undefined) {
|
|
3089
|
+
props = _objectSpread2(
|
|
3090
|
+
_objectSpread2({}, props.$props),
|
|
3091
|
+
{},
|
|
3092
|
+
{
|
|
3093
|
+
jsxAttributes: props.jsxAttributes,
|
|
3094
|
+
children: props.children,
|
|
3095
|
+
}
|
|
3096
|
+
);
|
|
3097
|
+
}
|
|
3098
|
+
return _objectSpread2({}, props);
|
|
3099
|
+
};
|
|
3100
|
+
|
|
3101
|
+
var currentInstance = null;
|
|
3102
|
+
var FunctionalComponent = /*#__PURE__*/ (function (_PureContainer) {
|
|
3103
|
+
_inheritsLoose(FunctionalComponent, _PureContainer);
|
|
3104
|
+
function FunctionalComponent() {
|
|
3105
|
+
return _PureContainer.apply(this, arguments) || this;
|
|
3106
|
+
}
|
|
3107
|
+
var _proto = FunctionalComponent.prototype;
|
|
3108
|
+
_proto.initInstance = function initInstance(context, instance) {
|
|
3109
|
+
this.clear();
|
|
3110
|
+
currentInstance = instance;
|
|
3111
|
+
this.add(this.childrenFactory(this.props));
|
|
3112
|
+
instance.content = this.layout ? this.layout.items : this.items;
|
|
3113
|
+
this.clear();
|
|
3114
|
+
currentInstance = null;
|
|
3115
|
+
};
|
|
3116
|
+
_proto.explore = function explore(context, instance) {
|
|
3117
|
+
if (this.layout) this.layout.items = instance.content;
|
|
3118
|
+
else this.items = instance.content;
|
|
3119
|
+
this.exploreItems(context, instance, instance.content);
|
|
3120
|
+
if (instance.computables) {
|
|
3121
|
+
instance.computables.forEach(function (cb) {
|
|
3122
|
+
return cb(instance.store.getData());
|
|
3123
|
+
});
|
|
3124
|
+
}
|
|
3125
|
+
};
|
|
3126
|
+
return FunctionalComponent;
|
|
3127
|
+
})(PureContainer);
|
|
3128
|
+
function createFunctionalComponent(factory) {
|
|
3129
|
+
if (isComponentFactory(factory)) return factory;
|
|
3130
|
+
return createComponentFactory(factory, function (props) {
|
|
3131
|
+
if (props === void 0) {
|
|
3132
|
+
props = {};
|
|
3133
|
+
}
|
|
3134
|
+
var innerProps = flattenProps(props);
|
|
3135
|
+
delete innerProps.visible;
|
|
3136
|
+
delete innerProps["if"];
|
|
3137
|
+
delete innerProps.controller;
|
|
3138
|
+
delete innerProps.layout;
|
|
3139
|
+
delete innerProps.outerLayout;
|
|
3140
|
+
delete innerProps.putInto;
|
|
3141
|
+
delete innerProps.contentFor;
|
|
3142
|
+
delete innerProps.jsxAttributes;
|
|
3143
|
+
delete innerProps.$type;
|
|
3144
|
+
delete innerProps.vdomKey;
|
|
3145
|
+
return {
|
|
3146
|
+
type: FunctionalComponent,
|
|
3147
|
+
visible: isDefined(props["if"]) ? props["if"] : isDefined(props.visible) ? props.visible : true,
|
|
3148
|
+
layout: props.layout || UseParentLayout,
|
|
3149
|
+
controller: props.controller,
|
|
3150
|
+
outerLayout: props.outerLayout,
|
|
3151
|
+
putInto: props.contentFor || props.putInto,
|
|
3152
|
+
vdomKey: props.vdomKey,
|
|
3153
|
+
childrenFactory: factory,
|
|
3154
|
+
props: innerProps,
|
|
3155
|
+
};
|
|
3156
|
+
});
|
|
3157
|
+
}
|
|
3158
|
+
function getCurrentInstance() {
|
|
3159
|
+
return currentInstance;
|
|
3160
|
+
}
|
|
3161
|
+
|
|
3162
|
+
var Selection = /*#__PURE__*/ (function (_Component) {
|
|
3163
|
+
_inheritsLoose(Selection, _Component);
|
|
3164
|
+
function Selection() {
|
|
3165
|
+
return _Component.apply(this, arguments) || this;
|
|
3166
|
+
}
|
|
3167
|
+
var _proto = Selection.prototype;
|
|
3168
|
+
_proto.isSelected = function isSelected(store, record, index) {
|
|
3169
|
+
return this.bind && store.get(this.bind) === record;
|
|
3170
|
+
};
|
|
3171
|
+
_proto.getIsSelectedDelegate = function getIsSelectedDelegate(store) {
|
|
3172
|
+
var _this = this;
|
|
3173
|
+
return function (record, index) {
|
|
3174
|
+
return _this.isSelected(store, record, index);
|
|
3175
|
+
};
|
|
3176
|
+
};
|
|
3177
|
+
_proto.select = function select(store, record, index, options) {
|
|
3178
|
+
this.selectMultiple(store, [record], [index], options);
|
|
3179
|
+
};
|
|
3180
|
+
_proto.selectMultiple = function selectMultiple(store, records, indexes, options) {
|
|
3181
|
+
//abstract
|
|
3182
|
+
};
|
|
3183
|
+
_proto.declareData = function declareData() {
|
|
3184
|
+
var declaration = {
|
|
3185
|
+
$selection: {
|
|
3186
|
+
structured: true,
|
|
3187
|
+
},
|
|
3188
|
+
};
|
|
3189
|
+
return Object.assign.apply(Object, [declaration].concat(Array.prototype.slice.call(arguments)));
|
|
3190
|
+
};
|
|
3191
|
+
_proto.configureWidget = function configureWidget(widget) {
|
|
3192
|
+
if (this.record || this.index) {
|
|
3193
|
+
widget.$selection = Object.assign(widget.$selection || {}, {
|
|
3194
|
+
record: this.record,
|
|
3195
|
+
index: this.index,
|
|
3196
|
+
});
|
|
3197
|
+
}
|
|
3198
|
+
return this.declareData();
|
|
3199
|
+
};
|
|
3200
|
+
_proto.selectInstance = function selectInstance(instance, options) {
|
|
3201
|
+
var store = instance.store,
|
|
3202
|
+
data = instance.data;
|
|
3203
|
+
if (!data.$selection)
|
|
3204
|
+
throw new Error(
|
|
3205
|
+
"Selection model not properly configured. Using the selectInstance method without specified record and index bindings."
|
|
3206
|
+
);
|
|
3207
|
+
return this.select(store, data.$selection.record, data.$selection.index, options);
|
|
3208
|
+
};
|
|
3209
|
+
_proto.isInstanceSelected = function isInstanceSelected(instance) {
|
|
3210
|
+
var store = instance.store,
|
|
3211
|
+
data = instance.data;
|
|
3212
|
+
return data.$selection && this.isSelected(store, data.$selection.record, data.$selection.index);
|
|
3213
|
+
};
|
|
3214
|
+
return Selection;
|
|
3215
|
+
})(Component);
|
|
3216
|
+
Selection.prototype.toggle = false;
|
|
3217
|
+
Selection.namespace = "ui.selection.";
|
|
3218
|
+
var SimpleSelection = /*#__PURE__*/ (function (_Selection) {
|
|
3219
|
+
_inheritsLoose(SimpleSelection, _Selection);
|
|
3220
|
+
function SimpleSelection() {
|
|
3221
|
+
return _Selection.apply(this, arguments) || this;
|
|
3222
|
+
}
|
|
3223
|
+
var _proto2 = SimpleSelection.prototype;
|
|
3224
|
+
_proto2.isSelected = function isSelected(store, record, index) {
|
|
3225
|
+
return this.getIsSelectedDelegate(store)(record, index);
|
|
3226
|
+
};
|
|
3227
|
+
_proto2.getIsSelectedDelegate = function getIsSelectedDelegate(store) {
|
|
3228
|
+
var selection = this.bind && store.get(this.bind);
|
|
3229
|
+
return function (record, index) {
|
|
3230
|
+
return record === selection;
|
|
3231
|
+
};
|
|
3232
|
+
};
|
|
3233
|
+
_proto2.selectMultiple = function selectMultiple(store, records, index) {
|
|
3234
|
+
if (this.bind) store.set(this.bind, records[0]);
|
|
3235
|
+
};
|
|
3236
|
+
return SimpleSelection;
|
|
3237
|
+
})(Selection);
|
|
3238
|
+
var DummySelection = /*#__PURE__*/ (function (_Selection2) {
|
|
3239
|
+
_inheritsLoose(DummySelection, _Selection2);
|
|
3240
|
+
function DummySelection() {
|
|
3241
|
+
return _Selection2.apply(this, arguments) || this;
|
|
3242
|
+
}
|
|
3243
|
+
var _proto3 = DummySelection.prototype;
|
|
3244
|
+
_proto3.isSelected = function isSelected(store, record, index) {
|
|
3245
|
+
return false;
|
|
3246
|
+
};
|
|
3247
|
+
_proto3.selectMultiple = function selectMultiple() {
|
|
3248
|
+
//dummy
|
|
3249
|
+
};
|
|
3250
|
+
_proto3.selectInstance = function selectInstance() {
|
|
3251
|
+
//dummy
|
|
3252
|
+
};
|
|
3253
|
+
return DummySelection;
|
|
3254
|
+
})(Selection);
|
|
3255
|
+
DummySelection.prototype.isDummy = true;
|
|
3256
|
+
Selection.factory = function (name) {
|
|
3257
|
+
if (typeof name == "object") return new SimpleSelection(name);
|
|
3258
|
+
return new DummySelection();
|
|
3259
|
+
};
|
|
3260
|
+
|
|
3261
|
+
var PropertySelection = /*#__PURE__*/ (function (_Selection) {
|
|
3262
|
+
_inheritsLoose(PropertySelection, _Selection);
|
|
3263
|
+
function PropertySelection() {
|
|
3264
|
+
return _Selection.apply(this, arguments) || this;
|
|
3265
|
+
}
|
|
3266
|
+
var _proto = PropertySelection.prototype;
|
|
3267
|
+
_proto.selectMultiple = function selectMultiple(store, records, indexes, _temp) {
|
|
3268
|
+
var _this = this;
|
|
3269
|
+
var _ref = _temp === void 0 ? {} : _temp,
|
|
3270
|
+
toggle = _ref.toggle,
|
|
3271
|
+
add = _ref.add;
|
|
3272
|
+
if (this.toggle) toggle = true;
|
|
3273
|
+
if (!this.records || !this.records.bind) return false;
|
|
3274
|
+
var array = store.get(this.records.bind);
|
|
3275
|
+
var newArray = [].concat(array);
|
|
3276
|
+
var dirty = false;
|
|
3277
|
+
if (!toggle && !add) {
|
|
3278
|
+
newArray.forEach(function (r, i) {
|
|
3279
|
+
if (r[_this.selectedField]) {
|
|
3280
|
+
var nr = Object.assign({}, r);
|
|
3281
|
+
nr[_this.selectedField] = false;
|
|
3282
|
+
newArray[i] = nr;
|
|
3283
|
+
dirty = true;
|
|
3284
|
+
}
|
|
3285
|
+
});
|
|
3286
|
+
}
|
|
3287
|
+
records.forEach(function (record, i) {
|
|
3288
|
+
var index = indexes[i];
|
|
3289
|
+
var rec = newArray[index];
|
|
3290
|
+
if (array[index] !== record) throw new Error("Stale data.");
|
|
3291
|
+
var value = rec[_this.selectedField];
|
|
3292
|
+
var newValue = add ? true : toggle ? !value : true;
|
|
3293
|
+
if (value == newValue) return;
|
|
3294
|
+
var newRec = Object.assign({}, rec);
|
|
3295
|
+
newRec[_this.selectedField] = newValue;
|
|
3296
|
+
newArray[index] = newRec;
|
|
3297
|
+
dirty = true;
|
|
3298
|
+
});
|
|
3299
|
+
if (dirty) store.set(this.records.bind, newArray);
|
|
3300
|
+
};
|
|
3301
|
+
_proto.isSelected = function isSelected(store, record, index) {
|
|
3302
|
+
return record && record[this.selectedField];
|
|
3303
|
+
};
|
|
3304
|
+
return PropertySelection;
|
|
3305
|
+
})(Selection);
|
|
3306
|
+
PropertySelection.prototype.selectedField = "selected";
|
|
3307
|
+
PropertySelection.prototype.multiple = false;
|
|
3308
|
+
Selection.alias("property", PropertySelection);
|
|
3309
|
+
|
|
3310
|
+
var KeySelection = /*#__PURE__*/ (function (_Selection) {
|
|
3311
|
+
_inheritsLoose(KeySelection, _Selection);
|
|
3312
|
+
function KeySelection() {
|
|
3313
|
+
return _Selection.apply(this, arguments) || this;
|
|
3314
|
+
}
|
|
3315
|
+
var _proto = KeySelection.prototype;
|
|
3316
|
+
_proto.init = function init() {
|
|
3317
|
+
if (this.bind && !this.selection)
|
|
3318
|
+
this.selection = {
|
|
3319
|
+
bind: this.bind,
|
|
3320
|
+
};
|
|
3321
|
+
if (!this.selection) this.selection = {};
|
|
3322
|
+
if (isArray(this.keyFields)) this.keyField = false;
|
|
3323
|
+
this.initialized = true;
|
|
3324
|
+
};
|
|
3325
|
+
_proto.getKey = function getKey(record) {
|
|
3326
|
+
if (this.key != null) return this.key;
|
|
3327
|
+
if (!record) return null;
|
|
3328
|
+
if (this.keyField) return record[this.keyField];
|
|
3329
|
+
var key = {};
|
|
3330
|
+
this.keyFields.forEach(function (k) {
|
|
3331
|
+
key[k] = record[k];
|
|
3332
|
+
});
|
|
3333
|
+
return key;
|
|
3334
|
+
};
|
|
3335
|
+
_proto.areKeysEqual = function areKeysEqual(key1, key2) {
|
|
3336
|
+
if (this.keyField) return key1 === key2 && key1 != null;
|
|
3337
|
+
if (!key1 || !key2) return false;
|
|
3338
|
+
return !this.keyFields.some(function (k) {
|
|
3339
|
+
return key1[k] !== key2[k];
|
|
3340
|
+
});
|
|
3341
|
+
};
|
|
3342
|
+
_proto.declareData = function declareData() {
|
|
3343
|
+
var _Selection$prototype$;
|
|
3344
|
+
return (_Selection$prototype$ = _Selection.prototype.declareData).call.apply(
|
|
3345
|
+
_Selection$prototype$,
|
|
3346
|
+
[
|
|
3347
|
+
this,
|
|
3348
|
+
{
|
|
3349
|
+
$selection: {
|
|
3350
|
+
structured: true,
|
|
3351
|
+
},
|
|
3352
|
+
},
|
|
3353
|
+
].concat(Array.prototype.slice.call(arguments))
|
|
3354
|
+
);
|
|
3355
|
+
};
|
|
3356
|
+
_proto.configureWidget = function configureWidget(widget) {
|
|
3357
|
+
if (!this.initialized) this.init();
|
|
3358
|
+
widget.$selection = Object.assign(widget.$selection || {}, {
|
|
3359
|
+
keys: this.selection,
|
|
3360
|
+
});
|
|
3361
|
+
return _Selection.prototype.configureWidget.call(this, widget);
|
|
3362
|
+
};
|
|
3363
|
+
_proto.selectMultiple = function selectMultiple(store, records, indexes, _temp) {
|
|
3364
|
+
var _this = this;
|
|
3365
|
+
var _ref = _temp === void 0 ? {} : _temp,
|
|
3366
|
+
toggle = _ref.toggle,
|
|
3367
|
+
add = _ref.add;
|
|
3368
|
+
if (!this.selection.bind) return false;
|
|
3369
|
+
if (this.toggle) toggle = true;
|
|
3370
|
+
if (!isNonEmptyArray(records)) {
|
|
3371
|
+
if (!toggle && !add) return store["delete"](this.selection.bind);
|
|
3372
|
+
return false;
|
|
3373
|
+
}
|
|
3374
|
+
var keys = records.map(function (record) {
|
|
3375
|
+
return _this.getKey(record);
|
|
3376
|
+
});
|
|
3377
|
+
var selection = store.get(this.selection.bind);
|
|
3378
|
+
if (!this.multiple) {
|
|
3379
|
+
var key = keys[0];
|
|
3380
|
+
if (!toggle || !this.areKeysEqual(selection, key)) store.set(this.selection.bind, key);
|
|
3381
|
+
else store["delete"](this.selection.bind);
|
|
3382
|
+
} else {
|
|
3383
|
+
if (this.storage == "array") {
|
|
3384
|
+
if (!isArray(selection) || (!toggle && !add)) this.updateSelectionWithShallowEqualsCheck(store, keys);
|
|
3385
|
+
else {
|
|
3386
|
+
var newSelection = [].concat(selection);
|
|
3387
|
+
keys.forEach(function (key) {
|
|
3388
|
+
var exists = selection.some(function (x) {
|
|
3389
|
+
return _this.areKeysEqual(x, key);
|
|
3390
|
+
});
|
|
3391
|
+
if (!exists) newSelection.push(key);
|
|
3392
|
+
else if (toggle)
|
|
3393
|
+
newSelection = newSelection.filter(function (x) {
|
|
3394
|
+
return !_this.areKeysEqual(x, key);
|
|
3395
|
+
}); //TODO: optimize
|
|
3396
|
+
});
|
|
3397
|
+
|
|
3398
|
+
this.updateSelectionWithShallowEqualsCheck(store, newSelection);
|
|
3399
|
+
}
|
|
3400
|
+
} else if (this.storage == "hash") {
|
|
3401
|
+
var _newSelection = toggle ? _objectSpread2({}, selection) : {};
|
|
3402
|
+
keys.forEach(function (key) {
|
|
3403
|
+
_newSelection[key] = !_newSelection[key];
|
|
3404
|
+
});
|
|
3405
|
+
this.updateSelectionWithShallowEqualsCheck(store, _newSelection);
|
|
3406
|
+
}
|
|
3407
|
+
}
|
|
3408
|
+
};
|
|
3409
|
+
_proto.updateSelectionWithShallowEqualsCheck = function updateSelectionWithShallowEqualsCheck(store, newSelection) {
|
|
3410
|
+
store.update(this.selection.bind, function (data) {
|
|
3411
|
+
return shallowEquals(data, newSelection) ? data : newSelection;
|
|
3412
|
+
});
|
|
3413
|
+
};
|
|
3414
|
+
_proto.getIsSelectedDelegate = function getIsSelectedDelegate(store) {
|
|
3415
|
+
var _this2 = this;
|
|
3416
|
+
if (!this.selection.bind)
|
|
3417
|
+
return function () {
|
|
3418
|
+
return false;
|
|
3419
|
+
};
|
|
3420
|
+
var selection = store.get(this.selection.bind);
|
|
3421
|
+
if (this.multiple) {
|
|
3422
|
+
if (this.storage == "array") {
|
|
3423
|
+
selection = selection || [];
|
|
3424
|
+
return function (record, index) {
|
|
3425
|
+
return selection.some(function (k) {
|
|
3426
|
+
return _this2.areKeysEqual(_this2.getKey(record), k);
|
|
3427
|
+
});
|
|
3428
|
+
};
|
|
3429
|
+
} else {
|
|
3430
|
+
selection = selection || {};
|
|
3431
|
+
return function (record, index) {
|
|
3432
|
+
return selection[_this2.getKey(record)];
|
|
3433
|
+
};
|
|
3434
|
+
}
|
|
3435
|
+
} else
|
|
3436
|
+
return function (record, index) {
|
|
3437
|
+
return _this2.areKeysEqual(selection, _this2.getKey(record));
|
|
3438
|
+
};
|
|
3439
|
+
};
|
|
3440
|
+
_proto.isSelected = function isSelected(store, record, index) {
|
|
3441
|
+
return this.getIsSelectedDelegate(store)(record, index);
|
|
3442
|
+
};
|
|
3443
|
+
return KeySelection;
|
|
3444
|
+
})(Selection);
|
|
3445
|
+
KeySelection.prototype.multiple = false;
|
|
3446
|
+
KeySelection.prototype.keyField = "id";
|
|
3447
|
+
KeySelection.prototype.storage = "array";
|
|
3448
|
+
KeySelection.autoInit = true;
|
|
3449
|
+
Selection.alias("key", KeySelection);
|
|
3450
|
+
|
|
3451
|
+
function isVisibleDeep(instance) {
|
|
3452
|
+
if (instance.visible && (!instance.widget.isPureContainer || !instance.widget.useParentLayout)) return true;
|
|
3453
|
+
if (instance.children) {
|
|
3454
|
+
for (var i = 0; i < instance.children.length; i++) if (isVisibleDeep(instance.children[i])) return true;
|
|
3455
|
+
}
|
|
3456
|
+
return false;
|
|
3457
|
+
}
|
|
3458
|
+
var FirstVisibleChildItem = /*#__PURE__*/ (function (_PureContainer) {
|
|
3459
|
+
_inheritsLoose(FirstVisibleChildItem, _PureContainer);
|
|
3460
|
+
function FirstVisibleChildItem() {
|
|
3461
|
+
return _PureContainer.apply(this, arguments) || this;
|
|
3462
|
+
}
|
|
3463
|
+
var _proto = FirstVisibleChildItem.prototype;
|
|
3464
|
+
_proto.checkVisible = function checkVisible(context, instance, data) {
|
|
3465
|
+
if (instance.parent.firstVisibleChild) return false;
|
|
3466
|
+
return _PureContainer.prototype.checkVisible.call(this, context, instance, data);
|
|
3467
|
+
};
|
|
3468
|
+
_proto.explore = function explore(context, instance) {
|
|
3469
|
+
if (instance.parent.firstVisibleChild) return;
|
|
3470
|
+
_PureContainer.prototype.explore.call(this, context, instance);
|
|
3471
|
+
};
|
|
3472
|
+
_proto.exploreCleanup = function exploreCleanup(context, instance) {
|
|
3473
|
+
if (instance.parent.firstVisibleChild) return;
|
|
3474
|
+
if (isVisibleDeep(instance)) instance.parent.firstVisibleChild = instance;
|
|
3475
|
+
};
|
|
3476
|
+
_proto.render = function render(context, instance, key) {
|
|
3477
|
+
if (instance.parent.firstVisibleChild != instance) return null;
|
|
3478
|
+
return _PureContainer.prototype.render.call(this, context, instance, key);
|
|
3479
|
+
};
|
|
3480
|
+
return FirstVisibleChildItem;
|
|
3481
|
+
})(PureContainer);
|
|
3482
|
+
FirstVisibleChildItem.prototype.useParentLayout = true;
|
|
3483
|
+
var FirstVisibleChildLayout = /*#__PURE__*/ (function (_PureContainer2) {
|
|
3484
|
+
_inheritsLoose(FirstVisibleChildLayout, _PureContainer2);
|
|
3485
|
+
function FirstVisibleChildLayout() {
|
|
3486
|
+
return _PureContainer2.apply(this, arguments) || this;
|
|
3487
|
+
}
|
|
3488
|
+
var _proto2 = FirstVisibleChildLayout.prototype;
|
|
3489
|
+
_proto2.explore = function explore(context, instance) {
|
|
3490
|
+
instance.firstVisibleChild = null;
|
|
3491
|
+
_PureContainer2.prototype.explore.call(this, context, instance);
|
|
3492
|
+
};
|
|
3493
|
+
_proto2.exploreCleanup = function exploreCleanup(context, instance) {
|
|
3494
|
+
var children = instance.children,
|
|
3495
|
+
firstVisibleChild = instance.firstVisibleChild;
|
|
3496
|
+
if (children) {
|
|
3497
|
+
for (var i = 0; i < children.length; i++) if (children[i] != firstVisibleChild) children[i].destroy();
|
|
3498
|
+
}
|
|
3499
|
+
instance.children = [];
|
|
3500
|
+
if (firstVisibleChild) instance.children.push(firstVisibleChild);
|
|
3501
|
+
};
|
|
3502
|
+
_proto2.wrapItem = function wrapItem(item) {
|
|
3503
|
+
return item instanceof FirstVisibleChildItem
|
|
3504
|
+
? item
|
|
3505
|
+
: FirstVisibleChildItem.create({
|
|
3506
|
+
items: item,
|
|
3507
|
+
});
|
|
3508
|
+
};
|
|
3509
|
+
return FirstVisibleChildLayout;
|
|
3510
|
+
})(PureContainer);
|
|
3511
|
+
|
|
3512
|
+
function validContent$1(r) {
|
|
3513
|
+
if (!r.hasOwnProperty("content")) return r;
|
|
3514
|
+
var content = [];
|
|
3515
|
+
for (var key in r) if (key != "label") contentAppend(content, r[key]);
|
|
3516
|
+
return content;
|
|
3517
|
+
}
|
|
3518
|
+
var LabelsLeftLayout = /*#__PURE__*/ (function (_PureContainer) {
|
|
3519
|
+
_inheritsLoose(LabelsLeftLayout, _PureContainer);
|
|
3520
|
+
function LabelsLeftLayout() {
|
|
3521
|
+
return _PureContainer.apply(this, arguments) || this;
|
|
3522
|
+
}
|
|
3523
|
+
var _proto = LabelsLeftLayout.prototype;
|
|
3524
|
+
_proto.init = function init() {
|
|
3525
|
+
this.labelStyle = parseStyle(this.labelStyle);
|
|
3526
|
+
_PureContainer.prototype.init.call(this);
|
|
3527
|
+
};
|
|
3528
|
+
_proto.declareData = function declareData() {
|
|
3529
|
+
var _PureContainer$protot;
|
|
3530
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3531
|
+
args[_key] = arguments[_key];
|
|
3532
|
+
}
|
|
3533
|
+
return (_PureContainer$protot = _PureContainer.prototype.declareData).call.apply(
|
|
3534
|
+
_PureContainer$protot,
|
|
3535
|
+
[this].concat(args, [
|
|
3536
|
+
{
|
|
3537
|
+
labelStyle: {
|
|
3538
|
+
structured: true,
|
|
3539
|
+
},
|
|
3540
|
+
labelClass: {
|
|
3541
|
+
structured: true,
|
|
3542
|
+
},
|
|
3543
|
+
},
|
|
3544
|
+
])
|
|
3545
|
+
);
|
|
3546
|
+
};
|
|
3547
|
+
_proto.render = function render(context, instance, key) {
|
|
3548
|
+
var result = [];
|
|
3549
|
+
var children = instance.children,
|
|
3550
|
+
data = instance.data;
|
|
3551
|
+
var CSS = this.CSS,
|
|
3552
|
+
baseClass = this.baseClass;
|
|
3553
|
+
var labelClass = CSS.expand(CSS.element(baseClass, "label"), data.labelClass);
|
|
3554
|
+
var addItem = function addItem(r, key) {
|
|
3555
|
+
if (!r) return;
|
|
3556
|
+
if (r.useParentLayout && isArray(r.content))
|
|
3557
|
+
r.content.forEach(function (x, i) {
|
|
3558
|
+
return addItem(x, key + "-" + i);
|
|
3559
|
+
});
|
|
3560
|
+
else {
|
|
3561
|
+
result.push(
|
|
3562
|
+
/*#__PURE__*/ jsxs(
|
|
3563
|
+
"tr",
|
|
3564
|
+
{
|
|
3565
|
+
children: [
|
|
3566
|
+
/*#__PURE__*/ jsx("td", {
|
|
3567
|
+
className: labelClass,
|
|
3568
|
+
style: data.labelStyle,
|
|
3569
|
+
children: getContent(r.label),
|
|
3570
|
+
}),
|
|
3571
|
+
/*#__PURE__*/ jsx("td", {
|
|
3572
|
+
className: CSS.element(baseClass, "field"),
|
|
3573
|
+
children: validContent$1(r),
|
|
3574
|
+
}),
|
|
3575
|
+
],
|
|
3576
|
+
},
|
|
3577
|
+
key
|
|
3578
|
+
)
|
|
3579
|
+
);
|
|
3580
|
+
}
|
|
3581
|
+
};
|
|
3582
|
+
children.forEach(function (c) {
|
|
3583
|
+
addItem(c.vdom, c.key);
|
|
3584
|
+
});
|
|
3585
|
+
return /*#__PURE__*/ jsx(
|
|
3586
|
+
"table",
|
|
3587
|
+
{
|
|
3588
|
+
className: data.classNames,
|
|
3589
|
+
style: data.style,
|
|
3590
|
+
children: /*#__PURE__*/ jsx("tbody", {
|
|
3591
|
+
children: result,
|
|
3592
|
+
}),
|
|
3593
|
+
},
|
|
3594
|
+
key
|
|
3595
|
+
);
|
|
3596
|
+
};
|
|
3597
|
+
return LabelsLeftLayout;
|
|
3598
|
+
})(PureContainer);
|
|
3599
|
+
LabelsLeftLayout.prototype.baseClass = "labelsleftlayout";
|
|
3600
|
+
LabelsLeftLayout.prototype.styled = true;
|
|
3601
|
+
|
|
3602
|
+
function validContent(r) {
|
|
3603
|
+
var content = [];
|
|
3604
|
+
for (var key in r) if (key != "label") contentAppend(content, r[key]);
|
|
3605
|
+
return content;
|
|
3606
|
+
}
|
|
3607
|
+
var LabelsTopLayout = /*#__PURE__*/ (function (_Container) {
|
|
3608
|
+
_inheritsLoose(LabelsTopLayout, _Container);
|
|
3609
|
+
function LabelsTopLayout() {
|
|
3610
|
+
return _Container.apply(this, arguments) || this;
|
|
3611
|
+
}
|
|
3612
|
+
var _proto = LabelsTopLayout.prototype;
|
|
3613
|
+
_proto.init = function init() {
|
|
3614
|
+
if (this.vertical && isUndefined(this.columns)) this.columns = 1;
|
|
3615
|
+
_Container.prototype.init.call(this);
|
|
3616
|
+
};
|
|
3617
|
+
_proto.render = function render(context, instance, key) {
|
|
3618
|
+
var _this = this;
|
|
3619
|
+
var children = instance.children,
|
|
3620
|
+
data = instance.data;
|
|
3621
|
+
var state = {
|
|
3622
|
+
rows: [],
|
|
3623
|
+
currentRow: 0,
|
|
3624
|
+
labelCells: [],
|
|
3625
|
+
fieldCells: [],
|
|
3626
|
+
rowCapacities: [this.columns],
|
|
3627
|
+
};
|
|
3628
|
+
var processContent = function processContent(r) {
|
|
3629
|
+
if (!r) return;
|
|
3630
|
+
if (isArray(r.content) && r.useParentLayout)
|
|
3631
|
+
r.content.forEach(function (x) {
|
|
3632
|
+
return processContent(x);
|
|
3633
|
+
});
|
|
3634
|
+
else if (r.atomic && r.type == "layout-cell")
|
|
3635
|
+
_this.addItem(state, isArray(r.content) && r.content.length == 1 ? r.content[0] : r.content, r.data);
|
|
3636
|
+
else _this.addItem(state, r, {});
|
|
3637
|
+
};
|
|
3638
|
+
children.forEach(function (item) {
|
|
3639
|
+
return processContent(item.vdom);
|
|
3640
|
+
});
|
|
3641
|
+
this.addRow(state);
|
|
3642
|
+
return /*#__PURE__*/ jsx(
|
|
3643
|
+
"table",
|
|
3644
|
+
{
|
|
3645
|
+
className: data.classNames,
|
|
3646
|
+
style: data.style,
|
|
3647
|
+
children: /*#__PURE__*/ jsx("tbody", {
|
|
3648
|
+
children: state.rows,
|
|
3649
|
+
}),
|
|
3650
|
+
},
|
|
3651
|
+
key
|
|
3652
|
+
);
|
|
3653
|
+
};
|
|
3654
|
+
_proto.addRow = function addRow(state) {
|
|
3655
|
+
if (state.labelCells.length > 0)
|
|
3656
|
+
state.rows.push(
|
|
3657
|
+
/*#__PURE__*/ jsx(
|
|
3658
|
+
"tr",
|
|
3659
|
+
{
|
|
3660
|
+
children: state.labelCells,
|
|
3661
|
+
},
|
|
3662
|
+
state.rows.length
|
|
3663
|
+
)
|
|
3664
|
+
);
|
|
3665
|
+
if (state.fieldCells.length > 0)
|
|
3666
|
+
state.rows.push(
|
|
3667
|
+
/*#__PURE__*/ jsx(
|
|
3668
|
+
"tr",
|
|
3669
|
+
{
|
|
3670
|
+
children: state.fieldCells,
|
|
3671
|
+
},
|
|
3672
|
+
state.rows.length
|
|
3673
|
+
)
|
|
3674
|
+
);
|
|
3675
|
+
state.labelCells = [];
|
|
3676
|
+
state.fieldCells = [];
|
|
3677
|
+
state.currentRow++;
|
|
3678
|
+
if (state.currentRow == state.rowCapacities.length) state.rowCapacities.push(this.columns);
|
|
3679
|
+
};
|
|
3680
|
+
_proto.addItem = function addItem(state, item, data) {
|
|
3681
|
+
while (state.labelCells.length == state.rowCapacities[state.currentRow]) this.addRow(state);
|
|
3682
|
+
if (data.rowSpan > 1) {
|
|
3683
|
+
for (var row = state.currentRow + 1; row < state.currentRow + data.rowSpan; row++) {
|
|
3684
|
+
if (row == state.rowCapacities.length) state.rowCapacities.push(this.columns);
|
|
3685
|
+
state.rowCapacities[row] -= data.colSpan || 1;
|
|
3686
|
+
}
|
|
3687
|
+
}
|
|
3688
|
+
if (data.colSpan > 1) state.rowCapacities[state.currentRow] -= data.colSpan - 1;
|
|
3689
|
+
state.labelCells.push(
|
|
3690
|
+
/*#__PURE__*/ jsx(
|
|
3691
|
+
"td",
|
|
3692
|
+
{
|
|
3693
|
+
className: this.CSS.element(this.baseClass, "label"),
|
|
3694
|
+
colSpan: data.colSpan,
|
|
3695
|
+
children: getContent(item.label),
|
|
3696
|
+
},
|
|
3697
|
+
state.labelCells.length
|
|
3698
|
+
)
|
|
3699
|
+
);
|
|
3700
|
+
state.fieldCells.push(
|
|
3701
|
+
/*#__PURE__*/ jsx(
|
|
3702
|
+
"td",
|
|
3703
|
+
{
|
|
3704
|
+
className: this.CSS.element(this.baseClass, "field"),
|
|
3705
|
+
colSpan: data.colSpan,
|
|
3706
|
+
rowSpan: isNumber(data.rowSpan) ? 2 * data.rowSpan - 1 : undefined,
|
|
3707
|
+
style: data.style,
|
|
3708
|
+
children: validContent(item),
|
|
3709
|
+
},
|
|
3710
|
+
state.fieldCells.length
|
|
3711
|
+
)
|
|
3712
|
+
);
|
|
3713
|
+
};
|
|
3714
|
+
return LabelsTopLayout;
|
|
3715
|
+
})(Container);
|
|
3716
|
+
LabelsTopLayout.prototype.baseClass = "labelstoplayout";
|
|
3717
|
+
LabelsTopLayout.prototype.vertical = false;
|
|
3718
|
+
LabelsTopLayout.prototype.columns = undefined;
|
|
3719
|
+
LabelsTopLayout.prototype.styled = true;
|
|
3720
|
+
var LabelsTopLayoutCell = /*#__PURE__*/ (function (_PureContainer) {
|
|
3721
|
+
_inheritsLoose(LabelsTopLayoutCell, _PureContainer);
|
|
3722
|
+
function LabelsTopLayoutCell() {
|
|
3723
|
+
return _PureContainer.apply(this, arguments) || this;
|
|
3724
|
+
}
|
|
3725
|
+
var _proto2 = LabelsTopLayoutCell.prototype;
|
|
3726
|
+
_proto2.declareData = function declareData() {
|
|
3727
|
+
var _PureContainer$protot;
|
|
3728
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3729
|
+
args[_key] = arguments[_key];
|
|
3730
|
+
}
|
|
3731
|
+
(_PureContainer$protot = _PureContainer.prototype.declareData).call.apply(
|
|
3732
|
+
_PureContainer$protot,
|
|
3733
|
+
[this].concat(args, [
|
|
3734
|
+
{
|
|
3735
|
+
colSpan: undefined,
|
|
3736
|
+
rowSpan: undefined,
|
|
3737
|
+
},
|
|
3738
|
+
])
|
|
3739
|
+
);
|
|
3740
|
+
};
|
|
3741
|
+
_proto2.render = function render(context, instance, key) {
|
|
3742
|
+
var _this$renderChildren = this.renderChildren(context, instance),
|
|
3743
|
+
content = _this$renderChildren.content;
|
|
3744
|
+
return {
|
|
3745
|
+
atomic: true,
|
|
3746
|
+
type: "layout-cell",
|
|
3747
|
+
data: instance.data,
|
|
3748
|
+
content: content,
|
|
3749
|
+
};
|
|
3750
|
+
};
|
|
3751
|
+
return LabelsTopLayoutCell;
|
|
3752
|
+
})(PureContainer);
|
|
3753
|
+
LabelsTopLayoutCell.prototype.styled = true;
|
|
3754
|
+
LabelsTopLayoutCell.prototype.useParentLayout = true;
|
|
3755
|
+
|
|
3756
|
+
var Content = /*#__PURE__*/ (function (_PureContainer) {
|
|
3757
|
+
_inheritsLoose(Content, _PureContainer);
|
|
3758
|
+
function Content() {
|
|
3759
|
+
return _PureContainer.apply(this, arguments) || this;
|
|
3760
|
+
}
|
|
3761
|
+
var _proto = Content.prototype;
|
|
3762
|
+
_proto.init = function init() {
|
|
3763
|
+
_PureContainer.prototype.init.call(this);
|
|
3764
|
+
this.putInto = this["for"] || this.name;
|
|
3765
|
+
};
|
|
3766
|
+
return Content;
|
|
3767
|
+
})(PureContainer);
|
|
3768
|
+
Content.prototype.name = "body";
|
|
3769
|
+
Content.prototype.isContent = true;
|
|
3770
|
+
Widget.alias("content", Content);
|
|
3771
|
+
|
|
3772
|
+
var ContentPlaceholder = /*#__PURE__*/ (function (_PureContainer) {
|
|
3773
|
+
_inheritsLoose(ContentPlaceholder, _PureContainer);
|
|
3774
|
+
function ContentPlaceholder() {
|
|
3775
|
+
return _PureContainer.apply(this, arguments) || this;
|
|
3776
|
+
}
|
|
3777
|
+
var _proto = ContentPlaceholder.prototype;
|
|
3778
|
+
_proto.declareData = function declareData() {
|
|
3779
|
+
var _PureContainer$protot;
|
|
3780
|
+
(_PureContainer$protot = _PureContainer.prototype.declareData).call.apply(
|
|
3781
|
+
_PureContainer$protot,
|
|
3782
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
3783
|
+
{
|
|
3784
|
+
name: undefined,
|
|
3785
|
+
},
|
|
3786
|
+
])
|
|
3787
|
+
);
|
|
3788
|
+
};
|
|
3789
|
+
_proto.explore = function explore(context, instance) {
|
|
3790
|
+
var _this = this;
|
|
3791
|
+
instance.content = null;
|
|
3792
|
+
var data = instance.data;
|
|
3793
|
+
var content = context.content && context.content[data.name];
|
|
3794
|
+
if (content && !this.scoped) this.setContent(context, instance, content);
|
|
3795
|
+
else
|
|
3796
|
+
context.pushNamedValue("contentPlaceholder", data.name, function (content) {
|
|
3797
|
+
_this.setContent(context, instance, content);
|
|
3798
|
+
});
|
|
3799
|
+
if (this.scoped)
|
|
3800
|
+
instance.unregisterContentPlaceholder = function () {
|
|
3801
|
+
context.popNamedValue("contentPlaceholder", data.name);
|
|
3802
|
+
};
|
|
3803
|
+
_PureContainer.prototype.explore.call(this, context, instance);
|
|
3804
|
+
};
|
|
3805
|
+
_proto.prepare = function prepare(context, instance) {
|
|
3806
|
+
var content = instance.content;
|
|
3807
|
+
if (instance.cache("content", content) || (content && content.shouldUpdate)) instance.markShouldUpdate(context);
|
|
3808
|
+
};
|
|
3809
|
+
_proto.setContent = function setContent(context, instance, content) {
|
|
3810
|
+
instance.content = content;
|
|
3811
|
+
content.contentPlaceholder = instance;
|
|
3812
|
+
};
|
|
3813
|
+
_proto.render = function render(context, instance, key) {
|
|
3814
|
+
var content = instance.content;
|
|
3815
|
+
if (content) return content.contentVDOM;
|
|
3816
|
+
return _PureContainer.prototype.render.call(this, context, instance, key);
|
|
3817
|
+
};
|
|
3818
|
+
return ContentPlaceholder;
|
|
3819
|
+
})(PureContainer);
|
|
3820
|
+
ContentPlaceholder.prototype.name = "body";
|
|
3821
|
+
ContentPlaceholder.prototype.scoped = false;
|
|
3822
|
+
Widget.alias("content-placeholder", ContentPlaceholder);
|
|
3823
|
+
var ContentPlaceholderScope = /*#__PURE__*/ (function (_PureContainer2) {
|
|
3824
|
+
_inheritsLoose(ContentPlaceholderScope, _PureContainer2);
|
|
3825
|
+
function ContentPlaceholderScope() {
|
|
3826
|
+
return _PureContainer2.apply(this, arguments) || this;
|
|
3827
|
+
}
|
|
3828
|
+
var _proto2 = ContentPlaceholderScope.prototype;
|
|
3829
|
+
_proto2.init = function init() {
|
|
3830
|
+
_PureContainer2.prototype.init.call(this);
|
|
3831
|
+
if (isString(this.name)) this.name = [this.name];
|
|
3832
|
+
};
|
|
3833
|
+
_proto2.explore = function explore(context, instance) {
|
|
3834
|
+
this.name.forEach(function (name) {
|
|
3835
|
+
context.pushNamedValue("contentPlaceholder", name, null);
|
|
3836
|
+
context.pushNamedValue("content", name, null);
|
|
3837
|
+
});
|
|
3838
|
+
_PureContainer2.prototype.explore.call(this, context, instance);
|
|
3839
|
+
};
|
|
3840
|
+
_proto2.exploreCleanup = function exploreCleanup(context, instance) {
|
|
3841
|
+
this.name.forEach(function (name) {
|
|
3842
|
+
context.popNamedValue("contentPlaceholder", name);
|
|
3843
|
+
context.popNamedValue("content", name);
|
|
3844
|
+
});
|
|
3845
|
+
};
|
|
3846
|
+
return ContentPlaceholderScope;
|
|
3847
|
+
})(PureContainer);
|
|
3848
|
+
|
|
3849
|
+
function startAppLoop(parentDOMElement, storeOrInstance, widget, options) {
|
|
3850
|
+
if (options === void 0) {
|
|
3851
|
+
options = {};
|
|
3852
|
+
}
|
|
3853
|
+
if (!parentDOMElement || parentDOMElement.nodeType !== 1)
|
|
3854
|
+
throw new Error("First argument to startAppLoop should be a valid DOM element.");
|
|
3855
|
+
var store, instance, parentInstance;
|
|
3856
|
+
if (!storeOrInstance) storeOrInstance = new Store();
|
|
3857
|
+
if (storeOrInstance.notify) store = storeOrInstance;
|
|
3858
|
+
else if (storeOrInstance.getChild) {
|
|
3859
|
+
if (storeOrInstance.widget === widget) instance = storeOrInstance;
|
|
3860
|
+
else parentInstance = storeOrInstance;
|
|
3861
|
+
} else throw new Error("Second argument to startAppLoop should be either of type Store or Instance");
|
|
3862
|
+
var root = /*#__PURE__*/ jsx(Cx, {
|
|
3863
|
+
store: store,
|
|
3864
|
+
widget: widget,
|
|
3865
|
+
instance: instance,
|
|
3866
|
+
parentInstance: parentInstance,
|
|
3867
|
+
options: options,
|
|
3868
|
+
subscribe: true,
|
|
3869
|
+
});
|
|
3870
|
+
VDOM.DOM.render(root, parentDOMElement);
|
|
3871
|
+
var stopped = false;
|
|
3872
|
+
return function () {
|
|
3873
|
+
if (stopped) return;
|
|
3874
|
+
stopped = true;
|
|
3875
|
+
if (!options.destroyDelay) destroy(parentDOMElement, options);
|
|
3876
|
+
else {
|
|
3877
|
+
setTimeout(function () {
|
|
3878
|
+
destroy(parentDOMElement, options);
|
|
3879
|
+
}, options.destroyDelay);
|
|
3880
|
+
}
|
|
3881
|
+
};
|
|
3882
|
+
}
|
|
3883
|
+
function destroy(parentDOMElement, options) {
|
|
3884
|
+
VDOM.DOM.unmountComponentAtNode(parentDOMElement);
|
|
3885
|
+
if (options.removeParentDOMElement && parentDOMElement.parentNode)
|
|
3886
|
+
parentDOMElement.parentNode.removeChild(parentDOMElement);
|
|
3887
|
+
}
|
|
3888
|
+
|
|
3889
|
+
var Url = /*#__PURE__*/ (function () {
|
|
3890
|
+
function Url() {}
|
|
3891
|
+
Url.resolve = function resolve(path) {
|
|
3892
|
+
return path.replace("~/", this.base);
|
|
3893
|
+
};
|
|
3894
|
+
Url.absolute = function absolute(path) {
|
|
3895
|
+
return path.replace("~/", this.absoluteBase);
|
|
3896
|
+
};
|
|
3897
|
+
Url.unresolve = function unresolve(path) {
|
|
3898
|
+
if (path.indexOf("~/") == 0) return path;
|
|
3899
|
+
var absBase = this.absoluteBase || "";
|
|
3900
|
+
|
|
3901
|
+
//handle paths like /app and /app/
|
|
3902
|
+
if (path.length == absBase.length - 1 && absBase == path + "/") return "~/";
|
|
3903
|
+
if (path.indexOf(absBase) == 0) return "~/" + path.substring(absBase.length);
|
|
3904
|
+
return "~/" + path.substring(this.base.length);
|
|
3905
|
+
};
|
|
3906
|
+
Url.getAbsoluteBase = function getAbsoluteBase() {
|
|
3907
|
+
return this.absoluteBase;
|
|
3908
|
+
};
|
|
3909
|
+
Url.isLocal = function isLocal(url) {
|
|
3910
|
+
var absBase = this.getAbsoluteBase();
|
|
3911
|
+
return url.indexOf("~/") == 0 || url.indexOf(absBase) == 0 || url.indexOf(this.base) == 0;
|
|
3912
|
+
};
|
|
3913
|
+
Url.setBase = function setBase(base) {
|
|
3914
|
+
if (!base || base[base.length - 1] != "/") base += "/";
|
|
3915
|
+
this.base = base;
|
|
3916
|
+
if (typeof window != "undefined")
|
|
3917
|
+
this.absoluteBase = window.location.protocol + "//" + window.location.host + this.base;
|
|
3918
|
+
};
|
|
3919
|
+
Url.getOrigin = function getOrigin() {
|
|
3920
|
+
if (typeof window == "undefined") return "";
|
|
3921
|
+
return (
|
|
3922
|
+
window.location.protocol +
|
|
3923
|
+
"//" +
|
|
3924
|
+
window.location.hostname +
|
|
3925
|
+
(window.location.port ? ":" + window.location.port : "")
|
|
3926
|
+
);
|
|
3927
|
+
};
|
|
3928
|
+
Url.getBaseFromScriptSrc = function getBaseFromScriptSrc(src, scriptPath) {
|
|
3929
|
+
if (!(scriptPath instanceof RegExp)) scriptPath = getBasePathRegex(scriptPath);
|
|
3930
|
+
var index = src.search(scriptPath);
|
|
3931
|
+
if (index == -1) return false;
|
|
3932
|
+
var origin = this.getOrigin();
|
|
3933
|
+
return src.substring(src.indexOf(origin) == 0 ? origin.length : 0, index);
|
|
3934
|
+
};
|
|
3935
|
+
Url.setBaseFromScript = function setBaseFromScript(scriptPath) {
|
|
3936
|
+
var scripts = document.getElementsByTagName("script"),
|
|
3937
|
+
base;
|
|
3938
|
+
if (!(scriptPath instanceof RegExp)) scriptPath = getBasePathRegex(scriptPath);
|
|
3939
|
+
for (var i = 0; i < scripts.length; i++) {
|
|
3940
|
+
base = this.getBaseFromScriptSrc(scripts[i].src, scriptPath);
|
|
3941
|
+
if (base) {
|
|
3942
|
+
this.setBase(base);
|
|
3943
|
+
return;
|
|
3944
|
+
}
|
|
3945
|
+
}
|
|
3946
|
+
throw new Error("Could not resolve url base from script matching '" + scriptPath + "'.");
|
|
3947
|
+
};
|
|
3948
|
+
return Url;
|
|
3949
|
+
})();
|
|
3950
|
+
Url.setBase("/");
|
|
3951
|
+
function getBasePathRegex(str) {
|
|
3952
|
+
var regex = "";
|
|
3953
|
+
var start = 0;
|
|
3954
|
+
if (str.indexOf("~/") == 0) start = 2;
|
|
3955
|
+
for (var i = start; i < str.length; i++) {
|
|
3956
|
+
switch (str[i]) {
|
|
3957
|
+
case ".":
|
|
3958
|
+
regex += "\\.";
|
|
3959
|
+
break;
|
|
3960
|
+
case "*":
|
|
3961
|
+
regex += ".*";
|
|
3962
|
+
break;
|
|
3963
|
+
default:
|
|
3964
|
+
regex += str[i];
|
|
3965
|
+
}
|
|
3966
|
+
}
|
|
3967
|
+
return new RegExp(regex + "(\\?.*)?$", "i");
|
|
3968
|
+
}
|
|
3969
|
+
|
|
3970
|
+
var last = 0,
|
|
3971
|
+
next = 1,
|
|
3972
|
+
transitions = {},
|
|
3973
|
+
subscribers = null,
|
|
3974
|
+
reload = false,
|
|
3975
|
+
navigateConfirmationCallback = null,
|
|
3976
|
+
permanentNavigateConfirmation = false;
|
|
3977
|
+
var History = /*#__PURE__*/ (function () {
|
|
3978
|
+
function History() {}
|
|
3979
|
+
History.connect = function connect(store, urlBinding, hashBinding) {
|
|
3980
|
+
var _this = this;
|
|
3981
|
+
this.store = store;
|
|
3982
|
+
this.urlBinding = urlBinding;
|
|
3983
|
+
this.hashBinding = hashBinding;
|
|
3984
|
+
this.updateStore();
|
|
3985
|
+
window.onpopstate = function () {
|
|
3986
|
+
_this.updateStore();
|
|
3987
|
+
};
|
|
3988
|
+
};
|
|
3989
|
+
History.pushState = function pushState(state, title, url) {
|
|
3990
|
+
return this.confirmAndNavigate(state, title, url);
|
|
3991
|
+
};
|
|
3992
|
+
History.replaceState = function replaceState(state, title, url) {
|
|
3993
|
+
return this.navigate(state, title, url, true);
|
|
3994
|
+
};
|
|
3995
|
+
History.reloadOnNextChange = function reloadOnNextChange() {
|
|
3996
|
+
reload = true;
|
|
3997
|
+
};
|
|
3998
|
+
History.addNavigateConfirmation = function addNavigateConfirmation(callback, permanent) {
|
|
3999
|
+
if (permanent === void 0) {
|
|
4000
|
+
permanent = false;
|
|
4001
|
+
}
|
|
4002
|
+
navigateConfirmationCallback = callback;
|
|
4003
|
+
permanentNavigateConfirmation = permanent;
|
|
4004
|
+
};
|
|
4005
|
+
History.confirm = function confirm(continueCallback, state) {
|
|
4006
|
+
if (!navigateConfirmationCallback) return continueCallback();
|
|
4007
|
+
var result = navigateConfirmationCallback(state);
|
|
4008
|
+
Promise.resolve(result).then(function (value) {
|
|
4009
|
+
if (value) {
|
|
4010
|
+
if (!permanentNavigateConfirmation) navigateConfirmationCallback = null;
|
|
4011
|
+
continueCallback();
|
|
4012
|
+
}
|
|
4013
|
+
});
|
|
4014
|
+
return false;
|
|
4015
|
+
};
|
|
4016
|
+
History.confirmAndNavigate = function confirmAndNavigate(state, title, url, replace) {
|
|
4017
|
+
var _this2 = this;
|
|
4018
|
+
return this.confirm(function () {
|
|
4019
|
+
return _this2.navigate(state, title, url, replace);
|
|
4020
|
+
}, url);
|
|
4021
|
+
};
|
|
4022
|
+
History.navigate = function navigate(state, title, url, replace) {
|
|
4023
|
+
var _this3 = this;
|
|
4024
|
+
if (replace === void 0) {
|
|
4025
|
+
replace = false;
|
|
4026
|
+
}
|
|
4027
|
+
url = Url.resolve(url);
|
|
4028
|
+
if (!window.history.pushState || reload) {
|
|
4029
|
+
window.location[replace ? "replace" : "assign"](url);
|
|
4030
|
+
return true;
|
|
4031
|
+
}
|
|
4032
|
+
var transition,
|
|
4033
|
+
changed = false;
|
|
4034
|
+
batchUpdatesAndNotify(
|
|
4035
|
+
function () {
|
|
4036
|
+
changed = _this3.updateStore(url);
|
|
4037
|
+
if (changed)
|
|
4038
|
+
transitions[++last] = transition = {
|
|
4039
|
+
url: url,
|
|
4040
|
+
state: state,
|
|
4041
|
+
title: title,
|
|
4042
|
+
replace: replace,
|
|
4043
|
+
};
|
|
4044
|
+
},
|
|
4045
|
+
function () {
|
|
4046
|
+
if (transition) transition.completed = true;
|
|
4047
|
+
|
|
4048
|
+
//update history once the page is rendered and the title is set
|
|
4049
|
+
while (transitions[next] && transitions[next].completed) {
|
|
4050
|
+
var tr = transitions[next];
|
|
4051
|
+
delete transitions[next];
|
|
4052
|
+
next++;
|
|
4053
|
+
var op = tr.replace ? "replaceState" : "pushState";
|
|
4054
|
+
window.history[op](tr.state, tr.title, tr.url);
|
|
4055
|
+
if (subscribers) subscribers.notify(tr.url, op);
|
|
4056
|
+
}
|
|
4057
|
+
}
|
|
4058
|
+
);
|
|
4059
|
+
return changed;
|
|
4060
|
+
};
|
|
4061
|
+
History.updateStore = function updateStore(href) {
|
|
4062
|
+
var url = Url.unresolve(href || document.location.href),
|
|
4063
|
+
hash = null;
|
|
4064
|
+
var hashIndex = url.indexOf("#");
|
|
4065
|
+
if (hashIndex !== -1) {
|
|
4066
|
+
hash = url.substring(hashIndex);
|
|
4067
|
+
url = url.substring(0, hashIndex);
|
|
4068
|
+
}
|
|
4069
|
+
if (this.hashBinding) this.store.set(this.hashBinding, hash);
|
|
4070
|
+
return this.store.set(this.urlBinding, url);
|
|
4071
|
+
};
|
|
4072
|
+
History.subscribe = function subscribe(callback) {
|
|
4073
|
+
if (!subscribers) subscribers = new SubscriberList();
|
|
4074
|
+
return subscribers.subscribe(callback);
|
|
4075
|
+
};
|
|
4076
|
+
return History;
|
|
4077
|
+
})();
|
|
4078
|
+
|
|
4079
|
+
function startHotAppLoop(appModule, element, store, widgets, options) {
|
|
4080
|
+
var stop;
|
|
4081
|
+
//webpack (HMR)
|
|
4082
|
+
if (appModule.hot) {
|
|
4083
|
+
// accept itself
|
|
4084
|
+
appModule.hot.accept();
|
|
4085
|
+
|
|
4086
|
+
// remember data on dispose
|
|
4087
|
+
appModule.hot.dispose(function (data) {
|
|
4088
|
+
data.state = store.getData();
|
|
4089
|
+
if (stop) stop();
|
|
4090
|
+
});
|
|
4091
|
+
|
|
4092
|
+
//apply data on hot replace
|
|
4093
|
+
if (appModule.hot.data) store.load(appModule.hot.data.state);
|
|
4094
|
+
}
|
|
4095
|
+
Widget.resetCounter();
|
|
4096
|
+
|
|
4097
|
+
//app loop
|
|
4098
|
+
return (stop = startAppLoop(element, store, widgets, options));
|
|
4099
|
+
}
|
|
4100
|
+
|
|
4101
|
+
var GroupAdapter = /*#__PURE__*/ (function (_ArrayAdapter) {
|
|
4102
|
+
_inheritsLoose(GroupAdapter, _ArrayAdapter);
|
|
4103
|
+
function GroupAdapter() {
|
|
4104
|
+
return _ArrayAdapter.apply(this, arguments) || this;
|
|
4105
|
+
}
|
|
4106
|
+
var _proto = GroupAdapter.prototype;
|
|
4107
|
+
_proto.init = function init() {
|
|
4108
|
+
_ArrayAdapter.prototype.init.call(this);
|
|
4109
|
+
if (this.groupRecordsAlias) this.groupRecordsName = this.groupRecordsAlias;
|
|
4110
|
+
if (this.groupings) this.groupBy(this.groupings);
|
|
4111
|
+
};
|
|
4112
|
+
_proto.getRecords = function getRecords(context, instance, records, parentStore) {
|
|
4113
|
+
var result = _ArrayAdapter.prototype.getRecords.call(this, context, instance, records, parentStore);
|
|
4114
|
+
if (this.groupings) {
|
|
4115
|
+
var groupedResults = [];
|
|
4116
|
+
this.processLevel([], result, groupedResults, parentStore);
|
|
4117
|
+
result = groupedResults;
|
|
4118
|
+
}
|
|
4119
|
+
return result;
|
|
4120
|
+
};
|
|
4121
|
+
_proto.processLevel = function processLevel(keys, records, result, parentStore) {
|
|
4122
|
+
var _this = this;
|
|
4123
|
+
var level = keys.length;
|
|
4124
|
+
var inverseLevel = this.groupings.length - level;
|
|
4125
|
+
if (inverseLevel == 0) {
|
|
4126
|
+
for (var i = 0; i < records.length; i++) {
|
|
4127
|
+
records[i].store.setStore(parentStore);
|
|
4128
|
+
result.push(records[i]);
|
|
4129
|
+
}
|
|
4130
|
+
return;
|
|
4131
|
+
}
|
|
4132
|
+
var grouping = this.groupings[level];
|
|
4133
|
+
var grouper = grouping.grouper;
|
|
4134
|
+
grouper.reset();
|
|
4135
|
+
grouper.processAll(records);
|
|
4136
|
+
var results = grouper.getResults();
|
|
4137
|
+
if (grouping.comparer) results.sort(grouping.comparer);
|
|
4138
|
+
results.forEach(function (gr) {
|
|
4139
|
+
var _data;
|
|
4140
|
+
keys.push(gr.key);
|
|
4141
|
+
var key = keys
|
|
4142
|
+
.map(function (key) {
|
|
4143
|
+
return Object.keys(key)
|
|
4144
|
+
.map(function (k) {
|
|
4145
|
+
return key[k];
|
|
4146
|
+
})
|
|
4147
|
+
.join(":");
|
|
4148
|
+
})
|
|
4149
|
+
.join("|");
|
|
4150
|
+
var $group = _objectSpread2(
|
|
4151
|
+
_objectSpread2(_objectSpread2({}, gr.key), gr.aggregates),
|
|
4152
|
+
{},
|
|
4153
|
+
{
|
|
4154
|
+
$name: gr.name,
|
|
4155
|
+
$level: inverseLevel,
|
|
4156
|
+
$records: gr.records || [],
|
|
4157
|
+
$key: key,
|
|
4158
|
+
}
|
|
4159
|
+
);
|
|
4160
|
+
var data =
|
|
4161
|
+
((_data = {}),
|
|
4162
|
+
(_data[_this.recordName] = gr.records.length > 0 ? gr.records[0].data : null),
|
|
4163
|
+
(_data[_this.groupName] = $group),
|
|
4164
|
+
_data);
|
|
4165
|
+
var groupStore = new ReadOnlyDataView({
|
|
4166
|
+
store: parentStore,
|
|
4167
|
+
data: data,
|
|
4168
|
+
immutable: _this.immutable,
|
|
4169
|
+
});
|
|
4170
|
+
var group = {
|
|
4171
|
+
key: key,
|
|
4172
|
+
data: data,
|
|
4173
|
+
group: $group,
|
|
4174
|
+
grouping: grouping,
|
|
4175
|
+
store: groupStore,
|
|
4176
|
+
level: inverseLevel,
|
|
4177
|
+
};
|
|
4178
|
+
if (grouping.includeHeader !== false)
|
|
4179
|
+
result.push(
|
|
4180
|
+
_objectSpread2(
|
|
4181
|
+
_objectSpread2({}, group),
|
|
4182
|
+
{},
|
|
4183
|
+
{
|
|
4184
|
+
type: "group-header",
|
|
4185
|
+
key: "header:" + group.key,
|
|
4186
|
+
}
|
|
4187
|
+
)
|
|
4188
|
+
);
|
|
4189
|
+
_this.processLevel(keys, gr.records, result, groupStore);
|
|
4190
|
+
if (grouping.includeFooter !== false)
|
|
4191
|
+
result.push(
|
|
4192
|
+
_objectSpread2(
|
|
4193
|
+
_objectSpread2({}, group),
|
|
4194
|
+
{},
|
|
4195
|
+
{
|
|
4196
|
+
type: "group-footer",
|
|
4197
|
+
key: "footer:" + group.key,
|
|
4198
|
+
}
|
|
4199
|
+
)
|
|
4200
|
+
);
|
|
4201
|
+
keys.pop();
|
|
4202
|
+
});
|
|
4203
|
+
};
|
|
4204
|
+
_proto.groupBy = function groupBy(groupings) {
|
|
4205
|
+
var _this2 = this;
|
|
4206
|
+
if (!groupings) this.groupings = null;
|
|
4207
|
+
else if (isArray(groupings)) {
|
|
4208
|
+
this.groupings = groupings;
|
|
4209
|
+
this.groupings.forEach(function (g) {
|
|
4210
|
+
var groupSorters = [];
|
|
4211
|
+
var key = {};
|
|
4212
|
+
for (var name in g.key) {
|
|
4213
|
+
if (!g.key[name] || !isDefined(g.key[name].direction) || !isDefined(g.key[name].value))
|
|
4214
|
+
g.key[name] = {
|
|
4215
|
+
value: g.key[name],
|
|
4216
|
+
direction: "ASC",
|
|
4217
|
+
};
|
|
4218
|
+
key[name] = g.key[name].value;
|
|
4219
|
+
groupSorters.push({
|
|
4220
|
+
field: name,
|
|
4221
|
+
direction: g.key[name].direction,
|
|
4222
|
+
});
|
|
4223
|
+
}
|
|
4224
|
+
g.grouper = new Grouper(
|
|
4225
|
+
key,
|
|
4226
|
+
_objectSpread2(_objectSpread2({}, _this2.aggregates), g.aggregates),
|
|
4227
|
+
function (r) {
|
|
4228
|
+
return r.store.getData();
|
|
4229
|
+
},
|
|
4230
|
+
g.text
|
|
4231
|
+
);
|
|
4232
|
+
g.comparer = null;
|
|
4233
|
+
if (groupSorters.length > 0)
|
|
4234
|
+
g.comparer = getComparer(
|
|
4235
|
+
groupSorters,
|
|
4236
|
+
function (x) {
|
|
4237
|
+
return x.key;
|
|
4238
|
+
},
|
|
4239
|
+
_this2.sortOptions ? Culture.getComparer(_this2.sortOptions) : null
|
|
4240
|
+
);
|
|
4241
|
+
});
|
|
4242
|
+
} else throw new Error("Invalid grouping provided.");
|
|
4243
|
+
};
|
|
4244
|
+
return GroupAdapter;
|
|
4245
|
+
})(ArrayAdapter);
|
|
4246
|
+
GroupAdapter.prototype.groupName = "$group";
|
|
4247
|
+
|
|
4248
|
+
var TreeAdapter = /*#__PURE__*/ (function (_ArrayAdapter) {
|
|
4249
|
+
_inheritsLoose(TreeAdapter, _ArrayAdapter);
|
|
4250
|
+
function TreeAdapter() {
|
|
4251
|
+
return _ArrayAdapter.apply(this, arguments) || this;
|
|
4252
|
+
}
|
|
4253
|
+
var _proto = TreeAdapter.prototype;
|
|
4254
|
+
_proto.init = function init() {
|
|
4255
|
+
_ArrayAdapter.prototype.init.call(this);
|
|
4256
|
+
this.childrenAccessor = getAccessor({
|
|
4257
|
+
bind: this.recordName + "." + this.childrenField,
|
|
4258
|
+
});
|
|
4259
|
+
if (this.restoreExpandedNodesOnLoad) {
|
|
4260
|
+
if (!this.keyField)
|
|
4261
|
+
throw new Error(
|
|
4262
|
+
"Stateful tree adapter requires keyField property to be specified on either Grid or data adapter."
|
|
4263
|
+
);
|
|
4264
|
+
this.expandedState = {
|
|
4265
|
+
next: new Set(),
|
|
4266
|
+
};
|
|
4267
|
+
}
|
|
4268
|
+
};
|
|
4269
|
+
_proto.mapRecords = function mapRecords(context, instance, data, parentStore, recordsAccessor) {
|
|
4270
|
+
var nodes = _ArrayAdapter.prototype.mapRecords.call(this, context, instance, data, parentStore, recordsAccessor);
|
|
4271
|
+
var result = [];
|
|
4272
|
+
if (this.restoreExpandedNodesOnLoad) {
|
|
4273
|
+
this.expandedState = {
|
|
4274
|
+
current: this.expandedState.next,
|
|
4275
|
+
next: new Set(),
|
|
4276
|
+
};
|
|
4277
|
+
}
|
|
4278
|
+
this.processList(context, instance, 0, "", nodes, result);
|
|
4279
|
+
return result;
|
|
4280
|
+
};
|
|
4281
|
+
_proto.processList = function processList(context, instance, level, parentKey, nodes, result) {
|
|
4282
|
+
var _this = this;
|
|
4283
|
+
nodes.forEach(function (record) {
|
|
4284
|
+
record.key = parentKey + record.key;
|
|
4285
|
+
_this.processNode(context, instance, level, result, record);
|
|
4286
|
+
});
|
|
4287
|
+
};
|
|
4288
|
+
_proto.processNode = function processNode(context, instance, level, result, record) {
|
|
4289
|
+
var _this2 = this;
|
|
4290
|
+
var isHiddenRootNode = level == 0 && this.hideRootNodes;
|
|
4291
|
+
if (!isHiddenRootNode) result.push(record);
|
|
4292
|
+
var data = record.data,
|
|
4293
|
+
store = record.store;
|
|
4294
|
+
data.$level = this.hideRootNodes ? level - 1 : level;
|
|
4295
|
+
if (!data[this.leafField]) {
|
|
4296
|
+
if (this.restoreExpandedNodesOnLoad && data[this.expandedField] == null)
|
|
4297
|
+
data[this.expandedField] = this.expandedState.current.has(data[this.keyField]);
|
|
4298
|
+
if (data[this.expandedField] || isHiddenRootNode) {
|
|
4299
|
+
if (this.restoreExpandedNodesOnLoad) this.expandedState.next.add(data[this.keyField]);
|
|
4300
|
+
if (data[this.childrenField]) {
|
|
4301
|
+
var childNodes = _ArrayAdapter.prototype.mapRecords.call(
|
|
4302
|
+
this,
|
|
4303
|
+
context,
|
|
4304
|
+
instance,
|
|
4305
|
+
data[this.childrenField],
|
|
4306
|
+
store,
|
|
4307
|
+
this.childrenAccessor
|
|
4308
|
+
);
|
|
4309
|
+
this.processList(context, instance, level + 1, record.key + ":", childNodes, result);
|
|
4310
|
+
} else if (this.load && !data[this.loadedField] && !data[this.loadingField]) {
|
|
4311
|
+
store.set(this.recordName + "." + this.loadingField, true);
|
|
4312
|
+
var response = this.load(context, instance, data);
|
|
4313
|
+
Promise.resolve(response)
|
|
4314
|
+
.then(function (children) {
|
|
4315
|
+
store.set(_this2.recordName + "." + _this2.childrenField, children);
|
|
4316
|
+
store.set(_this2.recordName + "." + _this2.loadedField, true);
|
|
4317
|
+
store.set(_this2.recordName + "." + _this2.loadingField, false);
|
|
4318
|
+
})
|
|
4319
|
+
["catch"](function (response) {
|
|
4320
|
+
store.set(_this2.recordName + "." + _this2.loadingField, false);
|
|
4321
|
+
if (_this2.onLoadError) _this2.onLoadError(response);
|
|
4322
|
+
});
|
|
4323
|
+
}
|
|
4324
|
+
} else data[this.expandedField] = false;
|
|
4325
|
+
}
|
|
4326
|
+
};
|
|
4327
|
+
_proto.sort = function sort(sorters) {
|
|
4328
|
+
if (this.foldersFirst) {
|
|
4329
|
+
if (!sorters || !isArray(sorters)) sorters = [];
|
|
4330
|
+
sorters = [
|
|
4331
|
+
{
|
|
4332
|
+
field: this.leafField,
|
|
4333
|
+
direction: "ASC",
|
|
4334
|
+
},
|
|
4335
|
+
].concat(sorters);
|
|
4336
|
+
}
|
|
4337
|
+
_ArrayAdapter.prototype.sort.call(this, sorters);
|
|
4338
|
+
};
|
|
4339
|
+
return TreeAdapter;
|
|
4340
|
+
})(ArrayAdapter);
|
|
4341
|
+
TreeAdapter.prototype.childrenField = "$children";
|
|
4342
|
+
TreeAdapter.prototype.expandedField = "$expanded";
|
|
4343
|
+
TreeAdapter.prototype.leafField = "$leaf";
|
|
4344
|
+
TreeAdapter.prototype.loadingField = "$loading";
|
|
4345
|
+
TreeAdapter.prototype.loadedField = "$loaded";
|
|
4346
|
+
TreeAdapter.prototype.foldersFirst = true;
|
|
4347
|
+
TreeAdapter.prototype.isTreeAdapter = true;
|
|
4348
|
+
TreeAdapter.prototype.hideRootNodes = false;
|
|
4349
|
+
|
|
4350
|
+
function bind(path, defaultValue) {
|
|
4351
|
+
return {
|
|
4352
|
+
//toString will ensure chain accessors are converted to strings
|
|
4353
|
+
bind: path.toString(),
|
|
4354
|
+
defaultValue: defaultValue,
|
|
4355
|
+
};
|
|
4356
|
+
}
|
|
4357
|
+
|
|
4358
|
+
function tpl(text) {
|
|
4359
|
+
return {
|
|
4360
|
+
tpl: text,
|
|
4361
|
+
};
|
|
4362
|
+
}
|
|
4363
|
+
|
|
4364
|
+
function expr(text) {
|
|
4365
|
+
var _this = this;
|
|
4366
|
+
if (isString(text))
|
|
4367
|
+
return {
|
|
4368
|
+
expr: text,
|
|
4369
|
+
};
|
|
4370
|
+
var getters = [];
|
|
4371
|
+
var compute = arguments[arguments.length - 1];
|
|
4372
|
+
for (var i = 0; i < arguments.length - 1; i++) getters.push(Binding.get(arguments[i]).value);
|
|
4373
|
+
return function (data) {
|
|
4374
|
+
var argv = getters.map(function (g) {
|
|
4375
|
+
return g(data);
|
|
4376
|
+
});
|
|
4377
|
+
return compute.apply(_this, argv);
|
|
4378
|
+
};
|
|
4379
|
+
}
|
|
4380
|
+
|
|
4381
|
+
export {
|
|
4382
|
+
ArrayAdapter,
|
|
4383
|
+
CSS,
|
|
4384
|
+
CSSHelper,
|
|
4385
|
+
Container,
|
|
4386
|
+
Content,
|
|
4387
|
+
ContentPlaceholder,
|
|
4388
|
+
ContentPlaceholderScope,
|
|
4389
|
+
ContentResolver,
|
|
4390
|
+
Controller,
|
|
4391
|
+
Culture,
|
|
4392
|
+
Cx,
|
|
4393
|
+
DataAdapter,
|
|
4394
|
+
DataProxy,
|
|
4395
|
+
DetachedScope,
|
|
4396
|
+
FirstVisibleChildLayout,
|
|
4397
|
+
FocusManager,
|
|
4398
|
+
Format,
|
|
4399
|
+
GroupAdapter,
|
|
4400
|
+
History,
|
|
4401
|
+
HoverSync,
|
|
4402
|
+
HoverSyncElement,
|
|
4403
|
+
Instance,
|
|
4404
|
+
InstanceCache,
|
|
4405
|
+
IsolatedScope,
|
|
4406
|
+
KeySelection,
|
|
4407
|
+
LabelsLeftLayout,
|
|
4408
|
+
LabelsTopLayout,
|
|
4409
|
+
LabelsTopLayoutCell,
|
|
4410
|
+
Localization,
|
|
4411
|
+
PrivateStore,
|
|
4412
|
+
PropertySelection,
|
|
4413
|
+
PureContainer,
|
|
4414
|
+
RenderingContext,
|
|
4415
|
+
Repeater,
|
|
4416
|
+
Rescope,
|
|
4417
|
+
ResizeManager,
|
|
4418
|
+
Restate,
|
|
4419
|
+
Selection,
|
|
4420
|
+
SimpleSelection,
|
|
4421
|
+
StaticText,
|
|
4422
|
+
StructuredInstanceDataAccessor,
|
|
4423
|
+
Text,
|
|
4424
|
+
TreeAdapter,
|
|
4425
|
+
Url,
|
|
4426
|
+
UseParentLayout,
|
|
4427
|
+
VDOM,
|
|
4428
|
+
Widget,
|
|
4429
|
+
ZIndexManager,
|
|
4430
|
+
batchUpdates,
|
|
4431
|
+
batchUpdatesAndNotify,
|
|
4432
|
+
bind,
|
|
4433
|
+
contentAppend,
|
|
4434
|
+
createFunctionalComponent,
|
|
4435
|
+
enableCultureSensitiveFormatting,
|
|
4436
|
+
executeKeyboardShortcuts,
|
|
4437
|
+
exploreChildren,
|
|
4438
|
+
expr,
|
|
4439
|
+
flattenProps,
|
|
4440
|
+
getContent,
|
|
4441
|
+
getContentArray,
|
|
4442
|
+
getCurrentInstance,
|
|
4443
|
+
isBatchingUpdates,
|
|
4444
|
+
notifyBatchedUpdateCompleted,
|
|
4445
|
+
notifyBatchedUpdateStarting,
|
|
4446
|
+
offFocusOut,
|
|
4447
|
+
oneFocusOut,
|
|
4448
|
+
preventFocus,
|
|
4449
|
+
preventFocusOnTouch,
|
|
4450
|
+
registerKeyboardShortcut,
|
|
4451
|
+
startAppLoop,
|
|
4452
|
+
startHotAppLoop,
|
|
4453
|
+
tpl,
|
|
4454
|
+
unfocusElement,
|
|
4455
|
+
withHoverSync,
|
|
4456
|
+
};
|