@editora/ui-core 0.2.0 → 0.2.1
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 +8 -0
- package/dist/accordion.cjs.js +1 -1
- package/dist/accordion.esm.js +1 -1
- package/dist/alert-dialog.cjs.js +32 -24
- package/dist/alert-dialog.esm.js +48 -40
- package/dist/alert.cjs.js +2 -2
- package/dist/alert.esm.js +2 -2
- package/dist/animated-text.cjs.js +5 -5
- package/dist/animated-text.esm.js +5 -5
- package/dist/app-header.cjs.js +12 -7
- package/dist/app-header.esm.js +12 -7
- package/dist/avatar.cjs.js +3 -3
- package/dist/avatar.esm.js +3 -3
- package/dist/{calendar-o273O28D.js → calendar-CzpWDxLc.js} +5 -4
- package/dist/{calendar-DmxiZrR7.mjs → calendar-DkSDFg33.mjs} +1 -0
- package/dist/calendar.cjs.js +1 -1
- package/dist/calendar.esm.js +1 -1
- package/dist/chart.cjs.js +13 -7
- package/dist/chart.esm.js +13 -7
- package/dist/collapsible.cjs.js +2 -2
- package/dist/collapsible.esm.js +2 -2
- package/dist/color-picker.cjs.js +3 -3
- package/dist/color-picker.esm.js +3 -3
- package/dist/combobox.cjs.js +3 -3
- package/dist/combobox.esm.js +36 -36
- package/dist/components/ui-alert-dialog.d.ts.map +1 -1
- package/dist/components/ui-app-header.d.ts.map +1 -1
- package/dist/components/ui-calendar.d.ts.map +1 -1
- package/dist/components/ui-chart.d.ts.map +1 -1
- package/dist/components/ui-gantt.d.ts.map +1 -1
- package/dist/components/ui-hover-card.d.ts.map +1 -1
- package/dist/components/ui-inline-edit.d.ts.map +1 -1
- package/dist/components/ui-multi-select.d.ts.map +1 -1
- package/dist/components/ui-sidebar.d.ts.map +1 -1
- package/dist/components/ui-tabs.d.ts.map +1 -1
- package/dist/components/ui-wizard.d.ts.map +1 -1
- package/dist/context-menu.cjs.js +1 -1
- package/dist/context-menu.esm.js +1 -1
- package/dist/data-table.cjs.js +3 -3
- package/dist/data-table.esm.js +3 -3
- package/dist/date-field.cjs.js +2 -2
- package/dist/date-field.esm.js +14 -14
- package/dist/date-picker.cjs.js +3 -3
- package/dist/date-picker.esm.js +4 -4
- package/dist/date-range-picker.cjs.js +3 -3
- package/dist/date-range-picker.esm.js +59 -59
- package/dist/date-range-time-picker.cjs.js +2 -2
- package/dist/date-range-time-picker.esm.js +3 -3
- package/dist/date-time-picker.cjs.js +2 -2
- package/dist/date-time-picker.esm.js +3 -3
- package/dist/{date-time-utils-DdigV4hs.js → date-time-utils-C-4eHTyy.js} +1 -1
- package/dist/{date-time-utils-B4hAkt36.mjs → date-time-utils-zAx4ghvC.mjs} +1 -1
- package/dist/description.cjs.js +4 -4
- package/dist/description.esm.js +4 -4
- package/dist/dialog.cjs.js +2 -2
- package/dist/dialog.esm.js +2 -2
- package/dist/direction-provider.cjs.js +1 -1
- package/dist/direction-provider.esm.js +1 -1
- package/dist/dock.cjs.js +1 -1
- package/dist/dock.esm.js +1 -1
- package/dist/dropdown.cjs.js +1 -1
- package/dist/dropdown.esm.js +1 -1
- package/dist/field-error.cjs.js +1 -1
- package/dist/field-error.esm.js +7 -7
- package/dist/field.cjs.js +1 -1
- package/dist/field.esm.js +29 -29
- package/dist/fieldset.cjs.js +4 -4
- package/dist/fieldset.esm.js +3 -3
- package/dist/file-upload.cjs.js +2 -2
- package/dist/file-upload.esm.js +2 -2
- package/dist/flex.cjs.js +2 -2
- package/dist/flex.esm.js +8 -8
- package/dist/form.cjs.js +4 -4
- package/dist/form.esm.js +4 -4
- package/dist/gantt.cjs.js +7 -5
- package/dist/gantt.esm.js +7 -5
- package/dist/grid.cjs.js +1 -1
- package/dist/grid.esm.js +1 -1
- package/dist/hover-card.cjs.js +1 -1
- package/dist/hover-card.esm.js +11 -8
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/inline-edit.cjs.js +6 -6
- package/dist/inline-edit.esm.js +15 -15
- package/dist/input.cjs.js +1 -1
- package/dist/input.esm.js +1 -1
- package/dist/label.cjs.js +6 -6
- package/dist/label.esm.js +6 -6
- package/dist/masonry-grid.cjs.js +2 -2
- package/dist/masonry-grid.esm.js +11 -11
- package/dist/{menu-item-styles-IGSFLAHu.mjs → menu-item-styles-CdqxPUuw.mjs} +15 -15
- package/dist/{menu-item-styles-B4onAr4C.js → menu-item-styles-DUdyjQ7i.js} +10 -10
- package/dist/menu.cjs.js +1 -1
- package/dist/menu.esm.js +1 -1
- package/dist/menubar.cjs.js +1 -1
- package/dist/menubar.esm.js +1 -1
- package/dist/multi-select.cjs.js +7 -7
- package/dist/multi-select.esm.js +26 -26
- package/dist/number-field.cjs.js +1 -1
- package/dist/number-field.esm.js +1 -1
- package/dist/number-ticker.cjs.js +4 -4
- package/dist/number-ticker.esm.js +10 -10
- package/dist/odometer.cjs.js +7 -7
- package/dist/odometer.esm.js +14 -14
- package/dist/password-field.cjs.js +1 -1
- package/dist/password-field.esm.js +1 -1
- package/dist/pin-input.cjs.js +1 -1
- package/dist/pin-input.esm.js +1 -1
- package/dist/placement-grid.cjs.js +1 -1
- package/dist/placement-grid.esm.js +1 -1
- package/dist/portal.cjs.js +1 -1
- package/dist/portal.esm.js +1 -1
- package/dist/presence.cjs.js +1 -1
- package/dist/presence.esm.js +1 -1
- package/dist/quick-actions.cjs.js +1 -1
- package/dist/quick-actions.esm.js +1 -1
- package/dist/radio.cjs.js +1 -1
- package/dist/radio.esm.js +1 -1
- package/dist/{runtime-CQM6wZOc.mjs → runtime-BRT7E4A8.mjs} +377 -329
- package/dist/runtime-CXw4SGV9.js +5 -0
- package/dist/runtime.cjs.js +1 -1
- package/dist/runtime.esm.js +1 -1
- package/dist/select.cjs.js +2 -2
- package/dist/select.esm.js +2 -2
- package/dist/separator.cjs.js +6 -6
- package/dist/separator.esm.js +7 -7
- package/dist/sidebar.cjs.js +7 -6
- package/dist/sidebar.esm.js +7 -6
- package/dist/slot.cjs.js +1 -1
- package/dist/slot.esm.js +1 -1
- package/dist/sortable.cjs.js +6 -6
- package/dist/sortable.esm.js +6 -6
- package/dist/split-button.cjs.js +2 -2
- package/dist/split-button.esm.js +2 -2
- package/dist/tabs.cjs.js +11 -6
- package/dist/tabs.esm.js +28 -23
- package/dist/tags-input.cjs.js +2 -2
- package/dist/tags-input.esm.js +2 -2
- package/dist/textarea.cjs.js +2 -2
- package/dist/textarea.esm.js +16 -16
- package/dist/theme.d.ts.map +1 -1
- package/dist/time-field.cjs.js +2 -2
- package/dist/time-field.esm.js +24 -24
- package/dist/time-picker.cjs.js +2 -2
- package/dist/time-picker.esm.js +3 -3
- package/dist/toast.cjs.js +2 -2
- package/dist/toast.esm.js +2 -2
- package/dist/transfer-list.cjs.js +9 -9
- package/dist/transfer-list.esm.js +4 -4
- package/dist/wizard.cjs.js +16 -7
- package/dist/wizard.esm.js +16 -7
- package/package.json +1 -1
- package/dist/runtime-DxCl0A5q.js +0 -5
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";const y=['[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]',".item","[data-menu-item]"],I=[".shortcut"];function r(e,o){return e.flatMap(i=>o.map(
|
|
2
|
-
`)}function
|
|
1
|
+
"use strict";const y=['[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]',".item","[data-menu-item]"],I=[".shortcut"];function r(e,o){return e.flatMap(i=>o.map(c=>`${i} ${c}`)).join(`,
|
|
2
|
+
`)}function n(e,o){return e.map(i=>`${i}${o}`)}function s(e,o){return e.map(i=>`${i}${o}`)}function T(e){const o=e.itemSelectors??y,i=e.shortcutSelectors??I,c=e.activeStateSelectors??[],t=e.prefix,a=r(e.scopes,o),l=r(e.scopes,[...n(o,":hover"),...n(o,":focus-visible"),...c]),p=r(e.scopes,n(o,":focus-visible")),m=r(e.scopes,s(o,'[aria-disabled="true"]')),u=r(e.scopes,s(o,'[data-tone="danger"]')),d=r(e.scopes,s(o,'[data-tone="success"]')),x=r(e.scopes,s(o,'[data-tone="warning"]')),b=r(e.scopes,[".separator",'[role="separator"]']),g=r(e.scopes,[".label"]),h=r(e.scopes,[".label .text"]),$=r(e.scopes,[".label .caption"]),f=r(e.scopes,[".section-label"]),v=r(e.scopes,[".icon"]),S=r(e.scopes,[".selection-icon"]),k=r(e.scopes,['[role="menuitemcheckbox"][aria-checked="true"] .selection-icon::before']),w=r(e.scopes,['[role="menuitemradio"][aria-checked="true"] .selection-icon::before']),z=r(e.scopes,i),C=r(e.scopes,[".submenu-arrow"]);return`
|
|
3
3
|
${f} {
|
|
4
4
|
padding: 6px 10px 4px;
|
|
5
|
-
color: color-mix(in srgb, var(${t}-color, #0f172a)
|
|
5
|
+
color: color-mix(in srgb, var(${t}-color, #0f172a) 72%, transparent);
|
|
6
6
|
font: 600 11px/1.4 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
|
7
7
|
letter-spacing: 0.04em;
|
|
8
8
|
text-transform: uppercase;
|
|
@@ -53,16 +53,16 @@
|
|
|
53
53
|
pointer-events: none;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
${
|
|
57
|
-
color: #dc2626;
|
|
56
|
+
${u} {
|
|
57
|
+
color: var(--ui-color-danger-text, #dc2626);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
${
|
|
61
|
-
color: #15803d;
|
|
60
|
+
${d} {
|
|
61
|
+
color: var(--ui-color-success-text, #15803d);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
${x} {
|
|
65
|
-
color: #b45309;
|
|
65
|
+
color: var(--ui-color-warning-text, #b45309);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
${v} {
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
${$} {
|
|
128
|
-
color: color-mix(in srgb, currentColor
|
|
128
|
+
color: color-mix(in srgb, currentColor 88%, transparent);
|
|
129
129
|
font-size: calc(var(${t}-item-font-size, 14px) - 1px);
|
|
130
130
|
line-height: 1.35;
|
|
131
131
|
letter-spacing: inherit;
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
padding-left: 14px;
|
|
137
137
|
flex: 0 0 auto;
|
|
138
138
|
min-width: max-content;
|
|
139
|
-
color: color-mix(in srgb, currentColor
|
|
139
|
+
color: color-mix(in srgb, currentColor 88%, transparent);
|
|
140
140
|
font-size: calc(var(${t}-item-font-size, 14px) - 1px);
|
|
141
141
|
line-height: 1;
|
|
142
142
|
letter-spacing: inherit;
|
package/dist/menu.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("./ElementBase-DxbvhLJs.js"),x=require("./trigger-DkPsKxsP.js"),A=require("./portal-XbYR3m_q.js"),E=require("./dismissable-layer-DNfrKA20.js"),S=require("./positioner-DZ1FW6A9.js"),c=require("./overlay-motion-B56x1GoY.js"),k=require("./menu-item-styles-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("./ElementBase-DxbvhLJs.js"),x=require("./trigger-DkPsKxsP.js"),A=require("./portal-XbYR3m_q.js"),E=require("./dismissable-layer-DNfrKA20.js"),S=require("./positioner-DZ1FW6A9.js"),c=require("./overlay-motion-B56x1GoY.js"),k=require("./menu-item-styles-DUdyjQ7i.js");function _(r){return r==="top"||r==="left"||r==="right"?r:"bottom"}function w(r){return r==="sm"||r==="1"||r==="compact"?"sm":r==="lg"||r==="3"||r==="comfortable"?"lg":"md"}function I(r){return!r||r==="default"?null:r==="none"?"0px":r==="sm"?"8px":r==="md"?"12px":r==="lg"?"16px":r==="full"?"999px":r==="square"?"6px":r==="soft"?"14px":/^\d+(\.\d+)?$/.test(r)?`${r}px`:/^\d+(\.\d+)?(px|rem|em|%)$/.test(r)?r:null}function l(r,e){return r.getAttribute(e)||""}function p(r,e){if(r==null)return e;const t=String(r).toLowerCase();return t!=="false"&&t!=="0"}function u(){return['[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]',".item","[data-menu-item]"].join(", ")}function m(r){return r.hasAttribute("disabled")||r.getAttribute("aria-disabled")==="true"||!!r.disabled}function f(r){const e=typeof r.composedPath=="function"?r.composedPath():[];for(const i of e)if(i instanceof HTMLElement&&i.matches(u()))return i;const t=r.target;return t instanceof HTMLElement?t.closest(u()):null}const C=new Set(["variant","density","shape","elevation","tone","size","radius"]),T=["--ui-menu-bg","--ui-menu-color","--ui-menu-border-color","--ui-menu-border","--ui-menu-shadow","--ui-menu-radius","--ui-menu-padding","--ui-menu-min-width","--ui-menu-ring","--ui-menu-backdrop","--ui-menu-z","--ui-menu-item-radius","--ui-menu-item-gap","--ui-menu-item-min-height","--ui-menu-item-pad-y","--ui-menu-item-pad-x","--ui-menu-item-font-size","--ui-menu-item-line-height","--ui-menu-separator-margin","--ui-menu-item-hover-bg","--ui-menu-item-active-color"],L=`
|
|
2
2
|
:host {
|
|
3
3
|
--ui-menu-bg: var(--base-menu-bg, var(--color-panel-solid, var(--ui-color-surface, var(--ui-surface, #ffffff))));
|
|
4
4
|
--ui-menu-color: var(--ui-color-text, var(--ui-text, #0f172a));
|
package/dist/menu.esm.js
CHANGED
|
@@ -4,7 +4,7 @@ import { b as x } from "./portal-DeaM1tYY.mjs";
|
|
|
4
4
|
import { c as A } from "./dismissable-layer-BmPIoK80.mjs";
|
|
5
5
|
import { e as E } from "./positioner-BE8Nbho2.mjs";
|
|
6
6
|
import { O as k, o as g, r as S, a as w } from "./overlay-motion-BX3dPLay.mjs";
|
|
7
|
-
import { c as I } from "./menu-item-styles-
|
|
7
|
+
import { c as I } from "./menu-item-styles-CdqxPUuw.mjs";
|
|
8
8
|
function _(r) {
|
|
9
9
|
return r === "top" || r === "left" || r === "right" ? r : "bottom";
|
|
10
10
|
}
|
package/dist/menubar.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("./ElementBase-DxbvhLJs.js"),E=require("./portal-XbYR3m_q.js"),k=require("./collection-qv8A8rq4.js"),I=require("./dismissable-layer-DNfrKA20.js"),m=require("./roving-focus-group-BdJ_4Njm.js"),L=require("./positioner-DZ1FW6A9.js"),v=require("./overlay-motion-B56x1GoY.js");require("./listbox-CTpRpuF7.js");const C=require("./menu-item-styles-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("./ElementBase-DxbvhLJs.js"),E=require("./portal-XbYR3m_q.js"),k=require("./collection-qv8A8rq4.js"),I=require("./dismissable-layer-DNfrKA20.js"),m=require("./roving-focus-group-BdJ_4Njm.js"),L=require("./positioner-DZ1FW6A9.js"),v=require("./overlay-motion-B56x1GoY.js");require("./listbox-CTpRpuF7.js");const C=require("./menu-item-styles-DUdyjQ7i.js"),T=":scope > .submenu",D=["--ui-color-primary","--ui-color-primary-hover","--ui-color-foreground-on-primary","--ui-color-background","--ui-color-surface","--ui-color-surface-alt","--ui-color-text","--ui-color-muted","--ui-color-border","--ui-color-focus-ring","--ui-color-success","--ui-color-danger","--ui-color-warning","--ui-primary","--ui-primary-hover","--ui-foreground","--ui-background","--ui-surface","--ui-surface-alt","--ui-text","--ui-muted","--ui-border","--ui-focus-ring","--ui-radius","--color-background","--color-surface","--color-panel","--color-panel-solid","--color-panel-translucent","--color-overlay","--accent-contrast","--accent-surface","--accent-indicator","--accent-track"],z=[{prefix:"--accent-",from:1,to:12},{prefix:"--accent-a",from:1,to:12},{prefix:"--gray-",from:1,to:12},{prefix:"--gray-a",from:1,to:12},{prefix:"--black-a",from:1,to:12},{prefix:"--white-a",from:1,to:12},{prefix:"--shadow-",from:1,to:6},{prefix:"--radius-",from:1,to:6}];function B(n){return n==="sm"||n==="1"||n==="compact"?"sm":n==="lg"||n==="3"||n==="comfortable"?"lg":"md"}function y(n){return!n||n==="default"?null:n==="none"||n==="square"?"0px":n==="sm"?"8px":n==="md"||n==="soft"?"12px":n==="lg"?"16px":n==="full"?"999px":/^\d+(\.\d+)?$/.test(n)?`${n}px`:/^\d+(\.\d+)?(px|rem|em|%)$/.test(n)?n:null}const O=`
|
|
2
2
|
:host {
|
|
3
3
|
--ui-menubar-gap: var(--base-menubar-gap, 6px);
|
|
4
4
|
--ui-menubar-padding: var(--base-menubar-padding, 6px);
|
package/dist/menubar.esm.js
CHANGED
|
@@ -6,7 +6,7 @@ import { r as g, s as v, f as C, m as y, g as x } from "./roving-focus-group-Dbm
|
|
|
6
6
|
import { e as T } from "./positioner-BE8Nbho2.mjs";
|
|
7
7
|
import { O as D, o as z, r as O, a as B } from "./overlay-motion-BX3dPLay.mjs";
|
|
8
8
|
import "./listbox-hMVOhKHC.mjs";
|
|
9
|
-
import { c as F } from "./menu-item-styles-
|
|
9
|
+
import { c as F } from "./menu-item-styles-CdqxPUuw.mjs";
|
|
10
10
|
const R = ":scope > .submenu", M = [
|
|
11
11
|
"--ui-color-primary",
|
|
12
12
|
"--ui-color-primary-hover",
|
package/dist/multi-select.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const M=require("./ElementBase-DxbvhLJs.js"),O=require("./overlay-motion-B56x1GoY.js"),K=require("./control-name-BmoI1m3a.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const M=require("./ElementBase-DxbvhLJs.js"),O=require("./overlay-motion-B56x1GoY.js"),K=require("./control-name-BmoI1m3a.js"),S=require("./collection-qv8A8rq4.js");require("./listbox-CTpRpuF7.js");let W=0;const j=`
|
|
2
2
|
${O.OVERLAY_MOTION_CSS}
|
|
3
3
|
|
|
4
4
|
:host {
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
--ui-multi-select-text: var(--ui-color-text, var(--ui-text, #0f172a));
|
|
10
10
|
--ui-multi-select-muted: var(--ui-color-muted, var(--ui-muted, #526175));
|
|
11
11
|
--ui-multi-select-focus: var(--ui-color-focus-ring, #2563eb);
|
|
12
|
-
--ui-multi-select-danger: var(--ui-color-danger, #dc2626);
|
|
12
|
+
--ui-multi-select-danger: var(--ui-color-danger-text, var(--ui-color-danger, #dc2626));
|
|
13
13
|
--ui-multi-select-accent: var(--ui-color-primary, #2563eb);
|
|
14
14
|
--ui-multi-select-chip-bg: color-mix(in srgb, var(--ui-color-primary, #2563eb) 10%, transparent);
|
|
15
|
-
--ui-multi-select-chip-text: color-mix(in srgb, var(--ui-color-primary, #2563eb)
|
|
15
|
+
--ui-multi-select-chip-text: color-mix(in srgb, var(--ui-color-primary, #2563eb) 45%, var(--ui-color-text-strong, #0f172a));
|
|
16
16
|
--ui-multi-select-panel-bg: var(--base-multi-select-panel-bg, color-mix(in srgb, var(--ui-multi-select-bg) 98%, transparent));
|
|
17
17
|
--ui-multi-select-panel-border: var(--base-multi-select-panel-border, 1px solid color-mix(in srgb, var(--ui-multi-select-border-color) 84%, transparent));
|
|
18
18
|
--ui-multi-select-panel-shadow: var(--base-multi-select-panel-shadow, var(--shadow-4, 0 20px 34px rgba(2, 6, 23, 0.16)));
|
|
@@ -519,21 +519,21 @@
|
|
|
519
519
|
--ui-multi-select-accent: var(--ui-color-success, #15803d);
|
|
520
520
|
--ui-multi-select-focus: var(--ui-color-success, #15803d);
|
|
521
521
|
--ui-multi-select-chip-bg: color-mix(in srgb, var(--ui-color-success, #15803d) 12%, transparent);
|
|
522
|
-
--ui-multi-select-chip-text: color-mix(in srgb, var(--ui-color-success, #15803d) 82%, #0f172a 18%);
|
|
522
|
+
--ui-multi-select-chip-text: var(--ui-color-success-text, color-mix(in srgb, var(--ui-color-success, #15803d) 82%, #0f172a 18%));
|
|
523
523
|
}
|
|
524
524
|
|
|
525
525
|
:host([tone="warning"]) {
|
|
526
526
|
--ui-multi-select-accent: var(--ui-color-warning, #b45309);
|
|
527
527
|
--ui-multi-select-focus: var(--ui-color-warning, #b45309);
|
|
528
528
|
--ui-multi-select-chip-bg: color-mix(in srgb, var(--ui-color-warning, #b45309) 12%, transparent);
|
|
529
|
-
--ui-multi-select-chip-text: color-mix(in srgb, var(--ui-color-warning, #b45309) 82%, #0f172a 18%);
|
|
529
|
+
--ui-multi-select-chip-text: var(--ui-color-warning-text, color-mix(in srgb, var(--ui-color-warning, #b45309) 82%, #0f172a 18%));
|
|
530
530
|
}
|
|
531
531
|
|
|
532
532
|
:host([tone="danger"]) {
|
|
533
533
|
--ui-multi-select-accent: var(--ui-color-danger, #dc2626);
|
|
534
534
|
--ui-multi-select-focus: var(--ui-color-danger, #dc2626);
|
|
535
535
|
--ui-multi-select-chip-bg: color-mix(in srgb, var(--ui-color-danger, #dc2626) 12%, transparent);
|
|
536
|
-
--ui-multi-select-chip-text: color-mix(in srgb, var(--ui-color-danger, #dc2626) 82%, #0f172a 18%);
|
|
536
|
+
--ui-multi-select-chip-text: var(--ui-color-danger-text, color-mix(in srgb, var(--ui-color-danger, #dc2626) 82%, #0f172a 18%));
|
|
537
537
|
}
|
|
538
538
|
`;function I(r){if(!r)return[];try{const e=JSON.parse(r);if(!Array.isArray(e))return[];const t=[],s=(l,n)=>{const a=String(l.value??"").trim();a&&t.push({value:a,label:String(l.label??a),description:l.description?String(l.description):void 0,disabled:!!l.disabled,group:n})};return e.forEach(l=>{if(!l||typeof l!="object")return;const n=l;if(Array.isArray(n.options)){const a=String(n.label??"").trim();n.options.forEach(c=>{!c||typeof c!="object"||s(c,a||void 0)});return}s(n)}),t}catch{return[]}}function v(r){if(!r)return[];const e=r.trim();if(!e)return[];if(e.startsWith("["))try{const t=JSON.parse(e);if(Array.isArray(t))return t.map(s=>String(s)).filter(Boolean)}catch{}return e.split(",").map(t=>t.trim()).filter(Boolean)}function L(r){return!r||r==="default"?null:r==="none"||r==="square"?"0px":r==="sm"?"8px":r==="md"||r==="soft"?"12px":r==="lg"?"16px":r==="full"?"999px":/^\d+(\.\d+)?$/.test(r)?`${r}px`:/^\d+(\.\d+)?(px|rem|em|%)$/.test(r)?r:null}function H(r){return r==="sm"||r==="1"?"sm":r==="lg"||r==="3"?"lg":"md"}class N extends M.ElementBase{constructor(){super(),this._options=[],this._selected=[],this._query="",this._inputEl=null,this._shellEl=null,this._panelEl=null,this._formUnregister=null,this._outsidePointerDown=null,this._activeValue=null,this._uid=`ui-multi-select-${++W}`,this._isSyncingUi=!1,this._needsSyncUi=!1,this._onInput=this._onInput.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onToggle=this._onToggle.bind(this),this._onFocusIn=this._onFocusIn.bind(this),this._onFocusOut=this._onFocusOut.bind(this)}static get observedAttributes(){return["options","value","placeholder","label","aria-label","aria-description","aria-describedby","description","data-error","name","required","disabled","readonly","loading","loading-text","clearable","open","max-selections","render-limit","selection-indicator","option-border","variant","tone","density","shape","size","radius","option-radius","elevation"]}get value(){return[...this._selected]}set value(e){const t=Array.isArray(e)?e.map(s=>String(s)).filter(Boolean):v(String(e??""));this._setSelected(t,"api")}get open(){return this.hasAttribute("open")}set open(e){e?this.setAttribute("open",""):this.removeAttribute("open")}connectedCallback(){super.connectedCallback(),this._registerWithForm()}disconnectedCallback(){this._detachOutsideListener(),this._formUnregister&&(this._formUnregister(),this._formUnregister=null),super.disconnectedCallback()}attributeChangedCallback(e,t,s){if(t!==s&&(e==="options"&&(this._options=I(s)),e==="value"&&(this._selected=v(s)),e==="name"&&this.isConnected&&this._registerWithForm(),!!this._shellEl)){if(e==="variant"||e==="tone"||e==="density"||e==="shape"||e==="size"||e==="radius"||e==="option-radius"||e==="elevation"){this._syncVisualState(),e==="size"&&this._syncUi();return}this._syncUi()}}shouldRenderOnAttributeChange(){return!1}render(){this.setContent(`
|
|
539
539
|
<style>${j}</style>
|
|
@@ -559,4 +559,4 @@
|
|
|
559
559
|
</div>
|
|
560
560
|
<div class="error" part="error" hidden></div>
|
|
561
561
|
</div>
|
|
562
|
-
`),this._options=I(this.getAttribute("options")),this._selected=v(this.getAttribute("value")),this._shellEl=this.root.querySelector(".shell"),this._inputEl=this.root.querySelector(".input"),this._panelEl=this.root.querySelector(".panel"),this._inputEl?.addEventListener("input",this._onInput),this._inputEl?.addEventListener("keydown",this._onKeyDown),this.root.querySelector(".toggle")?.addEventListener("click",this._onToggle),this.root.querySelector(".clear")?.addEventListener("click",()=>this._clearSelection("clear-button")),this._shellEl?.addEventListener("focusin",this._onFocusIn),this._shellEl?.addEventListener("focusout",this._onFocusOut),this._syncVisualState(),this._syncUi()}_syncVisualState(){const e=L(this.getAttribute("radius")||this.getAttribute("shape"));e?this.style.setProperty("--ui-multi-select-radius",e):this.style.removeProperty("--ui-multi-select-radius");const t=L(this.getAttribute("option-radius"));t?this.style.setProperty("--ui-multi-select-option-radius",t):this.style.removeProperty("--ui-multi-select-option-radius");const s=H(this.getAttribute("size"));this.setAttribute("data-size",s)}_selectionIndicator(){const e=(this.getAttribute("selection-indicator")||"checkbox").trim().toLowerCase();return e==="none"||e==="check"?e:"checkbox"}_isInteractionLocked(){return this.hasAttribute("disabled")||this.hasAttribute("readonly")}_attachOutsideListener(){this._outsidePointerDown||typeof document>"u"||(this._outsidePointerDown=e=>{const t=e.composedPath();t.includes(this)||t.includes(this.root)||this._panelEl&&t.includes(this._panelEl)||this._inputEl&&t.includes(this._inputEl)||(this.open=!1,this._syncUi())},document.addEventListener("pointerdown",this._outsidePointerDown))}_detachOutsideListener(){!this._outsidePointerDown||typeof document>"u"||(document.removeEventListener("pointerdown",this._outsidePointerDown),this._outsidePointerDown=null)}_filteredOptions(){const e=z.normalizeCollectionText(this._query);return e?this._options.filter(t=>z.normalizeCollectionText(t.label).includes(e)||z.normalizeCollectionText(t.value).includes(e)):this._options}_renderLimit(){const e=Number(this.getAttribute("render-limit"));return Number.isFinite(e)&&e>0?e:200}_findOptionNode(e){return!e||!this._panelEl?null:Array.from(this._panelEl.querySelectorAll(".option")).find(t=>t.getAttribute("data-value")===e)}_selectedOptionRecords(){return this._selected.map(e=>this._options.find(t=>t.value===e)).filter(Boolean)}_emitChange(e,t){this.dispatchEvent(new CustomEvent("change",{detail:{value:[...this._selected],previousValue:t,selectedItems:this._selectedOptionRecords(),source:e},bubbles:!0,composed:!0}))}_setSelected(e,t){const s=Number(this.getAttribute("max-selections")),l=[];e.forEach(c=>{if(!c)return;const p=l.indexOf(c);p>=0&&l.splice(p,1),l.push(c)});const n=Number.isFinite(s)&&s>0?l.slice(-s):l,a=[...this._selected];if(a.length===n.length&&a.every((c,p)=>c===n[p])){this._syncUi();return}this._selected=n,this._selected.length?this.setAttribute("value",JSON.stringify(this._selected)):this.removeAttribute("value"),this._syncUi(),this._emitChange(t,a)}_toggleValue(e,t){if(this._isInteractionLocked()||this.hasAttribute("loading"))return;const l=this._selected.includes(e)?this._selected.filter(n=>n!==e):[...this._selected,e];this._activeValue=e,this._setSelected(l,t)}_removeChip(e){this._isInteractionLocked()||(this._activeValue===e&&(this._activeValue=null),this._toggleValue(e,"remove-chip"))}_clearSelection(e){if(!(this._isInteractionLocked()||!this._selected.length)){this._activeValue=null,this._setSelected([],e),this._query="",this._inputEl&&(this._inputEl.value="");try{this._inputEl?.focus({preventScroll:!0})}catch{this._inputEl?.focus()}}}_registerWithForm(){this._formUnregister&&(this._formUnregister(),this._formUnregister=null);try{const l=this.getRootNode().host?.closest?.("ui-form")||null||this.closest("ui-form"),n=this.getAttribute("name");l&&typeof l.registerField=="function"&&n&&(this._formUnregister=l.registerField(n,{name:n,getValue:()=>[...this._selected],setValue:a=>{Array.isArray(a)?this._setSelected(a.map(c=>String(c)),"form"):this._setSelected(v(String(a??"")),"form")},validate:async()=>this.hasAttribute("required")&&this._selected.length===0?{valid:!1,message:"At least one option is required"}:{valid:!0},setError:a=>{a?this.setAttribute("data-error",a):this.removeAttribute("data-error"),this._syncUi()}}))}catch{}}_onInput(e){this._isInteractionLocked()||(this._query=e.target?.value||"",this.open||(this.open=!0),this._syncUi())}_onKeyDown(e){if(!this._isInteractionLocked()){if(e.key==="ArrowDown"){e.preventDefault(),this.open||(this.open=!0),this._syncUi(),this._panelEl?.getActiveItem()?this._panelEl.move(1,{focus:!1,owner:this._inputEl,scroll:!1}):this._panelEl?.focusBoundary("first",{focus:!1,owner:this._inputEl,scroll:!1});return}if(e.key==="ArrowUp"){e.preventDefault(),this.open||(this.open=!0),this._syncUi(),this._panelEl?.getActiveItem()?this._panelEl.move(-1,{focus:!1,owner:this._inputEl,scroll:!1}):this._panelEl?.focusBoundary("last",{focus:!1,owner:this._inputEl,scroll:!1});return}if(e.key==="Home"){e.preventDefault(),this.open||(this.open=!0),this._syncUi(),this._panelEl?.focusBoundary("first",{focus:!1,owner:this._inputEl,scroll:!1});return}if(e.key==="End"){e.preventDefault(),this.open||(this.open=!0),this._syncUi(),this._panelEl?.focusBoundary("last",{focus:!1,owner:this._inputEl,scroll:!1});return}if(e.key==="Enter"){const t=this._panelEl?.getActiveItem();if(t){e.preventDefault();const s=t.getAttribute("data-value");s&&(this._activeValue=s,this._toggleValue(s,"keyboard"),this._query="",this._inputEl&&(this._inputEl.value=""),this._inputEl?.focus())}return}if(e.key==="Escape"){e.preventDefault(),this._query?(this._query="",this._inputEl&&(this._inputEl.value="")):this.open=!1,this._syncUi();return}if(e.key==="Tab"){this.open=!1,this._syncUi();return}e.key==="Backspace"&&!this._query&&this._selected.length&&this._removeChip(this._selected[this._selected.length-1])}}_onToggle(){this._isInteractionLocked()||(this.open=!this.open,this._syncUi(),this.open&&this._inputEl?.focus())}_onFocusIn(){this._isInteractionLocked()||(this.open=!0),this._syncUi()}_onFocusOut(e){this._shellEl?.contains(e.relatedTarget)||(this.open=!1,this._syncUi())}_syncUi(){if(this._isSyncingUi){this._needsSyncUi=!0;return}if(!(!this._shellEl||!this._inputEl||!this._panelEl)){this._isSyncingUi=!0;try{const e=(this.getAttribute("label")||"").trim(),t=(this.getAttribute("description")||"").trim(),s=(this.getAttribute("data-error")||"").trim(),l=this.root.querySelector(".meta"),n=this.root.querySelector(".label"),a=this.root.querySelector(".label-text"),c=this.root.querySelector(".required"),p=this.root.querySelector(".description"),D=this.root.querySelector(".chips"),S=this.root.querySelector(".toggle"),C=this.root.querySelector(".clear"),x=this.root.querySelector(".error"),q=this._selectionIndicator(),U=this.hasAttribute("loading"),V=(this.getAttribute("loading-text")||"Loading options...").trim(),m=this.hasAttribute("disabled"),b=this.hasAttribute("readonly"),F=this.hasAttribute("clearable");if(l.hidden=!e&&!t,n.hidden=!e,a.textContent=e,e)this._inputEl.setAttribute("aria-labelledby",`${this._uid}-label`),this._inputEl.removeAttribute("aria-label");else{this._inputEl.removeAttribute("aria-labelledby");const i=(this.getAttribute("aria-label")||"").trim();i?this._inputEl.setAttribute("aria-label",i):this._inputEl.removeAttribute("aria-label")}c.hidden=!this.hasAttribute("required"),p.hidden=!t,p.textContent=t,x.hidden=!s,x.textContent=s,x.id=`${this._uid}-error`,K.syncControlDescription(this._inputEl,this,this._uid,[t?`${this._uid}-description`:"",s?`${this._uid}-error`:""].filter(Boolean)),this._shellEl.setAttribute("data-open",this.open?"true":"false"),this._shellEl.setAttribute("data-invalid",s?"true":"false"),this._shellEl.setAttribute("data-readonly",b?"true":"false"),m?this._shellEl.setAttribute("aria-disabled","true"):this._shellEl.removeAttribute("aria-disabled"),S.setAttribute("data-open",this.open?"true":"false"),S.disabled=m||b,C.hidden=!F||this._selected.length===0,C.disabled=m||b,this._inputEl.setAttribute("aria-expanded",this.open?"true":"false"),this._inputEl.setAttribute("aria-busy",U?"true":"false"),this._inputEl.placeholder=this._selected.length?"":this.getAttribute("placeholder")||"Select options",this._inputEl.disabled=m,this._inputEl.readOnly=b,this._inputEl.value!==this._query&&(this._inputEl.value=this._query),this.open?this._attachOutsideListener():this._detachOutsideListener(),D.replaceChildren(...this._selectedOptionRecords().map(i=>{const h=document.createElement("span");h.className="chip",h.textContent=i.label;const d=document.createElement("button");return d.type="button",d.className="chip-remove",d.setAttribute("data-value",i.value),d.setAttribute("aria-label",`Remove ${i.label}`),d.textContent="×",d.disabled=this.hasAttribute("disabled"),d.addEventListener("pointerdown",o=>{o.preventDefault()}),d.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),this._removeChip(i.value),this._inputEl?.focus()}),h.append(d),h}));const _=this._filteredOptions(),$=this._renderLimit(),y=_.slice(0,$),B=_.length>y.length;if(O.setPanelOpen(this._panelEl,this.open,"bottom"),U){const i=document.createElement("div");i.className="status",i.textContent=V,this._panelEl.replaceChildren(i),this._inputEl.removeAttribute("aria-activedescendant");return}if(!_.length){const i=document.createElement("div");i.className="status",i.textContent="No matching options",this._panelEl.replaceChildren(i),this._inputEl.removeAttribute("aria-activedescendant");return}const P=new Set(this._selected),T=this._panelEl.getActiveItem()?.getAttribute("data-value"),g=[];let E=null;if(y.forEach((i,h)=>{if(i.group&&i.group!==E){const u=document.createElement("div");u.className="group",u.setAttribute("role","presentation"),u.textContent=i.group,g.push(u),E=i.group}else i.group||(E=null);const d=P.has(i.value),o=document.createElement("button");o.className="option",o.type="button",o.id=`${this._uid}-option-${h}`,o.setAttribute("role","option"),o.setAttribute("data-value",i.value),o.setAttribute("data-selected",String(d)),o.setAttribute("data-indicator",q),o.setAttribute("aria-selected",d?"true":"false"),(i.disabled||m||b)&&(o.disabled=!0),o.addEventListener("pointerdown",u=>{u.preventDefault()}),o.addEventListener("click",u=>{u.preventDefault(),!i.disabled&&(this._activeValue=i.value,this._toggleValue(i.value,"option"),this._query="",this._inputEl&&(this._inputEl.value=""),this._inputEl?.focus())});const f=document.createElement("div");f.className="option-text";const w=document.createElement("span");if(w.className="option-label",w.textContent=i.label,f.append(w),i.description){const u=document.createElement("span");u.className="option-description",u.textContent=i.description,f.append(u)}if(q!=="none"){const u=document.createElement("span");u.className="check",u.textContent=d?"✓":"",o.append(u)}o.append(f),g.push(o)}),B){const i=document.createElement("div");i.className="status",i.textContent=`Showing first ${y.length} results. Keep typing to narrow the list.`,g.push(i)}this._panelEl.replaceChildren(...g);const R=T||this._activeValue||this._selected[this._selected.length-1]||null,A=this._findOptionNode(R),k=A&&!A.hasAttribute("disabled")?this._panelEl.setActiveItem(A,{focus:!1,owner:this._inputEl,scroll:!1}):(this._panelEl.clearActive(),null);this._activeValue=k?.getAttribute("data-value")||null,k?.id?this._inputEl.setAttribute("aria-activedescendant",k.id):this._inputEl.removeAttribute("aria-activedescendant")}finally{this._isSyncingUi=!1,this._needsSyncUi&&(this._needsSyncUi=!1,this._syncUi())}}}}typeof customElements<"u"&&!customElements.get("ui-multi-select")&&customElements.define("ui-multi-select",N);exports.UIMultiSelect=N;
|
|
562
|
+
`),this._options=I(this.getAttribute("options")),this._selected=v(this.getAttribute("value")),this._shellEl=this.root.querySelector(".shell"),this._inputEl=this.root.querySelector(".input"),this._panelEl=this.root.querySelector(".panel"),this._inputEl?.addEventListener("input",this._onInput),this._inputEl?.addEventListener("keydown",this._onKeyDown),this.root.querySelector(".toggle")?.addEventListener("click",this._onToggle),this.root.querySelector(".clear")?.addEventListener("click",()=>this._clearSelection("clear-button")),this._shellEl?.addEventListener("focusin",this._onFocusIn),this._shellEl?.addEventListener("focusout",this._onFocusOut),this._syncVisualState(),this._syncUi()}_syncVisualState(){const e=L(this.getAttribute("radius")||this.getAttribute("shape"));e?this.style.setProperty("--ui-multi-select-radius",e):this.style.removeProperty("--ui-multi-select-radius");const t=L(this.getAttribute("option-radius"));t?this.style.setProperty("--ui-multi-select-option-radius",t):this.style.removeProperty("--ui-multi-select-option-radius");const s=H(this.getAttribute("size"));this.setAttribute("data-size",s)}_selectionIndicator(){const e=(this.getAttribute("selection-indicator")||"checkbox").trim().toLowerCase();return e==="none"||e==="check"?e:"checkbox"}_isInteractionLocked(){return this.hasAttribute("disabled")||this.hasAttribute("readonly")}_attachOutsideListener(){this._outsidePointerDown||typeof document>"u"||(this._outsidePointerDown=e=>{const t=e.composedPath();t.includes(this)||t.includes(this.root)||this._panelEl&&t.includes(this._panelEl)||this._inputEl&&t.includes(this._inputEl)||(this.open=!1,this._syncUi())},document.addEventListener("pointerdown",this._outsidePointerDown))}_detachOutsideListener(){!this._outsidePointerDown||typeof document>"u"||(document.removeEventListener("pointerdown",this._outsidePointerDown),this._outsidePointerDown=null)}_filteredOptions(){const e=S.normalizeCollectionText(this._query);return e?this._options.filter(t=>S.normalizeCollectionText(t.label).includes(e)||S.normalizeCollectionText(t.value).includes(e)):this._options}_renderLimit(){const e=Number(this.getAttribute("render-limit"));return Number.isFinite(e)&&e>0?e:200}_findOptionNode(e){return!e||!this._panelEl?null:Array.from(this._panelEl.querySelectorAll(".option")).find(t=>t.getAttribute("data-value")===e)}_selectedOptionRecords(){return this._selected.map(e=>this._options.find(t=>t.value===e)).filter(Boolean)}_emitChange(e,t){this.dispatchEvent(new CustomEvent("change",{detail:{value:[...this._selected],previousValue:t,selectedItems:this._selectedOptionRecords(),source:e},bubbles:!0,composed:!0}))}_setSelected(e,t){const s=Number(this.getAttribute("max-selections")),l=[];e.forEach(c=>{if(!c)return;const p=l.indexOf(c);p>=0&&l.splice(p,1),l.push(c)});const n=Number.isFinite(s)&&s>0?l.slice(-s):l,a=[...this._selected];if(a.length===n.length&&a.every((c,p)=>c===n[p])){this._syncUi();return}this._selected=n,this._selected.length?this.setAttribute("value",JSON.stringify(this._selected)):this.removeAttribute("value"),this._syncUi(),this._emitChange(t,a)}_toggleValue(e,t){if(this._isInteractionLocked()||this.hasAttribute("loading"))return;const l=this._selected.includes(e)?this._selected.filter(n=>n!==e):[...this._selected,e];this._activeValue=e,this._setSelected(l,t)}_removeChip(e){this._isInteractionLocked()||(this._activeValue===e&&(this._activeValue=null),this._toggleValue(e,"remove-chip"))}_clearSelection(e){if(!(this._isInteractionLocked()||!this._selected.length)){this._activeValue=null,this._setSelected([],e),this._query="",this._inputEl&&(this._inputEl.value="");try{this._inputEl?.focus({preventScroll:!0})}catch{this._inputEl?.focus()}}}_registerWithForm(){this._formUnregister&&(this._formUnregister(),this._formUnregister=null);try{const l=this.getRootNode().host?.closest?.("ui-form")||null||this.closest("ui-form"),n=this.getAttribute("name");l&&typeof l.registerField=="function"&&n&&(this._formUnregister=l.registerField(n,{name:n,getValue:()=>[...this._selected],setValue:a=>{Array.isArray(a)?this._setSelected(a.map(c=>String(c)),"form"):this._setSelected(v(String(a??"")),"form")},validate:async()=>this.hasAttribute("required")&&this._selected.length===0?{valid:!1,message:"At least one option is required"}:{valid:!0},setError:a=>{a?this.setAttribute("data-error",a):this.removeAttribute("data-error"),this._syncUi()}}))}catch{}}_onInput(e){this._isInteractionLocked()||(this._query=e.target?.value||"",this.open||(this.open=!0),this._syncUi())}_onKeyDown(e){if(!this._isInteractionLocked()){if(e.key==="ArrowDown"){e.preventDefault(),this.open||(this.open=!0),this._syncUi(),this._panelEl?.getActiveItem()?this._panelEl.move(1,{focus:!1,owner:this._inputEl,scroll:!1}):this._panelEl?.focusBoundary("first",{focus:!1,owner:this._inputEl,scroll:!1});return}if(e.key==="ArrowUp"){e.preventDefault(),this.open||(this.open=!0),this._syncUi(),this._panelEl?.getActiveItem()?this._panelEl.move(-1,{focus:!1,owner:this._inputEl,scroll:!1}):this._panelEl?.focusBoundary("last",{focus:!1,owner:this._inputEl,scroll:!1});return}if(e.key==="Home"){e.preventDefault(),this.open||(this.open=!0),this._syncUi(),this._panelEl?.focusBoundary("first",{focus:!1,owner:this._inputEl,scroll:!1});return}if(e.key==="End"){e.preventDefault(),this.open||(this.open=!0),this._syncUi(),this._panelEl?.focusBoundary("last",{focus:!1,owner:this._inputEl,scroll:!1});return}if(e.key==="Enter"){const t=this._panelEl?.getActiveItem();if(t){e.preventDefault();const s=t.getAttribute("data-value");s&&(this._activeValue=s,this._toggleValue(s,"keyboard"),this._query="",this._inputEl&&(this._inputEl.value=""),this._inputEl?.focus())}return}if(e.key==="Escape"){e.preventDefault(),this._query?(this._query="",this._inputEl&&(this._inputEl.value="")):this.open=!1,this._syncUi();return}if(e.key==="Tab"){this.open=!1,this._syncUi();return}e.key==="Backspace"&&!this._query&&this._selected.length&&this._removeChip(this._selected[this._selected.length-1])}}_onToggle(){this._isInteractionLocked()||(this.open=!this.open,this._syncUi(),this.open&&this._inputEl?.focus())}_onFocusIn(){this._isInteractionLocked()||(this.open=!0),this._syncUi()}_onFocusOut(e){this._shellEl?.contains(e.relatedTarget)||(this.open=!1,this._syncUi())}_syncUi(){if(this._isSyncingUi){this._needsSyncUi=!0;return}if(!(!this._shellEl||!this._inputEl||!this._panelEl)){this._isSyncingUi=!0;try{const e=(this.getAttribute("label")||"").trim(),t=(this.getAttribute("description")||"").trim(),s=(this.getAttribute("data-error")||"").trim(),l=this.root.querySelector(".meta"),n=this.root.querySelector(".label"),a=this.root.querySelector(".label-text"),c=this.root.querySelector(".required"),p=this.root.querySelector(".description"),D=this.root.querySelector(".chips"),C=this.root.querySelector(".toggle"),q=this.root.querySelector(".clear"),x=this.root.querySelector(".error"),U=this._selectionIndicator(),_=this.hasAttribute("loading"),V=(this.getAttribute("loading-text")||"Loading options...").trim(),m=this.hasAttribute("disabled"),b=this.hasAttribute("readonly"),F=this.hasAttribute("clearable");if(l.hidden=!e&&!t,n.hidden=!e,a.textContent=e,e)this._inputEl.setAttribute("aria-labelledby",`${this._uid}-label`),this._inputEl.removeAttribute("aria-label");else{this._inputEl.removeAttribute("aria-labelledby");const i=(this.getAttribute("aria-label")||"").trim();i?this._inputEl.setAttribute("aria-label",i):this._inputEl.removeAttribute("aria-label")}c.hidden=!this.hasAttribute("required"),p.hidden=!t,p.textContent=t,x.hidden=!s,x.textContent=s,x.id=`${this._uid}-error`,K.syncControlDescription(this._inputEl,this,this._uid,[t?`${this._uid}-description`:"",s?`${this._uid}-error`:""].filter(Boolean)),this._shellEl.setAttribute("data-open",this.open?"true":"false"),this._shellEl.setAttribute("data-invalid",s?"true":"false"),this._shellEl.setAttribute("data-readonly",b?"true":"false"),m?this._shellEl.setAttribute("aria-disabled","true"):this._shellEl.removeAttribute("aria-disabled"),C.setAttribute("data-open",this.open?"true":"false"),C.disabled=m||b,q.hidden=!F||this._selected.length===0,q.disabled=m||b,this._inputEl.setAttribute("aria-expanded",this.open?"true":"false"),this._inputEl.setAttribute("aria-busy",_?"true":"false"),this._inputEl.placeholder=this._selected.length?"":this.getAttribute("placeholder")||"Select options",this._inputEl.disabled=m,this._inputEl.readOnly=b,this._inputEl.value!==this._query&&(this._inputEl.value=this._query),this.open?this._attachOutsideListener():this._detachOutsideListener(),D.replaceChildren(...this._selectedOptionRecords().map(i=>{const h=document.createElement("span");h.className="chip",h.textContent=i.label;const d=document.createElement("button");return d.type="button",d.className="chip-remove",d.setAttribute("data-value",i.value),d.setAttribute("aria-label",`Remove ${i.label}`),d.textContent="×",d.disabled=this.hasAttribute("disabled"),d.addEventListener("pointerdown",o=>{o.preventDefault()}),d.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),this._removeChip(i.value),this._inputEl?.focus()}),h.append(d),h}));const y=this._filteredOptions(),$=this._renderLimit(),E=y.slice(0,$),B=y.length>E.length;if(O.setPanelOpen(this._panelEl,this.open,"bottom"),_?this._panelEl.setAttribute("aria-busy","true"):this._panelEl.removeAttribute("aria-busy"),_){const i=document.createElement("div");i.className="status",i.textContent=V,this._panelEl.replaceChildren(i),this._inputEl.removeAttribute("aria-activedescendant");return}if(!y.length){const i=document.createElement("div");i.className="status",i.setAttribute("role","option"),i.setAttribute("aria-disabled","true"),i.setAttribute("aria-selected","false"),i.textContent="No matching options",this._panelEl.replaceChildren(i),this._inputEl.removeAttribute("aria-activedescendant");return}const P=new Set(this._selected),T=this._panelEl.getActiveItem()?.getAttribute("data-value"),g=[];let A=null;if(E.forEach((i,h)=>{if(i.group&&i.group!==A){const u=document.createElement("div");u.className="group",u.setAttribute("role","presentation"),u.textContent=i.group,g.push(u),A=i.group}else i.group||(A=null);const d=P.has(i.value),o=document.createElement("button");o.className="option",o.type="button",o.id=`${this._uid}-option-${h}`,o.setAttribute("role","option"),o.setAttribute("data-value",i.value),o.setAttribute("data-selected",String(d)),o.setAttribute("data-indicator",U),o.setAttribute("aria-selected",d?"true":"false"),(i.disabled||m||b)&&(o.disabled=!0),o.addEventListener("pointerdown",u=>{u.preventDefault()}),o.addEventListener("click",u=>{u.preventDefault(),!i.disabled&&(this._activeValue=i.value,this._toggleValue(i.value,"option"),this._query="",this._inputEl&&(this._inputEl.value=""),this._inputEl?.focus())});const f=document.createElement("div");f.className="option-text";const z=document.createElement("span");if(z.className="option-label",z.textContent=i.label,f.append(z),i.description){const u=document.createElement("span");u.className="option-description",u.textContent=i.description,f.append(u)}if(U!=="none"){const u=document.createElement("span");u.className="check",u.textContent=d?"✓":"",o.append(u)}o.append(f),g.push(o)}),B){const i=document.createElement("div");i.className="status",i.textContent=`Showing first ${E.length} results. Keep typing to narrow the list.`,g.push(i)}this._panelEl.replaceChildren(...g);const R=T||this._activeValue||this._selected[this._selected.length-1]||null,k=this._findOptionNode(R),w=k&&!k.hasAttribute("disabled")?this._panelEl.setActiveItem(k,{focus:!1,owner:this._inputEl,scroll:!1}):(this._panelEl.clearActive(),null);this._activeValue=w?.getAttribute("data-value")||null,w?.id?this._inputEl.setAttribute("aria-activedescendant",w.id):this._inputEl.removeAttribute("aria-activedescendant")}finally{this._isSyncingUi=!1,this._needsSyncUi&&(this._needsSyncUi=!1,this._syncUi())}}}}typeof customElements<"u"&&!customElements.get("ui-multi-select")&&customElements.define("ui-multi-select",N);exports.UIMultiSelect=N;
|
package/dist/multi-select.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { E as T } from "./ElementBase-BeZT54Hj.mjs";
|
|
2
2
|
import { O as R, s as K } from "./overlay-motion-BX3dPLay.mjs";
|
|
3
3
|
import { a as M } from "./control-name-Bpj7F34X.mjs";
|
|
4
|
-
import { n as
|
|
4
|
+
import { n as S } from "./collection-C7URGjEI.mjs";
|
|
5
5
|
import "./listbox-hMVOhKHC.mjs";
|
|
6
6
|
let W = 0;
|
|
7
7
|
const H = `
|
|
@@ -15,10 +15,10 @@ const H = `
|
|
|
15
15
|
--ui-multi-select-text: var(--ui-color-text, var(--ui-text, #0f172a));
|
|
16
16
|
--ui-multi-select-muted: var(--ui-color-muted, var(--ui-muted, #526175));
|
|
17
17
|
--ui-multi-select-focus: var(--ui-color-focus-ring, #2563eb);
|
|
18
|
-
--ui-multi-select-danger: var(--ui-color-danger, #dc2626);
|
|
18
|
+
--ui-multi-select-danger: var(--ui-color-danger-text, var(--ui-color-danger, #dc2626));
|
|
19
19
|
--ui-multi-select-accent: var(--ui-color-primary, #2563eb);
|
|
20
20
|
--ui-multi-select-chip-bg: color-mix(in srgb, var(--ui-color-primary, #2563eb) 10%, transparent);
|
|
21
|
-
--ui-multi-select-chip-text: color-mix(in srgb, var(--ui-color-primary, #2563eb)
|
|
21
|
+
--ui-multi-select-chip-text: color-mix(in srgb, var(--ui-color-primary, #2563eb) 45%, var(--ui-color-text-strong, #0f172a));
|
|
22
22
|
--ui-multi-select-panel-bg: var(--base-multi-select-panel-bg, color-mix(in srgb, var(--ui-multi-select-bg) 98%, transparent));
|
|
23
23
|
--ui-multi-select-panel-border: var(--base-multi-select-panel-border, 1px solid color-mix(in srgb, var(--ui-multi-select-border-color) 84%, transparent));
|
|
24
24
|
--ui-multi-select-panel-shadow: var(--base-multi-select-panel-shadow, var(--shadow-4, 0 20px 34px rgba(2, 6, 23, 0.16)));
|
|
@@ -525,21 +525,21 @@ const H = `
|
|
|
525
525
|
--ui-multi-select-accent: var(--ui-color-success, #15803d);
|
|
526
526
|
--ui-multi-select-focus: var(--ui-color-success, #15803d);
|
|
527
527
|
--ui-multi-select-chip-bg: color-mix(in srgb, var(--ui-color-success, #15803d) 12%, transparent);
|
|
528
|
-
--ui-multi-select-chip-text: color-mix(in srgb, var(--ui-color-success, #15803d) 82%, #0f172a 18%);
|
|
528
|
+
--ui-multi-select-chip-text: var(--ui-color-success-text, color-mix(in srgb, var(--ui-color-success, #15803d) 82%, #0f172a 18%));
|
|
529
529
|
}
|
|
530
530
|
|
|
531
531
|
:host([tone="warning"]) {
|
|
532
532
|
--ui-multi-select-accent: var(--ui-color-warning, #b45309);
|
|
533
533
|
--ui-multi-select-focus: var(--ui-color-warning, #b45309);
|
|
534
534
|
--ui-multi-select-chip-bg: color-mix(in srgb, var(--ui-color-warning, #b45309) 12%, transparent);
|
|
535
|
-
--ui-multi-select-chip-text: color-mix(in srgb, var(--ui-color-warning, #b45309) 82%, #0f172a 18%);
|
|
535
|
+
--ui-multi-select-chip-text: var(--ui-color-warning-text, color-mix(in srgb, var(--ui-color-warning, #b45309) 82%, #0f172a 18%));
|
|
536
536
|
}
|
|
537
537
|
|
|
538
538
|
:host([tone="danger"]) {
|
|
539
539
|
--ui-multi-select-accent: var(--ui-color-danger, #dc2626);
|
|
540
540
|
--ui-multi-select-focus: var(--ui-color-danger, #dc2626);
|
|
541
541
|
--ui-multi-select-chip-bg: color-mix(in srgb, var(--ui-color-danger, #dc2626) 12%, transparent);
|
|
542
|
-
--ui-multi-select-chip-text: color-mix(in srgb, var(--ui-color-danger, #dc2626) 82%, #0f172a 18%);
|
|
542
|
+
--ui-multi-select-chip-text: var(--ui-color-danger-text, color-mix(in srgb, var(--ui-color-danger, #dc2626) 82%, #0f172a 18%));
|
|
543
543
|
}
|
|
544
544
|
`;
|
|
545
545
|
function q(r) {
|
|
@@ -711,8 +711,8 @@ class J extends T {
|
|
|
711
711
|
!this._outsidePointerDown || typeof document > "u" || (document.removeEventListener("pointerdown", this._outsidePointerDown), this._outsidePointerDown = null);
|
|
712
712
|
}
|
|
713
713
|
_filteredOptions() {
|
|
714
|
-
const e =
|
|
715
|
-
return e ? this._options.filter((t) =>
|
|
714
|
+
const e = S(this._query);
|
|
715
|
+
return e ? this._options.filter((t) => S(t.label).includes(e) || S(t.value).includes(e)) : this._options;
|
|
716
716
|
}
|
|
717
717
|
_renderLimit() {
|
|
718
718
|
const e = Number(this.getAttribute("render-limit"));
|
|
@@ -846,7 +846,7 @@ class J extends T {
|
|
|
846
846
|
if (!(!this._shellEl || !this._inputEl || !this._panelEl)) {
|
|
847
847
|
this._isSyncingUi = !0;
|
|
848
848
|
try {
|
|
849
|
-
const e = (this.getAttribute("label") || "").trim(), t = (this.getAttribute("description") || "").trim(), s = (this.getAttribute("data-error") || "").trim(), l = this.root.querySelector(".meta"), n = this.root.querySelector(".label"), a = this.root.querySelector(".label-text"), c = this.root.querySelector(".required"), p = this.root.querySelector(".description"), O = this.root.querySelector(".chips"),
|
|
849
|
+
const e = (this.getAttribute("label") || "").trim(), t = (this.getAttribute("description") || "").trim(), s = (this.getAttribute("data-error") || "").trim(), l = this.root.querySelector(".meta"), n = this.root.querySelector(".label"), a = this.root.querySelector(".label-text"), c = this.root.querySelector(".required"), p = this.root.querySelector(".description"), O = this.root.querySelector(".chips"), C = this.root.querySelector(".toggle"), U = this.root.querySelector(".clear"), x = this.root.querySelector(".error"), I = this._selectionIndicator(), _ = this.hasAttribute("loading"), N = (this.getAttribute("loading-text") || "Loading options...").trim(), m = this.hasAttribute("disabled"), b = this.hasAttribute("readonly"), D = this.hasAttribute("clearable");
|
|
850
850
|
if (l.hidden = !e && !t, n.hidden = !e, a.textContent = e, e)
|
|
851
851
|
this._inputEl.setAttribute("aria-labelledby", `${this._uid}-label`), this._inputEl.removeAttribute("aria-label");
|
|
852
852
|
else {
|
|
@@ -859,7 +859,7 @@ class J extends T {
|
|
|
859
859
|
this,
|
|
860
860
|
this._uid,
|
|
861
861
|
[t ? `${this._uid}-description` : "", s ? `${this._uid}-error` : ""].filter(Boolean)
|
|
862
|
-
), this._shellEl.setAttribute("data-open", this.open ? "true" : "false"), this._shellEl.setAttribute("data-invalid", s ? "true" : "false"), this._shellEl.setAttribute("data-readonly", b ? "true" : "false"), m ? this._shellEl.setAttribute("aria-disabled", "true") : this._shellEl.removeAttribute("aria-disabled"),
|
|
862
|
+
), this._shellEl.setAttribute("data-open", this.open ? "true" : "false"), this._shellEl.setAttribute("data-invalid", s ? "true" : "false"), this._shellEl.setAttribute("data-readonly", b ? "true" : "false"), m ? this._shellEl.setAttribute("aria-disabled", "true") : this._shellEl.removeAttribute("aria-disabled"), C.setAttribute("data-open", this.open ? "true" : "false"), C.disabled = m || b, U.hidden = !D || this._selected.length === 0, U.disabled = m || b, this._inputEl.setAttribute("aria-expanded", this.open ? "true" : "false"), this._inputEl.setAttribute("aria-busy", _ ? "true" : "false"), this._inputEl.placeholder = this._selected.length ? "" : this.getAttribute("placeholder") || "Select options", this._inputEl.disabled = m, this._inputEl.readOnly = b, this._inputEl.value !== this._query && (this._inputEl.value = this._query), this.open ? this._attachOutsideListener() : this._detachOutsideListener(), O.replaceChildren(...this._selectedOptionRecords().map((i) => {
|
|
863
863
|
const h = document.createElement("span");
|
|
864
864
|
h.className = "chip", h.textContent = i.label;
|
|
865
865
|
const d = document.createElement("button");
|
|
@@ -869,49 +869,49 @@ class J extends T {
|
|
|
869
869
|
o.preventDefault(), o.stopPropagation(), this._removeChip(i.value), this._inputEl?.focus();
|
|
870
870
|
}), h.append(d), h;
|
|
871
871
|
}));
|
|
872
|
-
const
|
|
873
|
-
if (K(this._panelEl, this.open, "bottom"),
|
|
872
|
+
const y = this._filteredOptions(), V = this._renderLimit(), E = y.slice(0, V), F = y.length > E.length;
|
|
873
|
+
if (K(this._panelEl, this.open, "bottom"), _ ? this._panelEl.setAttribute("aria-busy", "true") : this._panelEl.removeAttribute("aria-busy"), _) {
|
|
874
874
|
const i = document.createElement("div");
|
|
875
875
|
i.className = "status", i.textContent = N, this._panelEl.replaceChildren(i), this._inputEl.removeAttribute("aria-activedescendant");
|
|
876
876
|
return;
|
|
877
877
|
}
|
|
878
|
-
if (!
|
|
878
|
+
if (!y.length) {
|
|
879
879
|
const i = document.createElement("div");
|
|
880
|
-
i.className = "status", i.textContent = "No matching options", this._panelEl.replaceChildren(i), this._inputEl.removeAttribute("aria-activedescendant");
|
|
880
|
+
i.className = "status", i.setAttribute("role", "option"), i.setAttribute("aria-disabled", "true"), i.setAttribute("aria-selected", "false"), i.textContent = "No matching options", this._panelEl.replaceChildren(i), this._inputEl.removeAttribute("aria-activedescendant");
|
|
881
881
|
return;
|
|
882
882
|
}
|
|
883
883
|
const $ = new Set(this._selected), B = this._panelEl.getActiveItem()?.getAttribute("data-value"), g = [];
|
|
884
|
-
let
|
|
885
|
-
if (
|
|
886
|
-
if (i.group && i.group !==
|
|
884
|
+
let A = null;
|
|
885
|
+
if (E.forEach((i, h) => {
|
|
886
|
+
if (i.group && i.group !== A) {
|
|
887
887
|
const u = document.createElement("div");
|
|
888
|
-
u.className = "group", u.setAttribute("role", "presentation"), u.textContent = i.group, g.push(u),
|
|
889
|
-
} else i.group || (
|
|
888
|
+
u.className = "group", u.setAttribute("role", "presentation"), u.textContent = i.group, g.push(u), A = i.group;
|
|
889
|
+
} else i.group || (A = null);
|
|
890
890
|
const d = $.has(i.value), o = document.createElement("button");
|
|
891
|
-
o.className = "option", o.type = "button", o.id = `${this._uid}-option-${h}`, o.setAttribute("role", "option"), o.setAttribute("data-value", i.value), o.setAttribute("data-selected", String(d)), o.setAttribute("data-indicator",
|
|
891
|
+
o.className = "option", o.type = "button", o.id = `${this._uid}-option-${h}`, o.setAttribute("role", "option"), o.setAttribute("data-value", i.value), o.setAttribute("data-selected", String(d)), o.setAttribute("data-indicator", I), o.setAttribute("aria-selected", d ? "true" : "false"), (i.disabled || m || b) && (o.disabled = !0), o.addEventListener("pointerdown", (u) => {
|
|
892
892
|
u.preventDefault();
|
|
893
893
|
}), o.addEventListener("click", (u) => {
|
|
894
894
|
u.preventDefault(), !i.disabled && (this._activeValue = i.value, this._toggleValue(i.value, "option"), this._query = "", this._inputEl && (this._inputEl.value = ""), this._inputEl?.focus());
|
|
895
895
|
});
|
|
896
896
|
const f = document.createElement("div");
|
|
897
897
|
f.className = "option-text";
|
|
898
|
-
const
|
|
899
|
-
if (
|
|
898
|
+
const z = document.createElement("span");
|
|
899
|
+
if (z.className = "option-label", z.textContent = i.label, f.append(z), i.description) {
|
|
900
900
|
const u = document.createElement("span");
|
|
901
901
|
u.className = "option-description", u.textContent = i.description, f.append(u);
|
|
902
902
|
}
|
|
903
|
-
if (
|
|
903
|
+
if (I !== "none") {
|
|
904
904
|
const u = document.createElement("span");
|
|
905
905
|
u.className = "check", u.textContent = d ? "✓" : "", o.append(u);
|
|
906
906
|
}
|
|
907
907
|
o.append(f), g.push(o);
|
|
908
908
|
}), F) {
|
|
909
909
|
const i = document.createElement("div");
|
|
910
|
-
i.className = "status", i.textContent = `Showing first ${
|
|
910
|
+
i.className = "status", i.textContent = `Showing first ${E.length} results. Keep typing to narrow the list.`, g.push(i);
|
|
911
911
|
}
|
|
912
912
|
this._panelEl.replaceChildren(...g);
|
|
913
|
-
const P = B || this._activeValue || this._selected[this._selected.length - 1] || null,
|
|
914
|
-
this._activeValue =
|
|
913
|
+
const P = B || this._activeValue || this._selected[this._selected.length - 1] || null, k = this._findOptionNode(P), w = k && !k.hasAttribute("disabled") ? this._panelEl.setActiveItem(k, { focus: !1, owner: this._inputEl, scroll: !1 }) : (this._panelEl.clearActive(), null);
|
|
914
|
+
this._activeValue = w?.getAttribute("data-value") || null, w?.id ? this._inputEl.setAttribute("aria-activedescendant", w.id) : this._inputEl.removeAttribute("aria-activedescendant");
|
|
915
915
|
} finally {
|
|
916
916
|
this._isSyncingUi = !1, this._needsSyncUi && (this._needsSyncUi = !1, this._syncUi());
|
|
917
917
|
}
|
package/dist/number-field.cjs.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
--ui-number-field-color: var(--ui-color-text, var(--ui-text, #0f172a));
|
|
16
16
|
--ui-number-field-muted: var(--ui-color-muted, var(--ui-muted, #526175));
|
|
17
17
|
--ui-number-field-focus: var(--ui-color-focus-ring, var(--ui-focus-ring, #2563eb));
|
|
18
|
-
--ui-number-field-danger: var(--ui-color-danger, var(--ui-error, #dc2626));
|
|
18
|
+
--ui-number-field-danger: var(--ui-color-danger-text, var(--ui-color-danger, var(--ui-error, #dc2626)));
|
|
19
19
|
--ui-number-field-shadow: none;
|
|
20
20
|
--ui-number-field-gap: 8px;
|
|
21
21
|
--ui-number-field-shell-gap: 8px;
|
package/dist/number-field.esm.js
CHANGED
|
@@ -17,7 +17,7 @@ const N = `
|
|
|
17
17
|
--ui-number-field-color: var(--ui-color-text, var(--ui-text, #0f172a));
|
|
18
18
|
--ui-number-field-muted: var(--ui-color-muted, var(--ui-muted, #526175));
|
|
19
19
|
--ui-number-field-focus: var(--ui-color-focus-ring, var(--ui-focus-ring, #2563eb));
|
|
20
|
-
--ui-number-field-danger: var(--ui-color-danger, var(--ui-error, #dc2626));
|
|
20
|
+
--ui-number-field-danger: var(--ui-color-danger-text, var(--ui-color-danger, var(--ui-error, #dc2626)));
|
|
21
21
|
--ui-number-field-shadow: none;
|
|
22
22
|
--ui-number-field-gap: 8px;
|
|
23
23
|
--ui-number-field-shell-gap: 8px;
|
|
@@ -54,19 +54,19 @@
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
:host([tone="info"]) {
|
|
57
|
-
--ui-number-ticker-color: var(--ui-color-info, #0e7490);
|
|
57
|
+
--ui-number-ticker-color: var(--ui-color-info-text, var(--ui-color-info, #0e7490));
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
:host([tone="success"]) {
|
|
61
|
-
--ui-number-ticker-color: var(--ui-color-success, #15803d);
|
|
61
|
+
--ui-number-ticker-color: var(--ui-color-success-text, var(--ui-color-success, #15803d));
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
:host([tone="warning"]) {
|
|
65
|
-
--ui-number-ticker-color: var(--ui-color-warning, #b45309);
|
|
65
|
+
--ui-number-ticker-color: var(--ui-color-warning-text, var(--ui-color-warning, #b45309));
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
:host([tone="danger"]) {
|
|
69
|
-
--ui-number-ticker-color: var(--ui-color-danger, #dc2626);
|
|
69
|
+
--ui-number-ticker-color: var(--ui-color-danger-text, var(--ui-color-danger, #dc2626));
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
:host([align="left"]),
|
|
@@ -84,19 +84,19 @@ const y = 1200, v = 0, I = "ease-out", O = "decimal", A = 0, S = 0.4, F = 6, L =
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
:host([tone="info"]) {
|
|
87
|
-
--ui-number-ticker-color: var(--ui-color-info, #0e7490);
|
|
87
|
+
--ui-number-ticker-color: var(--ui-color-info-text, var(--ui-color-info, #0e7490));
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
:host([tone="success"]) {
|
|
91
|
-
--ui-number-ticker-color: var(--ui-color-success, #15803d);
|
|
91
|
+
--ui-number-ticker-color: var(--ui-color-success-text, var(--ui-color-success, #15803d));
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
:host([tone="warning"]) {
|
|
95
|
-
--ui-number-ticker-color: var(--ui-color-warning, #b45309);
|
|
95
|
+
--ui-number-ticker-color: var(--ui-color-warning-text, var(--ui-color-warning, #b45309));
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
:host([tone="danger"]) {
|
|
99
|
-
--ui-number-ticker-color: var(--ui-color-danger, #dc2626);
|
|
99
|
+
--ui-number-ticker-color: var(--ui-color-danger-text, var(--ui-color-danger, #dc2626));
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
:host([align="left"]),
|
|
@@ -384,7 +384,7 @@ class W extends M {
|
|
|
384
384
|
this._renderValue(this._animationFrom), this._setState("running"), this._frame = this._requestFrame(this._tick);
|
|
385
385
|
return;
|
|
386
386
|
}
|
|
387
|
-
const n = c((i - this._animationDelay) / Math.max(this._animationDuration, 1), 0, 1), r = nt(
|
|
387
|
+
const n = c((i - this._animationDelay) / Math.max(this._animationDuration, 1), 0, 1), r = nt(k(this.getAttribute("easing")), n), s = this._animationFrom + (this._animationTo - this._animationFrom) * r;
|
|
388
388
|
if (this._currentValue = s, this._renderValue(s), n >= 1) {
|
|
389
389
|
this._animationPrepared = !1, this._animationStartTime = 0, this._pausedElapsed = 0, this._currentValue = this._animationTo, this._renderValue(this._animationTo), this._setState("completed");
|
|
390
390
|
return;
|
|
@@ -436,7 +436,7 @@ class W extends M {
|
|
|
436
436
|
prefix: i,
|
|
437
437
|
suffix: n,
|
|
438
438
|
locale: this.getAttribute("locale") || void 0,
|
|
439
|
-
formatStyle:
|
|
439
|
+
formatStyle: x(this.getAttribute("format-style")),
|
|
440
440
|
currency: this.getAttribute("currency") || void 0,
|
|
441
441
|
notation: w(this.getAttribute("notation")),
|
|
442
442
|
signDisplay: z(this.getAttribute("sign-display")),
|
|
@@ -453,7 +453,7 @@ class W extends M {
|
|
|
453
453
|
return s;
|
|
454
454
|
}
|
|
455
455
|
_createFormatter() {
|
|
456
|
-
const t =
|
|
456
|
+
const t = x(this.getAttribute("format-style")), i = this.getAttribute("locale") || void 0, n = D(
|
|
457
457
|
this.getAttribute("fraction-digits"),
|
|
458
458
|
this.getAttribute("value"),
|
|
459
459
|
this.getAttribute("from")
|
|
@@ -485,7 +485,7 @@ class W extends M {
|
|
|
485
485
|
this.style.setProperty(
|
|
486
486
|
"--ui-number-ticker-roll-duration",
|
|
487
487
|
`${Math.round(c(this._animationDuration * 0.55, 180, 900))}ms`
|
|
488
|
-
), this.style.setProperty("--ui-number-ticker-roll-ease", at(
|
|
488
|
+
), this.style.setProperty("--ui-number-ticker-roll-ease", at(k(this.getAttribute("easing"))));
|
|
489
489
|
}
|
|
490
490
|
_resolvedTargetValue() {
|
|
491
491
|
return b(this.getAttribute("value"), 0);
|
|
@@ -562,7 +562,7 @@ class W extends M {
|
|
|
562
562
|
window.clearTimeout(t);
|
|
563
563
|
}
|
|
564
564
|
}
|
|
565
|
-
function
|
|
565
|
+
function x(e) {
|
|
566
566
|
return e != null && N.has(e) ? e : O;
|
|
567
567
|
}
|
|
568
568
|
function j(e) {
|
|
@@ -574,7 +574,7 @@ function m(e) {
|
|
|
574
574
|
function Z(e) {
|
|
575
575
|
return e != null && q.has(e) ? e : "start";
|
|
576
576
|
}
|
|
577
|
-
function
|
|
577
|
+
function k(e) {
|
|
578
578
|
return e != null && L.has(e) ? e : I;
|
|
579
579
|
}
|
|
580
580
|
function K(e) {
|
package/dist/odometer.cjs.js
CHANGED
|
@@ -52,19 +52,19 @@
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
:host([tone="brand"]) {
|
|
55
|
-
--ui-odometer-color: var(--ui-color-primary, #2563eb);
|
|
55
|
+
--ui-odometer-color: var(--ui-color-accent-text, var(--ui-color-primary, #2563eb));
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
:host([tone="success"]) {
|
|
59
|
-
--ui-odometer-color: var(--ui-color-success, #15803d);
|
|
59
|
+
--ui-odometer-color: var(--ui-color-success-text, var(--ui-color-success, #15803d));
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
:host([tone="warning"]) {
|
|
63
|
-
--ui-odometer-color: var(--ui-color-warning, #b45309);
|
|
63
|
+
--ui-odometer-color: var(--ui-color-warning-text, var(--ui-color-warning, #b45309));
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
:host([tone="danger"]) {
|
|
67
|
-
--ui-odometer-color: var(--ui-color-danger, #dc2626);
|
|
67
|
+
--ui-odometer-color: var(--ui-color-danger-text, var(--ui-color-danger, #dc2626));
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
:host([theme="dark"]) {
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
:host([theme="brand"]) {
|
|
78
|
-
--ui-odometer-color: var(--ui-color-primary, #2563eb);
|
|
78
|
+
--ui-odometer-color: var(--ui-color-accent-text, var(--ui-color-primary, #2563eb));
|
|
79
79
|
--ui-odometer-digit-bg: linear-gradient(180deg, rgba(219, 234, 254, 0.98), rgba(191, 219, 254, 0.94));
|
|
80
80
|
--ui-odometer-digit-border: 1px solid rgba(37, 99, 235, 0.22);
|
|
81
81
|
}
|
|
@@ -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),
|
|
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),v={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 g;try{g=new Intl.NumberFormat(r,v).formatToParts(t)}catch{g=new Intl.NumberFormat(void 0,v).formatToParts(t)}const d=[];for(const a of g){const y=a.type==="decimal"&&m!=null?m:a.type==="group"&&c!=null?c:a.value;for(const f of y){if(/[0-9]/.test(f)){d.push({kind:"digit",value:f});continue}let p="literal";a.type==="group"?p="group":a.type==="decimal"?p="decimal":a.type==="currency"||a.type==="percentSign"||a.type==="unit"?p="symbol":(a.type==="minusSign"||a.type==="plusSign")&&(p="sign"),d.push({kind:"text",value:f,textType:p})}}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,v=this._motionDirection==="down"?-1:this._motionDirection==="up"?1:0;let g="value-display",d="";t==="digital"?(g+=" digital-display",d=[`--ui-odometer-motion-intensity: ${s.toFixed(3)}`,`--ui-odometer-digital-shift-y: ${(v*s*.16).toFixed(3)}em`,`--ui-odometer-digital-scale-y: ${(1+s*.08).toFixed(3)}`].join("; ")):t==="analog"&&(g+=" analog-display",d=[`--ui-odometer-motion-intensity: ${s.toFixed(3)}`,`--ui-odometer-analog-shift-x: ${(v*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="${g}" part="value" aria-hidden="true"${d?` style="${d}"`:""}>${x(u.text)}</span>`;if(t==="odometer"){const y=A(n(this,"direction")),f=y==="auto"?this._targetValue>=this._startValue?"up":"down":y,p=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=p.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}
|