@editora/ui-core 0.1.19 → 0.1.21
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 +30 -29
- package/dist/color-picker.cjs.js +10 -10
- package/dist/color-picker.esm.js +190 -253
- 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-collection.d.ts.map +1 -1
- package/dist/components/ui-multi-select.d.ts.map +1 -1
- package/dist/components/ui-orbiter.d.ts.map +1 -1
- package/dist/components/ui-portal.d.ts.map +1 -1
- package/dist/components/ui-positioner.d.ts.map +1 -1
- package/dist/components/ui-skeleton.d.ts.map +1 -1
- package/dist/components/ui-sortable.d.ts +8 -0
- package/dist/components/ui-sortable.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-tabs.d.ts.map +1 -1
- package/dist/components/ui-textarea.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 +7 -7
- package/dist/date-time-picker.esm.js +115 -147
- 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 +5 -5
- package/dist/multi-select.esm.js +125 -137
- 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 +3 -3
- package/dist/portal.esm.js +20 -28
- 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 +22 -28
- package/dist/presence.cjs.js +1 -1
- package/dist/presence.esm.js +7 -13
- package/dist/primitives/auto-scroll.d.ts +9 -0
- package/dist/primitives/auto-scroll.d.ts.map +1 -0
- package/dist/primitives/selector.d.ts +4 -0
- package/dist/primitives/selector.d.ts.map +1 -0
- 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/selector-BvAh35ve.js +1 -0
- package/dist/selector-WI8pD7YO.mjs +18 -0
- 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 +79 -65
- package/dist/sortable.esm.js +714 -734
- 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 +8 -8
- package/dist/tabs.esm.js +89 -109
- package/dist/tags-input.cjs.js +4 -4
- package/dist/tags-input.esm.js +45 -62
- package/dist/textarea.cjs.js +10 -10
- package/dist/textarea.esm.js +49 -52
- 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 +31 -31
- package/dist/transfer-list.esm.js +114 -127
- 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 +1 @@
|
|
|
1
|
-
"use strict";class s extends HTMLElement{constructor(){super(),this._isRendering=!1,this._renderRequested=!1,this._renderScheduled=!1,this._hasRendered=!1,this._visibilityGuardApplied=!1,this._lastRenderedContent=null,this.root=this.attachShadow({mode:"open"})}connectedCallback(){if(!this._hasRendered&&!this._visibilityGuardApplied&&(this.style.getPropertyValue("visibility").trim()||(this.style.setProperty("visibility","hidden"),this._visibilityGuardApplied=!0)),!this._hasRendered){this._requestRender();return}this._scheduleRender()}disconnectedCallback(){try{if(typeof this.close=="function")try{this.close()}catch{}if(typeof this._cleanup=="function"){try{this._cleanup()}catch{}this._cleanup=void 0}if(typeof this.__menuCleanup=="function"){try{this.__menuCleanup()}catch{}this.__menuCleanup=null}const e=this._portalEl;if(e&&e.parentElement)try{e.parentElement.removeChild(e)}catch{}}catch{}}attributeChangedCallback(e,t,i){t!==i&&this.isConnected&&(e&&!this.shouldRenderOnAttributeChange(e,t??null,i??null)||this._scheduleRender())}shouldRenderOnAttributeChange(e,t,i){return!0}setContent(e,t){!
|
|
1
|
+
"use strict";class s extends HTMLElement{constructor(){super(),this._isRendering=!1,this._renderRequested=!1,this._renderScheduled=!1,this._hasRendered=!1,this._visibilityGuardApplied=!1,this._lastRenderedContent=null,this.root=this.attachShadow({mode:"open"})}connectedCallback(){if(!this._hasRendered&&!this._visibilityGuardApplied&&(this.style.getPropertyValue("visibility").trim()||(this.style.setProperty("visibility","hidden"),this._visibilityGuardApplied=!0)),!this._hasRendered){this._requestRender();return}this._scheduleRender()}disconnectedCallback(){try{if(typeof this.close=="function")try{this.close()}catch{}if(typeof this._cleanup=="function"){try{this._cleanup()}catch{}this._cleanup=void 0}if(typeof this.__menuCleanup=="function"){try{this.__menuCleanup()}catch{}this.__menuCleanup=null}const e=this._portalEl;if(e&&e.parentElement)try{e.parentElement.removeChild(e)}catch{}}catch{}}attributeChangedCallback(e,t,i){t!==i&&this.isConnected&&(e&&!this.shouldRenderOnAttributeChange(e,t??null,i??null)||this._scheduleRender())}shouldRenderOnAttributeChange(e,t,i){return!0}setContent(e,t){!t?.force&&this._lastRenderedContent===e||(this.root.innerHTML=e,this._lastRenderedContent=e)}invalidateContentCache(){this._lastRenderedContent=null}requestRender(){this._scheduleRender()}_scheduleRender(){this._renderScheduled||(this._renderScheduled=!0,queueMicrotask(()=>{this._renderScheduled=!1,this._requestRender()}))}_requestRender(){if(this._isRendering){this._renderRequested=!0;return}this._isRendering=!0;try{this.render()}finally{this._isRendering=!1,this._hasRendered||(this._hasRendered=!0,this._visibilityGuardApplied&&(this.style.removeProperty("visibility"),this._visibilityGuardApplied=!1))}this._renderRequested&&(this._renderRequested=!1,this._scheduleRender())}}exports.ElementBase=s;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class n extends HTMLElement {
|
|
2
2
|
constructor() {
|
|
3
3
|
super(), this._isRendering = !1, this._renderRequested = !1, this._renderScheduled = !1, this._hasRendered = !1, this._visibilityGuardApplied = !1, this._lastRenderedContent = null, this.root = this.attachShadow({ mode: "open" });
|
|
4
4
|
}
|
|
@@ -47,7 +47,7 @@ class r extends HTMLElement {
|
|
|
47
47
|
return !0;
|
|
48
48
|
}
|
|
49
49
|
setContent(e, t) {
|
|
50
|
-
!
|
|
50
|
+
!t?.force && this._lastRenderedContent === e || (this.root.innerHTML = e, this._lastRenderedContent = e);
|
|
51
51
|
}
|
|
52
52
|
invalidateContentCache() {
|
|
53
53
|
this._lastRenderedContent = null;
|
|
@@ -75,5 +75,5 @@ class r extends HTMLElement {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
export {
|
|
78
|
-
|
|
78
|
+
n as E
|
|
79
79
|
};
|
package/dist/accordion.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("./ElementBase-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("./ElementBase-EV6mVBUV.js"),p=`
|
|
2
2
|
ui-accordion[data-ui-accordion-root="true"] {
|
|
3
3
|
display: block;
|
|
4
4
|
overflow-anchor: none;
|
|
@@ -353,8 +353,8 @@
|
|
|
353
353
|
color: HighlightText;
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
|
-
`;function u(c){const i=Number(c);if(!Number.isFinite(i))return-1;const r=Math.trunc(i);return r>=0?r:-1}function m(c,i){if(c==null)return i;const r=c.toLowerCase();return r!=="false"&&r!=="0"&&r!=="no"}function v(c,i){if(!c)return[];if(!i){const o=u(c);return o>=0?[o]:[]}try{const o=JSON.parse(c);if(Array.isArray(o))return o.map(u).filter(e=>e>=0)}catch{}const r=u(c);return r>=0?[r]:[]}function h(c,i){return i?JSON.stringify(c):String(c[0]??-1)}function x(c,i="var(--base-card-radius, var(--ui-radius, 4px))"){if(!c||!c.trim())return i;const r=c.trim().toLowerCase();return r==="full"||r==="pill"?"999px":r==="square"||r==="none"?"0px":/^-?\d+(\.\d+)?$/.test(r)?`${r}px`:c.trim()}function y(c){return c instanceof HTMLElement&&c.hasAttribute("data-ui-accordion-item")}class g extends b.ElementBase{constructor(){super(),this._uid=`ui-accordion-${Math.random().toString(36).slice(2,8)}`,this._observer=null,this._panelResizeObserver=null,this._heightSyncRaf=0,this._syncingOpenAttr=!1,this._syncingDom=!1,this._syncingDomResetTimer=null,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onMutations=this._onMutations.bind(this)}static get observedAttributes(){return["open","multiple","collapsible","headless","shape","elevation","variant","size","tone","radius","indicator"]}connectedCallback(){super.connectedCallback(),this.setAttribute("data-ui-accordion-root","true"),this._syncHostStyles(),this.addEventListener("click",this._onClick),this.addEventListener("keydown",this._onKeyDown),this._observer=new MutationObserver(this._onMutations),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0}),typeof ResizeObserver<"u"&&(this._panelResizeObserver=new ResizeObserver(()=>{this._syncPanelHeights()}))}disconnectedCallback(){this.removeEventListener("click",this._onClick),this.removeEventListener("keydown",this._onKeyDown),this._observer&&(this._observer.disconnect(),this._observer=null),this._panelResizeObserver&&(this._panelResizeObserver.disconnect(),this._panelResizeObserver=null),this._heightSyncRaf&&(cancelAnimationFrame(this._heightSyncRaf),this._heightSyncRaf=0),this._syncingDomResetTimer!=null&&(clearTimeout(this._syncingDomResetTimer),this._syncingDomResetTimer=null),super.disconnectedCallback()}attributeChangedCallback(i,r,o){if(r!==o){if(i==="radius"||i==="shape"){this._syncHostStyles();return}if(this.isConnected){if(i==="open"){this._applyOpenState();return}this.requestRender()}}}get multiple(){return this.hasAttribute("multiple")}set multiple(i){i!==this.multiple&&(i?this.setAttribute("multiple",""):this.removeAttribute("multiple"))}get collapsible(){return m(this.getAttribute("collapsible"),!0)}set collapsible(i){this.setAttribute("collapsible",String(!!i))}get open(){const i=this._normalizeOpen(this._sourceItems());return this.multiple?i:i[0]??-1}set open(i){const r=Array.isArray(i)?i:[i];this._commitOpen(r.map(u).filter(o=>o>=0),!1)}_sourceItems(){return Array.from(this.children).filter(y).map((r,o)=>{const e=Array.from(r.children),t=e.find(n=>n.hasAttribute("data-ui-accordion-trigger"))||null,a=e.find(n=>n.hasAttribute("data-ui-accordion-panel"))||null;return{index:o,itemNode:r,trigger:t,panel:a,disabled:r.hasAttribute("disabled")||
|
|
356
|
+
`;function u(c){const i=Number(c);if(!Number.isFinite(i))return-1;const r=Math.trunc(i);return r>=0?r:-1}function m(c,i){if(c==null)return i;const r=c.toLowerCase();return r!=="false"&&r!=="0"&&r!=="no"}function v(c,i){if(!c)return[];if(!i){const o=u(c);return o>=0?[o]:[]}try{const o=JSON.parse(c);if(Array.isArray(o))return o.map(u).filter(e=>e>=0)}catch{}const r=u(c);return r>=0?[r]:[]}function h(c,i){return i?JSON.stringify(c):String(c[0]??-1)}function x(c,i="var(--base-card-radius, var(--ui-radius, 4px))"){if(!c||!c.trim())return i;const r=c.trim().toLowerCase();return r==="full"||r==="pill"?"999px":r==="square"||r==="none"?"0px":/^-?\d+(\.\d+)?$/.test(r)?`${r}px`:c.trim()}function y(c){return c instanceof HTMLElement&&c.hasAttribute("data-ui-accordion-item")}class g extends b.ElementBase{constructor(){super(),this._uid=`ui-accordion-${Math.random().toString(36).slice(2,8)}`,this._observer=null,this._panelResizeObserver=null,this._heightSyncRaf=0,this._syncingOpenAttr=!1,this._syncingDom=!1,this._syncingDomResetTimer=null,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onMutations=this._onMutations.bind(this)}static get observedAttributes(){return["open","multiple","collapsible","headless","shape","elevation","variant","size","tone","radius","indicator"]}connectedCallback(){super.connectedCallback(),this.setAttribute("data-ui-accordion-root","true"),this._syncHostStyles(),this.addEventListener("click",this._onClick),this.addEventListener("keydown",this._onKeyDown),this._observer=new MutationObserver(this._onMutations),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0}),typeof ResizeObserver<"u"&&(this._panelResizeObserver=new ResizeObserver(()=>{this._syncPanelHeights()}))}disconnectedCallback(){this.removeEventListener("click",this._onClick),this.removeEventListener("keydown",this._onKeyDown),this._observer&&(this._observer.disconnect(),this._observer=null),this._panelResizeObserver&&(this._panelResizeObserver.disconnect(),this._panelResizeObserver=null),this._heightSyncRaf&&(cancelAnimationFrame(this._heightSyncRaf),this._heightSyncRaf=0),this._syncingDomResetTimer!=null&&(clearTimeout(this._syncingDomResetTimer),this._syncingDomResetTimer=null),super.disconnectedCallback()}attributeChangedCallback(i,r,o){if(r!==o){if(i==="radius"||i==="shape"){this._syncHostStyles();return}if(this.isConnected){if(i==="open"){this._applyOpenState();return}this.requestRender()}}}get multiple(){return this.hasAttribute("multiple")}set multiple(i){i!==this.multiple&&(i?this.setAttribute("multiple",""):this.removeAttribute("multiple"))}get collapsible(){return m(this.getAttribute("collapsible"),!0)}set collapsible(i){this.setAttribute("collapsible",String(!!i))}get open(){const i=this._normalizeOpen(this._sourceItems());return this.multiple?i:i[0]??-1}set open(i){const r=Array.isArray(i)?i:[i];this._commitOpen(r.map(u).filter(o=>o>=0),!1)}_sourceItems(){return Array.from(this.children).filter(y).map((r,o)=>{const e=Array.from(r.children),t=e.find(n=>n.hasAttribute("data-ui-accordion-trigger"))||null,a=e.find(n=>n.hasAttribute("data-ui-accordion-panel"))||null;return{index:o,itemNode:r,trigger:t,panel:a,disabled:r.hasAttribute("disabled")||t?.hasAttribute("disabled")||!1,description:r.getAttribute("description")||r.getAttribute("data-description")||"",badge:r.getAttribute("badge")||r.getAttribute("data-badge")||""}})}_normalizeOpen(i){const r=v(this.getAttribute("open"),this.multiple),o=Array.from(new Set(r.map(u).filter(t=>t>=0&&t<i.length&&!i[t]?.disabled))).sort((t,a)=>t-a),e=i.findIndex(t=>!t.disabled);return this.multiple?this.collapsible||i.length===0||o.length>0?o:e>=0?[e]:[]:o.length>0?[o[0]]:this.collapsible||i.length===0?[]:e>=0?[e]:[]}_normalizeNext(i,r){const o=Array.from(new Set(i.map(u).filter(t=>t>=0&&t<r.length&&!r[t]?.disabled))).sort((t,a)=>t-a),e=r.findIndex(t=>!t.disabled);return this.multiple?this.collapsible||r.length===0||o.length>0?o:e>=0?[e]:[]:o.length>0?[o[0]]:this.collapsible||r.length===0?[]:e>=0?[e]:[]}_commitOpen(i,r){const o=this._sourceItems(),e=this._normalizeNext(i,o),t=h(e,this.multiple),a=this.getAttribute("open")??(this.multiple?"[]":"-1");if(t!==a&&(this._syncingOpenAttr=!0,this.setAttribute("open",t),this._syncingOpenAttr=!1,this._applyOpenState()),!r)return;const n=this.multiple?e:e[0]??-1;this.dispatchEvent(new CustomEvent("toggle",{detail:{open:n},bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{open:n},bubbles:!0}))}_ensureStyleNode(){let i=this.querySelector(":scope > style[data-ui-accordion-style]");if(!i){i=document.createElement("style"),i.setAttribute("data-ui-accordion-style",""),i.textContent=p,this.prepend(i);return}i.textContent!==p&&(i.textContent=p)}_markSyncingDom(){this._syncingDom=!0,this._syncingDomResetTimer!=null&&clearTimeout(this._syncingDomResetTimer),this._syncingDomResetTimer=window.setTimeout(()=>{this._syncingDom=!1,this._syncingDomResetTimer=null},0)}_syncHostStyles(){const i=this.getAttribute("radius"),r=this.getAttribute("shape");if(i&&i.trim()){this.style.setProperty("--ui-accordion-radius",x(i));return}if(r==="square"){this.style.setProperty("--ui-accordion-radius","4px");return}if(r==="pill"){this.style.setProperty("--ui-accordion-radius","999px");return}this.style.removeProperty("--ui-accordion-radius")}_ensureGeneratedNodes(i){const{trigger:r,itemNode:o,description:e,badge:t}=i;if(!r)return;let a=r.querySelector("[data-ui-accordion-trailing]");a||(a=document.createElement("span"),a.setAttribute("data-ui-accordion-trailing",""),r.appendChild(a));let n=a.querySelector("[data-ui-accordion-generated-badge]");t?(n||(n=document.createElement("span"),n.setAttribute("data-ui-accordion-generated-badge",""),a.appendChild(n)),n.textContent=t):n&&n.remove();let s=a.querySelector("[data-ui-accordion-chevron]");s||(s=document.createElement("span"),s.setAttribute("data-ui-accordion-chevron",""),s.setAttribute("aria-hidden","true"),s.innerHTML=`
|
|
357
357
|
<svg width="16" height="16" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
|
358
358
|
<path d="M5 7.5 10 12.5 15 7.5"></path>
|
|
359
359
|
</svg>
|
|
360
|
-
`,a.appendChild(
|
|
360
|
+
`,a.appendChild(s));let d=o.querySelector(":scope > [data-ui-accordion-generated-description]");if(e){if(!d){d=document.createElement("div"),d.setAttribute("data-ui-accordion-generated-description","");const l=i.panel;l?o.insertBefore(d,l):o.appendChild(d)}d.textContent=e,d.hidden=!1}else d&&(d.hidden=!0)}_applyOpenState(){this._markSyncingDom();const i=this._sourceItems(),r=this._normalizeOpen(i),o=h(r,this.multiple),e=this.getAttribute("open")??(this.multiple?"[]":"-1");o!==e&&!this._syncingOpenAttr&&(this._syncingOpenAttr=!0,this.setAttribute("open",o),this._syncingOpenAttr=!1);const t=new Set(r);i.forEach(a=>{const{itemNode:n,trigger:s,panel:d}=a,l=t.has(a.index);if(n.setAttribute("data-disabled",a.disabled?"true":"false"),l?n.setAttribute("open",""):n.removeAttribute("open"),s&&(s.setAttribute("aria-expanded",l?"true":"false"),s.disabled=a.disabled),d){const f=l?32:0;d.style.setProperty("--ui-accordion-panel-height",`${d.scrollHeight+f}px`),d.setAttribute("aria-hidden",l?"false":"true")}}),this._queuePanelHeightSync()}_observePanels(i){this._panelResizeObserver&&(this._panelResizeObserver.disconnect(),i.forEach(r=>{r.panel&&this._panelResizeObserver?.observe(r.panel)}))}_syncPanelHeights(){this._sourceItems().forEach(i=>{if(!i.panel)return;const o=i.itemNode.hasAttribute("open")?32:0;i.panel.style.setProperty("--ui-accordion-panel-height",`${i.panel.scrollHeight+o}px`)})}_queuePanelHeightSync(){this._heightSyncRaf&&cancelAnimationFrame(this._heightSyncRaf),this._heightSyncRaf=requestAnimationFrame(()=>{this._syncPanelHeights(),this._heightSyncRaf=requestAnimationFrame(()=>{this._syncPanelHeights(),this._heightSyncRaf=0})})}_syncLightDom(){if(this.hasAttribute("headless"))return;const i=this._sourceItems();this._markSyncingDom(),this.setAttribute("data-ui-accordion-root","true"),this._syncHostStyles(),this._ensureStyleNode(),i.forEach(r=>{const{itemNode:o,trigger:e,panel:t,index:a,disabled:n}=r;if(o.setAttribute("data-disabled",n?"true":"false"),e){const s=`${this._uid}-trigger-${a}`,d=`${this._uid}-panel-${a}`;e.id||(e.id=s),e.setAttribute("type","button"),e.setAttribute("aria-controls",d),e.setAttribute("data-index",String(a)),n?e.setAttribute("disabled",""):e.removeAttribute("disabled"),this._ensureGeneratedNodes(r)}if(t){const s=`${this._uid}-panel-${a}`;t.id=s,t.setAttribute("role","region"),e&&t.setAttribute("aria-labelledby",e.id)}}),this._observePanels(i),this._applyOpenState()}_onMutations(i){this._syncingDom||!i.some(o=>{if(o.target===this&&o.type==="attributes"){const e=o.attributeName||"";return!["open","multiple","collapsible","headless","shape","elevation","variant","size","tone","radius","indicator","data-ui-accordion-root","style"].includes(e)}return!(o.target instanceof HTMLStyleElement&&o.target.hasAttribute("data-ui-accordion-style"))})||this.requestRender()}_toggleIndex(i){const r=this._sourceItems();if(i<0||i>=r.length||r[i].disabled)return;const o=this._normalizeOpen(r),e=o.includes(i);let t=[...o];this.multiple?e?t=o.filter(a=>a!==i):t.push(i):t=e?[]:[i],this._commitOpen(t,!0)}_onClick(i){const o=i.target.closest("[data-ui-accordion-trigger]");if(!o||o.disabled||!this.contains(o))return;const e=u(o.getAttribute("data-index"));this._toggleIndex(e)}_onKeyDown(i){const o=i.target.closest("[data-ui-accordion-trigger]");if(!o||!this.contains(o))return;const e=this._sourceItems().map(n=>n.trigger).filter(n=>!!n&&!n.disabled),t=e.indexOf(o);if(t<0)return;if(i.key==="Enter"||i.key===" "){i.preventDefault();const n=u(o.getAttribute("data-index"));this._toggleIndex(n);return}if(!["ArrowDown","ArrowUp","Home","End"].includes(i.key))return;let a=t;i.key==="ArrowDown"&&(a=(t+1)%e.length),i.key==="ArrowUp"&&(a=(t-1+e.length)%e.length),i.key==="Home"&&(a=0),i.key==="End"&&(a=e.length-1),i.preventDefault(),e[a]?.focus({preventScroll:!0})}render(){this.setContent("<slot></slot>"),this.hasAttribute("headless")||this._syncLightDom()}}typeof customElements<"u"&&!customElements.get("ui-accordion")&&customElements.define("ui-accordion",g);exports.UIAccordion=g;
|
package/dist/accordion.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as f } from "./ElementBase-
|
|
1
|
+
import { E as f } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
2
|
const p = `
|
|
3
3
|
ui-accordion[data-ui-accordion-root="true"] {
|
|
4
4
|
display: block;
|
|
@@ -357,28 +357,24 @@ const p = `
|
|
|
357
357
|
`;
|
|
358
358
|
function u(c) {
|
|
359
359
|
const i = Number(c);
|
|
360
|
-
if (!Number.isFinite(i))
|
|
361
|
-
return -1;
|
|
360
|
+
if (!Number.isFinite(i)) return -1;
|
|
362
361
|
const r = Math.trunc(i);
|
|
363
362
|
return r >= 0 ? r : -1;
|
|
364
363
|
}
|
|
365
364
|
function b(c, i) {
|
|
366
|
-
if (c == null)
|
|
367
|
-
return i;
|
|
365
|
+
if (c == null) return i;
|
|
368
366
|
const r = c.toLowerCase();
|
|
369
367
|
return r !== "false" && r !== "0" && r !== "no";
|
|
370
368
|
}
|
|
371
369
|
function m(c, i) {
|
|
372
|
-
if (!c)
|
|
373
|
-
return [];
|
|
370
|
+
if (!c) return [];
|
|
374
371
|
if (!i) {
|
|
375
372
|
const o = u(c);
|
|
376
373
|
return o >= 0 ? [o] : [];
|
|
377
374
|
}
|
|
378
375
|
try {
|
|
379
376
|
const o = JSON.parse(c);
|
|
380
|
-
if (Array.isArray(o))
|
|
381
|
-
return o.map(u).filter((e) => e >= 0);
|
|
377
|
+
if (Array.isArray(o)) return o.map(u).filter((e) => e >= 0);
|
|
382
378
|
} catch {
|
|
383
379
|
}
|
|
384
380
|
const r = u(c);
|
|
@@ -388,8 +384,7 @@ function h(c, i) {
|
|
|
388
384
|
return i ? JSON.stringify(c) : String(c[0] ?? -1);
|
|
389
385
|
}
|
|
390
386
|
function v(c, i = "var(--base-card-radius, var(--ui-radius, 4px))") {
|
|
391
|
-
if (!c || !c.trim())
|
|
392
|
-
return i;
|
|
387
|
+
if (!c || !c.trim()) return i;
|
|
393
388
|
const r = c.trim().toLowerCase();
|
|
394
389
|
return r === "full" || r === "pill" ? "999px" : r === "square" || r === "none" ? "0px" : /^-?\d+(\.\d+)?$/.test(r) ? `${r}px` : c.trim();
|
|
395
390
|
}
|
|
@@ -459,7 +454,7 @@ class y extends f {
|
|
|
459
454
|
itemNode: r,
|
|
460
455
|
trigger: t,
|
|
461
456
|
panel: a,
|
|
462
|
-
disabled: r.hasAttribute("disabled") ||
|
|
457
|
+
disabled: r.hasAttribute("disabled") || t?.hasAttribute("disabled") || !1,
|
|
463
458
|
description: r.getAttribute("description") || r.getAttribute("data-description") || "",
|
|
464
459
|
badge: r.getAttribute("badge") || r.getAttribute("data-badge") || ""
|
|
465
460
|
};
|
|
@@ -467,26 +462,19 @@ class y extends f {
|
|
|
467
462
|
}
|
|
468
463
|
_normalizeOpen(i) {
|
|
469
464
|
const r = m(this.getAttribute("open"), this.multiple), o = Array.from(
|
|
470
|
-
new Set(r.map(u).filter((t) =>
|
|
471
|
-
var a;
|
|
472
|
-
return t >= 0 && t < i.length && !((a = i[t]) != null && a.disabled);
|
|
473
|
-
}))
|
|
465
|
+
new Set(r.map(u).filter((t) => t >= 0 && t < i.length && !i[t]?.disabled))
|
|
474
466
|
).sort((t, a) => t - a), e = i.findIndex((t) => !t.disabled);
|
|
475
467
|
return this.multiple ? this.collapsible || i.length === 0 || o.length > 0 ? o : e >= 0 ? [e] : [] : o.length > 0 ? [o[0]] : this.collapsible || i.length === 0 ? [] : e >= 0 ? [e] : [];
|
|
476
468
|
}
|
|
477
469
|
_normalizeNext(i, r) {
|
|
478
470
|
const o = Array.from(
|
|
479
|
-
new Set(i.map(u).filter((t) =>
|
|
480
|
-
var a;
|
|
481
|
-
return t >= 0 && t < r.length && !((a = r[t]) != null && a.disabled);
|
|
482
|
-
}))
|
|
471
|
+
new Set(i.map(u).filter((t) => t >= 0 && t < r.length && !r[t]?.disabled))
|
|
483
472
|
).sort((t, a) => t - a), e = r.findIndex((t) => !t.disabled);
|
|
484
473
|
return this.multiple ? this.collapsible || r.length === 0 || o.length > 0 ? o : e >= 0 ? [e] : [] : o.length > 0 ? [o[0]] : this.collapsible || r.length === 0 ? [] : e >= 0 ? [e] : [];
|
|
485
474
|
}
|
|
486
475
|
_commitOpen(i, r) {
|
|
487
476
|
const o = this._sourceItems(), e = this._normalizeNext(i, o), t = h(e, this.multiple), a = this.getAttribute("open") ?? (this.multiple ? "[]" : "-1");
|
|
488
|
-
if (t !== a && (this._syncingOpenAttr = !0, this.setAttribute("open", t), this._syncingOpenAttr = !1, this._applyOpenState()), !r)
|
|
489
|
-
return;
|
|
477
|
+
if (t !== a && (this._syncingOpenAttr = !0, this.setAttribute("open", t), this._syncingOpenAttr = !1, this._applyOpenState()), !r) return;
|
|
490
478
|
const n = this.multiple ? e : e[0] ?? -1;
|
|
491
479
|
this.dispatchEvent(new CustomEvent("toggle", { detail: { open: n }, bubbles: !0 })), this.dispatchEvent(new CustomEvent("change", { detail: { open: n }, bubbles: !0 }));
|
|
492
480
|
}
|
|
@@ -521,28 +509,26 @@ class y extends f {
|
|
|
521
509
|
}
|
|
522
510
|
_ensureGeneratedNodes(i) {
|
|
523
511
|
const { trigger: r, itemNode: o, description: e, badge: t } = i;
|
|
524
|
-
if (!r)
|
|
525
|
-
return;
|
|
512
|
+
if (!r) return;
|
|
526
513
|
let a = r.querySelector("[data-ui-accordion-trailing]");
|
|
527
514
|
a || (a = document.createElement("span"), a.setAttribute("data-ui-accordion-trailing", ""), r.appendChild(a));
|
|
528
515
|
let n = a.querySelector("[data-ui-accordion-generated-badge]");
|
|
529
516
|
t ? (n || (n = document.createElement("span"), n.setAttribute("data-ui-accordion-generated-badge", ""), a.appendChild(n)), n.textContent = t) : n && n.remove();
|
|
530
|
-
let
|
|
531
|
-
|
|
517
|
+
let s = a.querySelector("[data-ui-accordion-chevron]");
|
|
518
|
+
s || (s = document.createElement("span"), s.setAttribute("data-ui-accordion-chevron", ""), s.setAttribute("aria-hidden", "true"), s.innerHTML = `
|
|
532
519
|
<svg width="16" height="16" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
|
533
520
|
<path d="M5 7.5 10 12.5 15 7.5"></path>
|
|
534
521
|
</svg>
|
|
535
|
-
`, a.appendChild(
|
|
536
|
-
let
|
|
522
|
+
`, a.appendChild(s));
|
|
523
|
+
let d = o.querySelector(":scope > [data-ui-accordion-generated-description]");
|
|
537
524
|
if (e) {
|
|
538
|
-
if (!
|
|
539
|
-
|
|
525
|
+
if (!d) {
|
|
526
|
+
d = document.createElement("div"), d.setAttribute("data-ui-accordion-generated-description", "");
|
|
540
527
|
const l = i.panel;
|
|
541
|
-
l ? o.insertBefore(
|
|
528
|
+
l ? o.insertBefore(d, l) : o.appendChild(d);
|
|
542
529
|
}
|
|
543
|
-
|
|
544
|
-
} else
|
|
545
|
-
s && (s.hidden = !0);
|
|
530
|
+
d.textContent = e, d.hidden = !1;
|
|
531
|
+
} else d && (d.hidden = !0);
|
|
546
532
|
}
|
|
547
533
|
_applyOpenState() {
|
|
548
534
|
this._markSyncingDom();
|
|
@@ -550,23 +536,21 @@ class y extends f {
|
|
|
550
536
|
o !== e && !this._syncingOpenAttr && (this._syncingOpenAttr = !0, this.setAttribute("open", o), this._syncingOpenAttr = !1);
|
|
551
537
|
const t = new Set(r);
|
|
552
538
|
i.forEach((a) => {
|
|
553
|
-
const { itemNode: n, trigger:
|
|
554
|
-
if (n.setAttribute("data-disabled", a.disabled ? "true" : "false"), l ? n.setAttribute("open", "") : n.removeAttribute("open"),
|
|
539
|
+
const { itemNode: n, trigger: s, panel: d } = a, l = t.has(a.index);
|
|
540
|
+
if (n.setAttribute("data-disabled", a.disabled ? "true" : "false"), l ? n.setAttribute("open", "") : n.removeAttribute("open"), s && (s.setAttribute("aria-expanded", l ? "true" : "false"), s.disabled = a.disabled), d) {
|
|
555
541
|
const g = l ? 32 : 0;
|
|
556
|
-
|
|
542
|
+
d.style.setProperty("--ui-accordion-panel-height", `${d.scrollHeight + g}px`), d.setAttribute("aria-hidden", l ? "false" : "true");
|
|
557
543
|
}
|
|
558
544
|
}), this._queuePanelHeightSync();
|
|
559
545
|
}
|
|
560
546
|
_observePanels(i) {
|
|
561
547
|
this._panelResizeObserver && (this._panelResizeObserver.disconnect(), i.forEach((r) => {
|
|
562
|
-
|
|
563
|
-
r.panel && ((o = this._panelResizeObserver) == null || o.observe(r.panel));
|
|
548
|
+
r.panel && this._panelResizeObserver?.observe(r.panel);
|
|
564
549
|
}));
|
|
565
550
|
}
|
|
566
551
|
_syncPanelHeights() {
|
|
567
552
|
this._sourceItems().forEach((i) => {
|
|
568
|
-
if (!i.panel)
|
|
569
|
-
return;
|
|
553
|
+
if (!i.panel) return;
|
|
570
554
|
const o = i.itemNode.hasAttribute("open") ? 32 : 0;
|
|
571
555
|
i.panel.style.setProperty("--ui-accordion-panel-height", `${i.panel.scrollHeight + o}px`);
|
|
572
556
|
});
|
|
@@ -579,18 +563,17 @@ class y extends f {
|
|
|
579
563
|
});
|
|
580
564
|
}
|
|
581
565
|
_syncLightDom() {
|
|
582
|
-
if (this.hasAttribute("headless"))
|
|
583
|
-
return;
|
|
566
|
+
if (this.hasAttribute("headless")) return;
|
|
584
567
|
const i = this._sourceItems();
|
|
585
568
|
this._markSyncingDom(), this.setAttribute("data-ui-accordion-root", "true"), this._syncHostStyles(), this._ensureStyleNode(), i.forEach((r) => {
|
|
586
569
|
const { itemNode: o, trigger: e, panel: t, index: a, disabled: n } = r;
|
|
587
570
|
if (o.setAttribute("data-disabled", n ? "true" : "false"), e) {
|
|
588
|
-
const
|
|
589
|
-
e.id || (e.id =
|
|
571
|
+
const s = `${this._uid}-trigger-${a}`, d = `${this._uid}-panel-${a}`;
|
|
572
|
+
e.id || (e.id = s), e.setAttribute("type", "button"), e.setAttribute("aria-controls", d), e.setAttribute("data-index", String(a)), n ? e.setAttribute("disabled", "") : e.removeAttribute("disabled"), this._ensureGeneratedNodes(r);
|
|
590
573
|
}
|
|
591
574
|
if (t) {
|
|
592
|
-
const
|
|
593
|
-
t.id =
|
|
575
|
+
const s = `${this._uid}-panel-${a}`;
|
|
576
|
+
t.id = s, t.setAttribute("role", "region"), e && t.setAttribute("aria-labelledby", e.id);
|
|
594
577
|
}
|
|
595
578
|
}), this._observePanels(i), this._applyOpenState();
|
|
596
579
|
}
|
|
@@ -605,37 +588,31 @@ class y extends f {
|
|
|
605
588
|
}
|
|
606
589
|
_toggleIndex(i) {
|
|
607
590
|
const r = this._sourceItems();
|
|
608
|
-
if (i < 0 || i >= r.length || r[i].disabled)
|
|
609
|
-
return;
|
|
591
|
+
if (i < 0 || i >= r.length || r[i].disabled) return;
|
|
610
592
|
const o = this._normalizeOpen(r), e = o.includes(i);
|
|
611
593
|
let t = [...o];
|
|
612
594
|
this.multiple ? e ? t = o.filter((a) => a !== i) : t.push(i) : t = e ? [] : [i], this._commitOpen(t, !0);
|
|
613
595
|
}
|
|
614
596
|
_onClick(i) {
|
|
615
597
|
const o = i.target.closest("[data-ui-accordion-trigger]");
|
|
616
|
-
if (!o || o.disabled || !this.contains(o))
|
|
617
|
-
return;
|
|
598
|
+
if (!o || o.disabled || !this.contains(o)) return;
|
|
618
599
|
const e = u(o.getAttribute("data-index"));
|
|
619
600
|
this._toggleIndex(e);
|
|
620
601
|
}
|
|
621
602
|
_onKeyDown(i) {
|
|
622
|
-
var n;
|
|
623
603
|
const o = i.target.closest("[data-ui-accordion-trigger]");
|
|
624
|
-
if (!o || !this.contains(o))
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
if (t < 0)
|
|
628
|
-
return;
|
|
604
|
+
if (!o || !this.contains(o)) return;
|
|
605
|
+
const e = this._sourceItems().map((n) => n.trigger).filter((n) => !!n && !n.disabled), t = e.indexOf(o);
|
|
606
|
+
if (t < 0) return;
|
|
629
607
|
if (i.key === "Enter" || i.key === " ") {
|
|
630
608
|
i.preventDefault();
|
|
631
|
-
const
|
|
632
|
-
this._toggleIndex(
|
|
609
|
+
const n = u(o.getAttribute("data-index"));
|
|
610
|
+
this._toggleIndex(n);
|
|
633
611
|
return;
|
|
634
612
|
}
|
|
635
|
-
if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(i.key))
|
|
636
|
-
return;
|
|
613
|
+
if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(i.key)) return;
|
|
637
614
|
let a = t;
|
|
638
|
-
i.key === "ArrowDown" && (a = (t + 1) % e.length), i.key === "ArrowUp" && (a = (t - 1 + e.length) % e.length), i.key === "Home" && (a = 0), i.key === "End" && (a = e.length - 1), i.preventDefault(),
|
|
615
|
+
i.key === "ArrowDown" && (a = (t + 1) % e.length), i.key === "ArrowUp" && (a = (t - 1 + e.length) % e.length), i.key === "Home" && (a = 0), i.key === "End" && (a = e.length - 1), i.preventDefault(), e[a]?.focus({ preventScroll: !0 });
|
|
639
616
|
}
|
|
640
617
|
render() {
|
|
641
618
|
this.setContent("<slot></slot>"), this.hasAttribute("headless") || this._syncLightDom();
|
package/dist/alert-dialog.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const j=require("./ElementBase-EV6mVBUV.js"),p=require("./scroll-lock-BX6e3Ced.js"),K=`
|
|
2
2
|
:host {
|
|
3
3
|
display: block;
|
|
4
4
|
color-scheme: light dark;
|
|
@@ -497,71 +497,71 @@
|
|
|
497
497
|
border: 1px solid CanvasText;
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
|
-
`,X='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function g(i,t){if(i==null)return t;const e=i.trim().toLowerCase();return e!=="false"&&e!=="0"&&e!=="off"}function a(i){return String(i).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function tt(i){return i==="info"||i==="success"||i==="warning"||i==="danger"?i:"neutral"}function et(i){return i==="sm"||i==="1"?"sm":i==="lg"||i==="3"?"lg":"md"}function it(i){return i==="soft"||i==="outline"||i==="solid"?i:"surface"}function rt(i){return i==="none"||i==="high"?i:"low"}function st(i){return i==="none"?"none":"line"}function at(i,t="var(--base-alert-dialog-radius, var(--ui-radius, 4px))"){if(i==null)return t;const e=i.trim().toLowerCase();return e?e==="full"||e==="pill"?"999px":/^-?\d+(\.\d+)?$/.test(e)?`${e}px`:i:t}const ot=new Set(["tone","size","variant","elevation","indicator","radius"]);function nt(i){return i==="success"?'<svg width="16" height="16" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M5 10.2 8.3 13.4 15 6.8"></path></svg>':i==="warning"?'<svg width="16" height="16" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M10 3.6 17 16.4H3L10 3.6Z"></path><path d="M10 8v3.4"></path><circle cx="10" cy="14.1" r="0.9" fill="currentColor" stroke="none"></circle></svg>':i==="danger"?'<svg width="16" height="16" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="10" r="7.1"></circle><path d="m7.5 7.5 5 5M12.5 7.5l-5 5"></path></svg>':i==="info"?'<svg width="16" height="16" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="10" r="7.1"></circle><path d="M10 13v-3.8"></path><circle cx="10" cy="6.5" r="0.9" fill="currentColor" stroke="none"></circle></svg>':'<svg width="16" height="16" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M6 10h8"></path><circle cx="10" cy="10" r="7.1"></circle></svg>'}function l(){return typeof window<"u"&&typeof document<"u"}function S(){if(!l())return null;const i=document.activeElement;return i instanceof HTMLElement?i:null}function x(i){return typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>i()):window.setTimeout(i,16)}function h(i){if(i){if(typeof cancelAnimationFrame=="function"){cancelAnimationFrame(i);return}window.clearTimeout(i)}}const B=class c extends J.ElementBase{constructor(){super(),this._lastActive=null,this._active=!1,this._terminalEmitted=!1,this._closeMeta=null,this._uid=Math.random().toString(36).slice(2,10),this._dialogId="",this._config={},this._inputValue="",this._checked=!1,this._runtimeError="",this._activeHeadless=!1,this._focusInitialFrame=0,this._restoreFocusFrame=0,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusIn=this._onFocusIn.bind(this),this._onInput=this._onInput.bind(this),this._dialogId=this._uid}static get observedAttributes(){return["open","headless","dismissible","close-on-esc","close-on-backdrop","lock-while-loading","role","tone","size","variant","elevation","indicator","radius","state","aria-label","aria-labelledby","aria-describedby","initial-focus","title","description","confirm-text","cancel-text","loading-text","error-message"]}connectedCallback(){super.connectedCallback(),this.root.addEventListener("click",this._onClick),this.root.addEventListener("keydown",this._onKeyDown),this.root.addEventListener("input",this._onInput),this._syncFromAttributes(),this._syncVisualTokens(),this._syncOpenState()}disconnectedCallback(){this.root.removeEventListener("click",this._onClick),this.root.removeEventListener("keydown",this._onKeyDown),this.root.removeEventListener("input",this._onInput),this._focusInitialFrame&&(h(this._focusInitialFrame),this._focusInitialFrame=0),this._restoreFocusFrame&&(h(this._restoreFocusFrame),this._restoreFocusFrame=0),this._active&&!this._terminalEmitted&&this.close("dismiss","unmount"),this._deactivate(),super.disconnectedCallback()}attributeChangedCallback(t,e,r){if(e!==r){if(ot.has(t)){this._syncVisualTokens();return}if(t==="headless"){this._syncActiveEnvironment(),this.requestRender();return}if(t==="open"){this._syncOpenState();return}t==="state"&&r!=="error"&&(this._runtimeError=""),this._syncFromAttributes(),this.isConnected&&this.requestRender()}}get open(){return this.hasAttribute("open")}set open(t){t?this.setAttribute("open",""):this.close("dismiss","programmatic")}get headless(){return this.hasAttribute("headless")}set headless(t){t?this.setAttribute("headless",""):this.removeAttribute("headless")}get dismissible(){return g(this.getAttribute("dismissible"),!0)}set dismissible(t){this.setAttribute("dismissible",String(t))}get closeOnEsc(){return g(this.getAttribute("close-on-esc"),this.dismissible)}set closeOnEsc(t){this.setAttribute("close-on-esc",String(t))}get closeOnBackdrop(){return g(this.getAttribute("close-on-backdrop"),this.dismissible)}set closeOnBackdrop(t){this.setAttribute("close-on-backdrop",String(t))}get lockWhileLoading(){return g(this.getAttribute("lock-while-loading"),!0)}set lockWhileLoading(t){this.setAttribute("lock-while-loading",String(t))}get roleType(){return this.getAttribute("role")==="dialog"?"dialog":"alertdialog"}set roleType(t){this.setAttribute("role",t)}get tone(){return tt(this.getAttribute("tone"))}set tone(t){if(t==="neutral"){this.removeAttribute("tone");return}this.setAttribute("tone",t)}get size(){return et(this.getAttribute("size"))}set size(t){if(t==="md"){this.removeAttribute("size");return}this.setAttribute("size",t)}get variant(){return it(this.getAttribute("variant"))}set variant(t){if(t==="surface"){this.removeAttribute("variant");return}this.setAttribute("variant",t)}get elevation(){return rt(this.getAttribute("elevation"))}set elevation(t){if(t==="low"){this.removeAttribute("elevation");return}this.setAttribute("elevation",t)}get indicator(){return st(this.getAttribute("indicator"))}set indicator(t){if(t==="line"){this.removeAttribute("indicator");return}this.setAttribute("indicator",t)}get radius(){return this.getAttribute("radius")||""}set radius(t){if(!t){this.removeAttribute("radius");return}this.setAttribute("radius",t)}get state(){const t=this.getAttribute("state");return t==="loading"||t==="error"?t:"idle"}set state(t){if(t==="idle"){this.removeAttribute("state");return}this.setAttribute("state",t)}get initialFocus(){return this.getAttribute("initial-focus")||this._config.initialFocus||""}set initialFocus(t){if(!t){this.removeAttribute("initial-focus");return}this.setAttribute("initial-focus",t)}get dialogId(){return this._dialogId}set dialogId(t){this._dialogId=t||this._uid,this.requestRender()}get config(){return this._config}set config(t){var e,r;this._config=t||{},this._config.id&&(this._dialogId=this._config.id),this._config.dismissible!=null&&(this.dismissible=!!this._config.dismissible),this._config.closeOnEsc!=null&&(this.closeOnEsc=!!this._config.closeOnEsc),this._config.closeOnBackdrop!=null&&(this.closeOnBackdrop=!!this._config.closeOnBackdrop),this._config.lockWhileLoading!=null&&(this.lockWhileLoading=!!this._config.lockWhileLoading),this._config.role&&(this.roleType=this._config.role),this._config.tone&&(this.tone=this._config.tone),this._config.size&&(this.size=this._config.size),this._config.variant&&(this.variant=this._config.variant),this._config.elevation&&(this.elevation=this._config.elevation),this._config.indicator&&(this.indicator=this._config.indicator),this._config.radius!=null&&(this.radius=String(this._config.radius)),this._config.ariaLabel&&this.setAttribute("aria-label",this._config.ariaLabel),this._config.ariaLabelledby&&this.setAttribute("aria-labelledby",this._config.ariaLabelledby),this._config.ariaDescribedby&&this.setAttribute("aria-describedby",this._config.ariaDescribedby),this._config.initialFocus&&(this.initialFocus=this._config.initialFocus),this._config.headless!=null&&(this.headless=!!this._config.headless),this._inputValue=((e=this._config.input)==null?void 0:e.value)??this._inputValue,this._checked=((r=this._config.checkbox)==null?void 0:r.checked)??this._checked,this._runtimeError=this._config.errorMessage||"",this._syncVisualTokens(),this.requestRender()}getInputValue(){const t=this.root.querySelector(".input");return(t==null?void 0:t.value)??this._inputValue}setInputValue(t){this._inputValue=t;const e=this.root.querySelector(".input");e&&(e.value=t)}getChecked(){const t=this.root.querySelector(".checkbox-input");return(t==null?void 0:t.checked)??this._checked}setChecked(t){this._checked=t;const e=this.root.querySelector(".checkbox-input");e&&(e.checked=t)}setError(t){this._runtimeError=t,this.state=t?"error":"idle",this.requestRender()}clearError(){this._runtimeError="",this.state==="error"&&(this.state="idle"),this.requestRender()}close(t="dismiss",e,r){this._terminalEmitted||(this._closeMeta={action:t,source:e,reason:r},this.hasAttribute("open")&&this.removeAttribute("open"),this._syncOpenState())}_syncFromAttributes(){this.hasAttribute("role")||this.setAttribute("role","alertdialog")}_syncVisualTokens(){this.style.setProperty("--ui-alert-radius",at(this.getAttribute("radius")))}_syncOpenState(){const t=this.hasAttribute("open");if(t&&!this._active){this._activate();return}!t&&this._active&&this._deactivate()}_activate(){this._active=!0,this._activeHeadless=this.headless,this._terminalEmitted=!1,this._closeMeta=null,c._openStack.includes(this)||c._openStack.push(this),this._lastActive=this.headless?null:S(),this.headless||p.acquireBodyScrollLock(),l()&&!this.headless&&document.addEventListener("focusin",this._onFocusIn,!0);const t=this.dialogId||this._uid;this._dispatchWithLegacy("ui-open","open",{id:t}),this.headless||(this._focusInitialFrame&&h(this._focusInitialFrame),this._focusInitialFrame=x(()=>{this._focusInitialFrame=0,this._focusInitial()})),this.requestRender()}_deactivate(){if(!this._active)return;this._active=!1;const t=c._openStack.lastIndexOf(this);if(t>=0&&c._openStack.splice(t,1),l()&&!this._activeHeadless&&document.removeEventListener("focusin",this._onFocusIn,!0),this._activeHeadless||p.releaseBodyScrollLock(),!this._terminalEmitted){const r=this._closeMeta||{action:"dismiss",source:"abort"},s=this.dialogId||this._uid;r.action==="cancel"?this._dispatchWithLegacy("ui-cancel","cancel",{id:s}):r.action==="dismiss"&&this._dispatchWithLegacy("ui-dismiss","dismiss",{id:s,source:r.source||"abort",reason:r.reason}),this._dispatchWithLegacy("ui-close","close",{id:s,action:r.action,source:r.source,reason:r.reason}),this._terminalEmitted=!0,this._closeMeta=null}const e=this._lastActive;this._lastActive=null,e&&!this._activeHeadless&&(this._restoreFocusFrame&&h(this._restoreFocusFrame),this._restoreFocusFrame=x(()=>{this._restoreFocusFrame=0;try{e.focus()}catch{}})),this._activeHeadless=!1,this.requestRender()}_syncActiveEnvironment(){if(this._active&&this.headless!==this._activeHeadless){if(this.headless){l()&&document.removeEventListener("focusin",this._onFocusIn,!0),p.releaseBodyScrollLock(),this._lastActive=null,this._activeHeadless=!0;return}this._lastActive=S(),p.acquireBodyScrollLock(),l()&&document.addEventListener("focusin",this._onFocusIn,!0),this._activeHeadless=!1,this._focusInitialFrame&&h(this._focusInitialFrame),this._focusInitialFrame=x(()=>{this._focusInitialFrame=0,this._focusInitial()})}}_dispatchWithLegacy(t,e,r,s=!1){const o=new CustomEvent(t,{detail:r,bubbles:!0,composed:!0,cancelable:s});this.dispatchEvent(o);const n=new CustomEvent(e,{detail:r,bubbles:!0,composed:!0,cancelable:s});return this.dispatchEvent(n),o}_isTopMost(){if(!this._active)return!1;const t=c._openStack;return t.length>0&&t[t.length-1]===this}_queryPanel(){return this.root.querySelector(".dialog")}_collectFocusable(t){return Array.from(t.querySelectorAll(X)).filter(e=>{if(e.disabled||e.getAttribute("aria-hidden")==="true")return!1;const s=l()?window.getComputedStyle(e):null;return!(s&&(s.display==="none"||s.visibility==="hidden"))})}_focusInitial(){if(!this.open)return;const t=this._queryPanel();if(!t)return;const e=this.initialFocus;if(e){const n=t.querySelector(e);if(n&&typeof n.focus=="function"){n.focus();return}}const r=this._collectFocusable(t),o=r.find(n=>n.hasAttribute("autofocus"))||r[0]||t;!o.hasAttribute("tabindex")&&o===t&&o.setAttribute("tabindex","-1");try{o.focus()}catch{}}_handleTab(t){if(t.key!=="Tab")return;const e=this._queryPanel();if(!e)return;const r=this._collectFocusable(e);if(!r.length){t.preventDefault(),e.focus();return}const s=this.root.activeElement||document.activeElement,o=r[0],n=r[r.length-1];if(t.shiftKey){(s===o||!s||!e.contains(s))&&(t.preventDefault(),n.focus());return}s===n&&(t.preventDefault(),o.focus())}_onFocusIn(t){if(!this.open||!this._isTopMost())return;const e=this._queryPanel();if(!e)return;const r=t.target;(typeof t.composedPath=="function"?t.composedPath():[]).includes(e)||r&&e.contains(r)||this._focusInitial()}_onInput(t){const e=t.target;e&&(e.classList.contains("input")&&(this._inputValue=e.value),e.classList.contains("checkbox-input")&&(this._checked=e.checked),this._dispatchWithLegacy("ui-change","change",{id:this.dialogId||this._uid,inputValue:this._inputValue,checked:this._checked}))}_isInteractionLocked(){return this.state==="loading"&&this.lockWhileLoading}_requestDismiss(t,e){this._isInteractionLocked()||this.close("dismiss",t,e)}_handleConfirm(){const t={id:this.dialogId||this._uid,inputValue:this.getInputValue(),checked:this.getChecked()};this._dispatchWithLegacy("ui-confirm","confirm",t,!0).defaultPrevented||this.close("confirm")}_handleCancel(){this._isInteractionLocked()||this.close("cancel")}_onClick(t){if(!this.open||!this._isTopMost())return;const e=t.target;if(e){if(e.classList.contains("backdrop")&&this.closeOnBackdrop){this._requestDismiss("backdrop");return}if(e.closest(".close")){this._requestDismiss("close-icon");return}if(e.closest(".btn-confirm")){this._handleConfirm();return}e.closest(".btn-cancel")&&this._handleCancel()}}_onKeyDown(t){if(!(!this.open||!this._isTopMost())){if(t.key==="Escape"){if(!this.closeOnEsc)return;t.preventDefault(),t.stopPropagation(),this._requestDismiss("esc");return}this._handleTab(t)}}render(){var F,z,I,E,C,L;if(!this.open){this.setContent("");return}const t=this._config.title??this.getAttribute("title")??"",e=this._config.description??this.getAttribute("description")??"",r=this._config.confirmText??this.getAttribute("confirm-text")??"Confirm",s=this._config.cancelText??this.getAttribute("cancel-text")??"Cancel",o=this._config.loadingText??this.getAttribute("loading-text")??"Working...",n=!!((F=this._config.input)!=null&&F.enabled),T=((z=this._config.input)==null?void 0:z.label)||"Value",q=((I=this._config.input)==null?void 0:I.placeholder)||"",D=!!((E=this._config.input)!=null&&E.required),M=!!((C=this._config.checkbox)!=null&&C.enabled),O=((L=this._config.checkbox)==null?void 0:L.label)||"Remember this choice",V=this.state,f=this._runtimeError||this._config.errorMessage||this.getAttribute("error-message")||"",_=`ui-alert-title-${this._uid}`,k=`ui-alert-description-${this._uid}`,y=`ui-alert-error-${this._uid}`,H=!!this.querySelector('[slot="title"]'),W=!!this.querySelector('[slot="description"]'),P=!!this.querySelector('[slot="icon"]'),R=!!this.querySelector('[slot="footer"]'),j=!!this.querySelector('[slot="content"]'),b=H||!!t,m=W||!!e,K=P||b||m,U=this._config.showCancel??this.dismissible,Y=this._config.showClose??this.dismissible,N=this.tone,Z=this.getAttribute("aria-label")||"",G=this.getAttribute("aria-labelledby")||"",w=this.getAttribute("aria-describedby")||"",v=G||(b?_:""),A=Z||(v?"":t||e||"Dialog"),u=[];w?u.push(w):(m&&u.push(k),f&&u.push(y));const d=V==="loading";this.setContent(`
|
|
501
|
-
<style>${
|
|
500
|
+
`,Y='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function f(i,t){if(i==null)return t;const e=i.trim().toLowerCase();return e!=="false"&&e!=="0"&&e!=="off"}function a(i){return String(i).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function N(i){return i==="info"||i==="success"||i==="warning"||i==="danger"?i:"neutral"}function U(i){return i==="sm"||i==="1"?"sm":i==="lg"||i==="3"?"lg":"md"}function Z(i){return i==="soft"||i==="outline"||i==="solid"?i:"surface"}function G(i){return i==="none"||i==="high"?i:"low"}function J(i){return i==="none"?"none":"line"}function Q(i,t="var(--base-alert-dialog-radius, var(--ui-radius, 4px))"){if(i==null)return t;const e=i.trim().toLowerCase();return e?e==="full"||e==="pill"?"999px":/^-?\d+(\.\d+)?$/.test(e)?`${e}px`:i:t}const X=new Set(["tone","size","variant","elevation","indicator","radius"]);function tt(i){return i==="success"?'<svg width="16" height="16" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M5 10.2 8.3 13.4 15 6.8"></path></svg>':i==="warning"?'<svg width="16" height="16" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M10 3.6 17 16.4H3L10 3.6Z"></path><path d="M10 8v3.4"></path><circle cx="10" cy="14.1" r="0.9" fill="currentColor" stroke="none"></circle></svg>':i==="danger"?'<svg width="16" height="16" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="10" r="7.1"></circle><path d="m7.5 7.5 5 5M12.5 7.5l-5 5"></path></svg>':i==="info"?'<svg width="16" height="16" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="10" r="7.1"></circle><path d="M10 13v-3.8"></path><circle cx="10" cy="6.5" r="0.9" fill="currentColor" stroke="none"></circle></svg>':'<svg width="16" height="16" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M6 10h8"></path><circle cx="10" cy="10" r="7.1"></circle></svg>'}function c(){return typeof window<"u"&&typeof document<"u"}function z(){if(!c())return null;const i=document.activeElement;return i instanceof HTMLElement?i:null}function _(i){return typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>i()):window.setTimeout(i,16)}function h(i){if(i){if(typeof cancelAnimationFrame=="function"){cancelAnimationFrame(i);return}window.clearTimeout(i)}}const l=class l extends j.ElementBase{constructor(){super(),this._lastActive=null,this._active=!1,this._terminalEmitted=!1,this._closeMeta=null,this._uid=Math.random().toString(36).slice(2,10),this._dialogId="",this._config={},this._inputValue="",this._checked=!1,this._runtimeError="",this._activeHeadless=!1,this._focusInitialFrame=0,this._restoreFocusFrame=0,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusIn=this._onFocusIn.bind(this),this._onInput=this._onInput.bind(this),this._dialogId=this._uid}static get observedAttributes(){return["open","headless","dismissible","close-on-esc","close-on-backdrop","lock-while-loading","role","tone","size","variant","elevation","indicator","radius","state","aria-label","aria-labelledby","aria-describedby","initial-focus","title","description","confirm-text","cancel-text","loading-text","error-message"]}connectedCallback(){super.connectedCallback(),this.root.addEventListener("click",this._onClick),this.root.addEventListener("keydown",this._onKeyDown),this.root.addEventListener("input",this._onInput),this._syncFromAttributes(),this._syncVisualTokens(),this._syncOpenState()}disconnectedCallback(){this.root.removeEventListener("click",this._onClick),this.root.removeEventListener("keydown",this._onKeyDown),this.root.removeEventListener("input",this._onInput),this._focusInitialFrame&&(h(this._focusInitialFrame),this._focusInitialFrame=0),this._restoreFocusFrame&&(h(this._restoreFocusFrame),this._restoreFocusFrame=0),this._active&&!this._terminalEmitted&&this.close("dismiss","unmount"),this._deactivate(),super.disconnectedCallback()}attributeChangedCallback(t,e,r){if(e!==r){if(X.has(t)){this._syncVisualTokens();return}if(t==="headless"){this._syncActiveEnvironment(),this.requestRender();return}if(t==="open"){this._syncOpenState();return}t==="state"&&r!=="error"&&(this._runtimeError=""),this._syncFromAttributes(),this.isConnected&&this.requestRender()}}get open(){return this.hasAttribute("open")}set open(t){t?this.setAttribute("open",""):this.close("dismiss","programmatic")}get headless(){return this.hasAttribute("headless")}set headless(t){t?this.setAttribute("headless",""):this.removeAttribute("headless")}get dismissible(){return f(this.getAttribute("dismissible"),!0)}set dismissible(t){this.setAttribute("dismissible",String(t))}get closeOnEsc(){return f(this.getAttribute("close-on-esc"),this.dismissible)}set closeOnEsc(t){this.setAttribute("close-on-esc",String(t))}get closeOnBackdrop(){return f(this.getAttribute("close-on-backdrop"),this.dismissible)}set closeOnBackdrop(t){this.setAttribute("close-on-backdrop",String(t))}get lockWhileLoading(){return f(this.getAttribute("lock-while-loading"),!0)}set lockWhileLoading(t){this.setAttribute("lock-while-loading",String(t))}get roleType(){return this.getAttribute("role")==="dialog"?"dialog":"alertdialog"}set roleType(t){this.setAttribute("role",t)}get tone(){return N(this.getAttribute("tone"))}set tone(t){if(t==="neutral"){this.removeAttribute("tone");return}this.setAttribute("tone",t)}get size(){return U(this.getAttribute("size"))}set size(t){if(t==="md"){this.removeAttribute("size");return}this.setAttribute("size",t)}get variant(){return Z(this.getAttribute("variant"))}set variant(t){if(t==="surface"){this.removeAttribute("variant");return}this.setAttribute("variant",t)}get elevation(){return G(this.getAttribute("elevation"))}set elevation(t){if(t==="low"){this.removeAttribute("elevation");return}this.setAttribute("elevation",t)}get indicator(){return J(this.getAttribute("indicator"))}set indicator(t){if(t==="line"){this.removeAttribute("indicator");return}this.setAttribute("indicator",t)}get radius(){return this.getAttribute("radius")||""}set radius(t){if(!t){this.removeAttribute("radius");return}this.setAttribute("radius",t)}get state(){const t=this.getAttribute("state");return t==="loading"||t==="error"?t:"idle"}set state(t){if(t==="idle"){this.removeAttribute("state");return}this.setAttribute("state",t)}get initialFocus(){return this.getAttribute("initial-focus")||this._config.initialFocus||""}set initialFocus(t){if(!t){this.removeAttribute("initial-focus");return}this.setAttribute("initial-focus",t)}get dialogId(){return this._dialogId}set dialogId(t){this._dialogId=t||this._uid,this.requestRender()}get config(){return this._config}set config(t){this._config=t||{},this._config.id&&(this._dialogId=this._config.id),this._config.dismissible!=null&&(this.dismissible=!!this._config.dismissible),this._config.closeOnEsc!=null&&(this.closeOnEsc=!!this._config.closeOnEsc),this._config.closeOnBackdrop!=null&&(this.closeOnBackdrop=!!this._config.closeOnBackdrop),this._config.lockWhileLoading!=null&&(this.lockWhileLoading=!!this._config.lockWhileLoading),this._config.role&&(this.roleType=this._config.role),this._config.tone&&(this.tone=this._config.tone),this._config.size&&(this.size=this._config.size),this._config.variant&&(this.variant=this._config.variant),this._config.elevation&&(this.elevation=this._config.elevation),this._config.indicator&&(this.indicator=this._config.indicator),this._config.radius!=null&&(this.radius=String(this._config.radius)),this._config.ariaLabel&&this.setAttribute("aria-label",this._config.ariaLabel),this._config.ariaLabelledby&&this.setAttribute("aria-labelledby",this._config.ariaLabelledby),this._config.ariaDescribedby&&this.setAttribute("aria-describedby",this._config.ariaDescribedby),this._config.initialFocus&&(this.initialFocus=this._config.initialFocus),this._config.headless!=null&&(this.headless=!!this._config.headless),this._inputValue=this._config.input?.value??this._inputValue,this._checked=this._config.checkbox?.checked??this._checked,this._runtimeError=this._config.errorMessage||"",this._syncVisualTokens(),this.requestRender()}getInputValue(){return this.root.querySelector(".input")?.value??this._inputValue}setInputValue(t){this._inputValue=t;const e=this.root.querySelector(".input");e&&(e.value=t)}getChecked(){return this.root.querySelector(".checkbox-input")?.checked??this._checked}setChecked(t){this._checked=t;const e=this.root.querySelector(".checkbox-input");e&&(e.checked=t)}setError(t){this._runtimeError=t,this.state=t?"error":"idle",this.requestRender()}clearError(){this._runtimeError="",this.state==="error"&&(this.state="idle"),this.requestRender()}close(t="dismiss",e,r){this._terminalEmitted||(this._closeMeta={action:t,source:e,reason:r},this.hasAttribute("open")&&this.removeAttribute("open"),this._syncOpenState())}_syncFromAttributes(){this.hasAttribute("role")||this.setAttribute("role","alertdialog")}_syncVisualTokens(){this.style.setProperty("--ui-alert-radius",Q(this.getAttribute("radius")))}_syncOpenState(){const t=this.hasAttribute("open");if(t&&!this._active){this._activate();return}!t&&this._active&&this._deactivate()}_activate(){this._active=!0,this._activeHeadless=this.headless,this._terminalEmitted=!1,this._closeMeta=null,l._openStack.includes(this)||l._openStack.push(this),this._lastActive=this.headless?null:z(),this.headless||p.acquireBodyScrollLock(),c()&&!this.headless&&document.addEventListener("focusin",this._onFocusIn,!0);const t=this.dialogId||this._uid;this._dispatchWithLegacy("ui-open","open",{id:t}),this.headless||(this._focusInitialFrame&&h(this._focusInitialFrame),this._focusInitialFrame=_(()=>{this._focusInitialFrame=0,this._focusInitial()})),this.requestRender()}_deactivate(){if(!this._active)return;this._active=!1;const t=l._openStack.lastIndexOf(this);if(t>=0&&l._openStack.splice(t,1),c()&&!this._activeHeadless&&document.removeEventListener("focusin",this._onFocusIn,!0),this._activeHeadless||p.releaseBodyScrollLock(),!this._terminalEmitted){const r=this._closeMeta||{action:"dismiss",source:"abort"},s=this.dialogId||this._uid;r.action==="cancel"?this._dispatchWithLegacy("ui-cancel","cancel",{id:s}):r.action==="dismiss"&&this._dispatchWithLegacy("ui-dismiss","dismiss",{id:s,source:r.source||"abort",reason:r.reason}),this._dispatchWithLegacy("ui-close","close",{id:s,action:r.action,source:r.source,reason:r.reason}),this._terminalEmitted=!0,this._closeMeta=null}const e=this._lastActive;this._lastActive=null,e&&!this._activeHeadless&&(this._restoreFocusFrame&&h(this._restoreFocusFrame),this._restoreFocusFrame=_(()=>{this._restoreFocusFrame=0;try{e.focus()}catch{}})),this._activeHeadless=!1,this.requestRender()}_syncActiveEnvironment(){if(this._active&&this.headless!==this._activeHeadless){if(this.headless){c()&&document.removeEventListener("focusin",this._onFocusIn,!0),p.releaseBodyScrollLock(),this._lastActive=null,this._activeHeadless=!0;return}this._lastActive=z(),p.acquireBodyScrollLock(),c()&&document.addEventListener("focusin",this._onFocusIn,!0),this._activeHeadless=!1,this._focusInitialFrame&&h(this._focusInitialFrame),this._focusInitialFrame=_(()=>{this._focusInitialFrame=0,this._focusInitial()})}}_dispatchWithLegacy(t,e,r,s=!1){const o=new CustomEvent(t,{detail:r,bubbles:!0,composed:!0,cancelable:s});this.dispatchEvent(o);const n=new CustomEvent(e,{detail:r,bubbles:!0,composed:!0,cancelable:s});return this.dispatchEvent(n),o}_isTopMost(){if(!this._active)return!1;const t=l._openStack;return t.length>0&&t[t.length-1]===this}_queryPanel(){return this.root.querySelector(".dialog")}_collectFocusable(t){return Array.from(t.querySelectorAll(Y)).filter(e=>{if(e.disabled||e.getAttribute("aria-hidden")==="true")return!1;const s=c()?window.getComputedStyle(e):null;return!(s&&(s.display==="none"||s.visibility==="hidden"))})}_focusInitial(){if(!this.open)return;const t=this._queryPanel();if(!t)return;const e=this.initialFocus;if(e){const n=t.querySelector(e);if(n&&typeof n.focus=="function"){n.focus();return}}const r=this._collectFocusable(t),o=r.find(n=>n.hasAttribute("autofocus"))||r[0]||t;!o.hasAttribute("tabindex")&&o===t&&o.setAttribute("tabindex","-1");try{o.focus()}catch{}}_handleTab(t){if(t.key!=="Tab")return;const e=this._queryPanel();if(!e)return;const r=this._collectFocusable(e);if(!r.length){t.preventDefault(),e.focus();return}const s=this.root.activeElement||document.activeElement,o=r[0],n=r[r.length-1];if(t.shiftKey){(s===o||!s||!e.contains(s))&&(t.preventDefault(),n.focus());return}s===n&&(t.preventDefault(),o.focus())}_onFocusIn(t){if(!this.open||!this._isTopMost())return;const e=this._queryPanel();if(!e)return;const r=t.target;(typeof t.composedPath=="function"?t.composedPath():[]).includes(e)||r&&e.contains(r)||this._focusInitial()}_onInput(t){const e=t.target;e&&(e.classList.contains("input")&&(this._inputValue=e.value),e.classList.contains("checkbox-input")&&(this._checked=e.checked),this._dispatchWithLegacy("ui-change","change",{id:this.dialogId||this._uid,inputValue:this._inputValue,checked:this._checked}))}_isInteractionLocked(){return this.state==="loading"&&this.lockWhileLoading}_requestDismiss(t,e){this._isInteractionLocked()||this.close("dismiss",t,e)}_handleConfirm(){const t={id:this.dialogId||this._uid,inputValue:this.getInputValue(),checked:this.getChecked()};this._dispatchWithLegacy("ui-confirm","confirm",t,!0).defaultPrevented||this.close("confirm")}_handleCancel(){this._isInteractionLocked()||this.close("cancel")}_onClick(t){if(!this.open||!this._isTopMost())return;const e=t.target;if(e){if(e.classList.contains("backdrop")&&this.closeOnBackdrop){this._requestDismiss("backdrop");return}if(e.closest(".close")){this._requestDismiss("close-icon");return}if(e.closest(".btn-confirm")){this._handleConfirm();return}e.closest(".btn-cancel")&&this._handleCancel()}}_onKeyDown(t){if(!(!this.open||!this._isTopMost())){if(t.key==="Escape"){if(!this.closeOnEsc)return;t.preventDefault(),t.stopPropagation(),this._requestDismiss("esc");return}this._handleTab(t)}}render(){if(!this.open){this.setContent("");return}const t=this._config.title??this.getAttribute("title")??"",e=this._config.description??this.getAttribute("description")??"",r=this._config.confirmText??this.getAttribute("confirm-text")??"Confirm",s=this._config.cancelText??this.getAttribute("cancel-text")??"Cancel",o=this._config.loadingText??this.getAttribute("loading-text")??"Working...",n=!!this._config.input?.enabled,E=this._config.input?.label||"Value",I=this._config.input?.placeholder||"",C=!!this._config.input?.required,L=!!this._config.checkbox?.enabled,S=this._config.checkbox?.label||"Remember this choice",B=this.state,b=this._runtimeError||this._config.errorMessage||this.getAttribute("error-message")||"",k=`ui-alert-title-${this._uid}`,y=`ui-alert-description-${this._uid}`,w=`ui-alert-error-${this._uid}`,$=!!this.querySelector('[slot="title"]'),T=!!this.querySelector('[slot="description"]'),q=!!this.querySelector('[slot="icon"]'),M=!!this.querySelector('[slot="footer"]'),O=!!this.querySelector('[slot="content"]'),m=$||!!t,v=T||!!e,D=q||m||v,V=this._config.showCancel??this.dismissible,H=this._config.showClose??this.dismissible,W=this.tone,P=this.getAttribute("aria-label")||"",R=this.getAttribute("aria-labelledby")||"",A=this.getAttribute("aria-describedby")||"",x=R||(m?k:""),F=P||(x?"":t||e||"Dialog"),u=[];A?u.push(A):(v&&u.push(y),b&&u.push(w));const d=B==="loading";this.setContent(`
|
|
501
|
+
<style>${K}</style>
|
|
502
502
|
<div class="backdrop" part="backdrop" role="presentation" data-open="${String(this.open)}">
|
|
503
503
|
<section
|
|
504
504
|
class="dialog"
|
|
505
505
|
part="dialog"
|
|
506
506
|
role="${a(this.roleType)}"
|
|
507
507
|
aria-modal="true"
|
|
508
|
-
${
|
|
509
|
-
${
|
|
508
|
+
${F?`aria-label="${a(F)}"`:""}
|
|
509
|
+
${x?`aria-labelledby="${a(x)}"`:""}
|
|
510
510
|
${u.length?`aria-describedby="${a(u.join(" "))}"`:""}
|
|
511
511
|
tabindex="-1"
|
|
512
512
|
>
|
|
513
|
-
${
|
|
513
|
+
${H?`<button class="close" part="close" aria-label="Close dialog">
|
|
514
514
|
<svg width="14" height="14" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round">
|
|
515
515
|
<path d="m6 6 8 8M14 6l-8 8"></path>
|
|
516
516
|
</svg>
|
|
517
517
|
</button>`:""}
|
|
518
518
|
|
|
519
|
-
${
|
|
519
|
+
${D?`<header class="header">
|
|
520
520
|
<div class="header-main">
|
|
521
521
|
<span class="icon-wrap" part="icon-wrap" aria-hidden="true">
|
|
522
522
|
<span class="icon" part="icon">
|
|
523
|
-
<slot name="icon">${
|
|
523
|
+
<slot name="icon">${tt(W)}</slot>
|
|
524
524
|
</span>
|
|
525
525
|
</span>
|
|
526
526
|
<div class="heading">
|
|
527
|
-
${
|
|
528
|
-
${
|
|
527
|
+
${m?`<h2 id="${k}" class="title" part="title"><slot name="title">${a(t)}</slot></h2>`:""}
|
|
528
|
+
${v?`<p id="${y}" class="description" part="description"><slot name="description">${a(e)}</slot></p>`:""}
|
|
529
529
|
</div>
|
|
530
530
|
</div>
|
|
531
531
|
</header>`:""}
|
|
532
532
|
|
|
533
533
|
<div class="content" part="content">
|
|
534
|
-
${
|
|
534
|
+
${O?'<slot name="content"></slot>':"<slot></slot>"}
|
|
535
535
|
|
|
536
536
|
${n?`<label class="input-wrap">
|
|
537
|
-
<span class="label">${a(
|
|
537
|
+
<span class="label">${a(E)}</span>
|
|
538
538
|
<input
|
|
539
539
|
class="input"
|
|
540
540
|
part="input"
|
|
541
541
|
type="text"
|
|
542
542
|
value="${a(this.getInputValue())}"
|
|
543
|
-
placeholder="${a(
|
|
544
|
-
${
|
|
543
|
+
placeholder="${a(I)}"
|
|
544
|
+
${C?"required":""}
|
|
545
545
|
${d?"disabled":""}
|
|
546
546
|
/>
|
|
547
547
|
</label>`:""}
|
|
548
548
|
|
|
549
|
-
${
|
|
549
|
+
${L?`<label class="checkbox" part="checkbox">
|
|
550
550
|
<span class="checkbox-line">
|
|
551
551
|
<input class="checkbox-input" type="checkbox" ${this.getChecked()?"checked":""} ${d?"disabled":""} />
|
|
552
|
-
<span>${a(
|
|
552
|
+
<span>${a(S)}</span>
|
|
553
553
|
</span>
|
|
554
554
|
</label>`:""}
|
|
555
555
|
</div>
|
|
556
556
|
|
|
557
|
-
<div class="error" id="${
|
|
557
|
+
<div class="error" id="${w}" part="error" aria-live="polite" data-empty="${String(!b)}">${a(b)}</div>
|
|
558
558
|
|
|
559
559
|
<footer class="footer" part="footer">
|
|
560
560
|
${d?`<span class="loading"><span class="spinner" aria-hidden="true"></span><span>${a(o)}</span></span>`:'<span aria-hidden="true"></span>'}
|
|
561
561
|
|
|
562
|
-
${
|
|
562
|
+
${M?'<slot name="footer"></slot>':`${V?`<button class="btn btn-cancel" part="cancel" type="button" ${d?"disabled":""}>${a(s)}</button>`:""}
|
|
563
563
|
<button class="btn btn-confirm" part="confirm" type="button" ${d?"disabled":""}>${a(r)}</button>`}
|
|
564
564
|
</footer>
|
|
565
565
|
</section>
|
|
566
566
|
</div>
|
|
567
|
-
`)}};
|
|
567
|
+
`)}};l._openStack=[];let g=l;typeof customElements<"u"&&!customElements.get("ui-alert-dialog")&&customElements.define("ui-alert-dialog",g);exports.UIAlertDialog=g;
|