chunk-2TTT3V5O.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // node_modules/@esri/calcite-components/dist/components/guid.js
  2. function gen(counts) {
  3. return counts.map((count) => {
  4. let out = "";
  5. for (let i = 0; i < count; i++) {
  6. out += ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
  7. }
  8. return out;
  9. }).join("-");
  10. }
  11. var guid = () => gen([2, 1, 1, 1, 3]);
  12. // node_modules/@esri/calcite-components/dist/components/dom.js
  13. var autoTheme = "calcite-theme-auto";
  14. var darkTheme = "calcite-theme-dark";
  15. function getElementDir(el) {
  16. const prop = "dir";
  17. const selector = `[${prop}]`;
  18. const closest = closestElementCrossShadowBoundary(el, selector);
  19. return closest ? closest.getAttribute(prop) : "ltr";
  20. }
  21. function getRootNode(el) {
  22. return el.getRootNode();
  23. }
  24. function getHost(root) {
  25. return root.host || null;
  26. }
  27. function queryElementRoots(element, { selector, id }) {
  28. function queryFrom(el) {
  29. if (!el) {
  30. return null;
  31. }
  32. if (el.assignedSlot) {
  33. el = el.assignedSlot;
  34. }
  35. const rootNode = getRootNode(el);
  36. const found = id ? "getElementById" in rootNode ? rootNode.getElementById(id) : null : selector ? rootNode.querySelector(selector) : null;
  37. const host = getHost(rootNode);
  38. return found ? found : host ? queryFrom(host) : null;
  39. }
  40. return queryFrom(element);
  41. }
  42. function closestElementCrossShadowBoundary(element, selector) {
  43. function closestFrom(el) {
  44. return el ? el.closest(selector) || closestFrom(getHost(getRootNode(el))) : null;
  45. }
  46. return closestFrom(element);
  47. }
  48. function isCalciteFocusable(el) {
  49. return typeof (el === null || el === void 0 ? void 0 : el.setFocus) === "function";
  50. }
  51. async function focusElement(el) {
  52. if (!el) {
  53. return;
  54. }
  55. return isCalciteFocusable(el) ? el.setFocus() : el.focus();
  56. }
  57. var defaultSlotSelector = ":not([slot])";
  58. function getSlotted(element, slotName, options) {
  59. if (slotName && !Array.isArray(slotName) && typeof slotName !== "string") {
  60. options = slotName;
  61. slotName = null;
  62. }
  63. const slotSelector = slotName ? Array.isArray(slotName) ? slotName.map((name) => `[slot="${name}"]`).join(",") : `[slot="${slotName}"]` : defaultSlotSelector;
  64. if (options === null || options === void 0 ? void 0 : options.all) {
  65. return queryMultiple(element, slotSelector, options);
  66. }
  67. return querySingle(element, slotSelector, options);
  68. }
  69. function getDirectChildren(el, selector) {
  70. return el ? Array.from(el.children || []).filter((child) => child === null || child === void 0 ? void 0 : child.matches(selector)) : [];
  71. }
  72. function queryMultiple(element, slotSelector, options) {
  73. let matches = slotSelector === defaultSlotSelector ? getDirectChildren(element, defaultSlotSelector) : Array.from(element.querySelectorAll(slotSelector));
  74. matches = options && options.direct === false ? matches : matches.filter((el) => el.parentElement === element);
  75. matches = (options === null || options === void 0 ? void 0 : options.matches) ? matches.filter((el) => el === null || el === void 0 ? void 0 : el.matches(options.matches)) : matches;
  76. const selector = options === null || options === void 0 ? void 0 : options.selector;
  77. return selector ? matches.map((item) => Array.from(item.querySelectorAll(selector))).reduce((previousValue, currentValue) => [...previousValue, ...currentValue], []).filter((match) => !!match) : matches;
  78. }
  79. function querySingle(element, slotSelector, options) {
  80. let match = slotSelector === defaultSlotSelector ? getDirectChildren(element, defaultSlotSelector)[0] || null : element.querySelector(slotSelector);
  81. match = options && options.direct === false ? match : (match === null || match === void 0 ? void 0 : match.parentElement) === element ? match : null;
  82. match = (options === null || options === void 0 ? void 0 : options.matches) ? (match === null || match === void 0 ? void 0 : match.matches(options.matches)) ? match : null : match;
  83. const selector = options === null || options === void 0 ? void 0 : options.selector;
  84. return selector ? match === null || match === void 0 ? void 0 : match.querySelector(selector) : match;
  85. }
  86. function setRequestedIcon(iconObject, iconValue, matchedValue) {
  87. if (typeof iconValue === "string" && iconValue !== "") {
  88. return iconValue;
  89. } else if (iconValue === "") {
  90. return iconObject[matchedValue];
  91. }
  92. }
  93. function toAriaBoolean(value) {
  94. return Boolean(value).toString();
  95. }
  96. function isPrimaryPointerButton(event) {
  97. return !!(event.isPrimary && event.button === 0);
  98. }
  99. export {
  100. guid,
  101. autoTheme,
  102. darkTheme,
  103. getElementDir,
  104. queryElementRoots,
  105. closestElementCrossShadowBoundary,
  106. focusElement,
  107. getSlotted,
  108. setRequestedIcon,
  109. toAriaBoolean,
  110. isPrimaryPointerButton
  111. };
  112. /*!
  113. * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  114. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
  115. * v1.0.0-beta.97
  116. */
  117. //# sourceMappingURL=chunk-2TTT3V5O.js.map