@10x-media/fields 0.1.0-beta.8 → 4.0.0-alpha.1

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 (89) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +8 -3
  3. package/dist/exports/client.d.ts +4 -1
  4. package/dist/exports/client.js +3 -1
  5. package/dist/fields/color/client/ColorField.d.ts +2 -0
  6. package/dist/fields/color/client/ColorField.js +34 -337
  7. package/dist/fields/color/client/ColorField.js.map +1 -1
  8. package/dist/fields/color/client/ColorInput.d.ts +44 -0
  9. package/dist/fields/color/client/ColorInput.js +385 -0
  10. package/dist/fields/color/client/ColorInput.js.map +1 -0
  11. package/dist/fields/color/client/ColorPickerPanel.js +18 -12
  12. package/dist/fields/color/client/ColorPickerPanel.js.map +1 -1
  13. package/dist/fields/color/client/colorField.css +131 -178
  14. package/dist/fields/color/client/icons.js +17 -24
  15. package/dist/fields/color/client/icons.js.map +1 -1
  16. package/dist/fields/color/colorField.js +5 -3
  17. package/dist/fields/color/colorField.js.map +1 -1
  18. package/dist/fields/color/server/colorCell.css +8 -9
  19. package/dist/fields/color/valueIssue.js +23 -0
  20. package/dist/fields/color/valueIssue.js.map +1 -0
  21. package/dist/fields/encrypted/components/EncryptedInput.js +44 -26
  22. package/dist/fields/encrypted/components/EncryptedInput.js.map +1 -1
  23. package/dist/fields/encrypted/components/EncryptedTextarea.js +29 -29
  24. package/dist/fields/encrypted/components/EncryptedTextarea.js.map +1 -1
  25. package/dist/fields/encrypted/components/EyeToggle.js +14 -35
  26. package/dist/fields/encrypted/components/EyeToggle.js.map +1 -1
  27. package/dist/fields/encrypted/components/ProtectedField.css +107 -159
  28. package/dist/fields/encrypted/components/ProtectedField.js +6 -2
  29. package/dist/fields/encrypted/components/ProtectedField.js.map +1 -1
  30. package/dist/fields/encrypted/components/RichTextRevealGate.js +3 -3
  31. package/dist/fields/encrypted/components/RichTextRevealGate.js.map +1 -1
  32. package/dist/fields/encrypted/components/WriteOnlyActions.js +58 -53
  33. package/dist/fields/encrypted/components/WriteOnlyActions.js.map +1 -1
  34. package/dist/fields/encrypted/components/WriteOnlyField.js +39 -21
  35. package/dist/fields/encrypted/components/WriteOnlyField.js.map +1 -1
  36. package/dist/fields/encrypted/components/facsimiles.js +70 -79
  37. package/dist/fields/encrypted/components/facsimiles.js.map +1 -1
  38. package/dist/fields/encrypted/components/placement.js.map +1 -1
  39. package/dist/fields/encrypted/encryptedField.js +25 -12
  40. package/dist/fields/encrypted/encryptedField.js.map +1 -1
  41. package/dist/fields/encrypted/{typescriptSchema.js → jsonSchema.js} +4 -4
  42. package/dist/fields/encrypted/jsonSchema.js.map +1 -0
  43. package/dist/fields/encrypted/queryRewrite.js +20 -0
  44. package/dist/fields/encrypted/queryRewrite.js.map +1 -1
  45. package/dist/fields/encrypted/validators.js +1 -1
  46. package/dist/fields/encrypted/validators.js.map +1 -1
  47. package/dist/fields/icon/adapters/tabler/generated/nodes.js +1 -1
  48. package/dist/fields/icon/adapters/tabler/generated/nodes.js.map +1 -1
  49. package/dist/fields/icon/client/IconDrawerContent.js +8 -6
  50. package/dist/fields/icon/client/IconDrawerContent.js.map +1 -1
  51. package/dist/fields/icon/client/IconFieldClient.js +15 -37
  52. package/dist/fields/icon/client/IconFieldClient.js.map +1 -1
  53. package/dist/fields/icon/client/icon-field.css +137 -233
  54. package/dist/fields/icon/codegen/sources/tabler.js +25 -6
  55. package/dist/fields/icon/codegen/sources/tabler.js.map +1 -1
  56. package/dist/fields/icon/layers/upload.js +3 -0
  57. package/dist/fields/icon/layers/upload.js.map +1 -1
  58. package/dist/fields/icon/react/createIcon.js +4 -4
  59. package/dist/fields/icon/react/createIcon.js.map +1 -1
  60. package/dist/fields/measurement/client/MeasurementField.d.ts +2 -0
  61. package/dist/fields/measurement/client/MeasurementField.js +29 -345
  62. package/dist/fields/measurement/client/MeasurementField.js.map +1 -1
  63. package/dist/fields/measurement/client/MeasurementInput.d.ts +42 -0
  64. package/dist/fields/measurement/client/MeasurementInput.js +313 -0
  65. package/dist/fields/measurement/client/MeasurementInput.js.map +1 -0
  66. package/dist/fields/measurement/client/measurementField.css +58 -105
  67. package/dist/fields/measurement/client/useMeasurementModel.d.ts +19 -0
  68. package/dist/fields/measurement/client/useMeasurementModel.js +85 -0
  69. package/dist/fields/measurement/client/useMeasurementModel.js.map +1 -0
  70. package/dist/fields/measurement/server/getUserUnits.js +2 -1
  71. package/dist/fields/measurement/server/getUserUnits.js.map +1 -1
  72. package/dist/fields/phoneNumber/client/CountryPicker.js +14 -9
  73. package/dist/fields/phoneNumber/client/CountryPicker.js.map +1 -1
  74. package/dist/fields/phoneNumber/client/PhoneNumberField.d.ts +1 -1
  75. package/dist/fields/phoneNumber/client/PhoneNumberField.js +22 -4
  76. package/dist/fields/phoneNumber/client/PhoneNumberField.js.map +1 -1
  77. package/dist/fields/phoneNumber/client/phoneNumberField.css +109 -142
  78. package/dist/fields/phoneNumber/phoneNumberField.js +1 -1
  79. package/dist/fields/phoneNumber/phoneNumberField.js.map +1 -1
  80. package/dist/fields/phoneNumber/server/PhoneNumberCellServer.js +2 -1
  81. package/dist/fields/phoneNumber/server/PhoneNumberCellServer.js.map +1 -1
  82. package/dist/index.d.ts +3 -2
  83. package/dist/index.js +5 -4
  84. package/dist/index.js.map +1 -1
  85. package/dist/plugin/companionSelect.d.ts +12 -0
  86. package/dist/plugin/companionSelect.js +107 -0
  87. package/dist/plugin/companionSelect.js.map +1 -0
  88. package/package.json +15 -15
  89. package/dist/fields/encrypted/typescriptSchema.js.map +0 -1
