@eightshift/ui-components 5.0.9 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Collection-uTAXq9Br.js → Collection-BRJOMbOa.js} +12 -7
- package/dist/{Dialog-CmAxaSUv.js → Dialog-D6EdDPeu.js} +8 -8
- package/dist/{useFormValidation-Dy0PXJg5.js → Form-Bnyyv3Im.js} +6 -4
- package/dist/{Group-DDPhPPTQ.js → Group-LBogWgyp.js} +2 -2
- package/dist/{Input-BmDS8Juy.js → Input-DfSBLhDx.js} +1 -1
- package/dist/List-BLeHBkfx.js +590 -0
- package/dist/{ListBox-_nDFq8-H.js → ListBox-BY3gwI8c.js} +3 -3
- package/dist/Select-BebwUgKB.js +764 -0
- package/dist/Separator-CTQWg_HO.js +1111 -0
- package/dist/TextField-o2U-uBWv.js +133 -0
- package/dist/assets/style-admin.css +268 -150
- package/dist/assets/style-editor.css +268 -150
- package/dist/assets/style.css +268 -150
- package/dist/assets/wp-font-enhancements.css +1 -1
- package/dist/assets/wp-ui-enhancements.css +1 -1
- package/dist/components/breakpoint-preview/breakpoint-preview.js +3 -4
- package/dist/components/button/button.js +3 -3
- package/dist/components/checkbox/checkbox.js +1 -2
- package/dist/components/color-pickers/color-picker.js +7 -9
- package/dist/components/color-pickers/color-swatch.js +1 -1
- package/dist/components/color-pickers/gradient-editor.js +19 -25
- package/dist/components/color-pickers/solid-color-picker.js +27 -27
- package/dist/components/component-toggle/component-toggle.js +1 -1
- package/dist/components/draggable/draggable-handle.js +2 -2
- package/dist/components/draggable/draggable.js +5 -5
- package/dist/components/draggable-list/draggable-list-item.js +2 -2
- package/dist/components/draggable-list/draggable-list.js +5 -5
- package/dist/components/expandable/expandable.js +1 -1
- package/dist/components/index.js +5 -5
- package/dist/components/input-field/input-field.js +13 -129
- package/dist/components/item-collection/item-collection.js +1 -1
- package/dist/components/link-input/link-input.js +1463 -17
- package/dist/components/matrix-align/matrix-align.js +11 -14
- package/dist/components/menu/menu.js +4 -8
- package/dist/components/modal/modal.js +3 -3
- package/dist/components/number-picker/number-picker.js +9 -10
- package/dist/components/option-select/option-select.js +140 -156
- package/dist/components/placeholders/file-placeholder.js +1 -1
- package/dist/components/placeholders/image-placeholder.js +3 -3
- package/dist/components/placeholders/media-placeholder.js +2 -2
- package/dist/components/popover/popover.js +10 -5
- package/dist/components/radio/radio.js +4 -5
- package/dist/components/repeater/repeater-item.js +1 -1
- package/dist/components/repeater/repeater.js +6 -6
- package/dist/components/responsive/mini-responsive.js +45 -47
- package/dist/components/responsive/responsive-legacy.js +51 -55
- package/dist/components/responsive/responsive.js +47 -49
- package/dist/components/responsive-preview/responsive-preview.js +12 -15
- package/dist/components/select/async-multi-select.js +4 -4
- package/dist/components/select/async-single-select.js +1 -1
- package/dist/components/select/multi-select-components.js +1 -1
- package/dist/components/select/multi-select.js +4 -4
- package/dist/components/select/shared.js +2 -2
- package/dist/components/select/single-select.js +1 -1
- package/dist/components/select/styles.js +3 -3
- package/dist/components/select/v2/async-select.js +215 -158
- package/dist/components/select/v2/shared.js +29 -20
- package/dist/components/select/v2/single-select.js +202 -851
- package/dist/components/slider/column-config-slider.js +2 -2
- package/dist/components/slider/slider.js +2 -2
- package/dist/components/slider/utils.js +1 -1
- package/dist/components/tabs/tabs.js +7 -8
- package/dist/components/toggle/switch.js +4 -3
- package/dist/components/toggle-button/toggle-button.js +1 -1
- package/dist/{default-i18n-CT_oS1Fy.js → default-i18n-OFa3zAyB.js} +5 -9
- package/dist/icons/jsx-svg.js +35 -5
- package/dist/index.js +4 -4
- package/dist/{multi-select-components-Sp-JEFEX.js → multi-select-components-BcKzA24f.js} +3 -3
- package/dist/{react-jsx-parser.min-DZCiis5V.js → react-jsx-parser.min-LF707GK8.js} +312 -332
- package/dist/useAsyncList-fLtZMvJO.js +420 -0
- package/dist/useFilter-BR5z1A4Q.js +50 -0
- package/dist/{useListState-9Hq_FiRF.js → useListState-BrZ2XvDS.js} +1 -1
- package/dist/{useNumberField-D0u2bh8g.js → useNumberField-y0dLc_6m.js} +2 -2
- package/dist/{useSingleSelectListState-DqhemUIh.js → useSingleSelectListState-Bh46cRXs.js} +1 -1
- package/dist/utilities/array-helpers.js +4 -7
- package/dist/utilities/es-dash.js +21 -3
- package/dist/utilities/index.js +2 -1
- package/dist/utilities/text-helpers.js +3 -3
- package/package.json +9 -9
- package/dist/ComboBox-BANSEKnb.js +0 -1915
- package/dist/Form-Cq3fu75_.js +0 -5
- package/dist/List-CZMUbkFU.js +0 -593
- package/dist/Separator-BN3mjL6q.js +0 -332
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __typeError = (msg) => {
|
|
3
|
-
throw TypeError(msg);
|
|
4
|
-
};
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
8
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
|
-
var _parseJSX, _parseExpression, _parseChainExpression, _parseMemberExpression, _parseName, _parseElement;
|
|
11
1
|
import React__default, { Fragment } from "react";
|
|
12
2
|
function getLocator(source, options) {
|
|
13
3
|
if (options === void 0) {
|
|
@@ -385,15 +375,15 @@ function svgToJsxString(svgString) {
|
|
|
385
375
|
}
|
|
386
376
|
var __create = Object.create;
|
|
387
377
|
var __getProtoOf = Object.getPrototypeOf;
|
|
388
|
-
var
|
|
378
|
+
var __defProp = Object.defineProperty;
|
|
389
379
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
390
380
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
391
381
|
var __toESM = (mod, isNodeMode, target) => {
|
|
392
382
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
393
|
-
const to =
|
|
383
|
+
const to = __defProp(target, "default", { value: mod, enumerable: true });
|
|
394
384
|
for (let key of __getOwnPropNames(mod))
|
|
395
385
|
if (!__hasOwnProp.call(to, key))
|
|
396
|
-
|
|
386
|
+
__defProp(to, key, {
|
|
397
387
|
get: () => mod[key],
|
|
398
388
|
enumerable: true
|
|
399
389
|
});
|
|
@@ -11409,343 +11399,333 @@ function handleNaN(child) {
|
|
|
11409
11399
|
return Number.isNaN(child) ? "NaN" : child;
|
|
11410
11400
|
}
|
|
11411
11401
|
class JsxParser extends React__default.Component {
|
|
11412
|
-
|
|
11413
|
-
|
|
11414
|
-
|
|
11415
|
-
|
|
11416
|
-
|
|
11417
|
-
|
|
11418
|
-
|
|
11419
|
-
|
|
11420
|
-
|
|
11421
|
-
|
|
11422
|
-
|
|
11423
|
-
|
|
11424
|
-
|
|
11425
|
-
|
|
11426
|
-
|
|
11427
|
-
|
|
11428
|
-
|
|
11429
|
-
|
|
11430
|
-
|
|
11431
|
-
|
|
11432
|
-
|
|
11402
|
+
static displayName = "JsxParser";
|
|
11403
|
+
static defaultProps = {
|
|
11404
|
+
allowUnknownElements: true,
|
|
11405
|
+
autoCloseVoidElements: false,
|
|
11406
|
+
bindings: {},
|
|
11407
|
+
blacklistedAttrs: [/^on.+/i],
|
|
11408
|
+
blacklistedTags: ["script"],
|
|
11409
|
+
className: "",
|
|
11410
|
+
components: {},
|
|
11411
|
+
componentsOnly: false,
|
|
11412
|
+
disableFragments: false,
|
|
11413
|
+
disableKeyGeneration: false,
|
|
11414
|
+
jsx: "",
|
|
11415
|
+
onError: () => {
|
|
11416
|
+
},
|
|
11417
|
+
showWarnings: false,
|
|
11418
|
+
renderError: void 0,
|
|
11419
|
+
renderInWrapper: true,
|
|
11420
|
+
renderUnrecognized: () => null
|
|
11421
|
+
};
|
|
11422
|
+
ParsedChildren = null;
|
|
11423
|
+
#parseJSX = (jsx) => {
|
|
11424
|
+
const parser = Parser.extend(AcornJSX.default({
|
|
11425
|
+
autoCloseVoidElements: this.props.autoCloseVoidElements
|
|
11426
|
+
}));
|
|
11427
|
+
const wrappedJsx = `<root>${jsx}</root>`;
|
|
11428
|
+
let parsed = [];
|
|
11429
|
+
try {
|
|
11430
|
+
parsed = parser.parse(wrappedJsx, { ecmaVersion: "latest" });
|
|
11431
|
+
parsed = parsed.body[0].expression.children || [];
|
|
11432
|
+
} catch (error) {
|
|
11433
|
+
if (this.props.showWarnings)
|
|
11434
|
+
console.warn(error);
|
|
11435
|
+
if (this.props.onError)
|
|
11436
|
+
this.props.onError(error);
|
|
11437
|
+
if (this.props.renderError) {
|
|
11438
|
+
return this.props.renderError({ error: String(error) });
|
|
11433
11439
|
}
|
|
11434
|
-
return
|
|
11435
|
-
}
|
|
11436
|
-
|
|
11437
|
-
|
|
11438
|
-
|
|
11439
|
-
|
|
11440
|
-
|
|
11441
|
-
|
|
11442
|
-
return
|
|
11443
|
-
|
|
11444
|
-
|
|
11445
|
-
|
|
11446
|
-
|
|
11447
|
-
|
|
11448
|
-
|
|
11449
|
-
|
|
11450
|
-
|
|
11451
|
-
|
|
11452
|
-
|
|
11453
|
-
|
|
11454
|
-
|
|
11455
|
-
|
|
11456
|
-
|
|
11457
|
-
|
|
11458
|
-
|
|
11459
|
-
|
|
11460
|
-
|
|
11461
|
-
|
|
11462
|
-
|
|
11463
|
-
|
|
11464
|
-
|
|
11465
|
-
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
|
|
11469
|
-
|
|
11470
|
-
|
|
11471
|
-
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
|
|
11480
|
-
|
|
11481
|
-
|
|
11482
|
-
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11486
|
-
|
|
11487
|
-
|
|
11488
|
-
|
|
11489
|
-
|
|
11490
|
-
|
|
11491
|
-
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
|
|
11496
|
-
|
|
11497
|
-
|
|
11498
|
-
|
|
11499
|
-
|
|
11500
|
-
|
|
11501
|
-
|
|
11502
|
-
|
|
11503
|
-
|
|
11504
|
-
|
|
11505
|
-
}
|
|
11506
|
-
return handleNaN(binaryResult);
|
|
11507
|
-
case "CallExpression":
|
|
11508
|
-
const parsedCallee = __privateGet(this, _parseExpression).call(this, expression.callee, scope);
|
|
11509
|
-
if (parsedCallee === void 0) {
|
|
11510
|
-
if (expression.optional) {
|
|
11511
|
-
throw new NullishShortCircuit();
|
|
11512
|
-
}
|
|
11513
|
-
this.props.onError(new Error(`The expression '${expression.callee}' could not be resolved, resulting in an undefined return value.`));
|
|
11440
|
+
return null;
|
|
11441
|
+
}
|
|
11442
|
+
return parsed.map((p) => this.#parseExpression(p)).filter(Boolean);
|
|
11443
|
+
};
|
|
11444
|
+
#parseExpression = (expression, scope) => {
|
|
11445
|
+
switch (expression.type) {
|
|
11446
|
+
case "JSXAttribute":
|
|
11447
|
+
if (expression.value === null)
|
|
11448
|
+
return true;
|
|
11449
|
+
return this.#parseExpression(expression.value, scope);
|
|
11450
|
+
case "JSXElement":
|
|
11451
|
+
case "JSXFragment":
|
|
11452
|
+
return this.#parseElement(expression, scope);
|
|
11453
|
+
case "JSXExpressionContainer":
|
|
11454
|
+
return this.#parseExpression(expression.expression, scope);
|
|
11455
|
+
case "JSXText":
|
|
11456
|
+
const key = this.props.disableKeyGeneration ? void 0 : randomHash();
|
|
11457
|
+
return this.props.disableFragments ? expression.value : /* @__PURE__ */ React__default.createElement(Fragment, {
|
|
11458
|
+
key
|
|
11459
|
+
}, expression.value);
|
|
11460
|
+
case "ArrayExpression":
|
|
11461
|
+
return expression.elements.map((ele) => this.#parseExpression(ele, scope));
|
|
11462
|
+
case "BinaryExpression":
|
|
11463
|
+
const binaryLeft = this.#parseExpression(expression.left, scope);
|
|
11464
|
+
const binaryRight = this.#parseExpression(expression.right, scope);
|
|
11465
|
+
let binaryResult;
|
|
11466
|
+
switch (expression.operator) {
|
|
11467
|
+
case "-":
|
|
11468
|
+
binaryResult = binaryLeft - binaryRight;
|
|
11469
|
+
break;
|
|
11470
|
+
case "!=":
|
|
11471
|
+
binaryResult = binaryLeft != binaryRight;
|
|
11472
|
+
break;
|
|
11473
|
+
case "!==":
|
|
11474
|
+
binaryResult = binaryLeft !== binaryRight;
|
|
11475
|
+
break;
|
|
11476
|
+
case "*":
|
|
11477
|
+
binaryResult = binaryLeft * binaryRight;
|
|
11478
|
+
break;
|
|
11479
|
+
case "**":
|
|
11480
|
+
binaryResult = binaryLeft ** binaryRight;
|
|
11481
|
+
break;
|
|
11482
|
+
case "/":
|
|
11483
|
+
binaryResult = binaryLeft / binaryRight;
|
|
11484
|
+
break;
|
|
11485
|
+
case "%":
|
|
11486
|
+
binaryResult = binaryLeft % binaryRight;
|
|
11487
|
+
break;
|
|
11488
|
+
case "+":
|
|
11489
|
+
binaryResult = binaryLeft + binaryRight;
|
|
11490
|
+
break;
|
|
11491
|
+
case "<":
|
|
11492
|
+
binaryResult = binaryLeft < binaryRight;
|
|
11493
|
+
break;
|
|
11494
|
+
case "<=":
|
|
11495
|
+
binaryResult = binaryLeft <= binaryRight;
|
|
11496
|
+
break;
|
|
11497
|
+
case "==":
|
|
11498
|
+
binaryResult = binaryLeft == binaryRight;
|
|
11499
|
+
break;
|
|
11500
|
+
case "===":
|
|
11501
|
+
binaryResult = binaryLeft === binaryRight;
|
|
11502
|
+
break;
|
|
11503
|
+
case ">":
|
|
11504
|
+
binaryResult = binaryLeft > binaryRight;
|
|
11505
|
+
break;
|
|
11506
|
+
case ">=":
|
|
11507
|
+
binaryResult = binaryLeft >= binaryRight;
|
|
11508
|
+
break;
|
|
11509
|
+
default:
|
|
11510
|
+
this.props.onError(new Error(`Unsupported binary operator: ${expression.operator}`));
|
|
11514
11511
|
return;
|
|
11512
|
+
}
|
|
11513
|
+
return handleNaN(binaryResult);
|
|
11514
|
+
case "CallExpression":
|
|
11515
|
+
const parsedCallee = this.#parseExpression(expression.callee, scope);
|
|
11516
|
+
if (parsedCallee === void 0) {
|
|
11517
|
+
if (expression.optional) {
|
|
11518
|
+
throw new NullishShortCircuit();
|
|
11515
11519
|
}
|
|
11516
|
-
|
|
11517
|
-
case "ConditionalExpression":
|
|
11518
|
-
return __privateGet(this, _parseExpression).call(this, expression.test, scope) ? __privateGet(this, _parseExpression).call(this, expression.consequent, scope) : __privateGet(this, _parseExpression).call(this, expression.alternate, scope);
|
|
11519
|
-
case "ExpressionStatement":
|
|
11520
|
-
return __privateGet(this, _parseExpression).call(this, expression.expression, scope);
|
|
11521
|
-
case "Identifier":
|
|
11522
|
-
if (expression.name === "Infinity")
|
|
11523
|
-
return Infinity;
|
|
11524
|
-
if (expression.name === "-Infinity")
|
|
11525
|
-
return -Infinity;
|
|
11526
|
-
if (expression.name === "NaN")
|
|
11527
|
-
return NaN;
|
|
11528
|
-
if (scope && expression.name in scope) {
|
|
11529
|
-
return handleNaN(scope[expression.name]);
|
|
11530
|
-
}
|
|
11531
|
-
return handleNaN((this.props.bindings || {})[expression.name]);
|
|
11532
|
-
case "Literal":
|
|
11533
|
-
return expression.value;
|
|
11534
|
-
case "LogicalExpression":
|
|
11535
|
-
const left = __privateGet(this, _parseExpression).call(this, expression.left, scope);
|
|
11536
|
-
if (expression.operator === "||" && left)
|
|
11537
|
-
return left;
|
|
11538
|
-
if (expression.operator === "&&" && left || expression.operator === "||" && !left) {
|
|
11539
|
-
return __privateGet(this, _parseExpression).call(this, expression.right, scope);
|
|
11540
|
-
}
|
|
11541
|
-
return false;
|
|
11542
|
-
case "MemberExpression":
|
|
11543
|
-
return __privateGet(this, _parseMemberExpression).call(this, expression, scope);
|
|
11544
|
-
case "ChainExpression":
|
|
11545
|
-
return __privateGet(this, _parseChainExpression).call(this, expression, scope);
|
|
11546
|
-
case "ObjectExpression":
|
|
11547
|
-
const object = {};
|
|
11548
|
-
expression.properties.forEach((prop) => {
|
|
11549
|
-
object[prop.key.name || prop.key.value] = __privateGet(this, _parseExpression).call(this, prop.value, scope);
|
|
11550
|
-
});
|
|
11551
|
-
return object;
|
|
11552
|
-
case "TemplateElement":
|
|
11553
|
-
return expression.value.cooked;
|
|
11554
|
-
case "TemplateLiteral":
|
|
11555
|
-
return [...expression.expressions, ...expression.quasis].sort((a, b) => {
|
|
11556
|
-
if (a.start < b.start)
|
|
11557
|
-
return -1;
|
|
11558
|
-
return 1;
|
|
11559
|
-
}).map((item) => __privateGet(this, _parseExpression).call(this, item, scope)).join("");
|
|
11560
|
-
case "UnaryExpression":
|
|
11561
|
-
const unaryValue = __privateGet(this, _parseExpression).call(this, expression.argument, scope);
|
|
11562
|
-
switch (expression.operator) {
|
|
11563
|
-
case "+":
|
|
11564
|
-
return +unaryValue;
|
|
11565
|
-
case "-":
|
|
11566
|
-
return -unaryValue;
|
|
11567
|
-
case "!":
|
|
11568
|
-
return !unaryValue;
|
|
11569
|
-
}
|
|
11570
|
-
return;
|
|
11571
|
-
case "ArrowFunctionExpression":
|
|
11572
|
-
if (expression.async || expression.generator) {
|
|
11573
|
-
(_b = (_a = this.props).onError) == null ? void 0 : _b.call(_a, new Error("Async and generator arrow functions are not supported."));
|
|
11574
|
-
}
|
|
11575
|
-
return (...args) => {
|
|
11576
|
-
const functionScope = { ...scope };
|
|
11577
|
-
expression.params.forEach((param, idx) => {
|
|
11578
|
-
functionScope[param.name] = args[idx];
|
|
11579
|
-
});
|
|
11580
|
-
return __privateGet(this, _parseExpression).call(this, expression.body, functionScope);
|
|
11581
|
-
};
|
|
11582
|
-
default:
|
|
11583
|
-
this.props.onError(new Error(`The expression type '${expression.type}' is not supported.`));
|
|
11520
|
+
this.props.onError(new Error(`The expression '${expression.callee}' could not be resolved, resulting in an undefined return value.`));
|
|
11584
11521
|
return;
|
|
11585
|
-
}
|
|
11586
|
-
});
|
|
11587
|
-
__privateAdd(this, _parseChainExpression, (expression, scope) => {
|
|
11588
|
-
try {
|
|
11589
|
-
return __privateGet(this, _parseExpression).call(this, expression.expression, scope);
|
|
11590
|
-
} catch (error) {
|
|
11591
|
-
if (error instanceof NullishShortCircuit)
|
|
11592
|
-
return;
|
|
11593
|
-
throw error;
|
|
11594
|
-
}
|
|
11595
|
-
});
|
|
11596
|
-
__privateAdd(this, _parseMemberExpression, (expression, scope) => {
|
|
11597
|
-
const object = __privateGet(this, _parseExpression).call(this, expression.object, scope);
|
|
11598
|
-
let property;
|
|
11599
|
-
if (expression.computed) {
|
|
11600
|
-
property = __privateGet(this, _parseExpression).call(this, expression.property, scope);
|
|
11601
|
-
} else if (expression.property.type === "Identifier") {
|
|
11602
|
-
property = expression.property.name;
|
|
11603
|
-
} else {
|
|
11604
|
-
this.props.onError(new Error("Only simple MemberExpressions are supported."));
|
|
11605
|
-
return;
|
|
11606
|
-
}
|
|
11607
|
-
if (object === null || object === void 0) {
|
|
11608
|
-
if (expression.optional)
|
|
11609
|
-
throw new NullishShortCircuit();
|
|
11610
|
-
}
|
|
11611
|
-
let member;
|
|
11612
|
-
try {
|
|
11613
|
-
member = object[property];
|
|
11614
|
-
} catch {
|
|
11615
|
-
this.props.onError(new Error(`The property '${property}' could not be resolved on the object '${object}'.`));
|
|
11616
|
-
return;
|
|
11617
|
-
}
|
|
11618
|
-
if (typeof member === "function")
|
|
11619
|
-
return member.bind(object);
|
|
11620
|
-
return member;
|
|
11621
|
-
});
|
|
11622
|
-
__privateAdd(this, _parseName, (element) => {
|
|
11623
|
-
if (element.type === "JSXIdentifier") {
|
|
11624
|
-
return element.name;
|
|
11625
|
-
}
|
|
11626
|
-
return `${__privateGet(this, _parseName).call(this, element.object)}.${__privateGet(this, _parseName).call(this, element.property)}`;
|
|
11627
|
-
});
|
|
11628
|
-
__privateAdd(this, _parseElement, (element, scope) => {
|
|
11629
|
-
const { allowUnknownElements, components, componentsOnly, onError } = this.props;
|
|
11630
|
-
const { children: childNodes = [] } = element;
|
|
11631
|
-
const openingTag = element.type === "JSXElement" ? element.openingElement : element.openingFragment;
|
|
11632
|
-
const { attributes = [] } = openingTag;
|
|
11633
|
-
const name = element.type === "JSXElement" ? __privateGet(this, _parseName).call(this, openingTag.name) : "";
|
|
11634
|
-
const blacklistedAttrs = (this.props.blacklistedAttrs || []).map((attr) => attr instanceof RegExp ? attr : new RegExp(attr, "i"));
|
|
11635
|
-
const blacklistedTags = (this.props.blacklistedTags || []).map((tag) => tag.trim().toLowerCase()).filter(Boolean);
|
|
11636
|
-
if (/^(html|head|body)$/i.test(name)) {
|
|
11637
|
-
return childNodes.map((c) => __privateGet(this, _parseElement).call(this, c, scope));
|
|
11638
|
-
}
|
|
11639
|
-
const tagName = name.trim().toLowerCase();
|
|
11640
|
-
if (blacklistedTags.indexOf(tagName) !== -1) {
|
|
11641
|
-
onError(new Error(`The tag <${name}> is blacklisted, and will not be rendered.`));
|
|
11642
|
-
return null;
|
|
11643
|
-
}
|
|
11644
|
-
if (name !== "" && !resolvePath(components, name)) {
|
|
11645
|
-
if (componentsOnly) {
|
|
11646
|
-
onError(new Error(`The component <${name}> is unrecognized, and will not be rendered.`));
|
|
11647
|
-
return this.props.renderUnrecognized(name);
|
|
11648
|
-
}
|
|
11649
|
-
if (!allowUnknownElements && document.createElement(name) instanceof HTMLUnknownElement) {
|
|
11650
|
-
onError(new Error(`The tag <${name}> is unrecognized in this browser, and will not be rendered.`));
|
|
11651
|
-
return this.props.renderUnrecognized(name);
|
|
11652
|
-
}
|
|
11653
|
-
}
|
|
11654
|
-
let children;
|
|
11655
|
-
let component = element.type === "JSXElement" ? resolvePath(components, name) : Fragment;
|
|
11656
|
-
if (component || canHaveChildren(name)) {
|
|
11657
|
-
children = childNodes.map((node) => __privateGet(this, _parseExpression).call(this, node, scope));
|
|
11658
|
-
if (name.includes(".")) {
|
|
11659
|
-
const nameParts = name.split(".");
|
|
11660
|
-
const componentPath = nameParts.reduce((acc, part) => acc ? acc[part] : components == null ? void 0 : components[part], null);
|
|
11661
|
-
if (componentPath) {
|
|
11662
|
-
component = componentPath;
|
|
11663
|
-
}
|
|
11664
11522
|
}
|
|
11665
|
-
|
|
11666
|
-
|
|
11523
|
+
return parsedCallee(...expression.arguments.map((arg) => this.#parseExpression(arg, scope)));
|
|
11524
|
+
case "ConditionalExpression":
|
|
11525
|
+
return this.#parseExpression(expression.test, scope) ? this.#parseExpression(expression.consequent, scope) : this.#parseExpression(expression.alternate, scope);
|
|
11526
|
+
case "ExpressionStatement":
|
|
11527
|
+
return this.#parseExpression(expression.expression, scope);
|
|
11528
|
+
case "Identifier":
|
|
11529
|
+
if (expression.name === "Infinity")
|
|
11530
|
+
return Infinity;
|
|
11531
|
+
if (expression.name === "-Infinity")
|
|
11532
|
+
return -Infinity;
|
|
11533
|
+
if (expression.name === "NaN")
|
|
11534
|
+
return NaN;
|
|
11535
|
+
if (scope && expression.name in scope) {
|
|
11536
|
+
return handleNaN(scope[expression.name]);
|
|
11537
|
+
}
|
|
11538
|
+
return handleNaN((this.props.bindings || {})[expression.name]);
|
|
11539
|
+
case "Literal":
|
|
11540
|
+
return expression.value;
|
|
11541
|
+
case "LogicalExpression":
|
|
11542
|
+
const left = this.#parseExpression(expression.left, scope);
|
|
11543
|
+
if (expression.operator === "||" && left)
|
|
11544
|
+
return left;
|
|
11545
|
+
if (expression.operator === "&&" && left || expression.operator === "||" && !left) {
|
|
11546
|
+
return this.#parseExpression(expression.right, scope);
|
|
11667
11547
|
}
|
|
11668
|
-
|
|
11669
|
-
|
|
11670
|
-
|
|
11671
|
-
|
|
11672
|
-
|
|
11673
|
-
|
|
11674
|
-
|
|
11675
|
-
|
|
11676
|
-
|
|
11548
|
+
return false;
|
|
11549
|
+
case "MemberExpression":
|
|
11550
|
+
return this.#parseMemberExpression(expression, scope);
|
|
11551
|
+
case "ChainExpression":
|
|
11552
|
+
return this.#parseChainExpression(expression, scope);
|
|
11553
|
+
case "ObjectExpression":
|
|
11554
|
+
const object = {};
|
|
11555
|
+
expression.properties.forEach((prop) => {
|
|
11556
|
+
object[prop.key.name || prop.key.value] = this.#parseExpression(prop.value, scope);
|
|
11557
|
+
});
|
|
11558
|
+
return object;
|
|
11559
|
+
case "TemplateElement":
|
|
11560
|
+
return expression.value.cooked;
|
|
11561
|
+
case "TemplateLiteral":
|
|
11562
|
+
return [...expression.expressions, ...expression.quasis].sort((a, b) => {
|
|
11563
|
+
if (a.start < b.start)
|
|
11564
|
+
return -1;
|
|
11565
|
+
return 1;
|
|
11566
|
+
}).map((item) => this.#parseExpression(item, scope)).join("");
|
|
11567
|
+
case "UnaryExpression":
|
|
11568
|
+
const unaryValue = this.#parseExpression(expression.argument, scope);
|
|
11569
|
+
switch (expression.operator) {
|
|
11570
|
+
case "+":
|
|
11571
|
+
return +unaryValue;
|
|
11572
|
+
case "-":
|
|
11573
|
+
return -unaryValue;
|
|
11574
|
+
case "!":
|
|
11575
|
+
return !unaryValue;
|
|
11677
11576
|
}
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
|
|
11681
|
-
|
|
11682
|
-
|
|
11683
|
-
|
|
11684
|
-
const
|
|
11685
|
-
|
|
11686
|
-
|
|
11687
|
-
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
|
|
11694
|
-
|
|
11695
|
-
|
|
11696
|
-
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
11577
|
+
return;
|
|
11578
|
+
case "ArrowFunctionExpression":
|
|
11579
|
+
if (expression.async || expression.generator) {
|
|
11580
|
+
this.props.onError?.(new Error("Async and generator arrow functions are not supported."));
|
|
11581
|
+
}
|
|
11582
|
+
return (...args) => {
|
|
11583
|
+
const functionScope = { ...scope };
|
|
11584
|
+
expression.params.forEach((param, idx) => {
|
|
11585
|
+
functionScope[param.name] = args[idx];
|
|
11586
|
+
});
|
|
11587
|
+
return this.#parseExpression(expression.body, functionScope);
|
|
11588
|
+
};
|
|
11589
|
+
default:
|
|
11590
|
+
this.props.onError(new Error(`The expression type '${expression.type}' is not supported.`));
|
|
11591
|
+
return;
|
|
11592
|
+
}
|
|
11593
|
+
};
|
|
11594
|
+
#parseChainExpression = (expression, scope) => {
|
|
11595
|
+
try {
|
|
11596
|
+
return this.#parseExpression(expression.expression, scope);
|
|
11597
|
+
} catch (error) {
|
|
11598
|
+
if (error instanceof NullishShortCircuit)
|
|
11599
|
+
return;
|
|
11600
|
+
throw error;
|
|
11601
|
+
}
|
|
11602
|
+
};
|
|
11603
|
+
#parseMemberExpression = (expression, scope) => {
|
|
11604
|
+
const object = this.#parseExpression(expression.object, scope);
|
|
11605
|
+
let property;
|
|
11606
|
+
if (expression.computed) {
|
|
11607
|
+
property = this.#parseExpression(expression.property, scope);
|
|
11608
|
+
} else if (expression.property.type === "Identifier") {
|
|
11609
|
+
property = expression.property.name;
|
|
11610
|
+
} else {
|
|
11611
|
+
this.props.onError(new Error("Only simple MemberExpressions are supported."));
|
|
11612
|
+
return;
|
|
11613
|
+
}
|
|
11614
|
+
if (object === null || object === void 0) {
|
|
11615
|
+
if (expression.optional)
|
|
11616
|
+
throw new NullishShortCircuit();
|
|
11617
|
+
}
|
|
11618
|
+
let member;
|
|
11619
|
+
try {
|
|
11620
|
+
member = object[property];
|
|
11621
|
+
} catch {
|
|
11622
|
+
this.props.onError(new Error(`The property '${property}' could not be resolved on the object '${object}'.`));
|
|
11623
|
+
return;
|
|
11624
|
+
}
|
|
11625
|
+
if (typeof member === "function")
|
|
11626
|
+
return member.bind(object);
|
|
11627
|
+
return member;
|
|
11628
|
+
};
|
|
11629
|
+
#parseName = (element) => {
|
|
11630
|
+
if (element.type === "JSXIdentifier") {
|
|
11631
|
+
return element.name;
|
|
11632
|
+
}
|
|
11633
|
+
return `${this.#parseName(element.object)}.${this.#parseName(element.property)}`;
|
|
11634
|
+
};
|
|
11635
|
+
#parseElement = (element, scope) => {
|
|
11636
|
+
const { allowUnknownElements, components, componentsOnly, onError } = this.props;
|
|
11637
|
+
const { children: childNodes = [] } = element;
|
|
11638
|
+
const openingTag = element.type === "JSXElement" ? element.openingElement : element.openingFragment;
|
|
11639
|
+
const { attributes = [] } = openingTag;
|
|
11640
|
+
const name = element.type === "JSXElement" ? this.#parseName(openingTag.name) : "";
|
|
11641
|
+
const blacklistedAttrs = (this.props.blacklistedAttrs || []).map((attr) => attr instanceof RegExp ? attr : new RegExp(attr, "i"));
|
|
11642
|
+
const blacklistedTags = (this.props.blacklistedTags || []).map((tag) => tag.trim().toLowerCase()).filter(Boolean);
|
|
11643
|
+
if (/^(html|head|body)$/i.test(name)) {
|
|
11644
|
+
return childNodes.map((c) => this.#parseElement(c, scope));
|
|
11645
|
+
}
|
|
11646
|
+
const tagName = name.trim().toLowerCase();
|
|
11647
|
+
if (blacklistedTags.indexOf(tagName) !== -1) {
|
|
11648
|
+
onError(new Error(`The tag <${name}> is blacklisted, and will not be rendered.`));
|
|
11649
|
+
return null;
|
|
11650
|
+
}
|
|
11651
|
+
if (name !== "" && !resolvePath(components, name)) {
|
|
11652
|
+
if (componentsOnly) {
|
|
11653
|
+
onError(new Error(`The component <${name}> is unrecognized, and will not be rendered.`));
|
|
11654
|
+
return this.props.renderUnrecognized(name);
|
|
11655
|
+
}
|
|
11656
|
+
if (!allowUnknownElements && document.createElement(name) instanceof HTMLUnknownElement) {
|
|
11657
|
+
onError(new Error(`The tag <${name}> is unrecognized in this browser, and will not be rendered.`));
|
|
11658
|
+
return this.props.renderUnrecognized(name);
|
|
11659
|
+
}
|
|
11660
|
+
}
|
|
11661
|
+
let children;
|
|
11662
|
+
let component = element.type === "JSXElement" ? resolvePath(components, name) : Fragment;
|
|
11663
|
+
if (component || canHaveChildren(name)) {
|
|
11664
|
+
children = childNodes.map((node) => this.#parseExpression(node, scope));
|
|
11665
|
+
if (name.includes(".")) {
|
|
11666
|
+
const nameParts = name.split(".");
|
|
11667
|
+
const componentPath = nameParts.reduce((acc, part) => acc ? acc[part] : components?.[part], null);
|
|
11668
|
+
if (componentPath) {
|
|
11669
|
+
component = componentPath;
|
|
11670
|
+
}
|
|
11671
|
+
}
|
|
11672
|
+
if (!component && !canHaveWhitespace(name)) {
|
|
11673
|
+
children = children.filter((child) => typeof child !== "string" || !/^\s*$/.test(child));
|
|
11674
|
+
}
|
|
11675
|
+
const childFn = children.find((child) => typeof child === "function");
|
|
11676
|
+
if (children.length === 0) {
|
|
11677
|
+
children = void 0;
|
|
11678
|
+
} else if (childFn) {
|
|
11679
|
+
children = childFn;
|
|
11680
|
+
} else if (children.length === 1) {
|
|
11681
|
+
[children] = children;
|
|
11682
|
+
} else if (children.length > 1 && !this.props.disableKeyGeneration) {
|
|
11683
|
+
children = children.map((child, key) => child?.type && !child?.key ? { ...child, key: child.key || key } : child);
|
|
11684
|
+
}
|
|
11685
|
+
}
|
|
11686
|
+
const props = {
|
|
11687
|
+
key: this.props.disableKeyGeneration ? void 0 : randomHash()
|
|
11688
|
+
};
|
|
11689
|
+
attributes.forEach((expr) => {
|
|
11690
|
+
if (expr.type === "JSXAttribute") {
|
|
11691
|
+
const rawName = expr.name.name;
|
|
11692
|
+
const attributeName = attributeNames_default[rawName] || rawName;
|
|
11693
|
+
const value = this.#parseExpression(expr, scope);
|
|
11694
|
+
const matches = blacklistedAttrs.filter((re) => re.test(attributeName));
|
|
11695
|
+
if (matches.length === 0) {
|
|
11696
|
+
props[attributeName] = value;
|
|
11697
|
+
}
|
|
11698
|
+
} else if (expr.type === "JSXSpreadAttribute" && expr.argument.type === "Identifier" || expr.argument.type === "MemberExpression") {
|
|
11699
|
+
const value = this.#parseExpression(expr.argument, scope);
|
|
11700
|
+
if (typeof value === "object") {
|
|
11701
|
+
Object.keys(value).forEach((rawName) => {
|
|
11702
|
+
const attributeName = attributeNames_default[rawName] || rawName;
|
|
11703
|
+
const matches = blacklistedAttrs.filter((re) => re.test(attributeName));
|
|
11704
|
+
if (matches.length === 0) {
|
|
11705
|
+
props[attributeName] = value[rawName];
|
|
11706
|
+
}
|
|
11707
|
+
});
|
|
11702
11708
|
}
|
|
11703
|
-
});
|
|
11704
|
-
if (typeof props.style === "string") {
|
|
11705
|
-
props.style = parseStyle(props.style);
|
|
11706
|
-
}
|
|
11707
|
-
const lowerName = name.toLowerCase();
|
|
11708
|
-
if (lowerName === "option") {
|
|
11709
|
-
children = children.props.children;
|
|
11710
11709
|
}
|
|
11711
|
-
return React__default.createElement(component || lowerName, props, children);
|
|
11712
11710
|
});
|
|
11713
|
-
|
|
11711
|
+
if (typeof props.style === "string") {
|
|
11712
|
+
props.style = parseStyle(props.style);
|
|
11713
|
+
}
|
|
11714
|
+
const lowerName = name.toLowerCase();
|
|
11715
|
+
if (lowerName === "option") {
|
|
11716
|
+
children = children.props.children;
|
|
11717
|
+
}
|
|
11718
|
+
return React__default.createElement(component || lowerName, props, children);
|
|
11719
|
+
};
|
|
11714
11720
|
render() {
|
|
11715
11721
|
const jsx = (this.props.jsx || "").trim().replace(/<!DOCTYPE([^>]*)>/g, "");
|
|
11716
|
-
this.ParsedChildren =
|
|
11722
|
+
this.ParsedChildren = this.#parseJSX(jsx);
|
|
11717
11723
|
const className = [.../* @__PURE__ */ new Set(["jsx-parser", ...String(this.props.className).split(" ")])].filter(Boolean).join(" ");
|
|
11718
11724
|
return this.props.renderInWrapper ? /* @__PURE__ */ React__default.createElement("div", {
|
|
11719
11725
|
className
|
|
11720
11726
|
}, this.ParsedChildren) : this.ParsedChildren;
|
|
11721
11727
|
}
|
|
11722
11728
|
}
|
|
11723
|
-
_parseJSX = new WeakMap();
|
|
11724
|
-
_parseExpression = new WeakMap();
|
|
11725
|
-
_parseChainExpression = new WeakMap();
|
|
11726
|
-
_parseMemberExpression = new WeakMap();
|
|
11727
|
-
_parseName = new WeakMap();
|
|
11728
|
-
_parseElement = new WeakMap();
|
|
11729
|
-
__publicField(JsxParser, "displayName", "JsxParser");
|
|
11730
|
-
__publicField(JsxParser, "defaultProps", {
|
|
11731
|
-
allowUnknownElements: true,
|
|
11732
|
-
autoCloseVoidElements: false,
|
|
11733
|
-
bindings: {},
|
|
11734
|
-
blacklistedAttrs: [/^on.+/i],
|
|
11735
|
-
blacklistedTags: ["script"],
|
|
11736
|
-
className: "",
|
|
11737
|
-
components: {},
|
|
11738
|
-
componentsOnly: false,
|
|
11739
|
-
disableFragments: false,
|
|
11740
|
-
disableKeyGeneration: false,
|
|
11741
|
-
jsx: "",
|
|
11742
|
-
onError: () => {
|
|
11743
|
-
},
|
|
11744
|
-
showWarnings: false,
|
|
11745
|
-
renderError: void 0,
|
|
11746
|
-
renderInWrapper: true,
|
|
11747
|
-
renderUnrecognized: () => null
|
|
11748
|
-
});
|
|
11749
11729
|
var source_default = JsxParser;
|
|
11750
11730
|
export {
|
|
11751
11731
|
source_default as a,
|