@bettercms-ai/kit 3.0.2 → 3.1.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 (155) hide show
  1. package/dist/brand/logo.js +18 -67
  2. package/dist/brand/logo.js.map +1 -1
  3. package/dist/context.js +3 -8
  4. package/dist/context.js.map +1 -1
  5. package/dist/controls/button.js +134 -451
  6. package/dist/controls/button.js.map +1 -1
  7. package/dist/controls/choice.js +95 -336
  8. package/dist/controls/choice.js.map +1 -1
  9. package/dist/controls/code.js +72 -245
  10. package/dist/controls/code.js.map +1 -1
  11. package/dist/controls/color.js +31 -108
  12. package/dist/controls/color.js.map +1 -1
  13. package/dist/controls/date.js +83 -268
  14. package/dist/controls/date.js.map +1 -1
  15. package/dist/controls/form-picker.js +9 -26
  16. package/dist/controls/form-picker.js.map +1 -1
  17. package/dist/controls/icon.js +100 -341
  18. package/dist/controls/icon.js.map +1 -1
  19. package/dist/controls/json.js +7 -20
  20. package/dist/controls/json.js.map +1 -1
  21. package/dist/controls/link.js +156 -561
  22. package/dist/controls/link.js.map +1 -1
  23. package/dist/controls/location.js +35 -124
  24. package/dist/controls/location.js.map +1 -1
  25. package/dist/controls/media.js +267 -928
  26. package/dist/controls/media.js.map +1 -1
  27. package/dist/controls/number.js +23 -80
  28. package/dist/controls/number.js.map +1 -1
  29. package/dist/controls/reference.js +155 -516
  30. package/dist/controls/reference.js.map +1 -1
  31. package/dist/controls/rich-text/article-shell.js +86 -327
  32. package/dist/controls/rich-text/article-shell.js.map +1 -1
  33. package/dist/controls/rich-text/author.js +21 -78
  34. package/dist/controls/rich-text/author.js.map +1 -1
  35. package/dist/controls/rich-text/blocks.js +317 -1086
  36. package/dist/controls/rich-text/blocks.js.map +1 -1
  37. package/dist/controls/rich-text/button.js +10 -31
  38. package/dist/controls/rich-text/button.js.map +1 -1
  39. package/dist/controls/rich-text/catalog.js +51 -168
  40. package/dist/controls/rich-text/catalog.js.map +1 -1
  41. package/dist/controls/rich-text/columns.js +31 -104
  42. package/dist/controls/rich-text/columns.js.map +1 -1
  43. package/dist/controls/rich-text/component-card.js +209 -790
  44. package/dist/controls/rich-text/component-card.js.map +1 -1
  45. package/dist/controls/rich-text/component-panel.js +40 -102
  46. package/dist/controls/rich-text/component-panel.js.map +1 -1
  47. package/dist/controls/rich-text/control.js +32 -101
  48. package/dist/controls/rich-text/control.js.map +1 -1
  49. package/dist/controls/rich-text/editor.js +108 -369
  50. package/dist/controls/rich-text/editor.js.map +1 -1
  51. package/dist/controls/rich-text/embed.js +51 -184
  52. package/dist/controls/rich-text/embed.js.map +1 -1
  53. package/dist/controls/rich-text/floating.js +42 -171
  54. package/dist/controls/rich-text/floating.js.map +1 -1
  55. package/dist/controls/rich-text/footnote.js +28 -89
  56. package/dist/controls/rich-text/footnote.js.map +1 -1
  57. package/dist/controls/rich-text/gallery.js +27 -88
  58. package/dist/controls/rich-text/gallery.js.map +1 -1
  59. package/dist/controls/rich-text/link-form.d.ts +10 -0
  60. package/dist/controls/rich-text/link-form.js +16 -204
  61. package/dist/controls/rich-text/link-form.js.map +1 -1
  62. package/dist/controls/rich-text/plain.js +3 -8
  63. package/dist/controls/rich-text/plain.js.map +1 -1
  64. package/dist/controls/rich-text/related.js +25 -86
  65. package/dist/controls/rich-text/related.js.map +1 -1
  66. package/dist/controls/rich-text/toc.js +15 -48
  67. package/dist/controls/rich-text/toc.js.map +1 -1
  68. package/dist/controls/rich-text/toolbar.js +105 -402
  69. package/dist/controls/rich-text/toolbar.js.map +1 -1
  70. package/dist/controls/scale.js +52 -169
  71. package/dist/controls/scale.js.map +1 -1
  72. package/dist/controls/slot.js +73 -238
  73. package/dist/controls/slot.js.map +1 -1
  74. package/dist/controls/table/table-editor.js +500 -1766
  75. package/dist/controls/table/table-editor.js.map +1 -1
  76. package/dist/controls/table/table-link.js +41 -121
  77. package/dist/controls/table/table-link.js.map +1 -1
  78. package/dist/controls/table/table.js +9 -26
  79. package/dist/controls/table/table.js.map +1 -1
  80. package/dist/controls/text.js +68 -221
  81. package/dist/controls/text.js.map +1 -1
  82. package/dist/controls/unknown-value.js +22 -79
  83. package/dist/controls/unknown-value.js.map +1 -1
  84. package/dist/engine/array.js +228 -821
  85. package/dist/engine/array.js.map +1 -1
  86. package/dist/engine/bits.js +13 -38
  87. package/dist/engine/bits.js.map +1 -1
  88. package/dist/engine/breadcrumb.js +8 -25
  89. package/dist/engine/breadcrumb.js.map +1 -1
  90. package/dist/engine/expand.js +13 -38
  91. package/dist/engine/expand.js.map +1 -1
  92. package/dist/engine/field-list.js +5 -14
  93. package/dist/engine/field-list.js.map +1 -1
  94. package/dist/engine/field-shell.js +244 -849
  95. package/dist/engine/field-shell.js.map +1 -1
  96. package/dist/engine/frame.js +78 -275
  97. package/dist/engine/frame.js.map +1 -1
  98. package/dist/engine/grouping.js +193 -630
  99. package/dist/engine/grouping.js.map +1 -1
  100. package/dist/engine/item-list.js +50 -187
  101. package/dist/engine/item-list.js.map +1 -1
  102. package/dist/engine/kit-field.js +95 -320
  103. package/dist/engine/kit-field.js.map +1 -1
  104. package/dist/engine/schema-form.js +32 -101
  105. package/dist/engine/schema-form.js.map +1 -1
  106. package/dist/engine/slot.js +45 -146
  107. package/dist/engine/slot.js.map +1 -1
  108. package/dist/lib/icons.js +5 -14
  109. package/dist/lib/icons.js.map +1 -1
  110. package/dist/styles.css +1 -5821
  111. package/dist/table/table-view.js +16 -49
  112. package/dist/table/table-view.js.map +1 -1
  113. package/dist/testing/test-form.js +5 -14
  114. package/dist/testing/test-form.js.map +1 -1
  115. package/dist/theme.js +3 -8
  116. package/dist/theme.js.map +1 -1
  117. package/dist/ui/action-tray.js +24 -97
  118. package/dist/ui/action-tray.js.map +1 -1
  119. package/dist/ui/autocomplete.js +38 -135
  120. package/dist/ui/autocomplete.js.map +1 -1
  121. package/dist/ui/button.js +31 -108
  122. package/dist/ui/button.js.map +1 -1
  123. package/dist/ui/choice-switch.js +5 -14
  124. package/dist/ui/choice-switch.js.map +1 -1
  125. package/dist/ui/controls.js +86 -279
  126. package/dist/ui/controls.js.map +1 -1
  127. package/dist/ui/display.js +116 -401
  128. package/dist/ui/display.js.map +1 -1
  129. package/dist/ui/expanded-editor-modal.js +27 -100
  130. package/dist/ui/expanded-editor-modal.js.map +1 -1
  131. package/dist/ui/floating-panel.js +37 -130
  132. package/dist/ui/floating-panel.js.map +1 -1
  133. package/dist/ui/input.js +59 -196
  134. package/dist/ui/input.js.map +1 -1
  135. package/dist/ui/mode-bar.js +11 -32
  136. package/dist/ui/mode-bar.js.map +1 -1
  137. package/dist/ui/overlay.js +176 -613
  138. package/dist/ui/overlay.js.map +1 -1
  139. package/dist/ui/path-crumbs.js +113 -374
  140. package/dist/ui/path-crumbs.js.map +1 -1
  141. package/dist/ui/select.js +78 -311
  142. package/dist/ui/select.js.map +1 -1
  143. package/dist/ui/shortcut-hint.js +6 -19
  144. package/dist/ui/shortcut-hint.js.map +1 -1
  145. package/dist/ui/spinner.js +7 -20
  146. package/dist/ui/spinner.js.map +1 -1
  147. package/dist/ui/split-button.js +10 -35
  148. package/dist/ui/split-button.js.map +1 -1
  149. package/dist/ui/tab.js +17 -50
  150. package/dist/ui/tab.js.map +1 -1
  151. package/dist/ui/toast.js +30 -107
  152. package/dist/ui/toast.js.map +1 -1
  153. package/dist/ui/tooltip-root.js +7 -24
  154. package/dist/ui/tooltip-root.js.map +1 -1
  155. package/package.json +2 -2
