@quartzds/core 1.0.0-beta.124 → 1.0.0-beta.125

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 (125) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/components/{p-D5u-bDNf.js → p-2tdMcXmA.js} +3 -3
  3. package/components/{p-D5u-bDNf.js.map → p-2tdMcXmA.js.map} +1 -1
  4. package/components/{p-BxrR19WD.js → p-BRpaYGSM.js} +3 -3
  5. package/components/{p-BxrR19WD.js.map → p-BRpaYGSM.js.map} +1 -1
  6. package/components/{p-BGAgQ6J5.js → p-B_CYrw-t.js} +3 -3
  7. package/components/{p-BGAgQ6J5.js.map → p-B_CYrw-t.js.map} +1 -1
  8. package/components/{p-BPNu4xuI.js → p-BuCcV5P1.js} +5 -5
  9. package/components/p-BuCcV5P1.js.map +1 -0
  10. package/components/{p-DVXvtEPn.js → p-CG_jPYOl.js} +5 -5
  11. package/components/{p-DVXvtEPn.js.map → p-CG_jPYOl.js.map} +1 -1
  12. package/components/p-CaibVX_2.js +3539 -0
  13. package/components/p-CaibVX_2.js.map +1 -0
  14. package/components/{p-CsIsG3ra.js → p-CgQQYnEy.js} +5 -5
  15. package/components/p-CgQQYnEy.js.map +1 -0
  16. package/components/{p-De7cAKF1.js → p-DTMrBXCl.js} +3 -3
  17. package/components/{p-De7cAKF1.js.map → p-DTMrBXCl.js.map} +1 -1
  18. package/components/{p-Vtb6GsBy.js → p-ox2syNht.js} +3 -3
  19. package/components/{p-Vtb6GsBy.js.map → p-ox2syNht.js.map} +1 -1
  20. package/components/qds-action-item.js +2 -2
  21. package/components/qds-breadcrumb-item.js +2 -2
  22. package/components/qds-button.js +3 -3
  23. package/components/qds-checkbox.js +1 -1
  24. package/components/qds-chip.js +4 -4
  25. package/components/qds-chip.js.map +1 -1
  26. package/components/qds-dialog.js +4 -4
  27. package/components/qds-dialog.js.map +1 -1
  28. package/components/qds-dropdown.js +1 -1
  29. package/components/qds-icon-button.js +1 -1
  30. package/components/qds-icon-tab.js +3 -3
  31. package/components/qds-inline-link.js +1 -1
  32. package/components/qds-input.js +3 -3
  33. package/components/qds-label.js +2 -2
  34. package/components/qds-list-item.js +6 -6
  35. package/components/qds-menu-item.js +4 -4
  36. package/components/qds-menu-item.js.map +1 -1
  37. package/components/qds-mini-button.js +1 -1
  38. package/components/qds-radio.js +1 -1
  39. package/components/qds-select.js +2 -2
  40. package/components/qds-standalone-link.js +1 -1
  41. package/components/qds-switch.js +2 -2
  42. package/components/qds-switch.js.map +1 -1
  43. package/components/qds-tab.js +3 -3
  44. package/components/qds-tabbar.js +6 -6
  45. package/components/qds-tabbar.js.map +1 -1
  46. package/components/qds-tag.js +1 -1
  47. package/components/qds-textarea.js +1 -1
  48. package/components/qds-title.js +1 -1
  49. package/components/qds-tooltip.js +1 -1
  50. package/dist/cjs/helpers-DjUgyTKn.js +3559 -0
  51. package/dist/cjs/helpers-DjUgyTKn.js.map +1 -0
  52. package/dist/cjs/qds-action-item.cjs.entry.js +1 -1
  53. package/dist/cjs/qds-avatar-media.qds-checkbox.qds-radio.entry.cjs.js.map +1 -1
  54. package/dist/cjs/qds-avatar-media_3.cjs.entry.js +3 -3
  55. package/dist/cjs/qds-breadcrumb-item.cjs.entry.js +1 -1
  56. package/dist/cjs/qds-button.cjs.entry.js +2 -2
  57. package/dist/cjs/qds-chip.cjs.entry.js +2 -2
  58. package/dist/cjs/qds-chip.entry.cjs.js.map +1 -1
  59. package/dist/cjs/qds-dialog.cjs.entry.js +2 -2
  60. package/dist/cjs/qds-dialog.entry.cjs.js.map +1 -1
  61. package/dist/cjs/qds-divider_2.cjs.entry.js +2 -2
  62. package/dist/cjs/qds-dropdown.cjs.entry.js +1 -1
  63. package/dist/cjs/qds-icon-tab.cjs.entry.js +1 -1
  64. package/dist/cjs/qds-inline-link.cjs.entry.js +1 -1
  65. package/dist/cjs/qds-input.cjs.entry.js +2 -2
  66. package/dist/cjs/qds-label.cjs.entry.js +1 -1
  67. package/dist/cjs/qds-list-item.cjs.entry.js +1 -1
  68. package/dist/cjs/qds-menu-item.cjs.entry.js +2 -2
  69. package/dist/cjs/qds-menu-item.entry.cjs.js.map +1 -1
  70. package/dist/cjs/qds-mini-button.cjs.entry.js +1 -1
  71. package/dist/cjs/qds-select.cjs.entry.js +2 -2
  72. package/dist/cjs/qds-standalone-link.cjs.entry.js +1 -1
  73. package/dist/cjs/qds-switch.cjs.entry.js +2 -2
  74. package/dist/cjs/qds-switch.entry.cjs.js.map +1 -1
  75. package/dist/cjs/qds-tab.cjs.entry.js +1 -1
  76. package/dist/cjs/qds-tabbar.cjs.entry.js +4 -4
  77. package/dist/cjs/qds-tabbar.entry.cjs.js.map +1 -1
  78. package/dist/cjs/qds-tag.cjs.entry.js +1 -1
  79. package/dist/cjs/qds-textarea.cjs.entry.js +1 -1
  80. package/dist/cjs/qds-title.cjs.entry.js +1 -1
  81. package/dist/cjs/qds-tooltip.cjs.entry.js +1 -1
  82. package/dist/docs.json +1 -1
  83. package/dist/esm/helpers-mPQzhx-O.js +3539 -0
  84. package/dist/esm/helpers-mPQzhx-O.js.map +1 -0
  85. package/dist/esm/qds-action-item.entry.js +1 -1
  86. package/dist/esm/qds-avatar-media.qds-checkbox.qds-radio.entry.js.map +1 -1
  87. package/dist/esm/qds-avatar-media_3.entry.js +3 -3
  88. package/dist/esm/qds-breadcrumb-item.entry.js +1 -1
  89. package/dist/esm/qds-button.entry.js +2 -2
  90. package/dist/esm/qds-chip.entry.js +2 -2
  91. package/dist/esm/qds-chip.entry.js.map +1 -1
  92. package/dist/esm/qds-dialog.entry.js +2 -2
  93. package/dist/esm/qds-dialog.entry.js.map +1 -1
  94. package/dist/esm/qds-divider_2.entry.js +2 -2
  95. package/dist/esm/qds-dropdown.entry.js +1 -1
  96. package/dist/esm/qds-icon-tab.entry.js +1 -1
  97. package/dist/esm/qds-inline-link.entry.js +1 -1
  98. package/dist/esm/qds-input.entry.js +2 -2
  99. package/dist/esm/qds-label.entry.js +1 -1
  100. package/dist/esm/qds-list-item.entry.js +1 -1
  101. package/dist/esm/qds-menu-item.entry.js +2 -2
  102. package/dist/esm/qds-menu-item.entry.js.map +1 -1
  103. package/dist/esm/qds-mini-button.entry.js +1 -1
  104. package/dist/esm/qds-select.entry.js +2 -2
  105. package/dist/esm/qds-standalone-link.entry.js +1 -1
  106. package/dist/esm/qds-switch.entry.js +2 -2
  107. package/dist/esm/qds-switch.entry.js.map +1 -1
  108. package/dist/esm/qds-tab.entry.js +1 -1
  109. package/dist/esm/qds-tabbar.entry.js +4 -4
  110. package/dist/esm/qds-tabbar.entry.js.map +1 -1
  111. package/dist/esm/qds-tag.entry.js +1 -1
  112. package/dist/esm/qds-textarea.entry.js +1 -1
  113. package/dist/esm/qds-title.entry.js +1 -1
  114. package/dist/esm/qds-tooltip.entry.js +1 -1
  115. package/hydrate/index.js +3270 -25
  116. package/hydrate/index.mjs +3270 -25
  117. package/package.json +2 -1
  118. package/components/p-BPNu4xuI.js.map +0 -1
  119. package/components/p-Bm_hrsjc.js +0 -294
  120. package/components/p-Bm_hrsjc.js.map +0 -1
  121. package/components/p-CsIsG3ra.js.map +0 -1
  122. package/dist/cjs/helpers-CPSgo4Ef.js +0 -314
  123. package/dist/cjs/helpers-CPSgo4Ef.js.map +0 -1
  124. package/dist/esm/helpers-JWnSavo8.js +0 -294
  125. package/dist/esm/helpers-JWnSavo8.js.map +0 -1