@@ -0,0 +1,313 @@
1
+ "use client";
2
+ import { COMPOUNDS } from "../engine/units.js";
3
+ import { keys } from "../../../translations/keys.js";
4
+ import { useTranslation as useTranslation$1 } from "../../../translations/useTranslation.js";
5
+ import { commitDrafts, draftsFor } from "./editModel.js";
6
+ import { useMeasurementModel } from "./useMeasurementModel.js";
7
+ import { FieldDescription, FieldError, FieldLabel, MoreIcon, Popup, RenderCustomComponent, fieldBaseClass } from "@payloadcms/ui";
8
+ import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
9
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
+ import "./measurementField.css";
11
+ //#region src/fields/measurement/client/MeasurementInput.tsx
12
+ const baseClass = "fields-measurement";
13
+ const CLEAN = {
14
+ minor: false,
15
+ primary: false
16
+ };
17
+ /**
18
+ * Every value input sizes to its content so "5 ft 11 in" (or a lone scalar)
19
+ * reads as one left-aligned phrase. The half-ch keeps the caret off the edge;
20
+ * the clamp keeps an empty input clickable and a runaway draft from pushing
21
+ * the row into overflow.
22
+ */
23
+ const draftWidth = (draft) => ({ width: `${Math.min(Math.max(draft.length, 2), 12) + .5}ch` });
24
+ /** Payload's own "more" glyph, turned upright: a vertical kebab reads as the row's menu. */
25
+ const unitKebab = /* @__PURE__ */ jsx(MoreIcon, {
26
+ className: `${baseClass}__kebab`,
27
+ size: 24
28
+ });
29
+ /** The row itself, shared by `MeasurementInput` and the form-bound `MeasurementField`. */
30
+ const MeasurementInputView = (props) => {
31
+ const { AfterInput, BeforeInput, className, Description, description, Error: ErrorComponent, error, Label, label, localized, max, min, model, onChange, path, placeholder, readOnly, required, showError: showErrorFromProps, style, value } = props;
32
+ const { displayPrecision, displayUnit, engine, fmtBound, locale, resolvedPrecision, selectUnit: selectModelUnit, storageUnit, units } = model;
33
+ const { t } = useTranslation$1();
34
+ const isReadOnly = Boolean(readOnly);
35
+ const numericValue = typeof value === "number" && !Number.isNaN(value) ? value : null;
36
+ const draftOpts = useMemo(() => ({
37
+ displayUnit,
38
+ draft: resolvedPrecision.draft,
39
+ engine,
40
+ precision: displayPrecision,
41
+ storageDigits: resolvedPrecision.storage,
42
+ storageUnit
43
+ }), [
44
+ displayUnit,
45
+ engine,
46
+ displayPrecision,
47
+ resolvedPrecision,
48
+ storageUnit
49
+ ]);
50
+ const boundsMessage = useMemo(() => {
51
+ if (numericValue === null) return void 0;
52
+ if (typeof min === "number" && numericValue < min) return t(keys.measurementBelowMin, { min: fmtBound(min) });
53
+ if (typeof max === "number" && numericValue > max) return t(keys.measurementAboveMax, { max: fmtBound(max) });
54
+ }, [
55
+ numericValue,
56
+ min,
57
+ max,
58
+ fmtBound,
59
+ t
60
+ ]);
61
+ const errorMessage = error ?? boundsMessage;
62
+ const showError = showErrorFromProps ?? errorMessage !== void 0;
63
+ const editingRef = useRef(false);
64
+ const [drafts, setDrafts] = useState(() => draftsFor(numericValue, draftOpts));
65
+ const paintedDraftsRef = useRef(drafts);
66
+ const paintedStoredRef = useRef(numericValue);
67
+ const [dirty, setDirty] = useState(CLEAN);
68
+ useEffect(() => {
69
+ if (!editingRef.current) {
70
+ const resynced = draftsFor(numericValue, draftOpts);
71
+ setDrafts(resynced);
72
+ paintedDraftsRef.current = resynced;
73
+ paintedStoredRef.current = numericValue;
74
+ setDirty(CLEAN);
75
+ }
76
+ }, [numericValue, draftOpts]);
77
+ const onDraftChange = useCallback((part) => (event) => {
78
+ editingRef.current = true;
79
+ const next = {
80
+ ...drafts,
81
+ [part]: event.target.value
82
+ };
83
+ const nextDirty = {
84
+ ...dirty,
85
+ [part]: true
86
+ };
87
+ setDrafts(next);
88
+ setDirty(nextDirty);
89
+ onChange(commitDrafts(next, {
90
+ ...draftOpts,
91
+ dirty: nextDirty,
92
+ entry: resolvedPrecision.entry,
93
+ paintedDrafts: paintedDraftsRef.current,
94
+ storedValue: paintedStoredRef.current
95
+ }));
96
+ }, [
97
+ dirty,
98
+ drafts,
99
+ draftOpts,
100
+ onChange,
101
+ resolvedPrecision.entry
102
+ ]);
103
+ const onBlur = useCallback(() => {
104
+ editingRef.current = false;
105
+ const resynced = draftsFor(numericValue, draftOpts);
106
+ setDrafts(resynced);
107
+ paintedDraftsRef.current = resynced;
108
+ paintedStoredRef.current = numericValue;
109
+ setDirty(CLEAN);
110
+ }, [numericValue, draftOpts]);
111
+ const selectUnit = useCallback((unit) => {
112
+ editingRef.current = false;
113
+ setDirty(CLEAN);
114
+ selectModelUnit(unit);
115
+ }, [selectModelUnit]);
116
+ const isCompound = engine.isCompoundUnit(displayUnit);
117
+ const compoundDef = isCompound ? COMPOUNDS[displayUnit] : null;
118
+ const generatedId = useId();
119
+ const inputId = path ? `field-${path.replace(/\./g, "__")}` : generatedId;
120
+ const primaryInputRef = useRef(null);
121
+ const minorInputRef = useRef(null);
122
+ const focusNearestInput = useCallback((event) => {
123
+ const target = event.target;
124
+ const isUnitSuffix = target.closest(`.${baseClass}__unit-static`) !== null;
125
+ if (target !== event.currentTarget && !isUnitSuffix) return;
126
+ event.preventDefault();
127
+ const active = document.activeElement;
128
+ if (active === primaryInputRef.current || active === minorInputRef.current) return;
129
+ const [first, ...rest] = [primaryInputRef.current, minorInputRef.current].filter((input) => input !== null);
130
+ if (!first) return;
131
+ const distanceFrom = (input) => {
132
+ const rect = input.getBoundingClientRect();
133
+ return Math.abs(event.clientX - (rect.left + rect.width / 2));
134
+ };
135
+ let nearest = first;
136
+ let nearestDistance = distanceFrom(first);
137
+ for (const input of rest) {
138
+ const distance = distanceFrom(input);
139
+ if (distance < nearestDistance) {
140
+ nearestDistance = distance;
141
+ nearest = input;
142
+ }
143
+ }
144
+ nearest.focus();
145
+ }, []);
146
+ const isUnitInteractive = units.length > 1 && !isReadOnly;
147
+ const renderUnitPanel = ({ close }) => /* @__PURE__ */ jsx("div", {
148
+ "aria-label": t(keys.selectUnit),
149
+ className: `${baseClass}__unit-panel popup-button-list`,
150
+ role: "listbox",
151
+ children: units.map((unit) => /* @__PURE__ */ jsxs("button", {
152
+ "aria-selected": unit === displayUnit,
153
+ className: [
154
+ `${baseClass}__unit-option`,
155
+ "popup-button-list__button",
156
+ unit === displayUnit && "popup-button-list__button--selected"
157
+ ].filter(Boolean).join(" "),
158
+ onClick: () => {
159
+ selectUnit(unit);
160
+ close();
161
+ },
162
+ role: "option",
163
+ type: "button",
164
+ children: [/* @__PURE__ */ jsx("span", { children: engine.unitLabel(unit, locale, "long") }), /* @__PURE__ */ jsx("span", {
165
+ className: `${baseClass}__unit-symbol`,
166
+ children: engine.unitLabel(unit, locale, "short")
167
+ })]
168
+ }, unit))
169
+ });
170
+ const renderUnitSuffix = (unit) => /* @__PURE__ */ jsx("span", {
171
+ className: `${baseClass}__unit-static`,
172
+ children: engine.unitLabel(unit, locale, "short")
173
+ });
174
+ const renderMenuTrigger = () => {
175
+ if (!isUnitInteractive) return null;
176
+ const shortLabel = engine.unitLabel(displayUnit, locale, "short");
177
+ return /* @__PURE__ */ jsx(Popup, {
178
+ button: /* @__PURE__ */ jsxs(Fragment, { children: [unitKebab, /* @__PURE__ */ jsxs("span", {
179
+ className: `${baseClass}__sr-only`,
180
+ children: [
181
+ t(keys.selectUnit),
182
+ ": ",
183
+ shortLabel
184
+ ]
185
+ })] }),
186
+ buttonClassName: `${baseClass}__unit-trigger`,
187
+ buttonType: "default",
188
+ caret: false,
189
+ className: `${baseClass}__popup`,
190
+ horizontalAlign: "right",
191
+ render: renderUnitPanel,
192
+ size: "fit-content",
193
+ verticalAlign: "bottom"
194
+ });
195
+ };
196
+ return /* @__PURE__ */ jsxs("div", {
197
+ className: [
198
+ fieldBaseClass,
199
+ baseClass,
200
+ className,
201
+ showError && "error",
202
+ isReadOnly && "read-only"
203
+ ].filter(Boolean).join(" "),
204
+ style,
205
+ children: [/* @__PURE__ */ jsx(RenderCustomComponent, {
206
+ CustomComponent: Label,
207
+ Fallback: /* @__PURE__ */ jsx(FieldLabel, {
208
+ htmlFor: path ? void 0 : inputId,
209
+ label,
210
+ localized,
211
+ path,
212
+ required
213
+ })
214
+ }), /* @__PURE__ */ jsxs("div", {
215
+ className: `${fieldBaseClass}__wrap`,
216
+ children: [
217
+ /* @__PURE__ */ jsx(RenderCustomComponent, {
218
+ CustomComponent: ErrorComponent,
219
+ Fallback: /* @__PURE__ */ jsx(FieldError, {
220
+ message: errorMessage,
221
+ path,
222
+ showError
223
+ })
224
+ }),
225
+ BeforeInput,
226
+ /* @__PURE__ */ jsxs("div", {
227
+ className: [
228
+ `${baseClass}__container`,
229
+ "form-input-group",
230
+ showError && "form-input-group-error"
231
+ ].filter(Boolean).join(" "),
232
+ onMouseDown: focusNearestInput,
233
+ children: [isCompound && compoundDef ? /* @__PURE__ */ jsxs("span", {
234
+ className: `${baseClass}__compound`,
235
+ onMouseDown: focusNearestInput,
236
+ children: [/* @__PURE__ */ jsxs("span", {
237
+ className: `${baseClass}__part`,
238
+ children: [/* @__PURE__ */ jsx("input", {
239
+ className: `${baseClass}__input`,
240
+ id: inputId,
241
+ inputMode: "decimal",
242
+ name: path,
243
+ onBlur,
244
+ onChange: onDraftChange("primary"),
245
+ readOnly: isReadOnly,
246
+ ref: primaryInputRef,
247
+ step: "any",
248
+ style: draftWidth(drafts.primary),
249
+ type: "number",
250
+ value: drafts.primary
251
+ }), renderUnitSuffix(compoundDef.major)]
252
+ }), /* @__PURE__ */ jsxs("span", {
253
+ className: `${baseClass}__part`,
254
+ children: [/* @__PURE__ */ jsx("input", {
255
+ "aria-label": engine.unitLabel(compoundDef.minor, locale, "long"),
256
+ className: `${baseClass}__input`,
257
+ inputMode: "decimal",
258
+ max: compoundDef.ratio - .001,
259
+ min: 0,
260
+ onBlur,
261
+ onChange: onDraftChange("minor"),
262
+ readOnly: isReadOnly,
263
+ ref: minorInputRef,
264
+ step: "any",
265
+ style: draftWidth(drafts.minor),
266
+ type: "number",
267
+ value: drafts.minor
268
+ }), renderUnitSuffix(compoundDef.minor)]
269
+ })]
270
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("input", {
271
+ className: `${baseClass}__input`,
272
+ id: inputId,
273
+ inputMode: "decimal",
274
+ name: path,
275
+ onBlur,
276
+ onChange: onDraftChange("primary"),
277
+ placeholder,
278
+ readOnly: isReadOnly,
279
+ ref: primaryInputRef,
280
+ step: "any",
281
+ style: draftWidth(drafts.primary || placeholder || ""),
282
+ type: "number",
283
+ value: drafts.primary
284
+ }), renderUnitSuffix(displayUnit)] }), renderMenuTrigger()]
285
+ }),
286
+ AfterInput,
287
+ /* @__PURE__ */ jsx(RenderCustomComponent, {
288
+ CustomComponent: Description,
289
+ Fallback: /* @__PURE__ */ jsx(FieldDescription, {
290
+ description,
291
+ path: path ?? ""
292
+ })
293
+ })
294
+ ]
295
+ })]
296
+ });
297
+ };
298
+ /**
299
+ * The measurement field's row, unit menu and conversion pipeline with no form behind
300
+ * it, for custom admin views and components. Inside the admin the display unit is the
301
+ * viewer's saved preference for `preferenceKey`, shared with every measurement field
302
+ * on that key; `MeasurementField` is this plus `useField`.
303
+ */
304
+ const MeasurementInput = ({ options, ...props }) => {
305
+ return /* @__PURE__ */ jsx(MeasurementInputView, {
306
+ model: useMeasurementModel(options),
307
+ ...props
308
+ });
309
+ };
310
+ //#endregion
311
+ export { MeasurementInput, MeasurementInputView };
312
+
313
+ //# sourceMappingURL=MeasurementInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MeasurementInput.js","names":["useTranslation"],"sources":["../../../../src/fields/measurement/client/MeasurementInput.tsx"],"sourcesContent":["'use client'\nimport {\n\tFieldDescription,\n\tFieldError,\n\tFieldLabel,\n\tfieldBaseClass,\n\tMoreIcon,\n\tPopup,\n\tRenderCustomComponent,\n} from '@payloadcms/ui'\nimport type { StaticDescription, StaticLabel } from 'payload'\nimport type React from 'react'\nimport { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react'\nimport { keys } from '../../../translations/keys'\nimport { useTranslation } from '../../../translations/useTranslation'\nimport { COMPOUNDS, type MeasurementUnitId } from '../engine/units'\nimport { commitDrafts, type DirtyDrafts, draftsFor, type MeasurementDrafts } from './editModel'\nimport {\n\ttype MeasurementInputOptions,\n\ttype MeasurementModel,\n\tuseMeasurementModel,\n} from './useMeasurementModel'\nimport './measurementField.css'\n\nconst baseClass = 'fields-measurement'\n\nconst CLEAN: DirtyDrafts = { minor: false, primary: false }\n\n/**\n * Every value input sizes to its content so \"5 ft 11 in\" (or a lone scalar)\n * reads as one left-aligned phrase. The half-ch keeps the caret off the edge;\n * the clamp keeps an empty input clickable and a runaway draft from pushing\n * the row into overflow.\n */\nconst draftWidth = (draft: string): React.CSSProperties => ({\n\twidth: `${Math.min(Math.max(draft.length, 2), 12) + 0.5}ch`,\n})\n\n/** Payload's own \"more\" glyph, turned upright: a vertical kebab reads as the row's menu. */\nconst unitKebab = <MoreIcon className={`${baseClass}__kebab`} size={24} />\n\n/**\n * Props for the form-free measurement input. `value` is the number in\n * `options.storageUnit`, exactly as `measurementField` stores it; the viewer reads and\n * types in their display unit.\n */\nexport type MeasurementInputProps = {\n\tvalue: null | number | undefined\n\t/** Fires on every edit with the value converted back to the storage unit. */\n\tonChange: (value: null | number) => void\n\toptions: MeasurementInputOptions\n\t/** Bounds in the storage unit; a value outside them shows a message in the display unit. */\n\tmin?: number\n\tmax?: number\n\t/** Names the input (`id`, `name`, label `htmlFor`), as on a native field. */\n\tpath?: string\n\tlabel?: StaticLabel\n\tdescription?: StaticDescription\n\tplaceholder?: string\n\trequired?: boolean\n\tlocalized?: boolean\n\treadOnly?: boolean\n\t/** Message shown in the error tooltip. Left unset, the input reports its own bound errors. */\n\terror?: string\n\t/** Forces the error state on or off. Left unset, it follows `error` and the bound check. */\n\tshowError?: boolean\n\tclassName?: string\n\tstyle?: React.CSSProperties\n\tLabel?: React.ReactNode\n\tError?: React.ReactNode\n\tDescription?: React.ReactNode\n\tBeforeInput?: React.ReactNode\n\tAfterInput?: React.ReactNode\n}\n\ntype MeasurementInputViewProps = { model: MeasurementModel } & Omit<\n\tMeasurementInputProps,\n\t'options'\n>\n\n/** The row itself, shared by `MeasurementInput` and the form-bound `MeasurementField`. */\nexport const MeasurementInputView: React.FC<MeasurementInputViewProps> = (props) => {\n\tconst {\n\t\tAfterInput,\n\t\tBeforeInput,\n\t\tclassName,\n\t\tDescription,\n\t\tdescription,\n\t\tError: ErrorComponent,\n\t\terror,\n\t\tLabel,\n\t\tlabel,\n\t\tlocalized,\n\t\tmax,\n\t\tmin,\n\t\tmodel,\n\t\tonChange,\n\t\tpath,\n\t\tplaceholder,\n\t\treadOnly,\n\t\trequired,\n\t\tshowError: showErrorFromProps,\n\t\tstyle,\n\t\tvalue,\n\t} = props\n\tconst {\n\t\tdisplayPrecision,\n\t\tdisplayUnit,\n\t\tengine,\n\t\tfmtBound,\n\t\tlocale,\n\t\tresolvedPrecision,\n\t\tselectUnit: selectModelUnit,\n\t\tstorageUnit,\n\t\tunits,\n\t} = model\n\tconst { t } = useTranslation()\n\tconst isReadOnly = Boolean(readOnly)\n\n\tconst numericValue = typeof value === 'number' && !Number.isNaN(value) ? value : null\n\tconst draftOpts = useMemo(\n\t\t() => ({\n\t\t\tdisplayUnit,\n\t\t\tdraft: resolvedPrecision.draft,\n\t\t\tengine,\n\t\t\tprecision: displayPrecision,\n\t\t\tstorageDigits: resolvedPrecision.storage,\n\t\t\tstorageUnit,\n\t\t}),\n\t\t[displayUnit, engine, displayPrecision, resolvedPrecision, storageUnit]\n\t)\n\n\t// Payload's server-driven form-state refresh (conditional-logic revalidation on\n\t// every change) can replace this field's errorMessage with the server's raw,\n\t// storage-unit message before our own throttled client validate lands. Compute\n\t// the unit-aware bound message independently and pass it straight to FieldError\n\t// so display never depends on winning that race.\n\tconst boundsMessage = useMemo(() => {\n\t\tif (numericValue === null) return undefined\n\t\tif (typeof min === 'number' && numericValue < min) {\n\t\t\treturn t(keys.measurementBelowMin, { min: fmtBound(min) })\n\t\t}\n\t\tif (typeof max === 'number' && numericValue > max) {\n\t\t\treturn t(keys.measurementAboveMax, { max: fmtBound(max) })\n\t\t}\n\t\treturn undefined\n\t}, [numericValue, min, max, fmtBound, t])\n\tconst errorMessage = error ?? boundsMessage\n\tconst showError = showErrorFromProps ?? errorMessage !== undefined\n\n\tconst editingRef = useRef(false)\n\tconst [drafts, setDrafts] = useState<MeasurementDrafts>(() => draftsFor(numericValue, draftOpts))\n\t// The drafts as painted on screen immediately before the current edit, refreshed\n\t// only at a resync (mount, external value, blur, unit switch) and never per\n\t// keystroke. A carry-rounded display (182.5 cm storage paints as 6 ft 0 in even\n\t// though the exact split is 5 ft 11.850394 in) must never be mistaken for the\n\t// exact stored value, so commits diff the typed value against this baseline\n\t// rather than against the exact decompose.\n\tconst paintedDraftsRef = useRef<MeasurementDrafts>(drafts)\n\t// The stored value the painted drafts were derived from, frozen at the same\n\t// resync points as paintedDraftsRef. A mid-edit commit updates the live value\n\t// (and so `numericValue`) before the viewer blurs; diffing the next keystroke's\n\t// delta against that advanced value, instead of this frozen snapshot, would\n\t// re-apply an already-committed delta on top of itself.\n\tconst paintedStoredRef = useRef<number | null>(numericValue)\n\t// Which part the viewer has actually typed into since the last resync: an\n\t// untouched part must commit the value it already holds, never whatever the\n\t// display-policy draft happens to show for it.\n\tconst [dirty, setDirty] = useState<DirtyDrafts>(CLEAN)\n\tuseEffect(() => {\n\t\tif (!editingRef.current) {\n\t\t\tconst resynced = draftsFor(numericValue, draftOpts)\n\t\t\tsetDrafts(resynced)\n\t\t\tpaintedDraftsRef.current = resynced\n\t\t\tpaintedStoredRef.current = numericValue\n\t\t\tsetDirty(CLEAN)\n\t\t}\n\t}, [numericValue, draftOpts])\n\n\tconst onDraftChange = useCallback(\n\t\t(part: keyof MeasurementDrafts) => (event: React.ChangeEvent<HTMLInputElement>) => {\n\t\t\teditingRef.current = true\n\t\t\tconst next = { ...drafts, [part]: event.target.value }\n\t\t\tconst nextDirty = { ...dirty, [part]: true }\n\t\t\tsetDrafts(next)\n\t\t\tsetDirty(nextDirty)\n\t\t\tonChange(\n\t\t\t\tcommitDrafts(next, {\n\t\t\t\t\t...draftOpts,\n\t\t\t\t\tdirty: nextDirty,\n\t\t\t\t\tentry: resolvedPrecision.entry,\n\t\t\t\t\tpaintedDrafts: paintedDraftsRef.current,\n\t\t\t\t\tstoredValue: paintedStoredRef.current,\n\t\t\t\t})\n\t\t\t)\n\t\t},\n\t\t[dirty, drafts, draftOpts, onChange, resolvedPrecision.entry]\n\t)\n\n\tconst onBlur = useCallback(() => {\n\t\teditingRef.current = false\n\t\tconst resynced = draftsFor(numericValue, draftOpts)\n\t\tsetDrafts(resynced)\n\t\tpaintedDraftsRef.current = resynced\n\t\tpaintedStoredRef.current = numericValue\n\t\tsetDirty(CLEAN)\n\t}, [numericValue, draftOpts])\n\n\tconst selectUnit = useCallback(\n\t\t(unit: MeasurementUnitId) => {\n\t\t\teditingRef.current = false\n\t\t\tsetDirty(CLEAN)\n\t\t\tselectModelUnit(unit)\n\t\t},\n\t\t[selectModelUnit]\n\t)\n\n\tconst isCompound = engine.isCompoundUnit(displayUnit)\n\tconst compoundDef = isCompound ? COMPOUNDS[displayUnit] : null\n\t// Without a path there is no field id to derive, so the label pairs with a generated one\n\tconst generatedId = useId()\n\tconst inputId = path ? `field-${path.replace(/\\./g, '__')}` : generatedId\n\n\tconst primaryInputRef = useRef<HTMLInputElement>(null)\n\tconst minorInputRef = useRef<HTMLInputElement>(null)\n\n\t// Dead-space (or the passive unit suffix, e.g. \"in\") mousedown focuses the nearest\n\t// input like a native control; preventDefault stops an already-focused input from\n\t// blurring, so we never steal focus from it. The suffix is never inside the unit\n\t// trigger button, so this never intercepts opening the unit popup.\n\tconst focusNearestInput = useCallback((event: React.MouseEvent<HTMLElement>) => {\n\t\tconst target = event.target as HTMLElement\n\t\tconst isUnitSuffix = target.closest(`.${baseClass}__unit-static`) !== null\n\t\tif (target !== event.currentTarget && !isUnitSuffix) return\n\t\tevent.preventDefault()\n\t\tconst active = document.activeElement\n\t\tif (active === primaryInputRef.current || active === minorInputRef.current) return\n\t\tconst inputs = [primaryInputRef.current, minorInputRef.current].filter(\n\t\t\t(input): input is HTMLInputElement => input !== null\n\t\t)\n\t\tconst [first, ...rest] = inputs\n\t\tif (!first) return\n\t\tconst distanceFrom = (input: HTMLInputElement) => {\n\t\t\tconst rect = input.getBoundingClientRect()\n\t\t\treturn Math.abs(event.clientX - (rect.left + rect.width / 2))\n\t\t}\n\t\tlet nearest = first\n\t\tlet nearestDistance = distanceFrom(first)\n\t\tfor (const input of rest) {\n\t\t\tconst distance = distanceFrom(input)\n\t\t\tif (distance < nearestDistance) {\n\t\t\t\tnearestDistance = distance\n\t\t\t\tnearest = input\n\t\t\t}\n\t\t}\n\t\tnearest.focus()\n\t}, [])\n\n\tconst isUnitInteractive = units.length > 1 && !isReadOnly\n\n\tconst renderUnitPanel = ({ close }: { close: () => void }) => (\n\t\t<div\n\t\t\taria-label={t(keys.selectUnit)}\n\t\t\tclassName={`${baseClass}__unit-panel popup-button-list`}\n\t\t\trole=\"listbox\"\n\t\t>\n\t\t\t{units.map((unit) => (\n\t\t\t\t<button\n\t\t\t\t\taria-selected={unit === displayUnit}\n\t\t\t\t\tclassName={[\n\t\t\t\t\t\t`${baseClass}__unit-option`,\n\t\t\t\t\t\t'popup-button-list__button',\n\t\t\t\t\t\tunit === displayUnit && 'popup-button-list__button--selected',\n\t\t\t\t\t]\n\t\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t\t.join(' ')}\n\t\t\t\t\tkey={unit}\n\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\tselectUnit(unit)\n\t\t\t\t\t\tclose()\n\t\t\t\t\t}}\n\t\t\t\t\trole=\"option\"\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t>\n\t\t\t\t\t<span>{engine.unitLabel(unit, locale, 'long')}</span>\n\t\t\t\t\t<span className={`${baseClass}__unit-symbol`}>\n\t\t\t\t\t\t{engine.unitLabel(unit, locale, 'short')}\n\t\t\t\t\t</span>\n\t\t\t\t</button>\n\t\t\t))}\n\t\t</div>\n\t)\n\n\tconst renderUnitSuffix = (unit: MeasurementUnitId) => (\n\t\t<span className={`${baseClass}__unit-static`}>{engine.unitLabel(unit, locale, 'short')}</span>\n\t)\n\n\t// One kebab per field, pinned to the row's right edge; the unit text itself\n\t// stays a passive suffix so value and unit read as a single phrase.\n\tconst renderMenuTrigger = () => {\n\t\tif (!isUnitInteractive) return null\n\t\tconst shortLabel = engine.unitLabel(displayUnit, locale, 'short')\n\t\treturn (\n\t\t\t// @todo Payload 4's Popup pins its panel to the viewport edge once the field scrolls out of\n\t\t\t// view (v3 let it scroll away with the field). Adopt the option if Payload adds one.\n\t\t\t<Popup\n\t\t\t\tbutton={\n\t\t\t\t\t<>\n\t\t\t\t\t\t{unitKebab}\n\t\t\t\t\t\t<span className={`${baseClass}__sr-only`}>\n\t\t\t\t\t\t\t{t(keys.selectUnit)}: {shortLabel}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</>\n\t\t\t\t}\n\t\t\t\tbuttonClassName={`${baseClass}__unit-trigger`}\n\t\t\t\tbuttonType=\"default\"\n\t\t\t\tcaret={false}\n\t\t\t\tclassName={`${baseClass}__popup`}\n\t\t\t\thorizontalAlign=\"right\"\n\t\t\t\trender={renderUnitPanel}\n\t\t\t\tsize=\"fit-content\"\n\t\t\t\tverticalAlign=\"bottom\"\n\t\t\t/>\n\t\t)\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tclassName={[\n\t\t\t\tfieldBaseClass,\n\t\t\t\tbaseClass,\n\t\t\t\tclassName,\n\t\t\t\tshowError && 'error',\n\t\t\t\tisReadOnly && 'read-only',\n\t\t\t]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(' ')}\n\t\t\tstyle={style}\n\t\t>\n\t\t\t<RenderCustomComponent\n\t\t\t\tCustomComponent={Label}\n\t\t\t\tFallback={\n\t\t\t\t\t<FieldLabel\n\t\t\t\t\t\thtmlFor={path ? undefined : inputId}\n\t\t\t\t\t\tlabel={label}\n\t\t\t\t\t\tlocalized={localized}\n\t\t\t\t\t\tpath={path}\n\t\t\t\t\t\trequired={required}\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<div className={`${fieldBaseClass}__wrap`}>\n\t\t\t\t<RenderCustomComponent\n\t\t\t\t\tCustomComponent={ErrorComponent}\n\t\t\t\t\tFallback={<FieldError message={errorMessage} path={path} showError={showError} />}\n\t\t\t\t/>\n\t\t\t\t{BeforeInput}\n\t\t\t\t{/* biome-ignore lint/a11y/noStaticElementInteractions: mousedown only refocuses an inner input, it adds no control and changes no semantics */}\n\t\t\t\t<div\n\t\t\t\t\tclassName={[\n\t\t\t\t\t\t`${baseClass}__container`,\n\t\t\t\t\t\t'form-input-group',\n\t\t\t\t\t\tshowError && 'form-input-group-error',\n\t\t\t\t\t]\n\t\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t\t.join(' ')}\n\t\t\t\t\tonMouseDown={focusNearestInput}\n\t\t\t\t>\n\t\t\t\t\t{isCompound && compoundDef ? (\n\t\t\t\t\t\t// biome-ignore lint/a11y/noStaticElementInteractions: same as the container, refocuses whichever inner input is nearest\n\t\t\t\t\t\t<span className={`${baseClass}__compound`} onMouseDown={focusNearestInput}>\n\t\t\t\t\t\t\t<span className={`${baseClass}__part`}>\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\tclassName={`${baseClass}__input`}\n\t\t\t\t\t\t\t\t\tid={inputId}\n\t\t\t\t\t\t\t\t\tinputMode=\"decimal\"\n\t\t\t\t\t\t\t\t\tname={path}\n\t\t\t\t\t\t\t\t\tonBlur={onBlur}\n\t\t\t\t\t\t\t\t\tonChange={onDraftChange('primary')}\n\t\t\t\t\t\t\t\t\treadOnly={isReadOnly}\n\t\t\t\t\t\t\t\t\tref={primaryInputRef}\n\t\t\t\t\t\t\t\t\tstep=\"any\"\n\t\t\t\t\t\t\t\t\tstyle={draftWidth(drafts.primary)}\n\t\t\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\t\t\tvalue={drafts.primary}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{renderUnitSuffix(compoundDef.major)}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t<span className={`${baseClass}__part`}>\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\taria-label={engine.unitLabel(compoundDef.minor, locale, 'long')}\n\t\t\t\t\t\t\t\t\tclassName={`${baseClass}__input`}\n\t\t\t\t\t\t\t\t\tinputMode=\"decimal\"\n\t\t\t\t\t\t\t\t\tmax={compoundDef.ratio - 0.001}\n\t\t\t\t\t\t\t\t\tmin={0}\n\t\t\t\t\t\t\t\t\tonBlur={onBlur}\n\t\t\t\t\t\t\t\t\tonChange={onDraftChange('minor')}\n\t\t\t\t\t\t\t\t\treadOnly={isReadOnly}\n\t\t\t\t\t\t\t\t\tref={minorInputRef}\n\t\t\t\t\t\t\t\t\tstep=\"any\"\n\t\t\t\t\t\t\t\t\tstyle={draftWidth(drafts.minor)}\n\t\t\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\t\t\tvalue={drafts.minor}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{renderUnitSuffix(compoundDef.minor)}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tclassName={`${baseClass}__input`}\n\t\t\t\t\t\t\t\tid={inputId}\n\t\t\t\t\t\t\t\tinputMode=\"decimal\"\n\t\t\t\t\t\t\t\tname={path}\n\t\t\t\t\t\t\t\tonBlur={onBlur}\n\t\t\t\t\t\t\t\tonChange={onDraftChange('primary')}\n\t\t\t\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t\t\t\treadOnly={isReadOnly}\n\t\t\t\t\t\t\t\tref={primaryInputRef}\n\t\t\t\t\t\t\t\tstep=\"any\"\n\t\t\t\t\t\t\t\tstyle={draftWidth(drafts.primary || placeholder || '')}\n\t\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\t\tvalue={drafts.primary}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{renderUnitSuffix(displayUnit)}\n\t\t\t\t\t\t</>\n\t\t\t\t\t)}\n\t\t\t\t\t{renderMenuTrigger()}\n\t\t\t\t</div>\n\t\t\t\t{AfterInput}\n\t\t\t\t<RenderCustomComponent\n\t\t\t\t\tCustomComponent={Description}\n\t\t\t\t\tFallback={<FieldDescription description={description} path={path ?? ''} />}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n\n/**\n * The measurement field's row, unit menu and conversion pipeline with no form behind\n * it, for custom admin views and components. Inside the admin the display unit is the\n * viewer's saved preference for `preferenceKey`, shared with every measurement field\n * on that key; `MeasurementField` is this plus `useField`.\n */\nexport const MeasurementInput: React.FC<MeasurementInputProps> = ({ options, ...props }) => {\n\tconst model = useMeasurementModel(options)\n\treturn <MeasurementInputView model={model} {...props} />\n}\n"],"mappings":";;;;;;;;;;;AAwBA,MAAM,YAAY;AAElB,MAAM,QAAqB;CAAE,OAAO;CAAO,SAAS;AAAM;;;;;;;AAQ1D,MAAM,cAAc,WAAwC,EAC3D,OAAO,GAAG,KAAK,IAAI,KAAK,IAAI,MAAM,QAAQ,CAAC,GAAG,EAAE,IAAI,GAAI,IACzD;;AAGA,MAAM,YAAY,oBAAC,UAAD;CAAU,WAAW,GAAG,UAAU;CAAU,MAAM;AAAK,CAAA;;AA0CzE,MAAa,wBAA6D,UAAU;CACnF,MAAM,EACL,YACA,aACA,WACA,aACA,aACA,OAAO,gBACP,OACA,OACA,OACA,WACA,KACA,KACA,OACA,UACA,MACA,aACA,UACA,UACA,WAAW,oBACX,OACA,UACG;CACJ,MAAM,EACL,kBACA,aACA,QACA,UACA,QACA,mBACA,YAAY,iBACZ,aACA,UACG;CACJ,MAAM,EAAE,MAAMA,iBAAe;CAC7B,MAAM,aAAa,QAAQ,QAAQ;CAEnC,MAAM,eAAe,OAAO,UAAU,YAAY,CAAC,OAAO,MAAM,KAAK,IAAI,QAAQ;CACjF,MAAM,YAAY,eACV;EACN;EACA,OAAO,kBAAkB;EACzB;EACA,WAAW;EACX,eAAe,kBAAkB;EACjC;CACD,IACA;EAAC;EAAa;EAAQ;EAAkB;EAAmB;CAAW,CACvE;CAOA,MAAM,gBAAgB,cAAc;EACnC,IAAI,iBAAiB,MAAM,OAA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,UAAU;MACV,KAAK;MACL,MAAK;MACL,OAAO,WAAW,OAAO,WAAW,eAAe,EAAE;MACrD,MAAK;MACL,OAAO,OAAO;KACd,CAAA,GACA,iBAAiB,WAAW,CAC5B,EAAA,CAAA,GAEF,kBAAkB,CACf;;IACJ;IACD,oBAAC,uBAAD;KACC,iBAAiB;KACjB,UAAU,oBAAC,kBAAD;MAA+B;MAAa,MAAM,QAAQ;KAAK,CAAA;IACzE,CAAA;GACG;IACD;;AAEP;;;;;;;AAQA,MAAa,oBAAqD,EAAE,SAAS,GAAG,YAAY;CAE3F,OAAO,oBAAC,sBAAD;EAAsB,OADf,oBAAoB,OACM;EAAG,GAAI;CAAQ,CAAA;AACxD"}
@@ -2,61 +2,36 @@
2
2
  position: relative;