@@ -5,7 +5,7 @@ import { fieldScale } from "../schema/scale.js";
5
5
  import { FallbackControl } from "../engine/kit-field.js";
6
6
  import { TEXT_FOCUS } from "./text.js";
7
7
  import * as React from "react";
8
- import { jsxDEV } from "react/jsx-dev-runtime";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
9
  import { IconStarFilled } from "@tabler/icons-react";
10
10
  //#region src/controls/number.tsx
11
11
  /**
@@ -19,7 +19,6 @@ import { IconStarFilled } from "@tabler/icons-react";
19
19
  * Stored shapes (prod `number`, `typeof === "number"`): a number, or null when cleared. A rating stays on its scale
20
20
  * (ratingToProd refuses anything off it), so the control only ever writes a step of the scale or null.
21
21
  */
22
- var _jsxFileName = "D:/Github/bettercms/bettercms-backend/packages/kit/src/controls/number.tsx";
23
22
  /** Registered by the choice / scale lane: the control for a number with a scale. */
24
23
  var NUMBER_SCALE = {};
25
24
  var toNum = (v) => typeof v === "number" && Number.isFinite(v) ? v : typeof v === "string" && v.trim() !== "" && Number.isFinite(Number(v)) ? Number(v) : null;
@@ -27,17 +26,9 @@ var toNum = (v) => typeof v === "number" && Number.isFinite(v) ? v : typeof v ==
27
26
  var NUMBER_TYPING = /^-?\d*\.?\d*$/;