@@ -1,314 +0,0 @@
1
- /*!
2
- * SPDX-FileCopyrightText: © 2026 Schneider Electric
3
- *
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- 'use strict';
7
-
8
- // SPDX-FileCopyrightText: © 2024 Schneider Electric
9
- //
10
- // SPDX-License-Identifier: Apache-2.0
11
- const inheritAttributes = (element, attributes = []) => {
12
- const attributeObject = {};
13
- for (const attribute of attributes) {
14
- const value = element.getAttribute(attribute);
15
- if (value !== null) {
16
- attributeObject[attribute] = value;
17
- element.removeAttribute(attribute);
18
- }
19
- }
20
- return attributeObject;
21
- };
22
- const ariaAttributes = [
23
- 'aria-activedescendant',
24
- 'aria-atomic',
25
- 'aria-autocomplete',
26
- 'aria-braillelabel',
27
- 'aria-brailleroledescription',
28
- 'aria-busy',
29
- 'aria-checked',
30
- 'aria-colcount',
31
- 'aria-colindex',
32
- 'aria-colindextext',
33
- 'aria-colspan',
34
- 'aria-controls',
35
- 'aria-current',
36
- 'aria-describedby',
37
- 'aria-description',
38
- 'aria-details',
39
- 'aria-disabled',
40
- 'aria-errormessage',
41
- 'aria-expanded',
42
- 'aria-flowto',
43
- 'aria-haspopup',
44
- 'aria-hidden',
45
- 'aria-invalid',
46
- 'aria-keyshortcuts',
47
- 'aria-label',
48
- 'aria-labelledby',
49
- 'aria-level',
50
- 'aria-live',
51
- 'aria-multiline',
52
- 'aria-multiselectable',
53
- 'aria-orientation',
54
- 'aria-owns',
55
- 'aria-placeholder',
56
- 'aria-posinset',
57
- 'aria-pressed',
58
- 'aria-readonly',
59
- 'aria-relevant',
60
- 'aria-required',
61
- 'aria-roledescription',
62
- 'aria-rowcount',
63
- 'aria-rowindex',
64
- 'aria-rowindextext',
65
- 'aria-rowspan',
66
- 'aria-selected',
67
- 'aria-setsize',
68
- 'aria-sort',
69
- 'aria-valuemax',
70
- 'aria-valuemin',
71
- 'aria-valuenow',
72
- 'aria-valuetext',
73
- 'role',
74
- ];
75
- /**
76
- * Returns an array of aria attributes that should be copied from
77
- * the shadow host element to a target within the light DOM.
78
- *
79
- * @param element The element that the attributes should be copied from.
80
- */
81
- const inheritAriaAttributes = (element) => inheritAttributes(element, ariaAttributes);
82
- const prefix = 'Invariant failed';
83
- /**
84
- * Throws an error if the value is falsy.
85
- *
86
- * @param value Value to test.
87
- * @param message Optional message to display in development builds.
88
- */
89
- function invariant(value, message) {
90
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
91
- if (value)
92
- return;
93
- throw new Error(prefix);
94
- }
95
- /**
96
- * From an object pick a set of keys.
97
- *
98
- * @param object Object to pick from.
99
- * @param keys They keys to pick.
100
- * @returns New object with only the picked keys.
101
- */
102
- const pick = (object, ...keys) => {
103
- const returnValue = {};
104
- for (const key of keys)
105
- returnValue[key] = object[key];
106
- return returnValue;
107
- };
108
- const pickFocusEventAttributes = (event) => pick(event, 'relatedTarget');
109
- const pickInputEventAttributes = (event) => pick(event, 'data', 'inputType', 'isComposing');
110
- const getConversionFactor = (element, unit) => {
111
- switch (unit) {
112
- case 'cm': {
113
- return 96 / 2.54;
114
- }
115
- case 'em': {
116
- return Number.parseFloat(globalThis.getComputedStyle(element.parentElement ?? document.documentElement).fontSize);
117
- }
118
- case 'in': {
119
- return 96;
120
- }
121
- case 'mm': {
122
- return 96 / 25.4;
123
- }
124
- case 'pc': {
125
- return 16;
126
- }
127
- case 'pt': {
128
- return 96 / 72;
129
- }
130
- case 'px': {
131
- return 1;
132
- }
133
- case 'rem': {
134
- return Number.parseFloat(globalThis.getComputedStyle(document.documentElement).fontSize);
135
- }
136
- default: {
137
- return undefined;
138
- }
139
- }
140
- };
141
- const propertyToPx = (element, property) => {
142
- const value = globalThis.getComputedStyle(element).getPropertyValue(property);
143
- const number = Number.parseFloat(value);
144
- if (Number.isNaN(number))
145
- return undefined;
146
- const unit = /\s*[\d+.-]*\s*(.*)/.exec(value)?.[1] ?? '';
147
- const conversionFactor = getConversionFactor(element, unit) ?? 1;
148
- return number * conversionFactor;
149
- };
150
- const ignorePromise = (promise) => {
151
- promise.catch(() => {
152
- invariant(false);
153
- });
154
- };
155
- const isTouchDevice = () => 'ontouchstart' in globalThis ||
156
- ('maxTouchPoints' in globalThis && globalThis.navigator.maxTouchPoints > 0);
157
- /**
158
- * Checks if an element's ellipsis is active.
159
- *
160
- * @param element The element to check.
161
- * @returns `true` if ellipsis is active, `false` otherwise.
162
- */
163
- const isEllipsisActive = (element) => {
164
- const range = document.createRange();
165
- range.selectNodeContents(element);
166
- const rangeRect = range.getBoundingClientRect();
167
- const elementWidth = element.getBoundingClientRect().width;
168
- if (rangeRect.width > elementWidth)
169
- return true;
170
- const { webkitLineClamp, lineHeight } = globalThis.getComputedStyle(element);
171
- const parsedLineClamp = Number.parseInt(webkitLineClamp, 10);
172
- if (Number.isNaN(parsedLineClamp))
173
- return false;
174
- const parsedLineHeight = Number.parseInt(lineHeight, 10);
175
- if (Number.isNaN(parsedLineHeight))
176
- return false;
177
- return rangeRect.height >= (parsedLineClamp + 1) * parsedLineHeight;
178
- };
179
- const determineLinkIcon = (target,
180
- // eslint-disable-next-line unicorn/prevent-abbreviations
181
- rel) => {
182
- if (!(rel?.split(' ') ?? []).includes('external'))
183
- return undefined;
184
- return target === '_blank' ? 'external-new-tab-link' : 'external-link';
185
- };
186
- const resolveTarget = (target) => {
187
- const resolvedTarget = typeof target === 'function' ? target() : target;
188
- if (typeof resolvedTarget !== 'string')
189
- return resolvedTarget;
190
- const element = document.querySelector(resolvedTarget);
191
- if (element === null)
192
- throw new Error('String must resolve to an Element.');
193
- return element;
194
- };
195
- /**
196
- * Patched version of requestAnimationFrame that avoids ngzone
197
- * Use only when you know ngzone should not run
198
- */
199
- const raf = (h) => {
200
- const win = window;
201
- // eslint-disable-next-line no-underscore-dangle
202
- if (typeof win.__zone_symbol__requestAnimationFrame === 'function') {
203
- // eslint-disable-next-line no-underscore-dangle
204
- return win.__zone_symbol__requestAnimationFrame(h);
205
- }
206
- if (typeof requestAnimationFrame === 'function') {
207
- return requestAnimationFrame(h);
208
- }
209
- return setTimeout(h);
210
- };
211
- /**
212
- * Waits for a component to be ready for
213
- * both custom element and non-custom element builds.
214
- * If non-custom element build, el.componentOnReady
215
- * will be used.
216
- * For custom element builds, we wait a frame
217
- * so that the inner contents of the component
218
- * have a chance to render.
219
- *
220
- * Use this utility rather than calling
221
- * el.componentOnReady yourself.
222
- *
223
- * Reference: https://stenciljs.com/docs/api#componentonready
224
- */
225
- const componentOnReady = (element, callback) => {
226
- if (element.componentOnReady === undefined) {
227
- raf(() => {
228
- callback(element);
229
- });
230
- }
231
- else {
232
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
233
- element.componentOnReady().then((resolvedElement) => {
234
- callback(resolvedElement);
235
- });
236
- }
237
- };
238
- const resolvePanelFromValue = (value) => {
239
- if (value instanceof HTMLElement) {
240
- return value;
241
- }
242
- if (typeof value === 'string') {
243
- const element = document.querySelector(value);
244
- return element instanceof HTMLElement ? element : undefined;
245
- }
246
- return undefined;
247
- };
248
- const resolvePanelElement = (tab) => {
249
- const panelValue = typeof tab.panel === 'function' ? tab.panel() : tab.panel;
250
- return resolvePanelFromValue(panelValue);
251
- };
252
- const HORIZONTAL_MOVE_KEYS = new Set([
253
- 'ArrowLeft',
254
- 'ArrowRight',
255
- 'Home',
256
- 'End',
257
- ]);
258
- const VERTICAL_MOVE_KEYS = new Set([
259
- 'ArrowUp',
260
- 'ArrowDown',
261
- 'Home',
262
- 'End',
263
- ]);
264
- const closestElement = (selector, base) => {
265
- function closestFrom(element) {
266
- if (element === document || element === globalThis)
267
- return undefined;
268
- const { assignedSlot } = element;
269
- // eslint-disable-next-line no-param-reassign
270
- if (assignedSlot)
271
- element = assignedSlot;
272
- const found = element.closest(selector);
273
- return (found ??
274
- closestFrom(element.getRootNode().host));
275
- }
276
- return closestFrom(base);
277
- };
278
- const isRTL = (element) => getComputedStyle(element).direction === 'rtl';
279
- const getSubmenuOpenKey = (element) => isRTL(element) ? 'ArrowLeft' : 'ArrowRight';
280
- const getSubmenuCloseKey = (element) => isRTL(element) ? 'ArrowRight' : 'ArrowLeft';
281
- const isCurrentPage = (url) => {
282
- try {
283
- const currentUrl = new URL(window.location.href);
284
- const targetUrl = new URL(url);
285
- return (currentUrl.origin === targetUrl.origin &&
286
- currentUrl.pathname === targetUrl.pathname);
287
- }
288
- catch {
289
- return false;
290
- }
291
- };
292
-
293
- exports.HORIZONTAL_MOVE_KEYS = HORIZONTAL_MOVE_KEYS;
294
- exports.VERTICAL_MOVE_KEYS = VERTICAL_MOVE_KEYS;
295
- exports.closestElement = closestElement;
296
- exports.componentOnReady = componentOnReady;
297
- exports.determineLinkIcon = determineLinkIcon;
298
- exports.getSubmenuCloseKey = getSubmenuCloseKey;
299
- exports.getSubmenuOpenKey = getSubmenuOpenKey;
300
- exports.ignorePromise = ignorePromise;
301
- exports.inheritAriaAttributes = inheritAriaAttributes;
302
- exports.invariant = invariant;
303
- exports.isCurrentPage = isCurrentPage;
304
- exports.isEllipsisActive = isEllipsisActive;
305
- exports.isRTL = isRTL;
306
- exports.isTouchDevice = isTouchDevice;
307
- exports.pickFocusEventAttributes = pickFocusEventAttributes;
308
- exports.pickInputEventAttributes = pickInputEventAttributes;
309
- exports.propertyToPx = propertyToPx;
310
- exports.resolvePanelElement = resolvePanelElement;
311
- exports.resolveTarget = resolveTarget;
312
- //# sourceMappingURL=helpers-CPSgo4Ef.js.map
313
-
314
- //# sourceMappingURL=helpers-CPSgo4Ef.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers-CPSgo4Ef.js","sources":["src/helpers.ts"],"sourcesContent":["// SPDX-FileCopyrightText: © 2024 Schneider Electric\n//\n// SPDX-License-Identifier: Apache-2.0\n\nimport type {\n MiddlewareState,\n OffsetOptions as LibraryOffsetOptions,\n ReferenceElement,\n} from '@floating-ui/dom'\nimport type { Except, Replace } from 'type-fest'\n\nimport type { LinkIcon } from './components/shared'\n\nexport type Attributes = Record<string, string | undefined>\n\nconst inheritAttributes = (\n element: Element,\n attributes: string[] = [],\n): Attributes => {\n const attributeObject: Attributes = {}\n\n for (const attribute of attributes) {\n const value = element.getAttribute(attribute)\n if (value !== null) {\n attributeObject[attribute] = value\n element.removeAttribute(attribute)\n }\n }\n\n return attributeObject\n}\n\ntype ARIAAttribute =\n | Replace<Lowercase<keyof ARIAMixin>, 'aria', 'aria-'>\n | 'aria-activedescendant'\n | 'aria-braillelabel'\n | 'aria-brailleroledescription'\n | 'aria-colindextext'\n | 'aria-controls'\n | 'aria-describedby'\n | 'aria-description'\n | 'aria-details'\n | 'aria-errormessage'\n | 'aria-flowto'\n | 'aria-labelledby'\n | 'aria-owns'\n | 'aria-relevant'\n | 'aria-rowindextext'\n\nconst ariaAttributes: ARIAAttribute[] = [\n 'aria-activedescendant',\n 'aria-atomic',\n 'aria-autocomplete',\n 'aria-braillelabel',\n 'aria-brailleroledescription',\n 'aria-busy',\n 'aria-checked',\n 'aria-colcount',\n 'aria-colindex',\n 'aria-colindextext',\n 'aria-colspan',\n 'aria-controls',\n 'aria-current',\n 'aria-describedby',\n 'aria-description',\n 'aria-details',\n 'aria-disabled',\n 'aria-errormessage',\n 'aria-expanded',\n 'aria-flowto',\n 'aria-haspopup',\n 'aria-hidden',\n 'aria-invalid',\n 'aria-keyshortcuts',\n 'aria-label',\n 'aria-labelledby',\n 'aria-level',\n 'aria-live',\n 'aria-multiline',\n 'aria-multiselectable',\n 'aria-orientation',\n 'aria-owns',\n 'aria-placeholder',\n 'aria-posinset',\n 'aria-pressed',\n 'aria-readonly',\n 'aria-relevant',\n 'aria-required',\n 'aria-roledescription',\n 'aria-rowcount',\n 'aria-rowindex',\n 'aria-rowindextext',\n 'aria-rowspan',\n 'aria-selected',\n 'aria-setsize',\n 'aria-sort',\n 'aria-valuemax',\n 'aria-valuemin',\n 'aria-valuenow',\n 'aria-valuetext',\n 'role',\n]\n\n/**\n * Returns an array of aria attributes that should be copied from\n * the shadow host element to a target within the light DOM.\n *\n * @param element The element that the attributes should be copied from.\n */\nexport const inheritAriaAttributes = (\n element: Element,\n): ReturnType<typeof inheritAttributes> =>\n inheritAttributes(element, ariaAttributes)\n\nconst isProduction = process.env.NODE_ENV === 'production'\nconst prefix = 'Invariant failed'\n\n/**\n * Throws an error if the value is falsy.\n *\n * @param value Value to test.\n * @param message Optional message to display in development builds.\n */\nexport function invariant(value: unknown, message?: string): asserts value {\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (value) return\n if (isProduction) throw new Error(prefix)\n\n const error = message === undefined ? prefix : `${prefix}: ${message}`\n throw new Error(error)\n}\n\n/**\n * From an object pick a set of keys.\n *\n * @param object Object to pick from.\n * @param keys They keys to pick.\n * @returns New object with only the picked keys.\n */\nexport const pick = <T, K extends keyof T>(\n object: T,\n ...keys: K[]\n): Pick<T, K> => {\n const returnValue: Partial<Pick<T, K>> = {}\n for (const key of keys) returnValue[key] = object[key]\n return returnValue as Pick<T, K>\n}\n\nexport type QdsFocusEventDetail = Pick<FocusEvent, 'relatedTarget'>\nexport type QdsInputEventDetail = Pick<\n InputEvent,\n 'data' | 'inputType' | 'isComposing'\n>\nexport const pickFocusEventAttributes = (\n event: FocusEvent,\n): QdsFocusEventDetail => pick(event, 'relatedTarget')\nexport const pickInputEventAttributes = (\n event: InputEvent,\n): QdsInputEventDetail => pick(event, 'data', 'inputType', 'isComposing')\n\nconst getConversionFactor = (\n element: Element,\n unit: string,\n): number | undefined => {\n switch (unit) {\n case 'cm': {\n return 96 / 2.54\n }\n case 'em': {\n return Number.parseFloat(\n globalThis.getComputedStyle(\n element.parentElement ?? document.documentElement,\n ).fontSize,\n )\n }\n case 'in': {\n return 96\n }\n case 'mm': {\n return 96 / 25.4\n }\n case 'pc': {\n return 16\n }\n case 'pt': {\n return 96 / 72\n }\n case 'px': {\n return 1\n }\n case 'rem': {\n return Number.parseFloat(\n globalThis.getComputedStyle(document.documentElement).fontSize,\n )\n }\n default: {\n return undefined\n }\n }\n}\n\nexport const propertyToPx = (\n element: Element,\n property: string,\n): number | undefined => {\n const value = globalThis.getComputedStyle(element).getPropertyValue(property)\n const number = Number.parseFloat(value)\n if (Number.isNaN(number)) return undefined\n const unit = /\\s*[\\d+.-]*\\s*(.*)/.exec(value)?.[1] ?? ''\n\n const conversionFactor = getConversionFactor(element, unit) ?? 1\n return number * conversionFactor\n}\n\nexport const ignorePromise = <T>(promise: Promise<T>): void => {\n promise.catch(() => {\n invariant(false)\n })\n}\n\nexport const isTouchDevice = (): boolean =>\n 'ontouchstart' in globalThis ||\n ('maxTouchPoints' in globalThis && globalThis.navigator.maxTouchPoints > 0)\n\n/**\n * Checks if an element's ellipsis is active.\n *\n * @param element The element to check.\n * @returns `true` if ellipsis is active, `false` otherwise.\n */\nexport const isEllipsisActive = (element: Element): boolean => {\n const range = document.createRange()\n range.selectNodeContents(element)\n\n const rangeRect = range.getBoundingClientRect()\n const elementWidth = element.getBoundingClientRect().width\n\n if (rangeRect.width > elementWidth) return true\n\n const { webkitLineClamp, lineHeight } = globalThis.getComputedStyle(element)\n\n const parsedLineClamp = Number.parseInt(webkitLineClamp, 10)\n if (Number.isNaN(parsedLineClamp)) return false\n const parsedLineHeight = Number.parseInt(lineHeight, 10)\n if (Number.isNaN(parsedLineHeight)) return false\n\n return rangeRect.height >= (parsedLineClamp + 1) * parsedLineHeight\n}\n\nexport const determineLinkIcon = (\n target?: string,\n // eslint-disable-next-line unicorn/prevent-abbreviations\n rel?: string,\n): LinkIcon | undefined => {\n if (!(rel?.split(' ') ?? []).includes('external')) return undefined\n return target === '_blank' ? 'external-new-tab-link' : 'external-link'\n}\n\nexport const resolveTarget = (\n target?: ReferenceElement | string | (() => ReferenceElement | string),\n): ReferenceElement | undefined => {\n const resolvedTarget = typeof target === 'function' ? target() : target\n if (typeof resolvedTarget !== 'string') return resolvedTarget\n\n const element = document.querySelector(resolvedTarget)\n if (element === null) throw new Error('String must resolve to an Element.')\n return element\n}\n\n/**\n * Patched version of requestAnimationFrame that avoids ngzone\n * Use only when you know ngzone should not run\n */\nconst raf = (h: FrameRequestCallback): number => {\n const win = window as Window & {\n ['__zone_symbol__requestAnimationFrame']?: (\n callback: FrameRequestCallback,\n ) => number\n }\n // eslint-disable-next-line no-underscore-dangle\n if (typeof win.__zone_symbol__requestAnimationFrame === 'function') {\n // eslint-disable-next-line no-underscore-dangle\n return win.__zone_symbol__requestAnimationFrame(h)\n }\n if (typeof requestAnimationFrame === 'function') {\n return requestAnimationFrame(h)\n }\n return setTimeout(h)\n}\n\n/**\n * Waits for a component to be ready for\n * both custom element and non-custom element builds.\n * If non-custom element build, el.componentOnReady\n * will be used.\n * For custom element builds, we wait a frame\n * so that the inner contents of the component\n * have a chance to render.\n *\n * Use this utility rather than calling\n * el.componentOnReady yourself.\n *\n * Reference: https://stenciljs.com/docs/api#componentonready\n */\nexport const componentOnReady = <\n T extends { componentOnReady?: () => Promise<T> },\n>(\n element: T,\n callback: (element_: T) => void,\n): void => {\n if (element.componentOnReady === undefined) {\n raf(() => {\n callback(element)\n })\n } else {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n element.componentOnReady().then((resolvedElement) => {\n callback(resolvedElement)\n })\n }\n}\n\nconst resolvePanelFromValue = (value: unknown): HTMLElement | undefined => {\n if (value instanceof HTMLElement) {\n return value\n }\n\n if (typeof value === 'string') {\n const element = document.querySelector(value)\n return element instanceof HTMLElement ? element : undefined\n }\n\n return undefined\n}\n\nexport const resolvePanelElement = (tab: {\n panel: Element | string | (() => Element | string)\n}): HTMLElement | undefined => {\n const panelValue = typeof tab.panel === 'function' ? tab.panel() : tab.panel\n return resolvePanelFromValue(panelValue)\n}\n\ntype OffsetValue = Except<\n Exclude<\n LibraryOffsetOptions,\n // eslint-disable-next-line @typescript-eslint/ban-types\n Function | number\n >,\n 'mainAxis'\n>\ntype OffsetFunction = (state: MiddlewareState) => OffsetValue\nexport type OffsetOptions = OffsetFunction | OffsetValue\n\nexport const HORIZONTAL_MOVE_KEYS: ReadonlySet<string> = new Set([\n 'ArrowLeft',\n 'ArrowRight',\n 'Home',\n 'End',\n])\n\nexport const VERTICAL_MOVE_KEYS: ReadonlySet<string> = new Set([\n 'ArrowUp',\n 'ArrowDown',\n 'Home',\n 'End',\n])\n\nexport const closestElement = (\n selector: string,\n base: Element,\n): Element | undefined => {\n function closestFrom(\n element: Document | Element | typeof globalThis,\n ): Element | undefined {\n if (element === document || element === globalThis) return undefined\n const { assignedSlot } = element as Slottable\n // eslint-disable-next-line no-param-reassign\n if (assignedSlot) element = assignedSlot\n const found = (element as Element).closest(selector)\n return (\n found ??\n closestFrom(((element as Element).getRootNode() as ShadowRoot).host)\n )\n }\n return closestFrom(base)\n}\n\nexport const isRTL = (element: Element): boolean =>\n getComputedStyle(element).direction === 'rtl'\n\nexport const getSubmenuOpenKey = (element: Element): string =>\n isRTL(element) ? 'ArrowLeft' : 'ArrowRight'\n\nexport const getSubmenuCloseKey = (element: Element): string =>\n isRTL(element) ? 'ArrowRight' : 'ArrowLeft'\n\nexport const isCurrentPage = (url: string): boolean => {\n try {\n const currentUrl = new URL(window.location.href)\n const targetUrl = new URL(url)\n return (\n currentUrl.origin === targetUrl.origin &&\n currentUrl.pathname === targetUrl.pathname\n )\n } catch {\n return false\n }\n}\n"],"names":[],"mappings":";;;;;;;AAAA;AACA;AACA;AAaA,MAAM,iBAAiB,GAAG,CACxB,OAAgB,EAChB,UAAuB,GAAA,EAAE,KACX;IACd,MAAM,eAAe,GAAe,EAAE;AAEtC,IAAA,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;QAClC,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC;AAC7C,QAAA,IAAI,KAAK,KAAK,IAAI,EAAE;AAClB,YAAA,eAAe,CAAC,SAAS,CAAC,GAAG,KAAK;AAClC,YAAA,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC;;;AAItC,IAAA,OAAO,eAAe;AACxB,CAAC;AAmBD,MAAM,cAAc,GAAoB;IACtC,uBAAuB;IACvB,aAAa;IACb,mBAAmB;IACnB,mBAAmB;IACnB,6BAA6B;IAC7B,WAAW;IACX,cAAc;IACd,eAAe;IACf,eAAe;IACf,mBAAmB;IACnB,cAAc;IACd,eAAe;IACf,cAAc;IACd,kBAAkB;IAClB,kBAAkB;IAClB,cAAc;IACd,eAAe;IACf,mBAAmB;IACnB,eAAe;IACf,aAAa;IACb,eAAe;IACf,aAAa;IACb,cAAc;IACd,mBAAmB;IACnB,YAAY;IACZ,iBAAiB;IACjB,YAAY;IACZ,WAAW;IACX,gBAAgB;IAChB,sBAAsB;IACtB,kBAAkB;IAClB,WAAW;IACX,kBAAkB;IA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C,QAAQ,CAAC,IAAI,CAAC;AAChD,QAAA,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC;AAC9B,QAAA,QACE,UAAU,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM;AACtC,YAAA,UAAU,CAAC,QAAQ,KAAK,SAAS,CAAC,QAAQ;;AAE5C,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;;AAEhB;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,294 +0,0 @@
1
- /*!
2
- * SPDX-FileCopyrightText: © 2026 Schneider Electric
3
- *
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- // SPDX-FileCopyrightText: © 2024 Schneider Electric
7
- //
8
- // SPDX-License-Identifier: Apache-2.0
9
- const inheritAttributes = (element, attributes = []) => {
10
- const attributeObject = {};
11
- for (const attribute of attributes) {
12
- const value = element.getAttribute(attribute);
13
- if (value !== null) {
14
- attributeObject[attribute] = value;
15
- element.removeAttribute(attribute);
16
- }
17
- }
18
- return attributeObject;
19
- };
20
- const ariaAttributes = [
21
- 'aria-activedescendant',
22
- 'aria-atomic',
23
- 'aria-autocomplete',
24
- 'aria-braillelabel',
25
- 'aria-brailleroledescription',
26
- 'aria-busy',
27
- 'aria-checked',
28
- 'aria-colcount',
29
- 'aria-colindex',
30
- 'aria-colindextext',
31
- 'aria-colspan',
32
- 'aria-controls',
33
- 'aria-current',
34
- 'aria-describedby',
35
- 'aria-description',
36
- 'aria-details',
37
- 'aria-disabled',
38
- 'aria-errormessage',
39
- 'aria-expanded',
40
- 'aria-flowto',
41
- 'aria-haspopup',
42
- 'aria-hidden',
43
- 'aria-invalid',
44
- 'aria-keyshortcuts',
45
- 'aria-label',
46
- 'aria-labelledby',
47
- 'aria-level',
48
- 'aria-live',
49
- 'aria-multiline',
50
- 'aria-multiselectable',
51
- 'aria-orientation',
52
- 'aria-owns',
53
- 'aria-placeholder',
54
- 'aria-posinset',
55
- 'aria-pressed',
56
- 'aria-readonly',
57
- 'aria-relevant',
58
- 'aria-required',
59
- 'aria-roledescription',
60
- 'aria-rowcount',
61
- 'aria-rowindex',
62
- 'aria-rowindextext',
63
- 'aria-rowspan',
64
- 'aria-selected',
65
- 'aria-setsize',
66
- 'aria-sort',
67
- 'aria-valuemax',
68
- 'aria-valuemin',
69
- 'aria-valuenow',
70
- 'aria-valuetext',
71
- 'role',
72
- ];
73
- /**
74
- * Returns an array of aria attributes that should be copied from
75
- * the shadow host element to a target within the light DOM.
76
- *
77
- * @param element The element that the attributes should be copied from.
78
- */
79
- const inheritAriaAttributes = (element) => inheritAttributes(element, ariaAttributes);
80
- const prefix = 'Invariant failed';
81
- /**
82
- * Throws an error if the value is falsy.
83
- *
84
- * @param value Value to test.
85
- * @param message Optional message to display in development builds.
86
- */
87
- function invariant(value, message) {
88
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
89
- if (value)
90
- return;
91
- throw new Error(prefix);
92
- }
93
- /**
94
- * From an object pick a set of keys.
95
- *
96
- * @param object Object to pick from.
97
- * @param keys They keys to pick.
98
- * @returns New object with only the picked keys.
99
- */
100
- const pick = (object, ...keys) => {
101
- const returnValue = {};
102
- for (const key of keys)
103
- returnValue[key] = object[key];
104
- return returnValue;
105
- };
106
- const pickFocusEventAttributes = (event) => pick(event, 'relatedTarget');
107
- const pickInputEventAttributes = (event) => pick(event, 'data', 'inputType', 'isComposing');
108
- const getConversionFactor = (element, unit) => {
109
- switch (unit) {
110
- case 'cm': {
111
- return 96 / 2.54;
112
- }
113
- case 'em': {
114
- return Number.parseFloat(globalThis.getComputedStyle(element.parentElement ?? document.documentElement).fontSize);
115
- }
116
- case 'in': {
117
- return 96;
118
- }
119
- case 'mm': {
120
- return 96 / 25.4;
121
- }
122
- case 'pc': {
123
- return 16;
124
- }
125
- case 'pt': {
126
- return 96 / 72;
127
- }
128
- case 'px': {
129
- return 1;
130
- }
131
- case 'rem': {
132
- return Number.parseFloat(globalThis.getComputedStyle(document.documentElement).fontSize);
133
- }
134
- default: {
135
- return undefined;
136
- }
137
- }
138
- };
139
- const propertyToPx = (element, property) => {
140
- const value = globalThis.getComputedStyle(element).getPropertyValue(property);
141
- const number = Number.parseFloat(value);
142
- if (Number.isNaN(number))
143
- return undefined;
144
- const unit = /\s*[\d+.-]*\s*(.*)/.exec(value)?.[1] ?? '';
145
- const conversionFactor = getConversionFactor(element, unit) ?? 1;
146
- return number * conversionFactor;
147
- };
148
- const ignorePromise = (promise) => {
149
- promise.catch(() => {
150
- invariant(false);
151
- });
152
- };
153
- const isTouchDevice = () => 'ontouchstart' in globalThis ||
154
- ('maxTouchPoints' in globalThis && globalThis.navigator.maxTouchPoints > 0);
155
- /**
156
- * Checks if an element's ellipsis is active.
157
- *
158
- * @param element The element to check.
159
- * @returns `true` if ellipsis is active, `false` otherwise.
160
- */
161
- const isEllipsisActive = (element) => {
162
- const range = document.createRange();
163
- range.selectNodeContents(element);
164
- const rangeRect = range.getBoundingClientRect();
165
- const elementWidth = element.getBoundingClientRect().width;
166
- if (rangeRect.width > elementWidth)
167
- return true;
168
- const { webkitLineClamp, lineHeight } = globalThis.getComputedStyle(element);
169
- const parsedLineClamp = Number.parseInt(webkitLineClamp, 10);
170
- if (Number.isNaN(parsedLineClamp))
171
- return false;
172
- const parsedLineHeight = Number.parseInt(lineHeight, 10);
173
- if (Number.isNaN(parsedLineHeight))
174
- return false;
175
- return rangeRect.height >= (parsedLineClamp + 1) * parsedLineHeight;
176
- };
177
- const determineLinkIcon = (target,
178
- // eslint-disable-next-line unicorn/prevent-abbreviations
179
- rel) => {
180
- if (!(rel?.split(' ') ?? []).includes('external'))
181
- return undefined;
182
- return target === '_blank' ? 'external-new-tab-link' : 'external-link';
183
- };
184
- const resolveTarget = (target) => {
185
- const resolvedTarget = typeof target === 'function' ? target() : target;
186
- if (typeof resolvedTarget !== 'string')
187
- return resolvedTarget;
188
- const element = document.querySelector(resolvedTarget);
189
- if (element === null)
190
- throw new Error('String must resolve to an Element.');
191
- return element;
192
- };
193
- /**
194
- * Patched version of requestAnimationFrame that avoids ngzone
195
- * Use only when you know ngzone should not run
196
- */
197
- const raf = (h) => {
198
- const win = window;
199
- // eslint-disable-next-line no-underscore-dangle
200
- if (typeof win.__zone_symbol__requestAnimationFrame === 'function') {
201
- // eslint-disable-next-line no-underscore-dangle
202
- return win.__zone_symbol__requestAnimationFrame(h);
203
- }
204
- if (typeof requestAnimationFrame === 'function') {
205
- return requestAnimationFrame(h);
206
- }
207
- return setTimeout(h);
208
- };
209
- /**
210
- * Waits for a component to be ready for
211
- * both custom element and non-custom element builds.
212
- * If non-custom element build, el.componentOnReady
213
- * will be used.
214
- * For custom element builds, we wait a frame
215
- * so that the inner contents of the component
216
- * have a chance to render.
217
- *
218
- * Use this utility rather than calling
219
- * el.componentOnReady yourself.
220
- *
221
- * Reference: https://stenciljs.com/docs/api#componentonready
222
- */
223
- const componentOnReady = (element, callback) => {
224
- if (element.componentOnReady === undefined) {
225
- raf(() => {
226
- callback(element);
227
- });
228
- }
229
- else {
230
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
231
- element.componentOnReady().then((resolvedElement) => {
232
- callback(resolvedElement);
233
- });
234
- }
235
- };
236
- const resolvePanelFromValue = (value) => {
237
- if (value instanceof HTMLElement) {
238
- return value;
239
- }
240
- if (typeof value === 'string') {
241
- const element = document.querySelector(value);
242
- return element instanceof HTMLElement ? element : undefined;
243
- }
244
- return undefined;
245
- };
246
- const resolvePanelElement = (tab) => {
247
- const panelValue = typeof tab.panel === 'function' ? tab.panel() : tab.panel;
248
- return resolvePanelFromValue(panelValue);
249
- };
250
- const HORIZONTAL_MOVE_KEYS = new Set([
251
- 'ArrowLeft',
252
- 'ArrowRight',
253
- 'Home',
254
- 'End',
255
- ]);
256
- const VERTICAL_MOVE_KEYS = new Set([
257
- 'ArrowUp',
258
- 'ArrowDown',
259
- 'Home',
260
- 'End',
261
- ]);
262
- const closestElement = (selector, base) => {
263
- function closestFrom(element) {
264
- if (element === document || element === globalThis)
265
- return undefined;
266
- const { assignedSlot } = element;
267
- // eslint-disable-next-line no-param-reassign
268
- if (assignedSlot)
269
- element = assignedSlot;
270
- const found = element.closest(selector);
271
- return (found ??
272
- closestFrom(element.getRootNode().host));
273
- }
274
- return closestFrom(base);
275
- };
276
- const isRTL = (element) => getComputedStyle(element).direction === 'rtl';
277
- const getSubmenuOpenKey = (element) => isRTL(element) ? 'ArrowLeft' : 'ArrowRight';
278
- const getSubmenuCloseKey = (element) => isRTL(element) ? 'ArrowRight' : 'ArrowLeft';
279
- const isCurrentPage = (url) => {
280
- try {
281
- const currentUrl = new URL(window.location.href);
282
- const targetUrl = new URL(url);
283
- return (currentUrl.origin === targetUrl.origin &&
284
- currentUrl.pathname === targetUrl.pathname);
285
- }
286
- catch {
287
- return false;
288
- }
289
- };
290
-
291
- export { HORIZONTAL_MOVE_KEYS as H, VERTICAL_MOVE_KEYS as V, isEllipsisActive as a, isCurrentPage as b, inheritAriaAttributes as c, determineLinkIcon as d, pickInputEventAttributes as e, isRTL as f, getSubmenuOpenKey as g, resolvePanelElement as h, invariant as i, componentOnReady as j, ignorePromise as k, closestElement as l, getSubmenuCloseKey as m, propertyToPx as n, isTouchDevice as o, pickFocusEventAttributes as p, resolveTarget as r };
292
- //# sourceMappingURL=helpers-JWnSavo8.js.map
293
-
294
- //# sourceMappingURL=helpers-JWnSavo8.js.map