@eightshift/ui-components 5.0.10 → 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.
Files changed (83) hide show
  1. package/dist/{Collection-uTAXq9Br.js → Collection-BRJOMbOa.js} +12 -7
  2. package/dist/{Dialog-CmAxaSUv.js → Dialog-D6EdDPeu.js} +8 -8
  3. package/dist/{useFormValidation-Dy0PXJg5.js → Form-Bnyyv3Im.js} +6 -4
  4. package/dist/{Group-DDPhPPTQ.js → Group-LBogWgyp.js} +2 -2
  5. package/dist/{Input-BmDS8Juy.js → Input-DfSBLhDx.js} +1 -1
  6. package/dist/List-BLeHBkfx.js +590 -0
  7. package/dist/{ListBox-_nDFq8-H.js → ListBox-BY3gwI8c.js} +3 -3
  8. package/dist/Select-BebwUgKB.js +764 -0
  9. package/dist/Separator-CTQWg_HO.js +1111 -0
  10. package/dist/TextField-o2U-uBWv.js +133 -0
  11. package/dist/assets/style-admin.css +268 -150
  12. package/dist/assets/style-editor.css +268 -150
  13. package/dist/assets/style.css +268 -150
  14. package/dist/assets/wp-font-enhancements.css +1 -1
  15. package/dist/assets/wp-ui-enhancements.css +1 -1
  16. package/dist/components/breakpoint-preview/breakpoint-preview.js +3 -4
  17. package/dist/components/button/button.js +3 -3
  18. package/dist/components/checkbox/checkbox.js +1 -2
  19. package/dist/components/color-pickers/color-picker.js +7 -9
  20. package/dist/components/color-pickers/color-swatch.js +1 -1
  21. package/dist/components/color-pickers/gradient-editor.js +19 -25
  22. package/dist/components/color-pickers/solid-color-picker.js +27 -27
  23. package/dist/components/component-toggle/component-toggle.js +1 -1
  24. package/dist/components/draggable/draggable-handle.js +2 -2
  25. package/dist/components/draggable/draggable.js +5 -5
  26. package/dist/components/draggable-list/draggable-list-item.js +2 -2
  27. package/dist/components/draggable-list/draggable-list.js +5 -5
  28. package/dist/components/expandable/expandable.js +1 -1
  29. package/dist/components/index.js +5 -5
  30. package/dist/components/input-field/input-field.js +13 -129
  31. package/dist/components/item-collection/item-collection.js +1 -1
  32. package/dist/components/link-input/link-input.js +1463 -17
  33. package/dist/components/matrix-align/matrix-align.js +11 -14
  34. package/dist/components/menu/menu.js +4 -8
  35. package/dist/components/modal/modal.js +3 -3
  36. package/dist/components/number-picker/number-picker.js +9 -10
  37. package/dist/components/option-select/option-select.js +140 -156
  38. package/dist/components/placeholders/file-placeholder.js +1 -1
  39. package/dist/components/placeholders/image-placeholder.js +3 -3
  40. package/dist/components/placeholders/media-placeholder.js +2 -2
  41. package/dist/components/popover/popover.js +10 -5
  42. package/dist/components/radio/radio.js +4 -5
  43. package/dist/components/repeater/repeater-item.js +1 -1
  44. package/dist/components/repeater/repeater.js +6 -6
  45. package/dist/components/responsive/mini-responsive.js +45 -47
  46. package/dist/components/responsive/responsive-legacy.js +51 -55
  47. package/dist/components/responsive/responsive.js +47 -49
  48. package/dist/components/responsive-preview/responsive-preview.js +12 -15
  49. package/dist/components/select/async-multi-select.js +4 -4
  50. package/dist/components/select/async-single-select.js +1 -1
  51. package/dist/components/select/multi-select-components.js +1 -1
  52. package/dist/components/select/multi-select.js +4 -4
  53. package/dist/components/select/shared.js +2 -2
  54. package/dist/components/select/single-select.js +1 -1
  55. package/dist/components/select/styles.js +3 -3
  56. package/dist/components/select/v2/async-select.js +215 -158
  57. package/dist/components/select/v2/shared.js +29 -20
  58. package/dist/components/select/v2/single-select.js +202 -851
  59. package/dist/components/slider/column-config-slider.js +2 -2
  60. package/dist/components/slider/slider.js +2 -2
  61. package/dist/components/slider/utils.js +1 -1
  62. package/dist/components/tabs/tabs.js +7 -8
  63. package/dist/components/toggle/switch.js +4 -3
  64. package/dist/components/toggle-button/toggle-button.js +1 -1
  65. package/dist/{default-i18n-CT_oS1Fy.js → default-i18n-OFa3zAyB.js} +5 -9
  66. package/dist/icons/jsx-svg.js +3 -4
  67. package/dist/index.js +4 -4
  68. package/dist/{multi-select-components-Sp-JEFEX.js → multi-select-components-BcKzA24f.js} +3 -3
  69. package/dist/{react-jsx-parser.min-DZCiis5V.js → react-jsx-parser.min-LF707GK8.js} +312 -332
  70. package/dist/useAsyncList-fLtZMvJO.js +420 -0
  71. package/dist/useFilter-BR5z1A4Q.js +50 -0
  72. package/dist/{useListState-9Hq_FiRF.js → useListState-BrZ2XvDS.js} +1 -1
  73. package/dist/{useNumberField-D0u2bh8g.js → useNumberField-y0dLc_6m.js} +2 -2
  74. package/dist/{useSingleSelectListState-DqhemUIh.js → useSingleSelectListState-Bh46cRXs.js} +1 -1
  75. package/dist/utilities/array-helpers.js +4 -7
  76. package/dist/utilities/es-dash.js +21 -3
  77. package/dist/utilities/index.js +2 -1
  78. package/dist/utilities/text-helpers.js +3 -3
  79. package/package.json +9 -9
  80. package/dist/ComboBox-BANSEKnb.js +0 -1915
  81. package/dist/Form-Cq3fu75_.js +0 -5
  82. package/dist/List-CZMUbkFU.js +0 -593
  83. 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 __defProp2 = Object.defineProperty;
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 = __defProp2(target, "default", { value: mod, enumerable: true });
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
- __defProp2(to, key, {
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
- constructor() {
11413
- super(...arguments);
11414
- __publicField(this, "ParsedChildren", null);
11415
- __privateAdd(this, _parseJSX, (jsx) => {
11416
- const parser = Parser.extend(AcornJSX.default({
11417
- autoCloseVoidElements: this.props.autoCloseVoidElements
11418
- }));
11419
- const wrappedJsx = `<root>${jsx}</root>`;
11420
- let parsed = [];
11421
- try {
11422
- parsed = parser.parse(wrappedJsx, { ecmaVersion: "latest" });
11423
- parsed = parsed.body[0].expression.children || [];
11424
- } catch (error) {
11425
- if (this.props.showWarnings)
11426
- console.warn(error);
11427
- if (this.props.onError)
11428
- this.props.onError(error);
11429
- if (this.props.renderError) {
11430
- return this.props.renderError({ error: String(error) });
11431
- }
11432
- return null;
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 parsed.map((p) => __privateGet(this, _parseExpression).call(this, p)).filter(Boolean);
11435
- });
11436
- __privateAdd(this, _parseExpression, (expression, scope) => {
11437
- var _a, _b;
11438
- switch (expression.type) {
11439
- case "JSXAttribute":
11440
- if (expression.value === null)
11441
- return true;
11442
- return __privateGet(this, _parseExpression).call(this, expression.value, scope);
11443
- case "JSXElement":
11444
- case "JSXFragment":
11445
- return __privateGet(this, _parseElement).call(this, expression, scope);
11446
- case "JSXExpressionContainer":
11447
- return __privateGet(this, _parseExpression).call(this, expression.expression, scope);
11448
- case "JSXText":
11449
- const key = this.props.disableKeyGeneration ? void 0 : randomHash();
11450
- return this.props.disableFragments ? expression.value : /* @__PURE__ */ React__default.createElement(Fragment, {
11451
- key
11452
- }, expression.value);
11453
- case "ArrayExpression":
11454
- return expression.elements.map((ele) => __privateGet(this, _parseExpression).call(this, ele, scope));
11455
- case "BinaryExpression":
11456
- const binaryLeft = __privateGet(this, _parseExpression).call(this, expression.left, scope);
11457
- const binaryRight = __privateGet(this, _parseExpression).call(this, expression.right, scope);
11458
- let binaryResult;
11459
- switch (expression.operator) {
11460
- case "-":
11461
- binaryResult = binaryLeft - binaryRight;
11462
- break;
11463
- case "!=":
11464
- binaryResult = binaryLeft != binaryRight;
11465
- break;
11466
- case "!==":
11467
- binaryResult = binaryLeft !== binaryRight;
11468
- break;
11469
- case "*":
11470
- binaryResult = binaryLeft * binaryRight;
11471
- break;
11472
- case "**":
11473
- binaryResult = binaryLeft ** binaryRight;
11474
- break;
11475
- case "/":
11476
- binaryResult = binaryLeft / binaryRight;
11477
- break;
11478
- case "%":
11479
- binaryResult = binaryLeft % binaryRight;
11480
- break;
11481
- case "+":
11482
- binaryResult = binaryLeft + binaryRight;
11483
- break;
11484
- case "<":
11485
- binaryResult = binaryLeft < binaryRight;
11486
- break;
11487
- case "<=":
11488
- binaryResult = binaryLeft <= binaryRight;
11489
- break;
11490
- case "==":
11491
- binaryResult = binaryLeft == binaryRight;
11492
- break;
11493
- case "===":
11494
- binaryResult = binaryLeft === binaryRight;
11495
- break;
11496
- case ">":
11497
- binaryResult = binaryLeft > binaryRight;
11498
- break;
11499
- case ">=":
11500
- binaryResult = binaryLeft >= binaryRight;
11501
- break;
11502
- default:
11503
- this.props.onError(new Error(`Unsupported binary operator: ${expression.operator}`));
11504
- return;
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
- return parsedCallee(...expression.arguments.map((arg) => __privateGet(this, _parseExpression).call(this, arg, scope)));
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
- if (!component && !canHaveWhitespace(name)) {
11666
- children = children.filter((child) => typeof child !== "string" || !/^\s*$/.test(child));
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
- const childFn = children.find((child) => typeof child === "function");
11669
- if (children.length === 0) {
11670
- children = void 0;
11671
- } else if (childFn) {
11672
- children = childFn;
11673
- } else if (children.length === 1) {
11674
- [children] = children;
11675
- } else if (children.length > 1 && !this.props.disableKeyGeneration) {
11676
- children = children.map((child, key) => (child == null ? void 0 : child.type) && !(child == null ? void 0 : child.key) ? { ...child, key: child.key || key } : child);
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
- const props = {
11680
- key: this.props.disableKeyGeneration ? void 0 : randomHash()
11681
- };
11682
- attributes.forEach((expr) => {
11683
- if (expr.type === "JSXAttribute") {
11684
- const rawName = expr.name.name;
11685
- const attributeName = attributeNames_default[rawName] || rawName;
11686
- const value = __privateGet(this, _parseExpression).call(this, expr, scope);
11687
- const matches = blacklistedAttrs.filter((re) => re.test(attributeName));
11688
- if (matches.length === 0) {
11689
- props[attributeName] = value;
11690
- }
11691
- } else if (expr.type === "JSXSpreadAttribute" && expr.argument.type === "Identifier" || expr.argument.type === "MemberExpression") {
11692
- const value = __privateGet(this, _parseExpression).call(this, expr.argument, scope);
11693
- if (typeof value === "object") {
11694
- Object.keys(value).forEach((rawName) => {
11695
- const attributeName = attributeNames_default[rawName] || rawName;
11696
- const matches = blacklistedAttrs.filter((re) => re.test(attributeName));
11697
- if (matches.length === 0) {
11698
- props[attributeName] = value[rawName];
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 = __privateGet(this, _parseJSX).call(this, jsx);
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,