@digdir/designsystemet-web 0.0.1 → 1.12.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 (150) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +277 -21
  3. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -0
  4. package/dist/cjs/breadcrumbs/breadcrumbs.cjs +2 -0
  5. package/dist/cjs/breadcrumbs/breadcrumbs.cjs.map +1 -0
  6. package/dist/cjs/clickdelegatefor/clickdelegatefor.cjs +2 -0
  7. package/dist/cjs/clickdelegatefor/clickdelegatefor.cjs.map +1 -0
  8. package/dist/cjs/dialog/dialog.cjs +2 -0
  9. package/dist/cjs/dialog/dialog.cjs.map +1 -0
  10. package/dist/cjs/error-summary/error-summary.cjs +2 -0
  11. package/dist/cjs/error-summary/error-summary.cjs.map +1 -0
  12. package/dist/cjs/field/field.cjs +2 -0
  13. package/dist/cjs/field/field.cjs.map +1 -0
  14. package/dist/cjs/index.cjs +1 -36
  15. package/dist/cjs/index.cjs.map +1 -1
  16. package/dist/cjs/pagination/pagination.cjs +2 -0
  17. package/dist/cjs/pagination/pagination.cjs.map +1 -0
  18. package/dist/cjs/popover/popover.cjs +2 -0
  19. package/dist/cjs/popover/popover.cjs.map +1 -0
  20. package/dist/cjs/readonly/readonly.cjs +2 -0
  21. package/dist/cjs/readonly/readonly.cjs.map +1 -0
  22. package/dist/cjs/suggestion/suggestion.cjs +2 -0
  23. package/dist/cjs/suggestion/suggestion.cjs.map +1 -0
  24. package/dist/cjs/tabs/tabs.cjs +2 -0
  25. package/dist/cjs/tabs/tabs.cjs.map +1 -0
  26. package/dist/cjs/toggle-group/toggle-group.cjs +2 -0
  27. package/dist/cjs/toggle-group/toggle-group.cjs.map +1 -0
  28. package/dist/cjs/tooltip/tooltip.cjs +2 -0
  29. package/dist/cjs/tooltip/tooltip.cjs.map +1 -0
  30. package/dist/cjs/utils/utils.cjs +2 -0
  31. package/dist/cjs/utils/utils.cjs.map +1 -0
  32. package/dist/custom-elements.json +531 -0
  33. package/dist/esm/breadcrumbs/breadcrumbs.js +2 -0
  34. package/dist/esm/breadcrumbs/breadcrumbs.js.map +1 -0
  35. package/dist/esm/clickdelegatefor/clickdelegatefor.js +2 -0
  36. package/dist/esm/clickdelegatefor/clickdelegatefor.js.map +1 -0
  37. package/dist/esm/dialog/dialog.js +2 -0
  38. package/dist/esm/dialog/dialog.js.map +1 -0
  39. package/dist/esm/error-summary/error-summary.js +2 -0
  40. package/dist/esm/error-summary/error-summary.js.map +1 -0
  41. package/dist/esm/field/field.js +2 -0
  42. package/dist/esm/field/field.js.map +1 -0
  43. package/dist/esm/index.js +1 -21
  44. package/dist/esm/index.js.map +1 -1
  45. package/dist/esm/pagination/pagination.js +2 -0
  46. package/dist/esm/pagination/pagination.js.map +1 -0
  47. package/dist/esm/popover/popover.js +2 -0
  48. package/dist/esm/popover/popover.js.map +1 -0
  49. package/dist/esm/readonly/readonly.js +2 -0
  50. package/dist/esm/readonly/readonly.js.map +1 -0
  51. package/dist/esm/suggestion/suggestion.js +2 -0
  52. package/dist/esm/suggestion/suggestion.js.map +1 -0
  53. package/dist/esm/tabs/tabs.js +2 -0
  54. package/dist/esm/tabs/tabs.js.map +1 -0
  55. package/dist/esm/toggle-group/toggle-group.js +2 -0
  56. package/dist/esm/toggle-group/toggle-group.js.map +1 -0
  57. package/dist/esm/tooltip/tooltip.js +2 -0
  58. package/dist/esm/tooltip/tooltip.js.map +1 -0
  59. package/dist/esm/utils/utils.js +2 -0
  60. package/dist/esm/utils/utils.js.map +1 -0
  61. package/dist/index.d.ts +321 -0
  62. package/dist/index.js +710 -0
  63. package/dist/umd/index.js +15 -0
  64. package/dist/umd/index.js.map +1 -0
  65. package/dist/vscode.html-custom-data.json +60 -0
  66. package/dist/web.manifest.json +969 -0
  67. package/dist/web.vscode.json +60 -0
  68. package/package.json +56 -46
  69. package/dist/cjs/_virtual/rolldown_runtime.cjs +0 -29
  70. package/dist/cjs/breadcrumbs.cjs +0 -50
  71. package/dist/cjs/breadcrumbs.cjs.map +0 -1
  72. package/dist/cjs/clickdelegatefor.cjs +0 -35
  73. package/dist/cjs/clickdelegatefor.cjs.map +0 -1
  74. package/dist/cjs/details.cjs +0 -21
  75. package/dist/cjs/details.cjs.map +0 -1
  76. package/dist/cjs/dialog.cjs +0 -18
  77. package/dist/cjs/dialog.cjs.map +0 -1
  78. package/dist/cjs/error-summary.cjs +0 -24
  79. package/dist/cjs/error-summary.cjs.map +0 -1
  80. package/dist/cjs/field.cjs +0 -115
  81. package/dist/cjs/field.cjs.map +0 -1
  82. package/dist/cjs/pagination.cjs +0 -72
  83. package/dist/cjs/pagination.cjs.map +0 -1
  84. package/dist/cjs/popover.cjs +0 -89
  85. package/dist/cjs/popover.cjs.map +0 -1
  86. package/dist/cjs/suggestion.cjs +0 -24
  87. package/dist/cjs/suggestion.cjs.map +0 -1
  88. package/dist/cjs/tabs.cjs +0 -21
  89. package/dist/cjs/tabs.cjs.map +0 -1
  90. package/dist/cjs/toggle-group.cjs +0 -29
  91. package/dist/cjs/toggle-group.cjs.map +0 -1
  92. package/dist/cjs/tooltip.cjs +0 -55
  93. package/dist/cjs/tooltip.cjs.map +0 -1
  94. package/dist/cjs/utils.cjs +0 -159
  95. package/dist/cjs/utils.cjs.map +0 -1
  96. package/dist/esm/breadcrumbs.js +0 -50
  97. package/dist/esm/breadcrumbs.js.map +0 -1
  98. package/dist/esm/clickdelegatefor.js +0 -35
  99. package/dist/esm/clickdelegatefor.js.map +0 -1
  100. package/dist/esm/details.js +0 -21
  101. package/dist/esm/details.js.map +0 -1
  102. package/dist/esm/dialog.js +0 -18
  103. package/dist/esm/dialog.js.map +0 -1
  104. package/dist/esm/error-summary.js +0 -24
  105. package/dist/esm/error-summary.js.map +0 -1
  106. package/dist/esm/field.js +0 -115
  107. package/dist/esm/field.js.map +0 -1
  108. package/dist/esm/pagination.js +0 -71
  109. package/dist/esm/pagination.js.map +0 -1
  110. package/dist/esm/popover.js +0 -88
  111. package/dist/esm/popover.js.map +0 -1
  112. package/dist/esm/src/breadcrumbs.d.ts +0 -16
  113. package/dist/esm/src/breadcrumbs.d.ts.map +0 -1
  114. package/dist/esm/src/clickdelegatefor.d.ts +0 -2
  115. package/dist/esm/src/clickdelegatefor.d.ts.map +0 -1
  116. package/dist/esm/src/details.d.ts +0 -2
  117. package/dist/esm/src/details.d.ts.map +0 -1
  118. package/dist/esm/src/dialog.d.ts +0 -2
  119. package/dist/esm/src/dialog.d.ts.map +0 -1
  120. package/dist/esm/src/error-summary.d.ts +0 -12
  121. package/dist/esm/src/error-summary.d.ts.map +0 -1
  122. package/dist/esm/src/field.d.ts +0 -15
  123. package/dist/esm/src/field.d.ts.map +0 -1
  124. package/dist/esm/src/index.d.ts +0 -14
  125. package/dist/esm/src/index.d.ts.map +0 -1
  126. package/dist/esm/src/pagination.d.ts +0 -27
  127. package/dist/esm/src/pagination.d.ts.map +0 -1
  128. package/dist/esm/src/popover.d.ts +0 -2
  129. package/dist/esm/src/popover.d.ts.map +0 -1
  130. package/dist/esm/src/suggestion.d.ts +0 -11
  131. package/dist/esm/src/suggestion.d.ts.map +0 -1
  132. package/dist/esm/src/tabs.d.ts +0 -18
  133. package/dist/esm/src/tabs.d.ts.map +0 -1
  134. package/dist/esm/src/toggle-group.d.ts +0 -2
  135. package/dist/esm/src/toggle-group.d.ts.map +0 -1
  136. package/dist/esm/src/tooltip.d.ts +0 -2
  137. package/dist/esm/src/tooltip.d.ts.map +0 -1
  138. package/dist/esm/src/utils.d.ts +0 -78
  139. package/dist/esm/src/utils.d.ts.map +0 -1
  140. package/dist/esm/suggestion.js +0 -23
  141. package/dist/esm/suggestion.js.map +0 -1
  142. package/dist/esm/tabs.js +0 -16
  143. package/dist/esm/tabs.js.map +0 -1
  144. package/dist/esm/toggle-group.js +0 -29
  145. package/dist/esm/toggle-group.js.map +0 -1
  146. package/dist/esm/tooltip.js +0 -55
  147. package/dist/esm/tooltip.js.map +0 -1
  148. package/dist/esm/tsconfig.tsbuildinfo +0 -1
  149. package/dist/esm/utils.js +0 -145
  150. package/dist/esm/utils.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.cjs","names":[],"sources":["../../../src/utils/utils.ts"],"sourcesContent":["export const QUICK_EVENT = { passive: true, capture: true };\n\n// Using function instead of constant to support evnironments where DOM can be unloaded (like Vitest with jsdom)\nexport const isBrowser = () =>\n typeof window !== 'undefined' && typeof document !== 'undefined';\n\nexport const isWindows = () =>\n isBrowser() &&\n // @ts-expect-error Typescript has not implemented userAgentData yet https://stackoverflow.com/a/71392474\n /^Win/i.test(navigator.userAgentData?.platform || navigator.platform);\n\n// Make sure we have a HTMLElement to extend (for server side rendering)\nexport const DSElement =\n typeof HTMLElement === 'undefined'\n ? (class {} as typeof HTMLElement)\n : HTMLElement;\n\nexport function debounce<T extends unknown[]>(\n callback: (...args: T) => void,\n delay: number,\n) {\n let timer: ReturnType<typeof setTimeout>;\n\n return function (this: unknown, ...args: T) {\n clearTimeout(timer);\n timer = setTimeout(() => callback.apply(this, args), delay);\n };\n}\n\n/**\n * warn\n * @description Utility to console.warn, but can be silenced in production with window.dsWarnings = false;\n */\ndeclare global {\n interface Window {\n dsWarnings?: boolean;\n }\n}\nexport const warn = (\n message: string,\n ...args: Parameters<typeof console.warn>\n) =>\n typeof window === 'undefined' ||\n window.dsWarnings === false ||\n console.warn(`Designsystemet: ${message}`, ...args);\n\n/**\n * attr\n * @description Utility to quickly get, set and remove attributes\n * @param el The Element to read/write attributes from\n * @param name The attribute name to get, set or remove, or a object to set multiple attributes\n * @param value A valid attribute value or null to remove attribute\n */\nexport const attr = (\n el: Element,\n name: string,\n value?: string | null,\n): string | null => {\n if (value === undefined) return el.getAttribute(name) ?? null; // Fallback to null only if el is undefined\n if (value === null) el.removeAttribute(name);\n else if (el.getAttribute(name) !== value) el.setAttribute(name, value);\n return null;\n};\n\n/**\n * attrOrCSS\n * @description Retrieves and updates attribute based on attribute or CSS property value\n * @param el The Element to read attributes/CSS from\n * @param name Attribute or CSS property to get\n * @return string attribute or CSS property value\n */\nconst STRIP_SURROUNDING_QUOTES = /^[\"']|[\"']$/g; // Matches surrounding single or double quotes\nexport const attrOrCSS = (el: Element, name: string) => {\n let value = attr(el, name);\n if (!value) {\n const prop = getComputedStyle(el).getPropertyValue(`--_ds-${name}`);\n value = prop.replace(STRIP_SURROUNDING_QUOTES, '').trim() || null;\n }\n if (!value) warn(`Missing ${name} on:`, el);\n return value;\n};\n\n/**\n * on\n * @param el The Element to use as EventTarget\n * @param types A space separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const on = (\n el: Node | Window | ShadowRoot,\n ...rest: Parameters<typeof Element.prototype.addEventListener>\n): (() => void) => {\n const [types, ...options] = rest;\n for (const type of types.split(' ')) el.addEventListener(type, ...options);\n return () => off(el, ...rest);\n};\n\n/**\n * off\n * @param el The Element to use as EventTarget\n * @param types A space separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const off = (\n el: Node | Window | ShadowRoot,\n ...rest: Parameters<typeof Element.prototype.removeEventListener>\n): void => {\n const [types, ...options] = rest;\n for (const type of types.split(' ')) el.removeEventListener(type, ...options);\n};\n\n// Used to store cleanup functions for hot-reloading\ndeclare global {\n interface Window {\n _dsHotReloadCleanup?: Map<string, Array<() => void>>;\n }\n}\n\n/**\n * onHotReload\n * @description Runs a callback when window is loaded in browser, and ensures cleanup when hot-reloading\n * @param key The key to identify setup and corresponding cleanup\n * @param callback The callback to run when the page is ready\n */\nexport const onHotReload = (key: string, setup: () => Array<() => void>) => {\n if (!isBrowser()) return; // Skip if not in modern browser environment, but on each call as Vitest might have unloaded jsdom between tests\n if (!window._dsHotReloadCleanup) window._dsHotReloadCleanup = new Map(); // Hot reload cleanup support supporting all build tools\n\n window._dsHotReloadCleanup?.get(key)?.map((cleanup) => cleanup()); // Run previous cleanup\n window._dsHotReloadCleanup?.set(key, setup()); // Store new cleanup\n};\n\n/**\n * Speed up MutationObserver by debouncing and only running when page is visible\n * @return new MutaionObserver\n */\nlet SKIP_MUTATIONS = false;\nexport const onMutation = (\n el: Node,\n callback: (observer: MutationObserver) => void,\n options: MutationObserverInit,\n) => {\n let queue = 0;\n const onFrame = () => {\n if (!el.isConnected) return cleanup(); // Stop observing if element is removed from DOM\n callback(observer);\n observer.takeRecords(); // Clear records in case mutations happened during callback\n queue = 0;\n };\n const cleanup = () => observer?.disconnect?.();\n const observer = new MutationObserver(() => {\n if (!SKIP_MUTATIONS && !queue) queue = requestAnimationFrame(onFrame); // requestAnimationFrame only runs when page is visible\n });\n\n observer.observe(el, options);\n requestAnimationFrame(onFrame); // Initial run when page is visible and children has mounted\n return cleanup;\n};\n\n/**\n * Many mutation observers need to watch childNodes, thus running on all `textContent` changes\n * This utility allows skipping mutation observers while updating textContent\n */\nexport const setTextWithoutMutation = (el: Element, text: string | null) => {\n SKIP_MUTATIONS = true;\n el.textContent = text;\n requestAnimationFrame(enableMutations); // Let all mutationobservers run before enabling again\n};\nconst enableMutations = () => {\n SKIP_MUTATIONS = false;\n};\n\n/**\n * tag\n * @description creates element and assigns properties\n * @param tagName The tagname of element to create\n * @param attrs Optional attributes to add to the element\n * @param text Optional text content to add to the element\n * @return HTMLElement with props\n */\nexport const tag = <TagName extends keyof HTMLElementTagNameMap>(\n tagName: TagName,\n attrs?: Record<string, string | null> | null,\n): HTMLElementTagNameMap[TagName] => {\n const el = document.createElement(tagName);\n if (attrs) for (const [key, val] of Object.entries(attrs)) attr(el, key, val);\n return el;\n};\n\n/**\n * customElements.define\n * @description Defines a customElement if running in browser and if not already registered\n * Scoped/named \"customElements.define\" so @custom-elements-manifest/analyzer can find tag names\n */\nexport const customElements = {\n define: (name: string, instance: CustomElementConstructor) =>\n !isBrowser() ||\n window.customElements.get(name) ||\n window.customElements.define(name, instance),\n};\n\n/**\n * useId\n * @return A generated unique ID\n */\nlet id = 0;\nconst hash = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;\nexport function useId(el?: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1,531 @@
