@deepfuture/dui-components 0.0.21 → 1.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 (333) hide show
  1. package/README.md +56 -65
  2. package/_install.js +11 -0
  3. package/accordion/accordion-item.d.ts +3 -20
  4. package/accordion/accordion-item.js +93 -292
  5. package/accordion/accordion.d.ts +3 -18
  6. package/accordion/accordion.js +9 -247
  7. package/accordion/index.d.ts +6 -6
  8. package/accordion/index.js +5 -5
  9. package/alert-dialog/alert-dialog-close.d.ts +3 -14
  10. package/alert-dialog/alert-dialog-close.js +4 -34
  11. package/alert-dialog/alert-dialog-popup.d.ts +3 -32
  12. package/alert-dialog/alert-dialog-popup.js +68 -317
  13. package/alert-dialog/alert-dialog-trigger.d.ts +3 -14
  14. package/alert-dialog/alert-dialog-trigger.js +4 -51
  15. package/alert-dialog/alert-dialog.d.ts +3 -30
  16. package/alert-dialog/alert-dialog.js +8 -158
  17. package/alert-dialog/index.d.ts +11 -11
  18. package/alert-dialog/index.js +9 -9
  19. package/all.d.ts +159 -123
  20. package/all.js +134 -231
  21. package/avatar/avatar.d.ts +3 -39
  22. package/avatar/avatar.js +18 -238
  23. package/avatar/index.d.ts +4 -4
  24. package/avatar/index.js +3 -3
  25. package/badge/badge.d.ts +3 -10
  26. package/badge/badge.js +88 -22
  27. package/badge/index.d.ts +2 -3
  28. package/badge/index.js +2 -3
  29. package/breadcrumb/breadcrumb-ellipsis.d.ts +3 -12
  30. package/breadcrumb/breadcrumb-ellipsis.js +8 -34
  31. package/breadcrumb/breadcrumb-item.d.ts +3 -11
  32. package/breadcrumb/breadcrumb-item.js +7 -26
  33. package/breadcrumb/breadcrumb-link.d.ts +3 -12
  34. package/breadcrumb/breadcrumb-link.js +16 -26
  35. package/breadcrumb/breadcrumb-page.d.ts +3 -11
  36. package/breadcrumb/breadcrumb-page.js +8 -31
  37. package/breadcrumb/breadcrumb-separator.d.ts +3 -12
  38. package/breadcrumb/breadcrumb-separator.js +8 -31
  39. package/breadcrumb/breadcrumb.d.ts +3 -12
  40. package/breadcrumb/breadcrumb.js +10 -33
  41. package/breadcrumb/index.d.ts +12 -13
  42. package/breadcrumb/index.js +12 -13
  43. package/button/button.d.ts +3 -32
  44. package/button/button.js +221 -165
  45. package/button/index.d.ts +3 -3
  46. package/button/index.js +3 -3
  47. package/calendar/calendar.d.ts +3 -31
  48. package/calendar/calendar.js +71 -481
  49. package/calendar/index.d.ts +3 -3
  50. package/calendar/index.js +3 -3
  51. package/card/card.d.ts +3 -27
  52. package/card/card.js +80 -163
  53. package/card/index.d.ts +2 -3
  54. package/card/index.js +2 -3
  55. package/card-grid/card-grid.d.ts +3 -15
  56. package/card-grid/card-grid.js +8 -106
  57. package/card-grid/index.d.ts +2 -3
  58. package/card-grid/index.js +2 -3
  59. package/checkbox/checkbox-group.d.ts +3 -34
  60. package/checkbox/checkbox-group.js +11 -188
  61. package/checkbox/checkbox.d.ts +3 -47
  62. package/checkbox/checkbox.js +43 -341
  63. package/checkbox/index.d.ts +6 -6
  64. package/checkbox/index.js +5 -5
  65. package/collapsible/collapsible.d.ts +3 -20
  66. package/collapsible/collapsible.js +83 -277
  67. package/collapsible/index.d.ts +3 -3
  68. package/collapsible/index.js +3 -3
  69. package/combobox/combobox.d.ts +3 -47
  70. package/combobox/combobox.js +136 -538
  71. package/combobox/index.d.ts +4 -4
  72. package/combobox/index.js +3 -3
  73. package/command/command-empty.d.ts +3 -8
  74. package/command/command-empty.js +10 -88
  75. package/command/command-group.d.ts +3 -13
  76. package/command/command-group.js +15 -114
  77. package/command/command-input.d.ts +3 -11
  78. package/command/command-input.js +20 -136
  79. package/command/command-item.d.ts +3 -18
  80. package/command/command-item.js +24 -212
  81. package/command/command-list.d.ts +3 -7
  82. package/command/command-list.js +11 -79
  83. package/command/command-separator.d.ts +3 -5
  84. package/command/command-separator.js +10 -11
  85. package/command/command-shortcut.d.ts +3 -5
  86. package/command/command-shortcut.js +9 -12
  87. package/command/command.d.ts +3 -23
  88. package/command/command.js +10 -339
  89. package/command/index.d.ts +17 -19
  90. package/command/index.js +16 -18
  91. package/data-table/data-table.d.ts +3 -57
  92. package/data-table/data-table.js +86 -449
  93. package/data-table/index.d.ts +3 -4
  94. package/data-table/index.js +2 -3
  95. package/dialog/dialog-close.d.ts +3 -14
  96. package/dialog/dialog-close.js +4 -34
  97. package/dialog/dialog-popup.d.ts +3 -34
  98. package/dialog/dialog-popup.js +70 -336
  99. package/dialog/dialog-trigger.d.ts +3 -14
  100. package/dialog/dialog-trigger.js +4 -51
  101. package/dialog/dialog.d.ts +3 -30
  102. package/dialog/dialog.js +8 -158
  103. package/dialog/index.d.ts +11 -11
  104. package/dialog/index.js +9 -9
  105. package/dropzone/dropzone.d.ts +3 -72
  106. package/dropzone/dropzone.js +29 -407
  107. package/dropzone/index.d.ts +4 -4
  108. package/dropzone/index.js +3 -3
  109. package/field/field.d.ts +3 -30
  110. package/field/field.js +34 -353
  111. package/field/index.d.ts +1 -0
  112. package/field/index.js +1 -0
  113. package/fieldset/fieldset.d.ts +3 -18
  114. package/fieldset/fieldset.js +21 -110
  115. package/fieldset/index.d.ts +1 -0
  116. package/fieldset/index.js +1 -0
  117. package/icon/icon.d.ts +3 -15
  118. package/icon/icon.js +4 -33
  119. package/icon/index.d.ts +2 -3
  120. package/icon/index.js +2 -3
  121. package/input/index.d.ts +3 -3
  122. package/input/index.js +3 -3
  123. package/input/input.d.ts +3 -49
  124. package/input/input.js +57 -238
  125. package/menu/index.d.ts +4 -5
  126. package/menu/index.js +4 -5
  127. package/menu/menu-item.d.ts +3 -13
  128. package/menu/menu-item.js +41 -91
  129. package/menu/menu.d.ts +3 -15
  130. package/menu/menu.js +27 -277
  131. package/menubar/index.d.ts +3 -4
  132. package/menubar/index.js +2 -3
  133. package/menubar/menubar.d.ts +3 -19
  134. package/menubar/menubar.js +12 -183
  135. package/number-field/index.d.ts +3 -3
  136. package/number-field/index.js +3 -3
  137. package/number-field/number-field.d.ts +3 -55
  138. package/number-field/number-field.js +205 -698
  139. package/package.json +126 -113
  140. package/popover/index.d.ts +11 -11
  141. package/popover/index.js +9 -9
  142. package/popover/popover-close.d.ts +3 -12
  143. package/popover/popover-close.js +4 -32
  144. package/popover/popover-popup.d.ts +3 -18
  145. package/popover/popover-popup.js +28 -205
  146. package/popover/popover-trigger.d.ts +3 -13
  147. package/popover/popover-trigger.js +4 -73
  148. package/popover/popover.d.ts +3 -29
  149. package/popover/popover.js +8 -207
  150. package/portal/index.d.ts +3 -4
  151. package/portal/index.js +2 -3
  152. package/portal/portal.d.ts +3 -27
  153. package/portal/portal.js +8 -157
  154. package/preview-card/index.d.ts +9 -9
  155. package/preview-card/index.js +7 -7
  156. package/preview-card/preview-card-popup.d.ts +3 -14
  157. package/preview-card/preview-card-popup.js +29 -194
  158. package/preview-card/preview-card-trigger.d.ts +3 -12
  159. package/preview-card/preview-card-trigger.js +4 -74
  160. package/preview-card/preview-card.d.ts +3 -33
  161. package/preview-card/preview-card.js +8 -239
  162. package/progress/index.d.ts +2 -3
  163. package/progress/index.js +2 -3
  164. package/progress/progress.d.ts +3 -17
  165. package/progress/progress.js +28 -130
  166. package/radio/index.d.ts +6 -6
  167. package/radio/index.js +5 -5
  168. package/radio/radio-group.d.ts +3 -37
  169. package/radio/radio-group.js +8 -200
  170. package/radio/radio.d.ts +3 -28
  171. package/radio/radio.js +38 -213
  172. package/scroll-area/index.d.ts +2 -3
  173. package/scroll-area/index.js +2 -3
  174. package/scroll-area/scroll-area.d.ts +3 -36
  175. package/scroll-area/scroll-area.js +25 -535
  176. package/select/index.d.ts +3 -4
  177. package/select/index.js +2 -3
  178. package/select/select.d.ts +3 -39
  179. package/select/select.js +115 -425
  180. package/separator/index.d.ts +2 -3
  181. package/separator/index.js +2 -3
  182. package/separator/separator.d.ts +3 -10
  183. package/separator/separator.js +23 -85
  184. package/sidebar/index.d.ts +29 -29
  185. package/sidebar/index.js +27 -32
  186. package/sidebar/sidebar-content.d.ts +3 -12
  187. package/sidebar/sidebar-content.js +7 -29
  188. package/sidebar/sidebar-footer.d.ts +3 -10
  189. package/sidebar/sidebar-footer.js +7 -20
  190. package/sidebar/sidebar-group-label.d.ts +3 -15
  191. package/sidebar/sidebar-group-label.js +17 -41
  192. package/sidebar/sidebar-group.d.ts +3 -13
  193. package/sidebar/sidebar-group.js +7 -24
  194. package/sidebar/sidebar-header.d.ts +3 -10
  195. package/sidebar/sidebar-header.js +7 -16
  196. package/sidebar/sidebar-inset.d.ts +3 -13
  197. package/sidebar/sidebar-inset.js +7 -28
  198. package/sidebar/sidebar-menu-button.d.ts +3 -26
  199. package/sidebar/sidebar-menu-button.js +60 -217
  200. package/sidebar/sidebar-menu-item.d.ts +3 -10
  201. package/sidebar/sidebar-menu-item.js +7 -19
  202. package/sidebar/sidebar-menu.d.ts +3 -12
  203. package/sidebar/sidebar-menu.js +7 -25
  204. package/sidebar/sidebar-provider.d.ts +3 -34
  205. package/sidebar/sidebar-provider.js +22 -232
  206. package/sidebar/sidebar-separator.d.ts +3 -10
  207. package/sidebar/sidebar-separator.js +9 -19
  208. package/sidebar/sidebar-trigger.d.ts +3 -14
  209. package/sidebar/sidebar-trigger.js +10 -46
  210. package/sidebar/sidebar.d.ts +3 -19
  211. package/sidebar/sidebar.js +65 -262
  212. package/slider/index.d.ts +3 -3
  213. package/slider/index.js +3 -3
  214. package/slider/slider.d.ts +3 -45
  215. package/slider/slider.js +97 -382
  216. package/spinner/index.d.ts +2 -3
  217. package/spinner/index.js +2 -3
  218. package/spinner/spinner.d.ts +3 -11
  219. package/spinner/spinner.js +20 -163
  220. package/split-button/index.d.ts +3 -1
  221. package/split-button/index.js +3 -1
  222. package/split-button/split-button.d.ts +3 -33
  223. package/split-button/split-button.js +307 -394
  224. package/stepper/index.d.ts +3 -3
  225. package/stepper/index.js +3 -3
  226. package/stepper/stepper.d.ts +3 -41
  227. package/stepper/stepper.js +57 -381
  228. package/switch/index.d.ts +3 -3
  229. package/switch/index.js +3 -3
  230. package/switch/switch.d.ts +3 -30
  231. package/switch/switch.js +63 -228
  232. package/tabs/index.d.ts +12 -12
  233. package/tabs/index.js +11 -11
  234. package/tabs/tab.d.ts +3 -14
  235. package/tabs/tab.js +33 -131
  236. package/tabs/tabs-indicator.d.ts +3 -9
  237. package/tabs/tabs-indicator.js +17 -22
  238. package/tabs/tabs-list.d.ts +3 -15
  239. package/tabs/tabs-list.js +14 -113
  240. package/tabs/tabs-panel.d.ts +3 -16
  241. package/tabs/tabs-panel.js +32 -114
  242. package/tabs/tabs.d.ts +3 -22
  243. package/tabs/tabs.js +8 -170
  244. package/textarea/index.d.ts +4 -4
  245. package/textarea/index.js +3 -3
  246. package/textarea/textarea.d.ts +3 -36
  247. package/textarea/textarea.js +63 -220
  248. package/toggle/index.d.ts +6 -6
  249. package/toggle/index.js +5 -5
  250. package/toggle/toggle-group.d.ts +3 -27
  251. package/toggle/toggle-group.js +9 -224
  252. package/toggle/toggle.d.ts +3 -26
  253. package/toggle/toggle.js +94 -178
  254. package/tokens/properties.css +361 -0
  255. package/tokens/prose.css +250 -0
  256. package/tokens/prose.d.ts +2 -0
  257. package/tokens/prose.js +4 -0
  258. package/tokens/tokens-raw.d.ts +2 -0
  259. package/tokens/tokens-raw.js +2 -0
  260. package/tokens/tokens.css +409 -0
  261. package/tokens/tokens.d.ts +2 -0
  262. package/tokens/tokens.js +5 -0
  263. package/toolbar/index.d.ts +2 -3
  264. package/toolbar/index.js +2 -3
  265. package/toolbar/toolbar.d.ts +3 -11
  266. package/toolbar/toolbar.js +25 -116
  267. package/tooltip/index.d.ts +9 -9
  268. package/tooltip/index.js +7 -7
  269. package/tooltip/tooltip-popup.d.ts +3 -14
  270. package/tooltip/tooltip-popup.js +32 -185
  271. package/tooltip/tooltip-trigger.d.ts +3 -14
  272. package/tooltip/tooltip-trigger.js +5 -148
  273. package/tooltip/tooltip.d.ts +3 -35
  274. package/tooltip/tooltip.js +8 -253
  275. package/trunc/index.d.ts +2 -3
  276. package/trunc/index.js +2 -3
  277. package/trunc/trunc.d.ts +3 -17
  278. package/trunc/trunc.js +10 -108
  279. package/_deprecated/center/center.d.ts +0 -14
  280. package/_deprecated/center/center.js +0 -37
  281. package/_deprecated/center/index.d.ts +0 -3
  282. package/_deprecated/center/index.js +0 -3
  283. package/_deprecated/center/register.js +0 -4
  284. package/_deprecated/hstack/hstack.d.ts +0 -25
  285. package/_deprecated/hstack/hstack.js +0 -187
  286. package/_deprecated/hstack/index.d.ts +0 -4
  287. package/_deprecated/hstack/index.js +0 -3
  288. package/_deprecated/hstack/register.d.ts +0 -1
  289. package/_deprecated/hstack/register.js +0 -4
  290. package/_deprecated/page-inset/index.d.ts +0 -3
  291. package/_deprecated/page-inset/index.js +0 -3
  292. package/_deprecated/page-inset/page-inset.d.ts +0 -28
  293. package/_deprecated/page-inset/page-inset.js +0 -151
  294. package/_deprecated/page-inset/register.d.ts +0 -1
  295. package/_deprecated/page-inset/register.js +0 -4
  296. package/_deprecated/vstack/index.d.ts +0 -3
  297. package/_deprecated/vstack/index.js +0 -3
  298. package/_deprecated/vstack/register.d.ts +0 -1
  299. package/_deprecated/vstack/register.js +0 -4
  300. package/_deprecated/vstack/vstack.d.ts +0 -17
  301. package/_deprecated/vstack/vstack.js +0 -125
  302. package/accordion/accordion-context.d.ts +0 -15
  303. package/accordion/accordion-context.js +0 -3
  304. package/alert-dialog/alert-dialog-context.d.ts +0 -13
  305. package/alert-dialog/alert-dialog-context.js +0 -3
  306. package/checkbox/checkbox-group-context.d.ts +0 -11
  307. package/checkbox/checkbox-group-context.js +0 -3
  308. package/command/command-context.d.ts +0 -30
  309. package/command/command-context.js +0 -3
  310. package/command/command-score.d.ts +0 -6
  311. package/command/command-score.js +0 -31
  312. package/dialog/dialog-context.d.ts +0 -13
  313. package/dialog/dialog-context.js +0 -3
  314. package/global.d.ts +0 -179
  315. package/menubar/menubar-context.d.ts +0 -9
  316. package/menubar/menubar-context.js +0 -2
  317. package/popover/popover-context.d.ts +0 -17
  318. package/popover/popover-context.js +0 -3
  319. package/preview-card/preview-card-context.d.ts +0 -16
  320. package/preview-card/preview-card-context.js +0 -3
  321. package/radio/radio-group-context.d.ts +0 -11
  322. package/radio/radio-group-context.js +0 -2
  323. package/sidebar/sidebar-context.d.ts +0 -15
  324. package/sidebar/sidebar-context.js +0 -3
  325. package/split-button/register.d.ts +0 -1
  326. package/split-button/register.js +0 -4
  327. package/tabs/tabs-context.d.ts +0 -8
  328. package/tabs/tabs-context.js +0 -2
  329. package/toggle/toggle-group-context.d.ts +0 -9
  330. package/toggle/toggle-group-context.js +0 -2
  331. package/tooltip/tooltip-context.d.ts +0 -17
  332. package/tooltip/tooltip-context.js +0 -3
  333. /package/{_deprecated/center/register.d.ts → _install.d.ts} +0 -0
