@editora/ui-core 0.2.1 → 0.3.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/dist/{ElementBase-DxbvhLJs.js → ElementBase-CbUsP3D6.js} +1 -1
- package/dist/{ElementBase-BeZT54Hj.mjs → ElementBase-D5QsC5Vw.mjs} +10 -1
- package/dist/ElementBase.d.ts +7 -0
- package/dist/ElementBase.d.ts.map +1 -1
- package/dist/accordion.cjs.js +1 -1
- package/dist/accordion.esm.js +1 -1
- package/dist/add-icons-CVeHOsWl.js +1 -0
- package/dist/add-icons-DBUZJ0g7.mjs +14 -0
- package/dist/add-icons.cjs.js +1 -0
- package/dist/add-icons.d.ts +16 -0
- package/dist/add-icons.d.ts.map +1 -0
- package/dist/add-icons.esm.js +4 -0
- package/dist/alert-dialog.cjs.js +24 -24
- package/dist/alert-dialog.esm.js +112 -107
- package/dist/alert.cjs.js +8 -8
- package/dist/alert.esm.js +22 -22
- package/dist/animated-beam.cjs.js +1 -1
- package/dist/animated-beam.esm.js +1 -1
- package/dist/animated-list.cjs.js +1 -1
- package/dist/animated-list.esm.js +1 -1
- package/dist/animated-text.cjs.js +1 -1
- package/dist/animated-text.esm.js +1 -1
- package/dist/app-header.cjs.js +15 -3
- package/dist/app-header.esm.js +31 -4
- package/dist/aspect-ratio.cjs.js +1 -1
- package/dist/aspect-ratio.esm.js +1 -1
- package/dist/avatar.cjs.js +1 -1
- package/dist/avatar.esm.js +1 -1
- package/dist/badge.cjs.js +1 -1
- package/dist/badge.esm.js +1 -1
- package/dist/block-controls.cjs.js +1 -1
- package/dist/block-controls.esm.js +1 -1
- package/dist/box.cjs.js +1 -1
- package/dist/box.esm.js +1 -1
- package/dist/breadcrumb.cjs.js +4 -4
- package/dist/breadcrumb.esm.js +93 -84
- package/dist/button.cjs.js +520 -1
- package/dist/button.esm.js +682 -2
- package/dist/{calendar-CzpWDxLc.js → calendar-BsVqtpjM.js} +6 -6
- package/dist/{calendar-DkSDFg33.mjs → calendar-CFafqZVA.mjs} +6 -6
- package/dist/calendar.cjs.js +1 -1
- package/dist/calendar.esm.js +1 -1
- package/dist/card.cjs.js +6 -5
- package/dist/card.esm.js +52 -39
- package/dist/chart.cjs.js +2 -2
- package/dist/chart.esm.js +2 -2
- package/dist/checkbox.cjs.js +4 -4
- package/dist/checkbox.esm.js +36 -15
- package/dist/clone-source-BxK2pEVw.mjs +11 -0
- package/dist/clone-source-C7E_ri5f.js +1 -0
- package/dist/collapsible.cjs.js +1 -1
- package/dist/collapsible.esm.js +1 -1
- package/dist/color-picker.cjs.js +2 -2
- package/dist/color-picker.esm.js +3 -3
- package/dist/combobox.cjs.js +4 -4
- package/dist/combobox.esm.js +22 -19
- package/dist/command-palette.cjs.js +1 -1
- package/dist/command-palette.esm.js +1 -1
- package/dist/command.cjs.js +1 -1
- package/dist/command.esm.js +1 -1
- 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-app-header.d.ts +1 -0
- package/dist/components/ui-app-header.d.ts.map +1 -1
- package/dist/components/ui-breadcrumb.d.ts.map +1 -1
- package/dist/components/ui-card.d.ts +7 -0
- package/dist/components/ui-card.d.ts.map +1 -1
- package/dist/components/ui-checkbox.d.ts +6 -0
- package/dist/components/ui-checkbox.d.ts.map +1 -1
- package/dist/components/ui-combobox.d.ts.map +1 -1
- package/dist/components/ui-date-time-picker.d.ts.map +1 -1
- package/dist/components/ui-dialog.d.ts +1 -0
- package/dist/components/ui-dialog.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-hover-card.d.ts.map +1 -1
- package/dist/components/ui-icon.d.ts +1 -0
- package/dist/components/ui-icon.d.ts.map +1 -1
- package/dist/components/ui-input.d.ts +16 -0
- package/dist/components/ui-input.d.ts.map +1 -1
- package/dist/components/ui-layout.d.ts +20 -0
- package/dist/components/ui-layout.d.ts.map +1 -1
- package/dist/components/ui-menu.d.ts +1 -0
- package/dist/components/ui-menu.d.ts.map +1 -1
- package/dist/components/ui-menubar.d.ts.map +1 -1
- package/dist/components/ui-multi-select.d.ts +6 -0
- package/dist/components/ui-multi-select.d.ts.map +1 -1
- package/dist/components/ui-number-field.d.ts +6 -0
- package/dist/components/ui-number-field.d.ts.map +1 -1
- package/dist/components/ui-pagination.d.ts.map +1 -1
- package/dist/components/ui-password-field.d.ts +11 -0
- package/dist/components/ui-password-field.d.ts.map +1 -1
- package/dist/components/ui-popover.d.ts.map +1 -1
- package/dist/components/ui-positioner.d.ts.map +1 -1
- package/dist/components/ui-radio-group.d.ts +6 -0
- package/dist/components/ui-radio-group.d.ts.map +1 -1
- package/dist/components/ui-rating.d.ts +1 -0
- package/dist/components/ui-rating.d.ts.map +1 -1
- package/dist/components/ui-select.d.ts +7 -0
- package/dist/components/ui-select.d.ts.map +1 -1
- package/dist/components/ui-sidebar.d.ts +1 -0
- package/dist/components/ui-sidebar.d.ts.map +1 -1
- package/dist/components/ui-slider.d.ts +6 -0
- package/dist/components/ui-slider.d.ts.map +1 -1
- package/dist/components/ui-sortable.d.ts +1 -0
- package/dist/components/ui-sortable.d.ts.map +1 -1
- package/dist/components/ui-switch.d.ts +6 -0
- package/dist/components/ui-switch.d.ts.map +1 -1
- package/dist/components/ui-tabs.d.ts +2 -0
- package/dist/components/ui-tabs.d.ts.map +1 -1
- package/dist/components/ui-textarea.d.ts +6 -0
- package/dist/components/ui-textarea.d.ts.map +1 -1
- package/dist/components/ui-toast.d.ts.map +1 -1
- package/dist/components/ui-tooltip.d.ts.map +1 -1
- package/dist/container.cjs.js +1 -1
- package/dist/container.esm.js +1 -1
- package/dist/context-menu.cjs.js +2 -2
- package/dist/context-menu.esm.js +2 -2
- package/dist/control-group.cjs.js +1 -1
- package/dist/control-group.esm.js +1 -1
- package/dist/data-table.cjs.js +5 -5
- package/dist/data-table.esm.js +7 -7
- package/dist/date-field.cjs.js +1 -1
- package/dist/date-field.esm.js +3 -3
- package/dist/date-picker.cjs.js +2 -2
- package/dist/date-picker.esm.js +17 -17
- package/dist/date-range-picker.cjs.js +2 -2
- package/dist/date-range-picker.esm.js +4 -4
- package/dist/date-range-time-picker.cjs.js +3 -3
- package/dist/date-range-time-picker.esm.js +16 -16
- package/dist/date-time-picker.cjs.js +26 -23
- package/dist/date-time-picker.esm.js +49 -46
- package/dist/{date-time-utils-zAx4ghvC.mjs → date-time-utils-CJUksWj3.mjs} +1 -1
- package/dist/{date-time-utils-C-4eHTyy.js → date-time-utils-D3hQQ5Om.js} +1 -1
- package/dist/description.cjs.js +1 -1
- package/dist/description.esm.js +1 -1
- package/dist/dialog.cjs.js +7 -7
- package/dist/dialog.esm.js +51 -47
- package/dist/direction-provider.cjs.js +1 -1
- package/dist/direction-provider.esm.js +1 -1
- package/dist/dismissable-layer.cjs.js +1 -1
- package/dist/dismissable-layer.esm.js +1 -1
- package/dist/dock.cjs.js +1 -1
- package/dist/dock.esm.js +1 -1
- package/dist/drawer.cjs.js +5 -5
- package/dist/drawer.esm.js +18 -17
- package/dist/dropdown.cjs.js +7 -7
- package/dist/dropdown.esm.js +39 -38
- package/dist/empty-state.cjs.js +12 -2
- package/dist/empty-state.esm.js +17 -7
- package/dist/field-error.cjs.js +1 -1
- package/dist/field-error.esm.js +1 -1
- package/dist/field.cjs.js +2 -2
- package/dist/field.esm.js +2 -2
- package/dist/fieldset.cjs.js +1 -1
- package/dist/fieldset.esm.js +1 -1
- package/dist/file-upload.cjs.js +1 -1
- package/dist/file-upload.esm.js +1 -1
- package/dist/flex.cjs.js +1 -1
- package/dist/flex.esm.js +1 -1
- package/dist/floating-toolbar.cjs.js +2 -2
- package/dist/floating-toolbar.esm.js +2 -2
- package/dist/focus-scope-Dl0qk5GP.mjs +177 -0
- package/dist/focus-scope-Doz0bnE1.js +1 -0
- package/dist/focus-scope.cjs.js +1 -1
- package/dist/focus-scope.esm.js +2 -2
- package/dist/form-control-B90_3kYN.js +1 -0
- package/dist/form-control-D9wWUMBl.mjs +86 -0
- package/dist/form.cjs.js +2 -2
- package/dist/form.esm.js +2 -2
- package/dist/gantt.cjs.js +2 -2
- package/dist/gantt.esm.js +2 -2
- package/dist/grid.cjs.js +1 -1
- package/dist/grid.esm.js +1 -1
- package/dist/hover-card.cjs.js +5 -5
- package/dist/hover-card.esm.js +19 -18
- package/dist/icon-cloud.cjs.js +1 -1
- package/dist/icon-cloud.esm.js +1 -1
- package/dist/icon.cjs.js +207 -1
- package/dist/icon.esm.js +294 -2
- package/dist/icons-CpCpPXV5.js +1 -0
- package/dist/icons-DWYbbhb0.mjs +115 -0
- package/dist/icons.d.ts +11 -1
- package/dist/icons.d.ts.map +1 -1
- package/dist/implicit-submit-B6M5Uc56.js +1 -0
- package/dist/implicit-submit-Lr0-q2LR.mjs +44 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +309 -299
- package/dist/inline-edit.cjs.js +1 -1
- package/dist/inline-edit.esm.js +1 -1
- package/dist/input.cjs.js +62 -20
- package/dist/input.esm.js +164 -58
- package/dist/label.cjs.js +1 -1
- package/dist/label.esm.js +1 -1
- package/dist/layout.cjs.js +145 -4
- package/dist/layout.esm.js +278 -40
- package/dist/marquee.cjs.js +1 -1
- package/dist/marquee.esm.js +1 -1
- package/dist/masonry-grid.cjs.js +1 -1
- package/dist/masonry-grid.esm.js +1 -1
- package/dist/menu.cjs.js +8 -8
- package/dist/menu.esm.js +51 -47
- package/dist/menubar.cjs.js +9 -9
- package/dist/menubar.esm.js +41 -40
- package/dist/meter.cjs.js +1 -1
- package/dist/meter.esm.js +1 -1
- package/dist/multi-select.cjs.js +7 -7
- package/dist/multi-select.esm.js +55 -34
- package/dist/navigate-CXebafwF.mjs +18 -0
- package/dist/navigate-ChJVIIuS.js +1 -0
- package/dist/navigation-menu.cjs.js +1 -1
- package/dist/navigation-menu.esm.js +1 -1
- package/dist/number-attribute-BAF07JrU.mjs +8 -0
- package/dist/number-attribute-C4Rrl7d3.js +1 -0
- package/dist/number-field.cjs.js +8 -8
- package/dist/number-field.esm.js +90 -69
- package/dist/number-ticker.cjs.js +1 -1
- package/dist/number-ticker.esm.js +1 -1
- package/dist/odometer.cjs.js +1 -1
- package/dist/odometer.esm.js +1 -1
- package/dist/orbiter.cjs.js +1 -1
- package/dist/orbiter.esm.js +1 -1
- package/dist/pagination.cjs.js +24 -23
- package/dist/pagination.esm.js +61 -46
- package/dist/{panel-group-BVHJEdfx.js → panel-group-BIzzpQ5i.js} +1 -1
- package/dist/{panel-group-BxO_eNW6.mjs → panel-group-CFLjzRWI.mjs} +1 -1
- package/dist/panel-group.cjs.js +1 -1
- package/dist/panel-group.esm.js +1 -1
- package/dist/panel.cjs.js +1 -1
- package/dist/panel.esm.js +1 -1
- package/dist/password-field.cjs.js +36 -16
- package/dist/password-field.esm.js +113 -44
- 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/plugin-panel.cjs.js +1 -1
- package/dist/plugin-panel.esm.js +1 -1
- package/dist/popover.cjs.js +2 -2
- package/dist/popover.esm.js +28 -26
- package/dist/portal.cjs.js +1 -1
- package/dist/portal.esm.js +1 -1
- package/dist/positioner.cjs.js +2 -2
- package/dist/positioner.esm.js +35 -38
- package/dist/preload.cjs.js +221 -0
- package/dist/preload.css +220 -0
- package/dist/preload.d.ts +17 -0
- package/dist/preload.d.ts.map +1 -0
- package/dist/preload.esm.js +224 -0
- package/dist/presence.cjs.js +1 -1
- package/dist/presence.esm.js +1 -1
- package/dist/primitives/clone-source.d.ts +3 -0
- package/dist/primitives/clone-source.d.ts.map +1 -0
- package/dist/primitives/focus-scope.d.ts +6 -0
- package/dist/primitives/focus-scope.d.ts.map +1 -1
- package/dist/primitives/form-control.d.ts +68 -0
- package/dist/primitives/form-control.d.ts.map +1 -0
- package/dist/primitives/implicit-submit.d.ts +17 -0
- package/dist/primitives/implicit-submit.d.ts.map +1 -0
- package/dist/primitives/navigate.d.ts +27 -0
- package/dist/primitives/navigate.d.ts.map +1 -0
- package/dist/primitives/number-attribute.d.ts +7 -0
- package/dist/primitives/number-attribute.d.ts.map +1 -0
- package/dist/primitives/slotted-input.d.ts +19 -0
- package/dist/primitives/slotted-input.d.ts.map +1 -0
- package/dist/progress.cjs.js +3 -3
- package/dist/progress.esm.js +3 -3
- package/dist/quick-actions.cjs.js +5 -5
- package/dist/quick-actions.esm.js +3 -3
- package/dist/radio-group.cjs.js +9 -9
- package/dist/radio-group.esm.js +47 -24
- package/dist/radio.cjs.js +1 -1
- package/dist/radio.esm.js +1 -1
- package/dist/rating.cjs.js +6 -6
- package/dist/rating.esm.js +21 -10
- package/dist/{runtime-BRT7E4A8.mjs → runtime-CORXjP7e.mjs} +379 -357
- package/dist/runtime-uCly3ECd.js +5 -0
- package/dist/runtime.cjs.js +1 -1
- package/dist/runtime.esm.js +1 -1
- package/dist/scroll-area.cjs.js +1 -1
- package/dist/scroll-area.esm.js +1 -1
- package/dist/section.cjs.js +1 -1
- package/dist/section.esm.js +1 -1
- package/dist/select.cjs.js +21 -21
- package/dist/select.esm.js +111 -71
- package/dist/selection-popup.cjs.js +2 -2
- package/dist/selection-popup.esm.js +2 -2
- package/dist/semantic-tokens.d.ts.map +1 -1
- package/dist/separator.cjs.js +1 -1
- package/dist/separator.esm.js +1 -1
- package/dist/sidebar.cjs.js +15 -15
- package/dist/sidebar.esm.js +48 -42
- package/dist/skeleton.cjs.js +1 -1
- package/dist/skeleton.esm.js +1 -1
- package/dist/slider.cjs.js +11 -11
- package/dist/slider.esm.js +40 -23
- package/dist/slot.cjs.js +1 -1
- package/dist/slot.esm.js +1 -1
- package/dist/slotted-input-BVq2QQg2.js +1 -0
- package/dist/slotted-input-atWznLfm.mjs +13 -0
- package/dist/sortable.cjs.js +25 -25
- package/dist/sortable.esm.js +29 -21
- package/dist/spinning-text.cjs.js +1 -1
- package/dist/spinning-text.esm.js +1 -1
- package/dist/split-button.cjs.js +1 -1
- package/dist/split-button.esm.js +1 -1
- package/dist/splitter.cjs.js +1 -1
- package/dist/splitter.esm.js +1 -1
- package/dist/standalone/add-icons.d.ts +2 -0
- package/dist/standalone/add-icons.d.ts.map +1 -0
- package/dist/standalone/preload.d.ts +2 -0
- package/dist/standalone/preload.d.ts.map +1 -0
- package/dist/stepper.cjs.js +3 -3
- package/dist/stepper.esm.js +3 -3
- package/dist/switch.cjs.js +9 -9
- package/dist/switch.esm.js +56 -35
- package/dist/table.cjs.js +1 -1
- package/dist/table.esm.js +1 -1
- package/dist/tabs.cjs.js +14 -14
- package/dist/tabs.esm.js +129 -115
- package/dist/tags-input.cjs.js +1 -1
- package/dist/tags-input.esm.js +1 -1
- package/dist/textarea.cjs.js +33 -11
- package/dist/textarea.esm.js +74 -35
- package/dist/theme.d.ts +6 -0
- package/dist/theme.d.ts.map +1 -1
- package/dist/time-field.cjs.js +1 -1
- package/dist/time-field.esm.js +2 -2
- package/dist/time-picker.cjs.js +1 -1
- package/dist/time-picker.esm.js +3 -3
- package/dist/timeline.cjs.js +2 -2
- package/dist/timeline.esm.js +2 -2
- package/dist/toast.cjs.js +4 -4
- package/dist/toast.esm.js +17 -16
- package/dist/toggle-group.cjs.js +1 -1
- package/dist/toggle-group.esm.js +1 -1
- package/dist/toggle.cjs.js +3 -3
- package/dist/toggle.esm.js +9 -9
- package/dist/toolbar.cjs.js +1 -1
- package/dist/toolbar.esm.js +1 -1
- package/dist/tooltip.cjs.js +2 -2
- package/dist/tooltip.esm.js +12 -14
- package/dist/transfer-list.cjs.js +1 -1
- package/dist/transfer-list.esm.js +1 -1
- package/dist/{tree-33fVNnaf.mjs → tree-CD2k2lIC.mjs} +1 -1
- package/dist/{tree-Dc02MChE.js → tree-ChQfhxya.js} +1 -1
- package/dist/tree-item.cjs.js +1 -1
- package/dist/tree-item.esm.js +1 -1
- package/dist/tree.cjs.js +1 -1
- package/dist/tree.esm.js +1 -1
- package/dist/visually-hidden.cjs.js +1 -1
- package/dist/visually-hidden.esm.js +1 -1
- package/dist/wizard.cjs.js +4 -4
- package/dist/wizard.esm.js +4 -4
- package/package.json +3 -2
- package/dist/focus-scope-Bwug2gDv.js +0 -1
- package/dist/focus-scope-CmEsG5UZ.mjs +0 -138
- package/dist/runtime-CXw4SGV9.js +0 -5
- package/dist/ui-button-C3OmI7Sn.mjs +0 -684
- package/dist/ui-button-CnLwXBnx.js +0 -520
- package/dist/ui-icon-D3avtxX_.js +0 -207
- package/dist/ui-icon-DLhB08Fo.mjs +0 -361
package/dist/inline-edit.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("./ElementBase-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("./ElementBase-CbUsP3D6.js"),v=`
|
|
2
2
|
:host {
|
|
3
3
|
--ui-inline-edit-bg: transparent;
|
|
4
4
|
--ui-inline-edit-border: 1px dashed transparent;
|
package/dist/inline-edit.esm.js
CHANGED
package/dist/input.cjs.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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 L=require("./ElementBase-CbUsP3D6.js"),q=require("./slotted-input-BVq2QQg2.js"),T=require("./implicit-submit-B6M5Uc56.js"),I=require("./control-name-BmoI1m3a.js"),V=`
|
|
2
2
|
<svg viewBox="0 0 20 20" aria-hidden="true" focusable="false">
|
|
3
3
|
<path d="m6 6 8 8M14 6l-8 8" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>
|
|
4
4
|
</svg>
|
|
5
|
-
`,
|
|
5
|
+
`,D=`
|
|
6
6
|
:host {
|
|
7
7
|
--ui-input-action-size: 24px;
|
|
8
8
|
--ui-input-padding: var(--ui-padding, 0);
|
|
@@ -69,6 +69,28 @@
|
|
|
69
69
|
transform: translateY(-0.5px);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
/* description-position="below": the hint goes under the field (DOM order, and so what a
|
|
73
|
+
screen reader reads, stays label, description, field). */
|
|
74
|
+
:host([description-position="below"]) .meta:not([hidden]) {
|
|
75
|
+
display: contents;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
:host([description-position="below"]) .label {
|
|
79
|
+
order: 0;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
:host([description-position="below"]) .shell {
|
|
83
|
+
order: 1;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
:host([description-position="below"]) .description {
|
|
87
|
+
order: 2;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
:host([description-position="below"]) .footer {
|
|
91
|
+
order: 3;
|
|
92
|
+
}
|
|
93
|
+
|
|
72
94
|
.description {
|
|
73
95
|
margin: 0;
|
|
74
96
|
color: var(--ui-description-color);
|
|
@@ -197,6 +219,25 @@
|
|
|
197
219
|
color: var(--ui-input-placeholder);
|
|
198
220
|
}
|
|
199
221
|
|
|
222
|
+
/* <input slot="input">: the author's own input (password managers, autofill), styled the same. */
|
|
223
|
+
::slotted(input[slot="input"]) {
|
|
224
|
+
inline-size: 100%;
|
|
225
|
+
min-inline-size: 0;
|
|
226
|
+
box-sizing: border-box;
|
|
227
|
+
border: none;
|
|
228
|
+
background: transparent;
|
|
229
|
+
color: inherit;
|
|
230
|
+
font: 500 var(--ui-input-font-size)/var(--ui-default-line-height, var(--line-height-2, 20px)) var(--ui-font-family, var(--default-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif));
|
|
231
|
+
padding: var(--ui-input-padding);
|
|
232
|
+
min-block-size: calc(var(--ui-input-min-height) - 2px);
|
|
233
|
+
margin: 0;
|
|
234
|
+
outline: none;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.control[data-slotted-input] > input {
|
|
238
|
+
display: none;
|
|
239
|
+
}
|
|
240
|
+
|
|
200
241
|
input::-webkit-search-cancel-button {
|
|
201
242
|
display: none;
|
|
202
243
|
}
|
|
@@ -354,7 +395,7 @@
|
|
|
354
395
|
--ui-label-color: #cbd5e1;
|
|
355
396
|
--ui-description-color: #93a4bd;
|
|
356
397
|
--ui-input-border-color: #334155;
|
|
357
|
-
--ui-input-focus-ring: #93c5fd;
|
|
398
|
+
--ui-input-focus-ring: var(--ui-color-accent-on-dark, #93c5fd);
|
|
358
399
|
--ui-input-placeholder: color-mix(in srgb, #e2e8f0 46%, transparent);
|
|
359
400
|
--ui-input-shadow: 0 2px 8px rgba(2, 6, 23, 0.24);
|
|
360
401
|
}
|
|
@@ -488,16 +529,16 @@
|
|
|
488
529
|
box-shadow: none;
|
|
489
530
|
}
|
|
490
531
|
}
|
|
491
|
-
`;function r(a){return a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function w(a){if(!a)return!1;const t=a.assignedNodes({flatten:!0});return t.length?t.some(e=>e.nodeType===Node.TEXT_NODE?!!e.textContent?.trim():e.nodeType===Node.ELEMENT_NODE):!1}function A(a,t){const e=a.getAttribute(t);if(e==null)return!1;const i=String(e).trim().toLowerCase();return i!=="false"&&i!=="0"}function T(a){return a==="none"||a==="large"||a==="full"}class E extends $.ElementBase{constructor(){super(),this._input=null,this._clearBtn=null,this._debounceTimer=null,this._formUnregister=null,this._uid=Math.random().toString(36).slice(2,9),this._autofocusApplied=!1,this._onNativeInput=this._onNativeInput.bind(this),this._onNativeChange=this._onNativeChange.bind(this),this._onClearClick=this._onClearClick.bind(this),this._onSlotChange=this._onSlotChange.bind(this)}static get observedAttributes(){return["value","placeholder","disabled","clearable","size","validation","debounce","maxlength","minlength","readonly","autofocus","counter","floating-label","headless","type","name","required","pattern","inputmode","autocomplete","min","max","step","spellcheck","variant","tone","density","shape","color","radius","label","aria-label","aria-description","aria-describedby","description","data-error"]}connectedCallback(){super.connectedCallback(),this.root.addEventListener("slotchange",this._onSlotChange),this._registerWithForm()}disconnectedCallback(){this.root.removeEventListener("slotchange",this._onSlotChange),this._detachListeners(),this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null),this._formUnregister&&(this._formUnregister(),this._formUnregister=null),this._autofocusApplied=!1,super.disconnectedCallback()}_syncHostTokens(){const t=this.getAttribute("color");t?this.style.setProperty("--ui-input-accent",t):this.style.removeProperty("--ui-input-accent");const e=this.getAttribute("radius")||"";e&&!T(e)?this.style.setProperty("--ui-input-border-radius",e):this.style.removeProperty("--ui-input-border-radius")}_syncControlAttrs(){if(this._syncHostTokens(),!this._input)return;const t=this._input,e=this.getAttribute("type")||"text",i=this.getAttribute("placeholder")||"",n=this.getAttribute("name")||"",s=this.getAttribute("pattern")||"",o=this.getAttribute("inputmode")||"",g=this.getAttribute("autocomplete")||"",p=this.getAttribute("min")||"",u=this.getAttribute("max")||"",l=this.getAttribute("step")||"",c=this.getAttribute("spellcheck")||"",d=this.getAttribute("maxlength")||"",h=this.getAttribute("minlength")||"",b=A(this,"disabled"),f=this.hasAttribute("required"),v=this.hasAttribute("readonly");try{t.type=e}catch{t.type="text"}t.placeholder=i,t.disabled=b,t.required=f,t.readOnly=v,t.name=n,s?t.setAttribute("pattern",s):t.removeAttribute("pattern"),o?t.setAttribute("inputmode",o):t.removeAttribute("inputmode"),g?t.setAttribute("autocomplete",g):t.removeAttribute("autocomplete"),p?t.setAttribute("min",p):t.removeAttribute("min"),u?t.setAttribute("max",u):t.removeAttribute("max"),l?t.setAttribute("step",l):t.removeAttribute("step"),c?t.setAttribute("spellcheck",c):t.removeAttribute("spellcheck"),d&&Number.isFinite(Number(d))?t.setAttribute("maxlength",d):t.removeAttribute("maxlength"),h&&Number.isFinite(Number(h))?t.setAttribute("minlength",h):t.removeAttribute("minlength")}attributeChangedCallback(t,e,i){if(e===i)return;if(t==="value"){this._syncInputValue(i||"");return}if(t==="name"&&this._registerWithForm(),t==="autofocus"&&!this.hasAttribute("autofocus")&&(this._autofocusApplied=!1),new Set(["placeholder","disabled","clearable","size","validation","debounce","maxlength","minlength","readonly","autofocus","counter","headless","type","name","required","pattern","inputmode","autocomplete","min","max","step","spellcheck","variant","tone","density","shape","color","radius","aria-label","aria-description","aria-describedby"]).has(t)){this._syncControlAttrs(),this._syncInputValue(this.value),this._syncDerivedState(),t==="autofocus"&&this.hasAttribute("autofocus")&&!this._autofocusApplied&&(this._autofocusApplied=!0,queueMicrotask(()=>{if(this.isConnected)try{this._input?.focus({preventScroll:!0})}catch{this._input?.focus()}}));return}this.isConnected&&this.requestRender()}get value(){return this.getAttribute("value")||""}set value(t){this.setAttribute("value",t||"")}focus(t){if(this._input){this._input.focus(t);return}super.focus(t)}blur(){this._input?.blur()}select(){this._input?.select()}_emitValueEvent(t,e){this.dispatchEvent(new CustomEvent(t,{detail:{value:e},bubbles:!0,composed:!0}))}_registerWithForm(){this._formUnregister&&(this._formUnregister(),this._formUnregister=null);try{const n=this.getRootNode().host?.closest?.("ui-form")||null||this.closest("ui-form"),s=this.getAttribute("name");n&&typeof n.registerField=="function"&&s&&(this._formUnregister=n.registerField(s,{name:s,getValue:()=>this.value,setValue:o=>{this.value=String(o??"")},validate:async()=>this._input?{valid:this._input.checkValidity(),message:this._input.validationMessage||void 0}:{valid:!0},setError:o=>{o?(this.setAttribute("validation","error"),this.setAttribute("data-error",o)):(this.removeAttribute("validation"),this.removeAttribute("data-error"))}}))}catch{}}_detachListeners(){this._input&&(this._input.removeEventListener("input",this._onNativeInput),this._input.removeEventListener("change",this._onNativeChange)),this._clearBtn&&this._clearBtn.removeEventListener("click",this._onClearClick),this._clearBtn=null}_syncInputValue(t){this._input&&this._input.value!==t&&(this._input.value=t),this._clearBtn&&(A(this,"clearable")&&t.length>0&&!A(this,"disabled")&&!this.hasAttribute("readonly")?this._clearBtn.removeAttribute("hidden"):this._clearBtn.setAttribute("hidden",""));const e=this.root.querySelector(".counter");if(e&&this.hasAttribute("counter")){const n=this.getAttribute("maxlength"),s=n?`${t.length}/${n}`:String(t.length);e.textContent=s}const i=this.root.querySelector(".shell");i&&i.setAttribute("data-has-value",t?"true":"false")}_onSlotChange(){this._syncDerivedState()}_syncDerivedState(){const t=this.root.querySelector('slot[name="label"]'),e=this.root.querySelector('slot[name="description"]'),i=this.root.querySelector('slot[name="error"]'),n=this.root.querySelector('slot[name="prefix"]'),s=this.root.querySelector('slot[name="suffix"]'),o=(this.getAttribute("label")||"").trim(),g=(this.getAttribute("description")||"").trim(),p=(this.getAttribute("data-error")||"").trim(),u=!!o||w(t),l=!!g||w(e),c=!!p||w(i),d=w(n),h=w(s),b=this.root.querySelector(".label"),f=this.root.querySelector(".description"),v=this.root.querySelector(".prefix"),m=this.root.querySelector(".suffix"),x=this.root.querySelector(".meta"),y=this.root.querySelector(".footer"),_=this.root.querySelector(".error"),C=this.root.querySelector(".counter");b&&(u?b.removeAttribute("hidden"):b.setAttribute("hidden","")),f&&(l?f.removeAttribute("hidden"):f.setAttribute("hidden","")),v&&(d?v.removeAttribute("hidden"):v.setAttribute("hidden","")),m&&(h?m.removeAttribute("hidden"):m.setAttribute("hidden","")),x&&(u||l?x.removeAttribute("hidden"):x.setAttribute("hidden",""));const k=this.hasAttribute("counter");if(C&&(k?C.removeAttribute("hidden"):C.setAttribute("hidden","")),_&&(c?_.removeAttribute("hidden"):_.setAttribute("hidden","")),y&&(c||k?y.removeAttribute("hidden"):y.setAttribute("hidden","")),this._input){S.syncControlName(this._input,this,u?`${this._uid}-label`:null);const z=[];l&&z.push(`${this._uid}-description`),c&&z.push(`${this._uid}-error`),S.syncControlDescription(this._input,this,this._uid,z),this.getAttribute("validation")==="error"||!!p?this._input.setAttribute("aria-invalid","true"):this._input.removeAttribute("aria-invalid"),this.hasAttribute("required")?this._input.setAttribute("aria-required","true"):this._input.removeAttribute("aria-required")}}_onNativeInput(t){const e=t.target.value;this.getAttribute("value")!==e?this.setAttribute("value",e):this._syncInputValue(e),this._emitValueEvent("input",e);const i=Number(this.getAttribute("debounce")||0);i>0?(this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._emitValueEvent("debounced-input",e),this._debounceTimer=null},i)):this._emitValueEvent("debounced-input",e)}_onNativeChange(t){const e=t.target.value;this._emitValueEvent("change",e)}_onClearClick(t){if(t.preventDefault(),!(A(this,"disabled")||this.hasAttribute("readonly"))&&this._input){this.value="",this._input.value="",this._input.dispatchEvent(new Event("input",{bubbles:!0})),this._input.dispatchEvent(new Event("change",{bubbles:!0})),this.dispatchEvent(new CustomEvent("clear",{bubbles:!0,composed:!0}));try{this._input.focus({preventScroll:!0})}catch{this._input.focus()}}}render(){const t=this.getAttribute("value")||"",e=this.getAttribute("placeholder")||"",i=A(this,"disabled"),n=A(this,"clearable"),s=this.getAttribute("type")||"text",o=this.getAttribute("name")||"",g=this.hasAttribute("required"),p=this.getAttribute("pattern")||"",u=this.getAttribute("inputmode")||"",l=this.getAttribute("autocomplete")||"",c=this.getAttribute("min")||"",d=this.getAttribute("max")||"",h=this.getAttribute("step")||"",b=this.getAttribute("spellcheck")||"",f=this.getAttribute("maxlength")||"",v=this.getAttribute("minlength")||"",m=this.hasAttribute("readonly"),x=this.getAttribute("label")||"",y=this.getAttribute("description")||"",_=this.getAttribute("data-error")||"",C=this.getAttribute("validation")||"",k=this.hasAttribute("floating-label"),z=g?'<span class="required" aria-hidden="true">*</span>':"";this._syncHostTokens(),this.setContent(`
|
|
492
|
-
<style>${
|
|
532
|
+
`;function r(a){return a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function k(a){if(!a)return!1;const t=a.assignedNodes({flatten:!0});return t.length?t.some(e=>e.nodeType===Node.TEXT_NODE?!!e.textContent?.trim():e.nodeType===Node.ELEMENT_NODE):!1}function m(a,t){const e=a.getAttribute(t);if(e==null)return!1;const i=String(e).trim().toLowerCase();return i!=="false"&&i!=="0"}function M(a){return a==="none"||a==="large"||a==="full"}const E=class E extends L.ElementBase{constructor(){super(),this._input=null,this._clearBtn=null,this._debounceTimer=null,this._formUnregister=null,this._uid=Math.random().toString(36).slice(2,9),this._autofocusApplied=!1,this._internals=null,this._defaultValue=null,this._formDisabled=!1,this._slottedInput=null,this._dirty=!1,this._onLabelClick=t=>{t.target?.closest?.(".label")&&this._input?.focus()};try{this._internals=typeof this.attachInternals=="function"?this.attachInternals():null}catch{this._internals=null}this._onNativeKeyDown=this._onNativeKeyDown.bind(this),this._onNativeInput=this._onNativeInput.bind(this),this._onNativeChange=this._onNativeChange.bind(this),this._onClearClick=this._onClearClick.bind(this),this._onSlotChange=this._onSlotChange.bind(this)}static get observedAttributes(){return["value","placeholder","disabled","clearable","size","validation","debounce","maxlength","minlength","readonly","autofocus","counter","floating-label","headless","type","name","required","pattern","inputmode","autocomplete","min","max","step","spellcheck","variant","tone","density","shape","color","radius","label","aria-label","aria-description","aria-describedby","description","data-error"]}connectedCallback(){this._dirty||(this._defaultValue=this.getAttribute("value")||""),super.connectedCallback(),this.root.addEventListener("slotchange",this._onSlotChange),this.root.addEventListener("click",this._onLabelClick),this._registerWithForm()}get form(){try{return this._internals?.form??null}catch{return null}}formResetCallback(){this._dirty=!1,this.value=this._defaultValue||""}formDisabledCallback(t){this._formDisabled=t,this._input&&(this._input.disabled=t||m(this,"disabled"))}_syncFormState(){const t=this._internals;if(t)try{if(this._slottedInput){t.setFormValue?.(null),t.setValidity?.({});return}t.setFormValue?.(this.value);const e=this._input;e&&typeof t.setValidity=="function"&&(e.validity&&!e.validity.valid?t.setValidity(e.validity,e.validationMessage,e):t.setValidity({}))}catch{}}_onNativeKeyDown(t){T.scheduleImplicitSubmit(t,this,()=>this.form)}disconnectedCallback(){this.root.removeEventListener("slotchange",this._onSlotChange),this.root.removeEventListener("click",this._onLabelClick),this._detachListeners(),this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null),this._formUnregister&&(this._formUnregister(),this._formUnregister=null),this._autofocusApplied=!1,super.disconnectedCallback()}_syncHostTokens(){const t=this.getAttribute("color");t?this.style.setProperty("--ui-input-accent",t):this.style.removeProperty("--ui-input-accent");const e=this.getAttribute("radius")||"";e&&!M(e)?this.style.setProperty("--ui-input-border-radius",e):this.style.removeProperty("--ui-input-border-radius")}_bindInput(){this._input&&(this._input.removeEventListener("input",this._onNativeInput),this._input.removeEventListener("change",this._onNativeChange),this._input.removeEventListener("keydown",this._onNativeKeyDown));const t=q.findSlottedInput(this);this._slottedInput=t;const e=this.root.querySelector(".control");t?e?.setAttribute("data-slotted-input",""):e?.removeAttribute("data-slotted-input"),this._input=t||this.root.querySelector(".control > input"),t&&!this.hasAttribute("value")&&t.value&&this.setAttribute("value",t.value),this._input&&(this._input.addEventListener("input",this._onNativeInput),this._input.addEventListener("change",this._onNativeChange),t||this._input.addEventListener("keydown",this._onNativeKeyDown))}_syncSlottedInputAttrs(t){const e=m(this,"disabled")||this._formDisabled;(this.hasAttribute("disabled")||this._formDisabled)&&(t.disabled=e),this.hasAttribute("required")&&(t.required=!0),this.hasAttribute("readonly")&&(t.readOnly=!0)}_syncControlAttrs(){if(this._syncHostTokens(),!this._input)return;if(this._slottedInput){this._syncSlottedInputAttrs(this._slottedInput);return}const t=this._input,e=this.getAttribute("type")||"text",i=this.getAttribute("placeholder")||"",n=this.getAttribute("name")||"",o=this.getAttribute("pattern")||"",s=this.getAttribute("inputmode")||"",g=this.getAttribute("autocomplete")||"",u=this.getAttribute("min")||"",l=this.getAttribute("max")||"",c=this.getAttribute("step")||"",d=this.getAttribute("spellcheck")||"",p=this.getAttribute("maxlength")||"",h=this.getAttribute("minlength")||"",b=m(this,"disabled"),f=this.hasAttribute("required"),v=this.hasAttribute("readonly");try{t.type=e}catch{t.type="text"}t.placeholder=i,t.disabled=b||this._formDisabled,t.required=f,t.readOnly=v,t.name=n,o?t.setAttribute("pattern",o):t.removeAttribute("pattern"),s?t.setAttribute("inputmode",s):t.removeAttribute("inputmode"),g?t.setAttribute("autocomplete",g):t.removeAttribute("autocomplete"),u?t.setAttribute("min",u):t.removeAttribute("min"),l?t.setAttribute("max",l):t.removeAttribute("max"),c?t.setAttribute("step",c):t.removeAttribute("step"),d?t.setAttribute("spellcheck",d):t.removeAttribute("spellcheck"),p&&Number.isFinite(Number(p))?t.setAttribute("maxlength",p):t.removeAttribute("maxlength"),h&&Number.isFinite(Number(h))?t.setAttribute("minlength",h):t.removeAttribute("minlength")}attributeChangedCallback(t,e,i){if(e===i)return;if(t==="value"){this._dirty||(this._defaultValue=i||""),this._syncInputValue(i||"");return}if(t==="name"&&this._registerWithForm(),t==="autofocus"&&!this.hasAttribute("autofocus")&&(this._autofocusApplied=!1),new Set(["placeholder","disabled","clearable","size","validation","debounce","maxlength","minlength","readonly","autofocus","counter","headless","type","name","required","pattern","inputmode","autocomplete","min","max","step","spellcheck","variant","tone","density","shape","color","radius","aria-label","aria-description","aria-describedby"]).has(t)){this._syncControlAttrs(),this._syncInputValue(this.value),this._syncDerivedState(),t==="autofocus"&&this.hasAttribute("autofocus")&&!this._autofocusApplied&&(this._autofocusApplied=!0,queueMicrotask(()=>{if(this.isConnected)try{this._input?.focus({preventScroll:!0})}catch{this._input?.focus()}}));return}this.isConnected&&this.requestRender()}get value(){return this.getAttribute("value")||""}set value(t){this.setAttribute("value",t||"")}focus(t){if(this._input){this._input.focus(t);return}super.focus(t)}blur(){this._input?.blur()}select(){this._input?.select()}_emitValueEvent(t,e){this.dispatchEvent(new CustomEvent(t,{detail:{value:e},bubbles:!0,composed:!0}))}_registerWithForm(){this._formUnregister&&(this._formUnregister(),this._formUnregister=null);try{const n=this.getRootNode().host?.closest?.("ui-form")||null||this.closest("ui-form"),o=this.getAttribute("name");n&&typeof n.registerField=="function"&&o&&(this._formUnregister=n.registerField(o,{name:o,getValue:()=>this.value,setValue:s=>{this.value=String(s??"")},validate:async()=>this._input?{valid:this._input.checkValidity(),message:this._input.validationMessage||void 0}:{valid:!0},setError:s=>{s?(this.setAttribute("validation","error"),this.setAttribute("data-error",s)):(this.removeAttribute("validation"),this.removeAttribute("data-error"))}}))}catch{}}_detachListeners(){this._input&&(this._input.removeEventListener("input",this._onNativeInput),this._input.removeEventListener("change",this._onNativeChange),this._input.removeEventListener("keydown",this._onNativeKeyDown)),this._clearBtn&&this._clearBtn.removeEventListener("click",this._onClearClick),this._clearBtn=null}_syncInputValue(t){this._input&&this._input.value!==t&&(this._input.value=t),this._syncFormState(),this._clearBtn&&(m(this,"clearable")&&t.length>0&&!m(this,"disabled")&&!this.hasAttribute("readonly")?this._clearBtn.removeAttribute("hidden"):this._clearBtn.setAttribute("hidden",""));const e=this.root.querySelector(".counter");if(e&&this.hasAttribute("counter")){const n=this.getAttribute("maxlength"),o=n?`${t.length}/${n}`:String(t.length);e.textContent=o}const i=this.root.querySelector(".shell");i&&i.setAttribute("data-has-value",t?"true":"false")}_onSlotChange(t){t?.target?.name==="input"&&(this._bindInput(),this._syncControlAttrs(),this._syncInputValue(this.value)),this._syncDerivedState()}_syncDerivedState(){const t=this.root.querySelector('slot[name="label"]'),e=this.root.querySelector('slot[name="description"]'),i=this.root.querySelector('slot[name="error"]'),n=this.root.querySelector('slot[name="prefix"]'),o=this.root.querySelector('slot[name="suffix"]'),s=(this.getAttribute("label")||"").trim(),g=(this.getAttribute("description")||"").trim(),u=(this.getAttribute("data-error")||"").trim(),l=!!s||k(t),c=!!g||k(e),d=!!u||k(i),p=k(n),h=k(o),b=this.root.querySelector(".label"),f=this.root.querySelector(".description"),v=this.root.querySelector(".prefix"),_=this.root.querySelector(".suffix"),y=this.root.querySelector(".meta"),w=this.root.querySelector(".footer"),A=this.root.querySelector(".error"),C=this.root.querySelector(".counter");b&&(l?b.removeAttribute("hidden"):b.setAttribute("hidden","")),f&&(c?f.removeAttribute("hidden"):f.setAttribute("hidden","")),v&&(p?v.removeAttribute("hidden"):v.setAttribute("hidden","")),_&&(h?_.removeAttribute("hidden"):_.setAttribute("hidden","")),y&&(l||c?y.removeAttribute("hidden"):y.setAttribute("hidden",""));const z=this.hasAttribute("counter");if(C&&(z?C.removeAttribute("hidden"):C.setAttribute("hidden","")),A&&(d?A.removeAttribute("hidden"):A.setAttribute("hidden","")),w&&(d||z?w.removeAttribute("hidden"):w.setAttribute("hidden","")),this._slottedInput){const x=(this.getAttribute("label")||t?.assignedNodes({flatten:!0}).map(N=>N.textContent||"").join(" ")||this.getAttribute("aria-label")||"").trim(),$=(this.getAttribute("description")||"").trim();q.nameSlottedInput(this._slottedInput,x,$),this.getAttribute("validation")==="error"||!!u?this._slottedInput.setAttribute("aria-invalid","true"):this._slottedInput.removeAttribute("aria-invalid")}else if(this._input){I.syncControlName(this._input,this,l?`${this._uid}-label`:null);const x=[];c&&x.push(`${this._uid}-description`),d&&x.push(`${this._uid}-error`),I.syncControlDescription(this._input,this,this._uid,x),this.getAttribute("validation")==="error"||!!u?this._input.setAttribute("aria-invalid","true"):this._input.removeAttribute("aria-invalid"),this.hasAttribute("required")?this._input.setAttribute("aria-required","true"):this._input.removeAttribute("aria-required")}}_onNativeInput(t){const e=t.target.value;this._dirty=!0,this.getAttribute("value")!==e?this.setAttribute("value",e):this._syncInputValue(e),this._emitValueEvent("input",e);const i=Number(this.getAttribute("debounce")||0);i>0?(this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._emitValueEvent("debounced-input",e),this._debounceTimer=null},i)):this._emitValueEvent("debounced-input",e)}_onNativeChange(t){const e=t.target.value;this._emitValueEvent("change",e)}_onClearClick(t){if(t.preventDefault(),!(m(this,"disabled")||this.hasAttribute("readonly"))&&this._input){this.value="",this._input.value="",this._input.dispatchEvent(new Event("input",{bubbles:!0})),this._input.dispatchEvent(new Event("change",{bubbles:!0})),this.dispatchEvent(new CustomEvent("clear",{bubbles:!0,composed:!0}));try{this._input.focus({preventScroll:!0})}catch{this._input.focus()}}}render(){const t=this.getAttribute("value")||"",e=this.getAttribute("placeholder")||"",i=m(this,"disabled"),n=m(this,"clearable"),o=this.getAttribute("type")||"text",s=this.getAttribute("name")||"",g=this.hasAttribute("required"),u=this.getAttribute("pattern")||"",l=this.getAttribute("inputmode")||"",c=this.getAttribute("autocomplete")||"",d=this.getAttribute("min")||"",p=this.getAttribute("max")||"",h=this.getAttribute("step")||"",b=this.getAttribute("spellcheck")||"",f=this.getAttribute("maxlength")||"",v=this.getAttribute("minlength")||"",_=this.hasAttribute("readonly"),y=this.getAttribute("label")||"",w=this.getAttribute("description")||"",A=this.getAttribute("data-error")||"",C=this.getAttribute("validation")||"",z=this.hasAttribute("floating-label"),x=g?'<span class="required" aria-hidden="true">*</span>':"";this._syncHostTokens(),this.setContent(`
|
|
533
|
+
<style>${D}</style>
|
|
493
534
|
<div class="root" part="root">
|
|
494
535
|
<div class="meta" part="meta">
|
|
495
536
|
<label class="label" id="${this._uid}-label" part="label">
|
|
496
|
-
<slot name="label">${r(
|
|
497
|
-
${
|
|
537
|
+
<slot name="label">${r(y)}</slot>
|
|
538
|
+
${x}
|
|
498
539
|
</label>
|
|
499
540
|
<p class="description" id="${this._uid}-description" part="description">
|
|
500
|
-
<slot name="description">${r(
|
|
541
|
+
<slot name="description">${r(w)}</slot>
|
|
501
542
|
</p>
|
|
502
543
|
</div>
|
|
503
544
|
|
|
@@ -505,38 +546,39 @@
|
|
|
505
546
|
<span class="prefix" part="prefix"><slot name="prefix"></slot></span>
|
|
506
547
|
|
|
507
548
|
<div class="control" part="control">
|
|
549
|
+
<slot name="input"></slot>
|
|
508
550
|
<input
|
|
509
551
|
part="input"
|
|
510
|
-
type="${r(
|
|
511
|
-
name="${r(
|
|
552
|
+
type="${r(o)}"
|
|
553
|
+
name="${r(s)}"
|
|
512
554
|
value="${r(t)}"
|
|
513
555
|
placeholder="${r(e)}"
|
|
514
556
|
${g?"required":""}
|
|
515
|
-
${
|
|
516
|
-
${
|
|
517
|
-
${
|
|
518
|
-
${
|
|
519
|
-
${
|
|
557
|
+
${u?`pattern="${r(u)}"`:""}
|
|
558
|
+
${l?`inputmode="${r(l)}"`:""}
|
|
559
|
+
${c?`autocomplete="${r(c)}"`:""}
|
|
560
|
+
${d?`min="${r(d)}"`:""}
|
|
561
|
+
${p?`max="${r(p)}"`:""}
|
|
520
562
|
${h?`step="${r(h)}"`:""}
|
|
521
563
|
${b?`spellcheck="${r(b)}"`:""}
|
|
522
564
|
${f?`maxlength="${r(f)}"`:""}
|
|
523
565
|
${v?`minlength="${r(v)}"`:""}
|
|
524
566
|
${i?"disabled":""}
|
|
525
|
-
${
|
|
567
|
+
${_?"readonly":""}
|
|
526
568
|
/>
|
|
527
|
-
${
|
|
569
|
+
${z?`<span class="floating-label" part="floating-label">${r(y||e||s||"Input")}</span>`:""}
|
|
528
570
|
</div>
|
|
529
571
|
|
|
530
|
-
<button class="clear-btn" part="clear" aria-label="Clear" ${n&&t&&!i&&!
|
|
572
|
+
<button class="clear-btn" part="clear" aria-label="Clear" ${n&&t&&!i&&!_?"":"hidden"}>${V}</button>
|
|
531
573
|
|
|
532
574
|
<span class="suffix" part="suffix"><slot name="suffix"></slot></span>
|
|
533
575
|
</div>
|
|
534
576
|
|
|
535
577
|
<div class="footer" part="footer">
|
|
536
578
|
<p class="error" id="${this._uid}-error" part="error" aria-live="polite">
|
|
537
|
-
${
|
|
579
|
+
${A?r(A):'<slot name="error"></slot>'}
|
|
538
580
|
</p>
|
|
539
581
|
<p class="counter" part="counter"></p>
|
|
540
582
|
</div>
|
|
541
583
|
</div>
|
|
542
|
-
`),this._detachListeners(),this.
|
|
584
|
+
`),this._detachListeners(),this._bindInput(),this._clearBtn=this.root.querySelector("button.clear-btn"),this._clearBtn?.addEventListener("click",this._onClearClick),this._syncControlAttrs(),this._syncInputValue(this._slottedInput?this.value:t),this._syncDerivedState(),this.hasAttribute("autofocus")&&!this._autofocusApplied&&(this._autofocusApplied=!0,queueMicrotask(()=>{if(this.isConnected)try{this._input?.focus({preventScroll:!0})}catch{this._input?.focus()}}))}shouldRenderOnAttributeChange(t,e,i){return t==="label"||t==="description"||t==="data-error"||t==="floating-label"}};E.formAssociated=!0;let S=E;typeof customElements<"u"&&!customElements.get("ui-input")&&customElements.define("ui-input",S);exports.UIInput=S;
|
package/dist/input.esm.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { E as
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { E as N } from "./ElementBase-D5QsC5Vw.mjs";
|
|
2
|
+
import { f as I, n as L } from "./slotted-input-atWznLfm.mjs";
|
|
3
|
+
import { s as T } from "./implicit-submit-Lr0-q2LR.mjs";
|
|
4
|
+
import { s as V, a as D } from "./control-name-Bpj7F34X.mjs";
|
|
5
|
+
const F = `
|
|
4
6
|
<svg viewBox="0 0 20 20" aria-hidden="true" focusable="false">
|
|
5
7
|
<path d="m6 6 8 8M14 6l-8 8" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>
|
|
6
8
|
</svg>
|
|
7
|
-
`,
|
|
9
|
+
`, B = `
|
|
8
10
|
:host {
|
|
9
11
|
--ui-input-action-size: 24px;
|
|
10
12
|
--ui-input-padding: var(--ui-padding, 0);
|
|
@@ -71,6 +73,28 @@ const q = `
|
|
|
71
73
|
transform: translateY(-0.5px);
|
|
72
74
|
}
|
|
73
75
|
|
|
76
|
+
/* description-position="below": the hint goes under the field (DOM order, and so what a
|
|
77
|
+
screen reader reads, stays label, description, field). */
|
|
78
|
+
:host([description-position="below"]) .meta:not([hidden]) {
|
|
79
|
+
display: contents;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
:host([description-position="below"]) .label {
|
|
83
|
+
order: 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
:host([description-position="below"]) .shell {
|
|
87
|
+
order: 1;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
:host([description-position="below"]) .description {
|
|
91
|
+
order: 2;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
:host([description-position="below"]) .footer {
|
|
95
|
+
order: 3;
|
|
96
|
+
}
|
|
97
|
+
|
|
74
98
|
.description {
|
|
75
99
|
margin: 0;
|
|
76
100
|
color: var(--ui-description-color);
|
|
@@ -199,6 +223,25 @@ const q = `
|
|
|
199
223
|
color: var(--ui-input-placeholder);
|
|
200
224
|
}
|
|
201
225
|
|
|
226
|
+
/* <input slot="input">: the author's own input (password managers, autofill), styled the same. */
|
|
227
|
+
::slotted(input[slot="input"]) {
|
|
228
|
+
inline-size: 100%;
|
|
229
|
+
min-inline-size: 0;
|
|
230
|
+
box-sizing: border-box;
|
|
231
|
+
border: none;
|
|
232
|
+
background: transparent;
|
|
233
|
+
color: inherit;
|
|
234
|
+
font: 500 var(--ui-input-font-size)/var(--ui-default-line-height, var(--line-height-2, 20px)) var(--ui-font-family, var(--default-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif));
|
|
235
|
+
padding: var(--ui-input-padding);
|
|
236
|
+
min-block-size: calc(var(--ui-input-min-height) - 2px);
|
|
237
|
+
margin: 0;
|
|
238
|
+
outline: none;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.control[data-slotted-input] > input {
|
|
242
|
+
display: none;
|
|
243
|
+
}
|
|
244
|
+
|
|
202
245
|
input::-webkit-search-cancel-button {
|
|
203
246
|
display: none;
|
|
204
247
|
}
|
|
@@ -356,7 +399,7 @@ const q = `
|
|
|
356
399
|
--ui-label-color: #cbd5e1;
|
|
357
400
|
--ui-description-color: #93a4bd;
|
|
358
401
|
--ui-input-border-color: #334155;
|
|
359
|
-
--ui-input-focus-ring: #93c5fd;
|
|
402
|
+
--ui-input-focus-ring: var(--ui-color-accent-on-dark, #93c5fd);
|
|
360
403
|
--ui-input-placeholder: color-mix(in srgb, #e2e8f0 46%, transparent);
|
|
361
404
|
--ui-input-shadow: 0 2px 8px rgba(2, 6, 23, 0.24);
|
|
362
405
|
}
|
|
@@ -494,23 +537,31 @@ const q = `
|
|
|
494
537
|
function r(a) {
|
|
495
538
|
return a.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
496
539
|
}
|
|
497
|
-
function
|
|
540
|
+
function k(a) {
|
|
498
541
|
if (!a) return !1;
|
|
499
542
|
const t = a.assignedNodes({ flatten: !0 });
|
|
500
543
|
return t.length ? t.some((e) => e.nodeType === Node.TEXT_NODE ? !!e.textContent?.trim() : e.nodeType === Node.ELEMENT_NODE) : !1;
|
|
501
544
|
}
|
|
502
|
-
function
|
|
545
|
+
function m(a, t) {
|
|
503
546
|
const e = a.getAttribute(t);
|
|
504
547
|
if (e == null) return !1;
|
|
505
548
|
const i = String(e).trim().toLowerCase();
|
|
506
549
|
return i !== "false" && i !== "0";
|
|
507
550
|
}
|
|
508
|
-
function
|
|
551
|
+
function M(a) {
|
|
509
552
|
return a === "none" || a === "large" || a === "full";
|
|
510
553
|
}
|
|
511
|
-
class
|
|
554
|
+
const E = class E extends N {
|
|
512
555
|
constructor() {
|
|
513
|
-
super(), this._input = null, this._clearBtn = null, this._debounceTimer = null, this._formUnregister = null, this._uid = Math.random().toString(36).slice(2, 9), this._autofocusApplied = !1, this.
|
|
556
|
+
super(), this._input = null, this._clearBtn = null, this._debounceTimer = null, this._formUnregister = null, this._uid = Math.random().toString(36).slice(2, 9), this._autofocusApplied = !1, this._internals = null, this._defaultValue = null, this._formDisabled = !1, this._slottedInput = null, this._dirty = !1, this._onLabelClick = (t) => {
|
|
557
|
+
t.target?.closest?.(".label") && this._input?.focus();
|
|
558
|
+
};
|
|
559
|
+
try {
|
|
560
|
+
this._internals = typeof this.attachInternals == "function" ? this.attachInternals() : null;
|
|
561
|
+
} catch {
|
|
562
|
+
this._internals = null;
|
|
563
|
+
}
|
|
564
|
+
this._onNativeKeyDown = this._onNativeKeyDown.bind(this), this._onNativeInput = this._onNativeInput.bind(this), this._onNativeChange = this._onNativeChange.bind(this), this._onClearClick = this._onClearClick.bind(this), this._onSlotChange = this._onSlotChange.bind(this);
|
|
514
565
|
}
|
|
515
566
|
static get observedAttributes() {
|
|
516
567
|
return [
|
|
@@ -553,31 +604,80 @@ class L extends S {
|
|
|
553
604
|
];
|
|
554
605
|
}
|
|
555
606
|
connectedCallback() {
|
|
556
|
-
super.connectedCallback(), this.root.addEventListener("slotchange", this._onSlotChange), this._registerWithForm();
|
|
607
|
+
this._dirty || (this._defaultValue = this.getAttribute("value") || ""), super.connectedCallback(), this.root.addEventListener("slotchange", this._onSlotChange), this.root.addEventListener("click", this._onLabelClick), this._registerWithForm();
|
|
608
|
+
}
|
|
609
|
+
/** The `<form>` this field belongs to, if any. */
|
|
610
|
+
get form() {
|
|
611
|
+
try {
|
|
612
|
+
return this._internals?.form ?? null;
|
|
613
|
+
} catch {
|
|
614
|
+
return null;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
formResetCallback() {
|
|
618
|
+
this._dirty = !1, this.value = this._defaultValue || "";
|
|
619
|
+
}
|
|
620
|
+
formDisabledCallback(t) {
|
|
621
|
+
this._formDisabled = t, this._input && (this._input.disabled = t || m(this, "disabled"));
|
|
622
|
+
}
|
|
623
|
+
_syncFormState() {
|
|
624
|
+
const t = this._internals;
|
|
625
|
+
if (t)
|
|
626
|
+
try {
|
|
627
|
+
if (this._slottedInput) {
|
|
628
|
+
t.setFormValue?.(null), t.setValidity?.({});
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
t.setFormValue?.(this.value);
|
|
632
|
+
const e = this._input;
|
|
633
|
+
e && typeof t.setValidity == "function" && (e.validity && !e.validity.valid ? t.setValidity(e.validity, e.validationMessage, e) : t.setValidity({}));
|
|
634
|
+
} catch {
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
_onNativeKeyDown(t) {
|
|
638
|
+
T(t, this, () => this.form);
|
|
557
639
|
}
|
|
558
640
|
disconnectedCallback() {
|
|
559
|
-
this.root.removeEventListener("slotchange", this._onSlotChange), this._detachListeners(), this._debounceTimer && (clearTimeout(this._debounceTimer), this._debounceTimer = null), this._formUnregister && (this._formUnregister(), this._formUnregister = null), this._autofocusApplied = !1, super.disconnectedCallback();
|
|
641
|
+
this.root.removeEventListener("slotchange", this._onSlotChange), this.root.removeEventListener("click", this._onLabelClick), this._detachListeners(), this._debounceTimer && (clearTimeout(this._debounceTimer), this._debounceTimer = null), this._formUnregister && (this._formUnregister(), this._formUnregister = null), this._autofocusApplied = !1, super.disconnectedCallback();
|
|
560
642
|
}
|
|
561
643
|
_syncHostTokens() {
|
|
562
644
|
const t = this.getAttribute("color");
|
|
563
645
|
t ? this.style.setProperty("--ui-input-accent", t) : this.style.removeProperty("--ui-input-accent");
|
|
564
646
|
const e = this.getAttribute("radius") || "";
|
|
565
|
-
e && !
|
|
647
|
+
e && !M(e) ? this.style.setProperty("--ui-input-border-radius", e) : this.style.removeProperty("--ui-input-border-radius");
|
|
648
|
+
}
|
|
649
|
+
/** The control: the author's <input slot="input"> when there is one, else the inner input. */
|
|
650
|
+
_bindInput() {
|
|
651
|
+
this._input && (this._input.removeEventListener("input", this._onNativeInput), this._input.removeEventListener("change", this._onNativeChange), this._input.removeEventListener("keydown", this._onNativeKeyDown));
|
|
652
|
+
const t = I(this);
|
|
653
|
+
this._slottedInput = t;
|
|
654
|
+
const e = this.root.querySelector(".control");
|
|
655
|
+
t ? e?.setAttribute("data-slotted-input", "") : e?.removeAttribute("data-slotted-input"), this._input = t || this.root.querySelector(".control > input"), t && !this.hasAttribute("value") && t.value && this.setAttribute("value", t.value), this._input && (this._input.addEventListener("input", this._onNativeInput), this._input.addEventListener("change", this._onNativeChange), t || this._input.addEventListener("keydown", this._onNativeKeyDown));
|
|
656
|
+
}
|
|
657
|
+
// The author's input keeps its own type, name, autocomplete, placeholder...: only the states the
|
|
658
|
+
// host was given are passed on, so the component never undoes what password managers rely on.
|
|
659
|
+
_syncSlottedInputAttrs(t) {
|
|
660
|
+
const e = m(this, "disabled") || this._formDisabled;
|
|
661
|
+
(this.hasAttribute("disabled") || this._formDisabled) && (t.disabled = e), this.hasAttribute("required") && (t.required = !0), this.hasAttribute("readonly") && (t.readOnly = !0);
|
|
566
662
|
}
|
|
567
663
|
_syncControlAttrs() {
|
|
568
664
|
if (this._syncHostTokens(), !this._input) return;
|
|
569
|
-
|
|
665
|
+
if (this._slottedInput) {
|
|
666
|
+
this._syncSlottedInputAttrs(this._slottedInput);
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
const t = this._input, e = this.getAttribute("type") || "text", i = this.getAttribute("placeholder") || "", n = this.getAttribute("name") || "", o = this.getAttribute("pattern") || "", s = this.getAttribute("inputmode") || "", g = this.getAttribute("autocomplete") || "", u = this.getAttribute("min") || "", l = this.getAttribute("max") || "", c = this.getAttribute("step") || "", d = this.getAttribute("spellcheck") || "", p = this.getAttribute("maxlength") || "", h = this.getAttribute("minlength") || "", b = m(this, "disabled"), f = this.hasAttribute("required"), v = this.hasAttribute("readonly");
|
|
570
670
|
try {
|
|
571
671
|
t.type = e;
|
|
572
672
|
} catch {
|
|
573
673
|
t.type = "text";
|
|
574
674
|
}
|
|
575
|
-
t.placeholder = i, t.disabled = b, t.required = f, t.readOnly = v, t.name = n,
|
|
675
|
+
t.placeholder = i, t.disabled = b || this._formDisabled, t.required = f, t.readOnly = v, t.name = n, o ? t.setAttribute("pattern", o) : t.removeAttribute("pattern"), s ? t.setAttribute("inputmode", s) : t.removeAttribute("inputmode"), g ? t.setAttribute("autocomplete", g) : t.removeAttribute("autocomplete"), u ? t.setAttribute("min", u) : t.removeAttribute("min"), l ? t.setAttribute("max", l) : t.removeAttribute("max"), c ? t.setAttribute("step", c) : t.removeAttribute("step"), d ? t.setAttribute("spellcheck", d) : t.removeAttribute("spellcheck"), p && Number.isFinite(Number(p)) ? t.setAttribute("maxlength", p) : t.removeAttribute("maxlength"), h && Number.isFinite(Number(h)) ? t.setAttribute("minlength", h) : t.removeAttribute("minlength");
|
|
576
676
|
}
|
|
577
677
|
attributeChangedCallback(t, e, i) {
|
|
578
678
|
if (e === i) return;
|
|
579
679
|
if (t === "value") {
|
|
580
|
-
this._syncInputValue(i || "");
|
|
680
|
+
this._dirty || (this._defaultValue = i || ""), this._syncInputValue(i || "");
|
|
581
681
|
return;
|
|
582
682
|
}
|
|
583
683
|
if (t === "name" && this._registerWithForm(), t === "autofocus" && !this.hasAttribute("autofocus") && (this._autofocusApplied = !1), (/* @__PURE__ */ new Set([
|
|
@@ -656,50 +756,53 @@ class L extends S {
|
|
|
656
756
|
_registerWithForm() {
|
|
657
757
|
this._formUnregister && (this._formUnregister(), this._formUnregister = null);
|
|
658
758
|
try {
|
|
659
|
-
const n = this.getRootNode().host?.closest?.("ui-form") || null || this.closest("ui-form"),
|
|
660
|
-
n && typeof n.registerField == "function" &&
|
|
661
|
-
name:
|
|
759
|
+
const n = this.getRootNode().host?.closest?.("ui-form") || null || this.closest("ui-form"), o = this.getAttribute("name");
|
|
760
|
+
n && typeof n.registerField == "function" && o && (this._formUnregister = n.registerField(o, {
|
|
761
|
+
name: o,
|
|
662
762
|
getValue: () => this.value,
|
|
663
|
-
setValue: (
|
|
664
|
-
this.value = String(
|
|
763
|
+
setValue: (s) => {
|
|
764
|
+
this.value = String(s ?? "");
|
|
665
765
|
},
|
|
666
766
|
validate: async () => this._input ? { valid: this._input.checkValidity(), message: this._input.validationMessage || void 0 } : { valid: !0 },
|
|
667
|
-
setError: (
|
|
668
|
-
|
|
767
|
+
setError: (s) => {
|
|
768
|
+
s ? (this.setAttribute("validation", "error"), this.setAttribute("data-error", s)) : (this.removeAttribute("validation"), this.removeAttribute("data-error"));
|
|
669
769
|
}
|
|
670
770
|
}));
|
|
671
771
|
} catch {
|
|
672
772
|
}
|
|
673
773
|
}
|
|
674
774
|
_detachListeners() {
|
|
675
|
-
this._input && (this._input.removeEventListener("input", this._onNativeInput), this._input.removeEventListener("change", this._onNativeChange)), this._clearBtn && this._clearBtn.removeEventListener("click", this._onClearClick), this._clearBtn = null;
|
|
775
|
+
this._input && (this._input.removeEventListener("input", this._onNativeInput), this._input.removeEventListener("change", this._onNativeChange), this._input.removeEventListener("keydown", this._onNativeKeyDown)), this._clearBtn && this._clearBtn.removeEventListener("click", this._onClearClick), this._clearBtn = null;
|
|
676
776
|
}
|
|
677
777
|
_syncInputValue(t) {
|
|
678
|
-
this._input && this._input.value !== t && (this._input.value = t), this._clearBtn && (
|
|
778
|
+
this._input && this._input.value !== t && (this._input.value = t), this._syncFormState(), this._clearBtn && (m(this, "clearable") && t.length > 0 && !m(this, "disabled") && !this.hasAttribute("readonly") ? this._clearBtn.removeAttribute("hidden") : this._clearBtn.setAttribute("hidden", ""));
|
|
679
779
|
const e = this.root.querySelector(".counter");
|
|
680
780
|
if (e && this.hasAttribute("counter")) {
|
|
681
|
-
const n = this.getAttribute("maxlength"),
|
|
682
|
-
e.textContent =
|
|
781
|
+
const n = this.getAttribute("maxlength"), o = n ? `${t.length}/${n}` : String(t.length);
|
|
782
|
+
e.textContent = o;
|
|
683
783
|
}
|
|
684
784
|
const i = this.root.querySelector(".shell");
|
|
685
785
|
i && i.setAttribute("data-has-value", t ? "true" : "false");
|
|
686
786
|
}
|
|
687
|
-
_onSlotChange() {
|
|
688
|
-
this._syncDerivedState();
|
|
787
|
+
_onSlotChange(t) {
|
|
788
|
+
t?.target?.name === "input" && (this._bindInput(), this._syncControlAttrs(), this._syncInputValue(this.value)), this._syncDerivedState();
|
|
689
789
|
}
|
|
690
790
|
_syncDerivedState() {
|
|
691
|
-
const t = this.root.querySelector('slot[name="label"]'), e = this.root.querySelector('slot[name="description"]'), i = this.root.querySelector('slot[name="error"]'), n = this.root.querySelector('slot[name="prefix"]'),
|
|
692
|
-
b && (
|
|
693
|
-
const
|
|
694
|
-
if (C && (
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
791
|
+
const t = this.root.querySelector('slot[name="label"]'), e = this.root.querySelector('slot[name="description"]'), i = this.root.querySelector('slot[name="error"]'), n = this.root.querySelector('slot[name="prefix"]'), o = this.root.querySelector('slot[name="suffix"]'), s = (this.getAttribute("label") || "").trim(), g = (this.getAttribute("description") || "").trim(), u = (this.getAttribute("data-error") || "").trim(), l = !!s || k(t), c = !!g || k(e), d = !!u || k(i), p = k(n), h = k(o), b = this.root.querySelector(".label"), f = this.root.querySelector(".description"), v = this.root.querySelector(".prefix"), _ = this.root.querySelector(".suffix"), y = this.root.querySelector(".meta"), w = this.root.querySelector(".footer"), A = this.root.querySelector(".error"), C = this.root.querySelector(".counter");
|
|
792
|
+
b && (l ? b.removeAttribute("hidden") : b.setAttribute("hidden", "")), f && (c ? f.removeAttribute("hidden") : f.setAttribute("hidden", "")), v && (p ? v.removeAttribute("hidden") : v.setAttribute("hidden", "")), _ && (h ? _.removeAttribute("hidden") : _.setAttribute("hidden", "")), y && (l || c ? y.removeAttribute("hidden") : y.setAttribute("hidden", ""));
|
|
793
|
+
const z = this.hasAttribute("counter");
|
|
794
|
+
if (C && (z ? C.removeAttribute("hidden") : C.setAttribute("hidden", "")), A && (d ? A.removeAttribute("hidden") : A.setAttribute("hidden", "")), w && (d || z ? w.removeAttribute("hidden") : w.setAttribute("hidden", "")), this._slottedInput) {
|
|
795
|
+
const x = (this.getAttribute("label") || t?.assignedNodes({ flatten: !0 }).map((q) => q.textContent || "").join(" ") || this.getAttribute("aria-label") || "").trim(), $ = (this.getAttribute("description") || "").trim();
|
|
796
|
+
L(this._slottedInput, x, $), this.getAttribute("validation") === "error" || !!u ? this._slottedInput.setAttribute("aria-invalid", "true") : this._slottedInput.removeAttribute("aria-invalid");
|
|
797
|
+
} else if (this._input) {
|
|
798
|
+
V(this._input, this, l ? `${this._uid}-label` : null);
|
|
799
|
+
const x = [];
|
|
800
|
+
c && x.push(`${this._uid}-description`), d && x.push(`${this._uid}-error`), D(this._input, this, this._uid, x), this.getAttribute("validation") === "error" || !!u ? this._input.setAttribute("aria-invalid", "true") : this._input.removeAttribute("aria-invalid"), this.hasAttribute("required") ? this._input.setAttribute("aria-required", "true") : this._input.removeAttribute("aria-required");
|
|
698
801
|
}
|
|
699
802
|
}
|
|
700
803
|
_onNativeInput(t) {
|
|
701
804
|
const e = t.target.value;
|
|
702
|
-
this.getAttribute("value") !== e ? this.setAttribute("value", e) : this._syncInputValue(e), this._emitValueEvent("input", e);
|
|
805
|
+
this._dirty = !0, this.getAttribute("value") !== e ? this.setAttribute("value", e) : this._syncInputValue(e), this._emitValueEvent("input", e);
|
|
703
806
|
const i = Number(this.getAttribute("debounce") || 0);
|
|
704
807
|
i > 0 ? (this._debounceTimer && clearTimeout(this._debounceTimer), this._debounceTimer = setTimeout(() => {
|
|
705
808
|
this._emitValueEvent("debounced-input", e), this._debounceTimer = null;
|
|
@@ -710,7 +813,7 @@ class L extends S {
|
|
|
710
813
|
this._emitValueEvent("change", e);
|
|
711
814
|
}
|
|
712
815
|
_onClearClick(t) {
|
|
713
|
-
if (t.preventDefault(), !(
|
|
816
|
+
if (t.preventDefault(), !(m(this, "disabled") || this.hasAttribute("readonly")) && this._input) {
|
|
714
817
|
this.value = "", this._input.value = "", this._input.dispatchEvent(new Event("input", { bubbles: !0 })), this._input.dispatchEvent(new Event("change", { bubbles: !0 })), this.dispatchEvent(new CustomEvent("clear", { bubbles: !0, composed: !0 }));
|
|
715
818
|
try {
|
|
716
819
|
this._input.focus({ preventScroll: !0 });
|
|
@@ -720,17 +823,17 @@ class L extends S {
|
|
|
720
823
|
}
|
|
721
824
|
}
|
|
722
825
|
render() {
|
|
723
|
-
const t = this.getAttribute("value") || "", e = this.getAttribute("placeholder") || "", i =
|
|
826
|
+
const t = this.getAttribute("value") || "", e = this.getAttribute("placeholder") || "", i = m(this, "disabled"), n = m(this, "clearable"), o = this.getAttribute("type") || "text", s = this.getAttribute("name") || "", g = this.hasAttribute("required"), u = this.getAttribute("pattern") || "", l = this.getAttribute("inputmode") || "", c = this.getAttribute("autocomplete") || "", d = this.getAttribute("min") || "", p = this.getAttribute("max") || "", h = this.getAttribute("step") || "", b = this.getAttribute("spellcheck") || "", f = this.getAttribute("maxlength") || "", v = this.getAttribute("minlength") || "", _ = this.hasAttribute("readonly"), y = this.getAttribute("label") || "", w = this.getAttribute("description") || "", A = this.getAttribute("data-error") || "", C = this.getAttribute("validation") || "", z = this.hasAttribute("floating-label"), x = g ? '<span class="required" aria-hidden="true">*</span>' : "";
|
|
724
827
|
this._syncHostTokens(), this.setContent(`
|
|
725
|
-
<style>${
|
|
828
|
+
<style>${B}</style>
|
|
726
829
|
<div class="root" part="root">
|
|
727
830
|
<div class="meta" part="meta">
|
|
728
831
|
<label class="label" id="${this._uid}-label" part="label">
|
|
729
|
-
<slot name="label">${r(
|
|
730
|
-
${
|
|
832
|
+
<slot name="label">${r(y)}</slot>
|
|
833
|
+
${x}
|
|
731
834
|
</label>
|
|
732
835
|
<p class="description" id="${this._uid}-description" part="description">
|
|
733
|
-
<slot name="description">${r(
|
|
836
|
+
<slot name="description">${r(w)}</slot>
|
|
734
837
|
</p>
|
|
735
838
|
</div>
|
|
736
839
|
|
|
@@ -738,41 +841,42 @@ class L extends S {
|
|
|
738
841
|
<span class="prefix" part="prefix"><slot name="prefix"></slot></span>
|
|
739
842
|
|
|
740
843
|
<div class="control" part="control">
|
|
844
|
+
<slot name="input"></slot>
|
|
741
845
|
<input
|
|
742
846
|
part="input"
|
|
743
|
-
type="${r(
|
|
744
|
-
name="${r(
|
|
847
|
+
type="${r(o)}"
|
|
848
|
+
name="${r(s)}"
|
|
745
849
|
value="${r(t)}"
|
|
746
850
|
placeholder="${r(e)}"
|
|
747
851
|
${g ? "required" : ""}
|
|
748
|
-
${
|
|
749
|
-
${
|
|
750
|
-
${
|
|
751
|
-
${
|
|
752
|
-
${
|
|
852
|
+
${u ? `pattern="${r(u)}"` : ""}
|
|
853
|
+
${l ? `inputmode="${r(l)}"` : ""}
|
|
854
|
+
${c ? `autocomplete="${r(c)}"` : ""}
|
|
855
|
+
${d ? `min="${r(d)}"` : ""}
|
|
856
|
+
${p ? `max="${r(p)}"` : ""}
|
|
753
857
|
${h ? `step="${r(h)}"` : ""}
|
|
754
858
|
${b ? `spellcheck="${r(b)}"` : ""}
|
|
755
859
|
${f ? `maxlength="${r(f)}"` : ""}
|
|
756
860
|
${v ? `minlength="${r(v)}"` : ""}
|
|
757
861
|
${i ? "disabled" : ""}
|
|
758
|
-
${
|
|
862
|
+
${_ ? "readonly" : ""}
|
|
759
863
|
/>
|
|
760
|
-
${
|
|
864
|
+
${z ? `<span class="floating-label" part="floating-label">${r(y || e || s || "Input")}</span>` : ""}
|
|
761
865
|
</div>
|
|
762
866
|
|
|
763
|
-
<button class="clear-btn" part="clear" aria-label="Clear" ${n && t && !i && !
|
|
867
|
+
<button class="clear-btn" part="clear" aria-label="Clear" ${n && t && !i && !_ ? "" : "hidden"}>${F}</button>
|
|
764
868
|
|
|
765
869
|
<span class="suffix" part="suffix"><slot name="suffix"></slot></span>
|
|
766
870
|
</div>
|
|
767
871
|
|
|
768
872
|
<div class="footer" part="footer">
|
|
769
873
|
<p class="error" id="${this._uid}-error" part="error" aria-live="polite">
|
|
770
|
-
${
|
|
874
|
+
${A ? r(A) : '<slot name="error"></slot>'}
|
|
771
875
|
</p>
|
|
772
876
|
<p class="counter" part="counter"></p>
|
|
773
877
|
</div>
|
|
774
878
|
</div>
|
|
775
|
-
`), this._detachListeners(), this.
|
|
879
|
+
`), this._detachListeners(), this._bindInput(), this._clearBtn = this.root.querySelector("button.clear-btn"), this._clearBtn?.addEventListener("click", this._onClearClick), this._syncControlAttrs(), this._syncInputValue(this._slottedInput ? this.value : t), this._syncDerivedState(), this.hasAttribute("autofocus") && !this._autofocusApplied && (this._autofocusApplied = !0, queueMicrotask(() => {
|
|
776
880
|
if (this.isConnected)
|
|
777
881
|
try {
|
|
778
882
|
this._input?.focus({ preventScroll: !0 });
|
|
@@ -784,8 +888,10 @@ class L extends S {
|
|
|
784
888
|
shouldRenderOnAttributeChange(t, e, i) {
|
|
785
889
|
return t === "label" || t === "description" || t === "data-error" || t === "floating-label";
|
|
786
890
|
}
|
|
787
|
-
}
|
|
788
|
-
|
|
891
|
+
};
|
|
892
|
+
E.formAssociated = !0;
|
|
893
|
+
let S = E;
|
|
894
|
+
typeof customElements < "u" && !customElements.get("ui-input") && customElements.define("ui-input", S);
|
|
789
895
|
export {
|
|
790
|
-
|
|
896
|
+
S as UIInput
|
|
791
897
|
};
|