@greypan/web-ui 3.0.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/README.CN.md +292 -31
  2. package/README.md +294 -31
  3. package/dist/_virtual/{_@oxc-project_runtime@0.140.0 → _@oxc-project_runtime@0.146.0}/helpers/esm/decorate.js +1 -1
  4. package/dist/assets/glass.js +1 -1
  5. package/dist/assets/glass.js.map +1 -1
  6. package/dist/assets/menu-portal.js +1 -1
  7. package/dist/assets/menu-portal.js.map +1 -1
  8. package/dist/assets/overlay-motion.js +1 -1
  9. package/dist/assets/overlay-motion.js.map +1 -1
  10. package/dist/assets/toast-containers.js +1 -1
  11. package/dist/assets/toast-containers.js.map +1 -1
  12. package/dist/components/autocomplete/index.d.ts +4 -12
  13. package/dist/components/autocomplete/index.js +95 -102
  14. package/dist/components/autocomplete/index.js.map +1 -1
  15. package/dist/components/autocomplete/style.js +1 -1
  16. package/dist/components/autocomplete/style.js.map +1 -1
  17. package/dist/components/avatar/index.d.ts +0 -1
  18. package/dist/components/avatar/index.js +8 -13
  19. package/dist/components/avatar/index.js.map +1 -1
  20. package/dist/components/back-top/index.js +1 -1
  21. package/dist/components/back-top/style.js +1 -1
  22. package/dist/components/back-top/style.js.map +1 -1
  23. package/dist/components/badge/index.d.ts +1 -0
  24. package/dist/components/badge/index.js +12 -14
  25. package/dist/components/badge/index.js.map +1 -1
  26. package/dist/components/button/index.d.ts +2 -0
  27. package/dist/components/button/index.js +51 -38
  28. package/dist/components/button/index.js.map +1 -1
  29. package/dist/components/button/style.js +1 -1
  30. package/dist/components/button/style.js.map +1 -1
  31. package/dist/components/button-group/index.d.ts +1 -2
  32. package/dist/components/button-group/index.js +19 -23
  33. package/dist/components/button-group/index.js.map +1 -1
  34. package/dist/components/checkbox/index.d.ts +4 -7
  35. package/dist/components/checkbox/index.js +48 -37
  36. package/dist/components/checkbox/index.js.map +1 -1
  37. package/dist/components/checkbox/style.js +1 -1
  38. package/dist/components/checkbox/style.js.map +1 -1
  39. package/dist/components/checkbox-group/index.d.ts +4 -10
  40. package/dist/components/checkbox-group/index.js +74 -60
  41. package/dist/components/checkbox-group/index.js.map +1 -1
  42. package/dist/components/context-menu/index.js +7 -8
  43. package/dist/components/context-menu/index.js.map +1 -1
  44. package/dist/components/dialog/index.js +6 -6
  45. package/dist/components/dialog/index.js.map +1 -1
  46. package/dist/components/dialog/style.js +1 -1
  47. package/dist/components/dialog/style.js.map +1 -1
  48. package/dist/components/drawer/index.d.ts +15 -0
  49. package/dist/components/drawer/index.js +58 -34
  50. package/dist/components/drawer/index.js.map +1 -1
  51. package/dist/components/drawer/style.js +1 -1
  52. package/dist/components/drawer/style.js.map +1 -1
  53. package/dist/components/dropdown/index.js +1 -1
  54. package/dist/components/dropdown-divider/index.js +1 -1
  55. package/dist/components/dropdown-header/index.js +1 -1
  56. package/dist/components/dropdown-header/style.js +1 -1
  57. package/dist/components/dropdown-header/style.js.map +1 -1
  58. package/dist/components/dropdown-item/index.js +3 -2
  59. package/dist/components/dropdown-item/index.js.map +1 -1
  60. package/dist/components/empty/index.js +1 -1
  61. package/dist/components/empty/style.js +1 -1
  62. package/dist/components/empty/style.js.map +1 -1
  63. package/dist/components/icon/index.js +1 -1
  64. package/dist/components/index.js +9 -9
  65. package/dist/components/input/index.d.ts +2 -3
  66. package/dist/components/input/index.js +62 -52
  67. package/dist/components/input/index.js.map +1 -1
  68. package/dist/components/input/style.js +1 -1
  69. package/dist/components/input/style.js.map +1 -1
  70. package/dist/components/input-number/index.d.ts +2 -3
  71. package/dist/components/input-number/index.js +58 -38
  72. package/dist/components/input-number/index.js.map +1 -1
  73. package/dist/components/input-number/style.js +1 -1
  74. package/dist/components/input-number/style.js.map +1 -1
  75. package/dist/components/layout/index.d.ts +53 -3
  76. package/dist/components/layout/index.js +146 -39
  77. package/dist/components/layout/index.js.map +1 -1
  78. package/dist/components/layout/style.js +1 -1
  79. package/dist/components/layout/style.js.map +1 -1
  80. package/dist/components/option/index.js +1 -1
  81. package/dist/components/option/style.js +1 -1
  82. package/dist/components/option/style.js.map +1 -1
  83. package/dist/components/popover/index.js +7 -5
  84. package/dist/components/popover/index.js.map +1 -1
  85. package/dist/components/popover/style.js +1 -1
  86. package/dist/components/popover/style.js.map +1 -1
  87. package/dist/components/radio/index.d.ts +4 -7
  88. package/dist/components/radio/index.js +48 -37
  89. package/dist/components/radio/index.js.map +1 -1
  90. package/dist/components/radio/style.js +1 -1
  91. package/dist/components/radio/style.js.map +1 -1
  92. package/dist/components/radio-group/index.d.ts +4 -10
  93. package/dist/components/radio-group/index.js +70 -52
  94. package/dist/components/radio-group/index.js.map +1 -1
  95. package/dist/components/segmented/index.d.ts +6 -11
  96. package/dist/components/segmented/index.js +67 -55
  97. package/dist/components/segmented/index.js.map +1 -1
  98. package/dist/components/segmented/style.js +1 -1
  99. package/dist/components/segmented/style.js.map +1 -1
  100. package/dist/components/segmented-trigger/index.d.ts +1 -2
  101. package/dist/components/segmented-trigger/index.js +18 -19
  102. package/dist/components/segmented-trigger/index.js.map +1 -1
  103. package/dist/components/segmented-trigger/style.js +1 -1
  104. package/dist/components/segmented-trigger/style.js.map +1 -1
  105. package/dist/components/select/index.d.ts +13 -8
  106. package/dist/components/select/index.js +110 -75
  107. package/dist/components/select/index.js.map +1 -1
  108. package/dist/components/select/style.js +1 -1
  109. package/dist/components/select/style.js.map +1 -1
  110. package/dist/components/slider/index.d.ts +3 -5
  111. package/dist/components/slider/index.js +59 -42
  112. package/dist/components/slider/index.js.map +1 -1
  113. package/dist/components/slider/style.js +1 -1
  114. package/dist/components/slider/style.js.map +1 -1
  115. package/dist/components/spinner/index.d.ts +0 -2
  116. package/dist/components/spinner/index.js +14 -13
  117. package/dist/components/spinner/index.js.map +1 -1
  118. package/dist/components/spinner/style.js +1 -1
  119. package/dist/components/spinner/style.js.map +1 -1
  120. package/dist/components/svg-draw-lines/index.js +1 -1
  121. package/dist/components/switch/index.d.ts +5 -6
  122. package/dist/components/switch/index.js +51 -37
  123. package/dist/components/switch/index.js.map +1 -1
  124. package/dist/components/switch/style.js +1 -1
  125. package/dist/components/switch/style.js.map +1 -1
  126. package/dist/components/textarea/index.d.ts +5 -6
  127. package/dist/components/textarea/index.js +73 -63
  128. package/dist/components/textarea/index.js.map +1 -1
  129. package/dist/components/textarea/style.js +1 -1
  130. package/dist/components/textarea/style.js.map +1 -1
  131. package/dist/components/theme/index.js +1 -1
  132. package/dist/components/theme/style.js +1 -1
  133. package/dist/components/theme/style.js.map +1 -1
  134. package/dist/components/toast/style.js +1 -1
  135. package/dist/components/toast/style.js.map +1 -1
  136. package/dist/components/toast/toast.js +12 -12
  137. package/dist/components/toast/toast.js.map +1 -1
  138. package/dist/components/tooltip/index.js +1 -1
  139. package/dist/components/tooltip/style.js +1 -1
  140. package/dist/components/tooltip/style.js.map +1 -1
  141. package/dist/icons/generated/lucide-clapperboard.d.ts +6 -0
  142. package/dist/icons/generated/lucide-clapperboard.js +10 -0
  143. package/dist/icons/generated/lucide-clapperboard.js.map +1 -0
  144. package/dist/icons/generated/lucide-eye.d.ts +6 -0
  145. package/dist/icons/generated/lucide-eye.js +10 -0
  146. package/dist/icons/generated/lucide-eye.js.map +1 -0
  147. package/dist/icons/generated/lucide-headphones.d.ts +6 -0
  148. package/dist/icons/generated/lucide-headphones.js +10 -0
  149. package/dist/icons/generated/lucide-headphones.js.map +1 -0
  150. package/dist/icons/generated/lucide-link.d.ts +6 -0
  151. package/dist/icons/generated/lucide-link.js +10 -0
  152. package/dist/icons/generated/lucide-link.js.map +1 -0
  153. package/dist/icons/generated/lucide-pen-line.d.ts +6 -0
  154. package/dist/icons/generated/lucide-pen-line.js +10 -0
  155. package/dist/icons/generated/lucide-pen-line.js.map +1 -0
  156. package/dist/icons/generated/lucide-play.d.ts +6 -0
  157. package/dist/icons/generated/lucide-play.js +10 -0
  158. package/dist/icons/generated/lucide-play.js.map +1 -0
  159. package/dist/icons/generated/lucide-sliders-horizontal.d.ts +6 -0
  160. package/dist/icons/generated/lucide-sliders-horizontal.js +10 -0
  161. package/dist/icons/generated/lucide-sliders-horizontal.js.map +1 -0
  162. package/dist/icons/index.d.ts +7 -0
  163. package/dist/icons/index.js +8 -1
  164. package/dist/node_modules/.pnpm/@floating-ui_core@1.8.0/node_modules/@floating-ui/core/dist/floating-ui.core.js +1 -3
  165. package/dist/node_modules/.pnpm/@floating-ui_core@1.8.0/node_modules/@floating-ui/core/dist/floating-ui.core.js.map +1 -1
  166. package/dist/node_modules/.pnpm/@floating-ui_utils@0.2.12/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +2 -1
  167. package/dist/node_modules/.pnpm/@floating-ui_utils@0.2.12/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js.map +1 -1
  168. package/dist/shared/events/user-change.js.map +1 -1
  169. package/dist/shared/form-association/index.js +41 -0
  170. package/dist/shared/form-association/index.js.map +1 -0
  171. package/dist/shared/group-management/index.js +109 -0
  172. package/dist/shared/group-management/index.js.map +1 -0
  173. package/dist/shared/menu-portal/menu-tree.js +20 -7
  174. package/dist/shared/menu-portal/menu-tree.js.map +1 -1
  175. package/dist/shared/option-portal/index.js +65 -0
  176. package/dist/shared/option-portal/index.js.map +1 -0
  177. package/dist/shared/overlay/overlay.js +1 -1
  178. package/dist/shared/overlay/overlay.js.map +1 -1
  179. package/dist/shared/overlay/portal.js +9 -6
  180. package/dist/shared/overlay/portal.js.map +1 -1
  181. package/dist/shared/overlay/presence.js.map +1 -1
  182. package/dist/shared/visible-area/index.js +69 -0
  183. package/dist/shared/visible-area/index.js.map +1 -0
  184. package/package.json +6 -4
