@editora/ui-core 0.1.18 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ElementBase-1b301e7f.js → ElementBase-EV6mVBUV.js} +1 -1
- package/dist/{ElementBase-909688f3.mjs → ElementBase-YlTLMsGk.mjs} +3 -3
- package/dist/accordion.cjs.js +3 -3
- package/dist/accordion.esm.js +39 -62
- package/dist/alert-dialog.cjs.js +19 -19
- package/dist/alert-dialog.esm.js +69 -87
- package/dist/alert.cjs.js +1 -1
- package/dist/alert.esm.js +4 -7
- package/dist/anchor.cjs.js +2 -2
- package/dist/anchor.esm.js +3 -3
- package/dist/animated-beam.cjs.js +83 -83
- package/dist/animated-beam.esm.js +250 -277
- package/dist/animated-list.cjs.js +4 -4
- package/dist/animated-list.esm.js +47 -61
- package/dist/animated-text.cjs.js +2 -2
- package/dist/animated-text.esm.js +13 -24
- package/dist/app-header.cjs.js +3 -3
- package/dist/app-header.esm.js +11 -13
- package/dist/aspect-ratio.cjs.js +1 -1
- package/dist/aspect-ratio.esm.js +4 -7
- package/dist/avatar.cjs.js +1 -1
- package/dist/avatar.esm.js +7 -13
- package/dist/badge.cjs.js +1 -1
- package/dist/badge.esm.js +4 -7
- package/dist/block-controls.cjs.js +2 -2
- package/dist/block-controls.esm.js +19 -35
- package/dist/box.cjs.js +1 -1
- package/dist/box.esm.js +8 -15
- package/dist/breadcrumb.cjs.js +2 -2
- package/dist/breadcrumb.esm.js +20 -37
- package/dist/button.cjs.js +1 -521
- package/dist/button.esm.js +2 -669
- package/dist/{calendar-2c11b824.mjs → calendar-DLY4acgn.mjs} +293 -342
- package/dist/{calendar-a8735e40.js → calendar-Dkof-FTK.js} +25 -25
- package/dist/calendar.cjs.js +1 -1
- package/dist/calendar.esm.js +8 -9
- package/dist/card.cjs.js +4 -4
- package/dist/card.esm.js +13 -19
- package/dist/chart.cjs.js +64 -64
- package/dist/chart.esm.js +223 -254
- package/dist/checkbox.cjs.js +1 -1
- package/dist/checkbox.esm.js +2 -3
- package/dist/collapsible.cjs.js +1 -1
- package/dist/collapsible.esm.js +5 -9
- package/dist/{collection-a1aac0c6.mjs → collection-C7URGjEI.mjs} +8 -14
- package/dist/collection.cjs.js +1 -1
- package/dist/collection.esm.js +4 -7
- package/dist/color-picker.cjs.js +9 -9
- package/dist/color-picker.esm.js +189 -252
- package/dist/combobox.cjs.js +13 -13
- package/dist/combobox.esm.js +93 -126
- package/dist/command-palette.cjs.js +3 -3
- package/dist/command-palette.esm.js +19 -30
- package/dist/command.cjs.js +4 -4
- package/dist/command.esm.js +41 -53
- package/dist/components/ui-button.d.ts +1 -0
- package/dist/components/ui-button.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 +1 -0
- package/dist/components/ui-date-range-time-picker.d.ts.map +1 -1
- package/dist/components/ui-date-time-picker.d.ts +1 -0
- package/dist/components/ui-date-time-picker.d.ts.map +1 -1
- package/dist/components/ui-orbiter.d.ts.map +1 -1
- package/dist/components/ui-skeleton.d.ts.map +1 -1
- package/dist/components/ui-split-button.d.ts +1 -0
- package/dist/components/ui-split-button.d.ts.map +1 -1
- package/dist/components/ui-time-picker.d.ts.map +1 -1
- package/dist/container.cjs.js +2 -2
- package/dist/container.esm.js +2 -3
- package/dist/context-menu.cjs.js +8 -8
- package/dist/context-menu.esm.js +157 -219
- package/dist/control-group.cjs.js +1 -1
- package/dist/control-group.esm.js +2 -3
- package/dist/data-table.cjs.js +4 -4
- package/dist/data-table.esm.js +299 -381
- package/dist/date-field.cjs.js +3 -3
- package/dist/date-field.esm.js +68 -80
- package/dist/date-picker.cjs.js +30 -9
- package/dist/date-picker.esm.js +90 -97
- package/dist/date-range-picker.cjs.js +22 -3
- package/dist/date-range-picker.esm.js +103 -108
- package/dist/date-range-time-picker.cjs.js +28 -12
- package/dist/date-range-time-picker.esm.js +137 -150
- package/dist/date-time-picker.cjs.js +25 -9
- package/dist/date-time-picker.esm.js +139 -155
- package/dist/date-time-utils-Dmost5Ee.js +1 -0
- package/dist/date-time-utils-y1N2gvG2.mjs +268 -0
- package/dist/description.cjs.js +1 -1
- package/dist/description.esm.js +3 -5
- package/dist/dialog.cjs.js +12 -12
- package/dist/dialog.esm.js +44 -63
- package/dist/direction-provider.cjs.js +1 -1
- package/dist/direction-provider.esm.js +2 -3
- package/dist/{dismissable-layer-9c7e6b58.mjs → dismissable-layer-BmPIoK80.mjs} +29 -33
- package/dist/dismissable-layer-DNfrKA20.js +1 -0
- package/dist/dismissable-layer.cjs.js +2 -2
- package/dist/dismissable-layer.esm.js +4 -6
- package/dist/dock.cjs.js +5 -5
- package/dist/dock.esm.js +134 -155
- package/dist/drawer.cjs.js +2 -2
- package/dist/drawer.esm.js +18 -35
- package/dist/dropdown.cjs.js +2 -2
- package/dist/dropdown.esm.js +119 -149
- package/dist/dropzone.cjs.js +1 -1
- package/dist/dropzone.esm.js +0 -1
- package/dist/empty-state.cjs.js +1 -1
- package/dist/empty-state.esm.js +1 -1
- package/dist/field-error.cjs.js +1 -1
- package/dist/field-error.esm.js +3 -5
- package/dist/field.cjs.js +5 -5
- package/dist/field.esm.js +27 -34
- package/dist/fieldset.cjs.js +4 -4
- package/dist/fieldset.esm.js +19 -24
- package/dist/file-upload.cjs.js +4 -4
- package/dist/file-upload.esm.js +69 -93
- package/dist/flex.cjs.js +1 -1
- package/dist/flex.esm.js +5 -9
- package/dist/floating-toolbar.cjs.js +4 -4
- package/dist/floating-toolbar.esm.js +60 -85
- package/dist/focus-scope-Bwug2gDv.js +1 -0
- package/dist/{focus-scope-103833ee.mjs → focus-scope-CmEsG5UZ.mjs} +39 -48
- package/dist/focus-scope.cjs.js +2 -2
- package/dist/focus-scope.esm.js +15 -20
- package/dist/form.cjs.js +2 -2
- package/dist/form.esm.js +26 -53
- package/dist/gantt.cjs.js +43 -43
- package/dist/gantt.esm.js +295 -322
- package/dist/grid.cjs.js +1 -1
- package/dist/grid.esm.js +5 -9
- package/dist/hover-card.cjs.js +4 -4
- package/dist/hover-card.esm.js +22 -28
- package/dist/icon-cloud.cjs.js +7 -7
- package/dist/icon-cloud.esm.js +48 -62
- package/dist/icon.cjs.js +1 -1
- package/dist/icon.esm.js +2 -4
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +378 -390
- package/dist/inline-edit.cjs.js +11 -11
- package/dist/inline-edit.esm.js +32 -36
- package/dist/input.cjs.js +17 -17
- package/dist/input.esm.js +50 -63
- package/dist/label.cjs.js +2 -2
- package/dist/label.esm.js +8 -17
- package/dist/layout.cjs.js +2 -2
- package/dist/layout.esm.js +20 -26
- package/dist/listbox-B6QgECax.js +46 -0
- package/dist/listbox-DJamVeFj.mjs +200 -0
- package/dist/listbox.cjs.js +1 -1
- package/dist/listbox.esm.js +2 -4
- package/dist/marquee.cjs.js +5 -5
- package/dist/marquee.esm.js +33 -50
- package/dist/masonry-grid.cjs.js +1 -1
- package/dist/masonry-grid.esm.js +5 -9
- package/dist/menu.cjs.js +3 -3
- package/dist/menu.esm.js +106 -126
- package/dist/menubar.cjs.js +5 -5
- package/dist/menubar.esm.js +118 -164
- package/dist/meter.cjs.js +2 -2
- package/dist/meter.esm.js +4 -4
- package/dist/multi-select.cjs.js +4 -4
- package/dist/multi-select.esm.js +120 -140
- package/dist/navigation-menu.cjs.js +4 -4
- package/dist/navigation-menu.esm.js +44 -55
- package/dist/number-field.cjs.js +2 -2
- package/dist/number-field.esm.js +73 -98
- package/dist/number-ticker.cjs.js +3 -3
- package/dist/number-ticker.esm.js +22 -43
- package/dist/odometer.cjs.js +1 -1
- package/dist/odometer.esm.js +5 -9
- package/dist/orbiter.cjs.js +13 -13
- package/dist/orbiter.esm.js +79 -90
- package/dist/{overlayManager-5bbd4dc3.mjs → overlayManager-BJjU1VA8.mjs} +4 -5
- package/dist/{overlayManager-0eda4e08.js → overlayManager-CSy3fJmJ.js} +1 -1
- package/dist/pagination.cjs.js +2 -2
- package/dist/pagination.esm.js +14 -18
- package/dist/{panel-group-a376cc5e.mjs → panel-group-8sVNnGxg.mjs} +24 -46
- package/dist/panel-group-CaD0_KQf.js +36 -0
- package/dist/panel-group.cjs.js +1 -1
- package/dist/panel-group.esm.js +2 -5
- package/dist/panel.cjs.js +4 -4
- package/dist/panel.esm.js +8 -10
- package/dist/password-field.cjs.js +9 -9
- package/dist/password-field.esm.js +62 -82
- package/dist/pin-input.cjs.js +3 -3
- package/dist/pin-input.esm.js +33 -39
- package/dist/placement-grid.cjs.js +4 -4
- package/dist/placement-grid.esm.js +108 -131
- package/dist/plugin-panel.cjs.js +7 -7
- package/dist/plugin-panel.esm.js +13 -15
- package/dist/popover.cjs.js +2 -2
- package/dist/popover.esm.js +21 -31
- package/dist/portal-DgpQ3Jo1.js +1 -0
- package/dist/{portal-fe73e5cc.mjs → portal-bR42gHvG.mjs} +43 -48
- package/dist/portal.cjs.js +2 -2
- package/dist/portal.esm.js +10 -19
- package/dist/{positioner-e9770c66.mjs → positioner-D0VGxtYU.mjs} +189 -209
- package/dist/positioner-D_fqyx_j.js +1 -0
- package/dist/positioner.cjs.js +2 -2
- package/dist/positioner.esm.js +11 -18
- package/dist/presence.cjs.js +1 -1
- package/dist/presence.esm.js +7 -13
- package/dist/progress.cjs.js +1 -1
- package/dist/progress.esm.js +5 -9
- package/dist/quick-actions.cjs.js +6 -6
- package/dist/quick-actions.esm.js +52 -62
- package/dist/radio-group.cjs.js +13 -13
- package/dist/radio-group.esm.js +39 -51
- package/dist/radio.cjs.js +1 -1
- package/dist/radio.esm.js +5 -9
- package/dist/rating.cjs.js +1 -1
- package/dist/rating.esm.js +12 -23
- package/dist/{roving-focus-group-4350c9a7.mjs → roving-focus-group-Dbm1Jko_.mjs} +3 -6
- package/dist/roving-focus-group.cjs.js +1 -1
- package/dist/roving-focus-group.esm.js +3 -5
- package/dist/runtime-CTaOSmBj.js +1 -0
- package/dist/{runtime-161f68a2.mjs → runtime-D1gFh1fS.mjs} +338 -366
- package/dist/runtime.cjs.js +1 -1
- package/dist/runtime.esm.js +6 -6
- package/dist/scroll-area.cjs.js +3 -3
- package/dist/scroll-area.esm.js +38 -46
- package/dist/{scroll-lock-31da444f.mjs → scroll-lock-LfqXXqsu.mjs} +5 -9
- package/dist/section.cjs.js +1 -1
- package/dist/section.esm.js +1 -1
- package/dist/select.cjs.js +7 -7
- package/dist/select.esm.js +67 -97
- package/dist/selection-popup.cjs.js +1 -1
- package/dist/selection-popup.esm.js +8 -15
- package/dist/separator.cjs.js +1 -1
- package/dist/separator.esm.js +1 -1
- package/dist/sidebar.cjs.js +18 -18
- package/dist/sidebar.esm.js +117 -139
- package/dist/skeleton.cjs.js +11 -11
- package/dist/skeleton.esm.js +27 -24
- package/dist/slider.cjs.js +1 -1
- package/dist/slider.esm.js +6 -11
- package/dist/slot.cjs.js +4 -4
- package/dist/slot.esm.js +16 -19
- package/dist/sortable.cjs.js +45 -45
- package/dist/sortable.esm.js +421 -524
- package/dist/spinning-text.cjs.js +12 -12
- package/dist/spinning-text.esm.js +80 -92
- package/dist/split-button.cjs.js +4 -4
- package/dist/split-button.esm.js +77 -62
- package/dist/splitter.cjs.js +1 -1
- package/dist/splitter.esm.js +1 -1
- package/dist/stepper.cjs.js +8 -8
- package/dist/stepper.esm.js +32 -52
- package/dist/switch.cjs.js +7 -7
- package/dist/switch.esm.js +23 -31
- package/dist/table.cjs.js +2 -2
- package/dist/table.esm.js +46 -56
- package/dist/tabs.cjs.js +3 -3
- package/dist/tabs.esm.js +35 -55
- package/dist/tags-input.cjs.js +4 -4
- package/dist/tags-input.esm.js +45 -62
- package/dist/textarea.cjs.js +6 -6
- package/dist/textarea.esm.js +32 -41
- package/dist/time-field.cjs.js +4 -4
- package/dist/time-field.esm.js +70 -84
- package/dist/time-picker.cjs.js +29 -21
- package/dist/time-picker.esm.js +96 -110
- package/dist/timeline.cjs.js +1 -1
- package/dist/timeline.esm.js +3 -5
- package/dist/toast.cjs.js +2 -2
- package/dist/toast.esm.js +33 -47
- package/dist/toggle-group.cjs.js +6 -6
- package/dist/toggle-group.esm.js +85 -105
- package/dist/toggle.cjs.js +1 -1
- package/dist/toggle.esm.js +3 -5
- package/dist/toolbar.cjs.js +1 -1
- package/dist/toolbar.esm.js +13 -24
- package/dist/tooltip.cjs.js +2 -2
- package/dist/tooltip.esm.js +31 -42
- package/dist/transfer-list.cjs.js +19 -19
- package/dist/transfer-list.esm.js +98 -111
- package/dist/{tree-dcd74a4a.mjs → tree-B3kE8ESs.mjs} +55 -62
- package/dist/tree-Dx_kv_ih.js +39 -0
- package/dist/tree-item.cjs.js +2 -2
- package/dist/tree-item.esm.js +2 -3
- package/dist/tree.cjs.js +1 -1
- package/dist/tree.esm.js +2 -5
- package/dist/ui-button-Q0GNNWKC.mjs +665 -0
- package/dist/ui-button-rXQOS9QJ.js +521 -0
- package/dist/{icon-9e9da03b.js → ui-icon-BzVNC_lr.js} +4 -4
- package/dist/{icon-e2a85cc1.mjs → ui-icon-YI6lyuqU.mjs} +58 -65
- package/dist/visually-hidden.cjs.js +1 -1
- package/dist/visually-hidden.esm.js +1 -1
- package/dist/wizard.cjs.js +14 -14
- package/dist/wizard.esm.js +85 -105
- package/package.json +3 -3
- 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
package/dist/runtime.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("./portal-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("./portal-DgpQ3Jo1.js"),t=require("./positioner-D_fqyx_j.js"),e=require("./runtime-CTaOSmBj.js");exports.autoUpdatePosition=a.autoUpdatePosition;exports.computePosition=a.computePosition;exports.createPortalContainer=a.createPortalContainer;exports.showPortalFor=a.showPortalFor;exports.arrowMiddleware=t.arrowMiddleware;exports.autoPlacementMiddleware=t.autoPlacementMiddleware;exports.autoUpdatePositioner=t.autoUpdatePositioner;exports.computePositionState=t.computePositionState;exports.createPositioner=t.createPositioner;exports.createVirtualPoint=t.createVirtualPoint;exports.createVirtualRange=t.createVirtualRange;exports.createVirtualRect=t.createVirtualRect;exports.detectPositionerOverflow=t.detectPositionerOverflow;exports.flipMiddleware=t.flipMiddleware;exports.hideMiddleware=t.hideMiddleware;exports.offsetMiddleware=t.offsetMiddleware;exports.shiftMiddleware=t.shiftMiddleware;exports.sizeMiddleware=t.sizeMiddleware;exports.AlertDialogManager=e.AlertDialogManager;exports.DialogManager=e.DialogManager;exports.alert=e.alert;exports.applyTheme=e.applyTheme;exports.baselineDarkTokens=e.baselineDarkTokens;exports.baselineLightTokens=e.baselineLightTokens;exports.confirm=e.confirm;exports.confirmDialog=e.confirmDialog;exports.createAlertDialogManager=e.createAlertDialogManager;exports.createDialogManager=e.createDialogManager;exports.createThemeTokens=e.createThemeTokens;exports.defaultTokens=e.defaultTokens;exports.dismissAllAlertDialogs=e.dismissAllAlertDialogs;exports.dismissAllDialogs=e.dismissAllDialogs;exports.prompt=e.prompt;exports.registerThemeHost=e.registerThemeHost;exports.showDialog=e.showDialog;exports.withAccentPalette=e.withAccentPalette;
|
package/dist/runtime.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { A, D as T, a as b,
|
|
1
|
+
import { a as s, c as t, b as o, s as i } from "./portal-bR42gHvG.mjs";
|
|
2
|
+
import { b as l, d as n, a as d, c, e as g, f as m, g as f, h as p, i as w, j as h, k as M, o as P, s as D, l as u } from "./positioner-D0VGxtYU.mjs";
|
|
3
|
+
import { A, D as T, a as b, b as x, d as V, e as j, f as R, g as U, h as v, i as y, j as z, k as C, l as F, m as H, p as L, r as O, s as S, w as q } from "./runtime-D1gFh1fS.mjs";
|
|
4
4
|
export {
|
|
5
5
|
A as AlertDialogManager,
|
|
6
6
|
T as DialogManager,
|
|
@@ -28,9 +28,9 @@ export {
|
|
|
28
28
|
w as detectPositionerOverflow,
|
|
29
29
|
F as dismissAllAlertDialogs,
|
|
30
30
|
H as dismissAllDialogs,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
h as flipMiddleware,
|
|
32
|
+
M as hideMiddleware,
|
|
33
|
+
P as offsetMiddleware,
|
|
34
34
|
L as prompt,
|
|
35
35
|
O as registerThemeHost,
|
|
36
36
|
D as shiftMiddleware,
|
package/dist/scroll-area.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("./ElementBase-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("./ElementBase-EV6mVBUV.js"),p=`
|
|
2
2
|
:host {
|
|
3
3
|
display: block;
|
|
4
4
|
max-height: 240px;
|
|
@@ -271,7 +271,7 @@
|
|
|
271
271
|
background: Highlight;
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
|
-
`;function g(
|
|
274
|
+
`;function g(e){return e==="both"||e==="horizontal"?e:"vertical"}function f(e){return e==="sm"||e==="lg"?e:"md"}function w(e){return e==="soft"||e==="inset"||e==="contrast"||e==="minimal"?e:"default"}function E(e){return e==="brand"||e==="info"||e==="success"||e==="warning"||e==="danger"?e:"neutral"}function m(e,t){if(e==null)return t;const r=e.toLowerCase();return r!=="false"&&r!=="0"}class _ extends v.ElementBase{constructor(){super(),this._domReady=!1,this._headless=!1,this._orientation="vertical",this._autoHide=!0,this._showShadows=!0,this._shellEl=null,this._viewportEl=null,this._contentEl=null,this._vTrackEl=null,this._hTrackEl=null,this._vThumbEl=null,this._hThumbEl=null,this._shadowTopEl=null,this._shadowBottomEl=null,this._shadowLeftEl=null,this._shadowRightEl=null,this._resizeObserver=null,this._mutationObserver=null,this._raf=0,this._hideTimer=0,this._dragAxis=null,this._dragStart=0,this._dragScrollStart=0,this._atStartY=!1,this._atEndY=!1,this._atStartX=!1,this._atEndX=!1,this._onViewportScroll=()=>{const t=this._viewportEl;if(!t)return;const r=Math.max(0,t.scrollHeight-t.clientHeight),i=Math.max(0,t.scrollWidth-t.clientWidth);this.dispatchEvent(new CustomEvent("scroll",{detail:{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,maxScrollTop:r,maxScrollLeft:i,progressY:r>0?t.scrollTop/r:0,progressX:i>0?t.scrollLeft/i:0},bubbles:!0,composed:!0})),this._showScrollbarsTemporarily(),this._scheduleMetrics()},this._onThumbPointerDownY=t=>{const r=t;!this._viewportEl||!this._vThumbEl||(r.preventDefault(),this._dragAxis="y",this._dragStart=r.clientY,this._dragScrollStart=this._viewportEl.scrollTop,this._vThumbEl.dataset.dragging="true",this._attachDrag())},this._onThumbPointerDownX=t=>{const r=t;!this._viewportEl||!this._hThumbEl||(r.preventDefault(),this._dragAxis="x",this._dragStart=r.clientX,this._dragScrollStart=this._viewportEl.scrollLeft,this._hThumbEl.dataset.dragging="true",this._attachDrag())},this._onPointerMove=t=>{const r=this._viewportEl;if(!(!r||!this._dragAxis)){if(this._dragAxis==="y"&&this._vTrackEl&&this._vThumbEl){const i=Math.max(1,this._vTrackEl.clientHeight),s=Math.max(1,this._vThumbEl.clientHeight),o=Math.max(1,i-s),l=Math.max(1,r.scrollHeight-r.clientHeight),a=t.clientY-this._dragStart;r.scrollTop=this._dragScrollStart+a/o*l;return}if(this._dragAxis==="x"&&this._hTrackEl&&this._hThumbEl){const i=Math.max(1,this._hTrackEl.clientWidth),s=Math.max(1,this._hThumbEl.clientWidth),o=Math.max(1,i-s),l=Math.max(1,r.scrollWidth-r.clientWidth),a=t.clientX-this._dragStart;r.scrollLeft=this._dragScrollStart+a/o*l}}},this._onPointerUp=()=>{this._detachDrag()}}static get observedAttributes(){return["orientation","size","variant","tone","auto-hide","shadows","headless"]}connectedCallback(){this._syncFromAttributes(),super.connectedCallback(),this._observe(),this._scheduleMetrics()}disconnectedCallback(){this._unobserve(),this._detachDrag(),this._raf&&cancelAnimationFrame(this._raf),this._hideTimer&&window.clearTimeout(this._hideTimer),super.disconnectedCallback()}attributeChangedCallback(t,r,i){r!==i&&(this._syncFromAttributes(),this._syncDomState(),this._scheduleMetrics())}get viewport(){return this._viewportEl}scrollToTop(t="smooth"){this._viewportEl?.scrollTo({top:0,behavior:t})}scrollToBottom(t="smooth"){const r=this._viewportEl;r&&r.scrollTo({top:r.scrollHeight,behavior:t})}scrollToLeft(t="smooth"){this._viewportEl?.scrollTo({left:0,behavior:t})}scrollToRight(t="smooth"){const r=this._viewportEl;r&&r.scrollTo({left:r.scrollWidth,behavior:t})}scrollToIndex(t,r="smooth"){const i=this._contentEl;if(!i)return;const o=Array.from(i.children)[t];o&&typeof o.scrollIntoView=="function"&&o.scrollIntoView({block:"nearest",inline:"nearest",behavior:r})}_syncFromAttributes(){this._headless=this.hasAttribute("headless"),this._orientation=g(this.getAttribute("orientation")),this._autoHide=m(this.getAttribute("auto-hide"),!0),this._showShadows=m(this.getAttribute("shadows"),!0)}_syncDomState(){const t=this._shellEl,r=this._viewportEl;if(!t||!r)return;const i=f(this.getAttribute("size")),s=w(this.getAttribute("variant")),o=E(this.getAttribute("tone"));t.dataset.size=i,t.dataset.variant=s,t.dataset.tone=o,t.dataset.orientation=this._orientation;const l=this.getAttribute("aria-label")||"Scrollable area";r.setAttribute("aria-label",l)}_ensureDom(){this._domReady||(this.setContent(`
|
|
275
275
|
<style>${p}</style>
|
|
276
276
|
<div class="shell" part="shell" data-scrolling="false">
|
|
277
277
|
<div class="shadow top" part="shadow-top"></div>
|
|
@@ -291,4 +291,4 @@
|
|
|
291
291
|
<div class="thumb" part="thumb thumb-horizontal"></div>
|
|
292
292
|
</div>
|
|
293
293
|
</div>
|
|
294
|
-
`),this._shellEl=this.root.querySelector(".shell"),this._viewportEl=this.root.querySelector(".scroll-area"),this._contentEl=this.root.querySelector(".scroll-content"),this._vTrackEl=this.root.querySelector(".scrollbar.vertical"),this._hTrackEl=this.root.querySelector(".scrollbar.horizontal"),this._vThumbEl=this.root.querySelector(".scrollbar.vertical .thumb"),this._hThumbEl=this.root.querySelector(".scrollbar.horizontal .thumb"),this._shadowTopEl=this.root.querySelector(".shadow.top"),this._shadowBottomEl=this.root.querySelector(".shadow.bottom"),this._shadowLeftEl=this.root.querySelector(".shadow.left"),this._shadowRightEl=this.root.querySelector(".shadow.right"),this._domReady=!0)}_attachDomListeners(){this._viewportEl&&(this._viewportEl.removeEventListener("scroll",this._onViewportScroll),this._viewportEl.addEventListener("scroll",this._onViewportScroll)),this._vThumbEl&&(this._vThumbEl.removeEventListener("pointerdown",this._onThumbPointerDownY),this._vThumbEl.addEventListener("pointerdown",this._onThumbPointerDownY)),this._hThumbEl&&(this._hThumbEl.removeEventListener("pointerdown",this._onThumbPointerDownX),this._hThumbEl.addEventListener("pointerdown",this._onThumbPointerDownX))}_observe(){typeof ResizeObserver<"u"&&(this._resizeObserver||(this._resizeObserver=new ResizeObserver(()=>this._scheduleMetrics())),this._viewportEl&&this._resizeObserver.observe(this._viewportEl),this._contentEl&&this._resizeObserver.observe(this._contentEl),this._resizeObserver.observe(this)),typeof MutationObserver<"u"&&this._contentEl&&(this._mutationObserver||(this._mutationObserver=new MutationObserver(()=>this._scheduleMetrics())),this._mutationObserver.observe(this._contentEl,{childList:!0,subtree:!0,characterData:!0}))}_unobserve(){
|
|
294
|
+
`),this._shellEl=this.root.querySelector(".shell"),this._viewportEl=this.root.querySelector(".scroll-area"),this._contentEl=this.root.querySelector(".scroll-content"),this._vTrackEl=this.root.querySelector(".scrollbar.vertical"),this._hTrackEl=this.root.querySelector(".scrollbar.horizontal"),this._vThumbEl=this.root.querySelector(".scrollbar.vertical .thumb"),this._hThumbEl=this.root.querySelector(".scrollbar.horizontal .thumb"),this._shadowTopEl=this.root.querySelector(".shadow.top"),this._shadowBottomEl=this.root.querySelector(".shadow.bottom"),this._shadowLeftEl=this.root.querySelector(".shadow.left"),this._shadowRightEl=this.root.querySelector(".shadow.right"),this._domReady=!0)}_attachDomListeners(){this._viewportEl&&(this._viewportEl.removeEventListener("scroll",this._onViewportScroll),this._viewportEl.addEventListener("scroll",this._onViewportScroll)),this._vThumbEl&&(this._vThumbEl.removeEventListener("pointerdown",this._onThumbPointerDownY),this._vThumbEl.addEventListener("pointerdown",this._onThumbPointerDownY)),this._hThumbEl&&(this._hThumbEl.removeEventListener("pointerdown",this._onThumbPointerDownX),this._hThumbEl.addEventListener("pointerdown",this._onThumbPointerDownX))}_observe(){typeof ResizeObserver<"u"&&(this._resizeObserver||(this._resizeObserver=new ResizeObserver(()=>this._scheduleMetrics())),this._viewportEl&&this._resizeObserver.observe(this._viewportEl),this._contentEl&&this._resizeObserver.observe(this._contentEl),this._resizeObserver.observe(this)),typeof MutationObserver<"u"&&this._contentEl&&(this._mutationObserver||(this._mutationObserver=new MutationObserver(()=>this._scheduleMetrics())),this._mutationObserver.observe(this._contentEl,{childList:!0,subtree:!0,characterData:!0}))}_unobserve(){this._viewportEl&&this._viewportEl.removeEventListener("scroll",this._onViewportScroll),this._vThumbEl?.removeEventListener("pointerdown",this._onThumbPointerDownY),this._hThumbEl?.removeEventListener("pointerdown",this._onThumbPointerDownX),this._resizeObserver?.disconnect(),this._mutationObserver?.disconnect(),this._resizeObserver=null,this._mutationObserver=null}_scheduleMetrics(){this._raf||(this._raf=requestAnimationFrame(()=>{this._raf=0,this._updateMetrics()}))}_showScrollbarsTemporarily(){if(this._shellEl){if(!this._autoHide){this._shellEl.dataset.scrolling="true";return}this._shellEl.dataset.scrolling="true",this._hideTimer&&window.clearTimeout(this._hideTimer),this._hideTimer=window.setTimeout(()=>{this._shellEl&&(this._shellEl.dataset.scrolling="false")},860)}}_updateMetrics(){const t=this._viewportEl,r=this._vTrackEl,i=this._hTrackEl,s=this._vThumbEl,o=this._hThumbEl;if(!t||!r||!i||!s||!o)return;const l=this._orientation!=="horizontal"&&t.scrollHeight>t.clientHeight+1,a=this._orientation!=="vertical"&&t.scrollWidth>t.clientWidth+1;r.style.display=l?"":"none",i.style.display=a?"":"none";const n=Math.max(1,t.scrollHeight-t.clientHeight),d=Math.max(1,t.scrollWidth-t.clientWidth);if(l){const h=Math.max(1,r.clientHeight),c=Math.max(24,t.clientHeight/t.scrollHeight*h),u=Math.max(0,h-c),b=t.scrollTop/n*u;s.style.height=`${c}px`,s.style.transform=`translateY(${b}px)`}if(a){const h=Math.max(1,i.clientWidth),c=Math.max(24,t.clientWidth/t.scrollWidth*h),u=Math.max(0,h-c),b=t.scrollLeft/d*u;o.style.width=`${c}px`,o.style.transform=`translateX(${b}px)`}this._updateShadows(t,n,d),this._emitEdgeEvents(t,n,d)}_updateShadows(t,r,i){const s=this._showShadows,o=s&&t.scrollTop>1,l=s&&t.scrollTop<r-1,a=s&&t.scrollLeft>1,n=s&&t.scrollLeft<i-1;this._shadowTopEl&&(this._shadowTopEl.style.opacity=o?"1":"0"),this._shadowBottomEl&&(this._shadowBottomEl.style.opacity=l?"1":"0"),this._shadowLeftEl&&(this._shadowLeftEl.style.opacity=a?"1":"0"),this._shadowRightEl&&(this._shadowRightEl.style.opacity=n?"1":"0")}_emitEdgeEvents(t,r,i){const s=t.scrollTop<=0,o=t.scrollTop>=r-1,l=t.scrollLeft<=0,a=t.scrollLeft>=i-1;s&&!this._atStartY&&this.dispatchEvent(new CustomEvent("reach-start",{bubbles:!0,composed:!0})),o&&!this._atEndY&&this.dispatchEvent(new CustomEvent("reach-end",{bubbles:!0,composed:!0})),l&&!this._atStartX&&this.dispatchEvent(new CustomEvent("reach-start-x",{bubbles:!0,composed:!0})),a&&!this._atEndX&&this.dispatchEvent(new CustomEvent("reach-end-x",{bubbles:!0,composed:!0})),this._atStartY=s,this._atEndY=o,this._atStartX=l,this._atEndX=a}_attachDrag(){window.addEventListener("pointermove",this._onPointerMove),window.addEventListener("pointerup",this._onPointerUp)}_detachDrag(){window.removeEventListener("pointermove",this._onPointerMove),window.removeEventListener("pointerup",this._onPointerUp),this._vThumbEl&&(this._vThumbEl.dataset.dragging="false"),this._hThumbEl&&(this._hThumbEl.dataset.dragging="false"),this._dragAxis=null}render(){this._ensureDom(),!(!this._shellEl||!this._viewportEl)&&(this._attachDomListeners(),this._syncDomState(),this._observe(),this._scheduleMetrics())}shouldRenderOnAttributeChange(t,r,i){return!1}}typeof customElements<"u"&&!customElements.get("ui-scroll-area")&&customElements.define("ui-scroll-area",_);exports.UIScrollArea=_;
|
package/dist/scroll-area.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as _ } from "./ElementBase-
|
|
1
|
+
import { E as _ } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
2
|
const p = `
|
|
3
3
|
:host {
|
|
4
4
|
display: block;
|
|
@@ -273,40 +273,38 @@ const p = `
|
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
`;
|
|
276
|
-
function v(
|
|
277
|
-
return
|
|
276
|
+
function v(e) {
|
|
277
|
+
return e === "both" || e === "horizontal" ? e : "vertical";
|
|
278
278
|
}
|
|
279
|
-
function g(
|
|
280
|
-
return
|
|
279
|
+
function g(e) {
|
|
280
|
+
return e === "sm" || e === "lg" ? e : "md";
|
|
281
281
|
}
|
|
282
|
-
function f(
|
|
283
|
-
return
|
|
282
|
+
function f(e) {
|
|
283
|
+
return e === "soft" || e === "inset" || e === "contrast" || e === "minimal" ? e : "default";
|
|
284
284
|
}
|
|
285
|
-
function w(
|
|
286
|
-
return
|
|
285
|
+
function w(e) {
|
|
286
|
+
return e === "brand" || e === "info" || e === "success" || e === "warning" || e === "danger" ? e : "neutral";
|
|
287
287
|
}
|
|
288
|
-
function m(
|
|
289
|
-
if (
|
|
290
|
-
|
|
291
|
-
const r = i.toLowerCase();
|
|
288
|
+
function m(e, t) {
|
|
289
|
+
if (e == null) return t;
|
|
290
|
+
const r = e.toLowerCase();
|
|
292
291
|
return r !== "false" && r !== "0";
|
|
293
292
|
}
|
|
294
293
|
class E extends _ {
|
|
295
294
|
constructor() {
|
|
296
295
|
super(), this._domReady = !1, this._headless = !1, this._orientation = "vertical", this._autoHide = !0, this._showShadows = !0, this._shellEl = null, this._viewportEl = null, this._contentEl = null, this._vTrackEl = null, this._hTrackEl = null, this._vThumbEl = null, this._hThumbEl = null, this._shadowTopEl = null, this._shadowBottomEl = null, this._shadowLeftEl = null, this._shadowRightEl = null, this._resizeObserver = null, this._mutationObserver = null, this._raf = 0, this._hideTimer = 0, this._dragAxis = null, this._dragStart = 0, this._dragScrollStart = 0, this._atStartY = !1, this._atEndY = !1, this._atStartX = !1, this._atEndX = !1, this._onViewportScroll = () => {
|
|
297
296
|
const t = this._viewportEl;
|
|
298
|
-
if (!t)
|
|
299
|
-
|
|
300
|
-
const r = Math.max(0, t.scrollHeight - t.clientHeight), e = Math.max(0, t.scrollWidth - t.clientWidth);
|
|
297
|
+
if (!t) return;
|
|
298
|
+
const r = Math.max(0, t.scrollHeight - t.clientHeight), i = Math.max(0, t.scrollWidth - t.clientWidth);
|
|
301
299
|
this.dispatchEvent(
|
|
302
300
|
new CustomEvent("scroll", {
|
|
303
301
|
detail: {
|
|
304
302
|
scrollTop: t.scrollTop,
|
|
305
303
|
scrollLeft: t.scrollLeft,
|
|
306
304
|
maxScrollTop: r,
|
|
307
|
-
maxScrollLeft:
|
|
305
|
+
maxScrollLeft: i,
|
|
308
306
|
progressY: r > 0 ? t.scrollTop / r : 0,
|
|
309
|
-
progressX:
|
|
307
|
+
progressX: i > 0 ? t.scrollLeft / i : 0
|
|
310
308
|
},
|
|
311
309
|
bubbles: !0,
|
|
312
310
|
composed: !0
|
|
@@ -322,12 +320,12 @@ class E extends _ {
|
|
|
322
320
|
const r = this._viewportEl;
|
|
323
321
|
if (!(!r || !this._dragAxis)) {
|
|
324
322
|
if (this._dragAxis === "y" && this._vTrackEl && this._vThumbEl) {
|
|
325
|
-
const
|
|
323
|
+
const i = Math.max(1, this._vTrackEl.clientHeight), s = Math.max(1, this._vThumbEl.clientHeight), o = Math.max(1, i - s), l = Math.max(1, r.scrollHeight - r.clientHeight), a = t.clientY - this._dragStart;
|
|
326
324
|
r.scrollTop = this._dragScrollStart + a / o * l;
|
|
327
325
|
return;
|
|
328
326
|
}
|
|
329
327
|
if (this._dragAxis === "x" && this._hTrackEl && this._hThumbEl) {
|
|
330
|
-
const
|
|
328
|
+
const i = Math.max(1, this._hTrackEl.clientWidth), s = Math.max(1, this._hThumbEl.clientWidth), o = Math.max(1, i - s), l = Math.max(1, r.scrollWidth - r.clientWidth), a = t.clientX - this._dragStart;
|
|
331
329
|
r.scrollLeft = this._dragScrollStart + a / o * l;
|
|
332
330
|
}
|
|
333
331
|
}
|
|
@@ -344,33 +342,30 @@ class E extends _ {
|
|
|
344
342
|
disconnectedCallback() {
|
|
345
343
|
this._unobserve(), this._detachDrag(), this._raf && cancelAnimationFrame(this._raf), this._hideTimer && window.clearTimeout(this._hideTimer), super.disconnectedCallback();
|
|
346
344
|
}
|
|
347
|
-
attributeChangedCallback(t, r,
|
|
348
|
-
r !==
|
|
345
|
+
attributeChangedCallback(t, r, i) {
|
|
346
|
+
r !== i && (this._syncFromAttributes(), this._syncDomState(), this._scheduleMetrics());
|
|
349
347
|
}
|
|
350
348
|
get viewport() {
|
|
351
349
|
return this._viewportEl;
|
|
352
350
|
}
|
|
353
351
|
scrollToTop(t = "smooth") {
|
|
354
|
-
|
|
355
|
-
(r = this._viewportEl) == null || r.scrollTo({ top: 0, behavior: t });
|
|
352
|
+
this._viewportEl?.scrollTo({ top: 0, behavior: t });
|
|
356
353
|
}
|
|
357
354
|
scrollToBottom(t = "smooth") {
|
|
358
355
|
const r = this._viewportEl;
|
|
359
356
|
r && r.scrollTo({ top: r.scrollHeight, behavior: t });
|
|
360
357
|
}
|
|
361
358
|
scrollToLeft(t = "smooth") {
|
|
362
|
-
|
|
363
|
-
(r = this._viewportEl) == null || r.scrollTo({ left: 0, behavior: t });
|
|
359
|
+
this._viewportEl?.scrollTo({ left: 0, behavior: t });
|
|
364
360
|
}
|
|
365
361
|
scrollToRight(t = "smooth") {
|
|
366
362
|
const r = this._viewportEl;
|
|
367
363
|
r && r.scrollTo({ left: r.scrollWidth, behavior: t });
|
|
368
364
|
}
|
|
369
365
|
scrollToIndex(t, r = "smooth") {
|
|
370
|
-
const
|
|
371
|
-
if (!
|
|
372
|
-
|
|
373
|
-
const o = Array.from(e.children)[t];
|
|
366
|
+
const i = this._contentEl;
|
|
367
|
+
if (!i) return;
|
|
368
|
+
const o = Array.from(i.children)[t];
|
|
374
369
|
o && typeof o.scrollIntoView == "function" && o.scrollIntoView({ block: "nearest", inline: "nearest", behavior: r });
|
|
375
370
|
}
|
|
376
371
|
_syncFromAttributes() {
|
|
@@ -378,10 +373,9 @@ class E extends _ {
|
|
|
378
373
|
}
|
|
379
374
|
_syncDomState() {
|
|
380
375
|
const t = this._shellEl, r = this._viewportEl;
|
|
381
|
-
if (!t || !r)
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
t.dataset.size = e, t.dataset.variant = s, t.dataset.tone = o, t.dataset.orientation = this._orientation;
|
|
376
|
+
if (!t || !r) return;
|
|
377
|
+
const i = g(this.getAttribute("size")), s = f(this.getAttribute("variant")), o = w(this.getAttribute("tone"));
|
|
378
|
+
t.dataset.size = i, t.dataset.variant = s, t.dataset.tone = o, t.dataset.orientation = this._orientation;
|
|
385
379
|
const l = this.getAttribute("aria-label") || "Scrollable area";
|
|
386
380
|
r.setAttribute("aria-label", l);
|
|
387
381
|
}
|
|
@@ -415,8 +409,7 @@ class E extends _ {
|
|
|
415
409
|
typeof ResizeObserver < "u" && (this._resizeObserver || (this._resizeObserver = new ResizeObserver(() => this._scheduleMetrics())), this._viewportEl && this._resizeObserver.observe(this._viewportEl), this._contentEl && this._resizeObserver.observe(this._contentEl), this._resizeObserver.observe(this)), typeof MutationObserver < "u" && this._contentEl && (this._mutationObserver || (this._mutationObserver = new MutationObserver(() => this._scheduleMetrics())), this._mutationObserver.observe(this._contentEl, { childList: !0, subtree: !0, characterData: !0 }));
|
|
416
410
|
}
|
|
417
411
|
_unobserve() {
|
|
418
|
-
|
|
419
|
-
this._viewportEl && this._viewportEl.removeEventListener("scroll", this._onViewportScroll), (t = this._vThumbEl) == null || t.removeEventListener("pointerdown", this._onThumbPointerDownY), (r = this._hThumbEl) == null || r.removeEventListener("pointerdown", this._onThumbPointerDownX), (e = this._resizeObserver) == null || e.disconnect(), (s = this._mutationObserver) == null || s.disconnect(), this._resizeObserver = null, this._mutationObserver = null;
|
|
412
|
+
this._viewportEl && this._viewportEl.removeEventListener("scroll", this._onViewportScroll), this._vThumbEl?.removeEventListener("pointerdown", this._onThumbPointerDownY), this._hThumbEl?.removeEventListener("pointerdown", this._onThumbPointerDownX), this._resizeObserver?.disconnect(), this._mutationObserver?.disconnect(), this._resizeObserver = null, this._mutationObserver = null;
|
|
420
413
|
}
|
|
421
414
|
_scheduleMetrics() {
|
|
422
415
|
this._raf || (this._raf = requestAnimationFrame(() => {
|
|
@@ -435,28 +428,27 @@ class E extends _ {
|
|
|
435
428
|
}
|
|
436
429
|
}
|
|
437
430
|
_updateMetrics() {
|
|
438
|
-
const t = this._viewportEl, r = this._vTrackEl,
|
|
439
|
-
if (!t || !r || !
|
|
440
|
-
return;
|
|
431
|
+
const t = this._viewportEl, r = this._vTrackEl, i = this._hTrackEl, s = this._vThumbEl, o = this._hThumbEl;
|
|
432
|
+
if (!t || !r || !i || !s || !o) return;
|
|
441
433
|
const l = this._orientation !== "horizontal" && t.scrollHeight > t.clientHeight + 1, a = this._orientation !== "vertical" && t.scrollWidth > t.clientWidth + 1;
|
|
442
|
-
r.style.display = l ? "" : "none",
|
|
434
|
+
r.style.display = l ? "" : "none", i.style.display = a ? "" : "none";
|
|
443
435
|
const n = Math.max(1, t.scrollHeight - t.clientHeight), d = Math.max(1, t.scrollWidth - t.clientWidth);
|
|
444
436
|
if (l) {
|
|
445
437
|
const h = Math.max(1, r.clientHeight), c = Math.max(24, t.clientHeight / t.scrollHeight * h), u = Math.max(0, h - c), b = t.scrollTop / n * u;
|
|
446
438
|
s.style.height = `${c}px`, s.style.transform = `translateY(${b}px)`;
|
|
447
439
|
}
|
|
448
440
|
if (a) {
|
|
449
|
-
const h = Math.max(1,
|
|
441
|
+
const h = Math.max(1, i.clientWidth), c = Math.max(24, t.clientWidth / t.scrollWidth * h), u = Math.max(0, h - c), b = t.scrollLeft / d * u;
|
|
450
442
|
o.style.width = `${c}px`, o.style.transform = `translateX(${b}px)`;
|
|
451
443
|
}
|
|
452
444
|
this._updateShadows(t, n, d), this._emitEdgeEvents(t, n, d);
|
|
453
445
|
}
|
|
454
|
-
_updateShadows(t, r,
|
|
455
|
-
const s = this._showShadows, o = s && t.scrollTop > 1, l = s && t.scrollTop < r - 1, a = s && t.scrollLeft > 1, n = s && t.scrollLeft <
|
|
446
|
+
_updateShadows(t, r, i) {
|
|
447
|
+
const s = this._showShadows, o = s && t.scrollTop > 1, l = s && t.scrollTop < r - 1, a = s && t.scrollLeft > 1, n = s && t.scrollLeft < i - 1;
|
|
456
448
|
this._shadowTopEl && (this._shadowTopEl.style.opacity = o ? "1" : "0"), this._shadowBottomEl && (this._shadowBottomEl.style.opacity = l ? "1" : "0"), this._shadowLeftEl && (this._shadowLeftEl.style.opacity = a ? "1" : "0"), this._shadowRightEl && (this._shadowRightEl.style.opacity = n ? "1" : "0");
|
|
457
449
|
}
|
|
458
|
-
_emitEdgeEvents(t, r,
|
|
459
|
-
const s = t.scrollTop <= 0, o = t.scrollTop >= r - 1, l = t.scrollLeft <= 0, a = t.scrollLeft >=
|
|
450
|
+
_emitEdgeEvents(t, r, i) {
|
|
451
|
+
const s = t.scrollTop <= 0, o = t.scrollTop >= r - 1, l = t.scrollLeft <= 0, a = t.scrollLeft >= i - 1;
|
|
460
452
|
s && !this._atStartY && this.dispatchEvent(new CustomEvent("reach-start", { bubbles: !0, composed: !0 })), o && !this._atEndY && this.dispatchEvent(new CustomEvent("reach-end", { bubbles: !0, composed: !0 })), l && !this._atStartX && this.dispatchEvent(new CustomEvent("reach-start-x", { bubbles: !0, composed: !0 })), a && !this._atEndX && this.dispatchEvent(new CustomEvent("reach-end-x", { bubbles: !0, composed: !0 })), this._atStartY = s, this._atEndY = o, this._atStartX = l, this._atEndX = a;
|
|
461
453
|
}
|
|
462
454
|
_attachDrag() {
|
|
@@ -468,7 +460,7 @@ class E extends _ {
|
|
|
468
460
|
render() {
|
|
469
461
|
this._ensureDom(), !(!this._shellEl || !this._viewportEl) && (this._attachDomListeners(), this._syncDomState(), this._observe(), this._scheduleMetrics());
|
|
470
462
|
}
|
|
471
|
-
shouldRenderOnAttributeChange(t, r,
|
|
463
|
+
shouldRenderOnAttributeChange(t, r, i) {
|
|
472
464
|
return !1;
|
|
473
465
|
}
|
|
474
466
|
}
|
|
@@ -4,8 +4,7 @@ function c() {
|
|
|
4
4
|
}
|
|
5
5
|
function l() {
|
|
6
6
|
const t = globalThis, o = t[n];
|
|
7
|
-
if (o)
|
|
8
|
-
return o;
|
|
7
|
+
if (o) return o;
|
|
9
8
|
const e = {
|
|
10
9
|
count: 0,
|
|
11
10
|
bodyOverflow: "",
|
|
@@ -24,9 +23,8 @@ function u(t) {
|
|
|
24
23
|
return !o || o === "0" || o === "0px" ? "calc(100vw - 100%)" : `calc(${o} + (100vw - 100%))`;
|
|
25
24
|
}
|
|
26
25
|
function i() {
|
|
27
|
-
if (!c())
|
|
28
|
-
|
|
29
|
-
};
|
|
26
|
+
if (!c()) return () => {
|
|
27
|
+
};
|
|
30
28
|
const t = l();
|
|
31
29
|
if (t.count += 1, t.count === 1) {
|
|
32
30
|
const e = document.body, r = document.documentElement;
|
|
@@ -38,11 +36,9 @@ function i() {
|
|
|
38
36
|
};
|
|
39
37
|
}
|
|
40
38
|
function d() {
|
|
41
|
-
if (!c())
|
|
42
|
-
return;
|
|
39
|
+
if (!c()) return;
|
|
43
40
|
const t = l();
|
|
44
|
-
if (t.count <= 0 || (t.count -= 1, t.count > 0))
|
|
45
|
-
return;
|
|
41
|
+
if (t.count <= 0 || (t.count -= 1, t.count > 0)) return;
|
|
46
42
|
const o = document.body, e = document.documentElement;
|
|
47
43
|
o.style.overflow = t.bodyOverflow, e.style.overflow = t.htmlOverflow, o.style.paddingRight = t.bodyPaddingRight, e.style.scrollbarGutter = t.htmlScrollbarGutter, o.style.scrollbarGutter = t.bodyScrollbarGutter;
|
|
48
44
|
}
|
package/dist/section.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("./ElementBase-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("./ElementBase-EV6mVBUV.js"),c=`
|
|
2
2
|
:host {
|
|
3
3
|
display: block;
|
|
4
4
|
width: 100%;
|
package/dist/section.esm.js
CHANGED
package/dist/select.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const q=require("./ElementBase-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const q=require("./ElementBase-EV6mVBUV.js"),x=require("./collection-qv8A8rq4.js"),$=require("./listbox-B6QgECax.js"),L=`
|
|
2
2
|
:host {
|
|
3
3
|
--ui-select-width: var(--ui-width, min(340px, 100%));
|
|
4
4
|
--ui-select-min-height: var(--base-select-height-md, 42px);
|
|
@@ -742,12 +742,12 @@
|
|
|
742
742
|
border-bottom-color: CanvasText;
|
|
743
743
|
}
|
|
744
744
|
}
|
|
745
|
-
`;function h(p){if(p==null)return!1;const e=String(p).toLowerCase();return e!=="false"&&e!=="0"}function f(p){return String(p).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function F(p){if(!p)return null;const e=String(p).trim();return e?e==="none"?"4px":e==="full"?"999px":e==="large"?"16px":/^-?\\d+(\\.\\d+)?$/.test(e)?`${e}px`:e:null}const C=new Set(["value","disabled","loading","required","placeholder","name","tabindex","headless","size","variant","tone","density","radius","shape","elevation","option-border","show-check","check-placement","label","description","error","aria-label","validation","invalid","data-invalid","data-valid","close-on-scroll"]);class I extends q.ElementBase{constructor(){super(),this._controlEl=null,this._triggerEl=null,this._valueEl=null,this._panelEl=null,this._menuEl=null,this._observer=null,this._formUnregister=null,this._optionsSyncRaf=0,this._panelPlacementRaf=0,this._uid=Math.random().toString(36).slice(2,8),this._options=[],this._menuItems=[],this._optionsFingerprint="",this._menuRenderFingerprint="",this._open=!1,this._activeIndex=-1,this._placement="bottom",this._onRootClick=this._onRootClick.bind(this),this._onRootKeyDown=this._onRootKeyDown.bind(this),this._onRootPointerDown=this._onRootPointerDown.bind(this),this._onRootPointerMove=this._onRootPointerMove.bind(this),this._onSlotChange=this._onSlotChange.bind(this),this._onDocumentPointerDown=this._onDocumentPointerDown.bind(this),this._onWindowResize=this._onWindowResize.bind(this),this._onWindowScroll=this._onWindowScroll.bind(this)}static get observedAttributes(){return["value","disabled","loading","required","placeholder","name","tabindex","headless","size","variant","tone","density","radius","shape","elevation","option-border","show-check","check-placement","label","description","error","aria-label","validation","invalid","data-invalid","data-valid","close-on-scroll"]}connectedCallback(){super.connectedCallback(),this.root.addEventListener("click",this._onRootClick),this.root.addEventListener("keydown",this._onRootKeyDown),this.root.addEventListener("pointerdown",this._onRootPointerDown),this.root.addEventListener("pointermove",this._onRootPointerMove,{passive:!0}),this.root.addEventListener("slotchange",this._onSlotChange),this._observer=new MutationObserver(e=>{e.some(i=>{if(!(i.target instanceof HTMLElement)||i.target===this)return i.type==="childList";const s=i.target.tagName.toLowerCase();return s==="option"||s==="optgroup"})&&this._scheduleOptionsSync()}),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value","selected","disabled","label","slot"]}),this._attachFormRegistration()}disconnectedCallback(){this.root.removeEventListener("click",this._onRootClick),this.root.removeEventListener("keydown",this._onRootKeyDown),this.root.removeEventListener("pointerdown",this._onRootPointerDown),this.root.removeEventListener("pointermove",this._onRootPointerMove),this.root.removeEventListener("slotchange",this._onSlotChange),this._teardownOpenListeners(),this._observer&&(this._observer.disconnect(),this._observer=null),this._cancelOptionsSync(),this._cancelPanelPlacement(),this._formUnregister&&(this._formUnregister(),this._formUnregister=null),super.disconnectedCallback()}shouldRenderOnAttributeChange(e){return!C.has(e)}attributeChangedCallback(e,t,i){if(t!==i){if(e==="name"&&this._attachFormRegistration(),this._triggerEl&&C.has(e)){(e==="value"||e==="placeholder"||e==="required")&&(this._syncOptionsData(),this._open&&this._renderMenu()),(e==="show-check"||e==="check-placement")&&this._open&&this._renderMenu(),this._syncControlState(),this.disabled&&this._open&&this._closeMenu({restoreFocus:!1});return}super.attributeChangedCallback(e,t,i)}}get value(){return this.getAttribute("value")||""}set value(e){const t=String(e||"");t!==this.value&&this.setAttribute("value",t)}get disabled(){return h(this.getAttribute("disabled"))||h(this.getAttribute("loading"))}set disabled(e){e?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get closeOnScroll(){return h(this.getAttribute("close-on-scroll"))||!this.hasAttribute("close-on-scroll")}set closeOnScroll(e){this.setAttribute("close-on-scroll",e?"true":"false")}get showCheck(){return h(this.getAttribute("show-check"))}set showCheck(e){e?this.setAttribute("show-check","true"):this.removeAttribute("show-check")}focus(e){if(this._triggerEl){this._triggerEl.focus(e);return}super.focus(e)}blur(){if(this._triggerEl){this._triggerEl.blur();return}super.blur()}_onSlotChange(){this.requestRender()}_onRootPointerDown(e){const t=e.target;t&&t.closest(".menu-item")&&e.preventDefault()}_onRootPointerMove(e){if(!this._open)return;const t=e.target,i=t==null?void 0:t.closest(".menu-item[data-index]");if(!i)return;const s=Number(i.dataset.index||"-1"),o=this._options[s];!o||o.disabled||s===this._activeIndex||this._setActiveIndex(s)}_onRootClick(e){const t=e.target;if(!t)return;if(t.closest(".trigger")){if(this.disabled)return;this._open?this._closeMenu({restoreFocus:!1}):this._openMenu();return}const i=t.closest(".menu-item[data-index]");if(!i)return;const s=Number(i.dataset.index||"-1"),o=this._options[s];!o||o.disabled||(this._applyValueFromUser(o.value),this._closeMenu())}_onRootKeyDown(e){const t=e.target;if(!(!t||t!==this._triggerEl&&!t.closest(".menu"))&&!this.disabled)switch(e.key){case"ArrowDown":e.preventDefault(),this._open?this._moveActive(1):this._openMenu();break;case"ArrowUp":e.preventDefault(),this._open?this._moveActive(-1):this._openMenu();break;case"Home":if(!this._open)return;e.preventDefault(),this._setActiveIndex(this._firstEnabledIndex());break;case"End":if(!this._open)return;e.preventDefault(),this._setActiveIndex(this._lastEnabledIndex());break;case"Enter":case" ":{if(e.preventDefault(),!this._open){this._openMenu();return}this._selectActiveOption();break}case"Escape":if(!this._open)return;e.preventDefault(),this._closeMenu();break;case"Tab":this._open&&this._closeMenu({restoreFocus:!1});break}}_onDocumentPointerDown(e){if(!this._open)return;const t=typeof e.composedPath=="function"?e.composedPath():[];t.includes(this)||t.includes(this.root)||this._closeMenu({restoreFocus:!1})}_isInternalEvent(e){var s,o,a;const t=e.target,i=typeof e.composedPath=="function"?e.composedPath():[];return i.includes(this)||i.includes(this.root)||t instanceof Node&&(t===this||this.root.contains(t)||(s=this._controlEl)!=null&&s.contains(t)||(o=this._panelEl)!=null&&o.contains(t)||(a=this._menuEl)!=null&&a.contains(t))?!0:!!(this._controlEl&&i.includes(this._controlEl)||this._triggerEl&&i.includes(this._triggerEl)||this._panelEl&&i.includes(this._panelEl)||this._menuEl&&i.includes(this._menuEl))}_onWindowResize(){this._open&&this._schedulePanelPlacement()}_onWindowScroll(e){if(this._open&&!this._isInternalEvent(e)){if(this.closeOnScroll){this._closeMenu({restoreFocus:!1});return}this._schedulePanelPlacement()}}_attachOpenListeners(){document.addEventListener("pointerdown",this._onDocumentPointerDown,!0),window.addEventListener("resize",this._onWindowResize,{passive:!0}),window.addEventListener("scroll",this._onWindowScroll,{passive:!0,capture:!0})}_teardownOpenListeners(){document.removeEventListener("pointerdown",this._onDocumentPointerDown,!0),window.removeEventListener("resize",this._onWindowResize),window.removeEventListener("scroll",this._onWindowScroll,!0)}_scheduleOptionsSync(){this._optionsSyncRaf||(this._optionsSyncRaf=requestAnimationFrame(()=>{this._optionsSyncRaf=0,this._syncOptionsData()&&this._open?this._renderMenu():this._syncControlState()}))}_cancelOptionsSync(){this._optionsSyncRaf&&(cancelAnimationFrame(this._optionsSyncRaf),this._optionsSyncRaf=0)}_schedulePanelPlacement(){this._panelPlacementRaf||(this._panelPlacementRaf=requestAnimationFrame(()=>{this._panelPlacementRaf=0,this._syncPanelPlacement()}))}_cancelPanelPlacement(){this._panelPlacementRaf&&(cancelAnimationFrame(this._panelPlacementRaf),this._panelPlacementRaf=0)}_emitValue(e,t){this.dispatchEvent(new CustomEvent(e,{detail:{value:t},bubbles:!0,composed:!0}))}_applyValueFromUser(e){(this.getAttribute("value")||"")!==e&&(this.setAttribute("value",e),this._emitValue("input",e),this._emitValue("change",e))}_attachFormRegistration(){var o;this._formUnregister&&(this._formUnregister(),this._formUnregister=null);const e=this.getAttribute("name");if(!e)return;const t=this.getRootNode(),i=t instanceof ShadowRoot?t.host:null,s=((o=i==null?void 0:i.closest)==null?void 0:o.call(i,"ui-form"))||this.closest("ui-form");!s||typeof s.registerField!="function"||(this._formUnregister=s.registerField(e,{name:e,getValue:()=>this.value,setValue:a=>{this.value=a},validate:async()=>{if(!(h(this.getAttribute("required"))||this.hasAttribute("required")))return{valid:!0};const r=this.value.trim().length>0;return{valid:r,message:r?void 0:"This field is required."}},setError:a=>{a?(this.setAttribute("validation","error"),this.setAttribute("error",a)):(this.getAttribute("validation")==="error"&&this.removeAttribute("validation"),this.removeAttribute("error"))}}))}_hasSlotContent(e){return!!this.querySelector(`[slot="${e}"]`)}_setValueAttr(e){const t=String(e??"");this.getAttribute("value")!==t&&this.setAttribute("value",t)}_buildOptionsFromChildren(){const e=[],t=(r,u)=>{const n=(r.label||r.textContent||r.value||"").trim(),c=String(r.value??"");e.push({value:c,label:n||c,disabled:!!r.disabled,group:u})};Array.from(this.children).filter(r=>r instanceof HTMLElement?!r.hasAttribute("slot"):!1).forEach(r=>{const u=r.tagName.toLowerCase();if(u==="option"){t(r,"");return}if(u==="optgroup"){const n=r,c=(n.label||"").trim();Array.from(n.children).forEach(l=>{l instanceof HTMLOptionElement&&e.push({value:String(l.value??""),label:(l.label||l.textContent||l.value||"").trim()||String(l.value??""),disabled:!!l.disabled||!!n.disabled,group:c})})}});const s=(this.getAttribute("placeholder")||"").trim(),o=h(this.getAttribute("required"))||this.hasAttribute("required"),a=e.some(r=>r.value==="");return s&&!o&&!a&&e.unshift({value:"",label:s,disabled:!1,group:""}),e}_computeOptionsFingerprint(e){return e.map(t=>`${t.value}${t.label}${t.disabled?"1":"0"}${t.group}`).join("")}_firstEnabledIndex(){return x.findFirstEnabledIndex(this._options,e=>e.disabled)}_lastEnabledIndex(){return x.findLastEnabledIndex(this._options,e=>e.disabled)}_selectedIndex(){return x.findIndexByValue(this._options,this.value,e=>e.value)}_checkPlacement(){return this.getAttribute("check-placement")==="start"?"start":"end"}_syncOptionsData(){var c;const e=this._buildOptionsFromChildren(),t=this._computeOptionsFingerprint(e),i=t!==this._optionsFingerprint;this._options=e,this._optionsFingerprint=t;const s=this.getAttribute("value")||"",o=this.hasAttribute("value"),a=this._options.some(l=>l.value===s),r=h(this.getAttribute("required"))||this.hasAttribute("required"),u=((c=this._options.find(l=>!l.disabled))==null?void 0:c.value)||"",n=!r&&this._options.some(l=>l.value==="")?"":u;return o?a||this._setValueAttr(n):this._setValueAttr(n),i}_currentDisplayText(){const e=this.value,t=(this.getAttribute("placeholder")||"").trim();if(e===""&&t)return t;const i=this._options.find(s=>s.value===e);return(i==null?void 0:i.label)||e}_setActiveIndex(e){if(!this._menuEl||e===this._activeIndex)return;this._activeIndex=e;const t=e>=0&&this._menuItems[e]||null;this._menuEl.setActiveItem(t,{focus:!1,owner:this._triggerEl,scroll:!0})}_moveActive(e){if(!this._menuEl||!this._options.length)return;const t=this._activeIndex>=0?this._menuItems[this._activeIndex]:null,i=this._menuEl.move(e,{current:t,focus:!1,owner:this._triggerEl,scroll:!0});if(!i)return;const s=Number(i.dataset.index||"-1");s>=0&&(this._activeIndex=s)}_selectActiveOption(){if(this._activeIndex<0)return;const e=this._options[this._activeIndex];!e||e.disabled||(this._applyValueFromUser(e.value),this._closeMenu())}_renderMenu(){const e=this._menuEl;if(!e)return;const t=`${this._optionsFingerprint}${this.showCheck?"1":"0"}${this._checkPlacement()}`;if(this._menuItems.length>0&&t===this._menuRenderFingerprint&&this._menuItems.length===this._options.length){this._syncMenuSelectionState(),this._schedulePanelPlacement();return}if(e.replaceChildren(),this._menuItems=[],!this._options.length){const r=document.createElement("p");r.className="menu-empty",r.textContent="No options available",e.appendChild(r),this._menuRenderFingerprint=t,e.refresh();return}let s="__none__";this._options.forEach((r,u)=>{if(r.group&&r.group!==s){const d=document.createElement("div");d.className="menu-group",d.setAttribute("role","presentation"),d.textContent=r.group,e.appendChild(d),s=r.group}r.group||(s="__none__");const n=document.createElement("button");n.type="button",n.className="menu-item",n.id=`${this._uid}-opt-${u}`,n.setAttribute("role","option"),n.setAttribute("data-index",String(u)),n.setAttribute("data-value",r.value),n.setAttribute("aria-selected",r.value===this.value?"true":"false"),n.setAttribute("aria-disabled",r.disabled?"true":"false"),n.tabIndex=-1,r.disabled&&(n.disabled=!0);const c=document.createElement("span");c.className="menu-item-label",c.textContent=r.label;const l=document.createElement("span");l.className="menu-item-check",l.setAttribute("aria-hidden","true");const b=this.showCheck,m=this._checkPlacement();l.hidden=!b,n.setAttribute("data-check-placement",m),b&&m==="start"?n.append(l,c):n.append(c,l),e.appendChild(n),this._menuItems.push(n)});const o=this._menuItems[0]||null,a=this._menuItems[this._menuItems.length-1]||null;o&&o.setAttribute("data-edge-start","true"),a&&a.setAttribute("data-edge-end","true"),e.refresh(),this._menuRenderFingerprint=t,this._syncMenuSelectionState(),this._schedulePanelPlacement()}_syncMenuSelectionState(){if(!this._menuEl)return;const e=this._selectedIndex();this._menuItems.forEach(i=>{const s=Number(i.dataset.index||"-1");i.setAttribute("aria-selected",s===e?"true":"false")}),this._activeIndex=$.resolveListboxActiveIndex(this._options,{selectedIndex:e,getDisabled:i=>i.disabled});const t=this._activeIndex>=0&&this._menuItems[this._activeIndex]||null;this._menuEl.setActiveItem(t,{focus:!1,owner:this._triggerEl,scroll:!0})}_syncPanelPlacement(){const e=this._panelEl,t=this._controlEl,i=this._menuEl;if(!e||!t||!i||!this._open)return;const s=t.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight||0,a=Math.max(0,o-s.bottom-12),r=Math.max(0,s.top-12),u=Math.min(Math.max(i.scrollHeight,i.offsetHeight)+4,320),n=a<u&&r>a;this._placement=n?"top":"bottom",e.setAttribute("data-placement",this._placement),e.style.setProperty("--ui-select-available-height",`${Math.floor(n?r:a)}px`)}_openMenu(){this._open||this.disabled||(this._cancelPanelPlacement(),this._syncOptionsData(),this._open=!0,this._syncControlState(),this._renderMenu(),this._attachOpenListeners())}_closeMenu(e={}){var t,i;if(this._open&&(this._open=!1,this._activeIndex=-1,this._cancelPanelPlacement(),this._teardownOpenListeners(),this._syncControlState(),e.restoreFocus!==!1))try{(t=this._triggerEl)==null||t.focus({preventScroll:!0})}catch{(i=this._triggerEl)==null||i.focus()}}_syncControlState(){const e=this._triggerEl,t=this._controlEl,i=this._valueEl,s=this._panelEl;if(!e||!t||!i||!s)return;const o=this.getAttribute("label")||"",a=this.getAttribute("description")||"",r=this.getAttribute("error")||"",u=this.getAttribute("aria-label")||o||"Select",n=h(this.getAttribute("loading")),c=h(this.getAttribute("required"))||this.hasAttribute("required"),l=this.getAttribute("tabindex"),b=this.hasAttribute("validation")&&this.getAttribute("validation")==="error"||this.hasAttribute("invalid")||this.getAttribute("data-invalid")==="true",m=F(this.getAttribute("radius")),d=this.root.querySelector(".label"),v=this.root.querySelector(".label-text"),g=this.root.querySelector(".description"),_=this.root.querySelector(".description-text"),y=this.root.querySelector(".error"),w=this.root.querySelector(".error-text"),A=this.root.querySelector(".meta"),E=this.root.querySelector(".required"),k=!!o||this._hasSlotContent("label"),S=!!a||this._hasSlotContent("description"),z=!!r||this._hasSlotContent("error"),P=this._hasSlotContent("leading"),R=this._hasSlotContent("trailing"),M=!!(this.getAttribute("placeholder")||"").trim()&&this.value==="";v&&(v.textContent=o),_&&(_.textContent=a),w&&(w.textContent=r),d&&(d.hidden=!k),g&&(g.hidden=!S),y&&(y.hidden=!z),A&&(A.hidden=!k&&!S),E&&(E.hidden=!c),i.textContent=this._currentDisplayText(),t.setAttribute("data-open",this._open?"true":"false"),t.setAttribute("data-placeholder-shown",M?"true":"false"),t.setAttribute("data-has-leading",String(P)),t.setAttribute("data-has-trailing",String(R)),e.disabled=this.disabled,e.setAttribute("aria-label",u),e.setAttribute("aria-expanded",this._open?"true":"false"),e.setAttribute("aria-busy",n?"true":"false"),e.setAttribute("aria-required",c?"true":"false"),b?e.setAttribute("aria-invalid","true"):e.removeAttribute("aria-invalid"),l!=null&&!this.disabled?e.setAttribute("tabindex",l):this.disabled?e.setAttribute("tabindex","-1"):e.setAttribute("tabindex","0"),s.hidden=!this._open,s.setAttribute("data-placement",this._placement),this._open?e.setAttribute("aria-controls",`${this._uid}-listbox`):e.removeAttribute("aria-controls"),m&&!["none","full","large"].includes(this.getAttribute("radius")||"")?this.style.setProperty("--ui-select-radius",m):this.style.removeProperty("--ui-select-radius"),this.setAttribute("aria-disabled",this.disabled?"true":"false"),this.setAttribute("aria-busy",n?"true":"false"),this.toggleAttribute("open",this._open),this._open&&this._schedulePanelPlacement()}render(){const e=this.getAttribute("label")||"",t=this.getAttribute("description")||"",i=this.getAttribute("error")||"",s=h(this.getAttribute("required"))||this.hasAttribute("required"),o=this.getAttribute("aria-label")||e||"Select",a=!!e||this._hasSlotContent("label"),r=!!t||this._hasSlotContent("description"),u=!!i||this._hasSlotContent("error"),n=this._hasSlotContent("leading"),c=this._hasSlotContent("trailing"),l=`${this._uid}-label`,b=`${this._uid}-description`,m=`${this._uid}-error`,d=`${this._uid}-trigger`,v=`${this._uid}-listbox`,g=[r?b:"",u?m:""].filter(Boolean).join(" ");this.setContent(`
|
|
745
|
+
`;function h(p){if(p==null)return!1;const e=String(p).toLowerCase();return e!=="false"&&e!=="0"}function f(p){return String(p).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function F(p){if(!p)return null;const e=String(p).trim();return e?e==="none"?"4px":e==="full"?"999px":e==="large"?"16px":/^-?\\d+(\\.\\d+)?$/.test(e)?`${e}px`:e:null}const C=new Set(["value","disabled","loading","required","placeholder","name","tabindex","headless","size","variant","tone","density","radius","shape","elevation","option-border","show-check","check-placement","label","description","error","aria-label","validation","invalid","data-invalid","data-valid","close-on-scroll"]);class I extends q.ElementBase{constructor(){super(),this._controlEl=null,this._triggerEl=null,this._valueEl=null,this._panelEl=null,this._menuEl=null,this._observer=null,this._formUnregister=null,this._optionsSyncRaf=0,this._panelPlacementRaf=0,this._uid=Math.random().toString(36).slice(2,8),this._options=[],this._menuItems=[],this._optionsFingerprint="",this._menuRenderFingerprint="",this._open=!1,this._activeIndex=-1,this._placement="bottom",this._onRootClick=this._onRootClick.bind(this),this._onRootKeyDown=this._onRootKeyDown.bind(this),this._onRootPointerDown=this._onRootPointerDown.bind(this),this._onRootPointerMove=this._onRootPointerMove.bind(this),this._onSlotChange=this._onSlotChange.bind(this),this._onDocumentPointerDown=this._onDocumentPointerDown.bind(this),this._onWindowResize=this._onWindowResize.bind(this),this._onWindowScroll=this._onWindowScroll.bind(this)}static get observedAttributes(){return["value","disabled","loading","required","placeholder","name","tabindex","headless","size","variant","tone","density","radius","shape","elevation","option-border","show-check","check-placement","label","description","error","aria-label","validation","invalid","data-invalid","data-valid","close-on-scroll"]}connectedCallback(){super.connectedCallback(),this.root.addEventListener("click",this._onRootClick),this.root.addEventListener("keydown",this._onRootKeyDown),this.root.addEventListener("pointerdown",this._onRootPointerDown),this.root.addEventListener("pointermove",this._onRootPointerMove,{passive:!0}),this.root.addEventListener("slotchange",this._onSlotChange),this._observer=new MutationObserver(e=>{e.some(i=>{if(!(i.target instanceof HTMLElement)||i.target===this)return i.type==="childList";const s=i.target.tagName.toLowerCase();return s==="option"||s==="optgroup"})&&this._scheduleOptionsSync()}),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value","selected","disabled","label","slot"]}),this._attachFormRegistration()}disconnectedCallback(){this.root.removeEventListener("click",this._onRootClick),this.root.removeEventListener("keydown",this._onRootKeyDown),this.root.removeEventListener("pointerdown",this._onRootPointerDown),this.root.removeEventListener("pointermove",this._onRootPointerMove),this.root.removeEventListener("slotchange",this._onSlotChange),this._teardownOpenListeners(),this._observer&&(this._observer.disconnect(),this._observer=null),this._cancelOptionsSync(),this._cancelPanelPlacement(),this._formUnregister&&(this._formUnregister(),this._formUnregister=null),super.disconnectedCallback()}shouldRenderOnAttributeChange(e){return!C.has(e)}attributeChangedCallback(e,t,i){if(t!==i){if(e==="name"&&this._attachFormRegistration(),this._triggerEl&&C.has(e)){(e==="value"||e==="placeholder"||e==="required")&&(this._syncOptionsData(),this._open&&this._renderMenu()),(e==="show-check"||e==="check-placement")&&this._open&&this._renderMenu(),this._syncControlState(),this.disabled&&this._open&&this._closeMenu({restoreFocus:!1});return}super.attributeChangedCallback(e,t,i)}}get value(){return this.getAttribute("value")||""}set value(e){const t=String(e||"");t!==this.value&&this.setAttribute("value",t)}get disabled(){return h(this.getAttribute("disabled"))||h(this.getAttribute("loading"))}set disabled(e){e?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get closeOnScroll(){return h(this.getAttribute("close-on-scroll"))||!this.hasAttribute("close-on-scroll")}set closeOnScroll(e){this.setAttribute("close-on-scroll",e?"true":"false")}get showCheck(){return h(this.getAttribute("show-check"))}set showCheck(e){e?this.setAttribute("show-check","true"):this.removeAttribute("show-check")}focus(e){if(this._triggerEl){this._triggerEl.focus(e);return}super.focus(e)}blur(){if(this._triggerEl){this._triggerEl.blur();return}super.blur()}_onSlotChange(){this.requestRender()}_onRootPointerDown(e){const t=e.target;t&&t.closest(".menu-item")&&e.preventDefault()}_onRootPointerMove(e){if(!this._open)return;const i=e.target?.closest(".menu-item[data-index]");if(!i)return;const s=Number(i.dataset.index||"-1"),o=this._options[s];!o||o.disabled||s===this._activeIndex||this._setActiveIndex(s)}_onRootClick(e){const t=e.target;if(!t)return;if(t.closest(".trigger")){if(this.disabled)return;this._open?this._closeMenu({restoreFocus:!1}):this._openMenu();return}const i=t.closest(".menu-item[data-index]");if(!i)return;const s=Number(i.dataset.index||"-1"),o=this._options[s];!o||o.disabled||(this._applyValueFromUser(o.value),this._closeMenu())}_onRootKeyDown(e){const t=e.target;if(!(!t||t!==this._triggerEl&&!t.closest(".menu"))&&!this.disabled)switch(e.key){case"ArrowDown":e.preventDefault(),this._open?this._moveActive(1):this._openMenu();break;case"ArrowUp":e.preventDefault(),this._open?this._moveActive(-1):this._openMenu();break;case"Home":if(!this._open)return;e.preventDefault(),this._setActiveIndex(this._firstEnabledIndex());break;case"End":if(!this._open)return;e.preventDefault(),this._setActiveIndex(this._lastEnabledIndex());break;case"Enter":case" ":{if(e.preventDefault(),!this._open){this._openMenu();return}this._selectActiveOption();break}case"Escape":if(!this._open)return;e.preventDefault(),this._closeMenu();break;case"Tab":this._open&&this._closeMenu({restoreFocus:!1});break}}_onDocumentPointerDown(e){if(!this._open)return;const t=typeof e.composedPath=="function"?e.composedPath():[];t.includes(this)||t.includes(this.root)||this._closeMenu({restoreFocus:!1})}_isInternalEvent(e){const t=e.target,i=typeof e.composedPath=="function"?e.composedPath():[];return i.includes(this)||i.includes(this.root)||t instanceof Node&&(t===this||this.root.contains(t)||this._controlEl?.contains(t)||this._panelEl?.contains(t)||this._menuEl?.contains(t))?!0:!!(this._controlEl&&i.includes(this._controlEl)||this._triggerEl&&i.includes(this._triggerEl)||this._panelEl&&i.includes(this._panelEl)||this._menuEl&&i.includes(this._menuEl))}_onWindowResize(){this._open&&this._schedulePanelPlacement()}_onWindowScroll(e){if(this._open&&!this._isInternalEvent(e)){if(this.closeOnScroll){this._closeMenu({restoreFocus:!1});return}this._schedulePanelPlacement()}}_attachOpenListeners(){document.addEventListener("pointerdown",this._onDocumentPointerDown,!0),window.addEventListener("resize",this._onWindowResize,{passive:!0}),window.addEventListener("scroll",this._onWindowScroll,{passive:!0,capture:!0})}_teardownOpenListeners(){document.removeEventListener("pointerdown",this._onDocumentPointerDown,!0),window.removeEventListener("resize",this._onWindowResize),window.removeEventListener("scroll",this._onWindowScroll,!0)}_scheduleOptionsSync(){this._optionsSyncRaf||(this._optionsSyncRaf=requestAnimationFrame(()=>{this._optionsSyncRaf=0,this._syncOptionsData()&&this._open?this._renderMenu():this._syncControlState()}))}_cancelOptionsSync(){this._optionsSyncRaf&&(cancelAnimationFrame(this._optionsSyncRaf),this._optionsSyncRaf=0)}_schedulePanelPlacement(){this._panelPlacementRaf||(this._panelPlacementRaf=requestAnimationFrame(()=>{this._panelPlacementRaf=0,this._syncPanelPlacement()}))}_cancelPanelPlacement(){this._panelPlacementRaf&&(cancelAnimationFrame(this._panelPlacementRaf),this._panelPlacementRaf=0)}_emitValue(e,t){this.dispatchEvent(new CustomEvent(e,{detail:{value:t},bubbles:!0,composed:!0}))}_applyValueFromUser(e){(this.getAttribute("value")||"")!==e&&(this.setAttribute("value",e),this._emitValue("input",e),this._emitValue("change",e))}_attachFormRegistration(){this._formUnregister&&(this._formUnregister(),this._formUnregister=null);const e=this.getAttribute("name");if(!e)return;const t=this.getRootNode(),s=(t instanceof ShadowRoot?t.host:null)?.closest?.("ui-form")||this.closest("ui-form");!s||typeof s.registerField!="function"||(this._formUnregister=s.registerField(e,{name:e,getValue:()=>this.value,setValue:o=>{this.value=o},validate:async()=>{if(!(h(this.getAttribute("required"))||this.hasAttribute("required")))return{valid:!0};const l=this.value.trim().length>0;return{valid:l,message:l?void 0:"This field is required."}},setError:o=>{o?(this.setAttribute("validation","error"),this.setAttribute("error",o)):(this.getAttribute("validation")==="error"&&this.removeAttribute("validation"),this.removeAttribute("error"))}}))}_hasSlotContent(e){return!!this.querySelector(`[slot="${e}"]`)}_setValueAttr(e){const t=String(e??"");this.getAttribute("value")!==t&&this.setAttribute("value",t)}_buildOptionsFromChildren(){const e=[],t=(r,u)=>{const n=(r.label||r.textContent||r.value||"").trim(),a=String(r.value??"");e.push({value:a,label:n||a,disabled:!!r.disabled,group:u})};Array.from(this.children).filter(r=>r instanceof HTMLElement?!r.hasAttribute("slot"):!1).forEach(r=>{const u=r.tagName.toLowerCase();if(u==="option"){t(r,"");return}if(u==="optgroup"){const n=r,a=(n.label||"").trim();Array.from(n.children).forEach(c=>{c instanceof HTMLOptionElement&&e.push({value:String(c.value??""),label:(c.label||c.textContent||c.value||"").trim()||String(c.value??""),disabled:!!c.disabled||!!n.disabled,group:a})})}});const s=(this.getAttribute("placeholder")||"").trim(),o=h(this.getAttribute("required"))||this.hasAttribute("required"),l=e.some(r=>r.value==="");return s&&!o&&!l&&e.unshift({value:"",label:s,disabled:!1,group:""}),e}_computeOptionsFingerprint(e){return e.map(t=>`${t.value}${t.label}${t.disabled?"1":"0"}${t.group}`).join("")}_firstEnabledIndex(){return x.findFirstEnabledIndex(this._options,e=>e.disabled)}_lastEnabledIndex(){return x.findLastEnabledIndex(this._options,e=>e.disabled)}_selectedIndex(){return x.findIndexByValue(this._options,this.value,e=>e.value)}_checkPlacement(){return this.getAttribute("check-placement")==="start"?"start":"end"}_syncOptionsData(){const e=this._buildOptionsFromChildren(),t=this._computeOptionsFingerprint(e),i=t!==this._optionsFingerprint;this._options=e,this._optionsFingerprint=t;const s=this.getAttribute("value")||"",o=this.hasAttribute("value"),l=this._options.some(a=>a.value===s),r=h(this.getAttribute("required"))||this.hasAttribute("required"),u=this._options.find(a=>!a.disabled)?.value||"",n=!r&&this._options.some(a=>a.value==="")?"":u;return o?l||this._setValueAttr(n):this._setValueAttr(n),i}_currentDisplayText(){const e=this.value,t=(this.getAttribute("placeholder")||"").trim();return e===""&&t?t:this._options.find(s=>s.value===e)?.label||e}_setActiveIndex(e){if(!this._menuEl||e===this._activeIndex)return;this._activeIndex=e;const t=e>=0&&this._menuItems[e]||null;this._menuEl.setActiveItem(t,{focus:!1,owner:this._triggerEl,scroll:!0})}_moveActive(e){if(!this._menuEl||!this._options.length)return;const t=this._activeIndex>=0?this._menuItems[this._activeIndex]:null,i=this._menuEl.move(e,{current:t,focus:!1,owner:this._triggerEl,scroll:!0});if(!i)return;const s=Number(i.dataset.index||"-1");s>=0&&(this._activeIndex=s)}_selectActiveOption(){if(this._activeIndex<0)return;const e=this._options[this._activeIndex];!e||e.disabled||(this._applyValueFromUser(e.value),this._closeMenu())}_renderMenu(){const e=this._menuEl;if(!e)return;const t=`${this._optionsFingerprint}${this.showCheck?"1":"0"}${this._checkPlacement()}`;if(this._menuItems.length>0&&t===this._menuRenderFingerprint&&this._menuItems.length===this._options.length){this._syncMenuSelectionState(),this._schedulePanelPlacement();return}if(e.replaceChildren(),this._menuItems=[],!this._options.length){const r=document.createElement("p");r.className="menu-empty",r.textContent="No options available",e.appendChild(r),this._menuRenderFingerprint=t,e.refresh();return}let s="__none__";this._options.forEach((r,u)=>{if(r.group&&r.group!==s){const d=document.createElement("div");d.className="menu-group",d.setAttribute("role","presentation"),d.textContent=r.group,e.appendChild(d),s=r.group}r.group||(s="__none__");const n=document.createElement("button");n.type="button",n.className="menu-item",n.id=`${this._uid}-opt-${u}`,n.setAttribute("role","option"),n.setAttribute("data-index",String(u)),n.setAttribute("data-value",r.value),n.setAttribute("aria-selected",r.value===this.value?"true":"false"),n.setAttribute("aria-disabled",r.disabled?"true":"false"),n.tabIndex=-1,r.disabled&&(n.disabled=!0);const a=document.createElement("span");a.className="menu-item-label",a.textContent=r.label;const c=document.createElement("span");c.className="menu-item-check",c.setAttribute("aria-hidden","true");const b=this.showCheck,m=this._checkPlacement();c.hidden=!b,n.setAttribute("data-check-placement",m),b&&m==="start"?n.append(c,a):n.append(a,c),e.appendChild(n),this._menuItems.push(n)});const o=this._menuItems[0]||null,l=this._menuItems[this._menuItems.length-1]||null;o&&o.setAttribute("data-edge-start","true"),l&&l.setAttribute("data-edge-end","true"),e.refresh(),this._menuRenderFingerprint=t,this._syncMenuSelectionState(),this._schedulePanelPlacement()}_syncMenuSelectionState(){if(!this._menuEl)return;const e=this._selectedIndex();this._menuItems.forEach(i=>{const s=Number(i.dataset.index||"-1");i.setAttribute("aria-selected",s===e?"true":"false")}),this._activeIndex=$.resolveListboxActiveIndex(this._options,{selectedIndex:e,getDisabled:i=>i.disabled});const t=this._activeIndex>=0&&this._menuItems[this._activeIndex]||null;this._menuEl.setActiveItem(t,{focus:!1,owner:this._triggerEl,scroll:!0})}_syncPanelPlacement(){const e=this._panelEl,t=this._controlEl,i=this._menuEl;if(!e||!t||!i||!this._open)return;const s=t.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight||0,l=Math.max(0,o-s.bottom-12),r=Math.max(0,s.top-12),u=Math.min(Math.max(i.scrollHeight,i.offsetHeight)+4,320),n=l<u&&r>l;this._placement=n?"top":"bottom",e.setAttribute("data-placement",this._placement),e.style.setProperty("--ui-select-available-height",`${Math.floor(n?r:l)}px`)}_openMenu(){this._open||this.disabled||(this._cancelPanelPlacement(),this._syncOptionsData(),this._open=!0,this._syncControlState(),this._renderMenu(),this._attachOpenListeners())}_closeMenu(e={}){if(this._open&&(this._open=!1,this._activeIndex=-1,this._cancelPanelPlacement(),this._teardownOpenListeners(),this._syncControlState(),e.restoreFocus!==!1))try{this._triggerEl?.focus({preventScroll:!0})}catch{this._triggerEl?.focus()}}_syncControlState(){const e=this._triggerEl,t=this._controlEl,i=this._valueEl,s=this._panelEl;if(!e||!t||!i||!s)return;const o=this.getAttribute("label")||"",l=this.getAttribute("description")||"",r=this.getAttribute("error")||"",u=this.getAttribute("aria-label")||o||"Select",n=h(this.getAttribute("loading")),a=h(this.getAttribute("required"))||this.hasAttribute("required"),c=this.getAttribute("tabindex"),b=this.hasAttribute("validation")&&this.getAttribute("validation")==="error"||this.hasAttribute("invalid")||this.getAttribute("data-invalid")==="true",m=F(this.getAttribute("radius")),d=this.root.querySelector(".label"),v=this.root.querySelector(".label-text"),g=this.root.querySelector(".description"),_=this.root.querySelector(".description-text"),y=this.root.querySelector(".error"),w=this.root.querySelector(".error-text"),A=this.root.querySelector(".meta"),E=this.root.querySelector(".required"),k=!!o||this._hasSlotContent("label"),S=!!l||this._hasSlotContent("description"),z=!!r||this._hasSlotContent("error"),P=this._hasSlotContent("leading"),R=this._hasSlotContent("trailing"),M=!!(this.getAttribute("placeholder")||"").trim()&&this.value==="";v&&(v.textContent=o),_&&(_.textContent=l),w&&(w.textContent=r),d&&(d.hidden=!k),g&&(g.hidden=!S),y&&(y.hidden=!z),A&&(A.hidden=!k&&!S),E&&(E.hidden=!a),i.textContent=this._currentDisplayText(),t.setAttribute("data-open",this._open?"true":"false"),t.setAttribute("data-placeholder-shown",M?"true":"false"),t.setAttribute("data-has-leading",String(P)),t.setAttribute("data-has-trailing",String(R)),e.disabled=this.disabled,e.setAttribute("aria-label",u),e.setAttribute("aria-expanded",this._open?"true":"false"),e.setAttribute("aria-busy",n?"true":"false"),e.setAttribute("aria-required",a?"true":"false"),b?e.setAttribute("aria-invalid","true"):e.removeAttribute("aria-invalid"),c!=null&&!this.disabled?e.setAttribute("tabindex",c):this.disabled?e.setAttribute("tabindex","-1"):e.setAttribute("tabindex","0"),s.hidden=!this._open,s.setAttribute("data-placement",this._placement),this._open?e.setAttribute("aria-controls",`${this._uid}-listbox`):e.removeAttribute("aria-controls"),m&&!["none","full","large"].includes(this.getAttribute("radius")||"")?this.style.setProperty("--ui-select-radius",m):this.style.removeProperty("--ui-select-radius"),this.setAttribute("aria-disabled",this.disabled?"true":"false"),this.setAttribute("aria-busy",n?"true":"false"),this.toggleAttribute("open",this._open),this._open&&this._schedulePanelPlacement()}render(){const e=this.getAttribute("label")||"",t=this.getAttribute("description")||"",i=this.getAttribute("error")||"",s=h(this.getAttribute("required"))||this.hasAttribute("required"),o=this.getAttribute("aria-label")||e||"Select",l=!!e||this._hasSlotContent("label"),r=!!t||this._hasSlotContent("description"),u=!!i||this._hasSlotContent("error"),n=this._hasSlotContent("leading"),a=this._hasSlotContent("trailing"),c=`${this._uid}-label`,b=`${this._uid}-description`,m=`${this._uid}-error`,d=`${this._uid}-trigger`,v=`${this._uid}-listbox`,g=[r?b:"",u?m:""].filter(Boolean).join(" ");this.setContent(`
|
|
746
746
|
<style>${L}</style>
|
|
747
747
|
<slot class="content-slot"></slot>
|
|
748
748
|
<div class="root" part="root">
|
|
749
|
-
<div class="meta" part="meta" ${
|
|
750
|
-
<label class="label" part="label" id="${
|
|
749
|
+
<div class="meta" part="meta" ${l||r?"":"hidden"}>
|
|
750
|
+
<label class="label" part="label" id="${c}" for="${d}" ${l?"":"hidden"}>
|
|
751
751
|
<slot name="label"><span class="label-text">${f(e)}</span></slot>
|
|
752
752
|
<span class="required" aria-hidden="true" ${s?"":"hidden"}>*</span>
|
|
753
753
|
</label>
|
|
@@ -756,7 +756,7 @@
|
|
|
756
756
|
</p>
|
|
757
757
|
</div>
|
|
758
758
|
<div class="field-shell" part="field-shell">
|
|
759
|
-
<div class="control" part="control" data-has-leading="${n}" data-has-trailing="${
|
|
759
|
+
<div class="control" part="control" data-has-leading="${n}" data-has-trailing="${a}" data-open="false">
|
|
760
760
|
<span class="leading" part="leading" ${n?"":"hidden"}>
|
|
761
761
|
<slot name="leading"></slot>
|
|
762
762
|
</span>
|
|
@@ -769,12 +769,12 @@
|
|
|
769
769
|
aria-haspopup="listbox"
|
|
770
770
|
aria-expanded="false"
|
|
771
771
|
aria-label="${f(o)}"
|
|
772
|
-
${
|
|
772
|
+
${l?`aria-labelledby="${c}"`:""}
|
|
773
773
|
${g?`aria-describedby="${f(g)}"`:""}
|
|
774
774
|
>
|
|
775
775
|
<span class="value" part="value"></span>
|
|
776
776
|
</button>
|
|
777
|
-
<span class="trailing" part="trailing" ${
|
|
777
|
+
<span class="trailing" part="trailing" ${a?"":"hidden"}>
|
|
778
778
|
<slot name="trailing"></slot>
|
|
779
779
|
</span>
|
|
780
780
|
<span class="indicator" part="indicator" aria-hidden="true"></span>
|