28
27
  var decimals = (n) => (String(n).split(".")[1] ?? "").length;
29
28
  function NumberControl(p) {
30
- if (!fieldScale(p.field)) return /* @__PURE__ */ jsxDEV(PlainNumber, { ...p }, void 0, false, {
31
- fileName: _jsxFileName,
32
- lineNumber: 33,
33
- columnNumber: 36
34
- }, this);
29
+ if (!fieldScale(p.field)) return /* @__PURE__ */ jsx(PlainNumber, { ...p });
35
30
  const Scale = NUMBER_SCALE.control ?? FallbackControl;
36
- return /* @__PURE__ */ jsxDEV(Scale, { ...p }, void 0, false, {
37
- fileName: _jsxFileName,
38
- lineNumber: 35,
39
- columnNumber: 10
40
- }, this);
31
+ return /* @__PURE__ */ jsx(Scale, { ...p });
41
32
  }
42
33
  function PlainNumber({ field, value, onChange, readOnly, id, invalid, onBlur }) {
43
34
  const { variant } = useKitEnv();
@@ -62,10 +53,10 @@ function PlainNumber({ field, value, onChange, readOnly, id, invalid, onBlur })
62
53
  }
63
54
  setDraft(null);
64
55
  };
65
- return /* @__PURE__ */ jsxDEV("div", {
56
+ return /* @__PURE__ */ jsxs("div", {
66
57
  "data-slot": "kit-number",
67
58
  className: cn("flex w-full max-w-40 items-center rounded-kit-md border border-kit-line-strong bg-kit-field-bg transition-colors hover:border-kit-line-strong focus-within:border-kit-line-strong focus-within:bg-kit-field-bg", variant === "document" ? "h-9" : "h-8", invalid && "border-[var(--kit-field-invalid)]", readOnly && "opacity-80"),
68
- children: [/* @__PURE__ */ jsxDEV("input", {
59
+ children: [/* @__PURE__ */ jsx("input", {
69
60
  id,
70
61
  inputMode: "decimal",
71
62
  value: draft ?? (n == null ? "" : String(n)),
@@ -94,13 +85,9 @@ function PlainNumber({ field, value, onChange, readOnly, id, invalid, onBlur })
94
85
  }
95
86
  },
96
87
  className: cn(TEXT_FOCUS, "tabular-nums h-full min-w-0 flex-1 bg-transparent px-2.5 text-kit-sm text-kit-fg outline-none placeholder:text-kit-fg-3")
97
- }, void 0, false, {
98
- fileName: _jsxFileName,
99
- lineNumber: 73,
100
- columnNumber: 7
101
- }, this), unit ? /* @__PURE__ */ jsxDEV(Tooltip, {
88
+ }), unit ? /* @__PURE__ */ jsx(Tooltip, {
102
89
  content: readOnly ? void 0 : "Drag to adjust · Shift for ×10",
103
- children: /* @__PURE__ */ jsxDEV("span", {
90
+ children: /* @__PURE__ */ jsx("span", {
104
91
  "data-slot": "kit-number-unit",
105
92
  onPointerDown: (e) => {
106
93
  if (readOnly) return;
@@ -120,21 +107,9 @@ function PlainNumber({ field, value, onChange, readOnly, id, invalid, onBlur })
120
107
  onPointerCancel: () => start.current = null,
121
108
  className: "flex h-full cursor-ew-resize select-none items-center pl-1 pr-2.5 text-kit-xs text-kit-fg-3 hover:text-kit-fg",
122
109
  children: unit
123
- }, void 0, false, {
124
- fileName: _jsxFileName,
125
- lineNumber: 105,
126
- columnNumber: 11
127
- }, this)
128
- }, void 0, false, {
129
- fileName: _jsxFileName,
130
- lineNumber: 104,
131
- columnNumber: 9
132
- }, this) : null]
133
- }, void 0, true, {
134
- fileName: _jsxFileName,
135
- lineNumber: 64,
136
- columnNumber: 5
137
- }, this);
110
+ })
111
+ }) : null]
112
+ });
138
113
  }
139
114
  /** Prod's rating scale, from the field's numeric bounds (0 · 5 · 1 unset). */
140
115
  function ratingScale(field) {
@@ -164,10 +139,10 @@ function RatingControl({ field, value, onChange, readOnly, id, invalid, onBlur }
164
139
  }
165
140
  setDraft(null);
166
141
  };