3
3
  }
4
4
 
5
- /* Mirrors Payload's formInput mixin (packages/ui/src/scss/vars.scss) so the composite
6
- container reads as one native text input; focus rides :focus-within.
7
- Dimensions are static px on purpose: Payload compiles scss base() to literal px
8
- (native inputs stay 40px tall at every breakpoint), while the runtime --base var
9
- is rem-based and shrinks with the responsive html font-size. Deriving from
10
- var(--base) made this container 3px shorter than native inputs at <=1024px. */
11
- .fields-measurement__container {
5
+ .fields-measurement > .field-type__wrap {
12
6
  display: flex;
13
- align-items: center;
14
- gap: 3px;
15
- width: 100%;
16
- height: 40px;
17
- padding: 0 8px 0 6px;
18
- border: 1px solid var(--theme-elevation-150);
19
- border-radius: var(--style-radius-s);
20
- background: var(--theme-input-bg);
21
- color: var(--theme-elevation-800);
22
- font-family: var(--font-body);
23
- font-size: 1rem;
24
- box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1);
25
- transition-property: border, box-shadow, background-color;
26
- transition-duration: 100ms, 100ms, 500ms;
27
- transition-timing-function: cubic-bezier(0, 0.2, 0.2, 1);
28
- }
29
-
30
- .fields-measurement__container:hover {
31
- border-color: var(--theme-elevation-250);
32
- box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.2);
33
- }
34
-
35
- .fields-measurement__container:focus-within {
36
- border-color: var(--theme-elevation-400);
37
- outline: 0;
38
- }
39
-
40
- html[data-theme="light"] .fields-measurement.error .fields-measurement__container {
41
- background-color: var(--theme-error-50);
42
- border-color: var(--theme-error-500);
7
+ flex-direction: column;
8
+ gap: var(--spacer-2);
43
9
  }
