@editora/ui-core 0.1.20 → 0.1.22
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/accordion.cjs.js +3 -3
- package/dist/accordion.esm.js +3 -3
- package/dist/alert-dialog.cjs.js +32 -32
- package/dist/alert-dialog.esm.js +95 -75
- package/dist/alert.cjs.js +6 -6
- package/dist/alert.esm.js +6 -6
- package/dist/animated-list.cjs.js +4 -4
- package/dist/animated-list.esm.js +4 -4
- package/dist/animated-text.cjs.js +4 -4
- package/dist/animated-text.esm.js +4 -4
- package/dist/app-header.cjs.js +3 -3
- package/dist/app-header.esm.js +3 -3
- package/dist/aspect-ratio.cjs.js +3 -3
- package/dist/aspect-ratio.esm.js +3 -3
- package/dist/avatar.cjs.js +14 -14
- package/dist/avatar.esm.js +31 -29
- package/dist/badge.cjs.js +4 -4
- package/dist/badge.esm.js +4 -4
- package/dist/block-controls.cjs.js +4 -4
- package/dist/block-controls.esm.js +4 -4
- package/dist/box.cjs.js +2 -2
- package/dist/box.esm.js +2 -2
- package/dist/breadcrumb.cjs.js +5 -5
- package/dist/breadcrumb.esm.js +5 -5
- package/dist/button.cjs.js +1 -1
- package/dist/button.esm.js +1 -1
- package/dist/{calendar-DLY4acgn.mjs → calendar-DbxYRdlv.mjs} +227 -183
- package/dist/{calendar-Dkof-FTK.js → calendar-Qa-cFOp3.js} +74 -35
- package/dist/calendar.cjs.js +1 -1
- package/dist/calendar.esm.js +1 -1
- package/dist/card.cjs.js +8 -8
- package/dist/card.esm.js +63 -20
- package/dist/chart.cjs.js +4 -4
- package/dist/chart.esm.js +6 -6
- package/dist/checkbox.cjs.js +2 -2
- package/dist/checkbox.esm.js +2 -2
- package/dist/collapsible.cjs.js +7 -7
- package/dist/collapsible.esm.js +7 -7
- package/dist/collection.cjs.js +1 -1
- package/dist/collection.esm.js +27 -23
- package/dist/color-picker.cjs.js +34 -14
- package/dist/color-picker.esm.js +89 -67
- package/dist/combobox.cjs.js +29 -27
- package/dist/combobox.esm.js +51 -45
- package/dist/command.cjs.js +2 -2
- package/dist/command.esm.js +2 -2
- package/dist/components/ui-alert-dialog.d.ts +1 -0
- package/dist/components/ui-alert-dialog.d.ts.map +1 -1
- package/dist/components/ui-avatar.d.ts +1 -0
- package/dist/components/ui-avatar.d.ts.map +1 -1
- package/dist/components/ui-button.d.ts +1 -0
- package/dist/components/ui-button.d.ts.map +1 -1
- package/dist/components/ui-calendar.d.ts.map +1 -1
- package/dist/components/ui-card.d.ts +3 -0
- package/dist/components/ui-card.d.ts.map +1 -1
- package/dist/components/ui-checkbox.d.ts.map +1 -1
- package/dist/components/ui-collection.d.ts.map +1 -1
- package/dist/components/ui-color-picker.d.ts.map +1 -1
- package/dist/components/ui-combobox.d.ts.map +1 -1
- package/dist/components/ui-data-table.d.ts.map +1 -1
- package/dist/components/ui-date-field.d.ts.map +1 -1
- package/dist/components/ui-date-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-time-picker.d.ts.map +1 -1
- package/dist/components/ui-date-time-picker.d.ts.map +1 -1
- package/dist/components/ui-dock.d.ts +1 -0
- package/dist/components/ui-dock.d.ts.map +1 -1
- package/dist/components/ui-drawer.d.ts.map +1 -1
- package/dist/components/ui-dropdown.d.ts.map +1 -1
- package/dist/components/ui-field.d.ts.map +1 -1
- package/dist/components/ui-file-upload.d.ts.map +1 -1
- package/dist/components/ui-gantt.d.ts.map +1 -1
- package/dist/components/ui-input.d.ts.map +1 -1
- package/dist/components/ui-menu.d.ts.map +1 -1
- package/dist/components/ui-multi-select.d.ts.map +1 -1
- package/dist/components/ui-number-field.d.ts.map +1 -1
- package/dist/components/ui-password-field.d.ts.map +1 -1
- package/dist/components/ui-pin-input.d.ts +1 -0
- package/dist/components/ui-pin-input.d.ts.map +1 -1
- package/dist/components/ui-placement-grid.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-progress.d.ts.map +1 -1
- package/dist/components/ui-radio.d.ts.map +1 -1
- package/dist/components/ui-rating.d.ts +1 -0
- package/dist/components/ui-rating.d.ts.map +1 -1
- package/dist/components/ui-select.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-switch.d.ts.map +1 -1
- package/dist/components/ui-table.d.ts.map +1 -1
- package/dist/components/ui-tabs.d.ts +1 -0
- package/dist/components/ui-tabs.d.ts.map +1 -1
- package/dist/components/ui-tags-input.d.ts +1 -0
- package/dist/components/ui-tags-input.d.ts.map +1 -1
- package/dist/components/ui-textarea.d.ts.map +1 -1
- package/dist/components/ui-time-field.d.ts.map +1 -1
- package/dist/components/ui-toggle-group.d.ts.map +1 -1
- package/dist/components/ui-toggle.d.ts.map +1 -1
- package/dist/components/ui-tree.d.ts.map +1 -1
- package/dist/components/ui-wizard.d.ts.map +1 -1
- package/dist/context-menu.cjs.js +3 -3
- package/dist/context-menu.esm.js +4 -4
- package/dist/control-name-BmoI1m3a.js +1 -0
- package/dist/control-name-Bpj7F34X.mjs +48 -0
- package/dist/data-table.cjs.js +5 -2
- package/dist/data-table.esm.js +145 -142
- package/dist/date-field.cjs.js +5 -5
- package/dist/date-field.esm.js +34 -31
- package/dist/date-picker.cjs.js +16 -16
- package/dist/date-picker.esm.js +48 -44
- package/dist/date-range-picker.cjs.js +5 -5
- package/dist/date-range-picker.esm.js +120 -118
- package/dist/date-range-time-picker.cjs.js +22 -22
- package/dist/date-range-time-picker.esm.js +88 -84
- package/dist/date-time-picker.cjs.js +26 -26
- package/dist/date-time-picker.esm.js +105 -101
- package/dist/{date-time-utils-Dmost5Ee.js → date-time-utils-BzfTpeU-.js} +1 -1
- package/dist/{date-time-utils-y1N2gvG2.mjs → date-time-utils-Cps2aSu2.mjs} +1 -1
- package/dist/description.cjs.js +3 -3
- package/dist/description.esm.js +3 -3
- package/dist/dialog.cjs.js +2 -2
- package/dist/dialog.esm.js +2 -2
- package/dist/dock.cjs.js +12 -12
- package/dist/dock.esm.js +72 -74
- package/dist/drawer.cjs.js +19 -19
- package/dist/drawer.esm.js +58 -58
- package/dist/dropdown.cjs.js +13 -13
- package/dist/dropdown.esm.js +49 -48
- package/dist/empty-state.cjs.js +3 -3
- package/dist/empty-state.esm.js +3 -3
- package/dist/field-error.cjs.js +1 -1
- package/dist/field-error.esm.js +1 -1
- package/dist/field.cjs.js +12 -12
- package/dist/field.esm.js +84 -75
- package/dist/fieldset.cjs.js +4 -4
- package/dist/fieldset.esm.js +4 -4
- package/dist/file-upload.cjs.js +3 -3
- package/dist/file-upload.esm.js +5 -3
- package/dist/floating-toolbar.cjs.js +8 -8
- package/dist/floating-toolbar.esm.js +9 -9
- package/dist/form.cjs.js +11 -11
- package/dist/form.esm.js +11 -11
- package/dist/gantt.cjs.js +43 -32
- package/dist/gantt.esm.js +99 -88
- package/dist/icon-cloud.cjs.js +3 -3
- package/dist/icon-cloud.esm.js +3 -3
- package/dist/icon.cjs.js +1 -1
- package/dist/icon.esm.js +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +121 -118
- package/dist/inline-edit.cjs.js +1 -1
- package/dist/inline-edit.esm.js +1 -1
- package/dist/input.cjs.js +14 -14
- package/dist/input.esm.js +39 -32
- package/dist/label.cjs.js +3 -3
- package/dist/label.esm.js +3 -3
- package/dist/{listbox-B6QgECax.js → listbox-CTpRpuF7.js} +1 -1
- package/dist/{listbox-DJamVeFj.mjs → listbox-hMVOhKHC.mjs} +1 -1
- package/dist/listbox.cjs.js +1 -1
- package/dist/listbox.esm.js +1 -1
- package/dist/marquee.cjs.js +3 -3
- package/dist/marquee.esm.js +3 -3
- package/dist/{menu-item-styles-CbNUEwP2.js → menu-item-styles-B4onAr4C.js} +3 -3
- package/dist/{menu-item-styles-CZiPwPwl.mjs → menu-item-styles-IGSFLAHu.mjs} +3 -3
- package/dist/menu.cjs.js +7 -7
- package/dist/menu.esm.js +29 -28
- package/dist/menubar.cjs.js +1 -1
- package/dist/menubar.esm.js +2 -2
- package/dist/meter.cjs.js +1 -1
- package/dist/meter.esm.js +1 -1
- package/dist/multi-select.cjs.js +18 -18
- package/dist/multi-select.esm.js +82 -66
- package/dist/navigation-menu.cjs.js +1 -1
- package/dist/navigation-menu.esm.js +1 -1
- package/dist/number-field.cjs.js +11 -13
- package/dist/number-field.esm.js +29 -27
- package/dist/number-ticker.cjs.js +4 -4
- package/dist/number-ticker.esm.js +4 -4
- package/dist/odometer.cjs.js +2 -2
- package/dist/odometer.esm.js +2 -2
- package/dist/orbiter.cjs.js +3 -3
- package/dist/orbiter.esm.js +3 -3
- package/dist/pagination.cjs.js +1 -1
- package/dist/pagination.esm.js +1 -1
- package/dist/password-field.cjs.js +23 -23
- package/dist/password-field.esm.js +48 -47
- package/dist/pin-input.cjs.js +8 -6
- package/dist/pin-input.esm.js +21 -15
- package/dist/placement-grid.cjs.js +4 -4
- package/dist/placement-grid.esm.js +58 -58
- package/dist/plugin-panel.cjs.js +1 -1
- package/dist/plugin-panel.esm.js +1 -1
- package/dist/popover.cjs.js +5 -5
- package/dist/popover.esm.js +4 -4
- package/dist/portal.cjs.js +3 -3
- package/dist/portal.esm.js +11 -10
- package/dist/positioner.cjs.js +2 -2
- package/dist/positioner.esm.js +15 -14
- package/dist/primitives/auto-scroll.d.ts +9 -0
- package/dist/primitives/auto-scroll.d.ts.map +1 -0
- package/dist/primitives/control-name.d.ts +30 -0
- package/dist/primitives/control-name.d.ts.map +1 -0
- package/dist/primitives/selector.d.ts +4 -0
- package/dist/primitives/selector.d.ts.map +1 -0
- package/dist/primitives/trigger.d.ts +2 -0
- package/dist/primitives/trigger.d.ts.map +1 -0
- package/dist/progress.cjs.js +4 -4
- package/dist/progress.esm.js +20 -18
- package/dist/quick-actions.cjs.js +3 -3
- package/dist/quick-actions.esm.js +3 -3
- package/dist/radio-group.cjs.js +1 -1
- package/dist/radio-group.esm.js +1 -1
- package/dist/radio.cjs.js +2 -2
- package/dist/radio.esm.js +2 -2
- package/dist/rating.cjs.js +17 -16
- package/dist/rating.esm.js +91 -92
- package/dist/{runtime-D1gFh1fS.mjs → runtime-CFnK53iC.mjs} +133 -94
- package/dist/runtime-DwE-tizc.js +1 -0
- package/dist/runtime.cjs.js +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.esm.js +29 -26
- package/dist/select.cjs.js +20 -19
- package/dist/select.esm.js +36 -32
- package/dist/selection-popup.cjs.js +2 -2
- package/dist/selection-popup.esm.js +2 -2
- package/dist/selector-BvAh35ve.js +1 -0
- package/dist/selector-WI8pD7YO.mjs +18 -0
- package/dist/separator.cjs.js +7 -7
- package/dist/separator.esm.js +7 -7
- package/dist/sidebar.cjs.js +7 -7
- package/dist/sidebar.esm.js +7 -7
- package/dist/skeleton.cjs.js +7 -7
- package/dist/skeleton.esm.js +7 -7
- package/dist/slider.cjs.js +3 -3
- package/dist/slider.esm.js +3 -3
- package/dist/slot.cjs.js +3 -3
- package/dist/slot.esm.js +3 -3
- package/dist/sortable.cjs.js +61 -48
- package/dist/sortable.esm.js +636 -554
- package/dist/spinning-text.cjs.js +3 -3
- package/dist/spinning-text.esm.js +3 -3
- package/dist/split-button.cjs.js +1 -1
- package/dist/split-button.esm.js +1 -1
- package/dist/stepper.cjs.js +1 -1
- package/dist/stepper.esm.js +1 -1
- package/dist/switch.cjs.js +10 -12
- package/dist/switch.esm.js +10 -12
- package/dist/table.cjs.js +9 -6
- package/dist/table.esm.js +46 -43
- package/dist/tabs.cjs.js +22 -23
- package/dist/tabs.esm.js +116 -112
- package/dist/tags-input.cjs.js +9 -9
- package/dist/tags-input.esm.js +32 -25
- package/dist/textarea.cjs.js +13 -13
- package/dist/textarea.esm.js +46 -31
- package/dist/theme.d.ts +18 -0
- package/dist/theme.d.ts.map +1 -1
- package/dist/time-field.cjs.js +5 -5
- package/dist/time-field.esm.js +21 -18
- package/dist/time-picker.cjs.js +4 -4
- package/dist/time-picker.esm.js +5 -5
- package/dist/timeline.cjs.js +2 -2
- package/dist/timeline.esm.js +4 -4
- package/dist/toast.cjs.js +6 -6
- package/dist/toast.esm.js +13 -13
- package/dist/toggle-group.cjs.js +5 -6
- package/dist/toggle-group.esm.js +63 -60
- package/dist/toggle.cjs.js +18 -18
- package/dist/toggle.esm.js +32 -31
- package/dist/tooltip.cjs.js +4 -4
- package/dist/tooltip.esm.js +4 -4
- package/dist/transfer-list.cjs.js +32 -32
- package/dist/transfer-list.esm.js +57 -57
- package/dist/tree-7qbVnpGp.js +39 -0
- package/dist/{tree-B3kE8ESs.mjs → tree-Deoft-kO.mjs} +34 -33
- package/dist/tree.cjs.js +1 -1
- package/dist/tree.esm.js +1 -1
- package/dist/trigger-BjnxLCeQ.mjs +9 -0
- package/dist/trigger-DkPsKxsP.js +1 -0
- package/dist/{ui-button-rXQOS9QJ.js → ui-button-BInsgSbr.js} +27 -26
- package/dist/{ui-button-Q0GNNWKC.mjs → ui-button-rfiuUnUD.mjs} +65 -48
- package/dist/{ui-icon-YI6lyuqU.mjs → ui-icon-BSi_GtqO.mjs} +2 -2
- package/dist/{ui-icon-BzVNC_lr.js → ui-icon-Bvt9oIIR.js} +5 -5
- package/dist/wizard.cjs.js +12 -13
- package/dist/wizard.esm.js +17 -15
- package/package.json +1 -1
- package/dist/runtime-CTaOSmBj.js +0 -1
- package/dist/tree-Dx_kv_ih.js +0 -39
package/dist/tabs.cjs.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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 y=require("./ElementBase-EV6mVBUV.js"),d=require("./roving-focus-group-BdJ_4Njm.js"),_=`
|
|
2
2
|
:host {
|
|
3
3
|
--ui-tabs-nav-bg: var(--ui-color-surface, #ffffff);
|
|
4
4
|
--ui-tabs-panel-bg: var(--ui-color-surface, #ffffff);
|
|
5
5
|
--ui-tabs-border: var(--ui-color-border, #cbd5e1);
|
|
6
6
|
--ui-tabs-text: var(--ui-color-text, #0f172a);
|
|
7
|
-
--ui-tabs-muted: var(--ui-color-muted, #
|
|
7
|
+
--ui-tabs-muted: var(--ui-color-muted, #526175);
|
|
8
8
|
--ui-tabs-accent: var(--ui-tabs-active-bg, var(--ui-color-primary, #2563eb));
|
|
9
9
|
--ui-tabs-active-text: color-mix(in srgb, var(--ui-tabs-accent) 82%, #0f172a 18%);
|
|
10
10
|
--ui-tabs-focus: var(--ui-color-focus-ring, #2563eb);
|
|
@@ -298,18 +298,18 @@
|
|
|
298
298
|
--ui-tabs-nav-bg: var(--ui-tabs-accent);
|
|
299
299
|
--ui-tabs-panel-bg: var(--ui-color-surface, #ffffff);
|
|
300
300
|
--ui-tabs-border: color-mix(in srgb, var(--ui-tabs-accent) 76%, #0f172a 24%);
|
|
301
|
-
--ui-tabs-muted: color-mix(in srgb, var(--ui-color-primary-foreground, #ffffff)
|
|
301
|
+
--ui-tabs-muted: color-mix(in srgb, var(--ui-color-primary-foreground, var(--ui-color-foreground-on-primary, #ffffff)) 94%, transparent);
|
|
302
302
|
--ui-tabs-active-text: color-mix(in srgb, var(--ui-tabs-accent) 78%, #0f172a 22%);
|
|
303
|
-
--ui-tabs-focus: color-mix(in srgb, var(--ui-color-primary-foreground, #ffffff) 72%, var(--ui-tabs-accent));
|
|
303
|
+
--ui-tabs-focus: color-mix(in srgb, var(--ui-color-primary-foreground, var(--ui-color-foreground-on-primary, #ffffff)) 72%, var(--ui-tabs-accent));
|
|
304
304
|
}
|
|
305
305
|
|
|
306
306
|
:host([variant="solid"]) .tab:hover {
|
|
307
|
-
background: color-mix(in srgb, var(--ui-color-primary-foreground, #ffffff) 14%, transparent);
|
|
308
|
-
color: var(--ui-color-primary-foreground, #ffffff);
|
|
307
|
+
background: color-mix(in srgb, var(--ui-color-primary-foreground, var(--ui-color-foreground-on-primary, #ffffff)) 14%, transparent);
|
|
308
|
+
color: var(--ui-color-primary-foreground, var(--ui-color-foreground-on-primary, #ffffff));
|
|
309
309
|
}
|
|
310
310
|
|
|
311
311
|
:host([variant="solid"]) .tab[aria-selected="true"] {
|
|
312
|
-
background: var(--ui-color-primary-foreground, #ffffff);
|
|
312
|
+
background: var(--ui-color-primary-foreground, var(--ui-color-foreground-on-primary, #ffffff));
|
|
313
313
|
border-color: color-mix(in srgb, var(--ui-tabs-accent) 44%, var(--ui-tabs-border));
|
|
314
314
|
color: var(--ui-tabs-active-text);
|
|
315
315
|
}
|
|
@@ -433,11 +433,11 @@
|
|
|
433
433
|
}
|
|
434
434
|
|
|
435
435
|
:host([tone="success"]) {
|
|
436
|
-
--ui-tabs-accent: var(--ui-color-success, #
|
|
436
|
+
--ui-tabs-accent: var(--ui-color-success, #15803d);
|
|
437
437
|
}
|
|
438
438
|
|
|
439
439
|
:host([tone="warning"]) {
|
|
440
|
-
--ui-tabs-accent: var(--ui-color-warning, #
|
|
440
|
+
--ui-tabs-accent: var(--ui-color-warning, #b45309);
|
|
441
441
|
}
|
|
442
442
|
|
|
443
443
|
:host([tone="danger"]) {
|
|
@@ -483,33 +483,32 @@
|
|
|
483
483
|
border-color: Highlight;
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
|
-
|
|
486
|
+
`,f="data-ui-tabs-auto-label";function p(h){return String(h).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function g(h){if(h==null)return!1;const t=String(h).toLowerCase();return t!=="false"&&t!=="0"&&t!=="off"}const w=new Set(["aria-label","aria-labelledby","orientation","activation","headless","variant","size","density","tone","stretched","shape","elevation","bare"]);class x extends y.ElementBase{constructor(){super(),this._uid=`ui-tabs-${Math.random().toString(36).slice(2,9)}`,this._observer=null,this._resizeObserver=null,this._isSyncing=!1,this._isSyncingSelectionAttributes=!1,this._focusIndex=-1,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onWindowResize=this._onWindowResize.bind(this)}static get observedAttributes(){return["selected","value","orientation","activation","headless","variant","size","density","tone","stretched","shape","elevation","loop","bare","aria-label","aria-labelledby"]}connectedCallback(){super.connectedCallback(),this.root.addEventListener("click",this._onClick),this.root.addEventListener("keydown",this._onKeyDown),this._observer=new MutationObserver(()=>{this._isSyncing||this.requestRender()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["slot","data-label","data-value","data-icon","data-disabled","disabled","data-active"]}),typeof ResizeObserver<"u"?(this._resizeObserver=new ResizeObserver(()=>this._syncSelectionUi()),this._resizeObserver.observe(this)):window.addEventListener("resize",this._onWindowResize),this._syncSelectionUi()}disconnectedCallback(){this.root.removeEventListener("click",this._onClick),this.root.removeEventListener("keydown",this._onKeyDown),this._observer&&(this._observer.disconnect(),this._observer=null),this._resizeObserver?(this._resizeObserver.disconnect(),this._resizeObserver=null):window.removeEventListener("resize",this._onWindowResize),super.disconnectedCallback()}attributeChangedCallback(t,e,r){if(e!==r){if(t==="selected"||t==="value"){this._isSyncingSelectionAttributes||this._syncSelectionUi();return}w.has(t)&&this.isConnected&&this.requestRender()}}get selected(){return this.getAttribute("selected")||"0"}set selected(t){const e=String(t);e?this.setAttribute("selected",e):this.removeAttribute("selected")}_sourceTabs(){return Array.from(this.querySelectorAll('[slot="tab"]'))}_sourcePanels(){return Array.from(this.querySelectorAll('[slot="panel"]'))}_tabsModel(){return this._sourceTabs().map((t,e)=>{const r=t.getAttribute("data-value")||t.getAttribute("value")||String(e),a=t.getAttribute("data-label")||t.textContent?.trim()||`Tab ${e+1}`,i=t.getAttribute("data-icon")||"",s=t.hasAttribute("disabled")||g(t.getAttribute("data-disabled")),c=`${this._uid}-tab-${e}`,b=`${this._uid}-panel-${e}`;return{index:e,value:r,label:a,icon:i,disabled:s,tabId:c,panelId:b}})}_resolveSelectedIndex(t){if(!t.length)return-1;const e=this.getAttribute("selected"),r=this.getAttribute("value"),a=this._sourceTabs();let i=-1;if(e!=null&&e!==""){const s=Number(e);Number.isFinite(s)?i=Math.trunc(s):i=t.findIndex(c=>c.value===e)}return i<0&&r&&(i=t.findIndex(s=>s.value===r)),i<0&&(i=t.findIndex((s,c)=>!!a[c]?.hasAttribute("data-active")&&!s.disabled)),(i<0||!t[i]||t[i].disabled)&&(i=t.findIndex(s=>!s.disabled)),i}_syncSelectedAttributes(t,e){const r=t[e];this._isSyncingSelectionAttributes=!0;try{if(!r){this.removeAttribute("selected"),this.removeAttribute("value");return}this.getAttribute("selected")!==String(e)&&this.setAttribute("selected",String(e)),this.getAttribute("value")!==r.value&&this.setAttribute("value",r.value)}finally{this._isSyncingSelectionAttributes=!1}}_emit(t,e,r){const a=e[r];if(!a)return;const i={selected:r,index:r,value:a.value,label:a.label,tabId:a.tabId,panelId:a.panelId};this.dispatchEvent(new CustomEvent(t,{detail:i,bubbles:!0,composed:!0}))}_setSelectedByIndex(t,e,r){const a=t[e];if(!a||a.disabled)return;if(this._resolveSelectedIndex(t)===e){this._focusTab(e);return}this._focusIndex=e,this.setAttribute("selected",String(e)),this.setAttribute("value",a.value),r&&(this._emit("change",t,e),this._emit("select",t,e))}_syncSelectionUi(){if(!this.isConnected)return;if(!this.root.querySelector(".nav")){this.requestRender();return}const t=this._tabsModel();if(!t.length)return;const e=this._resolveSelectedIndex(t),r=this._resolveFocusIndex(t,e);this._syncSelectedAttributes(t,e);const a=Array.from(this.root.querySelectorAll(".tab"));a.forEach((s,c)=>{const b=t[c];if(!b)return;const o=c===e;s.setAttribute("aria-selected",o?"true":"false"),s.setAttribute("aria-disabled",b.disabled?"true":"false"),b.disabled?s.setAttribute("disabled",""):s.removeAttribute("disabled")}),d.syncRovingTabStops(a,a[r]||null,{activeAttribute:null});const i=t[e];this._syncIndicator(e),this._clearCrossRootReferences(),i&&this._scrollSelectedTabIntoView(e),this._syncPanels(t,e)}_syncIndicator(t){const e=this.root.querySelector(".nav");if(!e)return;const r=this.getAttribute("variant")||"default",a=r==="indicator";if(!a&&!(r==="indicator-line")){e.removeAttribute("data-indicator-ready"),e.style.removeProperty("--ui-tabs-indicator-x"),e.style.removeProperty("--ui-tabs-indicator-y"),e.style.removeProperty("--ui-tabs-indicator-w"),e.style.removeProperty("--ui-tabs-indicator-h");return}const s=this.root.querySelector(`.tab[data-index="${t}"]`);if(!s){e.removeAttribute("data-indicator-ready");return}const c=this.getAttribute("orientation")==="vertical"?"vertical":"horizontal",b=getComputedStyle(this).direction==="rtl";let o=s.offsetLeft,u=s.offsetTop,n=s.offsetWidth,l=s.offsetHeight;a?(o+=2,u+=2,n=Math.max(0,n-4),l=Math.max(0,l-4)):c==="vertical"?(u+=5,l=Math.max(8,l-10),n=3,o+=b?s.offsetWidth-3-2:2):(o+=8,n=Math.max(12,n-16),l=2,u+=s.offsetHeight-2-2),e.style.setProperty("--ui-tabs-indicator-x",`${o}px`),e.style.setProperty("--ui-tabs-indicator-y",`${u}px`),e.style.setProperty("--ui-tabs-indicator-w",`${n}px`),e.style.setProperty("--ui-tabs-indicator-h",`${l}px`),e.setAttribute("data-indicator-ready","true")}_clearCrossRootReferences(){this.removeAttribute("aria-activedescendant"),this.removeAttribute("aria-controls")}_syncPanels(t,e){const r=this._sourcePanels(),a=this.root.querySelector(".panel-wrap");a&&(r.length?a.removeAttribute("hidden"):a.setAttribute("hidden","")),this._isSyncing=!0;try{r.forEach((i,s)=>{const c=t[s],b=s===e;i.id=c?.panelId||`${this._uid}-panel-${s}`,i.setAttribute("role","tabpanel"),i.setAttribute("tabindex",b?"0":"-1"),i.setAttribute("aria-hidden",b?"false":"true"),c&&(i.getAttribute("aria-labelledby")===c.tabId&&i.removeAttribute("aria-labelledby"),i.hasAttribute("aria-labelledby")||i.hasAttribute("aria-label")&&!i.hasAttribute(f)||(i.setAttribute("aria-label",c.label),i.setAttribute(f,""))),b?i.removeAttribute("hidden"):i.setAttribute("hidden","")})}finally{this._isSyncing=!1}}_enabledIndices(t){return t.filter(e=>!e.disabled).map(e=>e.index)}_resolveFocusIndex(t,e){const r=d.resolveRovingFocusIndex(t,{activeIndex:this._focusIndex,selectedIndex:e,getDisabled:a=>a.disabled});return this._focusIndex=r,r}_onWindowResize(){this._syncSelectionUi()}_focusTab(t){this._focusIndex=t;const e=this.root.querySelector(`.tab[data-index="${t}"]`),r=Array.from(this.root.querySelectorAll(".tab"));d.syncRovingTabStops(r,e,{activeAttribute:null}),d.focusRovingItem(e)}_scrollSelectedTabIntoView(t){const e=this.root.querySelector(".nav"),r=this.root.querySelector(`.tab[data-index="${t}"]`);if(!e||!r)return;const a=this.getAttribute("orientation")!=="vertical",i=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;typeof r.scrollIntoView=="function"&&r.scrollIntoView({behavior:i?"auto":"smooth",block:"nearest",inline:a?"center":"nearest"})}_onClick(t){const r=t.target?.closest(".tab");if(!r||r.disabled)return;const a=Number(r.getAttribute("data-index"));if(!Number.isFinite(a))return;const i=this._tabsModel();this._setSelectedByIndex(i,a,!0)}_onKeyDown(t){const r=t.target?.closest(".tab");if(!r)return;const a=this._tabsModel();if(!a.length)return;const i=this.getAttribute("orientation")==="vertical"?"vertical":"horizontal",s=this.getAttribute("activation")==="manual"?"manual":"auto",c=!this.hasAttribute("loop")||g(this.getAttribute("loop")),b=getComputedStyle(this).direction==="rtl",o=Number(r.getAttribute("data-index"));if(!Number.isFinite(o))return;const u=n=>{const l=d.moveRovingFocusIndex(a,o,n,{wrap:c,fallbackIndex:this._resolveFocusIndex(a,this._resolveSelectedIndex(a)),getDisabled:v=>v.disabled});l!=null&&(this._focusTab(l),s==="auto"?this._setSelectedByIndex(a,l,!0):this._emit("focus",a,l))};if(i==="horizontal"&&(t.key==="ArrowRight"&&!b||t.key==="ArrowLeft"&&b)||i==="vertical"&&t.key==="ArrowDown"){t.preventDefault(),u(1);return}if(i==="horizontal"&&(t.key==="ArrowLeft"&&!b||t.key==="ArrowRight"&&b)||i==="vertical"&&t.key==="ArrowUp"){t.preventDefault(),u(-1);return}if(t.key==="Home"){t.preventDefault();const n=d.getRovingFocusBoundaryIndex(a,"first",l=>l.disabled);if(n<0)return;this._focusTab(n),s==="auto"?this._setSelectedByIndex(a,n,!0):this._emit("focus",a,n);return}if(t.key==="End"){t.preventDefault();const n=d.getRovingFocusBoundaryIndex(a,"last",l=>l.disabled);if(n<0)return;this._focusTab(n),s==="auto"?this._setSelectedByIndex(a,n,!0):this._emit("focus",a,n);return}(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this._setSelectedByIndex(a,o,!0))}render(){const t=this._tabsModel(),e=this._resolveSelectedIndex(t),r=this._resolveFocusIndex(t,e);this._syncSelectedAttributes(t,e);const a=this.getAttribute("orientation")==="vertical"?"vertical":"horizontal",i=(this.getAttribute("aria-label")||"").trim(),s=(this.getAttribute("aria-labelledby")||"").trim(),c=(i?` aria-label="${p(i)}"`:"")+(s?` aria-labelledby="${p(s)}"`:""),b=t.map(o=>{const u=o.index===e,n=o.icon?`<span class="tab-icon" aria-hidden="true">${p(o.icon)}</span>`:"";return`
|
|
487
487
|
<button
|
|
488
488
|
type="button"
|
|
489
489
|
class="tab"
|
|
490
490
|
part="tab"
|
|
491
|
-
id="${
|
|
491
|
+
id="${o.tabId}"
|
|
492
492
|
role="tab"
|
|
493
|
-
data-index="${
|
|
494
|
-
aria-selected="${
|
|
495
|
-
aria-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
${n.disabled?"disabled":""}
|
|
493
|
+
data-index="${o.index}"
|
|
494
|
+
aria-selected="${u?"true":"false"}"
|
|
495
|
+
aria-disabled="${o.disabled?"true":"false"}"
|
|
496
|
+
tabindex="${o.index===r&&!o.disabled?"0":"-1"}"
|
|
497
|
+
${o.disabled?"disabled":""}
|
|
499
498
|
>
|
|
500
|
-
${
|
|
501
|
-
<span class="tab-label">${p(
|
|
499
|
+
${n}
|
|
500
|
+
<span class="tab-label">${p(o.label)}</span>
|
|
502
501
|
</button>
|
|
503
502
|
`}).join("");this.setContent(`
|
|
504
|
-
<style>${
|
|
503
|
+
<style>${_}</style>
|
|
505
504
|
<section class="shell" part="shell">
|
|
506
|
-
<div class="nav" role="tablist" aria-orientation="${a}" part="nav">
|
|
505
|
+
<div class="nav" role="tablist" aria-orientation="${a}"${c} part="nav">
|
|
507
506
|
<span class="indicator" part="indicator" aria-hidden="true"></span>
|
|
508
|
-
${
|
|
507
|
+
${b}
|
|
509
508
|
</div>
|
|
510
509
|
<div class="panel-wrap" part="panel-wrap" aria-live="polite">
|
|
511
510
|
<slot name="panel"></slot>
|
|
512
511
|
</div>
|
|
513
512
|
</section>
|
|
514
513
|
<slot class="source-tabs" name="tab"></slot>
|
|
515
|
-
`)
|
|
514
|
+
`),this._clearCrossRootReferences(),this._syncIndicator(e),this._syncPanels(t,e)}}typeof customElements<"u"&&!customElements.get("ui-tabs")&&customElements.define("ui-tabs",x);exports.UITabs=x;
|
package/dist/tabs.esm.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { E as
|
|
2
|
-
import { s as
|
|
3
|
-
const
|
|
1
|
+
import { E as y } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
|
+
import { s as p, r as _, f as w, g as f, m as A } from "./roving-focus-group-Dbm1Jko_.mjs";
|
|
3
|
+
const k = `
|
|
4
4
|
:host {
|
|
5
5
|
--ui-tabs-nav-bg: var(--ui-color-surface, #ffffff);
|
|
6
6
|
--ui-tabs-panel-bg: var(--ui-color-surface, #ffffff);
|
|
7
7
|
--ui-tabs-border: var(--ui-color-border, #cbd5e1);
|
|
8
8
|
--ui-tabs-text: var(--ui-color-text, #0f172a);
|
|
9
|
-
--ui-tabs-muted: var(--ui-color-muted, #
|
|
9
|
+
--ui-tabs-muted: var(--ui-color-muted, #526175);
|
|
10
10
|
--ui-tabs-accent: var(--ui-tabs-active-bg, var(--ui-color-primary, #2563eb));
|
|
11
11
|
--ui-tabs-active-text: color-mix(in srgb, var(--ui-tabs-accent) 82%, #0f172a 18%);
|
|
12
12
|
--ui-tabs-focus: var(--ui-color-focus-ring, #2563eb);
|
|
@@ -300,18 +300,18 @@ const A = `
|
|
|
300
300
|
--ui-tabs-nav-bg: var(--ui-tabs-accent);
|
|
301
301
|
--ui-tabs-panel-bg: var(--ui-color-surface, #ffffff);
|
|
302
302
|
--ui-tabs-border: color-mix(in srgb, var(--ui-tabs-accent) 76%, #0f172a 24%);
|
|
303
|
-
--ui-tabs-muted: color-mix(in srgb, var(--ui-color-primary-foreground, #ffffff)
|
|
303
|
+
--ui-tabs-muted: color-mix(in srgb, var(--ui-color-primary-foreground, var(--ui-color-foreground-on-primary, #ffffff)) 94%, transparent);
|
|
304
304
|
--ui-tabs-active-text: color-mix(in srgb, var(--ui-tabs-accent) 78%, #0f172a 22%);
|
|
305
|
-
--ui-tabs-focus: color-mix(in srgb, var(--ui-color-primary-foreground, #ffffff) 72%, var(--ui-tabs-accent));
|
|
305
|
+
--ui-tabs-focus: color-mix(in srgb, var(--ui-color-primary-foreground, var(--ui-color-foreground-on-primary, #ffffff)) 72%, var(--ui-tabs-accent));
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
:host([variant="solid"]) .tab:hover {
|
|
309
|
-
background: color-mix(in srgb, var(--ui-color-primary-foreground, #ffffff) 14%, transparent);
|
|
310
|
-
color: var(--ui-color-primary-foreground, #ffffff);
|
|
309
|
+
background: color-mix(in srgb, var(--ui-color-primary-foreground, var(--ui-color-foreground-on-primary, #ffffff)) 14%, transparent);
|
|
310
|
+
color: var(--ui-color-primary-foreground, var(--ui-color-foreground-on-primary, #ffffff));
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
:host([variant="solid"]) .tab[aria-selected="true"] {
|
|
314
|
-
background: var(--ui-color-primary-foreground, #ffffff);
|
|
314
|
+
background: var(--ui-color-primary-foreground, var(--ui-color-foreground-on-primary, #ffffff));
|
|
315
315
|
border-color: color-mix(in srgb, var(--ui-tabs-accent) 44%, var(--ui-tabs-border));
|
|
316
316
|
color: var(--ui-tabs-active-text);
|
|
317
317
|
}
|
|
@@ -435,11 +435,11 @@ const A = `
|
|
|
435
435
|
}
|
|
436
436
|
|
|
437
437
|
:host([tone="success"]) {
|
|
438
|
-
--ui-tabs-accent: var(--ui-color-success, #
|
|
438
|
+
--ui-tabs-accent: var(--ui-color-success, #15803d);
|
|
439
439
|
}
|
|
440
440
|
|
|
441
441
|
:host([tone="warning"]) {
|
|
442
|
-
--ui-tabs-accent: var(--ui-color-warning, #
|
|
442
|
+
--ui-tabs-accent: var(--ui-color-warning, #b45309);
|
|
443
443
|
}
|
|
444
444
|
|
|
445
445
|
:host([tone="danger"]) {
|
|
@@ -485,16 +485,18 @@ const A = `
|
|
|
485
485
|
border-color: Highlight;
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
|
-
|
|
489
|
-
function
|
|
490
|
-
return String(
|
|
488
|
+
`, g = "data-ui-tabs-auto-label";
|
|
489
|
+
function v(d) {
|
|
490
|
+
return String(d).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
491
491
|
}
|
|
492
|
-
function
|
|
493
|
-
if (
|
|
494
|
-
const t = String(
|
|
492
|
+
function x(d) {
|
|
493
|
+
if (d == null) return !1;
|
|
494
|
+
const t = String(d).toLowerCase();
|
|
495
495
|
return t !== "false" && t !== "0" && t !== "off";
|
|
496
496
|
}
|
|
497
|
-
const
|
|
497
|
+
const S = /* @__PURE__ */ new Set([
|
|
498
|
+
"aria-label",
|
|
499
|
+
"aria-labelledby",
|
|
498
500
|
"orientation",
|
|
499
501
|
"activation",
|
|
500
502
|
"headless",
|
|
@@ -507,7 +509,7 @@ const k = /* @__PURE__ */ new Set([
|
|
|
507
509
|
"elevation",
|
|
508
510
|
"bare"
|
|
509
511
|
]);
|
|
510
|
-
class
|
|
512
|
+
class I extends y {
|
|
511
513
|
constructor() {
|
|
512
514
|
super(), this._uid = `ui-tabs-${Math.random().toString(36).slice(2, 9)}`, this._observer = null, this._resizeObserver = null, this._isSyncing = !1, this._isSyncingSelectionAttributes = !1, this._focusIndex = -1, this._onClick = this._onClick.bind(this), this._onKeyDown = this._onKeyDown.bind(this), this._onWindowResize = this._onWindowResize.bind(this);
|
|
513
515
|
}
|
|
@@ -526,7 +528,9 @@ class S extends m {
|
|
|
526
528
|
"shape",
|
|
527
529
|
"elevation",
|
|
528
530
|
"loop",
|
|
529
|
-
"bare"
|
|
531
|
+
"bare",
|
|
532
|
+
"aria-label",
|
|
533
|
+
"aria-labelledby"
|
|
530
534
|
];
|
|
531
535
|
}
|
|
532
536
|
connectedCallback() {
|
|
@@ -543,13 +547,13 @@ class S extends m {
|
|
|
543
547
|
disconnectedCallback() {
|
|
544
548
|
this.root.removeEventListener("click", this._onClick), this.root.removeEventListener("keydown", this._onKeyDown), this._observer && (this._observer.disconnect(), this._observer = null), this._resizeObserver ? (this._resizeObserver.disconnect(), this._resizeObserver = null) : window.removeEventListener("resize", this._onWindowResize), super.disconnectedCallback();
|
|
545
549
|
}
|
|
546
|
-
attributeChangedCallback(t, e,
|
|
547
|
-
if (e !==
|
|
550
|
+
attributeChangedCallback(t, e, r) {
|
|
551
|
+
if (e !== r) {
|
|
548
552
|
if (t === "selected" || t === "value") {
|
|
549
553
|
this._isSyncingSelectionAttributes || this._syncSelectionUi();
|
|
550
554
|
return;
|
|
551
555
|
}
|
|
552
|
-
|
|
556
|
+
S.has(t) && this.isConnected && this.requestRender();
|
|
553
557
|
}
|
|
554
558
|
}
|
|
555
559
|
get selected() {
|
|
@@ -567,54 +571,54 @@ class S extends m {
|
|
|
567
571
|
}
|
|
568
572
|
_tabsModel() {
|
|
569
573
|
return this._sourceTabs().map((t, e) => {
|
|
570
|
-
const
|
|
571
|
-
return { index: e, value:
|
|
574
|
+
const r = t.getAttribute("data-value") || t.getAttribute("value") || String(e), a = t.getAttribute("data-label") || t.textContent?.trim() || `Tab ${e + 1}`, i = t.getAttribute("data-icon") || "", s = t.hasAttribute("disabled") || x(t.getAttribute("data-disabled")), b = `${this._uid}-tab-${e}`, c = `${this._uid}-panel-${e}`;
|
|
575
|
+
return { index: e, value: r, label: a, icon: i, disabled: s, tabId: b, panelId: c };
|
|
572
576
|
});
|
|
573
577
|
}
|
|
574
578
|
_resolveSelectedIndex(t) {
|
|
575
579
|
if (!t.length) return -1;
|
|
576
|
-
const e = this.getAttribute("selected"),
|
|
577
|
-
let
|
|
580
|
+
const e = this.getAttribute("selected"), r = this.getAttribute("value"), a = this._sourceTabs();
|
|
581
|
+
let i = -1;
|
|
578
582
|
if (e != null && e !== "") {
|
|
579
583
|
const s = Number(e);
|
|
580
|
-
Number.isFinite(s) ?
|
|
584
|
+
Number.isFinite(s) ? i = Math.trunc(s) : i = t.findIndex((b) => b.value === e);
|
|
581
585
|
}
|
|
582
|
-
return
|
|
586
|
+
return i < 0 && r && (i = t.findIndex((s) => s.value === r)), i < 0 && (i = t.findIndex((s, b) => !!a[b]?.hasAttribute("data-active") && !s.disabled)), (i < 0 || !t[i] || t[i].disabled) && (i = t.findIndex((s) => !s.disabled)), i;
|
|
583
587
|
}
|
|
584
588
|
_syncSelectedAttributes(t, e) {
|
|
585
|
-
const
|
|
589
|
+
const r = t[e];
|
|
586
590
|
this._isSyncingSelectionAttributes = !0;
|
|
587
591
|
try {
|
|
588
|
-
if (!
|
|
592
|
+
if (!r) {
|
|
589
593
|
this.removeAttribute("selected"), this.removeAttribute("value");
|
|
590
594
|
return;
|
|
591
595
|
}
|
|
592
|
-
this.getAttribute("selected") !== String(e) && this.setAttribute("selected", String(e)), this.getAttribute("value") !==
|
|
596
|
+
this.getAttribute("selected") !== String(e) && this.setAttribute("selected", String(e)), this.getAttribute("value") !== r.value && this.setAttribute("value", r.value);
|
|
593
597
|
} finally {
|
|
594
598
|
this._isSyncingSelectionAttributes = !1;
|
|
595
599
|
}
|
|
596
600
|
}
|
|
597
|
-
_emit(t, e,
|
|
598
|
-
const a = e[
|
|
601
|
+
_emit(t, e, r) {
|
|
602
|
+
const a = e[r];
|
|
599
603
|
if (!a) return;
|
|
600
|
-
const
|
|
601
|
-
selected:
|
|
602
|
-
index:
|
|
604
|
+
const i = {
|
|
605
|
+
selected: r,
|
|
606
|
+
index: r,
|
|
603
607
|
value: a.value,
|
|
604
608
|
label: a.label,
|
|
605
609
|
tabId: a.tabId,
|
|
606
610
|
panelId: a.panelId
|
|
607
611
|
};
|
|
608
|
-
this.dispatchEvent(new CustomEvent(t, { detail:
|
|
612
|
+
this.dispatchEvent(new CustomEvent(t, { detail: i, bubbles: !0, composed: !0 }));
|
|
609
613
|
}
|
|
610
|
-
_setSelectedByIndex(t, e,
|
|
614
|
+
_setSelectedByIndex(t, e, r) {
|
|
611
615
|
const a = t[e];
|
|
612
616
|
if (!a || a.disabled) return;
|
|
613
617
|
if (this._resolveSelectedIndex(t) === e) {
|
|
614
618
|
this._focusTab(e);
|
|
615
619
|
return;
|
|
616
620
|
}
|
|
617
|
-
this._focusIndex = e, this.setAttribute("selected", String(e)), this.setAttribute("value", a.value),
|
|
621
|
+
this._focusIndex = e, this.setAttribute("selected", String(e)), this.setAttribute("value", a.value), r && (this._emit("change", t, e), this._emit("select", t, e));
|
|
618
622
|
}
|
|
619
623
|
_syncSelectionUi() {
|
|
620
624
|
if (!this.isConnected) return;
|
|
@@ -624,23 +628,23 @@ class S extends m {
|
|
|
624
628
|
}
|
|
625
629
|
const t = this._tabsModel();
|
|
626
630
|
if (!t.length) return;
|
|
627
|
-
const e = this._resolveSelectedIndex(t),
|
|
631
|
+
const e = this._resolveSelectedIndex(t), r = this._resolveFocusIndex(t, e);
|
|
628
632
|
this._syncSelectedAttributes(t, e);
|
|
629
633
|
const a = Array.from(this.root.querySelectorAll(".tab"));
|
|
630
|
-
a.forEach((s,
|
|
631
|
-
const
|
|
632
|
-
if (!
|
|
633
|
-
const
|
|
634
|
-
s.setAttribute("aria-selected",
|
|
635
|
-
}),
|
|
636
|
-
const
|
|
637
|
-
this._syncIndicator(e),
|
|
634
|
+
a.forEach((s, b) => {
|
|
635
|
+
const c = t[b];
|
|
636
|
+
if (!c) return;
|
|
637
|
+
const o = b === e;
|
|
638
|
+
s.setAttribute("aria-selected", o ? "true" : "false"), s.setAttribute("aria-disabled", c.disabled ? "true" : "false"), c.disabled ? s.setAttribute("disabled", "") : s.removeAttribute("disabled");
|
|
639
|
+
}), p(a, a[r] || null, { activeAttribute: null });
|
|
640
|
+
const i = t[e];
|
|
641
|
+
this._syncIndicator(e), this._clearCrossRootReferences(), i && this._scrollSelectedTabIntoView(e), this._syncPanels(t, e);
|
|
638
642
|
}
|
|
639
643
|
_syncIndicator(t) {
|
|
640
644
|
const e = this.root.querySelector(".nav");
|
|
641
645
|
if (!e) return;
|
|
642
|
-
const
|
|
643
|
-
if (!a && !(
|
|
646
|
+
const r = this.getAttribute("variant") || "default", a = r === "indicator";
|
|
647
|
+
if (!a && !(r === "indicator-line")) {
|
|
644
648
|
e.removeAttribute("data-indicator-ready"), e.style.removeProperty("--ui-tabs-indicator-x"), e.style.removeProperty("--ui-tabs-indicator-y"), e.style.removeProperty("--ui-tabs-indicator-w"), e.style.removeProperty("--ui-tabs-indicator-h");
|
|
645
649
|
return;
|
|
646
650
|
}
|
|
@@ -649,17 +653,20 @@ class S extends m {
|
|
|
649
653
|
e.removeAttribute("data-indicator-ready");
|
|
650
654
|
return;
|
|
651
655
|
}
|
|
652
|
-
const
|
|
653
|
-
let
|
|
654
|
-
a ? (
|
|
656
|
+
const b = this.getAttribute("orientation") === "vertical" ? "vertical" : "horizontal", c = getComputedStyle(this).direction === "rtl";
|
|
657
|
+
let o = s.offsetLeft, u = s.offsetTop, n = s.offsetWidth, l = s.offsetHeight;
|
|
658
|
+
a ? (o += 2, u += 2, n = Math.max(0, n - 4), l = Math.max(0, l - 4)) : b === "vertical" ? (u += 5, l = Math.max(8, l - 10), n = 3, o += c ? s.offsetWidth - 3 - 2 : 2) : (o += 8, n = Math.max(12, n - 16), l = 2, u += s.offsetHeight - 2 - 2), e.style.setProperty("--ui-tabs-indicator-x", `${o}px`), e.style.setProperty("--ui-tabs-indicator-y", `${u}px`), e.style.setProperty("--ui-tabs-indicator-w", `${n}px`), e.style.setProperty("--ui-tabs-indicator-h", `${l}px`), e.setAttribute("data-indicator-ready", "true");
|
|
659
|
+
}
|
|
660
|
+
_clearCrossRootReferences() {
|
|
661
|
+
this.removeAttribute("aria-activedescendant"), this.removeAttribute("aria-controls");
|
|
655
662
|
}
|
|
656
663
|
_syncPanels(t, e) {
|
|
657
|
-
const
|
|
658
|
-
a && (
|
|
664
|
+
const r = this._sourcePanels(), a = this.root.querySelector(".panel-wrap");
|
|
665
|
+
a && (r.length ? a.removeAttribute("hidden") : a.setAttribute("hidden", "")), this._isSyncing = !0;
|
|
659
666
|
try {
|
|
660
|
-
|
|
661
|
-
const
|
|
662
|
-
|
|
667
|
+
r.forEach((i, s) => {
|
|
668
|
+
const b = t[s], c = s === e;
|
|
669
|
+
i.id = b?.panelId || `${this._uid}-panel-${s}`, i.setAttribute("role", "tabpanel"), i.setAttribute("tabindex", c ? "0" : "-1"), i.setAttribute("aria-hidden", c ? "false" : "true"), b && (i.getAttribute("aria-labelledby") === b.tabId && i.removeAttribute("aria-labelledby"), i.hasAttribute("aria-labelledby") || i.hasAttribute("aria-label") && !i.hasAttribute(g) || (i.setAttribute("aria-label", b.label), i.setAttribute(g, ""))), c ? i.removeAttribute("hidden") : i.setAttribute("hidden", "");
|
|
663
670
|
});
|
|
664
671
|
} finally {
|
|
665
672
|
this._isSyncing = !1;
|
|
@@ -669,120 +676,117 @@ class S extends m {
|
|
|
669
676
|
return t.filter((e) => !e.disabled).map((e) => e.index);
|
|
670
677
|
}
|
|
671
678
|
_resolveFocusIndex(t, e) {
|
|
672
|
-
const
|
|
679
|
+
const r = _(t, {
|
|
673
680
|
activeIndex: this._focusIndex,
|
|
674
681
|
selectedIndex: e,
|
|
675
682
|
getDisabled: (a) => a.disabled
|
|
676
683
|
});
|
|
677
|
-
return this._focusIndex =
|
|
684
|
+
return this._focusIndex = r, r;
|
|
678
685
|
}
|
|
679
686
|
_onWindowResize() {
|
|
680
687
|
this._syncSelectionUi();
|
|
681
688
|
}
|
|
682
689
|
_focusTab(t) {
|
|
683
690
|
this._focusIndex = t;
|
|
684
|
-
const e = this.root.querySelector(`.tab[data-index="${t}"]`),
|
|
685
|
-
|
|
691
|
+
const e = this.root.querySelector(`.tab[data-index="${t}"]`), r = Array.from(this.root.querySelectorAll(".tab"));
|
|
692
|
+
p(r, e, { activeAttribute: null }), w(e);
|
|
686
693
|
}
|
|
687
694
|
_scrollSelectedTabIntoView(t) {
|
|
688
|
-
const e = this.root.querySelector(".nav"),
|
|
689
|
-
if (!e || !
|
|
690
|
-
const a = this.getAttribute("orientation") !== "vertical",
|
|
691
|
-
typeof
|
|
692
|
-
behavior:
|
|
695
|
+
const e = this.root.querySelector(".nav"), r = this.root.querySelector(`.tab[data-index="${t}"]`);
|
|
696
|
+
if (!e || !r) return;
|
|
697
|
+
const a = this.getAttribute("orientation") !== "vertical", i = typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
698
|
+
typeof r.scrollIntoView == "function" && r.scrollIntoView({
|
|
699
|
+
behavior: i ? "auto" : "smooth",
|
|
693
700
|
block: "nearest",
|
|
694
701
|
inline: a ? "center" : "nearest"
|
|
695
702
|
});
|
|
696
703
|
}
|
|
697
704
|
_onClick(t) {
|
|
698
|
-
const
|
|
699
|
-
if (!
|
|
700
|
-
const a = Number(
|
|
705
|
+
const r = t.target?.closest(".tab");
|
|
706
|
+
if (!r || r.disabled) return;
|
|
707
|
+
const a = Number(r.getAttribute("data-index"));
|
|
701
708
|
if (!Number.isFinite(a)) return;
|
|
702
|
-
const
|
|
703
|
-
this._setSelectedByIndex(
|
|
709
|
+
const i = this._tabsModel();
|
|
710
|
+
this._setSelectedByIndex(i, a, !0);
|
|
704
711
|
}
|
|
705
712
|
_onKeyDown(t) {
|
|
706
|
-
const
|
|
707
|
-
if (!
|
|
713
|
+
const r = t.target?.closest(".tab");
|
|
714
|
+
if (!r) return;
|
|
708
715
|
const a = this._tabsModel();
|
|
709
716
|
if (!a.length) return;
|
|
710
|
-
const
|
|
711
|
-
if (!Number.isFinite(
|
|
712
|
-
const
|
|
713
|
-
const
|
|
714
|
-
wrap:
|
|
717
|
+
const i = this.getAttribute("orientation") === "vertical" ? "vertical" : "horizontal", s = this.getAttribute("activation") === "manual" ? "manual" : "auto", b = !this.hasAttribute("loop") || x(this.getAttribute("loop")), c = getComputedStyle(this).direction === "rtl", o = Number(r.getAttribute("data-index"));
|
|
718
|
+
if (!Number.isFinite(o)) return;
|
|
719
|
+
const u = (n) => {
|
|
720
|
+
const l = A(a, o, n, {
|
|
721
|
+
wrap: b,
|
|
715
722
|
fallbackIndex: this._resolveFocusIndex(a, this._resolveSelectedIndex(a)),
|
|
716
723
|
getDisabled: (h) => h.disabled
|
|
717
724
|
});
|
|
718
|
-
|
|
725
|
+
l != null && (this._focusTab(l), s === "auto" ? this._setSelectedByIndex(a, l, !0) : this._emit("focus", a, l));
|
|
719
726
|
};
|
|
720
|
-
if (
|
|
721
|
-
t.preventDefault(),
|
|
727
|
+
if (i === "horizontal" && (t.key === "ArrowRight" && !c || t.key === "ArrowLeft" && c) || i === "vertical" && t.key === "ArrowDown") {
|
|
728
|
+
t.preventDefault(), u(1);
|
|
722
729
|
return;
|
|
723
730
|
}
|
|
724
|
-
if (
|
|
725
|
-
t.preventDefault(),
|
|
731
|
+
if (i === "horizontal" && (t.key === "ArrowLeft" && !c || t.key === "ArrowRight" && c) || i === "vertical" && t.key === "ArrowUp") {
|
|
732
|
+
t.preventDefault(), u(-1);
|
|
726
733
|
return;
|
|
727
734
|
}
|
|
728
735
|
if (t.key === "Home") {
|
|
729
736
|
t.preventDefault();
|
|
730
|
-
const
|
|
731
|
-
if (
|
|
732
|
-
this._focusTab(
|
|
737
|
+
const n = f(a, "first", (l) => l.disabled);
|
|
738
|
+
if (n < 0) return;
|
|
739
|
+
this._focusTab(n), s === "auto" ? this._setSelectedByIndex(a, n, !0) : this._emit("focus", a, n);
|
|
733
740
|
return;
|
|
734
741
|
}
|
|
735
742
|
if (t.key === "End") {
|
|
736
743
|
t.preventDefault();
|
|
737
|
-
const
|
|
738
|
-
if (
|
|
739
|
-
this._focusTab(
|
|
744
|
+
const n = f(a, "last", (l) => l.disabled);
|
|
745
|
+
if (n < 0) return;
|
|
746
|
+
this._focusTab(n), s === "auto" ? this._setSelectedByIndex(a, n, !0) : this._emit("focus", a, n);
|
|
740
747
|
return;
|
|
741
748
|
}
|
|
742
|
-
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), this._setSelectedByIndex(a,
|
|
749
|
+
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), this._setSelectedByIndex(a, o, !0));
|
|
743
750
|
}
|
|
744
751
|
render() {
|
|
745
|
-
const t = this._tabsModel(), e = this._resolveSelectedIndex(t),
|
|
752
|
+
const t = this._tabsModel(), e = this._resolveSelectedIndex(t), r = this._resolveFocusIndex(t, e);
|
|
746
753
|
this._syncSelectedAttributes(t, e);
|
|
747
|
-
const a = this.getAttribute("orientation") === "vertical" ? "vertical" : "horizontal",
|
|
748
|
-
const
|
|
754
|
+
const a = this.getAttribute("orientation") === "vertical" ? "vertical" : "horizontal", i = (this.getAttribute("aria-label") || "").trim(), s = (this.getAttribute("aria-labelledby") || "").trim(), b = (i ? ` aria-label="${v(i)}"` : "") + (s ? ` aria-labelledby="${v(s)}"` : ""), c = t.map((o) => {
|
|
755
|
+
const u = o.index === e, n = o.icon ? `<span class="tab-icon" aria-hidden="true">${v(o.icon)}</span>` : "";
|
|
749
756
|
return `
|
|
750
757
|
<button
|
|
751
758
|
type="button"
|
|
752
759
|
class="tab"
|
|
753
760
|
part="tab"
|
|
754
|
-
id="${
|
|
761
|
+
id="${o.tabId}"
|
|
755
762
|
role="tab"
|
|
756
|
-
data-index="${
|
|
757
|
-
aria-selected="${
|
|
758
|
-
aria-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
${n.disabled ? "disabled" : ""}
|
|
763
|
+
data-index="${o.index}"
|
|
764
|
+
aria-selected="${u ? "true" : "false"}"
|
|
765
|
+
aria-disabled="${o.disabled ? "true" : "false"}"
|
|
766
|
+
tabindex="${o.index === r && !o.disabled ? "0" : "-1"}"
|
|
767
|
+
${o.disabled ? "disabled" : ""}
|
|
762
768
|
>
|
|
763
|
-
${
|
|
764
|
-
<span class="tab-label">${
|
|
769
|
+
${n}
|
|
770
|
+
<span class="tab-label">${v(o.label)}</span>
|
|
765
771
|
</button>
|
|
766
772
|
`;
|
|
767
773
|
}).join("");
|
|
768
774
|
this.setContent(`
|
|
769
|
-
<style>${
|
|
775
|
+
<style>${k}</style>
|
|
770
776
|
<section class="shell" part="shell">
|
|
771
|
-
<div class="nav" role="tablist" aria-orientation="${a}" part="nav">
|
|
777
|
+
<div class="nav" role="tablist" aria-orientation="${a}"${b} part="nav">
|
|
772
778
|
<span class="indicator" part="indicator" aria-hidden="true"></span>
|
|
773
|
-
${
|
|
779
|
+
${c}
|
|
774
780
|
</div>
|
|
775
781
|
<div class="panel-wrap" part="panel-wrap" aria-live="polite">
|
|
776
782
|
<slot name="panel"></slot>
|
|
777
783
|
</div>
|
|
778
784
|
</section>
|
|
779
785
|
<slot class="source-tabs" name="tab"></slot>
|
|
780
|
-
`);
|
|
781
|
-
const s = t[e];
|
|
782
|
-
s ? (this.setAttribute("aria-activedescendant", s.tabId), this.setAttribute("aria-controls", s.panelId)) : (this.removeAttribute("aria-activedescendant"), this.removeAttribute("aria-controls")), this._syncIndicator(e), this._syncPanels(t, e);
|
|
786
|
+
`), this._clearCrossRootReferences(), this._syncIndicator(e), this._syncPanels(t, e);
|
|
783
787
|
}
|
|
784
788
|
}
|
|
785
|
-
typeof customElements < "u" && !customElements.get("ui-tabs") && customElements.define("ui-tabs",
|
|
789
|
+
typeof customElements < "u" && !customElements.get("ui-tabs") && customElements.define("ui-tabs", I);
|
|
786
790
|
export {
|
|
787
|
-
|
|
791
|
+
I as UITabs
|
|
788
792
|
};
|