@editora/ui-core 0.1.19 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ElementBase-1b301e7f.js → ElementBase-EV6mVBUV.js} +1 -1
- package/dist/{ElementBase-909688f3.mjs → ElementBase-YlTLMsGk.mjs} +3 -3
- package/dist/accordion.cjs.js +3 -3
- package/dist/accordion.esm.js +39 -62
- package/dist/alert-dialog.cjs.js +19 -19
- package/dist/alert-dialog.esm.js +69 -87
- package/dist/alert.cjs.js +1 -1
- package/dist/alert.esm.js +4 -7
- package/dist/anchor.cjs.js +2 -2
- package/dist/anchor.esm.js +3 -3
- package/dist/animated-beam.cjs.js +83 -83
- package/dist/animated-beam.esm.js +250 -277
- package/dist/animated-list.cjs.js +4 -4
- package/dist/animated-list.esm.js +47 -61
- package/dist/animated-text.cjs.js +2 -2
- package/dist/animated-text.esm.js +13 -24
- package/dist/app-header.cjs.js +3 -3
- package/dist/app-header.esm.js +11 -13
- package/dist/aspect-ratio.cjs.js +1 -1
- package/dist/aspect-ratio.esm.js +4 -7
- package/dist/avatar.cjs.js +1 -1
- package/dist/avatar.esm.js +7 -13
- package/dist/badge.cjs.js +1 -1
- package/dist/badge.esm.js +4 -7
- package/dist/block-controls.cjs.js +2 -2
- package/dist/block-controls.esm.js +19 -35
- package/dist/box.cjs.js +1 -1
- package/dist/box.esm.js +8 -15
- package/dist/breadcrumb.cjs.js +2 -2
- package/dist/breadcrumb.esm.js +20 -37
- package/dist/button.cjs.js +1 -521
- package/dist/button.esm.js +2 -671
- package/dist/{calendar-2c11b824.mjs → calendar-DLY4acgn.mjs} +293 -342
- package/dist/{calendar-a8735e40.js → calendar-Dkof-FTK.js} +25 -25
- package/dist/calendar.cjs.js +1 -1
- package/dist/calendar.esm.js +8 -9
- package/dist/card.cjs.js +4 -4
- package/dist/card.esm.js +13 -19
- package/dist/chart.cjs.js +64 -64
- package/dist/chart.esm.js +223 -254
- package/dist/checkbox.cjs.js +1 -1
- package/dist/checkbox.esm.js +2 -3
- package/dist/collapsible.cjs.js +1 -1
- package/dist/collapsible.esm.js +5 -9
- package/dist/{collection-a1aac0c6.mjs → collection-C7URGjEI.mjs} +8 -14
- package/dist/collection.cjs.js +1 -1
- package/dist/collection.esm.js +30 -29
- package/dist/color-picker.cjs.js +10 -10
- package/dist/color-picker.esm.js +190 -253
- package/dist/combobox.cjs.js +13 -13
- package/dist/combobox.esm.js +93 -126
- package/dist/command-palette.cjs.js +3 -3
- package/dist/command-palette.esm.js +19 -30
- package/dist/command.cjs.js +4 -4
- package/dist/command.esm.js +41 -53
- package/dist/components/ui-collection.d.ts.map +1 -1
- package/dist/components/ui-multi-select.d.ts.map +1 -1
- package/dist/components/ui-orbiter.d.ts.map +1 -1
- package/dist/components/ui-portal.d.ts.map +1 -1
- package/dist/components/ui-positioner.d.ts.map +1 -1
- package/dist/components/ui-skeleton.d.ts.map +1 -1
- package/dist/components/ui-sortable.d.ts +8 -0
- package/dist/components/ui-sortable.d.ts.map +1 -1
- package/dist/components/ui-split-button.d.ts +1 -0
- package/dist/components/ui-split-button.d.ts.map +1 -1
- package/dist/components/ui-tabs.d.ts.map +1 -1
- package/dist/components/ui-textarea.d.ts.map +1 -1
- package/dist/components/ui-time-picker.d.ts.map +1 -1
- package/dist/container.cjs.js +2 -2
- package/dist/container.esm.js +2 -3
- package/dist/context-menu.cjs.js +8 -8
- package/dist/context-menu.esm.js +157 -219
- package/dist/control-group.cjs.js +1 -1
- package/dist/control-group.esm.js +2 -3
- package/dist/data-table.cjs.js +4 -4
- package/dist/data-table.esm.js +299 -381
- package/dist/date-field.cjs.js +3 -3
- package/dist/date-field.esm.js +68 -80
- package/dist/date-picker.cjs.js +9 -9
- package/dist/date-picker.esm.js +69 -97
- package/dist/date-range-picker.cjs.js +3 -3
- package/dist/date-range-picker.esm.js +32 -56
- package/dist/date-range-time-picker.cjs.js +9 -9
- package/dist/date-range-time-picker.esm.js +111 -140
- package/dist/date-time-picker.cjs.js +7 -7
- package/dist/date-time-picker.esm.js +115 -147
- package/dist/date-time-utils-Dmost5Ee.js +1 -0
- package/dist/date-time-utils-y1N2gvG2.mjs +268 -0
- package/dist/description.cjs.js +1 -1
- package/dist/description.esm.js +3 -5
- package/dist/dialog.cjs.js +12 -12
- package/dist/dialog.esm.js +44 -63
- package/dist/direction-provider.cjs.js +1 -1
- package/dist/direction-provider.esm.js +2 -3
- package/dist/{dismissable-layer-9c7e6b58.mjs → dismissable-layer-BmPIoK80.mjs} +29 -33
- package/dist/dismissable-layer-DNfrKA20.js +1 -0
- package/dist/dismissable-layer.cjs.js +2 -2
- package/dist/dismissable-layer.esm.js +4 -6
- package/dist/dock.cjs.js +5 -5
- package/dist/dock.esm.js +134 -155
- package/dist/drawer.cjs.js +2 -2
- package/dist/drawer.esm.js +18 -35
- package/dist/dropdown.cjs.js +2 -2
- package/dist/dropdown.esm.js +119 -149
- package/dist/dropzone.cjs.js +1 -1
- package/dist/dropzone.esm.js +0 -1
- package/dist/empty-state.cjs.js +1 -1
- package/dist/empty-state.esm.js +1 -1
- package/dist/field-error.cjs.js +1 -1
- package/dist/field-error.esm.js +3 -5
- package/dist/field.cjs.js +5 -5
- package/dist/field.esm.js +27 -34
- package/dist/fieldset.cjs.js +4 -4
- package/dist/fieldset.esm.js +19 -24
- package/dist/file-upload.cjs.js +4 -4
- package/dist/file-upload.esm.js +69 -93
- package/dist/flex.cjs.js +1 -1
- package/dist/flex.esm.js +5 -9
- package/dist/floating-toolbar.cjs.js +4 -4
- package/dist/floating-toolbar.esm.js +60 -85
- package/dist/focus-scope-Bwug2gDv.js +1 -0
- package/dist/{focus-scope-103833ee.mjs → focus-scope-CmEsG5UZ.mjs} +39 -48
- package/dist/focus-scope.cjs.js +2 -2
- package/dist/focus-scope.esm.js +15 -20
- package/dist/form.cjs.js +2 -2
- package/dist/form.esm.js +26 -53
- package/dist/gantt.cjs.js +43 -43
- package/dist/gantt.esm.js +295 -322
- package/dist/grid.cjs.js +1 -1
- package/dist/grid.esm.js +5 -9
- package/dist/hover-card.cjs.js +4 -4
- package/dist/hover-card.esm.js +22 -28
- package/dist/icon-cloud.cjs.js +7 -7
- package/dist/icon-cloud.esm.js +48 -62
- package/dist/icon.cjs.js +1 -1
- package/dist/icon.esm.js +2 -4
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +378 -390
- package/dist/inline-edit.cjs.js +11 -11
- package/dist/inline-edit.esm.js +32 -36
- package/dist/input.cjs.js +17 -17
- package/dist/input.esm.js +50 -63
- package/dist/label.cjs.js +2 -2
- package/dist/label.esm.js +8 -17
- package/dist/layout.cjs.js +2 -2
- package/dist/layout.esm.js +20 -26
- package/dist/listbox-B6QgECax.js +46 -0
- package/dist/listbox-DJamVeFj.mjs +200 -0
- package/dist/listbox.cjs.js +1 -1
- package/dist/listbox.esm.js +2 -4
- package/dist/marquee.cjs.js +5 -5
- package/dist/marquee.esm.js +33 -50
- package/dist/masonry-grid.cjs.js +1 -1
- package/dist/masonry-grid.esm.js +5 -9
- package/dist/menu.cjs.js +3 -3
- package/dist/menu.esm.js +106 -126
- package/dist/menubar.cjs.js +5 -5
- package/dist/menubar.esm.js +118 -164
- package/dist/meter.cjs.js +2 -2
- package/dist/meter.esm.js +4 -4
- package/dist/multi-select.cjs.js +5 -5
- package/dist/multi-select.esm.js +125 -137
- package/dist/navigation-menu.cjs.js +4 -4
- package/dist/navigation-menu.esm.js +44 -55
- package/dist/number-field.cjs.js +2 -2
- package/dist/number-field.esm.js +73 -98
- package/dist/number-ticker.cjs.js +3 -3
- package/dist/number-ticker.esm.js +22 -43
- package/dist/odometer.cjs.js +1 -1
- package/dist/odometer.esm.js +5 -9
- package/dist/orbiter.cjs.js +13 -13
- package/dist/orbiter.esm.js +79 -90
- package/dist/{overlayManager-5bbd4dc3.mjs → overlayManager-BJjU1VA8.mjs} +4 -5
- package/dist/{overlayManager-0eda4e08.js → overlayManager-CSy3fJmJ.js} +1 -1
- package/dist/pagination.cjs.js +2 -2
- package/dist/pagination.esm.js +14 -18
- package/dist/{panel-group-a376cc5e.mjs → panel-group-8sVNnGxg.mjs} +24 -46
- package/dist/panel-group-CaD0_KQf.js +36 -0
- package/dist/panel-group.cjs.js +1 -1
- package/dist/panel-group.esm.js +2 -5
- package/dist/panel.cjs.js +4 -4
- package/dist/panel.esm.js +8 -10
- package/dist/password-field.cjs.js +9 -9
- package/dist/password-field.esm.js +62 -82
- package/dist/pin-input.cjs.js +3 -3
- package/dist/pin-input.esm.js +33 -39
- package/dist/placement-grid.cjs.js +4 -4
- package/dist/placement-grid.esm.js +108 -131
- package/dist/plugin-panel.cjs.js +7 -7
- package/dist/plugin-panel.esm.js +13 -15
- package/dist/popover.cjs.js +2 -2
- package/dist/popover.esm.js +21 -31
- package/dist/portal-DgpQ3Jo1.js +1 -0
- package/dist/{portal-fe73e5cc.mjs → portal-bR42gHvG.mjs} +43 -48
- package/dist/portal.cjs.js +3 -3
- package/dist/portal.esm.js +20 -28
- package/dist/{positioner-e9770c66.mjs → positioner-D0VGxtYU.mjs} +189 -209
- package/dist/positioner-D_fqyx_j.js +1 -0
- package/dist/positioner.cjs.js +2 -2
- package/dist/positioner.esm.js +22 -28
- package/dist/presence.cjs.js +1 -1
- package/dist/presence.esm.js +7 -13
- package/dist/primitives/auto-scroll.d.ts +9 -0
- package/dist/primitives/auto-scroll.d.ts.map +1 -0
- package/dist/primitives/selector.d.ts +4 -0
- package/dist/primitives/selector.d.ts.map +1 -0
- package/dist/progress.cjs.js +1 -1
- package/dist/progress.esm.js +5 -9
- package/dist/quick-actions.cjs.js +6 -6
- package/dist/quick-actions.esm.js +52 -62
- package/dist/radio-group.cjs.js +13 -13
- package/dist/radio-group.esm.js +39 -51
- package/dist/radio.cjs.js +1 -1
- package/dist/radio.esm.js +5 -9
- package/dist/rating.cjs.js +1 -1
- package/dist/rating.esm.js +12 -23
- package/dist/{roving-focus-group-4350c9a7.mjs → roving-focus-group-Dbm1Jko_.mjs} +3 -6
- package/dist/roving-focus-group.cjs.js +1 -1
- package/dist/roving-focus-group.esm.js +3 -5
- package/dist/runtime-CTaOSmBj.js +1 -0
- package/dist/{runtime-161f68a2.mjs → runtime-D1gFh1fS.mjs} +338 -366
- package/dist/runtime.cjs.js +1 -1
- package/dist/runtime.esm.js +6 -6
- package/dist/scroll-area.cjs.js +3 -3
- package/dist/scroll-area.esm.js +38 -46
- package/dist/{scroll-lock-31da444f.mjs → scroll-lock-LfqXXqsu.mjs} +5 -9
- package/dist/section.cjs.js +1 -1
- package/dist/section.esm.js +1 -1
- package/dist/select.cjs.js +7 -7
- package/dist/select.esm.js +67 -97
- package/dist/selection-popup.cjs.js +1 -1
- package/dist/selection-popup.esm.js +8 -15
- package/dist/selector-BvAh35ve.js +1 -0
- package/dist/selector-WI8pD7YO.mjs +18 -0
- package/dist/separator.cjs.js +1 -1
- package/dist/separator.esm.js +1 -1
- package/dist/sidebar.cjs.js +18 -18
- package/dist/sidebar.esm.js +117 -139
- package/dist/skeleton.cjs.js +11 -11
- package/dist/skeleton.esm.js +27 -24
- package/dist/slider.cjs.js +1 -1
- package/dist/slider.esm.js +6 -11
- package/dist/slot.cjs.js +4 -4
- package/dist/slot.esm.js +16 -19
- package/dist/sortable.cjs.js +79 -65
- package/dist/sortable.esm.js +714 -734
- package/dist/spinning-text.cjs.js +12 -12
- package/dist/spinning-text.esm.js +80 -92
- package/dist/split-button.cjs.js +4 -4
- package/dist/split-button.esm.js +77 -62
- package/dist/splitter.cjs.js +1 -1
- package/dist/splitter.esm.js +1 -1
- package/dist/stepper.cjs.js +8 -8
- package/dist/stepper.esm.js +32 -52
- package/dist/switch.cjs.js +7 -7
- package/dist/switch.esm.js +23 -31
- package/dist/table.cjs.js +2 -2
- package/dist/table.esm.js +46 -56
- package/dist/tabs.cjs.js +8 -8
- package/dist/tabs.esm.js +89 -109
- package/dist/tags-input.cjs.js +4 -4
- package/dist/tags-input.esm.js +45 -62
- package/dist/textarea.cjs.js +10 -10
- package/dist/textarea.esm.js +49 -52
- package/dist/time-field.cjs.js +4 -4
- package/dist/time-field.esm.js +70 -84
- package/dist/time-picker.cjs.js +22 -22
- package/dist/time-picker.esm.js +88 -110
- package/dist/timeline.cjs.js +1 -1
- package/dist/timeline.esm.js +3 -5
- package/dist/toast.cjs.js +2 -2
- package/dist/toast.esm.js +33 -47
- package/dist/toggle-group.cjs.js +6 -6
- package/dist/toggle-group.esm.js +85 -105
- package/dist/toggle.cjs.js +1 -1
- package/dist/toggle.esm.js +3 -5
- package/dist/toolbar.cjs.js +1 -1
- package/dist/toolbar.esm.js +13 -24
- package/dist/tooltip.cjs.js +2 -2
- package/dist/tooltip.esm.js +31 -42
- package/dist/transfer-list.cjs.js +31 -31
- package/dist/transfer-list.esm.js +114 -127
- package/dist/{tree-dcd74a4a.mjs → tree-B3kE8ESs.mjs} +55 -62
- package/dist/tree-Dx_kv_ih.js +39 -0
- package/dist/tree-item.cjs.js +2 -2
- package/dist/tree-item.esm.js +2 -3
- package/dist/tree.cjs.js +1 -1
- package/dist/tree.esm.js +2 -5
- package/dist/ui-button-Q0GNNWKC.mjs +665 -0
- package/dist/ui-button-rXQOS9QJ.js +521 -0
- package/dist/{icon-9e9da03b.js → ui-icon-BzVNC_lr.js} +4 -4
- package/dist/{icon-e2a85cc1.mjs → ui-icon-YI6lyuqU.mjs} +58 -65
- package/dist/visually-hidden.cjs.js +1 -1
- package/dist/visually-hidden.esm.js +1 -1
- package/dist/wizard.cjs.js +14 -14
- package/dist/wizard.esm.js +85 -105
- package/package.json +2 -2
- package/dist/date-time-utils-66480de4.js +0 -1
- package/dist/date-time-utils-a2c7af25.mjs +0 -307
- package/dist/dismissable-layer-193e3bed.js +0 -1
- package/dist/focus-scope-2b12b4e7.js +0 -1
- package/dist/listbox-308789a0.mjs +0 -210
- package/dist/listbox-ef2f708e.js +0 -46
- package/dist/panel-group-40254cdd.js +0 -36
- package/dist/portal-c69756c0.js +0 -1
- package/dist/positioner-33529bb8.js +0 -1
- package/dist/runtime-3f13807b.js +0 -1
- package/dist/tree-0a7a8d05.js +0 -39
- /package/dist/{collection-a2969ad2.js → collection-qv8A8rq4.js} +0 -0
- /package/dist/{menu-item-styles-27fdbac4.mjs → menu-item-styles-CZiPwPwl.mjs} +0 -0
- /package/dist/{menu-item-styles-83ad1e22.js → menu-item-styles-CbNUEwP2.js} +0 -0
- /package/dist/{roving-focus-group-5c059bf9.js → roving-focus-group-BdJ_4Njm.js} +0 -0
- /package/dist/{scroll-lock-d7b0df21.js → scroll-lock-BX6e3Ced.js} +0 -0
package/dist/inline-edit.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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 h=require("./ElementBase-EV6mVBUV.js"),b=`
|
|
2
2
|
:host {
|
|
3
3
|
--ui-inline-edit-bg: transparent;
|
|
4
4
|
--ui-inline-edit-border: 1px dashed transparent;
|
|
@@ -100,19 +100,19 @@
|
|
|
100
100
|
gap: 8px;
|
|
101
101
|
justify-content: flex-end;
|
|
102
102
|
}
|
|
103
|
-
`;function o(
|
|
104
|
-
<style>${
|
|
103
|
+
`;function o(d){return d.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}class c extends h.ElementBase{constructor(){super(...arguments),this._draft="",this._formUnregister=null,this._lastFocusTarget=null}static get observedAttributes(){return["value","placeholder","editing","multiline","disabled","readonly","name"]}get value(){return this.getAttribute("value")||""}set value(e){e?this.setAttribute("value",e):this.removeAttribute("value")}startEditing(){this.hasAttribute("disabled")||this.hasAttribute("readonly")||(this._lastFocusTarget=document.activeElement||this,this._draft=this.value,this.setAttribute("editing",""),queueMicrotask(()=>{const e=this.root.querySelector(".field");e?.focus(),e?.select?.()}),this.dispatchEvent(new CustomEvent("editing-change",{detail:{editing:!0},bubbles:!0,composed:!0})))}cancelEditing(){this.removeAttribute("editing"),this._draft=this.value,this.dispatchEvent(new CustomEvent("cancel",{detail:{value:this.value},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("editing-change",{detail:{editing:!1},bubbles:!0,composed:!0})),this._restoreFocus()}saveEditing(){if(this.hasAttribute("disabled")||this.hasAttribute("readonly"))return;if(this.hasAttribute("required")&&!this._draft.trim()){this.setAttribute("invalid","");return}const e=this.value;this._draft?this.setAttribute("value",this._draft):this.removeAttribute("value"),this.removeAttribute("invalid"),this.removeAttribute("editing"),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value,previousValue:e,source:"save"},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("save",{detail:{value:this.value,previousValue:e},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("editing-change",{detail:{editing:!1},bubbles:!0,composed:!0})),this._restoreFocus()}connectedCallback(){super.connectedCallback(),this._draft=this.value,this._registerWithForm()}disconnectedCallback(){this._formUnregister&&this._formUnregister(),super.disconnectedCallback()}attributeChangedCallback(e,a,s){a!==s&&(e==="name"&&this.isConnected&&this._registerWithForm(),e==="value"&&!this.hasAttribute("editing")&&(this._draft=s||""),this.isConnected&&this.requestRender())}render(){const e=this.hasAttribute("editing")?this._draft:this.value,a=this.getAttribute("placeholder")||"Add value",s=this.hasAttribute("multiline"),r=this.hasAttribute("editing"),n=!this.value,t=this.hasAttribute("disabled")||this.hasAttribute("readonly");this.setContent(`
|
|
104
|
+
<style>${b}</style>
|
|
105
105
|
<div class="root">
|
|
106
|
-
<div class="display"${
|
|
107
|
-
<div class="value" data-empty="${
|
|
108
|
-
<button class="edit-btn" type="button"${
|
|
106
|
+
<div class="display"${r?" hidden":""}>
|
|
107
|
+
<div class="value" data-empty="${n}">${o(n?a:this.value)}</div>
|
|
108
|
+
<button class="edit-btn" type="button"${t?" disabled":""}>Edit</button>
|
|
109
109
|
</div>
|
|
110
|
-
<div class="editor"${
|
|
111
|
-
${
|
|
110
|
+
<div class="editor"${r?"":" hidden"}>
|
|
111
|
+
${s?`<textarea class="field" rows="4"${t?" disabled":""}>${o(e)}</textarea>`:`<input class="field" type="text" value="${o(e)}"${t?" disabled":""} />`}
|
|
112
112
|
<div class="actions">
|
|
113
|
-
<button class="cancel-btn" type="button"${
|
|
114
|
-
<button class="save-btn" type="button"${
|
|
113
|
+
<button class="cancel-btn" type="button"${t?" disabled":""}>Cancel</button>
|
|
114
|
+
<button class="save-btn" type="button"${t?" disabled":""}>Save</button>
|
|
115
115
|
</div>
|
|
116
116
|
</div>
|
|
117
117
|
</div>
|
|
118
|
-
`);const
|
|
118
|
+
`);const u=this.root.querySelector(".field");u?.addEventListener("input",l=>{this._draft=l.target.value}),u?.addEventListener("keydown",l=>{const i=l;i.key==="Escape"&&(i.preventDefault(),this.cancelEditing()),!s&&i.key==="Enter"&&(i.preventDefault(),this.saveEditing()),(i.metaKey||i.ctrlKey)&&i.key==="Enter"&&(i.preventDefault(),this.saveEditing())}),this.root.querySelector(".edit-btn")?.addEventListener("click",()=>this.startEditing()),this.root.querySelector(".cancel-btn")?.addEventListener("click",()=>this.cancelEditing()),this.root.querySelector(".save-btn")?.addEventListener("click",()=>this.saveEditing())}_registerWithForm(){this._formUnregister&&(this._formUnregister(),this._formUnregister=null);try{const r=this.getRootNode().host?.closest?.("ui-form")||null||this.closest("ui-form"),n=this.getAttribute("name");r&&typeof r.registerField=="function"&&n&&(this._formUnregister=r.registerField(n,{name:n,getValue:()=>this.value,setValue:t=>{t==null||t===""?this.removeAttribute("value"):this.setAttribute("value",String(t))}}))}catch{}}_restoreFocus(){const e=this._lastFocusTarget&&this._lastFocusTarget.isConnected?this._lastFocusTarget:this.root.querySelector(".edit-btn");e&&(queueMicrotask(()=>{try{e.focus({preventScroll:!0})}catch{e.focus()}}),this._lastFocusTarget=null)}}typeof customElements<"u"&&!customElements.get("ui-inline-edit")&&customElements.define("ui-inline-edit",c);exports.UIInlineEdit=c;
|
package/dist/inline-edit.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as
|
|
2
|
-
const
|
|
1
|
+
import { E as c } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
|
+
const h = `
|
|
3
3
|
:host {
|
|
4
4
|
--ui-inline-edit-bg: transparent;
|
|
5
5
|
--ui-inline-edit-border: 1px dashed transparent;
|
|
@@ -102,10 +102,10 @@ const p = `
|
|
|
102
102
|
justify-content: flex-end;
|
|
103
103
|
}
|
|
104
104
|
`;
|
|
105
|
-
function o(
|
|
106
|
-
return
|
|
105
|
+
function o(d) {
|
|
106
|
+
return d.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
107
107
|
}
|
|
108
|
-
class
|
|
108
|
+
class b extends c {
|
|
109
109
|
constructor() {
|
|
110
110
|
super(...arguments), this._draft = "", this._formUnregister = null, this._lastFocusTarget = null;
|
|
111
111
|
}
|
|
@@ -120,17 +120,15 @@ class g extends v {
|
|
|
120
120
|
}
|
|
121
121
|
startEditing() {
|
|
122
122
|
this.hasAttribute("disabled") || this.hasAttribute("readonly") || (this._lastFocusTarget = document.activeElement || this, this._draft = this.value, this.setAttribute("editing", ""), queueMicrotask(() => {
|
|
123
|
-
var n;
|
|
124
123
|
const t = this.root.querySelector(".field");
|
|
125
|
-
t
|
|
124
|
+
t?.focus(), t?.select?.();
|
|
126
125
|
}), this.dispatchEvent(new CustomEvent("editing-change", { detail: { editing: !0 }, bubbles: !0, composed: !0 })));
|
|
127
126
|
}
|
|
128
127
|
cancelEditing() {
|
|
129
128
|
this.removeAttribute("editing"), this._draft = this.value, this.dispatchEvent(new CustomEvent("cancel", { detail: { value: this.value }, bubbles: !0, composed: !0 })), this.dispatchEvent(new CustomEvent("editing-change", { detail: { editing: !1 }, bubbles: !0, composed: !0 })), this._restoreFocus();
|
|
130
129
|
}
|
|
131
130
|
saveEditing() {
|
|
132
|
-
if (this.hasAttribute("disabled") || this.hasAttribute("readonly"))
|
|
133
|
-
return;
|
|
131
|
+
if (this.hasAttribute("disabled") || this.hasAttribute("readonly")) return;
|
|
134
132
|
if (this.hasAttribute("required") && !this._draft.trim()) {
|
|
135
133
|
this.setAttribute("invalid", "");
|
|
136
134
|
return;
|
|
@@ -144,46 +142,44 @@ class g extends v {
|
|
|
144
142
|
disconnectedCallback() {
|
|
145
143
|
this._formUnregister && this._formUnregister(), super.disconnectedCallback();
|
|
146
144
|
}
|
|
147
|
-
attributeChangedCallback(t,
|
|
148
|
-
|
|
145
|
+
attributeChangedCallback(t, a, s) {
|
|
146
|
+
a !== s && (t === "name" && this.isConnected && this._registerWithForm(), t === "value" && !this.hasAttribute("editing") && (this._draft = s || ""), this.isConnected && this.requestRender());
|
|
149
147
|
}
|
|
150
148
|
render() {
|
|
151
|
-
|
|
152
|
-
const t = this.hasAttribute("editing") ? this._draft : this.value, n = this.getAttribute("placeholder") || "Add value", e = this.hasAttribute("multiline"), l = this.hasAttribute("editing"), a = !this.value, s = this.hasAttribute("disabled") || this.hasAttribute("readonly");
|
|
149
|
+
const t = this.hasAttribute("editing") ? this._draft : this.value, a = this.getAttribute("placeholder") || "Add value", s = this.hasAttribute("multiline"), r = this.hasAttribute("editing"), n = !this.value, e = this.hasAttribute("disabled") || this.hasAttribute("readonly");
|
|
153
150
|
this.setContent(`
|
|
154
|
-
<style>${
|
|
151
|
+
<style>${h}</style>
|
|
155
152
|
<div class="root">
|
|
156
|
-
<div class="display"${
|
|
157
|
-
<div class="value" data-empty="${
|
|
158
|
-
<button class="edit-btn" type="button"${
|
|
153
|
+
<div class="display"${r ? " hidden" : ""}>
|
|
154
|
+
<div class="value" data-empty="${n}">${o(n ? a : this.value)}</div>
|
|
155
|
+
<button class="edit-btn" type="button"${e ? " disabled" : ""}>Edit</button>
|
|
159
156
|
</div>
|
|
160
|
-
<div class="editor"${
|
|
161
|
-
${
|
|
157
|
+
<div class="editor"${r ? "" : " hidden"}>
|
|
158
|
+
${s ? `<textarea class="field" rows="4"${e ? " disabled" : ""}>${o(t)}</textarea>` : `<input class="field" type="text" value="${o(t)}"${e ? " disabled" : ""} />`}
|
|
162
159
|
<div class="actions">
|
|
163
|
-
<button class="cancel-btn" type="button"${
|
|
164
|
-
<button class="save-btn" type="button"${
|
|
160
|
+
<button class="cancel-btn" type="button"${e ? " disabled" : ""}>Cancel</button>
|
|
161
|
+
<button class="save-btn" type="button"${e ? " disabled" : ""}>Save</button>
|
|
165
162
|
</div>
|
|
166
163
|
</div>
|
|
167
164
|
</div>
|
|
168
165
|
`);
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
this._draft =
|
|
172
|
-
}),
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
}),
|
|
166
|
+
const u = this.root.querySelector(".field");
|
|
167
|
+
u?.addEventListener("input", (l) => {
|
|
168
|
+
this._draft = l.target.value;
|
|
169
|
+
}), u?.addEventListener("keydown", (l) => {
|
|
170
|
+
const i = l;
|
|
171
|
+
i.key === "Escape" && (i.preventDefault(), this.cancelEditing()), !s && i.key === "Enter" && (i.preventDefault(), this.saveEditing()), (i.metaKey || i.ctrlKey) && i.key === "Enter" && (i.preventDefault(), this.saveEditing());
|
|
172
|
+
}), this.root.querySelector(".edit-btn")?.addEventListener("click", () => this.startEditing()), this.root.querySelector(".cancel-btn")?.addEventListener("click", () => this.cancelEditing()), this.root.querySelector(".save-btn")?.addEventListener("click", () => this.saveEditing());
|
|
176
173
|
}
|
|
177
174
|
_registerWithForm() {
|
|
178
|
-
var t;
|
|
179
175
|
this._formUnregister && (this._formUnregister(), this._formUnregister = null);
|
|
180
176
|
try {
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
name:
|
|
177
|
+
const r = this.getRootNode().host?.closest?.("ui-form") || null || this.closest("ui-form"), n = this.getAttribute("name");
|
|
178
|
+
r && typeof r.registerField == "function" && n && (this._formUnregister = r.registerField(n, {
|
|
179
|
+
name: n,
|
|
184
180
|
getValue: () => this.value,
|
|
185
|
-
setValue: (
|
|
186
|
-
|
|
181
|
+
setValue: (e) => {
|
|
182
|
+
e == null || e === "" ? this.removeAttribute("value") : this.setAttribute("value", String(e));
|
|
187
183
|
}
|
|
188
184
|
}));
|
|
189
185
|
} catch {
|
|
@@ -200,7 +196,7 @@ class g extends v {
|
|
|
200
196
|
}), this._lastFocusTarget = null);
|
|
201
197
|
}
|
|
202
198
|
}
|
|
203
|
-
typeof customElements < "u" && !customElements.get("ui-inline-edit") && customElements.define("ui-inline-edit",
|
|
199
|
+
typeof customElements < "u" && !customElements.get("ui-inline-edit") && customElements.define("ui-inline-edit", b);
|
|
204
200
|
export {
|
|
205
|
-
|
|
201
|
+
b as UIInlineEdit
|
|
206
202
|
};
|
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 E=require("./ElementBase-EV6mVBUV.js"),$=`
|
|
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
|
+
`,q=`
|
|
6
6
|
:host {
|
|
7
7
|
--ui-input-padding: var(--ui-padding, 10px 12px);
|
|
8
8
|
--ui-input-border-color: var(--ui-color-border, var(--ui-border-color, #cbd5e1));
|
|
@@ -481,8 +481,8 @@
|
|
|
481
481
|
box-shadow: none;
|
|
482
482
|
}
|
|
483
483
|
}
|
|
484
|
-
`;function r(a){return a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function z(a){if(!a)return!1;const t=a.assignedNodes({flatten:!0});return t.length?t.some(e=>
|
|
485
|
-
<style>${
|
|
484
|
+
`;function r(a){return a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function z(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 y(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 S extends E.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","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")||"",o=this.getAttribute("pattern")||"",s=this.getAttribute("inputmode")||"",m=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=y(this,"disabled"),f=this.hasAttribute("required"),g=this.hasAttribute("readonly");try{t.type=e}catch{t.type="text"}t.placeholder=i,t.disabled=b,t.required=f,t.readOnly=g,t.name=n,o?t.setAttribute("pattern",o):t.removeAttribute("pattern"),s?t.setAttribute("inputmode",s):t.removeAttribute("inputmode"),m?t.setAttribute("autocomplete",m):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"]).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._clearBtn&&this._clearBtn.removeEventListener("click",this._onClearClick),this._clearBtn=null}_syncInputValue(t){this._input&&this._input.value!==t&&(this._input.value=t),this._clearBtn&&(y(this,"clearable")&&t.length>0&&!y(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(){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(),m=(this.getAttribute("description")||"").trim(),p=(this.getAttribute("data-error")||"").trim(),u=!!s||z(t),l=!!m||z(e),c=!!p||z(i),d=z(n),h=z(o),b=this.root.querySelector(".label"),f=this.root.querySelector(".description"),g=this.root.querySelector(".prefix"),v=this.root.querySelector(".suffix"),x=this.root.querySelector(".meta"),C=this.root.querySelector(".footer"),_=this.root.querySelector(".error"),w=this.root.querySelector(".counter");b&&(u?b.removeAttribute("hidden"):b.setAttribute("hidden","")),f&&(l?f.removeAttribute("hidden"):f.setAttribute("hidden","")),g&&(d?g.removeAttribute("hidden"):g.setAttribute("hidden","")),v&&(h?v.removeAttribute("hidden"):v.setAttribute("hidden","")),x&&(u||l?x.removeAttribute("hidden"):x.setAttribute("hidden",""));const k=this.hasAttribute("counter");if(w&&(k?w.removeAttribute("hidden"):w.setAttribute("hidden","")),_&&(c?_.removeAttribute("hidden"):_.setAttribute("hidden","")),C&&(c||k?C.removeAttribute("hidden"):C.setAttribute("hidden","")),this._input){u?this._input.setAttribute("aria-labelledby",`${this._uid}-label`):this._input.removeAttribute("aria-labelledby");const A=[];l&&A.push(`${this._uid}-description`),c&&A.push(`${this._uid}-error`),A.length?this._input.setAttribute("aria-describedby",A.join(" ")):this._input.removeAttribute("aria-describedby"),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(),!(y(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=y(this,"disabled"),n=y(this,"clearable"),o=this.getAttribute("type")||"text",s=this.getAttribute("name")||"",m=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")||"",g=this.getAttribute("minlength")||"",v=this.hasAttribute("readonly"),x=this.getAttribute("label")||"",C=this.getAttribute("description")||"",_=this.getAttribute("data-error")||"",w=this.getAttribute("validation")||"",k=this.hasAttribute("floating-label"),A=m?'<span class="required" aria-hidden="true">*</span>':"";this._syncHostTokens(),this.setContent(`
|
|
485
|
+
<style>${q}</style>
|
|
486
486
|
<div class="root" part="root">
|
|
487
487
|
<div class="meta" part="meta">
|
|
488
488
|
<label class="label" id="${this._uid}-label" part="label">
|
|
@@ -500,27 +500,27 @@
|
|
|
500
500
|
<div class="control" part="control">
|
|
501
501
|
<input
|
|
502
502
|
part="input"
|
|
503
|
-
type="${r(
|
|
503
|
+
type="${r(o)}"
|
|
504
504
|
name="${r(s)}"
|
|
505
505
|
value="${r(t)}"
|
|
506
506
|
placeholder="${r(e)}"
|
|
507
|
-
${
|
|
508
|
-
${
|
|
509
|
-
${
|
|
510
|
-
${
|
|
511
|
-
${
|
|
512
|
-
${
|
|
513
|
-
${
|
|
514
|
-
${
|
|
515
|
-
${
|
|
516
|
-
${
|
|
507
|
+
${m?"required":""}
|
|
508
|
+
${p?`pattern="${r(p)}"`:""}
|
|
509
|
+
${u?`inputmode="${r(u)}"`:""}
|
|
510
|
+
${l?`autocomplete="${r(l)}"`:""}
|
|
511
|
+
${c?`min="${r(c)}"`:""}
|
|
512
|
+
${d?`max="${r(d)}"`:""}
|
|
513
|
+
${h?`step="${r(h)}"`:""}
|
|
514
|
+
${b?`spellcheck="${r(b)}"`:""}
|
|
515
|
+
${f?`maxlength="${r(f)}"`:""}
|
|
516
|
+
${g?`minlength="${r(g)}"`:""}
|
|
517
517
|
${i?"disabled":""}
|
|
518
518
|
${v?"readonly":""}
|
|
519
519
|
/>
|
|
520
520
|
${k?`<span class="floating-label" part="floating-label">${r(x||e||s||"Input")}</span>`:""}
|
|
521
521
|
</div>
|
|
522
522
|
|
|
523
|
-
<button class="clear-btn" part="clear" aria-label="Clear" ${
|
|
523
|
+
<button class="clear-btn" part="clear" aria-label="Clear" ${n&&t&&!i&&!v?"":"hidden"}>${$}</button>
|
|
524
524
|
|
|
525
525
|
<span class="suffix" part="suffix"><slot name="suffix"></slot></span>
|
|
526
526
|
</div>
|
|
@@ -532,4 +532,4 @@
|
|
|
532
532
|
<p class="counter" part="counter"></p>
|
|
533
533
|
</div>
|
|
534
534
|
</div>
|
|
535
|
-
`),this._detachListeners(),this._input=this.root.querySelector("input"),this._clearBtn=this.root.querySelector("button.clear-btn"),this._input&&(this._input.addEventListener("input",this._onNativeInput),this._input.addEventListener("change",this._onNativeChange)),
|
|
535
|
+
`),this._detachListeners(),this._input=this.root.querySelector("input"),this._clearBtn=this.root.querySelector("button.clear-btn"),this._input&&(this._input.addEventListener("input",this._onNativeInput),this._input.addEventListener("change",this._onNativeChange)),this._clearBtn?.addEventListener("click",this._onClearClick),this._syncControlAttrs(),this._syncInputValue(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"}}typeof customElements<"u"&&!customElements.get("ui-input")&&customElements.define("ui-input",S);exports.UIInput=S;
|
package/dist/input.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { E as
|
|
2
|
-
const
|
|
1
|
+
import { E as S } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
|
+
const E = `
|
|
3
3
|
<svg viewBox="0 0 20 20" aria-hidden="true" focusable="false">
|
|
4
4
|
<path d="m6 6 8 8M14 6l-8 8" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>
|
|
5
5
|
</svg>
|
|
6
|
-
`,
|
|
6
|
+
`, $ = `
|
|
7
7
|
:host {
|
|
8
8
|
--ui-input-padding: var(--ui-padding, 10px 12px);
|
|
9
9
|
--ui-input-border-color: var(--ui-color-border, var(--ui-border-color, #cbd5e1));
|
|
@@ -487,25 +487,20 @@ function r(a) {
|
|
|
487
487
|
return a.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
488
488
|
}
|
|
489
489
|
function z(a) {
|
|
490
|
-
if (!a)
|
|
491
|
-
return !1;
|
|
490
|
+
if (!a) return !1;
|
|
492
491
|
const t = a.assignedNodes({ flatten: !0 });
|
|
493
|
-
return t.length ? t.some((e) =>
|
|
494
|
-
var i;
|
|
495
|
-
return e.nodeType === Node.TEXT_NODE ? !!((i = e.textContent) != null && i.trim()) : e.nodeType === Node.ELEMENT_NODE;
|
|
496
|
-
}) : !1;
|
|
492
|
+
return t.length ? t.some((e) => e.nodeType === Node.TEXT_NODE ? !!e.textContent?.trim() : e.nodeType === Node.ELEMENT_NODE) : !1;
|
|
497
493
|
}
|
|
498
494
|
function y(a, t) {
|
|
499
495
|
const e = a.getAttribute(t);
|
|
500
|
-
if (e == null)
|
|
501
|
-
return !1;
|
|
496
|
+
if (e == null) return !1;
|
|
502
497
|
const i = String(e).trim().toLowerCase();
|
|
503
498
|
return i !== "false" && i !== "0";
|
|
504
499
|
}
|
|
505
|
-
function
|
|
500
|
+
function q(a) {
|
|
506
501
|
return a === "none" || a === "large" || a === "full";
|
|
507
502
|
}
|
|
508
|
-
class
|
|
503
|
+
class T extends S {
|
|
509
504
|
constructor() {
|
|
510
505
|
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);
|
|
511
506
|
}
|
|
@@ -556,22 +551,20 @@ class I extends q {
|
|
|
556
551
|
const t = this.getAttribute("color");
|
|
557
552
|
t ? this.style.setProperty("--ui-input-accent", t) : this.style.removeProperty("--ui-input-accent");
|
|
558
553
|
const e = this.getAttribute("radius") || "";
|
|
559
|
-
e && !
|
|
554
|
+
e && !q(e) ? this.style.setProperty("--ui-input-border-radius", e) : this.style.removeProperty("--ui-input-border-radius");
|
|
560
555
|
}
|
|
561
556
|
_syncControlAttrs() {
|
|
562
|
-
if (this._syncHostTokens(), !this._input)
|
|
563
|
-
|
|
564
|
-
const t = this._input, e = this.getAttribute("type") || "text", i = this.getAttribute("placeholder") || "", u = this.getAttribute("name") || "", n = this.getAttribute("pattern") || "", s = this.getAttribute("inputmode") || "", o = this.getAttribute("autocomplete") || "", d = this.getAttribute("min") || "", l = this.getAttribute("max") || "", c = this.getAttribute("step") || "", p = this.getAttribute("spellcheck") || "", h = this.getAttribute("maxlength") || "", b = this.getAttribute("minlength") || "", f = y(this, "disabled"), g = this.hasAttribute("required"), m = this.hasAttribute("readonly");
|
|
557
|
+
if (this._syncHostTokens(), !this._input) return;
|
|
558
|
+
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") || "", m = 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 = y(this, "disabled"), f = this.hasAttribute("required"), g = this.hasAttribute("readonly");
|
|
565
559
|
try {
|
|
566
560
|
t.type = e;
|
|
567
561
|
} catch {
|
|
568
562
|
t.type = "text";
|
|
569
563
|
}
|
|
570
|
-
t.placeholder = i, t.disabled =
|
|
564
|
+
t.placeholder = i, t.disabled = b, t.required = f, t.readOnly = g, t.name = n, o ? t.setAttribute("pattern", o) : t.removeAttribute("pattern"), s ? t.setAttribute("inputmode", s) : t.removeAttribute("inputmode"), m ? t.setAttribute("autocomplete", m) : 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");
|
|
571
565
|
}
|
|
572
566
|
attributeChangedCallback(t, e, i) {
|
|
573
|
-
if (e === i)
|
|
574
|
-
return;
|
|
567
|
+
if (e === i) return;
|
|
575
568
|
if (t === "value") {
|
|
576
569
|
this._syncInputValue(i || "");
|
|
577
570
|
return;
|
|
@@ -607,12 +600,11 @@ class I extends q {
|
|
|
607
600
|
"radius"
|
|
608
601
|
])).has(t)) {
|
|
609
602
|
this._syncControlAttrs(), this._syncInputValue(this.value), this._syncDerivedState(), t === "autofocus" && this.hasAttribute("autofocus") && !this._autofocusApplied && (this._autofocusApplied = !0, queueMicrotask(() => {
|
|
610
|
-
var n, s;
|
|
611
603
|
if (this.isConnected)
|
|
612
604
|
try {
|
|
613
|
-
|
|
605
|
+
this._input?.focus({ preventScroll: !0 });
|
|
614
606
|
} catch {
|
|
615
|
-
|
|
607
|
+
this._input?.focus();
|
|
616
608
|
}
|
|
617
609
|
}));
|
|
618
610
|
return;
|
|
@@ -633,12 +625,10 @@ class I extends q {
|
|
|
633
625
|
super.focus(t);
|
|
634
626
|
}
|
|
635
627
|
blur() {
|
|
636
|
-
|
|
637
|
-
(t = this._input) == null || t.blur();
|
|
628
|
+
this._input?.blur();
|
|
638
629
|
}
|
|
639
630
|
select() {
|
|
640
|
-
|
|
641
|
-
(t = this._input) == null || t.select();
|
|
631
|
+
this._input?.select();
|
|
642
632
|
}
|
|
643
633
|
_emitValueEvent(t, e) {
|
|
644
634
|
this.dispatchEvent(
|
|
@@ -650,19 +640,18 @@ class I extends q {
|
|
|
650
640
|
);
|
|
651
641
|
}
|
|
652
642
|
_registerWithForm() {
|
|
653
|
-
var t;
|
|
654
643
|
this._formUnregister && (this._formUnregister(), this._formUnregister = null);
|
|
655
644
|
try {
|
|
656
|
-
const
|
|
657
|
-
n && typeof n.registerField == "function" &&
|
|
658
|
-
name:
|
|
645
|
+
const n = this.getRootNode().host?.closest?.("ui-form") || null || this.closest("ui-form"), o = this.getAttribute("name");
|
|
646
|
+
n && typeof n.registerField == "function" && o && (this._formUnregister = n.registerField(o, {
|
|
647
|
+
name: o,
|
|
659
648
|
getValue: () => this.value,
|
|
660
|
-
setValue: (
|
|
661
|
-
this.value = String(
|
|
649
|
+
setValue: (s) => {
|
|
650
|
+
this.value = String(s ?? "");
|
|
662
651
|
},
|
|
663
652
|
validate: async () => this._input ? { valid: this._input.checkValidity(), message: this._input.validationMessage || void 0 } : { valid: !0 },
|
|
664
|
-
setError: (
|
|
665
|
-
|
|
653
|
+
setError: (s) => {
|
|
654
|
+
s ? (this.setAttribute("validation", "error"), this.setAttribute("data-error", s)) : (this.removeAttribute("validation"), this.removeAttribute("data-error"));
|
|
666
655
|
}
|
|
667
656
|
}));
|
|
668
657
|
} catch {
|
|
@@ -675,8 +664,8 @@ class I extends q {
|
|
|
675
664
|
this._input && this._input.value !== t && (this._input.value = t), this._clearBtn && (y(this, "clearable") && t.length > 0 && !y(this, "disabled") && !this.hasAttribute("readonly") ? this._clearBtn.removeAttribute("hidden") : this._clearBtn.setAttribute("hidden", ""));
|
|
676
665
|
const e = this.root.querySelector(".counter");
|
|
677
666
|
if (e && this.hasAttribute("counter")) {
|
|
678
|
-
const
|
|
679
|
-
e.textContent =
|
|
667
|
+
const n = this.getAttribute("maxlength"), o = n ? `${t.length}/${n}` : String(t.length);
|
|
668
|
+
e.textContent = o;
|
|
680
669
|
}
|
|
681
670
|
const i = this.root.querySelector(".shell");
|
|
682
671
|
i && i.setAttribute("data-has-value", t ? "true" : "false");
|
|
@@ -685,13 +674,13 @@ class I extends q {
|
|
|
685
674
|
this._syncDerivedState();
|
|
686
675
|
}
|
|
687
676
|
_syncDerivedState() {
|
|
688
|
-
const t = this.root.querySelector('slot[name="label"]'), e = this.root.querySelector('slot[name="description"]'), i = this.root.querySelector('slot[name="error"]'),
|
|
689
|
-
|
|
677
|
+
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(), m = (this.getAttribute("description") || "").trim(), p = (this.getAttribute("data-error") || "").trim(), u = !!s || z(t), l = !!m || z(e), c = !!p || z(i), d = z(n), h = z(o), b = this.root.querySelector(".label"), f = this.root.querySelector(".description"), g = this.root.querySelector(".prefix"), v = this.root.querySelector(".suffix"), x = this.root.querySelector(".meta"), C = this.root.querySelector(".footer"), _ = this.root.querySelector(".error"), w = this.root.querySelector(".counter");
|
|
678
|
+
b && (u ? b.removeAttribute("hidden") : b.setAttribute("hidden", "")), f && (l ? f.removeAttribute("hidden") : f.setAttribute("hidden", "")), g && (d ? g.removeAttribute("hidden") : g.setAttribute("hidden", "")), v && (h ? v.removeAttribute("hidden") : v.setAttribute("hidden", "")), x && (u || l ? x.removeAttribute("hidden") : x.setAttribute("hidden", ""));
|
|
690
679
|
const k = this.hasAttribute("counter");
|
|
691
|
-
if (w && (k ? w.removeAttribute("hidden") : w.setAttribute("hidden", "")), _ && (
|
|
692
|
-
|
|
680
|
+
if (w && (k ? w.removeAttribute("hidden") : w.setAttribute("hidden", "")), _ && (c ? _.removeAttribute("hidden") : _.setAttribute("hidden", "")), C && (c || k ? C.removeAttribute("hidden") : C.setAttribute("hidden", "")), this._input) {
|
|
681
|
+
u ? this._input.setAttribute("aria-labelledby", `${this._uid}-label`) : this._input.removeAttribute("aria-labelledby");
|
|
693
682
|
const A = [];
|
|
694
|
-
|
|
683
|
+
l && A.push(`${this._uid}-description`), c && A.push(`${this._uid}-error`), A.length ? this._input.setAttribute("aria-describedby", A.join(" ")) : this._input.removeAttribute("aria-describedby"), 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");
|
|
695
684
|
}
|
|
696
685
|
}
|
|
697
686
|
_onNativeInput(t) {
|
|
@@ -717,10 +706,9 @@ class I extends q {
|
|
|
717
706
|
}
|
|
718
707
|
}
|
|
719
708
|
render() {
|
|
720
|
-
|
|
721
|
-
const t = this.getAttribute("value") || "", e = this.getAttribute("placeholder") || "", i = y(this, "disabled"), u = y(this, "clearable"), n = this.getAttribute("type") || "text", s = this.getAttribute("name") || "", o = this.hasAttribute("required"), d = this.getAttribute("pattern") || "", l = this.getAttribute("inputmode") || "", c = this.getAttribute("autocomplete") || "", p = this.getAttribute("min") || "", h = this.getAttribute("max") || "", b = this.getAttribute("step") || "", f = this.getAttribute("spellcheck") || "", g = this.getAttribute("maxlength") || "", m = this.getAttribute("minlength") || "", v = this.hasAttribute("readonly"), x = this.getAttribute("label") || "", C = this.getAttribute("description") || "", _ = this.getAttribute("data-error") || "", w = this.getAttribute("validation") || "", k = this.hasAttribute("floating-label"), A = o ? '<span class="required" aria-hidden="true">*</span>' : "";
|
|
709
|
+
const t = this.getAttribute("value") || "", e = this.getAttribute("placeholder") || "", i = y(this, "disabled"), n = y(this, "clearable"), o = this.getAttribute("type") || "text", s = this.getAttribute("name") || "", m = 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") || "", g = this.getAttribute("minlength") || "", v = this.hasAttribute("readonly"), x = this.getAttribute("label") || "", C = this.getAttribute("description") || "", _ = this.getAttribute("data-error") || "", w = this.getAttribute("validation") || "", k = this.hasAttribute("floating-label"), A = m ? '<span class="required" aria-hidden="true">*</span>' : "";
|
|
722
710
|
this._syncHostTokens(), this.setContent(`
|
|
723
|
-
<style>${
|
|
711
|
+
<style>${$}</style>
|
|
724
712
|
<div class="root" part="root">
|
|
725
713
|
<div class="meta" part="meta">
|
|
726
714
|
<label class="label" id="${this._uid}-label" part="label">
|
|
@@ -738,27 +726,27 @@ class I extends q {
|
|
|
738
726
|
<div class="control" part="control">
|
|
739
727
|
<input
|
|
740
728
|
part="input"
|
|
741
|
-
type="${r(
|
|
729
|
+
type="${r(o)}"
|
|
742
730
|
name="${r(s)}"
|
|
743
731
|
value="${r(t)}"
|
|
744
732
|
placeholder="${r(e)}"
|
|
745
|
-
${
|
|
746
|
-
${
|
|
747
|
-
${
|
|
748
|
-
${
|
|
749
|
-
${
|
|
750
|
-
${
|
|
751
|
-
${
|
|
752
|
-
${
|
|
753
|
-
${
|
|
754
|
-
${
|
|
733
|
+
${m ? "required" : ""}
|
|
734
|
+
${p ? `pattern="${r(p)}"` : ""}
|
|
735
|
+
${u ? `inputmode="${r(u)}"` : ""}
|
|
736
|
+
${l ? `autocomplete="${r(l)}"` : ""}
|
|
737
|
+
${c ? `min="${r(c)}"` : ""}
|
|
738
|
+
${d ? `max="${r(d)}"` : ""}
|
|
739
|
+
${h ? `step="${r(h)}"` : ""}
|
|
740
|
+
${b ? `spellcheck="${r(b)}"` : ""}
|
|
741
|
+
${f ? `maxlength="${r(f)}"` : ""}
|
|
742
|
+
${g ? `minlength="${r(g)}"` : ""}
|
|
755
743
|
${i ? "disabled" : ""}
|
|
756
744
|
${v ? "readonly" : ""}
|
|
757
745
|
/>
|
|
758
746
|
${k ? `<span class="floating-label" part="floating-label">${r(x || e || s || "Input")}</span>` : ""}
|
|
759
747
|
</div>
|
|
760
748
|
|
|
761
|
-
<button class="clear-btn" part="clear" aria-label="Clear" ${
|
|
749
|
+
<button class="clear-btn" part="clear" aria-label="Clear" ${n && t && !i && !v ? "" : "hidden"}>${E}</button>
|
|
762
750
|
|
|
763
751
|
<span class="suffix" part="suffix"><slot name="suffix"></slot></span>
|
|
764
752
|
</div>
|
|
@@ -770,13 +758,12 @@ class I extends q {
|
|
|
770
758
|
<p class="counter" part="counter"></p>
|
|
771
759
|
</div>
|
|
772
760
|
</div>
|
|
773
|
-
`), this._detachListeners(), this._input = this.root.querySelector("input"), this._clearBtn = this.root.querySelector("button.clear-btn"), this._input && (this._input.addEventListener("input", this._onNativeInput), this._input.addEventListener("change", this._onNativeChange)),
|
|
774
|
-
var E, $;
|
|
761
|
+
`), this._detachListeners(), this._input = this.root.querySelector("input"), this._clearBtn = this.root.querySelector("button.clear-btn"), this._input && (this._input.addEventListener("input", this._onNativeInput), this._input.addEventListener("change", this._onNativeChange)), this._clearBtn?.addEventListener("click", this._onClearClick), this._syncControlAttrs(), this._syncInputValue(t), this._syncDerivedState(), this.hasAttribute("autofocus") && !this._autofocusApplied && (this._autofocusApplied = !0, queueMicrotask(() => {
|
|
775
762
|
if (this.isConnected)
|
|
776
763
|
try {
|
|
777
|
-
|
|
764
|
+
this._input?.focus({ preventScroll: !0 });
|
|
778
765
|
} catch {
|
|
779
|
-
|
|
766
|
+
this._input?.focus();
|
|
780
767
|
}
|
|
781
768
|
}));
|
|
782
769
|
}
|
|
@@ -784,7 +771,7 @@ class I extends q {
|
|
|
784
771
|
return t === "label" || t === "description" || t === "data-error" || t === "floating-label";
|
|
785
772
|
}
|
|
786
773
|
}
|
|
787
|
-
typeof customElements < "u" && !customElements.get("ui-input") && customElements.define("ui-input",
|
|
774
|
+
typeof customElements < "u" && !customElements.get("ui-input") && customElements.define("ui-input", T);
|
|
788
775
|
export {
|
|
789
|
-
|
|
776
|
+
T as UIInput
|
|
790
777
|
};
|
package/dist/label.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("./ElementBase-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("./ElementBase-EV6mVBUV.js"),u=`
|
|
2
2
|
:host {
|
|
3
3
|
--ui-label-color: var(--ui-color-text, var(--ui-text, #0f172a));
|
|
4
4
|
--ui-label-muted: var(--ui-color-muted, var(--ui-muted, #64748b));
|
|
@@ -181,7 +181,7 @@
|
|
|
181
181
|
box-shadow: none;
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
|
-
`;function a(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function c(i){if(!i)return!1;const e=i.assignedNodes({flatten:!0});return e.length?e.some(o=>
|
|
184
|
+
`;function a(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function c(i){if(!i)return!1;const e=i.assignedNodes({flatten:!0});return e.length?e.some(o=>o.nodeType===Node.TEXT_NODE?!!o.textContent?.trim():o.nodeType===Node.ELEMENT_NODE):!1}function l(i){if(i.hasAttribute("disabled")||i.getAttribute("aria-disabled")==="true")return!1;const e=window.getComputedStyle(i);return!(e.display==="none"||e.visibility==="hidden")}class s extends n.ElementBase{constructor(){super(),this._uid=Math.random().toString(36).slice(2,9),this._onRootClick=this._onRootClick.bind(this),this._onRootFocusIn=this._onRootFocusIn.bind(this),this._onRootFocusOut=this._onRootFocusOut.bind(this),this._onSlotChange=this._onSlotChange.bind(this)}static get observedAttributes(){return["for","required","description","variant","tone","size","density","shape","disabled","headless"]}connectedCallback(){super.connectedCallback(),this.root.addEventListener("click",this._onRootClick),this.root.addEventListener("focusin",this._onRootFocusIn),this.root.addEventListener("focusout",this._onRootFocusOut),this.root.addEventListener("slotchange",this._onSlotChange),this._syncDescriptionVisibility()}disconnectedCallback(){this.root.removeEventListener("click",this._onRootClick),this.root.removeEventListener("focusin",this._onRootFocusIn),this.root.removeEventListener("focusout",this._onRootFocusOut),this.root.removeEventListener("slotchange",this._onSlotChange),super.disconnectedCallback()}_resolveControl(){const e=this.getAttribute("for");if(e){const t=document.getElementById(e);if(t instanceof HTMLElement&&l(t))return t}const o=[this.nextElementSibling,this.parentElement,this.closest('[role="group"], form, ui-form, fieldset, .field, [data-field]')];for(const t of o){if(!t)continue;const r=t.querySelector('ui-input, ui-textarea, ui-select, ui-combobox, input, textarea, select, button, [tabindex]:not([tabindex="-1"])');if(r&&l(r))return r}return null}_focusControl(){const e=this._resolveControl();if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}_onRootClick(e){if(this.hasAttribute("disabled"))return;const o=e.composedPath(),t=this.root.querySelector(".label");!t||!o.includes(t)||(this._focusControl(),this.dispatchEvent(new CustomEvent("click",{bubbles:!0})))}_onRootFocusIn(){this.dispatchEvent(new CustomEvent("focus",{bubbles:!0}))}_onRootFocusOut(){this.dispatchEvent(new CustomEvent("blur",{bubbles:!0}))}_onSlotChange(){this._syncDescriptionVisibility()}_syncDescriptionVisibility(){const e=(this.getAttribute("description")||"").trim(),o=this.root.querySelector('slot[name="description"]'),t=!!e||c(o),r=this.root.querySelector(".description");r&&(t?r.removeAttribute("hidden"):r.setAttribute("hidden",""))}render(){const e=this.getAttribute("for")||"",o=this.getAttribute("description")||"",t=this.hasAttribute("required");this.setContent(`
|
|
185
185
|
<style>${u}</style>
|
|
186
186
|
<div class="root" part="root">
|
|
187
187
|
<label class="label" id="${this._uid}-label" part="label" ${e?`for="${a(e)}"`:""}>
|