167
- return /* @__PURE__ */ jsxDEV("div", {
142
+ return /* @__PURE__ */ jsxs("div", {
168
143
  className: "flex items-center gap-3",
169
144
  children: [
170
- /* @__PURE__ */ jsxDEV("div", {
145
+ /* @__PURE__ */ jsx("div", {
171
146
  role: "radiogroup",
172
147
  "aria-label": `${field.title} rating`,
173
148
  className: "flex items-center",
@@ -175,7 +150,7 @@ function RatingControl({ field, value, onChange, readOnly, id, invalid, onBlur }
175
150
  children: Array.from({ length: stars }, (_, k) => k + 1).map((i) => {
176
151
  const fill = Math.max(0, Math.min(1, shown - (i - 1)));
177
152
  const pick = snapRating(i, scale);
178
- return /* @__PURE__ */ jsxDEV("button", {
153
+ return /* @__PURE__ */ jsxs("button", {
179
154
  type: "button",
180
155
  role: "radio",
181
156
  "aria-checked": n != null && Math.ceil(n) === i,
@@ -184,35 +159,15 @@ function RatingControl({ field, value, onChange, readOnly, id, invalid, onBlur }
184
159
  onMouseEnter: () => setHover(i),
185
160
  onClick: () => onChange(pick),
186
161
  className: "relative flex size-7 items-center justify-center transition-transform hover:scale-110",
187
- children: [/* @__PURE__ */ jsxDEV(IconStarFilled, { className: "size-[18px] text-kit-line-strong" }, void 0, false, {
188
- fileName: _jsxFileName,
189
- lineNumber: 176,
190
- columnNumber: 15
191
- }, this), /* @__PURE__ */ jsxDEV("span", {
162
+ children: [/* @__PURE__ */ jsx(IconStarFilled, { className: "size-[18px] text-kit-line-strong" }), /* @__PURE__ */ jsx("span", {
192
163
  className: "absolute inset-0 flex items-center justify-center overflow-hidden",
193
164
  style: { clipPath: `inset(0 ${100 - fill * 100}% 0 0)` },
194
- children: /* @__PURE__ */ jsxDEV(IconStarFilled, { className: "size-[18px] text-kit-warning" }, void 0, false, {
195
- fileName: _jsxFileName,
196
- lineNumber: 178,
197
- columnNumber: 17
198
- }, this)
199
- }, void 0, false, {
200
- fileName: _jsxFileName,
201
- lineNumber: 177,
202
- columnNumber: 15
203
- }, this)]
204
- }, i, true, {
205
- fileName: _jsxFileName,
206
- lineNumber: 165,
207
- columnNumber: 13
208
- }, this);
165
+ children: /* @__PURE__ */ jsx(IconStarFilled, { className: "size-[18px] text-kit-warning" })
166
+ })]
167
+ }, i);
209
168
  })
210
- }, void 0, false, {
211
- fileName: _jsxFileName,
212
- lineNumber: 160,
213
- columnNumber: 7
214
- }, this),
215
- /* @__PURE__ */ jsxDEV("input", {
169
+ }),
170
+ /* @__PURE__ */ jsx("input", {
216
171
  id,
217
172
  inputMode: "decimal",
218
173
  value: draft ?? (n == null ? "" : String(n)),
@@ -227,25 +182,13 @@ function RatingControl({ field, value, onChange, readOnly, id, invalid, onBlur }
227
182
  },
228
183
  onKeyDown: (e) => e.key === "Enter" && e.currentTarget.blur(),
229
184
  className: "tabular-nums h-7 w-12 rounded-kit-md border border-kit-line-strong bg-kit-field-bg px-2 text-kit-sm text-kit-fg outline-none hover:border-kit-line-strong focus:border-kit-line-strong focus:bg-kit-field-bg"
230
- }, void 0, false, {
231
- fileName: _jsxFileName,
232
- lineNumber: 184,
233
- columnNumber: 7
234
- }, this),
235
- /* @__PURE__ */ jsxDEV("span", {
185
+ }),
186
+ /* @__PURE__ */ jsxs("span", {
236
187
  className: "text-kit-xs text-kit-fg-3",
237
188
  children: ["out of ", scale.max]
238
- }, void 0, true, {
239
- fileName: _jsxFileName,
240
- lineNumber: 200,
241
- columnNumber: 7
242
- }, this)
189
+ })
243
190
  ]
244
- }, void 0, true, {
245
- fileName: _jsxFileName,
246
- lineNumber: 159,
247
- columnNumber: 5
248
- }, this);
191
+ });
249
192
  }
250
193
  //#endregion
251
194
  export { NUMBER_SCALE, NumberControl, PlainNumber, RatingControl, ratingScale, snapRating, toNum };
@@ -1 +1 @@
1
- {"version":3,"file":"number.js","names":[],"sources":["../../src/controls/number.tsx"],"sourcesContent":["/**\n * NUMBER — a plain input, NO stepper (prod CPO-068), V2 HEAD 9829bf1 kit/controls/number.tsx, DESIGN §8.4.\n * ↑/↓ step (Shift ×10), the value commits on blur or Enter, clamped to min/max and rounded to the step's precision only when the schema sets a step (V2 rounds to a default step of 1; prod never rounds, so a typed 2.5 stays 2.5);\n * the unit suffix scrubs on drag (Shift ×10); the wheel never changes a value (it blurs).\n * A number with a scale (`field.scale`, or `layout: \"slider\"` + min/max) is the scale control, which the choice lane\n * registers in NUMBER_SCALE; a host that never registered it edits the raw value (FallbackControl), never a plain box.\n * RATING — stars across the prod scale (config.min 0 · max 5 · step 1 unset) plus a number box for half steps.\n *\n * Stored shapes (prod `number`, `typeof === \"number\"`): a number, or null when cleared. A rating stays on its scale\n * (ratingToProd refuses anything off it), so the control only ever writes a step of the scale or null.\n */\nimport * as React from \"react\";\nimport type { ComponentType } from \"react\";\nimport { IconStarFilled } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitEnv } from \"../context\";\nimport { fieldScale } from \"../schema/scale\";\nimport { FallbackControl } from \"../engine/kit-field\";\nimport { Tooltip } from \"../ui/overlay\";\nimport type { ControlProps } from \"../types\";\nimport { TEXT_FOCUS } from \"./text\";\n\n/** Registered by the choice / scale lane: the control for a number with a scale. */\nexport const NUMBER_SCALE: { control?: ComponentType<ControlProps> } = {};\n\nexport const toNum = (v: unknown): number | null =>\n typeof v === \"number\" && Number.isFinite(v) ? v : typeof v === \"string\" && v.trim() !== \"\" && Number.isFinite(Number(v)) ? Number(v) : null;\n/** What a keystroke may leave in a number box: an optional minus, digits, one decimal point. */\nconst NUMBER_TYPING = /^-?\\d*\\.?\\d*$/;\nconst decimals = (n: number) => (String(n).split(\".\")[1] ?? \"\").length;\n\nexport function NumberControl(p: ControlProps) {\n if (!fieldScale(p.field)) return <PlainNumber {...p} />;\n const Scale = NUMBER_SCALE.control ?? FallbackControl;\n return <Scale {...p} />;\n}\n\nexport function PlainNumber({ field, value, onChange, readOnly, id, invalid, onBlur }: ControlProps) {\n const { variant } = useKitEnv();\n const n = toNum(value);\n const step = field.numeric?.step && field.numeric.step > 0 ? field.numeric.step : 1;\n const lo = field.numeric?.min ?? -Infinity;\n const hi = field.numeric?.max ?? Infinity;\n /* Round to the step only when the schema sets one: with no step a typed 2.5 stays 2.5 (prod NumberField never rounds).\n The rounding then only trims float noise from ↑/↓ (2.5 + 1 → 3.5, 0.1 + 0.2 → 0.3). */\n const setStep = !!field.numeric?.step && field.numeric.step > 0;\n const clamp = (x: number, from?: number) => {\n const precision = setStep ? decimals(step) : from == null ? null : Math.max(decimals(step), decimals(from));\n return Math.min(hi, Math.max(lo, precision == null ? x : Number(x.toFixed(precision))));\n };\n const [draft, setDraft] = React.useState<string | null>(null);\n const start = React.useRef<{ x: number; v: number } | null>(null);\n const unit = field.numeric?.unit;\n const commit = () => {\n if (draft !== null) {\n const t = draft.trim();\n const x = Number(t);\n if (t === \"\") onChange(null);\n else if (t !== \"-\" && t !== \".\" && Number.isFinite(x)) onChange(clamp(x));\n }\n setDraft(null);\n };\n return (\n <div\n data-slot=\"kit-number\"\n className={cn(\n \"flex w-full max-w-40 items-center rounded-kit-md border border-kit-line-strong bg-kit-field-bg transition-colors hover:border-kit-line-strong focus-within:border-kit-line-strong focus-within:bg-kit-field-bg\",\n variant === \"document\" ? \"h-9\" : \"h-8\",\n invalid && \"border-[var(--kit-field-invalid)]\",\n readOnly && \"opacity-80\",\n )}\n >\n <input\n id={id}\n inputMode=\"decimal\"\n value={draft ?? (n == null ? \"\" : String(n))}\n readOnly={readOnly}\n aria-invalid={invalid}\n placeholder={field.placeholder ?? \"0\"}\n onWheel={(e) => e.currentTarget.blur()}\n onChange={(e) => NUMBER_TYPING.test(e.target.value) && setDraft(e.target.value)}\n onBlur={() => {\n commit();\n onBlur?.();\n }}\n onKeyDown={(e) => {\n if (readOnly) return;\n if (e.key === \"Enter\") e.currentTarget.blur();\n if (e.key === \"Escape\" && draft !== null) {\n e.stopPropagation();\n setDraft(null);\n }\n if (e.key === \"ArrowUp\" || e.key === \"ArrowDown\") {\n e.preventDefault();\n const base = draft !== null && Number.isFinite(Number(draft)) && draft.trim() !== \"\" ? Number(draft) : (n ?? 0);\n const d = (e.key === \"ArrowUp\" ? 1 : -1) * step * (e.shiftKey ? 10 : 1);\n setDraft(null);\n onChange(clamp(base + d, base));\n }\n }}\n className={cn(TEXT_FOCUS, \"tabular-nums h-full min-w-0 flex-1 bg-transparent px-2.5 text-kit-sm text-kit-fg outline-none placeholder:text-kit-fg-3\")}\n />\n {unit ? (\n <Tooltip content={readOnly ? undefined : \"Drag to adjust · Shift for ×10\"}>\n <span\n data-slot=\"kit-number-unit\"\n onPointerDown={(e) => {\n if (readOnly) return;\n e.currentTarget.setPointerCapture?.(e.pointerId);\n start.current = { x: e.clientX, v: n ?? 0 };\n }}\n onPointerMove={(e) => {\n if (!start.current) return;\n const dx = e.clientX - start.current.x;\n const next = clamp(start.current.v + Math.round(dx / 4) * step * (e.shiftKey ? 10 : 1), start.current.v);\n if (next !== n) onChange(next);\n }}\n onPointerUp={() => (start.current = null)}\n onPointerCancel={() => (start.current = null)}\n className=\"flex h-full cursor-ew-resize select-none items-center pl-1 pr-2.5 text-kit-xs text-kit-fg-3 hover:text-kit-fg\"\n >\n {unit}\n </span>\n </Tooltip>\n ) : null}\n </div>\n );\n}\n\n/** Prod's rating scale, from the field's numeric bounds (0 · 5 · 1 unset). */\nexport function ratingScale(field: ControlProps[\"field\"]) {\n const min = field.numeric?.min ?? 0;\n const max = field.numeric?.max ?? 5;\n const step = field.numeric?.step && field.numeric.step > 0 ? field.numeric.step : 1;\n return { min, max, step };\n}\n/** A typed rating snapped onto its scale; null when it cannot be (empty, not a number). */\nexport function snapRating(x: number, { min, max, step }: { min: number; max: number; step: number }): number {\n const snapped = min + Math.round((x - min) / step) * step;\n return Number(Math.min(max, Math.max(min, snapped)).toFixed(decimals(step)));\n}\n\nexport function RatingControl({ field, value, onChange, readOnly, id, invalid, onBlur }: ControlProps) {\n const scale = ratingScale(field);\n const stars = Math.max(1, Math.min(10, Math.ceil(scale.max)));\n const n = toNum(value);\n const [hover, setHover] = React.useState<number | null>(null);\n const [draft, setDraft] = React.useState<string | null>(null);\n const shown = hover ?? n ?? 0;\n const commit = () => {\n if (draft !== null) {\n const t = draft.trim();\n if (t === \"\") onChange(null);\n else if (Number.isFinite(Number(t)) && t !== \".\") onChange(snapRating(Number(t), scale));\n }\n setDraft(null);\n };\n return (\n <div className=\"flex items-center gap-3\">\n <div role=\"radiogroup\" aria-label={`${field.title} rating`} className=\"flex items-center\" onMouseLeave={() => setHover(null)}>\n {Array.from({ length: stars }, (_, k) => k + 1).map((i) => {\n const fill = Math.max(0, Math.min(1, shown - (i - 1)));\n const pick = snapRating(i, scale);\n return (\n <button\n key={i}\n type=\"button\"\n role=\"radio\"\n aria-checked={n != null && Math.ceil(n) === i}\n aria-label={`${i} star${i > 1 ? \"s\" : \"\"}`}\n disabled={readOnly}\n onMouseEnter={() => setHover(i)}\n onClick={() => onChange(pick)}\n className=\"relative flex size-7 items-center justify-center transition-transform hover:scale-110\"\n >\n <IconStarFilled className=\"size-[18px] text-kit-line-strong\" />\n <span className=\"absolute inset-0 flex items-center justify-center overflow-hidden\" style={{ clipPath: `inset(0 ${100 - fill * 100}% 0 0)` }}>\n <IconStarFilled className=\"size-[18px] text-kit-warning\" />\n </span>\n </button>\n );\n })}\n </div>\n <input\n id={id}\n inputMode=\"decimal\"\n value={draft ?? (n == null ? \"\" : String(n))}\n readOnly={readOnly}\n aria-invalid={invalid}\n placeholder=\"–\"\n onWheel={(e) => e.currentTarget.blur()}\n onChange={(e) => /^\\d*\\.?\\d*$/.test(e.target.value) && setDraft(e.target.value)}\n onBlur={() => {\n commit();\n onBlur?.();\n }}\n onKeyDown={(e) => e.key === \"Enter\" && e.currentTarget.blur()}\n className=\"tabular-nums h-7 w-12 rounded-kit-md border border-kit-line-strong bg-kit-field-bg px-2 text-kit-sm text-kit-fg outline-none hover:border-kit-line-strong focus:border-kit-line-strong focus:bg-kit-field-bg\"\n />\n <span className=\"text-kit-xs text-kit-fg-3\">out of {scale.max}</span>\n </div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AA,GAAA,uBAAC,QAAD;OAAM,WAAU;OAAoE,OAAO,EAAE,UAAU,WAAW,MAAM,OAAO,IAAI,QAAQ;OACzI,UAAA,uBAAC,gBAAD,EAAgB,WAAU,+BAAgC,GAAA,KAAA,GAAA,OAAA;;;;;MACtD,GAAA,KAAA,GAAA,OAAA;;;;MACA,GAAA,IAAA,CAAA;KAdD,GAAA,GAAA,MAAA;;;;KAcC,GAAA,IAAA;IAEZ,CAAC;GACE,GAAA,KAAA,GAAA,OAAA;;;;;GACL,uBAAC,SAAD;IACM;IACJ,WAAU;IACV,OAAO,UAAU,KAAK,OAAO,KAAK,OAAO,CAAC;IAChC;IACV,gBAAc;IACd,aAAY;IACZ,UAAU,MAAM,EAAE,cAAc,KAAK;IACrC,WAAW,MAAM,cAAc,KAAK,EAAE,OAAO,KAAK,KAAK,SAAS,EAAE,OAAO,KAAK;IAC9E,cAAc;KACZ,OAAO;KACP,SAAS;IACX;IACA,YAAY,MAAM,EAAE,QAAQ,WAAW,EAAE,cAAc,KAAK;IAC5D,WAAU;GACX,GAAA,KAAA,GAAA,OAAA;;;;;GACD,uBAAC,QAAD;IAAM,WAAU;IAAhB,UAAA,CAA4C,WAAQ,MAAM,GAAU;;;;;;EACjE;;;;;;AAET"}
1
+ {"version":3,"file":"number.js","names":[],"sources":["../../src/controls/number.tsx"],"sourcesContent":["/**\n * NUMBER — a plain input, NO stepper (prod CPO-068), V2 HEAD 9829bf1 kit/controls/number.tsx, DESIGN §8.4.\n * ↑/↓ step (Shift ×10), the value commits on blur or Enter, clamped to min/max and rounded to the step's precision only when the schema sets a step (V2 rounds to a default step of 1; prod never rounds, so a typed 2.5 stays 2.5);\n * the unit suffix scrubs on drag (Shift ×10); the wheel never changes a value (it blurs).\n * A number with a scale (`field.scale`, or `layout: \"slider\"` + min/max) is the scale control, which the choice lane\n * registers in NUMBER_SCALE; a host that never registered it edits the raw value (FallbackControl), never a plain box.\n * RATING — stars across the prod scale (config.min 0 · max 5 · step 1 unset) plus a number box for half steps.\n *\n * Stored shapes (prod `number`, `typeof === \"number\"`): a number, or null when cleared. A rating stays on its scale\n * (ratingToProd refuses anything off it), so the control only ever writes a step of the scale or null.\n */\nimport * as React from \"react\";\nimport type { ComponentType } from \"react\";\nimport { IconStarFilled } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitEnv } from \"../context\";\nimport { fieldScale } from \"../schema/scale\";\nimport { FallbackControl } from \"../engine/kit-field\";\nimport { Tooltip } from \"../ui/overlay\";\nimport type { ControlProps } from \"../types\";\nimport { TEXT_FOCUS } from \"./text\";\n\n/** Registered by the choice / scale lane: the control for a number with a scale. */\nexport const NUMBER_SCALE: { control?: ComponentType<ControlProps> } = {};\n\nexport const toNum = (v: unknown): number | null =>\n typeof v === \"number\" && Number.isFinite(v) ? v : typeof v === \"string\" && v.trim() !== \"\" && Number.isFinite(Number(v)) ? Number(v) : null;\n/** What a keystroke may leave in a number box: an optional minus, digits, one decimal point. */\nconst NUMBER_TYPING = /^-?\\d*\\.?\\d*$/;\nconst decimals = (n: number) => (String(n).split(\".\")[1] ?? \"\").length;\n\nexport function NumberControl(p: ControlProps) {\n if (!fieldScale(p.field)) return <PlainNumber {...p} />;\n const Scale = NUMBER_SCALE.control ?? FallbackControl;\n return <Scale {...p} />;\n}\n\nexport function PlainNumber({ field, value, onChange, readOnly, id, invalid, onBlur }: ControlProps) {\n const { variant } = useKitEnv();\n const n = toNum(value);\n const step = field.numeric?.step && field.numeric.step > 0 ? field.numeric.step : 1;\n const lo = field.numeric?.min ?? -Infinity;\n const hi = field.numeric?.max ?? Infinity;\n /* Round to the step only when the schema sets one: with no step a typed 2.5 stays 2.5 (prod NumberField never rounds).\n The rounding then only trims float noise from ↑/↓ (2.5 + 1 → 3.5, 0.1 + 0.2 → 0.3). */\n const setStep = !!field.numeric?.step && field.numeric.step > 0;\n const clamp = (x: number, from?: number) => {\n const precision = setStep ? decimals(step) : from == null ? null : Math.max(decimals(step), decimals(from));\n return Math.min(hi, Math.max(lo, precision == null ? x : Number(x.toFixed(precision))));\n };\n const [draft, setDraft] = React.useState<string | null>(null);\n const start = React.useRef<{ x: number; v: number } | null>(null);\n const unit = field.numeric?.unit;\n const commit = () => {\n if (draft !== null) {\n const t = draft.trim();\n const x = Number(t);\n if (t === \"\") onChange(null);\n else if (t !== \"-\" && t !== \".\" && Number.isFinite(x)) onChange(clamp(x));\n }\n setDraft(null);\n };\n return (\n <div\n data-slot=\"kit-number\"\n className={cn(\n \"flex w-full max-w-40 items-center rounded-kit-md border border-kit-line-strong bg-kit-field-bg transition-colors hover:border-kit-line-strong focus-within:border-kit-line-strong focus-within:bg-kit-field-bg\",\n variant === \"document\" ? \"h-9\" : \"h-8\",\n invalid && \"border-[var(--kit-field-invalid)]\",\n readOnly && \"opacity-80\",\n )}\n >\n <input\n id={id}\n inputMode=\"decimal\"\n value={draft ?? (n == null ? \"\" : String(n))}\n readOnly={readOnly}\n aria-invalid={invalid}\n placeholder={field.placeholder ?? \"0\"}\n onWheel={(e) => e.currentTarget.blur()}\n onChange={(e) => NUMBER_TYPING.test(e.target.value) && setDraft(e.target.value)}\n onBlur={() => {\n commit();\n onBlur?.();\n }}\n onKeyDown={(e) => {\n if (readOnly) return;\n if (e.key === \"Enter\") e.currentTarget.blur();\n if (e.key === \"Escape\" && draft !== null) {\n e.stopPropagation();\n setDraft(null);\n }\n if (e.key === \"ArrowUp\" || e.key === \"ArrowDown\") {\n e.preventDefault();\n const base = draft !== null && Number.isFinite(Number(draft)) && draft.trim() !== \"\" ? Number(draft) : (n ?? 0);\n const d = (e.key === \"ArrowUp\" ? 1 : -1) * step * (e.shiftKey ? 10 : 1);\n setDraft(null);\n onChange(clamp(base + d, base));\n }\n }}\n className={cn(TEXT_FOCUS, \"tabular-nums h-full min-w-0 flex-1 bg-transparent px-2.5 text-kit-sm text-kit-fg outline-none placeholder:text-kit-fg-3\")}\n />\n {unit ? (\n <Tooltip content={readOnly ? undefined : \"Drag to adjust · Shift for ×10\"}>\n <span\n data-slot=\"kit-number-unit\"\n onPointerDown={(e) => {\n if (readOnly) return;\n e.currentTarget.setPointerCapture?.(e.pointerId);\n start.current = { x: e.clientX, v: n ?? 0 };\n }}\n onPointerMove={(e) => {\n if (!start.current) return;\n const dx = e.clientX - start.current.x;\n const next = clamp(start.current.v + Math.round(dx / 4) * step * (e.shiftKey ? 10 : 1), start.current.v);\n if (next !== n) onChange(next);\n }}\n onPointerUp={() => (start.current = null)}\n onPointerCancel={() => (start.current = null)}\n className=\"flex h-full cursor-ew-resize select-none items-center pl-1 pr-2.5 text-kit-xs text-kit-fg-3 hover:text-kit-fg\"\n >\n {unit}\n </span>\n </Tooltip>\n ) : null}\n </div>\n );\n}\n\n/** Prod's rating scale, from the field's numeric bounds (0 · 5 · 1 unset). */\nexport function ratingScale(field: ControlProps[\"field\"]) {\n const min = field.numeric?.min ?? 0;\n const max = field.numeric?.max ?? 5;\n const step = field.numeric?.step && field.numeric.step > 0 ? field.numeric.step : 1;\n return { min, max, step };\n}\n/** A typed rating snapped onto its scale; null when it cannot be (empty, not a number). */\nexport function snapRating(x: number, { min, max, step }: { min: number; max: number; step: number }): number {\n const snapped = min + Math.round((x - min) / step) * step;\n return Number(Math.min(max, Math.max(min, snapped)).toFixed(decimals(step)));\n}\n\nexport function RatingControl({ field, value, onChange, readOnly, id, invalid, onBlur }: ControlProps) {\n const scale = ratingScale(field);\n const stars = Math.max(1, Math.min(10, Math.ceil(scale.max)));\n const n = toNum(value);\n const [hover, setHover] = React.useState<number | null>(null);\n const [draft, setDraft] = React.useState<string | null>(null);\n const shown = hover ?? n ?? 0;\n const commit = () => {\n if (draft !== null) {\n const t = draft.trim();\n if (t === \"\") onChange(null);\n else if (Number.isFinite(Number(t)) && t !== \".\") onChange(snapRating(Number(t), scale));\n }\n setDraft(null);\n };\n return (\n <div className=\"flex items-center gap-3\">\n <div role=\"radiogroup\" aria-label={`${field.title} rating`} className=\"flex items-center\" onMouseLeave={() => setHover(null)}>\n {Array.from({ length: stars }, (_, k) => k + 1).map((i) => {\n const fill = Math.max(0, Math.min(1, shown - (i - 1)));\n const pick = snapRating(i, scale);\n return (\n <button\n key={i}\n type=\"button\"\n role=\"radio\"\n aria-checked={n != null && Math.ceil(n) === i}\n aria-label={`${i} star${i > 1 ? \"s\" : \"\"}`}\n disabled={readOnly}\n onMouseEnter={() => setHover(i)}\n onClick={() => onChange(pick)}\n className=\"relative flex size-7 items-center justify-center transition-transform hover:scale-110\"\n >\n <IconStarFilled className=\"size-[18px] text-kit-line-strong\" />\n <span className=\"absolute inset-0 flex items-center justify-center overflow-hidden\" style={{ clipPath: `inset(0 ${100 - fill * 100}% 0 0)` }}>\n <IconStarFilled className=\"size-[18px] text-kit-warning\" />\n </span>\n </button>\n );\n })}\n </div>\n <input\n id={id}\n inputMode=\"decimal\"\n value={draft ?? (n == null ? \"\" : String(n))}\n readOnly={readOnly}\n aria-invalid={invalid}\n placeholder=\"–\"\n onWheel={(e) => e.currentTarget.blur()}\n onChange={(e) => /^\\d*\\.?\\d*$/.test(e.target.value) && setDraft(e.target.value)}\n onBlur={() => {\n commit();\n onBlur?.();\n }}\n onKeyDown={(e) => e.key === \"Enter\" && e.currentTarget.blur()}\n className=\"tabular-nums h-7 w-12 rounded-kit-md border border-kit-line-strong bg-kit-field-bg px-2 text-kit-sm text-kit-fg outline-none hover:border-kit-line-strong focus:border-kit-line-strong focus:bg-kit-field-bg\"\n />\n <span className=\"text-kit-xs text-kit-fg-3\">out of {scale.max}</span>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAa,eAA0D,CAAC;AAExE,IAAa,SAAS,MACpB,OAAO,MAAM,YAAY,OAAO,SAAS,CAAC,IAAI,IAAI,OAAO,MAAM,YAAY,EAAE,KAAK,MAAM,MAAM,OAAO,SAAS,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI;;AAEzI,IAAM,gBAAgB;AACtB,IAAM,YAAY,OAAe,OAAO,CAAC,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