@sitecore-feaas/clientside 0.1.15 → 0.1.16
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/README.md +5 -5
- package/build/basic.js +11 -0
- package/build/basic.js.map +1 -0
- package/build/cloud.js +22 -0
- package/build/cloud.js.map +1 -0
- package/build/components/FEAASBase.js +229 -0
- package/build/components/FEAASBase.js.map +1 -0
- package/build/components/FEAASComponent.js +84 -0
- package/build/components/FEAASComponent.js.map +1 -0
- package/build/components/FEAASLoader.js +100 -0
- package/build/components/FEAASLoader.js.map +1 -0
- package/build/components/FEAASStylesheet.js +31 -0
- package/build/components/FEAASStylesheet.js.map +1 -0
- package/build/dom.js +294 -0
- package/build/dom.js.map +1 -0
- package/build/fetch.js +56 -0
- package/build/fetch.js.map +1 -0
- package/build/ui/FEAASContext.js +68 -0
- package/build/ui/FEAASContext.js.map +1 -0
- package/build/ui/FEAASEditor.js +180 -0
- package/build/ui/FEAASEditor.js.map +1 -0
- package/build/ui/FEAASPicker.js +81 -0
- package/build/ui/FEAASPicker.js.map +1 -0
- package/build/ui/index.js +5 -0
- package/build/ui/index.js.map +1 -0
- package/dist/browser/basic.esm.js +68 -0
- package/dist/browser/basic.esm.js.map +1 -0
- package/dist/browser/basic.js +5 -4
- package/dist/browser/basic.js.map +1 -0
- package/dist/browser/index.esm.js +73 -0
- package/dist/browser/index.esm.js.map +1 -0
- package/dist/browser/index.js +8 -7
- package/dist/browser/index.js.map +1 -0
- package/dist/node/basic.esm.js +66 -0
- package/dist/node/basic.esm.js.map +1 -0
- package/dist/node/basic.js +4 -1458
- package/dist/node/basic.js.map +1 -0
- package/dist/node/index.esm.js +71 -0
- package/dist/node/index.esm.js.map +1 -0
- package/dist/node/index.js +7 -1858
- package/dist/node/index.js.map +1 -0
- package/package.json +25 -34
- package/scripts/build.js +76 -0
- package/src/basic.ts +11 -1
- package/src/components/FEAASBase.tsx +4 -2
- package/src/components/FEAASComponent.ts +7 -2
- package/src/components/FEAASLoader.ts +2 -0
- package/src/components/FEAASStylesheet.ts +2 -1
- package/src/{components → ui}/FEAASContext.tsx +3 -5
- package/src/{components → ui}/FEAASEditor.tsx +4 -4
- package/src/{components → ui}/FEAASPicker.tsx +3 -4
- package/src/ui/index.ts +4 -0
- package/src/ui/tsconfig.json +22 -0
- package/test/render.ts +0 -1
- package/tsconfig.json +3 -3
- package/tsconfig.test.json +0 -0
- package/types/basic.d.ts +8 -1
- package/types/basic.d.ts.map +1 -0
- package/types/cloud.d.ts +1 -0
- package/types/cloud.d.ts.map +1 -0
- package/types/components/FEAASBase.d.ts +7 -1
- package/types/components/FEAASBase.d.ts.map +1 -0
- package/types/components/FEAASComponent.d.ts +7 -1
- package/types/components/FEAASComponent.d.ts.map +1 -0
- package/types/components/FEAASLoader.d.ts +2 -1
- package/types/components/FEAASLoader.d.ts.map +1 -0
- package/types/components/FEAASStylesheet.d.ts +5 -1
- package/types/components/FEAASStylesheet.d.ts.map +1 -0
- package/types/dom.d.ts +1 -0
- package/types/dom.d.ts.map +1 -0
- package/types/fetch.d.ts +1 -0
- package/types/fetch.d.ts.map +1 -0
- package/types/tsbuildinfo +1 -1
- package/types/tsbuildinfo_ui +1 -0
- package/types/{components → ui}/FEAASContext.d.ts +3 -2
- package/types/ui/FEAASContext.d.ts.map +1 -0
- package/types/{components → ui}/FEAASEditor.d.ts +3 -2
- package/types/ui/FEAASEditor.d.ts.map +1 -0
- package/types/{components → ui}/FEAASPicker.d.ts +3 -2
- package/types/ui/FEAASPicker.d.ts.map +1 -0
- package/types/ui/index.d.ts +5 -0
- package/types/ui/index.d.ts.map +1 -0
- package/dist/browser/basic.cjs +0 -67
- package/dist/browser/index.cjs +0 -72
- package/dist/node/basic.cjs +0 -1539
- package/dist/node/index.cjs +0 -1941
- package/src/components/index.tsx +0 -7
- package/src/index.ts +0 -4
- package/test/components.js +0 -11
- package/test/render.js +0 -688
- package/types/components/index.d.ts +0 -7
- package/types/index.d.ts +0 -4
package/dist/node/index.js
CHANGED
|
@@ -1,1318 +1,4 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __async = (__this, __arguments, generator) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
var fulfilled = (value) => {
|
|
23
|
-
try {
|
|
24
|
-
step(generator.next(value));
|
|
25
|
-
} catch (e) {
|
|
26
|
-
reject(e);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var rejected = (value) => {
|
|
30
|
-
try {
|
|
31
|
-
step(generator.throw(value));
|
|
32
|
-
} catch (e) {
|
|
33
|
-
reject(e);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// ../node_modules/jsonpath-plus/dist/index-browser-esm.js
|
|
42
|
-
function _typeof(obj) {
|
|
43
|
-
"@babel/helpers - typeof";
|
|
44
|
-
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
45
|
-
_typeof = function(obj2) {
|
|
46
|
-
return typeof obj2;
|
|
47
|
-
};
|
|
48
|
-
} else {
|
|
49
|
-
_typeof = function(obj2) {
|
|
50
|
-
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
return _typeof(obj);
|
|
54
|
-
}
|
|
55
|
-
function _classCallCheck(instance, Constructor) {
|
|
56
|
-
if (!(instance instanceof Constructor)) {
|
|
57
|
-
throw new TypeError("Cannot call a class as a function");
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function _inherits(subClass, superClass) {
|
|
61
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
62
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
63
|
-
}
|
|
64
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
65
|
-
constructor: {
|
|
66
|
-
value: subClass,
|
|
67
|
-
writable: true,
|
|
68
|
-
configurable: true
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
if (superClass)
|
|
72
|
-
_setPrototypeOf(subClass, superClass);
|
|
73
|
-
}
|
|
74
|
-
function _getPrototypeOf(o) {
|
|
75
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o2) {
|
|
76
|
-
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
77
|
-
};
|
|
78
|
-
return _getPrototypeOf(o);
|
|
79
|
-
}
|
|
80
|
-
function _setPrototypeOf(o, p) {
|
|
81
|
-
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
|
|
82
|
-
o2.__proto__ = p2;
|
|
83
|
-
return o2;
|
|
84
|
-
};
|
|
85
|
-
return _setPrototypeOf(o, p);
|
|
86
|
-
}
|
|
87
|
-
function _isNativeReflectConstruct() {
|
|
88
|
-
if (typeof Reflect === "undefined" || !Reflect.construct)
|
|
89
|
-
return false;
|
|
90
|
-
if (Reflect.construct.sham)
|
|
91
|
-
return false;
|
|
92
|
-
if (typeof Proxy === "function")
|
|
93
|
-
return true;
|
|
94
|
-
try {
|
|
95
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
96
|
-
}));
|
|
97
|
-
return true;
|
|
98
|
-
} catch (e) {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
function _construct(Parent, args, Class) {
|
|
103
|
-
if (_isNativeReflectConstruct()) {
|
|
104
|
-
_construct = Reflect.construct;
|
|
105
|
-
} else {
|
|
106
|
-
_construct = function _construct2(Parent2, args2, Class2) {
|
|
107
|
-
var a = [null];
|
|
108
|
-
a.push.apply(a, args2);
|
|
109
|
-
var Constructor = Function.bind.apply(Parent2, a);
|
|
110
|
-
var instance = new Constructor();
|
|
111
|
-
if (Class2)
|
|
112
|
-
_setPrototypeOf(instance, Class2.prototype);
|
|
113
|
-
return instance;
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
return _construct.apply(null, arguments);
|
|
117
|
-
}
|
|
118
|
-
function _isNativeFunction(fn) {
|
|
119
|
-
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
120
|
-
}
|
|
121
|
-
function _wrapNativeSuper(Class) {
|
|
122
|
-
var _cache = typeof Map === "function" ? /* @__PURE__ */ new Map() : void 0;
|
|
123
|
-
_wrapNativeSuper = function _wrapNativeSuper2(Class2) {
|
|
124
|
-
if (Class2 === null || !_isNativeFunction(Class2))
|
|
125
|
-
return Class2;
|
|
126
|
-
if (typeof Class2 !== "function") {
|
|
127
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
128
|
-
}
|
|
129
|
-
if (typeof _cache !== "undefined") {
|
|
130
|
-
if (_cache.has(Class2))
|
|
131
|
-
return _cache.get(Class2);
|
|
132
|
-
_cache.set(Class2, Wrapper);
|
|
133
|
-
}
|
|
134
|
-
function Wrapper() {
|
|
135
|
-
return _construct(Class2, arguments, _getPrototypeOf(this).constructor);
|
|
136
|
-
}
|
|
137
|
-
Wrapper.prototype = Object.create(Class2.prototype, {
|
|
138
|
-
constructor: {
|
|
139
|
-
value: Wrapper,
|
|
140
|
-
enumerable: false,
|
|
141
|
-
writable: true,
|
|
142
|
-
configurable: true
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
return _setPrototypeOf(Wrapper, Class2);
|
|
146
|
-
};
|
|
147
|
-
return _wrapNativeSuper(Class);
|
|
148
|
-
}
|
|
149
|
-
function _assertThisInitialized(self) {
|
|
150
|
-
if (self === void 0) {
|
|
151
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
152
|
-
}
|
|
153
|
-
return self;
|
|
154
|
-
}
|
|
155
|
-
function _possibleConstructorReturn(self, call) {
|
|
156
|
-
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
157
|
-
return call;
|
|
158
|
-
}
|
|
159
|
-
return _assertThisInitialized(self);
|
|
160
|
-
}
|
|
161
|
-
function _createSuper(Derived) {
|
|
162
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
163
|
-
return function _createSuperInternal() {
|
|
164
|
-
var Super = _getPrototypeOf(Derived), result;
|
|
165
|
-
if (hasNativeReflectConstruct) {
|
|
166
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
167
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
168
|
-
} else {
|
|
169
|
-
result = Super.apply(this, arguments);
|
|
170
|
-
}
|
|
171
|
-
return _possibleConstructorReturn(this, result);
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
function _toConsumableArray(arr) {
|
|
175
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
176
|
-
}
|
|
177
|
-
function _arrayWithoutHoles(arr) {
|
|
178
|
-
if (Array.isArray(arr))
|
|
179
|
-
return _arrayLikeToArray(arr);
|
|
180
|
-
}
|
|
181
|
-
function _iterableToArray(iter) {
|
|
182
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
|
|
183
|
-
return Array.from(iter);
|
|
184
|
-
}
|
|
185
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
186
|
-
if (!o)
|
|
187
|
-
return;
|
|
188
|
-
if (typeof o === "string")
|
|
189
|
-
return _arrayLikeToArray(o, minLen);
|
|
190
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
191
|
-
if (n === "Object" && o.constructor)
|
|
192
|
-
n = o.constructor.name;
|
|
193
|
-
if (n === "Map" || n === "Set")
|
|
194
|
-
return Array.from(o);
|
|
195
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
196
|
-
return _arrayLikeToArray(o, minLen);
|
|
197
|
-
}
|
|
198
|
-
function _arrayLikeToArray(arr, len) {
|
|
199
|
-
if (len == null || len > arr.length)
|
|
200
|
-
len = arr.length;
|
|
201
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
202
|
-
arr2[i] = arr[i];
|
|
203
|
-
return arr2;
|
|
204
|
-
}
|
|
205
|
-
function _nonIterableSpread() {
|
|
206
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
207
|
-
}
|
|
208
|
-
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
209
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
210
|
-
if (!it) {
|
|
211
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
212
|
-
if (it)
|
|
213
|
-
o = it;
|
|
214
|
-
var i = 0;
|
|
215
|
-
var F = function() {
|
|
216
|
-
};
|
|
217
|
-
return {
|
|
218
|
-
s: F,
|
|
219
|
-
n: function() {
|
|
220
|
-
if (i >= o.length)
|
|
221
|
-
return {
|
|
222
|
-
done: true
|
|
223
|
-
};
|
|
224
|
-
return {
|
|
225
|
-
done: false,
|
|
226
|
-
value: o[i++]
|
|
227
|
-
};
|
|
228
|
-
},
|
|
229
|
-
e: function(e) {
|
|
230
|
-
throw e;
|
|
231
|
-
},
|
|
232
|
-
f: F
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
236
|
-
}
|
|
237
|
-
var normalCompletion = true, didErr = false, err;
|
|
238
|
-
return {
|
|
239
|
-
s: function() {
|
|
240
|
-
it = it.call(o);
|
|
241
|
-
},
|
|
242
|
-
n: function() {
|
|
243
|
-
var step = it.next();
|
|
244
|
-
normalCompletion = step.done;
|
|
245
|
-
return step;
|
|
246
|
-
},
|
|
247
|
-
e: function(e) {
|
|
248
|
-
didErr = true;
|
|
249
|
-
err = e;
|
|
250
|
-
},
|
|
251
|
-
f: function() {
|
|
252
|
-
try {
|
|
253
|
-
if (!normalCompletion && it.return != null)
|
|
254
|
-
it.return();
|
|
255
|
-
} finally {
|
|
256
|
-
if (didErr)
|
|
257
|
-
throw err;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
var hasOwnProp = Object.prototype.hasOwnProperty;
|
|
263
|
-
function push(arr, item) {
|
|
264
|
-
arr = arr.slice();
|
|
265
|
-
arr.push(item);
|
|
266
|
-
return arr;
|
|
267
|
-
}
|
|
268
|
-
function unshift(item, arr) {
|
|
269
|
-
arr = arr.slice();
|
|
270
|
-
arr.unshift(item);
|
|
271
|
-
return arr;
|
|
272
|
-
}
|
|
273
|
-
var NewError = /* @__PURE__ */ function(_Error) {
|
|
274
|
-
_inherits(NewError2, _Error);
|
|
275
|
-
var _super = _createSuper(NewError2);
|
|
276
|
-
function NewError2(value) {
|
|
277
|
-
var _this;
|
|
278
|
-
_classCallCheck(this, NewError2);
|
|
279
|
-
_this = _super.call(this, 'JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)');
|
|
280
|
-
_this.avoidNew = true;
|
|
281
|
-
_this.value = value;
|
|
282
|
-
_this.name = "NewError";
|
|
283
|
-
return _this;
|
|
284
|
-
}
|
|
285
|
-
return NewError2;
|
|
286
|
-
}(/* @__PURE__ */ _wrapNativeSuper(Error));
|
|
287
|
-
function JSONPath(opts, expr, obj, callback, otherTypeCallback) {
|
|
288
|
-
if (!(this instanceof JSONPath)) {
|
|
289
|
-
try {
|
|
290
|
-
return new JSONPath(opts, expr, obj, callback, otherTypeCallback);
|
|
291
|
-
} catch (e) {
|
|
292
|
-
if (!e.avoidNew) {
|
|
293
|
-
throw e;
|
|
294
|
-
}
|
|
295
|
-
return e.value;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
if (typeof opts === "string") {
|
|
299
|
-
otherTypeCallback = callback;
|
|
300
|
-
callback = obj;
|
|
301
|
-
obj = expr;
|
|
302
|
-
expr = opts;
|
|
303
|
-
opts = null;
|
|
304
|
-
}
|
|
305
|
-
var optObj = opts && _typeof(opts) === "object";
|
|
306
|
-
opts = opts || {};
|
|
307
|
-
this.json = opts.json || obj;
|
|
308
|
-
this.path = opts.path || expr;
|
|
309
|
-
this.resultType = opts.resultType || "value";
|
|
310
|
-
this.flatten = opts.flatten || false;
|
|
311
|
-
this.wrap = hasOwnProp.call(opts, "wrap") ? opts.wrap : true;
|
|
312
|
-
this.sandbox = opts.sandbox || {};
|
|
313
|
-
this.preventEval = opts.preventEval || false;
|
|
314
|
-
this.parent = opts.parent || null;
|
|
315
|
-
this.parentProperty = opts.parentProperty || null;
|
|
316
|
-
this.callback = opts.callback || callback || null;
|
|
317
|
-
this.otherTypeCallback = opts.otherTypeCallback || otherTypeCallback || function() {
|
|
318
|
-
throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.");
|
|
319
|
-
};
|
|
320
|
-
if (opts.autostart !== false) {
|
|
321
|
-
var args = {
|
|
322
|
-
path: optObj ? opts.path : expr
|
|
323
|
-
};
|
|
324
|
-
if (!optObj) {
|
|
325
|
-
args.json = obj;
|
|
326
|
-
} else if ("json" in opts) {
|
|
327
|
-
args.json = opts.json;
|
|
328
|
-
}
|
|
329
|
-
var ret = this.evaluate(args);
|
|
330
|
-
if (!ret || _typeof(ret) !== "object") {
|
|
331
|
-
throw new NewError(ret);
|
|
332
|
-
}
|
|
333
|
-
return ret;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
JSONPath.prototype.evaluate = function(expr, json, callback, otherTypeCallback) {
|
|
337
|
-
var _this2 = this;
|
|
338
|
-
var currParent = this.parent, currParentProperty = this.parentProperty;
|
|
339
|
-
var flatten = this.flatten, wrap = this.wrap;
|
|
340
|
-
this.currResultType = this.resultType;
|
|
341
|
-
this.currPreventEval = this.preventEval;
|
|
342
|
-
this.currSandbox = this.sandbox;
|
|
343
|
-
callback = callback || this.callback;
|
|
344
|
-
this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback;
|
|
345
|
-
json = json || this.json;
|
|
346
|
-
expr = expr || this.path;
|
|
347
|
-
if (expr && _typeof(expr) === "object" && !Array.isArray(expr)) {
|
|
348
|
-
if (!expr.path && expr.path !== "") {
|
|
349
|
-
throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');
|
|
350
|
-
}
|
|
351
|
-
if (!hasOwnProp.call(expr, "json")) {
|
|
352
|
-
throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');
|
|
353
|
-
}
|
|
354
|
-
var _expr = expr;
|
|
355
|
-
json = _expr.json;
|
|
356
|
-
flatten = hasOwnProp.call(expr, "flatten") ? expr.flatten : flatten;
|
|
357
|
-
this.currResultType = hasOwnProp.call(expr, "resultType") ? expr.resultType : this.currResultType;
|
|
358
|
-
this.currSandbox = hasOwnProp.call(expr, "sandbox") ? expr.sandbox : this.currSandbox;
|
|
359
|
-
wrap = hasOwnProp.call(expr, "wrap") ? expr.wrap : wrap;
|
|
360
|
-
this.currPreventEval = hasOwnProp.call(expr, "preventEval") ? expr.preventEval : this.currPreventEval;
|
|
361
|
-
callback = hasOwnProp.call(expr, "callback") ? expr.callback : callback;
|
|
362
|
-
this.currOtherTypeCallback = hasOwnProp.call(expr, "otherTypeCallback") ? expr.otherTypeCallback : this.currOtherTypeCallback;
|
|
363
|
-
currParent = hasOwnProp.call(expr, "parent") ? expr.parent : currParent;
|
|
364
|
-
currParentProperty = hasOwnProp.call(expr, "parentProperty") ? expr.parentProperty : currParentProperty;
|
|
365
|
-
expr = expr.path;
|
|
366
|
-
}
|
|
367
|
-
currParent = currParent || null;
|
|
368
|
-
currParentProperty = currParentProperty || null;
|
|
369
|
-
if (Array.isArray(expr)) {
|
|
370
|
-
expr = JSONPath.toPathString(expr);
|
|
371
|
-
}
|
|
372
|
-
if (!expr && expr !== "" || !json) {
|
|
373
|
-
return void 0;
|
|
374
|
-
}
|
|
375
|
-
var exprList = JSONPath.toPathArray(expr);
|
|
376
|
-
if (exprList[0] === "$" && exprList.length > 1) {
|
|
377
|
-
exprList.shift();
|
|
378
|
-
}
|
|
379
|
-
this._hasParentSelector = null;
|
|
380
|
-
var result = this._trace(exprList, json, ["$"], currParent, currParentProperty, callback).filter(function(ea) {
|
|
381
|
-
return ea && !ea.isParentSelector;
|
|
382
|
-
});
|
|
383
|
-
if (!result.length) {
|
|
384
|
-
return wrap ? [] : void 0;
|
|
385
|
-
}
|
|
386
|
-
if (!wrap && result.length === 1 && !result[0].hasArrExpr) {
|
|
387
|
-
return this._getPreferredOutput(result[0]);
|
|
388
|
-
}
|
|
389
|
-
return result.reduce(function(rslt, ea) {
|
|
390
|
-
var valOrPath = _this2._getPreferredOutput(ea);
|
|
391
|
-
if (flatten && Array.isArray(valOrPath)) {
|
|
392
|
-
rslt = rslt.concat(valOrPath);
|
|
393
|
-
} else {
|
|
394
|
-
rslt.push(valOrPath);
|
|
395
|
-
}
|
|
396
|
-
return rslt;
|
|
397
|
-
}, []);
|
|
398
|
-
};
|
|
399
|
-
JSONPath.prototype._getPreferredOutput = function(ea) {
|
|
400
|
-
var resultType = this.currResultType;
|
|
401
|
-
switch (resultType) {
|
|
402
|
-
case "all": {
|
|
403
|
-
var path = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);
|
|
404
|
-
ea.pointer = JSONPath.toPointer(path);
|
|
405
|
-
ea.path = typeof ea.path === "string" ? ea.path : JSONPath.toPathString(ea.path);
|
|
406
|
-
return ea;
|
|
407
|
-
}
|
|
408
|
-
case "value":
|
|
409
|
-
case "parent":
|
|
410
|
-
case "parentProperty":
|
|
411
|
-
return ea[resultType];
|
|
412
|
-
case "path":
|
|
413
|
-
return JSONPath.toPathString(ea[resultType]);
|
|
414
|
-
case "pointer":
|
|
415
|
-
return JSONPath.toPointer(ea.path);
|
|
416
|
-
default:
|
|
417
|
-
throw new TypeError("Unknown result type");
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
|
-
JSONPath.prototype._handleCallback = function(fullRetObj, callback, type) {
|
|
421
|
-
if (callback) {
|
|
422
|
-
var preferredOutput = this._getPreferredOutput(fullRetObj);
|
|
423
|
-
fullRetObj.path = typeof fullRetObj.path === "string" ? fullRetObj.path : JSONPath.toPathString(fullRetObj.path);
|
|
424
|
-
callback(preferredOutput, type, fullRetObj);
|
|
425
|
-
}
|
|
426
|
-
};
|
|
427
|
-
JSONPath.prototype._trace = function(expr, val, path, parent, parentPropName, callback, hasArrExpr, literalPriority) {
|
|
428
|
-
var _this3 = this;
|
|
429
|
-
var retObj;
|
|
430
|
-
if (!expr.length) {
|
|
431
|
-
retObj = {
|
|
432
|
-
path,
|
|
433
|
-
value: val,
|
|
434
|
-
parent,
|
|
435
|
-
parentProperty: parentPropName,
|
|
436
|
-
hasArrExpr
|
|
437
|
-
};
|
|
438
|
-
this._handleCallback(retObj, callback, "value");
|
|
439
|
-
return retObj;
|
|
440
|
-
}
|
|
441
|
-
var loc = expr[0], x = expr.slice(1);
|
|
442
|
-
var ret = [];
|
|
443
|
-
function addRet(elems) {
|
|
444
|
-
if (Array.isArray(elems)) {
|
|
445
|
-
elems.forEach(function(t2) {
|
|
446
|
-
ret.push(t2);
|
|
447
|
-
});
|
|
448
|
-
} else {
|
|
449
|
-
ret.push(elems);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
if ((typeof loc !== "string" || literalPriority) && val && hasOwnProp.call(val, loc)) {
|
|
453
|
-
addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback, hasArrExpr));
|
|
454
|
-
} else if (loc === "*") {
|
|
455
|
-
this._walk(loc, x, val, path, parent, parentPropName, callback, function(m, l, _x, v, p, par, pr, cb) {
|
|
456
|
-
addRet(_this3._trace(unshift(m, _x), v, p, par, pr, cb, true, true));
|
|
457
|
-
});
|
|
458
|
-
} else if (loc === "..") {
|
|
459
|
-
addRet(this._trace(x, val, path, parent, parentPropName, callback, hasArrExpr));
|
|
460
|
-
this._walk(loc, x, val, path, parent, parentPropName, callback, function(m, l, _x, v, p, par, pr, cb) {
|
|
461
|
-
if (_typeof(v[m]) === "object") {
|
|
462
|
-
addRet(_this3._trace(unshift(l, _x), v[m], push(p, m), v, m, cb, true));
|
|
463
|
-
}
|
|
464
|
-
});
|
|
465
|
-
} else if (loc === "^") {
|
|
466
|
-
this._hasParentSelector = true;
|
|
467
|
-
return {
|
|
468
|
-
path: path.slice(0, -1),
|
|
469
|
-
expr: x,
|
|
470
|
-
isParentSelector: true
|
|
471
|
-
};
|
|
472
|
-
} else if (loc === "~") {
|
|
473
|
-
retObj = {
|
|
474
|
-
path: push(path, loc),
|
|
475
|
-
value: parentPropName,
|
|
476
|
-
parent,
|
|
477
|
-
parentProperty: null
|
|
478
|
-
};
|
|
479
|
-
this._handleCallback(retObj, callback, "property");
|
|
480
|
-
return retObj;
|
|
481
|
-
} else if (loc === "$") {
|
|
482
|
-
addRet(this._trace(x, val, path, null, null, callback, hasArrExpr));
|
|
483
|
-
} else if (/^(\x2D?[0-9]*):(\x2D?[0-9]*):?([0-9]*)$/.test(loc)) {
|
|
484
|
-
addRet(this._slice(loc, x, val, path, parent, parentPropName, callback));
|
|
485
|
-
} else if (loc.indexOf("?(") === 0) {
|
|
486
|
-
if (this.currPreventEval) {
|
|
487
|
-
throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
|
|
488
|
-
}
|
|
489
|
-
this._walk(loc, x, val, path, parent, parentPropName, callback, function(m, l, _x, v, p, par, pr, cb) {
|
|
490
|
-
if (_this3._eval(l.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/, "$1"), v[m], m, p, par, pr)) {
|
|
491
|
-
addRet(_this3._trace(unshift(m, _x), v, p, par, pr, cb, true));
|
|
492
|
-
}
|
|
493
|
-
});
|
|
494
|
-
} else if (loc[0] === "(") {
|
|
495
|
-
if (this.currPreventEval) {
|
|
496
|
-
throw new Error("Eval [(expr)] prevented in JSONPath expression.");
|
|
497
|
-
}
|
|
498
|
-
addRet(this._trace(unshift(this._eval(loc, val, path[path.length - 1], path.slice(0, -1), parent, parentPropName), x), val, path, parent, parentPropName, callback, hasArrExpr));
|
|
499
|
-
} else if (loc[0] === "@") {
|
|
500
|
-
var addType = false;
|
|
501
|
-
var valueType = loc.slice(1, -2);
|
|
502
|
-
switch (valueType) {
|
|
503
|
-
case "scalar":
|
|
504
|
-
if (!val || !["object", "function"].includes(_typeof(val))) {
|
|
505
|
-
addType = true;
|
|
506
|
-
}
|
|
507
|
-
break;
|
|
508
|
-
case "boolean":
|
|
509
|
-
case "string":
|
|
510
|
-
case "undefined":
|
|
511
|
-
case "function":
|
|
512
|
-
if (_typeof(val) === valueType) {
|
|
513
|
-
addType = true;
|
|
514
|
-
}
|
|
515
|
-
break;
|
|
516
|
-
case "integer":
|
|
517
|
-
if (Number.isFinite(val) && !(val % 1)) {
|
|
518
|
-
addType = true;
|
|
519
|
-
}
|
|
520
|
-
break;
|
|
521
|
-
case "number":
|
|
522
|
-
if (Number.isFinite(val)) {
|
|
523
|
-
addType = true;
|
|
524
|
-
}
|
|
525
|
-
break;
|
|
526
|
-
case "nonFinite":
|
|
527
|
-
if (typeof val === "number" && !Number.isFinite(val)) {
|
|
528
|
-
addType = true;
|
|
529
|
-
}
|
|
530
|
-
break;
|
|
531
|
-
case "object":
|
|
532
|
-
if (val && _typeof(val) === valueType) {
|
|
533
|
-
addType = true;
|
|
534
|
-
}
|
|
535
|
-
break;
|
|
536
|
-
case "array":
|
|
537
|
-
if (Array.isArray(val)) {
|
|
538
|
-
addType = true;
|
|
539
|
-
}
|
|
540
|
-
break;
|
|
541
|
-
case "other":
|
|
542
|
-
addType = this.currOtherTypeCallback(val, path, parent, parentPropName);
|
|
543
|
-
break;
|
|
544
|
-
case "null":
|
|
545
|
-
if (val === null) {
|
|
546
|
-
addType = true;
|
|
547
|
-
}
|
|
548
|
-
break;
|
|
549
|
-
default:
|
|
550
|
-
throw new TypeError("Unknown value type " + valueType);
|
|
551
|
-
}
|
|
552
|
-
if (addType) {
|
|
553
|
-
retObj = {
|
|
554
|
-
path,
|
|
555
|
-
value: val,
|
|
556
|
-
parent,
|
|
557
|
-
parentProperty: parentPropName
|
|
558
|
-
};
|
|
559
|
-
this._handleCallback(retObj, callback, "value");
|
|
560
|
-
return retObj;
|
|
561
|
-
}
|
|
562
|
-
} else if (loc[0] === "`" && val && hasOwnProp.call(val, loc.slice(1))) {
|
|
563
|
-
var locProp = loc.slice(1);
|
|
564
|
-
addRet(this._trace(x, val[locProp], push(path, locProp), val, locProp, callback, hasArrExpr, true));
|
|
565
|
-
} else if (loc.includes(",")) {
|
|
566
|
-
var parts = loc.split(",");
|
|
567
|
-
var _iterator = _createForOfIteratorHelper(parts), _step;
|
|
568
|
-
try {
|
|
569
|
-
for (_iterator.s(); !(_step = _iterator.n()).done; ) {
|
|
570
|
-
var part = _step.value;
|
|
571
|
-
addRet(this._trace(unshift(part, x), val, path, parent, parentPropName, callback, true));
|
|
572
|
-
}
|
|
573
|
-
} catch (err) {
|
|
574
|
-
_iterator.e(err);
|
|
575
|
-
} finally {
|
|
576
|
-
_iterator.f();
|
|
577
|
-
}
|
|
578
|
-
} else if (!literalPriority && val && hasOwnProp.call(val, loc)) {
|
|
579
|
-
addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback, hasArrExpr, true));
|
|
580
|
-
}
|
|
581
|
-
if (this._hasParentSelector) {
|
|
582
|
-
for (var t = 0; t < ret.length; t++) {
|
|
583
|
-
var rett = ret[t];
|
|
584
|
-
if (rett && rett.isParentSelector) {
|
|
585
|
-
var tmp = this._trace(rett.expr, val, rett.path, parent, parentPropName, callback, hasArrExpr);
|
|
586
|
-
if (Array.isArray(tmp)) {
|
|
587
|
-
ret[t] = tmp[0];
|
|
588
|
-
var tl = tmp.length;
|
|
589
|
-
for (var tt = 1; tt < tl; tt++) {
|
|
590
|
-
t++;
|
|
591
|
-
ret.splice(t, 0, tmp[tt]);
|
|
592
|
-
}
|
|
593
|
-
} else {
|
|
594
|
-
ret[t] = tmp;
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
return ret;
|
|
600
|
-
};
|
|
601
|
-
JSONPath.prototype._walk = function(loc, expr, val, path, parent, parentPropName, callback, f) {
|
|
602
|
-
if (Array.isArray(val)) {
|
|
603
|
-
var n = val.length;
|
|
604
|
-
for (var i = 0; i < n; i++) {
|
|
605
|
-
f(i, loc, expr, val, path, parent, parentPropName, callback);
|
|
606
|
-
}
|
|
607
|
-
} else if (val && _typeof(val) === "object") {
|
|
608
|
-
Object.keys(val).forEach(function(m) {
|
|
609
|
-
f(m, loc, expr, val, path, parent, parentPropName, callback);
|
|
610
|
-
});
|
|
611
|
-
}
|
|
612
|
-
};
|
|
613
|
-
JSONPath.prototype._slice = function(loc, expr, val, path, parent, parentPropName, callback) {
|
|
614
|
-
if (!Array.isArray(val)) {
|
|
615
|
-
return void 0;
|
|
616
|
-
}
|
|
617
|
-
var len = val.length, parts = loc.split(":"), step = parts[2] && Number.parseInt(parts[2]) || 1;
|
|
618
|
-
var start = parts[0] && Number.parseInt(parts[0]) || 0, end = parts[1] && Number.parseInt(parts[1]) || len;
|
|
619
|
-
start = start < 0 ? Math.max(0, start + len) : Math.min(len, start);
|
|
620
|
-
end = end < 0 ? Math.max(0, end + len) : Math.min(len, end);
|
|
621
|
-
var ret = [];
|
|
622
|
-
for (var i = start; i < end; i += step) {
|
|
623
|
-
var tmp = this._trace(unshift(i, expr), val, path, parent, parentPropName, callback, true);
|
|
624
|
-
tmp.forEach(function(t) {
|
|
625
|
-
ret.push(t);
|
|
626
|
-
});
|
|
627
|
-
}
|
|
628
|
-
return ret;
|
|
629
|
-
};
|
|
630
|
-
JSONPath.prototype._eval = function(code, _v, _vname, path, parent, parentPropName) {
|
|
631
|
-
if (code.includes("@parentProperty")) {
|
|
632
|
-
this.currSandbox._$_parentProperty = parentPropName;
|
|
633
|
-
code = code.replace(/@parentProperty/g, "_$_parentProperty");
|
|
634
|
-
}
|
|
635
|
-
if (code.includes("@parent")) {
|
|
636
|
-
this.currSandbox._$_parent = parent;
|
|
637
|
-
code = code.replace(/@parent/g, "_$_parent");
|
|
638
|
-
}
|
|
639
|
-
if (code.includes("@property")) {
|
|
640
|
-
this.currSandbox._$_property = _vname;
|
|
641
|
-
code = code.replace(/@property/g, "_$_property");
|
|
642
|
-
}
|
|
643
|
-
if (code.includes("@path")) {
|
|
644
|
-
this.currSandbox._$_path = JSONPath.toPathString(path.concat([_vname]));
|
|
645
|
-
code = code.replace(/@path/g, "_$_path");
|
|
646
|
-
}
|
|
647
|
-
if (code.includes("@root")) {
|
|
648
|
-
this.currSandbox._$_root = this.json;
|
|
649
|
-
code = code.replace(/@root/g, "_$_root");
|
|
650
|
-
}
|
|
651
|
-
if (/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/.test(code)) {
|
|
652
|
-
this.currSandbox._$_v = _v;
|
|
653
|
-
code = code.replace(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/g, "_$_v$1");
|
|
654
|
-
}
|
|
655
|
-
try {
|
|
656
|
-
return this.vm.runInNewContext(code, this.currSandbox);
|
|
657
|
-
} catch (e) {
|
|
658
|
-
console.log(e);
|
|
659
|
-
throw new Error("jsonPath: " + e.message + ": " + code);
|
|
660
|
-
}
|
|
661
|
-
};
|
|
662
|
-
JSONPath.cache = {};
|
|
663
|
-
JSONPath.toPathString = function(pathArr) {
|
|
664
|
-
var x = pathArr, n = x.length;
|
|
665
|
-
var p = "$";
|
|
666
|
-
for (var i = 1; i < n; i++) {
|
|
667
|
-
if (!/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(x[i])) {
|
|
668
|
-
p += /^[\*0-9]+$/.test(x[i]) ? "[" + x[i] + "]" : "['" + x[i] + "']";
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
return p;
|
|
672
|
-
};
|
|
673
|
-
JSONPath.toPointer = function(pointer) {
|
|
674
|
-
var x = pointer, n = x.length;
|
|
675
|
-
var p = "";
|
|
676
|
-
for (var i = 1; i < n; i++) {
|
|
677
|
-
if (!/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(x[i])) {
|
|
678
|
-
p += "/" + x[i].toString().replace(/~/g, "~0").replace(/\//g, "~1");
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
return p;
|
|
682
|
-
};
|
|
683
|
-
JSONPath.toPathArray = function(expr) {
|
|
684
|
-
var cache = JSONPath.cache;
|
|
685
|
-
if (cache[expr]) {
|
|
686
|
-
return cache[expr].concat();
|
|
687
|
-
}
|
|
688
|
-
var subx = [];
|
|
689
|
-
var normalized = expr.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/g, ";$&;").replace(/['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))['\]]/g, function($0, $1) {
|
|
690
|
-
return "[#" + (subx.push($1) - 1) + "]";
|
|
691
|
-
}).replace(/\[["']((?:(?!['\]])[\s\S])*)["']\]/g, function($0, prop) {
|
|
692
|
-
return "['" + prop.replace(/\./g, "%@%").replace(/~/g, "%%@@%%") + "']";
|
|
693
|
-
}).replace(/~/g, ";~;").replace(/["']?\.["']?(?!(?:(?!\[)[\s\S])*\])|\[["']?/g, ";").replace(/%@%/g, ".").replace(/%%@@%%/g, "~").replace(/(?:;)?(\^+)(?:;)?/g, function($0, ups) {
|
|
694
|
-
return ";" + ups.split("").join(";") + ";";
|
|
695
|
-
}).replace(/;;;|;;/g, ";..;").replace(/;$|'?\]|'$/g, "");
|
|
696
|
-
var exprList = normalized.split(";").map(function(exp) {
|
|
697
|
-
var match = exp.match(/#([0-9]+)/);
|
|
698
|
-
return !match || !match[1] ? exp : subx[match[1]];
|
|
699
|
-
});
|
|
700
|
-
cache[expr] = exprList;
|
|
701
|
-
return cache[expr].concat();
|
|
702
|
-
};
|
|
703
|
-
var moveToAnotherArray = function moveToAnotherArray2(source, target, conditionCb) {
|
|
704
|
-
var il = source.length;
|
|
705
|
-
for (var i = 0; i < il; i++) {
|
|
706
|
-
var item = source[i];
|
|
707
|
-
if (conditionCb(item)) {
|
|
708
|
-
target.push(source.splice(i--, 1)[0]);
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
};
|
|
712
|
-
JSONPath.prototype.vm = {
|
|
713
|
-
runInNewContext: function runInNewContext(expr, context) {
|
|
714
|
-
var keys = Object.keys(context);
|
|
715
|
-
var funcs = [];
|
|
716
|
-
moveToAnotherArray(keys, funcs, function(key) {
|
|
717
|
-
return typeof context[key] === "function";
|
|
718
|
-
});
|
|
719
|
-
var values = keys.map(function(vr, i) {
|
|
720
|
-
return context[vr];
|
|
721
|
-
});
|
|
722
|
-
var funcString = funcs.reduce(function(s, func) {
|
|
723
|
-
var fString = context[func].toString();
|
|
724
|
-
if (!/function/.test(fString)) {
|
|
725
|
-
fString = "function " + fString;
|
|
726
|
-
}
|
|
727
|
-
return "var " + func + "=" + fString + ";" + s;
|
|
728
|
-
}, "");
|
|
729
|
-
expr = funcString + expr;
|
|
730
|
-
if (!/(["'])use strict\1/.test(expr) && !keys.includes("arguments")) {
|
|
731
|
-
expr = "var arguments = undefined;" + expr;
|
|
732
|
-
}
|
|
733
|
-
expr = expr.replace(/;[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*$/, "");
|
|
734
|
-
var lastStatementEnd = expr.lastIndexOf(";");
|
|
735
|
-
var code = lastStatementEnd > -1 ? expr.slice(0, lastStatementEnd + 1) + " return " + expr.slice(lastStatementEnd + 1) : " return " + expr;
|
|
736
|
-
return _construct(Function, _toConsumableArray(keys).concat([code])).apply(void 0, _toConsumableArray(values));
|
|
737
|
-
}
|
|
738
|
-
};
|
|
739
|
-
|
|
740
|
-
// src/fetch.ts
|
|
741
|
-
function fetchAndRevalidate(url, options, validator, callback) {
|
|
742
|
-
return __async(this, null, function* () {
|
|
743
|
-
const date = new Date();
|
|
744
|
-
const initialResponse = yield fetch(url, options);
|
|
745
|
-
if (!initialResponse.ok)
|
|
746
|
-
throw new Error("Fetch failed");
|
|
747
|
-
const responseDate = new Date(initialResponse.headers.get("date"));
|
|
748
|
-
var response = initialResponse;
|
|
749
|
-
callback(initialResponse, "cached");
|
|
750
|
-
if (responseDate < date) {
|
|
751
|
-
const freshHeadResponse = yield fetch(url + "?" + Math.random(), __spreadProps(__spreadValues({}, options), {
|
|
752
|
-
method: "HEAD",
|
|
753
|
-
cache: "no-cache"
|
|
754
|
-
}));
|
|
755
|
-
if (freshHeadResponse.headers.get("last-modified") != initialResponse.headers.get("last-modified")) {
|
|
756
|
-
if (validator(freshHeadResponse) === false) {
|
|
757
|
-
throw new Error("Response is stale");
|
|
758
|
-
}
|
|
759
|
-
response = yield fetch(url, __spreadProps(__spreadValues({}, options), {
|
|
760
|
-
cache: "reload"
|
|
761
|
-
}));
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
if (validator(response) === false) {
|
|
765
|
-
throw new Error("Response is not valid");
|
|
766
|
-
}
|
|
767
|
-
if (initialResponse !== response) {
|
|
768
|
-
callback(response, "valid");
|
|
769
|
-
}
|
|
770
|
-
return response;
|
|
771
|
-
});
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
// src/cloud.ts
|
|
775
|
-
function getComponentURL({
|
|
776
|
-
cdn = "https://feaascomponentsapidev.blob.core.windows.net",
|
|
777
|
-
hostname,
|
|
778
|
-
library,
|
|
779
|
-
component,
|
|
780
|
-
version,
|
|
781
|
-
revision = "published"
|
|
782
|
-
}) {
|
|
783
|
-
return `${cdn || hostname}/components/${library}/${component}/${version}/${revision}.html`;
|
|
784
|
-
}
|
|
785
|
-
function getStylesheetURL({
|
|
786
|
-
cdn = `https://feaascomponentsapidev.blob.core.windows.net`,
|
|
787
|
-
hostname,
|
|
788
|
-
library,
|
|
789
|
-
revision = "published"
|
|
790
|
-
}) {
|
|
791
|
-
return `${cdn || hostname}/styles/${library}/${revision}.css`;
|
|
792
|
-
}
|
|
793
|
-
function fetchComponent(props, callback) {
|
|
794
|
-
return __async(this, null, function* () {
|
|
795
|
-
return fetchAndRevalidate(
|
|
796
|
-
getComponentURL(props),
|
|
797
|
-
{},
|
|
798
|
-
(response) => {
|
|
799
|
-
return response.headers.get("x-ms-meta-versionDeletedAt") == null;
|
|
800
|
-
},
|
|
801
|
-
(response) => {
|
|
802
|
-
response.text().then(callback);
|
|
803
|
-
}
|
|
804
|
-
);
|
|
805
|
-
});
|
|
806
|
-
}
|
|
807
|
-
function fetchStylesheet(props, callback) {
|
|
808
|
-
return __async(this, null, function* () {
|
|
809
|
-
return fetchAndRevalidate(
|
|
810
|
-
getStylesheetURL(props),
|
|
811
|
-
{},
|
|
812
|
-
(response) => {
|
|
813
|
-
return response.headers.get("x-ms-meta-deletedAt") == null;
|
|
814
|
-
},
|
|
815
|
-
(response) => {
|
|
816
|
-
response.text().then(callback);
|
|
817
|
-
}
|
|
818
|
-
);
|
|
819
|
-
});
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
// src/dom.ts
|
|
823
|
-
function renderComponentElement(content, datasources) {
|
|
824
|
-
const wrapper = document.createElement("div");
|
|
825
|
-
wrapper.innerHTML = content;
|
|
826
|
-
const fragment = document.createDocumentFragment();
|
|
827
|
-
while (wrapper.firstChild) {
|
|
828
|
-
fragment.appendChild(wrapper.firstChild);
|
|
829
|
-
}
|
|
830
|
-
renderDOMElement(fragment, datasources);
|
|
831
|
-
return wrapper;
|
|
832
|
-
}
|
|
833
|
-
function cleanCollectionBit(path) {
|
|
834
|
-
return path.replace(/(\[[^\]\[]+\]|\.\*)$/g, "");
|
|
835
|
-
}
|
|
836
|
-
function normalizeCollectionScope(path) {
|
|
837
|
-
return cleanCollectionBit(path) + ".*";
|
|
838
|
-
}
|
|
839
|
-
function getDOMCollectionIndex(element) {
|
|
840
|
-
const datascope = element.getAttribute("data-path-scope");
|
|
841
|
-
var index = 0;
|
|
842
|
-
for (var p = element; p = p.previousElementSibling; ) {
|
|
843
|
-
if (p.getAttribute("data-path-scope") == datascope) {
|
|
844
|
-
index++;
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
return index;
|
|
848
|
-
}
|
|
849
|
-
function updateDOMClones(element, targetCount, config) {
|
|
850
|
-
const datascope = element.getAttribute("data-path-scope");
|
|
851
|
-
if (datascope == null) {
|
|
852
|
-
return;
|
|
853
|
-
}
|
|
854
|
-
var index = getDOMCollectionIndex(element);
|
|
855
|
-
if (index != 0) {
|
|
856
|
-
return;
|
|
857
|
-
}
|
|
858
|
-
const parentElement = element.parentElement;
|
|
859
|
-
if (parentElement == null) {
|
|
860
|
-
return;
|
|
861
|
-
}
|
|
862
|
-
if (targetCount == 0) {
|
|
863
|
-
element.style.display = "none";
|
|
864
|
-
} else if (element.style.display) {
|
|
865
|
-
element.style.display = "";
|
|
866
|
-
if (element.getAttribute("style") == "")
|
|
867
|
-
element.removeAttribute("style");
|
|
868
|
-
}
|
|
869
|
-
var count = index + 1;
|
|
870
|
-
var last = element;
|
|
871
|
-
for (var n = element; n = n.nextElementSibling; ) {
|
|
872
|
-
if (n.getAttribute("data-path-scope") == datascope) {
|
|
873
|
-
count++;
|
|
874
|
-
last = n;
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
for (var i = count; i < targetCount; i++) {
|
|
878
|
-
parentElement.insertBefore(last.cloneNode(true), last.nextElementSibling);
|
|
879
|
-
}
|
|
880
|
-
for (var i = Math.max(1, targetCount); i < count; i++) {
|
|
881
|
-
last = last.previousElementSibling;
|
|
882
|
-
parentElement.removeChild(last.nextElementSibling);
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
function queryScopes(scopes, datapath, singleValue = false, json = scopes) {
|
|
886
|
-
var path = datapath;
|
|
887
|
-
const keys = Object.keys(scopes).sort((b, a) => a.length - b.length);
|
|
888
|
-
for (const scope of keys) {
|
|
889
|
-
if (datapath.startsWith(scope) && "ends with it") {
|
|
890
|
-
if (scope == datapath) {
|
|
891
|
-
if (singleValue) {
|
|
892
|
-
return scopes[scope];
|
|
893
|
-
} else {
|
|
894
|
-
continue;
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
path = datapath.substring(scope.length + 1);
|
|
898
|
-
json = scopes[scope];
|
|
899
|
-
break;
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
const collection = JSONPath({
|
|
903
|
-
path,
|
|
904
|
-
json
|
|
905
|
-
});
|
|
906
|
-
if (singleValue && collection && Array.isArray(collection)) {
|
|
907
|
-
return collection[0];
|
|
908
|
-
} else {
|
|
909
|
-
return collection;
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
function setDOMAttribute(element, attribute, value, config) {
|
|
913
|
-
var _a;
|
|
914
|
-
if (!element)
|
|
915
|
-
return;
|
|
916
|
-
var target = element;
|
|
917
|
-
if (config == null ? void 0 : config.processValue) {
|
|
918
|
-
value = config == null ? void 0 : config.processValue(element, attribute, value);
|
|
919
|
-
}
|
|
920
|
-
var prop = attribute.replace("data-path-", "");
|
|
921
|
-
if (attribute == "data-path-src") {
|
|
922
|
-
target = element.tagName == "IMG" ? element : element.querySelector("img, video");
|
|
923
|
-
} else if (attribute == "data-path-href") {
|
|
924
|
-
target = element.querySelector("a") || element.closest("a");
|
|
925
|
-
} else if (attribute == "data-path-alt") {
|
|
926
|
-
target = element.querySelector("img, picture");
|
|
927
|
-
} else if (attribute == "data-path-hidden") {
|
|
928
|
-
value = !value ? true : null;
|
|
929
|
-
} else if (attribute == "data-path" || attribute == "data-embed-html" || attribute == "html") {
|
|
930
|
-
prop = "innerHTML";
|
|
931
|
-
} else if (attribute == "data-embed-src") {
|
|
932
|
-
loadScript(element, value);
|
|
933
|
-
} else if (attribute == "data-path-attributes") {
|
|
934
|
-
const oldKeys = ((_a = element.getAttribute("data-attributes-keys")) == null ? void 0 : _a.split(",").filter(Boolean)) || [];
|
|
935
|
-
for (var property in value) {
|
|
936
|
-
var subvalue = value[property];
|
|
937
|
-
setDOMAttribute(
|
|
938
|
-
element,
|
|
939
|
-
property,
|
|
940
|
-
typeof subvalue == "object" && subvalue ? JSON.stringify(subvalue) : subvalue,
|
|
941
|
-
config
|
|
942
|
-
);
|
|
943
|
-
}
|
|
944
|
-
for (var i = 0; i < oldKeys.length; i++) {
|
|
945
|
-
if (value == null || !(oldKeys[i] in value)) {
|
|
946
|
-
setDOMAttribute(element, oldKeys[i], null, config);
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
setDOMAttribute(element, "data-attributes-keys", Object.keys(value || {}).join(","));
|
|
950
|
-
return;
|
|
951
|
-
}
|
|
952
|
-
if (typeof value == "boolean") {
|
|
953
|
-
value = value ? "" : null;
|
|
954
|
-
}
|
|
955
|
-
if (!target)
|
|
956
|
-
return;
|
|
957
|
-
var placeholder = String(element.getAttribute("data-path-placeholder") || target[prop]);
|
|
958
|
-
if (value != null) {
|
|
959
|
-
if (prop == "innerHTML") {
|
|
960
|
-
if (target.innerHTML != value) {
|
|
961
|
-
target.innerHTML = value;
|
|
962
|
-
}
|
|
963
|
-
} else {
|
|
964
|
-
if (target.getAttribute(prop) != value) {
|
|
965
|
-
target.setAttribute(prop, value);
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
} else {
|
|
969
|
-
if (prop == "innerHTML") {
|
|
970
|
-
target.innerHTML = placeholder;
|
|
971
|
-
} else {
|
|
972
|
-
target.removeAttribute(prop);
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
function observeDOMElement(element) {
|
|
977
|
-
const observer = new element.ownerDocument.defaultView.MutationObserver((changes) => {
|
|
978
|
-
changes.forEach((change) => {
|
|
979
|
-
const target = change.target;
|
|
980
|
-
const src = target.getAttribute("data-embed-src");
|
|
981
|
-
if (src) {
|
|
982
|
-
loadScript(target, src);
|
|
983
|
-
}
|
|
984
|
-
if (change.addedNodes) {
|
|
985
|
-
change.addedNodes.forEach((node) => {
|
|
986
|
-
if (node.nodeType == 1)
|
|
987
|
-
autoloadScripts(node, false);
|
|
988
|
-
});
|
|
989
|
-
}
|
|
990
|
-
});
|
|
991
|
-
});
|
|
992
|
-
observer.observe(element, { attributes: true, subtree: true, childList: true });
|
|
993
|
-
return observer;
|
|
994
|
-
}
|
|
995
|
-
function autoloadScripts(element, observe = true) {
|
|
996
|
-
const embeds = element.querySelectorAll("[data-embed-src]");
|
|
997
|
-
for (var i = 0; i < embeds.length; i++) {
|
|
998
|
-
const embed = embeds[i];
|
|
999
|
-
loadScript(embed, embed.getAttribute("data-embed-src"));
|
|
1000
|
-
}
|
|
1001
|
-
if (observe)
|
|
1002
|
-
return observeDOMElement(element);
|
|
1003
|
-
}
|
|
1004
|
-
function loadScript(element, src) {
|
|
1005
|
-
for (var p = element; p; p = p.parentElement) {
|
|
1006
|
-
if (!p.parentElement) {
|
|
1007
|
-
const scripts = p.querySelectorAll("script");
|
|
1008
|
-
for (var i = 0; i < scripts.length; i++) {
|
|
1009
|
-
if (scripts[i].getAttribute("src") == src) {
|
|
1010
|
-
return true;
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
if (p.tagName == "HTML")
|
|
1014
|
-
p = p.querySelector("head") || p;
|
|
1015
|
-
const script = p.ownerDocument.createElement("script");
|
|
1016
|
-
script.type = "module";
|
|
1017
|
-
script.src = src;
|
|
1018
|
-
p.appendChild(script);
|
|
1019
|
-
break;
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
var sortOrder = ["data-attributes-keys", "data-path-attributes", "data-path-scope"];
|
|
1024
|
-
function renderDOMElement(input, datascopes, config, isNested) {
|
|
1025
|
-
var _a, _b, _c;
|
|
1026
|
-
const element = input;
|
|
1027
|
-
if (!isNested) {
|
|
1028
|
-
datascopes = ((_a = config == null ? void 0 : config.processData) == null ? void 0 : _a.call(config, element, datascopes)) || datascopes;
|
|
1029
|
-
}
|
|
1030
|
-
if (element.nodeType == 1) {
|
|
1031
|
-
const datascope = element.getAttribute("data-path-scope");
|
|
1032
|
-
if (datascope) {
|
|
1033
|
-
const index = getDOMCollectionIndex(element);
|
|
1034
|
-
const collection = queryScopes(datascopes, datascope, false) || [];
|
|
1035
|
-
if (index == 0) {
|
|
1036
|
-
updateDOMClones(element, ((_b = config == null ? void 0 : config.shouldRepeat) == null ? void 0 : _b.call(config, element, collection)) === false ? 1 : collection.length, config);
|
|
1037
|
-
}
|
|
1038
|
-
datascopes = __spreadProps(__spreadValues({}, datascopes), {
|
|
1039
|
-
[normalizeCollectionScope(datascope)]: collection[index]
|
|
1040
|
-
});
|
|
1041
|
-
}
|
|
1042
|
-
const attrs = Array.prototype.slice.call(element.attributes).sort((a, b) => {
|
|
1043
|
-
return sortOrder.indexOf(a.name) - sortOrder.indexOf(b.name);
|
|
1044
|
-
});
|
|
1045
|
-
for (var i = 0; i < attrs.length; i++) {
|
|
1046
|
-
const { name, value: datapath } = attrs[i];
|
|
1047
|
-
if (name.startsWith("data-path") && name != "data-path-scope") {
|
|
1048
|
-
setDOMAttribute(element, name, queryScopes(datascopes, datapath, true), config);
|
|
1049
|
-
}
|
|
1050
|
-
if (name == "data-embed-src") {
|
|
1051
|
-
setDOMAttribute(element, name, element.getAttribute(name), config);
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
for (var i = 0; i < element.children.length; i++) {
|
|
1056
|
-
renderDOMElement(element.children[i], datascopes, config, true);
|
|
1057
|
-
}
|
|
1058
|
-
if (!isNested) {
|
|
1059
|
-
(_c = config == null ? void 0 : config.onRender) == null ? void 0 : _c.call(config, element, datascopes);
|
|
1060
|
-
}
|
|
1061
|
-
return element;
|
|
1062
|
-
}
|
|
1063
|
-
function renderDOMContent(root, template, data, config) {
|
|
1064
|
-
var _a;
|
|
1065
|
-
const newTemplate = ((_a = config == null ? void 0 : config.processTemplate) == null ? void 0 : _a.call(config, root, template, data)) || template;
|
|
1066
|
-
root.innerHTML = newTemplate;
|
|
1067
|
-
root.classList.add("-feaas");
|
|
1068
|
-
return renderDOMElement(root, data, config);
|
|
1069
|
-
}
|
|
1070
|
-
function renderStylesheet(props, style) {
|
|
1071
|
-
renderStylesheetPromise(props, style || (style = document.createElement("style")));
|
|
1072
|
-
return style;
|
|
1073
|
-
}
|
|
1074
|
-
function renderStylesheetPromise(props, style) {
|
|
1075
|
-
style || (style = document.createElement("style"));
|
|
1076
|
-
return fetchStylesheet(props, (cssText) => {
|
|
1077
|
-
style.textContent = cssText;
|
|
1078
|
-
}).then(() => style);
|
|
1079
|
-
}
|
|
1080
|
-
function renderComponent(props, root) {
|
|
1081
|
-
renderComponentPromise(props, root || (root = document.createElement("div")));
|
|
1082
|
-
return root;
|
|
1083
|
-
}
|
|
1084
|
-
function renderComponentPromise(props, root) {
|
|
1085
|
-
return __async(this, null, function* () {
|
|
1086
|
-
root || (root = document.createElement("div"));
|
|
1087
|
-
if (!root.childNodes.length) {
|
|
1088
|
-
if ("template" in props) {
|
|
1089
|
-
return renderDOMContent(root, props.template, props.data, props);
|
|
1090
|
-
} else {
|
|
1091
|
-
return fetchComponent(props, (template) => {
|
|
1092
|
-
return renderDOMContent(root, template, props.data, props);
|
|
1093
|
-
}).then(() => root);
|
|
1094
|
-
}
|
|
1095
|
-
} else {
|
|
1096
|
-
return renderDOMElement(root, props.data, props);
|
|
1097
|
-
}
|
|
1098
|
-
});
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
|
-
// src/components/FEAASBase.tsx
|
|
1102
|
-
var FEAASBase = class extends HTMLElement {
|
|
1103
|
-
constructor() {
|
|
1104
|
-
super(...arguments);
|
|
1105
|
-
this.connected = null;
|
|
1106
|
-
this.refs = {};
|
|
1107
|
-
this.descendants = [];
|
|
1108
|
-
this.onLoad = (payload) => {
|
|
1109
|
-
if (payload == null)
|
|
1110
|
-
return;
|
|
1111
|
-
this.payload = payload;
|
|
1112
|
-
this.render();
|
|
1113
|
-
};
|
|
1114
|
-
}
|
|
1115
|
-
getProps(context) {
|
|
1116
|
-
return {};
|
|
1117
|
-
}
|
|
1118
|
-
getRoot() {
|
|
1119
|
-
return this;
|
|
1120
|
-
}
|
|
1121
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
1122
|
-
this.set();
|
|
1123
|
-
}
|
|
1124
|
-
connectedCallback() {
|
|
1125
|
-
console.log("FEAAS: Connected", this);
|
|
1126
|
-
this.connected = new Event("feaasConnected", { bubbles: true, composed: true });
|
|
1127
|
-
this.dispatchEvent(this.connected);
|
|
1128
|
-
this.addEventListener("feaasConnected", this);
|
|
1129
|
-
this.addEventListener("feaasDisconnected", this);
|
|
1130
|
-
this.set();
|
|
1131
|
-
}
|
|
1132
|
-
disconnectedCallback() {
|
|
1133
|
-
console.log("FEAAS: Disconnected", this);
|
|
1134
|
-
this.removeEventListener("feaasConnected", this);
|
|
1135
|
-
this.removeEventListener("feaasDisconnected", this);
|
|
1136
|
-
this.dispatchEvent(new Event("feaasDisconnected", { bubbles: true, composed: true }));
|
|
1137
|
-
this.connected = null;
|
|
1138
|
-
}
|
|
1139
|
-
handleEvent(event) {
|
|
1140
|
-
switch (event.type) {
|
|
1141
|
-
case "feaasConnected":
|
|
1142
|
-
this.nestedCallback(event);
|
|
1143
|
-
break;
|
|
1144
|
-
case "feaasDisconnected":
|
|
1145
|
-
this.unnestedCallback(event);
|
|
1146
|
-
break;
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
unnestedCallback(event) {
|
|
1150
|
-
const target = event.composedPath()[0];
|
|
1151
|
-
const index = this.descendants.indexOf(target);
|
|
1152
|
-
if (index == -1)
|
|
1153
|
-
return;
|
|
1154
|
-
console.log("FEAAS: Unnest", this, target);
|
|
1155
|
-
this.descendants.splice(index, -1);
|
|
1156
|
-
this.refs[target.getComponentName()] = null;
|
|
1157
|
-
if (target.refs.parent == this)
|
|
1158
|
-
target.refs.parent = null;
|
|
1159
|
-
if (target.refs.top == this) {
|
|
1160
|
-
target.refs.top = target.refs.parent;
|
|
1161
|
-
}
|
|
1162
|
-
}
|
|
1163
|
-
nestedCallback(event) {
|
|
1164
|
-
var _a, _b;
|
|
1165
|
-
const target = event.composedPath()[0];
|
|
1166
|
-
const index = this.descendants.indexOf(target);
|
|
1167
|
-
if (index != -1)
|
|
1168
|
-
return;
|
|
1169
|
-
this.descendants.push(target);
|
|
1170
|
-
console.log("FEAAS: Nest", this, target);
|
|
1171
|
-
this.refs[target.getComponentName()] = target;
|
|
1172
|
-
target.refs.top = this;
|
|
1173
|
-
(_a = target.refs).parent || (_a.parent = this);
|
|
1174
|
-
if (target.renderReact) {
|
|
1175
|
-
for (var p = target.refs.parent; p; p = p.refs.parent) {
|
|
1176
|
-
if (p.renderReact) {
|
|
1177
|
-
(_b = target.refs).parentReact || (_b.parentReact = p);
|
|
1178
|
-
target.refs.topReact = p;
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
getComponentName() {
|
|
1184
|
-
return this.tagName.replace("FEAAS-", "").toLowerCase();
|
|
1185
|
-
}
|
|
1186
|
-
isReadyToLoad() {
|
|
1187
|
-
return this.payload === void 0 && this.getAttribute("hidden") == null;
|
|
1188
|
-
}
|
|
1189
|
-
reify() {
|
|
1190
|
-
return __async(this, null, function* () {
|
|
1191
|
-
if (this.payload !== void 0) {
|
|
1192
|
-
this.render();
|
|
1193
|
-
} else if (this.isReadyToLoad()) {
|
|
1194
|
-
this.payload = null;
|
|
1195
|
-
this.load().then(this.onLoad);
|
|
1196
|
-
}
|
|
1197
|
-
});
|
|
1198
|
-
}
|
|
1199
|
-
load() {
|
|
1200
|
-
return Promise.resolve(null);
|
|
1201
|
-
}
|
|
1202
|
-
render(nested = false) {
|
|
1203
|
-
var _a, _b, _c;
|
|
1204
|
-
console.log("FEAAS: React", this.tagName, this.payload);
|
|
1205
|
-
if (this.payload == null)
|
|
1206
|
-
return;
|
|
1207
|
-
const { React: React2, ReactDOM } = this.payload || {};
|
|
1208
|
-
if (!React2)
|
|
1209
|
-
throw new Error(`${this.tagName}: React is not present in payload`);
|
|
1210
|
-
if (!ReactDOM)
|
|
1211
|
-
throw new Error(`${this.tagName}: ReactDOM is not present in payload`);
|
|
1212
|
-
if (!this.refs.topReact && !this.forceUpdateReact) {
|
|
1213
|
-
ReactDOM.render(React2.createElement(this.getReactWrapper()), this.getReactRoot());
|
|
1214
|
-
} else if (this.forceUpdateReact) {
|
|
1215
|
-
(_a = this.forceUpdateReact) == null ? void 0 : _a.call(this);
|
|
1216
|
-
} else {
|
|
1217
|
-
(_c = (_b = this.refs.topReact).forceUpdateReact) == null ? void 0 : _c.call(_b);
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
invokeReactRendering() {
|
|
1221
|
-
const { React: React2, ReactDOM } = this.payload || {};
|
|
1222
|
-
const children = this.descendants.filter((r) => {
|
|
1223
|
-
return r.refs.parentReact == this && r.payload;
|
|
1224
|
-
}).map((child, index) => {
|
|
1225
|
-
return React2.createElement(this.getReactWrapper(child), {
|
|
1226
|
-
key: this.tagName + "-" + index,
|
|
1227
|
-
slot: child.getAttribute("slot")
|
|
1228
|
-
});
|
|
1229
|
-
});
|
|
1230
|
-
return this.renderReact(__spreadProps(__spreadValues({}, this.props), { children }), this.payload);
|
|
1231
|
-
}
|
|
1232
|
-
getReactWrapper(target = this, displayName = target.tagName) {
|
|
1233
|
-
const Wrapper = target.reactWrapper || (target.reactWrapper = (props) => {
|
|
1234
|
-
if (target.renderReact) {
|
|
1235
|
-
const { React: React2, ReactDOM } = target.payload || {};
|
|
1236
|
-
const [value, forceUpdateReact] = React2.useReducer((r) => r + 1, 0);
|
|
1237
|
-
target.forceUpdateReact = forceUpdateReact;
|
|
1238
|
-
return ReactDOM.createPortal(/* @__PURE__ */ React2.createElement(React2.Fragment, null, target.invokeReactRendering()), target.getReactRoot());
|
|
1239
|
-
} else {
|
|
1240
|
-
return target.render();
|
|
1241
|
-
}
|
|
1242
|
-
});
|
|
1243
|
-
Object.assign(Wrapper, {
|
|
1244
|
-
displayName
|
|
1245
|
-
});
|
|
1246
|
-
return Wrapper;
|
|
1247
|
-
}
|
|
1248
|
-
getUID() {
|
|
1249
|
-
return this.uid || (this.uid = String(Math.random()));
|
|
1250
|
-
}
|
|
1251
|
-
getReactRoot() {
|
|
1252
|
-
return this.getRoot();
|
|
1253
|
-
}
|
|
1254
|
-
set(overrides) {
|
|
1255
|
-
this.overrides = __spreadValues(__spreadValues({}, this.overrides), overrides);
|
|
1256
|
-
this.props = __spreadValues(__spreadValues({}, this.getProps()), this.overrides);
|
|
1257
|
-
for (var property in this.props) {
|
|
1258
|
-
const value = this.props[property];
|
|
1259
|
-
if (this.props[property] == null) {
|
|
1260
|
-
this.removeAttribute(property);
|
|
1261
|
-
} else if (typeof value == "string" || typeof value == "number") {
|
|
1262
|
-
if (this.getAttribute(property) != String(value))
|
|
1263
|
-
this.setAttribute(property, String(value));
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
this.scheduleRender();
|
|
1267
|
-
}
|
|
1268
|
-
scheduleRender() {
|
|
1269
|
-
cancelAnimationFrame(this.nextRender);
|
|
1270
|
-
this.nextRender = requestAnimationFrame(() => {
|
|
1271
|
-
this.reify();
|
|
1272
|
-
});
|
|
1273
|
-
}
|
|
1274
|
-
formatURL(src, hostname) {
|
|
1275
|
-
if (typeof src == "string" && src.match(/^\/[^\/]/)) {
|
|
1276
|
-
return hostname + src;
|
|
1277
|
-
} else {
|
|
1278
|
-
return src;
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
getContextAttribute(name, element = this) {
|
|
1282
|
-
var _a, _b;
|
|
1283
|
-
return (_b = (_a = element.closest(`[${name}]`)) == null ? void 0 : _a.getAttribute(name)) != null ? _b : this.getAttribute(name);
|
|
1284
|
-
}
|
|
1285
|
-
static register(tagName) {
|
|
1286
|
-
if (!window.customElements.get(tagName)) {
|
|
1287
|
-
window.customElements.define(tagName, this);
|
|
1288
|
-
}
|
|
1289
|
-
}
|
|
1290
|
-
};
|
|
1291
|
-
|
|
1292
|
-
// src/components/FEAASLoader.ts
|
|
1293
|
-
function FEAASLoaderProps(element = this) {
|
|
1294
|
-
return {
|
|
1295
|
-
hidden: (element == null ? void 0 : element.getAttribute("hidden")) != null
|
|
1296
|
-
};
|
|
1297
|
-
}
|
|
1298
|
-
var FEAASLoader = class extends FEAASBase {
|
|
1299
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
1300
|
-
if (name == "hidden") {
|
|
1301
|
-
this.style.setProperty("display", "block", "important");
|
|
1302
|
-
this.style.setProperty("transition", "opacity 0.3s", "important");
|
|
1303
|
-
if (newValue) {
|
|
1304
|
-
this.style.setProperty("opacity", "0", "important");
|
|
1305
|
-
this.style.pointerEvents = "none";
|
|
1306
|
-
} else {
|
|
1307
|
-
this.style.setProperty("opacity", "1", "important");
|
|
1308
|
-
this.style.pointerEvents = "all";
|
|
1309
|
-
}
|
|
1310
|
-
}
|
|
1311
|
-
}
|
|
1312
|
-
connectedCallback() {
|
|
1313
|
-
this.attributeChangedCallback("hidden", this.getAttribute("hidden"), this.getAttribute("hidden"));
|
|
1314
|
-
this.stylesheet = document.createElement("style");
|
|
1315
|
-
this.stylesheet.textContent = `
|
|
1
|
+
var mt=Object.create;var F=Object.defineProperty;var At=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var Rt=Object.getPrototypeOf,Et=Object.prototype.hasOwnProperty;var xt=(t,e)=>{for(var r in e)F(t,r,{get:e[r],enumerable:!0})},Q=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of wt(e))!Et.call(t,n)&&n!==r&&F(t,n,{get:()=>e[n],enumerable:!(i=At(e,n))||i.enumerable});return t};var Ct=(t,e,r)=>(r=t!=null?mt(Rt(t)):{},Q(e||!t||!t.__esModule?F(r,"default",{value:t,enumerable:!0}):r,t)),_t=t=>Q(F({},"__esModule",{value:!0}),t);var Dt={};xt(Dt,{Base:()=>b,Component:()=>T,FEAASBase:()=>b,FEAASComponent:()=>T,FEAASComponentsProps:()=>at,FEAASContext:()=>L,FEAASContextProps:()=>pt,FEAASEditor:()=>B,FEAASEditorProps:()=>ct,FEAASLoader:()=>O,FEAASLoaderProps:()=>$t,FEAASPicker:()=>q,FEAASPickerLazy:()=>M,FEAASPickerLazyProps:()=>ht,FEAASPickerProps:()=>ut,FEAASStylesheet:()=>W,FEAASStylesheetProps:()=>lt,Loader:()=>O,Stylesheet:()=>W,autoloadScripts:()=>nt,cleanCollectionBit:()=>tt,fetchAndRevalidate:()=>j,getFramePosition:()=>dt,loadScript:()=>I,normalizeCollectionScope:()=>et,observeDOMElement:()=>it,queryScopes:()=>V,renderComponent:()=>Mt,renderComponentElement:()=>Pt,renderComponentPromise:()=>st,renderDOMContent:()=>P,renderDOMElement:()=>x,renderStylesheet:()=>Ot,renderStylesheetPromise:()=>ot,setDOMAttribute:()=>_});module.exports=_t(Dt);var X=Ct(require("vm"),1),{hasOwnProperty:m}=Object.prototype;function S(t,e){return t=t.slice(),t.push(e),t}function C(t,e){return e=e.slice(),e.unshift(t),e}var J=class extends Error{constructor(e){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=e,this.name="NewError"}};function f(t,e,r,i,n){if(!(this instanceof f))try{return new f(t,e,r,i,n)}catch(s){if(!s.avoidNew)throw s;return s.value}typeof t=="string"&&(n=i,i=r,r=e,e=t,t=null);let o=t&&typeof t=="object";if(t=t||{},this.json=t.json||r,this.path=t.path||e,this.resultType=t.resultType||"value",this.flatten=t.flatten||!1,this.wrap=m.call(t,"wrap")?t.wrap:!0,this.sandbox=t.sandbox||{},this.preventEval=t.preventEval||!1,this.parent=t.parent||null,this.parentProperty=t.parentProperty||null,this.callback=t.callback||i||null,this.otherTypeCallback=t.otherTypeCallback||n||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},t.autostart!==!1){let s={path:o?t.path:e};o?"json"in t&&(s.json=t.json):s.json=r;let a=this.evaluate(s);if(!a||typeof a!="object")throw new J(a);return a}}f.prototype.evaluate=function(t,e,r,i){let n=this.parent,o=this.parentProperty,{flatten:s,wrap:a}=this;if(this.currResultType=this.resultType,this.currPreventEval=this.preventEval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=i||this.otherTypeCallback,e=e||this.json,t=t||this.path,t&&typeof t=="object"&&!Array.isArray(t)){if(!t.path&&t.path!=="")throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!m.call(t,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:e}=t),s=m.call(t,"flatten")?t.flatten:s,this.currResultType=m.call(t,"resultType")?t.resultType:this.currResultType,this.currSandbox=m.call(t,"sandbox")?t.sandbox:this.currSandbox,a=m.call(t,"wrap")?t.wrap:a,this.currPreventEval=m.call(t,"preventEval")?t.preventEval:this.currPreventEval,r=m.call(t,"callback")?t.callback:r,this.currOtherTypeCallback=m.call(t,"otherTypeCallback")?t.otherTypeCallback:this.currOtherTypeCallback,n=m.call(t,"parent")?t.parent:n,o=m.call(t,"parentProperty")?t.parentProperty:o,t=t.path}if(n=n||null,o=o||null,Array.isArray(t)&&(t=f.toPathString(t)),!t&&t!==""||!e)return;let d=f.toPathArray(t);d[0]==="$"&&d.length>1&&d.shift(),this._hasParentSelector=null;let l=this._trace(d,e,["$"],n,o,r).filter(function(u){return u&&!u.isParentSelector});return l.length?!a&&l.length===1&&!l[0].hasArrExpr?this._getPreferredOutput(l[0]):l.reduce((u,h)=>{let p=this._getPreferredOutput(h);return s&&Array.isArray(p)?u=u.concat(p):u.push(p),u},[]):a?[]:void 0};f.prototype._getPreferredOutput=function(t){let e=this.currResultType;switch(e){case"all":{let r=Array.isArray(t.path)?t.path:f.toPathArray(t.path);return t.pointer=f.toPointer(r),t.path=typeof t.path=="string"?t.path:f.toPathString(t.path),t}case"value":case"parent":case"parentProperty":return t[e];case"path":return f.toPathString(t[e]);case"pointer":return f.toPointer(t.path);default:throw new TypeError("Unknown result type")}};f.prototype._handleCallback=function(t,e,r){if(e){let i=this._getPreferredOutput(t);t.path=typeof t.path=="string"?t.path:f.toPathString(t.path),e(i,r,t)}};f.prototype._trace=function(t,e,r,i,n,o,s,a){let d;if(!t.length)return d={path:r,value:e,parent:i,parentProperty:n,hasArrExpr:s},this._handleCallback(d,o,"value"),d;let l=t[0],u=t.slice(1),h=[];function p(c){Array.isArray(c)?c.forEach(g=>{h.push(g)}):h.push(c)}if((typeof l!="string"||a)&&e&&m.call(e,l))p(this._trace(u,e[l],S(r,l),e,l,o,s));else if(l==="*")this._walk(l,u,e,r,i,n,o,(c,g,v,A,w,E,R,y)=>{p(this._trace(C(c,v),A,w,E,R,y,!0,!0))});else if(l==="..")p(this._trace(u,e,r,i,n,o,s)),this._walk(l,u,e,r,i,n,o,(c,g,v,A,w,E,R,y)=>{typeof A[c]=="object"&&p(this._trace(C(g,v),A[c],S(w,c),A,c,y,!0))});else{if(l==="^")return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:u,isParentSelector:!0};if(l==="~")return d={path:S(r,l),value:n,parent:i,parentProperty:null},this._handleCallback(d,o,"property"),d;if(l==="$")p(this._trace(u,e,r,null,null,o,s));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(l))p(this._slice(l,u,e,r,i,n,o));else if(l.indexOf("?(")===0){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");this._walk(l,u,e,r,i,n,o,(c,g,v,A,w,E,R,y)=>{this._eval(g.replace(/^\?\((.*?)\)$/u,"$1"),A[c],c,w,E,R)&&p(this._trace(C(c,v),A,w,E,R,y,!0))})}else if(l[0]==="("){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");p(this._trace(C(this._eval(l,e,r[r.length-1],r.slice(0,-1),i,n),u),e,r,i,n,o,s))}else if(l[0]==="@"){let c=!1,g=l.slice(1,-2);switch(g){case"scalar":(!e||!["object","function"].includes(typeof e))&&(c=!0);break;case"boolean":case"string":case"undefined":case"function":typeof e===g&&(c=!0);break;case"integer":Number.isFinite(e)&&!(e%1)&&(c=!0);break;case"number":Number.isFinite(e)&&(c=!0);break;case"nonFinite":typeof e=="number"&&!Number.isFinite(e)&&(c=!0);break;case"object":e&&typeof e===g&&(c=!0);break;case"array":Array.isArray(e)&&(c=!0);break;case"other":c=this.currOtherTypeCallback(e,r,i,n);break;case"null":e===null&&(c=!0);break;default:throw new TypeError("Unknown value type "+g)}if(c)return d={path:r,value:e,parent:i,parentProperty:n},this._handleCallback(d,o,"value"),d}else if(l[0]==="`"&&e&&m.call(e,l.slice(1))){let c=l.slice(1);p(this._trace(u,e[c],S(r,c),e,c,o,s,!0))}else if(l.includes(",")){let c=l.split(",");for(let g of c)p(this._trace(C(g,u),e,r,i,n,o,!0))}else!a&&e&&m.call(e,l)&&p(this._trace(u,e[l],S(r,l),e,l,o,s,!0))}if(this._hasParentSelector)for(let c=0;c<h.length;c++){let g=h[c];if(g&&g.isParentSelector){let v=this._trace(g.expr,e,g.path,i,n,o,s);if(Array.isArray(v)){h[c]=v[0];let A=v.length;for(let w=1;w<A;w++)c++,h.splice(c,0,v[w])}else h[c]=v}}return h};f.prototype._walk=function(t,e,r,i,n,o,s,a){if(Array.isArray(r)){let d=r.length;for(let l=0;l<d;l++)a(l,t,e,r,i,n,o,s)}else r&&typeof r=="object"&&Object.keys(r).forEach(d=>{a(d,t,e,r,i,n,o,s)})};f.prototype._slice=function(t,e,r,i,n,o,s){if(!Array.isArray(r))return;let a=r.length,d=t.split(":"),l=d[2]&&Number.parseInt(d[2])||1,u=d[0]&&Number.parseInt(d[0])||0,h=d[1]&&Number.parseInt(d[1])||a;u=u<0?Math.max(0,u+a):Math.min(a,u),h=h<0?Math.max(0,h+a):Math.min(a,h);let p=[];for(let c=u;c<h;c+=l)this._trace(C(c,e),r,i,n,o,s,!0).forEach(v=>{p.push(v)});return p};f.prototype._eval=function(t,e,r,i,n,o){t.includes("@parentProperty")&&(this.currSandbox._$_parentProperty=o,t=t.replace(/@parentProperty/gu,"_$_parentProperty")),t.includes("@parent")&&(this.currSandbox._$_parent=n,t=t.replace(/@parent/gu,"_$_parent")),t.includes("@property")&&(this.currSandbox._$_property=r,t=t.replace(/@property/gu,"_$_property")),t.includes("@path")&&(this.currSandbox._$_path=f.toPathString(i.concat([r])),t=t.replace(/@path/gu,"_$_path")),t.includes("@root")&&(this.currSandbox._$_root=this.json,t=t.replace(/@root/gu,"_$_root")),/@([.\s)[])/u.test(t)&&(this.currSandbox._$_v=e,t=t.replace(/@([.\s)[])/gu,"_$_v$1"));try{return this.vm.runInNewContext(t,this.currSandbox)}catch(s){throw console.log(s),new Error("jsonPath: "+s.message+": "+t)}};f.cache={};f.toPathString=function(t){let e=t,r=e.length,i="$";for(let n=1;n<r;n++)/^(~|\^|@.*?\(\))$/u.test(e[n])||(i+=/^[0-9*]+$/u.test(e[n])?"["+e[n]+"]":"['"+e[n]+"']");return i};f.toPointer=function(t){let e=t,r=e.length,i="";for(let n=1;n<r;n++)/^(~|\^|@.*?\(\))$/u.test(e[n])||(i+="/"+e[n].toString().replace(/~/gu,"~0").replace(/\//gu,"~1"));return i};f.toPathArray=function(t){let{cache:e}=f;if(e[t])return e[t].concat();let r=[],n=t.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replace(/[['](\??\(.*?\))[\]']/gu,function(o,s){return"[#"+(r.push(s)-1)+"]"}).replace(/\[['"]([^'\]]*)['"]\]/gu,function(o,s){return"['"+s.replace(/\./gu,"%@%").replace(/~/gu,"%%@@%%")+"']"}).replace(/~/gu,";~;").replace(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replace(/%@%/gu,".").replace(/%%@@%%/gu,"~").replace(/(?:;)?(\^+)(?:;)?/gu,function(o,s){return";"+s.split("").join(";")+";"}).replace(/;;;|;;/gu,";..;").replace(/;$|'?\]|'$/gu,"").split(";").map(function(o){let s=o.match(/#(\d+)/u);return!s||!s[1]?o:r[s[1]]});return e[t]=n,e[t].concat()};f.prototype.vm=X.default;async function j(t,e,r,i){let n=new Date,o=await fetch(t,e);if(!o.ok)throw new Error("Fetch failed");let s=new Date(o.headers.get("date"));var a=o;if(i(o,"cached"),s<n){let d=await fetch(t+"?"+Math.random(),{...e,method:"HEAD",cache:"no-cache"});if(d.headers.get("last-modified")!=o.headers.get("last-modified")){if(r(d)===!1)throw new Error("Response is stale");a=await fetch(t,{...e,cache:"reload"})}}if(r(a)===!1)throw new Error("Response is not valid");return o!==a&&i(a,"valid"),a}function kt({cdn:t="https://feaascomponentsapidev.blob.core.windows.net",hostname:e,library:r,component:i,version:n,revision:o="published"}){return`${t||e}/components/${r}/${i}/${n}/${o}.html`}function St({cdn:t="https://feaascomponentsapidev.blob.core.windows.net",hostname:e,library:r,revision:i="published"}){return`${t||e}/styles/${r}/${i}.css`}async function U(t,e){return j(kt(t),{},r=>r.headers.get("x-ms-meta-versionDeletedAt")==null,r=>{r.text().then(e)})}async function H(t,e){return j(St(t),{},r=>r.headers.get("x-ms-meta-deletedAt")==null,r=>{r.text().then(e)})}function Pt(t,e){let r=document.createElement("div");r.innerHTML=t;let i=document.createDocumentFragment();for(;r.firstChild;)i.appendChild(r.firstChild);return x(i,e),r}function tt(t){return t.replace(/(\[[^\]\[]+\]|\.\*)$/g,"")}function et(t){return tt(t)+".*"}function rt(t){let e=t.getAttribute("data-path-scope");for(var r=0,i=t;i=i.previousElementSibling;)i.getAttribute("data-path-scope")==e&&r++;return r}function Tt(t,e,r){let i=t.getAttribute("data-path-scope");if(i==null)return;var n=rt(t);if(n!=0)return;let o=t.parentElement;if(o!=null){e==0?t.style.display="none":t.style.display&&(t.style.display="",t.getAttribute("style")==""&&t.removeAttribute("style"));for(var s=n+1,a=t,d=t;d=d.nextElementSibling;)d.getAttribute("data-path-scope")==i&&(s++,a=d);for(var l=s;l<e;l++)o.insertBefore(a.cloneNode(!0),a.nextElementSibling);for(var l=Math.max(1,e);l<s;l++)a=a.previousElementSibling,o.removeChild(a.nextElementSibling)}}function V(t,e,r=!1,i=t){var n=e;let o=Object.keys(t).sort((a,d)=>d.length-a.length);for(let a of o)if(e.startsWith(a)){if(a==e){if(r)return t[a];continue}n=e.substring(a.length+1),i=t[a];break}let s=f({path:n,json:i});return r&&s&&Array.isArray(s)?s[0]:s}function _(t,e,r,i){var n;if(t){var o=t;i!=null&&i.processValue&&(r=i==null?void 0:i.processValue(t,e,r));var s=e.replace("data-path-","");if(e=="data-path-src")o=t.tagName=="IMG"?t:t.querySelector("img, video");else if(e=="data-path-href")o=t.querySelector("a")||t.closest("a");else if(e=="data-path-alt")o=t.querySelector("img, picture");else if(e=="data-path-hidden")r=r?null:!0;else if(e=="data-path"||e=="data-embed-html"||e=="html")s="innerHTML";else if(e=="data-embed-src")I(t,r);else if(e=="data-path-attributes"){let h=((n=t.getAttribute("data-attributes-keys"))===null||n===void 0?void 0:n.split(",").filter(Boolean))||[];for(var a in r){var d=r[a];_(t,a,typeof d=="object"&&d?JSON.stringify(d):d,i)}for(var l=0;l<h.length;l++)(r==null||!(h[l]in r))&&_(t,h[l],null,i);_(t,"data-attributes-keys",Object.keys(r||{}).join(","));return}if(typeof r=="boolean"&&(r=r?"":null),!!o){var u=String(t.getAttribute("data-path-placeholder")||o[s]);r!=null?s=="innerHTML"?o.innerHTML!=r&&(o.innerHTML=r):o.getAttribute(s)!=r&&o.setAttribute(s,r):s=="innerHTML"?o.innerHTML=u:o.removeAttribute(s)}}}function it(t){let e=new t.ownerDocument.defaultView.MutationObserver(r=>{r.forEach(i=>{let n=i.target,o=n.getAttribute("data-embed-src");o&&I(n,o),i.addedNodes&&i.addedNodes.forEach(s=>{s.nodeType==1&&nt(s,!1)})})});return e.observe(t,{attributes:!0,subtree:!0,childList:!0}),e}function nt(t,e=!0){let r=t.querySelectorAll("[data-embed-src]");for(var i=0;i<r.length;i++){let n=r[i];I(n,n.getAttribute("data-embed-src"))}if(e)return it(t)}function I(t,e){for(var r=t;r;r=r.parentElement)if(!r.parentElement){let n=r.querySelectorAll("script");for(var i=0;i<n.length;i++)if(n[i].getAttribute("src")==e)return!0;r.tagName=="HTML"&&(r=r.querySelector("head")||r);let o=r.ownerDocument.createElement("script");o.type="module",o.src=e,r.appendChild(o);break}}var Z=["data-attributes-keys","data-path-attributes","data-path-scope"];function x(t,e,r,i){var n,o,s;let a=t;if(i||(e=((n=r==null?void 0:r.processData)===null||n===void 0?void 0:n.call(r,a,e))||e),a.nodeType==1){let l=a.getAttribute("data-path-scope");if(l){let h=rt(a),p=V(e,l,!1)||[];h==0&&Tt(a,((o=r==null?void 0:r.shouldRepeat)===null||o===void 0?void 0:o.call(r,a,p))===!1?1:p.length,r),e={...e,[et(l)]:p[h]}}let u=Array.prototype.slice.call(a.attributes).sort((h,p)=>Z.indexOf(h.name)-Z.indexOf(p.name));for(var d=0;d<u.length;d++){let{name:h,value:p}=u[d];h.startsWith("data-path")&&h!="data-path-scope"&&_(a,h,V(e,p,!0),r),h=="data-embed-src"&&_(a,h,a.getAttribute(h),r)}}for(var d=0;d<a.children.length;d++)x(a.children[d],e,r,!0);return i||(s=r==null?void 0:r.onRender)===null||s===void 0||s.call(r,a,e),a}function P(t,e,r,i){var n;let o=((n=i==null?void 0:i.processTemplate)===null||n===void 0?void 0:n.call(i,t,e,r))||e;return t.innerHTML=o,t.classList.add("-feaas"),x(t,r,i)}function Ot(t,e){return ot(t,e||(e=document.createElement("style"))),e}function ot(t,e){return e||(e=document.createElement("style")),H(t,r=>{e.textContent=r}).then(()=>e)}function Mt(t,e){return st(t,e||(e=document.createElement("div"))),e}async function st(t,e){return e||(e=document.createElement("div")),e.childNodes.length?x(e,t.data,t):"template"in t?P(e,t.template,t.data,t):U(t,r=>P(e,r,t.data,t)).then(()=>e)}var Lt=typeof HTMLElement=="undefined"?class{}:HTMLElement,b=class extends Lt{constructor(){super(...arguments),this.connected=null,this.refs={},this.descendants=[],this.onLoad=e=>{e!=null&&(this.payload=e,this.render())}}getProps(e){return{}}getRoot(){return this}attributeChangedCallback(e,r,i){this.set()}connectedCallback(){console.log("FEAAS: Connected",this),this.connected=new Event("feaasConnected",{bubbles:!0,composed:!0}),this.dispatchEvent(this.connected),this.addEventListener("feaasConnected",this),this.addEventListener("feaasDisconnected",this),this.set()}disconnectedCallback(){console.log("FEAAS: Disconnected",this),this.removeEventListener("feaasConnected",this),this.removeEventListener("feaasDisconnected",this),this.dispatchEvent(new Event("feaasDisconnected",{bubbles:!0,composed:!0})),this.connected=null}handleEvent(e){switch(e.type){case"feaasConnected":this.nestedCallback(e);break;case"feaasDisconnected":this.unnestedCallback(e);break}}unnestedCallback(e){let r=e.composedPath()[0],i=this.descendants.indexOf(r);i!=-1&&(console.log("FEAAS: Unnest",this,r),this.descendants.splice(i,-1),this.refs[r.getComponentName()]=null,r.refs.parent==this&&(r.refs.parent=null),r.refs.top==this&&(r.refs.top=r.refs.parent))}nestedCallback(e){var r,i;let n=e.composedPath()[0];if(this.descendants.indexOf(n)==-1&&(this.descendants.push(n),console.log("FEAAS: Nest",this,n),this.refs[n.getComponentName()]=n,n.refs.top=this,(r=n.refs).parent||(r.parent=this),n.renderReact))for(var s=n.refs.parent;s;s=s.refs.parent)s.renderReact&&((i=n.refs).parentReact||(i.parentReact=s),n.refs.topReact=s)}getComponentName(){return this.tagName.replace("FEAAS-","").toLowerCase()}isReadyToLoad(){return this.payload===void 0&&this.getAttribute("hidden")==null}async reify(){this.payload!==void 0?this.render():this.isReadyToLoad()&&(this.payload=null,this.load().then(this.onLoad))}load(){return Promise.resolve(null)}render(e=!1){var r,i,n;if(console.log("FEAAS: React",this.tagName,this.payload),this.payload==null)return;let{React:o,ReactDOM:s}=this.payload||{};if(!o)throw new Error(`${this.tagName}: React is not present in payload`);if(!s)throw new Error(`${this.tagName}: ReactDOM is not present in payload`);!this.refs.topReact&&!this.forceUpdateReact?s.render(o.createElement(this.getReactWrapper()),this.getReactRoot()):this.forceUpdateReact?(r=this.forceUpdateReact)===null||r===void 0||r.call(this):(n=(i=this.refs.topReact).forceUpdateReact)===null||n===void 0||n.call(i)}invokeReactRendering(){let{React:e,ReactDOM:r}=this.payload||{},i=this.descendants.filter(n=>n.refs.parentReact==this&&n.payload).map((n,o)=>e.createElement(this.getReactWrapper(n),{key:this.tagName+"-"+o,slot:n.getAttribute("slot")}));return this.renderReact({...this.props,children:i},this.payload)}getReactWrapper(e=this,r=e.tagName){let i=e.reactWrapper||(e.reactWrapper=n=>{if(e.renderReact){let{React:o,ReactDOM:s}=e.payload||{},[a,d]=o.useReducer(l=>l+1,0);return e.forceUpdateReact=d,s.createPortal(o.createElement(o.Fragment,null,e.invokeReactRendering()),e.getReactRoot())}else return e.render()});return Object.assign(i,{displayName:r}),i}getUID(){return this.uid||(this.uid=String(Math.random()))}getReactRoot(){return this.getRoot()}set(e){this.overrides={...this.overrides,...e},this.props={...this.getProps(),...this.overrides};for(var r in this.props){let i=this.props[r];this.props[r]==null?this.removeAttribute(r):(typeof i=="string"||typeof i=="number")&&this.getAttribute(r)!=String(i)&&this.setAttribute(r,String(i))}this.scheduleRender()}scheduleRender(){cancelAnimationFrame(this.nextRender),this.nextRender=requestAnimationFrame(()=>{this.reify()})}formatURL(e,r){return typeof e=="string"&&e.match(/^\/[^\/]/)?r+e:e}getContextAttribute(e,r=this){var i,n;return(n=(i=r.closest(`[${e}]`))===null||i===void 0?void 0:i.getAttribute(e))!==null&&n!==void 0?n:this.getAttribute(e)}static register(e){typeof window!="undefined"&&!window.customElements.get(e)&&window.customElements.define(e,this)}};function at(t=this){let e,r=t.getAttribute("data");if(r!=null)try{e=typeof r=="string"?JSON.parse(r):{}}catch(i){}return{data:e!=null?e:{},library:t.getAttribute("library"),component:t.getAttribute("component"),version:t.getAttribute("version"),revision:t.getAttribute("revision"),hostname:t.getAttribute("hostname"),cdn:t.getContextAttribute("cdn"),template:t.getAttribute("template"),suspended:t.getAttribute("suspended")!=null}}var T=class extends b{setData(e){this.set({data:e})}getProps(){return at(this)}attributeChangedCallback(e,r,i){this.payload=void 0,this.needsRefresh=!0,super.attributeChangedCallback(e,r,i)}getOriginal(){let e=this.getAttribute("data-path-scope");if(e){for(var r=this;(r=r.previousElementSibling)&&r.getAttribute("data-path-scope")==e;)var i=r;return i}}isReadyToLoad(){return super.isReadyToLoad()&&this.props.library!=null&&this.props.component!=null&&this.props.version!=null}async load(){if(!this.getOriginal())try{U(this.props,this.onLoad)}catch(e){console.error(`FEAAS: Could not fetch component: ${this.props.component}/${this.props.version}/${this.props.revision}`)}}render(){if(Array.from(this.children).filter(e=>e.tagName!="BR").length>0&&!this.needsRefresh)x(this,this.props.data);else{if(this.needsRefresh=!0,this.getOriginal())return;P(this,this.payload,this.props.data)}}};T.observedAttributes=["library","component","version","revision","hostname","cdn","template","data"];T.register("feaas-component");function $t(t=this){return{hidden:(t==null?void 0:t.getAttribute("hidden"))!=null}}var O=class extends b{attributeChangedCallback(e,r,i){e=="hidden"&&(this.style.setProperty("display","block","important"),this.style.setProperty("transition","opacity 0.3s","important"),i?(this.style.setProperty("opacity","0","important"),this.style.pointerEvents="none"):(this.style.setProperty("opacity","1","important"),this.style.pointerEvents="all"))}connectedCallback(){this.attributeChangedCallback("hidden",this.getAttribute("hidden"),this.getAttribute("hidden")),this.stylesheet=document.createElement("style"),this.stylesheet.textContent=`
|
|
1316
2
|
#loader {
|
|
1317
3
|
position: absolute;
|
|
1318
4
|
top: 0;
|
|
@@ -1353,10 +39,7 @@ var FEAASLoader = class extends FEAASBase {
|
|
|
1353
39
|
width: 48px;
|
|
1354
40
|
height: 48px;
|
|
1355
41
|
}
|
|
1356
|
-
|
|
1357
|
-
this.loader = document.createElement("div");
|
|
1358
|
-
this.loader.id = "loader";
|
|
1359
|
-
this.loader.innerHTML = `
|
|
42
|
+
`,this.loader=document.createElement("div"),this.loader.id="loader",this.loader.innerHTML=`
|
|
1360
43
|
<div class="spinner">
|
|
1361
44
|
<svg
|
|
1362
45
|
viewBox="0 0 100 100"
|
|
@@ -1379,544 +62,10 @@ var FEAASLoader = class extends FEAASBase {
|
|
|
1379
62
|
style="animation: 1.5s linear 0s infinite normal none running loader-circular-track"
|
|
1380
63
|
></circle>
|
|
1381
64
|
</svg>
|
|
1382
|
-
</div
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
}
|
|
1386
|
-
};
|
|
1387
|
-
FEAASLoader.observedAttributes = ["hidden"];
|
|
1388
|
-
FEAASLoader.register("feaas-loader");
|
|
1389
|
-
|
|
1390
|
-
// src/components/FEAASStylesheet.ts
|
|
1391
|
-
function FEAASStylesheetProps(element = this) {
|
|
1392
|
-
var _a;
|
|
1393
|
-
return {
|
|
1394
|
-
library: element == null ? void 0 : element.getContextAttribute("library"),
|
|
1395
|
-
revision: (_a = element == null ? void 0 : element.getAttribute("revision")) != null ? _a : "published",
|
|
1396
|
-
cdn: (element == null ? void 0 : element.getContextAttribute("cdn")) || (element == null ? void 0 : element.getContextAttribute("hostname"))
|
|
1397
|
-
};
|
|
1398
|
-
}
|
|
1399
|
-
var FEAASStylesheet = class extends FEAASBase {
|
|
1400
|
-
getProps() {
|
|
1401
|
-
return FEAASStylesheetProps(this);
|
|
1402
|
-
}
|
|
1403
|
-
isReadyToLoad() {
|
|
1404
|
-
return this.props.library != null && this.props.revision != null && this.props.cdn != null;
|
|
1405
|
-
}
|
|
1406
|
-
load() {
|
|
1407
|
-
return __async(this, null, function* () {
|
|
1408
|
-
fetchStylesheet(this.props, this.onLoad);
|
|
1409
|
-
});
|
|
1410
|
-
}
|
|
1411
|
-
render() {
|
|
1412
|
-
if (!this.stylesheet) {
|
|
1413
|
-
this.stylesheet = document.createElement("style");
|
|
1414
|
-
this.appendChild(this.stylesheet);
|
|
1415
|
-
}
|
|
1416
|
-
this.stylesheet.textContent = this.payload;
|
|
1417
|
-
}
|
|
1418
|
-
};
|
|
1419
|
-
FEAASStylesheet.register("feaas-stylesheet");
|
|
1420
|
-
|
|
1421
|
-
// src/components/FEAASComponent.ts
|
|
1422
|
-
function FEAASComponentsProps(element = this) {
|
|
1423
|
-
let data;
|
|
1424
|
-
const dataValue = element.getAttribute("data");
|
|
1425
|
-
if (dataValue != null) {
|
|
1426
|
-
try {
|
|
1427
|
-
data = typeof dataValue == "string" ? JSON.parse(dataValue) : {};
|
|
1428
|
-
} catch (e) {
|
|
1429
|
-
}
|
|
1430
|
-
}
|
|
1431
|
-
return {
|
|
1432
|
-
data: data != null ? data : {},
|
|
1433
|
-
library: element.getAttribute("library"),
|
|
1434
|
-
component: element.getAttribute("component"),
|
|
1435
|
-
version: element.getAttribute("version"),
|
|
1436
|
-
revision: element.getAttribute("revision"),
|
|
1437
|
-
hostname: element.getAttribute("hostname"),
|
|
1438
|
-
cdn: element.getContextAttribute("cdn"),
|
|
1439
|
-
template: element.getAttribute("template")
|
|
1440
|
-
};
|
|
1441
|
-
}
|
|
1442
|
-
var FEAASComponent = class extends FEAASBase {
|
|
1443
|
-
setData(data) {
|
|
1444
|
-
this.set({ data });
|
|
1445
|
-
}
|
|
1446
|
-
getProps() {
|
|
1447
|
-
return FEAASComponentsProps(this);
|
|
1448
|
-
}
|
|
1449
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
1450
|
-
this.payload = void 0;
|
|
1451
|
-
this.needsRefresh = true;
|
|
1452
|
-
super.attributeChangedCallback(name, oldValue, newValue);
|
|
1453
|
-
}
|
|
1454
|
-
getOriginal() {
|
|
1455
|
-
const scope = this.getAttribute("data-path-scope");
|
|
1456
|
-
if (!scope)
|
|
1457
|
-
return;
|
|
1458
|
-
for (var current = this; current = current.previousElementSibling; ) {
|
|
1459
|
-
if (current.getAttribute("data-path-scope") == scope) {
|
|
1460
|
-
var last = current;
|
|
1461
|
-
} else {
|
|
1462
|
-
break;
|
|
1463
|
-
}
|
|
1464
|
-
}
|
|
1465
|
-
return last;
|
|
1466
|
-
}
|
|
1467
|
-
isReadyToLoad() {
|
|
1468
|
-
return super.isReadyToLoad() && this.props.library != null && this.props.component != null && this.props.version != null;
|
|
1469
|
-
}
|
|
1470
|
-
load() {
|
|
1471
|
-
return __async(this, null, function* () {
|
|
1472
|
-
if (this.getOriginal()) {
|
|
1473
|
-
return;
|
|
1474
|
-
}
|
|
1475
|
-
try {
|
|
1476
|
-
fetchComponent(this.props, this.onLoad);
|
|
1477
|
-
} catch (e) {
|
|
1478
|
-
console.error(
|
|
1479
|
-
`FEAAS: Could not fetch component: ${this.props.component}/${this.props.version}/${this.props.revision}`
|
|
1480
|
-
);
|
|
1481
|
-
}
|
|
1482
|
-
});
|
|
1483
|
-
}
|
|
1484
|
-
render() {
|
|
1485
|
-
if (Array.from(this.children).filter((c) => c.tagName != "BR").length > 0 && !this.needsRefresh) {
|
|
1486
|
-
renderDOMElement(this, this.props.data);
|
|
1487
|
-
} else {
|
|
1488
|
-
this.needsRefresh = true;
|
|
1489
|
-
if (this.getOriginal()) {
|
|
1490
|
-
return;
|
|
1491
|
-
}
|
|
1492
|
-
renderDOMContent(this, this.payload, this.props.data);
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
};
|
|
1496
|
-
FEAASComponent.observedAttributes = ["library", "component", "version", "revision", "hostname", "cdn", "template", "data"];
|
|
1497
|
-
FEAASComponent.register("feaas-component");
|
|
1498
|
-
|
|
1499
|
-
// src/components/FEAASEditor.tsx
|
|
1500
|
-
function getFramePosition(element) {
|
|
1501
|
-
let positions = [];
|
|
1502
|
-
if (element) {
|
|
1503
|
-
let currentWindow = element.ownerDocument.defaultView;
|
|
1504
|
-
let currentParentWindow;
|
|
1505
|
-
let rect;
|
|
1506
|
-
while (currentWindow !== window.top) {
|
|
1507
|
-
currentParentWindow = currentWindow.parent;
|
|
1508
|
-
for (let idx = 0; idx < currentParentWindow.frames.length; idx++)
|
|
1509
|
-
if (currentParentWindow.frames[idx] === currentWindow) {
|
|
1510
|
-
for (let frameElement of currentParentWindow.document.getElementsByTagName("iframe")) {
|
|
1511
|
-
if (frameElement.contentWindow === currentWindow) {
|
|
1512
|
-
rect = frameElement.getBoundingClientRect();
|
|
1513
|
-
const style = frameElement.contentWindow.getComputedStyle(frameElement);
|
|
1514
|
-
positions.push({
|
|
1515
|
-
left: rect.left + parseInt(style.borderLeftWidth),
|
|
1516
|
-
top: rect.top + parseInt(style.borderTopWidth)
|
|
1517
|
-
});
|
|
1518
|
-
}
|
|
1519
|
-
}
|
|
1520
|
-
currentWindow = currentParentWindow;
|
|
1521
|
-
break;
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
}
|
|
1525
|
-
return positions.reduce(
|
|
1526
|
-
(accumulator, currentValue) => {
|
|
1527
|
-
return {
|
|
1528
|
-
left: accumulator.left + currentValue.left,
|
|
1529
|
-
top: accumulator.top + currentValue.top
|
|
1530
|
-
};
|
|
1531
|
-
},
|
|
1532
|
-
{ left: 0, top: 0 }
|
|
1533
|
-
);
|
|
1534
|
-
}
|
|
1535
|
-
function FEAASEditorProps(element = this) {
|
|
1536
|
-
var _a;
|
|
1537
|
-
return {
|
|
1538
|
-
context: HTMLElement,
|
|
1539
|
-
frontend: element == null ? void 0 : element.getContextAttribute("frontend"),
|
|
1540
|
-
src: (_a = element == null ? void 0 : element.getAttribute("src")) != null ? _a : "/assets/editor.js",
|
|
1541
|
-
library: element == null ? void 0 : element.getAttribute("library"),
|
|
1542
|
-
component: element == null ? void 0 : element.getAttribute("component"),
|
|
1543
|
-
version: element == null ? void 0 : element.getAttribute("version"),
|
|
1544
|
-
revision: (element == null ? void 0 : element.getAttribute("revision")) || "saved",
|
|
1545
|
-
hidden: (element == null ? void 0 : element.getAttribute("hidden")) != null,
|
|
1546
|
-
for: element == null ? void 0 : element.getAttribute("for")
|
|
1547
|
-
};
|
|
1548
|
-
}
|
|
1549
|
-
var FEAASEditor = class extends FEAASBase {
|
|
1550
|
-
constructor() {
|
|
1551
|
-
super(...arguments);
|
|
1552
|
-
this.framePoint = { top: 0, left: 0 };
|
|
1553
|
-
this.wrapperRect = { top: 0, left: 0, width: 0, height: 0 };
|
|
1554
|
-
this.bodyRect = { top: 0, left: 0, width: 0, height: 0 };
|
|
1555
|
-
this.getTarget = () => {
|
|
1556
|
-
return document.querySelector("iframe").contentWindow.document.getElementById(this.props.for);
|
|
1557
|
-
};
|
|
1558
|
-
this.onChromeMeasureElement = (element, rect) => {
|
|
1559
|
-
if (rect == null) {
|
|
1560
|
-
rect = element.getBoundingClientRect();
|
|
1561
|
-
}
|
|
1562
|
-
if (element.ownerDocument == document) {
|
|
1563
|
-
return {
|
|
1564
|
-
left: rect.left - this.bodyRect.left,
|
|
1565
|
-
top: rect.top - this.bodyRect.top,
|
|
1566
|
-
width: rect.width,
|
|
1567
|
-
height: rect.height
|
|
1568
|
-
};
|
|
1569
|
-
}
|
|
1570
|
-
return {
|
|
1571
|
-
left: rect.left + this.framePoint.left - this.bodyRect.left,
|
|
1572
|
-
top: rect.top + this.framePoint.top - this.bodyRect.top,
|
|
1573
|
-
width: rect.width,
|
|
1574
|
-
height: rect.height
|
|
1575
|
-
};
|
|
1576
|
-
};
|
|
1577
|
-
this.onBeforeMeasure = (refs) => {
|
|
1578
|
-
if (refs.memoized.focusable)
|
|
1579
|
-
this.framePoint = getFramePosition(refs.memoized.focusable);
|
|
1580
|
-
this.wrapperRect = this.wrapper.getBoundingClientRect();
|
|
1581
|
-
this.bodyRect = this.wrapper.ownerDocument.body.parentElement.getBoundingClientRect();
|
|
1582
|
-
};
|
|
1583
|
-
this.onMeasure = () => {
|
|
1584
|
-
};
|
|
1585
|
-
this.onPosition = ({ focusable, root }) => {
|
|
1586
|
-
const chrome = this.wrapper.querySelector(".editor-chrome");
|
|
1587
|
-
const absolute = this.wrapper.querySelector(".ui.overlays");
|
|
1588
|
-
if (focusable) {
|
|
1589
|
-
const topbarHeight = 64;
|
|
1590
|
-
const padding = 16;
|
|
1591
|
-
chrome.style.width = focusable.width + padding * 2 + "px";
|
|
1592
|
-
chrome.style.height = focusable.height + padding * 1 + topbarHeight + "px";
|
|
1593
|
-
chrome.style.left = focusable.left - padding + "px";
|
|
1594
|
-
chrome.style.top = focusable.top - topbarHeight + "px";
|
|
1595
|
-
if (absolute) {
|
|
1596
|
-
absolute.style.left = root.left + "px";
|
|
1597
|
-
absolute.style.top = root.top + "px";
|
|
1598
|
-
}
|
|
1599
|
-
} else {
|
|
1600
|
-
chrome.style.left = "-1000px";
|
|
1601
|
-
chrome.style.top = "-1000px";
|
|
1602
|
-
}
|
|
1603
|
-
};
|
|
1604
|
-
}
|
|
1605
|
-
getProps() {
|
|
1606
|
-
return FEAASEditorProps(this);
|
|
1607
|
-
}
|
|
1608
|
-
load() {
|
|
1609
|
-
return import(this.formatURL(this.props.src, this.props.frontend));
|
|
1610
|
-
}
|
|
1611
|
-
renderReact({ children, component: componentId, version: versionId }, {
|
|
1612
|
-
Editor,
|
|
1613
|
-
VersionStatusList,
|
|
1614
|
-
Version,
|
|
1615
|
-
EditorUIUndo,
|
|
1616
|
-
EditorUIMode,
|
|
1617
|
-
React: { useEffect, useMemo, useState },
|
|
1618
|
-
Chakra: { HStack, Box },
|
|
1619
|
-
Chrome,
|
|
1620
|
-
ReactDOM,
|
|
1621
|
-
useSDK,
|
|
1622
|
-
useSlots,
|
|
1623
|
-
useModelObserver
|
|
1624
|
-
}) {
|
|
1625
|
-
if (!this.payload)
|
|
1626
|
-
return;
|
|
1627
|
-
const { sdk } = useSDK();
|
|
1628
|
-
const [component, setComponent] = useState();
|
|
1629
|
-
const library = sdk.library;
|
|
1630
|
-
useEffect(() => {
|
|
1631
|
-
return setComponent(library.components.getItem(componentId));
|
|
1632
|
-
}, [componentId, library]);
|
|
1633
|
-
useEffect(() => {
|
|
1634
|
-
component == null ? void 0 : component.versions.fetch();
|
|
1635
|
-
}, [component]);
|
|
1636
|
-
const target = useMemo(this.getTarget, [this.props.for]);
|
|
1637
|
-
const observedVersions = useModelObserver(component == null ? void 0 : component.versions);
|
|
1638
|
-
const versions = useMemo(() => {
|
|
1639
|
-
return (observedVersions == null ? void 0 : observedVersions.filter((v) => v.id == versionId || !versionId)) || [];
|
|
1640
|
-
}, [observedVersions]);
|
|
1641
|
-
if (!component)
|
|
1642
|
-
return;
|
|
1643
|
-
return useSlots(children, ({ picker, children: children2 }) => /* @__PURE__ */ React.createElement(Box, {
|
|
1644
|
-
ref: (el) => this.wrapper = el
|
|
1645
|
-
}, /* @__PURE__ */ React.createElement(Box, {
|
|
1646
|
-
className: "editor-wrapper",
|
|
1647
|
-
position: "absolute",
|
|
1648
|
-
left: 0,
|
|
1649
|
-
top: 0
|
|
1650
|
-
}, /* @__PURE__ */ React.createElement(Editor, {
|
|
1651
|
-
sdk,
|
|
1652
|
-
library: sdk.library,
|
|
1653
|
-
component,
|
|
1654
|
-
versions,
|
|
1655
|
-
context: {
|
|
1656
|
-
onChromeMeasure: this.onMeasure,
|
|
1657
|
-
onChromeBeforeMeasure: this.onBeforeMeasure,
|
|
1658
|
-
onChromeMeasureElement: this.onChromeMeasureElement,
|
|
1659
|
-
onChromePosition: this.onPosition
|
|
1660
|
-
}
|
|
1661
|
-
}, ({ editor, status, isArchivedDisplayed }) => ({
|
|
1662
|
-
after: children2,
|
|
1663
|
-
picker,
|
|
1664
|
-
chrome: editor && /* @__PURE__ */ React.createElement(Chrome, null),
|
|
1665
|
-
children: component.reduceVersionRevisions(versions).filter((snapshot) => {
|
|
1666
|
-
var _a;
|
|
1667
|
-
return isArchivedDisplayed || !((_a = snapshot.saved || snapshot.draft) == null ? void 0 : _a.deletedAt);
|
|
1668
|
-
}).map((snapshot, index) => /* @__PURE__ */ React.createElement(Box, {
|
|
1669
|
-
key: snapshot.head.id,
|
|
1670
|
-
position: "absolute",
|
|
1671
|
-
left: 0,
|
|
1672
|
-
top: 0,
|
|
1673
|
-
className: "editor-chrome",
|
|
1674
|
-
p: 4,
|
|
1675
|
-
boxShadow: "2xl",
|
|
1676
|
-
pointerEvents: "none"
|
|
1677
|
-
}, /* @__PURE__ */ React.createElement(Box, {
|
|
1678
|
-
className: "borders",
|
|
1679
|
-
pointerEvents: "none",
|
|
1680
|
-
left: 0,
|
|
1681
|
-
width: "4",
|
|
1682
|
-
top: 0,
|
|
1683
|
-
bottom: 0,
|
|
1684
|
-
backdropFilter: "blur(2px)",
|
|
1685
|
-
background: "rgb(244 244 244 / 80%)",
|
|
1686
|
-
position: "absolute"
|
|
1687
|
-
}), /* @__PURE__ */ React.createElement(Box, {
|
|
1688
|
-
className: "borders",
|
|
1689
|
-
pointerEvents: "none",
|
|
1690
|
-
right: 0,
|
|
1691
|
-
width: "4",
|
|
1692
|
-
top: 0,
|
|
1693
|
-
bottom: 0,
|
|
1694
|
-
backdropFilter: "blur(2px)",
|
|
1695
|
-
background: "rgb(244 244 244 / 80%)",
|
|
1696
|
-
position: "absolute"
|
|
1697
|
-
}), /* @__PURE__ */ React.createElement(Box, {
|
|
1698
|
-
className: "borders",
|
|
1699
|
-
pointerEvents: "none",
|
|
1700
|
-
top: 0,
|
|
1701
|
-
height: "16",
|
|
1702
|
-
left: 0,
|
|
1703
|
-
right: 0,
|
|
1704
|
-
backdropFilter: "blur(2px)",
|
|
1705
|
-
background: "rgb(244 244 244 / 80%)",
|
|
1706
|
-
position: "absolute"
|
|
1707
|
-
}), /* @__PURE__ */ React.createElement(Box, {
|
|
1708
|
-
className: "borders",
|
|
1709
|
-
pointerEvents: "none",
|
|
1710
|
-
bottom: 0,
|
|
1711
|
-
height: "4",
|
|
1712
|
-
left: 0,
|
|
1713
|
-
right: 0,
|
|
1714
|
-
backdropFilter: "blur(2px)",
|
|
1715
|
-
background: "rgb(244 244 244 / 80%)",
|
|
1716
|
-
position: "absolute"
|
|
1717
|
-
}), /* @__PURE__ */ React.createElement(Version, {
|
|
1718
|
-
version: snapshot.head,
|
|
1719
|
-
node: target
|
|
1720
|
-
}, {
|
|
1721
|
-
left: /* @__PURE__ */ React.createElement(HStack, {
|
|
1722
|
-
justifyContent: "space-between"
|
|
1723
|
-
}, /* @__PURE__ */ React.createElement(EditorUIUndo, {
|
|
1724
|
-
size: "sm",
|
|
1725
|
-
editor: status == "ready" ? editor : null
|
|
1726
|
-
}), /* @__PURE__ */ React.createElement(EditorUIMode, {
|
|
1727
|
-
size: "sm"
|
|
1728
|
-
})),
|
|
1729
|
-
middle: /* @__PURE__ */ React.createElement(VersionStatusList, null)
|
|
1730
|
-
})))
|
|
1731
|
-
})))));
|
|
1732
|
-
}
|
|
1733
|
-
isReadyToLoad() {
|
|
1734
|
-
return this.props.component != null && this.props.version != null;
|
|
1735
|
-
}
|
|
1736
|
-
};
|
|
1737
|
-
FEAASEditor.register("feaas-editor");
|
|
1738
|
-
|
|
1739
|
-
// src/components/FEAASPicker.tsx
|
|
1740
|
-
function FEAASPickerProps(element = this) {
|
|
1741
|
-
var _a, _b;
|
|
1742
|
-
return {
|
|
1743
|
-
part: (element == null ? void 0 : element.getAttribute("part")) || "picker",
|
|
1744
|
-
slot: (element == null ? void 0 : element.getAttribute("part")) || "slot",
|
|
1745
|
-
mode: element == null ? void 0 : element.getAttribute("mode"),
|
|
1746
|
-
frontend: (_a = element == null ? void 0 : element.getContextAttribute("frontend")) != null ? _a : "https://components.sitecorecloud.io",
|
|
1747
|
-
src: (_b = element == null ? void 0 : element.getAttribute("src")) != null ? _b : "/assets/picker.js",
|
|
1748
|
-
hidden: (element == null ? void 0 : element.getAttribute("hidden")) != null,
|
|
1749
|
-
context: void 0,
|
|
1750
|
-
onClose: void 0
|
|
1751
|
-
};
|
|
1752
|
-
}
|
|
1753
|
-
var FEAASPicker = class extends FEAASBase {
|
|
1754
|
-
getProps() {
|
|
1755
|
-
return FEAASPickerProps(this);
|
|
1756
|
-
}
|
|
1757
|
-
load() {
|
|
1758
|
-
return import(this.formatURL(this.props.src, this.props.frontend));
|
|
1759
|
-
}
|
|
1760
|
-
renderReact({ context, mode, children }, { Picker, React: React2, ReactDOM }) {
|
|
1761
|
-
return /* @__PURE__ */ React2.createElement(Picker, {
|
|
1762
|
-
mode: mode || void 0,
|
|
1763
|
-
onClose: this.props.onClose,
|
|
1764
|
-
context
|
|
1765
|
-
}, children);
|
|
1766
|
-
}
|
|
1767
|
-
};
|
|
1768
|
-
FEAASPicker.register("feaas-picker");
|
|
1769
|
-
function FEAASPickerLazyProps(element = this) {
|
|
1770
|
-
var _a, _b;
|
|
1771
|
-
return {
|
|
1772
|
-
library: (element == null ? void 0 : element.getAttribute("library")) || "library",
|
|
1773
|
-
mode: element == null ? void 0 : element.getAttribute("mode"),
|
|
1774
|
-
frontend: (_a = element == null ? void 0 : element.getContextAttribute("frontend")) != null ? _a : "https://components.sitecorecloud.io",
|
|
1775
|
-
src: (_b = element == null ? void 0 : element.getAttribute("src")) != null ? _b : "/assets/picker.js",
|
|
1776
|
-
hidden: (element == null ? void 0 : element.getAttribute("hidden")) != null,
|
|
1777
|
-
context: null,
|
|
1778
|
-
getToken: null
|
|
1779
|
-
};
|
|
1780
|
-
}
|
|
1781
|
-
var FEAASPickerLazy = class extends FEAASBase {
|
|
1782
|
-
constructor() {
|
|
1783
|
-
super(...arguments);
|
|
1784
|
-
this.payload = null;
|
|
1785
|
-
this.onClose = () => {
|
|
1786
|
-
this.removeAttribute("mode");
|
|
1787
|
-
};
|
|
1788
|
-
}
|
|
1789
|
-
getProps() {
|
|
1790
|
-
return FEAASPickerLazyProps(this);
|
|
1791
|
-
}
|
|
1792
|
-
render() {
|
|
1793
|
-
const { frontend, library, getToken, src, mode, context } = this.props;
|
|
1794
|
-
if (this.getAttribute("mode") == null) {
|
|
1795
|
-
this.setAttribute("hidden", "hidden");
|
|
1796
|
-
} else {
|
|
1797
|
-
this.removeAttribute("hidden");
|
|
1798
|
-
}
|
|
1799
|
-
if (this.children.length == 0)
|
|
1800
|
-
this.innerHTML = `
|
|
1801
|
-
<feaas-context library='${library}'>
|
|
1802
|
-
<feaas-picker mode='${mode}'>
|
|
65
|
+
</div>`,this.getRoot().appendChild(this.stylesheet),this.getRoot().appendChild(this.loader)}};O.observedAttributes=["hidden"];O.register("feaas-loader");function lt(t=this){var e;return{library:t==null?void 0:t.getContextAttribute("library"),revision:(e=t==null?void 0:t.getAttribute("revision"))!==null&&e!==void 0?e:"published",cdn:(t==null?void 0:t.getContextAttribute("cdn"))||(t==null?void 0:t.getContextAttribute("hostname"))}}var W=class extends b{getProps(){return lt(this)}isReadyToLoad(){return this.props.library!=null&&this.props.revision!=null&&this.props.cdn!=null}async load(){H(this.props,this.onLoad)}render(){this.stylesheet||(this.stylesheet=document.createElement("style"),this.appendChild(this.stylesheet)),this.stylesheet.textContent=this.payload}};W.register("feaas-stylesheet");var G;console.log("FEAAS loaded");typeof window!="undefined"&&((G=window.FEAASLoading)!==null&&G!==void 0||(window.FEAASLoading=Promise.resolve()));function dt(t){let e=[];if(t){let r=t.ownerDocument.defaultView,i,n;for(;r!==window.top;){i=r.parent;for(let o=0;o<i.frames.length;o++)if(i.frames[o]===r){for(let s of i.document.getElementsByTagName("iframe"))if(s.contentWindow===r){n=s.getBoundingClientRect();let a=s.contentWindow.getComputedStyle(s);e.push({left:n.left+parseInt(a.borderLeftWidth),top:n.top+parseInt(a.borderTopWidth)})}r=i;break}}}return e.reduce((r,i)=>({left:r.left+i.left,top:r.top+i.top}),{left:0,top:0})}function ct(t=this){var e;return{context:HTMLElement,frontend:t==null?void 0:t.getContextAttribute("frontend"),src:(e=t==null?void 0:t.getAttribute("src"))!==null&&e!==void 0?e:"/assets/editor.js",library:t==null?void 0:t.getAttribute("library"),component:t==null?void 0:t.getAttribute("component"),version:t==null?void 0:t.getAttribute("version"),revision:(t==null?void 0:t.getAttribute("revision"))||"saved",hidden:(t==null?void 0:t.getAttribute("hidden"))!=null,for:t==null?void 0:t.getAttribute("for")}}var B=class extends b{constructor(){super(...arguments),this.framePoint={top:0,left:0},this.wrapperRect={top:0,left:0,width:0,height:0},this.bodyRect={top:0,left:0,width:0,height:0},this.getTarget=()=>document.querySelector("iframe").contentWindow.document.getElementById(this.props.for),this.onChromeMeasureElement=(e,r)=>(r==null&&(r=e.getBoundingClientRect()),e.ownerDocument==document?{left:r.left-this.bodyRect.left,top:r.top-this.bodyRect.top,width:r.width,height:r.height}:{left:r.left+this.framePoint.left-this.bodyRect.left,top:r.top+this.framePoint.top-this.bodyRect.top,width:r.width,height:r.height}),this.onBeforeMeasure=e=>{e.memoized.focusable&&(this.framePoint=dt(e.memoized.focusable)),this.wrapperRect=this.wrapper.getBoundingClientRect(),this.bodyRect=this.wrapper.ownerDocument.body.parentElement.getBoundingClientRect()},this.onMeasure=()=>{},this.onPosition=({focusable:e,root:r})=>{let i=this.wrapper.querySelector(".editor-chrome"),n=this.wrapper.querySelector(".ui.overlays");e?(i.style.width=e.width+16*2+"px",i.style.height=e.height+16*1+64+"px",i.style.left=e.left-16+"px",i.style.top=e.top-64+"px",n&&(n.style.left=r.left+"px",n.style.top=r.top+"px")):(i.style.left="-1000px",i.style.top="-1000px")}}getProps(){return ct(this)}load(){return import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}renderReact({children:e,component:r,version:i},{Editor:n,VersionStatusList:o,Version:s,EditorUIUndo:a,EditorUIMode:d,React:{useEffect:l,useMemo:u,useState:h},Chakra:{HStack:p,Box:c},Chrome:g,ReactDOM:v,useSDK:A,useSlots:w,useModelObserver:E}){if(!this.payload)return;let{sdk:R}=A(),[y,ft]=h(),K=R.library;l(()=>ft(K.components.getItem(r)),[r,K]),l(()=>{y==null||y.versions.fetch()},[y]);let gt=u(this.getTarget,[this.props.for]),$=E(y==null?void 0:y.versions),Y=u(()=>($==null?void 0:$.filter(z=>z.id==i||!i))||[],[$]);if(y)return w(e,({picker:z,children:yt})=>React.createElement(c,{ref:D=>this.wrapper=D},React.createElement(c,{className:"editor-wrapper",position:"absolute",left:0,top:0},React.createElement(n,{datasources:R.datasources,sdk:R,library:R.library,component:y,versions:Y,context:{onChromeMeasure:this.onMeasure,onChromeBeforeMeasure:this.onBeforeMeasure,onChromeMeasureElement:this.onChromeMeasureElement,onChromePosition:this.onPosition}},({editor:D,status:bt,isArchivedDisplayed:vt})=>({after:yt,picker:z,chrome:D&&React.createElement(g,null),children:y.reduceVersionRevisions(Y).filter(k=>{var N;return vt||!(!((N=k.saved||k.draft)===null||N===void 0)&&N.deletedAt)}).map((k,N)=>React.createElement(c,{key:k.head.id,position:"absolute",left:0,top:0,className:"editor-chrome",p:4,boxShadow:"2xl",pointerEvents:"none"},React.createElement(c,{className:"borders",pointerEvents:"none",left:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),React.createElement(c,{className:"borders",pointerEvents:"none",right:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),React.createElement(c,{className:"borders",pointerEvents:"none",top:0,height:"16",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),React.createElement(c,{className:"borders",pointerEvents:"none",bottom:0,height:"4",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),React.createElement(s,{version:k.head,node:gt},{left:React.createElement(p,{justifyContent:"space-between"},React.createElement(a,{size:"sm",editor:bt=="ready"?D:null}),React.createElement(d,{size:"sm"})),middle:React.createElement(o,null)})))})))))}isReadyToLoad(){return this.props.component!=null&&this.props.version!=null}};B.register("feaas-editor");function ut(t=this){var e,r;return{part:(t==null?void 0:t.getAttribute("part"))||"picker",slot:(t==null?void 0:t.getAttribute("part"))||"slot",mode:t==null?void 0:t.getAttribute("mode"),frontend:(e=t==null?void 0:t.getContextAttribute("frontend"))!==null&&e!==void 0?e:"https://components.sitecorecloud.io",src:(r=t==null?void 0:t.getAttribute("src"))!==null&&r!==void 0?r:"/assets/picker.js",hidden:(t==null?void 0:t.getAttribute("hidden"))!=null,context:void 0,onClose:void 0}}var q=class extends b{getProps(){return ut(this)}load(){return import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}renderReact({context:e,mode:r,children:i},{Picker:n,React:o,ReactDOM:s}){return o.createElement(n,{mode:r||void 0,onClose:this.props.onClose,context:e},i)}};q.register("feaas-picker");function ht(t=this){var e,r;return{library:(t==null?void 0:t.getAttribute("library"))||"library",mode:t==null?void 0:t.getAttribute("mode"),frontend:(e=t==null?void 0:t.getContextAttribute("frontend"))!==null&&e!==void 0?e:"https://components.sitecorecloud.io",src:(r=t==null?void 0:t.getAttribute("src"))!==null&&r!==void 0?r:"/assets/picker.js",hidden:(t==null?void 0:t.getAttribute("hidden"))!=null,context:null,getToken:null}}var M=class extends b{constructor(){super(...arguments),this.payload=null,this.onClose=()=>{this.removeAttribute("mode")}}getProps(){return ht(this)}render(){let{frontend:e,library:r,getToken:i,src:n,mode:o,context:s}=this.props;this.getAttribute("mode")==null?this.setAttribute("hidden","hidden"):this.removeAttribute("hidden"),this.children.length==0&&(this.innerHTML=`
|
|
66
|
+
<feaas-context library='${r}'>
|
|
67
|
+
<feaas-picker mode='${o}'>
|
|
1803
68
|
<feaas-loader />
|
|
1804
69
|
</feaas-context>
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
frontend,
|
|
1808
|
-
library,
|
|
1809
|
-
getToken
|
|
1810
|
-
});
|
|
1811
|
-
this.refs.picker.set({
|
|
1812
|
-
frontend,
|
|
1813
|
-
context,
|
|
1814
|
-
src,
|
|
1815
|
-
mode,
|
|
1816
|
-
onClose: this.onClose
|
|
1817
|
-
});
|
|
1818
|
-
}
|
|
1819
|
-
};
|
|
1820
|
-
FEAASPickerLazy.observedAttributes = ["library", "mode", "frontend", "src", "context"];
|
|
1821
|
-
FEAASPickerLazy.register("feaas-picker-lazy");
|
|
1822
|
-
|
|
1823
|
-
// src/components/FEAASContext.tsx
|
|
1824
|
-
function FEAASContextProps(element = this) {
|
|
1825
|
-
var _a, _b, _c, _d;
|
|
1826
|
-
return {
|
|
1827
|
-
library: element == null ? void 0 : element.getAttribute("library"),
|
|
1828
|
-
src: (_a = element == null ? void 0 : element.getAttribute("src")) != null ? _a : "/assets/context.js",
|
|
1829
|
-
frontend: (_b = element == null ? void 0 : element.getAttribute("frontend")) != null ? _b : "https://components.sitecoreclud.io",
|
|
1830
|
-
backend: (_c = element == null ? void 0 : element.getAttribute("backend")) != null ? _c : "https://components-api.sitecoreclud.io",
|
|
1831
|
-
cdn: (_d = element == null ? void 0 : element.getAttribute("cdn")) != null ? _d : "https://feaascompontsapiprod.blob.core.windows.net",
|
|
1832
|
-
getToken: null
|
|
1833
|
-
};
|
|
1834
|
-
}
|
|
1835
|
-
var FEAASContext = class extends FEAASBase {
|
|
1836
|
-
getProps() {
|
|
1837
|
-
return FEAASContextProps(this);
|
|
1838
|
-
}
|
|
1839
|
-
load() {
|
|
1840
|
-
return import(this.formatURL(this.props.src, this.props.frontend));
|
|
1841
|
-
}
|
|
1842
|
-
getTheme(theme) {
|
|
1843
|
-
return theme;
|
|
1844
|
-
}
|
|
1845
|
-
getRoot() {
|
|
1846
|
-
return this.shadowRoot || this.attachShadow({ mode: "open" });
|
|
1847
|
-
}
|
|
1848
|
-
getReactRoot() {
|
|
1849
|
-
if (!this.reactRoot) {
|
|
1850
|
-
this.reactRoot = document.createElement("div");
|
|
1851
|
-
this.getRoot().appendChild(this.reactRoot);
|
|
1852
|
-
}
|
|
1853
|
-
return this.reactRoot;
|
|
1854
|
-
}
|
|
1855
|
-
nestedCallback(event) {
|
|
1856
|
-
super.nestedCallback(event);
|
|
1857
|
-
const target = event.composedPath()[0];
|
|
1858
|
-
if (target.parentNode != this.getRoot()) {
|
|
1859
|
-
this.getRoot().appendChild(target);
|
|
1860
|
-
}
|
|
1861
|
-
}
|
|
1862
|
-
renderReact({ children, library }, { AppContext, Chakra: { Button, Tooltip }, React: React2 }) {
|
|
1863
|
-
const portalProps = {
|
|
1864
|
-
containerRef: { current: this.getRoot() }
|
|
1865
|
-
};
|
|
1866
|
-
Tooltip.defaultProps = {
|
|
1867
|
-
hasArrow: true,
|
|
1868
|
-
placement: "top",
|
|
1869
|
-
portalProps
|
|
1870
|
-
};
|
|
1871
|
-
return /* @__PURE__ */ React2.createElement(AppContext, {
|
|
1872
|
-
libraryId: this.props.library,
|
|
1873
|
-
container: this.getRoot(),
|
|
1874
|
-
getToken: this.props.getToken,
|
|
1875
|
-
getTheme: this.getTheme,
|
|
1876
|
-
modalProps: {
|
|
1877
|
-
portalProps
|
|
1878
|
-
},
|
|
1879
|
-
chakraProps: {
|
|
1880
|
-
cssVarsRoot: ":host",
|
|
1881
|
-
resetCSS: true,
|
|
1882
|
-
toastOptions: {
|
|
1883
|
-
portalProps
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
}, children);
|
|
1887
|
-
}
|
|
1888
|
-
};
|
|
1889
|
-
FEAASContext.observedAttributes = ["library", "component", "version", "revision", "hostname", "template"];
|
|
1890
|
-
FEAASContext.register("feaas-context");
|
|
1891
|
-
export {
|
|
1892
|
-
FEAASComponent,
|
|
1893
|
-
FEAASComponentsProps,
|
|
1894
|
-
FEAASContext,
|
|
1895
|
-
FEAASContextProps,
|
|
1896
|
-
FEAASEditor,
|
|
1897
|
-
FEAASEditorProps,
|
|
1898
|
-
FEAASLoader,
|
|
1899
|
-
FEAASLoaderProps,
|
|
1900
|
-
FEAASPicker,
|
|
1901
|
-
FEAASPickerLazy,
|
|
1902
|
-
FEAASPickerLazyProps,
|
|
1903
|
-
FEAASPickerProps,
|
|
1904
|
-
FEAASStylesheet,
|
|
1905
|
-
FEAASStylesheetProps,
|
|
1906
|
-
autoloadScripts,
|
|
1907
|
-
cleanCollectionBit,
|
|
1908
|
-
fetchAndRevalidate,
|
|
1909
|
-
getFramePosition,
|
|
1910
|
-
loadScript,
|
|
1911
|
-
normalizeCollectionScope,
|
|
1912
|
-
observeDOMElement,
|
|
1913
|
-
queryScopes,
|
|
1914
|
-
renderComponent,
|
|
1915
|
-
renderComponentElement,
|
|
1916
|
-
renderComponentPromise,
|
|
1917
|
-
renderDOMContent,
|
|
1918
|
-
renderDOMElement,
|
|
1919
|
-
renderStylesheet,
|
|
1920
|
-
renderStylesheetPromise,
|
|
1921
|
-
setDOMAttribute
|
|
1922
|
-
};
|
|
70
|
+
`),this.refs.context.set({frontend:e,library:r,getToken:i}),this.refs.picker.set({frontend:e,context:s,src:n,mode:o,onClose:this.onClose})}};M.observedAttributes=["library","mode","frontend","src","context"];M.register("feaas-picker-lazy");function pt(t=this){var e,r,i,n;return{library:t==null?void 0:t.getAttribute("library"),src:(e=t==null?void 0:t.getAttribute("src"))!==null&&e!==void 0?e:"/assets/context.js",frontend:(r=t==null?void 0:t.getAttribute("frontend"))!==null&&r!==void 0?r:"https://components.sitecoreclud.io",backend:(i=t==null?void 0:t.getAttribute("backend"))!==null&&i!==void 0?i:"https://components-api.sitecoreclud.io",cdn:(n=t==null?void 0:t.getAttribute("cdn"))!==null&&n!==void 0?n:"https://feaascompontsapiprod.blob.core.windows.net",getToken:null}}var L=class extends b{getProps(){return pt(this)}load(){return import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}getTheme(e){return e}getRoot(){return this.shadowRoot||this.attachShadow({mode:"open"})}getReactRoot(){return this.reactRoot||(this.reactRoot=document.createElement("div"),this.getRoot().appendChild(this.reactRoot)),this.reactRoot}nestedCallback(e){super.nestedCallback(e);let r=e.composedPath()[0];r.parentNode!=this.getRoot()&&this.getRoot().appendChild(r)}renderReact({children:e,library:r},{AppContext:i,Chakra:{Button:n,Tooltip:o},React:s}){let a={containerRef:{current:this.getRoot()}};return o.defaultProps={hasArrow:!0,placement:"top",portalProps:a},s.createElement(i,{libraryId:this.props.library,container:this.getRoot(),getToken:this.props.getToken,getTheme:this.getTheme,modalProps:{portalProps:a},chakraProps:{cssVarsRoot:":host",resetCSS:!0,toastOptions:{portalProps:a}}},e)}};L.observedAttributes=["library","component","version","revision","hostname","template"];L.register("feaas-context");0&&(module.exports={Base,Component,FEAASBase,FEAASComponent,FEAASComponentsProps,FEAASContext,FEAASContextProps,FEAASEditor,FEAASEditorProps,FEAASLoader,FEAASLoaderProps,FEAASPicker,FEAASPickerLazy,FEAASPickerLazyProps,FEAASPickerProps,FEAASStylesheet,FEAASStylesheetProps,Loader,Stylesheet,autoloadScripts,cleanCollectionBit,fetchAndRevalidate,getFramePosition,loadScript,normalizeCollectionScope,observeDOMElement,queryScopes,renderComponent,renderComponentElement,renderComponentPromise,renderDOMContent,renderDOMElement,renderStylesheet,renderStylesheetPromise,setDOMAttribute});
|
|
71
|
+
//# sourceMappingURL=index.js.map
|