@editora/ui-core 0.1.24 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +339 -5
- package/dist/accordion.cjs.js +13 -12
- package/dist/accordion.esm.js +13 -12
- package/dist/alert-dialog.cjs.js +76 -45
- package/dist/alert-dialog.esm.js +179 -135
- package/dist/alert.cjs.js +41 -32
- package/dist/alert.esm.js +79 -70
- package/dist/animated-beam.cjs.js +42 -50
- package/dist/animated-beam.esm.js +47 -55
- package/dist/animated-list.cjs.js +11 -27
- package/dist/animated-list.esm.js +12 -28
- package/dist/animated-text.cjs.js +4 -4
- package/dist/animated-text.esm.js +4 -4
- package/dist/app-header.cjs.js +5 -5
- package/dist/app-header.esm.js +6 -6
- package/dist/aspect-ratio.cjs.js +10 -12
- package/dist/aspect-ratio.esm.js +11 -13
- package/dist/avatar.cjs.js +13 -17
- package/dist/avatar.esm.js +13 -17
- package/dist/badge.cjs.js +27 -22
- package/dist/badge.esm.js +32 -27
- package/dist/block-controls.cjs.js +11 -12
- package/dist/block-controls.esm.js +8 -9
- package/dist/box.cjs.js +2 -3
- package/dist/box.esm.js +2 -3
- package/dist/breadcrumb.cjs.js +12 -18
- package/dist/breadcrumb.esm.js +11 -17
- package/dist/button.cjs.js +1 -1
- package/dist/button.esm.js +1 -1
- package/dist/{calendar-B3PUKHQm.mjs → calendar-DmxiZrR7.mjs} +126 -117
- package/dist/{calendar-D-mXMgqc.js → calendar-o273O28D.js} +53 -44
- package/dist/calendar.cjs.js +1 -1
- package/dist/calendar.esm.js +1 -1
- package/dist/card.cjs.js +6 -7
- package/dist/card.esm.js +5 -6
- package/dist/chart.cjs.js +52 -52
- package/dist/chart.esm.js +95 -95
- package/dist/checkbox.cjs.js +19 -15
- package/dist/checkbox.esm.js +19 -15
- package/dist/collapsible.cjs.js +7 -11
- package/dist/collapsible.esm.js +7 -11
- package/dist/color-picker.cjs.js +36 -17
- package/dist/color-picker.esm.js +132 -113
- package/dist/combobox.cjs.js +57 -54
- package/dist/combobox.esm.js +62 -58
- package/dist/command-palette.cjs.js +1 -0
- package/dist/command-palette.esm.js +1 -0
- package/dist/command.cjs.js +32 -14
- package/dist/command.esm.js +46 -28
- package/dist/components/date-time-utils.d.ts.map +1 -1
- package/dist/components/gantt-schedule.d.ts +79 -0
- package/dist/components/gantt-schedule.d.ts.map +1 -0
- package/dist/components/ui-accordion.d.ts.map +1 -1
- package/dist/components/ui-alert-dialog.d.ts +2 -0
- package/dist/components/ui-alert-dialog.d.ts.map +1 -1
- package/dist/components/ui-alert.d.ts.map +1 -1
- package/dist/components/ui-animated-beam.d.ts.map +1 -1
- package/dist/components/ui-animated-list.d.ts.map +1 -1
- package/dist/components/ui-aspect-ratio.d.ts.map +1 -1
- package/dist/components/ui-avatar.d.ts.map +1 -1
- package/dist/components/ui-badge.d.ts.map +1 -1
- package/dist/components/ui-block-controls.d.ts.map +1 -1
- package/dist/components/ui-box.d.ts.map +1 -1
- package/dist/components/ui-breadcrumb.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/components/ui-checkbox.d.ts.map +1 -1
- package/dist/components/ui-collapsible.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-command-palette.d.ts.map +1 -1
- package/dist/components/ui-command.d.ts.map +1 -1
- package/dist/components/ui-container.d.ts.map +1 -1
- package/dist/components/ui-context-menu.d.ts.map +1 -1
- package/dist/components/ui-data-table.d.ts +7 -0
- package/dist/components/ui-data-table.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-dialog.d.ts +2 -0
- package/dist/components/ui-dialog.d.ts.map +1 -1
- 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-empty-state.d.ts.map +1 -1
- package/dist/components/ui-field.d.ts.map +1 -1
- package/dist/components/ui-fieldset.d.ts.map +1 -1
- package/dist/components/ui-file-upload.d.ts.map +1 -1
- package/dist/components/ui-floating-toolbar.d.ts.map +1 -1
- package/dist/components/ui-form.d.ts.map +1 -1
- package/dist/components/ui-gantt.d.ts +186 -2
- package/dist/components/ui-gantt.d.ts.map +1 -1
- package/dist/components/ui-icon-cloud.d.ts.map +1 -1
- package/dist/components/ui-inline-edit.d.ts.map +1 -1
- package/dist/components/ui-input.d.ts.map +1 -1
- package/dist/components/ui-marquee.d.ts.map +1 -1
- package/dist/components/ui-menu.d.ts.map +1 -1
- package/dist/components/ui-menubar.d.ts.map +1 -1
- package/dist/components/ui-meter.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-orbiter.d.ts.map +1 -1
- package/dist/components/ui-pagination.d.ts.map +1 -1
- package/dist/components/ui-password-field.d.ts.map +1 -1
- package/dist/components/ui-pin-input.d.ts.map +1 -1
- package/dist/components/ui-popover.d.ts.map +1 -1
- package/dist/components/ui-progress.d.ts.map +1 -1
- package/dist/components/ui-radio-group.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-scroll-area.d.ts.map +1 -1
- package/dist/components/ui-section.d.ts.map +1 -1
- package/dist/components/ui-select.d.ts.map +1 -1
- package/dist/components/ui-selection-popup.d.ts.map +1 -1
- package/dist/components/ui-slider.d.ts.map +1 -1
- package/dist/components/ui-sortable.d.ts.map +1 -1
- package/dist/components/ui-spinning-text.d.ts.map +1 -1
- package/dist/components/ui-split-button.d.ts.map +1 -1
- package/dist/components/ui-splitter.d.ts.map +1 -1
- package/dist/components/ui-stepper.d.ts.map +1 -1
- package/dist/components/ui-switch.d.ts.map +1 -1
- package/dist/components/ui-tabs.d.ts.map +1 -1
- 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-picker.d.ts.map +1 -1
- package/dist/components/ui-toggle-group.d.ts +2 -0
- 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-toolbar.d.ts +2 -0
- package/dist/components/ui-toolbar.d.ts.map +1 -1
- package/dist/components/ui-tooltip.d.ts.map +1 -1
- package/dist/components/ui-transfer-list.d.ts.map +1 -1
- package/dist/components/ui-tree-item.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/container.cjs.js +6 -12
- package/dist/container.esm.js +8 -14
- package/dist/context-menu.cjs.js +8 -8
- package/dist/context-menu.esm.js +42 -41
- package/dist/data-table.cjs.js +18 -15
- package/dist/data-table.esm.js +207 -187
- package/dist/date-field.cjs.js +8 -8
- package/dist/date-field.esm.js +7 -7
- package/dist/date-picker.cjs.js +27 -18
- package/dist/date-picker.esm.js +57 -48
- package/dist/date-range-picker.cjs.js +22 -17
- package/dist/date-range-picker.esm.js +31 -26
- package/dist/date-range-time-picker.cjs.js +26 -19
- package/dist/date-range-time-picker.esm.js +23 -16
- package/dist/date-time-picker.cjs.js +23 -16
- package/dist/date-time-picker.esm.js +88 -81
- package/dist/{date-time-utils-BTlxnz5j.mjs → date-time-utils-B4hAkt36.mjs} +75 -68
- package/dist/date-time-utils-DdigV4hs.js +1 -0
- package/dist/dialog.cjs.js +57 -41
- package/dist/dialog.esm.js +84 -51
- package/dist/dock.cjs.js +16 -30
- package/dist/dock.esm.js +26 -40
- package/dist/drawer.cjs.js +8 -12
- package/dist/drawer.esm.js +6 -10
- package/dist/dropdown.cjs.js +8 -6
- package/dist/dropdown.esm.js +33 -30
- package/dist/empty-state.cjs.js +17 -15
- package/dist/empty-state.esm.js +13 -11
- package/dist/field.cjs.js +22 -13
- package/dist/field.esm.js +54 -45
- package/dist/fieldset.cjs.js +18 -11
- package/dist/fieldset.esm.js +20 -13
- package/dist/file-upload.cjs.js +77 -35
- package/dist/file-upload.esm.js +152 -110
- package/dist/floating-toolbar.cjs.js +6 -7
- package/dist/floating-toolbar.esm.js +8 -9
- package/dist/form.cjs.js +20 -23
- package/dist/form.esm.js +20 -23
- package/dist/gantt.cjs.js +525 -110
- package/dist/gantt.esm.js +1882 -377
- package/dist/hover-card.cjs.js +7 -7
- package/dist/hover-card.esm.js +7 -7
- package/dist/icon-cloud.cjs.js +19 -36
- package/dist/icon-cloud.esm.js +41 -58
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +108 -104
- package/dist/inline-edit.cjs.js +47 -19
- package/dist/inline-edit.esm.js +66 -38
- package/dist/input.cjs.js +44 -37
- package/dist/input.esm.js +59 -52
- package/dist/layout.cjs.js +3 -3
- package/dist/layout.esm.js +3 -3
- package/dist/marquee.cjs.js +7 -10
- package/dist/marquee.esm.js +7 -10
- package/dist/menu.cjs.js +8 -24
- package/dist/menu.esm.js +52 -72
- package/dist/menubar.cjs.js +9 -31
- package/dist/menubar.esm.js +127 -153
- package/dist/meter.cjs.js +4 -9
- package/dist/meter.esm.js +6 -11
- package/dist/multi-select.cjs.js +48 -35
- package/dist/multi-select.esm.js +67 -53
- package/dist/navigation-menu.cjs.js +10 -10
- package/dist/navigation-menu.esm.js +33 -33
- package/dist/number-field.cjs.js +27 -16
- package/dist/number-field.esm.js +36 -25
- package/dist/odometer.cjs.js +5 -5
- package/dist/odometer.esm.js +3 -3
- package/dist/orbiter.cjs.js +11 -28
- package/dist/orbiter.esm.js +28 -45
- package/dist/overlay-motion-B56x1GoY.js +49 -0
- package/dist/overlay-motion-BX3dPLay.mjs +120 -0
- package/dist/pagination.cjs.js +28 -25
- package/dist/pagination.esm.js +54 -51
- package/dist/password-field.cjs.js +38 -33
- package/dist/password-field.esm.js +62 -57
- package/dist/pin-input.cjs.js +17 -13
- package/dist/pin-input.esm.js +23 -19
- package/dist/plugin-panel.cjs.js +1 -1
- package/dist/plugin-panel.esm.js +1 -1
- package/dist/popover.cjs.js +16 -28
- package/dist/popover.esm.js +29 -45
- package/dist/portal-DeaM1tYY.mjs +121 -0
- package/dist/portal-XbYR3m_q.js +1 -0
- package/dist/portal.d.ts +3 -1
- package/dist/portal.d.ts.map +1 -1
- package/dist/{positioner-D0VGxtYU.mjs → positioner-BE8Nbho2.mjs} +5 -3
- package/dist/{positioner-D_fqyx_j.js → positioner-DZ1FW6A9.js} +1 -1
- package/dist/positioner.cjs.js +1 -1
- package/dist/positioner.esm.js +1 -1
- package/dist/primitives/overlay-motion.d.ts +47 -0
- package/dist/primitives/overlay-motion.d.ts.map +1 -0
- package/dist/primitives/positioner.d.ts.map +1 -1
- package/dist/progress.cjs.js +11 -16
- package/dist/progress.esm.js +37 -42
- package/dist/quick-actions.cjs.js +13 -13
- package/dist/quick-actions.esm.js +11 -11
- package/dist/radio-group.cjs.js +50 -26
- package/dist/radio-group.esm.js +53 -29
- package/dist/radio.cjs.js +15 -12
- package/dist/radio.esm.js +15 -12
- package/dist/rating.cjs.js +11 -15
- package/dist/rating.esm.js +48 -50
- package/dist/{runtime-CFnK53iC.mjs → runtime-CQM6wZOc.mjs} +498 -514
- package/dist/runtime-DxCl0A5q.js +5 -0
- package/dist/runtime.cjs.js +1 -1
- package/dist/runtime.d.ts +3 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.esm.js +36 -32
- package/dist/scroll-area.cjs.js +3 -4
- package/dist/scroll-area.esm.js +3 -4
- package/dist/section.cjs.js +2 -4
- package/dist/section.esm.js +2 -4
- package/dist/select.cjs.js +40 -73
- package/dist/select.esm.js +55 -87
- package/dist/selection-popup.cjs.js +3 -4
- package/dist/selection-popup.esm.js +3 -4
- package/dist/semantic-tokens.d.ts +17 -0
- package/dist/semantic-tokens.d.ts.map +1 -0
- package/dist/sidebar.cjs.js +22 -22
- package/dist/sidebar.esm.js +25 -25
- package/dist/skeleton.cjs.js +2 -2
- package/dist/skeleton.esm.js +2 -2
- package/dist/slider.cjs.js +22 -26
- package/dist/slider.esm.js +25 -29
- package/dist/sortable.cjs.js +4 -5
- package/dist/sortable.esm.js +4 -5
- package/dist/spinning-text.cjs.js +4 -13
- package/dist/spinning-text.esm.js +4 -13
- package/dist/split-button.cjs.js +5 -5
- package/dist/split-button.esm.js +15 -14
- package/dist/splitter.cjs.js +52 -10
- package/dist/splitter.esm.js +55 -13
- package/dist/stepper.cjs.js +31 -65
- package/dist/stepper.esm.js +32 -66
- package/dist/switch.cjs.js +20 -22
- package/dist/switch.esm.js +20 -22
- package/dist/table.cjs.js +5 -5
- package/dist/table.esm.js +20 -20
- package/dist/tabs.cjs.js +91 -21
- package/dist/tabs.esm.js +182 -112
- package/dist/tags-input.cjs.js +41 -15
- package/dist/tags-input.esm.js +73 -47
- package/dist/textarea.cjs.js +32 -33
- package/dist/textarea.esm.js +38 -39
- package/dist/theme.d.ts +25 -1
- package/dist/theme.d.ts.map +1 -1
- package/dist/time-field.cjs.js +7 -7
- package/dist/time-field.esm.js +6 -6
- package/dist/time-picker.cjs.js +16 -13
- package/dist/time-picker.esm.js +27 -24
- package/dist/timeline.cjs.js +10 -10
- package/dist/timeline.esm.js +7 -7
- package/dist/toggle-group.cjs.js +13 -13
- package/dist/toggle-group.esm.js +66 -61
- package/dist/toggle.cjs.js +52 -34
- package/dist/toggle.esm.js +80 -62
- package/dist/toolbar.cjs.js +14 -14
- package/dist/toolbar.esm.js +41 -33
- package/dist/tooltip.cjs.js +3 -3
- package/dist/tooltip.esm.js +39 -33
- package/dist/transfer-list.cjs.js +28 -29
- package/dist/transfer-list.esm.js +28 -29
- package/dist/{tree-B_oQput6.mjs → tree-33fVNnaf.mjs} +6 -5
- package/dist/{tree-SivHxcAy.js → tree-Dc02MChE.js} +6 -5
- package/dist/tree-item.cjs.js +9 -8
- package/dist/tree-item.esm.js +13 -12
- package/dist/tree.cjs.js +1 -1
- package/dist/tree.esm.js +1 -1
- package/dist/{ui-button-Co8Sid6t.mjs → ui-button-C3OmI7Sn.mjs} +152 -154
- package/dist/{ui-button-BPrzJScZ.js → ui-button-CnLwXBnx.js} +107 -109
- package/dist/wizard.cjs.js +39 -36
- package/dist/wizard.esm.js +39 -36
- package/package.json +1 -1
- package/dist/date-time-utils-y3AvNvGe.js +0 -1
- package/dist/portal-DgpQ3Jo1.js +0 -1
- package/dist/portal-bR42gHvG.mjs +0 -118
- package/dist/runtime-DwE-tizc.js +0 -1
package/dist/number-field.cjs.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
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 D=require("./ElementBase-DxbvhLJs.js"),A=require("./control-name-BmoI1m3a.js"),N=`
|
|
2
2
|
:host {
|
|
3
|
-
--ui-number-field-padding: var(--ui-padding,
|
|
4
|
-
--ui-number-field-
|
|
3
|
+
--ui-number-field-padding: var(--ui-padding, 0);
|
|
4
|
+
--ui-number-field-pad-x: calc(var(--ui-control-padding-inline-2, 12px) - 1px);
|
|
5
|
+
--ui-number-field-font-size: var(--ui-control-font-size-2, 14px);
|
|
6
|
+
--ui-number-field-border-color: var(--ui-color-line, var(--ui-color-border, var(--ui-border-color, #cbd5e1)));
|
|
5
7
|
--ui-number-field-border-width: 1px;
|
|
6
8
|
--ui-number-field-border-style: solid;
|
|
7
9
|
--ui-number-field-border:
|
|
8
10
|
var(--ui-number-field-border-width) var(--ui-number-field-border-style) var(--ui-number-field-border-color);
|
|
9
|
-
--ui-number-field-radius: var(--ui-radius,
|
|
10
|
-
--ui-number-field-min-height: var(--ui-min-height,
|
|
11
|
+
--ui-number-field-radius: var(--ui-control-radius-2, var(--ui-radius, 6px));
|
|
12
|
+
--ui-number-field-min-height: var(--ui-min-height, var(--base-input-height-md, var(--ui-control-height-2, 32px)));
|
|
11
13
|
--ui-number-field-width: 100%;
|
|
12
14
|
--ui-number-field-bg: var(--ui-color-surface, var(--ui-surface, #ffffff));
|
|
13
15
|
--ui-number-field-color: var(--ui-color-text, var(--ui-text, #0f172a));
|
|
@@ -18,7 +20,7 @@
|
|
|
18
20
|
--ui-number-field-gap: 8px;
|
|
19
21
|
--ui-number-field-shell-gap: 8px;
|
|
20
22
|
--ui-number-field-meta-gap: 4px;
|
|
21
|
-
--ui-number-field-placeholder: color-mix(in srgb, var(--ui-number-field-color)
|
|
23
|
+
--ui-number-field-placeholder: var(--ui-color-placeholder, color-mix(in srgb, var(--ui-number-field-color) 62%, transparent));
|
|
22
24
|
color-scheme: light dark;
|
|
23
25
|
display: block;
|
|
24
26
|
inline-size: var(--ui-number-field-width);
|
|
@@ -94,7 +96,7 @@
|
|
|
94
96
|
gap: var(--ui-number-field-shell-gap);
|
|
95
97
|
box-sizing: border-box;
|
|
96
98
|
min-block-size: var(--ui-number-field-min-height);
|
|
97
|
-
padding-inline:
|
|
99
|
+
padding-inline: var(--ui-number-field-pad-x);
|
|
98
100
|
border: var(--ui-number-field-border);
|
|
99
101
|
border-radius: var(--ui-number-field-radius);
|
|
100
102
|
background: var(--ui-number-field-bg);
|
|
@@ -107,8 +109,13 @@
|
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
.shell:focus-within {
|
|
110
|
-
border-color:
|
|
111
|
-
|
|
112
|
+
border-color: var(--ui-ring-color, var(--ui-number-field-focus));
|
|
113
|
+
outline: var(--ui-ring-width, 2px) solid var(--ui-ring-color, var(--ui-number-field-focus));
|
|
114
|
+
outline-offset: -1px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.shell:hover:not(:focus-within) {
|
|
118
|
+
border-color: var(--ui-color-line-strong, var(--ui-number-field-border-color));
|
|
112
119
|
}
|
|
113
120
|
|
|
114
121
|
.prefix,
|
|
@@ -136,7 +143,7 @@
|
|
|
136
143
|
border: none;
|
|
137
144
|
background: transparent;
|
|
138
145
|
color: inherit;
|
|
139
|
-
font: 500
|
|
146
|
+
font: 500 var(--ui-number-field-font-size)/1.4 "Inter", "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
140
147
|
padding: var(--ui-number-field-padding);
|
|
141
148
|
min-block-size: calc(var(--ui-number-field-min-height) - 2px);
|
|
142
149
|
margin: 0;
|
|
@@ -251,12 +258,14 @@
|
|
|
251
258
|
|
|
252
259
|
:host([invalid]) .shell,
|
|
253
260
|
:host([data-internal-invalid]) .shell {
|
|
254
|
-
box-shadow: 0 0 0
|
|
261
|
+
box-shadow: 0 0 0 1px var(--ui-number-field-danger);
|
|
255
262
|
}
|
|
256
263
|
|
|
257
264
|
:host([size="sm"]) {
|
|
258
|
-
--ui-number-field-min-height:
|
|
259
|
-
--ui-number-field-
|
|
265
|
+
--ui-number-field-min-height: var(--ui-min-height, var(--base-input-height-sm, var(--ui-control-height-1, 24px)));
|
|
266
|
+
--ui-number-field-pad-x: calc(var(--ui-control-padding-inline-1, 8px) - 1px);
|
|
267
|
+
--ui-number-field-font-size: var(--ui-control-font-size-1, 12px);
|
|
268
|
+
--ui-number-field-radius: var(--ui-control-radius-1, var(--ui-radius, 6px));
|
|
260
269
|
--ui-number-field-shell-gap: 6px;
|
|
261
270
|
}
|
|
262
271
|
|
|
@@ -270,8 +279,10 @@
|
|
|
270
279
|
}
|
|
271
280
|
|
|
272
281
|
:host([size="lg"]) {
|
|
273
|
-
--ui-number-field-min-height:
|
|
274
|
-
--ui-number-field-
|
|
282
|
+
--ui-number-field-min-height: var(--ui-min-height, var(--base-input-height-lg, var(--ui-control-height-3, 40px)));
|
|
283
|
+
--ui-number-field-pad-x: calc(var(--ui-control-padding-inline-3, 16px) - 1px);
|
|
284
|
+
--ui-number-field-font-size: var(--ui-control-font-size-3, 16px);
|
|
285
|
+
--ui-number-field-radius: var(--ui-control-radius-3, var(--ui-radius, 6px));
|
|
275
286
|
--ui-number-field-shell-gap: 10px;
|
|
276
287
|
}
|
|
277
288
|
|
|
@@ -309,7 +320,7 @@
|
|
|
309
320
|
transition: none !important;
|
|
310
321
|
}
|
|
311
322
|
}
|
|
312
|
-
`;function f(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function d(r){if(!r)return!1;const e=r.assignedNodes({flatten:!0});return e.length?e.some(t=>t.nodeType===Node.TEXT_NODE?!!t.textContent?.trim():t.nodeType===Node.ELEMENT_NODE):!1}function p(r,e){const t=r.getAttribute(e);if(t==null)return!1;const i=String(t).trim().toLowerCase();return i!=="false"&&i!=="0"}function g(r){if(r==null||r.trim()==="")return null;const e=Number(r);return Number.isFinite(e)?e:null}function B(r){const e=String(r),t=e.match(/e-(\d+)$/i);if(t)return Number(t[1]);const i=e.split(".")[1];return i?i.length:0}function m(r,e){if(e==null||e<0)return r;const t=10**e;return Math.round((r+Number.EPSILON)*t)/t}function w(r,e,t){return e!=null&&r<e?e:t!=null&&r>t?t:r}function C(r){return r??0}function q(r,e,t,i){if(e==null||e<=0)return!0;const s=m((r-t)/e,i!=null?i+2:8);return Math.abs(s-Math.round(s))<1e-7}function F(r){const e=new Intl.NumberFormat(r).formatToParts(12345.6);return{group:e.find(t=>t.type==="group")?.value||",",decimal:e.find(t=>t.type==="decimal")?.value||"."}}function _(r,e){const t=r.trim();if(!t)return null;const{group:i,decimal:s}=F(e);let n=t.replace(/[\s\u00a0\u202f]/g,"");if(n=n.split(i).join(""),s!=="."&&(n=n.split(s).join(".")),n=n.replace(/[−–]/g,"-"),!/^[+-]?(?:\d+\.?\d*|\.\d+)$/.test(n))return null;const l=Number(n);return Number.isFinite(l)?l:null}function L(r,e){return e!=null&&e>=0?r.toFixed(e):String(r)}class S extends z.ElementBase{constructor(){super(),this._input=null,this._formUnregister=null,this._uid=Math.random().toString(36).slice(2,9),this._rawValue="",this._isEditing=!1,this._internalInvalidReason=null,this._onInput=this._onInput.bind(this),this._onBlur=this._onBlur.bind(this),this._onFocus=this._onFocus.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onWheel=this._onWheel.bind(this),this._onSlotChange=this._onSlotChange.bind(this),this._onClick=this._onClick.bind(this)}static get observedAttributes(){return["value","min","max","step","precision","locale","format","name","placeholder","disabled","readonly","required","invalid","allow-wheel","show-steppers","clamp-on-blur","autocomplete","inputmode","label","aria-label","aria-description","aria-describedby","description","data-error","size","variant"]}connectedCallback(){super.connectedCallback(),this.root.addEventListener("slotchange",this._onSlotChange),this.addEventListener("click",this._onClick),this._registerWithForm()}disconnectedCallback(){this.root.removeEventListener("slotchange",this._onSlotChange),this.removeEventListener("click",this._onClick),this._detachListeners(),this._formUnregister&&(this._formUnregister(),this._formUnregister=null),super.disconnectedCallback()}shouldRenderOnAttributeChange(e){return e==="label"||e==="description"||e==="data-error"}attributeChangedCallback(e,t,i){if(t!==i){if(e==="value"){this._rawValue=i||"",this._clearInternalInvalid(),this._syncDisplayValue(),this._syncAria();return}if(e==="name"&&this._registerWithForm(),e==="min"||e==="max"||e==="step"||e==="precision"||e==="locale"||e==="format"||e==="placeholder"||e==="disabled"||e==="readonly"||e==="required"||e==="allow-wheel"||e==="show-steppers"||e==="clamp-on-blur"||e==="autocomplete"||e==="inputmode"||e==="size"||e==="variant"||e==="invalid"||e==="aria-label"||e==="aria-description"||e==="aria-describedby"){this._syncControlAttrs(),this._syncDisplayValue(),this._syncDerivedState(),this._syncAria();return}super.attributeChangedCallback(e,t,i)}}get value(){return this.getAttribute("value")||""}set value(e){e?this.setAttribute("value",e):this.removeAttribute("value")}get valueAsNumber(){return g(this.getAttribute("value"))}get rawValue(){return this._rawValue}set rawValue(e){this._rawValue=String(e??""),this._input&&(this._input.value=this._rawValue),this._syncAria()}focus(e){if(this._input){this._input.focus(e);return}super.focus(e)}blur(){this._input?.blur()}select(){this._input?.select()}stepUp(e=1){this._stepBy(Math.max(1,Number(e)||1),"step")}stepDown(e=1){this._stepBy(-Math.max(1,Number(e)||1),"step")}_locale(){return this.getAttribute("locale")||Intl.NumberFormat().resolvedOptions().locale||"en-US"}_precision(){const e=this.getAttribute("precision");if(e==null||e.trim()==="")return null;const t=Number(e);return Number.isInteger(t)&&t>=0?t:null}_step(){const e=this.getAttribute("step");if(e==null||e===""||e==="any")return null;const t=Number(e);return Number.isFinite(t)&&t>0?t:null}_effectivePrecision(){const e=this._precision();if(e!=null)return e;const t=this._step();return t!=null?B(t):null}_min(){return g(this.getAttribute("min"))}_max(){return g(this.getAttribute("max"))}_formatNumber(e){const t=this._effectivePrecision(),i=this.getAttribute("format")!=="plain";return new Intl.NumberFormat(this._locale(),{useGrouping:i,minimumFractionDigits:t??0,maximumFractionDigits:t??20}).format(e)}_displayStringForValue(){if(this._isEditing)return this._rawValue;const e=this.valueAsNumber;return e==null?this._rawValue:this._formatNumber(e)}_syncDisplayValue(){if(!this._input)return;const e=this._displayStringForValue();this._input.value!==e&&(this._input.value=e);const t=this.root.querySelector(".shell");t&&t.setAttribute("data-has-value",e?"true":"false")}_syncControlAttrs(){if(!this._input)return;this._input.placeholder=this.getAttribute("placeholder")||"",this._input.disabled=p(this,"disabled"),this._input.disabled?this.root.querySelector(".shell")?.setAttribute("aria-disabled","true"):this.root.querySelector(".shell")?.removeAttribute("aria-disabled"),this._input.readOnly=this.hasAttribute("readonly"),this._input.required=this.hasAttribute("required"),this._input.name=this.getAttribute("name")||"",this._input.setAttribute("inputmode",this.getAttribute("inputmode")||"decimal");const e=this.getAttribute("autocomplete");e?this._input.setAttribute("autocomplete",e):this._input.removeAttribute("autocomplete")}_syncAria(){if(!this._input)return;const e=this.valueAsNumber;this._input.setAttribute("role","spinbutton"),this._input.setAttribute("aria-valuetext",this._input.value||"");const t=this._min(),i=this._max();t!=null?this._input.setAttribute("aria-valuemin",String(t)):this._input.removeAttribute("aria-valuemin"),i!=null?this._input.setAttribute("aria-valuemax",String(i)):this._input.removeAttribute("aria-valuemax"),e!=null?this._input.setAttribute("aria-valuenow",String(e)):this._input.removeAttribute("aria-valuenow");const s=this.root.querySelector('slot[name="label"]'),n=this.root.querySelector('slot[name="description"]'),l=this.root.querySelector('slot[name="error"]'),u=!!(this.getAttribute("label")||"").trim()||d(s),a=!!(this.getAttribute("description")||"").trim()||d(n),o=!!(this.getAttribute("data-error")||"").trim()||d(l);A.syncControlName(this._input,this,u?`${this._uid}-label`:null);const c=[];a&&c.push(`${this._uid}-description`),o&&c.push(`${this._uid}-error`),A.syncControlDescription(this._input,this,this._uid,c),this.hasAttribute("required")?this._input.setAttribute("aria-required","true"):this._input.removeAttribute("aria-required"),this.hasAttribute("invalid")||this._internalInvalidReason!=null||o?this._input.setAttribute("aria-invalid","true"):this._input.removeAttribute("aria-invalid")}_syncDerivedState(){const e=this.root.querySelector('slot[name="label"]'),t=this.root.querySelector('slot[name="description"]'),i=this.root.querySelector('slot[name="error"]'),s=this.root.querySelector('slot[name="prefix"]'),n=this.root.querySelector('slot[name="suffix"]'),l=this.root.querySelector('slot[name="increment-trigger"]'),u=this.root.querySelector('slot[name="decrement-trigger"]'),a=!!(this.getAttribute("label")||"").trim()||d(e),o=!!(this.getAttribute("description")||"").trim()||d(t),c=!!(this.getAttribute("data-error")||"").trim()||d(i),v=d(s),V=d(n),k=d(l),E=d(u),y=p(this,"show-steppers")||k||E,h=(I,D)=>{const b=this.root.querySelector(I);b&&(D?b.removeAttribute("hidden"):b.setAttribute("hidden",""))};h(".meta",a||o),h(".label",a),h(".description",o),h(".prefix",v),h(".suffix",V),h(".footer",c),h(".error",c),h(".steppers",y);const x=this.root.querySelector(".shell");x&&x.setAttribute("data-show-steppers",y?"true":"false")}_emitValueEvent(e,t,i,s){this.dispatchEvent(new CustomEvent(e,{detail:{value:t,previousValue:i,source:s},bubbles:!0,composed:!0}))}_emitInvalid(e){this._internalInvalidReason=e,this.setAttribute("data-internal-invalid",e),this._syncAria(),this.dispatchEvent(new CustomEvent("invalid",{detail:{reason:e},bubbles:!0,composed:!0}))}_clearInternalInvalid(){this._internalInvalidReason=null,this.removeAttribute("data-internal-invalid"),this._syncAria()}_commitValue(e,t){const i=this.valueAsNumber;if(e==null){if(i==null&&!this.value){this._rawValue="",this._syncDisplayValue();return}this._emitValueEvent("before-value-change",null,i,t),this.removeAttribute("value"),this._rawValue="",this._clearInternalInvalid(),this._syncDisplayValue(),this._syncAria(),this._emitValueEvent("value-change",null,i,t);return}const s=this._effectivePrecision(),n=L(m(e,s),s),l=Number(n);if(i!=null&&l===i&&this.value===n){this._rawValue=n,this._clearInternalInvalid(),this._syncDisplayValue();return}this._emitValueEvent("before-value-change",l,i,t),this.setAttribute("value",n),this._rawValue=n,this._clearInternalInvalid(),this._syncDisplayValue(),this._syncAria(),this._emitValueEvent("value-change",l,i,t)}_commitRaw(e){const t=this._rawValue.trim();if(!t){this._commitValue(null,e);return}const i=_(t,this._locale());if(i==null){this._emitInvalid("parse"),this._syncDisplayValue();return}const s=this._min(),n=this._max(),l=this._effectivePrecision(),u=m(i,l),a=p(this,"clamp-on-blur"),o=a?w(u,s,n):u;if(!a&&s!=null&&o<s){this._emitInvalid("min"),this._syncDisplayValue();return}if(!a&&n!=null&&o>n){this._emitInvalid("max"),this._syncDisplayValue();return}const c=this._step();if(!q(o,c,C(s),l)){this._emitInvalid("step"),this._syncDisplayValue();return}this._commitValue(o,e)}_stepBy(e,t){if(p(this,"disabled")||this.hasAttribute("readonly"))return;const i=this._step()??1,s=this._effectivePrecision(),n=this._min(),l=this._max(),a=(this._isEditing?_(this._rawValue,this._locale()):this.valueAsNumber)??n??0,o=w(m(a+i*e,s),n,l);this._commitValue(o,t),this._isEditing&&this._input&&(this._input.value=this._rawValue)}_registerWithForm(){this._formUnregister&&(this._formUnregister(),this._formUnregister=null);try{const s=this.getRootNode().host?.closest?.("ui-form")||null||this.closest("ui-form"),n=this.getAttribute("name");s&&typeof s.registerField=="function"&&n&&(this._formUnregister=s.registerField(n,{name:n,getValue:()=>this.value,setValue:l=>{l==null||l===""?this.removeAttribute("value"):this.setAttribute("value",String(l))},validate:async()=>{const l=this.valueAsNumber,u=this._min(),a=this._max();return this.hasAttribute("required")&&l==null?{valid:!1,message:"A value is required."}:l!=null&&u!=null&&l<u?{valid:!1,message:`Value must be at least ${u}.`}:l!=null&&a!=null&&l>a?{valid:!1,message:`Value must be at most ${a}.`}:{valid:this._internalInvalidReason==null,message:void 0}},setError:l=>{l?(this.setAttribute("data-error",l),this.toggleAttribute("invalid",!0)):(this.removeAttribute("data-error"),this._internalInvalidReason==null&&this.removeAttribute("invalid")),this._syncDerivedState(),this._syncAria()}}))}catch{}}_detachListeners(){this._input&&(this._input.removeEventListener("input",this._onInput),this._input.removeEventListener("focus",this._onFocus),this._input.removeEventListener("blur",this._onBlur),this._input.removeEventListener("keydown",this._onKeyDown),this._input.removeEventListener("wheel",this._onWheel))}_bindInput(){this._input&&(this._detachListeners(),this._input.addEventListener("input",this._onInput),this._input.addEventListener("focus",this._onFocus),this._input.addEventListener("blur",this._onBlur),this._input.addEventListener("keydown",this._onKeyDown),this._input.addEventListener("wheel",this._onWheel,{passive:!1}))}_onInput(e){this._rawValue=e.target.value,this._syncDisplayValue(),this._syncAria();const t=_(this._rawValue,this._locale());this.dispatchEvent(new CustomEvent("input",{detail:{rawValue:this._rawValue,value:t,source:"input"},bubbles:!0,composed:!0}))}_onFocus(){this._isEditing=!0,this._rawValue=this.value||this._rawValue,this._syncDisplayValue(),this._syncAria()}_onBlur(){this._isEditing=!1,this._commitRaw("blur")}_onKeyDown(e){if(e.key==="ArrowUp"){e.preventDefault(),this._stepBy(1,"keyboard");return}if(e.key==="ArrowDown"){e.preventDefault(),this._stepBy(-1,"keyboard");return}if(e.key==="PageUp"){e.preventDefault(),this._stepBy(10,"keyboard");return}if(e.key==="PageDown"){e.preventDefault(),this._stepBy(-10,"keyboard");return}if(e.key==="Home"){const t=this._min();if(t==null)return;e.preventDefault(),this._commitValue(t,"keyboard");return}if(e.key==="End"){const t=this._max();if(t==null)return;e.preventDefault(),this._commitValue(t,"keyboard");return}if(e.key==="Enter"){e.preventDefault(),this._isEditing=!1,this._commitRaw("keyboard");return}e.key==="Escape"&&(this._isEditing=!1,this._rawValue=this.value,this._clearInternalInvalid(),this._syncDisplayValue())}_onWheel(e){p(this,"allow-wheel")&&(!this._input||this.root.activeElement!==this._input||(e.preventDefault(),this._stepBy(e.deltaY<0?1:-1,"wheel")))}_onClick(e){const i=e.composedPath().find(s=>s instanceof HTMLElement?s.dataset.stepAction==="up"||s.dataset.stepAction==="down"||s.getAttribute("slot")==="increment-trigger"||s.getAttribute("slot")==="decrement-trigger":!1);if(i){if(i.dataset.stepAction==="up"||i.getAttribute("slot")==="increment-trigger"){e.preventDefault(),this._stepBy(1,"step");return}(i.dataset.stepAction==="down"||i.getAttribute("slot")==="decrement-trigger")&&(e.preventDefault(),this._stepBy(-1,"step"))}}_onSlotChange(){this._syncDerivedState(),this._syncAria()}render(){const e=this.getAttribute("label")||"",t=this.getAttribute("description")||"",i=this.getAttribute("data-error")||"";this.setContent(`
|
|
323
|
+
`;function f(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function d(r){if(!r)return!1;const e=r.assignedNodes({flatten:!0});return e.length?e.some(t=>t.nodeType===Node.TEXT_NODE?!!t.textContent?.trim():t.nodeType===Node.ELEMENT_NODE):!1}function p(r,e){const t=r.getAttribute(e);if(t==null)return!1;const i=String(t).trim().toLowerCase();return i!=="false"&&i!=="0"}function g(r){if(r==null||r.trim()==="")return null;const e=Number(r);return Number.isFinite(e)?e:null}function B(r){const e=String(r),t=e.match(/e-(\d+)$/i);if(t)return Number(t[1]);const i=e.split(".")[1];return i?i.length:0}function m(r,e){if(e==null||e<0)return r;const t=10**e;return Math.round((r+Number.EPSILON)*t)/t}function w(r,e,t){return e!=null&&r<e?e:t!=null&&r>t?t:r}function C(r){return r??0}function q(r,e,t,i){if(e==null||e<=0)return!0;const s=m((r-t)/e,i!=null?i+2:8);return Math.abs(s-Math.round(s))<1e-7}function F(r){const e=new Intl.NumberFormat(r).formatToParts(12345.6);return{group:e.find(t=>t.type==="group")?.value||",",decimal:e.find(t=>t.type==="decimal")?.value||"."}}function v(r,e){const t=r.trim();if(!t)return null;const{group:i,decimal:s}=F(e);let n=t.replace(/[\s\u00a0\u202f]/g,"");if(n=n.split(i).join(""),s!=="."&&(n=n.split(s).join(".")),n=n.replace(/[−–]/g,"-"),!/^[+-]?(?:\d+\.?\d*|\.\d+)$/.test(n))return null;const l=Number(n);return Number.isFinite(l)?l:null}function L(r,e){return e!=null&&e>=0?r.toFixed(e):String(r)}class S extends D.ElementBase{constructor(){super(),this._input=null,this._formUnregister=null,this._uid=Math.random().toString(36).slice(2,9),this._rawValue="",this._isEditing=!1,this._internalInvalidReason=null,this._onInput=this._onInput.bind(this),this._onBlur=this._onBlur.bind(this),this._onFocus=this._onFocus.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onWheel=this._onWheel.bind(this),this._onSlotChange=this._onSlotChange.bind(this),this._onClick=this._onClick.bind(this)}static get observedAttributes(){return["value","min","max","step","precision","locale","format","name","placeholder","disabled","readonly","required","invalid","allow-wheel","show-steppers","clamp-on-blur","autocomplete","inputmode","label","aria-label","aria-description","aria-describedby","description","data-error","size","variant"]}connectedCallback(){super.connectedCallback(),this.root.addEventListener("slotchange",this._onSlotChange),this.addEventListener("click",this._onClick),this._registerWithForm()}disconnectedCallback(){this.root.removeEventListener("slotchange",this._onSlotChange),this.removeEventListener("click",this._onClick),this._detachListeners(),this._formUnregister&&(this._formUnregister(),this._formUnregister=null),super.disconnectedCallback()}shouldRenderOnAttributeChange(e){return e==="label"||e==="description"||e==="data-error"}attributeChangedCallback(e,t,i){if(t!==i){if(e==="value"){this._rawValue=i||"",this._clearInternalInvalid(),this._syncDisplayValue(),this._syncAria();return}if(e==="name"&&this._registerWithForm(),e==="min"||e==="max"||e==="step"||e==="precision"||e==="locale"||e==="format"||e==="placeholder"||e==="disabled"||e==="readonly"||e==="required"||e==="allow-wheel"||e==="show-steppers"||e==="clamp-on-blur"||e==="autocomplete"||e==="inputmode"||e==="size"||e==="variant"||e==="invalid"||e==="aria-label"||e==="aria-description"||e==="aria-describedby"){this._syncControlAttrs(),this._syncDisplayValue(),this._syncDerivedState(),this._syncAria();return}super.attributeChangedCallback(e,t,i)}}get value(){return this.getAttribute("value")||""}set value(e){e?this.setAttribute("value",e):this.removeAttribute("value")}get valueAsNumber(){return g(this.getAttribute("value"))}get rawValue(){return this._rawValue}set rawValue(e){this._rawValue=String(e??""),this._input&&(this._input.value=this._rawValue),this._syncAria()}focus(e){if(this._input){this._input.focus(e);return}super.focus(e)}blur(){this._input?.blur()}select(){this._input?.select()}stepUp(e=1){this._stepBy(Math.max(1,Number(e)||1),"step")}stepDown(e=1){this._stepBy(-Math.max(1,Number(e)||1),"step")}_locale(){return this.getAttribute("locale")||Intl.NumberFormat().resolvedOptions().locale||"en-US"}_precision(){const e=this.getAttribute("precision");if(e==null||e.trim()==="")return null;const t=Number(e);return Number.isInteger(t)&&t>=0?t:null}_step(){const e=this.getAttribute("step");if(e==null||e===""||e==="any")return null;const t=Number(e);return Number.isFinite(t)&&t>0?t:null}_effectivePrecision(){const e=this._precision();if(e!=null)return e;const t=this._step();return t!=null?B(t):null}_min(){return g(this.getAttribute("min"))}_max(){return g(this.getAttribute("max"))}_formatNumber(e){const t=this._effectivePrecision(),i=this.getAttribute("format")!=="plain";return new Intl.NumberFormat(this._locale(),{useGrouping:i,minimumFractionDigits:t??0,maximumFractionDigits:t??20}).format(e)}_displayStringForValue(){if(this._isEditing)return this._rawValue;const e=this.valueAsNumber;return e==null?this._rawValue:this._formatNumber(e)}_syncDisplayValue(){if(!this._input)return;const e=this._displayStringForValue();this._input.value!==e&&(this._input.value=e);const t=this.root.querySelector(".shell");t&&t.setAttribute("data-has-value",e?"true":"false")}_syncControlAttrs(){if(!this._input)return;this._input.placeholder=this.getAttribute("placeholder")||"",this._input.disabled=p(this,"disabled"),this._input.disabled?this.root.querySelector(".shell")?.setAttribute("aria-disabled","true"):this.root.querySelector(".shell")?.removeAttribute("aria-disabled"),this._input.readOnly=this.hasAttribute("readonly"),this._input.required=this.hasAttribute("required"),this._input.name=this.getAttribute("name")||"",this._input.setAttribute("inputmode",this.getAttribute("inputmode")||"decimal");const e=this.getAttribute("autocomplete");e?this._input.setAttribute("autocomplete",e):this._input.removeAttribute("autocomplete")}_syncAria(){if(!this._input)return;const e=this.valueAsNumber;this._input.setAttribute("role","spinbutton"),this._input.setAttribute("aria-valuetext",this._input.value||"");const t=this._min(),i=this._max();t!=null?this._input.setAttribute("aria-valuemin",String(t)):this._input.removeAttribute("aria-valuemin"),i!=null?this._input.setAttribute("aria-valuemax",String(i)):this._input.removeAttribute("aria-valuemax"),e!=null?this._input.setAttribute("aria-valuenow",String(e)):this._input.removeAttribute("aria-valuenow");const s=this.root.querySelector('slot[name="label"]'),n=this.root.querySelector('slot[name="description"]'),l=this.root.querySelector('slot[name="error"]'),u=!!(this.getAttribute("label")||"").trim()||d(s),a=!!(this.getAttribute("description")||"").trim()||d(n),o=!!(this.getAttribute("data-error")||"").trim()||d(l);A.syncControlName(this._input,this,u?`${this._uid}-label`:null);const c=[];a&&c.push(`${this._uid}-description`),o&&c.push(`${this._uid}-error`),A.syncControlDescription(this._input,this,this._uid,c),this.hasAttribute("required")?this._input.setAttribute("aria-required","true"):this._input.removeAttribute("aria-required"),this.hasAttribute("invalid")||this._internalInvalidReason!=null||o?this._input.setAttribute("aria-invalid","true"):this._input.removeAttribute("aria-invalid")}_syncDerivedState(){const e=this.root.querySelector('slot[name="label"]'),t=this.root.querySelector('slot[name="description"]'),i=this.root.querySelector('slot[name="error"]'),s=this.root.querySelector('slot[name="prefix"]'),n=this.root.querySelector('slot[name="suffix"]'),l=this.root.querySelector('slot[name="increment-trigger"]'),u=this.root.querySelector('slot[name="decrement-trigger"]'),a=!!(this.getAttribute("label")||"").trim()||d(e),o=!!(this.getAttribute("description")||"").trim()||d(t),c=!!(this.getAttribute("data-error")||"").trim()||d(i),_=d(s),V=d(n),k=d(l),E=d(u),y=p(this,"show-steppers")||k||E,h=(z,I)=>{const b=this.root.querySelector(z);b&&(I?b.removeAttribute("hidden"):b.setAttribute("hidden",""))};h(".meta",a||o),h(".label",a),h(".description",o),h(".prefix",_),h(".suffix",V),h(".footer",c),h(".error",c),h(".steppers",y);const x=this.root.querySelector(".shell");x&&x.setAttribute("data-show-steppers",y?"true":"false")}_emitValueEvent(e,t,i,s){this.dispatchEvent(new CustomEvent(e,{detail:{value:t,previousValue:i,source:s},bubbles:!0,composed:!0}))}_emitInvalid(e){this._internalInvalidReason=e,this.setAttribute("data-internal-invalid",e),this._syncAria(),this.dispatchEvent(new CustomEvent("invalid",{detail:{reason:e},bubbles:!0,composed:!0}))}_clearInternalInvalid(){this._internalInvalidReason=null,this.removeAttribute("data-internal-invalid"),this._syncAria()}_commitValue(e,t){const i=this.valueAsNumber;if(e==null){if(i==null&&!this.value){this._rawValue="",this._syncDisplayValue();return}this._emitValueEvent("before-value-change",null,i,t),this.removeAttribute("value"),this._rawValue="",this._clearInternalInvalid(),this._syncDisplayValue(),this._syncAria(),this._emitValueEvent("value-change",null,i,t);return}const s=this._effectivePrecision(),n=L(m(e,s),s),l=Number(n);if(i!=null&&l===i&&this.value===n){this._rawValue=n,this._clearInternalInvalid(),this._syncDisplayValue();return}this._emitValueEvent("before-value-change",l,i,t),this.setAttribute("value",n),this._rawValue=n,this._clearInternalInvalid(),this._syncDisplayValue(),this._syncAria(),this._emitValueEvent("value-change",l,i,t)}_commitRaw(e){const t=this._rawValue.trim();if(!t){this._commitValue(null,e);return}const i=v(t,this._locale());if(i==null){this._emitInvalid("parse"),this._syncDisplayValue();return}const s=this._min(),n=this._max(),l=this._effectivePrecision(),u=m(i,l),a=p(this,"clamp-on-blur"),o=a?w(u,s,n):u;if(!a&&s!=null&&o<s){this._emitInvalid("min"),this._syncDisplayValue();return}if(!a&&n!=null&&o>n){this._emitInvalid("max"),this._syncDisplayValue();return}const c=this._step();if(!q(o,c,C(s),l)){this._emitInvalid("step"),this._syncDisplayValue();return}this._commitValue(o,e)}_stepBy(e,t){if(p(this,"disabled")||this.hasAttribute("readonly"))return;const i=this._step()??1,s=this._effectivePrecision(),n=this._min(),l=this._max(),a=(this._isEditing?v(this._rawValue,this._locale()):this.valueAsNumber)??n??0,o=w(m(a+i*e,s),n,l);this._commitValue(o,t),this._isEditing&&this._input&&(this._input.value=this._rawValue)}_registerWithForm(){this._formUnregister&&(this._formUnregister(),this._formUnregister=null);try{const s=this.getRootNode().host?.closest?.("ui-form")||null||this.closest("ui-form"),n=this.getAttribute("name");s&&typeof s.registerField=="function"&&n&&(this._formUnregister=s.registerField(n,{name:n,getValue:()=>this.value,setValue:l=>{l==null||l===""?this.removeAttribute("value"):this.setAttribute("value",String(l))},validate:async()=>{const l=this.valueAsNumber,u=this._min(),a=this._max();return this.hasAttribute("required")&&l==null?{valid:!1,message:"A value is required."}:l!=null&&u!=null&&l<u?{valid:!1,message:`Value must be at least ${u}.`}:l!=null&&a!=null&&l>a?{valid:!1,message:`Value must be at most ${a}.`}:{valid:this._internalInvalidReason==null,message:void 0}},setError:l=>{l?(this.setAttribute("data-error",l),this.toggleAttribute("invalid",!0)):(this.removeAttribute("data-error"),this._internalInvalidReason==null&&this.removeAttribute("invalid")),this._syncDerivedState(),this._syncAria()}}))}catch{}}_detachListeners(){this._input&&(this._input.removeEventListener("input",this._onInput),this._input.removeEventListener("focus",this._onFocus),this._input.removeEventListener("blur",this._onBlur),this._input.removeEventListener("keydown",this._onKeyDown),this._input.removeEventListener("wheel",this._onWheel))}_bindInput(){this._input&&(this._detachListeners(),this._input.addEventListener("input",this._onInput),this._input.addEventListener("focus",this._onFocus),this._input.addEventListener("blur",this._onBlur),this._input.addEventListener("keydown",this._onKeyDown),this._input.addEventListener("wheel",this._onWheel,{passive:!1}))}_onInput(e){this._rawValue=e.target.value,this._syncDisplayValue(),this._syncAria();const t=v(this._rawValue,this._locale());this.dispatchEvent(new CustomEvent("input",{detail:{rawValue:this._rawValue,value:t,source:"input"},bubbles:!0,composed:!0}))}_onFocus(){this._isEditing=!0,this._rawValue=this.value||this._rawValue,this._syncDisplayValue(),this._syncAria()}_onBlur(){this._isEditing=!1,this._commitRaw("blur")}_onKeyDown(e){if(e.key==="ArrowUp"){e.preventDefault(),this._stepBy(1,"keyboard");return}if(e.key==="ArrowDown"){e.preventDefault(),this._stepBy(-1,"keyboard");return}if(e.key==="PageUp"){e.preventDefault(),this._stepBy(10,"keyboard");return}if(e.key==="PageDown"){e.preventDefault(),this._stepBy(-10,"keyboard");return}if(e.key==="Home"){const t=this._min();if(t==null)return;e.preventDefault(),this._commitValue(t,"keyboard");return}if(e.key==="End"){const t=this._max();if(t==null)return;e.preventDefault(),this._commitValue(t,"keyboard");return}if(e.key==="Enter"){e.preventDefault(),this._isEditing=!1,this._commitRaw("keyboard");return}e.key==="Escape"&&(this._isEditing=!1,this._rawValue=this.value,this._clearInternalInvalid(),this._syncDisplayValue())}_onWheel(e){p(this,"allow-wheel")&&(!this._input||this.root.activeElement!==this._input||(e.preventDefault(),this._stepBy(e.deltaY<0?1:-1,"wheel")))}_onClick(e){const i=e.composedPath().find(s=>s instanceof HTMLElement?s.dataset.stepAction==="up"||s.dataset.stepAction==="down"||s.getAttribute("slot")==="increment-trigger"||s.getAttribute("slot")==="decrement-trigger":!1);if(i){if(i.dataset.stepAction==="up"||i.getAttribute("slot")==="increment-trigger"){e.preventDefault(),this._stepBy(1,"step");return}(i.dataset.stepAction==="down"||i.getAttribute("slot")==="decrement-trigger")&&(e.preventDefault(),this._stepBy(-1,"step"))}}_onSlotChange(){this._syncDerivedState(),this._syncAria()}render(){const e=this.getAttribute("label")||"",t=this.getAttribute("description")||"",i=this.getAttribute("data-error")||"";this.setContent(`
|
|
313
324
|
<style>${N}</style>
|
|
314
325
|
<div class="root">
|
|
315
326
|
<div class="meta">
|
package/dist/number-field.esm.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { E as
|
|
2
|
-
import { s as
|
|
1
|
+
import { E as z } from "./ElementBase-BeZT54Hj.mjs";
|
|
2
|
+
import { s as I, a as D } from "./control-name-Bpj7F34X.mjs";
|
|
3
3
|
const N = `
|
|
4
4
|
:host {
|
|
5
|
-
--ui-number-field-padding: var(--ui-padding,
|
|
6
|
-
--ui-number-field-
|
|
5
|
+
--ui-number-field-padding: var(--ui-padding, 0);
|
|
6
|
+
--ui-number-field-pad-x: calc(var(--ui-control-padding-inline-2, 12px) - 1px);
|
|
7
|
+
--ui-number-field-font-size: var(--ui-control-font-size-2, 14px);
|
|
8
|
+
--ui-number-field-border-color: var(--ui-color-line, var(--ui-color-border, var(--ui-border-color, #cbd5e1)));
|
|
7
9
|
--ui-number-field-border-width: 1px;
|
|
8
10
|
--ui-number-field-border-style: solid;
|
|
9
11
|
--ui-number-field-border:
|
|
10
12
|
var(--ui-number-field-border-width) var(--ui-number-field-border-style) var(--ui-number-field-border-color);
|
|
11
|
-
--ui-number-field-radius: var(--ui-radius,
|
|
12
|
-
--ui-number-field-min-height: var(--ui-min-height,
|
|
13
|
+
--ui-number-field-radius: var(--ui-control-radius-2, var(--ui-radius, 6px));
|
|
14
|
+
--ui-number-field-min-height: var(--ui-min-height, var(--base-input-height-md, var(--ui-control-height-2, 32px)));
|
|
13
15
|
--ui-number-field-width: 100%;
|
|
14
16
|
--ui-number-field-bg: var(--ui-color-surface, var(--ui-surface, #ffffff));
|
|
15
17
|
--ui-number-field-color: var(--ui-color-text, var(--ui-text, #0f172a));
|
|
@@ -20,7 +22,7 @@ const N = `
|
|
|
20
22
|
--ui-number-field-gap: 8px;
|
|
21
23
|
--ui-number-field-shell-gap: 8px;
|
|
22
24
|
--ui-number-field-meta-gap: 4px;
|
|
23
|
-
--ui-number-field-placeholder: color-mix(in srgb, var(--ui-number-field-color)
|
|
25
|
+
--ui-number-field-placeholder: var(--ui-color-placeholder, color-mix(in srgb, var(--ui-number-field-color) 62%, transparent));
|
|
24
26
|
color-scheme: light dark;
|
|
25
27
|
display: block;
|
|
26
28
|
inline-size: var(--ui-number-field-width);
|
|
@@ -96,7 +98,7 @@ const N = `
|
|
|
96
98
|
gap: var(--ui-number-field-shell-gap);
|
|
97
99
|
box-sizing: border-box;
|
|
98
100
|
min-block-size: var(--ui-number-field-min-height);
|
|
99
|
-
padding-inline:
|
|
101
|
+
padding-inline: var(--ui-number-field-pad-x);
|
|
100
102
|
border: var(--ui-number-field-border);
|
|
101
103
|
border-radius: var(--ui-number-field-radius);
|
|
102
104
|
background: var(--ui-number-field-bg);
|
|
@@ -109,8 +111,13 @@ const N = `
|
|
|
109
111
|
}
|
|
110
112
|
|
|
111
113
|
.shell:focus-within {
|
|
112
|
-
border-color:
|
|
113
|
-
|
|
114
|
+
border-color: var(--ui-ring-color, var(--ui-number-field-focus));
|
|
115
|
+
outline: var(--ui-ring-width, 2px) solid var(--ui-ring-color, var(--ui-number-field-focus));
|
|
116
|
+
outline-offset: -1px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.shell:hover:not(:focus-within) {
|
|
120
|
+
border-color: var(--ui-color-line-strong, var(--ui-number-field-border-color));
|
|
114
121
|
}
|
|
115
122
|
|
|
116
123
|
.prefix,
|
|
@@ -138,7 +145,7 @@ const N = `
|
|
|
138
145
|
border: none;
|
|
139
146
|
background: transparent;
|
|
140
147
|
color: inherit;
|
|
141
|
-
font: 500
|
|
148
|
+
font: 500 var(--ui-number-field-font-size)/1.4 "Inter", "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
142
149
|
padding: var(--ui-number-field-padding);
|
|
143
150
|
min-block-size: calc(var(--ui-number-field-min-height) - 2px);
|
|
144
151
|
margin: 0;
|
|
@@ -253,12 +260,14 @@ const N = `
|
|
|
253
260
|
|
|
254
261
|
:host([invalid]) .shell,
|
|
255
262
|
:host([data-internal-invalid]) .shell {
|
|
256
|
-
box-shadow: 0 0 0
|
|
263
|
+
box-shadow: 0 0 0 1px var(--ui-number-field-danger);
|
|
257
264
|
}
|
|
258
265
|
|
|
259
266
|
:host([size="sm"]) {
|
|
260
|
-
--ui-number-field-min-height:
|
|
261
|
-
--ui-number-field-
|
|
267
|
+
--ui-number-field-min-height: var(--ui-min-height, var(--base-input-height-sm, var(--ui-control-height-1, 24px)));
|
|
268
|
+
--ui-number-field-pad-x: calc(var(--ui-control-padding-inline-1, 8px) - 1px);
|
|
269
|
+
--ui-number-field-font-size: var(--ui-control-font-size-1, 12px);
|
|
270
|
+
--ui-number-field-radius: var(--ui-control-radius-1, var(--ui-radius, 6px));
|
|
262
271
|
--ui-number-field-shell-gap: 6px;
|
|
263
272
|
}
|
|
264
273
|
|
|
@@ -272,8 +281,10 @@ const N = `
|
|
|
272
281
|
}
|
|
273
282
|
|
|
274
283
|
:host([size="lg"]) {
|
|
275
|
-
--ui-number-field-min-height:
|
|
276
|
-
--ui-number-field-
|
|
284
|
+
--ui-number-field-min-height: var(--ui-min-height, var(--base-input-height-lg, var(--ui-control-height-3, 40px)));
|
|
285
|
+
--ui-number-field-pad-x: calc(var(--ui-control-padding-inline-3, 16px) - 1px);
|
|
286
|
+
--ui-number-field-font-size: var(--ui-control-font-size-3, 16px);
|
|
287
|
+
--ui-number-field-radius: var(--ui-control-radius-3, var(--ui-radius, 6px));
|
|
277
288
|
--ui-number-field-shell-gap: 10px;
|
|
278
289
|
}
|
|
279
290
|
|
|
@@ -360,7 +371,7 @@ function q(r) {
|
|
|
360
371
|
decimal: e.find((t) => t.type === "decimal")?.value || "."
|
|
361
372
|
};
|
|
362
373
|
}
|
|
363
|
-
function
|
|
374
|
+
function v(r, e) {
|
|
364
375
|
const t = r.trim();
|
|
365
376
|
if (!t) return null;
|
|
366
377
|
const { group: i, decimal: s } = q(e);
|
|
@@ -372,7 +383,7 @@ function _(r, e) {
|
|
|
372
383
|
function L(r, e) {
|
|
373
384
|
return e != null && e >= 0 ? r.toFixed(e) : String(r);
|
|
374
385
|
}
|
|
375
|
-
class M extends
|
|
386
|
+
class M extends z {
|
|
376
387
|
constructor() {
|
|
377
388
|
super(), this._input = null, this._formUnregister = null, this._uid = Math.random().toString(36).slice(2, 9), this._rawValue = "", this._isEditing = !1, this._internalInvalidReason = null, this._onInput = this._onInput.bind(this), this._onBlur = this._onBlur.bind(this), this._onFocus = this._onFocus.bind(this), this._onKeyDown = this._onKeyDown.bind(this), this._onWheel = this._onWheel.bind(this), this._onSlotChange = this._onSlotChange.bind(this), this._onClick = this._onClick.bind(this);
|
|
378
389
|
}
|
|
@@ -522,16 +533,16 @@ class M extends I {
|
|
|
522
533
|
const t = this._min(), i = this._max();
|
|
523
534
|
t != null ? this._input.setAttribute("aria-valuemin", String(t)) : this._input.removeAttribute("aria-valuemin"), i != null ? this._input.setAttribute("aria-valuemax", String(i)) : this._input.removeAttribute("aria-valuemax"), e != null ? this._input.setAttribute("aria-valuenow", String(e)) : this._input.removeAttribute("aria-valuenow");
|
|
524
535
|
const s = this.root.querySelector('slot[name="label"]'), n = this.root.querySelector('slot[name="description"]'), l = this.root.querySelector('slot[name="error"]'), u = !!(this.getAttribute("label") || "").trim() || d(s), a = !!(this.getAttribute("description") || "").trim() || d(n), o = !!(this.getAttribute("data-error") || "").trim() || d(l);
|
|
525
|
-
|
|
536
|
+
I(this._input, this, u ? `${this._uid}-label` : null);
|
|
526
537
|
const c = [];
|
|
527
|
-
a && c.push(`${this._uid}-description`), o && c.push(`${this._uid}-error`),
|
|
538
|
+
a && c.push(`${this._uid}-description`), o && c.push(`${this._uid}-error`), D(this._input, this, this._uid, c), this.hasAttribute("required") ? this._input.setAttribute("aria-required", "true") : this._input.removeAttribute("aria-required"), this.hasAttribute("invalid") || this._internalInvalidReason != null || o ? this._input.setAttribute("aria-invalid", "true") : this._input.removeAttribute("aria-invalid");
|
|
528
539
|
}
|
|
529
540
|
_syncDerivedState() {
|
|
530
|
-
const e = this.root.querySelector('slot[name="label"]'), t = this.root.querySelector('slot[name="description"]'), i = this.root.querySelector('slot[name="error"]'), s = this.root.querySelector('slot[name="prefix"]'), n = this.root.querySelector('slot[name="suffix"]'), l = this.root.querySelector('slot[name="increment-trigger"]'), u = this.root.querySelector('slot[name="decrement-trigger"]'), a = !!(this.getAttribute("label") || "").trim() || d(e), o = !!(this.getAttribute("description") || "").trim() || d(t), c = !!(this.getAttribute("data-error") || "").trim() || d(i),
|
|
541
|
+
const e = this.root.querySelector('slot[name="label"]'), t = this.root.querySelector('slot[name="description"]'), i = this.root.querySelector('slot[name="error"]'), s = this.root.querySelector('slot[name="prefix"]'), n = this.root.querySelector('slot[name="suffix"]'), l = this.root.querySelector('slot[name="increment-trigger"]'), u = this.root.querySelector('slot[name="decrement-trigger"]'), a = !!(this.getAttribute("label") || "").trim() || d(e), o = !!(this.getAttribute("description") || "").trim() || d(t), c = !!(this.getAttribute("data-error") || "").trim() || d(i), _ = d(s), w = d(n), S = d(l), V = d(u), y = p(this, "show-steppers") || S || V, h = (k, E) => {
|
|
531
542
|
const b = this.root.querySelector(k);
|
|
532
543
|
b && (E ? b.removeAttribute("hidden") : b.setAttribute("hidden", ""));
|
|
533
544
|
};
|
|
534
|
-
h(".meta", a || o), h(".label", a), h(".description", o), h(".prefix",
|
|
545
|
+
h(".meta", a || o), h(".label", a), h(".description", o), h(".prefix", _), h(".suffix", w), h(".footer", c), h(".error", c), h(".steppers", y);
|
|
535
546
|
const x = this.root.querySelector(".shell");
|
|
536
547
|
x && x.setAttribute("data-show-steppers", y ? "true" : "false");
|
|
537
548
|
}
|
|
@@ -579,7 +590,7 @@ class M extends I {
|
|
|
579
590
|
this._commitValue(null, e);
|
|
580
591
|
return;
|
|
581
592
|
}
|
|
582
|
-
const i =
|
|
593
|
+
const i = v(t, this._locale());
|
|
583
594
|
if (i == null) {
|
|
584
595
|
this._emitInvalid("parse"), this._syncDisplayValue();
|
|
585
596
|
return;
|
|
@@ -602,7 +613,7 @@ class M extends I {
|
|
|
602
613
|
}
|
|
603
614
|
_stepBy(e, t) {
|
|
604
615
|
if (p(this, "disabled") || this.hasAttribute("readonly")) return;
|
|
605
|
-
const i = this._step() ?? 1, s = this._effectivePrecision(), n = this._min(), l = this._max(), a = (this._isEditing ?
|
|
616
|
+
const i = this._step() ?? 1, s = this._effectivePrecision(), n = this._min(), l = this._max(), a = (this._isEditing ? v(this._rawValue, this._locale()) : this.valueAsNumber) ?? n ?? 0, o = A(m(a + i * e, s), n, l);
|
|
606
617
|
this._commitValue(o, t), this._isEditing && this._input && (this._input.value = this._rawValue);
|
|
607
618
|
}
|
|
608
619
|
_registerWithForm() {
|
|
@@ -634,7 +645,7 @@ class M extends I {
|
|
|
634
645
|
}
|
|
635
646
|
_onInput(e) {
|
|
636
647
|
this._rawValue = e.target.value, this._syncDisplayValue(), this._syncAria();
|
|
637
|
-
const t =
|
|
648
|
+
const t = v(this._rawValue, this._locale());
|
|
638
649
|
this.dispatchEvent(
|
|
639
650
|
new CustomEvent("input", {
|
|
640
651
|
detail: { rawValue: this._rawValue, value: t, source: "input" },
|
package/dist/odometer.cjs.js
CHANGED
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
--ui-odometer-container-bg: transparent;
|
|
16
16
|
--ui-odometer-container-border: none;
|
|
17
17
|
--ui-odometer-container-radius: 999px;
|
|
18
|
-
--ui-odometer-digit-bg:
|
|
19
|
-
--ui-odometer-digit-border: 1px solid rgba(148, 163, 184, 0.35);
|
|
18
|
+
--ui-odometer-digit-bg: var(--ui-color-fill, #f0f0f0);
|
|
19
|
+
--ui-odometer-digit-border: 1px solid var(--ui-color-line-subtle, rgba(148, 163, 184, 0.35));
|
|
20
20
|
--ui-odometer-digit-radius: 0.18em;
|
|
21
|
-
--ui-odometer-digit-shadow:
|
|
21
|
+
--ui-odometer-digit-shadow: none;
|
|
22
22
|
--ui-odometer-separator-opacity: 0.7;
|
|
23
23
|
--ui-odometer-affix-opacity: 0.82;
|
|
24
24
|
|
|
@@ -292,9 +292,9 @@
|
|
|
292
292
|
will-change: auto;
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
|
-
`;function V(e){return e!==null&&e.toLowerCase()!=="false"&&e!=="0"}function n(e,t){const i=e.getAttribute(t);if(i!=null)return i;const r=e[t];return typeof r=="string"&&r.length>0?r:null}function l(e,t){const i=e.getAttribute(t);if(i!=null){const o=parseFloat(i);return Number.isNaN(o)?null:o}const r=e[t];if(typeof r=="number")return Number.isNaN(r)?null:r;if(typeof r=="string"){const o=parseFloat(r);return Number.isNaN(o)?null:o}return null}function w(e,t){const i=e.getAttribute(t);if(i!=null)return V(i);const r=e[t];return typeof r=="boolean"?r:typeof r=="string"?V(r):!1}function x(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function F(e,t,i){let r=e;return t!==null&&r<t&&(r=t),i!==null&&r>i&&(r=i),r}function k(e){return e==="inline"||e==="digital"||e==="odometer"||e==="analog"?e:"inline"}function C(e){return e==="currency"||e==="percent"||e==="number"||e==="decimal"?e:"decimal"}function N(e){return e==="compact"?"compact":"standard"}function A(e){return e==="up"||e==="down"||e==="auto"?e:"auto"}function S(e){const t=l(e,"decimals"),i=l(e,"minimum-fraction-digits"),r=l(e,"maximum-fraction-digits");return i!=null||r!=null?{minimumFractionDigits:i??void 0,maximumFractionDigits:r??void 0}:t!=null?{minimumFractionDigits:t,maximumFractionDigits:t}:{}}function P(e,t){const i=C(n(e,"format")),r=n(e,"locale")||void 0,o=n(e,"currency")||void 0,u=N(n(e,"notation")),m=n(e,"decimal-separator"),c=n(e,"group-separator"),s=S(e),y={style:i==="currency"&&o?"currency":i==="percent"?"percent":"decimal",currency:i==="currency"&&o?o:void 0,notation:u,useGrouping:!0,numberingSystem:"latn",minimumFractionDigits:s.minimumFractionDigits,maximumFractionDigits:s.maximumFractionDigits};let
|
|
295
|
+
`;function V(e){return e!==null&&e.toLowerCase()!=="false"&&e!=="0"}function n(e,t){const i=e.getAttribute(t);if(i!=null)return i;const r=e[t];return typeof r=="string"&&r.length>0?r:null}function l(e,t){const i=e.getAttribute(t);if(i!=null){const o=parseFloat(i);return Number.isNaN(o)?null:o}const r=e[t];if(typeof r=="number")return Number.isNaN(r)?null:r;if(typeof r=="string"){const o=parseFloat(r);return Number.isNaN(o)?null:o}return null}function w(e,t){const i=e.getAttribute(t);if(i!=null)return V(i);const r=e[t];return typeof r=="boolean"?r:typeof r=="string"?V(r):!1}function x(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function F(e,t,i){let r=e;return t!==null&&r<t&&(r=t),i!==null&&r>i&&(r=i),r}function k(e){return e==="inline"||e==="digital"||e==="odometer"||e==="analog"?e:"inline"}function C(e){return e==="currency"||e==="percent"||e==="number"||e==="decimal"?e:"decimal"}function N(e){return e==="compact"?"compact":"standard"}function A(e){return e==="up"||e==="down"||e==="auto"?e:"auto"}function S(e){const t=l(e,"decimals"),i=l(e,"minimum-fraction-digits"),r=l(e,"maximum-fraction-digits");return i!=null||r!=null?{minimumFractionDigits:i??void 0,maximumFractionDigits:r??void 0}:t!=null?{minimumFractionDigits:t,maximumFractionDigits:t}:{}}function P(e,t){const i=C(n(e,"format")),r=n(e,"locale")||void 0,o=n(e,"currency")||void 0,u=N(n(e,"notation")),m=n(e,"decimal-separator"),c=n(e,"group-separator"),s=S(e),y={style:i==="currency"&&o?"currency":i==="percent"?"percent":"decimal",currency:i==="currency"&&o?o:void 0,notation:u,useGrouping:!0,numberingSystem:"latn",minimumFractionDigits:s.minimumFractionDigits,maximumFractionDigits:s.maximumFractionDigits};let p;try{p=new Intl.NumberFormat(r,y).formatToParts(t)}catch{p=new Intl.NumberFormat(void 0,y).formatToParts(t)}const d=[];for(const a of p){const v=a.type==="decimal"&&m!=null?m:a.type==="group"&&c!=null?c:a.value;for(const f of v){if(/[0-9]/.test(f)){d.push({kind:"digit",value:f});continue}let g="literal";a.type==="group"?g="group":a.type==="decimal"?g="decimal":a.type==="currency"||a.type==="percentSign"||a.type==="unit"?g="symbol":(a.type==="minusSign"||a.type==="plusSign")&&(g="sign"),d.push({kind:"text",value:f,textType:g})}}return{tokens:d,text:d.map(a=>a.value).join("")}}function q(e){return e==="down"?["9","8","7","6","5","4","3","2","1","0"]:["0","1","2","3","4","5","6","7","8","9"]}function j(e,t){const i=parseInt(e,10);return Number.isNaN(i)?0:t==="down"?-(9-i)*100:-i*100}function R(e,t){return e==="linear"?t:e==="ease-in"?t*t*t:e==="ease-out"?1-Math.pow(1-t,3):e==="ease-in-out"?t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2:e==="spring"?t===0||t===1?t:Math.min(1,1-Math.cos(t*Math.PI*4)*Math.exp(-t*6)):t*t*(3-2*t)}class $ extends M.ElementBase{constructor(){super(...arguments),this._currentValue=0,this._targetValue=0,this._startValue=0,this._startTime=null,this._animationFrame=null,this._initialized=!1,this._animationProgress=1,this._motionDirection="none"}static get observedAttributes(){return["value","variant","size","tone","theme","format","locale","currency","notation","decimals","minimum-fraction-digits","maximum-fraction-digits","duration","animation","direction","prefix","suffix","decimal-separator","group-separator","separator","animate","animate-on-mount","count-up","min","max","auto-format","label"]}connectedCallback(){if(super.connectedCallback(),this._initialized)return;const t=this._readClampedValue();if(this._targetValue=t,this._shouldAnimateOnMount()&&t!==this._getMountStartValue()){this._currentValue=this._getMountStartValue(),this._initialized=!0,this.requestRender(),this._animateToValue(t);return}this._currentValue=t,this._initialized=!0,this.requestRender()}disconnectedCallback(){super.disconnectedCallback(),this._stopAnimation()}attributeChangedCallback(t,i,r){if(i!==r){if(t==="value"){const o=this._readClampedValue(r);if(!this.isConnected){this._currentValue=o,this._targetValue=o;return}if(!this._initialized){this._currentValue=o,this._targetValue=o,this._initialized=!0,this.requestRender();return}this._animateToValue(o);return}super.attributeChangedCallback(t,i,r)}}_readClampedValue(t){const i=t!=null?(()=>{const r=parseFloat(t);return Number.isNaN(r)?0:r})():l(this,"value")??0;return F(i,l(this,"min"),l(this,"max"))}_getMountStartValue(){return F(0,l(this,"min"),l(this,"max"))}_shouldAnimate(){return w(this,"animate")&&!this._isReducedMotion()}_shouldAnimateOnMount(){return(w(this,"animate-on-mount")||w(this,"count-up"))&&this._shouldAnimate()}_stopAnimation(){this._animationFrame!==null&&(cancelAnimationFrame(this._animationFrame),this._animationFrame=null),this._startTime=null,this._animationProgress=1}_animateToValue(t){if(!this._shouldAnimate()){const i=this._currentValue;this._stopAnimation(),this._currentValue=t,this._targetValue=t,this._motionDirection=t>i?"up":t<i?"down":"none",this.requestRender();return}this._stopAnimation(),this._startValue=this._currentValue,this._targetValue=t,this._startTime=null,this._animationProgress=0,this._motionDirection=t>this._startValue?"up":t<this._startValue?"down":"none",this._animationFrame=requestAnimationFrame(i=>this._animate(i))}_animate(t){this._startTime===null&&(this._startTime=t);const i=Math.max(1,l(this,"duration")??800),r=n(this,"animation")||"spring",o=t-this._startTime,u=Math.min(1,o/i),m=R(r,u);if(this._animationProgress=u,this._currentValue=this._startValue+(this._targetValue-this._startValue)*m,this.requestRender(),u<1){this._animationFrame=requestAnimationFrame(c=>this._animate(c));return}this._currentValue=this._targetValue,this._animationFrame=null,this._startTime=null,this._animationProgress=1,this.requestRender(),this._emitComplete()}_emitComplete(){this.dispatchEvent(new CustomEvent("complete",{detail:{value:this._currentValue},bubbles:!0,composed:!0}))}_isReducedMotion(){return typeof window<"u"&&window.matchMedia?window.matchMedia("(prefers-reduced-motion: reduce)").matches:!1}render(){const t=k(n(this,"variant")),i=n(this,"prefix")||"",r=n(this,"suffix")||"",o=n(this,"label"),u=P(this,this._currentValue),m=o||`${i}${u.text}${r}`,c=this._animationFrame!==null,s=c?1-this._animationProgress:0,y=this._motionDirection==="down"?-1:this._motionDirection==="up"?1:0;let p="value-display",d="";t==="digital"?(p+=" digital-display",d=[`--ui-odometer-motion-intensity: ${s.toFixed(3)}`,`--ui-odometer-digital-shift-y: ${(y*s*.16).toFixed(3)}em`,`--ui-odometer-digital-scale-y: ${(1+s*.08).toFixed(3)}`].join("; ")):t==="analog"&&(p+=" analog-display",d=[`--ui-odometer-motion-intensity: ${s.toFixed(3)}`,`--ui-odometer-analog-shift-x: ${(y*s*.08).toFixed(3)}em`,`--ui-odometer-analog-shift-y: ${(-s*.05).toFixed(3)}em`,`--ui-odometer-analog-scale: ${(1+s*.03).toFixed(3)}`,`--ui-odometer-analog-blur: ${(s*.035).toFixed(3)}em`].join("; "));let a=`<span class="${p}" part="value" aria-hidden="true"${d?` style="${d}"`:""}>${x(u.text)}</span>`;if(t==="odometer"){const v=A(n(this,"direction")),f=v==="auto"?this._targetValue>=this._startValue?"up":"down":v,g=q(f);a=`
|
|
296
296
|
<span class="digits" part="digits" role="img" aria-label="${x(m)}">
|
|
297
|
-
${u.tokens.map(_=>{if(_.kind==="digit"){const z=
|
|
297
|
+
${u.tokens.map(_=>{if(_.kind==="digit"){const z=g.map(T=>`<span class="digit-value" aria-hidden="true">${T}</span>`).join("");return`
|
|
298
298
|
<span class="digit" part="digit" aria-hidden="true">
|
|
299
299
|
<span class="digit-track" style="--ui-odometer-offset: ${j(_.value,f)}%;">
|
|
300
300
|
${z}
|
package/dist/odometer.esm.js
CHANGED
|
@@ -16,10 +16,10 @@ const D = `
|
|
|
16
16
|
--ui-odometer-container-bg: transparent;
|
|
17
17
|
--ui-odometer-container-border: none;
|
|
18
18
|
--ui-odometer-container-radius: 999px;
|
|
19
|
-
--ui-odometer-digit-bg:
|
|
20
|
-
--ui-odometer-digit-border: 1px solid rgba(148, 163, 184, 0.35);
|
|
19
|
+
--ui-odometer-digit-bg: var(--ui-color-fill, #f0f0f0);
|
|
20
|
+
--ui-odometer-digit-border: 1px solid var(--ui-color-line-subtle, rgba(148, 163, 184, 0.35));
|
|
21
21
|
--ui-odometer-digit-radius: 0.18em;
|
|
22
|
-
--ui-odometer-digit-shadow:
|
|
22
|
+
--ui-odometer-digit-shadow: none;
|
|
23
23
|
--ui-odometer-separator-opacity: 0.7;
|
|
24
24
|
--ui-odometer-affix-opacity: 0.82;
|
|
25
25
|
|
package/dist/orbiter.cjs.js
CHANGED
|
@@ -7,40 +7,23 @@
|
|
|
7
7
|
--ui-orbiter-center-size: ${w};
|
|
8
8
|
--ui-orbiter-ring-gap: ${E};
|
|
9
9
|
--ui-orbiter-padding: ${$};
|
|
10
|
-
--ui-orbiter-radius:
|
|
10
|
+
--ui-orbiter-radius: calc(var(--ui-radius, 6px) + 4px);
|
|
11
11
|
--ui-orbiter-stage-size:
|
|
12
12
|
calc((2 * var(--ui-orbiter-farthest-radius, ${A})) + var(--ui-orbiter-item-size));
|
|
13
13
|
--ui-orbiter-accent: var(--ui-color-primary, var(--ui-primary, #2563eb));
|
|
14
|
-
--ui-orbiter-bg:
|
|
15
|
-
radial-gradient(
|
|
16
|
-
circle at 50% 50%,
|
|
17
|
-
color-mix(in srgb, var(--ui-color-surface-elevated, #f8fafc) 92%, transparent) 0%,
|
|
18
|
-
color-mix(in srgb, var(--ui-color-surface, #ffffff) 98%, transparent) 64%,
|
|
19
|
-
color-mix(in srgb, var(--ui-color-surface, #ffffff) 84%, transparent) 100%
|
|
20
|
-
);
|
|
14
|
+
--ui-orbiter-bg: var(--color-panel-solid, var(--ui-color-surface, #ffffff));
|
|
21
15
|
--ui-orbiter-color: var(--ui-color-text, #0f172a);
|
|
22
|
-
--ui-orbiter-border-color:
|
|
23
|
-
color-mix(in srgb, var(--ui-color-border, rgba(15, 23, 42, 0.16)) 86%, transparent);
|
|
16
|
+
--ui-orbiter-border-color: var(--ui-color-line-subtle, color-mix(in srgb, var(--ui-color-border, #cbd5e1) 76%, transparent));
|
|
24
17
|
--ui-orbiter-border: 1px solid var(--ui-orbiter-border-color);
|
|
25
|
-
--ui-orbiter-shadow:
|
|
26
|
-
0 1px 3px rgba(15, 23, 42, 0.06),
|
|
27
|
-
0 24px 44px rgba(15, 23, 42, 0.12);
|
|
18
|
+
--ui-orbiter-shadow: none;
|
|
28
19
|
--ui-orbiter-backdrop: none;
|
|
29
20
|
--ui-orbiter-path-color:
|
|
30
21
|
color-mix(in srgb, var(--ui-orbiter-accent) 16%, var(--ui-orbiter-border-color));
|
|
31
22
|
--ui-orbiter-path-opacity: 0.95;
|
|
32
|
-
--ui-orbiter-item-bg:
|
|
33
|
-
linear-gradient(
|
|
34
|
-
180deg,
|
|
35
|
-
color-mix(in srgb, #ffffff 96%, transparent),
|
|
36
|
-
color-mix(in srgb, var(--ui-orbiter-accent) 8%, rgba(255, 255, 255, 0.9))
|
|
37
|
-
);
|
|
23
|
+
--ui-orbiter-item-bg: var(--color-panel-solid, var(--ui-color-surface, #ffffff));
|
|
38
24
|
--ui-orbiter-item-color: var(--ui-orbiter-color);
|
|
39
|
-
--ui-orbiter-item-border:
|
|
40
|
-
|
|
41
|
-
--ui-orbiter-item-shadow:
|
|
42
|
-
0 8px 14px rgba(15, 23, 42, 0.08),
|
|
43
|
-
0 1px 2px rgba(15, 23, 42, 0.05);
|
|
25
|
+
--ui-orbiter-item-border: 1px solid var(--ui-color-line-subtle, color-mix(in srgb, var(--ui-color-border, #cbd5e1) 76%, transparent));
|
|
26
|
+
--ui-orbiter-item-shadow: none;
|
|
44
27
|
--ui-orbiter-item-backdrop: none;
|
|
45
28
|
--ui-orbiter-center-bg:
|
|
46
29
|
radial-gradient(
|
|
@@ -366,7 +349,7 @@
|
|
|
366
349
|
outline: none;
|
|
367
350
|
border-color: color-mix(in srgb, var(--ui-orbiter-focus-ring) 30%, transparent);
|
|
368
351
|
box-shadow:
|
|
369
|
-
0 0 0
|
|
352
|
+
0 0 0 2px var(--ui-ring-color, var(--ui-orbiter-focus-ring)),
|
|
370
353
|
var(--ui-orbiter-item-shadow);
|
|
371
354
|
}
|
|
372
355
|
|
|
@@ -434,7 +417,7 @@
|
|
|
434
417
|
outline: none;
|
|
435
418
|
border-color: color-mix(in srgb, var(--ui-orbiter-focus-ring) 24%, transparent);
|
|
436
419
|
box-shadow:
|
|
437
|
-
0 0 0
|
|
420
|
+
0 0 0 2px var(--ui-ring-color, var(--ui-orbiter-focus-ring)),
|
|
438
421
|
var(--ui-orbiter-shadow);
|
|
439
422
|
}
|
|
440
423
|
|
|
@@ -479,7 +462,7 @@
|
|
|
479
462
|
forced-color-adjust: none;
|
|
480
463
|
}
|
|
481
464
|
}
|
|
482
|
-
`;function h(i,t){if(i==null||i==="")return t;const e=i.trim();if(!e)return t;const s=e.split(/\s+/).filter(Boolean);if(!s.length)return t;const
|
|
465
|
+
`;function h(i,t){if(i==null||i==="")return t;const e=i.trim();if(!e)return t;const s=e.split(/\s+/).filter(Boolean);if(!s.length)return t;const c=s.map(a=>/^-?\d+(\.\d+)?$/.test(a)?`${a}px`:/^-?\d*\.?\d+(px|rem|em|%|vh|vw|ch|ex|vmin|vmax)$/.test(a)?a:null);return c.some(a=>a===null)?t:c.join(" ")}function N(i,t){if(i==null||i==="")return t;const e=i.trim();return e?/^-?\d+(\.\d+)?(ms|s)$/i.test(e)?e:/^-?\d+(\.\d+)?$/i.test(e)?`${e}s`:t:t}function F(i,t){if(i==null||i==="")return t;const e=i.trim();return e?/^-?\d+(\.\d+)?ms$/i.test(e)?Number.parseFloat(e):/^-?\d+(\.\d+)?s$/i.test(e)||/^-?\d+(\.\d+)?$/i.test(e)?Number.parseFloat(e)*1e3:t:t}function g(i,t){if(i==null||i==="")return t;const e=Number.parseFloat(i);return Number.isFinite(e)?e:t}function S(i,t){const e=g(i,t);return Number.isFinite(e)&&e>0?e:t}function q(i,t){if(i==null)return t;const e=i.trim().toLowerCase();return e?e==="false"||e==="0"||e==="off"||e==="no"?!1:e==="true"||e==="1"||e==="on"||e==="yes"?!0:t:!0}function v(i,t){return`translate(-50%, -50%) rotate(${i}deg) translateX(${t}) rotate(${-i}deg)`}function z(i){const t=Math.round(g(i,1));return Math.min(X,Math.max(1,t||1))}class D extends B.ElementBase{constructor(){super(),this._itemSlot=null,this._centerSlot=null,this._pathsEl=null,this._items=[],this._centerNodes=[],this._animations=new Map,this._hovering=!1,this._itemHovering=!1,this._focusWithin=!1,this._itemHoverHandlers=new WeakMap,this._boundSlotChange=this._handleSlotChange.bind(this),this._boundPointerEnter=()=>{this._hovering=!0,this._syncState()},this._boundPointerLeave=()=>{this._hovering=!1,this._syncState()},this._boundFocusIn=()=>{this._focusWithin=!0,this._syncState()},this._boundFocusOut=()=>{this._focusWithin=this.matches(":focus-within"),this._syncState()},this.addEventListener("pointerenter",this._boundPointerEnter),this.addEventListener("pointerleave",this._boundPointerLeave),this.addEventListener("focusin",this._boundFocusIn),this.addEventListener("focusout",this._boundFocusOut)}static get observedAttributes(){return["duration","delay","speed","reverse","radius","orbit-radius","icon-size","item-size","center-size","ring-gap","rings","start-angle","direction","animation","variant","tone","size","surface-radius","elevation","padding","path","show-paths","pause-on-hover","pause-on-item-hover","pause-on-focus","paused"]}play(){this.hasAttribute("paused")&&this.removeAttribute("paused"),this._syncState()}pause(){this.hasAttribute("paused")||this.setAttribute("paused",""),this._syncState()}refresh(){this._syncRuntimeStyles(),this._syncItems(),this._renderPaths(),this._syncAnimations(),this._syncState()}disconnectedCallback(){this._cancelAllAnimations(),this._hovering=!1,this._itemHovering=!1,this._focusWithin=!1,super.disconnectedCallback()}render(){this.setContent(`
|
|
483
466
|
<style>${Q}</style>
|
|
484
467
|
<div class="root" part="root">
|
|
485
468
|
<div class="surface" part="surface">
|
|
@@ -492,4 +475,4 @@
|
|
|
492
475
|
</div>
|
|
493
476
|
</div>
|
|
494
477
|
</div>
|
|
495
|
-
`),this._itemSlot=this.root.querySelector("slot:not([name])"),this._centerSlot=this.root.querySelector('slot[name="center"]'),this._pathsEl=this.root.querySelector(".paths"),this._itemSlot?.addEventListener("slotchange",this._boundSlotChange),this._centerSlot?.addEventListener("slotchange",this._boundSlotChange),this._syncRuntimeStyles(),this._syncItems(),this._renderPaths(),this._syncAnimations(),this._syncState()}shouldRenderOnAttributeChange(){return!1}attributeChangedCallback(t,e,s){if(!(e===s||!this.isConnected)){if(t==="paused"){this._syncState();return}this._syncRuntimeStyles(),t==="orbit-radius"||t==="radius"||t==="icon-size"||t==="item-size"||t==="center-size"||t==="ring-gap"||t==="rings"||t==="start-angle"||t==="direction"||t==="reverse"||t==="size"?(this._syncItems(),this._renderPaths(),this._syncAnimations()):(t==="duration"||t==="delay"||t==="speed"||t==="animation")&&this._syncAnimations(),this._syncState()}}_handleSlotChange(){this._syncItems(),this._renderPaths(),this._syncAnimations(),this._syncState()}_itemsFromSlot(){return this._itemSlot?this._itemSlot.assignedElements({flatten:!0}).filter(t=>t instanceof HTMLElement):[]}_centerFromSlot(){return this._centerSlot?this._centerSlot.assignedElements({flatten:!0}).filter(t=>t instanceof HTMLElement):[]}_syncItems(){const t=this._itemsFromSlot(),e=this._centerFromSlot(),s=new Set(t),b=new Set(e);for(const r of this._items)s.has(r)||(this._unbindItemHover(r),this._cancelAnimation(r),r.removeAttribute("data-ui-orbiter-managed"),r.removeAttribute("data-ui-orbit-runtime"),r.style.removeProperty("--ui-orbit-index"),r.style.removeProperty("--ui-orbit-ring"),r.style.removeProperty("--ui-orbit-radius"),r.style.removeProperty("--ui-orbit-start-angle"),r.style.removeProperty("--ui-orbit-quarter-angle"),r.style.removeProperty("--ui-orbit-half-angle"),r.style.removeProperty("--ui-orbit-three-quarter-angle"),r.style.removeProperty("--ui-orbit-end-angle"),r.style.removeProperty("--ui-orbit-start-angle-inverse"),r.style.removeProperty("--ui-orbit-quarter-angle-inverse"),r.style.removeProperty("--ui-orbit-half-angle-inverse"),r.style.removeProperty("--ui-orbit-three-quarter-angle-inverse"),r.style.removeProperty("--ui-orbit-end-angle-inverse"),r.style.removeProperty("--ui-orbit-duration"),r.style.removeProperty("--ui-orbit-duration-scale"),r.style.removeProperty("animation"),r.style.removeProperty("transform"),r.hasAttribute("data-ui-orbiter-owned")&&(r.removeAttribute("data-ui-orbiter-item"),r.removeAttribute("data-ui-orbiter-owned")));for(const r of this._centerNodes)b.has(r)||(r.removeAttribute("data-ui-orbiter-managed"),r.hasAttribute("data-ui-orbiter-owned")&&(r.removeAttribute("data-ui-orbiter-center"),r.removeAttribute("data-ui-orbiter-owned")));e.forEach(r=>{r.setAttribute("data-ui-orbiter-managed",""),r.hasAttribute("data-ui-orbiter-center")||(r.setAttribute("data-ui-orbiter-center",""),r.setAttribute("data-ui-orbiter-owned","")),r.setAttribute("slot","center")});const a=z(this.getAttribute("rings")),u=h(this._orbitRadiusValue(),this._sizePreset().orbitRadius),o=h(this.getAttribute("ring-gap"),this._sizePreset().ringGap),l=g(this.getAttribute("start-angle"),C),d=Array.from({length:a},()=>[]);t.forEach((r,c)=>{r.setAttribute("data-ui-orbiter-managed",""),r.hasAttribute("data-ui-orbiter-item")||(r.setAttribute("data-ui-orbiter-item",""),r.setAttribute("data-ui-orbiter-owned","")),this._bindItemHover(r),d[c%a].push({item:r,index:c})}),d.forEach((r,c)=>{const f=r.length?360/r.length:360,y=r.length>1&&c%2===1?f/2:0,p=c===0?u:`calc(${u} + ${c} * ${o})`,x=360*this._directionSign(c);r.forEach(({item:n,index:G},U)=>{const m=l+y+U*f,R=m+x,k=m+x*.25,I=m+x*.5,L=m+x*.75,H=1+c*.14;n.style.setProperty("--ui-orbit-index",String(G)),n.style.setProperty("--ui-orbit-ring",String(c)),n.style.setProperty("--ui-orbit-radius",p),n.style.setProperty("--ui-orbit-duration",`calc(var(--ui-orbiter-duration) * ${H})`),n.style.setProperty("--ui-orbit-duration-scale",String(H)),n.style.setProperty("--ui-orbit-start-angle",`${m}deg`),n.style.setProperty("--ui-orbit-quarter-angle",`${k}deg`),n.style.setProperty("--ui-orbit-half-angle",`${I}deg`),n.style.setProperty("--ui-orbit-three-quarter-angle",`${L}deg`),n.style.setProperty("--ui-orbit-end-angle",`${R}deg`),n.style.setProperty("--ui-orbit-start-angle-inverse",`${-m}deg`),n.style.setProperty("--ui-orbit-quarter-angle-inverse",`${-k}deg`),n.style.setProperty("--ui-orbit-half-angle-inverse",`${-I}deg`),n.style.setProperty("--ui-orbit-three-quarter-angle-inverse",`${-L}deg`),n.style.setProperty("--ui-orbit-end-angle-inverse",`${-R}deg`),n.style.setProperty("transform",v(m,p))})}),this._items=t,this._centerNodes=e,this._itemHovering=this._items.some(r=>r.matches(":hover")),this.setAttribute("data-item-count",String(this._items.length)),this.setAttribute("data-center-count",String(this._centerNodes.length)),this.setAttribute("data-ring-count",String(a))}_renderPaths(){if(!this._pathsEl)return;const t=z(this.getAttribute("rings")),e=h(this._orbitRadiusValue(),this._sizePreset().orbitRadius),s=h(this.getAttribute("ring-gap"),this._sizePreset().ringGap),b=Array.from({length:t},(a,u)=>{const o=u===0?e:`calc(${e} + ${u} * ${s})`;return`<div class="path" part="path path-${u+1}" style="inline-size:calc(2 * (${o}));block-size:calc(2 * (${o}));"></div>`}).join("");this._pathsEl.innerHTML=b,this._pathsEl.toggleAttribute("hidden",!this._pathVisible())}_bindItemHover(t){if(this._itemHoverHandlers.has(t))return;const e=()=>{this._itemHovering=!0,this._syncState()},s=b=>{const u=(b.relatedTarget instanceof HTMLElement?b.relatedTarget:null)?.closest("[data-ui-orbiter-item]");this._itemHovering=u instanceof HTMLElement?this._items.includes(u):!1,this._syncState()};t.addEventListener("pointerenter",e),t.addEventListener("pointerleave",s),this._itemHoverHandlers.set(t,{enter:e,leave:s})}_unbindItemHover(t){const e=this._itemHoverHandlers.get(t);e&&(t.removeEventListener("pointerenter",e.enter),t.removeEventListener("pointerleave",e.leave),this._itemHoverHandlers.delete(t))}_sizePreset(){switch(this.getAttribute("size")){case"xs":case"0":return _.xs;case"sm":case"1":return _.sm;case"lg":case"3":return _.lg;case"xl":case"4":return _.xl;default:return _.md}}_motionPreset(){const t=this.getAttribute("animation");return t&&Z.has(t)?M[t]:M.smooth}_direction(){const t=this.getAttribute("direction");return t&&j.has(t)?t:"clockwise"}_directionSign(t){const e=this._direction();let s=e==="counterclockwise"||e==="alternate"&&t%2===1?-1:1;return q(this.getAttribute("reverse"),this.hasAttribute("reverse"))&&(s*=-1),s}_pathVisible(){const t=this.getAttribute("path");return t!=null?q(t,!0):(this.hasAttribute("show-paths"),!0)}_orbitRadiusValue(){return this.getAttribute("radius")??this.getAttribute("orbit-radius")}_iconSizeValue(){return this.getAttribute("icon-size")??this.getAttribute("item-size")}_syncRuntimeStyles(){const t=this._sizePreset(),e=this._motionPreset(),s=N(this.getAttribute("duration"),O),b=N(this.getAttribute("delay"),V),a=h(this._orbitRadiusValue(),t.orbitRadius),u=h(this._iconSizeValue(),t.itemSize),o=h(this.getAttribute("center-size"),t.centerSize),l=h(this.getAttribute("ring-gap"),t.ringGap),d=h(this.getAttribute("padding"),t.padding),r=z(this.getAttribute("rings")),c=S(this.getAttribute("speed"),1),f=r<=1?a:`calc(${a} + ${r-1} * ${l})`,y=`calc((2 * (${f})) + ${u})`;this.style.setProperty("--ui-orbiter-duration",`calc((${s}) * ${e.durationScale} / ${c})`),this.style.setProperty("--ui-orbiter-delay",b),this.style.setProperty("--ui-orbiter-orbit-radius",a),this.style.setProperty("--ui-orbiter-item-size",u),this.style.setProperty("--ui-orbiter-center-size",o),this.style.setProperty("--ui-orbiter-ring-gap",l),this.style.setProperty("--ui-orbiter-padding",d),this.style.setProperty("--ui-orbiter-farthest-radius",f),this.style.setProperty("--ui-orbiter-stage-size",y),this.style.setProperty("--ui-orbiter-path-opacity",String(e.accentOpacity>.18?1:.95));const p=this.getAttribute("surface-radius");!p||W.has(p.trim())?this.style.removeProperty("--ui-orbiter-radius"):this.style.setProperty("--ui-orbiter-radius",h(p,t.panelRadius))}_syncAnimations(){const t=this._items,e=new Set(t);for(const[o,l]of this._animations.entries())e.has(o)||(l.cancel(),this._animations.delete(o));if(typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches){this._cancelAllAnimations(),t.forEach(o=>o.removeAttribute("data-ui-orbit-runtime"));return}if(typeof HTMLElement>"u"||typeof HTMLElement.prototype.animate!="function"){t.forEach(o=>o.removeAttribute("data-ui-orbit-runtime"));return}const s=this._motionPreset(),b=F(this.getAttribute("duration"),18e3),a=F(this.getAttribute("delay"),0),u=S(this.getAttribute("speed"),1);for(const o of t){const l=o.style.getPropertyValue("--ui-orbit-radius")||"var(--ui-orbiter-orbit-radius)",d=g(o.style.getPropertyValue("--ui-orbit-start-angle"),C),r=g(o.style.getPropertyValue("--ui-orbit-quarter-angle"),d+90),c=g(o.style.getPropertyValue("--ui-orbit-half-angle"),d+180),f=g(o.style.getPropertyValue("--ui-orbit-three-quarter-angle"),d+270),y=g(o.style.getPropertyValue("--ui-orbit-end-angle"),d+360),p=S(o.style.getPropertyValue("--ui-orbit-duration-scale"),1),T=b*s.durationScale*p/u;this._animations.get(o)?.cancel(),o.setAttribute("data-ui-orbit-runtime","");const n=o.animate([{transform:v(d,l),offset:0},{transform:v(r,l),offset:.25},{transform:v(c,l),offset:.5},{transform:v(f,l),offset:.75},{transform:v(y,l),offset:1}],{duration:Math.max(1,T),delay:Math.max(0,a),easing:"linear",iterations:Number.POSITIVE_INFINITY,fill:"both"});this._animations.set(o,n)}}_cancelAnimation(t){const e=this._animations.get(t);t.removeAttribute("data-ui-orbit-runtime"),e&&(e.cancel(),this._animations.delete(t))}_cancelAllAnimations(){for(const t of this._animations.values())t.cancel();this._animations.clear(),this._items.forEach(t=>{t.removeAttribute("data-ui-orbit-runtime"),this._unbindItemHover(t)})}_effectivePaused(){return!!(this.hasAttribute("paused")||this.hasAttribute("pause-on-hover")&&this._hovering||this.hasAttribute("pause-on-item-hover")&&this._itemHovering||this.hasAttribute("pause-on-focus")&&this._focusWithin)}_syncState(){const t=this._effectivePaused()?"paused":"running";this.setAttribute("data-state",t),this.setAttribute("data-path-visible",this._pathVisible()?"true":"false"),this.setAttribute("data-item-hovered",this._itemHovering?"true":"false");for(const e of this._animations.values())t==="paused"?e.pause():e.play()}}typeof customElements<"u"&&!customElements.get("ui-orbiter")&&customElements.define("ui-orbiter",D);exports.UIOrbiter=D;
|
|
478
|
+
`),this._itemSlot=this.root.querySelector("slot:not([name])"),this._centerSlot=this.root.querySelector('slot[name="center"]'),this._pathsEl=this.root.querySelector(".paths"),this._itemSlot?.addEventListener("slotchange",this._boundSlotChange),this._centerSlot?.addEventListener("slotchange",this._boundSlotChange),this._syncRuntimeStyles(),this._syncItems(),this._renderPaths(),this._syncAnimations(),this._syncState()}shouldRenderOnAttributeChange(){return!1}attributeChangedCallback(t,e,s){if(!(e===s||!this.isConnected)){if(t==="paused"){this._syncState();return}this._syncRuntimeStyles(),t==="orbit-radius"||t==="radius"||t==="icon-size"||t==="item-size"||t==="center-size"||t==="ring-gap"||t==="rings"||t==="start-angle"||t==="direction"||t==="reverse"||t==="size"?(this._syncItems(),this._renderPaths(),this._syncAnimations()):(t==="duration"||t==="delay"||t==="speed"||t==="animation")&&this._syncAnimations(),this._syncState()}}_handleSlotChange(){this._syncItems(),this._renderPaths(),this._syncAnimations(),this._syncState()}_itemsFromSlot(){return this._itemSlot?this._itemSlot.assignedElements({flatten:!0}).filter(t=>t instanceof HTMLElement):[]}_centerFromSlot(){return this._centerSlot?this._centerSlot.assignedElements({flatten:!0}).filter(t=>t instanceof HTMLElement):[]}_syncItems(){const t=this._itemsFromSlot(),e=this._centerFromSlot(),s=new Set(t),c=new Set(e);for(const r of this._items)s.has(r)||(this._unbindItemHover(r),this._cancelAnimation(r),r.removeAttribute("data-ui-orbiter-managed"),r.removeAttribute("data-ui-orbit-runtime"),r.style.removeProperty("--ui-orbit-index"),r.style.removeProperty("--ui-orbit-ring"),r.style.removeProperty("--ui-orbit-radius"),r.style.removeProperty("--ui-orbit-start-angle"),r.style.removeProperty("--ui-orbit-quarter-angle"),r.style.removeProperty("--ui-orbit-half-angle"),r.style.removeProperty("--ui-orbit-three-quarter-angle"),r.style.removeProperty("--ui-orbit-end-angle"),r.style.removeProperty("--ui-orbit-start-angle-inverse"),r.style.removeProperty("--ui-orbit-quarter-angle-inverse"),r.style.removeProperty("--ui-orbit-half-angle-inverse"),r.style.removeProperty("--ui-orbit-three-quarter-angle-inverse"),r.style.removeProperty("--ui-orbit-end-angle-inverse"),r.style.removeProperty("--ui-orbit-duration"),r.style.removeProperty("--ui-orbit-duration-scale"),r.style.removeProperty("animation"),r.style.removeProperty("transform"),r.hasAttribute("data-ui-orbiter-owned")&&(r.removeAttribute("data-ui-orbiter-item"),r.removeAttribute("data-ui-orbiter-owned")));for(const r of this._centerNodes)c.has(r)||(r.removeAttribute("data-ui-orbiter-managed"),r.hasAttribute("data-ui-orbiter-owned")&&(r.removeAttribute("data-ui-orbiter-center"),r.removeAttribute("data-ui-orbiter-owned")));e.forEach(r=>{r.setAttribute("data-ui-orbiter-managed",""),r.hasAttribute("data-ui-orbiter-center")||(r.setAttribute("data-ui-orbiter-center",""),r.setAttribute("data-ui-orbiter-owned","")),r.setAttribute("slot","center")});const a=z(this.getAttribute("rings")),u=h(this._orbitRadiusValue(),this._sizePreset().orbitRadius),o=h(this.getAttribute("ring-gap"),this._sizePreset().ringGap),l=g(this.getAttribute("start-angle"),C),d=Array.from({length:a},()=>[]);t.forEach((r,b)=>{r.setAttribute("data-ui-orbiter-managed",""),r.hasAttribute("data-ui-orbiter-item")||(r.setAttribute("data-ui-orbiter-item",""),r.setAttribute("data-ui-orbiter-owned","")),this._bindItemHover(r),d[b%a].push({item:r,index:b})}),d.forEach((r,b)=>{const f=r.length?360/r.length:360,y=r.length>1&&b%2===1?f/2:0,p=b===0?u:`calc(${u} + ${b} * ${o})`,x=360*this._directionSign(b);r.forEach(({item:n,index:G},U)=>{const m=l+y+U*f,R=m+x,k=m+x*.25,I=m+x*.5,L=m+x*.75,H=1+b*.14;n.style.setProperty("--ui-orbit-index",String(G)),n.style.setProperty("--ui-orbit-ring",String(b)),n.style.setProperty("--ui-orbit-radius",p),n.style.setProperty("--ui-orbit-duration",`calc(var(--ui-orbiter-duration) * ${H})`),n.style.setProperty("--ui-orbit-duration-scale",String(H)),n.style.setProperty("--ui-orbit-start-angle",`${m}deg`),n.style.setProperty("--ui-orbit-quarter-angle",`${k}deg`),n.style.setProperty("--ui-orbit-half-angle",`${I}deg`),n.style.setProperty("--ui-orbit-three-quarter-angle",`${L}deg`),n.style.setProperty("--ui-orbit-end-angle",`${R}deg`),n.style.setProperty("--ui-orbit-start-angle-inverse",`${-m}deg`),n.style.setProperty("--ui-orbit-quarter-angle-inverse",`${-k}deg`),n.style.setProperty("--ui-orbit-half-angle-inverse",`${-I}deg`),n.style.setProperty("--ui-orbit-three-quarter-angle-inverse",`${-L}deg`),n.style.setProperty("--ui-orbit-end-angle-inverse",`${-R}deg`),n.style.setProperty("transform",v(m,p))})}),this._items=t,this._centerNodes=e,this._itemHovering=this._items.some(r=>r.matches(":hover")),this.setAttribute("data-item-count",String(this._items.length)),this.setAttribute("data-center-count",String(this._centerNodes.length)),this.setAttribute("data-ring-count",String(a))}_renderPaths(){if(!this._pathsEl)return;const t=z(this.getAttribute("rings")),e=h(this._orbitRadiusValue(),this._sizePreset().orbitRadius),s=h(this.getAttribute("ring-gap"),this._sizePreset().ringGap),c=Array.from({length:t},(a,u)=>{const o=u===0?e:`calc(${e} + ${u} * ${s})`;return`<div class="path" part="path path-${u+1}" style="inline-size:calc(2 * (${o}));block-size:calc(2 * (${o}));"></div>`}).join("");this._pathsEl.innerHTML=c,this._pathsEl.toggleAttribute("hidden",!this._pathVisible())}_bindItemHover(t){if(this._itemHoverHandlers.has(t))return;const e=()=>{this._itemHovering=!0,this._syncState()},s=c=>{const u=(c.relatedTarget instanceof HTMLElement?c.relatedTarget:null)?.closest("[data-ui-orbiter-item]");this._itemHovering=u instanceof HTMLElement?this._items.includes(u):!1,this._syncState()};t.addEventListener("pointerenter",e),t.addEventListener("pointerleave",s),this._itemHoverHandlers.set(t,{enter:e,leave:s})}_unbindItemHover(t){const e=this._itemHoverHandlers.get(t);e&&(t.removeEventListener("pointerenter",e.enter),t.removeEventListener("pointerleave",e.leave),this._itemHoverHandlers.delete(t))}_sizePreset(){switch(this.getAttribute("size")){case"xs":case"0":return _.xs;case"sm":case"1":return _.sm;case"lg":case"3":return _.lg;case"xl":case"4":return _.xl;default:return _.md}}_motionPreset(){const t=this.getAttribute("animation");return t&&Z.has(t)?M[t]:M.smooth}_direction(){const t=this.getAttribute("direction");return t&&j.has(t)?t:"clockwise"}_directionSign(t){const e=this._direction();let s=e==="counterclockwise"||e==="alternate"&&t%2===1?-1:1;return q(this.getAttribute("reverse"),this.hasAttribute("reverse"))&&(s*=-1),s}_pathVisible(){const t=this.getAttribute("path");return t!=null?q(t,!0):(this.hasAttribute("show-paths"),!0)}_orbitRadiusValue(){return this.getAttribute("radius")??this.getAttribute("orbit-radius")}_iconSizeValue(){return this.getAttribute("icon-size")??this.getAttribute("item-size")}_syncRuntimeStyles(){const t=this._sizePreset(),e=this._motionPreset(),s=N(this.getAttribute("duration"),O),c=N(this.getAttribute("delay"),V),a=h(this._orbitRadiusValue(),t.orbitRadius),u=h(this._iconSizeValue(),t.itemSize),o=h(this.getAttribute("center-size"),t.centerSize),l=h(this.getAttribute("ring-gap"),t.ringGap),d=h(this.getAttribute("padding"),t.padding),r=z(this.getAttribute("rings")),b=S(this.getAttribute("speed"),1),f=r<=1?a:`calc(${a} + ${r-1} * ${l})`,y=`calc((2 * (${f})) + ${u})`;this.style.setProperty("--ui-orbiter-duration",`calc((${s}) * ${e.durationScale} / ${b})`),this.style.setProperty("--ui-orbiter-delay",c),this.style.setProperty("--ui-orbiter-orbit-radius",a),this.style.setProperty("--ui-orbiter-item-size",u),this.style.setProperty("--ui-orbiter-center-size",o),this.style.setProperty("--ui-orbiter-ring-gap",l),this.style.setProperty("--ui-orbiter-padding",d),this.style.setProperty("--ui-orbiter-farthest-radius",f),this.style.setProperty("--ui-orbiter-stage-size",y),this.style.setProperty("--ui-orbiter-path-opacity",String(e.accentOpacity>.18?1:.95));const p=this.getAttribute("surface-radius");!p||W.has(p.trim())?this.style.removeProperty("--ui-orbiter-radius"):this.style.setProperty("--ui-orbiter-radius",h(p,t.panelRadius))}_syncAnimations(){const t=this._items,e=new Set(t);for(const[o,l]of this._animations.entries())e.has(o)||(l.cancel(),this._animations.delete(o));if(typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches){this._cancelAllAnimations(),t.forEach(o=>o.removeAttribute("data-ui-orbit-runtime"));return}if(typeof HTMLElement>"u"||typeof HTMLElement.prototype.animate!="function"){t.forEach(o=>o.removeAttribute("data-ui-orbit-runtime"));return}const s=this._motionPreset(),c=F(this.getAttribute("duration"),18e3),a=F(this.getAttribute("delay"),0),u=S(this.getAttribute("speed"),1);for(const o of t){const l=o.style.getPropertyValue("--ui-orbit-radius")||"var(--ui-orbiter-orbit-radius)",d=g(o.style.getPropertyValue("--ui-orbit-start-angle"),C),r=g(o.style.getPropertyValue("--ui-orbit-quarter-angle"),d+90),b=g(o.style.getPropertyValue("--ui-orbit-half-angle"),d+180),f=g(o.style.getPropertyValue("--ui-orbit-three-quarter-angle"),d+270),y=g(o.style.getPropertyValue("--ui-orbit-end-angle"),d+360),p=S(o.style.getPropertyValue("--ui-orbit-duration-scale"),1),T=c*s.durationScale*p/u;this._animations.get(o)?.cancel(),o.setAttribute("data-ui-orbit-runtime","");const n=o.animate([{transform:v(d,l),offset:0},{transform:v(r,l),offset:.25},{transform:v(b,l),offset:.5},{transform:v(f,l),offset:.75},{transform:v(y,l),offset:1}],{duration:Math.max(1,T),delay:Math.max(0,a),easing:"linear",iterations:Number.POSITIVE_INFINITY,fill:"both"});this._animations.set(o,n)}}_cancelAnimation(t){const e=this._animations.get(t);t.removeAttribute("data-ui-orbit-runtime"),e&&(e.cancel(),this._animations.delete(t))}_cancelAllAnimations(){for(const t of this._animations.values())t.cancel();this._animations.clear(),this._items.forEach(t=>{t.removeAttribute("data-ui-orbit-runtime"),this._unbindItemHover(t)})}_effectivePaused(){return!!(this.hasAttribute("paused")||this.hasAttribute("pause-on-hover")&&this._hovering||this.hasAttribute("pause-on-item-hover")&&this._itemHovering||this.hasAttribute("pause-on-focus")&&this._focusWithin)}_syncState(){const t=this._effectivePaused()?"paused":"running";this.setAttribute("data-state",t),this.setAttribute("data-path-visible",this._pathVisible()?"true":"false"),this.setAttribute("data-item-hovered",this._itemHovering?"true":"false");for(const e of this._animations.values())t==="paused"?e.pause():e.play()}}typeof customElements<"u"&&!customElements.get("ui-orbiter")&&customElements.define("ui-orbiter",D);exports.UIOrbiter=D;
|