@editora/ui-core 0.1.19 → 0.1.20
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/dist/{ElementBase-1b301e7f.js → ElementBase-EV6mVBUV.js} +1 -1
- package/dist/{ElementBase-909688f3.mjs → ElementBase-YlTLMsGk.mjs} +3 -3
- package/dist/accordion.cjs.js +3 -3
- package/dist/accordion.esm.js +39 -62
- package/dist/alert-dialog.cjs.js +19 -19
- package/dist/alert-dialog.esm.js +69 -87
- package/dist/alert.cjs.js +1 -1
- package/dist/alert.esm.js +4 -7
- package/dist/anchor.cjs.js +2 -2
- package/dist/anchor.esm.js +3 -3
- package/dist/animated-beam.cjs.js +83 -83
- package/dist/animated-beam.esm.js +250 -277
- package/dist/animated-list.cjs.js +4 -4
- package/dist/animated-list.esm.js +47 -61
- package/dist/animated-text.cjs.js +2 -2
- package/dist/animated-text.esm.js +13 -24
- package/dist/app-header.cjs.js +3 -3
- package/dist/app-header.esm.js +11 -13
- package/dist/aspect-ratio.cjs.js +1 -1
- package/dist/aspect-ratio.esm.js +4 -7
- package/dist/avatar.cjs.js +1 -1
- package/dist/avatar.esm.js +7 -13
- package/dist/badge.cjs.js +1 -1
- package/dist/badge.esm.js +4 -7
- package/dist/block-controls.cjs.js +2 -2
- package/dist/block-controls.esm.js +19 -35
- package/dist/box.cjs.js +1 -1
- package/dist/box.esm.js +8 -15
- package/dist/breadcrumb.cjs.js +2 -2
- package/dist/breadcrumb.esm.js +20 -37
- package/dist/button.cjs.js +1 -521
- package/dist/button.esm.js +2 -671
- package/dist/{calendar-2c11b824.mjs → calendar-DLY4acgn.mjs} +293 -342
- package/dist/{calendar-a8735e40.js → calendar-Dkof-FTK.js} +25 -25
- package/dist/calendar.cjs.js +1 -1
- package/dist/calendar.esm.js +8 -9
- package/dist/card.cjs.js +4 -4
- package/dist/card.esm.js +13 -19
- package/dist/chart.cjs.js +64 -64
- package/dist/chart.esm.js +223 -254
- package/dist/checkbox.cjs.js +1 -1
- package/dist/checkbox.esm.js +2 -3
- package/dist/collapsible.cjs.js +1 -1
- package/dist/collapsible.esm.js +5 -9
- package/dist/{collection-a1aac0c6.mjs → collection-C7URGjEI.mjs} +8 -14
- package/dist/collection.cjs.js +1 -1
- package/dist/collection.esm.js +4 -7
- package/dist/color-picker.cjs.js +9 -9
- package/dist/color-picker.esm.js +189 -252
- package/dist/combobox.cjs.js +13 -13
- package/dist/combobox.esm.js +93 -126
- package/dist/command-palette.cjs.js +3 -3
- package/dist/command-palette.esm.js +19 -30
- package/dist/command.cjs.js +4 -4
- package/dist/command.esm.js +41 -53
- package/dist/components/ui-orbiter.d.ts.map +1 -1
- package/dist/components/ui-skeleton.d.ts.map +1 -1
- package/dist/components/ui-split-button.d.ts +1 -0
- package/dist/components/ui-split-button.d.ts.map +1 -1
- package/dist/components/ui-time-picker.d.ts.map +1 -1
- package/dist/container.cjs.js +2 -2
- package/dist/container.esm.js +2 -3
- package/dist/context-menu.cjs.js +8 -8
- package/dist/context-menu.esm.js +157 -219
- package/dist/control-group.cjs.js +1 -1
- package/dist/control-group.esm.js +2 -3
- package/dist/data-table.cjs.js +4 -4
- package/dist/data-table.esm.js +299 -381
- package/dist/date-field.cjs.js +3 -3
- package/dist/date-field.esm.js +68 -80
- package/dist/date-picker.cjs.js +9 -9
- package/dist/date-picker.esm.js +69 -97
- package/dist/date-range-picker.cjs.js +3 -3
- package/dist/date-range-picker.esm.js +32 -56
- package/dist/date-range-time-picker.cjs.js +9 -9
- package/dist/date-range-time-picker.esm.js +111 -140
- package/dist/date-time-picker.cjs.js +4 -4
- package/dist/date-time-picker.esm.js +112 -144
- package/dist/date-time-utils-Dmost5Ee.js +1 -0
- package/dist/date-time-utils-y1N2gvG2.mjs +268 -0
- package/dist/description.cjs.js +1 -1
- package/dist/description.esm.js +3 -5
- package/dist/dialog.cjs.js +12 -12
- package/dist/dialog.esm.js +44 -63
- package/dist/direction-provider.cjs.js +1 -1
- package/dist/direction-provider.esm.js +2 -3
- package/dist/{dismissable-layer-9c7e6b58.mjs → dismissable-layer-BmPIoK80.mjs} +29 -33
- package/dist/dismissable-layer-DNfrKA20.js +1 -0
- package/dist/dismissable-layer.cjs.js +2 -2
- package/dist/dismissable-layer.esm.js +4 -6
- package/dist/dock.cjs.js +5 -5
- package/dist/dock.esm.js +134 -155
- package/dist/drawer.cjs.js +2 -2
- package/dist/drawer.esm.js +18 -35
- package/dist/dropdown.cjs.js +2 -2
- package/dist/dropdown.esm.js +119 -149
- package/dist/dropzone.cjs.js +1 -1
- package/dist/dropzone.esm.js +0 -1
- package/dist/empty-state.cjs.js +1 -1
- package/dist/empty-state.esm.js +1 -1
- package/dist/field-error.cjs.js +1 -1
- package/dist/field-error.esm.js +3 -5
- package/dist/field.cjs.js +5 -5
- package/dist/field.esm.js +27 -34
- package/dist/fieldset.cjs.js +4 -4
- package/dist/fieldset.esm.js +19 -24
- package/dist/file-upload.cjs.js +4 -4
- package/dist/file-upload.esm.js +69 -93
- package/dist/flex.cjs.js +1 -1
- package/dist/flex.esm.js +5 -9
- package/dist/floating-toolbar.cjs.js +4 -4
- package/dist/floating-toolbar.esm.js +60 -85
- package/dist/focus-scope-Bwug2gDv.js +1 -0
- package/dist/{focus-scope-103833ee.mjs → focus-scope-CmEsG5UZ.mjs} +39 -48
- package/dist/focus-scope.cjs.js +2 -2
- package/dist/focus-scope.esm.js +15 -20
- package/dist/form.cjs.js +2 -2
- package/dist/form.esm.js +26 -53
- package/dist/gantt.cjs.js +43 -43
- package/dist/gantt.esm.js +295 -322
- package/dist/grid.cjs.js +1 -1
- package/dist/grid.esm.js +5 -9
- package/dist/hover-card.cjs.js +4 -4
- package/dist/hover-card.esm.js +22 -28
- package/dist/icon-cloud.cjs.js +7 -7
- package/dist/icon-cloud.esm.js +48 -62
- package/dist/icon.cjs.js +1 -1
- package/dist/icon.esm.js +2 -4
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +378 -390
- package/dist/inline-edit.cjs.js +11 -11
- package/dist/inline-edit.esm.js +32 -36
- package/dist/input.cjs.js +17 -17
- package/dist/input.esm.js +50 -63
- package/dist/label.cjs.js +2 -2
- package/dist/label.esm.js +8 -17
- package/dist/layout.cjs.js +2 -2
- package/dist/layout.esm.js +20 -26
- package/dist/listbox-B6QgECax.js +46 -0
- package/dist/listbox-DJamVeFj.mjs +200 -0
- package/dist/listbox.cjs.js +1 -1
- package/dist/listbox.esm.js +2 -4
- package/dist/marquee.cjs.js +5 -5
- package/dist/marquee.esm.js +33 -50
- package/dist/masonry-grid.cjs.js +1 -1
- package/dist/masonry-grid.esm.js +5 -9
- package/dist/menu.cjs.js +3 -3
- package/dist/menu.esm.js +106 -126
- package/dist/menubar.cjs.js +5 -5
- package/dist/menubar.esm.js +118 -164
- package/dist/meter.cjs.js +2 -2
- package/dist/meter.esm.js +4 -4
- package/dist/multi-select.cjs.js +4 -4
- package/dist/multi-select.esm.js +120 -140
- package/dist/navigation-menu.cjs.js +4 -4
- package/dist/navigation-menu.esm.js +44 -55
- package/dist/number-field.cjs.js +2 -2
- package/dist/number-field.esm.js +73 -98
- package/dist/number-ticker.cjs.js +3 -3
- package/dist/number-ticker.esm.js +22 -43
- package/dist/odometer.cjs.js +1 -1
- package/dist/odometer.esm.js +5 -9
- package/dist/orbiter.cjs.js +13 -13
- package/dist/orbiter.esm.js +79 -90
- package/dist/{overlayManager-5bbd4dc3.mjs → overlayManager-BJjU1VA8.mjs} +4 -5
- package/dist/{overlayManager-0eda4e08.js → overlayManager-CSy3fJmJ.js} +1 -1
- package/dist/pagination.cjs.js +2 -2
- package/dist/pagination.esm.js +14 -18
- package/dist/{panel-group-a376cc5e.mjs → panel-group-8sVNnGxg.mjs} +24 -46
- package/dist/panel-group-CaD0_KQf.js +36 -0
- package/dist/panel-group.cjs.js +1 -1
- package/dist/panel-group.esm.js +2 -5
- package/dist/panel.cjs.js +4 -4
- package/dist/panel.esm.js +8 -10
- package/dist/password-field.cjs.js +9 -9
- package/dist/password-field.esm.js +62 -82
- package/dist/pin-input.cjs.js +3 -3
- package/dist/pin-input.esm.js +33 -39
- package/dist/placement-grid.cjs.js +4 -4
- package/dist/placement-grid.esm.js +108 -131
- package/dist/plugin-panel.cjs.js +7 -7
- package/dist/plugin-panel.esm.js +13 -15
- package/dist/popover.cjs.js +2 -2
- package/dist/popover.esm.js +21 -31
- package/dist/portal-DgpQ3Jo1.js +1 -0
- package/dist/{portal-fe73e5cc.mjs → portal-bR42gHvG.mjs} +43 -48
- package/dist/portal.cjs.js +2 -2
- package/dist/portal.esm.js +10 -19
- package/dist/{positioner-e9770c66.mjs → positioner-D0VGxtYU.mjs} +189 -209
- package/dist/positioner-D_fqyx_j.js +1 -0
- package/dist/positioner.cjs.js +2 -2
- package/dist/positioner.esm.js +11 -18
- package/dist/presence.cjs.js +1 -1
- package/dist/presence.esm.js +7 -13
- package/dist/progress.cjs.js +1 -1
- package/dist/progress.esm.js +5 -9
- package/dist/quick-actions.cjs.js +6 -6
- package/dist/quick-actions.esm.js +52 -62
- package/dist/radio-group.cjs.js +13 -13
- package/dist/radio-group.esm.js +39 -51
- package/dist/radio.cjs.js +1 -1
- package/dist/radio.esm.js +5 -9
- package/dist/rating.cjs.js +1 -1
- package/dist/rating.esm.js +12 -23
- package/dist/{roving-focus-group-4350c9a7.mjs → roving-focus-group-Dbm1Jko_.mjs} +3 -6
- package/dist/roving-focus-group.cjs.js +1 -1
- package/dist/roving-focus-group.esm.js +3 -5
- package/dist/runtime-CTaOSmBj.js +1 -0
- package/dist/{runtime-161f68a2.mjs → runtime-D1gFh1fS.mjs} +338 -366
- package/dist/runtime.cjs.js +1 -1
- package/dist/runtime.esm.js +6 -6
- package/dist/scroll-area.cjs.js +3 -3
- package/dist/scroll-area.esm.js +38 -46
- package/dist/{scroll-lock-31da444f.mjs → scroll-lock-LfqXXqsu.mjs} +5 -9
- package/dist/section.cjs.js +1 -1
- package/dist/section.esm.js +1 -1
- package/dist/select.cjs.js +7 -7
- package/dist/select.esm.js +67 -97
- package/dist/selection-popup.cjs.js +1 -1
- package/dist/selection-popup.esm.js +8 -15
- package/dist/separator.cjs.js +1 -1
- package/dist/separator.esm.js +1 -1
- package/dist/sidebar.cjs.js +18 -18
- package/dist/sidebar.esm.js +117 -139
- package/dist/skeleton.cjs.js +11 -11
- package/dist/skeleton.esm.js +27 -24
- package/dist/slider.cjs.js +1 -1
- package/dist/slider.esm.js +6 -11
- package/dist/slot.cjs.js +4 -4
- package/dist/slot.esm.js +16 -19
- package/dist/sortable.cjs.js +45 -45
- package/dist/sortable.esm.js +421 -524
- package/dist/spinning-text.cjs.js +12 -12
- package/dist/spinning-text.esm.js +80 -92
- package/dist/split-button.cjs.js +4 -4
- package/dist/split-button.esm.js +77 -62
- package/dist/splitter.cjs.js +1 -1
- package/dist/splitter.esm.js +1 -1
- package/dist/stepper.cjs.js +8 -8
- package/dist/stepper.esm.js +32 -52
- package/dist/switch.cjs.js +7 -7
- package/dist/switch.esm.js +23 -31
- package/dist/table.cjs.js +2 -2
- package/dist/table.esm.js +46 -56
- package/dist/tabs.cjs.js +3 -3
- package/dist/tabs.esm.js +35 -55
- package/dist/tags-input.cjs.js +4 -4
- package/dist/tags-input.esm.js +45 -62
- package/dist/textarea.cjs.js +6 -6
- package/dist/textarea.esm.js +32 -41
- package/dist/time-field.cjs.js +4 -4
- package/dist/time-field.esm.js +70 -84
- package/dist/time-picker.cjs.js +22 -22
- package/dist/time-picker.esm.js +88 -110
- package/dist/timeline.cjs.js +1 -1
- package/dist/timeline.esm.js +3 -5
- package/dist/toast.cjs.js +2 -2
- package/dist/toast.esm.js +33 -47
- package/dist/toggle-group.cjs.js +6 -6
- package/dist/toggle-group.esm.js +85 -105
- package/dist/toggle.cjs.js +1 -1
- package/dist/toggle.esm.js +3 -5
- package/dist/toolbar.cjs.js +1 -1
- package/dist/toolbar.esm.js +13 -24
- package/dist/tooltip.cjs.js +2 -2
- package/dist/tooltip.esm.js +31 -42
- package/dist/transfer-list.cjs.js +19 -19
- package/dist/transfer-list.esm.js +98 -111
- package/dist/{tree-dcd74a4a.mjs → tree-B3kE8ESs.mjs} +55 -62
- package/dist/tree-Dx_kv_ih.js +39 -0
- package/dist/tree-item.cjs.js +2 -2
- package/dist/tree-item.esm.js +2 -3
- package/dist/tree.cjs.js +1 -1
- package/dist/tree.esm.js +2 -5
- package/dist/ui-button-Q0GNNWKC.mjs +665 -0
- package/dist/ui-button-rXQOS9QJ.js +521 -0
- package/dist/{icon-9e9da03b.js → ui-icon-BzVNC_lr.js} +4 -4
- package/dist/{icon-e2a85cc1.mjs → ui-icon-YI6lyuqU.mjs} +58 -65
- package/dist/visually-hidden.cjs.js +1 -1
- package/dist/visually-hidden.esm.js +1 -1
- package/dist/wizard.cjs.js +14 -14
- package/dist/wizard.esm.js +85 -105
- package/package.json +2 -2
- package/dist/date-time-utils-66480de4.js +0 -1
- package/dist/date-time-utils-a2c7af25.mjs +0 -307
- package/dist/dismissable-layer-193e3bed.js +0 -1
- package/dist/focus-scope-2b12b4e7.js +0 -1
- package/dist/listbox-308789a0.mjs +0 -210
- package/dist/listbox-ef2f708e.js +0 -46
- package/dist/panel-group-40254cdd.js +0 -36
- package/dist/portal-c69756c0.js +0 -1
- package/dist/positioner-33529bb8.js +0 -1
- package/dist/runtime-3f13807b.js +0 -1
- package/dist/tree-0a7a8d05.js +0 -39
- /package/dist/{collection-a2969ad2.js → collection-qv8A8rq4.js} +0 -0
- /package/dist/{menu-item-styles-27fdbac4.mjs → menu-item-styles-CZiPwPwl.mjs} +0 -0
- /package/dist/{menu-item-styles-83ad1e22.js → menu-item-styles-CbNUEwP2.js} +0 -0
- /package/dist/{roving-focus-group-5c059bf9.js → roving-focus-group-BdJ_4Njm.js} +0 -0
- /package/dist/{scroll-lock-d7b0df21.js → scroll-lock-BX6e3Ced.js} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { E as
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
1
|
+
import { E as u } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
|
+
import { e as h } from "./positioner-D0VGxtYU.mjs";
|
|
3
|
+
const d = `
|
|
4
4
|
:host {
|
|
5
5
|
position: fixed;
|
|
6
6
|
inset: 0;
|
|
@@ -203,41 +203,38 @@ const f = `
|
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
`;
|
|
206
|
-
function
|
|
207
|
-
if (
|
|
208
|
-
|
|
209
|
-
const e = Number(i);
|
|
206
|
+
function c(o, t) {
|
|
207
|
+
if (o == null || o === "") return t;
|
|
208
|
+
const e = Number(o);
|
|
210
209
|
return Number.isFinite(e) ? e : t;
|
|
211
210
|
}
|
|
212
|
-
function
|
|
213
|
-
if (
|
|
214
|
-
|
|
215
|
-
const e = i.trim().toLowerCase();
|
|
211
|
+
function a(o, t) {
|
|
212
|
+
if (o == null) return t;
|
|
213
|
+
const e = o.trim().toLowerCase();
|
|
216
214
|
return e !== "false" && e !== "0" && e !== "off";
|
|
217
215
|
}
|
|
218
|
-
function
|
|
219
|
-
if (!document.body.contains(
|
|
220
|
-
|
|
221
|
-
const t = window.getComputedStyle(i);
|
|
216
|
+
function b(o) {
|
|
217
|
+
if (!document.body.contains(o)) return !1;
|
|
218
|
+
const t = window.getComputedStyle(o);
|
|
222
219
|
return !(t.display === "none" || t.visibility === "hidden" || Number.parseFloat(t.opacity || "1") <= 0);
|
|
223
220
|
}
|
|
224
|
-
function
|
|
225
|
-
return
|
|
221
|
+
function f(o) {
|
|
222
|
+
return o === "top" || o === "bottom" ? o : "auto";
|
|
226
223
|
}
|
|
227
|
-
function
|
|
228
|
-
return
|
|
224
|
+
function p(o) {
|
|
225
|
+
return o === "start" || o === "end" ? o : "center";
|
|
229
226
|
}
|
|
230
|
-
function
|
|
231
|
-
const e =
|
|
227
|
+
function g(o, t) {
|
|
228
|
+
const e = o === "top" ? "top" : "bottom";
|
|
232
229
|
return t === "start" ? `${e}-start` : t === "end" ? `${e}-end` : e;
|
|
233
230
|
}
|
|
234
|
-
function
|
|
231
|
+
function _(o) {
|
|
235
232
|
const t = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])', e = [];
|
|
236
|
-
return
|
|
237
|
-
|
|
233
|
+
return o.forEach((i) => {
|
|
234
|
+
i instanceof HTMLElement && (i.matches(t) && e.push(i), e.push(...Array.from(i.querySelectorAll(t))));
|
|
238
235
|
}), Array.from(new Set(e));
|
|
239
236
|
}
|
|
240
|
-
class
|
|
237
|
+
class m extends u {
|
|
241
238
|
constructor() {
|
|
242
239
|
super(...arguments), this._anchor = null, this._panel = null, this._toolbarSlot = null, this._defaultSlot = null, this._raf = null, this._resizeObserver = null, this._mutationObserver = null, this._positioner = null, this._positionerPlacement = null, this._positionerOffset = 0, this._globalListenersBound = !1, this._isOpen = !1, this._closeReason = "programmatic", this._onWindowChangeBound = this._onWindowChange.bind(this), this._onDocumentPointerDownBound = this._onDocumentPointerDown.bind(this), this._onDocumentKeyDownBound = this._onDocumentKeyDown.bind(this), this._onPanelKeyDownBound = this._onPanelKeyDown.bind(this), this._onSlotChangeBound = this._onSlotChange.bind(this);
|
|
243
240
|
}
|
|
@@ -265,11 +262,10 @@ class w extends c {
|
|
|
265
262
|
super.connectedCallback(), this._syncAnchorFromAttribute(), this._syncOpenState(), this._schedulePosition();
|
|
266
263
|
}
|
|
267
264
|
disconnectedCallback() {
|
|
268
|
-
|
|
269
|
-
this._unbindGlobalListeners(), this._teardownObservers(), (t = this._positioner) == null || t.destroy(), this._positioner = null, this._raf != null && (cancelAnimationFrame(this._raf), this._raf = null), super.disconnectedCallback();
|
|
265
|
+
this._unbindGlobalListeners(), this._teardownObservers(), this._positioner?.destroy(), this._positioner = null, this._raf != null && (cancelAnimationFrame(this._raf), this._raf = null), super.disconnectedCallback();
|
|
270
266
|
}
|
|
271
|
-
attributeChangedCallback(t, e,
|
|
272
|
-
if (e !==
|
|
267
|
+
attributeChangedCallback(t, e, i) {
|
|
268
|
+
if (e !== i) {
|
|
273
269
|
if (t === "anchor-id") {
|
|
274
270
|
this._syncAnchorFromAttribute(), this.hasAttribute("open") && !this._anchor && this._requestClose("anchor-missing"), this._schedulePosition();
|
|
275
271
|
return;
|
|
@@ -294,8 +290,7 @@ class w extends c {
|
|
|
294
290
|
}
|
|
295
291
|
}
|
|
296
292
|
showForAnchorId(t) {
|
|
297
|
-
if (this.hasAttribute("disabled") || !t)
|
|
298
|
-
return;
|
|
293
|
+
if (this.hasAttribute("disabled") || !t) return;
|
|
299
294
|
const e = document.getElementById(t);
|
|
300
295
|
if (!e) {
|
|
301
296
|
this._requestClose("anchor-missing");
|
|
@@ -313,7 +308,6 @@ class w extends c {
|
|
|
313
308
|
this.hasAttribute("open") && (this._closeReason = t, this.removeAttribute("open"));
|
|
314
309
|
}
|
|
315
310
|
_syncOpenState() {
|
|
316
|
-
var e;
|
|
317
311
|
const t = this.hasAttribute("open") && !this.hasAttribute("headless") && !this.hasAttribute("disabled");
|
|
318
312
|
if (t === this._isOpen) {
|
|
319
313
|
t && this._schedulePosition();
|
|
@@ -323,7 +317,7 @@ class w extends c {
|
|
|
323
317
|
this._bindGlobalListeners(), this._ensureObservers(), this._dispatchOpenEvents(), this._schedulePosition();
|
|
324
318
|
return;
|
|
325
319
|
}
|
|
326
|
-
this._unbindGlobalListeners(), this._teardownObservers(),
|
|
320
|
+
this._unbindGlobalListeners(), this._teardownObservers(), this._positioner?.destroy(), this._positioner = null, this._positionerPlacement = null, this._positionerOffset = 0, this._raf != null && (cancelAnimationFrame(this._raf), this._raf = null), this._dispatchCloseEvents(this._closeReason), this._closeReason = "programmatic";
|
|
327
321
|
}
|
|
328
322
|
_dispatchOpenEvents() {
|
|
329
323
|
this.dispatchEvent(new CustomEvent("open", { bubbles: !0, composed: !0 })), this.dispatchEvent(
|
|
@@ -350,8 +344,7 @@ class w extends c {
|
|
|
350
344
|
);
|
|
351
345
|
}
|
|
352
346
|
_requestClose(t) {
|
|
353
|
-
if (!this.hasAttribute("open"))
|
|
354
|
-
return;
|
|
347
|
+
if (!this.hasAttribute("open")) return;
|
|
355
348
|
const e = new CustomEvent("request-close", {
|
|
356
349
|
detail: { reason: t },
|
|
357
350
|
bubbles: !0,
|
|
@@ -359,13 +352,13 @@ class w extends c {
|
|
|
359
352
|
cancelable: !0
|
|
360
353
|
});
|
|
361
354
|
this.dispatchEvent(e);
|
|
362
|
-
const
|
|
355
|
+
const i = new CustomEvent("ui-request-close", {
|
|
363
356
|
detail: { reason: t },
|
|
364
357
|
bubbles: !0,
|
|
365
358
|
composed: !0,
|
|
366
359
|
cancelable: !0
|
|
367
360
|
});
|
|
368
|
-
this.dispatchEvent(
|
|
361
|
+
this.dispatchEvent(i), !(e.defaultPrevented || i.defaultPrevented) && this.closeToolbar(t);
|
|
369
362
|
}
|
|
370
363
|
_syncAnchorFromAttribute() {
|
|
371
364
|
const t = this.getAttribute("anchor-id");
|
|
@@ -416,25 +409,22 @@ class w extends c {
|
|
|
416
409
|
this._globalListenersBound && (window.removeEventListener("scroll", this._onWindowChangeBound, !0), window.removeEventListener("resize", this._onWindowChangeBound), document.removeEventListener("pointerdown", this._onDocumentPointerDownBound, !0), document.removeEventListener("keydown", this._onDocumentKeyDownBound, !0), this._globalListenersBound = !1);
|
|
417
410
|
}
|
|
418
411
|
_position() {
|
|
419
|
-
|
|
420
|
-
if (!this.hasAttribute("open") || this.hasAttribute("headless") || this.hasAttribute("disabled"))
|
|
421
|
-
return;
|
|
412
|
+
if (!this.hasAttribute("open") || this.hasAttribute("headless") || this.hasAttribute("disabled")) return;
|
|
422
413
|
if (!this._anchor) {
|
|
423
414
|
this._requestClose("anchor-missing");
|
|
424
415
|
return;
|
|
425
416
|
}
|
|
426
|
-
if (!
|
|
417
|
+
if (!b(this._anchor)) {
|
|
427
418
|
this._requestClose("anchor-hidden");
|
|
428
419
|
return;
|
|
429
420
|
}
|
|
430
|
-
if (!this._panel)
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
(s = this._positioner) == null || s.destroy(), this._positioner = b({
|
|
421
|
+
if (!this._panel) return;
|
|
422
|
+
const t = Math.max(0, c(this.getAttribute("offset"), 8)), e = f(this.getAttribute("placement")), i = p(this.getAttribute("align")), r = g(e, i);
|
|
423
|
+
if (!this._positioner || this._positionerPlacement !== r || this._positionerOffset !== t) {
|
|
424
|
+
this._positioner?.destroy(), this._positioner = h({
|
|
435
425
|
anchor: this._anchor,
|
|
436
426
|
floating: this._panel,
|
|
437
|
-
placement:
|
|
427
|
+
placement: r,
|
|
438
428
|
strategy: "fixed",
|
|
439
429
|
offset: t,
|
|
440
430
|
flip: !0,
|
|
@@ -447,72 +437,57 @@ class w extends c {
|
|
|
447
437
|
observeLayoutShift: !1,
|
|
448
438
|
observeAnchorResize: !1,
|
|
449
439
|
observeFloatingResize: !1,
|
|
450
|
-
onUpdate: (
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
this.style.setProperty("--ui-floating-toolbar-origin-x", o === "start" ? "0%" : o === "end" ? "100%" : "50%"), (u = this._panel) == null || u.setAttribute("data-side", d);
|
|
440
|
+
onUpdate: (s) => {
|
|
441
|
+
const l = s.placement.startsWith("top") ? "top" : "bottom";
|
|
442
|
+
this.style.setProperty("--ui-floating-toolbar-origin-x", i === "start" ? "0%" : i === "end" ? "100%" : "50%"), this._panel?.setAttribute("data-side", l);
|
|
454
443
|
}
|
|
455
|
-
}), this._positionerPlacement =
|
|
444
|
+
}), this._positionerPlacement = r, this._positionerOffset = t;
|
|
456
445
|
return;
|
|
457
446
|
}
|
|
458
|
-
|
|
447
|
+
this._positioner?.update();
|
|
459
448
|
}
|
|
460
449
|
_onWindowChange() {
|
|
461
450
|
this.hasAttribute("open") && this._schedulePosition();
|
|
462
451
|
}
|
|
463
452
|
_onDocumentPointerDown(t) {
|
|
464
|
-
if (!this.hasAttribute("open") || !
|
|
465
|
-
return;
|
|
453
|
+
if (!this.hasAttribute("open") || !a(this.getAttribute("close-on-outside"), !0)) return;
|
|
466
454
|
const e = t.composedPath();
|
|
467
455
|
e.includes(this) || this._anchor && e.includes(this._anchor) || this._requestClose("outside");
|
|
468
456
|
}
|
|
469
457
|
_onDocumentKeyDown(t) {
|
|
470
|
-
this.hasAttribute("open") && t.key === "Escape" &&
|
|
458
|
+
this.hasAttribute("open") && t.key === "Escape" && a(this.getAttribute("close-on-escape"), !0) && (t.preventDefault(), this._requestClose("escape"));
|
|
471
459
|
}
|
|
472
460
|
_onPanelKeyDown(t) {
|
|
473
|
-
if (!this._panel || !["ArrowRight", "ArrowLeft", "Home", "End"].includes(t.key))
|
|
474
|
-
return;
|
|
461
|
+
if (!this._panel || !["ArrowRight", "ArrowLeft", "Home", "End"].includes(t.key)) return;
|
|
475
462
|
const e = this._getFocusableItems();
|
|
476
|
-
if (e.length === 0)
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
const s = e[r];
|
|
463
|
+
if (e.length === 0) return;
|
|
464
|
+
const i = document.activeElement, r = i ? e.indexOf(i) : -1;
|
|
465
|
+
let n = r;
|
|
466
|
+
t.key === "Home" ? n = 0 : t.key === "End" ? n = e.length - 1 : t.key === "ArrowRight" ? n = r < 0 ? 0 : (r + 1) % e.length : t.key === "ArrowLeft" && (n = r < 0 ? e.length - 1 : (r - 1 + e.length) % e.length);
|
|
467
|
+
const s = e[n];
|
|
482
468
|
s && (t.preventDefault(), s.focus());
|
|
483
469
|
}
|
|
484
470
|
_getFocusableItems() {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
return y([...t, ...e]);
|
|
471
|
+
const t = this._toolbarSlot?.assignedElements({ flatten: !0 }) || [], e = this._defaultSlot?.assignedElements({ flatten: !0 }) || [];
|
|
472
|
+
return _([...t, ...e]);
|
|
488
473
|
}
|
|
489
474
|
_onSlotChange() {
|
|
490
475
|
this._syncRowVisibility(), this._schedulePosition();
|
|
491
476
|
}
|
|
492
477
|
_syncRowVisibility() {
|
|
493
|
-
var r, s;
|
|
494
478
|
const t = this.root.querySelector(".row-toolbar"), e = this.root.querySelector(".row-default");
|
|
495
|
-
if (!t || !e)
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
var l;
|
|
499
|
-
return a.nodeType === Node.TEXT_NODE ? !!((l = a.textContent) != null && l.trim()) : a.nodeType === Node.ELEMENT_NODE;
|
|
500
|
-
}), n = (((s = this._defaultSlot) == null ? void 0 : s.assignedNodes({ flatten: !0 })) || []).some((a) => {
|
|
501
|
-
var l;
|
|
502
|
-
return a.nodeType === Node.TEXT_NODE ? !!((l = a.textContent) != null && l.trim()) : a.nodeType === Node.ELEMENT_NODE;
|
|
503
|
-
});
|
|
504
|
-
o ? t.removeAttribute("hidden") : t.setAttribute("hidden", ""), n ? e.removeAttribute("hidden") : e.setAttribute("hidden", "");
|
|
479
|
+
if (!t || !e) return;
|
|
480
|
+
const i = (this._toolbarSlot?.assignedNodes({ flatten: !0 }) || []).some((n) => n.nodeType === Node.TEXT_NODE ? !!n.textContent?.trim() : n.nodeType === Node.ELEMENT_NODE), r = (this._defaultSlot?.assignedNodes({ flatten: !0 }) || []).some((n) => n.nodeType === Node.TEXT_NODE ? !!n.textContent?.trim() : n.nodeType === Node.ELEMENT_NODE);
|
|
481
|
+
i ? t.removeAttribute("hidden") : t.setAttribute("hidden", ""), r ? e.removeAttribute("hidden") : e.setAttribute("hidden", "");
|
|
505
482
|
}
|
|
506
483
|
_syncPanelA11y() {
|
|
507
|
-
if (!this._panel)
|
|
508
|
-
return;
|
|
484
|
+
if (!this._panel) return;
|
|
509
485
|
const t = this.getAttribute("aria-labelledby"), e = this.getAttribute("aria-label") || (t ? null : "Floating toolbar");
|
|
510
486
|
t ? this._panel.setAttribute("aria-labelledby", t) : this._panel.removeAttribute("aria-labelledby"), e ? this._panel.setAttribute("aria-label", e) : this._panel.removeAttribute("aria-label");
|
|
511
487
|
}
|
|
512
488
|
render() {
|
|
513
|
-
var t, e, o, n, r, s;
|
|
514
489
|
this.setContent(`
|
|
515
|
-
<style>${
|
|
490
|
+
<style>${d}</style>
|
|
516
491
|
<section class="panel" part="panel" role="toolbar" aria-orientation="horizontal" tabindex="-1">
|
|
517
492
|
<div class="row row-toolbar" part="row-toolbar">
|
|
518
493
|
<slot name="toolbar"></slot>
|
|
@@ -521,10 +496,10 @@ class w extends c {
|
|
|
521
496
|
<slot></slot>
|
|
522
497
|
</div>
|
|
523
498
|
</section>
|
|
524
|
-
`), this._panel = this.root.querySelector(".panel"), this._toolbarSlot = this.root.querySelector('slot[name="toolbar"]'), this._defaultSlot = this.root.querySelector("slot:not([name])"),
|
|
499
|
+
`), this._panel = this.root.querySelector(".panel"), this._toolbarSlot = this.root.querySelector('slot[name="toolbar"]'), this._defaultSlot = this.root.querySelector("slot:not([name])"), this._panel?.removeEventListener("keydown", this._onPanelKeyDownBound), this._panel?.addEventListener("keydown", this._onPanelKeyDownBound), this._toolbarSlot?.removeEventListener("slotchange", this._onSlotChangeBound), this._defaultSlot?.removeEventListener("slotchange", this._onSlotChangeBound), this._toolbarSlot?.addEventListener("slotchange", this._onSlotChangeBound), this._defaultSlot?.addEventListener("slotchange", this._onSlotChangeBound), this._syncPanelA11y(), this._syncRowVisibility(), this._refreshObservers(), this._schedulePosition();
|
|
525
500
|
}
|
|
526
501
|
}
|
|
527
|
-
typeof customElements < "u" && !customElements.get("ui-floating-toolbar") && customElements.define("ui-floating-toolbar",
|
|
502
|
+
typeof customElements < "u" && !customElements.get("ui-floating-toolbar") && customElements.define("ui-floating-toolbar", m);
|
|
528
503
|
export {
|
|
529
|
-
|
|
504
|
+
m as UIFloatingToolbar
|
|
530
505
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const f=[],b=["a[href]","area[href]",'input:not([type="hidden"])',"select","textarea","button","iframe","[tabindex]",'[contenteditable="true"]'].join(", ");function h(){const t=f.filter(e=>!e.paused);return t.length?t[t.length-1]:null}function y(t){return!(t.hasAttribute("disabled")||t.getAttribute("aria-hidden")==="true"||t.hasAttribute("hidden")||t.getAttribute("tabindex")==="-1")}function a(t){return Array.from(t.querySelectorAll(b)).filter(y)}function d(t){t.hasAttribute("tabindex")||t.setAttribute("tabindex","-1")}function m(t){return typeof t=="function"?t():t??null}function s(t){if(!t||!t.isConnected)return!1;try{return t.focus(),!0}catch{return!1}}function F(t){return t.querySelector('[aria-selected="true"], [data-selected="true"], [selected], [checked], [aria-current="true"]')||null}function E(t){if(!t.options.inertOthers||typeof document>"u"||!document.body)return;const e=Array.from(document.body.children);t.inerted=e.filter(r=>r!==t.options.node&&!r.contains(t.options.node)).map(r=>{const c=r.hasAttribute("inert");return c||r.setAttribute("inert",""),{element:r,hadInert:c}})}function v(t){t.inerted.forEach(({element:e,hadInert:r})=>{r||e.removeAttribute("inert")}),t.inerted=[]}function A(t){if(!(t.node instanceof HTMLElement))throw new Error("createFocusScope requires a valid HTMLElement node");const e={id:Symbol("focus-scope"),options:{trapped:!0,loop:!0,restoreFocus:!0,autoFocus:"first",inertOthers:!1,...t},paused:!1,previouslyFocused:document.activeElement instanceof HTMLElement?document.activeElement:null,inerted:[],onKeyDown:()=>{},onFocusIn:()=>{}},r=()=>{const n=a(e.options.node)[0]||null;s(n)||(d(e.options.node),s(e.options.node))},c=()=>{const n=a(e.options.node),o=n.length?n[n.length-1]:null;s(o)||(d(e.options.node),s(e.options.node))},u=()=>{const n=m(e.options.initialFocus);if(s(n))return;const o=e.options.autoFocus;if(o!=="none"){if(o==="container"){d(e.options.node),s(e.options.node);return}if(o==="selected"){const i=F(e.options.node);if(s(i))return}r()}};return e.onKeyDown=n=>{if(e.paused||h()?.id!==e.id||!e.options.trapped||n.key!=="Tab")return;const o=a(e.options.node);if(!o.length){n.preventDefault(),u();return}const i=document.activeElement instanceof HTMLElement?document.activeElement:null;if(!i||!e.options.node.contains(i)){n.preventDefault(),u();return}const l=o[0],p=o[o.length-1];if(n.shiftKey){(i===l||i===e.options.node)&&(n.preventDefault(),e.options.loop&&s(p));return}i===p&&(n.preventDefault(),e.options.loop&&s(l))},e.onFocusIn=n=>{if(e.paused||h()?.id!==e.id||!e.options.trapped)return;const o=n.target;(typeof n.composedPath=="function"?n.composedPath():[]).includes(e.options.node)||o instanceof Node&&(e.options.node.contains(o)||u())},f.push(e),E(e),document.addEventListener("keydown",e.onKeyDown,!0),document.addEventListener("focusin",e.onFocusIn,!0),u(),{destroy(){const n=f.findIndex(i=>i.id===e.id);if(n>=0&&f.splice(n,1),document.removeEventListener("keydown",e.onKeyDown,!0),document.removeEventListener("focusin",e.onFocusIn,!0),v(e),!e.options.restoreFocus)return;const o=m(e.options.finalFocus)||e.previouslyFocused;s(o)},focusFirst:r,focusLast:c,focusInitial:u,pause(){e.paused=!0},resume(){e.paused=!1}}}exports.createFocusScope=A;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const f = [], b = [
|
|
2
2
|
"a[href]",
|
|
3
3
|
"area[href]",
|
|
4
4
|
'input:not([type="hidden"])',
|
|
@@ -9,55 +9,53 @@ const a = [], y = [
|
|
|
9
9
|
"[tabindex]",
|
|
10
10
|
'[contenteditable="true"]'
|
|
11
11
|
].join(", ");
|
|
12
|
-
function
|
|
13
|
-
const t =
|
|
12
|
+
function h() {
|
|
13
|
+
const t = f.filter((e) => !e.paused);
|
|
14
14
|
return t.length ? t[t.length - 1] : null;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function y(t) {
|
|
17
17
|
return !(t.hasAttribute("disabled") || t.getAttribute("aria-hidden") === "true" || t.hasAttribute("hidden") || t.getAttribute("tabindex") === "-1");
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return Array.from(t.querySelectorAll(
|
|
19
|
+
function a(t) {
|
|
20
|
+
return Array.from(t.querySelectorAll(b)).filter(y);
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function d(t) {
|
|
23
23
|
t.hasAttribute("tabindex") || t.setAttribute("tabindex", "-1");
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function m(t) {
|
|
26
26
|
return typeof t == "function" ? t() : t ?? null;
|
|
27
27
|
}
|
|
28
28
|
function s(t) {
|
|
29
|
-
if (!t || !t.isConnected)
|
|
30
|
-
return !1;
|
|
29
|
+
if (!t || !t.isConnected) return !1;
|
|
31
30
|
try {
|
|
32
31
|
return t.focus(), !0;
|
|
33
32
|
} catch {
|
|
34
33
|
return !1;
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
|
-
function
|
|
36
|
+
function F(t) {
|
|
38
37
|
return t.querySelector(
|
|
39
38
|
'[aria-selected="true"], [data-selected="true"], [selected], [checked], [aria-current="true"]'
|
|
40
39
|
) || null;
|
|
41
40
|
}
|
|
42
|
-
function
|
|
43
|
-
if (!t.options.inertOthers || typeof document > "u" || !document.body)
|
|
44
|
-
return;
|
|
41
|
+
function E(t) {
|
|
42
|
+
if (!t.options.inertOthers || typeof document > "u" || !document.body) return;
|
|
45
43
|
const e = Array.from(document.body.children);
|
|
46
44
|
t.inerted = e.filter((r) => r !== t.options.node && !r.contains(t.options.node)).map((r) => {
|
|
47
|
-
const
|
|
48
|
-
return
|
|
45
|
+
const c = r.hasAttribute("inert");
|
|
46
|
+
return c || r.setAttribute("inert", ""), { element: r, hadInert: c };
|
|
49
47
|
});
|
|
50
48
|
}
|
|
51
|
-
function
|
|
49
|
+
function v(t) {
|
|
52
50
|
t.inerted.forEach(({ element: e, hadInert: r }) => {
|
|
53
51
|
r || e.removeAttribute("inert");
|
|
54
52
|
}), t.inerted = [];
|
|
55
53
|
}
|
|
56
|
-
function
|
|
54
|
+
function A(t) {
|
|
57
55
|
if (!(t.node instanceof HTMLElement))
|
|
58
56
|
throw new Error("createFocusScope requires a valid HTMLElement node");
|
|
59
57
|
const e = {
|
|
60
|
-
id: Symbol("focus-scope"),
|
|
58
|
+
id: /* @__PURE__ */ Symbol("focus-scope"),
|
|
61
59
|
options: {
|
|
62
60
|
trapped: !0,
|
|
63
61
|
loop: !0,
|
|
@@ -74,34 +72,30 @@ function L(t) {
|
|
|
74
72
|
onFocusIn: () => {
|
|
75
73
|
}
|
|
76
74
|
}, r = () => {
|
|
77
|
-
const n =
|
|
78
|
-
s(n) || (
|
|
79
|
-
},
|
|
80
|
-
const n =
|
|
81
|
-
s(o) || (
|
|
75
|
+
const n = a(e.options.node)[0] || null;
|
|
76
|
+
s(n) || (d(e.options.node), s(e.options.node));
|
|
77
|
+
}, c = () => {
|
|
78
|
+
const n = a(e.options.node), o = n.length ? n[n.length - 1] : null;
|
|
79
|
+
s(o) || (d(e.options.node), s(e.options.node));
|
|
82
80
|
}, u = () => {
|
|
83
|
-
const n =
|
|
84
|
-
if (s(n))
|
|
85
|
-
return;
|
|
81
|
+
const n = m(e.options.initialFocus);
|
|
82
|
+
if (s(n)) return;
|
|
86
83
|
const o = e.options.autoFocus;
|
|
87
84
|
if (o !== "none") {
|
|
88
85
|
if (o === "container") {
|
|
89
|
-
|
|
86
|
+
d(e.options.node), s(e.options.node);
|
|
90
87
|
return;
|
|
91
88
|
}
|
|
92
89
|
if (o === "selected") {
|
|
93
|
-
const i =
|
|
94
|
-
if (s(i))
|
|
95
|
-
return;
|
|
90
|
+
const i = F(e.options.node);
|
|
91
|
+
if (s(i)) return;
|
|
96
92
|
}
|
|
97
93
|
r();
|
|
98
94
|
}
|
|
99
95
|
};
|
|
100
96
|
return e.onKeyDown = (n) => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return;
|
|
104
|
-
const o = d(e.options.node);
|
|
97
|
+
if (e.paused || h()?.id !== e.id || !e.options.trapped || n.key !== "Tab") return;
|
|
98
|
+
const o = a(e.options.node);
|
|
105
99
|
if (!o.length) {
|
|
106
100
|
n.preventDefault(), u();
|
|
107
101
|
return;
|
|
@@ -111,28 +105,25 @@ function L(t) {
|
|
|
111
105
|
n.preventDefault(), u();
|
|
112
106
|
return;
|
|
113
107
|
}
|
|
114
|
-
const
|
|
108
|
+
const l = o[0], p = o[o.length - 1];
|
|
115
109
|
if (n.shiftKey) {
|
|
116
|
-
(i ===
|
|
110
|
+
(i === l || i === e.options.node) && (n.preventDefault(), e.options.loop && s(p));
|
|
117
111
|
return;
|
|
118
112
|
}
|
|
119
|
-
i === p && (n.preventDefault(), e.options.loop && s(
|
|
113
|
+
i === p && (n.preventDefault(), e.options.loop && s(l));
|
|
120
114
|
}, e.onFocusIn = (n) => {
|
|
121
|
-
|
|
122
|
-
if (e.paused || ((c = m()) == null ? void 0 : c.id) !== e.id || !e.options.trapped)
|
|
123
|
-
return;
|
|
115
|
+
if (e.paused || h()?.id !== e.id || !e.options.trapped) return;
|
|
124
116
|
const o = n.target;
|
|
125
117
|
(typeof n.composedPath == "function" ? n.composedPath() : []).includes(e.options.node) || o instanceof Node && (e.options.node.contains(o) || u());
|
|
126
|
-
},
|
|
118
|
+
}, f.push(e), E(e), document.addEventListener("keydown", e.onKeyDown, !0), document.addEventListener("focusin", e.onFocusIn, !0), u(), {
|
|
127
119
|
destroy() {
|
|
128
|
-
const n =
|
|
129
|
-
if (n >= 0 &&
|
|
130
|
-
|
|
131
|
-
const o = b(e.options.finalFocus) || e.previouslyFocused;
|
|
120
|
+
const n = f.findIndex((i) => i.id === e.id);
|
|
121
|
+
if (n >= 0 && f.splice(n, 1), document.removeEventListener("keydown", e.onKeyDown, !0), document.removeEventListener("focusin", e.onFocusIn, !0), v(e), !e.options.restoreFocus) return;
|
|
122
|
+
const o = m(e.options.finalFocus) || e.previouslyFocused;
|
|
132
123
|
s(o);
|
|
133
124
|
},
|
|
134
125
|
focusFirst: r,
|
|
135
|
-
focusLast:
|
|
126
|
+
focusLast: c,
|
|
136
127
|
focusInitial: u,
|
|
137
128
|
pause() {
|
|
138
129
|
e.paused = !0;
|
|
@@ -143,5 +134,5 @@ function L(t) {
|
|
|
143
134
|
};
|
|
144
135
|
}
|
|
145
136
|
export {
|
|
146
|
-
|
|
137
|
+
A as c
|
|
147
138
|
};
|
package/dist/focus-scope.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("./ElementBase-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("./ElementBase-EV6mVBUV.js"),n=require("./focus-scope-Bwug2gDv.js"),u=`
|
|
2
2
|
:host {
|
|
3
3
|
display: contents;
|
|
4
4
|
color-scheme: light dark;
|
|
5
5
|
}
|
|
6
|
-
`;function a(
|
|
6
|
+
`;function a(t){return t==="selected"||t==="container"||t==="none"?t:"first"}function o(t){if(t==null)return!1;const e=t.toLowerCase();return e!=="false"&&e!=="0"&&e!=="off"}class i extends c.ElementBase{constructor(){super(...arguments),this._scope=null,this._onKeyDown=e=>{if(e.key!=="Escape"||!this.hasAttribute("active"))return;const s=document.activeElement;s&&!this.contains(s)||this.dispatchEvent(new CustomEvent("escape",{detail:{originalEvent:e},bubbles:!0,composed:!0}))}}static get observedAttributes(){return["active","trapped","loop","restore-focus","auto-focus","inert-others","headless"]}connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this._onKeyDown,!0),this._syncScope()}disconnectedCallback(){document.removeEventListener("keydown",this._onKeyDown,!0),this._destroyScope(),super.disconnectedCallback()}attributeChangedCallback(e,s,r){s!==r&&this._syncScope()}get initialFocus(){return this.querySelector("[data-ui-initial-focus], [autofocus]")}get finalFocus(){return this.querySelector("[data-ui-final-focus]")}activate(){this.setAttribute("active","")}deactivate(){this.removeAttribute("active")}focusFirst(){this._scope?.focusFirst()}focusInitial(){this._scope?.focusInitial()}_destroyScope(){this._scope?.destroy(),this._scope=null}_syncScope(){if(this.isConnected){if(this.hasAttribute("headless")||!this.hasAttribute("active")){this._destroyScope();return}this._destroyScope(),this._scope=n.createFocusScope({node:this,trapped:!this.hasAttribute("trapped")||o(this.getAttribute("trapped")),loop:!this.hasAttribute("loop")||o(this.getAttribute("loop")),restoreFocus:!this.hasAttribute("restore-focus")||o(this.getAttribute("restore-focus")),autoFocus:a(this.getAttribute("auto-focus")),initialFocus:this.initialFocus,finalFocus:this.finalFocus,inertOthers:o(this.getAttribute("inert-others"))}),this.dispatchEvent(new CustomEvent("focus-scope-mount",{bubbles:!0,composed:!0}))}}render(){this.setContent(`<style>${u}</style><slot></slot>`)}shouldRenderOnAttributeChange(){return!1}}typeof customElements<"u"&&!customElements.get("ui-focus-scope")&&customElements.define("ui-focus-scope",i);exports.UIFocusScope=i;
|
package/dist/focus-scope.esm.js
CHANGED
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
import { E as r } from "./ElementBase-
|
|
2
|
-
import { c as n } from "./focus-scope-
|
|
1
|
+
import { E as r } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
|
+
import { c as n } from "./focus-scope-CmEsG5UZ.mjs";
|
|
3
3
|
const c = `
|
|
4
4
|
:host {
|
|
5
5
|
display: contents;
|
|
6
6
|
color-scheme: light dark;
|
|
7
7
|
}
|
|
8
8
|
`;
|
|
9
|
-
function u(
|
|
10
|
-
return
|
|
9
|
+
function u(t) {
|
|
10
|
+
return t === "selected" || t === "container" || t === "none" ? t : "first";
|
|
11
11
|
}
|
|
12
|
-
function o(
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return t !== "false" && t !== "0" && t !== "off";
|
|
12
|
+
function o(t) {
|
|
13
|
+
if (t == null) return !1;
|
|
14
|
+
const e = t.toLowerCase();
|
|
15
|
+
return e !== "false" && e !== "0" && e !== "off";
|
|
17
16
|
}
|
|
18
17
|
class a extends r {
|
|
19
18
|
constructor() {
|
|
20
|
-
super(...arguments), this._scope = null, this._onKeyDown = (
|
|
21
|
-
if (
|
|
22
|
-
return;
|
|
19
|
+
super(...arguments), this._scope = null, this._onKeyDown = (e) => {
|
|
20
|
+
if (e.key !== "Escape" || !this.hasAttribute("active")) return;
|
|
23
21
|
const s = document.activeElement;
|
|
24
22
|
s && !this.contains(s) || this.dispatchEvent(
|
|
25
23
|
new CustomEvent("escape", {
|
|
26
|
-
detail: { originalEvent:
|
|
24
|
+
detail: { originalEvent: e },
|
|
27
25
|
bubbles: !0,
|
|
28
26
|
composed: !0
|
|
29
27
|
})
|
|
@@ -39,7 +37,7 @@ class a extends r {
|
|
|
39
37
|
disconnectedCallback() {
|
|
40
38
|
document.removeEventListener("keydown", this._onKeyDown, !0), this._destroyScope(), super.disconnectedCallback();
|
|
41
39
|
}
|
|
42
|
-
attributeChangedCallback(
|
|
40
|
+
attributeChangedCallback(e, s, i) {
|
|
43
41
|
s !== i && this._syncScope();
|
|
44
42
|
}
|
|
45
43
|
get initialFocus() {
|
|
@@ -55,16 +53,13 @@ class a extends r {
|
|
|
55
53
|
this.removeAttribute("active");
|
|
56
54
|
}
|
|
57
55
|
focusFirst() {
|
|
58
|
-
|
|
59
|
-
(t = this._scope) == null || t.focusFirst();
|
|
56
|
+
this._scope?.focusFirst();
|
|
60
57
|
}
|
|
61
58
|
focusInitial() {
|
|
62
|
-
|
|
63
|
-
(t = this._scope) == null || t.focusInitial();
|
|
59
|
+
this._scope?.focusInitial();
|
|
64
60
|
}
|
|
65
61
|
_destroyScope() {
|
|
66
|
-
|
|
67
|
-
(t = this._scope) == null || t.destroy(), this._scope = null;
|
|
62
|
+
this._scope?.destroy(), this._scope = null;
|
|
68
63
|
}
|
|
69
64
|
_syncScope() {
|
|
70
65
|
if (this.isConnected) {
|