@quartzds/core 1.0.0-beta.23 → 1.0.0-beta.25
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/components/controls.js +27 -0
- package/components/controls.js.map +1 -0
- package/components/helpers.js +109 -109
- package/components/helpers.js.map +1 -1
- package/components/icon.js +120 -119
- package/components/icon.js.map +1 -1
- package/components/index.js +21 -21
- package/components/index.js.map +1 -1
- package/components/label.js +38 -38
- package/components/label.js.map +1 -1
- package/components/qds-button.d.ts +2 -2
- package/components/qds-button.js +124 -124
- package/components/qds-button.js.map +1 -1
- package/components/qds-checkbox.d.ts +2 -2
- package/components/qds-checkbox.js +193 -136
- package/components/qds-checkbox.js.map +1 -1
- package/components/qds-dialog.d.ts +2 -2
- package/components/qds-dialog.js +89 -89
- package/components/qds-dialog.js.map +1 -1
- package/components/qds-divider.d.ts +2 -2
- package/components/qds-divider.js +28 -28
- package/components/qds-divider.js.map +1 -1
- package/components/qds-dropdown.d.ts +2 -2
- package/components/qds-dropdown.js +243 -243
- package/components/qds-dropdown.js.map +1 -1
- package/components/qds-form-message.d.ts +2 -2
- package/components/qds-form-message.js +42 -42
- package/components/qds-form-message.js.map +1 -1
- package/components/qds-icon.d.ts +2 -2
- package/components/qds-inline-link.d.ts +2 -2
- package/components/qds-inline-link.js +67 -67
- package/components/qds-inline-link.js.map +1 -1
- package/components/qds-input.d.ts +2 -2
- package/components/qds-input.js +295 -229
- package/components/qds-input.js.map +1 -1
- package/components/qds-label.d.ts +2 -2
- package/components/qds-radio.d.ts +2 -2
- package/components/qds-radio.js +90 -90
- package/components/qds-radio.js.map +1 -1
- package/components/qds-select.d.ts +2 -2
- package/components/qds-select.js +236 -170
- package/components/qds-select.js.map +1 -1
- package/components/qds-switch.d.ts +2 -2
- package/components/qds-switch.js +96 -96
- package/components/qds-switch.js.map +1 -1
- package/components/qds-table-body.d.ts +2 -2
- package/components/qds-table-body.js +25 -25
- package/components/qds-table-body.js.map +1 -1
- package/components/qds-table-cell.d.ts +2 -2
- package/components/qds-table-cell.js +30 -30
- package/components/qds-table-cell.js.map +1 -1
- package/components/qds-table-head-cell.d.ts +2 -2
- package/components/qds-table-head-cell.js +34 -34
- package/components/qds-table-head-cell.js.map +1 -1
- package/components/qds-table-head.d.ts +2 -2
- package/components/qds-table-head.js +25 -25
- package/components/qds-table-head.js.map +1 -1
- package/components/qds-table-row.d.ts +2 -2
- package/components/qds-table-row.js +25 -25
- package/components/qds-table-row.js.map +1 -1
- package/components/qds-table.d.ts +2 -2
- package/components/qds-table.js +25 -25
- package/components/qds-table.js.map +1 -1
- package/components/qds-textarea.d.ts +2 -2
- package/components/qds-textarea.js +254 -192
- package/components/qds-textarea.js.map +1 -1
- package/components/qds-title.d.ts +2 -2
- package/components/qds-title.js +74 -74
- package/components/qds-title.js.map +1 -1
- package/components/qds-tooltip.d.ts +2 -2
- package/components/qds-tooltip.js +314 -314
- package/components/qds-tooltip.js.map +1 -1
- package/dist/cjs/controls-3efe912a.js +31 -0
- package/dist/cjs/controls-3efe912a.js.map +1 -0
- package/dist/cjs/helpers-21f9a5f5.js +185 -0
- package/dist/cjs/helpers-21f9a5f5.js.map +1 -0
- package/dist/cjs/{index-54d11f50.js → index-70b91d40.js} +242 -75
- package/dist/cjs/index-70b91d40.js.map +1 -0
- package/dist/cjs/index.cjs.js +23 -23
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/{library-4c55a413.js → library-429681d8.js} +22 -22
- package/dist/cjs/{library-4c55a413.js.map → library-429681d8.js.map} +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/qds-button.cjs.entry.js +89 -89
- package/dist/cjs/qds-button.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-checkbox.cjs.entry.js +154 -98
- package/dist/cjs/qds-checkbox.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-dialog.cjs.entry.js +70 -70
- package/dist/cjs/qds-dialog.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-divider.cjs.entry.js +14 -14
- package/dist/cjs/qds-divider.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-dropdown.cjs.entry.js +206 -206
- package/dist/cjs/qds-dropdown.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-form-message.cjs.entry.js +20 -20
- package/dist/cjs/qds-form-message.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-icon.cjs.entry.js +82 -81
- package/dist/cjs/qds-icon.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-inline-link.cjs.entry.js +41 -41
- package/dist/cjs/qds-inline-link.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-input.cjs.entry.js +242 -181
- package/dist/cjs/qds-input.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-label.cjs.entry.js +21 -21
- package/dist/cjs/qds-label.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-radio.cjs.entry.js +58 -58
- package/dist/cjs/qds-radio.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-select.cjs.entry.js +199 -133
- package/dist/cjs/qds-select.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-switch.cjs.entry.js +59 -59
- package/dist/cjs/qds-switch.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-table-body.cjs.entry.js +13 -13
- package/dist/cjs/qds-table-body.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-table-cell.cjs.entry.js +15 -15
- package/dist/cjs/qds-table-cell.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-table-head-cell.cjs.entry.js +17 -17
- package/dist/cjs/qds-table-head-cell.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-table-head.cjs.entry.js +13 -13
- package/dist/cjs/qds-table-head.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-table-row.cjs.entry.js +13 -13
- package/dist/cjs/qds-table-row.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-table.cjs.entry.js +13 -13
- package/dist/cjs/qds-table.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-textarea.cjs.entry.js +210 -150
- package/dist/cjs/qds-textarea.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-title.cjs.entry.js +49 -49
- package/dist/cjs/qds-title.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-tooltip.cjs.entry.js +261 -261
- package/dist/cjs/qds-tooltip.cjs.entry.js.map +1 -1
- package/dist/cjs/qds.cjs.js +3 -3
- package/dist/cjs/qds.cjs.js.map +1 -1
- package/dist/custom-elements.json +1040 -429
- package/dist/docs.json +982 -991
- package/dist/esm/controls-eec36daa.js +27 -0
- package/dist/esm/controls-eec36daa.js.map +1 -0
- package/dist/esm/helpers-7aa0fd7b.js +175 -0
- package/dist/esm/helpers-7aa0fd7b.js.map +1 -0
- package/dist/esm/{index-5d80e9c2.js → index-7104bb46.js} +242 -75
- package/dist/esm/index-7104bb46.js.map +1 -0
- package/dist/esm/index.js +23 -23
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/{library-376fa462.js → library-3b5966e6.js} +22 -22
- package/dist/esm/{library-376fa462.js.map → library-3b5966e6.js.map} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/qds-button.entry.js +89 -89
- package/dist/esm/qds-button.entry.js.map +1 -1
- package/dist/esm/qds-checkbox.entry.js +154 -98
- package/dist/esm/qds-checkbox.entry.js.map +1 -1
- package/dist/esm/qds-dialog.entry.js +70 -70
- package/dist/esm/qds-dialog.entry.js.map +1 -1
- package/dist/esm/qds-divider.entry.js +14 -14
- package/dist/esm/qds-divider.entry.js.map +1 -1
- package/dist/esm/qds-dropdown.entry.js +206 -206
- package/dist/esm/qds-dropdown.entry.js.map +1 -1
- package/dist/esm/qds-form-message.entry.js +20 -20
- package/dist/esm/qds-form-message.entry.js.map +1 -1
- package/dist/esm/qds-icon.entry.js +82 -81
- package/dist/esm/qds-icon.entry.js.map +1 -1
- package/dist/esm/qds-inline-link.entry.js +41 -41
- package/dist/esm/qds-inline-link.entry.js.map +1 -1
- package/dist/esm/qds-input.entry.js +242 -181
- package/dist/esm/qds-input.entry.js.map +1 -1
- package/dist/esm/qds-label.entry.js +21 -21
- package/dist/esm/qds-label.entry.js.map +1 -1
- package/dist/esm/qds-radio.entry.js +58 -58
- package/dist/esm/qds-radio.entry.js.map +1 -1
- package/dist/esm/qds-select.entry.js +199 -133
- package/dist/esm/qds-select.entry.js.map +1 -1
- package/dist/esm/qds-switch.entry.js +59 -59
- package/dist/esm/qds-switch.entry.js.map +1 -1
- package/dist/esm/qds-table-body.entry.js +13 -13
- package/dist/esm/qds-table-body.entry.js.map +1 -1
- package/dist/esm/qds-table-cell.entry.js +15 -15
- package/dist/esm/qds-table-cell.entry.js.map +1 -1
- package/dist/esm/qds-table-head-cell.entry.js +17 -17
- package/dist/esm/qds-table-head-cell.entry.js.map +1 -1
- package/dist/esm/qds-table-head.entry.js +13 -13
- package/dist/esm/qds-table-head.entry.js.map +1 -1
- package/dist/esm/qds-table-row.entry.js +13 -13
- package/dist/esm/qds-table-row.entry.js.map +1 -1
- package/dist/esm/qds-table.entry.js +13 -13
- package/dist/esm/qds-table.entry.js.map +1 -1
- package/dist/esm/qds-textarea.entry.js +210 -150
- package/dist/esm/qds-textarea.entry.js.map +1 -1
- package/dist/esm/qds-title.entry.js +49 -49
- package/dist/esm/qds-title.entry.js.map +1 -1
- package/dist/esm/qds-tooltip.entry.js +261 -261
- package/dist/esm/qds-tooltip.entry.js.map +1 -1
- package/dist/esm/qds.js +4 -4
- package/dist/esm/qds.js.map +1 -1
- package/dist/types/components/button/button.d.ts +195 -195
- package/dist/types/components/checkbox/checkbox.d.ts +145 -123
- package/dist/types/components/controls.d.ts +3 -1
- package/dist/types/components/dialog/dialog.d.ts +41 -41
- package/dist/types/components/divider/divider.d.ts +8 -8
- package/dist/types/components/dropdown/dropdown.d.ts +124 -124
- package/dist/types/components/form-message/form-message.d.ts +23 -23
- package/dist/types/components/icon/icon.d.ts +24 -24
- package/dist/types/components/icon/library.d.ts +2 -2
- package/dist/types/components/icon/request.d.ts +4 -4
- package/dist/types/components/inline-link/inline-link.d.ts +190 -190
- package/dist/types/components/input/input.d.ts +386 -369
- package/dist/types/components/interfaces.d.ts +179 -0
- package/dist/types/components/label/label.d.ts +23 -23
- package/dist/types/components/radio/radio.d.ts +95 -95
- package/dist/types/components/select/select.d.ts +208 -163
- package/dist/types/components/switch/switch.d.ts +106 -106
- package/dist/types/components/table/table.d.ts +4 -4
- package/dist/types/components/table-body/table-body.d.ts +4 -4
- package/dist/types/components/table-cell/table-cell.d.ts +22 -22
- package/dist/types/components/table-head/table-head.d.ts +4 -4
- package/dist/types/components/table-head-cell/table-head-cell.d.ts +44 -44
- package/dist/types/components/table-row/table-row.d.ts +4 -4
- package/dist/types/components/textarea/textarea.d.ts +321 -299
- package/dist/types/components/title/title.d.ts +31 -31
- package/dist/types/components/tooltip/tooltip.d.ts +136 -136
- package/dist/types/components.d.ts +314 -165
- package/dist/types/helpers.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/qds-test.d.ts +18 -18
- package/dist/types/stencil-public-runtime.d.ts +8 -0
- package/dist/vscode.html-custom-data.json +112 -37
- package/hydrate/index.d.ts +1 -1
- package/hydrate/index.js +6784 -6473
- package/package.json +11 -10
- package/dist/cjs/helpers-452256e8.js +0 -185
- package/dist/cjs/helpers-452256e8.js.map +0 -1
- package/dist/cjs/index-54d11f50.js.map +0 -1
- package/dist/esm/helpers-76b84f45.js +0 -175
- package/dist/esm/helpers-76b84f45.js.map +0 -1
- package/dist/esm/index-5d80e9c2.js.map +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* SPDX-FileCopyrightText: © 2023 Schneider Electric
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: LGPL-2.1-only
|
|
5
|
+
*/
|
|
6
|
+
// SPDX-FileCopyrightText: © 2023 Schneider Electric
|
|
7
|
+
//
|
|
8
|
+
// SPDX-License-Identifier: LGPL-2.1-only
|
|
9
|
+
const CUSTOM_ERROR_FLAGS = { customError: true };
|
|
10
|
+
const NO_ERROR_FLAGS = {};
|
|
11
|
+
const VALID_STATE = {
|
|
12
|
+
badInput: false,
|
|
13
|
+
customError: false,
|
|
14
|
+
patternMismatch: false,
|
|
15
|
+
rangeOverflow: false,
|
|
16
|
+
rangeUnderflow: false,
|
|
17
|
+
stepMismatch: false,
|
|
18
|
+
tooLong: false,
|
|
19
|
+
tooShort: false,
|
|
20
|
+
typeMismatch: false,
|
|
21
|
+
valid: true,
|
|
22
|
+
valueMissing: false,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { CUSTOM_ERROR_FLAGS as C, NO_ERROR_FLAGS as N, VALID_STATE as V };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=controls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"controls.js","mappings":";;;;;AAAA;AACA;AACA;MAmFa,kBAAkB,GAAuB,EAAE,WAAW,EAAE,IAAI,GAAE;MAC9D,cAAc,GAAuB,GAAE;MACvC,WAAW,GAAkB;IACxC,QAAQ,EAAE,KAAK;IACf,WAAW,EAAE,KAAK;IAClB,eAAe,EAAE,KAAK;IACtB,aAAa,EAAE,KAAK;IACpB,cAAc,EAAE,KAAK;IACrB,YAAY,EAAE,KAAK;IACnB,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,KAAK;IACf,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE,IAAI;IACX,YAAY,EAAE,KAAK;;;;;","names":[],"sources":["src/components/controls.ts"],"sourcesContent":["// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nexport type AutoComplete =\n | 'additional-name'\n | 'address-level1'\n | 'address-level2'\n | 'address-level3'\n | 'address-level4'\n | 'address-line1'\n | 'address-line2'\n | 'address-line3'\n | 'bday-day'\n | 'bday-month'\n | 'bday-year'\n | 'bday'\n | 'cc-additional-name'\n | 'cc-csc'\n | 'cc-exp-month'\n | 'cc-exp-year'\n | 'cc-exp'\n | 'cc-family-name'\n | 'cc-given-name'\n | 'cc-name'\n | 'cc-number'\n | 'cc-type'\n | 'country-name'\n | 'country'\n | 'current-password'\n | 'email'\n | 'family-name'\n | 'given-name'\n | 'honorific-prefix'\n | 'honorific-suffix'\n | 'impp'\n | 'language'\n | 'name'\n | 'new-password'\n | 'nickname'\n | 'off'\n | 'on'\n | 'one-time-code'\n | 'organization-title'\n | 'organization'\n | 'photo'\n | 'postal-code'\n | 'sex'\n | 'street-address'\n | 'tel-area-code'\n | 'tel-country-code'\n | 'tel-extension'\n | 'tel-local'\n | 'tel-national'\n | 'tel'\n | 'transaction-amount'\n | 'transaction-currency'\n | 'url'\n | 'username'\nexport type AutoCapitalize =\n | 'characters'\n | 'none'\n | 'off'\n | 'on'\n | 'sentences'\n | 'words'\nexport type EnterKeyHint =\n | 'done'\n | 'enter'\n | 'go'\n | 'next'\n | 'previous'\n | 'search'\n | 'send'\nexport type InputMode =\n | 'decimal'\n | 'email'\n | 'none'\n | 'numeric'\n | 'search'\n | 'tel'\n | 'text'\n | 'url'\nexport type Value = number | string | null\n\nexport const CUSTOM_ERROR_FLAGS: ValidityStateFlags = { customError: true }\nexport const NO_ERROR_FLAGS: ValidityStateFlags = {}\nexport const VALID_STATE: ValidityState = {\n badInput: false,\n customError: false,\n patternMismatch: false,\n rangeOverflow: false,\n rangeUnderflow: false,\n stepMismatch: false,\n tooLong: false,\n tooShort: false,\n typeMismatch: false,\n valid: true,\n valueMissing: false,\n}\n"],"version":3}
|
package/components/helpers.js
CHANGED
|
@@ -20,68 +20,68 @@
|
|
|
20
20
|
* @param attributes Which attributes to inherit.
|
|
21
21
|
*/
|
|
22
22
|
const inheritAttributes = (element, attributes = []) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
const attributeObject = {};
|
|
24
|
+
for (const attribute of attributes) {
|
|
25
|
+
const value = element.getAttribute(attribute);
|
|
26
|
+
if (value !== null) {
|
|
27
|
+
attributeObject[attribute] = value;
|
|
28
|
+
element.removeAttribute(attribute);
|
|
29
|
+
}
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
-
return attributeObject;
|
|
31
|
+
return attributeObject;
|
|
32
32
|
};
|
|
33
33
|
const ariaAttributes = [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
34
|
+
'aria-activedescendant',
|
|
35
|
+
'aria-atomic',
|
|
36
|
+
'aria-autocomplete',
|
|
37
|
+
'aria-braillelabel',
|
|
38
|
+
'aria-brailleroledescription',
|
|
39
|
+
'aria-busy',
|
|
40
|
+
'aria-checked',
|
|
41
|
+
'aria-colcount',
|
|
42
|
+
'aria-colindex',
|
|
43
|
+
'aria-colindextext',
|
|
44
|
+
'aria-colspan',
|
|
45
|
+
'aria-controls',
|
|
46
|
+
'aria-current',
|
|
47
|
+
'aria-describedby',
|
|
48
|
+
'aria-description',
|
|
49
|
+
'aria-details',
|
|
50
|
+
'aria-disabled',
|
|
51
|
+
'aria-errormessage',
|
|
52
|
+
'aria-expanded',
|
|
53
|
+
'aria-flowto',
|
|
54
|
+
'aria-haspopup',
|
|
55
|
+
'aria-hidden',
|
|
56
|
+
'aria-invalid',
|
|
57
|
+
'aria-keyshortcuts',
|
|
58
|
+
'aria-label',
|
|
59
|
+
'aria-labelledby',
|
|
60
|
+
'aria-level',
|
|
61
|
+
'aria-live',
|
|
62
|
+
'aria-multiline',
|
|
63
|
+
'aria-multiselectable',
|
|
64
|
+
'aria-orientation',
|
|
65
|
+
'aria-owns',
|
|
66
|
+
'aria-placeholder',
|
|
67
|
+
'aria-posinset',
|
|
68
|
+
'aria-pressed',
|
|
69
|
+
'aria-readonly',
|
|
70
|
+
'aria-relevant',
|
|
71
|
+
'aria-required',
|
|
72
|
+
'aria-roledescription',
|
|
73
|
+
'aria-rowcount',
|
|
74
|
+
'aria-rowindex',
|
|
75
|
+
'aria-rowindextext',
|
|
76
|
+
'aria-rowspan',
|
|
77
|
+
'aria-selected',
|
|
78
|
+
'aria-setsize',
|
|
79
|
+
'aria-sort',
|
|
80
|
+
'aria-valuemax',
|
|
81
|
+
'aria-valuemin',
|
|
82
|
+
'aria-valuenow',
|
|
83
|
+
'aria-valuetext',
|
|
84
|
+
'role',
|
|
85
85
|
];
|
|
86
86
|
/**
|
|
87
87
|
* Returns an array of aria attributes that should be copied from
|
|
@@ -98,10 +98,10 @@ const prefix = 'Invariant failed';
|
|
|
98
98
|
* @param message Optional message to display in development builds.
|
|
99
99
|
*/
|
|
100
100
|
function invariant(value, message) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
102
|
+
if (value)
|
|
103
|
+
return;
|
|
104
|
+
throw new Error(prefix);
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
107
107
|
* From an object pick a set of keys.
|
|
@@ -111,65 +111,65 @@ function invariant(value, message) {
|
|
|
111
111
|
* @returns New object with only the picked keys.
|
|
112
112
|
*/
|
|
113
113
|
const pick = (object, ...keys) => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
const returnValue = {};
|
|
115
|
+
for (const key of keys)
|
|
116
|
+
returnValue[key] = object[key];
|
|
117
|
+
return returnValue;
|
|
118
118
|
};
|
|
119
119
|
const pickFocusEventAttributes = (event) => pick(event, 'relatedTarget');
|
|
120
120
|
const pickInputEventAttributes = (event) => pick(event, 'data', 'inputType', 'isComposing');
|
|
121
121
|
const getConversionFactor = (element, unit) => {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
switch (unit) {
|
|
123
|
+
case 'cm': {
|
|
124
|
+
return 96 / 2.54;
|
|
125
|
+
}
|
|
126
|
+
case 'em': {
|
|
127
|
+
return Number.parseFloat(globalThis.getComputedStyle(element.parentElement ?? document.documentElement).fontSize);
|
|
128
|
+
}
|
|
129
|
+
case 'in': {
|
|
130
|
+
return 96;
|
|
131
|
+
}
|
|
132
|
+
case 'mm': {
|
|
133
|
+
return 96 / 25.4;
|
|
134
|
+
}
|
|
135
|
+
case 'pc': {
|
|
136
|
+
return 16;
|
|
137
|
+
}
|
|
138
|
+
case 'pt': {
|
|
139
|
+
return 96 / 72;
|
|
140
|
+
}
|
|
141
|
+
case 'px': {
|
|
142
|
+
return 1;
|
|
143
|
+
}
|
|
144
|
+
case 'rem': {
|
|
145
|
+
return Number.parseFloat(globalThis.getComputedStyle(document.documentElement).fontSize);
|
|
146
|
+
}
|
|
147
|
+
default: {
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
125
150
|
}
|
|
126
|
-
case 'em': {
|
|
127
|
-
return Number.parseFloat(globalThis.getComputedStyle(element.parentElement ?? document.documentElement).fontSize);
|
|
128
|
-
}
|
|
129
|
-
case 'in': {
|
|
130
|
-
return 96;
|
|
131
|
-
}
|
|
132
|
-
case 'mm': {
|
|
133
|
-
return 96 / 25.4;
|
|
134
|
-
}
|
|
135
|
-
case 'pc': {
|
|
136
|
-
return 16;
|
|
137
|
-
}
|
|
138
|
-
case 'pt': {
|
|
139
|
-
return 96 / 72;
|
|
140
|
-
}
|
|
141
|
-
case 'px': {
|
|
142
|
-
return 1;
|
|
143
|
-
}
|
|
144
|
-
case 'rem': {
|
|
145
|
-
return Number.parseFloat(globalThis.getComputedStyle(document.documentElement).fontSize);
|
|
146
|
-
}
|
|
147
|
-
default: {
|
|
148
|
-
return undefined;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
151
|
};
|
|
152
152
|
const propertyToPx = (element, property) => {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
153
|
+
const value = globalThis.getComputedStyle(element).getPropertyValue(property);
|
|
154
|
+
const number = Number.parseFloat(value);
|
|
155
|
+
if (Number.isNaN(number))
|
|
156
|
+
return undefined;
|
|
157
|
+
const unit = /\s*[\d+.-]*\s*(.*)/.exec(value)?.[1] ?? '';
|
|
158
|
+
const conversionFactor = getConversionFactor(element, unit) ?? 1;
|
|
159
|
+
return number * conversionFactor;
|
|
160
160
|
};
|
|
161
161
|
const ignorePromise = (promise) => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
promise.catch(() => {
|
|
163
|
+
invariant(false);
|
|
164
|
+
});
|
|
165
165
|
};
|
|
166
166
|
const isTouchDevice = () => 'ontouchstart' in globalThis ||
|
|
167
|
-
|
|
167
|
+
('maxTouchPoints' in globalThis && globalThis.navigator.maxTouchPoints > 0);
|
|
168
168
|
const roundByDPR = (value) => {
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
const dpr = devicePixelRatio || 1;
|
|
170
|
+
return Math.round(value * dpr) / dpr;
|
|
171
171
|
};
|
|
172
172
|
|
|
173
|
-
export {
|
|
173
|
+
export { inheritAttributes as a, ignorePromise as b, invariant as c, propertyToPx as d, pickInputEventAttributes as e, isTouchDevice as f, inheritAriaAttributes as i, pickFocusEventAttributes as p, roundByDPR as r };
|
|
174
174
|
|
|
175
175
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"helpers.js","mappings":";;;;;AAAA;AACA;AACA;AAUA;;;;;;;;;;;;;MAaa,iBAAiB,GAAG,CAC/B,OAAgB,EAChB,aAAuB,EAAE;
|
|
1
|
+
{"file":"helpers.js","mappings":"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","names":[],"sources":["src/helpers.ts"],"sourcesContent":["// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nimport type {\n MiddlewareState,\n OffsetOptions as LibraryOffsetOptions,\n} from '@floating-ui/dom'\nimport type { Except, Replace } from 'type-fest'\n\nexport type Attributes = Record<string, string | undefined>\n\n/**\n * Elements inside of web components sometimes need to inherit global attributes\n * set on the host. For example, the inner input in `qds-input` should inherit\n * the `tabindex` attribute that developers set directly on `qds-input`. This\n * helper function should be called in componentWillLoad and assigned to a variable\n * that is later used in the render function.\n *\n * This does not need to be reactive as changing attributes on the host element\n * does not trigger a re-render.\n *\n * @param element Element to inherit attributes from.\n * @param attributes Which attributes to inherit.\n */\nexport const 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\nexport const roundByDPR = (value: number): number => {\n const dpr = devicePixelRatio || 1\n return Math.round(value * dpr) / dpr\n}\n\nexport type OffsetValue = Except<\n Exclude<\n LibraryOffsetOptions,\n // eslint-disable-next-line @typescript-eslint/ban-types\n Function | number\n >,\n 'mainAxis'\n>\nexport type OffsetFunction = (state: MiddlewareState) => OffsetValue\nexport type OffsetOptions = OffsetFunction | OffsetValue\n"],"version":3}
|
package/components/icon.js
CHANGED
|
@@ -22,26 +22,26 @@ const xMarkSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5v
|
|
|
22
22
|
|
|
23
23
|
// SPDX-FileCopyrightText: © 2023 Schneider Electric
|
|
24
24
|
const icons = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
26
|
+
'external-link': arrowTopRightOnSquareSvg,
|
|
27
|
+
checked: checkSvg,
|
|
28
|
+
indeterminate: minusSvg,
|
|
29
|
+
dropdown: caretDownSvg,
|
|
30
|
+
'status-error': xMarkSvg,
|
|
31
|
+
'status-info': informationSvg,
|
|
32
|
+
'status-success': checkSvg,
|
|
33
|
+
'status-warning': exclamationSvg,
|
|
34
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
35
35
|
};
|
|
36
36
|
const coreLibrary = {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
name: 'core',
|
|
38
|
+
resolver: (name) => icons[name] ?? '',
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
// SPDX-FileCopyrightText: © 2023 Schneider Electric
|
|
42
42
|
const library = {
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
name: 'default',
|
|
44
|
+
resolver: (name) => getAssetPath(`icons/${name}.svg`),
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
// SPDX-FileCopyrightText: © 2023 Schneider Electric
|
|
@@ -54,136 +54,137 @@ const getIconLibrary = (name) => registry.find((library) => library.name === nam
|
|
|
54
54
|
* Removes an icon library from the registry.
|
|
55
55
|
*/
|
|
56
56
|
const unregisterIconLibrary = (name) => {
|
|
57
|
-
|
|
57
|
+
registry = registry.filter((library) => library.name !== name);
|
|
58
58
|
};
|
|
59
59
|
/**
|
|
60
60
|
* Adds an icon library to the registry or overrides an existing one.
|
|
61
61
|
*/
|
|
62
62
|
const registerIconLibrary = (name, options) => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
unregisterIconLibrary(name);
|
|
64
|
+
registry.push({
|
|
65
|
+
name,
|
|
66
|
+
...options,
|
|
67
|
+
});
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
// SPDX-FileCopyrightText: © 2023 Schneider Electric
|
|
71
71
|
//
|
|
72
72
|
// SPDX-License-Identifier: LGPL-2.1-only
|
|
73
73
|
const request = async (source) => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
const response = await fetch(source, { mode: 'cors' });
|
|
75
|
+
return {
|
|
76
|
+
ok: response.ok,
|
|
77
|
+
data: await response.text(),
|
|
78
|
+
};
|
|
79
79
|
};
|
|
80
80
|
const cachedIconRequests = new Map();
|
|
81
81
|
const requestIcon = async (url) => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
82
|
+
const cachedIconRequest = cachedIconRequests.get(url);
|
|
83
|
+
if (cachedIconRequest)
|
|
84
|
+
return cachedIconRequest;
|
|
85
|
+
const fileData = await request(url);
|
|
86
|
+
const iconFileData = {
|
|
87
|
+
ok: fileData.ok,
|
|
88
|
+
};
|
|
89
|
+
if (fileData.ok) {
|
|
90
|
+
const div = document.createElement('div');
|
|
91
|
+
div.innerHTML = fileData.data;
|
|
92
|
+
const child = div.firstElementChild;
|
|
93
|
+
iconFileData.data =
|
|
94
|
+
child?.tagName.toLowerCase() === 'svg' ? child.outerHTML : '';
|
|
95
|
+
}
|
|
96
|
+
cachedIconRequests.set(url, iconFileData);
|
|
97
|
+
return iconFileData;
|
|
98
98
|
};
|
|
99
99
|
|
|
100
100
|
const iconCss = ":host([hidden]){display:none !important}:host{contain:strict;display:inline-block;height:1em;width:1em}.qds-wrapper{display:contents}svg{display:block;fill:currentcolor;height:100%;width:100%}";
|
|
101
101
|
|
|
102
102
|
let parser;
|
|
103
103
|
const Icon = /*@__PURE__*/ proxyCustomElement(class Icon extends HTMLElement {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
this.svg = '';
|
|
114
|
-
}
|
|
115
|
-
async setIcon() {
|
|
116
|
-
if (!this.name)
|
|
117
|
-
return;
|
|
118
|
-
const library = getIconLibrary(this.library);
|
|
119
|
-
if (!library)
|
|
120
|
-
return;
|
|
121
|
-
const url = library.resolver(this.name);
|
|
122
|
-
if (!url) {
|
|
123
|
-
this.svg = '';
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
try {
|
|
127
|
-
const request = await requestIcon(url);
|
|
128
|
-
if (!request.ok) {
|
|
129
|
-
this.svg = '';
|
|
130
|
-
this.errorEmitter.emit();
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
// Create an instance of the DOM parser. We do it here instead of at the
|
|
134
|
-
// top-level to support SSR while maintaining a single parser instance
|
|
135
|
-
// for optimal performance.
|
|
136
|
-
parser || (parser = new DOMParser());
|
|
137
|
-
const document = parser.parseFromString(request.data, 'text/html');
|
|
138
|
-
const svgElement = document.body.querySelector('svg');
|
|
139
|
-
if (svgElement === null) {
|
|
104
|
+
constructor() {
|
|
105
|
+
super();
|
|
106
|
+
this.__registerHost();
|
|
107
|
+
this.__attachShadow();
|
|
108
|
+
this.loadEmitter = createEvent(this, "qdsLoad", 6);
|
|
109
|
+
this.errorEmitter = createEvent(this, "qdsError", 6);
|
|
110
|
+
this.inheritedAttributes = {};
|
|
111
|
+
this.name = undefined;
|
|
112
|
+
this.library = 'default';
|
|
140
113
|
this.svg = '';
|
|
141
|
-
this.errorEmitter.emit();
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
for (const [key, value] of Object.entries(this.inheritedAttributes))
|
|
145
|
-
svgElement.setAttribute(key, value);
|
|
146
|
-
this.svg = svgElement.outerHTML;
|
|
147
|
-
this.loadEmitter.emit();
|
|
148
|
-
}
|
|
149
114
|
}
|
|
150
|
-
|
|
151
|
-
|
|
115
|
+
async setIcon() {
|
|
116
|
+
if (!this.name)
|
|
117
|
+
return;
|
|
118
|
+
const library = getIconLibrary(this.library);
|
|
119
|
+
if (!library)
|
|
120
|
+
return;
|
|
121
|
+
const url = library.resolver(this.name);
|
|
122
|
+
if (!url) {
|
|
123
|
+
this.svg = '';
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
const request = await requestIcon(url);
|
|
128
|
+
if (!request.ok) {
|
|
129
|
+
this.svg = '';
|
|
130
|
+
this.errorEmitter.emit();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
// Create an instance of the DOM parser. We do it here instead of at the
|
|
134
|
+
// top-level to support SSR while maintaining a single parser instance
|
|
135
|
+
// for optimal performance.
|
|
136
|
+
parser || (parser = new DOMParser());
|
|
137
|
+
const document = parser.parseFromString(request.data, 'text/html');
|
|
138
|
+
const svgElement = document.body.querySelector('svg');
|
|
139
|
+
if (svgElement === null) {
|
|
140
|
+
this.svg = '';
|
|
141
|
+
this.errorEmitter.emit();
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
for (const [key, value] of Object.entries(this.inheritedAttributes))
|
|
145
|
+
if (value !== undefined)
|
|
146
|
+
svgElement.setAttribute(key, value);
|
|
147
|
+
this.svg = svgElement.outerHTML;
|
|
148
|
+
this.loadEmitter.emit();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
this.errorEmitter.emit();
|
|
153
|
+
}
|
|
152
154
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
static get style() { return iconCss; }
|
|
155
|
+
async componentWillLoad() {
|
|
156
|
+
this.inheritedAttributes = inheritAriaAttributes(this.element);
|
|
157
|
+
await this.setIcon();
|
|
158
|
+
}
|
|
159
|
+
render() {
|
|
160
|
+
return h("span", { class: "qds-wrapper", innerHTML: this.svg });
|
|
161
|
+
}
|
|
162
|
+
get element() { return this; }
|
|
163
|
+
static get watchers() { return {
|
|
164
|
+
"name": ["setIcon"],
|
|
165
|
+
"library": ["setIcon"]
|
|
166
|
+
}; }
|
|
167
|
+
static get style() { return iconCss; }
|
|
167
168
|
}, [1, "qds-icon", {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
169
|
+
"name": [1],
|
|
170
|
+
"library": [1],
|
|
171
|
+
"svg": [32]
|
|
172
|
+
}, undefined, {
|
|
173
|
+
"name": ["setIcon"],
|
|
174
|
+
"library": ["setIcon"]
|
|
175
|
+
}]);
|
|
175
176
|
function defineCustomElement() {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
177
|
+
if (typeof customElements === "undefined") {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const components = ["qds-icon"];
|
|
181
|
+
components.forEach(tagName => { switch (tagName) {
|
|
182
|
+
case "qds-icon":
|
|
183
|
+
if (!customElements.get(tagName)) {
|
|
184
|
+
customElements.define(tagName, Icon);
|
|
185
|
+
}
|
|
186
|
+
break;
|
|
187
|
+
} });
|
|
187
188
|
}
|
|
188
189
|
|
|
189
190
|
export { Icon as I, defineCustomElement as d, registerIconLibrary as r, unregisterIconLibrary as u };
|