@@ -1,5 +1,5 @@
1
1
  //#region src/components/empty/style.css?inline
2
- var e = "*,:before,:after{box-sizing:border-box}:host{display:block}.empty{width:100%;min-block-size:var(--wui-empty-min-height,240px);padding:var(--wui-empty-padding,32px 24px);text-align:center;flex-direction:column;align-items:center;display:flex}.empty-icon{--wui-glass-shadow:none;width:var(--wui-empty-icon-size,56px);height:var(--wui-empty-icon-size,56px);color:var(--wui-color-text-muted,#6a6a6a);background-color:var(--wui-color-surface-raised,#f2f2f7);border-radius:16px;flex:none;justify-content:center;align-items:center;display:flex}.empty-title,.empty-description,.empty-action{max-inline-size:var(--wui-empty-content-width,480px)}.empty-title{margin-top:var(--wui-empty-title-margin-top,16px);font-size:var(--wui-empty-title-font-size,16px);color:var(--wui-color-text,#262626);overflow-wrap:anywhere;font-weight:600;line-height:1.5}.empty-description{font-size:var(--wui-empty-description-font-size,14px);color:var(--wui-color-text-muted,#6a6a6a);overflow-wrap:anywhere;margin-top:6px;line-height:1.6}.empty-action{margin-top:var(--wui-empty-action-margin-top,20px)}.is-hidden{display:none}:host([size=small]){--wui-empty-min-height:160px;--wui-empty-padding:20px 16px;--wui-empty-icon-size:40px;--wui-empty-title-margin-top:12px;--wui-empty-title-font-size:14px;--wui-empty-description-font-size:13px;--wui-empty-action-margin-top:16px}:host([size=large]){--wui-empty-min-height:320px;--wui-empty-padding:48px 32px;--wui-empty-icon-size:72px;--wui-empty-title-margin-top:20px;--wui-empty-title-font-size:18px;--wui-empty-action-margin-top:24px}";
2
+ var e = "*,:before,:after{box-sizing:border-box}:host{display:block}.empty{width:100%;min-block-size:var(--wui-empty-min-height,240px);padding:var(--wui-empty-padding,32px 24px);text-align:center;flex-direction:column;align-items:center;display:flex}.empty-icon{width:var(--wui-empty-icon-size,56px);height:var(--wui-empty-icon-size,56px);color:var(--wui-color-text-secondary,#6a6a6a);background-color:var(--wui-color-surface-raised,#f2f2f7);box-shadow:none;border-radius:16px;flex:none;justify-content:center;align-items:center;display:flex}.empty-title,.empty-description,.empty-action{max-inline-size:var(--wui-empty-content-width,480px)}.empty-title{margin-top:var(--wui-empty-title-margin-top,16px);font-size:var(--wui-empty-title-font-size,16px);color:var(--wui-color-text,#1b1b1b);overflow-wrap:anywhere;font-weight:600;line-height:1.5}.empty-description{font-size:var(--wui-empty-description-font-size,14px);color:var(--wui-color-text-secondary,#6a6a6a);overflow-wrap:anywhere;margin-top:6px;line-height:1.6}.empty-action{margin-top:var(--wui-empty-action-margin-top,20px)}.is-hidden{display:none}:host([size=small]){--wui-empty-min-height:160px;--wui-empty-padding:20px 16px;--wui-empty-icon-size:40px;--wui-empty-title-margin-top:12px;--wui-empty-title-font-size:14px;--wui-empty-description-font-size:13px;--wui-empty-action-margin-top:16px}:host([size=large]){--wui-empty-min-height:320px;--wui-empty-padding:48px 32px;--wui-empty-icon-size:72px;--wui-empty-title-margin-top:20px;--wui-empty-title-font-size:18px;--wui-empty-action-margin-top:24px}";
3
3
  //#endregion