1
+ {
2
+ "schemaVersion": "1.0.0",
3
+ "readme": "",
4
+ "modules": [
5
+ {
6
+ "kind": "javascript-module",
7
+ "path": "src/index.ts",
8
+ "declarations": [],
9
+ "exports": [
10
+ {
11
+ "kind": "js",
12
+ "name": "*",
13
+ "declaration": {
14
+ "name": "*",
15
+ "package": "@u-elements/u-datalist"
16
+ }
17
+ },
18
+ {
19
+ "kind": "js",
20
+ "name": "*",
21
+ "declaration": {
22
+ "name": "*",
23
+ "module": "src/breadcrumbs/breadcrumbs"
24
+ }
25
+ },
26
+ {
27
+ "kind": "js",
28
+ "name": "*",
29
+ "declaration": {
30
+ "name": "*",
31
+ "module": "src/error-summary/error-summary"
32
+ }
33
+ },
34
+ {
35
+ "kind": "js",
36
+ "name": "*",
37
+ "declaration": {
38
+ "name": "*",
39
+ "module": "src/field/field"
40
+ }
41
+ },
42
+ {
43
+ "kind": "js",
44
+ "name": "*",
45
+ "declaration": {
46
+ "name": "*",
47
+ "module": "src/pagination/pagination"
48
+ }
49
+ },
50
+ {
51
+ "kind": "js",
52
+ "name": "*",
53
+ "declaration": {
54
+ "name": "*",
55
+ "module": "src/suggestion/suggestion"
56
+ }
57
+ },
58
+ {
59
+ "kind": "js",
60
+ "name": "*",
61
+ "declaration": {
62
+ "name": "*",
63
+ "module": "src/tabs/tabs"
64
+ }
65
+ },
66
+ {
67
+ "kind": "js",
68
+ "name": "*",
69
+ "declaration": {
70
+ "name": "*",
71
+ "module": "src/tooltip/tooltip"
72
+ }
73
+ }
74
+ ]
75
+ },
76
+ {
77
+ "kind": "javascript-module",
78
+ "path": "src/breadcrumbs/breadcrumbs.ts",
79
+ "declarations": [
80
+ {
81
+ "kind": "class",
82
+ "description": "",
83
+ "name": "DSBreadcrumbsElement",
84
+ "members": [
85
+ {
86
+ "kind": "field",
87
+ "name": "_items",
88
+ "type": {
89
+ "text": "HTMLCollectionOf<HTMLAnchorElement> | undefined"
90
+ }
91
+ },
92
+ {
93
+ "kind": "field",
94
+ "name": "_label",
95
+ "type": {
96
+ "text": "string | null"
97
+ },
98
+ "default": "null"
99
+ },
100
+ {
101
+ "kind": "field",
102
+ "name": "_render",
103
+ "type": {
104
+ "text": "() => void | undefined"
105
+ }
106
+ },
107
+ {
108
+ "kind": "field",
109
+ "name": "_unresize",
110
+ "type": {
111
+ "text": "() => void | undefined"
112
+ }
113
+ },
114
+ {
115
+ "kind": "field",
116
+ "name": "_unmutate",
117
+ "type": {
118
+ "text": "() => void | undefined"
119
+ }
120
+ }
121
+ ],
122
+ "superclass": {
123
+ "name": "DSElement",
124
+ "module": "/src/utils/utils"
125
+ },
126
+ "tagName": "ds-breadcrumbs",
127
+ "customElement": true
128
+ }
129
+ ],
130
+ "exports": [
131
+ {
132
+ "kind": "js",
133
+ "name": "DSBreadcrumbsElement",
134
+ "declaration": {
135
+ "name": "DSBreadcrumbsElement",
136
+ "module": "src/breadcrumbs/breadcrumbs.ts"
137
+ }
138
+ },
139
+ {
140
+ "kind": "custom-element-definition",
141
+ "name": "ds-breadcrumbs",
142
+ "declaration": {
143
+ "name": "DSBreadcrumbsElement",
144
+ "module": "src/breadcrumbs/breadcrumbs.ts"
145
+ }
146
+ }
147
+ ]
148
+ },
149
+ {
150
+ "kind": "javascript-module",
151
+ "path": "src/clickdelegatefor/clickdelegatefor.ts",
152
+ "declarations": [],
153
+ "exports": []
154
+ },
155
+ {
156
+ "kind": "javascript-module",
157
+ "path": "src/dialog/dialog.ts",
158
+ "declarations": [],
159
+ "exports": []
160
+ },
161
+ {
162
+ "kind": "javascript-module",
163
+ "path": "src/error-summary/error-summary.ts",
164
+ "declarations": [
165
+ {
166
+ "kind": "class",
167
+ "description": "",
168
+ "name": "DSErrorSummaryElement",
169
+ "members": [
170
+ {
171
+ "kind": "method",
172
+ "name": "handleEvent",
173
+ "parameters": [
174
+ {
175
+ "name": "{ target }",
176
+ "type": {
177
+ "text": "Partial<Event>"
178
+ }
179
+ }
180
+ ]
181
+ }
182
+ ],
183
+ "superclass": {
184
+ "name": "DSElement",
185
+ "module": "/src/utils/utils"
186
+ },
187
+ "tagName": "ds-error-summary",
188
+ "customElement": true
189
+ }
190
+ ],
191
+ "exports": [
192
+ {
193
+ "kind": "js",
194
+ "name": "DSErrorSummaryElement",
195
+ "declaration": {
196
+ "name": "DSErrorSummaryElement",
197
+ "module": "src/error-summary/error-summary.ts"
198
+ }
199
+ },
200
+ {
201
+ "kind": "custom-element-definition",
202
+ "name": "ds-error-summary",
203
+ "declaration": {
204
+ "name": "DSErrorSummaryElement",
205
+ "module": "src/error-summary/error-summary.ts"
206
+ }
207
+ }
208
+ ]
209
+ },
210
+ {
211
+ "kind": "javascript-module",
212
+ "path": "src/field/field.ts",
213
+ "declarations": [
214
+ {
215
+ "kind": "class",
216
+ "description": "",
217
+ "name": "DSFieldElement",
218
+ "superclass": {
219
+ "name": "DSElement",
220
+ "module": "/src/utils/utils"
221
+ },
222
+ "tagName": "ds-field",
223
+ "customElement": true
224
+ }
225
+ ],
226
+ "exports": [
227
+ {
228
+ "kind": "js",
229
+ "name": "DSFieldElement",
230
+ "declaration": {
231
+ "name": "DSFieldElement",
232
+ "module": "src/field/field.ts"
233
+ }
234
+ },
235
+ {
236
+ "kind": "custom-element-definition",
237
+ "name": "ds-field",
238
+ "declaration": {
239
+ "name": "DSFieldElement",
240
+ "module": "src/field/field.ts"
241
+ }
242
+ }
243
+ ]
244
+ },
245
+ {
246
+ "kind": "javascript-module",
247
+ "path": "src/pagination/pagination.ts",
248
+ "declarations": [
249
+ {
250
+ "kind": "function",
251
+ "name": "pagination",
252
+ "parameters": [
253
+ {
254
+ "name": "{ current = 1, total = 10, show = 7 }"
255
+ }
256
+ ]
257
+ },
258
+ {
259
+ "kind": "class",
260
+ "description": "",
261
+ "name": "DSPaginationElement",
262
+ "members": [
263
+ {
264
+ "kind": "field",
265
+ "name": "_unmutate",
266
+ "type": {
267
+ "text": "() => void | undefined"
268
+ }
269
+ },
270
+ {
271
+ "kind": "field",
272
+ "name": "_render",
273
+ "type": {
274
+ "text": "() => void | undefined"
275
+ }
276
+ }
277
+ ],
278
+ "superclass": {
279
+ "name": "DSElement",
280
+ "module": "/src/utils/utils"
281
+ },
282
+ "tagName": "ds-pagination",
283
+ "customElement": true
284
+ }
285
+ ],
286
+ "exports": [
287
+ {
288
+ "kind": "js",
289
+ "name": "pagination",
290
+ "declaration": {
291
+ "name": "pagination",
292
+ "module": "src/pagination/pagination.ts"
293
+ }
294
+ },
295
+ {
296
+ "kind": "js",
297
+ "name": "DSPaginationElement",
298
+ "declaration": {
299
+ "name": "DSPaginationElement",
300
+ "module": "src/pagination/pagination.ts"
301
+ }
302
+ },
303
+ {
304
+ "kind": "custom-element-definition",
305
+ "name": "ds-pagination",
306
+ "declaration": {
307
+ "name": "DSPaginationElement",
308
+ "module": "src/pagination/pagination.ts"
309
+ }
310
+ }
311
+ ]
312
+ },
313
+ {
314
+ "kind": "javascript-module",
315
+ "path": "src/popover/popover.ts",
316
+ "declarations": [
317
+ {
318
+ "kind": "variable",
319
+ "name": "placement"
320
+ }
321
+ ],
322
+ "exports": []
323
+ },
324
+ {
325
+ "kind": "javascript-module",
326
+ "path": "src/readonly/readonly.ts",
327
+ "declarations": [],
328
+ "exports": []
329
+ },
330
+ {
331
+ "kind": "javascript-module",
332
+ "path": "src/suggestion/suggestion.ts",
333
+ "declarations": [
334
+ {
335
+ "kind": "class",
336
+ "description": "",
337
+ "name": "DSSuggestionElement",
338
+ "members": [
339
+ {
340
+ "kind": "field",
341
+ "name": "_unmutate",
342
+ "type": {
343
+ "text": "ReturnType<typeof onMutation> | undefined"
344
+ }
345
+ },
346
+ {
347
+ "kind": "field",
348
+ "name": "_render",
349
+ "type": {
350
+ "text": "() => void | undefined"
351
+ }
352
+ }
353
+ ],
354
+ "superclass": {
355
+ "name": "UHTMLComboboxElement",
356
+ "package": "@u-elements/u-combobox"
357
+ },
358
+ "tagName": "ds-suggestion",
359
+ "customElement": true
360
+ }
361
+ ],
362
+ "exports": [
363
+ {
364
+ "kind": "js",
365
+ "name": "DSSuggestionElement",
366
+ "declaration": {
367
+ "name": "DSSuggestionElement",
368
+ "module": "src/suggestion/suggestion.ts"
369
+ }
370
+ },
371
+ {
372
+ "kind": "custom-element-definition",
373
+ "name": "ds-suggestion",
374
+ "declaration": {
375
+ "name": "DSSuggestionElement",
376
+ "module": "src/suggestion/suggestion.ts"
377
+ }
378
+ }
379
+ ]
380
+ },
381
+ {
382
+ "kind": "javascript-module",
383
+ "path": "src/tabs/tabs.ts",
384
+ "declarations": [
385
+ {
386
+ "kind": "class",
387
+ "description": "",
388
+ "name": "DSTabsElement",
389
+ "superclass": {
390
+ "module": "src/tabs/tabs.ts"
391
+ },
392
+ "tagName": "ds-tabs",
393
+ "customElement": true
394
+ },
395
+ {
396
+ "kind": "class",
397
+ "description": "",
398
+ "name": "DSTabListElement",
399
+ "superclass": {
400
+ "module": "src/tabs/tabs.ts"
401
+ },
402
+ "tagName": "ds-tablist",
403
+ "customElement": true
404
+ },
405
+ {
406
+ "kind": "class",
407
+ "description": "",
408
+ "name": "DSTabElement",
409
+ "superclass": {
410
+ "module": "src/tabs/tabs.ts"
411
+ },
412
+ "tagName": "ds-tab",
413
+ "customElement": true
414
+ },
415
+ {
416
+ "kind": "class",
417
+ "description": "",
418
+ "name": "DSTabPanelElement",
419
+ "superclass": {
420
+ "module": "src/tabs/tabs.ts"
421
+ },
422
+ "tagName": "ds-tabpanel",
423
+ "customElement": true
424
+ }
425
+ ],
426
+ "exports": [
427
+ {
428
+ "kind": "js",
429
+ "name": "DSTabsElement",
430
+ "declaration": {
431
+ "name": "DSTabsElement",
432
+ "module": "src/tabs/tabs.ts"
433
+ }
434
+ },
435
+ {
436
+ "kind": "js",
437
+ "name": "DSTabListElement",
438
+ "declaration": {
439
+ "name": "DSTabListElement",
440
+ "module": "src/tabs/tabs.ts"
441
+ }
442
+ },
443
+ {
444
+ "kind": "js",
445
+ "name": "DSTabElement",
446
+ "declaration": {
447
+ "name": "DSTabElement",
448
+ "module": "src/tabs/tabs.ts"
449
+ }
450
+ },
451
+ {
452
+ "kind": "js",
453
+ "name": "DSTabPanelElement",
454
+ "declaration": {
455
+ "name": "DSTabPanelElement",
456
+ "module": "src/tabs/tabs.ts"
457
+ }
458
+ },
459
+ {
460
+ "kind": "custom-element-definition",
461
+ "name": "ds-tabs",
462
+ "declaration": {
463
+ "name": "DSTabsElement",
464
+ "module": "src/tabs/tabs.ts"
465
+ }
466
+ },
467
+ {
468
+ "kind": "custom-element-definition",
469
+ "name": "ds-tablist",
470
+ "declaration": {
471
+ "name": "DSTabListElement",
472
+ "module": "src/tabs/tabs.ts"
473
+ }
474
+ },
475
+ {
476
+ "kind": "custom-element-definition",
477
+ "name": "ds-tab",
478
+ "declaration": {
479
+ "name": "DSTabElement",
480
+ "module": "src/tabs/tabs.ts"
481
+ }
482
+ },
483
+ {
484
+ "kind": "custom-element-definition",
485
+ "name": "ds-tabpanel",
486
+ "declaration": {
487
+ "name": "DSTabPanelElement",
488
+ "module": "src/tabs/tabs.ts"
489
+ }
490
+ }
491
+ ]
492
+ },
493
+ {
494
+ "kind": "javascript-module",
495
+ "path": "src/toggle-group/toggle-group.ts",
496
+ "declarations": [],
497
+ "exports": []
498
+ },
499
+ {
500
+ "kind": "javascript-module",
501
+ "path": "src/tooltip/tooltip.ts",
502
+ "declarations": [
503
+ {
504
+ "kind": "function",
505
+ "name": "setTooltipElement",
506
+ "parameters": [
507
+ {
508
+ "name": "el",
509
+ "optional": true,
510
+ "type": {
511
+ "text": "HTMLElement | null"
512
+ },
513
+ "description": "The HTMLElement to use as tooltip"
514
+ }
515
+ ],
516
+ "description": "setTooltipElement"
517
+ }
518
+ ],
519
+ "exports": [
520
+ {
521
+ "kind": "js",
522
+ "name": "setTooltipElement",
523
+ "declaration": {
524
+ "name": "setTooltipElement",
525
+ "module": "src/tooltip/tooltip.ts"
526
+ }
527
+ }
528
+ ]
529
+ }
530
+ ]
531
+ }
@@ -0,0 +1,2 @@
1
+ import{DSElement as e,attr as t,attrOrCSS as n,customElements as r,debounce as i,on as a,onMutation as o}from"../utils/utils.js";const s=`aria-label`;var c=class extends e{_items;_label=null;_render;_unresize;_unmutate;static get observedAttributes(){return[s]}connectedCallback(){this._label=n(this,s),this._items=this.getElementsByTagName(`a`),this._render=i(()=>l(this),100),this._unresize=a(window,`resize`,this._render),this._unmutate=o(this,this._render,{childList:!0,subtree:!0})}attributeChangedCallback(e,t,n){n&&(this._label=n),this._render?.()}disconnectedCallback(){this._unresize?.(),this._unmutate?.(),this._unresize=this._unmutate=this._render=this._items=void 0}};const l=e=>{let n=e._items?.[e._items.length-1],r=n?.parentElement===e?null:n,i=!r?.offsetHeight;t(e,`role`,i?null:`navigation`),t(e,s,i?null:e._label);for(let n of e._items||[])t(n,`aria-current`,n===r?`page`:null)};r.define(`ds-breadcrumbs`,c);export{c as DSBreadcrumbsElement};
2
+ //# sourceMappingURL=breadcrumbs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breadcrumbs.js","names":[],"sources":["../../../src/breadcrumbs/breadcrumbs.ts"],"sourcesContent":["import {\n attr,\n attrOrCSS,\n customElements,\n DSElement,\n debounce,\n on,\n onMutation,\n} from '../utils/utils';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ds-breadcrumbs': DSBreadcrumbsElement;\n }\n}\n\nconst ATTR_LABEL = 'aria-label';\n\nexport class DSBreadcrumbsElement extends DSElement {\n _items?: HTMLCollectionOf<HTMLAnchorElement>; // Using underscore instead of private fields for backwards compatibility\n _label: string | null = null;\n _render?: () => void;\n _unresize?: () => void;\n _unmutate?: () => void;\n\n static get observedAttributes() {\n return [ATTR_LABEL]; // Using ES2015 syntax for backwards compatibility\n }\n connectedCallback() {\n this._label = attrOrCSS(this, ATTR_LABEL); // Cache label for when list is hidden to prevent expensive DOM reads during resize\n this._items = this.getElementsByTagName('a'); // Speed up by caching HTMLCollection\n this._render = debounce(() => render(this), 100); // Debounce render to prevent multiple calls during resize and mutation observer calls\n this._unresize = on(window, 'resize', this._render);\n this._unmutate = onMutation(this, this._render, {\n childList: true,\n subtree: true,\n });\n }\n attributeChangedCallback(_name: string, _prev?: string, next?: string) {\n if (next) this._label = next; // Update cacheed label if aria-label attribute changes\n this._render?.();\n }\n disconnectedCallback() {\n this._unresize?.();\n this._unmutate?.();\n this._unresize = this._unmutate = this._render = this._items = undefined;\n }\n}\n\nconst render = (self: DSBreadcrumbsElement) => {\n const lastItem = self._items?.[self._items.length - 1];\n const lastItemInList = lastItem?.parentElement === self ? null : lastItem;\n const isListHidden = !lastItemInList?.offsetHeight;\n\n attr(self, 'role', isListHidden ? null : 'navigation');\n attr(self, ATTR_LABEL, isListHidden ? null : self._label); // Remove aria-label if list is hidden to prevent screen readers from announcing as breadcrumbs\n\n for (const item of self._items || [])\n attr(item, 'aria-current', item === lastItemInList ? 'page' : null);\n};\n\ncustomElements.define('ds-breadcrumbs', DSBreadcrumbsElement);\n"],"mappings":"iIAgBA,MAAM,EAAa,aAEnB,IAAa,EAAb,cAA0C,CAAU,CAClD,OACA,OAAwB,KACxB,QACA,UACA,UAEA,WAAW,oBAAqB,CAC9B,MAAO,CAAC,EAAW,CAErB,mBAAoB,CAClB,KAAK,OAAS,EAAU,KAAM,EAAW,CACzC,KAAK,OAAS,KAAK,qBAAqB,IAAI,CAC5C,KAAK,QAAU,MAAe,EAAO,KAAK,CAAE,IAAI,CAChD,KAAK,UAAY,EAAG,OAAQ,SAAU,KAAK,QAAQ,CACnD,KAAK,UAAY,EAAW,KAAM,KAAK,QAAS,CAC9C,UAAW,GACX,QAAS,GACV,CAAC,CAEJ,yBAAyB,EAAe,EAAgB,EAAe,CACjE,IAAM,KAAK,OAAS,GACxB,KAAK,WAAW,CAElB,sBAAuB,CACrB,KAAK,aAAa,CAClB,KAAK,aAAa,CAClB,KAAK,UAAY,KAAK,UAAY,KAAK,QAAU,KAAK,OAAS,IAAA,KAInE,MAAM,EAAU,GAA+B,CAC7C,IAAM,EAAW,EAAK,SAAS,EAAK,OAAO,OAAS,GAC9C,EAAiB,GAAU,gBAAkB,EAAO,KAAO,EAC3D,EAAe,CAAC,GAAgB,aAEtC,EAAK,EAAM,OAAQ,EAAe,KAAO,aAAa,CACtD,EAAK,EAAM,EAAY,EAAe,KAAO,EAAK,OAAO,CAEzD,IAAK,IAAM,KAAQ,EAAK,QAAU,EAAE,CAClC,EAAK,EAAM,eAAgB,IAAS,EAAiB,OAAS,KAAK,EAGvE,EAAe,OAAO,iBAAkB,EAAqB"}
@@ -0,0 +1,2 @@
1
+ import{QUICK_EVENT as e,on as t,onHotReload as n}from"../utils/utils.js";const r=`:click-delegate-hover`,i=`data-clickdelegatefor`,a=`[${i}]`,o=e=>{let t=e.button===1||e.metaKey||e.ctrlKey,n=e.isTrusted&&e.button<2&&l(e);if(!(!n||n.contains(e.target))){if(t&&n instanceof HTMLAnchorElement)return window.open(n.href,void 0,n.rel);e.stopImmediatePropagation(),n.click()}};let s;const c=e=>{let t=l(e);s!==t&&(s&&s.classList.remove(r),t&&t.classList.add(r),s=t)},l=({target:e})=>{let t=(e instanceof Element?e.closest(a):null)?.getAttribute(i),n=t&&document.getElementById(t)||void 0,r=n&&e.closest(`a,button,label,input,select,textarea,details,dialog,[role="button"],[popover],[contenteditable]`);return(!r||r===n)&&!n?.disabled?n:void 0};n(`clickdelegatefor`,()=>[t(window,`click auxclick`,o,!0),t(document,`mouseover`,c,e)]);
2
+ //# sourceMappingURL=clickdelegatefor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clickdelegatefor.js","names":[],"sources":["../../../src/clickdelegatefor/clickdelegatefor.ts"],"sourcesContent":["// Adding support for click deletagtion, following\n// https://open-ui.org/components/link-area-delegation-explainer/\n// and https://github.com/openui/open-ui/issues/1104#issuecomment-3151387080\nimport { on, onHotReload, QUICK_EVENT } from '../utils/utils';\n\nconst CLASS_HOVER = ':click-delegate-hover';\nconst ATTR_CLICKDELEGATEFOR = 'data-clickdelegatefor';\nconst SELECTOR_CLICKDELEGATEFOR = `[${ATTR_CLICKDELEGATEFOR}]`;\nconst SELECTOR_SKIP =\n 'a,button,label,input,select,textarea,details,dialog,[role=\"button\"],[popover],[contenteditable]';\n\nconst handleClickDelegateFor = (event: MouseEvent) => {\n const isNewTab = event.button === 1 || event.metaKey || event.ctrlKey; // Middle click or cmd/ctrl + click should open in new tab\n const isUserLeftOrMiddleClick = event.isTrusted && event.button < 2; // Only accept left or middle clicks, and ignore the programatic .click() we're about to trigger\n const delegateTarget = isUserLeftOrMiddleClick && getDelegateTarget(event);\n\n if (!delegateTarget || delegateTarget.contains(event.target as Node)) return; // Only proxy event if delegated target isn't part of the original target\n if (isNewTab && delegateTarget instanceof HTMLAnchorElement)\n return window.open(delegateTarget.href, undefined, delegateTarget.rel); // If middle click or cmd/ctrl click on link, open in new tab\n event.stopImmediatePropagation(); // We'll trigger a new click event anyway, so prevent actions on this one\n delegateTarget.click(); // Forward click to the clickable element\n};\n\nlet HOVER: Element | undefined;\nconst handleMouseOver = (event: Event) => {\n const delegateTarget = getDelegateTarget(event);\n if (HOVER === delegateTarget) return; // No change\n if (HOVER) HOVER.classList.remove(CLASS_HOVER);\n if (delegateTarget) delegateTarget.classList.add(CLASS_HOVER);\n HOVER = delegateTarget;\n};\n\nconst getDelegateTarget = ({ target: el }: Event) => {\n const scope =\n el instanceof Element ? el.closest(SELECTOR_CLICKDELEGATEFOR) : null;\n const id = scope?.getAttribute(ATTR_CLICKDELEGATEFOR);\n const target = (id && document.getElementById(id)) || undefined;\n const skip = target && (el as Element).closest(SELECTOR_SKIP); // Ignore if interactive\n\n return (!skip || skip === target) && !(target as HTMLInputElement)?.disabled\n ? target\n : undefined; // Skip disabled inputs\n};\n\nonHotReload('clickdelegatefor', () => [\n on(window, 'click auxclick', handleClickDelegateFor as EventListener, true), // Use capture to ensure we run before other click listeners\n on(document, 'mouseover', handleMouseOver, QUICK_EVENT), // Use passive for better performance\n]);\n"],"mappings":"yEAKA,MAAM,EAAc,wBACd,EAAwB,wBACxB,EAA4B,IAAI,EAAsB,GAItD,EAA0B,GAAsB,CACpD,IAAM,EAAW,EAAM,SAAW,GAAK,EAAM,SAAW,EAAM,QAExD,EAD0B,EAAM,WAAa,EAAM,OAAS,GAChB,EAAkB,EAAM,CAEtE,MAAC,GAAkB,EAAe,SAAS,EAAM,OAAe,EACpE,IAAI,GAAY,aAA0B,kBACxC,OAAO,OAAO,KAAK,EAAe,KAAM,IAAA,GAAW,EAAe,IAAI,CACxE,EAAM,0BAA0B,CAChC,EAAe,OAAO,GAGxB,IAAI,EACJ,MAAM,EAAmB,GAAiB,CACxC,IAAM,EAAiB,EAAkB,EAAM,CAC3C,IAAU,IACV,GAAO,EAAM,UAAU,OAAO,EAAY,CAC1C,GAAgB,EAAe,UAAU,IAAI,EAAY,CAC7D,EAAQ,IAGJ,GAAqB,CAAE,OAAQ,KAAgB,CAGnD,IAAM,GADJ,aAAc,QAAU,EAAG,QAAQ,EAA0B,CAAG,OAChD,aAAa,EAAsB,CAC/C,EAAU,GAAM,SAAS,eAAe,EAAG,EAAK,IAAA,GAChD,EAAO,GAAW,EAAe,QAAQ,kGAAc,CAE7D,OAAQ,CAAC,GAAQ,IAAS,IAAW,CAAE,GAA6B,SAChE,EACA,IAAA,IAGN,EAAY,uBAA0B,CACpC,EAAG,OAAQ,iBAAkB,EAAyC,GAAK,CAC3E,EAAG,SAAU,YAAa,EAAiB,EAAY,CACxD,CAAC"}
@@ -0,0 +1,2 @@
1
+ import{QUICK_EVENT as e,attr as t,on as n,onHotReload as r,onMutation as i}from"../utils/utils.js";let a=!1;const o=({type:e,target:n,clientX:r=0,clientY:i=0})=>{if(e===`pointerdown`){let e=n?.closest?.(`dialog`)?.getBoundingClientRect();a=!!(e&&e.top<=i&&i<=e.bottom&&e.left<=r&&r<=e.right)}else{let e=n instanceof HTMLDialogElement&&!a&&t(n,`closedby`)===`any`;a=!1,e&&requestAnimationFrame(()=>n.open&&n.close())}},s=()=>{for(let e of document.querySelectorAll(`button[command="show-modal"]`))t(e,`aria-haspopup`,`dialog`)},c=({command:e,target:t})=>e===`--show-non-modal`&&t instanceof HTMLDialogElement&&t.show();r(`dialog`,()=>[n(document,`command`,c,e),n(document,`pointerdown pointerup`,o,e),i(document,s,{attributeFilter:[`command`],attributes:!0,childList:!0,subtree:!0})]);
2
+ //# sourceMappingURL=dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialog.js","names":[],"sources":["../../../src/dialog/dialog.ts"],"sourcesContent":["import { attr, on, onHotReload, onMutation, QUICK_EVENT } from '../utils/utils';\n\n// Polyfill closedby functionaliy in Safari\n// Also in Safari 26.2 where `closedBy` property is supported natively,\n// but no corresponding functionality/behavior is implemented.\nlet DOWN_INSIDE = false; // Prevent close if selecting text inside dialog\nconst handleClosedbyAny = ({\n type,\n target: el,\n clientX: x = 0,\n clientY: y = 0,\n}: Partial<MouseEvent>) => {\n if (type === 'pointerdown') {\n const r = (el as Element)?.closest?.('dialog')?.getBoundingClientRect();\n const isInside =\n r && r.top <= y && y <= r.bottom && r.left <= x && x <= r.right;\n\n DOWN_INSIDE = !!isInside;\n } else {\n const isDialog = el instanceof HTMLDialogElement;\n const isClose = isDialog && !DOWN_INSIDE && attr(el, 'closedby') === 'any';\n\n DOWN_INSIDE = false; // Reset on every pointerup\n if (isClose) requestAnimationFrame(() => el.open && el.close()); // Close if browser did not do it\n }\n};\n\n// Ensure buttons that trigger a modeal dialog has aria-haspopup=\"dialog\" for better screen reader experience\nconst handleAriaAttributes = () => {\n for (const btn of document.querySelectorAll('button[command=\"show-modal\"]'))\n attr(btn, 'aria-haspopup', 'dialog');\n};\n\nconst handleCommand = ({ command, target }: Event & { command?: string }) =>\n command === '--show-non-modal' &&\n target instanceof HTMLDialogElement &&\n target.show();\n\nonHotReload('dialog', () => [\n on(document, 'command', handleCommand, QUICK_EVENT),\n on(document, 'pointerdown pointerup', handleClosedbyAny, QUICK_EVENT),\n onMutation(document, handleAriaAttributes, {\n attributeFilter: ['command'],\n attributes: true,\n childList: true,\n subtree: true,\n }),\n]);\n"],"mappings":"mGAKA,IAAI,EAAc,GAClB,MAAM,GAAqB,CACzB,OACA,OAAQ,EACR,QAAS,EAAI,EACb,QAAS,EAAI,KACY,CACzB,GAAI,IAAS,cAAe,CAC1B,IAAM,EAAK,GAAgB,UAAU,SAAS,EAAE,uBAAuB,CAIvE,EAAc,CAAC,EAFb,GAAK,EAAE,KAAO,GAAK,GAAK,EAAE,QAAU,EAAE,MAAQ,GAAK,GAAK,EAAE,WAGvD,CAEL,IAAM,EADW,aAAc,mBACH,CAAC,GAAe,EAAK,EAAI,WAAW,GAAK,MAErE,EAAc,GACV,GAAS,0BAA4B,EAAG,MAAQ,EAAG,OAAO,CAAC,GAK7D,MAA6B,CACjC,IAAK,IAAM,KAAO,SAAS,iBAAiB,+BAA+B,CACzE,EAAK,EAAK,gBAAiB,SAAS,EAGlC,GAAiB,CAAE,UAAS,YAChC,IAAY,oBACZ,aAAkB,mBAClB,EAAO,MAAM,CAEf,EAAY,aAAgB,CAC1B,EAAG,SAAU,UAAW,EAAe,EAAY,CACnD,EAAG,SAAU,wBAAyB,EAAmB,EAAY,CACrE,EAAW,SAAU,EAAsB,CACzC,gBAAiB,CAAC,UAAU,CAC5B,WAAY,GACZ,UAAW,GACX,QAAS,GACV,CAAC,CACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ import{DSElement as e,QUICK_EVENT as t,attr as n,customElements as r,off as i,on as a,useId as o}from"../utils/utils.js";var s=class extends e{connectedCallback(){a(this,`animationend`,this,t),requestAnimationFrame(()=>this.handleEvent({target:this}))}handleEvent({target:e}){if(e!==this)return;let t=this.querySelector(`h2,h3,h4,h5,h6`);t&&n(this,`aria-labelledby`,o(t)),n(this,`tabindex`,`-1`),this.focus()}disconnectedCallback(){i(this,`animationend`,this,t)}};r.define(`ds-error-summary`,s);export{s as DSErrorSummaryElement};
2
+ //# sourceMappingURL=error-summary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-summary.js","names":[],"sources":["../../../src/error-summary/error-summary.ts"],"sourcesContent":["import {\n attr,\n customElements,\n DSElement,\n off,\n on,\n QUICK_EVENT,\n useId,\n} from '../utils/utils';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ds-error-summary': DSErrorSummaryElement;\n }\n}\n\nexport class DSErrorSummaryElement extends DSElement {\n connectedCallback() {\n on(this, 'animationend', this, QUICK_EVENT); // Using animationend to detect when element is visible\n requestAnimationFrame(() => this.handleEvent({ target: this })); // Initial setup when children has rendered\n }\n handleEvent({ target }: Partial<Event>) {\n if (target !== this) return; // Ignore if animation event was triggered by child\n const heading = this.querySelector('h2,h3,h4,h5,h6');\n if (heading) attr(this, 'aria-labelledby', useId(heading));\n attr(this, 'tabindex', '-1');\n this.focus();\n }\n disconnectedCallback() {\n off(this, 'animationend', this, QUICK_EVENT);\n }\n}\n\ncustomElements.define('ds-error-summary', DSErrorSummaryElement);\n"],"mappings":"yHAgBA,IAAa,EAAb,cAA2C,CAAU,CACnD,mBAAoB,CAClB,EAAG,KAAM,eAAgB,KAAM,EAAY,CAC3C,0BAA4B,KAAK,YAAY,CAAE,OAAQ,KAAM,CAAC,CAAC,CAEjE,YAAY,CAAE,UAA0B,CACtC,GAAI,IAAW,KAAM,OACrB,IAAM,EAAU,KAAK,cAAc,iBAAiB,CAChD,GAAS,EAAK,KAAM,kBAAmB,EAAM,EAAQ,CAAC,CAC1D,EAAK,KAAM,WAAY,KAAK,CAC5B,KAAK,OAAO,CAEd,sBAAuB,CACrB,EAAI,KAAM,eAAgB,KAAM,EAAY,GAIhD,EAAe,OAAO,mBAAoB,EAAsB"}
@@ -0,0 +1,2 @@
1
+ import{DSElement as e,QUICK_EVENT as t,attr as n,attrOrCSS as r,customElements as i,debounce as a,isBrowser as o,isWindows as s,on as c,onHotReload as l,onMutation as u,setTextWithoutMutation as d,tag as f,useId as p,warn as m}from"../utils/utils.js";const h=`data-indeterminate`,g=new Set,_=new WeakMap,v=o()?document.getElementsByTagName(`fieldset`):[],y=o()&&CSS.supports(`field-sizing`,`content`),b=s()?800:200,x=new WeakSet,S=a(()=>{for(let e of v)n(e,`aria-labelledby`,`${p(e.querySelector(`legend`))} ${p(e.querySelector(`:scope > :is([data-field="description"],legend + p)`))}`.trim()||null);for(let e of g){let t=[],r=[],i,a,o=!1,s=!1;for(let n of e.getElementsByTagName(`*`))if(n instanceof HTMLLabelElement&&r.push(n),!n.hidden)if(D(n))i?m(`Fields should only have one input element. Use <fieldset> to group multiple fields:`,e):i=n;else{let e=n.getAttribute(`data-field`);e===`counter`&&(a=n),e===`validation`?(t.unshift(n),o=!0,s||=E(n)):e&&t.push(n)}if(!i)m(`Field is missing input element:`,e);else{a&&_.set(i,a);for(let e of r)n(e,`for`,p(i));let c=i.type===`radio`||i.type===`checkbox`,l=e.closest(`fieldset`)?.querySelector(`:scope > [data-field="validation"]`);l&&!l?.hidden&&(o=!0,s||=E(l),t.unshift(l));let u=n(i,h);u&&(i.indeterminate=u===`true`),n(e,`data-clickdelegatefor`,c?p(i):null),n(i,`aria-describedby`,t.map(p).join(` `)||null),(o||x.has(i))&&(x[o?`add`:`delete`](i),n(i,`aria-invalid`,`${s}`)),w(i)}}},0),C=o()?f(`div`,{"aria-live":`polite`,style:`position:fixed;white-space:nowrap;clip:rect(0 0 0 0)`}):null,w=e=>{let t=e.target||e,i=_.get(t);if(i?.isConnected){let a=(Number(n(i,`data-limit`))||0)-t.value.length,o=a<0?`over`:`under`,s=r(i,`data-${o}`)?.replace(`%d`,`${Math.abs(a)}`);n(i,`data-label`,s),n(i,`data-state`,o),n(i,`data-color`,a<0?`danger`:null),e.type===`input`&&C&&s&&(C?.isConnected||document.body.appendChild(C),T(t,s))}!y&&t instanceof HTMLTextAreaElement&&(t.style.setProperty(`--_ds-field-sizing`,`auto`),t.style.setProperty(`--_ds-field-sizing`,`${t.scrollHeight}px`))},T=a((e,t)=>{let n=document.activeElement===e;C?.isConnected&&n&&d(C,t)},b),E=e=>e.getAttribute(`data-color`)!==`success`,D=e=>e instanceof HTMLElement&&`validity`in e&&!(e instanceof HTMLButtonElement)&&e.type!==`hidden`;var O=class extends e{connectedCallback(){g.add(this),S()}disconnectedCallback(){g.delete(this)}};i.define(`ds-field`,O),l(`field`,()=>[c(document,`input`,w,t),u(document,S,{attributeFilter:[`value`,`hidden`,`data-field`,h],attributes:!0,childList:!0,subtree:!0})]);export{O as DSFieldElement};
2
+ //# sourceMappingURL=field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.js","names":[],"sources":["../../../src/field/field.ts"],"sourcesContent":["import {\n attr,\n attrOrCSS,\n customElements,\n DSElement,\n debounce,\n isBrowser,\n isWindows,\n on,\n onHotReload,\n onMutation,\n QUICK_EVENT,\n setTextWithoutMutation,\n tag,\n useId,\n warn,\n} from '../utils/utils';\n\n// TODO: Document that Validation must be hidden with \"hidden\" attribute (or completely removed from DOM), not display: none\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ds-field': DSFieldElement;\n }\n}\n\nconst INDETERMINATE = 'data-indeterminate';\nconst FIELDS = new Set<DSFieldElement>(); // Set of Field\nconst COUNTS = new WeakMap<HTMLInputElement, Element>(); // Using WeakMap so removed inputs/counts does not cause memory leaks\nconst FIELDSETS = isBrowser() ? document.getElementsByTagName('fieldset') : [];\nconst HAS_FIELD_SIZING = isBrowser() && CSS.supports('field-sizing', 'content');\nconst COUNTER_DEBOUNCE = isWindows() ? 800 : 200; // Longer debounce on Windows due to NVDA performance\nconst HAS_VALIDATION = new WeakSet<HTMLInputElement>(); // Used to store inputs that have/had validation elements to manage aria-invalid\n\nconst handleMutations = debounce(() => {\n for (const el of FIELDSETS) {\n const labelledby = `${useId(el.querySelector('legend'))} ${useId(el.querySelector(':scope > :is([data-field=\"description\"],legend + p)'))}`;\n attr(el, 'aria-labelledby', labelledby.trim() || null);\n }\n for (const field of FIELDS) {\n const descs: Element[] = [];\n const labels: HTMLLabelElement[] = [];\n let input: HTMLInputElement | undefined;\n let counter: Element | undefined;\n let hasValidation = false;\n let invalid = false;\n\n for (const el of field.getElementsByTagName('*')) {\n if (el instanceof HTMLLabelElement) labels.push(el);\n if ((el as HTMLElement).hidden) continue; // Skip hidden elements except labels\n if (isInputLike(el)) {\n if (input)\n warn(\n `Fields should only have one input element. Use <fieldset> to group multiple fields:`,\n field,\n );\n else input = el; // Only register if visible input\n } else {\n const type = el.getAttribute('data-field'); // Using getAttribute instead of attr for best performance\n if (type === 'counter') counter = el;\n if (type === 'validation') {\n descs.unshift(el);\n hasValidation = true;\n invalid = invalid || isInvalid(el);\n } else if (type) descs.push(el); // Adds both counter and descriptions\n }\n }\n\n if (!input) warn(`Field is missing input element:`, field);\n else {\n if (counter) COUNTS.set(input, counter);\n for (const label of labels) attr(label, 'for', useId(input));\n\n const isBoolish = input.type === 'radio' || input.type === 'checkbox';\n const fieldsetValidation = field\n .closest('fieldset')\n ?.querySelector<HTMLElement>(':scope > [data-field=\"validation\"]');\n if (fieldsetValidation && !fieldsetValidation?.hidden) {\n hasValidation = true;\n invalid = invalid || isInvalid(fieldsetValidation);\n descs.unshift(fieldsetValidation);\n }\n\n const indeterminate = attr(input, INDETERMINATE);\n if (indeterminate) input.indeterminate = indeterminate === 'true';\n\n attr(field, 'data-clickdelegatefor', isBoolish ? useId(input) : null); // Expand click area to ds-field if radio/checkbox\n attr(input, 'aria-describedby', descs.map(useId).join(' ') || null);\n if (hasValidation || HAS_VALIDATION.has(input)) {\n HAS_VALIDATION[hasValidation ? 'add' : 'delete'](input); // Track if field has validation elements to avoid managing aria-invalid on every mutation\n attr(input, 'aria-invalid', `${invalid}`); // Only manage aria-invalid when field has validation elements\n }\n updateField(input); // Update counter and textarea sizing\n }\n }\n}, 0); // Debounce to merge multiple mutations\n\nconst SR_ONLY = 'position:fixed;white-space:nowrap;clip:rect(0 0 0 0)';\nconst SR_LIVE = isBrowser()\n ? tag('div', { 'aria-live': 'polite', style: SR_ONLY })\n : null;\n\nconst updateField = (e: Event | Element) => {\n const input = ((e as Event).target || e) as HTMLInputElement;\n const counter = COUNTS.get(input);\n\n if (counter?.isConnected) {\n const limit = Number(attr(counter, 'data-limit')) || 0;\n const count = limit - input.value.length;\n const state = count < 0 ? 'over' : 'under';\n const label = attrOrCSS(counter, `data-${state}`)?.replace(\n '%d',\n `${Math.abs(count)}`,\n );\n\n attr(counter, 'data-label', label); // Using attribute to prevent hydation errors, not using aria-label to make axe tests happy\n attr(counter, 'data-state', state);\n attr(counter, 'data-color', count < 0 ? 'danger' : null);\n\n // Only update live region when user is actually typing\n if ((e as Event).type === 'input' && SR_LIVE && label) {\n if (!SR_LIVE?.isConnected) document.body.appendChild(SR_LIVE); // Prepare live region\n debouncedCounterLiveRegion(input, label); // Debounce live region to avoid NVDA interupting announcing typed text\n }\n }\n if (!HAS_FIELD_SIZING && input instanceof HTMLTextAreaElement) {\n input.style.setProperty('--_ds-field-sizing', 'auto');\n input.style.setProperty('--_ds-field-sizing', `${input.scrollHeight}px`);\n }\n};\n\nconst debouncedCounterLiveRegion = debounce((input: Element, text: string) => {\n const hasFocus = document.activeElement === input; // Only announce if input is still focused\n if (SR_LIVE?.isConnected && hasFocus) setTextWithoutMutation(SR_LIVE, text);\n}, COUNTER_DEBOUNCE);\n\nconst isInvalid = (el: Element) => el.getAttribute('data-color') !== 'success';\nconst isInputLike = (el: unknown): el is HTMLInputElement =>\n el instanceof HTMLElement &&\n 'validity' in el && // Adds support for custom elements implemeted with attachInternals()\n !(el instanceof HTMLButtonElement) && // But skip <button> elements\n (el as HTMLInputElement).type !== 'hidden'; // And skip input type=\"hidden\"\n\n// Custom element is used to performantly keep track of fields on the page\nexport class DSFieldElement extends DSElement {\n connectedCallback() {\n FIELDS.add(this); // Register field\n handleMutations(); // Initial setup\n }\n disconnectedCallback() {\n FIELDS.delete(this);\n }\n}\n\ncustomElements.define('ds-field', DSFieldElement);\n\n// Listen for hidden to detect hidden validations, and listen for value to detect controlled React inputs\nonHotReload('field', () => [\n on(document, 'input', updateField, QUICK_EVENT),\n onMutation(document, handleMutations, {\n attributeFilter: ['value', 'hidden', 'data-field', INDETERMINATE],\n attributes: true,\n childList: true,\n subtree: true,\n }),\n]);\n"],"mappings":"2PAyBA,MAAM,EAAgB,qBAChB,EAAS,IAAI,IACb,EAAS,IAAI,QACb,EAAY,GAAW,CAAG,SAAS,qBAAqB,WAAW,CAAG,EAAE,CACxE,EAAmB,GAAW,EAAI,IAAI,SAAS,eAAgB,UAAU,CACzE,EAAmB,GAAW,CAAG,IAAM,IACvC,EAAiB,IAAI,QAErB,EAAkB,MAAe,CACrC,IAAK,IAAM,KAAM,EAEf,EAAK,EAAI,kBADU,GAAG,EAAM,EAAG,cAAc,SAAS,CAAC,CAAC,GAAG,EAAM,EAAG,cAAc,sDAAsD,CAAC,GAClG,MAAM,EAAI,KAAK,CAExD,IAAK,IAAM,KAAS,EAAQ,CAC1B,IAAM,EAAmB,EAAE,CACrB,EAA6B,EAAE,CACjC,EACA,EACA,EAAgB,GAChB,EAAU,GAEd,IAAK,IAAM,KAAM,EAAM,qBAAqB,IAAI,CAC9C,GAAI,aAAc,kBAAkB,EAAO,KAAK,EAAG,CAC9C,GAAmB,OACxB,GAAI,EAAY,EAAG,CACb,EACF,EACE,sFACA,EACD,CACE,EAAQ,MACR,CACL,IAAM,EAAO,EAAG,aAAa,aAAa,CACtC,IAAS,YAAW,EAAU,GAC9B,IAAS,cACX,EAAM,QAAQ,EAAG,CACjB,EAAgB,GAChB,IAAqB,EAAU,EAAG,EACzB,GAAM,EAAM,KAAK,EAAG,CAInC,GAAI,CAAC,EAAO,EAAK,kCAAmC,EAAM,KACrD,CACC,GAAS,EAAO,IAAI,EAAO,EAAQ,CACvC,IAAK,IAAM,KAAS,EAAQ,EAAK,EAAO,MAAO,EAAM,EAAM,CAAC,CAE5D,IAAM,EAAY,EAAM,OAAS,SAAW,EAAM,OAAS,WACrD,EAAqB,EACxB,QAAQ,WAAW,EAClB,cAA2B,qCAAqC,CAChE,GAAsB,CAAC,GAAoB,SAC7C,EAAgB,GAChB,IA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