@digdir/designsystemet-web 1.15.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.
Files changed (34) hide show
  1. package/README.md +136 -103
  2. package/dist/cjs/_vendors/@oddbird/popover-polyfill/dist/popover-fn.cjs +64 -0
  3. package/dist/cjs/_vendors/@oddbird/popover-polyfill/dist/popover-fn.cjs.map +1 -0
  4. package/dist/cjs/details/details.cjs +1 -0
  5. package/dist/cjs/index.cjs +1 -2
  6. package/dist/cjs/invokers/invokers.cjs +2 -0
  7. package/dist/cjs/invokers/invokers.cjs.map +1 -0
  8. package/dist/cjs/popover/popover.cjs +1 -1
  9. package/dist/cjs/popover/popover.cjs.map +1 -1
  10. package/dist/cjs/suggestion/suggestion.cjs +1 -1
  11. package/dist/cjs/suggestion/suggestion.cjs.map +1 -1
  12. package/dist/cjs/tooltip/tooltip.cjs +1 -1
  13. package/dist/cjs/tooltip/tooltip.cjs.map +1 -1
  14. package/dist/custom-elements.json +12 -0
  15. package/dist/esm/_vendors/@oddbird/popover-polyfill/dist/popover-fn.js +64 -0
  16. package/dist/esm/_vendors/@oddbird/popover-polyfill/dist/popover-fn.js.map +1 -0
  17. package/dist/esm/details/details.js +1 -0
  18. package/dist/esm/index.js +1 -2
  19. package/dist/esm/invokers/invokers.js +2 -0
  20. package/dist/esm/invokers/invokers.js.map +1 -0
  21. package/dist/esm/popover/popover.js +1 -1
  22. package/dist/esm/popover/popover.js.map +1 -1
  23. package/dist/esm/suggestion/suggestion.js +1 -1
  24. package/dist/esm/suggestion/suggestion.js.map +1 -1
  25. package/dist/esm/tooltip/tooltip.js +1 -1
  26. package/dist/esm/tooltip/tooltip.js.map +1 -1
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +823 -234
  29. package/dist/index.js.map +1 -1
  30. package/dist/umd/index.js +69 -7
  31. package/dist/umd/index.js.map +1 -1
  32. package/package.json +14 -3
  33. package/dist/cjs/index.cjs.map +0 -1
  34. package/dist/esm/index.js.map +0 -1