4
4
  export { e as default };
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"style.js","names":[],"sources":["../../../src/components/empty/style.css?inline"],"sourcesContent":["*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\n\n:host {\n display: block;\n}\n\n.empty {\n display: flex;\n flex-direction: column;\n align-items: center;\n\n width: 100%;\n min-block-size: var(--wui-empty-min-height, 240px);\n padding: var(--wui-empty-padding, 32px 24px);\n\n text-align: center;\n}\n\n.empty-icon {\n --wui-glass-shadow: none;\n\n display: flex;\n flex: none;\n align-items: center;\n justify-content: center;\n\n width: var(--wui-empty-icon-size, 56px);\n height: var(--wui-empty-icon-size, 56px);\n border-radius: 16px;\n\n color: var(--wui-color-text-muted, #6a6a6a);\n\n background-color: var(--wui-color-surface-raised, #f2f2f7);\n}\n\n.empty-title,\n.empty-description,\n.empty-action {\n max-inline-size: var(--wui-empty-content-width, 480px);\n}\n\n.empty-title {\n margin-top: var(--wui-empty-title-margin-top, 16px);\n\n font-size: var(--wui-empty-title-font-size, 16px);\n font-weight: 600;\n line-height: 1.5;\n color: var(--wui-color-text, #262626);\n overflow-wrap: anywhere;\n}\n\n.empty-description {\n margin-top: 6px;\n\n font-size: var(--wui-empty-description-font-size, 14px);\n line-height: 1.6;\n color: var(--wui-color-text-muted, #6a6a6a);\n overflow-wrap: anywhere;\n}\n\n.empty-action {\n margin-top: var(--wui-empty-action-margin-top, 20px);\n}\n\n.is-hidden {\n display: none;\n}\n\n:host([size='small']) {\n --wui-empty-min-height: 160px;\n --wui-empty-padding: 20px 16px;\n --wui-empty-icon-size: 40px;\n --wui-empty-title-margin-top: 12px;\n --wui-empty-title-font-size: 14px;\n --wui-empty-description-font-size: 13px;\n --wui-empty-action-margin-top: 16px;\n}\n\n:host([size='large']) {\n --wui-empty-min-height: 320px;\n --wui-empty-padding: 48px 32px;\n --wui-empty-icon-size: 72px;\n --wui-empty-title-margin-top: 20px;\n --wui-empty-title-font-size: 18px;\n --wui-empty-action-margin-top: 24px;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"style.js","names":[],"sources":["../../../src/components/empty/style.css?inline"],"sourcesContent":["*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\n\n:host {\n display: block;\n}\n\n.empty {\n display: flex;\n flex-direction: column;\n align-items: center;\n\n width: 100%;\n min-block-size: var(--wui-empty-min-height, 240px);\n padding: var(--wui-empty-padding, 32px 24px);\n\n text-align: center;\n}\n\n.empty-icon {\n display: flex;\n flex: none;\n align-items: center;\n justify-content: center;\n\n width: var(--wui-empty-icon-size, 56px);\n height: var(--wui-empty-icon-size, 56px);\n border-radius: 16px;\n\n color: var(--wui-color-text-secondary, #6a6a6a);\n\n background-color: var(--wui-color-surface-raised, #f2f2f7);\n box-shadow: none;\n}\n\n.empty-title,\n.empty-description,\n.empty-action {\n max-inline-size: var(--wui-empty-content-width, 480px);\n}\n\n.empty-title {\n margin-top: var(--wui-empty-title-margin-top, 16px);\n\n font-size: var(--wui-empty-title-font-size, 16px);\n font-weight: 600;\n line-height: 1.5;\n color: var(--wui-color-text, #1b1b1b);\n overflow-wrap: anywhere;\n}\n\n.empty-description {\n margin-top: 6px;\n\n font-size: var(--wui-empty-description-font-size, 14px);\n line-height: 1.6;\n color: var(--wui-color-text-secondary, #6a6a6a);\n overflow-wrap: anywhere;\n}\n\n.empty-action {\n margin-top: var(--wui-empty-action-margin-top, 20px);\n}\n\n.is-hidden {\n display: none;\n}\n\n:host([size='small']) {\n --wui-empty-min-height: 160px;\n --wui-empty-padding: 20px 16px;\n --wui-empty-icon-size: 40px;\n --wui-empty-title-margin-top: 12px;\n --wui-empty-title-font-size: 14px;\n --wui-empty-description-font-size: 13px;\n --wui-empty-action-margin-top: 16px;\n}\n\n:host([size='large']) {\n --wui-empty-min-height: 320px;\n --wui-empty-padding: 48px 32px;\n --wui-empty-icon-size: 72px;\n --wui-empty-title-margin-top: 20px;\n --wui-empty-title-font-size: 18px;\n --wui-empty-action-margin-top: 24px;\n}\n"],"mappings":""}
@@ -1,5 +1,5 @@
1
1
  import e from "./style.js";
2
- import t from "../../_virtual/_@oxc-project_runtime@0.140.0/helpers/esm/decorate.js";
2
+ import t from "../../_virtual/_@oxc-project_runtime@0.146.0/helpers/esm/decorate.js";
3
3
  import { LitElement as n, html as r, nothing as i, unsafeCSS as a } from "lit";
4
4
  import { customElement as o, property as s } from "lit/decorators.js";
5
5
  import { classMap as c } from "lit/directives/class-map.js";
@@ -26,13 +26,13 @@ import { WebUiSegmented as w } from "./segmented/index.js";
26
26
  import { WebUiSegmentedTrigger as T } from "./segmented-trigger/index.js";
27
27
  import { WebUiSelect as E } from "./select/index.js";
28
28
  import { WebUiSlider as D } from "./slider/index.js";
29
- import { WebUiSpinner as O, WebUiSpinnerElement as k } from "./spinner/index.js";
30
- import { WebUiTextarea as A } from "./textarea/index.js";
31
- import { WebUiTheme as j } from "./theme/index.js";
32
- import { toast as M } from "./toast/manager.js";
33
- import { WebUiToast as N } from "./toast/toast.js";
29
+ import { WebUiSpinner as O } from "./spinner/index.js";
30
+ import { WebUiTextarea as k } from "./textarea/index.js";
31
+ import { WebUiTheme as A } from "./theme/index.js";
32
+ import { toast as j } from "./toast/manager.js";
33
+ import { WebUiToast as M } from "./toast/toast.js";
34
34
  import "./toast/index.js";
35
- import { WebUiSvgDrawLines as P } from "./svg-draw-lines/index.js";
36
- import { WebUiSwitch as F } from "./switch/index.js";
37
- import { WebUiTooltip as I } from "./tooltip/index.js";
38
- export { n as WebUiAutocomplete, r as WebUiAvatar, a as WebUiBackTop, o as WebUiBadge, i as WebUiButton, s as WebUiButtonGroup, c as WebUiCheckbox, l as WebUiCheckboxGroup, p as WebUiContextMenu, m as WebUiDialog, h as WebUiDrawer, g as WebUiDropdown, u as WebUiDropdownDivider, d as WebUiDropdownHeader, f as WebUiDropdownItem, _ as WebUiEmpty, e as WebUiIcon, v as WebUiInput, y as WebUiInputNumber, b as WebUiLayout, t as WebUiOption, x as WebUiPopover, S as WebUiRadio, C as WebUiRadioGroup, w as WebUiSegmented, T as WebUiSegmentedTrigger, E as WebUiSelect, D as WebUiSlider, O as WebUiSpinner, k as WebUiSpinnerElement, P as WebUiSvgDrawLines, F as WebUiSwitch, A as WebUiTextarea, j as WebUiTheme, N as WebUiToast, I as WebUiTooltip, M as toast };
35
+ import { WebUiSvgDrawLines as N } from "./svg-draw-lines/index.js";
36
+ import { WebUiSwitch as P } from "./switch/index.js";
37
+ import { WebUiTooltip as F } from "./tooltip/index.js";
38
+ export { n as WebUiAutocomplete, r as WebUiAvatar, a as WebUiBackTop, o as WebUiBadge, i as WebUiButton, s as WebUiButtonGroup, c as WebUiCheckbox, l as WebUiCheckboxGroup, p as WebUiContextMenu, m as WebUiDialog, h as WebUiDrawer, g as WebUiDropdown, u as WebUiDropdownDivider, d as WebUiDropdownHeader, f as WebUiDropdownItem, _ as WebUiEmpty, e as WebUiIcon, v as WebUiInput, y as WebUiInputNumber, b as WebUiLayout, t as WebUiOption, x as WebUiPopover, S as WebUiRadio, C as WebUiRadioGroup, w as WebUiSegmented, T as WebUiSegmentedTrigger, E as WebUiSelect, D as WebUiSlider, O as WebUiSpinner, N as WebUiSvgDrawLines, P as WebUiSwitch, k as WebUiTextarea, A as WebUiTheme, M as WebUiToast, F as WebUiTooltip, j as toast };
@@ -14,14 +14,13 @@ export declare class WebUiInput extends LitElement {
14
14
  ariaLabel: string | null;
15
15
  private _value;
16
16
  private _focused;
17
- private _formDisabled;
18
17
  private _hasPrefix;
19
18
  private _hasSuffix;
20
- private _internals?;
21
19
  get value(): string;
22
20
  set value(v: string);
23
21
  private get _isDisabled();
24
- connectedCallback(): void;
22
+ private readonly _formAssociation;
23
+ private readonly _formAssociationController;
25
24
  updated(changed: Map<string, unknown>): void;
26
25
  formResetCallback(): void;
27
26
  formDisabledCallback(disabled: boolean): void;
@@ -1,36 +1,46 @@
1
- import e from "../../_virtual/_@oxc-project_runtime@0.140.0/helpers/esm/decorate.js";
1
+ import e from "../../_virtual/_@oxc-project_runtime@0.146.0/helpers/esm/decorate.js";
2
2
  import "../icon/index.js";
3
3
  import t from "../../icons/generated/jam-close-circle-f.js";
4
4
  import n from "../../assets/glass.js";
5
+ import { FormAssociationController as r, defineFormAssociation as i } from "../../shared/form-association/index.js";
5
6
  import "../button/index.js";
6
- import r from "./style.js";
7
- import { LitElement as i, html as a, unsafeCSS as o } from "lit";
8
- import { customElement as s, property as c, state as l } from "lit/decorators.js";
9
- import { ifDefined as u } from "lit/directives/if-defined.js";
10
- import { classMap as d } from "lit/directives/class-map.js";
7
+ import a from "./style.js";
8
+ import { LitElement as o, html as s, unsafeCSS as c } from "lit";
9
+ import { customElement as l, property as u, state as d } from "lit/decorators.js";
10
+ import { ifDefined as f } from "lit/directives/if-defined.js";
11
+ import { classMap as p } from "lit/directives/class-map.js";
11
12
  //#region src/components/input/index.ts
12
- var f = class extends i {
13
+ var m = class extends o {
13
14
  constructor(...e) {
14
- super(...e), this.type = "text", this.placeholder = "", this.name = "", this.disabled = !1, this.readonly = !1, this.required = !1, this.clearable = !1, this.full = !1, this.borderless = !1, this.ariaLabel = null, this._value = "", this._focused = !1, this._formDisabled = !1, this._hasPrefix = !1, this._hasSuffix = !1;
15
+ super(...e), this.type = "text", this.placeholder = "", this.name = "", this.disabled = !1, this.readonly = !1, this.required = !1, this.clearable = !1, this.full = !1, this.borderless = !1, this.ariaLabel = null, this._value = "", this._focused = !1, this._hasPrefix = !1, this._hasSuffix = !1, this._formAssociation = i({
16
+ host: this,
17
+ getState: () => this._value,
18
+ setState: (e) => {
19
+ this.value = e;
20
+ },
21
+ getFormValue: () => this._value,
22
+ getFormState: () => this._value,
23
+ restoreState: (e) => {
24
+ typeof e == "string" && (this.value = e);
25
+ },
26
+ syncValidity: () => this._syncValidity()
27
+ }).make(), this._formAssociationController = new r(this, this._formAssociation);
15
28
  }
16
29
  static {
17
30
  this.formAssociated = !0;
18
31
  }
19
32
  static {
20
- this.styles = [o(n), o(r)];
33
+ this.styles = [c(n), c(a)];
21
34
  }
22
35
  get value() {
23
36
  return this._value;
24
37
  }
25
38
  set value(e) {
26
39
  let t = this._value;
27
- this._value = e, this._internals?.setFormValue?.(e), this.requestUpdate("value", t);
40
+ this._value = e, this._formAssociation.sync(), this.requestUpdate("value", t);
28
41
  }
29
42
  get _isDisabled() {
30
- return this.disabled || this._formDisabled;
31
- }
32
- connectedCallback() {
33
- super.connectedCallback(), this._internals ||= this.attachInternals(), this._internals.setFormValue?.(this._value);
43
+ return this.disabled || this._formAssociation.isFormDisabled();
34
44
  }
35
45
  updated(e) {
36
46
  if (e.has("_value")) {
@@ -40,23 +50,23 @@ var f = class extends i {
40
50
  this._syncValidity(), this.toggleAttribute("focused", this._focused);
41
51
  }
42
52
  formResetCallback() {
43
- this.value = this.getAttribute("value") || "";
53
+ this._formAssociation.reset();
44
54
  }
45
55
  formDisabledCallback(e) {
46
- this._formDisabled = e;
56
+ this._formAssociation.setDisabled(e);
47
57
  }
48
58
  formStateRestoreCallback(e) {
49
- typeof e == "string" && (this.value = e);
59
+ this._formAssociation.restore(e);
50
60
  }
51
61
  _syncValidity() {
52
- let e = this.shadowRoot?.querySelector("input");
53
- if (!this._internals || !e || typeof this._internals.setValidity != "function") return;
62
+ let e = this.shadowRoot?.querySelector("input"), t = this._formAssociation.getInternals();
63
+ if (!t || !e || typeof t.setValidity != "function") return;
54
64
  if (this._isDisabled || e.validity.valid) {
55
- this._internals.setValidity({});
65
+ t.setValidity({});
56
66
  return;
57
67
  }
58
- let t = {};
59
- e.validity.valueMissing && (t.valueMissing = !0), e.validity.typeMismatch && (t.typeMismatch = !0), e.validity.patternMismatch && (t.patternMismatch = !0), e.validity.tooLong && (t.tooLong = !0), e.validity.tooShort && (t.tooShort = !0), this._internals.setValidity(t, e.validationMessage, e);
68
+ let n = {};
69
+ e.validity.valueMissing && (n.valueMissing = !0), e.validity.typeMismatch && (n.typeMismatch = !0), e.validity.patternMismatch && (n.patternMismatch = !0), e.validity.tooLong && (n.tooLong = !0), e.validity.tooShort && (n.tooShort = !0), t.setValidity(n, e.validationMessage, e);
60
70
  }
61
71
  _onSlotChange(e) {
62
72
  if (!(e.target instanceof HTMLSlotElement)) return;
@@ -64,10 +74,10 @@ var f = class extends i {
64
74
  t.name === "prefix" && (this._hasPrefix = n), t.name === "suffix" && (this._hasSuffix = n);
65
75
  }
66
76
  handleInput(e) {
67
- this._isDisabled || this.readonly || e.target instanceof HTMLInputElement && (this._value = e.target.value, this._internals?.setFormValue?.(this._value), this._syncValidity());
77
+ this._isDisabled || this.readonly || e.target instanceof HTMLInputElement && (this._value = e.target.value, this._formAssociation.sync());
68
78
  }
69
79
  handleNativeChange(e) {
70
- this.readonly || e.target instanceof HTMLInputElement && (this._value = e.target.value, this._internals?.setFormValue?.(this._value), this._syncValidity(), this.dispatchEvent(new Event("change", {
80
+ this.readonly || e.target instanceof HTMLInputElement && (this._value = e.target.value, this._formAssociation.sync(), this.dispatchEvent(new Event("change", {
71
81
  bubbles: !0,
72
82
  composed: !0
73
83
  })));
@@ -79,7 +89,7 @@ var f = class extends i {
79
89
  this._focused = !1;
80
90
  }
81
91
  handleClear() {
82
- this._isDisabled || this.readonly || (this._value = "", this._internals?.setFormValue?.(""), this._syncValidity(), this.dispatchEvent(new Event("input", {
92
+ this._isDisabled || this.readonly || (this._value = "", this._formAssociation.sync(), this.dispatchEvent(new Event("input", {
83
93
  bubbles: !0,
84
94
  composed: !0
85
95
  })));
@@ -92,14 +102,14 @@ var f = class extends i {
92
102
  }
93
103
  render() {
94
104
  let e = this.clearable && this._value && !this.readonly;
95
- return a`
105
+ return s`
96
106
  <div class="wui-glass wui-input-inner" @click=${this.focusInput}>
97
- <slot name="prefix" class=${d({ empty: !this._hasPrefix })} @slotchange=${this._onSlotChange}></slot>
107
+ <slot name="prefix" class=${p({ empty: !this._hasPrefix })} @slotchange=${this._onSlotChange}></slot>
98
108
  <input
99
109
  type=${this.type}
100
110
  placeholder=${this.placeholder}
101
111
  name=${this.name}
102
- aria-label=${u(this.ariaLabel)}
112
+ aria-label=${f(this.ariaLabel)}
103
113
  ?disabled=${this._isDisabled}
104
114
  ?readonly=${this.readonly}
105
115
  ?required=${this.required}
@@ -109,56 +119,56 @@ var f = class extends i {
109
119
  @focus=${this.handleFocus}
110
120
  @blur=${this.handleBlur}
111
121
  />
112
- ${e ? a`<web-ui-button
113
- icon
114
- variant="ghost"
115
- size="24"
116
- aria-label="清除"
117
- @pointerdown=${this.preventMouseDownBlur}
118
- @click=${this.handleClear}
119
- >
120
- <web-ui-icon .icon=${t}></web-ui-icon>
121
- </web-ui-button>` : ""}
122
- <slot name="suffix" class=${d({ empty: !this._hasSuffix })} @slotchange=${this._onSlotChange}></slot>
122
+ ${e ? s`<web-ui-button
123
+ icon
124
+ variant="ghost"
125
+ size="24"
126
+ aria-label="清除"
127
+ @pointerdown=${this.preventMouseDownBlur}
128
+ @click=${this.handleClear}
129
+ >
130
+ <web-ui-icon .icon=${t}></web-ui-icon>
131
+ </web-ui-button>` : ""}
132
+ <slot name="suffix" class=${p({ empty: !this._hasSuffix })} @slotchange=${this._onSlotChange}></slot>
123
133
  </div>
124
134
  `;
125
135
  }
126
136
  };
127
- e([c({
137
+ e([u({
128
138
  type: String,
129
139
  reflect: !0
130
- })], f.prototype, "type", void 0), e([c({
140
+ })], m.prototype, "type", void 0), e([u({
131
141
  type: String,
132
142
  reflect: !0
133
- })], f.prototype, "placeholder", void 0), e([c({
143
+ })], m.prototype, "placeholder", void 0), e([u({
134
144
  type: String,
135
145
  reflect: !0
136
- })], f.prototype, "name", void 0), e([c({
146
+ })], m.prototype, "name", void 0), e([u({
137
147
  type: Boolean,
138
148
  reflect: !0
139
- })], f.prototype, "disabled", void 0), e([c({
149
+ })], m.prototype, "disabled", void 0), e([u({
140
150
  type: Boolean,
141
151
  reflect: !0
142
- })], f.prototype, "readonly", void 0), e([c({
152
+ })], m.prototype, "readonly", void 0), e([u({
143
153
  type: Boolean,
144
154
  reflect: !0
145
- })], f.prototype, "required", void 0), e([c({
155
+ })], m.prototype, "required", void 0), e([u({
146
156
  type: Boolean,
147
157
  reflect: !0
148
- })], f.prototype, "clearable", void 0), e([c({
158
+ })], m.prototype, "clearable", void 0), e([u({
149
159
  type: Boolean,
150
160
  reflect: !0
151
- })], f.prototype, "full", void 0), e([c({
161
+ })], m.prototype, "full", void 0), e([u({
152
162
  type: Boolean,
153
163
  reflect: !0
154
- })], f.prototype, "borderless", void 0), e([c({
164
+ })], m.prototype, "borderless", void 0), e([u({
155
165
  type: String,
156
166
  attribute: "aria-label"
157
- })], f.prototype, "ariaLabel", void 0), e([l()], f.prototype, "_value", void 0), e([l()], f.prototype, "_focused", void 0), e([l()], f.prototype, "_formDisabled", void 0), e([l()], f.prototype, "_hasPrefix", void 0), e([l()], f.prototype, "_hasSuffix", void 0), e([c({
167
+ })], m.prototype, "ariaLabel", void 0), e([d()], m.prototype, "_value", void 0), e([d()], m.prototype, "_focused", void 0), e([d()], m.prototype, "_hasPrefix", void 0), e([d()], m.prototype, "_hasSuffix", void 0), e([u({
158
168
  type: String,
159
169
  reflect: !0
160
- })], f.prototype, "value", null), f = e([s("web-ui-input")], f);
170
+ })], m.prototype, "value", null), m = e([l("web-ui-input")], m);
161
171
  //#endregion
162
- export { f as WebUiInput };
172
+ export { m as WebUiInput };
163
173
 
164
174
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/components/input/index.ts"],"sourcesContent":["import { html, LitElement, unsafeCSS } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { ifDefined } from 'lit/directives/if-defined.js'\n\nimport '@/components/icon'\nimport '@/components/button'\nimport glass from '@/assets/glass.css?inline'\nimport { jamCloseCircleF } from '@/icons'\n\nimport style from './style.css?inline'\n\n@customElement('web-ui-input')\nexport class WebUiInput extends LitElement {\n static formAssociated = true\n static override styles = [unsafeCSS(glass), unsafeCSS(style)]\n\n @property({ type: String, reflect: true }) type = 'text'\n @property({ type: String, reflect: true }) placeholder = ''\n @property({ type: String, reflect: true }) name = ''\n @property({ type: Boolean, reflect: true }) disabled = false\n @property({ type: Boolean, reflect: true }) readonly = false\n @property({ type: Boolean, reflect: true }) required = false\n @property({ type: Boolean, reflect: true }) clearable = false\n @property({ type: Boolean, reflect: true }) full = false\n @property({ type: Boolean, reflect: true }) borderless = false\n @property({ type: String, attribute: 'aria-label' }) override ariaLabel: string | null = null\n\n @state() private _value = ''\n @state() private _focused = false\n @state() private _formDisabled = false\n @state() private _hasPrefix = false\n @state() private _hasSuffix = false\n\n private _internals?: ElementInternals\n\n @property({ type: String, reflect: true })\n get value(): string {\n return this._value\n }\n\n set value(v: string) {\n const old = this._value\n this._value = v\n this._internals?.setFormValue?.(v)\n this.requestUpdate('value', old)\n }\n\n private get _isDisabled(): boolean {\n return this.disabled || this._formDisabled\n }\n\n override connectedCallback() {\n super.connectedCallback()\n if (!this._internals) {\n this._internals = this.attachInternals()\n }\n this._internals.setFormValue?.(this._value)\n }\n\n override updated(changed: Map<string, unknown>) {\n if (changed.has('_value')) {\n const input = this.shadowRoot?.querySelector('input')\n if (input && input.value !== this._value) {\n input.value = this._value\n }\n }\n this._syncValidity()\n this.toggleAttribute('focused', this._focused)\n }\n\n formResetCallback() {\n this.value = this.getAttribute('value') || ''\n }\n\n formDisabledCallback(disabled: boolean) {\n this._formDisabled = disabled\n }\n\n formStateRestoreCallback(state: string | File | FormData | null) {\n if (typeof state === 'string') this.value = state\n }\n\n private _syncValidity() {\n const input = this.shadowRoot?.querySelector('input')\n if (!this._internals || !input || typeof this._internals.setValidity !== 'function') return\n if (this._isDisabled || input.validity.valid) {\n this._internals.setValidity({})\n return\n }\n\n const flags: ValidityStateFlags = {}\n if (input.validity.valueMissing) flags.valueMissing = true\n if (input.validity.typeMismatch) flags.typeMismatch = true\n if (input.validity.patternMismatch) flags.patternMismatch = true\n if (input.validity.tooLong) flags.tooLong = true\n if (input.validity.tooShort) flags.tooShort = true\n this._internals.setValidity(flags, input.validationMessage, input)\n }\n\n private _onSlotChange(e: Event) {\n if (!(e.target instanceof HTMLSlotElement)) return\n const slot = e.target\n const hasContent = slot.assignedElements().length > 0\n if (slot.name === 'prefix') this._hasPrefix = hasContent\n if (slot.name === 'suffix') this._hasSuffix = hasContent\n }\n\n private handleInput(e: Event) {\n if (this._isDisabled || this.readonly) return\n if (!(e.target instanceof HTMLInputElement)) return\n this._value = e.target.value\n this._internals?.setFormValue?.(this._value)\n this._syncValidity()\n }\n\n // 原生 change 不 composed,被 shadow root 挡住;这里补发 composed 事件,\n // 兑现 $events/README 声明的公共 change 契约。\n private handleNativeChange(e: Event) {\n if (this.readonly) return\n if (!(e.target instanceof HTMLInputElement)) return\n this._value = e.target.value\n this._internals?.setFormValue?.(this._value)\n this._syncValidity()\n this.dispatchEvent(new Event('change', { bubbles: true, composed: true }))\n }\n\n private handleFocus() {\n if (!this._isDisabled) this._focused = true\n }\n\n private handleBlur() {\n this._focused = false\n }\n\n private handleClear() {\n if (this._isDisabled || this.readonly) return\n this._value = ''\n this._internals?.setFormValue?.('')\n this._syncValidity()\n this.dispatchEvent(new Event('input', { bubbles: true, composed: true }))\n }\n\n private preventMouseDownBlur(e: Event) {\n e.preventDefault()\n }\n\n private focusInput() {\n if (this._isDisabled) return\n this.shadowRoot?.querySelector('input')?.focus()\n }\n\n override render() {\n // readonly 下不可清除:清空按钮会修改值,与只读语义冲突\n const showClear = this.clearable && this._value && !this.readonly\n\n return html`\n <div class=\"wui-glass wui-input-inner\" @click=${this.focusInput}>\n <slot name=\"prefix\" class=${classMap({ empty: !this._hasPrefix })} @slotchange=${this._onSlotChange}></slot>\n <input\n type=${this.type}\n placeholder=${this.placeholder}\n name=${this.name}\n aria-label=${ifDefined(this.ariaLabel)}\n ?disabled=${this._isDisabled}\n ?readonly=${this.readonly}\n ?required=${this.required}\n .value=${this._value}\n @input=${this.handleInput}\n @change=${this.handleNativeChange}\n @focus=${this.handleFocus}\n @blur=${this.handleBlur}\n />\n ${showClear\n ? html`<web-ui-button\n icon\n variant=\"ghost\"\n size=\"24\"\n aria-label=\"清除\"\n @pointerdown=${this.preventMouseDownBlur}\n @click=${this.handleClear}\n >\n <web-ui-icon .icon=${jamCloseCircleF}></web-ui-icon>\n </web-ui-button>`\n : ''}\n <slot name=\"suffix\" class=${classMap({ empty: !this._hasSuffix })} @slotchange=${this._onSlotChange}></slot>\n </div>\n `\n }\n\n declare readonly $events: {\n input: Event\n change: Event\n focus: FocusEvent\n blur: FocusEvent\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'web-ui-input': WebUiInput\n }\n}\n"],"mappings":";;;;;;;;;;;AAaO,IAAM,IAAN,cAAyB,EAAW;;EAmBX,aAfoB,KAAA,OAAA,QACO,KAAA,cAAA,IACP,KAAA,OAAA,IACK,KAAA,WAAA,IACA,KAAA,WAAA,IACA,KAAA,WAAA,IACC,KAAA,YAAA,IACL,KAAA,OAAA,IACM,KAAA,aAAA,IACgC,KAAA,YAAA,MAE/D,KAAA,SAAA,IACE,KAAA,WAAA,IACK,KAAA,gBAAA,IACH,KAAA,aAAA,IACA,KAAA,aAAA;;;EAlBN,KAAA,iBAAA;;;EACC,KAAA,SAAA,CAAC,EAAU,CAAK,GAAG,EAAU,CAAK,CAAC;;CAqB5D,IACI,QAAgB;EAClB,OAAO,KAAK;CACd;CAEA,IAAI,MAAM,GAAW;EACnB,IAAM,IAAM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CAAC,CAAA,GAAA,EAAA,WAAA,cAAA,KAAA,CAAA,GACzC,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAa,CAAC,CAAA,GAAA,EAAA,WAAA,aAAA,KAAA,CAAA,GAElD,EAAA,CAAA,EAAM,CAAA,GAAA,EAAA,WAAA,UAAA,KAAA,CAAA,GACN,EAAA,CAAA,EAAM,CAAA,GAAA,EAAA,WAAA,YAAA,KAAA,CAAA,GACN,EAAA,CAAA,EAAM,CAAA,GAAA,EAAA,WAAA,iBAAA,KAAA,CAAA,GACN,EAAA,CAAA,EAAM,CAAA,GAAA,EAAA,WAAA,cAAA,KAAA,CAAA,GACN,EAAA,CAAA,EAAM,CAAA,GAAA,EAAA,WAAA,cAAA,KAAA,CAAA,GAIN,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,SAAA,IAAA,GAxB1C,IAAA,EAAA,CAAA,EAAc,cAAc,CAAA,GAAA,CAAA"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/components/input/index.ts"],"sourcesContent":["import { html, LitElement, unsafeCSS } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { ifDefined } from 'lit/directives/if-defined.js'\n\nimport '@/components/icon'\nimport '@/components/button'\nimport glass from '@/assets/glass.css?inline'\nimport { jamCloseCircleF } from '@/icons'\nimport { defineFormAssociation, FormAssociationController } from '@/shared/form-association'\n\nimport style from './style.css?inline'\n\n@customElement('web-ui-input')\nexport class WebUiInput extends LitElement {\n static formAssociated = true\n static override styles = [unsafeCSS(glass), unsafeCSS(style)]\n\n @property({ type: String, reflect: true }) type = 'text'\n @property({ type: String, reflect: true }) placeholder = ''\n @property({ type: String, reflect: true }) name = ''\n @property({ type: Boolean, reflect: true }) disabled = false\n @property({ type: Boolean, reflect: true }) readonly = false\n @property({ type: Boolean, reflect: true }) required = false\n @property({ type: Boolean, reflect: true }) clearable = false\n @property({ type: Boolean, reflect: true }) full = false\n @property({ type: Boolean, reflect: true }) borderless = false\n @property({ type: String, attribute: 'aria-label' }) override ariaLabel: string | null = null\n\n @state() private _value = ''\n @state() private _focused = false\n @state() private _hasPrefix = false\n @state() private _hasSuffix = false\n\n @property({ type: String, reflect: true })\n get value(): string {\n return this._value\n }\n\n set value(v: string) {\n const old = this._value\n this._value = v\n this._formAssociation.sync()\n this.requestUpdate('value', old)\n }\n\n private get _isDisabled(): boolean {\n return this.disabled || this._formAssociation.isFormDisabled()\n }\n\n private readonly _formAssociation = defineFormAssociation<string>({\n host: this,\n getState: () => this._value,\n setState: value => {\n this.value = value\n },\n getFormValue: () => this._value,\n getFormState: () => this._value,\n restoreState: state => {\n if (typeof state === 'string') this.value = state\n },\n syncValidity: () => this._syncValidity()\n }).make()\n\n private readonly _formAssociationController = new FormAssociationController(this, this._formAssociation)\n\n override updated(changed: Map<string, unknown>) {\n if (changed.has('_value')) {\n const input = this.shadowRoot?.querySelector('input')\n if (input && input.value !== this._value) {\n input.value = this._value\n }\n }\n this._syncValidity()\n this.toggleAttribute('focused', this._focused)\n }\n\n formResetCallback() {\n this._formAssociation.reset()\n }\n\n formDisabledCallback(disabled: boolean) {\n this._formAssociation.setDisabled(disabled)\n }\n\n formStateRestoreCallback(state: string | File | FormData | null) {\n this._formAssociation.restore(state)\n }\n\n private _syncValidity() {\n const input = this.shadowRoot?.querySelector('input')\n const internals = this._formAssociation.getInternals()\n if (!internals || !input || typeof internals.setValidity !== 'function') return\n if (this._isDisabled || input.validity.valid) {\n internals.setValidity({})\n return\n }\n\n const flags: ValidityStateFlags = {}\n if (input.validity.valueMissing) flags.valueMissing = true\n if (input.validity.typeMismatch) flags.typeMismatch = true\n if (input.validity.patternMismatch) flags.patternMismatch = true\n if (input.validity.tooLong) flags.tooLong = true\n if (input.validity.tooShort) flags.tooShort = true\n internals.setValidity(flags, input.validationMessage, input)\n }\n\n private _onSlotChange(e: Event) {\n if (!(e.target instanceof HTMLSlotElement)) return\n const slot = e.target\n const hasContent = slot.assignedElements().length > 0\n if (slot.name === 'prefix') this._hasPrefix = hasContent\n if (slot.name === 'suffix') this._hasSuffix = hasContent\n }\n\n private handleInput(e: Event) {\n if (this._isDisabled || this.readonly) return\n if (!(e.target instanceof HTMLInputElement)) return\n this._value = e.target.value\n this._formAssociation.sync()\n }\n\n // 原生 change 不 composed,被 shadow root 挡住;这里补发 composed 事件,\n // 兑现 $events/README 声明的公共 change 契约。\n private handleNativeChange(e: Event) {\n if (this.readonly) return\n if (!(e.target instanceof HTMLInputElement)) return\n this._value = e.target.value\n this._formAssociation.sync()\n this.dispatchEvent(new Event('change', { bubbles: true, composed: true }))\n }\n\n private handleFocus() {\n if (!this._isDisabled) this._focused = true\n }\n\n private handleBlur() {\n this._focused = false\n }\n\n private handleClear() {\n if (this._isDisabled || this.readonly) return\n this._value = ''\n this._formAssociation.sync()\n this.dispatchEvent(new Event('input', { bubbles: true, composed: true }))\n }\n\n private preventMouseDownBlur(e: Event) {\n e.preventDefault()\n }\n\n private focusInput() {\n if (this._isDisabled) return\n this.shadowRoot?.querySelector('input')?.focus()\n }\n\n override render() {\n // readonly 下不可清除:清空按钮会修改值,与只读语义冲突\n const showClear = this.clearable && this._value && !this.readonly\n\n return html`\n <div class=\"wui-glass wui-input-inner\" @click=${this.focusInput}>\n <slot name=\"prefix\" class=${classMap({ empty: !this._hasPrefix })} @slotchange=${this._onSlotChange}></slot>\n <input\n type=${this.type}\n placeholder=${this.placeholder}\n name=${this.name}\n aria-label=${ifDefined(this.ariaLabel)}\n ?disabled=${this._isDisabled}\n ?readonly=${this.readonly}\n ?required=${this.required}\n .value=${this._value}\n @input=${this.handleInput}\n @change=${this.handleNativeChange}\n @focus=${this.handleFocus}\n @blur=${this.handleBlur}\n />\n ${\n showClear\n ? html`<web-ui-button\n icon\n variant=\"ghost\"\n size=\"24\"\n aria-label=\"清除\"\n @pointerdown=${this.preventMouseDownBlur}\n @click=${this.handleClear}\n >\n <web-ui-icon .icon=${jamCloseCircleF}></web-ui-icon>\n </web-ui-button>`\n : ''\n }\n <slot name=\"suffix\" class=${classMap({ empty: !this._hasSuffix })} @slotchange=${this._onSlotChange}></slot>\n </div>\n `\n }\n\n declare readonly $events: {\n input: Event\n change: Event\n focus: FocusEvent\n blur: FocusEvent\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'web-ui-input': WebUiInput\n }\n}\n"],"mappings":";;;;;;;;;;;;AAcO,IAAM,IAAN,cAAyB,EAAW;;EAkDK,aA9CI,KAAA,OAAA,QACO,KAAA,cAAA,IACP,KAAA,OAAA,IACK,KAAA,WAAA,IACA,KAAA,WAAA,IACA,KAAA,WAAA,IACC,KAAA,YAAA,IACL,KAAA,OAAA,IACM,KAAA,aAAA,IACgC,KAAA,YAAA,MAE/D,KAAA,SAAA,IACE,KAAA,WAAA,IACE,KAAA,aAAA,IACA,KAAA,aAAA,IAkBM,KAAA,mBAAA,EAA8B;GAChE,MAAM;GACN,gBAAgB,KAAK;GACrB,WAAU,MAAS;IACjB,KAAK,QAAQ;GACf;GACA,oBAAoB,KAAK;GACzB,oBAAoB,KAAK;GACzB,eAAc,MAAS;IACrB,AAAI,OAAO,KAAU,aAAU,KAAK,QAAQ;GAC9C;GACA,oBAAoB,KAAK,cAAc;EACzC,CAAC,CAAC,CAAC,KAAK,GAEsC,KAAA,6BAAA,IAAI,EAA0B,MAAM,KAAK,gBAAgB;;;EAjD/E,KAAA,iBAAA;;;EACC,KAAA,SAAA,CAAC,EAAU,CAAK,GAAG,EAAU,CAAK,CAAC;;CAkB5D,IACI,QAAgB;EAClB,OAAO,KAAK;CACd;CAEA,IAAI,MAAM,GAAW;EACnB,IAAM,IAAM,KAAK;EAGjB,AAFA,KAAK,SAAS,GACd,KAAK,iBAAiB,KAAK,GAC3B,KAAK,cAAc,SAAS,CAAG;CACjC;CAEA,IAAY,cAAuB;EACjC,OAAO,KAAK,YAAY,KAAK,iBAAiB,eAAe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,GACN,EAAA,CAAA,EAAM,CAAA,GAAA,EAAA,WAAA,cAAA,KAAA,CAAA,GAEN,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,SAAA,IAAA,GArB1C,IAAA,EAAA,CAAA,EAAc,cAAc,CAAA,GAAA,CAAA"}
@@ -1,5 +1,5 @@
1
1
  //#region src/components/input/style.css?inline
2
- var e = "*,:before,:after{box-sizing:border-box}:host{display:inline-block}:host([disabled]){cursor:not-allowed;opacity:.4}.wui-input-inner{box-sizing:border-box;width:var(--wui-input-width,200px);min-width:var(--wui-button-size,40px);height:var(--wui-button-size,40px);transition:border-color var(--wui-duration-focus,.2s), box-shadow var(--wui-duration-focus,.2s);border-radius:2147483647px;align-items:center;gap:8px;padding:0 12px;display:flex;position:relative}:host([full]){display:block}:host([full]) .wui-input-inner{width:100%}:host([borderless]) .wui-input-inner{-webkit-backdrop-filter:none;backdrop-filter:none;box-shadow:none;background:0 0;border:none;padding:0}:host([focused]) .wui-input-inner{--wui-glass-shadow:var(--wui-shadow-glass,0 2px 16px #0000000f), 0 0 0 3px var(--wui-focus-ring,#08f6);border-color:var(--wui-color-border-strong,#006ee680)}:host([borderless][focused]) .wui-input-inner{box-shadow:none;border-color:#0000}input{min-width:0;height:100%;font:inherit;font-size:var(--wui-font-size,14px);color:var(--wui-color-text,#1b1b1b);background:0 0;border:none;outline:none;flex:1;margin:0;padding:0}input::placeholder{color:var(--wui-color-text-muted,#6a6a6a)}input:disabled{cursor:not-allowed;opacity:.4}slot{font-size:var(--wui-font-size,14px);color:var(--wui-color-text-muted,#6a6a6a);flex-shrink:0;align-items:center;display:flex}slot.empty{display:none}.wui-input-inner web-ui-button[variant=ghost]{--wui-button-color:var(--wui-color-text-muted,#6a6a6a);margin-left:-8px}";
2
+ var e = "*,:before,:after{box-sizing:border-box}:host{--wui-input-clear-color:var(--wui-color-text-tertiary,#1b1b1b59);display:inline-block}:host([disabled]){cursor:not-allowed;opacity:.4}.wui-input-inner{box-sizing:border-box;width:var(--wui-input-width,200px);min-width:var(--wui-control-size,40px);height:var(--wui-control-size,40px);transition:border-color var(--wui-duration-focus,.2s), box-shadow var(--wui-duration-focus,.2s);border-radius:2147483647px;align-items:center;gap:8px;padding:0 12px;display:flex;position:relative}:host([full]){display:block}:host([full]) .wui-input-inner{width:100%}:host([borderless]) .wui-input-inner{-webkit-backdrop-filter:none;backdrop-filter:none;box-shadow:none;background:0 0;border:none;padding:0}:host([focused]) .wui-input-inner{--wui-internal-glass-focus-ring:inset 0 0 0 1px var(--wui-color-accent,#08f), 0 0 0 var(--wui-focus-ring-width,3px) var(--wui-color-focus-ring,#08f6)}:host([borderless][focused]) .wui-input-inner{outline:var(--wui-focus-ring-width,3px) solid var(--wui-color-focus-ring,#08f6);outline-offset:2px;border-color:#0000}input{min-width:0;height:100%;font:inherit;font-size:var(--wui-font-size,14px);color:var(--wui-color-text,#1b1b1b);background:0 0;border:none;outline:none;flex:1;margin:0;padding:0}input::placeholder{color:var(--wui-color-text-secondary,#6a6a6a)}input:disabled{cursor:not-allowed;opacity:.4}slot{font-size:var(--wui-font-size,14px);color:var(--wui-color-text-secondary,#6a6a6a);flex-shrink:0;align-items:center;display:flex}slot.empty{display:none}.wui-input-inner web-ui-button[variant=ghost]{--wui-button-color:var(--wui-input-clear-color);margin-left:-8px}";
3
3
  //#endregion
4
4
  export { e as default };
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"style.js","names":[],"sources":["../../../src/components/input/style.css?inline"],"sourcesContent":["*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\n\n:host {\n display: inline-block;\n}\n\n:host([disabled]) {\n cursor: not-allowed;\n opacity: 0.4;\n}\n\n.wui-input-inner {\n position: relative;\n\n display: flex;\n gap: 8px;\n align-items: center;\n\n box-sizing: border-box;\n width: var(--wui-input-width, 200px);\n min-width: var(--wui-button-size, 40px);\n height: var(--wui-button-size, 40px);\n padding: 0 12px;\n border-radius: calc(infinity * 1px);\n\n transition:\n border-color var(--wui-duration-focus, 200ms),\n box-shadow var(--wui-duration-focus, 200ms);\n}\n\n:host([full]) {\n display: block;\n}\n\n:host([full]) .wui-input-inner {\n width: 100%;\n}\n\n/* ===== Borderless ===== */\n\n:host([borderless]) .wui-input-inner {\n padding: 0;\n border: none;\n\n background: transparent;\n backdrop-filter: none;\n box-shadow: none;\n}\n\n:host([focused]) .wui-input-inner {\n --wui-glass-shadow:\n var(--wui-shadow-glass, 0 2px 16px rgb(0 0 0 / 0.06)), 0 0 0 3px var(--wui-focus-ring, rgb(0 136 255 / 0.4));\n border-color: var(--wui-color-border-strong, rgb(0 110 230 / 0.5));\n}\n\n:host([borderless][focused]) .wui-input-inner {\n border-color: transparent;\n box-shadow: none;\n}\n\n/* ===== Input ===== */\n\ninput {\n flex: 1;\n\n min-width: 0;\n height: 100%;\n margin: 0;\n padding: 0;\n border: none;\n\n /* 表单控件不继承字体;显式继承以对齐宿主排版,避免 UA 默认字体差异 */\n font: inherit;\n font-size: var(--wui-font-size, 14px);\n color: var(--wui-color-text, #1b1b1b);\n\n background: transparent;\n outline: none;\n\n &::placeholder {\n color: var(--wui-color-text-muted, #6a6a6a);\n }\n\n &:disabled {\n cursor: not-allowed;\n opacity: 0.4;\n }\n}\n\n/* ===== Prefix / Suffix ===== */\n\nslot {\n display: flex;\n flex-shrink: 0;\n align-items: center;\n\n font-size: var(--wui-font-size, 14px);\n color: var(--wui-color-text-muted, #6a6a6a);\n}\n\n/* slot 无 slotted 内容时折叠 */\nslot.empty {\n display: none;\n}\n\n/* ===== Clear button ===== */\n\n/* 复用 web-ui-button icon ghost:仅覆盖颜色为 muted,保持原清除图标观感;\n 负 margin-left 抵消容器 8px flex gap,让清除按钮紧贴输入文本 */\n.wui-input-inner web-ui-button[variant='ghost'] {\n --wui-button-color: var(--wui-color-text-muted, #6a6a6a);\n margin-left: -8px;\n}\n\n/* ===== Disabled ===== */\n"],"mappings":""}
1
+ {"version":3,"file":"style.js","names":[],"sources":["../../../src/components/input/style.css?inline"],"sourcesContent":["*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\n\n:host {\n --wui-input-clear-color: var(--wui-color-text-tertiary, rgb(27 27 27 / 0.35));\n display: inline-block;\n}\n\n:host([disabled]) {\n cursor: not-allowed;\n opacity: 0.4;\n}\n\n.wui-input-inner {\n position: relative;\n\n display: flex;\n gap: 8px;\n align-items: center;\n\n box-sizing: border-box;\n width: var(--wui-input-width, 200px);\n min-width: var(--wui-control-size, 40px);\n height: var(--wui-control-size, 40px);\n padding: 0 12px;\n border-radius: calc(infinity * 1px);\n\n transition:\n border-color var(--wui-duration-focus, 200ms),\n box-shadow var(--wui-duration-focus, 200ms);\n}\n\n:host([full]) {\n display: block;\n}\n\n:host([full]) .wui-input-inner {\n width: 100%;\n}\n\n/* ===== Borderless ===== */\n\n:host([borderless]) .wui-input-inner {\n padding: 0;\n border: none;\n\n background: transparent;\n backdrop-filter: none;\n box-shadow: none;\n}\n\n:host([focused]) .wui-input-inner {\n --wui-internal-glass-focus-ring:\n inset 0 0 0 1px var(--wui-color-accent, #08f),\n 0 0 0 var(--wui-focus-ring-width, 3px) var(--wui-color-focus-ring, rgb(0 136 255 / 0.4));\n}\n\n:host([borderless][focused]) .wui-input-inner {\n border-color: transparent;\n\n /* borderless 移除了背景和玻璃阴影,但仍必须保留可感知的键盘/输入焦点边界 */\n outline: var(--wui-focus-ring-width, 3px) solid var(--wui-color-focus-ring, rgb(0 136 255 / 0.4));\n outline-offset: 2px;\n}\n\n/* ===== Input ===== */\n\ninput {\n flex: 1;\n\n min-width: 0;\n height: 100%;\n margin: 0;\n padding: 0;\n border: none;\n\n /* 表单控件不继承字体;显式继承以对齐宿主排版,避免 UA 默认字体差异 */\n font: inherit;\n font-size: var(--wui-font-size, 14px);\n color: var(--wui-color-text, #1b1b1b);\n\n background: transparent;\n outline: none;\n\n &::placeholder {\n color: var(--wui-color-text-secondary, #6a6a6a);\n }\n\n &:disabled {\n cursor: not-allowed;\n opacity: 0.4;\n }\n}\n\n/* ===== Prefix / Suffix ===== */\n\nslot {\n display: flex;\n flex-shrink: 0;\n align-items: center;\n\n font-size: var(--wui-font-size, 14px);\n color: var(--wui-color-text-secondary, #6a6a6a);\n}\n\n/* slot 无 slotted 内容时折叠 */\nslot.empty {\n display: none;\n}\n\n/* ===== Clear button ===== */\n\n/* 复用 web-ui-button icon ghost:仅覆盖颜色为 faint,保持弱意图清除图标观感;\n 负 margin-left 抵消容器 8px flex gap,让清除按钮紧贴输入文本 */\n.wui-input-inner web-ui-button[variant='ghost'] {\n --wui-button-color: var(--wui-input-clear-color);\n margin-left: -8px;\n}\n\n/* ===== Disabled ===== */\n"],"mappings":""}
@@ -14,9 +14,7 @@ export declare class WebUiInputNumber extends LitElement {
14
14
  private _max;
15
15
  private _step;
16
16
  private _focused;
17
- private _formDisabled;
18
17
  private _precision;
19
- private _internals?;
20
18
  get value(): number;
21
19
  set value(v: number);
22
20
  private get _isDisabled();
@@ -29,7 +27,8 @@ export declare class WebUiInputNumber extends LitElement {
29
27
  private get _effectiveStep();
30
28
  private get atMin();
31
29
  private get atMax();
32
- connectedCallback(): void;
30
+ private readonly _formAssociation;
31
+ private readonly _formAssociationController;
33
32
  formResetCallback(): void;
34
33
  formDisabledCallback(disabled: boolean): void;
35
34
  formStateRestoreCallback(state: string | File | FormData | null): void;
@@ -1,22 +1,37 @@
1
- import e from "../../_virtual/_@oxc-project_runtime@0.140.0/helpers/esm/decorate.js";
1
+ import e from "../../_virtual/_@oxc-project_runtime@0.146.0/helpers/esm/decorate.js";
2
2
  import "../icon/index.js";
3
3
  import t from "../../icons/generated/lucide-plus.js";
4
4
  import n from "../../icons/generated/lucide-minus.js";
5
5
  import r from "../../assets/glass.js";
6
- import { normalizeNumber as i } from "../../shared/normalize/index.js";
7
- import a from "./style.js";
8
- import { LitElement as o, html as s, unsafeCSS as c } from "lit";
9
- import { customElement as l, property as u, state as d } from "lit/decorators.js";
6
+ import { FormAssociationController as i, defineFormAssociation as a } from "../../shared/form-association/index.js";
7
+ import { normalizeNumber as o } from "../../shared/normalize/index.js";
8
+ import s from "./style.js";
9
+ import { LitElement as c, html as l, unsafeCSS as u } from "lit";
10
+ import { customElement as d, property as f, state as p } from "lit/decorators.js";
10
11
  //#region src/components/input-number/index.ts
11
- var f = class extends o {
12
+ var m = class extends c {
12
13
  constructor(...e) {
13
- super(...e), this.placeholder = "", this.name = "", this.disabled = !1, this.readonly = !1, this.required = !1, this._value = 0, this._min = 0, this._max = Infinity, this._step = 1, this._focused = !1, this._formDisabled = !1, this._precision = 0;
14
+ super(...e), this.placeholder = "", this.name = "", this.disabled = !1, this.readonly = !1, this.required = !1, this._value = 0, this._min = 0, this._max = Infinity, this._step = 1, this._focused = !1, this._precision = 0, this._formAssociation = a({
15
+ host: this,
16
+ getState: () => this._value,
17
+ setState: (e) => {
18
+ this.value = e;
19
+ },
20
+ getFormValue: () => String(this._value),
21
+ getFormState: () => String(this._value),
22
+ restoreState: (e) => {
23
+ if (typeof e != "string") return;
24
+ let t = Number(e);
25
+ Number.isFinite(t) && (this.value = t);
26
+ },
27
+ syncValidity: () => this._syncValidity()
28
+ }).make(), this._formAssociationController = new i(this, this._formAssociation);
14
29
  }
15
30
  static {
16
31
  this.formAssociated = !0;
17
32
  }
18
33
  static {
19
- this.styles = [c(r), c(a)];
34
+ this.styles = [u(r), u(s)];
20
35
  }
21
36
  get precision() {
22
37
  return this._precision;
@@ -25,35 +40,35 @@ var f = class extends o {
25
40
  let t = this._precision;
26
41
  this._precision = e;
27
42
  let n = this.clamp(this.round(this._value));
28
- n !== this._value && (this._value = n, this._internals?.setFormValue?.(String(n))), this.requestUpdate("precision", t);
43
+ n !== this._value && (this._value = n, this._formAssociation.sync()), this.requestUpdate("precision", t);
29
44
  }
30
45
  get value() {
31
46
  return this._value;
32
47
  }
33
48
  set value(e) {
34
49
  let t = this.clamp(this.round(e)), n = this._value;
35
- this._value = t, this._internals?.setFormValue?.(String(t)), this.requestUpdate("value", n);
50
+ this._value = t, this._formAssociation.sync(), this.requestUpdate("value", n);
36
51
  }
37
52
  get _isDisabled() {
38
- return this.disabled || this._formDisabled;
53
+ return this.disabled || this._formAssociation.isFormDisabled();
39
54
  }
40
55
  get min() {
41
56
  return this._min;
42
57
  }
43
58
  set min(e) {
44
- this._min = i(e, -Infinity, Infinity, 0);
59
+ this._min = o(e, -Infinity, Infinity, 0);
45
60
  }
46
61
  get max() {
47
62
  return this._max;
48
63
  }
49
64
  set max(e) {
50
- this._max = i(e, -Infinity, Infinity, Infinity);
65
+ this._max = o(e, -Infinity, Infinity, Infinity);
51
66
  }
52
67
  get step() {
53
68
  return this._step;
54
69
  }
55
70
  set step(e) {
56
- this._step = i(e, 0, Infinity, 1);
71
+ this._step = o(e, 0, Infinity, 1);
57
72
  }
58
73
  get _effectiveStep() {
59
74
  return this._step;
@@ -64,31 +79,27 @@ var f = class extends o {
64
79
  get atMax() {
65
80
  return this._value >= this._max;
66
81
  }
67
- connectedCallback() {
68
- super.connectedCallback(), this._internals ||= this.attachInternals(), this._internals.setFormValue?.(String(this._value));
69
- }
70
82
  formResetCallback() {
71
- let e = this.getAttribute("value");
72
- this.value = e === null ? 0 : Number(e);
83
+ this._formAssociation.reset();
73
84
  }
74
85
  formDisabledCallback(e) {
75
- this._formDisabled = e;
86
+ this._formAssociation.setDisabled(e);
76
87
  }
77
88
  formStateRestoreCallback(e) {
78
- typeof e == "string" && (this.value = Number(e));
89
+ this._formAssociation.restore(e);
79
90
  }
80
91
  updated() {
81
92
  this._syncValidity(), this.toggleAttribute("focused", this._focused);
82
93
  }
83
94
  _syncValidity() {
84
- let e = this.shadowRoot?.querySelector("input");
85
- if (!this._internals || !e || typeof this._internals.setValidity != "function") return;
95
+ let e = this.shadowRoot?.querySelector("input"), t = this._formAssociation.getInternals();
96
+ if (!t || !e || typeof t.setValidity != "function") return;
86
97
  if (this._isDisabled || e.validity.valid) {
87
- this._internals.setValidity({});
98
+ t.setValidity({});
88
99
  return;
89
100
  }
90
- let t = {};
91
- e.validity.valueMissing && (t.valueMissing = !0), e.validity.rangeUnderflow && (t.rangeUnderflow = !0), e.validity.rangeOverflow && (t.rangeOverflow = !0), e.validity.stepMismatch && (t.stepMismatch = !0), this._internals.setValidity(t, e.validationMessage, e);
101
+ let n = {};
102
+ e.validity.valueMissing && (n.valueMissing = !0), e.validity.rangeUnderflow && (n.rangeUnderflow = !0), e.validity.rangeOverflow && (n.rangeOverflow = !0), e.validity.stepMismatch && (n.stepMismatch = !0), t.setValidity(n, e.validationMessage, e);
92
103
  }
93
104
  clamp(e) {
94
105
  return Math.min(this._max, Math.max(this._min, e));
@@ -109,12 +120,12 @@ var f = class extends o {
109
120
  handleInput(e) {
110
121
  if (this.readonly || !(e.target instanceof HTMLInputElement)) return;
111
122
  let t = e.target.value;
112
- t !== "" && t !== "-" && (this._value = this.clamp(this.round(Number(t))), this._internals?.setFormValue?.(String(this._value)), this._syncValidity());
123
+ t !== "" && t !== "-" && (this._value = this.clamp(this.round(Number(t))), this._formAssociation.sync(), this._syncValidity());
113
124
  }
114
125
  handleNativeChange(e) {
115
126
  if (this.readonly || !(e.target instanceof HTMLInputElement)) return;
116
127
  let t = e.target.value;
117
- t !== "" && t !== "-" && (this._value = this.clamp(this.round(Number(t))), this._internals?.setFormValue?.(String(this._value)), this._syncValidity(), this.dispatchEvent(new Event("change", {
128
+ t !== "" && t !== "-" && (this._value = this.clamp(this.round(Number(t))), this._formAssociation.sync(), this._syncValidity(), this.dispatchEvent(new Event("change", {
118
129
  bubbles: !0,
119
130
  composed: !0
120
131
  })));
@@ -135,7 +146,7 @@ var f = class extends o {
135
146
  this._focused = !1;
136
147
  }
137
148
  render() {
138
- return s`
149
+ return l`
139
150
  <div class="wui-glass wui-input-inner">
140
151
  <button
141
152
  class="num-btn"
@@ -171,29 +182,38 @@ var f = class extends o {
171
182
  `;
172
183
  }
173
184
  };
174
- e([u({
185
+ e([f({
175
186
  type: String,
176
187
  reflect: !0
177
- })], f.prototype, "placeholder", void 0), e([u({
188
+ })], m.prototype, "placeholder", void 0), e([f({
178
189
  type: String,
179
190
  reflect: !0
180
- })], f.prototype, "name", void 0), e([u({
191
+ })], m.prototype, "name", void 0), e([f({
181
192
  type: Boolean,
182
193
  reflect: !0
183
- })], f.prototype, "disabled", void 0), e([u({
194
+ })], m.prototype, "disabled", void 0), e([f({
184
195
  type: Boolean,
185
196
  reflect: !0
186
- })], f.prototype, "readonly", void 0), e([u({
197
+ })], m.prototype, "readonly", void 0), e([f({
187
198
  type: Boolean,
188
199
  reflect: !0
189
- })], f.prototype, "required", void 0), e([u({
200
+ })], m.prototype, "required", void 0), e([f({
201
+ type: Number,
202
+ reflect: !0
203
+ })], m.prototype, "precision", null), e([p()], m.prototype, "_value", void 0), e([p()], m.prototype, "_min", void 0), e([p()], m.prototype, "_max", void 0), e([p()], m.prototype, "_step", void 0), e([p()], m.prototype, "_focused", void 0), e([f({
204
+ type: Number,
205
+ reflect: !0
206
+ })], m.prototype, "value", null), e([f({
207
+ type: Number,
208
+ reflect: !0
209
+ })], m.prototype, "min", null), e([f({
190
210
  type: Number,
191
211
  reflect: !0
192
- })], f.prototype, "precision", null), e([d()], f.prototype, "_value", void 0), e([d()], f.prototype, "_min", void 0), e([d()], f.prototype, "_max", void 0), e([d()], f.prototype, "_step", void 0), e([d()], f.prototype, "_focused", void 0), e([d()], f.prototype, "_formDisabled", void 0), e([u({
212
+ })], m.prototype, "max", null), e([f({
193
213
  type: Number,
194
214
  reflect: !0
195
- })], f.prototype, "value", null), e([u({ type: Number })], f.prototype, "min", null), e([u({ type: Number })], f.prototype, "max", null), e([u({ type: Number })], f.prototype, "step", null), f = e([l("web-ui-input-number")], f);
215
+ })], m.prototype, "step", null), m = e([d("web-ui-input-number")], m);
196
216
  //#endregion
197
- export { f as WebUiInputNumber };
217
+ export { m as WebUiInputNumber };
198
218
 
199
219
  //# sourceMappingURL=index.js.map