@digdir/designsystemet-web 1.14.0 → 1.16.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.
- package/README.md +136 -103
- package/dist/cjs/_vendors/@oddbird/popover-polyfill/dist/popover-fn.cjs +64 -0
- package/dist/cjs/_vendors/@oddbird/popover-polyfill/dist/popover-fn.cjs.map +1 -0
- package/dist/cjs/_vendors/invokers-polyfill/invoker.cjs.map +1 -1
- package/dist/cjs/breadcrumbs/breadcrumbs.cjs.map +1 -1
- package/dist/cjs/clickdelegatefor/clickdelegatefor.cjs.map +1 -1
- package/dist/cjs/details/details.cjs +1 -0
- package/dist/cjs/dialog/dialog.cjs.map +1 -1
- package/dist/cjs/error-summary/error-summary.cjs +2 -1
- package/dist/cjs/error-summary/error-summary.cjs.map +1 -1
- package/dist/cjs/field/field.cjs.map +1 -1
- package/dist/cjs/fieldset/fieldset.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -2
- package/dist/cjs/invokers/invokers.cjs +2 -0
- package/dist/cjs/invokers/invokers.cjs.map +1 -0
- package/dist/cjs/pagination/pagination.cjs.map +1 -1
- package/dist/cjs/popover/popover.cjs +1 -1
- package/dist/cjs/popover/popover.cjs.map +1 -1
- package/dist/cjs/readonly/readonly.cjs.map +1 -1
- package/dist/cjs/suggestion/suggestion.cjs +1 -1
- package/dist/cjs/suggestion/suggestion.cjs.map +1 -1
- package/dist/cjs/tabs/tabs.cjs +1 -1
- package/dist/cjs/tabs/tabs.cjs.map +1 -1
- package/dist/cjs/toggle-group/toggle-group.cjs.map +1 -1
- package/dist/cjs/tooltip/tooltip.cjs +1 -1
- package/dist/cjs/tooltip/tooltip.cjs.map +1 -1
- package/dist/cjs/utils/utils.cjs.map +1 -1
- package/dist/custom-elements.json +12 -0
- package/dist/esm/_vendors/@oddbird/popover-polyfill/dist/popover-fn.js +64 -0
- package/dist/esm/_vendors/@oddbird/popover-polyfill/dist/popover-fn.js.map +1 -0
- package/dist/esm/_vendors/invokers-polyfill/invoker.js.map +1 -1
- package/dist/esm/breadcrumbs/breadcrumbs.js.map +1 -1
- package/dist/esm/clickdelegatefor/clickdelegatefor.js.map +1 -1
- package/dist/esm/details/details.js +1 -0
- package/dist/esm/dialog/dialog.js.map +1 -1
- package/dist/esm/error-summary/error-summary.js +2 -1
- package/dist/esm/error-summary/error-summary.js.map +1 -1
- package/dist/esm/field/field.js.map +1 -1
- package/dist/esm/fieldset/fieldset.js.map +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/invokers/invokers.js +2 -0
- package/dist/esm/invokers/invokers.js.map +1 -0
- package/dist/esm/pagination/pagination.js.map +1 -1
- package/dist/esm/popover/popover.js +1 -1
- package/dist/esm/popover/popover.js.map +1 -1
- package/dist/esm/readonly/readonly.js.map +1 -1
- package/dist/esm/suggestion/suggestion.js +1 -1
- package/dist/esm/suggestion/suggestion.js.map +1 -1
- package/dist/esm/tabs/tabs.js.map +1 -1
- package/dist/esm/toggle-group/toggle-group.js.map +1 -1
- package/dist/esm/tooltip/tooltip.js +1 -1
- package/dist/esm/tooltip/tooltip.js.map +1 -1
- package/dist/esm/utils/utils.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +829 -236
- package/dist/index.js.map +1 -1
- package/dist/umd/index.js +69 -6
- package/dist/umd/index.js.map +1 -1
- package/package.json +18 -7
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/esm/index.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -3,11 +3,230 @@ import { autoUpdate, computePosition, flip, limitShift, offset, shift, size } fr
|
|
|
3
3
|
import { UHTMLComboboxElement } from "@u-elements/u-combobox";
|
|
4
4
|
import * as UTabs from "@u-elements/u-tabs";
|
|
5
5
|
export * from "@u-elements/u-datalist";
|
|
6
|
+
//#region src/utils/utils.ts
|
|
7
|
+
const QUICK_EVENT = {
|
|
8
|
+
passive: true,
|
|
9
|
+
capture: true
|
|
10
|
+
};
|
|
11
|
+
const isBrowser = () => typeof window !== "undefined" && typeof document !== "undefined";
|
|
12
|
+
const isWindows = () => isBrowser() && /^Win/i.test(navigator.userAgentData?.platform || navigator.platform);
|
|
13
|
+
const DSElement = typeof HTMLElement === "undefined" ? class {} : HTMLElement;
|
|
14
|
+
function debounce(callback, delay) {
|
|
15
|
+
let timer;
|
|
16
|
+
return function(...args) {
|
|
17
|
+
clearTimeout(timer);
|
|
18
|
+
timer = setTimeout(() => callback.apply(this, args), delay);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const warn = (message, ...args) => !isBrowser() || window.dsWarnings === false || console.log(`\x1B[1mDesignsystemet:\x1B[m ${message}`, ...args);
|
|
22
|
+
/**
|
|
23
|
+
* attr
|
|
24
|
+
* @description Utility to quickly get, set and remove attributes
|
|
25
|
+
* @param el The Element to read/write attributes from
|
|
26
|
+
* @param name The attribute name to get, set or remove, or a object to set multiple attributes
|
|
27
|
+
* @param value A valid attribute value or null to remove attribute
|
|
28
|
+
*/
|
|
29
|
+
const attr = (el, name, value) => {
|
|
30
|
+
if (value === void 0) return el.getAttribute(name) ?? null;
|
|
31
|
+
if (value === null) el.removeAttribute(name);
|
|
32
|
+
else if (el.getAttribute(name) !== value) el.setAttribute(name, value);
|
|
33
|
+
return null;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* getCSSProp
|
|
37
|
+
* @description Retrieves and CSS property value and trims it
|
|
38
|
+
* @param el The Element to read attributes/CSS from
|
|
39
|
+
* @param name Attribute or CSS property to get
|
|
40
|
+
* @return string CSS property value
|
|
41
|
+
*/
|
|
42
|
+
const getCSSProp = (el, prop) => getComputedStyle(el).getPropertyValue(prop).trim();
|
|
43
|
+
const STRIP_QUOTES = /^["']|["']$/g;
|
|
44
|
+
/**
|
|
45
|
+
* attrOrCSS
|
|
46
|
+
* @description Retrieves and updates attribute based on attribute or CSS property value
|
|
47
|
+
* @param el The Element to read attributes/CSS from
|
|
48
|
+
* @param name Attribute or CSS property to get
|
|
49
|
+
* @return string attribute or CSS property value
|
|
50
|
+
*/
|
|
51
|
+
const attrOrCSS = (el, name) => {
|
|
52
|
+
let value = attr(el, name);
|
|
53
|
+
if (!value) value = getCSSProp(el, `--_ds-${name}`).replace(STRIP_QUOTES, "").trim();
|
|
54
|
+
if (!value) warn(`Missing ${name} on:`, el);
|
|
55
|
+
return value || null;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* on
|
|
59
|
+
* @param el The Element to use as EventTarget
|
|
60
|
+
* @param types A space separated string of event types
|
|
61
|
+
* @param listener An event listener function or listener object
|
|
62
|
+
*/
|
|
63
|
+
const on = (el, ...rest) => {
|
|
64
|
+
const [types, ...options] = rest;
|
|
65
|
+
for (const type of types.split(" ")) el.addEventListener(type, ...options);
|
|
66
|
+
return () => off(el, ...rest);
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* off
|
|
70
|
+
* @param el The Element to use as EventTarget
|
|
71
|
+
* @param types A space separated string of event types
|
|
72
|
+
* @param listener An event listener function or listener object
|
|
73
|
+
*/
|
|
74
|
+
const off = (el, ...rest) => {
|
|
75
|
+
const [types, ...options] = rest;
|
|
76
|
+
for (const type of types.split(" ")) el.removeEventListener(type, ...options);
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* onHotReload
|
|
80
|
+
* @description Runs a callback when window is loaded in browser, and ensures cleanup when hot-reloading
|
|
81
|
+
* @param key The key to identify setup and corresponding cleanup
|
|
82
|
+
* @param callback The callback to run when the page is ready
|
|
83
|
+
*/
|
|
84
|
+
const onHotReload = (key, setup) => {
|
|
85
|
+
if (!isBrowser()) return;
|
|
86
|
+
if (!window._dsHotReloadCleanup) window._dsHotReloadCleanup = /* @__PURE__ */ new Map();
|
|
87
|
+
window._dsHotReloadCleanup?.get(key)?.map((cleanup) => cleanup());
|
|
88
|
+
window._dsHotReloadCleanup?.set(key, setup());
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* MutationObserver wrapper with automatic cleanup
|
|
92
|
+
* @return new MutaionObserver
|
|
93
|
+
*/
|
|
94
|
+
const onMutation = (el, callback, options) => {
|
|
95
|
+
const cleanup = () => observer.disconnect();
|
|
96
|
+
const observer = new MutationObserver((records) => {
|
|
97
|
+
if (!isBrowser() || !el.isConnected) return cleanup();
|
|
98
|
+
callback(el, records);
|
|
99
|
+
});
|
|
100
|
+
callback(el);
|
|
101
|
+
observer.observe(el, options);
|
|
102
|
+
return cleanup;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* tag
|
|
106
|
+
* @description creates element and assigns properties
|
|
107
|
+
* @param tagName The tagname of element to create
|
|
108
|
+
* @param attrs Optional attributes to add to the element
|
|
109
|
+
* @param text Optional text content to add to the element
|
|
110
|
+
* @return HTMLElement with props
|
|
111
|
+
*/
|
|
112
|
+
const tag = (tagName, attrs) => {
|
|
113
|
+
const el = document.createElement(tagName);
|
|
114
|
+
if (attrs) for (const [key, val] of Object.entries(attrs)) attr(el, key, val);
|
|
115
|
+
return el;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* customElements.define
|
|
119
|
+
* @description Defines a customElement if running in browser and if not already registered
|
|
120
|
+
* Scoped/named "customElements.define" so @custom-elements-manifest/analyzer can find tag names
|
|
121
|
+
*/
|
|
122
|
+
const customElements = { define: (name, instance) => !isBrowser() || window.customElements.get(name) || window.customElements.define(name, instance) };
|
|
123
|
+
let id = 0;
|
|
124
|
+
function useId(el) {
|
|
125
|
+
if (!isBrowser()) return `:ds:${++id}`;
|
|
126
|
+
if (!window.dsUseId) window.dsUseId = 0;
|
|
127
|
+
if (el && !el.id) el.id = `:ds:${++window.dsUseId}`;
|
|
128
|
+
return el?.id || "";
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* @description Based off speak function from [U-elements](https://github.com/u-elements/u-elements/blob/main/packages/utils.ts#L210)
|
|
132
|
+
* @param text The text to announce
|
|
133
|
+
*/
|
|
134
|
+
let LIVE_EL;
|
|
135
|
+
let LIVE_FIX = 0;
|
|
136
|
+
let LIVE_CLEAR = 0;
|
|
137
|
+
const announce = (text) => {
|
|
138
|
+
clearTimeout(LIVE_CLEAR);
|
|
139
|
+
if (LIVE_EL) LIVE_EL.textContent = `${text}${LIVE_FIX++ % 2 ? "\xA0" : ""}`;
|
|
140
|
+
if (text) LIVE_CLEAR = setTimeout(announce, 2e3, "");
|
|
141
|
+
};
|
|
142
|
+
const announceMount = () => {
|
|
143
|
+
if (document.readyState !== "complete") return;
|
|
144
|
+
if (!LIVE_EL) {
|
|
145
|
+
LIVE_EL = tag("div", { "aria-live": "assertive" });
|
|
146
|
+
LIVE_EL.style.overflow = "hidden";
|
|
147
|
+
LIVE_EL.style.position = "fixed";
|
|
148
|
+
LIVE_EL.style.whiteSpace = "nowrap";
|
|
149
|
+
LIVE_EL.style.width = "1px";
|
|
150
|
+
}
|
|
151
|
+
if (!LIVE_EL.isConnected) document.body.appendChild(LIVE_EL);
|
|
152
|
+
};
|
|
153
|
+
onHotReload("announce", () => [on(document, "focus mouseover", announceMount, QUICK_EVENT)]);
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/clickdelegatefor/clickdelegatefor.ts
|
|
156
|
+
const CLASS_HOVER = ":click-delegate-hover";
|
|
157
|
+
const ATTR_CLICKDELEGATEFOR = "data-clickdelegatefor";
|
|
158
|
+
const SELECTOR_CLICKDELEGATEFOR = `[${ATTR_CLICKDELEGATEFOR}]`;
|
|
159
|
+
const SELECTOR_SKIP = "a,button,label,input,select,textarea,details,dialog,[role=\"button\"],[popover],[contenteditable]";
|
|
160
|
+
const handleClickDelegateFor = (event) => {
|
|
161
|
+
const isNewTab = event.button === 1 || event.metaKey || event.ctrlKey;
|
|
162
|
+
const delegateTarget = event.button < 2 && getDelegateTarget(event);
|
|
163
|
+
if (!delegateTarget || delegateTarget.contains(event.target)) return;
|
|
164
|
+
if (isNewTab && delegateTarget instanceof HTMLAnchorElement) return window.open(delegateTarget.href, void 0, delegateTarget.rel);
|
|
165
|
+
event.stopImmediatePropagation();
|
|
166
|
+
delegateTarget.click();
|
|
167
|
+
};
|
|
168
|
+
let HOVER;
|
|
169
|
+
const handleMouseOver = (event) => {
|
|
170
|
+
const delegateTarget = getDelegateTarget(event);
|
|
171
|
+
if (HOVER === delegateTarget) return;
|
|
172
|
+
if (HOVER) HOVER.classList.remove(CLASS_HOVER);
|
|
173
|
+
if (delegateTarget) delegateTarget.classList.add(CLASS_HOVER);
|
|
174
|
+
HOVER = delegateTarget;
|
|
175
|
+
};
|
|
176
|
+
const getDelegateTarget = ({ target: el }) => {
|
|
177
|
+
const id = (el instanceof Element ? el.closest(SELECTOR_CLICKDELEGATEFOR) : null)?.getAttribute(ATTR_CLICKDELEGATEFOR);
|
|
178
|
+
const target = id && document.getElementById(id) || void 0;
|
|
179
|
+
const skip = target && el.closest(SELECTOR_SKIP);
|
|
180
|
+
return (!skip || skip === target) && !target?.disabled ? target : void 0;
|
|
181
|
+
};
|
|
182
|
+
onHotReload("clickdelegatefor", () => [on(window, "click auxclick", handleClickDelegateFor, true), on(document, "mouseover", handleMouseOver, QUICK_EVENT)]);
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/dialog/dialog.ts
|
|
185
|
+
let DOWN_INSIDE = false;
|
|
186
|
+
const handleClosedbyAny = ({ type, target: el, clientX: x = 0, clientY: y = 0 }) => {
|
|
187
|
+
if (type === "pointerdown") {
|
|
188
|
+
const r = el?.closest?.("dialog")?.getBoundingClientRect();
|
|
189
|
+
DOWN_INSIDE = !!(r && r.top <= y && y <= r.bottom && r.left <= x && x <= r.right);
|
|
190
|
+
} else {
|
|
191
|
+
const isClose = el instanceof HTMLDialogElement && !DOWN_INSIDE && attr(el, "closedby") === "any";
|
|
192
|
+
DOWN_INSIDE = false;
|
|
193
|
+
if (isClose) requestAnimationFrame(() => el.open && el.close());
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
const BUTTONS = isBrowser() ? document.getElementsByTagName("button") : [];
|
|
197
|
+
const handleAriaAttributes$2 = () => {
|
|
198
|
+
for (const btn of BUTTONS) if (btn.getAttribute("command")?.endsWith("-modal")) btn.setAttribute("aria-haspopup", "dialog");
|
|
199
|
+
};
|
|
200
|
+
const handleCommand = ({ command, target }) => command === "--show-non-modal" && target instanceof HTMLDialogElement && target.show();
|
|
201
|
+
onHotReload("dialog", () => [
|
|
202
|
+
on(document, "command", handleCommand, QUICK_EVENT),
|
|
203
|
+
on(document, "pointerdown pointerup", handleClosedbyAny, QUICK_EVENT),
|
|
204
|
+
onMutation(document, handleAriaAttributes$2, {
|
|
205
|
+
attributeFilter: ["command"],
|
|
206
|
+
attributes: true,
|
|
207
|
+
childList: true,
|
|
208
|
+
subtree: true
|
|
209
|
+
})
|
|
210
|
+
]);
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region src/fieldset/fieldset.ts
|
|
213
|
+
const FIELDSETS = isBrowser() ? document.getElementsByTagName("fieldset") : [];
|
|
214
|
+
const handleFieldsetMutations = () => {
|
|
215
|
+
for (const el of FIELDSETS) {
|
|
216
|
+
if (el.hasAttribute("aria-labelledby")) continue;
|
|
217
|
+
attr(el, "aria-labelledby", `${useId(el.querySelector("legend"))} ${useId(el.querySelector(":scope > :is([data-field=\"description\"],legend + p)"))}`.trim() || null);
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
onHotReload("fieldset", () => [onMutation(document, handleFieldsetMutations, {
|
|
221
|
+
childList: true,
|
|
222
|
+
subtree: true
|
|
223
|
+
})]);
|
|
224
|
+
//#endregion
|
|
6
225
|
//#region ../../node_modules/.pnpm/invokers-polyfill@1.0.3/node_modules/invokers-polyfill/invoker.js
|
|
7
|
-
function isSupported() {
|
|
226
|
+
function isSupported$1() {
|
|
8
227
|
return typeof HTMLButtonElement !== "undefined" && "command" in HTMLButtonElement.prototype && "source" in ((globalThis.CommandEvent || {}).prototype || {});
|
|
9
228
|
}
|
|
10
|
-
function apply() {
|
|
229
|
+
function apply$1() {
|
|
11
230
|
document.addEventListener("invoke", (e) => {
|
|
12
231
|
if (e.type == "invoke" && e.isTrusted) {
|
|
13
232
|
e.stopImmediatePropagation();
|
|
@@ -215,239 +434,609 @@ function apply() {
|
|
|
215
434
|
ElementClass.prototype.attachInternals = function() {
|
|
216
435
|
const internals = attachInternals.call(this);
|
|
217
436
|
if (internals.shadowRoot) callback(internals.shadowRoot);
|
|
218
|
-
return internals;
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
applyInvokerMixin(HTMLButtonElement);
|
|
222
|
-
observeShadowRoots(HTMLElement, (shadow) => {
|
|
223
|
-
setupInvokeListeners(shadow);
|
|
224
|
-
oncommandObserver.observe(shadow, { attributeFilter: ["oncommand"] });
|
|
225
|
-
applyOnCommandHandler(shadow.querySelectorAll("[oncommand]"));
|
|
226
|
-
});
|
|
227
|
-
setupInvokeListeners(document);
|
|
228
|
-
Object.assign(globalThis, { CommandEvent });
|
|
229
|
-
}
|
|
230
|
-
//#endregion
|
|
231
|
-
//#region src/utils/utils.ts
|
|
232
|
-
const QUICK_EVENT = {
|
|
233
|
-
passive: true,
|
|
234
|
-
capture: true
|
|
235
|
-
};
|
|
236
|
-
const isBrowser = () => typeof window !== "undefined" && typeof document !== "undefined";
|
|
237
|
-
const isWindows = () => isBrowser() && /^Win/i.test(navigator.userAgentData?.platform || navigator.platform);
|
|
238
|
-
const DSElement = typeof HTMLElement === "undefined" ? class {} : HTMLElement;
|
|
239
|
-
function debounce(callback, delay) {
|
|
240
|
-
let timer;
|
|
241
|
-
return function(...args) {
|
|
242
|
-
clearTimeout(timer);
|
|
243
|
-
timer = setTimeout(() => callback.apply(this, args), delay);
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
const warn = (message, ...args) => !isBrowser() || window.dsWarnings === false || console.log(`\x1B[1mDesignsystemet:\x1B[m ${message}`, ...args);
|
|
247
|
-
/**
|
|
248
|
-
* attr
|
|
249
|
-
* @description Utility to quickly get, set and remove attributes
|
|
250
|
-
* @param el The Element to read/write attributes from
|
|
251
|
-
* @param name The attribute name to get, set or remove, or a object to set multiple attributes
|
|
252
|
-
* @param value A valid attribute value or null to remove attribute
|
|
253
|
-
*/
|
|
254
|
-
const attr = (el, name, value) => {
|
|
255
|
-
if (value === void 0) return el.getAttribute(name) ?? null;
|
|
256
|
-
if (value === null) el.removeAttribute(name);
|
|
257
|
-
else if (el.getAttribute(name) !== value) el.setAttribute(name, value);
|
|
258
|
-
return null;
|
|
259
|
-
};
|
|
260
|
-
/**
|
|
261
|
-
* getCSSProp
|
|
262
|
-
* @description Retrieves and CSS property value and trims it
|
|
263
|
-
* @param el The Element to read attributes/CSS from
|
|
264
|
-
* @param name Attribute or CSS property to get
|
|
265
|
-
* @return string CSS property value
|
|
266
|
-
*/
|
|
267
|
-
const getCSSProp = (el, prop) => getComputedStyle(el).getPropertyValue(prop).trim();
|
|
268
|
-
const STRIP_QUOTES = /^["']|["']$/g;
|
|
269
|
-
/**
|
|
270
|
-
* attrOrCSS
|
|
271
|
-
* @description Retrieves and updates attribute based on attribute or CSS property value
|
|
272
|
-
* @param el The Element to read attributes/CSS from
|
|
273
|
-
* @param name Attribute or CSS property to get
|
|
274
|
-
* @return string attribute or CSS property value
|
|
275
|
-
*/
|
|
276
|
-
const attrOrCSS = (el, name) => {
|
|
277
|
-
let value = attr(el, name);
|
|
278
|
-
if (!value) value = getCSSProp(el, `--_ds-${name}`).replace(STRIP_QUOTES, "").trim();
|
|
279
|
-
if (!value) warn(`Missing ${name} on:`, el);
|
|
280
|
-
return value || null;
|
|
281
|
-
};
|
|
282
|
-
/**
|
|
283
|
-
* on
|
|
284
|
-
* @param el The Element to use as EventTarget
|
|
285
|
-
* @param types A space separated string of event types
|
|
286
|
-
* @param listener An event listener function or listener object
|
|
287
|
-
*/
|
|
288
|
-
const on = (el, ...rest) => {
|
|
289
|
-
const [types, ...options] = rest;
|
|
290
|
-
for (const type of types.split(" ")) el.addEventListener(type, ...options);
|
|
291
|
-
return () => off(el, ...rest);
|
|
292
|
-
};
|
|
293
|
-
/**
|
|
294
|
-
* off
|
|
295
|
-
* @param el The Element to use as EventTarget
|
|
296
|
-
* @param types A space separated string of event types
|
|
297
|
-
* @param listener An event listener function or listener object
|
|
298
|
-
*/
|
|
299
|
-
const off = (el, ...rest) => {
|
|
300
|
-
const [types, ...options] = rest;
|
|
301
|
-
for (const type of types.split(" ")) el.removeEventListener(type, ...options);
|
|
302
|
-
};
|
|
303
|
-
/**
|
|
304
|
-
* onHotReload
|
|
305
|
-
* @description Runs a callback when window is loaded in browser, and ensures cleanup when hot-reloading
|
|
306
|
-
* @param key The key to identify setup and corresponding cleanup
|
|
307
|
-
* @param callback The callback to run when the page is ready
|
|
308
|
-
*/
|
|
309
|
-
const onHotReload = (key, setup) => {
|
|
310
|
-
if (!isBrowser()) return;
|
|
311
|
-
if (!window._dsHotReloadCleanup) window._dsHotReloadCleanup = /* @__PURE__ */ new Map();
|
|
312
|
-
window._dsHotReloadCleanup?.get(key)?.map((cleanup) => cleanup());
|
|
313
|
-
window._dsHotReloadCleanup?.set(key, setup());
|
|
314
|
-
};
|
|
315
|
-
/**
|
|
316
|
-
* MutationObserver wrapper with automatic cleanup
|
|
317
|
-
* @return new MutaionObserver
|
|
318
|
-
*/
|
|
319
|
-
const onMutation = (el, callback, options) => {
|
|
320
|
-
const cleanup = () => observer.disconnect();
|
|
321
|
-
const observer = new MutationObserver((records) => {
|
|
322
|
-
if (!isBrowser() || !el.isConnected) return cleanup();
|
|
323
|
-
callback(el, records);
|
|
437
|
+
return internals;
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
applyInvokerMixin(HTMLButtonElement);
|
|
441
|
+
observeShadowRoots(HTMLElement, (shadow) => {
|
|
442
|
+
setupInvokeListeners(shadow);
|
|
443
|
+
oncommandObserver.observe(shadow, { attributeFilter: ["oncommand"] });
|
|
444
|
+
applyOnCommandHandler(shadow.querySelectorAll("[oncommand]"));
|
|
324
445
|
});
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
return cleanup;
|
|
328
|
-
};
|
|
329
|
-
/**
|
|
330
|
-
* tag
|
|
331
|
-
* @description creates element and assigns properties
|
|
332
|
-
* @param tagName The tagname of element to create
|
|
333
|
-
* @param attrs Optional attributes to add to the element
|
|
334
|
-
* @param text Optional text content to add to the element
|
|
335
|
-
* @return HTMLElement with props
|
|
336
|
-
*/
|
|
337
|
-
const tag = (tagName, attrs) => {
|
|
338
|
-
const el = document.createElement(tagName);
|
|
339
|
-
if (attrs) for (const [key, val] of Object.entries(attrs)) attr(el, key, val);
|
|
340
|
-
return el;
|
|
341
|
-
};
|
|
342
|
-
/**
|
|
343
|
-
* customElements.define
|
|
344
|
-
* @description Defines a customElement if running in browser and if not already registered
|
|
345
|
-
* Scoped/named "customElements.define" so @custom-elements-manifest/analyzer can find tag names
|
|
346
|
-
*/
|
|
347
|
-
const customElements = { define: (name, instance) => !isBrowser() || window.customElements.get(name) || window.customElements.define(name, instance) };
|
|
348
|
-
let id = 0;
|
|
349
|
-
function useId(el) {
|
|
350
|
-
if (!isBrowser()) return `:ds:${++id}`;
|
|
351
|
-
if (!window.dsUseId) window.dsUseId = 0;
|
|
352
|
-
if (el && !el.id) el.id = `:ds:${++window.dsUseId}`;
|
|
353
|
-
return el?.id || "";
|
|
446
|
+
setupInvokeListeners(document);
|
|
447
|
+
Object.assign(globalThis, { CommandEvent });
|
|
354
448
|
}
|
|
355
|
-
/**
|
|
356
|
-
* @description Based off speak function from [U-elements](https://github.com/u-elements/u-elements/blob/main/packages/utils.ts#L210)
|
|
357
|
-
* @param text The text to announce
|
|
358
|
-
*/
|
|
359
|
-
let LIVE_EL;
|
|
360
|
-
let LIVE_FIX = 0;
|
|
361
|
-
let LIVE_CLEAR = 0;
|
|
362
|
-
const announce = (text) => {
|
|
363
|
-
clearTimeout(LIVE_CLEAR);
|
|
364
|
-
if (LIVE_EL) LIVE_EL.textContent = `${text}${LIVE_FIX++ % 2 ? "\xA0" : ""}`;
|
|
365
|
-
if (text) LIVE_CLEAR = setTimeout(announce, 2e3, "");
|
|
366
|
-
};
|
|
367
|
-
const announceMount = () => {
|
|
368
|
-
if (document.readyState !== "complete") return;
|
|
369
|
-
if (!LIVE_EL) {
|
|
370
|
-
LIVE_EL = tag("div", { "aria-live": "assertive" });
|
|
371
|
-
LIVE_EL.style.overflow = "hidden";
|
|
372
|
-
LIVE_EL.style.position = "fixed";
|
|
373
|
-
LIVE_EL.style.whiteSpace = "nowrap";
|
|
374
|
-
LIVE_EL.style.width = "1px";
|
|
375
|
-
}
|
|
376
|
-
if (!LIVE_EL.isConnected) document.body.appendChild(LIVE_EL);
|
|
377
|
-
};
|
|
378
|
-
onHotReload("announce", () => [on(document, "focus mouseover", announceMount, QUICK_EVENT)]);
|
|
379
449
|
//#endregion
|
|
380
|
-
//#region src/
|
|
381
|
-
|
|
382
|
-
const ATTR_CLICKDELEGATEFOR = "data-clickdelegatefor";
|
|
383
|
-
const SELECTOR_CLICKDELEGATEFOR = `[${ATTR_CLICKDELEGATEFOR}]`;
|
|
384
|
-
const SELECTOR_SKIP = "a,button,label,input,select,textarea,details,dialog,[role=\"button\"],[popover],[contenteditable]";
|
|
385
|
-
const handleClickDelegateFor = (event) => {
|
|
386
|
-
const isNewTab = event.button === 1 || event.metaKey || event.ctrlKey;
|
|
387
|
-
const delegateTarget = event.button < 2 && getDelegateTarget(event);
|
|
388
|
-
if (!delegateTarget || delegateTarget.contains(event.target)) return;
|
|
389
|
-
if (isNewTab && delegateTarget instanceof HTMLAnchorElement) return window.open(delegateTarget.href, void 0, delegateTarget.rel);
|
|
390
|
-
event.stopImmediatePropagation();
|
|
391
|
-
delegateTarget.click();
|
|
392
|
-
};
|
|
393
|
-
let HOVER;
|
|
394
|
-
const handleMouseOver = (event) => {
|
|
395
|
-
const delegateTarget = getDelegateTarget(event);
|
|
396
|
-
if (HOVER === delegateTarget) return;
|
|
397
|
-
if (HOVER) HOVER.classList.remove(CLASS_HOVER);
|
|
398
|
-
if (delegateTarget) delegateTarget.classList.add(CLASS_HOVER);
|
|
399
|
-
HOVER = delegateTarget;
|
|
400
|
-
};
|
|
401
|
-
const getDelegateTarget = ({ target: el }) => {
|
|
402
|
-
const id = (el instanceof Element ? el.closest(SELECTOR_CLICKDELEGATEFOR) : null)?.getAttribute(ATTR_CLICKDELEGATEFOR);
|
|
403
|
-
const target = id && document.getElementById(id) || void 0;
|
|
404
|
-
const skip = target && el.closest(SELECTOR_SKIP);
|
|
405
|
-
return (!skip || skip === target) && !target?.disabled ? target : void 0;
|
|
406
|
-
};
|
|
407
|
-
onHotReload("clickdelegatefor", () => [on(window, "click auxclick", handleClickDelegateFor, true), on(document, "mouseover", handleMouseOver, QUICK_EVENT)]);
|
|
450
|
+
//#region src/invokers/invokers.ts
|
|
451
|
+
if (isBrowser() && !isSupported$1()) apply$1();
|
|
408
452
|
//#endregion
|
|
409
|
-
//#region
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
DOWN_INSIDE = false;
|
|
418
|
-
if (isClose) requestAnimationFrame(() => el.open && el.close());
|
|
453
|
+
//#region ../../node_modules/.pnpm/@oddbird+popover-polyfill@0.6.1/node_modules/@oddbird/popover-polyfill/dist/popover-fn.js
|
|
454
|
+
var ToggleEvent = class extends Event {
|
|
455
|
+
oldState;
|
|
456
|
+
newState;
|
|
457
|
+
constructor(type, { oldState = "", newState = "", ...init } = {}) {
|
|
458
|
+
super(type, init);
|
|
459
|
+
this.oldState = String(oldState || "");
|
|
460
|
+
this.newState = String(newState || "");
|
|
419
461
|
}
|
|
420
462
|
};
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
463
|
+
var popoverToggleTaskQueue = /* @__PURE__ */ new WeakMap();
|
|
464
|
+
function queuePopoverToggleEventTask(element, oldState, newState) {
|
|
465
|
+
popoverToggleTaskQueue.set(element, setTimeout(() => {
|
|
466
|
+
if (!popoverToggleTaskQueue.has(element)) return;
|
|
467
|
+
element.dispatchEvent(new ToggleEvent("toggle", {
|
|
468
|
+
cancelable: false,
|
|
469
|
+
oldState,
|
|
470
|
+
newState
|
|
471
|
+
}));
|
|
472
|
+
}, 0));
|
|
473
|
+
}
|
|
474
|
+
var ShadowRoot$1 = globalThis.ShadowRoot || function() {};
|
|
475
|
+
var HTMLDialogElement$1 = globalThis.HTMLDialogElement || function() {};
|
|
476
|
+
var topLayerElements = /* @__PURE__ */ new WeakMap();
|
|
477
|
+
var autoPopoverList = /* @__PURE__ */ new WeakMap();
|
|
478
|
+
var hintPopoverList = /* @__PURE__ */ new WeakMap();
|
|
479
|
+
var visibilityState = /* @__PURE__ */ new WeakMap();
|
|
480
|
+
function getPopoverVisibilityState(popover) {
|
|
481
|
+
return visibilityState.get(popover) || "hidden";
|
|
482
|
+
}
|
|
483
|
+
var popoverInvoker = /* @__PURE__ */ new WeakMap();
|
|
484
|
+
function lastSetElement(set) {
|
|
485
|
+
return [...set].pop();
|
|
486
|
+
}
|
|
487
|
+
function popoverTargetAttributeActivationBehavior(element) {
|
|
488
|
+
const popover = element.popoverTargetElement;
|
|
489
|
+
if (!(popover instanceof HTMLElement)) return;
|
|
490
|
+
const visibility = getPopoverVisibilityState(popover);
|
|
491
|
+
if (element.popoverTargetAction === "show" && visibility === "showing") return;
|
|
492
|
+
if (element.popoverTargetAction === "hide" && visibility === "hidden") return;
|
|
493
|
+
if (visibility === "showing") hidePopover(popover, true, true);
|
|
494
|
+
else if (checkPopoverValidity(popover, false)) {
|
|
495
|
+
popoverInvoker.set(popover, element);
|
|
496
|
+
showPopover(popover);
|
|
443
497
|
}
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
498
|
+
}
|
|
499
|
+
function checkPopoverValidity(element, expectedToBeShowing) {
|
|
500
|
+
if (element.popover !== "auto" && element.popover !== "manual" && element.popover !== "hint") return false;
|
|
501
|
+
if (!element.isConnected) return false;
|
|
502
|
+
if (expectedToBeShowing && getPopoverVisibilityState(element) !== "showing") return false;
|
|
503
|
+
if (!expectedToBeShowing && getPopoverVisibilityState(element) !== "hidden") return false;
|
|
504
|
+
if (element instanceof HTMLDialogElement$1 && element.hasAttribute("open")) return false;
|
|
505
|
+
if (document.fullscreenElement === element) return false;
|
|
506
|
+
return true;
|
|
507
|
+
}
|
|
508
|
+
function getStackPosition(popover) {
|
|
509
|
+
if (!popover) return 0;
|
|
510
|
+
const autoPopovers = autoPopoverList.get(document) || /* @__PURE__ */ new Set();
|
|
511
|
+
const hintPopovers = hintPopoverList.get(document) || /* @__PURE__ */ new Set();
|
|
512
|
+
if (hintPopovers.has(popover)) return [...hintPopovers].indexOf(popover) + autoPopovers.size + 1;
|
|
513
|
+
if (autoPopovers.has(popover)) return [...autoPopovers].indexOf(popover) + 1;
|
|
514
|
+
return 0;
|
|
515
|
+
}
|
|
516
|
+
function topMostClickedPopover(target) {
|
|
517
|
+
const clickedPopover = nearestInclusiveOpenPopover(target);
|
|
518
|
+
const invokerPopover = nearestInclusiveTargetPopoverForInvoker(target);
|
|
519
|
+
if (getStackPosition(clickedPopover) > getStackPosition(invokerPopover)) return clickedPopover;
|
|
520
|
+
return invokerPopover;
|
|
521
|
+
}
|
|
522
|
+
function topmostAutoOrHintPopover(document2) {
|
|
523
|
+
let topmostPopover;
|
|
524
|
+
const hintPopovers = hintPopoverList.get(document2) || /* @__PURE__ */ new Set();
|
|
525
|
+
const autoPopovers = autoPopoverList.get(document2) || /* @__PURE__ */ new Set();
|
|
526
|
+
const usedStack = hintPopovers.size > 0 ? hintPopovers : autoPopovers.size > 0 ? autoPopovers : null;
|
|
527
|
+
if (usedStack) {
|
|
528
|
+
topmostPopover = lastSetElement(usedStack);
|
|
529
|
+
if (!topmostPopover.isConnected) {
|
|
530
|
+
usedStack.delete(topmostPopover);
|
|
531
|
+
return topmostAutoOrHintPopover(document2);
|
|
532
|
+
}
|
|
533
|
+
return topmostPopover;
|
|
534
|
+
}
|
|
535
|
+
return null;
|
|
536
|
+
}
|
|
537
|
+
function topMostPopoverInList(list) {
|
|
538
|
+
for (const popover of list || []) if (!popover.isConnected) list.delete(popover);
|
|
539
|
+
else return popover;
|
|
540
|
+
return null;
|
|
541
|
+
}
|
|
542
|
+
function getRootNode(node) {
|
|
543
|
+
if (typeof node.getRootNode === "function") return node.getRootNode();
|
|
544
|
+
if (node.parentNode) return getRootNode(node.parentNode);
|
|
545
|
+
return node;
|
|
546
|
+
}
|
|
547
|
+
function nearestInclusiveOpenPopover(node) {
|
|
548
|
+
while (node) {
|
|
549
|
+
if (node instanceof HTMLElement && node.popover === "auto" && visibilityState.get(node) === "showing") return node;
|
|
550
|
+
node = node instanceof Element && node.assignedSlot || node.parentElement || getRootNode(node);
|
|
551
|
+
if (node instanceof ShadowRoot$1) node = node.host;
|
|
552
|
+
if (node instanceof Document) return;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
function nearestInclusiveTargetPopoverForInvoker(node) {
|
|
556
|
+
while (node) {
|
|
557
|
+
const nodePopover = node.popoverTargetElement;
|
|
558
|
+
if (nodePopover instanceof HTMLElement) return nodePopover;
|
|
559
|
+
node = node.parentElement || getRootNode(node);
|
|
560
|
+
if (node instanceof ShadowRoot$1) node = node.host;
|
|
561
|
+
if (node instanceof Document) return;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
function topMostPopoverAncestor(newPopover, list) {
|
|
565
|
+
const popoverPositions = /* @__PURE__ */ new Map();
|
|
566
|
+
let i = 0;
|
|
567
|
+
for (const popover of list || []) {
|
|
568
|
+
popoverPositions.set(popover, i);
|
|
569
|
+
i += 1;
|
|
570
|
+
}
|
|
571
|
+
popoverPositions.set(newPopover, i);
|
|
572
|
+
i += 1;
|
|
573
|
+
let topMostPopoverAncestor2 = null;
|
|
574
|
+
function checkAncestor(candidate) {
|
|
575
|
+
if (!candidate) return;
|
|
576
|
+
let okNesting = false;
|
|
577
|
+
let candidateAncestor = null;
|
|
578
|
+
let candidatePosition = null;
|
|
579
|
+
while (!okNesting) {
|
|
580
|
+
candidateAncestor = nearestInclusiveOpenPopover(candidate) || null;
|
|
581
|
+
if (candidateAncestor === null) return;
|
|
582
|
+
if (!popoverPositions.has(candidateAncestor)) return;
|
|
583
|
+
if (newPopover.popover === "hint" || candidateAncestor.popover === "auto") okNesting = true;
|
|
584
|
+
if (!okNesting) candidate = candidateAncestor.parentElement;
|
|
585
|
+
}
|
|
586
|
+
candidatePosition = popoverPositions.get(candidateAncestor);
|
|
587
|
+
if (topMostPopoverAncestor2 === null || popoverPositions.get(topMostPopoverAncestor2) < candidatePosition) topMostPopoverAncestor2 = candidateAncestor;
|
|
588
|
+
}
|
|
589
|
+
checkAncestor(newPopover.parentElement || getRootNode(newPopover));
|
|
590
|
+
return topMostPopoverAncestor2;
|
|
591
|
+
}
|
|
592
|
+
function isFocusable(focusTarget) {
|
|
593
|
+
if (focusTarget.hidden || focusTarget instanceof ShadowRoot$1) return false;
|
|
594
|
+
if (focusTarget instanceof HTMLButtonElement || focusTarget instanceof HTMLInputElement || focusTarget instanceof HTMLSelectElement || focusTarget instanceof HTMLTextAreaElement || focusTarget instanceof HTMLOptGroupElement || focusTarget instanceof HTMLOptionElement || focusTarget instanceof HTMLFieldSetElement) {
|
|
595
|
+
if (focusTarget.disabled) return false;
|
|
596
|
+
}
|
|
597
|
+
if (focusTarget instanceof HTMLInputElement && focusTarget.type === "hidden") return false;
|
|
598
|
+
if (focusTarget instanceof HTMLAnchorElement && focusTarget.href === "") return false;
|
|
599
|
+
return typeof focusTarget.tabIndex === "number" && focusTarget.tabIndex !== -1;
|
|
600
|
+
}
|
|
601
|
+
function focusDelegate(focusTarget) {
|
|
602
|
+
if (focusTarget.shadowRoot && focusTarget.shadowRoot.delegatesFocus !== true) return null;
|
|
603
|
+
let whereToLook = focusTarget;
|
|
604
|
+
if (whereToLook.shadowRoot) whereToLook = whereToLook.shadowRoot;
|
|
605
|
+
let autoFocusDelegate = whereToLook.querySelector("[autofocus]");
|
|
606
|
+
if (autoFocusDelegate) return autoFocusDelegate;
|
|
607
|
+
else {
|
|
608
|
+
const slots = whereToLook.querySelectorAll("slot");
|
|
609
|
+
for (const slot of slots) {
|
|
610
|
+
const assignedElements = slot.assignedElements({ flatten: true });
|
|
611
|
+
for (const el of assignedElements) if (el.hasAttribute("autofocus")) return el;
|
|
612
|
+
else {
|
|
613
|
+
autoFocusDelegate = el.querySelector("[autofocus]");
|
|
614
|
+
if (autoFocusDelegate) return autoFocusDelegate;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
const walker = focusTarget.ownerDocument.createTreeWalker(whereToLook, NodeFilter.SHOW_ELEMENT);
|
|
619
|
+
let descendant = walker.currentNode;
|
|
620
|
+
while (descendant) {
|
|
621
|
+
if (isFocusable(descendant)) return descendant;
|
|
622
|
+
descendant = walker.nextNode();
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
function popoverFocusingSteps(subject) {
|
|
626
|
+
var _a;
|
|
627
|
+
(_a = focusDelegate(subject)) == null || _a.focus();
|
|
628
|
+
}
|
|
629
|
+
var previouslyFocusedElements = /* @__PURE__ */ new WeakMap();
|
|
630
|
+
function showPopover(element) {
|
|
631
|
+
if (!checkPopoverValidity(element, false)) return;
|
|
632
|
+
const document2 = element.ownerDocument;
|
|
633
|
+
if (!element.dispatchEvent(new ToggleEvent("beforetoggle", {
|
|
634
|
+
cancelable: true,
|
|
635
|
+
oldState: "closed",
|
|
636
|
+
newState: "open"
|
|
637
|
+
}))) return;
|
|
638
|
+
if (!checkPopoverValidity(element, false)) return;
|
|
639
|
+
let shouldRestoreFocus = false;
|
|
640
|
+
const originalType = element.popover;
|
|
641
|
+
let stackToAppendTo = null;
|
|
642
|
+
const autoAncestor = topMostPopoverAncestor(element, autoPopoverList.get(document2) || /* @__PURE__ */ new Set());
|
|
643
|
+
const hintAncestor = topMostPopoverAncestor(element, hintPopoverList.get(document2) || /* @__PURE__ */ new Set());
|
|
644
|
+
if (originalType === "auto") {
|
|
645
|
+
closeAllOpenPopoversInList(hintPopoverList.get(document2) || /* @__PURE__ */ new Set(), shouldRestoreFocus, true);
|
|
646
|
+
hideAllPopoversUntil(autoAncestor || document2, shouldRestoreFocus, true);
|
|
647
|
+
stackToAppendTo = "auto";
|
|
648
|
+
}
|
|
649
|
+
if (originalType === "hint") if (hintAncestor) {
|
|
650
|
+
hideAllPopoversUntil(hintAncestor, shouldRestoreFocus, true);
|
|
651
|
+
stackToAppendTo = "hint";
|
|
652
|
+
} else {
|
|
653
|
+
closeAllOpenPopoversInList(hintPopoverList.get(document2) || /* @__PURE__ */ new Set(), shouldRestoreFocus, true);
|
|
654
|
+
if (autoAncestor) {
|
|
655
|
+
hideAllPopoversUntil(autoAncestor, shouldRestoreFocus, true);
|
|
656
|
+
stackToAppendTo = "auto";
|
|
657
|
+
} else stackToAppendTo = "hint";
|
|
658
|
+
}
|
|
659
|
+
if (originalType === "auto" || originalType === "hint") {
|
|
660
|
+
if (originalType !== element.popover || !checkPopoverValidity(element, false)) return;
|
|
661
|
+
if (!topmostAutoOrHintPopover(document2)) shouldRestoreFocus = true;
|
|
662
|
+
if (stackToAppendTo === "auto") {
|
|
663
|
+
if (!autoPopoverList.has(document2)) autoPopoverList.set(document2, /* @__PURE__ */ new Set());
|
|
664
|
+
autoPopoverList.get(document2).add(element);
|
|
665
|
+
} else if (stackToAppendTo === "hint") {
|
|
666
|
+
if (!hintPopoverList.has(document2)) hintPopoverList.set(document2, /* @__PURE__ */ new Set());
|
|
667
|
+
hintPopoverList.get(document2).add(element);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
previouslyFocusedElements.delete(element);
|
|
671
|
+
const originallyFocusedElement = document2.activeElement;
|
|
672
|
+
element.classList.add(":popover-open");
|
|
673
|
+
visibilityState.set(element, "showing");
|
|
674
|
+
if (!topLayerElements.has(document2)) topLayerElements.set(document2, /* @__PURE__ */ new Set());
|
|
675
|
+
topLayerElements.get(document2).add(element);
|
|
676
|
+
setInvokerAriaExpanded(popoverInvoker.get(element), true);
|
|
677
|
+
popoverFocusingSteps(element);
|
|
678
|
+
if (shouldRestoreFocus && originallyFocusedElement && element.popover === "auto") previouslyFocusedElements.set(element, originallyFocusedElement);
|
|
679
|
+
queuePopoverToggleEventTask(element, "closed", "open");
|
|
680
|
+
}
|
|
681
|
+
function hidePopover(element, focusPreviousElement = false, fireEvents = false) {
|
|
682
|
+
var _a, _b;
|
|
683
|
+
if (!checkPopoverValidity(element, true)) return;
|
|
684
|
+
const document2 = element.ownerDocument;
|
|
685
|
+
if (["auto", "hint"].includes(element.popover)) {
|
|
686
|
+
hideAllPopoversUntil(element, focusPreviousElement, fireEvents);
|
|
687
|
+
if (!checkPopoverValidity(element, true)) return;
|
|
688
|
+
}
|
|
689
|
+
const autoList = autoPopoverList.get(document2) || /* @__PURE__ */ new Set();
|
|
690
|
+
const autoPopoverListContainsElement = autoList.has(element) && lastSetElement(autoList) === element;
|
|
691
|
+
setInvokerAriaExpanded(popoverInvoker.get(element), false);
|
|
692
|
+
popoverInvoker.delete(element);
|
|
693
|
+
if (fireEvents) {
|
|
694
|
+
element.dispatchEvent(new ToggleEvent("beforetoggle", {
|
|
695
|
+
oldState: "open",
|
|
696
|
+
newState: "closed"
|
|
697
|
+
}));
|
|
698
|
+
if (autoPopoverListContainsElement && lastSetElement(autoList) !== element) hideAllPopoversUntil(element, focusPreviousElement, fireEvents);
|
|
699
|
+
if (!checkPopoverValidity(element, true)) return;
|
|
700
|
+
}
|
|
701
|
+
(_a = topLayerElements.get(document2)) == null || _a.delete(element);
|
|
702
|
+
autoList.delete(element);
|
|
703
|
+
(_b = hintPopoverList.get(document2)) == null || _b.delete(element);
|
|
704
|
+
element.classList.remove(":popover-open");
|
|
705
|
+
visibilityState.set(element, "hidden");
|
|
706
|
+
if (fireEvents) queuePopoverToggleEventTask(element, "open", "closed");
|
|
707
|
+
const previouslyFocusedElement = previouslyFocusedElements.get(element);
|
|
708
|
+
if (previouslyFocusedElement) {
|
|
709
|
+
previouslyFocusedElements.delete(element);
|
|
710
|
+
if (focusPreviousElement) previouslyFocusedElement.focus();
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
function closeAllOpenPopovers(document2, focusPreviousElement = false, fireEvents = false) {
|
|
714
|
+
let popover = topmostAutoOrHintPopover(document2);
|
|
715
|
+
while (popover) {
|
|
716
|
+
hidePopover(popover, focusPreviousElement, fireEvents);
|
|
717
|
+
popover = topmostAutoOrHintPopover(document2);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
function closeAllOpenPopoversInList(list, focusPreviousElement = false, fireEvents = false) {
|
|
721
|
+
let popover = topMostPopoverInList(list);
|
|
722
|
+
while (popover) {
|
|
723
|
+
hidePopover(popover, focusPreviousElement, fireEvents);
|
|
724
|
+
popover = topMostPopoverInList(list);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
function hidePopoverStackUntil(endpoint, set, focusPreviousElement, fireEvents) {
|
|
728
|
+
let repeatingHide = false;
|
|
729
|
+
let hasRunOnce = false;
|
|
730
|
+
while (repeatingHide || !hasRunOnce) {
|
|
731
|
+
hasRunOnce = true;
|
|
732
|
+
let lastToHide = null;
|
|
733
|
+
let foundEndpoint = false;
|
|
734
|
+
for (const popover of set) if (popover === endpoint) foundEndpoint = true;
|
|
735
|
+
else if (foundEndpoint) {
|
|
736
|
+
lastToHide = popover;
|
|
737
|
+
break;
|
|
738
|
+
}
|
|
739
|
+
if (!lastToHide) return;
|
|
740
|
+
while (getPopoverVisibilityState(lastToHide) === "showing" && set.size) hidePopover(lastSetElement(set), focusPreviousElement, fireEvents);
|
|
741
|
+
if (set.has(endpoint) && lastSetElement(set) !== endpoint) repeatingHide = true;
|
|
742
|
+
if (repeatingHide) fireEvents = false;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
function hideAllPopoversUntil(endpoint, focusPreviousElement, fireEvents) {
|
|
746
|
+
var _a, _b;
|
|
747
|
+
const document2 = endpoint.ownerDocument || endpoint;
|
|
748
|
+
if (endpoint instanceof Document) return closeAllOpenPopovers(document2, focusPreviousElement, fireEvents);
|
|
749
|
+
if ((_a = hintPopoverList.get(document2)) == null ? void 0 : _a.has(endpoint)) {
|
|
750
|
+
hidePopoverStackUntil(endpoint, hintPopoverList.get(document2), focusPreviousElement, fireEvents);
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
closeAllOpenPopoversInList(hintPopoverList.get(document2) || /* @__PURE__ */ new Set(), focusPreviousElement, fireEvents);
|
|
754
|
+
if (!((_b = autoPopoverList.get(document2)) == null ? void 0 : _b.has(endpoint))) return;
|
|
755
|
+
hidePopoverStackUntil(endpoint, autoPopoverList.get(document2), focusPreviousElement, fireEvents);
|
|
756
|
+
}
|
|
757
|
+
var popoverPointerDownTargets = /* @__PURE__ */ new WeakMap();
|
|
758
|
+
function lightDismissOpenPopovers(event) {
|
|
759
|
+
if (!event.isTrusted) return;
|
|
760
|
+
const target = event.composedPath()[0];
|
|
761
|
+
if (!target) return;
|
|
762
|
+
const document2 = target.ownerDocument;
|
|
763
|
+
if (!topmostAutoOrHintPopover(document2)) return;
|
|
764
|
+
const ancestor = topMostClickedPopover(target);
|
|
765
|
+
if (ancestor && event.type === "pointerdown") popoverPointerDownTargets.set(document2, ancestor);
|
|
766
|
+
else if (event.type === "pointerup") {
|
|
767
|
+
const sameTarget = popoverPointerDownTargets.get(document2) === ancestor;
|
|
768
|
+
popoverPointerDownTargets.delete(document2);
|
|
769
|
+
if (sameTarget) hideAllPopoversUntil(ancestor || document2, false, true);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
var initialAriaExpandedValue = /* @__PURE__ */ new WeakMap();
|
|
773
|
+
function setInvokerAriaExpanded(el, force = false) {
|
|
774
|
+
if (!el) return;
|
|
775
|
+
if (!initialAriaExpandedValue.has(el)) initialAriaExpandedValue.set(el, el.getAttribute("aria-expanded"));
|
|
776
|
+
const popover = el.popoverTargetElement;
|
|
777
|
+
if (popover instanceof HTMLElement && popover.popover === "auto") el.setAttribute("aria-expanded", String(force));
|
|
778
|
+
else {
|
|
779
|
+
const initialValue = initialAriaExpandedValue.get(el);
|
|
780
|
+
if (!initialValue) el.removeAttribute("aria-expanded");
|
|
781
|
+
else el.setAttribute("aria-expanded", initialValue);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
var ShadowRoot2 = globalThis.ShadowRoot || function() {};
|
|
785
|
+
function isSupported() {
|
|
786
|
+
return typeof HTMLElement !== "undefined" && typeof HTMLElement.prototype === "object" && "popover" in HTMLElement.prototype;
|
|
787
|
+
}
|
|
788
|
+
function patchSelectorFn(object, name, mapper) {
|
|
789
|
+
const original = object[name];
|
|
790
|
+
Object.defineProperty(object, name, { value(selector) {
|
|
791
|
+
return original.call(this, mapper(selector));
|
|
792
|
+
} });
|
|
793
|
+
}
|
|
794
|
+
var nonEscapedPopoverSelector = /(^|[^\\]):popover-open\b/g;
|
|
795
|
+
function hasLayerSupport() {
|
|
796
|
+
return typeof globalThis.CSSLayerBlockRule === "function";
|
|
797
|
+
}
|
|
798
|
+
function getStyles() {
|
|
799
|
+
const useLayer = hasLayerSupport();
|
|
800
|
+
return `
|
|
801
|
+
${useLayer ? "@layer popover-polyfill {" : ""}
|
|
802
|
+
:where([popover]) {
|
|
803
|
+
position: fixed;
|
|
804
|
+
z-index: 2147483647;
|
|
805
|
+
inset: 0;
|
|
806
|
+
padding: 0.25em;
|
|
807
|
+
width: fit-content;
|
|
808
|
+
height: fit-content;
|
|
809
|
+
border-width: initial;
|
|
810
|
+
border-color: initial;
|
|
811
|
+
border-image: initial;
|
|
812
|
+
border-style: solid;
|
|
813
|
+
background-color: canvas;
|
|
814
|
+
color: canvastext;
|
|
815
|
+
overflow: auto;
|
|
816
|
+
margin: auto;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
:where([popover]:not(.\\:popover-open)) {
|
|
820
|
+
display: none;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
:where(dialog[popover].\\:popover-open) {
|
|
824
|
+
display: block;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
:where(dialog[popover][open]) {
|
|
828
|
+
display: revert;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
:where([anchor].\\:popover-open) {
|
|
832
|
+
inset: auto;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
:where([anchor]:popover-open) {
|
|
836
|
+
inset: auto;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
@supports not (background-color: canvas) {
|
|
840
|
+
:where([popover]) {
|
|
841
|
+
background-color: white;
|
|
842
|
+
color: black;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
@supports (width: -moz-fit-content) {
|
|
847
|
+
:where([popover]) {
|
|
848
|
+
width: -moz-fit-content;
|
|
849
|
+
height: -moz-fit-content;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
@supports not (inset: 0) {
|
|
854
|
+
:where([popover]) {
|
|
855
|
+
top: 0;
|
|
856
|
+
left: 0;
|
|
857
|
+
right: 0;
|
|
858
|
+
bottom: 0;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
${useLayer ? "}" : ""}
|
|
862
|
+
`;
|
|
863
|
+
}
|
|
864
|
+
var popoverStyleSheet = null;
|
|
865
|
+
function injectStyles(root) {
|
|
866
|
+
const styles = getStyles();
|
|
867
|
+
if (popoverStyleSheet === null) try {
|
|
868
|
+
popoverStyleSheet = new CSSStyleSheet();
|
|
869
|
+
popoverStyleSheet.replaceSync(styles);
|
|
870
|
+
} catch {
|
|
871
|
+
popoverStyleSheet = false;
|
|
872
|
+
}
|
|
873
|
+
if (popoverStyleSheet === false) {
|
|
874
|
+
const sheet = document.createElement("style");
|
|
875
|
+
sheet.textContent = styles;
|
|
876
|
+
if (root instanceof Document) root.head.prepend(sheet);
|
|
877
|
+
else root.prepend(sheet);
|
|
878
|
+
} else root.adoptedStyleSheets = [popoverStyleSheet, ...root.adoptedStyleSheets];
|
|
879
|
+
}
|
|
880
|
+
function apply() {
|
|
881
|
+
if (typeof window === "undefined") return;
|
|
882
|
+
window.ToggleEvent = window.ToggleEvent || ToggleEvent;
|
|
883
|
+
function rewriteSelector(selector) {
|
|
884
|
+
if (selector == null ? void 0 : selector.includes(":popover-open")) selector = selector.replace(nonEscapedPopoverSelector, "$1.\\:popover-open");
|
|
885
|
+
return selector;
|
|
886
|
+
}
|
|
887
|
+
patchSelectorFn(Document.prototype, "querySelector", rewriteSelector);
|
|
888
|
+
patchSelectorFn(Document.prototype, "querySelectorAll", rewriteSelector);
|
|
889
|
+
patchSelectorFn(Element.prototype, "querySelector", rewriteSelector);
|
|
890
|
+
patchSelectorFn(Element.prototype, "querySelectorAll", rewriteSelector);
|
|
891
|
+
patchSelectorFn(Element.prototype, "matches", rewriteSelector);
|
|
892
|
+
patchSelectorFn(Element.prototype, "closest", rewriteSelector);
|
|
893
|
+
patchSelectorFn(DocumentFragment.prototype, "querySelectorAll", rewriteSelector);
|
|
894
|
+
Object.defineProperties(HTMLElement.prototype, {
|
|
895
|
+
popover: {
|
|
896
|
+
enumerable: true,
|
|
897
|
+
configurable: true,
|
|
898
|
+
get() {
|
|
899
|
+
if (!this.hasAttribute("popover")) return null;
|
|
900
|
+
const value = (this.getAttribute("popover") || "").toLowerCase();
|
|
901
|
+
if (value === "" || value == "auto") return "auto";
|
|
902
|
+
if (value == "hint") return "hint";
|
|
903
|
+
return "manual";
|
|
904
|
+
},
|
|
905
|
+
set(value) {
|
|
906
|
+
if (value === null) this.removeAttribute("popover");
|
|
907
|
+
else this.setAttribute("popover", value);
|
|
908
|
+
}
|
|
909
|
+
},
|
|
910
|
+
showPopover: {
|
|
911
|
+
enumerable: true,
|
|
912
|
+
configurable: true,
|
|
913
|
+
value(options = {}) {
|
|
914
|
+
showPopover(this);
|
|
915
|
+
}
|
|
916
|
+
},
|
|
917
|
+
hidePopover: {
|
|
918
|
+
enumerable: true,
|
|
919
|
+
configurable: true,
|
|
920
|
+
value() {
|
|
921
|
+
hidePopover(this, true, true);
|
|
922
|
+
}
|
|
923
|
+
},
|
|
924
|
+
togglePopover: {
|
|
925
|
+
enumerable: true,
|
|
926
|
+
configurable: true,
|
|
927
|
+
value(options = {}) {
|
|
928
|
+
if (typeof options === "boolean") options = { force: options };
|
|
929
|
+
if (visibilityState.get(this) === "showing" && options.force === void 0 || options.force === false) hidePopover(this, true, true);
|
|
930
|
+
else if (options.force === void 0 || options.force === true) showPopover(this);
|
|
931
|
+
return visibilityState.get(this) === "showing";
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
});
|
|
935
|
+
const originalAttachShadow = Element.prototype.attachShadow;
|
|
936
|
+
if (originalAttachShadow) Object.defineProperties(Element.prototype, { attachShadow: {
|
|
937
|
+
enumerable: true,
|
|
938
|
+
configurable: true,
|
|
939
|
+
writable: true,
|
|
940
|
+
value(options) {
|
|
941
|
+
const shadowRoot = originalAttachShadow.call(this, options);
|
|
942
|
+
injectStyles(shadowRoot);
|
|
943
|
+
return shadowRoot;
|
|
944
|
+
}
|
|
945
|
+
} });
|
|
946
|
+
const originalAttachInternals = HTMLElement.prototype.attachInternals;
|
|
947
|
+
if (originalAttachInternals) Object.defineProperties(HTMLElement.prototype, { attachInternals: {
|
|
948
|
+
enumerable: true,
|
|
949
|
+
configurable: true,
|
|
950
|
+
writable: true,
|
|
951
|
+
value() {
|
|
952
|
+
const internals = originalAttachInternals.call(this);
|
|
953
|
+
if (internals.shadowRoot) injectStyles(internals.shadowRoot);
|
|
954
|
+
return internals;
|
|
955
|
+
}
|
|
956
|
+
} });
|
|
957
|
+
const popoverTargetAssociatedElements = /* @__PURE__ */ new WeakMap();
|
|
958
|
+
function applyPopoverInvokerElementMixin(ElementClass) {
|
|
959
|
+
Object.defineProperties(ElementClass.prototype, {
|
|
960
|
+
popoverTargetElement: {
|
|
961
|
+
enumerable: true,
|
|
962
|
+
configurable: true,
|
|
963
|
+
set(targetElement) {
|
|
964
|
+
if (targetElement === null) {
|
|
965
|
+
this.removeAttribute("popovertarget");
|
|
966
|
+
popoverTargetAssociatedElements.delete(this);
|
|
967
|
+
} else if (!(targetElement instanceof Element)) throw new TypeError(`popoverTargetElement must be an element or null`);
|
|
968
|
+
else {
|
|
969
|
+
this.setAttribute("popovertarget", "");
|
|
970
|
+
popoverTargetAssociatedElements.set(this, targetElement);
|
|
971
|
+
}
|
|
972
|
+
},
|
|
973
|
+
get() {
|
|
974
|
+
if (this.localName !== "button" && this.localName !== "input") return null;
|
|
975
|
+
if (this.localName === "input" && this.type !== "reset" && this.type !== "image" && this.type !== "button") return null;
|
|
976
|
+
if (this.disabled) return null;
|
|
977
|
+
if (this.form && this.type === "submit") return null;
|
|
978
|
+
const targetElement = popoverTargetAssociatedElements.get(this);
|
|
979
|
+
if (targetElement && targetElement.isConnected) return targetElement;
|
|
980
|
+
else if (targetElement && !targetElement.isConnected) {
|
|
981
|
+
popoverTargetAssociatedElements.delete(this);
|
|
982
|
+
return null;
|
|
983
|
+
}
|
|
984
|
+
const root = getRootNode(this);
|
|
985
|
+
const idref = this.getAttribute("popovertarget");
|
|
986
|
+
if ((root instanceof Document || root instanceof ShadowRoot2) && idref) return root.getElementById(idref) || null;
|
|
987
|
+
return null;
|
|
988
|
+
}
|
|
989
|
+
},
|
|
990
|
+
popoverTargetAction: {
|
|
991
|
+
enumerable: true,
|
|
992
|
+
configurable: true,
|
|
993
|
+
get() {
|
|
994
|
+
const value = (this.getAttribute("popovertargetaction") || "").toLowerCase();
|
|
995
|
+
if (value === "show" || value === "hide") return value;
|
|
996
|
+
return "toggle";
|
|
997
|
+
},
|
|
998
|
+
set(value) {
|
|
999
|
+
this.setAttribute("popovertargetaction", value);
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
applyPopoverInvokerElementMixin(HTMLButtonElement);
|
|
1005
|
+
applyPopoverInvokerElementMixin(HTMLInputElement);
|
|
1006
|
+
const handleInvokerActivation = (event) => {
|
|
1007
|
+
if (event.defaultPrevented) return;
|
|
1008
|
+
const composedPath = event.composedPath();
|
|
1009
|
+
const target = composedPath[0];
|
|
1010
|
+
if (!(target instanceof Element) || (target == null ? void 0 : target.shadowRoot)) return;
|
|
1011
|
+
const root = getRootNode(target);
|
|
1012
|
+
if (!(root instanceof ShadowRoot2 || root instanceof Document)) return;
|
|
1013
|
+
const invoker = composedPath.find((el) => {
|
|
1014
|
+
var _a;
|
|
1015
|
+
return (_a = el.matches) == null ? void 0 : _a.call(el, "[popovertargetaction],[popovertarget]");
|
|
1016
|
+
});
|
|
1017
|
+
if (invoker) {
|
|
1018
|
+
popoverTargetAttributeActivationBehavior(invoker);
|
|
1019
|
+
event.preventDefault();
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1022
|
+
};
|
|
1023
|
+
const onKeydown = (event) => {
|
|
1024
|
+
const key = event.key;
|
|
1025
|
+
const target = event.target;
|
|
1026
|
+
if (!event.defaultPrevented && target && (key === "Escape" || key === "Esc")) hideAllPopoversUntil(target.ownerDocument, true, true);
|
|
1027
|
+
};
|
|
1028
|
+
const addEventListeners = (root) => {
|
|
1029
|
+
root.addEventListener("click", handleInvokerActivation);
|
|
1030
|
+
root.addEventListener("keydown", onKeydown);
|
|
1031
|
+
root.addEventListener("pointerdown", lightDismissOpenPopovers);
|
|
1032
|
+
root.addEventListener("pointerup", lightDismissOpenPopovers);
|
|
1033
|
+
};
|
|
1034
|
+
addEventListeners(document);
|
|
1035
|
+
injectStyles(document);
|
|
1036
|
+
}
|
|
449
1037
|
//#endregion
|
|
450
1038
|
//#region src/popover/popover.ts
|
|
1039
|
+
if (isBrowser() && !isSupported()) apply();
|
|
451
1040
|
const ATTR_PLACE = "data-placement";
|
|
452
1041
|
const ATTR_AUTO = "data-autoplacement";
|
|
453
1042
|
const POPOVERS = /* @__PURE__ */ new Map();
|
|
@@ -462,11 +1051,12 @@ function handleToggle(event) {
|
|
|
462
1051
|
source = el.id && root?.querySelector?.(css) || void 0;
|
|
463
1052
|
}
|
|
464
1053
|
if (!source || source === el || oldState && oldState === newState) return;
|
|
1054
|
+
el.style.scrollMarginBottom = `var(--_ds-floating-arrow-size)`;
|
|
465
1055
|
const padding = 10;
|
|
466
1056
|
const overscroll = getCSSProp(el, "--_ds-floating-overscroll");
|
|
467
1057
|
const placement = attr(el, ATTR_PLACE) || attr(source, ATTR_PLACE) || float;
|
|
468
1058
|
const auto = attr(el, ATTR_AUTO) || attr(source, ATTR_AUTO);
|
|
469
|
-
const arrowSize = parseFloat(
|
|
1059
|
+
const arrowSize = parseFloat(getCSSProp(el, "scroll-margin-bottom")) || 0;
|
|
470
1060
|
const shiftProp = placement.match(/left|right/gi) ? "Height" : "Width";
|
|
471
1061
|
const shiftLimit = source[`offset${shiftProp}`] / 2 + arrowSize;
|
|
472
1062
|
if (placement === "none") return;
|
|
@@ -474,7 +1064,7 @@ function handleToggle(event) {
|
|
|
474
1064
|
strategy: "absolute",
|
|
475
1065
|
placement,
|
|
476
1066
|
middleware: [
|
|
477
|
-
offset(arrowSize
|
|
1067
|
+
offset(arrowSize),
|
|
478
1068
|
shift({
|
|
479
1069
|
padding,
|
|
480
1070
|
limiter: limitShift({ offset: { mainAxis: shiftLimit } })
|
|
@@ -485,7 +1075,7 @@ function handleToggle(event) {
|
|
|
485
1075
|
crossAxis: false
|
|
486
1076
|
})] : [],
|
|
487
1077
|
...overscroll ? [size({ apply({ availableHeight }) {
|
|
488
|
-
if (overscroll === "fit") el.style.width = `${source.
|
|
1078
|
+
if (overscroll === "fit") el.style.width = `${source.offsetWidth}px`;
|
|
489
1079
|
el.style.maxHeight = `${Math.max(50, availableHeight - padding * 2)}px`;
|
|
490
1080
|
} })] : []
|
|
491
1081
|
]
|
|
@@ -725,6 +1315,7 @@ var DSErrorSummaryElement = class extends DSElement {
|
|
|
725
1315
|
_unmutate;
|
|
726
1316
|
connectedCallback() {
|
|
727
1317
|
on(this, "animationend", this, QUICK_EVENT);
|
|
1318
|
+
attr(this, "role", "group");
|
|
728
1319
|
attr(this, "tabindex", "-1");
|
|
729
1320
|
this._unmutate = onMutation(this, render$2, {
|
|
730
1321
|
childList: true,
|
|
@@ -742,8 +1333,11 @@ var DSErrorSummaryElement = class extends DSElement {
|
|
|
742
1333
|
}
|
|
743
1334
|
};
|
|
744
1335
|
const render$2 = (self) => {
|
|
1336
|
+
const label = attr(self, "aria-label")?.trim();
|
|
1337
|
+
const labelledBy = attr(self, "aria-labelledby")?.trim();
|
|
745
1338
|
const heading = self.querySelector("h2,h3,h4,h5,h6");
|
|
746
|
-
if (heading) attr(self, "aria-labelledby", useId(heading));
|
|
1339
|
+
if (heading && !label && !labelledBy) attr(self, "aria-labelledby", useId(heading));
|
|
1340
|
+
if (!heading && !label && !labelledBy) warn("Missing accessible name on:", self, "\nAdd a heading (h2–h6), or set aria-label or aria-labelledby to provide an accessible name for screen readers.");
|
|
747
1341
|
};
|
|
748
1342
|
customElements.define("ds-error-summary", DSErrorSummaryElement);
|
|
749
1343
|
//#endregion
|
|
@@ -954,11 +1548,13 @@ var DSSuggestionElement = class extends UHTMLComboboxElement {
|
|
|
954
1548
|
off(this, "toggle", polyfillToggleSource, QUICK_EVENT);
|
|
955
1549
|
}
|
|
956
1550
|
};
|
|
957
|
-
const render = (
|
|
1551
|
+
const render = (self) => {
|
|
1552
|
+
const { control, list } = self;
|
|
1553
|
+
const datalist = list || self.querySelector("u-datalist");
|
|
958
1554
|
if (control && !control.placeholder) attr(control, "placeholder", " ");
|
|
959
1555
|
if (control) attr(control, "popovertarget", useId(list) || null);
|
|
960
|
-
if (
|
|
961
|
-
if (
|
|
1556
|
+
if (datalist) attr(datalist, "popover", "manual");
|
|
1557
|
+
if (datalist) attr(datalist, "data-is-floating", "true");
|
|
962
1558
|
};
|
|
963
1559
|
const polyfillToggleSource = (event) => {
|
|
964
1560
|
const self = event.currentTarget;
|
|
@@ -977,9 +1573,6 @@ customElements.define("ds-tablist", DSTabListElement);
|
|
|
977
1573
|
customElements.define("ds-tab", DSTabElement);
|
|
978
1574
|
customElements.define("ds-tabpanel", DSTabPanelElement);
|
|
979
1575
|
//#endregion
|
|
980
|
-
//#region src/index.ts
|
|
981
|
-
if (isBrowser() && !isSupported()) apply();
|
|
982
|
-
//#endregion
|
|
983
1576
|
export { DSBreadcrumbsElement, DSErrorSummaryElement, DSFieldElement, DSPaginationElement, DSSuggestionElement, DSTabElement, DSTabListElement, DSTabPanelElement, DSTabsElement, pagination, setTooltipElement };
|
|
984
1577
|
|
|
985
1578
|
//# sourceMappingURL=index.js.map
|