44
10
 
45
- html[data-theme="dark"] .fields-measurement.error .fields-measurement__container {
46
- background-color: var(--theme-error-100);
47
- border-color: var(--theme-error-400);
11
+ /* Payload's .form-input-group (on the same element) owns the border, background, radius,
12
+ height and the hover, focus, error and disabled states; this only lays out the row. */
13
+ .fields-measurement__container {
14
+ align-items: center;
15
+ gap: var(--spacer-1);
16
+ padding-inline: var(--field-padding-inline) var(--spacer-1);
17
+ color: var(--field-color-text);
18
+ font-family: var(--font-body);
19
+ font-size: var(--text-body-medium-font-size);
20
+ font-weight: var(--text-body-medium-font-weight);
21
+ line-height: var(--text-body-medium-line-height);
48
22
  }
49
23
 
50
- html[data-theme="dark"] .fields-measurement.error .fields-measurement__container:hover {
51
- border-color: var(--theme-error-500);
24
+ /* Native read-only inputs are disabled inputs on v4, so the row takes the disabled look.
25
+ A read-only input still takes focus here; Payload's .form-input:read-only:focus answers
26
+ that with the hover border, and so does this. */
27
+ .fields-measurement.read-only .fields-measurement__container {
28
+ border-color: var(--field-color-border-disabled);
29
+ background: var(--field-color-bg-disabled);
30
+ color: var(--field-color-text-disabled);
52
31
  }
53
32
 
54
- .fields-measurement.read-only .fields-measurement__container,
55
- .fields-measurement.read-only .fields-measurement__container:hover {
56
- border-color: var(--theme-elevation-150);
57
- background: var(--theme-elevation-100);
58
- color: var(--theme-elevation-400);
59
- box-shadow: none;
33
+ .fields-measurement.read-only .fields-measurement__container:focus-within {
34
+ border-color: var(--field-color-border-hover);
60
35
  }
61
36
 
62
37
  /* Each value hugs its unit; the wider gap separates the pairs, so the row
@@ -64,32 +39,27 @@ html[data-theme="dark"] .fields-measurement.error .fields-measurement__container
64
39
  .fields-measurement__compound {
65
40
  display: flex;
66
41
  flex: 1 1 auto;
42
+ align-self: stretch;
67
43
  min-width: 0;
68
44
  align-items: center;
69
- gap: 12px;
70
- height: 100%;
45
+ gap: var(--spacer-2-5);
71
46
  }
72
47
 
73
48
  .fields-measurement__part {
74
49
  display: flex;
50
+ align-self: stretch;
75
51
  align-items: center;
76
- gap: 3px;
77
- height: 100%;
52
+ gap: var(--spacer-1);
78
53
  }
79
54
 
80
55
  /* Width comes from an inline style tracking the draft's length, so every value
81
56
  (scalar or compound part) hugs its digits instead of stretching the row */
82
57
  .fields-measurement__input {
83
58
  flex: 0 1 auto;
59
+ align-self: stretch;
84
60
  min-width: 2ch;
85
- height: 100%;
86
- padding: 0;
87
- border: 0;
88
- background: transparent;
89
61
  color: inherit;
90
- font-family: inherit;
91
- font-size: inherit;
92
- appearance: none;
62
+ appearance: textfield;
93
63
  -webkit-appearance: none;
94
64
  -moz-appearance: textfield;
95
65
  }
@@ -105,13 +75,13 @@ html[data-theme="dark"] .fields-measurement.error .fields-measurement__container
105
75
  }
106
76
 
107
77
  .fields-measurement__input::placeholder {
108
- color: var(--theme-elevation-400);
78
+ color: var(--field-color-placeholder);
109
79
  }
110
80
 
111
- /* margin-left auto pins the kebab to the row's right edge, away from the
112
- value-unit phrase on the left */
81
+ /* margin-inline-start auto pins the kebab to the row's end, away from the
82
+ value-unit phrase */
113
83
  .fields-measurement__popup {
114
- margin-left: auto;
84
+ margin-inline-start: auto;
115
85
  }
116
86
 
117
87
  .fields-measurement__popup,
@@ -121,35 +91,30 @@ html[data-theme="dark"] .fields-measurement.error .fields-measurement__container
121
91
  }
122
92
 
123
93
  /* The trigger is a real button so it keeps native focus/keyboard semantics; the
124
- kebab is aria-hidden and a sr-only span next to it carries the name */
94
+ kebab is aria-hidden and a sr-only span next to it carries the name. Payload's
95
+ .popup-button paints its hover and pressed fills. */
125
96
  .fields-measurement__unit-trigger {
126
- display: inline-flex;
127
97
  flex-shrink: 0;
128
98
  align-items: center;
129
99
  justify-content: center;
130
- width: 24px;
131
- height: 24px;
132
- padding: 0;
133
- border: 0;
134
- border-radius: var(--style-radius-s);
135
- background: transparent;
136
- color: var(--theme-elevation-500);
137
- cursor: pointer;
100
+ width: var(--spacer-4);
101
+ height: var(--spacer-4);
102
+ color: var(--color-icon-secondary);
138
103
  }
139
104
 
140
105
  .fields-measurement__unit-trigger:hover {
141
- background: var(--theme-elevation-100);
142
- color: var(--theme-elevation-800);
106
+ color: var(--color-icon);
143
107
  }
144
108
 
145
109
  .fields-measurement__unit-trigger:focus-visible {
146
110
  outline: var(--accessibility-outline);
147
111
  }
148
112
 
113
+ /* MoreIcon's three dots sit symmetric about the centre of its box, so a quarter turn makes an
114
+ upright kebab without moving it. */
149
115
  .fields-measurement__kebab {
150
116
  flex-shrink: 0;
151
- width: 4px;
152
- height: 14px;
117
+ transform: rotate(90deg);
153
118
  }
154
119
 
155
120
  .fields-measurement__sr-only {
@@ -164,52 +129,40 @@ html[data-theme="dark"] .fields-measurement.error .fields-measurement__container
164
129
  border-width: 0;
165
130
  }
166
131
 
167
- /* The unit is always a passive suffix hugging its value; interactivity lives
168
- on the kebab at the row's right edge (absent when there is nothing to open) */
132
+ /* The unit is always a passive suffix hugging its value, styled as the native number
133
+ field's suffix; interactivity lives on the kebab at the row's end (absent when there
134
+ is nothing to open) */
169
135
  .fields-measurement__unit-static {
170
136
  flex-shrink: 0;
171
- color: var(--theme-elevation-500);
172
- font-size: 0.85rem;
137
+ color: var(--color-text-secondary);
173
138
  white-space: nowrap;
174
139
  cursor: default;
140
+ user-select: none;
175
141
  }
176
142
 
177
- .popup__scroll-container:has(> .fields-measurement__unit-panel) {
178
- max-height: none;
143
+ .fields-measurement.read-only .fields-measurement__unit-static {
144
+ color: inherit;
179
145
  }
180
146
 
147
+ /* Payload's .popup-button-list (on the same element) supplies the list padding, and
148
+ .popup-button-list__button the item type, radius, hover and selected fills. */
181
149
  .fields-measurement__unit-panel {
182
- display: flex;
183
- flex-direction: column;
184
- gap: 2px;
185
150
  min-width: 180px;
186
- padding: 4px;
187
151
  }
188
152
 
189
153
  .fields-measurement__unit-option {
190
- display: flex;
191
154
  align-items: center;
192
155
  justify-content: space-between;
193
- gap: 12px;
194
- padding: 6px 8px;
195
- border: 0;
196
- border-radius: var(--style-radius-s);
197
- background: transparent;
198
- color: var(--theme-elevation-800);
199
- font-size: 1rem;
156
+ gap: var(--spacer-2-5);
157
+ padding: var(--spacer-1) var(--spacer-2);
200
158
  text-align: start;
201
- cursor: pointer;
202
- }
203
-
204
- .fields-measurement__unit-option:hover {
205
- background: var(--theme-elevation-100);
206
159
  }
207
160
 
208
- .fields-measurement__unit-option[aria-selected="true"] {
209
- background: var(--theme-elevation-150);
161
+ .fields-measurement__unit-symbol {
162
+ color: var(--color-text-secondary);
210
163
  }
211
164
 
212
- .fields-measurement__unit-symbol {
213
- color: var(--theme-elevation-800);
214
- font-size: 0.75rem;
165
+ .fields-measurement__unit-option:is(:hover, [aria-selected="true"])
166
+ .fields-measurement__unit-symbol {
167
+ color: inherit;
215
168
  }
@@ -0,0 +1,19 @@
1
+ import { MeasurementPrecision, PrecisionMode } from "../engine/precision.js";
2
+ import { MeasurementUnitId } from "../engine/units.js";
3
+ import { MeasurementResolvedClientOptions } from "../options.js";
4
+
5
+ //#region src/fields/measurement/client/useMeasurementModel.d.ts
6
+ /**
7
+ * What the standalone input needs to know about a measurement. Only `storageUnit` is
8
+ * required: `dimension`, `preferenceKey` and `units` default the way `measurementField`
9
+ * defaults them, and `precision` is merged the way the field merges its own layer.
10
+ */
11
+ type MeasurementInputOptions = Omit<MeasurementResolvedClientOptions, 'dimension' | 'precision' | 'preferenceKey' | 'units'> & {
12
+ dimension?: string;
13
+ precision?: MeasurementPrecision | PrecisionMode;
14
+ preferenceKey?: string;
15
+ units?: readonly MeasurementUnitId[];
16
+ };
17
+ //#endregion
18
+ export { MeasurementInputOptions };
19
+ //# sourceMappingURL=useMeasurementModel.d.ts.map