package/README.md CHANGED
@@ -5,44 +5,72 @@
5
5
  - [`@digdir/designsystemet-web`](#digdirdesignsystemet-web)
6
6
  - [Table of contents](#table-of-contents)
7
7
  - [Get started](#get-started)
8
+ - [Pick the parts you need](#pick-the-parts-you-need)
8
9
  - [Individual imports](#individual-imports)
9
10
  - [Types](#types)
10
11
  - [Warnings:](#warnings)
11
12
  - [`<ds-breadcrumbs>`](#ds-breadcrumbs)
13
+ - [`data-clickdelegatefor`](#data-clickdelegatefor)
14
+ - [`details` and `summary` (accessibility polyfill)](#details-and-summary-accessibility-polyfill)
15
+ - [`<dialog>` (`closedby` polyfill)](#dialog-closedby-polyfill)
12
16
  - [`<ds-error-summary>`](#ds-error-summary)
13
17
  - [`<ds-field>`](#ds-field)
14
18
  - [Counter](#counter)
19
+ - [`fieldset`](#fieldset)
20
+ - [invokers (`command` polyfill)](#invokers-command-polyfill)
15
21
  - [`<ds-pagination>`](#ds-pagination)
22
+ - [`popover`](#popover)
23
+ - [`readonly`](#readonly)
16
24
  - [`<ds-suggestion>`](#ds-suggestion)
17
25
  - [`<ds-tabs>`](#ds-tabs)
18
26
  - [`data-toggle-group`](#data-toggle-group)
19
27
  - [`data-tooltip`](#data-tooltip)
20
- - [`data-clickdelegatefor`](#data-clickdelegatefor)
21
- - [`readonly`](#readonly)
22
- - [`fieldset`](#fieldset)
23
- - [Polyfills](#polyfills)
24
- - [invokers-polyfill](#invokers-polyfill)
25
- - [`<dialog>`](#dialog)
26
- - [open \& close](#open--close)
27
- - [`details` and `summary`](#details-and-summary)
28
- - [`popover`](#popover)
28
+
29
29
 
30
30
 
31
31
  ## Get started
32
32
 
33
- We recommend to import the whole package.
33
+ `@digdir/designsystemet-web` provides framework-independent behaviour for Designsystemet components.
34
+ It can be used together with `@digdir/designsystemet-css`, with your own CSS, or as a smaller enhancement layer in an existing setup.
35
+
36
+ We recommend importing the whole package when you want all web components, observers and polyfills available globally.
34
37
  This will register all web components and observers globally, so you only need to do this once.
38
+
35
39
  ```ts
36
40
  import '@digdir/designsystemet-web';
37
41
  ```
38
42
 
39
- ### Individual imports
43
+ ### Pick the parts you need
44
+
45
+ Designsystemet packages are meant to be used like a toolbox. You can use the full package, or only the parts that speed up your project.
46
+
47
+ For example, you can:
48
+
49
+ - use `@digdir/designsystemet-web` without `@digdir/designsystemet-css` if you already have your own styling
50
+ - use `@digdir/designsystemet-css` without `@digdir/designsystemet-web` if you only need styles and handle interactivity yourself
51
+ - combine some Designsystemet components with your own components
52
+ - build on top of the package where it helps, and skip the parts that do not fit your setup
40
53
 
41
- The package supports sub-path exports which means you can import individual parts of the package if needed, but this is used at own risk.
54
+ ### Individual imports
42
55
 
43
- For example - importing `tooltip`, you need to also import `popover` as its built using native popover functionality.
56
+ The package supports sub-path exports which means you can import individual parts of the package if needed.
44
57
 
45
- The [invokers-polyfill](#invokers-polyfill) will **not be automatically attached using individual imports**.
58
+ ```
59
+ import '@digdir/designsystemet-web/clickdelegatefor';
60
+ import '@digdir/designsystemet-web/details';
61
+ import '@digdir/designsystemet-web/dialog';
62
+ import '@digdir/designsystemet-web/ds-error-summary';
63
+ import '@digdir/designsystemet-web/ds-field';
64
+ import '@digdir/designsystemet-web/fieldset';
65
+ import '@digdir/designsystemet-web/invokers';
66
+ import '@digdir/designsystemet-web/ds-pagination';
67
+ import '@digdir/designsystemet-web/popover';
68
+ import '@digdir/designsystemet-web/readonly';
69
+ import '@digdir/designsystemet-web/ds-suggestion';
70
+ import '@digdir/designsystemet-web/ds-tabs';
71
+ import '@digdir/designsystemet-web/toggle-group';
72
+ import '@digdir/designsystemet-web/tooltip';
73
+ ```
46
74
 
47
75
  ### Types
48
76
  Add the package to your `types` for types:
@@ -59,8 +87,8 @@ Add the package to your `types` for types:
59
87
  `@digdir/designsystemet-web` will warn you about deprecations and missing attributes.
60
88
  This can come in handy while developing, but can also easily be hidden, for example in production:
61
89
 
62
- ```
63
- import `@digdir/designsystemet-web`;
90
+ ```ts
91
+ import '@digdir/designsystemet-web';
64
92
  if (typeof window !== 'undefined' && isProduction()) window.dsWarnings = false;
65
93
  ```
66
94
 
@@ -82,6 +110,50 @@ Automatically hides/shows `aria-label` on desktop/mobile and `aria-current="page
82
110
  </ds-breadcrumbs>
83
111
  ```
84
112
 
113
+ ### `details` and `summary`
114
+ Use native elements. We polyfill a bug in Firefox when combined with Android Talkback screen reader to announce state and role properly.
115
+
116
+ ```html
117
+ <details class="ds-details">
118
+ <summary>More info</summary>
119
+ <div>Lorem ipsum dolor sit amet.</div>
120
+ </details>
121
+ ```
122
+
123
+
124
+ ## `data-clickdelegatefor`
125
+ Used for delegating click event. For example, you can use this to delegate click events from a parent element to child elements that are added dynamically.
126
+
127
+ ```html
128
+ <div class="ds-card" data-clickdelegatefor="target">
129
+ <a id="target" href="https://example.com" rel="noopener">Go to example</a>
130
+ <span>Clicking this card will open example in a new tab</span>
131
+ </div>
132
+ ```
133
+
134
+
135
+
136
+ ### `<dialog>`
137
+ Use the native `<dialog>` element. We polyfill support for [`closedby="any"`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/closedBy#any).
138
+
139
+ ```html
140
+ <dialog class="ds-dialog" closedby="any" id="my-dialog">
141
+ my dialog
142
+ </dialog>
143
+ ```
144
+
145
+ #### open & close
146
+
147
+ Use invokers `command` and `commandfor`, to open and close dialog.
148
+ ```html
149
+ <button class="ds-button" type="button" command="show-modal" commandfor="my-dialog">
150
+ Open dialog
151
+ </button>
152
+ <dialog id="my-dialog" class="ds-dialog">
153
+ <button class="ds-button" command="close" commandfor="my-dialog">Close</button>
154
+ </dialog>
155
+ ```
156
+
85
157
  ## `<ds-error-summary>`
86
158
  Automatically takes focus when visible and sets `aria-labelledby` to the first child heading. No API.
87
159
 
@@ -126,6 +198,21 @@ You can add a counter to inputs and textareas by adding the `data-field="counter
126
198
  | data-over | string | %d tegn for mye | false |
127
199
  | data-under | string | %d tegn igjen | false |
128
200
 
201
+ ### invokers (`command` polyfill)
202
+ We automatically attach [invokers-polyfill](https://www.npmjs.com/package/invokers-polyfill), which means that you get support for `command` and `commandfor`.
203
+
204
+
205
+ ## `fieldset`
206
+
207
+ An observer will look on `fieldset` element, add an id to combine children element with `data-field="description"` and `legend` into `aria-labeledby` on `fieldset`.
208
+
209
+ ```html
210
+ <fieldset>
211
+ <legend>Delivery method</legend>
212
+ <p data-field="description">Choose one option</p>
213
+ </fieldset>
214
+ ```
215
+
129
216
  ## `<ds-pagination>`
130
217
  Implements pagination, fills buttons with text.
131
218
  You can use both `<a>` and `<button>` elements inside the pagination.
@@ -143,6 +230,39 @@ If you don't pass any attributes you can implement your own logic for current pa
143
230
  </ds-pagination>
144
231
  ```
145
232
 
233
+
234
+ ### `popover`
235
+ We use native popover functionality, but we attach an event listener that fixes placement of designsystem components.
236
+
237
+ ```html
238
+ <button class="ds-button" popovertarget="popover">Open popover</button>
239
+ <div class="ds-popover" popover id="popover" data-placement="left">
240
+ This is some popover content. It can be very long, but it will wrap and
241
+ stay within the viewport.
242
+ </div>
243
+ ```
244
+
245
+ | attribute | type | default | required |
246
+ |---------------|--------|------------|----------|
247
+ | data-placement | string | top | false |
248
+ | data-overscroll | 'contain' | undefined | undefined | false |
249
+ | data-autoplacement | boolean | true | false |
250
+
251
+ **If you don't use the class `ds-popover` you need to add the CSS property `--_ds-floating` to the popover element.** This can be `top`, `bottom`, `left` or `right`.
252
+
253
+
254
+ ## `readonly`
255
+ Used for fixing `readonly` support on `select` and `input` elements. Add `aria-readonly="true"` to make the element behave as readonly, which means that it will not be editable by the user or call any change events.
256
+
257
+ ```html
258
+ <select aria-readonly="true">
259
+ <option value="1">Option 1</option>
260
+ <option value="2">Option 2</option>
261
+ <option value="3">Option 3</option>
262
+ </select>
263
+ ```
264
+
265
+
146
266
  ## `<ds-suggestion>`
147
267
  Extends `u-combobox` from u-elements. See documentation for [u-combobox](https://u-elements.github.io/u-elements/elements/u-combobox).
148
268
 
@@ -209,92 +329,5 @@ Uses native popover functionality with our [`popover`](#popover) polyfill.
209
329
  <button data-placement="left" data-tooltip="left" class="ds-button">left</button>
210
330
  ```
211
331
 
212
- ## `data-clickdelegatefor`
213
- Used for delegating click event. For example, you can use this to delegate click events from a parent element to child elements that are added dynamically.
214
-
215
- ```html
216
- <div class="ds-card" data-clickdelegatefor="target">
217
- <a id="target" href="https://example.com" rel="noopener">Go to example</a>
218
- <span>Clicking this card will open example in a new tab</span>
219
- </div>
220
- ```
221
-
222
- ## `readonly`
223
- Used for fixing `readonly` support on `select` and `input` elements. Add `aria-readonly="true"` to make the element behave as readonly, which means that it will not be editable by the user or call any change events.
224
-
225
- ```html
226
- <select aria-readonly="true">
227
- <option value="1">Option 1</option>
228
- <option value="2">Option 2</option>
229
- <option value="3">Option 3</option>
230
- </select>
231
- ```
232
- ## `fieldset`
233
-
234
- An observer will look on `fieldset` element, add an id to combine children element with `data-field="description"` and `legend` into `aria-labeledby` on `fieldset`.
235
-
236
- ```html
237
- <fieldset>
238
- <legend>Delivery method</legend>
239
- <p data-field="description">Choose one option</p>
240
- </fieldset>
241
- ```
242
-
243
-
244
- ## Polyfills
245
-
246
- ### invokers-polyfill
247
- We automatically attach [invokers-polyfill](https://www.npmjs.com/package/invokers-polyfill/v/0.5.2), which means that you get support for `command` and `commandfor`.
248
-
249
- ### `<dialog>`
250
- Use the native `<dialog>` element. We polyfill support for [`closedby="any"`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/closedBy#any).
251
-
252
- ```html
253
- <dialog class="ds-dialog" closedby="any" id="my-dialog">
254
- my dialog
255
- </dialog>
256
- ```
257
-
258
- #### open & close
259
-
260
- Use invokers `command` and `commandfor`, to open and close dialog.
261
- ```html
262
- <button class="ds-button" type="button" command="show-modal" commandfor="my-dialog">
263
- Open dialog
264
- </button>
265
- <dialog id="my-dialog" class="ds-dialog">
266
- <button class="ds-button" command="close" commandfor="my-dialog">Close</button>
267
- </dialog>
268
- ```
269
-
270
- ### `details` and `summary`
271
- Use native elements. We polyfill a bug in Firefox when combined with Android Talkback screen reader to announce state and role properly.
272
-
273
- ```html
274
- <details class="ds-details">
275
- <summary>More info</summary>
276
- <div>Lorem ipsum dolor sit amet.</div>
277
- </details>
278
- ```
279
-
280
-
281
- ### `popover`
282
- We use native popover functionality, but we attach an event listener that fixes placement of designsystem components.
283
-
284
- ```html
285
- <button class="ds-button" popovertarget="popover">Open popover</button>
286
- <div class="ds-popover" popover id="popover" data-placement="left">
287
- This is some popover content. It can be very long, but it will wrap and
288
- stay within the viewport.
289
- </div>
290
- ```
291
-
292
- | attribute | type | default | required |
293
- |---------------|--------|------------|----------|
294
- | data-placement | string | top | false |
295
- | data-overscroll | 'contain' | undefined | undefined | false |
296
- | data-autoplacement | boolean | true | false |
297
-
298
- **If you don't use the class `ds-popover` you need to add the CSS property `--_ds-floating` to the popover element.** This can be `top`, `bottom`, `left` or `right`.
299
332
 
300
333
 
@@ -0,0 +1,64 @@
1
+ var e=class extends Event{oldState;newState;constructor(e,{oldState:t=``,newState:n=``,...r}={}){super(e,r),this.oldState=String(t||``),this.newState=String(n||``)}},t=new WeakMap;function n(n,r,i){t.set(n,setTimeout(()=>{t.has(n)&&n.dispatchEvent(new e(`toggle`,{cancelable:!1,oldState:r,newState:i}))},0))}var r=globalThis.ShadowRoot||function(){},i=globalThis.HTMLDialogElement||function(){},a=new WeakMap,o=new WeakMap,s=new WeakMap,c=new WeakMap;function l(e){return c.get(e)||`hidden`}var u=new WeakMap;function d(e){return[...e].pop()}function f(e){let t=e.popoverTargetElement;if(!(t instanceof HTMLElement))return;let n=l(t);e.popoverTargetAction===`show`&&n===`showing`||e.popoverTargetAction===`hide`&&n===`hidden`||(n===`showing`?D(t,!0,!0):p(t,!1)&&(u.set(t,e),E(t)))}function p(e,t){return!(e.popover!==`auto`&&e.popover!==`manual`&&e.popover!==`hint`||!e.isConnected||t&&l(e)!==`showing`||!t&&l(e)!==`hidden`||e instanceof i&&e.hasAttribute(`open`)||document.fullscreenElement===e)}function m(e){if(!e)return 0;let t=o.get(document)||new Set,n=s.get(document)||new Set;return n.has(e)?[...n].indexOf(e)+t.size+1:t.has(e)?[...t].indexOf(e)+1:0}function h(e){let t=y(e),n=b(e);return m(t)>m(n)?t:n}function g(e){let t,n=s.get(e)||new Set,r=o.get(e)||new Set,i=n.size>0?n:r.size>0?r:null;return i?(t=d(i),t.isConnected?t:(i.delete(t),g(e))):null}function _(e){for(let t of e||[])if(!t.isConnected)e.delete(t);else return t;return null}function v(e){return typeof e.getRootNode==`function`?e.getRootNode():e.parentNode?v(e.parentNode):e}function y(e){for(;e;){if(e instanceof HTMLElement&&e.popover===`auto`&&c.get(e)===`showing`)return e;if(e=e instanceof Element&&e.assignedSlot||e.parentElement||v(e),e instanceof r&&(e=e.host),e instanceof Document)return}}function b(e){for(;e;){let t=e.popoverTargetElement;if(t instanceof HTMLElement)return t;if(e=e.parentElement||v(e),e instanceof r&&(e=e.host),e instanceof Document)return}}function x(e,t){let n=new Map,r=0;for(let e of t||[])n.set(e,r),r+=1;n.set(e,r),r+=1;let i=null;function a(t){if(!t)return;let r=!1,a=null,o=null;for(;!r;){if(a=y(t)||null,a===null||!n.has(a))return;(e.popover===`hint`||a.popover===`auto`)&&(r=!0),r||(t=a.parentElement)}o=n.get(a),(i===null||n.get(i)<o)&&(i=a)}return a(e.parentElement||v(e)),i}function S(e){return e.hidden||e instanceof r||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLOptGroupElement||e instanceof HTMLOptionElement||e instanceof HTMLFieldSetElement)&&e.disabled||e instanceof HTMLInputElement&&e.type===`hidden`||e instanceof HTMLAnchorElement&&e.href===``?!1:typeof e.tabIndex==`number`&&e.tabIndex!==-1}function C(e){if(e.shadowRoot&&e.shadowRoot.delegatesFocus!==!0)return null;let t=e;t.shadowRoot&&(t=t.shadowRoot);let n=t.querySelector(`[autofocus]`);if(n)return n;{let e=t.querySelectorAll(`slot`);for(let t of e){let e=t.assignedElements({flatten:!0});for(let t of e)if(t.hasAttribute(`autofocus`))return t;else if(n=t.querySelector(`[autofocus]`),n)return n}}let r=e.ownerDocument.createTreeWalker(t,NodeFilter.SHOW_ELEMENT),i=r.currentNode;for(;i;){if(S(i))return i;i=r.nextNode()}}function w(e){var t;(t=C(e))==null||t.focus()}var T=new WeakMap;function E(t){if(!p(t,!1))return;let r=t.ownerDocument;if(!t.dispatchEvent(new e(`beforetoggle`,{cancelable:!0,oldState:`closed`,newState:`open`}))||!p(t,!1))return;let i=!1,l=t.popover,d=null,f=x(t,o.get(r)||new Set),m=x(t,s.get(r)||new Set);if(l===`auto`&&(k(s.get(r)||new Set,i,!0),j(f||r,i,!0),d=`auto`),l===`hint`&&(m?(j(m,i,!0),d=`hint`):(k(s.get(r)||new Set,i,!0),f?(j(f,i,!0),d=`auto`):d=`hint`)),l===`auto`||l===`hint`){if(l!==t.popover||!p(t,!1))return;g(r)||(i=!0),d===`auto`?(o.has(r)||o.set(r,new Set),o.get(r).add(t)):d===`hint`&&(s.has(r)||s.set(r,new Set),s.get(r).add(t))}T.delete(t);let h=r.activeElement;t.classList.add(`:popover-open`),c.set(t,`showing`),a.has(r)||a.set(r,new Set),a.get(r).add(t),F(u.get(t),!0),w(t),i&&h&&t.popover===`auto`&&T.set(t,h),n(t,`closed`,`open`)}function D(t,r=!1,i=!1){var l,f;if(!p(t,!0))return;let m=t.ownerDocument;if([`auto`,`hint`].includes(t.popover)&&(j(t,r,i),!p(t,!0)))return;let h=o.get(m)||new Set,g=h.has(t)&&d(h)===t;if(F(u.get(t),!1),u.delete(t),i&&(t.dispatchEvent(new e(`beforetoggle`,{oldState:`open`,newState:`closed`})),g&&d(h)!==t&&j(t,r,i),!p(t,!0)))return;(l=a.get(m))==null||l.delete(t),h.delete(t),(f=s.get(m))==null||f.delete(t),t.classList.remove(`:popover-open`),c.set(t,`hidden`),i&&n(t,`open`,`closed`);let _=T.get(t);_&&(T.delete(t),r&&_.focus())}function O(e,t=!1,n=!1){let r=g(e);for(;r;)D(r,t,n),r=g(e)}function k(e,t=!1,n=!1){let r=_(e);for(;r;)D(r,t,n),r=_(e)}function A(e,t,n,r){let i=!1,a=!1;for(;i||!a;){a=!0;let o=null,s=!1;for(let n of t)if(n===e)s=!0;else if(s){o=n;break}if(!o)return;for(;l(o)===`showing`&&t.size;)D(d(t),n,r);t.has(e)&&d(t)!==e&&(i=!0),i&&(r=!1)}}function j(e,t,n){let r=e.ownerDocument||e;if(e instanceof Document)return O(r,t,n);if(s.get(r)?.has(e)){A(e,s.get(r),t,n);return}k(s.get(r)||new Set,t,n),o.get(r)?.has(e)&&A(e,o.get(r),t,n)}var M=new WeakMap;function N(e){if(!e.isTrusted)return;let t=e.composedPath()[0];if(!t)return;let n=t.ownerDocument;if(!g(n))return;let r=h(t);if(r&&e.type===`pointerdown`)M.set(n,r);else if(e.type===`pointerup`){let e=M.get(n)===r;M.delete(n),e&&j(r||n,!1,!0)}}var P=new WeakMap;function F(e,t=!1){if(!e)return;P.has(e)||P.set(e,e.getAttribute(`aria-expanded`));let n=e.popoverTargetElement;if(n instanceof HTMLElement&&n.popover===`auto`)e.setAttribute(`aria-expanded`,String(t));else{let t=P.get(e);t?e.setAttribute(`aria-expanded`,t):e.removeAttribute(`aria-expanded`)}}var I=globalThis.ShadowRoot||function(){};function L(){return typeof HTMLElement<`u`&&typeof HTMLElement.prototype==`object`&&`popover`in HTMLElement.prototype}function R(e,t,n){let r=e[t];Object.defineProperty(e,t,{value(e){return r.call(this,n(e))}})}var z=/(^|[^\\]):popover-open\b/g;function B(){return typeof globalThis.CSSLayerBlockRule==`function`}function V(){let e=B();return`
2
+ ${e?`@layer popover-polyfill {`:``}
3
+ :where([popover]) {
4
+ position: fixed;
5
+ z-index: 2147483647;
6
+ inset: 0;
7
+ padding: 0.25em;
8
+ width: fit-content;
9
+ height: fit-content;
10
+ border-width: initial;
11
+ border-color: initial;
12
+ border-image: initial;
13
+ border-style: solid;
14
+ background-color: canvas;
15
+ color: canvastext;
16
+ overflow: auto;
17
+ margin: auto;
18
+ }
19
+
20
+ :where([popover]:not(.\\:popover-open)) {
21
+ display: none;
22
+ }
23
+
24
+ :where(dialog[popover].\\:popover-open) {
25
+ display: block;
26
+ }
27
+
28
+ :where(dialog[popover][open]) {
29
+ display: revert;
30
+ }
31
+
32
+ :where([anchor].\\:popover-open) {
33
+ inset: auto;
34
+ }
35
+
36
+ :where([anchor]:popover-open) {
37
+ inset: auto;
38
+ }
39
+
40
+ @supports not (background-color: canvas) {
41
+ :where([popover]) {
42
+ background-color: white;
43
+ color: black;
44
+ }
45
+ }
46
+
47
+ @supports (width: -moz-fit-content) {
48
+ :where([popover]) {
49
+ width: -moz-fit-content;
50
+ height: -moz-fit-content;
51
+ }
52
+ }
53
+
54
+ @supports not (inset: 0) {
55
+ :where([popover]) {
56
+ top: 0;
57
+ left: 0;
58
+ right: 0;
59
+ bottom: 0;
60
+ }
61
+ }
62
+ ${e?`}`:``}
63
+ `}var H=null;function U(e){let t=V();if(H===null)try{H=new CSSStyleSheet,H.replaceSync(t)}catch{H=!1}if(H===!1){let n=document.createElement(`style`);n.textContent=t,e instanceof Document?e.head.prepend(n):e.prepend(n)}else e.adoptedStyleSheets=[H,...e.adoptedStyleSheets]}function W(){if(typeof window>`u`)return;window.ToggleEvent=window.ToggleEvent||e;function t(e){return e?.includes(`:popover-open`)&&(e=e.replace(z,`$1.\\:popover-open`)),e}R(Document.prototype,`querySelector`,t),R(Document.prototype,`querySelectorAll`,t),R(Element.prototype,`querySelector`,t),R(Element.prototype,`querySelectorAll`,t),R(Element.prototype,`matches`,t),R(Element.prototype,`closest`,t),R(DocumentFragment.prototype,`querySelectorAll`,t),Object.defineProperties(HTMLElement.prototype,{popover:{enumerable:!0,configurable:!0,get(){if(!this.hasAttribute(`popover`))return null;let e=(this.getAttribute(`popover`)||``).toLowerCase();return e===``||e==`auto`?`auto`:e==`hint`?`hint`:`manual`},set(e){e===null?this.removeAttribute(`popover`):this.setAttribute(`popover`,e)}},showPopover:{enumerable:!0,configurable:!0,value(e={}){E(this)}},hidePopover:{enumerable:!0,configurable:!0,value(){D(this,!0,!0)}},togglePopover:{enumerable:!0,configurable:!0,value(e={}){return typeof e==`boolean`&&(e={force:e}),c.get(this)===`showing`&&e.force===void 0||e.force===!1?D(this,!0,!0):(e.force===void 0||e.force===!0)&&E(this),c.get(this)===`showing`}}});let n=Element.prototype.attachShadow;n&&Object.defineProperties(Element.prototype,{attachShadow:{enumerable:!0,configurable:!0,writable:!0,value(e){let t=n.call(this,e);return U(t),t}}});let r=HTMLElement.prototype.attachInternals;r&&Object.defineProperties(HTMLElement.prototype,{attachInternals:{enumerable:!0,configurable:!0,writable:!0,value(){let e=r.call(this);return e.shadowRoot&&U(e.shadowRoot),e}}});let i=new WeakMap;function a(e){Object.defineProperties(e.prototype,{popoverTargetElement:{enumerable:!0,configurable:!0,set(e){if(e===null)this.removeAttribute(`popovertarget`),i.delete(this);else if(e instanceof Element)this.setAttribute(`popovertarget`,``),i.set(this,e);else throw TypeError(`popoverTargetElement must be an element or null`)},get(){if(this.localName!==`button`&&this.localName!==`input`||this.localName===`input`&&this.type!==`reset`&&this.type!==`image`&&this.type!==`button`||this.disabled||this.form&&this.type===`submit`)return null;let e=i.get(this);if(e&&e.isConnected)return e;if(e&&!e.isConnected)return i.delete(this),null;let t=v(this),n=this.getAttribute(`popovertarget`);return(t instanceof Document||t instanceof I)&&n&&t.getElementById(n)||null}},popoverTargetAction:{enumerable:!0,configurable:!0,get(){let e=(this.getAttribute(`popovertargetaction`)||``).toLowerCase();return e===`show`||e===`hide`?e:`toggle`},set(e){this.setAttribute(`popovertargetaction`,e)}}})}a(HTMLButtonElement),a(HTMLInputElement);let o=e=>{if(e.defaultPrevented)return;let t=e.composedPath(),n=t[0];if(!(n instanceof Element)||n?.shadowRoot)return;let r=v(n);if(!(r instanceof I||r instanceof Document))return;let i=t.find(e=>e.matches?.call(e,`[popovertargetaction],[popovertarget]`));if(i){f(i),e.preventDefault();return}},s=e=>{let t=e.key,n=e.target;!e.defaultPrevented&&n&&(t===`Escape`||t===`Esc`)&&j(n.ownerDocument,!0,!0)};(e=>{e.addEventListener(`click`,o),e.addEventListener(`keydown`,s),e.addEventListener(`pointerdown`,N),e.addEventListener(`pointerup`,N)})(document),U(document)}exports.apply=W,exports.isSupported=L;
64
+ //# sourceMappingURL=popover-fn.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popover-fn.cjs","names":[],"sources":["../../../../../../../../node_modules/.pnpm/@oddbird+popover-polyfill@0.6.1/node_modules/@oddbird/popover-polyfill/dist/popover-fn.js"],"sourcesContent":["// src/events.ts\nvar ToggleEvent = class extends Event {\n oldState;\n newState;\n constructor(type, { oldState = \"\", newState = \"\", ...init } = {}) {\n super(type, init);\n this.oldState = String(oldState || \"\");\n this.newState = String(newState || \"\");\n }\n};\nvar popoverToggleTaskQueue = /* @__PURE__ */ new WeakMap();\nfunction queuePopoverToggleEventTask(element, oldState, newState) {\n popoverToggleTaskQueue.set(\n element,\n setTimeout(() => {\n if (!popoverToggleTaskQueue.has(element)) return;\n element.dispatchEvent(\n new ToggleEvent(\"toggle\", {\n cancelable: false,\n oldState,\n newState\n })\n );\n }, 0)\n );\n}\n\n// src/popover-helpers.ts\nvar ShadowRoot = globalThis.ShadowRoot || function() {\n};\nvar HTMLDialogElement = globalThis.HTMLDialogElement || function() {\n};\nvar topLayerElements = /* @__PURE__ */ new WeakMap();\nvar autoPopoverList = /* @__PURE__ */ new WeakMap();\nvar hintPopoverList = /* @__PURE__ */ new WeakMap();\nvar visibilityState = /* @__PURE__ */ new WeakMap();\nfunction getPopoverVisibilityState(popover) {\n return visibilityState.get(popover) || \"hidden\";\n}\nvar popoverInvoker = /* @__PURE__ */ new WeakMap();\nfunction lastSetElement(set) {\n return [...set].pop();\n}\nfunction popoverTargetAttributeActivationBehavior(element) {\n const popover = element.popoverTargetElement;\n if (!(popover instanceof HTMLElement)) {\n return;\n }\n const visibility = getPopoverVisibilityState(popover);\n if (element.popoverTargetAction === \"show\" && visibility === \"showing\") {\n return;\n }\n if (element.popoverTargetAction === \"hide\" && visibility === \"hidden\") return;\n if (visibility === \"showing\") {\n hidePopover(popover, true, true);\n } else if (checkPopoverValidity(popover, false)) {\n popoverInvoker.set(popover, element);\n showPopover(popover);\n }\n}\nfunction checkPopoverValidity(element, expectedToBeShowing) {\n if (element.popover !== \"auto\" && element.popover !== \"manual\" && element.popover !== \"hint\") {\n return false;\n }\n if (!element.isConnected) return false;\n if (expectedToBeShowing && getPopoverVisibilityState(element) !== \"showing\") {\n return false;\n }\n if (!expectedToBeShowing && getPopoverVisibilityState(element) !== \"hidden\") {\n return false;\n }\n if (element instanceof HTMLDialogElement && element.hasAttribute(\"open\")) {\n return false;\n }\n if (document.fullscreenElement === element) return false;\n return true;\n}\nfunction getStackPosition(popover) {\n if (!popover) return 0;\n const autoPopovers = autoPopoverList.get(document) || /* @__PURE__ */ new Set();\n const hintPopovers = hintPopoverList.get(document) || /* @__PURE__ */ new Set();\n if (hintPopovers.has(popover)) {\n return [...hintPopovers].indexOf(popover) + autoPopovers.size + 1;\n }\n if (autoPopovers.has(popover)) {\n return [...autoPopovers].indexOf(popover) + 1;\n }\n return 0;\n}\nfunction topMostClickedPopover(target) {\n const clickedPopover = nearestInclusiveOpenPopover(target);\n const invokerPopover = nearestInclusiveTargetPopoverForInvoker(target);\n if (getStackPosition(clickedPopover) > getStackPosition(invokerPopover)) {\n return clickedPopover;\n }\n return invokerPopover;\n}\nfunction topmostAutoOrHintPopover(document2) {\n let topmostPopover;\n const hintPopovers = hintPopoverList.get(document2) || /* @__PURE__ */ new Set();\n const autoPopovers = autoPopoverList.get(document2) || /* @__PURE__ */ new Set();\n const usedStack = hintPopovers.size > 0 ? hintPopovers : autoPopovers.size > 0 ? autoPopovers : null;\n if (usedStack) {\n topmostPopover = lastSetElement(usedStack);\n if (!topmostPopover.isConnected) {\n usedStack.delete(topmostPopover);\n return topmostAutoOrHintPopover(document2);\n }\n return topmostPopover;\n }\n return null;\n}\nfunction topMostPopoverInList(list) {\n for (const popover of list || []) {\n if (!popover.isConnected) {\n list.delete(popover);\n } else {\n return popover;\n }\n }\n return null;\n}\nfunction getRootNode(node) {\n if (typeof node.getRootNode === \"function\") {\n return node.getRootNode();\n }\n if (node.parentNode) return getRootNode(node.parentNode);\n return node;\n}\nfunction nearestInclusiveOpenPopover(node) {\n while (node) {\n if (node instanceof HTMLElement && node.popover === \"auto\" && visibilityState.get(node) === \"showing\") {\n return node;\n }\n node = node instanceof Element && node.assignedSlot || node.parentElement || getRootNode(node);\n if (node instanceof ShadowRoot) node = node.host;\n if (node instanceof Document) return;\n }\n}\nfunction nearestInclusiveTargetPopoverForInvoker(node) {\n while (node) {\n const nodePopover = node.popoverTargetElement;\n if (nodePopover instanceof HTMLElement) return nodePopover;\n node = node.parentElement || getRootNode(node);\n if (node instanceof ShadowRoot) node = node.host;\n if (node instanceof Document) return;\n }\n}\nfunction topMostPopoverAncestor(newPopover, list) {\n const popoverPositions = /* @__PURE__ */ new Map();\n let i = 0;\n for (const popover of list || []) {\n popoverPositions.set(popover, i);\n i += 1;\n }\n popoverPositions.set(newPopover, i);\n i += 1;\n let topMostPopoverAncestor2 = null;\n function checkAncestor(candidate) {\n if (!candidate) return;\n let okNesting = false;\n let candidateAncestor = null;\n let candidatePosition = null;\n while (!okNesting) {\n candidateAncestor = nearestInclusiveOpenPopover(candidate) || null;\n if (candidateAncestor === null) return;\n if (!popoverPositions.has(candidateAncestor)) return;\n if (newPopover.popover === \"hint\" || candidateAncestor.popover === \"auto\") {\n okNesting = true;\n }\n if (!okNesting) {\n candidate = candidateAncestor.parentElement;\n }\n }\n candidatePosition = popoverPositions.get(candidateAncestor);\n if (topMostPopoverAncestor2 === null || popoverPositions.get(topMostPopoverAncestor2) < candidatePosition) {\n topMostPopoverAncestor2 = candidateAncestor;\n }\n }\n checkAncestor(newPopover.parentElement || getRootNode(newPopover));\n return topMostPopoverAncestor2;\n}\nfunction isFocusable(focusTarget) {\n if (focusTarget.hidden || focusTarget instanceof ShadowRoot) return false;\n if (focusTarget instanceof HTMLButtonElement || focusTarget instanceof HTMLInputElement || focusTarget instanceof HTMLSelectElement || focusTarget instanceof HTMLTextAreaElement || focusTarget instanceof HTMLOptGroupElement || focusTarget instanceof HTMLOptionElement || focusTarget instanceof HTMLFieldSetElement) {\n if (focusTarget.disabled) return false;\n }\n if (focusTarget instanceof HTMLInputElement && focusTarget.type === \"hidden\") {\n return false;\n }\n if (focusTarget instanceof HTMLAnchorElement && focusTarget.href === \"\") {\n return false;\n }\n return typeof focusTarget.tabIndex === \"number\" && focusTarget.tabIndex !== -1;\n}\nfunction focusDelegate(focusTarget) {\n if (focusTarget.shadowRoot && focusTarget.shadowRoot.delegatesFocus !== true) {\n return null;\n }\n let whereToLook = focusTarget;\n if (whereToLook.shadowRoot) {\n whereToLook = whereToLook.shadowRoot;\n }\n let autoFocusDelegate = whereToLook.querySelector(\"[autofocus]\");\n if (autoFocusDelegate) {\n return autoFocusDelegate;\n } else {\n const slots = whereToLook.querySelectorAll(\"slot\");\n for (const slot of slots) {\n const assignedElements = slot.assignedElements({ flatten: true });\n for (const el of assignedElements) {\n if (el.hasAttribute(\"autofocus\")) {\n return el;\n } else {\n autoFocusDelegate = el.querySelector(\"[autofocus]\");\n if (autoFocusDelegate) {\n return autoFocusDelegate;\n }\n }\n }\n }\n }\n const walker = focusTarget.ownerDocument.createTreeWalker(\n whereToLook,\n NodeFilter.SHOW_ELEMENT\n );\n let descendant = walker.currentNode;\n while (descendant) {\n if (isFocusable(descendant)) {\n return descendant;\n }\n descendant = walker.nextNode();\n }\n}\nfunction popoverFocusingSteps(subject) {\n var _a;\n (_a = focusDelegate(subject)) == null ? void 0 : _a.focus();\n}\nvar previouslyFocusedElements = /* @__PURE__ */ new WeakMap();\nfunction showPopover(element) {\n if (!checkPopoverValidity(element, false)) {\n return;\n }\n const document2 = element.ownerDocument;\n if (!element.dispatchEvent(\n new ToggleEvent(\"beforetoggle\", {\n cancelable: true,\n oldState: \"closed\",\n newState: \"open\"\n })\n )) {\n return;\n }\n if (!checkPopoverValidity(element, false)) {\n return;\n }\n let shouldRestoreFocus = false;\n const originalType = element.popover;\n let stackToAppendTo = null;\n const autoAncestor = topMostPopoverAncestor(\n element,\n autoPopoverList.get(document2) || /* @__PURE__ */ new Set()\n );\n const hintAncestor = topMostPopoverAncestor(\n element,\n hintPopoverList.get(document2) || /* @__PURE__ */ new Set()\n );\n if (originalType === \"auto\") {\n closeAllOpenPopoversInList(\n hintPopoverList.get(document2) || /* @__PURE__ */ new Set(),\n shouldRestoreFocus,\n true\n );\n const ancestor = autoAncestor || document2;\n hideAllPopoversUntil(ancestor, shouldRestoreFocus, true);\n stackToAppendTo = \"auto\";\n }\n if (originalType === \"hint\") {\n if (hintAncestor) {\n hideAllPopoversUntil(hintAncestor, shouldRestoreFocus, true);\n stackToAppendTo = \"hint\";\n } else {\n closeAllOpenPopoversInList(\n hintPopoverList.get(document2) || /* @__PURE__ */ new Set(),\n shouldRestoreFocus,\n true\n );\n if (autoAncestor) {\n hideAllPopoversUntil(autoAncestor, shouldRestoreFocus, true);\n stackToAppendTo = \"auto\";\n } else {\n stackToAppendTo = \"hint\";\n }\n }\n }\n if (originalType === \"auto\" || originalType === \"hint\") {\n if (originalType !== element.popover || !checkPopoverValidity(element, false)) {\n return;\n }\n if (!topmostAutoOrHintPopover(document2)) {\n shouldRestoreFocus = true;\n }\n if (stackToAppendTo === \"auto\") {\n if (!autoPopoverList.has(document2)) {\n autoPopoverList.set(document2, /* @__PURE__ */ new Set());\n }\n autoPopoverList.get(document2).add(element);\n } else if (stackToAppendTo === \"hint\") {\n if (!hintPopoverList.has(document2)) {\n hintPopoverList.set(document2, /* @__PURE__ */ new Set());\n }\n hintPopoverList.get(document2).add(element);\n }\n }\n previouslyFocusedElements.delete(element);\n const originallyFocusedElement = document2.activeElement;\n element.classList.add(\":popover-open\");\n visibilityState.set(element, \"showing\");\n if (!topLayerElements.has(document2)) {\n topLayerElements.set(document2, /* @__PURE__ */ new Set());\n }\n topLayerElements.get(document2).add(element);\n setInvokerAriaExpanded(popoverInvoker.get(element), true);\n popoverFocusingSteps(element);\n if (shouldRestoreFocus && originallyFocusedElement && element.popover === \"auto\") {\n previouslyFocusedElements.set(element, originallyFocusedElement);\n }\n queuePopoverToggleEventTask(element, \"closed\", \"open\");\n}\nfunction hidePopover(element, focusPreviousElement = false, fireEvents = false) {\n var _a, _b;\n if (!checkPopoverValidity(element, true)) {\n return;\n }\n const document2 = element.ownerDocument;\n if ([\"auto\", \"hint\"].includes(element.popover)) {\n hideAllPopoversUntil(element, focusPreviousElement, fireEvents);\n if (!checkPopoverValidity(element, true)) {\n return;\n }\n }\n const autoList = autoPopoverList.get(document2) || /* @__PURE__ */ new Set();\n const autoPopoverListContainsElement = autoList.has(element) && lastSetElement(autoList) === element;\n setInvokerAriaExpanded(popoverInvoker.get(element), false);\n popoverInvoker.delete(element);\n if (fireEvents) {\n element.dispatchEvent(\n new ToggleEvent(\"beforetoggle\", {\n oldState: \"open\",\n newState: \"closed\"\n })\n );\n if (autoPopoverListContainsElement && lastSetElement(autoList) !== element) {\n hideAllPopoversUntil(element, focusPreviousElement, fireEvents);\n }\n if (!checkPopoverValidity(element, true)) {\n return;\n }\n }\n (_a = topLayerElements.get(document2)) == null ? void 0 : _a.delete(element);\n autoList.delete(element);\n (_b = hintPopoverList.get(document2)) == null ? void 0 : _b.delete(element);\n element.classList.remove(\":popover-open\");\n visibilityState.set(element, \"hidden\");\n if (fireEvents) {\n queuePopoverToggleEventTask(element, \"open\", \"closed\");\n }\n const previouslyFocusedElement = previouslyFocusedElements.get(element);\n if (previouslyFocusedElement) {\n previouslyFocusedElements.delete(element);\n if (focusPreviousElement) {\n previouslyFocusedElement.focus();\n }\n }\n}\nfunction closeAllOpenPopovers(document2, focusPreviousElement = false, fireEvents = false) {\n let popover = topmostAutoOrHintPopover(document2);\n while (popover) {\n hidePopover(popover, focusPreviousElement, fireEvents);\n popover = topmostAutoOrHintPopover(document2);\n }\n}\nfunction closeAllOpenPopoversInList(list, focusPreviousElement = false, fireEvents = false) {\n let popover = topMostPopoverInList(list);\n while (popover) {\n hidePopover(popover, focusPreviousElement, fireEvents);\n popover = topMostPopoverInList(list);\n }\n}\nfunction hidePopoverStackUntil(endpoint, set, focusPreviousElement, fireEvents) {\n let repeatingHide = false;\n let hasRunOnce = false;\n while (repeatingHide || !hasRunOnce) {\n hasRunOnce = true;\n let lastToHide = null;\n let foundEndpoint = false;\n for (const popover of set) {\n if (popover === endpoint) {\n foundEndpoint = true;\n } else if (foundEndpoint) {\n lastToHide = popover;\n break;\n }\n }\n if (!lastToHide) return;\n while (getPopoverVisibilityState(lastToHide) === \"showing\" && set.size) {\n hidePopover(lastSetElement(set), focusPreviousElement, fireEvents);\n }\n if (set.has(endpoint) && lastSetElement(set) !== endpoint) {\n repeatingHide = true;\n }\n if (repeatingHide) {\n fireEvents = false;\n }\n }\n}\nfunction hideAllPopoversUntil(endpoint, focusPreviousElement, fireEvents) {\n var _a, _b;\n const document2 = endpoint.ownerDocument || endpoint;\n if (endpoint instanceof Document) {\n return closeAllOpenPopovers(document2, focusPreviousElement, fireEvents);\n }\n if ((_a = hintPopoverList.get(document2)) == null ? void 0 : _a.has(endpoint)) {\n hidePopoverStackUntil(\n endpoint,\n hintPopoverList.get(document2),\n focusPreviousElement,\n fireEvents\n );\n return;\n }\n closeAllOpenPopoversInList(\n hintPopoverList.get(document2) || /* @__PURE__ */ new Set(),\n focusPreviousElement,\n fireEvents\n );\n if (!((_b = autoPopoverList.get(document2)) == null ? void 0 : _b.has(endpoint))) {\n return;\n }\n hidePopoverStackUntil(\n endpoint,\n autoPopoverList.get(document2),\n focusPreviousElement,\n fireEvents\n );\n}\nvar popoverPointerDownTargets = /* @__PURE__ */ new WeakMap();\nfunction lightDismissOpenPopovers(event) {\n if (!event.isTrusted) return;\n const target = event.composedPath()[0];\n if (!target) return;\n const document2 = target.ownerDocument;\n const topMostPopover = topmostAutoOrHintPopover(document2);\n if (!topMostPopover) return;\n const ancestor = topMostClickedPopover(target);\n if (ancestor && event.type === \"pointerdown\") {\n popoverPointerDownTargets.set(document2, ancestor);\n } else if (event.type === \"pointerup\") {\n const sameTarget = popoverPointerDownTargets.get(document2) === ancestor;\n popoverPointerDownTargets.delete(document2);\n if (sameTarget) {\n hideAllPopoversUntil(ancestor || document2, false, true);\n }\n }\n}\nvar initialAriaExpandedValue = /* @__PURE__ */ new WeakMap();\nfunction setInvokerAriaExpanded(el, force = false) {\n if (!el) return;\n if (!initialAriaExpandedValue.has(el)) {\n initialAriaExpandedValue.set(el, el.getAttribute(\"aria-expanded\"));\n }\n const popover = el.popoverTargetElement;\n if (popover instanceof HTMLElement && popover.popover === \"auto\") {\n el.setAttribute(\"aria-expanded\", String(force));\n } else {\n const initialValue = initialAriaExpandedValue.get(el);\n if (!initialValue) {\n el.removeAttribute(\"aria-expanded\");\n } else {\n el.setAttribute(\"aria-expanded\", initialValue);\n }\n }\n}\n\n// src/popover.ts\nvar ShadowRoot2 = globalThis.ShadowRoot || function() {\n};\nfunction isSupported() {\n return typeof HTMLElement !== \"undefined\" && typeof HTMLElement.prototype === \"object\" && \"popover\" in HTMLElement.prototype;\n}\nfunction isHintSupported() {\n const el = document.createElement(\"div\");\n el.setAttribute(\"popover\", \"hint\");\n return el.popover === \"hint\";\n}\nfunction isPolyfilled() {\n var _a;\n return Boolean(\n ((_a = document.body) == null ? void 0 : _a.showPopover) && !/native code/i.test(document.body.showPopover.toString())\n );\n}\nfunction patchSelectorFn(object, name, mapper) {\n const original = object[name];\n Object.defineProperty(object, name, {\n value(selector) {\n return original.call(this, mapper(selector));\n }\n });\n}\nvar nonEscapedPopoverSelector = /(^|[^\\\\]):popover-open\\b/g;\nfunction hasLayerSupport() {\n return typeof globalThis.CSSLayerBlockRule === \"function\";\n}\nfunction getStyles() {\n const useLayer = hasLayerSupport();\n return `\n${useLayer ? \"@layer popover-polyfill {\" : \"\"}\n :where([popover]) {\n position: fixed;\n z-index: 2147483647;\n inset: 0;\n padding: 0.25em;\n width: fit-content;\n height: fit-content;\n border-width: initial;\n border-color: initial;\n border-image: initial;\n border-style: solid;\n background-color: canvas;\n color: canvastext;\n overflow: auto;\n margin: auto;\n }\n\n :where([popover]:not(.\\\\:popover-open)) {\n display: none;\n }\n\n :where(dialog[popover].\\\\:popover-open) {\n display: block;\n }\n\n :where(dialog[popover][open]) {\n display: revert;\n }\n\n :where([anchor].\\\\:popover-open) {\n inset: auto;\n }\n\n :where([anchor]:popover-open) {\n inset: auto;\n }\n\n @supports not (background-color: canvas) {\n :where([popover]) {\n background-color: white;\n color: black;\n }\n }\n\n @supports (width: -moz-fit-content) {\n :where([popover]) {\n width: -moz-fit-content;\n height: -moz-fit-content;\n }\n }\n\n @supports not (inset: 0) {\n :where([popover]) {\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n }\n }\n${useLayer ? \"}\" : \"\"}\n`;\n}\nvar popoverStyleSheet = null;\nfunction injectStyles(root) {\n const styles = getStyles();\n if (popoverStyleSheet === null) {\n try {\n popoverStyleSheet = new CSSStyleSheet();\n popoverStyleSheet.replaceSync(styles);\n } catch {\n popoverStyleSheet = false;\n }\n }\n if (popoverStyleSheet === false) {\n const sheet = document.createElement(\"style\");\n sheet.textContent = styles;\n if (root instanceof Document) {\n root.head.prepend(sheet);\n } else {\n root.prepend(sheet);\n }\n } else {\n root.adoptedStyleSheets = [popoverStyleSheet, ...root.adoptedStyleSheets];\n }\n}\nfunction apply() {\n if (typeof window === \"undefined\") return;\n window.ToggleEvent = window.ToggleEvent || ToggleEvent;\n function rewriteSelector(selector) {\n if (selector == null ? void 0 : selector.includes(\":popover-open\")) {\n selector = selector.replace(\n nonEscapedPopoverSelector,\n \"$1.\\\\:popover-open\"\n );\n }\n return selector;\n }\n patchSelectorFn(Document.prototype, \"querySelector\", rewriteSelector);\n patchSelectorFn(Document.prototype, \"querySelectorAll\", rewriteSelector);\n patchSelectorFn(Element.prototype, \"querySelector\", rewriteSelector);\n patchSelectorFn(Element.prototype, \"querySelectorAll\", rewriteSelector);\n patchSelectorFn(Element.prototype, \"matches\", rewriteSelector);\n patchSelectorFn(Element.prototype, \"closest\", rewriteSelector);\n patchSelectorFn(\n DocumentFragment.prototype,\n \"querySelectorAll\",\n rewriteSelector\n );\n Object.defineProperties(HTMLElement.prototype, {\n popover: {\n enumerable: true,\n configurable: true,\n get() {\n if (!this.hasAttribute(\"popover\")) return null;\n const value = (this.getAttribute(\"popover\") || \"\").toLowerCase();\n if (value === \"\" || value == \"auto\") return \"auto\";\n if (value == \"hint\") return \"hint\";\n return \"manual\";\n },\n set(value) {\n if (value === null) {\n this.removeAttribute(\"popover\");\n } else {\n this.setAttribute(\"popover\", value);\n }\n }\n },\n showPopover: {\n enumerable: true,\n configurable: true,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n value(options = {}) {\n showPopover(this);\n }\n },\n hidePopover: {\n enumerable: true,\n configurable: true,\n value() {\n hidePopover(this, true, true);\n }\n },\n togglePopover: {\n enumerable: true,\n configurable: true,\n value(options = {}) {\n if (typeof options === \"boolean\") {\n options = { force: options };\n }\n if (visibilityState.get(this) === \"showing\" && options.force === void 0 || options.force === false) {\n hidePopover(this, true, true);\n } else if (options.force === void 0 || options.force === true) {\n showPopover(this);\n }\n return visibilityState.get(this) === \"showing\";\n }\n }\n });\n const originalAttachShadow = Element.prototype.attachShadow;\n if (originalAttachShadow) {\n Object.defineProperties(Element.prototype, {\n attachShadow: {\n enumerable: true,\n configurable: true,\n writable: true,\n value(options) {\n const shadowRoot = originalAttachShadow.call(this, options);\n injectStyles(shadowRoot);\n return shadowRoot;\n }\n }\n });\n }\n const originalAttachInternals = HTMLElement.prototype.attachInternals;\n if (originalAttachInternals) {\n Object.defineProperties(HTMLElement.prototype, {\n attachInternals: {\n enumerable: true,\n configurable: true,\n writable: true,\n value() {\n const internals = originalAttachInternals.call(this);\n if (internals.shadowRoot) {\n injectStyles(internals.shadowRoot);\n }\n return internals;\n }\n }\n });\n }\n const popoverTargetAssociatedElements = /* @__PURE__ */ new WeakMap();\n function applyPopoverInvokerElementMixin(ElementClass) {\n Object.defineProperties(ElementClass.prototype, {\n popoverTargetElement: {\n enumerable: true,\n configurable: true,\n set(targetElement) {\n if (targetElement === null) {\n this.removeAttribute(\"popovertarget\");\n popoverTargetAssociatedElements.delete(this);\n } else if (!(targetElement instanceof Element)) {\n throw new TypeError(\n `popoverTargetElement must be an element or null`\n );\n } else {\n this.setAttribute(\"popovertarget\", \"\");\n popoverTargetAssociatedElements.set(this, targetElement);\n }\n },\n get() {\n if (this.localName !== \"button\" && this.localName !== \"input\") {\n return null;\n }\n if (this.localName === \"input\" && this.type !== \"reset\" && this.type !== \"image\" && this.type !== \"button\") {\n return null;\n }\n if (this.disabled) {\n return null;\n }\n if (this.form && this.type === \"submit\") {\n return null;\n }\n const targetElement = popoverTargetAssociatedElements.get(this);\n if (targetElement && targetElement.isConnected) {\n return targetElement;\n } else if (targetElement && !targetElement.isConnected) {\n popoverTargetAssociatedElements.delete(this);\n return null;\n }\n const root = getRootNode(this);\n const idref = this.getAttribute(\"popovertarget\");\n if ((root instanceof Document || root instanceof ShadowRoot2) && idref) {\n return root.getElementById(idref) || null;\n }\n return null;\n }\n },\n popoverTargetAction: {\n enumerable: true,\n configurable: true,\n get() {\n const value = (this.getAttribute(\"popovertargetaction\") || \"\").toLowerCase();\n if (value === \"show\" || value === \"hide\") return value;\n return \"toggle\";\n },\n set(value) {\n this.setAttribute(\"popovertargetaction\", value);\n }\n }\n });\n }\n applyPopoverInvokerElementMixin(HTMLButtonElement);\n applyPopoverInvokerElementMixin(HTMLInputElement);\n const handleInvokerActivation = (event) => {\n if (event.defaultPrevented) {\n return;\n }\n const composedPath = event.composedPath();\n const target = composedPath[0];\n if (!(target instanceof Element) || (target == null ? void 0 : target.shadowRoot)) {\n return;\n }\n const root = getRootNode(target);\n if (!(root instanceof ShadowRoot2 || root instanceof Document)) {\n return;\n }\n const invoker = composedPath.find(\n (el) => {\n var _a;\n return (_a = el.matches) == null ? void 0 : _a.call(el, \"[popovertargetaction],[popovertarget]\");\n }\n );\n if (invoker) {\n popoverTargetAttributeActivationBehavior(invoker);\n event.preventDefault();\n return;\n }\n };\n const onKeydown = (event) => {\n const key = event.key;\n const target = event.target;\n if (!event.defaultPrevented && target && (key === \"Escape\" || key === \"Esc\")) {\n hideAllPopoversUntil(target.ownerDocument, true, true);\n }\n };\n const addEventListeners = (root) => {\n root.addEventListener(\"click\", handleInvokerActivation);\n root.addEventListener(\"keydown\", onKeydown);\n root.addEventListener(\"pointerdown\", lightDismissOpenPopovers);\n root.addEventListener(\"pointerup\", lightDismissOpenPopovers);\n };\n addEventListeners(document);\n injectStyles(document);\n}\nexport {\n apply,\n injectStyles,\n isHintSupported,\n isPolyfilled,\n isSupported\n};\n//# sourceMappingURL=popover-fn.js.map\n"],"x_google_ignoreList":[0],"mappings":"AACA,IAAI,EAAc,cAAc,KAAM,CACpC,SACA,SACA,YAAY,EAAM,CAAE,WAAW,GAAI,WAAW,GAAI,GAAG,GAAS,CAAC,EAAG,CAChE,MAAM,EAAM,CAAI,EAChB,KAAK,SAAW,OAAO,GAAY,EAAE,EACrC,KAAK,SAAW,OAAO,GAAY,EAAE,CACvC,CACF,EACI,EAAyC,IAAI,QACjD,SAAS,EAA4B,EAAS,EAAU,EAAU,CAChE,EAAuB,IACrB,EACA,eAAiB,CACV,EAAuB,IAAI,CAAO,GACvC,EAAQ,cACN,IAAI,EAAY,SAAU,CACxB,WAAY,GACZ,WACA,UACF,CAAC,CACH,CACF,EAAG,CAAC,CACN,CACF,CAGA,IAAI,EAAa,WAAW,YAAc,UAAW,CACrD,EACI,EAAoB,WAAW,mBAAqB,UAAW,CACnE,EACI,EAAmC,IAAI,QACvC,EAAkC,IAAI,QACtC,EAAkC,IAAI,QACtC,EAAkC,IAAI,QAC1C,SAAS,EAA0B,EAAS,CAC1C,OAAO,EAAgB,IAAI,CAAO,GA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,IAAM,EAAO,EAAY,CAAM,EAC/B,GAAI,EAAE,aAAgB,GAAe,aAAgB,UACnD,OAEF,IAAM,EAAU,EAAa,KAC1B,GAEc,EAAG,SAA+B,KAAK,EAAI,uCAAuC,CAEnG,EACA,GAAI,EAAS,CACX,EAAyC,CAAO,EAChD,EAAM,eAAe,EACrB,MACF,CACF,EACM,EAAa,GAAU,CAC3B,IAAM,EAAM,EAAM,IACZ,EAAS,EAAM,OACjB,CAAC,EAAM,kBAAoB,IAAW,IAAQ,UAAY,IAAQ,QACpE,EAAqB,EAAO,cAAe,GAAM,EAAI,CAEzD,GAC2B,GAAS,CAClC,EAAK,iBAAiB,QAAS,CAAuB,EACtD,EAAK,iBAAiB,UAAW,CAAS,EAC1C,EAAK,iBAAiB,cAAe,CAAwB,EAC7D,EAAK,iBAAiB,YAAa,CAAwB,CAC7D,GACkB,QAAQ,EAC1B,EAAa,QAAQ,CACvB"}
@@ -0,0 +1 @@
1
+ require(`@u-elements/u-details/polyfill`);
@@ -1,2 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./_vendors/invokers-polyfill/invoker.cjs`),t=require(`./utils/utils.cjs`);require(`./clickdelegatefor/clickdelegatefor.cjs`),require(`./dialog/dialog.cjs`),require(`./fieldset/fieldset.cjs`),require(`./popover/popover.cjs`),require(`./readonly/readonly.cjs`),require(`./toggle-group/toggle-group.cjs`);const n=require(`./tooltip/tooltip.cjs`),r=require(`./breadcrumbs/breadcrumbs.cjs`),i=require(`./error-summary/error-summary.cjs`),a=require(`./field/field.cjs`),o=require(`./pagination/pagination.cjs`),s=require(`./suggestion/suggestion.cjs`),c=require(`./tabs/tabs.cjs`);require(`@u-elements/u-details/polyfill`),t.isBrowser()&&!e.isSupported()&&e.apply(),exports.DSBreadcrumbsElement=r.DSBreadcrumbsElement,exports.DSErrorSummaryElement=i.DSErrorSummaryElement,exports.DSFieldElement=a.DSFieldElement,exports.DSPaginationElement=o.DSPaginationElement,exports.DSSuggestionElement=s.DSSuggestionElement,exports.DSTabElement=c.DSTabElement,exports.DSTabListElement=c.DSTabListElement,exports.DSTabPanelElement=c.DSTabPanelElement,exports.DSTabsElement=c.DSTabsElement,exports.pagination=o.pagination,exports.setTooltipElement=n.setTooltipElement;var l=require(`@u-elements/u-datalist`);Object.keys(l).forEach(function(e){e!==`default`&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return l[e]}})});
2
- //# sourceMappingURL=index.cjs.map
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./clickdelegatefor/clickdelegatefor.cjs`),require(`./details/details.cjs`),require(`./dialog/dialog.cjs`),require(`./fieldset/fieldset.cjs`),require(`./invokers/invokers.cjs`),require(`./popover/popover.cjs`),require(`./readonly/readonly.cjs`),require(`./toggle-group/toggle-group.cjs`);const e=require(`./tooltip/tooltip.cjs`),t=require(`./breadcrumbs/breadcrumbs.cjs`),n=require(`./error-summary/error-summary.cjs`),r=require(`./field/field.cjs`),i=require(`./pagination/pagination.cjs`),a=require(`./suggestion/suggestion.cjs`),o=require(`./tabs/tabs.cjs`);exports.DSBreadcrumbsElement=t.DSBreadcrumbsElement,exports.DSErrorSummaryElement=n.DSErrorSummaryElement,exports.DSFieldElement=r.DSFieldElement,exports.DSPaginationElement=i.DSPaginationElement,exports.DSSuggestionElement=a.DSSuggestionElement,exports.DSTabElement=o.DSTabElement,exports.DSTabListElement=o.DSTabListElement,exports.DSTabPanelElement=o.DSTabPanelElement,exports.DSTabsElement=o.DSTabsElement,exports.pagination=i.pagination,exports.setTooltipElement=e.setTooltipElement;var s=require(`@u-elements/u-datalist`);Object.keys(s).forEach(function(e){e!==`default`&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return s[e]}})});
@@ -0,0 +1,2 @@
1
+ const e=require(`../utils/utils.cjs`),t=require(`../_vendors/invokers-polyfill/invoker.cjs`);e.isBrowser()&&!t.isSupported()&&t.apply();
2
+ //# sourceMappingURL=invokers.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invokers.cjs","names":["isBrowser","isSupported"],"sources":["../../../src/invokers/invokers.ts"],"sourcesContent":["import { isSupported, apply as polyfillInvokers } from 'invokers-polyfill/fn';\nimport { isBrowser } from '../utils/utils';\n\nif (isBrowser() && !isSupported()) polyfillInvokers(); // Ensure invoker commands polyfill is loaded in browser environment only\n"],"mappings":"6FAGIA,EAAAA,UAAU,GAAK,CAACC,EAAAA,YAAY,GAAG,EAAA,MAAiB"}
@@ -1,2 +1,2 @@
1
- require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../utils/utils.cjs`);let t=require(`@floating-ui/dom`);const n=`data-placement`,r=`data-autoplacement`,i=new Map;function a(a){let{newState:o,oldState:s,target:l,source:u=a.detail}=a,d=l instanceof HTMLElement&&e.attr(l,`popover`)!==null&&e.getCSSProp(l,`--_ds-floating`);if(!d)return;if(o===`closed`)return i.get(l)?.();if(!u){let e=l.getRootNode(),t=`[popovertarget="${l.id}"],[commandfor="${l.id}"]`;u=l.id&&e?.querySelector?.(t)||void 0}if(!u||u===l||s&&s===o)return;let f=e.getCSSProp(l,`--_ds-floating-overscroll`),p=e.attr(l,n)||e.attr(u,n)||d,m=e.attr(l,r)||e.attr(u,r),h=parseFloat(getComputedStyle(l,`::before`).height)||0,g=p.match(/left|right/gi)?`Height`:`Width`,_=u[`offset${g}`]/2+h;if(p===`none`)return;let v={strategy:`absolute`,placement:p,middleware:[(0,t.offset)(h||0),(0,t.shift)({padding:10,limiter:(0,t.limitShift)({offset:{mainAxis:_}})}),c(),...m===`false`?[]:[(0,t.flip)({padding:10,crossAxis:!1})],...f?[(0,t.size)({apply({availableHeight:e}){f===`fit`&&(l.style.width=`${u.offsetWidth}px`),l.style.maxHeight=`${Math.max(50,e-20)}px`}})]:[]]},y=(0,t.autoUpdate)(u,l,async()=>{if(!u?.isConnected)return i.get(l)?.();let{x:e,y:n}=await(0,t.computePosition)(u,l,v);l.style.translate=`${e}px ${n}px`});i.set(l,()=>i.delete(l)&&y())}let o;const s=({type:e})=>{if(e===`mousedown`&&(o=!1),e===`scroll`&&o===!1&&(o=!0),e===`mouseup`&&o)for(let[e]of i)e.showPopover()};e.onHotReload(`popover`,()=>[e.on(document,`mousedown scroll mouseup`,s,!0),e.on(document,`toggle ds-toggle-source`,a,e.QUICK_EVENT)]);const c=()=>({name:`arrowPseudo`,fn(t){let n=t.elements.floating,r=t.rects.reference,i=`${Math.round(r.width/2+r.x-t.x)}px`,a=`${Math.round(r.height/2+r.y-t.y)}px`;return n.style.setProperty(`--_ds-floating-arrow-x`,i),n.style.setProperty(`--_ds-floating-arrow-y`,a),e.attr(n,`data-floating`,t.placement),t}});
1
+ require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../utils/utils.cjs`),t=require(`../_vendors/@oddbird/popover-polyfill/dist/popover-fn.cjs`);let n=require(`@floating-ui/dom`);e.isBrowser()&&!t.isSupported()&&t.apply();const r=`data-placement`,i=`data-autoplacement`,a=new Map;function o(t){let{newState:o,oldState:s,target:c,source:u=t.detail}=t,d=c instanceof HTMLElement&&e.attr(c,`popover`)!==null&&e.getCSSProp(c,`--_ds-floating`);if(!d)return;if(o===`closed`)return a.get(c)?.();if(!u){let e=c.getRootNode(),t=`[popovertarget="${c.id}"],[commandfor="${c.id}"]`;u=c.id&&e?.querySelector?.(t)||void 0}if(!u||u===c||s&&s===o)return;c.style.scrollMarginBottom=`var(--_ds-floating-arrow-size)`;let f=e.getCSSProp(c,`--_ds-floating-overscroll`),p=e.attr(c,r)||e.attr(u,r)||d,m=e.attr(c,i)||e.attr(u,i),h=parseFloat(e.getCSSProp(c,`scroll-margin-bottom`))||0,g=p.match(/left|right/gi)?`Height`:`Width`,_=u[`offset${g}`]/2+h;if(p===`none`)return;let v={strategy:`absolute`,placement:p,middleware:[(0,n.offset)(h),(0,n.shift)({padding:10,limiter:(0,n.limitShift)({offset:{mainAxis:_}})}),l(),...m===`false`?[]:[(0,n.flip)({padding:10,crossAxis:!1})],...f?[(0,n.size)({apply({availableHeight:e}){f===`fit`&&(c.style.width=`${u.offsetWidth}px`),c.style.maxHeight=`${Math.max(50,e-20)}px`}})]:[]]},y=(0,n.autoUpdate)(u,c,async()=>{if(!u?.isConnected)return a.get(c)?.();let{x:e,y:t}=await(0,n.computePosition)(u,c,v);c.style.translate=`${e}px ${t}px`});a.set(c,()=>a.delete(c)&&y())}let s;const c=({type:e})=>{if(e===`mousedown`&&(s=!1),e===`scroll`&&s===!1&&(s=!0),e===`mouseup`&&s)for(let[e]of a)e.showPopover()};e.onHotReload(`popover`,()=>[e.on(document,`mousedown scroll mouseup`,c,!0),e.on(document,`toggle ds-toggle-source`,o,e.QUICK_EVENT)]);const l=()=>({name:`arrowPseudo`,fn(t){let n=t.elements.floating,r=t.rects.reference,i=`${Math.round(r.width/2+r.x-t.x)}px`,a=`${Math.round(r.height/2+r.y-t.y)}px`;return n.style.setProperty(`--_ds-floating-arrow-x`,i),n.style.setProperty(`--_ds-floating-arrow-y`,a),e.attr(n,`data-floating`,t.placement),t}});
2
2
  //# sourceMappingURL=popover.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"popover.cjs","names":["attr","getCSSProp","onHotReload","on","QUICK_EVENT"],"sources":["../../../src/popover/popover.ts"],"sourcesContent":["import type { ComputePositionConfig, MiddlewareState } from '@floating-ui/dom';\nimport {\n autoUpdate,\n computePosition,\n flip,\n limitShift,\n offset,\n shift,\n size,\n} from '@floating-ui/dom';\nimport { attr, getCSSProp, on, onHotReload, QUICK_EVENT } from '../utils/utils';\n\ndeclare global {\n interface GlobalEventHandlersEventMap {\n 'ds-toggle-source': CustomEvent<Element>;\n }\n}\n\nconst ATTR_PLACE = 'data-placement';\nconst ATTR_AUTO = 'data-autoplacement';\nconst POPOVERS = new Map<HTMLElement, () => void>();\n\n// Sometimes use \"ds-toggle\" event while waiting for better support of\n// event.source (https://developer.mozilla.org/en-US/docs/Web/API/ToggleEvent/source)\nfunction handleToggle(\n event: Partial<ToggleEvent> & {\n detail?: HTMLElement;\n source?: HTMLElement;\n },\n) {\n let { newState, oldState, target: el, source = event.detail } = event;\n const isPopover = el instanceof HTMLElement && attr(el, 'popover') !== null;\n const float = isPopover && getCSSProp(el, '--_ds-floating');\n\n if (!float) return;\n if (newState === 'closed') return POPOVERS.get(el)?.(); // Cleanup on close\n if (!source) {\n const root = el.getRootNode() as Document; // Support shadow DOM\n const css = `[popovertarget=\"${el.id}\"],[commandfor=\"${el.id}\"]`;\n source = (el.id && root?.querySelector?.<HTMLElement>(css)) || undefined; // Polyfill ToggleEvent .source for older browsers\n }\n if (!source || source === el || (oldState && oldState === newState)) return; // No need to update\n const padding = 10;\n const overscroll = getCSSProp(el, '--_ds-floating-overscroll');\n const placement = attr(el, ATTR_PLACE) || attr(source, ATTR_PLACE) || float;\n const auto = attr(el, ATTR_AUTO) || attr(source, ATTR_AUTO);\n const arrowSize = parseFloat(getComputedStyle(el, '::before').height) || 0;\n const shiftProp = placement.match(/left|right/gi) ? 'Height' : 'Width';\n const shiftLimit = source[`offset${shiftProp}`] / 2 + arrowSize;\n\n if (placement === 'none') return; // No need to position\n\n const options = {\n strategy: 'absolute',\n placement,\n middleware: [\n offset(arrowSize || 0), // Add space for arrow or default to 8px\n shift({\n padding,\n limiter: limitShift({ offset: { mainAxis: shiftLimit } }), // Prevent from shifing away from source\n }),\n arrowPseudo(),\n ...(auto !== 'false' ? [flip({ padding, crossAxis: false })] : []),\n ...(overscroll\n ? [\n size({\n apply({ availableHeight }) {\n if (overscroll === 'fit')\n el.style.width = `${source.offsetWidth}px`; // Use offsetWidth to include padding, matching the width of the source element\n el.style.maxHeight = `${Math.max(50, availableHeight - padding * 2)}px`;\n },\n }),\n ]\n : []),\n ],\n } as ComputePositionConfig;\n const unfloat = autoUpdate(source, el, async () => {\n if (!source?.isConnected) return POPOVERS.get(el)?.(); // Cleanup if source element is removed\n const { x, y } = await computePosition(source, el, options);\n el.style.translate = `${x}px ${y}px`;\n });\n POPOVERS.set(el, () => POPOVERS.delete(el) && unfloat());\n}\n\n// Prevent closing when mouse interacts with scrollbar\nlet IS_SCROLL: boolean | undefined;\nconst handleScrollbar = ({ type }: Event) => {\n if (type === 'mousedown') IS_SCROLL = false;\n if (type === 'scroll' && IS_SCROLL === false) IS_SCROLL = true;\n if (type === 'mouseup' && IS_SCROLL)\n for (const [popover] of POPOVERS) popover.showPopover(); // Immediately show again to prevent flicker\n};\n\nonHotReload('popover', () => [\n on(document, 'mousedown scroll mouseup', handleScrollbar, true),\n on(document, 'toggle ds-toggle-source', handleToggle, QUICK_EVENT), // Use capture since the toggle event does not bubble\n]);\n\nconst arrowPseudo = () => ({\n name: 'arrowPseudo',\n fn(data: MiddlewareState) {\n const target = data.elements.floating;\n const source = data.rects.reference;\n const x = `${Math.round(source.width / 2 + source.x - data.x)}px`;\n const y = `${Math.round(source.height / 2 + source.y - data.y)}px`;\n\n target.style.setProperty('--_ds-floating-arrow-x', x);\n target.style.setProperty('--_ds-floating-arrow-y', y);\n attr(target, 'data-floating', data.placement);\n return data;\n },\n});\n"],"mappings":"qHAkBA,MAAM,EAAa,iBACb,EAAY,qBACZ,EAAW,IAAI,IAIrB,SAAS,EACP,EAIA,CACA,GAAI,CAAE,WAAU,WAAU,OAAQ,EAAI,SAAS,EAAM,QAAW,EAE1D,EADY,aAAc,aAAeA,EAAAA,KAAK,EAAI,SAAS,IAAM,MAC5CC,EAAAA,WAAW,EAAI,gBAAgB,EAE1D,GAAI,CAAC,EAAO,OACZ,GAAI,IAAa,SAAU,OAAO,EAAS,IAAI,CAAE,IAAI,EACrD,GAAI,CAAC,EAAQ,CACX,IAAM,EAAO,EAAG,YAAY,EACtB,EAAM,mBAAmB,EAAG,GAAG,kBAAkB,EAAG,GAAG,IAC7D,EAAU,EAAG,IAAM,GAAM,gBAA6B,CAAG,GAAM,IAAA,EACjE,CACA,GAAI,CAAC,GAAU,IAAW,GAAO,GAAY,IAA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GAFI,IAAS,cAAa,EAAY,IAClC,IAAS,UAAY,IAAc,KAAO,EAAY,IACtD,IAAS,WAAa,EACxB,IAAK,GAAM,CAAC,KAAY,EAAU,EAAQ,YAAY,CAC1D,EAEAE,EAAAA,YAAY,cAAiB,CAC3BC,EAAAA,GAAG,SAAU,2BAA4B,EAAiB,EAAI,EAC9DA,EAAAA,GAAG,SAAU,0BAA2B,EAAcC,EAAAA,WAAW,CACnE,CAAC,EAED,MAAM,OAAqB,CACzB,KAAM,cACN,GAAG,EAAuB,CACxB,IAAM,EAAS,EAAK,SAAS,SACvB,EAAS,EAAK,MAAM,UACpB,EAAI,GAAG,KAAK,MAAM,EAAO,MAAQ,EAAI,EAAO,EAAI,EAAK,CAAC,EAAE,IACxD,EAAI,GAAG,KAAK,MAAM,EAAO,OAAS,EAAI,EAAO,EAAI,EAAK,CAAC,EAAE,IAK/D,OAHA,EAAO,MAAM,YAAY,yBAA0B,CAAC,EACpD,EAAO,MAAM,YAAY,yBAA0B,CAAC,EACpD,EAAA,KAAK,EAAQ,gBAAiB,EAAK,SAAS,EACrC,CACT,CACF"}
1
+ {"version":3,"file":"popover.cjs","names":["isBrowser","isSupported","attr","getCSSProp","onHotReload","on","QUICK_EVENT"],"sources":["../../../src/popover/popover.ts"],"sourcesContent":["import type { ComputePositionConfig, MiddlewareState } from '@floating-ui/dom';\nimport {\n autoUpdate,\n computePosition,\n flip,\n limitShift,\n offset,\n shift,\n size,\n} from '@floating-ui/dom';\nimport {\n isSupported,\n apply as polyfillPopover,\n} from '@oddbird/popover-polyfill/fn';\nimport {\n attr,\n getCSSProp,\n isBrowser,\n on,\n onHotReload,\n QUICK_EVENT,\n} from '../utils/utils';\n\nif (isBrowser() && !isSupported()) polyfillPopover(); // Ensure popover polyfill is loaded in browser environment only\n\ndeclare global {\n interface GlobalEventHandlersEventMap {\n 'ds-toggle-source': CustomEvent<Element>;\n }\n}\n\nconst ATTR_PLACE = 'data-placement';\nconst ATTR_AUTO = 'data-autoplacement';\nconst POPOVERS = new Map<HTMLElement, () => void>();\n\n// Sometimes use \"ds-toggle\" event while waiting for better support of\n// event.source (https://developer.mozilla.org/en-US/docs/Web/API/ToggleEvent/source)\nfunction handleToggle(\n event: Partial<ToggleEvent> & {\n detail?: HTMLElement;\n source?: HTMLElement;\n },\n) {\n let { newState, oldState, target: el, source = event.detail } = event;\n const isPopover = el instanceof HTMLElement && attr(el, 'popover') !== null;\n const float = isPopover && getCSSProp(el, '--_ds-floating');\n\n if (!float) return;\n if (newState === 'closed') return POPOVERS.get(el)?.(); // Cleanup on close\n if (!source) {\n const root = el.getRootNode() as Document; // Support shadow DOM\n const css = `[popovertarget=\"${el.id}\"],[commandfor=\"${el.id}\"]`;\n source = (el.id && root?.querySelector?.<HTMLElement>(css)) || undefined; // Polyfill ToggleEvent .source for older browsers\n }\n if (!source || source === el || (oldState && oldState === newState)) return; // No need to update\n\n // Use scroll-margin-bottom to measure computed arrow-size property as this does\n // not affect layout or position, makes the browser calculate the pixel value instead\n // of returning the calc() (as it would if reading the --_ds-floating-arrow-size directly)\n // and makes it possible to read the value even if ::before is not used to draw the arrow.\n el.style.scrollMarginBottom = `var(--_ds-floating-arrow-size)`;\n\n const padding = 10;\n const overscroll = getCSSProp(el, '--_ds-floating-overscroll');\n const placement = attr(el, ATTR_PLACE) || attr(source, ATTR_PLACE) || float;\n const auto = attr(el, ATTR_AUTO) || attr(source, ATTR_AUTO);\n const arrowSize = parseFloat(getCSSProp(el, 'scroll-margin-bottom')) || 0;\n const shiftProp = placement.match(/left|right/gi) ? 'Height' : 'Width';\n const shiftLimit = source[`offset${shiftProp}`] / 2 + arrowSize;\n\n if (placement === 'none') return; // No need to position\n\n const options = {\n strategy: 'absolute',\n placement,\n middleware: [\n offset(arrowSize),\n shift({\n padding,\n limiter: limitShift({ offset: { mainAxis: shiftLimit } }), // Prevent from shifing away from source\n }),\n arrowPseudo(),\n ...(auto !== 'false' ? [flip({ padding, crossAxis: false })] : []),\n ...(overscroll\n ? [\n size({\n apply({ availableHeight }) {\n if (overscroll === 'fit')\n el.style.width = `${source.offsetWidth}px`; // Use offsetWidth to include padding, matching the width of the source element\n el.style.maxHeight = `${Math.max(50, availableHeight - padding * 2)}px`;\n },\n }),\n ]\n : []),\n ],\n } as ComputePositionConfig;\n const unfloat = autoUpdate(source, el, async () => {\n if (!source?.isConnected) return POPOVERS.get(el)?.(); // Cleanup if source element is removed\n const { x, y } = await computePosition(source, el, options);\n el.style.translate = `${x}px ${y}px`;\n });\n POPOVERS.set(el, () => POPOVERS.delete(el) && unfloat());\n}\n\n// Prevent closing when mouse interacts with scrollbar\nlet IS_SCROLL: boolean | undefined;\nconst handleScrollbar = ({ type }: Event) => {\n if (type === 'mousedown') IS_SCROLL = false;\n if (type === 'scroll' && IS_SCROLL === false) IS_SCROLL = true;\n if (type === 'mouseup' && IS_SCROLL)\n for (const [popover] of POPOVERS) popover.showPopover(); // Immediately show again to prevent flicker\n};\n\nonHotReload('popover', () => [\n on(document, 'mousedown scroll mouseup', handleScrollbar, true),\n on(document, 'toggle ds-toggle-source', handleToggle, QUICK_EVENT), // Use capture since the toggle event does not bubble\n]);\n\nconst arrowPseudo = () => ({\n name: 'arrowPseudo',\n fn(data: MiddlewareState) {\n const target = data.elements.floating;\n const source = data.rects.reference;\n const x = `${Math.round(source.width / 2 + source.x - data.x)}px`;\n const y = `${Math.round(source.height / 2 + source.y - data.y)}px`;\n\n target.style.setProperty('--_ds-floating-arrow-x', x);\n target.style.setProperty('--_ds-floating-arrow-y', y);\n attr(target, 'data-floating', data.placement);\n return data;\n },\n});\n"],"mappings":"4LAuBIA,EAAAA,UAAU,GAAK,CAACC,EAAAA,YAAY,GAAG,EAAA,MAAgB,EAQnD,MAAM,EAAa,iBACb,EAAY,qBACZ,EAAW,IAAI,IAIrB,SAAS,EACP,EAIA,CACA,GAAI,CAAE,WAAU,WAAU,OAAQ,EAAI,SAAS,EAAM,QAAW,EAE1D,EADY,aAAc,aAAeC,EAAAA,KAAK,EA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P,CACF,EACM,GAAA,EAAA,EAAA,YAAqB,EAAQ,EAAI,SAAY,CACjD,GAAI,CAAC,GAAQ,YAAa,OAAO,EAAS,IAAI,CAAE,IAAI,EACpD,GAAM,CAAE,IAAG,KAAM,MAAA,EAAA,EAAA,iBAAsB,EAAQ,EAAI,CAAO,EAC1D,EAAG,MAAM,UAAY,GAAG,EAAE,KAAK,EAAE,GACnC,CAAC,EACD,EAAS,IAAI,MAAU,EAAS,OAAO,CAAE,GAAK,EAAQ,CAAC,CACzD,CAGA,IAAI,EACJ,MAAM,GAAmB,CAAE,UAAkB,CAG3C,GAFI,IAAS,cAAa,EAAY,IAClC,IAAS,UAAY,IAAc,KAAO,EAAY,IACtD,IAAS,WAAa,EACxB,IAAK,GAAM,CAAC,KAAY,EAAU,EAAQ,YAAY,CAC1D,EAEAC,EAAAA,YAAY,cAAiB,CAC3BC,EAAAA,GAAG,SAAU,2BAA4B,EAAiB,EAAI,EAC9DA,EAAAA,GAAG,SAAU,0BAA2B,EAAcC,EAAAA,WAAW,CACnE,CAAC,EAED,MAAM,OAAqB,CACzB,KAAM,cACN,GAAG,EAAuB,CACxB,IAAM,EAAS,EAAK,SAAS,SACvB,EAAS,EAAK,MAAM,UACpB,EAAI,GAAG,KAAK,MAAM,EAAO,MAAQ,EAAI,EAAO,EAAI,EAAK,CAAC,EAAE,IACxD,EAAI,GAAG,KAAK,MAAM,EAAO,OAAS,EAAI,EAAO,EAAI,EAAK,CAAC,EAAE,IAK/D,OAHA,EAAO,MAAM,YAAY,yBAA0B,CAAC,EACpD,EAAO,MAAM,YAAY,yBAA0B,CAAC,EACpD,EAAA,KAAK,EAAQ,gBAAiB,EAAK,SAAS,EACrC,CACT,CACF"}
@@ -1,2 +1,2 @@
1
- require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../utils/utils.cjs`);let t=require(`@u-elements/u-combobox`);var n=class extends t.UHTMLComboboxElement{_unmutate;connectedCallback(){super.connectedCallback(),this._unmutate=e.onMutation(this,r,{childList:!0}),e.on(this,`toggle`,i,e.QUICK_EVENT)}disconnectedCallback(){super.disconnectedCallback(),this._unmutate?.(),this._unmutate=void 0,e.off(this,`toggle`,i,e.QUICK_EVENT)}};const r=({control:t,list:n})=>{t&&!t.placeholder&&e.attr(t,`placeholder`,` `),t&&e.attr(t,`popovertarget`,e.useId(n)||null),n&&e.attr(n,`popover`,`manual`),n&&e.attr(n,`data-is-floating`,`true`)},i=e=>{let t=e.currentTarget,n=e.newState===`open`&&t.control;n&&t.list?.dispatchEvent(new CustomEvent(`ds-toggle-source`,{detail:n}))};e.customElements.define(`ds-suggestion`,n),exports.DSSuggestionElement=n;
1
+ require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../utils/utils.cjs`);let t=require(`@u-elements/u-combobox`);var n=class extends t.UHTMLComboboxElement{_unmutate;connectedCallback(){super.connectedCallback(),this._unmutate=e.onMutation(this,r,{childList:!0}),e.on(this,`toggle`,i,e.QUICK_EVENT)}disconnectedCallback(){super.disconnectedCallback(),this._unmutate?.(),this._unmutate=void 0,e.off(this,`toggle`,i,e.QUICK_EVENT)}};const r=t=>{let{control:n,list:r}=t,i=r||t.querySelector(`u-datalist`);n&&!n.placeholder&&e.attr(n,`placeholder`,` `),n&&e.attr(n,`popovertarget`,e.useId(r)||null),i&&e.attr(i,`popover`,`manual`),i&&e.attr(i,`data-is-floating`,`true`)},i=e=>{let t=e.currentTarget,n=e.newState===`open`&&t.control;n&&t.list?.dispatchEvent(new CustomEvent(`ds-toggle-source`,{detail:n}))};e.customElements.define(`ds-suggestion`,n),exports.DSSuggestionElement=n;
2
2
  //# sourceMappingURL=suggestion.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"suggestion.cjs","names":["UHTMLComboboxElement","onMutation","QUICK_EVENT","useId","customElements"],"sources":["../../../src/suggestion/suggestion.ts"],"sourcesContent":["import { UHTMLComboboxElement } from '@u-elements/u-combobox';\nimport {\n attr,\n customElements,\n off,\n on,\n onMutation,\n QUICK_EVENT,\n useId,\n} from '../utils/utils';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ds-suggestion': DSSuggestionElement;\n }\n}\n\nexport class DSSuggestionElement extends UHTMLComboboxElement {\n _unmutate?: ReturnType<typeof onMutation>; // Using underscore instead of private fields for backwards compatibility\n\n connectedCallback() {\n super.connectedCallback();\n this._unmutate = onMutation(this, render, { childList: true }); // .control and .list are direct children of the custom element\n on(this, 'toggle', polyfillToggleSource, QUICK_EVENT);\n }\n disconnectedCallback() {\n super.disconnectedCallback();\n this._unmutate?.();\n this._unmutate = undefined;\n off(this, 'toggle', polyfillToggleSource, QUICK_EVENT);\n }\n}\n\n// A non-empty placeholder attribute is required to activate the :placeholder-shown pseudo selector used in our chevron styling\nconst render = ({ control, list }: DSSuggestionElement) => {\n if (control && !control.placeholder) attr(control, 'placeholder', ' '); // .control comes from UHTMLComboboxElement\n if (control) attr(control, 'popovertarget', useId(list) || null);\n if (list) attr(list, 'popover', 'manual'); // Ensure popover attribute is set on the list\n if (list) attr(list, 'data-is-floating', 'true'); // identifier for css to toggle opacity when it is placed by floating-ui.\n};\n\n// Since showPopover({ source }) is not supported in all browsers yet:\nconst polyfillToggleSource = (event: Partial<ToggleEvent>) => {\n const self = event.currentTarget as DSSuggestionElement;\n const detail = event.newState === 'open' && self.control; // .control comes from UHTMLComboboxElement\n\n if (detail)\n self.list?.dispatchEvent(new CustomEvent('ds-toggle-source', { detail }));\n};\n\ncustomElements.define('ds-suggestion', DSSuggestionElement);\n"],"mappings":"2HAiBA,IAAa,EAAb,cAAyCA,EAAAA,oBAAqB,CAC5D,UAEA,mBAAoB,CAClB,MAAM,kBAAkB,EACxB,KAAK,UAAYC,EAAAA,WAAW,KAAM,EAAQ,CAAE,UAAW,EAAK,CAAC,EAC7D,EAAA,GAAG,KAAM,SAAU,EAAsBC,EAAAA,WAAW,CACtD,CACA,sBAAuB,CACrB,MAAM,qBAAqB,EAC3B,KAAK,YAAY,EACjB,KAAK,UAAY,IAAA,GACjB,EAAA,IAAI,KAAM,SAAU,EAAsBA,EAAAA,WAAW,CACvD,CACF,EAGA,MAAM,GAAU,CAAE,UAAS,UAAgC,CACrD,GAAW,CAAC,EAAQ,aAAa,EAAA,KAAK,EAAS,cAAe,GAAG,EACjE,GAAS,EAAA,KAAK,EAAS,gBAAiBC,EAAAA,MAAM,CAAI,GAAK,IAAI,EAC3D,GAAM,EAAA,KAAK,EAAM,UAAW,QAAQ,EACpC,GAAM,EAAA,KAAK,EAAM,mBAAoB,MAAM,CACjD,EAGM,EAAwB,GAAgC,CAC5D,IAAM,EAAO,EAAM,cACb,EAAS,EAAM,WAAa,QAAU,EAAK,QAE7C,GACF,EAAK,MAAM,cAAc,IAAI,YAAY,mBAAoB,CAAE,QAAO,CAAC,CAAC,CAC5E,EAEAC,EAAAA,eAAe,OAAO,gBAAiB,CAAmB"}
1
+ {"version":3,"file":"suggestion.cjs","names":["UHTMLComboboxElement","onMutation","QUICK_EVENT","useId","customElements"],"sources":["../../../src/suggestion/suggestion.ts"],"sourcesContent":["import { UHTMLComboboxElement } from '@u-elements/u-combobox';\nimport {\n attr,\n customElements,\n off,\n on,\n onMutation,\n QUICK_EVENT,\n useId,\n} from '../utils/utils';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ds-suggestion': DSSuggestionElement;\n }\n}\n\nexport class DSSuggestionElement extends UHTMLComboboxElement {\n _unmutate?: ReturnType<typeof onMutation>; // Using underscore instead of private fields for backwards compatibility\n\n connectedCallback() {\n super.connectedCallback();\n this._unmutate = onMutation(this, render, { childList: true }); // .control and .list are direct children of the custom element\n on(this, 'toggle', polyfillToggleSource, QUICK_EVENT);\n }\n disconnectedCallback() {\n super.disconnectedCallback();\n this._unmutate?.();\n this._unmutate = undefined;\n off(this, 'toggle', polyfillToggleSource, QUICK_EVENT);\n }\n}\n\n// A non-empty placeholder attribute is required to activate the :placeholder-shown pseudo selector used in our chevron styling\nconst render = (self: DSSuggestionElement) => {\n const { control, list } = self;\n const datalist = list || self.querySelector('u-datalist'); // Fallback to u-datalist since React can render the ds-suggestion before u-datalist is connected\n\n if (control && !control.placeholder) attr(control, 'placeholder', ' '); // .control comes from UHTMLComboboxElement\n if (control) attr(control, 'popovertarget', useId(list) || null);\n if (datalist) attr(datalist, 'popover', 'manual'); // Ensure popover attribute is set on the list\n if (datalist) attr(datalist, 'data-is-floating', 'true'); // identifier for css to toggle opacity when it is placed by floating-ui.\n};\n\n// Since showPopover({ source }) is not supported in all browsers yet:\nconst polyfillToggleSource = (event: Partial<ToggleEvent>) => {\n const self = event.currentTarget as DSSuggestionElement;\n const detail = event.newState === 'open' && self.control; // .control comes from UHTMLComboboxElement\n\n if (detail)\n self.list?.dispatchEvent(new CustomEvent('ds-toggle-source', { detail }));\n};\n\n// Ensure u-datalist is defined before ds-suggestion\ncustomElements.define('ds-suggestion', DSSuggestionElement);\n"],"mappings":"2HAiBA,IAAa,EAAb,cAAyCA,EAAAA,oBAAqB,CAC5D,UAEA,mBAAoB,CAClB,MAAM,kBAAkB,EACxB,KAAK,UAAYC,EAAAA,WAAW,KAAM,EAAQ,CAAE,UAAW,EAAK,CAAC,EAC7D,EAAA,GAAG,KAAM,SAAU,EAAsBC,EAAAA,WAAW,CACtD,CACA,sBAAuB,CACrB,MAAM,qBAAqB,EAC3B,KAAK,YAAY,EACjB,KAAK,UAAY,IAAA,GACjB,EAAA,IAAI,KAAM,SAAU,EAAsBA,EAAAA,WAAW,CACvD,CACF,EAGA,MAAM,EAAU,GAA8B,CAC5C,GAAM,CAAE,UAAS,QAAS,EACpB,EAAW,GAAQ,EAAK,cAAc,YAAY,EAEpD,GAAW,CAAC,EAAQ,aAAa,EAAA,KAAK,EAAS,cAAe,GAAG,EACjE,GAAS,EAAA,KAAK,EAAS,gBAAiBC,EAAAA,MAAM,CAAI,GAAK,IAAI,EAC3D,GAAU,EAAA,KAAK,EAAU,UAAW,QAAQ,EAC5C,GAAU,EAAA,KAAK,EAAU,mBAAoB,MAAM,CACzD,EAGM,EAAwB,GAAgC,CAC5D,IAAM,EAAO,EAAM,cACb,EAAS,EAAM,WAAa,QAAU,EAAK,QAE7C,GACF,EAAK,MAAM,cAAc,IAAI,YAAY,mBAAoB,CAAE,QAAO,CAAC,CAAC,CAC5E,EAGAC,EAAAA,eAAe,OAAO,gBAAiB,CAAmB"}
@@ -1,2 +1,2 @@
1
- const e=require(`../utils/utils.cjs`);let t,n,r=!1,i=0,a=0;const o=e.isBrowser()&&/iPad|iPhone|iPod/.test(navigator.userAgent),s=`data-tooltip`,c=`data-color`,l=`aria-label`,u=`aria-description`,d=`[${c}]`,f=`[${s}]`,p=`data-color-scheme`,m=`[${p}]`,h=o=>{o&&!(o instanceof HTMLElement)&&e.warn(`setTooltipElement expects an HTMLElement, got: `,o),clearTimeout(a),clearTimeout(i),n=void 0,r=!1,t=o||void 0},g=()=>{for(let r of document.querySelectorAll(f)){let i=e.attrOrCSS(r,s);if(!i)return;if(i!==(r.getAttribute(l)||r.getAttribute(u))){let t=e.attr(r,`role`)!==`img`&&r.textContent?.trim();e.attr(r,s,i),e.attr(r,l,t?null:i),e.attr(r,u,t?i:null),r.matches(`a,button,input,label,select,textarea,[tabindex]`)||e.warn(`Missing tabindex="0" attribute on: `,r)}let a=r===n&&t?.offsetHeight&&t?.offsetWidth,o=a&&i&&t?.textContent!==i;a&&o&&(t&&(t.textContent=i),document.activeElement===r&&e.announce(i))}},_=({type:l,target:u})=>{if(clearTimeout(i),u===t)return;if(l===`mouseover`&&!r&&!o){i=setTimeout(_,300,{target:u});return}let f=u?.closest?.(`[${s}]`);if(f===n)return;if(!f)return v();t||=e.tag(`div`,{class:`ds-tooltip`}),t.isConnected||document.body.appendChild(t);let h=f.closest(d),g=f.closest(m),y=h!==g&&h?.contains(g);clearTimeout(a),e.attr(t,`popover`,`manual`),e.attr(t,p,g?.getAttribute(p)||null),e.attr(t,c,y&&h?.getAttribute(c)||null),t.textContent=e.attr(f,s),t.showPopover(),t.dispatchEvent(new CustomEvent(`ds-toggle-source`,{detail:f})),r=!0,n=f},v=()=>t?.isConnected&&t.popover&&t.hidePopover(),y=e=>{if(e?.type===`keydown`)return e?.key===`Escape`&&v();e?e.target===t&&e.newState===`closed`&&(n=void 0,a=setTimeout(y,300)):r=!1};e.onHotReload(`tooltip`,()=>[e.on(document,`blur focus mouseover`,_,e.QUICK_EVENT),e.on(document,`toggle keydown`,y,e.QUICK_EVENT),e.onMutation(document,g,{attributeFilter:[s],attributes:!0,childList:!0,subtree:!0})]),exports.setTooltipElement=h;
1
+ const e=require(`../utils/utils.cjs`);require(`../popover/popover.cjs`);let t,n,r=!1,i=0,a=0;const o=e.isBrowser()&&/iPad|iPhone|iPod/.test(navigator.userAgent),s=`data-tooltip`,c=`data-color`,l=`aria-label`,u=`aria-description`,d=`[${c}]`,f=`[${s}]`,p=`data-color-scheme`,m=`[${p}]`,h=o=>{o&&!(o instanceof HTMLElement)&&e.warn(`setTooltipElement expects an HTMLElement, got: `,o),clearTimeout(a),clearTimeout(i),n=void 0,r=!1,t=o||void 0},g=()=>{for(let r of document.querySelectorAll(f)){let i=e.attrOrCSS(r,s);if(!i)return;if(i!==(r.getAttribute(l)||r.getAttribute(u))){let t=e.attr(r,`role`)!==`img`&&r.textContent?.trim();e.attr(r,s,i),e.attr(r,l,t?null:i),e.attr(r,u,t?i:null),r.matches(`a,button,input,label,select,textarea,[tabindex]`)||e.warn(`Missing tabindex="0" attribute on: `,r)}let a=r===n&&t?.offsetHeight&&t?.offsetWidth,o=a&&i&&t?.textContent!==i;a&&o&&(t&&(t.textContent=i),document.activeElement===r&&e.announce(i))}},_=({type:l,target:u})=>{if(clearTimeout(i),u===t)return;if(l===`mouseover`&&!r&&!o){i=setTimeout(_,300,{target:u});return}let f=u?.closest?.(`[${s}]`);if(f===n)return;if(!f)return v();t||=e.tag(`div`,{class:`ds-tooltip`}),t.isConnected||document.body.appendChild(t);let h=f.closest(d),g=f.closest(m),y=h!==g&&h?.contains(g);clearTimeout(a),e.attr(t,`popover`,`manual`),e.attr(t,p,g?.getAttribute(p)||null),e.attr(t,c,y&&h?.getAttribute(c)||null),t.textContent=e.attr(f,s),t.showPopover(),t.dispatchEvent(new CustomEvent(`ds-toggle-source`,{detail:f})),r=!0,n=f},v=()=>t?.isConnected&&t.popover&&t.hidePopover(),y=e=>{if(e?.type===`keydown`)return e?.key===`Escape`&&v();e?e.target===t&&e.newState===`closed`&&(n=void 0,a=setTimeout(y,300)):r=!1};e.onHotReload(`tooltip`,()=>[e.on(document,`blur focus mouseover`,_,e.QUICK_EVENT),e.on(document,`toggle keydown`,y,e.QUICK_EVENT),e.onMutation(document,g,{attributeFilter:[s],attributes:!0,childList:!0,subtree:!0})]),exports.setTooltipElement=h;
2
2
  //# sourceMappingURL=tooltip.cjs.map