@editora/ui-core 0.1.19 → 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. package/dist/{ElementBase-1b301e7f.js → ElementBase-EV6mVBUV.js} +1 -1
  2. package/dist/{ElementBase-909688f3.mjs → ElementBase-YlTLMsGk.mjs} +3 -3
  3. package/dist/accordion.cjs.js +3 -3
  4. package/dist/accordion.esm.js +39 -62
  5. package/dist/alert-dialog.cjs.js +19 -19
  6. package/dist/alert-dialog.esm.js +69 -87
  7. package/dist/alert.cjs.js +1 -1
  8. package/dist/alert.esm.js +4 -7
  9. package/dist/anchor.cjs.js +2 -2
  10. package/dist/anchor.esm.js +3 -3
  11. package/dist/animated-beam.cjs.js +83 -83
  12. package/dist/animated-beam.esm.js +250 -277
  13. package/dist/animated-list.cjs.js +4 -4
  14. package/dist/animated-list.esm.js +47 -61
  15. package/dist/animated-text.cjs.js +2 -2
  16. package/dist/animated-text.esm.js +13 -24
  17. package/dist/app-header.cjs.js +3 -3
  18. package/dist/app-header.esm.js +11 -13
  19. package/dist/aspect-ratio.cjs.js +1 -1
  20. package/dist/aspect-ratio.esm.js +4 -7
  21. package/dist/avatar.cjs.js +1 -1
  22. package/dist/avatar.esm.js +7 -13
  23. package/dist/badge.cjs.js +1 -1
  24. package/dist/badge.esm.js +4 -7
  25. package/dist/block-controls.cjs.js +2 -2
  26. package/dist/block-controls.esm.js +19 -35
  27. package/dist/box.cjs.js +1 -1
  28. package/dist/box.esm.js +8 -15
  29. package/dist/breadcrumb.cjs.js +2 -2
  30. package/dist/breadcrumb.esm.js +20 -37
  31. package/dist/button.cjs.js +1 -521
  32. package/dist/button.esm.js +2 -671
  33. package/dist/{calendar-2c11b824.mjs → calendar-DLY4acgn.mjs} +293 -342
  34. package/dist/{calendar-a8735e40.js → calendar-Dkof-FTK.js} +25 -25
  35. package/dist/calendar.cjs.js +1 -1
  36. package/dist/calendar.esm.js +8 -9
  37. package/dist/card.cjs.js +4 -4
  38. package/dist/card.esm.js +13 -19
  39. package/dist/chart.cjs.js +64 -64
  40. package/dist/chart.esm.js +223 -254
  41. package/dist/checkbox.cjs.js +1 -1
  42. package/dist/checkbox.esm.js +2 -3
  43. package/dist/collapsible.cjs.js +1 -1
  44. package/dist/collapsible.esm.js +5 -9
  45. package/dist/{collection-a1aac0c6.mjs → collection-C7URGjEI.mjs} +8 -14
  46. package/dist/collection.cjs.js +1 -1
  47. package/dist/collection.esm.js +4 -7
  48. package/dist/color-picker.cjs.js +9 -9
  49. package/dist/color-picker.esm.js +189 -252
  50. package/dist/combobox.cjs.js +13 -13
  51. package/dist/combobox.esm.js +93 -126
  52. package/dist/command-palette.cjs.js +3 -3
  53. package/dist/command-palette.esm.js +19 -30
  54. package/dist/command.cjs.js +4 -4
  55. package/dist/command.esm.js +41 -53
  56. package/dist/components/ui-orbiter.d.ts.map +1 -1
  57. package/dist/components/ui-skeleton.d.ts.map +1 -1
  58. package/dist/components/ui-split-button.d.ts +1 -0
  59. package/dist/components/ui-split-button.d.ts.map +1 -1
  60. package/dist/components/ui-time-picker.d.ts.map +1 -1
  61. package/dist/container.cjs.js +2 -2
  62. package/dist/container.esm.js +2 -3
  63. package/dist/context-menu.cjs.js +8 -8
  64. package/dist/context-menu.esm.js +157 -219
  65. package/dist/control-group.cjs.js +1 -1
  66. package/dist/control-group.esm.js +2 -3
  67. package/dist/data-table.cjs.js +4 -4
  68. package/dist/data-table.esm.js +299 -381
  69. package/dist/date-field.cjs.js +3 -3
  70. package/dist/date-field.esm.js +68 -80
  71. package/dist/date-picker.cjs.js +9 -9
  72. package/dist/date-picker.esm.js +69 -97
  73. package/dist/date-range-picker.cjs.js +3 -3
  74. package/dist/date-range-picker.esm.js +32 -56
  75. package/dist/date-range-time-picker.cjs.js +9 -9
  76. package/dist/date-range-time-picker.esm.js +111 -140
  77. package/dist/date-time-picker.cjs.js +4 -4
  78. package/dist/date-time-picker.esm.js +112 -144
  79. package/dist/date-time-utils-Dmost5Ee.js +1 -0
  80. package/dist/date-time-utils-y1N2gvG2.mjs +268 -0
  81. package/dist/description.cjs.js +1 -1
  82. package/dist/description.esm.js +3 -5
  83. package/dist/dialog.cjs.js +12 -12
  84. package/dist/dialog.esm.js +44 -63
  85. package/dist/direction-provider.cjs.js +1 -1
  86. package/dist/direction-provider.esm.js +2 -3
  87. package/dist/{dismissable-layer-9c7e6b58.mjs → dismissable-layer-BmPIoK80.mjs} +29 -33
  88. package/dist/dismissable-layer-DNfrKA20.js +1 -0
  89. package/dist/dismissable-layer.cjs.js +2 -2
  90. package/dist/dismissable-layer.esm.js +4 -6
  91. package/dist/dock.cjs.js +5 -5
  92. package/dist/dock.esm.js +134 -155
  93. package/dist/drawer.cjs.js +2 -2
  94. package/dist/drawer.esm.js +18 -35
  95. package/dist/dropdown.cjs.js +2 -2
  96. package/dist/dropdown.esm.js +119 -149
  97. package/dist/dropzone.cjs.js +1 -1
  98. package/dist/dropzone.esm.js +0 -1
  99. package/dist/empty-state.cjs.js +1 -1
  100. package/dist/empty-state.esm.js +1 -1
  101. package/dist/field-error.cjs.js +1 -1
  102. package/dist/field-error.esm.js +3 -5
  103. package/dist/field.cjs.js +5 -5
  104. package/dist/field.esm.js +27 -34
  105. package/dist/fieldset.cjs.js +4 -4
  106. package/dist/fieldset.esm.js +19 -24
  107. package/dist/file-upload.cjs.js +4 -4
  108. package/dist/file-upload.esm.js +69 -93
  109. package/dist/flex.cjs.js +1 -1
  110. package/dist/flex.esm.js +5 -9
  111. package/dist/floating-toolbar.cjs.js +4 -4
  112. package/dist/floating-toolbar.esm.js +60 -85
  113. package/dist/focus-scope-Bwug2gDv.js +1 -0
  114. package/dist/{focus-scope-103833ee.mjs → focus-scope-CmEsG5UZ.mjs} +39 -48
  115. package/dist/focus-scope.cjs.js +2 -2
  116. package/dist/focus-scope.esm.js +15 -20
  117. package/dist/form.cjs.js +2 -2
  118. package/dist/form.esm.js +26 -53
  119. package/dist/gantt.cjs.js +43 -43
  120. package/dist/gantt.esm.js +295 -322
  121. package/dist/grid.cjs.js +1 -1
  122. package/dist/grid.esm.js +5 -9
  123. package/dist/hover-card.cjs.js +4 -4
  124. package/dist/hover-card.esm.js +22 -28
  125. package/dist/icon-cloud.cjs.js +7 -7
  126. package/dist/icon-cloud.esm.js +48 -62
  127. package/dist/icon.cjs.js +1 -1
  128. package/dist/icon.esm.js +2 -4
  129. package/dist/index.cjs.js +1 -1
  130. package/dist/index.esm.js +378 -390
  131. package/dist/inline-edit.cjs.js +11 -11
  132. package/dist/inline-edit.esm.js +32 -36
  133. package/dist/input.cjs.js +17 -17
  134. package/dist/input.esm.js +50 -63
  135. package/dist/label.cjs.js +2 -2
  136. package/dist/label.esm.js +8 -17
  137. package/dist/layout.cjs.js +2 -2
  138. package/dist/layout.esm.js +20 -26
  139. package/dist/listbox-B6QgECax.js +46 -0
  140. package/dist/listbox-DJamVeFj.mjs +200 -0
  141. package/dist/listbox.cjs.js +1 -1
  142. package/dist/listbox.esm.js +2 -4
  143. package/dist/marquee.cjs.js +5 -5
  144. package/dist/marquee.esm.js +33 -50
  145. package/dist/masonry-grid.cjs.js +1 -1
  146. package/dist/masonry-grid.esm.js +5 -9
  147. package/dist/menu.cjs.js +3 -3
  148. package/dist/menu.esm.js +106 -126
  149. package/dist/menubar.cjs.js +5 -5
  150. package/dist/menubar.esm.js +118 -164
  151. package/dist/meter.cjs.js +2 -2
  152. package/dist/meter.esm.js +4 -4
  153. package/dist/multi-select.cjs.js +4 -4
  154. package/dist/multi-select.esm.js +120 -140
  155. package/dist/navigation-menu.cjs.js +4 -4
  156. package/dist/navigation-menu.esm.js +44 -55
  157. package/dist/number-field.cjs.js +2 -2
  158. package/dist/number-field.esm.js +73 -98
  159. package/dist/number-ticker.cjs.js +3 -3
  160. package/dist/number-ticker.esm.js +22 -43
  161. package/dist/odometer.cjs.js +1 -1
  162. package/dist/odometer.esm.js +5 -9
  163. package/dist/orbiter.cjs.js +13 -13
  164. package/dist/orbiter.esm.js +79 -90
  165. package/dist/{overlayManager-5bbd4dc3.mjs → overlayManager-BJjU1VA8.mjs} +4 -5
  166. package/dist/{overlayManager-0eda4e08.js → overlayManager-CSy3fJmJ.js} +1 -1
  167. package/dist/pagination.cjs.js +2 -2
  168. package/dist/pagination.esm.js +14 -18
  169. package/dist/{panel-group-a376cc5e.mjs → panel-group-8sVNnGxg.mjs} +24 -46
  170. package/dist/panel-group-CaD0_KQf.js +36 -0
  171. package/dist/panel-group.cjs.js +1 -1
  172. package/dist/panel-group.esm.js +2 -5
  173. package/dist/panel.cjs.js +4 -4
  174. package/dist/panel.esm.js +8 -10
  175. package/dist/password-field.cjs.js +9 -9
  176. package/dist/password-field.esm.js +62 -82
  177. package/dist/pin-input.cjs.js +3 -3
  178. package/dist/pin-input.esm.js +33 -39
  179. package/dist/placement-grid.cjs.js +4 -4
  180. package/dist/placement-grid.esm.js +108 -131
  181. package/dist/plugin-panel.cjs.js +7 -7
  182. package/dist/plugin-panel.esm.js +13 -15
  183. package/dist/popover.cjs.js +2 -2
  184. package/dist/popover.esm.js +21 -31
  185. package/dist/portal-DgpQ3Jo1.js +1 -0
  186. package/dist/{portal-fe73e5cc.mjs → portal-bR42gHvG.mjs} +43 -48
  187. package/dist/portal.cjs.js +2 -2
  188. package/dist/portal.esm.js +10 -19
  189. package/dist/{positioner-e9770c66.mjs → positioner-D0VGxtYU.mjs} +189 -209
  190. package/dist/positioner-D_fqyx_j.js +1 -0
  191. package/dist/positioner.cjs.js +2 -2
  192. package/dist/positioner.esm.js +11 -18
  193. package/dist/presence.cjs.js +1 -1
  194. package/dist/presence.esm.js +7 -13
  195. package/dist/progress.cjs.js +1 -1
  196. package/dist/progress.esm.js +5 -9
  197. package/dist/quick-actions.cjs.js +6 -6
  198. package/dist/quick-actions.esm.js +52 -62
  199. package/dist/radio-group.cjs.js +13 -13
  200. package/dist/radio-group.esm.js +39 -51
  201. package/dist/radio.cjs.js +1 -1
  202. package/dist/radio.esm.js +5 -9
  203. package/dist/rating.cjs.js +1 -1
  204. package/dist/rating.esm.js +12 -23
  205. package/dist/{roving-focus-group-4350c9a7.mjs → roving-focus-group-Dbm1Jko_.mjs} +3 -6
  206. package/dist/roving-focus-group.cjs.js +1 -1
  207. package/dist/roving-focus-group.esm.js +3 -5
  208. package/dist/runtime-CTaOSmBj.js +1 -0
  209. package/dist/{runtime-161f68a2.mjs → runtime-D1gFh1fS.mjs} +338 -366
  210. package/dist/runtime.cjs.js +1 -1
  211. package/dist/runtime.esm.js +6 -6
  212. package/dist/scroll-area.cjs.js +3 -3
  213. package/dist/scroll-area.esm.js +38 -46
  214. package/dist/{scroll-lock-31da444f.mjs → scroll-lock-LfqXXqsu.mjs} +5 -9
  215. package/dist/section.cjs.js +1 -1
  216. package/dist/section.esm.js +1 -1
  217. package/dist/select.cjs.js +7 -7
  218. package/dist/select.esm.js +67 -97
  219. package/dist/selection-popup.cjs.js +1 -1
  220. package/dist/selection-popup.esm.js +8 -15
  221. package/dist/separator.cjs.js +1 -1
  222. package/dist/separator.esm.js +1 -1
  223. package/dist/sidebar.cjs.js +18 -18
  224. package/dist/sidebar.esm.js +117 -139
  225. package/dist/skeleton.cjs.js +11 -11
  226. package/dist/skeleton.esm.js +27 -24
  227. package/dist/slider.cjs.js +1 -1
  228. package/dist/slider.esm.js +6 -11
  229. package/dist/slot.cjs.js +4 -4
  230. package/dist/slot.esm.js +16 -19
  231. package/dist/sortable.cjs.js +45 -45
  232. package/dist/sortable.esm.js +421 -524
  233. package/dist/spinning-text.cjs.js +12 -12
  234. package/dist/spinning-text.esm.js +80 -92
  235. package/dist/split-button.cjs.js +4 -4
  236. package/dist/split-button.esm.js +77 -62
  237. package/dist/splitter.cjs.js +1 -1
  238. package/dist/splitter.esm.js +1 -1
  239. package/dist/stepper.cjs.js +8 -8
  240. package/dist/stepper.esm.js +32 -52
  241. package/dist/switch.cjs.js +7 -7
  242. package/dist/switch.esm.js +23 -31
  243. package/dist/table.cjs.js +2 -2
  244. package/dist/table.esm.js +46 -56
  245. package/dist/tabs.cjs.js +3 -3
  246. package/dist/tabs.esm.js +35 -55
  247. package/dist/tags-input.cjs.js +4 -4
  248. package/dist/tags-input.esm.js +45 -62
  249. package/dist/textarea.cjs.js +6 -6
  250. package/dist/textarea.esm.js +32 -41
  251. package/dist/time-field.cjs.js +4 -4
  252. package/dist/time-field.esm.js +70 -84
  253. package/dist/time-picker.cjs.js +22 -22
  254. package/dist/time-picker.esm.js +88 -110
  255. package/dist/timeline.cjs.js +1 -1
  256. package/dist/timeline.esm.js +3 -5
  257. package/dist/toast.cjs.js +2 -2
  258. package/dist/toast.esm.js +33 -47
  259. package/dist/toggle-group.cjs.js +6 -6
  260. package/dist/toggle-group.esm.js +85 -105
  261. package/dist/toggle.cjs.js +1 -1
  262. package/dist/toggle.esm.js +3 -5
  263. package/dist/toolbar.cjs.js +1 -1
  264. package/dist/toolbar.esm.js +13 -24
  265. package/dist/tooltip.cjs.js +2 -2
  266. package/dist/tooltip.esm.js +31 -42
  267. package/dist/transfer-list.cjs.js +19 -19
  268. package/dist/transfer-list.esm.js +98 -111
  269. package/dist/{tree-dcd74a4a.mjs → tree-B3kE8ESs.mjs} +55 -62
  270. package/dist/tree-Dx_kv_ih.js +39 -0
  271. package/dist/tree-item.cjs.js +2 -2
  272. package/dist/tree-item.esm.js +2 -3
  273. package/dist/tree.cjs.js +1 -1
  274. package/dist/tree.esm.js +2 -5
  275. package/dist/ui-button-Q0GNNWKC.mjs +665 -0
  276. package/dist/ui-button-rXQOS9QJ.js +521 -0
  277. package/dist/{icon-9e9da03b.js → ui-icon-BzVNC_lr.js} +4 -4
  278. package/dist/{icon-e2a85cc1.mjs → ui-icon-YI6lyuqU.mjs} +58 -65
  279. package/dist/visually-hidden.cjs.js +1 -1
  280. package/dist/visually-hidden.esm.js +1 -1
  281. package/dist/wizard.cjs.js +14 -14
  282. package/dist/wizard.esm.js +85 -105
  283. package/package.json +2 -2
  284. package/dist/date-time-utils-66480de4.js +0 -1
  285. package/dist/date-time-utils-a2c7af25.mjs +0 -307
  286. package/dist/dismissable-layer-193e3bed.js +0 -1
  287. package/dist/focus-scope-2b12b4e7.js +0 -1
  288. package/dist/listbox-308789a0.mjs +0 -210
  289. package/dist/listbox-ef2f708e.js +0 -46
  290. package/dist/panel-group-40254cdd.js +0 -36
  291. package/dist/portal-c69756c0.js +0 -1
  292. package/dist/positioner-33529bb8.js +0 -1
  293. package/dist/runtime-3f13807b.js +0 -1
  294. package/dist/tree-0a7a8d05.js +0 -39
  295. /package/dist/{collection-a2969ad2.js → collection-qv8A8rq4.js} +0 -0
  296. /package/dist/{menu-item-styles-27fdbac4.mjs → menu-item-styles-CZiPwPwl.mjs} +0 -0
  297. /package/dist/{menu-item-styles-83ad1e22.js → menu-item-styles-CbNUEwP2.js} +0 -0
  298. /package/dist/{roving-focus-group-5c059bf9.js → roving-focus-group-BdJ_4Njm.js} +0 -0
  299. /package/dist/{scroll-lock-d7b0df21.js → scroll-lock-BX6e3Ced.js} +0 -0
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("./ElementBase-1b301e7f.js"),g=`
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(u){return u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}class v extends p.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(t){t?this.setAttribute("value",t):this.removeAttribute("value")}startEditing(){this.hasAttribute("disabled")||this.hasAttribute("readonly")||(this._lastFocusTarget=document.activeElement||this,this._draft=this.value,this.setAttribute("editing",""),queueMicrotask(()=>{var n;const t=this.root.querySelector(".field");t==null||t.focus(),(n=t==null?void 0:t.select)==null||n.call(t)}),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 t=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:t,source:"save"},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("save",{detail:{value:this.value,previousValue:t},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(t,n,e){n!==e&&(t==="name"&&this.isConnected&&this._registerWithForm(),t==="value"&&!this.hasAttribute("editing")&&(this._draft=e||""),this.isConnected&&this.requestRender())}render(){var c,h,b;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");this.setContent(`
104
- <style>${g}</style>
103
+ `;function o(d){return d.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}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"${l?" hidden":""}>
107
- <div class="value" data-empty="${a}">${o(a?n:this.value)}</div>
108
- <button class="edit-btn" type="button"${s?" disabled":""}>Edit</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"${l?"":" hidden"}>
111
- ${e?`<textarea class="field" rows="4"${s?" disabled":""}>${o(t)}</textarea>`:`<input class="field" type="text" value="${o(t)}"${s?" disabled":""} />`}
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"${s?" disabled":""}>Cancel</button>
114
- <button class="save-btn" type="button"${s?" disabled":""}>Save</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 i=this.root.querySelector(".field");i==null||i.addEventListener("input",d=>{this._draft=d.target.value}),i==null||i.addEventListener("keydown",d=>{const r=d;r.key==="Escape"&&(r.preventDefault(),this.cancelEditing()),!e&&r.key==="Enter"&&(r.preventDefault(),this.saveEditing()),(r.metaKey||r.ctrlKey)&&r.key==="Enter"&&(r.preventDefault(),this.saveEditing())}),(c=this.root.querySelector(".edit-btn"))==null||c.addEventListener("click",()=>this.startEditing()),(h=this.root.querySelector(".cancel-btn"))==null||h.addEventListener("click",()=>this.cancelEditing()),(b=this.root.querySelector(".save-btn"))==null||b.addEventListener("click",()=>this.saveEditing())}_registerWithForm(){var t;this._formUnregister&&(this._formUnregister(),this._formUnregister=null);try{const e=this.getRootNode().host,a=((t=e==null?void 0:e.closest)==null?void 0:t.call(e,"ui-form"))||null||this.closest("ui-form"),s=this.getAttribute("name");a&&typeof a.registerField=="function"&&s&&(this._formUnregister=a.registerField(s,{name:s,getValue:()=>this.value,setValue:i=>{i==null||i===""?this.removeAttribute("value"):this.setAttribute("value",String(i))}}))}catch{}}_restoreFocus(){const t=this._lastFocusTarget&&this._lastFocusTarget.isConnected?this._lastFocusTarget:this.root.querySelector(".edit-btn");t&&(queueMicrotask(()=>{try{t.focus({preventScroll:!0})}catch{t.focus()}}),this._lastFocusTarget=null)}}typeof customElements<"u"&&!customElements.get("ui-inline-edit")&&customElements.define("ui-inline-edit",v);exports.UIInlineEdit=v;
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;
@@ -1,5 +1,5 @@
1
- import { E as v } from "./ElementBase-909688f3.mjs";
2
- const p = `
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(u) {
106
- return u.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
105
+ function o(d) {
106
+ return d.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
107
107
  }
108
- class g extends v {
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 == null || t.focus(), (n = t == null ? void 0 : t.select) == null || n.call(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, n, e) {
148
- n !== e && (t === "name" && this.isConnected && this._registerWithForm(), t === "value" && !this.hasAttribute("editing") && (this._draft = e || ""), this.isConnected && this.requestRender());
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
- var c, h, b;
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>${p}</style>
151
+ <style>${h}</style>
155
152
  <div class="root">
156
- <div class="display"${l ? " hidden" : ""}>
157
- <div class="value" data-empty="${a}">${o(a ? n : this.value)}</div>
158
- <button class="edit-btn" type="button"${s ? " disabled" : ""}>Edit</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"${l ? "" : " hidden"}>
161
- ${e ? `<textarea class="field" rows="4"${s ? " disabled" : ""}>${o(t)}</textarea>` : `<input class="field" type="text" value="${o(t)}"${s ? " disabled" : ""} />`}
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"${s ? " disabled" : ""}>Cancel</button>
164
- <button class="save-btn" type="button"${s ? " disabled" : ""}>Save</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 i = this.root.querySelector(".field");
170
- i == null || i.addEventListener("input", (d) => {
171
- this._draft = d.target.value;
172
- }), i == null || i.addEventListener("keydown", (d) => {
173
- const r = d;
174
- r.key === "Escape" && (r.preventDefault(), this.cancelEditing()), !e && r.key === "Enter" && (r.preventDefault(), this.saveEditing()), (r.metaKey || r.ctrlKey) && r.key === "Enter" && (r.preventDefault(), this.saveEditing());
175
- }), (c = this.root.querySelector(".edit-btn")) == null || c.addEventListener("click", () => this.startEditing()), (h = this.root.querySelector(".cancel-btn")) == null || h.addEventListener("click", () => this.cancelEditing()), (b = this.root.querySelector(".save-btn")) == null || b.addEventListener("click", () => this.saveEditing());
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 e = this.getRootNode().host, a = ((t = e == null ? void 0 : e.closest) == null ? void 0 : t.call(e, "ui-form")) || null || this.closest("ui-form"), s = this.getAttribute("name");
182
- a && typeof a.registerField == "function" && s && (this._formUnregister = a.registerField(s, {
183
- name: s,
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: (i) => {
186
- i == null || i === "" ? this.removeAttribute("value") : this.setAttribute("value", String(i));
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", g);
199
+ typeof customElements < "u" && !customElements.get("ui-inline-edit") && customElements.define("ui-inline-edit", b);
204
200
  export {
205
- g as UIInlineEdit
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 T=require("./ElementBase-1b301e7f.js"),N=`
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
- `,L=`
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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function z(a){if(!a)return!1;const t=a.assignedNodes({flatten:!0});return t.length?t.some(e=>{var i;return e.nodeType===Node.TEXT_NODE?!!((i=e.textContent)!=null&&i.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 I(a){return a==="none"||a==="large"||a==="full"}class q extends T.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&&!I(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")||"",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");try{t.type=e}catch{t.type="text"}t.placeholder=i,t.disabled=f,t.required=g,t.readOnly=m,t.name=u,n?t.setAttribute("pattern",n):t.removeAttribute("pattern"),s?t.setAttribute("inputmode",s):t.removeAttribute("inputmode"),o?t.setAttribute("autocomplete",o):t.removeAttribute("autocomplete"),d?t.setAttribute("min",d):t.removeAttribute("min"),l?t.setAttribute("max",l):t.removeAttribute("max"),c?t.setAttribute("step",c):t.removeAttribute("step"),p?t.setAttribute("spellcheck",p):t.removeAttribute("spellcheck"),h&&Number.isFinite(Number(h))?t.setAttribute("maxlength",h):t.removeAttribute("maxlength"),b&&Number.isFinite(Number(b))?t.setAttribute("minlength",b):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(()=>{var n,s;if(this.isConnected)try{(n=this._input)==null||n.focus({preventScroll:!0})}catch{(s=this._input)==null||s.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(){var t;(t=this._input)==null||t.blur()}select(){var t;(t=this._input)==null||t.select()}_emitValueEvent(t,e){this.dispatchEvent(new CustomEvent(t,{detail:{value:e},bubbles:!0,composed:!0}))}_registerWithForm(){var t;this._formUnregister&&(this._formUnregister(),this._formUnregister=null);try{const i=this.getRootNode().host,n=((t=i==null?void 0:i.closest)==null?void 0:t.call(i,"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&&(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 u=this.getAttribute("maxlength"),n=u?`${t.length}/${u}`:String(t.length);e.textContent=n}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"]'),u=this.root.querySelector('slot[name="prefix"]'),n=this.root.querySelector('slot[name="suffix"]'),s=(this.getAttribute("label")||"").trim(),o=(this.getAttribute("description")||"").trim(),d=(this.getAttribute("data-error")||"").trim(),l=!!s||z(t),c=!!o||z(e),p=!!d||z(i),h=z(u),b=z(n),f=this.root.querySelector(".label"),g=this.root.querySelector(".description"),m=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");f&&(l?f.removeAttribute("hidden"):f.setAttribute("hidden","")),g&&(c?g.removeAttribute("hidden"):g.setAttribute("hidden","")),m&&(h?m.removeAttribute("hidden"):m.setAttribute("hidden","")),v&&(b?v.removeAttribute("hidden"):v.setAttribute("hidden","")),x&&(l||c?x.removeAttribute("hidden"):x.setAttribute("hidden",""));const k=this.hasAttribute("counter");if(w&&(k?w.removeAttribute("hidden"):w.setAttribute("hidden","")),_&&(p?_.removeAttribute("hidden"):_.setAttribute("hidden","")),C&&(p||k?C.removeAttribute("hidden"):C.setAttribute("hidden","")),this._input){l?this._input.setAttribute("aria-labelledby",`${this._uid}-label`):this._input.removeAttribute("aria-labelledby");const A=[];c&&A.push(`${this._uid}-description`),p&&A.push(`${this._uid}-error`),A.length?this._input.setAttribute("aria-describedby",A.join(" ")):this._input.removeAttribute("aria-describedby"),this.getAttribute("validation")==="error"||!!d?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(){var S;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>':"";this._syncHostTokens(),this.setContent(`
485
- <style>${L}</style>
484
+ `;function r(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}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(n)}"
503
+ type="${r(o)}"
504
504
  name="${r(s)}"
505
505
  value="${r(t)}"
506
506
  placeholder="${r(e)}"
507
- ${o?"required":""}
508
- ${d?`pattern="${r(d)}"`:""}
509
- ${l?`inputmode="${r(l)}"`:""}
510
- ${c?`autocomplete="${r(c)}"`:""}
511
- ${p?`min="${r(p)}"`:""}
512
- ${h?`max="${r(h)}"`:""}
513
- ${b?`step="${r(b)}"`:""}
514
- ${f?`spellcheck="${r(f)}"`:""}
515
- ${g?`maxlength="${r(g)}"`:""}
516
- ${m?`minlength="${r(m)}"`:""}
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" ${u&&t&&!i&&!v?"":"hidden"}>${N}</button>
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)),(S=this._clearBtn)==null||S.addEventListener("click",this._onClearClick),this._syncControlAttrs(),this._syncInputValue(t),this._syncDerivedState(),this.hasAttribute("autofocus")&&!this._autofocusApplied&&(this._autofocusApplied=!0,queueMicrotask(()=>{var E,$;if(this.isConnected)try{(E=this._input)==null||E.focus({preventScroll:!0})}catch{($=this._input)==null||$.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",q);exports.UIInput=q;
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 q } from "./ElementBase-909688f3.mjs";
2
- const T = `
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
- `, N = `
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, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
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 L(a) {
500
+ function q(a) {
506
501
  return a === "none" || a === "large" || a === "full";
507
502
  }
508
- class I extends q {
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 && !L(e) ? this.style.setProperty("--ui-input-border-radius", e) : this.style.removeProperty("--ui-input-border-radius");
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
- return;
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 = f, t.required = g, t.readOnly = m, t.name = u, n ? t.setAttribute("pattern", n) : t.removeAttribute("pattern"), s ? t.setAttribute("inputmode", s) : t.removeAttribute("inputmode"), o ? t.setAttribute("autocomplete", o) : t.removeAttribute("autocomplete"), d ? t.setAttribute("min", d) : t.removeAttribute("min"), l ? t.setAttribute("max", l) : t.removeAttribute("max"), c ? t.setAttribute("step", c) : t.removeAttribute("step"), p ? t.setAttribute("spellcheck", p) : t.removeAttribute("spellcheck"), h && Number.isFinite(Number(h)) ? t.setAttribute("maxlength", h) : t.removeAttribute("maxlength"), b && Number.isFinite(Number(b)) ? t.setAttribute("minlength", b) : t.removeAttribute("minlength");
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
- (n = this._input) == null || n.focus({ preventScroll: !0 });
605
+ this._input?.focus({ preventScroll: !0 });
614
606
  } catch {
615
- (s = this._input) == null || s.focus();
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
- var t;
637
- (t = this._input) == null || t.blur();
628
+ this._input?.blur();
638
629
  }
639
630
  select() {
640
- var t;
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 i = this.getRootNode().host, n = ((t = i == null ? void 0 : i.closest) == null ? void 0 : t.call(i, "ui-form")) || null || this.closest("ui-form"), s = this.getAttribute("name");
657
- n && typeof n.registerField == "function" && s && (this._formUnregister = n.registerField(s, {
658
- name: s,
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: (o) => {
661
- this.value = String(o ?? "");
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: (o) => {
665
- o ? (this.setAttribute("validation", "error"), this.setAttribute("data-error", o)) : (this.removeAttribute("validation"), this.removeAttribute("data-error"));
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 u = this.getAttribute("maxlength"), n = u ? `${t.length}/${u}` : String(t.length);
679
- e.textContent = n;
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"]'), u = this.root.querySelector('slot[name="prefix"]'), n = this.root.querySelector('slot[name="suffix"]'), s = (this.getAttribute("label") || "").trim(), o = (this.getAttribute("description") || "").trim(), d = (this.getAttribute("data-error") || "").trim(), l = !!s || z(t), c = !!o || z(e), p = !!d || z(i), h = z(u), b = z(n), f = this.root.querySelector(".label"), g = this.root.querySelector(".description"), m = 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");
689
- f && (l ? f.removeAttribute("hidden") : f.setAttribute("hidden", "")), g && (c ? g.removeAttribute("hidden") : g.setAttribute("hidden", "")), m && (h ? m.removeAttribute("hidden") : m.setAttribute("hidden", "")), v && (b ? v.removeAttribute("hidden") : v.setAttribute("hidden", "")), x && (l || c ? x.removeAttribute("hidden") : x.setAttribute("hidden", ""));
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", "")), _ && (p ? _.removeAttribute("hidden") : _.setAttribute("hidden", "")), C && (p || k ? C.removeAttribute("hidden") : C.setAttribute("hidden", "")), this._input) {
692
- l ? this._input.setAttribute("aria-labelledby", `${this._uid}-label`) : this._input.removeAttribute("aria-labelledby");
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
- c && A.push(`${this._uid}-description`), p && A.push(`${this._uid}-error`), A.length ? this._input.setAttribute("aria-describedby", A.join(" ")) : this._input.removeAttribute("aria-describedby"), this.getAttribute("validation") === "error" || !!d ? 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");
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
- var S;
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>${N}</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(n)}"
729
+ type="${r(o)}"
742
730
  name="${r(s)}"
743
731
  value="${r(t)}"
744
732
  placeholder="${r(e)}"
745
- ${o ? "required" : ""}
746
- ${d ? `pattern="${r(d)}"` : ""}
747
- ${l ? `inputmode="${r(l)}"` : ""}
748
- ${c ? `autocomplete="${r(c)}"` : ""}
749
- ${p ? `min="${r(p)}"` : ""}
750
- ${h ? `max="${r(h)}"` : ""}
751
- ${b ? `step="${r(b)}"` : ""}
752
- ${f ? `spellcheck="${r(f)}"` : ""}
753
- ${g ? `maxlength="${r(g)}"` : ""}
754
- ${m ? `minlength="${r(m)}"` : ""}
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" ${u && t && !i && !v ? "" : "hidden"}>${T}</button>
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)), (S = this._clearBtn) == null || S.addEventListener("click", this._onClearClick), this._syncControlAttrs(), this._syncInputValue(t), this._syncDerivedState(), this.hasAttribute("autofocus") && !this._autofocusApplied && (this._autofocusApplied = !0, queueMicrotask(() => {
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
- (E = this._input) == null || E.focus({ preventScroll: !0 });
764
+ this._input?.focus({ preventScroll: !0 });
778
765
  } catch {
779
- ($ = this._input) == null || $.focus();
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", I);
774
+ typeof customElements < "u" && !customElements.get("ui-input") && customElements.define("ui-input", T);
788
775
  export {
789
- I as UIInput
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-1b301e7f.js"),u=`
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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function c(i){if(!i)return!1;const e=i.assignedNodes({flatten:!0});return e.length?e.some(o=>{var t;return o.nodeType===Node.TEXT_NODE?!!((t=o.textContent)!=null&&t.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(`
184
+ `;function a(i){return i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}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)}"`:""}>