@@ -1,729 +1,236 @@
1
- var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
2
- function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
3
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
4
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
5
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
6
- var _, done = false;
7
- for (var i = decorators.length - 1; i >= 0; i--) {
8
- var context = {};
9
- for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
10
- for (var p in contextIn.access) context.access[p] = contextIn.access[p];
11
- context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
12
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
13
- if (kind === "accessor") {
14
- if (result === void 0) continue;
15
- if (result === null || typeof result !== "object") throw new TypeError("Object expected");
16
- if (_ = accept(result.get)) descriptor.get = _;
17
- if (_ = accept(result.set)) descriptor.set = _;
18
- if (_ = accept(result.init)) initializers.unshift(_);
19
- }
20
- else if (_ = accept(result)) {
21
- if (kind === "field") initializers.unshift(_);
22
- else descriptor[key] = _;
23
- }
24
- }
25
- if (target) Object.defineProperty(target, contextIn.name, descriptor);
26
- done = true;
27
- };
28
- var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
29
- var useValue = arguments.length > 2;
30
- for (var i = 0; i < initializers.length; i++) {
31
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
32
- }
33
- return useValue ? value : void 0;
34
- };
35
- var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
36
- if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
37
- return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
38
- };
39
- import { css, html, LitElement, nothing } from "lit";
40
- import { property, state } from "lit/decorators.js";
41
- import { live } from "lit/directives/live.js";
42
- import { base } from "@deepfuture/dui-core/base";
43
- import { customEvent } from "@deepfuture/dui-core/event";
44
- export const valueChangeEvent = customEvent("value-change", { bubbles: true, composed: true });
45
- export const valueCommittedEvent = customEvent("value-committed", { bubbles: true, composed: true });
46
- /** Structural styles only — layout CSS. */
1
+ import { css } from "lit";
2
+ import { DuiNumberFieldPrimitive } from "@deepfuture/dui-primitives/number-field";
3
+ import "../_install.js";
47
4
  const styles = css `
48
5
  :host {
49
- display: block;
50
- }
6
+ --number-field-bg: transparent;
7
+ --number-field-fg: var(--text-1);
8
+ --number-field-border: var(--border);
9
+ --number-field-height: var(--component-height-sm);
10
+ --number-field-radius: var(--radius-md);
11
+ --number-field-font-size: var(--text-xs);
12
+ --number-field-value-align: center;
51
13
 
52
- [part="root"] {
53
- display: flex;
54
- align-items: center;
55
- width: 100%;
56
- position: relative;
57
- box-sizing: border-box;
58
- user-select: none;
59
- -webkit-tap-highlight-color: transparent;
60
- transition-property: background, box-shadow, border-color, color, opacity;
61
- }
14
+ /* Label tokens */
15
+ --number-field-label-bg: var(--surface-2, var(--muted, hsl(0 0% 90%)));
16
+ --number-field-label-fg: var(--text-2);
17
+ --number-field-label-width: var(--space-5);
62
18
 
63
- [part="root"][data-scrub] {
64
- cursor: ew-resize;
19
+ /* Private display toggles — hidden by default */
20
+ --_label-display: none;
21
+ --_icon-display: none;
22
+ --_unit-display: none;
65
23
  }
66
24
 
67
- [part="root"][data-disabled] {
68
- pointer-events: none;
25
+ /* -----------------------------------------------------------
26
+ * Label visibility
27
+ * ----------------------------------------------------------- */
28
+
29
+ :host([label]:not([label=""])) {
30
+ --_label-display: flex;
69
31
  }
70
32
 
71
33
  [part="label"] {
72
- display: flex;
34
+ display: var(--_label-display);
73
35
  align-items: center;
74
36
  justify-content: center;
75
37
  flex-shrink: 0;
76
38
  }
77
39
 
78
- [part="label"][data-scrub] {
79
- cursor: ew-resize;
80
- }
40
+ /* -----------------------------------------------------------
41
+ * Label position: inside-left
42
+ *
43
+ * Host becomes the bordered container so the label sits
44
+ * visually inside the border alongside the root content.
45
+ * ----------------------------------------------------------- */
81
46
 
82
- [part="icon"] {
83
- display: flex;
47
+ :host([label-position="inside-left"]) {
48
+ display: inline-flex;
84
49
  align-items: center;
85
- justify-content: center;
86
- flex-shrink: 0;
50
+ background: var(--number-field-bg);
51
+ border: var(--border-width-thin) solid var(--number-field-border);
52
+ border-radius: var(--number-field-radius);
53
+ overflow: hidden;
54
+ transition-property: border-color, box-shadow;
55
+ transition-duration: var(--duration-fast);
87
56
  }
88
57
 
89
- [part="input"] {
90
- box-sizing: border-box;
91
- outline: none;
58
+ :host([label-position="inside-left"]:hover) {
59
+ border-color: var(--ring, var(--border));
60
+ }
61
+
62
+ :host([label-position="inside-left"]:focus-within) {
63
+ box-shadow:
64
+ 0 0 0 var(--focus-ring-offset) var(--background),
65
+ 0 0 0 calc(var(--focus-ring-offset) + var(--focus-ring-width)) var(--focus-ring-color);
66
+ }
67
+
68
+ :host([label-position="inside-left"]) [part="label"] {
69
+ width: var(--number-field-label-width);
70
+ height: var(--number-field-height);
71
+ background: var(--number-field-label-bg);
72
+ color: var(--number-field-label-fg);
73
+ font-size: var(--text-2xs);
74
+ font-weight: var(--font-weight-medium, 500);
75
+ }
76
+
77
+ :host([label-position="inside-left"]) [part="root"] {
92
78
  border: none;
79
+ border-radius: 0;
93
80
  background: none;
94
- font: inherit;
95
- color: inherit;
96
- min-width: 0;
97
- flex: 1;
98
81
  }
99
82
 
100
- [part="input"][data-scrub] {
83
+ :host([label-position="inside-left"]) [part="root"]:focus-within {
84
+ box-shadow: none;
85
+ }
86
+
87
+ /* -----------------------------------------------------------
88
+ * Label position: above
89
+ * ----------------------------------------------------------- */
90
+
91
+ :host([label-position="above"]) {
92
+ display: flex;
93
+ flex-direction: column;
94
+ align-items: start;
95
+ gap: var(--space-1);
96
+ }
97
+
98
+ :host([label-position="above"]) [part="label"] {
99
+ font-size: var(--text-xs);
100
+ color: var(--text-2);
101
+ }
102
+
103
+ /* -----------------------------------------------------------
104
+ * Label position: below
105
+ * ----------------------------------------------------------- */
106
+
107
+ :host([label-position="below"]) {
108
+ display: flex;
109
+ flex-direction: column-reverse;
110
+ gap: var(--space-1);
111
+ }
112
+
113
+ :host([label-position="below"]) [part="label"] {
114
+ font-size: var(--text-xs);
115
+ color: var(--text-2);
116
+ }
117
+
118
+ /* -----------------------------------------------------------
119
+ * Label position: outside-left
120
+ * ----------------------------------------------------------- */
121
+
122
+ :host([label-position="outside-left"]) {
123
+ display: inline-flex;
124
+ align-items: center;
125
+ gap: var(--space-2);
126
+ }
127
+
128
+ :host([label-position="outside-left"]) [part="label"] {
129
+ font-size: var(--text-xs);
130
+ color: var(--text-2);
131
+ }
132
+
133
+ /* -----------------------------------------------------------
134
+ * Icon position
135
+ * ----------------------------------------------------------- */
136
+
137
+ :host([icon-position]) {
138
+ --_icon-display: flex;
139
+ }
140
+
141
+ :host([icon-position=""]) {
142
+ --_icon-display: none;
143
+ }
144
+
145
+ :host([icon-position="inside-left"]) [part="icon"] {
146
+ order: -1;
147
+ padding-left: var(--space-2);
148
+ color: var(--text-2);
149
+ }
150
+
151
+ :host([icon-position="inside-right"]) [part="icon"] {
152
+ order: 99;
153
+ padding-right: var(--space-2);
154
+ color: var(--text-2);
155
+ }
156
+
157
+ :host([icon-position="outside-left"]) [part="icon"] {
158
+ order: -2;
159
+ color: var(--text-2);
160
+ }
161
+
162
+ /* -----------------------------------------------------------
163
+ * Unit suffix visibility
164
+ * ----------------------------------------------------------- */
165
+
166
+ :host([unit]:not([unit=""])) {
167
+ --_unit-display: inline;
168
+ }
169
+
170
+ /* -----------------------------------------------------------
171
+ * Base appearance (root)
172
+ * ----------------------------------------------------------- */
173
+
174
+ [part="root"] {
175
+ height: var(--number-field-height);
176
+ background: var(--number-field-bg);
177
+ border: var(--border-width-thin) solid var(--number-field-border);
178
+ border-radius: var(--number-field-radius);
179
+ font-size: var(--number-field-font-size);
180
+ color: var(--number-field-fg);
181
+ cursor: text;
182
+ transition-duration: var(--duration-fast);
183
+ overflow: hidden;
184
+ }
185
+
186
+ [part="root"]:hover {
187
+ border-color: var(--ring, var(--border));
188
+ }
189
+
190
+ [part="root"]:focus-within {
191
+ box-shadow:
192
+ 0 0 0 var(--focus-ring-offset) var(--background),
193
+ 0 0 0 calc(var(--focus-ring-offset) + var(--focus-ring-width)) var(--focus-ring-color);
194
+ }
195
+
196
+ :host([aria-invalid="true"]) [part="root"] {
197
+ border-color: var(--destructive);
198
+ }
199
+
200
+ [part="root"][data-dragging] {
101
201
  cursor: ew-resize;
102
202
  }
103
203
 
104
- [part="input"]:disabled {
105
- cursor: not-allowed;
204
+ [part="root"][data-disabled] {
205
+ opacity: 0.4;
206
+ }
207
+
208
+ /* -----------------------------------------------------------
209
+ * Parts
210
+ * ----------------------------------------------------------- */
211
+
212
+ [part="icon"] {
213
+ display: var(--_icon-display);
106
214
  }
107
215
 
108
216
  [part="unit"] {
109
- flex-shrink: 0;
110
- pointer-events: none;
217
+ display: var(--_unit-display, none);
218
+ font-size: var(--text-2xs);
219
+ color: var(--text-2);
220
+ padding-right: var(--space-2);
111
221
  }
112
222
 
223
+ [part="input"] {
224
+ text-align: var(--number-field-value-align);
225
+ padding: 0 var(--space-2);
226
+ font-weight: var(--font-weight-medium);
227
+ }
228
+
229
+ :host([disabled]) {
230
+ opacity: 0.5;
231
+ }
113
232
  `;
114
- /** Drag threshold in px before scrub starts. */
115
- const DRAG_THRESHOLD = 3;
116
- /**
117
- * `<dui-number-field>` — A numeric input with optional label, icon,
118
- * unit suffix, drag-to-scrub behavior, and precision formatting.
119
- *
120
- * For simple step-up/step-down with buttons, use `<dui-stepper>` instead.
121
- *
122
- * @csspart root - The outer container.
123
- * @csspart label - Label text element.
124
- * @csspart icon - Icon slot wrapper.
125
- * @csspart input - The text input element.
126
- * @csspart unit - Unit suffix element.
127
- * @fires value-change - Fired when value changes. Detail: { value: number }
128
- * @fires value-committed - Fired on pointerup (end of drag), blur, or Enter. Detail: { value: number }
129
- */
130
- let DuiNumberField = (() => {
131
- let _classSuper = LitElement;
132
- let _value_decorators;
133
- let _value_initializers = [];
134
- let _value_extraInitializers = [];
135
- let _defaultValue_decorators;
136
- let _defaultValue_initializers = [];
137
- let _defaultValue_extraInitializers = [];
138
- let _min_decorators;
139
- let _min_initializers = [];
140
- let _min_extraInitializers = [];
141
- let _max_decorators;
142
- let _max_initializers = [];
143
- let _max_extraInitializers = [];
144
- let _step_decorators;
145
- let _step_initializers = [];
146
- let _step_extraInitializers = [];
147
- let _largeStep_decorators;
148
- let _largeStep_initializers = [];
149
- let _largeStep_extraInitializers = [];
150
- let _disabled_decorators;
151
- let _disabled_initializers = [];
152
- let _disabled_extraInitializers = [];
153
- let _readOnly_decorators;
154
- let _readOnly_initializers = [];
155
- let _readOnly_extraInitializers = [];
156
- let _required_decorators;
157
- let _required_initializers = [];
158
- let _required_extraInitializers = [];
159
- let _name_decorators;
160
- let _name_initializers = [];
161
- let _name_extraInitializers = [];
162
- let _label_decorators;
163
- let _label_initializers = [];
164
- let _label_extraInitializers = [];
165
- let _labelPosition_decorators;
166
- let _labelPosition_initializers = [];
167
- let _labelPosition_extraInitializers = [];
168
- let _iconPosition_decorators;
169
- let _iconPosition_initializers = [];
170
- let _iconPosition_extraInitializers = [];
171
- let _unit_decorators;
172
- let _unit_initializers = [];
173
- let _unit_extraInitializers = [];
174
- let _precision_decorators;
175
- let _precision_initializers = [];
176
- let _precision_extraInitializers = [];
177
- let _scrubLabel_decorators;
178
- let _scrubLabel_initializers = [];
179
- let _scrubLabel_extraInitializers = [];
180
- let _scrubValue_decorators;
181
- let _scrubValue_initializers = [];
182
- let _scrubValue_extraInitializers = [];
183
- let _scrubField_decorators;
184
- let _scrubField_initializers = [];
185
- let _scrubField_extraInitializers = [];
186
- let _clickLabel_decorators;
187
- let _clickLabel_initializers = [];
188
- let _clickLabel_extraInitializers = [];
189
- let _clickValue_decorators;
190
- let _clickValue_initializers = [];
191
- let _clickValue_extraInitializers = [];
192
- let _clickField_decorators;
193
- let _clickField_initializers = [];
194
- let _clickField_extraInitializers = [];
195
- let _private_internalValue_decorators;
196
- let _private_internalValue_initializers = [];
197
- let _private_internalValue_extraInitializers = [];
198
- let _private_internalValue_descriptor;
199
- let _private_inputText_decorators;
200
- let _private_inputText_initializers = [];
201
- let _private_inputText_extraInitializers = [];
202
- let _private_inputText_descriptor;
203
- let _private_dragging_decorators;
204
- let _private_dragging_initializers = [];
205
- let _private_dragging_extraInitializers = [];
206
- let _private_dragging_descriptor;
207
- let _private_editing_decorators;
208
- let _private_editing_initializers = [];
209
- let _private_editing_extraInitializers = [];
210
- let _private_editing_descriptor;
211
- return class DuiNumberField extends _classSuper {
212
- static {
213
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
214
- _value_decorators = [property({ type: Number })];
215
- _defaultValue_decorators = [property({ type: Number, attribute: "default-value" })];
216
- _min_decorators = [property({ type: Number })];
217
- _max_decorators = [property({ type: Number })];
218
- _step_decorators = [property({ type: Number })];
219
- _largeStep_decorators = [property({ type: Number, attribute: "large-step" })];
220
- _disabled_decorators = [property({ type: Boolean, reflect: true })];
221
- _readOnly_decorators = [property({ type: Boolean, reflect: true, attribute: "read-only" })];
222
- _required_decorators = [property({ type: Boolean })];
223
- _name_decorators = [property()];
224
- _label_decorators = [property({ reflect: true })];
225
- _labelPosition_decorators = [property({ reflect: true, attribute: "label-position" })];
226
- _iconPosition_decorators = [property({ reflect: true, attribute: "icon-position" })];
227
- _unit_decorators = [property({ reflect: true })];
228
- _precision_decorators = [property({ type: Number })];
229
- _scrubLabel_decorators = [property({ type: Boolean, reflect: true, attribute: "scrub-label" })];
230
- _scrubValue_decorators = [property({ type: Boolean, reflect: true, attribute: "scrub-value" })];
231
- _scrubField_decorators = [property({ type: Boolean, reflect: true, attribute: "scrub-field" })];
232
- _clickLabel_decorators = [property({ type: Boolean, reflect: true, attribute: "click-label" })];
233
- _clickValue_decorators = [property({ type: Boolean, reflect: true, attribute: "click-value" })];
234
- _clickField_decorators = [property({ type: Boolean, reflect: true, attribute: "click-field" })];
235
- _private_internalValue_decorators = [state()];
236
- _private_inputText_decorators = [state()];
237
- _private_dragging_decorators = [state()];
238
- _private_editing_decorators = [state()];
239
- __esDecorate(this, null, _value_decorators, { kind: "accessor", name: "value", static: false, private: false, access: { has: obj => "value" in obj, get: obj => obj.value, set: (obj, value) => { obj.value = value; } }, metadata: _metadata }, _value_initializers, _value_extraInitializers);
240
- __esDecorate(this, null, _defaultValue_decorators, { kind: "accessor", name: "defaultValue", static: false, private: false, access: { has: obj => "defaultValue" in obj, get: obj => obj.defaultValue, set: (obj, value) => { obj.defaultValue = value; } }, metadata: _metadata }, _defaultValue_initializers, _defaultValue_extraInitializers);
241
- __esDecorate(this, null, _min_decorators, { kind: "accessor", name: "min", static: false, private: false, access: { has: obj => "min" in obj, get: obj => obj.min, set: (obj, value) => { obj.min = value; } }, metadata: _metadata }, _min_initializers, _min_extraInitializers);
242
- __esDecorate(this, null, _max_decorators, { kind: "accessor", name: "max", static: false, private: false, access: { has: obj => "max" in obj, get: obj => obj.max, set: (obj, value) => { obj.max = value; } }, metadata: _metadata }, _max_initializers, _max_extraInitializers);
243
- __esDecorate(this, null, _step_decorators, { kind: "accessor", name: "step", static: false, private: false, access: { has: obj => "step" in obj, get: obj => obj.step, set: (obj, value) => { obj.step = value; } }, metadata: _metadata }, _step_initializers, _step_extraInitializers);
244
- __esDecorate(this, null, _largeStep_decorators, { kind: "accessor", name: "largeStep", static: false, private: false, access: { has: obj => "largeStep" in obj, get: obj => obj.largeStep, set: (obj, value) => { obj.largeStep = value; } }, metadata: _metadata }, _largeStep_initializers, _largeStep_extraInitializers);
245
- __esDecorate(this, null, _disabled_decorators, { kind: "accessor", name: "disabled", static: false, private: false, access: { has: obj => "disabled" in obj, get: obj => obj.disabled, set: (obj, value) => { obj.disabled = value; } }, metadata: _metadata }, _disabled_initializers, _disabled_extraInitializers);
246
- __esDecorate(this, null, _readOnly_decorators, { kind: "accessor", name: "readOnly", static: false, private: false, access: { has: obj => "readOnly" in obj, get: obj => obj.readOnly, set: (obj, value) => { obj.readOnly = value; } }, metadata: _metadata }, _readOnly_initializers, _readOnly_extraInitializers);
247
- __esDecorate(this, null, _required_decorators, { kind: "accessor", name: "required", static: false, private: false, access: { has: obj => "required" in obj, get: obj => obj.required, set: (obj, value) => { obj.required = value; } }, metadata: _metadata }, _required_initializers, _required_extraInitializers);
248
- __esDecorate(this, null, _name_decorators, { kind: "accessor", name: "name", static: false, private: false, access: { has: obj => "name" in obj, get: obj => obj.name, set: (obj, value) => { obj.name = value; } }, metadata: _metadata }, _name_initializers, _name_extraInitializers);
249
- __esDecorate(this, null, _label_decorators, { kind: "accessor", name: "label", static: false, private: false, access: { has: obj => "label" in obj, get: obj => obj.label, set: (obj, value) => { obj.label = value; } }, metadata: _metadata }, _label_initializers, _label_extraInitializers);
250
- __esDecorate(this, null, _labelPosition_decorators, { kind: "accessor", name: "labelPosition", static: false, private: false, access: { has: obj => "labelPosition" in obj, get: obj => obj.labelPosition, set: (obj, value) => { obj.labelPosition = value; } }, metadata: _metadata }, _labelPosition_initializers, _labelPosition_extraInitializers);
251
- __esDecorate(this, null, _iconPosition_decorators, { kind: "accessor", name: "iconPosition", static: false, private: false, access: { has: obj => "iconPosition" in obj, get: obj => obj.iconPosition, set: (obj, value) => { obj.iconPosition = value; } }, metadata: _metadata }, _iconPosition_initializers, _iconPosition_extraInitializers);
252
- __esDecorate(this, null, _unit_decorators, { kind: "accessor", name: "unit", static: false, private: false, access: { has: obj => "unit" in obj, get: obj => obj.unit, set: (obj, value) => { obj.unit = value; } }, metadata: _metadata }, _unit_initializers, _unit_extraInitializers);
253
- __esDecorate(this, null, _precision_decorators, { kind: "accessor", name: "precision", static: false, private: false, access: { has: obj => "precision" in obj, get: obj => obj.precision, set: (obj, value) => { obj.precision = value; } }, metadata: _metadata }, _precision_initializers, _precision_extraInitializers);
254
- __esDecorate(this, null, _scrubLabel_decorators, { kind: "accessor", name: "scrubLabel", static: false, private: false, access: { has: obj => "scrubLabel" in obj, get: obj => obj.scrubLabel, set: (obj, value) => { obj.scrubLabel = value; } }, metadata: _metadata }, _scrubLabel_initializers, _scrubLabel_extraInitializers);
255
- __esDecorate(this, null, _scrubValue_decorators, { kind: "accessor", name: "scrubValue", static: false, private: false, access: { has: obj => "scrubValue" in obj, get: obj => obj.scrubValue, set: (obj, value) => { obj.scrubValue = value; } }, metadata: _metadata }, _scrubValue_initializers, _scrubValue_extraInitializers);
256
- __esDecorate(this, null, _scrubField_decorators, { kind: "accessor", name: "scrubField", static: false, private: false, access: { has: obj => "scrubField" in obj, get: obj => obj.scrubField, set: (obj, value) => { obj.scrubField = value; } }, metadata: _metadata }, _scrubField_initializers, _scrubField_extraInitializers);
257
- __esDecorate(this, null, _clickLabel_decorators, { kind: "accessor", name: "clickLabel", static: false, private: false, access: { has: obj => "clickLabel" in obj, get: obj => obj.clickLabel, set: (obj, value) => { obj.clickLabel = value; } }, metadata: _metadata }, _clickLabel_initializers, _clickLabel_extraInitializers);
258
- __esDecorate(this, null, _clickValue_decorators, { kind: "accessor", name: "clickValue", static: false, private: false, access: { has: obj => "clickValue" in obj, get: obj => obj.clickValue, set: (obj, value) => { obj.clickValue = value; } }, metadata: _metadata }, _clickValue_initializers, _clickValue_extraInitializers);
259
- __esDecorate(this, null, _clickField_decorators, { kind: "accessor", name: "clickField", static: false, private: false, access: { has: obj => "clickField" in obj, get: obj => obj.clickField, set: (obj, value) => { obj.clickField = value; } }, metadata: _metadata }, _clickField_initializers, _clickField_extraInitializers);
260
- __esDecorate(this, _private_internalValue_descriptor = { get: __setFunctionName(function () { return this.#internalValue_accessor_storage; }, "#internalValue", "get"), set: __setFunctionName(function (value) { this.#internalValue_accessor_storage = value; }, "#internalValue", "set") }, _private_internalValue_decorators, { kind: "accessor", name: "#internalValue", static: false, private: true, access: { has: obj => #internalValue in obj, get: obj => obj.#internalValue, set: (obj, value) => { obj.#internalValue = value; } }, metadata: _metadata }, _private_internalValue_initializers, _private_internalValue_extraInitializers);
261
- __esDecorate(this, _private_inputText_descriptor = { get: __setFunctionName(function () { return this.#inputText_accessor_storage; }, "#inputText", "get"), set: __setFunctionName(function (value) { this.#inputText_accessor_storage = value; }, "#inputText", "set") }, _private_inputText_decorators, { kind: "accessor", name: "#inputText", static: false, private: true, access: { has: obj => #inputText in obj, get: obj => obj.#inputText, set: (obj, value) => { obj.#inputText = value; } }, metadata: _metadata }, _private_inputText_initializers, _private_inputText_extraInitializers);
262
- __esDecorate(this, _private_dragging_descriptor = { get: __setFunctionName(function () { return this.#dragging_accessor_storage; }, "#dragging", "get"), set: __setFunctionName(function (value) { this.#dragging_accessor_storage = value; }, "#dragging", "set") }, _private_dragging_decorators, { kind: "accessor", name: "#dragging", static: false, private: true, access: { has: obj => #dragging in obj, get: obj => obj.#dragging, set: (obj, value) => { obj.#dragging = value; } }, metadata: _metadata }, _private_dragging_initializers, _private_dragging_extraInitializers);
263
- __esDecorate(this, _private_editing_descriptor = { get: __setFunctionName(function () { return this.#editing_accessor_storage; }, "#editing", "get"), set: __setFunctionName(function (value) { this.#editing_accessor_storage = value; }, "#editing", "set") }, _private_editing_decorators, { kind: "accessor", name: "#editing", static: false, private: true, access: { has: obj => #editing in obj, get: obj => obj.#editing, set: (obj, value) => { obj.#editing = value; } }, metadata: _metadata }, _private_editing_initializers, _private_editing_extraInitializers);
264
- if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
265
- }
266
- static tagName = "dui-number-field";
267
- static formAssociated = true;
268
- static shadowRootOptions = {
269
- ...LitElement.shadowRootOptions,
270
- delegatesFocus: true,
271
- };
272
- static styles = [base, styles];
273
- #internals;
274
- constructor() {
275
- super();
276
- this.#internals = this.attachInternals();
277
- }
278
- #value_accessor_storage = __runInitializers(this, _value_initializers, undefined);
279
- // ── Core properties ────────────────────────────────────────────────
280
- get value() { return this.#value_accessor_storage; }
281
- set value(value) { this.#value_accessor_storage = value; }
282
- #defaultValue_accessor_storage = (__runInitializers(this, _value_extraInitializers), __runInitializers(this, _defaultValue_initializers, undefined));
283
- get defaultValue() { return this.#defaultValue_accessor_storage; }
284
- set defaultValue(value) { this.#defaultValue_accessor_storage = value; }
285
- #min_accessor_storage = (__runInitializers(this, _defaultValue_extraInitializers), __runInitializers(this, _min_initializers, undefined));
286
- get min() { return this.#min_accessor_storage; }
287
- set min(value) { this.#min_accessor_storage = value; }
288
- #max_accessor_storage = (__runInitializers(this, _min_extraInitializers), __runInitializers(this, _max_initializers, undefined));
289
- get max() { return this.#max_accessor_storage; }
290
- set max(value) { this.#max_accessor_storage = value; }
291
- #step_accessor_storage = (__runInitializers(this, _max_extraInitializers), __runInitializers(this, _step_initializers, 1));
292
- get step() { return this.#step_accessor_storage; }
293
- set step(value) { this.#step_accessor_storage = value; }
294
- #largeStep_accessor_storage = (__runInitializers(this, _step_extraInitializers), __runInitializers(this, _largeStep_initializers, 10));
295
- get largeStep() { return this.#largeStep_accessor_storage; }
296
- set largeStep(value) { this.#largeStep_accessor_storage = value; }
297
- #disabled_accessor_storage = (__runInitializers(this, _largeStep_extraInitializers), __runInitializers(this, _disabled_initializers, false));
298
- get disabled() { return this.#disabled_accessor_storage; }
299
- set disabled(value) { this.#disabled_accessor_storage = value; }
300
- #readOnly_accessor_storage = (__runInitializers(this, _disabled_extraInitializers), __runInitializers(this, _readOnly_initializers, false));
301
- get readOnly() { return this.#readOnly_accessor_storage; }
302
- set readOnly(value) { this.#readOnly_accessor_storage = value; }
303
- #required_accessor_storage = (__runInitializers(this, _readOnly_extraInitializers), __runInitializers(this, _required_initializers, false));
304
- get required() { return this.#required_accessor_storage; }
305
- set required(value) { this.#required_accessor_storage = value; }
306
- #name_accessor_storage = (__runInitializers(this, _required_extraInitializers), __runInitializers(this, _name_initializers, undefined));
307
- get name() { return this.#name_accessor_storage; }
308
- set name(value) { this.#name_accessor_storage = value; }
309
- #label_accessor_storage = (__runInitializers(this, _name_extraInitializers), __runInitializers(this, _label_initializers, ""));
310
- // ── Display properties ─────────────────────────────────────────────
311
- get label() { return this.#label_accessor_storage; }
312
- set label(value) { this.#label_accessor_storage = value; }
313
- #labelPosition_accessor_storage = (__runInitializers(this, _label_extraInitializers), __runInitializers(this, _labelPosition_initializers, ""));
314
- get labelPosition() { return this.#labelPosition_accessor_storage; }
315
- set labelPosition(value) { this.#labelPosition_accessor_storage = value; }
316
- #iconPosition_accessor_storage = (__runInitializers(this, _labelPosition_extraInitializers), __runInitializers(this, _iconPosition_initializers, ""));
317
- get iconPosition() { return this.#iconPosition_accessor_storage; }
318
- set iconPosition(value) { this.#iconPosition_accessor_storage = value; }
319
- #unit_accessor_storage = (__runInitializers(this, _iconPosition_extraInitializers), __runInitializers(this, _unit_initializers, ""));
320
- get unit() { return this.#unit_accessor_storage; }
321
- set unit(value) { this.#unit_accessor_storage = value; }
322
- #precision_accessor_storage = (__runInitializers(this, _unit_extraInitializers), __runInitializers(this, _precision_initializers, undefined));
323
- get precision() { return this.#precision_accessor_storage; }
324
- set precision(value) { this.#precision_accessor_storage = value; }
325
- #scrubLabel_accessor_storage = (__runInitializers(this, _precision_extraInitializers), __runInitializers(this, _scrubLabel_initializers, false));
326
- // ── Interaction zone booleans ──────────────────────────────────────
327
- get scrubLabel() { return this.#scrubLabel_accessor_storage; }
328
- set scrubLabel(value) { this.#scrubLabel_accessor_storage = value; }
329
- #scrubValue_accessor_storage = (__runInitializers(this, _scrubLabel_extraInitializers), __runInitializers(this, _scrubValue_initializers, false));
330
- get scrubValue() { return this.#scrubValue_accessor_storage; }
331
- set scrubValue(value) { this.#scrubValue_accessor_storage = value; }
332
- #scrubField_accessor_storage = (__runInitializers(this, _scrubValue_extraInitializers), __runInitializers(this, _scrubField_initializers, false));
333
- get scrubField() { return this.#scrubField_accessor_storage; }
334
- set scrubField(value) { this.#scrubField_accessor_storage = value; }
335
- #clickLabel_accessor_storage = (__runInitializers(this, _scrubField_extraInitializers), __runInitializers(this, _clickLabel_initializers, false));
336
- get clickLabel() { return this.#clickLabel_accessor_storage; }
337
- set clickLabel(value) { this.#clickLabel_accessor_storage = value; }
338
- #clickValue_accessor_storage = (__runInitializers(this, _clickLabel_extraInitializers), __runInitializers(this, _clickValue_initializers, false));
339
- get clickValue() { return this.#clickValue_accessor_storage; }
340
- set clickValue(value) { this.#clickValue_accessor_storage = value; }
341
- #clickField_accessor_storage = (__runInitializers(this, _clickValue_extraInitializers), __runInitializers(this, _clickField_initializers, false));
342
- get clickField() { return this.#clickField_accessor_storage; }
343
- set clickField(value) { this.#clickField_accessor_storage = value; }
344
- #internalValue_accessor_storage = (__runInitializers(this, _clickField_extraInitializers), __runInitializers(this, _private_internalValue_initializers, undefined));
345
- // ── Internal state ─────────────────────────────────────────────────
346
- get #internalValue() { return _private_internalValue_descriptor.get.call(this); }
347
- set #internalValue(value) { return _private_internalValue_descriptor.set.call(this, value); }
348
- #inputText_accessor_storage = (__runInitializers(this, _private_internalValue_extraInitializers), __runInitializers(this, _private_inputText_initializers, ""));
349
- get #inputText() { return _private_inputText_descriptor.get.call(this); }
350
- set #inputText(value) { return _private_inputText_descriptor.set.call(this, value); }
351
- #dragging_accessor_storage = (__runInitializers(this, _private_inputText_extraInitializers), __runInitializers(this, _private_dragging_initializers, false));
352
- get #dragging() { return _private_dragging_descriptor.get.call(this); }
353
- set #dragging(value) { return _private_dragging_descriptor.set.call(this, value); }
354
- #editing_accessor_storage = (__runInitializers(this, _private_dragging_extraInitializers), __runInitializers(this, _private_editing_initializers, false));
355
- get #editing() { return _private_editing_descriptor.get.call(this); }
356
- set #editing(value) { return _private_editing_descriptor.set.call(this, value); }
357
- // ── Drag state (not reactive) ──────────────────────────────────────
358
- #dragStartX = (__runInitializers(this, _private_editing_extraInitializers), 0);
359
- #dragStartValue = 0;
360
- #dragStarted = false;
361
- #dragPointerId = null;
362
- #dragZoneAllowsClick = false;
363
- // ── Computed getters ───────────────────────────────────────────────
364
- get #currentValue() {
365
- return this.value ?? this.#internalValue;
366
- }
367
- get #inferredPrecision() {
368
- const stepStr = String(this.step);
369
- const dotIndex = stepStr.indexOf(".");
370
- if (dotIndex === -1)
371
- return 0;
372
- return stepStr.length - dotIndex - 1;
373
- }
374
- get #displayValue() {
375
- const v = this.#currentValue;
376
- if (v === undefined)
377
- return "";
378
- const p = this.precision ?? this.#inferredPrecision;
379
- return v.toFixed(p);
380
- }
381
- /** Whether any interaction boolean is explicitly set by the consumer. */
382
- get #hasExplicitInteraction() {
383
- return (this.scrubLabel ||
384
- this.scrubValue ||
385
- this.scrubField ||
386
- this.clickLabel ||
387
- this.clickValue ||
388
- this.clickField);
389
- }
390
- /** Effective scrub-label: explicit or default. */
391
- get #effectiveScrubLabel() {
392
- if (this.#hasExplicitInteraction)
393
- return this.scrubLabel;
394
- // Default: scrub on label when a label is present
395
- return this.label !== "";
396
- }
397
- /** Effective scrub-value: explicit or default. */
398
- get #effectiveScrubValue() {
399
- if (this.#hasExplicitInteraction)
400
- return this.scrubValue;
401
- return false;
402
- }
403
- /** Effective scrub-field: explicit or default. */
404
- get #effectiveScrubField() {
405
- if (this.#hasExplicitInteraction)
406
- return this.scrubField;
407
- // Default: scrub on field when no label
408
- return this.label === "";
409
- }
410
- /** Effective click-label: explicit or default. */
411
- get #effectiveClickLabel() {
412
- if (this.#hasExplicitInteraction)
413
- return this.clickLabel;
414
- return false;
415
- }
416
- /** Effective click-value: explicit or default. */
417
- get #effectiveClickValue() {
418
- if (this.#hasExplicitInteraction)
419
- return this.clickValue;
420
- return true;
421
- }
422
- /** Effective click-field: explicit or default. */
423
- get #effectiveClickField() {
424
- if (this.#hasExplicitInteraction)
425
- return this.clickField;
426
- return false;
427
- }
428
- // ── Lifecycle ──────────────────────────────────────────────────────
429
- connectedCallback() {
430
- super.connectedCallback();
431
- if (this.value === undefined && this.defaultValue !== undefined) {
432
- this.#internalValue = this.#clamp(this.defaultValue);
433
- }
434
- this.#syncInputText();
435
- }
436
- willUpdate() {
437
- if (!this.#editing) {
438
- this.#syncInputText();
439
- }
440
- this.#internals.setFormValue(this.#currentValue !== undefined ? String(this.#currentValue) : null);
441
- }
442
- // ── Value helpers ──────────────────────────────────────────────────
443
- #syncInputText() {
444
- this.#inputText = this.#displayValue;
445
- }
446
- #clamp(val) {
447
- if (this.min !== undefined)
448
- val = Math.max(this.min, val);
449
- if (this.max !== undefined)
450
- val = Math.min(this.max, val);
451
- return val;
452
- }
453
- #setValue(val) {
454
- const clamped = this.#clamp(val);
455
- if (this.value === undefined) {
456
- this.#internalValue = clamped;
457
- }
458
- this.dispatchEvent(valueChangeEvent({ value: clamped }));
459
- }
460
- #increment = (amount) => {
461
- if (this.disabled || this.readOnly)
462
- return;
463
- const current = this.#currentValue ?? this.min ?? 0;
464
- this.#setValue(current + amount);
465
- };
466
- #decrement = (amount) => {
467
- if (this.disabled || this.readOnly)
468
- return;
469
- const current = this.#currentValue ?? this.max ?? 0;
470
- this.#setValue(current - amount);
471
- };
472
- #commitInput() {
473
- const parsed = parseFloat(this.#inputText);
474
- if (Number.isNaN(parsed)) {
475
- this.#syncInputText();
476
- }
477
- else {
478
- this.#setValue(parsed);
479
- }
480
- this.#editing = false;
481
- const v = this.#currentValue;
482
- if (v !== undefined) {
483
- this.dispatchEvent(valueCommittedEvent({ value: v }));
484
- }
485
- }
486
- #focusInputAndSelectAll() {
487
- const input = this.shadowRoot?.querySelector('[part="input"]');
488
- if (input) {
489
- this.#editing = true;
490
- input.focus();
491
- input.select();
492
- }
493
- }
494
- // ── Drag-to-scrub ─────────────────────────────────────────────────
495
- #startDrag(e, allowsClick) {
496
- if (this.disabled || this.readOnly)
497
- return;
498
- this.#dragPointerId = e.pointerId;
499
- this.#dragStartX = e.clientX;
500
- this.#dragStartValue = this.#currentValue ?? 0;
501
- this.#dragStarted = false;
502
- this.#dragZoneAllowsClick = allowsClick;
503
- this.setPointerCapture(e.pointerId);
504
- this.addEventListener("pointermove", this.#onPointerMove);
505
- this.addEventListener("pointerup", this.#onPointerUp);
506
- this.addEventListener("pointercancel", this.#onPointerUp);
507
- }
508
- #onPointerMove = (e) => {
509
- if (e.pointerId !== this.#dragPointerId)
510
- return;
511
- const deltaX = e.clientX - this.#dragStartX;
512
- if (!this.#dragStarted) {
513
- if (Math.abs(deltaX) < DRAG_THRESHOLD)
514
- return;
515
- this.#dragStarted = true;
516
- this.#dragging = true;
517
- }
518
- let sensitivity = this.step;
519
- if (e.shiftKey) {
520
- sensitivity = this.step * 0.1;
521
- }
522
- else if (e.ctrlKey || e.metaKey) {
523
- sensitivity = this.largeStep;
524
- }
525
- const newValue = this.#dragStartValue + deltaX * sensitivity;
526
- this.#setValue(newValue);
527
- };
528
- #onPointerUp = (e) => {
529
- if (e.pointerId !== this.#dragPointerId)
530
- return;
531
- this.releasePointerCapture(e.pointerId);
532
- this.removeEventListener("pointermove", this.#onPointerMove);
533
- this.removeEventListener("pointerup", this.#onPointerUp);
534
- this.removeEventListener("pointercancel", this.#onPointerUp);
535
- if (this.#dragStarted) {
536
- this.#dragging = false;
537
- const v = this.#currentValue;
538
- if (v !== undefined) {
539
- this.dispatchEvent(valueCommittedEvent({ value: v }));
540
- }
541
- }
542
- else if (this.#dragZoneAllowsClick) {
543
- this.#focusInputAndSelectAll();
544
- }
545
- this.#dragPointerId = null;
546
- };
547
- // ── Zone pointer handlers ──────────────────────────────────────────
548
- #onLabelPointerDown = (e) => {
549
- if (e.button !== 0)
550
- return;
551
- // Field-wide flags apply to all zones
552
- const allowsScrub = this.#effectiveScrubLabel || this.#effectiveScrubField;
553
- const allowsClick = this.#effectiveClickLabel || this.#effectiveClickField;
554
- if (allowsScrub && allowsClick) {
555
- e.preventDefault();
556
- this.#startDrag(e, true);
557
- }
558
- else if (allowsScrub) {
559
- e.preventDefault();
560
- this.#startDrag(e, false);
561
- }
562
- else if (allowsClick) {
563
- e.preventDefault();
564
- this.#focusInputAndSelectAll();
565
- }
566
- };
567
- #onInputPointerDown = (e) => {
568
- if (e.button !== 0)
569
- return;
570
- // Field-wide flags apply to all zones
571
- const allowsScrub = this.#effectiveScrubValue || this.#effectiveScrubField;
572
- const allowsClick = this.#effectiveClickValue || this.#effectiveClickField;
573
- if (allowsScrub && allowsClick) {
574
- e.preventDefault();
575
- this.#startDrag(e, true);
576
- }
577
- else if (allowsScrub) {
578
- e.preventDefault();
579
- this.#startDrag(e, false);
580
- }
581
- else if (allowsClick) {
582
- this.#editing = true;
583
- }
584
- };
585
- #onRootPointerDown = (e) => {
586
- if (e.button !== 0)
587
- return;
588
- // Root handler only fires for clicks on the root background itself
589
- const rootEl = this.shadowRoot?.querySelector('[part="root"]');
590
- if (e.target !== rootEl)
591
- return;
592
- const allowsScrub = this.#effectiveScrubField;
593
- const allowsClick = this.#effectiveClickField;
594
- if (allowsScrub && allowsClick) {
595
- e.preventDefault();
596
- this.#startDrag(e, true);
597
- }
598
- else if (allowsScrub) {
599
- e.preventDefault();
600
- this.#startDrag(e, false);
601
- }
602
- else if (allowsClick) {
603
- e.preventDefault();
604
- this.#focusInputAndSelectAll();
605
- }
606
- };
607
- // ── Input event handlers ───────────────────────────────────────────
608
- #onInput = (e) => {
609
- this.#inputText = e.target.value;
610
- };
611
- #onBlur = () => {
612
- if (this.#editing) {
613
- this.#commitInput();
614
- }
615
- };
616
- #onFocus = () => {
617
- this.#editing = true;
618
- const input = this.shadowRoot?.querySelector('[part="input"]');
619
- if (input) {
620
- requestAnimationFrame(() => input.select());
621
- }
622
- };
623
- #onKeyDown = (e) => {
624
- switch (e.key) {
625
- case "ArrowUp":
626
- e.preventDefault();
627
- if (e.shiftKey) {
628
- this.#increment(this.step * 0.1);
629
- }
630
- else if (e.ctrlKey || e.metaKey) {
631
- this.#increment(this.largeStep);
632
- }
633
- else {
634
- this.#increment(this.step);
635
- }
636
- this.#syncInputText();
637
- break;
638
- case "ArrowDown":
639
- e.preventDefault();
640
- if (e.shiftKey) {
641
- this.#decrement(this.step * 0.1);
642
- }
643
- else if (e.ctrlKey || e.metaKey) {
644
- this.#decrement(this.largeStep);
645
- }
646
- else {
647
- this.#decrement(this.step);
648
- }
649
- this.#syncInputText();
650
- break;
651
- case "Home":
652
- if (this.min !== undefined) {
653
- e.preventDefault();
654
- this.#setValue(this.min);
655
- }
656
- break;
657
- case "End":
658
- if (this.max !== undefined) {
659
- e.preventDefault();
660
- this.#setValue(this.max);
661
- }
662
- break;
663
- case "Enter":
664
- this.#commitInput();
665
- break;
666
- case "Escape": {
667
- this.#editing = false;
668
- this.#syncInputText();
669
- const input = this.shadowRoot?.querySelector('[part="input"]');
670
- if (input)
671
- input.blur();
672
- break;
673
- }
674
- }
675
- };
676
- // ── Render ─────────────────────────────────────────────────────────
677
- render() {
678
- const currentValue = this.#currentValue;
679
- // Compute which zones are scrubbable for cursor styling
680
- const labelScrub = this.#effectiveScrubLabel || this.#effectiveScrubField;
681
- const inputScrub = this.#effectiveScrubValue || this.#effectiveScrubField;
682
- const rootScrub = this.#effectiveScrubField;
683
- return html `
684
- <span
685
- part="label"
686
- ?data-scrub="${labelScrub}"
687
- @pointerdown="${this.#onLabelPointerDown}"
688
- >${this.label}</span>
689
-
690
- <div
691
- part="root"
692
- ?data-scrub="${rootScrub}"
693
- ?data-dragging="${this.#dragging}"
694
- ?data-disabled="${this.disabled}"
695
- ?data-readonly="${this.readOnly}"
696
- @pointerdown="${this.#onRootPointerDown}"
697
- >
698
- <span part="icon">
699
- <slot name="icon"></slot>
700
- </span>
701
-
702
- <input
703
- part="input"
704
- type="text"
705
- inputmode="decimal"
706
- ?data-scrub="${inputScrub}"
707
- .value="${live(this.#inputText)}"
708
- ?disabled="${this.disabled}"
709
- ?readonly="${this.readOnly}"
710
- ?required="${this.required}"
711
- aria-label="${this.label || nothing}"
712
- aria-valuenow="${currentValue ?? nothing}"
713
- aria-valuemin="${this.min ?? nothing}"
714
- aria-valuemax="${this.max ?? nothing}"
715
- @pointerdown="${this.#onInputPointerDown}"
716
- @input="${this.#onInput}"
717
- @keydown="${this.#onKeyDown}"
718
- @focus="${this.#onFocus}"
719
- @blur="${this.#onBlur}"
720
- />
721
-
722
- <span part="unit">${this.unit}</span>
723
-
724
- </div>
725
- `;
726
- }
727
- };
728
- })();
729
- export { DuiNumberField };
233
+ export class DuiNumberField extends DuiNumberFieldPrimitive {
234
+ static styles = [...DuiNumberFieldPrimitive.styles, styles];
235
+ }
236
+ customElements.define(DuiNumberField.tagName, DuiNumberField);