@10x-media/fields 0.1.0-beta.9 → 4.0.0-alpha.2

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 (76) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +9 -4
  3. package/dist/fields/color/client/ColorInput.js +17 -6
  4. package/dist/fields/color/client/ColorInput.js.map +1 -1
  5. package/dist/fields/color/client/ColorPickerPanel.js +18 -12
  6. package/dist/fields/color/client/ColorPickerPanel.js.map +1 -1
  7. package/dist/fields/color/client/colorField.css +131 -178
  8. package/dist/fields/color/client/icons.js +17 -24
  9. package/dist/fields/color/client/icons.js.map +1 -1
  10. package/dist/fields/color/colorField.js +5 -3
  11. package/dist/fields/color/colorField.js.map +1 -1
  12. package/dist/fields/color/server/colorCell.css +8 -9
  13. package/dist/fields/encrypted/components/EncryptedInput.js +44 -26
  14. package/dist/fields/encrypted/components/EncryptedInput.js.map +1 -1
  15. package/dist/fields/encrypted/components/EncryptedTextarea.js +29 -29
  16. package/dist/fields/encrypted/components/EncryptedTextarea.js.map +1 -1
  17. package/dist/fields/encrypted/components/EyeToggle.js +14 -35
  18. package/dist/fields/encrypted/components/EyeToggle.js.map +1 -1
  19. package/dist/fields/encrypted/components/ProtectedField.css +107 -159
  20. package/dist/fields/encrypted/components/ProtectedField.js +6 -2
  21. package/dist/fields/encrypted/components/ProtectedField.js.map +1 -1
  22. package/dist/fields/encrypted/components/RichTextRevealGate.js +3 -3
  23. package/dist/fields/encrypted/components/RichTextRevealGate.js.map +1 -1
  24. package/dist/fields/encrypted/components/WriteOnlyActions.js +58 -53
  25. package/dist/fields/encrypted/components/WriteOnlyActions.js.map +1 -1
  26. package/dist/fields/encrypted/components/WriteOnlyField.js +39 -21
  27. package/dist/fields/encrypted/components/WriteOnlyField.js.map +1 -1
  28. package/dist/fields/encrypted/components/facsimiles.js +70 -79
  29. package/dist/fields/encrypted/components/facsimiles.js.map +1 -1
  30. package/dist/fields/encrypted/components/placement.js.map +1 -1
  31. package/dist/fields/encrypted/encryptedField.js +25 -12
  32. package/dist/fields/encrypted/encryptedField.js.map +1 -1
  33. package/dist/fields/encrypted/{typescriptSchema.js → jsonSchema.js} +4 -4
  34. package/dist/fields/encrypted/jsonSchema.js.map +1 -0
  35. package/dist/fields/encrypted/queryRewrite.js +20 -0
  36. package/dist/fields/encrypted/queryRewrite.js.map +1 -1
  37. package/dist/fields/encrypted/validators.js +1 -1
  38. package/dist/fields/encrypted/validators.js.map +1 -1
  39. package/dist/fields/icon/adapters/tabler/generated/nodes.js +1 -1
  40. package/dist/fields/icon/adapters/tabler/generated/nodes.js.map +1 -1
  41. package/dist/fields/icon/client/IconDrawerContent.js +8 -6
  42. package/dist/fields/icon/client/IconDrawerContent.js.map +1 -1
  43. package/dist/fields/icon/client/IconFieldClient.js +15 -37
  44. package/dist/fields/icon/client/IconFieldClient.js.map +1 -1
  45. package/dist/fields/icon/client/icon-field.css +137 -233
  46. package/dist/fields/icon/codegen/sources/tabler.js +25 -6
  47. package/dist/fields/icon/codegen/sources/tabler.js.map +1 -1
  48. package/dist/fields/icon/layers/upload.js +3 -0
  49. package/dist/fields/icon/layers/upload.js.map +1 -1
  50. package/dist/fields/icon/react/createIcon.js +4 -4
  51. package/dist/fields/icon/react/createIcon.js.map +1 -1
  52. package/dist/fields/measurement/client/MeasurementInput.js +18 -32
  53. package/dist/fields/measurement/client/MeasurementInput.js.map +1 -1
  54. package/dist/fields/measurement/client/editModel.js +12 -3
  55. package/dist/fields/measurement/client/editModel.js.map +1 -1
  56. package/dist/fields/measurement/client/measurementField.css +58 -105
  57. package/dist/fields/measurement/server/getUserUnits.js +2 -1
  58. package/dist/fields/measurement/server/getUserUnits.js.map +1 -1
  59. package/dist/fields/phoneNumber/client/CountryPicker.js +14 -9
  60. package/dist/fields/phoneNumber/client/CountryPicker.js.map +1 -1
  61. package/dist/fields/phoneNumber/client/PhoneNumberField.d.ts +1 -1
  62. package/dist/fields/phoneNumber/client/PhoneNumberField.js +22 -4
  63. package/dist/fields/phoneNumber/client/PhoneNumberField.js.map +1 -1
  64. package/dist/fields/phoneNumber/client/phoneNumberField.css +109 -142
  65. package/dist/fields/phoneNumber/phoneNumberField.js +1 -1
  66. package/dist/fields/phoneNumber/phoneNumberField.js.map +1 -1
  67. package/dist/fields/phoneNumber/server/PhoneNumberCellServer.js +2 -1
  68. package/dist/fields/phoneNumber/server/PhoneNumberCellServer.js.map +1 -1
  69. package/dist/index.d.ts +3 -2
  70. package/dist/index.js +5 -4
  71. package/dist/index.js.map +1 -1
  72. package/dist/plugin/companionSelect.d.ts +12 -0
  73. package/dist/plugin/companionSelect.js +107 -0
  74. package/dist/plugin/companionSelect.js.map +1 -0
  75. package/package.json +15 -15
  76. package/dist/fields/encrypted/typescriptSchema.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @10x-media/fields
2
2
 
3
+ ## 4.0.0-alpha.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Measurement: an empty major part next to a typed minor part of a compound unit now reads as zero, so inches typed into an empty `ft in` field (or pounds into an empty `st lb` field) commit on blur. `5` in the inches input saves as `0 ft 5 in` instead of being dropped while the form turned dirty. Clearing the feet of a stored value while its inches are still shown likewise keeps those inches. Clearing both parts still clears the value.
8
+
9
+ ## 4.0.0-alpha.1
10
+
11
+ ### Major Changes
12
+
13
+ - Payload 4 support, on Next.js and TanStack Start. Every field now takes the native Payload 4 input look (row height, `--field-*` tokens, borders and focus states) in light and dark mode. Helper fields the factories add are hidden from list columns and filters through `admin.disabled` instead of `disableListColumn` / `disableListFilter`, and encrypted fields emit `jsonSchema` (Payload 4's name for `typescriptSchema`). Icon-library lookups against an upload collection and the measurement preference read pass `overrideAccess: true`, keeping their Payload 3 behaviour under Payload 4's access-by-default Local API.
14
+
3
15
  ## 0.1.0-beta.9
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -2,11 +2,16 @@
2
2
 
3
3
  # @10x-media/fields
4
4
 
5
- Reusable fields for Payload v3 that look and behave native: a full color picker in a constant-height row, a searchable icon picker over pluggable icon libraries, encrypted fields with key rotation and opt-in exact-match querying, and a unit-aware measurement field. Built from `@payloadcms/ui` primitives on Payload design tokens, indistinguishable from Payload's own fields.
5
+ > [!IMPORTANT]
6
+ > **This is the Payload v4 branch.** It targets Payload `4.0.0-beta` on Next.js and TanStack Start and is released under the `alpha` tag (`pnpm add @10x-media/fields@alpha`). The Payload v3 version lives on [`main`](https://github.com/10x-media/payload-plugins/tree/main/packages/fields) and is released as `latest`.
7
+ >
8
+ > Found a problem with the v4 version? Please [open an issue](https://github.com/10x-media/payload-plugins/issues/new?labels=v4) with the **`v4`** label.
6
9
 
7
- [![npm](https://img.shields.io/npm/v/@10x-media/fields?style=flat-square)](https://www.npmjs.com/package/@10x-media/fields)
10
+ Reusable fields for Payload that look and behave native: a full color picker in a constant-height row, a searchable icon picker over pluggable icon libraries, encrypted fields with key rotation and opt-in exact-match querying, and a unit-aware measurement field. Built from `@payloadcms/ui` primitives on Payload design tokens, indistinguishable from Payload's own fields.
8
11
 
9
- Part of the [@10x-media Payload plugins](https://github.com/10x-media/payload-plugins) collection. In beta: published under the `beta` dist-tag until a stable 1.0.
12
+ [![npm](https://img.shields.io/npm/v/@10x-media/fields/alpha?style=flat-square)](https://www.npmjs.com/package/@10x-media/fields)
13
+
14
+ Part of the [@10x-media Payload plugins](https://github.com/10x-media/payload-plugins) collection. In alpha on this branch: published under the `alpha` dist-tag until Payload 4 is stable.
10
15
 
11
16
  ## Features
12
17
 
@@ -14,7 +19,7 @@ Part of the [@10x-media Payload plugins](https://github.com/10x-media/payload-pl
14
19
  - **Icon field**: drawer browser with search, category rail, and keyboard navigation; Lucide, Radix, and Tabler adapters first-party; `defineIconAdapter()` plus codegen for any other library; per-icon lazy loading so no icon dataset ever enters an eager bundle; client and RSC frontend renderers; library-supplied labels for sets keyed by code; and layered libraries composing a package with a Payload upload collection editors can add to, each layer declaring its own render strategy and caching.
15
20
  - **Encrypted fields**: AES-256-GCM with authenticated field binding, for twelve field types including `richText` and `point`; zero-config keys derived from `PAYLOAD_SECRET` or explicit multi-key config with async providers and online rotation; opt-in blind-index querying (`equals`/`in`/`unique`); masked admin UX with reveal toggle.
16
21
  - **Measurement field**: a plain `number` column storing one canonical unit while each viewer edits and reads in their own preferred unit; eight ready-made presets (body weight, height, distance, mass, length, volume, temperature, speed) or free-form `storageUnit`/`units`/`preferenceKey` for anything else, plus serializable custom units and dimensions; per-bucket preference follows the viewer across devices, falls back through field and plugin defaults to browser-locale detection, then metric; compound entry for feet-and-inches and stone-and-pounds; zero-migration adoption on existing numeric columns.
17
- - **Native by construction**: 40px rows, Payload tokens, full `admin` prop contract, typed translations, function-form `overrides` on every factory.
22
+ - **Native by construction**: native-height rows, Payload tokens, full `admin` prop contract, typed translations, function-form `overrides` on every factory.
18
23
  - **Isolated bundles**: each family behind its own subpath export, isolation asserted on the built output in CI.
19
24
  - **Plugin optional**: every factory works standalone; the `fields()` plugin adds app-wide defaults that per-field options override.
20
25
 
@@ -13,7 +13,7 @@ import { resolveCommitValue } from "../commitValue.js";
13
13
  import { derivePresetChip } from "../presetChip.js";
14
14
  import { flatValue, swatchBackground } from "../schemeValue.js";
15
15
  import { ColorPickerPanel } from "./ColorPickerPanel.js";
16
- import { FieldDescription, FieldError, FieldLabel, Popup, RenderCustomComponent, XIcon, fieldBaseClass } from "@payloadcms/ui";
16
+ import { CircledXIcon, FieldDescription, FieldError, FieldLabel, Popup, RenderCustomComponent, fieldBaseClass } from "@payloadcms/ui";
17
17
  import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
18
18
  import { jsx, jsxs } from "react/jsx-runtime";
19
19
  import "./colorField.css";
@@ -243,6 +243,7 @@ const ColorInput = (props) => {
243
243
  children: [/* @__PURE__ */ jsx(RenderCustomComponent, {
244
244
  CustomComponent: Label,
245
245
  Fallback: /* @__PURE__ */ jsx(FieldLabel, {
246
+ hasRequiredAccessibleState: true,
246
247
  htmlFor: path ? void 0 : inputId,
247
248
  label,
248
249
  localized,
@@ -262,14 +263,21 @@ const ColorInput = (props) => {
262
263
  }),
263
264
  BeforeInput,
264
265
  /* @__PURE__ */ jsxs("div", {
265
- className: `${baseClass}__container`,
266
+ className: [
267
+ "form-input-group",
268
+ `${baseClass}__container`,
269
+ showError && "form-input-group-error"
270
+ ].filter(Boolean).join(" "),
266
271
  children: [
267
272
  isReadOnly ? /* @__PURE__ */ jsx("span", {
268
273
  className: `${baseClass}__swatch-button ${baseClass}__swatch-button--static`,
269
274
  children: swatch
270
275
  }) : /* @__PURE__ */ jsx(Popup, {
271
- button: swatch,
272
- buttonClassName: `${baseClass}__swatch-button`,
276
+ button: /* @__PURE__ */ jsx("button", {
277
+ className: `${baseClass}__swatch-button`,
278
+ type: "button",
279
+ children: swatch
280
+ }),
273
281
  buttonType: "custom",
274
282
  caret: false,
275
283
  className: `${baseClass}__popup`,
@@ -296,6 +304,7 @@ const ColorInput = (props) => {
296
304
  setDisplayFormat
297
305
  }),
298
306
  size: "fit-content",
307
+ theme: "auto",
299
308
  verticalAlign: "bottom"
300
309
  }),
301
310
  /* @__PURE__ */ jsxs("div", {
@@ -326,7 +335,9 @@ const ColorInput = (props) => {
326
335
  ]
327
336
  }) : null,
328
337
  /* @__PURE__ */ jsx("input", {
329
- className: `${baseClass}__input`,
338
+ "aria-invalid": showError || void 0,
339
+ "aria-required": required || void 0,
340
+ className: `form-input ${baseClass}__input`,
330
341
  id: inputId,
331
342
  name: path,
332
343
  onBlur: onTextBlur,
@@ -352,7 +363,7 @@ const ColorInput = (props) => {
352
363
  setValue(null);
353
364
  },
354
365
  type: "button",
355
- children: /* @__PURE__ */ jsx(XIcon, {})
366
+ children: /* @__PURE__ */ jsx(CircledXIcon, { size: 24 })
356
367
  }) : null
357
368
  ]
358
369
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"ColorInput.js","names":["useTranslation"],"sources":["../../../../src/fields/color/client/ColorInput.tsx"],"sourcesContent":["'use client'\nimport {\n\tFieldDescription,\n\tFieldError,\n\tFieldLabel,\n\tfieldBaseClass,\n\tPopup,\n\tRenderCustomComponent,\n\tXIcon,\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 type { ColorFormat } from '../../../types'\nimport { resolveCommitValue } from '../commitValue'\nimport {\n\tformatColor,\n\tisColorSchemeValue,\n\tparseColor,\n\trgbToHsv,\n\tsalvageColor,\n\ttoRgb,\n} from '../engine'\nimport { type ColorFieldClientOptions, PRESET_PREFIX, type ResolvedColorPreset } from '../options'\nimport { derivePresetChip } from '../presetChip'\nimport {\n\tapplyReferenceAlpha,\n\tformatPresetReference,\n\tparsePresetReference,\n\tpresetReferenceParts,\n} from '../presetReference'\nimport { flatValue, swatchBackground } from '../schemeValue'\nimport { colorValueIssue } from '../valueIssue'\nimport { ColorPickerPanel, type Hsva } from './ColorPickerPanel'\nimport './colorField.css'\n\nconst baseClass = 'fields-color'\n\nconst DEFAULT_OPTIONS: ColorFieldClientOptions = {\n\talpha: true,\n\tenableEyedropper: true,\n\tformat: 'hex',\n\tisClearable: true,\n\tlinked: false,\n\tlinkedFallback: null,\n}\n\nconst NO_PRESETS: ResolvedColorPreset[] = []\n\n/**\n * Props for the form-free color input. `value` and `onChange` carry the stored string\n * exactly as `colorField` would persist it: normalized to `options.format` on commit,\n * or a `preset:<key>` reference when `options.linked` is on.\n */\nexport type ColorInputProps = {\n\tvalue: null | string | undefined\n\t/** Fires at commit boundaries (debounced typing, blur, picker, preset, clear), never per keystroke. */\n\tonChange: (value: null | string) => void\n\t/** Any option left out takes `colorField`'s default (hex, alpha on, clearable, eyedropper, unlinked). */\n\toptions?: Partial<ColorFieldClientOptions>\n\t/** Already resolved presets; labels are plain strings in the viewer's language. */\n\tpresets?: ResolvedColorPreset[]\n\tpresetsLabel?: string\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/**\n\t * Message shown in the error tooltip. Left unset, the input reports its own\n\t * malformed-color and missing-preset errors.\n\t */\n\terror?: string\n\t/** Forces the error state on or off. Left unset, it follows `error` and the input's own 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\n/**\n * The color field's row, picker, preset chip and commit pipeline with no form behind\n * it, for custom admin views and components. `ColorField` is this plus `useField`.\n */\nexport const ColorInput: React.FC<ColorInputProps> = (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\tonChange,\n\t\toptions,\n\t\tpath,\n\t\tplaceholder,\n\t\tpresets: resolvedPresets = NO_PRESETS,\n\t\tpresetsLabel,\n\t\treadOnly,\n\t\trequired,\n\t\tshowError: showErrorFromProps,\n\t\tstyle,\n\t\tvalue,\n\t} = props\n\tconst { alpha, enableEyedropper, format, isClearable, linked, linkedFallback } = {\n\t\t...DEFAULT_OPTIONS,\n\t\t...options,\n\t}\n\tconst { t } = useTranslation()\n\tconst isReadOnly = Boolean(readOnly)\n\n\tconst stringValue = typeof value === 'string' ? value : ''\n\tconst ownIssue =\n\t\tshowErrorFromProps === undefined && error === undefined\n\t\t\t? colorValueIssue(stringValue, { linked, presets: resolvedPresets })\n\t\t\t: null\n\tconst errorMessage = error ?? (ownIssue ? t(keys[ownIssue]) : undefined)\n\tconst showError = showErrorFromProps ?? errorMessage !== undefined\n\n\tconst reference = linked ? parsePresetReference(stringValue) : null\n\tconst presetKey = reference?.key ?? null\n\t// With alpha disabled a stored suffix still parses, but renders at full\n\t// opacity so the field matches server resolution until commit strips it\n\tconst referenceAlpha = alpha ? (reference?.alpha ?? 100) : 100\n\tconst activePreset =\n\t\tpresetKey !== null ? resolvedPresets.find((preset) => preset.key === presetKey) : undefined\n\tconst presetMissing = presetKey !== null && !activePreset\n\tconst rawValue: unknown =\n\t\tpresetKey !== null ? (activePreset?.value ?? linkedFallback) : stringValue || null\n\tconst cssValue = flatValue(rawValue)\n\tconst parsed = useMemo(() => (cssValue ? parseColor(cssValue) : null), [cssValue])\n\n\tconst [displayFormat, setDisplayFormat] = useState<ColorFormat>(format)\n\tconst displayValue = useMemo(() => {\n\t\tif (presetKey !== null || !parsed || displayFormat === format) return stringValue\n\t\treturn formatColor(parsed, displayFormat, { alpha })\n\t}, [alpha, displayFormat, format, parsed, presetKey, stringValue])\n\n\tconst [draft, setDraft] = useState(displayValue)\n\tconst editingRef = useRef(false)\n\tuseEffect(() => {\n\t\tif (!editingRef.current) setDraft(displayValue)\n\t}, [displayValue])\n\n\t// Typing dismisses the chip into plain text entry; blur re-derives it from the committed value\n\tconst [chipDismissed, setChipDismissed] = useState(false)\n\tconst chip = useMemo(\n\t\t() =>\n\t\t\tderivePresetChip({\n\t\t\t\tediting: chipDismissed,\n\t\t\t\tlinked,\n\t\t\t\tpresets: resolvedPresets,\n\t\t\t\tvalue: stringValue,\n\t\t\t}),\n\t\t[chipDismissed, linked, resolvedPresets, stringValue]\n\t)\n\n\tconst debounceRef = useRef<null | ReturnType<typeof setTimeout>>(null)\n\tuseEffect(\n\t\t() => () => {\n\t\t\tif (debounceRef.current) clearTimeout(debounceRef.current)\n\t\t},\n\t\t[]\n\t)\n\n\t// The commit callbacks below read onChange through a ref, so a caller passing an\n\t// inline arrow does not re-create them (and with them the debounce) every render\n\tconst onChangeRef = useRef(onChange)\n\tonChangeRef.current = onChange\n\tconst setValue = useCallback((next: null | string) => onChangeRef.current(next), [])\n\n\t// Revert target for non-clearable commits; tracked from committed values so\n\t// picker commits, preset picks, and the initially loaded value all count\n\tconst lastValidRef = useRef<null | string>(null)\n\tuseEffect(() => {\n\t\tif (stringValue === '') return\n\t\tif (presetKey ? true : parseColor(stringValue) !== null) lastValidRef.current = stringValue\n\t}, [presetKey, stringValue])\n\n\t// Commits without touching editingRef: the debounced path must not let the draft resync mid-typing.\n\t// Returns true when a non-clearable empty or unparseable draft was reverted to the last valid value.\n\tconst commitText = useCallback(\n\t\t(raw: string): boolean => {\n\t\t\tlet normalized: null | string = null\n\t\t\tif (linked && raw.startsWith(PRESET_PREFIX)) {\n\t\t\t\tconst parts = presetReferenceParts(raw)\n\t\t\t\t// Canonical form: /100 collapses to the bare reference, and a disabled\n\t\t\t\t// alpha channel strips any hand-typed suffix. Empty keys commit raw so\n\t\t\t\t// validation surfaces the missing-preset error.\n\t\t\t\tif (parts) normalized = formatPresetReference(parts.key, alpha ? parts.alpha : 100)\n\t\t\t\telse if (raw.length > PRESET_PREFIX.length) normalized = raw\n\t\t\t} else {\n\t\t\t\tconst parsedRaw = parseColor(raw)\n\t\t\t\t// Unparseable input commits raw so validation surfaces the error\n\t\t\t\tif (parsedRaw) normalized = formatColor(parsedRaw, format, { alpha })\n\t\t\t}\n\t\t\tconst resolution = resolveCommitValue({\n\t\t\t\tdraft: raw,\n\t\t\t\tisClearable,\n\t\t\t\tlastValid: lastValidRef.current,\n\t\t\t\tparsed: normalized,\n\t\t\t})\n\t\t\tlastValidRef.current = resolution.lastValid\n\t\t\tsetValue(resolution.value)\n\t\t\treturn resolution.reverted\n\t\t},\n\t\t[alpha, format, isClearable, linked, setValue]\n\t)\n\n\tconst onTextChange = useCallback(\n\t\t(event: React.ChangeEvent<HTMLInputElement>) => {\n\t\t\tconst raw = event.target.value\n\t\t\teditingRef.current = true\n\t\t\tsetChipDismissed(true)\n\t\t\tsetDraft(raw)\n\t\t\tif (debounceRef.current) clearTimeout(debounceRef.current)\n\t\t\tdebounceRef.current = setTimeout(() => commitText(raw), 250)\n\t\t},\n\t\t[commitText]\n\t)\n\n\tconst onTextBlur = useCallback(() => {\n\t\tif (debounceRef.current) {\n\t\t\tclearTimeout(debounceRef.current)\n\t\t\tdebounceRef.current = null\n\t\t}\n\t\tif (editingRef.current) {\n\t\t\teditingRef.current = false\n\t\t\t// Blur-only salvage: recover the first valid color from dirty input\n\t\t\t// (double pastes, stray junk) before the normal commit pipeline\n\t\t\tconst isPresetDraft = linked && draft.startsWith(PRESET_PREFIX)\n\t\t\tconst salvaged =\n\t\t\t\t!isPresetDraft && draft.trim() !== '' && !parseColor(draft) ? salvageColor(draft) : null\n\t\t\tif (commitText(salvaged ?? draft)) {\n\t\t\t\t// A reverted commit usually leaves the value unchanged, so the\n\t\t\t\t// displayValue resync effect never fires; restore the draft here\n\t\t\t\tsetDraft(displayValue)\n\t\t\t} else if (salvaged !== null) {\n\t\t\t\t// A salvaged commit can store the same value as before (double paste of\n\t\t\t\t// the current color), which also skips the resync; clean the draft here\n\t\t\t\tconst parsedSalvaged = parseColor(salvaged)\n\t\t\t\tsetDraft(parsedSalvaged ? formatColor(parsedSalvaged, displayFormat, { alpha }) : salvaged)\n\t\t\t}\n\t\t}\n\t\tsetChipDismissed(false)\n\t}, [alpha, commitText, displayFormat, displayValue, draft, linked])\n\n\t// Backspace/Delete on the empty chip input never fires a change event, so clear here\n\tconst onTextKeyDown = useCallback(\n\t\t(event: React.KeyboardEvent<HTMLInputElement>) => {\n\t\t\tif (!chip || isReadOnly) return\n\t\t\tif (event.key === 'Backspace' || event.key === 'Delete') {\n\t\t\t\tevent.preventDefault()\n\t\t\t\tsetDraft('')\n\t\t\t\tif (isClearable) {\n\t\t\t\t\tsetValue(null)\n\t\t\t\t} else {\n\t\t\t\t\t// Keep the stored ref; the emptied draft reverts or gets replaced at commit\n\t\t\t\t\teditingRef.current = true\n\t\t\t\t\tsetChipDismissed(true)\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[chip, isClearable, isReadOnly, setValue]\n\t)\n\n\tconst commitCss = useCallback(\n\t\t(css: string) => {\n\t\t\tconst parsedCss = parseColor(css)\n\t\t\tif (parsedCss) setValue(formatColor(parsedCss, format, { alpha }))\n\t\t},\n\t\t[alpha, format, setValue]\n\t)\n\n\t// With a reference active the slider represents the reference alpha, not the\n\t// resolved color's own channel, so returning it to 100 restores the bare ref\n\tconst initialHsva = useMemo<Hsva | null>(() => {\n\t\tif (!parsed) return null\n\t\tconst rgb = toRgb(parsed)\n\t\tconst hsv = rgbToHsv(rgb)\n\t\treturn {\n\t\t\ta: presetKey !== null ? referenceAlpha / 100 : rgb.alpha,\n\t\t\th: hsv.h,\n\t\t\ts: hsv.s,\n\t\t\tv: hsv.v,\n\t\t}\n\t}, [parsed, presetKey, referenceAlpha])\n\n\tconst commitReferenceAlpha = useCallback(\n\t\t(alpha100: number) => {\n\t\t\tif (presetKey === null) return\n\t\t\tsetValue(formatPresetReference(presetKey, alpha100))\n\t\t},\n\t\t[presetKey, setValue]\n\t)\n\n\t// The fade must track real overflow, not chip presence: the badge always hugs\n\t// the content run's right edge (the input's flex-grow pushes it there), so an\n\t// unconditional mask would fade it even in a full-width field with room to spare\n\tconst contentRef = useRef<HTMLDivElement>(null)\n\tconst [contentClipped, setContentClipped] = useState(false)\n\tconst measureClip = useCallback(() => {\n\t\tconst el = contentRef.current\n\t\t// +1 absorbs subpixel rounding between scrollWidth (int) and clientWidth\n\t\tif (el) setContentClipped(el.scrollWidth > el.clientWidth + 1)\n\t}, [])\n\t// No dependency array on purpose: chip mount and label changes alter\n\t// scrollWidth without resizing the observed box, so re-measure every render\n\tuseEffect(measureClip)\n\tuseEffect(() => {\n\t\tconst el = contentRef.current\n\t\tif (!el) return\n\t\tconst observer = new ResizeObserver(measureClip)\n\t\tobserver.observe(el)\n\t\treturn () => observer.disconnect()\n\t}, [measureClip])\n\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 swatchValue =\n\t\treferenceAlpha !== 100 && (typeof rawValue === 'string' || isColorSchemeValue(rawValue))\n\t\t\t? applyReferenceAlpha(rawValue, referenceAlpha, 'rgb')\n\t\t\t: rawValue\n\tconst swatchCss = swatchBackground(swatchValue)\n\n\tconst swatch = (\n\t\t<span className={`${baseClass}__swatch ${baseClass}__checker`}>\n\t\t\t{swatchCss ? (\n\t\t\t\t<span className={`${baseClass}__swatch-color`} style={{ background: swatchCss }} />\n\t\t\t) : null}\n\t\t\t{presetMissing && !swatchCss ? (\n\t\t\t\t<span className={`${baseClass}__swatch-color`} data-missing=\"true\" />\n\t\t\t) : null}\n\t\t\t{isReadOnly ? null : <span className={`${baseClass}__sr-only`}>{t(keys.pickColor)}</span>}\n\t\t</span>\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<div className={`${baseClass}__container`}>\n\t\t\t\t\t{isReadOnly ? (\n\t\t\t\t\t\t<span className={`${baseClass}__swatch-button ${baseClass}__swatch-button--static`}>\n\t\t\t\t\t\t\t{swatch}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<Popup\n\t\t\t\t\t\t\tbutton={swatch}\n\t\t\t\t\t\t\tbuttonClassName={`${baseClass}__swatch-button`}\n\t\t\t\t\t\t\tbuttonType=\"custom\"\n\t\t\t\t\t\t\tcaret={false}\n\t\t\t\t\t\t\tclassName={`${baseClass}__popup`}\n\t\t\t\t\t\t\thorizontalAlign=\"left\"\n\t\t\t\t\t\t\trender={({ close }) => (\n\t\t\t\t\t\t\t\t<ColorPickerPanel\n\t\t\t\t\t\t\t\t\tactiveReference={reference}\n\t\t\t\t\t\t\t\t\talphaEnabled={alpha}\n\t\t\t\t\t\t\t\t\tclose={close}\n\t\t\t\t\t\t\t\t\tdisplayFormat={displayFormat}\n\t\t\t\t\t\t\t\t\tenableEyedropper={enableEyedropper}\n\t\t\t\t\t\t\t\t\tinitial={initialHsva}\n\t\t\t\t\t\t\t\t\tonPickAlpha={commitReferenceAlpha}\n\t\t\t\t\t\t\t\t\tonPickCss={commitCss}\n\t\t\t\t\t\t\t\t\tonPickPreset={(preset) => {\n\t\t\t\t\t\t\t\t\t\tif (linked) setValue(`${PRESET_PREFIX}${preset.key}`)\n\t\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\t\t// A text column holds one color, so a scheme preset stores its light member\n\t\t\t\t\t\t\t\t\t\t\tconst flat = flatValue(preset.value)\n\t\t\t\t\t\t\t\t\t\t\tif (flat) commitCss(flat)\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tpresetMissing={presetMissing}\n\t\t\t\t\t\t\t\t\tpresets={resolvedPresets}\n\t\t\t\t\t\t\t\t\tpresetsLabel={presetsLabel ?? t(keys.presets)}\n\t\t\t\t\t\t\t\t\tsetDisplayFormat={setDisplayFormat}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\tsize=\"fit-content\"\n\t\t\t\t\t\t\tverticalAlign=\"bottom\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={[`${baseClass}__content`, contentClipped && `${baseClass}__content--fade`]\n\t\t\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t\t\t.join(' ')}\n\t\t\t\t\t\tref={contentRef}\n\t\t\t\t\t>\n\t\t\t\t\t\t{chip ? (\n\t\t\t\t\t\t\t<span className={`${baseClass}__chip`}>\n\t\t\t\t\t\t\t\t<span className={`${baseClass}__chip-swatch ${baseClass}__checker`}>\n\t\t\t\t\t\t\t\t\t{swatchCss ? (\n\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\tclassName={`${baseClass}__chip-color`}\n\t\t\t\t\t\t\t\t\t\t\tstyle={{ background: swatchCss }}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t{chip.missing && !swatchCss ? (\n\t\t\t\t\t\t\t\t\t\t<span className={`${baseClass}__chip-color`} data-missing=\"true\" />\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t<span className={`${baseClass}__chip-label`}>{chip.label}</span>\n\t\t\t\t\t\t\t\t{alpha && chip.alpha !== 100 ? (\n\t\t\t\t\t\t\t\t\t<span className={`${baseClass}__chip-alpha`}>{chip.alpha}%</span>\n\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tclassName={`${baseClass}__input`}\n\t\t\t\t\t\t\tid={inputId}\n\t\t\t\t\t\t\tname={path}\n\t\t\t\t\t\t\tonBlur={onTextBlur}\n\t\t\t\t\t\t\tonChange={onTextChange}\n\t\t\t\t\t\t\tonKeyDown={onTextKeyDown}\n\t\t\t\t\t\t\tplaceholder={chip ? undefined : placeholder}\n\t\t\t\t\t\t\treadOnly={isReadOnly}\n\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\tvalue={chip ? '' : draft}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<span aria-hidden=\"true\" className={`${baseClass}__badge`}>\n\t\t\t\t\t\t\t{chip ? t(keys.preset) : displayFormat}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t{isClearable && !required && !isReadOnly && stringValue !== '' ? (\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\taria-label={t(keys.clearColor)}\n\t\t\t\t\t\t\tclassName={`${baseClass}__clear`}\n\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\tsetDraft('')\n\t\t\t\t\t\t\t\tsetValue(null)\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<XIcon />\n\t\t\t\t\t\t</button>\n\t\t\t\t\t) : null}\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,YAAY;AAElB,MAAM,kBAA2C;CAChD,OAAO;CACP,kBAAkB;CAClB,QAAQ;CACR,aAAa;CACb,QAAQ;CACR,gBAAgB;AACjB;AAEA,MAAM,aAAoC,CAAC;;;;;AA4C3C,MAAa,cAAyC,UAAU;CAC/D,MAAM,EACL,YACA,aACA,WACA,aACA,aACA,OAAO,gBACP,OACA,OACA,OACA,WACA,UACA,SACA,MACA,aACA,SAAS,kBAAkB,YAC3B,cACA,UACA,UACA,WA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client/ColorInput.tsx"],"sourcesContent":["'use client'\nimport {\n\tCircledXIcon,\n\tFieldDescription,\n\tFieldError,\n\tFieldLabel,\n\tfieldBaseClass,\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 type { ColorFormat } from '../../../types'\nimport { resolveCommitValue } from '../commitValue'\nimport {\n\tformatColor,\n\tisColorSchemeValue,\n\tparseColor,\n\trgbToHsv,\n\tsalvageColor,\n\ttoRgb,\n} from '../engine'\nimport { type ColorFieldClientOptions, PRESET_PREFIX, type ResolvedColorPreset } from '../options'\nimport { derivePresetChip } from '../presetChip'\nimport {\n\tapplyReferenceAlpha,\n\tformatPresetReference,\n\tparsePresetReference,\n\tpresetReferenceParts,\n} from '../presetReference'\nimport { flatValue, swatchBackground } from '../schemeValue'\nimport { colorValueIssue } from '../valueIssue'\nimport { ColorPickerPanel, type Hsva } from './ColorPickerPanel'\nimport './colorField.css'\n\nconst baseClass = 'fields-color'\n\nconst DEFAULT_OPTIONS: ColorFieldClientOptions = {\n\talpha: true,\n\tenableEyedropper: true,\n\tformat: 'hex',\n\tisClearable: true,\n\tlinked: false,\n\tlinkedFallback: null,\n}\n\nconst NO_PRESETS: ResolvedColorPreset[] = []\n\n/**\n * Props for the form-free color input. `value` and `onChange` carry the stored string\n * exactly as `colorField` would persist it: normalized to `options.format` on commit,\n * or a `preset:<key>` reference when `options.linked` is on.\n */\nexport type ColorInputProps = {\n\tvalue: null | string | undefined\n\t/** Fires at commit boundaries (debounced typing, blur, picker, preset, clear), never per keystroke. */\n\tonChange: (value: null | string) => void\n\t/** Any option left out takes `colorField`'s default (hex, alpha on, clearable, eyedropper, unlinked). */\n\toptions?: Partial<ColorFieldClientOptions>\n\t/** Already resolved presets; labels are plain strings in the viewer's language. */\n\tpresets?: ResolvedColorPreset[]\n\tpresetsLabel?: string\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/**\n\t * Message shown in the error tooltip. Left unset, the input reports its own\n\t * malformed-color and missing-preset errors.\n\t */\n\terror?: string\n\t/** Forces the error state on or off. Left unset, it follows `error` and the input's own 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\n/**\n * The color field's row, picker, preset chip and commit pipeline with no form behind\n * it, for custom admin views and components. `ColorField` is this plus `useField`.\n */\nexport const ColorInput: React.FC<ColorInputProps> = (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\tonChange,\n\t\toptions,\n\t\tpath,\n\t\tplaceholder,\n\t\tpresets: resolvedPresets = NO_PRESETS,\n\t\tpresetsLabel,\n\t\treadOnly,\n\t\trequired,\n\t\tshowError: showErrorFromProps,\n\t\tstyle,\n\t\tvalue,\n\t} = props\n\tconst { alpha, enableEyedropper, format, isClearable, linked, linkedFallback } = {\n\t\t...DEFAULT_OPTIONS,\n\t\t...options,\n\t}\n\tconst { t } = useTranslation()\n\tconst isReadOnly = Boolean(readOnly)\n\n\tconst stringValue = typeof value === 'string' ? value : ''\n\tconst ownIssue =\n\t\tshowErrorFromProps === undefined && error === undefined\n\t\t\t? colorValueIssue(stringValue, { linked, presets: resolvedPresets })\n\t\t\t: null\n\tconst errorMessage = error ?? (ownIssue ? t(keys[ownIssue]) : undefined)\n\tconst showError = showErrorFromProps ?? errorMessage !== undefined\n\n\tconst reference = linked ? parsePresetReference(stringValue) : null\n\tconst presetKey = reference?.key ?? null\n\t// With alpha disabled a stored suffix still parses, but renders at full\n\t// opacity so the field matches server resolution until commit strips it\n\tconst referenceAlpha = alpha ? (reference?.alpha ?? 100) : 100\n\tconst activePreset =\n\t\tpresetKey !== null ? resolvedPresets.find((preset) => preset.key === presetKey) : undefined\n\tconst presetMissing = presetKey !== null && !activePreset\n\tconst rawValue: unknown =\n\t\tpresetKey !== null ? (activePreset?.value ?? linkedFallback) : stringValue || null\n\tconst cssValue = flatValue(rawValue)\n\tconst parsed = useMemo(() => (cssValue ? parseColor(cssValue) : null), [cssValue])\n\n\tconst [displayFormat, setDisplayFormat] = useState<ColorFormat>(format)\n\tconst displayValue = useMemo(() => {\n\t\tif (presetKey !== null || !parsed || displayFormat === format) return stringValue\n\t\treturn formatColor(parsed, displayFormat, { alpha })\n\t}, [alpha, displayFormat, format, parsed, presetKey, stringValue])\n\n\tconst [draft, setDraft] = useState(displayValue)\n\tconst editingRef = useRef(false)\n\tuseEffect(() => {\n\t\tif (!editingRef.current) setDraft(displayValue)\n\t}, [displayValue])\n\n\t// Typing dismisses the chip into plain text entry; blur re-derives it from the committed value\n\tconst [chipDismissed, setChipDismissed] = useState(false)\n\tconst chip = useMemo(\n\t\t() =>\n\t\t\tderivePresetChip({\n\t\t\t\tediting: chipDismissed,\n\t\t\t\tlinked,\n\t\t\t\tpresets: resolvedPresets,\n\t\t\t\tvalue: stringValue,\n\t\t\t}),\n\t\t[chipDismissed, linked, resolvedPresets, stringValue]\n\t)\n\n\tconst debounceRef = useRef<null | ReturnType<typeof setTimeout>>(null)\n\tuseEffect(\n\t\t() => () => {\n\t\t\tif (debounceRef.current) clearTimeout(debounceRef.current)\n\t\t},\n\t\t[]\n\t)\n\n\t// The commit callbacks below read onChange through a ref, so a caller passing an\n\t// inline arrow does not re-create them (and with them the debounce) every render\n\tconst onChangeRef = useRef(onChange)\n\tonChangeRef.current = onChange\n\tconst setValue = useCallback((next: null | string) => onChangeRef.current(next), [])\n\n\t// Revert target for non-clearable commits; tracked from committed values so\n\t// picker commits, preset picks, and the initially loaded value all count\n\tconst lastValidRef = useRef<null | string>(null)\n\tuseEffect(() => {\n\t\tif (stringValue === '') return\n\t\tif (presetKey ? true : parseColor(stringValue) !== null) lastValidRef.current = stringValue\n\t}, [presetKey, stringValue])\n\n\t// Commits without touching editingRef: the debounced path must not let the draft resync mid-typing.\n\t// Returns true when a non-clearable empty or unparseable draft was reverted to the last valid value.\n\tconst commitText = useCallback(\n\t\t(raw: string): boolean => {\n\t\t\tlet normalized: null | string = null\n\t\t\tif (linked && raw.startsWith(PRESET_PREFIX)) {\n\t\t\t\tconst parts = presetReferenceParts(raw)\n\t\t\t\t// Canonical form: /100 collapses to the bare reference, and a disabled\n\t\t\t\t// alpha channel strips any hand-typed suffix. Empty keys commit raw so\n\t\t\t\t// validation surfaces the missing-preset error.\n\t\t\t\tif (parts) normalized = formatPresetReference(parts.key, alpha ? parts.alpha : 100)\n\t\t\t\telse if (raw.length > PRESET_PREFIX.length) normalized = raw\n\t\t\t} else {\n\t\t\t\tconst parsedRaw = parseColor(raw)\n\t\t\t\t// Unparseable input commits raw so validation surfaces the error\n\t\t\t\tif (parsedRaw) normalized = formatColor(parsedRaw, format, { alpha })\n\t\t\t}\n\t\t\tconst resolution = resolveCommitValue({\n\t\t\t\tdraft: raw,\n\t\t\t\tisClearable,\n\t\t\t\tlastValid: lastValidRef.current,\n\t\t\t\tparsed: normalized,\n\t\t\t})\n\t\t\tlastValidRef.current = resolution.lastValid\n\t\t\tsetValue(resolution.value)\n\t\t\treturn resolution.reverted\n\t\t},\n\t\t[alpha, format, isClearable, linked, setValue]\n\t)\n\n\tconst onTextChange = useCallback(\n\t\t(event: React.ChangeEvent<HTMLInputElement>) => {\n\t\t\tconst raw = event.target.value\n\t\t\teditingRef.current = true\n\t\t\tsetChipDismissed(true)\n\t\t\tsetDraft(raw)\n\t\t\tif (debounceRef.current) clearTimeout(debounceRef.current)\n\t\t\tdebounceRef.current = setTimeout(() => commitText(raw), 250)\n\t\t},\n\t\t[commitText]\n\t)\n\n\tconst onTextBlur = useCallback(() => {\n\t\tif (debounceRef.current) {\n\t\t\tclearTimeout(debounceRef.current)\n\t\t\tdebounceRef.current = null\n\t\t}\n\t\tif (editingRef.current) {\n\t\t\teditingRef.current = false\n\t\t\t// Blur-only salvage: recover the first valid color from dirty input\n\t\t\t// (double pastes, stray junk) before the normal commit pipeline\n\t\t\tconst isPresetDraft = linked && draft.startsWith(PRESET_PREFIX)\n\t\t\tconst salvaged =\n\t\t\t\t!isPresetDraft && draft.trim() !== '' && !parseColor(draft) ? salvageColor(draft) : null\n\t\t\tif (commitText(salvaged ?? draft)) {\n\t\t\t\t// A reverted commit usually leaves the value unchanged, so the\n\t\t\t\t// displayValue resync effect never fires; restore the draft here\n\t\t\t\tsetDraft(displayValue)\n\t\t\t} else if (salvaged !== null) {\n\t\t\t\t// A salvaged commit can store the same value as before (double paste of\n\t\t\t\t// the current color), which also skips the resync; clean the draft here\n\t\t\t\tconst parsedSalvaged = parseColor(salvaged)\n\t\t\t\tsetDraft(parsedSalvaged ? formatColor(parsedSalvaged, displayFormat, { alpha }) : salvaged)\n\t\t\t}\n\t\t}\n\t\tsetChipDismissed(false)\n\t}, [alpha, commitText, displayFormat, displayValue, draft, linked])\n\n\t// Backspace/Delete on the empty chip input never fires a change event, so clear here\n\tconst onTextKeyDown = useCallback(\n\t\t(event: React.KeyboardEvent<HTMLInputElement>) => {\n\t\t\tif (!chip || isReadOnly) return\n\t\t\tif (event.key === 'Backspace' || event.key === 'Delete') {\n\t\t\t\tevent.preventDefault()\n\t\t\t\tsetDraft('')\n\t\t\t\tif (isClearable) {\n\t\t\t\t\tsetValue(null)\n\t\t\t\t} else {\n\t\t\t\t\t// Keep the stored ref; the emptied draft reverts or gets replaced at commit\n\t\t\t\t\teditingRef.current = true\n\t\t\t\t\tsetChipDismissed(true)\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[chip, isClearable, isReadOnly, setValue]\n\t)\n\n\tconst commitCss = useCallback(\n\t\t(css: string) => {\n\t\t\tconst parsedCss = parseColor(css)\n\t\t\tif (parsedCss) setValue(formatColor(parsedCss, format, { alpha }))\n\t\t},\n\t\t[alpha, format, setValue]\n\t)\n\n\t// With a reference active the slider represents the reference alpha, not the\n\t// resolved color's own channel, so returning it to 100 restores the bare ref\n\tconst initialHsva = useMemo<Hsva | null>(() => {\n\t\tif (!parsed) return null\n\t\tconst rgb = toRgb(parsed)\n\t\tconst hsv = rgbToHsv(rgb)\n\t\treturn {\n\t\t\ta: presetKey !== null ? referenceAlpha / 100 : rgb.alpha,\n\t\t\th: hsv.h,\n\t\t\ts: hsv.s,\n\t\t\tv: hsv.v,\n\t\t}\n\t}, [parsed, presetKey, referenceAlpha])\n\n\tconst commitReferenceAlpha = useCallback(\n\t\t(alpha100: number) => {\n\t\t\tif (presetKey === null) return\n\t\t\tsetValue(formatPresetReference(presetKey, alpha100))\n\t\t},\n\t\t[presetKey, setValue]\n\t)\n\n\t// The fade must track real overflow, not chip presence: the badge always hugs\n\t// the content run's right edge (the input's flex-grow pushes it there), so an\n\t// unconditional mask would fade it even in a full-width field with room to spare\n\tconst contentRef = useRef<HTMLDivElement>(null)\n\tconst [contentClipped, setContentClipped] = useState(false)\n\tconst measureClip = useCallback(() => {\n\t\tconst el = contentRef.current\n\t\t// +1 absorbs subpixel rounding between scrollWidth (int) and clientWidth\n\t\tif (el) setContentClipped(el.scrollWidth > el.clientWidth + 1)\n\t}, [])\n\t// No dependency array on purpose: chip mount and label changes alter\n\t// scrollWidth without resizing the observed box, so re-measure every render\n\tuseEffect(measureClip)\n\tuseEffect(() => {\n\t\tconst el = contentRef.current\n\t\tif (!el) return\n\t\tconst observer = new ResizeObserver(measureClip)\n\t\tobserver.observe(el)\n\t\treturn () => observer.disconnect()\n\t}, [measureClip])\n\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 swatchValue =\n\t\treferenceAlpha !== 100 && (typeof rawValue === 'string' || isColorSchemeValue(rawValue))\n\t\t\t? applyReferenceAlpha(rawValue, referenceAlpha, 'rgb')\n\t\t\t: rawValue\n\tconst swatchCss = swatchBackground(swatchValue)\n\n\tconst swatch = (\n\t\t<span className={`${baseClass}__swatch ${baseClass}__checker`}>\n\t\t\t{swatchCss ? (\n\t\t\t\t<span className={`${baseClass}__swatch-color`} style={{ background: swatchCss }} />\n\t\t\t) : null}\n\t\t\t{presetMissing && !swatchCss ? (\n\t\t\t\t<span className={`${baseClass}__swatch-color`} data-missing=\"true\" />\n\t\t\t) : null}\n\t\t\t{isReadOnly ? null : <span className={`${baseClass}__sr-only`}>{t(keys.pickColor)}</span>}\n\t\t</span>\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\thasRequiredAccessibleState\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<div\n\t\t\t\t\tclassName={[\n\t\t\t\t\t\t'form-input-group',\n\t\t\t\t\t\t`${baseClass}__container`,\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>\n\t\t\t\t\t{isReadOnly ? (\n\t\t\t\t\t\t<span className={`${baseClass}__swatch-button ${baseClass}__swatch-button--static`}>\n\t\t\t\t\t\t\t{swatch}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t// @todo Payload 4's Popup pins its panel to the viewport edge once the field scrolls out\n\t\t\t\t\t\t// of view (v3 let it scroll away with the field). Adopt the option if Payload adds one.\n\t\t\t\t\t\t<Popup\n\t\t\t\t\t\t\tbutton={\n\t\t\t\t\t\t\t\t<button className={`${baseClass}__swatch-button`} type=\"button\">\n\t\t\t\t\t\t\t\t\t{swatch}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbuttonType=\"custom\"\n\t\t\t\t\t\t\tcaret={false}\n\t\t\t\t\t\t\tclassName={`${baseClass}__popup`}\n\t\t\t\t\t\t\thorizontalAlign=\"left\"\n\t\t\t\t\t\t\trender={({ close }) => (\n\t\t\t\t\t\t\t\t<ColorPickerPanel\n\t\t\t\t\t\t\t\t\tactiveReference={reference}\n\t\t\t\t\t\t\t\t\talphaEnabled={alpha}\n\t\t\t\t\t\t\t\t\tclose={close}\n\t\t\t\t\t\t\t\t\tdisplayFormat={displayFormat}\n\t\t\t\t\t\t\t\t\tenableEyedropper={enableEyedropper}\n\t\t\t\t\t\t\t\t\tinitial={initialHsva}\n\t\t\t\t\t\t\t\t\tonPickAlpha={commitReferenceAlpha}\n\t\t\t\t\t\t\t\t\tonPickCss={commitCss}\n\t\t\t\t\t\t\t\t\tonPickPreset={(preset) => {\n\t\t\t\t\t\t\t\t\t\tif (linked) setValue(`${PRESET_PREFIX}${preset.key}`)\n\t\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\t\t// A text column holds one color, so a scheme preset stores its light member\n\t\t\t\t\t\t\t\t\t\t\tconst flat = flatValue(preset.value)\n\t\t\t\t\t\t\t\t\t\t\tif (flat) commitCss(flat)\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tpresetMissing={presetMissing}\n\t\t\t\t\t\t\t\t\tpresets={resolvedPresets}\n\t\t\t\t\t\t\t\t\tpresetsLabel={presetsLabel ?? t(keys.presets)}\n\t\t\t\t\t\t\t\t\tsetDisplayFormat={setDisplayFormat}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\tsize=\"fit-content\"\n\t\t\t\t\t\t\ttheme=\"auto\"\n\t\t\t\t\t\t\tverticalAlign=\"bottom\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={[`${baseClass}__content`, contentClipped && `${baseClass}__content--fade`]\n\t\t\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t\t\t.join(' ')}\n\t\t\t\t\t\tref={contentRef}\n\t\t\t\t\t>\n\t\t\t\t\t\t{chip ? (\n\t\t\t\t\t\t\t<span className={`${baseClass}__chip`}>\n\t\t\t\t\t\t\t\t<span className={`${baseClass}__chip-swatch ${baseClass}__checker`}>\n\t\t\t\t\t\t\t\t\t{swatchCss ? (\n\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\tclassName={`${baseClass}__chip-color`}\n\t\t\t\t\t\t\t\t\t\t\tstyle={{ background: swatchCss }}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t{chip.missing && !swatchCss ? (\n\t\t\t\t\t\t\t\t\t\t<span className={`${baseClass}__chip-color`} data-missing=\"true\" />\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t<span className={`${baseClass}__chip-label`}>{chip.label}</span>\n\t\t\t\t\t\t\t\t{alpha && chip.alpha !== 100 ? (\n\t\t\t\t\t\t\t\t\t<span className={`${baseClass}__chip-alpha`}>{chip.alpha}%</span>\n\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\taria-invalid={showError || undefined}\n\t\t\t\t\t\t\taria-required={required || undefined}\n\t\t\t\t\t\t\tclassName={`form-input ${baseClass}__input`}\n\t\t\t\t\t\t\tid={inputId}\n\t\t\t\t\t\t\tname={path}\n\t\t\t\t\t\t\tonBlur={onTextBlur}\n\t\t\t\t\t\t\tonChange={onTextChange}\n\t\t\t\t\t\t\tonKeyDown={onTextKeyDown}\n\t\t\t\t\t\t\tplaceholder={chip ? undefined : placeholder}\n\t\t\t\t\t\t\treadOnly={isReadOnly}\n\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\tvalue={chip ? '' : draft}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<span aria-hidden=\"true\" className={`${baseClass}__badge`}>\n\t\t\t\t\t\t\t{chip ? t(keys.preset) : displayFormat}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t{isClearable && !required && !isReadOnly && stringValue !== '' ? (\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\taria-label={t(keys.clearColor)}\n\t\t\t\t\t\t\tclassName={`${baseClass}__clear`}\n\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\tsetDraft('')\n\t\t\t\t\t\t\t\tsetValue(null)\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<CircledXIcon size={24} />\n\t\t\t\t\t\t</button>\n\t\t\t\t\t) : null}\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,YAAY;AAElB,MAAM,kBAA2C;CAChD,OAAO;CACP,kBAAkB;CAClB,QAAQ;CACR,aAAa;CACb,QAAQ;CACR,gBAAgB;AACjB;AAEA,MAAM,aAAoC,CAAC;;;;;AA4C3C,MAAa,cAAyC,UAAU;CAC/D,MAAM,EACL,YACA,aACA,WACA,aACA,aACA,OAAO,gBACP,OACA,OACA,OACA,WACA,UACA,SACA,MACA,aACA,SAAS,kBAAkB,YAC3B,cACA,UACA,UACA,WAAW,oBACX,OACA,UACG;CACJ,MAAM,EAAE,OAAO,kBAAkB,QAAQ,aAAa,QAAQ,mBAAmB;EAChF,GAAG;EACH,GAAG;CACJ;CACA,MAAM,EAAE,MAAMA,iBAAe;CAC7B,MAAM,aAAa,QAAQ,QAAQ;CAEnC,MAAM,cAAc,OAAO,UAAU,WAAW,QAAQ;CACxD,MAAM,WACL,uBAAuB,KAAA,KAAa,UAAU,KAAA,IAC3C,gBAAgB,aAAa;EAAE;EAAQ,SAAS;CAAgB,CAAC,IACjE;CACJ,MAAM,eAAe,UAAU,WAAW,EAAE,KAAK,SAAS,IAAI,KAAA;CAC9D,MAAM,YAAY,sBAAsB,iBAAiB,KAAA;CAEzD,MAAM,YAAY,SAAS,qBAAqB,WAAW,IAAI;CAC/D,MAAM,YAAY,WAAW,OAAO;CAGpC,MAAM,iBAAiB,QAAS,WAAW,SAAS,MAAO;CAC3D,MAAM,eACL,cAAc,OAAO,gBAAgB,MAAM,WAAW,OAAO,QAAQ,SAAS,IAAI,KAAA;CACnF,MAAM,gBAAgB,cAAc,QAAQ,CAAC;CAC7C,MAAM,WACL,cAAc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C3B,WAAW,cAAc,UAAU;SACnC,IAAI;SACJ,MAAM;SACN,QAAQ;SACR,UAAU;SACV,WAAW;SACX,aAAa,OAAO,KAAA,IAAY;SAChC,UAAU;SACV,MAAK;SACL,OAAO,OAAO,KAAK;QACnB,CAAA;QACD,oBAAC,QAAD;SAAM,eAAY;SAAO,WAAW,GAAG,UAAU;mBAC/C,OAAO,EAAE,KAAK,MAAM,IAAI;QACpB,CAAA;OACF;;MACJ,eAAe,CAAC,YAAY,CAAC,cAAc,gBAAgB,KAC3D,oBAAC,UAAD;OACC,cAAY,EAAE,KAAK,UAAU;OAC7B,WAAW,GAAG,UAAU;OACxB,eAAe;QACd,SAAS,EAAE;QACX,SAAS,IAAI;OACd;OACA,MAAK;iBAEL,oBAAC,cAAD,EAAc,MAAM,GAAK,CAAA;MAClB,CAAA,IACL;KACA;;IACJ;IACD,oBAAC,uBAAD;KACC,iBAAiB;KACjB,UAAU,oBAAC,kBAAD;MAA+B;MAAa,MAAM,QAAQ;KAAK,CAAA;IACzE,CAAA;GACG;IACD;;AAEP"}
@@ -1,10 +1,11 @@
1
1
  "use client";
2
2
  import { keys } from "../../../translations/keys.js";
3
- import { useTranslation } from "../../../translations/useTranslation.js";
3
+ import { useTranslation as useTranslation$1 } from "../../../translations/useTranslation.js";
4
4
  import { hsvToRgb } from "../engine/convert.js";
5
5
  import { formatColor } from "../engine/format.js";
6
6
  import { swatchBackground } from "../schemeValue.js";
7
7
  import { EyedropperIcon } from "./icons.js";
8
+ import { Button } from "@payloadcms/ui";
8
9
  import { useCallback, useEffect, useRef, useState } from "react";
9
10
  import { jsx, jsxs } from "react/jsx-runtime";
10
11
  //#region src/fields/color/client/ColorPickerPanel.tsx
@@ -22,7 +23,7 @@ const getEyeDropper = () => {
22
23
  const clamp01 = (value) => Math.min(1, Math.max(0, value));
23
24
  const ColorPickerPanel = (props) => {
24
25
  const { activeReference, alphaEnabled, close, displayFormat, enableEyedropper, initial, onPickAlpha, onPickCss, onPickPreset, presetMissing, presets, presetsLabel, setDisplayFormat } = props;
25
- const { t } = useTranslation();
26
+ const { t } = useTranslation$1();
26
27
  const [hsva, setHsva] = useState(initial ?? {
27
28
  a: activeReference ? activeReference.alpha / 100 : 1,
28
29
  h: 0,
@@ -124,12 +125,13 @@ const ColorPickerPanel = (props) => {
124
125
  const endDrag = useCallback(() => {
125
126
  draggingRef.current = false;
126
127
  }, []);
128
+ const [eyeDropperSupported, setEyeDropperSupported] = useState(false);
129
+ useEffect(() => setEyeDropperSupported(getEyeDropper() !== null), []);
127
130
  const opaqueCss = formatColor(hsvToRgb({
128
131
  h: hsva.h,
129
132
  s: hsva.s,
130
133
  v: hsva.v
131
134
  }, 1), "rgb");
132
- const eyeDropperCtor = enableEyedropper ? getEyeDropper() : null;
133
135
  return /* @__PURE__ */ jsxs("div", {
134
136
  className: `${baseClass}__panel`,
135
137
  "data-popup-prevent-close": true,
@@ -193,7 +195,7 @@ const ColorPickerPanel = (props) => {
193
195
  onLostPointerCapture: endDrag,
194
196
  step: 1,
195
197
  style: {
196
- backgroundImage: `linear-gradient(to right, transparent, ${opaqueCss}), conic-gradient(var(--theme-elevation-150) 0 25%, transparent 0 50%, var(--theme-elevation-150) 0 75%, transparent 0)`,
198
+ backgroundImage: `linear-gradient(to right, transparent, ${opaqueCss}), conic-gradient(var(--color-bg-tertiary) 0 25%, transparent 0 50%, var(--color-bg-tertiary) 0 75%, transparent 0)`,
197
199
  backgroundSize: "100% 100%, 8px 8px"
198
200
  },
199
201
  type: "range",
@@ -205,21 +207,25 @@ const ColorPickerPanel = (props) => {
205
207
  "aria-label": t(keys.format),
206
208
  className: `${baseClass}__formats`,
207
209
  role: "group",
208
- children: FORMATS.map((entry) => /* @__PURE__ */ jsx("button", {
210
+ children: FORMATS.map((entry) => /* @__PURE__ */ jsx(Button, {
209
211
  "aria-pressed": entry === displayFormat,
212
+ buttonStyle: entry === displayFormat ? "pill" : "ghost",
210
213
  className: `${baseClass}__format`,
214
+ margin: false,
211
215
  onClick: () => setDisplayFormat(entry),
212
- type: "button",
213
- children: entry
216
+ children: entry.toUpperCase()
214
217
  }, entry))
215
- }), eyeDropperCtor ? /* @__PURE__ */ jsx("button", {
218
+ }), enableEyedropper && eyeDropperSupported ? /* @__PURE__ */ jsx(Button, {
216
219
  "aria-label": t(keys.eyedropperPick),
220
+ buttonStyle: "ghost",
217
221
  className: `${baseClass}__eyedropper`,
222
+ icon: /* @__PURE__ */ jsx(EyedropperIcon, {}),
223
+ margin: false,
218
224
  onClick: () => {
219
- new eyeDropperCtor().open().then((result) => onPickCss(result.sRGBHex), () => void 0);
220
- },
221
- type: "button",
222
- children: /* @__PURE__ */ jsx(EyedropperIcon, {})
225
+ const EyeDropper = getEyeDropper();
226
+ if (!EyeDropper) return;
227
+ new EyeDropper().open().then((result) => onPickCss(result.sRGBHex), () => void 0);
228
+ }
223
229
  }) : null]
224
230
  }),
225
231
  presets.length > 0 ? /* @__PURE__ */ jsxs("div", {
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPickerPanel.js","names":[],"sources":["../../../../src/fields/color/client/ColorPickerPanel.tsx"],"sourcesContent":["'use client'\nimport type React from 'react'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { keys } from '../../../translations/keys'\nimport { useTranslation } from '../../../translations/useTranslation'\nimport type { ColorFormat } from '../../../types'\nimport { formatColor, hsvToRgb } from '../engine'\nimport type { ResolvedColorPreset } from '../options'\nimport type { PresetReference } from '../presetReference'\nimport { swatchBackground } from '../schemeValue'\nimport { EyedropperIcon } from './icons'\n\nconst baseClass = 'fields-color'\nconst FORMATS: ColorFormat[] = ['hex', 'rgb', 'hsl', 'oklch']\n\nexport type Hsva = { a: number; h: number; s: number; v: number }\n\ntype EyeDropperConstructor = new () => { open: () => Promise<{ sRGBHex: string }> }\n\nconst getEyeDropper = (): EyeDropperConstructor | null => {\n\tif (typeof window === 'undefined') return null\n\treturn (window as Window & { EyeDropper?: EyeDropperConstructor }).EyeDropper ?? null\n}\n\nconst clamp01 = (value: number): number => Math.min(1, Math.max(0, value))\n\nexport type ColorPickerPanelProps = {\n\t/** The stored preset reference when one is active; alpha edits then keep the reference. */\n\tactiveReference: null | PresetReference\n\talphaEnabled: boolean\n\tclose: () => void\n\tdisplayFormat: ColorFormat\n\tenableEyedropper: boolean\n\tinitial: Hsva | null\n\tonPickAlpha: (alpha: number) => void\n\tonPickCss: (css: string) => void\n\tonPickPreset: (preset: ResolvedColorPreset) => void\n\tpresetMissing: boolean\n\tpresets: ResolvedColorPreset[]\n\tpresetsLabel: string\n\tsetDisplayFormat: (format: ColorFormat) => void\n}\n\nexport const ColorPickerPanel: React.FC<ColorPickerPanelProps> = (props) => {\n\tconst {\n\t\tactiveReference,\n\t\talphaEnabled,\n\t\tclose,\n\t\tdisplayFormat,\n\t\tenableEyedropper,\n\t\tinitial,\n\t\tonPickAlpha,\n\t\tonPickCss,\n\t\tonPickPreset,\n\t\tpresetMissing,\n\t\tpresets,\n\t\tpresetsLabel,\n\t\tsetDisplayFormat,\n\t} = props\n\tconst { t } = useTranslation()\n\n\t// A missing preset resolves no color (initial is null) but its stored alpha\n\t// must still seed the slider so dragging it edits the reference in place\n\tconst [hsva, setHsva] = useState<Hsva>(\n\t\tinitial ?? { a: activeReference ? activeReference.alpha / 100 : 1, h: 0, s: 1, v: 1 }\n\t)\n\tconst hsvaRef = useRef(hsva)\n\thsvaRef.current = hsva\n\tconst draggingRef = useRef(false)\n\tconst svRef = useRef<HTMLDivElement>(null)\n\tconst rafRef = useRef<null | number>(null)\n\tconst pendingRef = useRef<Hsva | null>(null)\n\tconst lastEmittedRef = useRef<null | string>(null)\n\n\tconst initialKey = initial ? `${initial.h}|${initial.s}|${initial.v}|${initial.a}` : ''\n\t// biome-ignore lint/correctness/useExhaustiveDependencies: resync only when the committed color changes, not on every initial object identity change\n\tuseEffect(() => {\n\t\tif (!initial) {\n\t\t\tlastEmittedRef.current = null\n\t\t\treturn\n\t\t}\n\t\tif (draggingRef.current) return\n\t\t// Skip echoes of our own commit: achromatic values round-trip with h/s zeroed and would clobber the local hue/saturation.\n\t\t// Compared opaque (alpha quantizes through hex storage) and one-shot (a stale ref must not suppress a later genuine match)\n\t\tconst incomingCss = formatColor(\n\t\t\thsvToRgb({ h: initial.h, s: initial.s, v: initial.v }, 1),\n\t\t\t'rgb'\n\t\t)\n\t\tconst skip = incomingCss === lastEmittedRef.current\n\t\tlastEmittedRef.current = null\n\t\tif (skip) return\n\t\tsetHsva(initial)\n\t}, [initialKey])\n\n\tconst alphaRafRef = useRef<null | number>(null)\n\tconst pendingAlphaRef = useRef(100)\n\n\tuseEffect(\n\t\t() => () => {\n\t\t\tif (rafRef.current !== null) cancelAnimationFrame(rafRef.current)\n\t\t\tif (alphaRafRef.current !== null) cancelAnimationFrame(alphaRafRef.current)\n\t\t},\n\t\t[]\n\t)\n\n\t// Commits are rAF-throttled: pointermove floods would otherwise dispatch a form update per event\n\tconst commit = useCallback(\n\t\t(next: Hsva) => {\n\t\t\tpendingRef.current = next\n\t\t\tif (rafRef.current !== null) return\n\t\t\trafRef.current = requestAnimationFrame(() => {\n\t\t\t\trafRef.current = null\n\t\t\t\tconst pending = pendingRef.current\n\t\t\t\tif (!pending) return\n\t\t\t\tlastEmittedRef.current = formatColor(\n\t\t\t\t\thsvToRgb({ h: pending.h, s: pending.s, v: pending.v }, 1),\n\t\t\t\t\t'rgb'\n\t\t\t\t)\n\t\t\t\tonPickCss(\n\t\t\t\t\tformatColor(\n\t\t\t\t\t\thsvToRgb({ h: pending.h, s: pending.s, v: pending.v }, alphaEnabled ? pending.a : 1),\n\t\t\t\t\t\t'rgb'\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t})\n\t\t},\n\t\t[alphaEnabled, onPickCss]\n\t)\n\n\tconst applyPartial = useCallback(\n\t\t(patch: Partial<Hsva>) => {\n\t\t\tconst next = { ...hsvaRef.current, ...patch }\n\t\t\tsetHsva(next)\n\t\t\tcommit(next)\n\t\t},\n\t\t[commit]\n\t)\n\n\t// Reference-preserving alpha path: while a preset is active, the slider\n\t// rewrites the stored `/<alpha>` suffix instead of committing a concrete\n\t// color. Same rAF throttling and echo suppression as the concrete path\n\t// (the opaque css is unchanged by alpha, so the resync effect skips it).\n\tconst commitReferenceAlpha = useCallback(\n\t\t(next: Hsva) => {\n\t\t\tsetHsva(next)\n\t\t\tpendingAlphaRef.current = Math.round(next.a * 100)\n\t\t\tif (alphaRafRef.current !== null) return\n\t\t\talphaRafRef.current = requestAnimationFrame(() => {\n\t\t\t\talphaRafRef.current = null\n\t\t\t\tconst current = hsvaRef.current\n\t\t\t\tlastEmittedRef.current = formatColor(\n\t\t\t\t\thsvToRgb({ h: current.h, s: current.s, v: current.v }, 1),\n\t\t\t\t\t'rgb'\n\t\t\t\t)\n\t\t\t\tonPickAlpha(pendingAlphaRef.current)\n\t\t\t})\n\t\t},\n\t\t[onPickAlpha]\n\t)\n\n\tconst svPointer = useCallback(\n\t\t(event: React.PointerEvent<HTMLDivElement>) => {\n\t\t\tconst rect = svRef.current?.getBoundingClientRect()\n\t\t\tif (!rect) return\n\t\t\tapplyPartial({\n\t\t\t\ts: clamp01((event.clientX - rect.left) / rect.width),\n\t\t\t\tv: clamp01(1 - (event.clientY - rect.top) / rect.height),\n\t\t\t})\n\t\t},\n\t\t[applyPartial]\n\t)\n\n\tconst onSvKeyDown = useCallback(\n\t\t(event: React.KeyboardEvent<HTMLDivElement>) => {\n\t\t\tif (!event.key.startsWith('Arrow')) return\n\t\t\t// Popup preventDefaults ArrowUp/ArrowDown at document level for focus cycling; consume first\n\t\t\tevent.stopPropagation()\n\t\t\tevent.preventDefault()\n\t\t\tconst step = event.shiftKey ? 0.1 : 0.01\n\t\t\tconst current = hsvaRef.current\n\t\t\tif (event.key === 'ArrowLeft') applyPartial({ s: clamp01(current.s - step) })\n\t\t\tif (event.key === 'ArrowRight') applyPartial({ s: clamp01(current.s + step) })\n\t\t\tif (event.key === 'ArrowUp') applyPartial({ v: clamp01(current.v + step) })\n\t\t\tif (event.key === 'ArrowDown') applyPartial({ v: clamp01(current.v - step) })\n\t\t},\n\t\t[applyPartial]\n\t)\n\n\t// Without this the Popup's document keydown handler preventDefaults native range stepping\n\tconst stopArrowKeys = useCallback((event: React.KeyboardEvent) => {\n\t\tif (event.key.startsWith('Arrow')) event.stopPropagation()\n\t}, [])\n\n\t// Fires after pointerup AND pointercancel, so an interrupted drag never leaves draggingRef stuck\n\tconst endDrag = useCallback(() => {\n\t\tdraggingRef.current = false\n\t}, [])\n\n\tconst opaqueCss = formatColor(hsvToRgb({ h: hsva.h, s: hsva.s, v: hsva.v }, 1), 'rgb')\n\tconst eyeDropperCtor = enableEyedropper ? getEyeDropper() : null\n\n\treturn (\n\t\t<div className={`${baseClass}__panel`} data-popup-prevent-close>\n\t\t\t<div\n\t\t\t\taria-label={t(keys.saturationBrightness)}\n\t\t\t\taria-valuemax={100}\n\t\t\t\taria-valuemin={0}\n\t\t\t\taria-valuenow={Math.round(hsva.v * 100)}\n\t\t\t\taria-valuetext={`${Math.round(hsva.s * 100)}% / ${Math.round(hsva.v * 100)}%`}\n\t\t\t\tclassName={`${baseClass}__sv`}\n\t\t\t\tonKeyDown={onSvKeyDown}\n\t\t\t\tonPointerDown={(event) => {\n\t\t\t\t\tdraggingRef.current = true\n\t\t\t\t\tevent.currentTarget.setPointerCapture(event.pointerId)\n\t\t\t\t\tsvPointer(event)\n\t\t\t\t}}\n\t\t\t\tonLostPointerCapture={endDrag}\n\t\t\t\tonPointerMove={(event) => {\n\t\t\t\t\tif (draggingRef.current) svPointer(event)\n\t\t\t\t}}\n\t\t\t\tonPointerUp={endDrag}\n\t\t\t\tref={svRef}\n\t\t\t\trole=\"slider\"\n\t\t\t\tstyle={{ backgroundColor: `hsl(${Math.round(hsva.h)} 100% 50%)` }}\n\t\t\t\ttabIndex={0}\n\t\t\t>\n\t\t\t\t<span\n\t\t\t\t\tclassName={`${baseClass}__sv-thumb`}\n\t\t\t\t\tstyle={{ left: `${hsva.s * 100}%`, top: `${(1 - hsva.v) * 100}%` }}\n\t\t\t\t/>\n\t\t\t</div>\n\n\t\t\t<input\n\t\t\t\taria-label={t(keys.hue)}\n\t\t\t\tclassName={`${baseClass}__slider ${baseClass}__slider--hue`}\n\t\t\t\tmax={360}\n\t\t\t\tmin={0}\n\t\t\t\tonChange={(event) => applyPartial({ h: Number(event.target.value) })}\n\t\t\t\tonKeyDown={stopArrowKeys}\n\t\t\t\tonLostPointerCapture={endDrag}\n\t\t\t\tstep={1}\n\t\t\t\ttype=\"range\"\n\t\t\t\tvalue={Math.round(hsva.h)}\n\t\t\t/>\n\n\t\t\t{alphaEnabled ? (\n\t\t\t\t<input\n\t\t\t\t\taria-label={t(keys.opacity)}\n\t\t\t\t\tclassName={`${baseClass}__slider ${baseClass}__slider--alpha`}\n\t\t\t\t\tmax={100}\n\t\t\t\t\tmin={0}\n\t\t\t\t\tonChange={(event) => {\n\t\t\t\t\t\tconst a = Number(event.target.value) / 100\n\t\t\t\t\t\tif (activeReference) commitReferenceAlpha({ ...hsvaRef.current, a })\n\t\t\t\t\t\telse applyPartial({ a })\n\t\t\t\t\t}}\n\t\t\t\t\tonKeyDown={stopArrowKeys}\n\t\t\t\t\tonLostPointerCapture={endDrag}\n\t\t\t\t\tstep={1}\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tbackgroundImage: `linear-gradient(to right, transparent, ${opaqueCss}), conic-gradient(var(--theme-elevation-150) 0 25%, transparent 0 50%, var(--theme-elevation-150) 0 75%, transparent 0)`,\n\t\t\t\t\t\tbackgroundSize: '100% 100%, 8px 8px',\n\t\t\t\t\t}}\n\t\t\t\t\ttype=\"range\"\n\t\t\t\t\tvalue={Math.round(hsva.a * 100)}\n\t\t\t\t/>\n\t\t\t) : null}\n\n\t\t\t<div className={`${baseClass}__controls`}>\n\t\t\t\t{/* biome-ignore lint/a11y/useSemanticElements: fieldset breaks flex layout in Safari; this is a toggle-button group, not a form fieldset */}\n\t\t\t\t<div aria-label={t(keys.format)} className={`${baseClass}__formats`} role=\"group\">\n\t\t\t\t\t{FORMATS.map((entry) => (\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\taria-pressed={entry === displayFormat}\n\t\t\t\t\t\t\tclassName={`${baseClass}__format`}\n\t\t\t\t\t\t\tkey={entry}\n\t\t\t\t\t\t\tonClick={() => setDisplayFormat(entry)}\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{entry}\n\t\t\t\t\t\t</button>\n\t\t\t\t\t))}\n\t\t\t\t</div>\n\t\t\t\t{eyeDropperCtor ? (\n\t\t\t\t\t<button\n\t\t\t\t\t\taria-label={t(keys.eyedropperPick)}\n\t\t\t\t\t\tclassName={`${baseClass}__eyedropper`}\n\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\tvoid new eyeDropperCtor().open().then(\n\t\t\t\t\t\t\t\t(result) => onPickCss(result.sRGBHex),\n\t\t\t\t\t\t\t\t// open() rejects when the user presses Escape; nothing to do\n\t\t\t\t\t\t\t\t() => undefined\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<EyedropperIcon />\n\t\t\t\t\t</button>\n\t\t\t\t) : null}\n\t\t\t</div>\n\n\t\t\t{presets.length > 0 ? (\n\t\t\t\t<div className={`${baseClass}__presets`}>\n\t\t\t\t\t<div className={`${baseClass}__presets-label`}>{presetsLabel}</div>\n\t\t\t\t\t{presetMissing ? (\n\t\t\t\t\t\t<p className={`${baseClass}__missing`}>{t(keys.missingPresetHint)}</p>\n\t\t\t\t\t) : null}\n\t\t\t\t\t<div className={`${baseClass}__presets-grid`}>\n\t\t\t\t\t\t{presets.map((preset) => (\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\taria-label={preset.label}\n\t\t\t\t\t\t\t\taria-pressed={preset.key === activeReference?.key}\n\t\t\t\t\t\t\t\tclassName={`${baseClass}__preset ${baseClass}__checker`}\n\t\t\t\t\t\t\t\tkey={preset.key}\n\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\tonPickPreset(preset)\n\t\t\t\t\t\t\t\t\tclose()\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\ttitle={preset.label}\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<span style={{ background: swatchBackground(preset.value) ?? undefined }} />\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;;;;;;;AAYA,MAAM,YAAY;AAClB,MAAM,UAAyB;CAAC;CAAO;CAAO;CAAO;AAAO;AAM5D,MAAM,sBAAoD;CACzD,IAAI,OAAO,WAAW,aAAa,OAAO;CAC1C,OAAQ,OAA2D,cAAc;AAClF;AAEA,MAAM,WAAW,UAA0B,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC;AAmBzE,MAAa,oBAAqD,UAAU;CAC3E,MAAM,EACL,iBACA,cACA,OACA,eACA,kBACA,SACA,aACA,WACA,cACA,eACA,SACA,cACA,qBACG;CACJ,MAAM,EAAE,MAAM,eAAe;CAI7B,MAAM,CAAC,MAAM,WAAW,SACvB,WAAW;EAAE,GAAG,kBAAkB,gBAAgB,QAAQ,MAAM;EAAG,GAAG;EAAG,GAAG;EAAG,GAAG;CAAE,CACrF;CACA,MAAM,UAAU,OAAO,IAAI;CAC3B,QAAQ,UAAU;CAClB,MAAM,cAAc,OAAO,KAAK;CAChC,MAAM,QAAQ,OAAuB,IAAI;CACzC,MAAM,SAAS,OAAsB,IAAI;CACzC,MAAM,aAAa,OAAoB,IAAI;CAC3C,MAAM,iBAAiB,OAAsB,IAAI;CAIjD,gBAAgB;EACf,IAAI,CAAC,SAAS;GACb,eAAe,UAAU;GACzB;EACD;EACA,IAAI,YAAY,SAAS;EAOz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KACJ,oBAAC,OAAD;MAAK,WAAW,GAAG,UAAU;gBAC3B,QAAQ,KAAK,WACb,oBAAC,UAAD;OACC,cAAY,OAAO;OACnB,gBAAc,OAAO,QAAQ,iBAAiB;OAC9C,WAAW,GAAG,UAAU,WAAW,UAAU;OAE7C,eAAe;QACd,aAAa,MAAM;QACnB,MAAM;OACP;OACA,OAAO,OAAO;OACd,MAAK;iBAEL,oBAAC,QAAD,EAAM,OAAO,EAAE,YAAY,iBAAiB,OAAO,KAAK,KAAK,KAAA,EAAU,EAAI,CAAA;MACpE,GATF,OAAO,GASL,CACR;KACG,CAAA;IACD;QACF;EACA;;AAEP"}
1
+ {"version":3,"file":"ColorPickerPanel.js","names":["useTranslation"],"sources":["../../../../src/fields/color/client/ColorPickerPanel.tsx"],"sourcesContent":["'use client'\nimport { Button } from '@payloadcms/ui'\nimport type React from 'react'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { keys } from '../../../translations/keys'\nimport { useTranslation } from '../../../translations/useTranslation'\nimport type { ColorFormat } from '../../../types'\nimport { formatColor, hsvToRgb } from '../engine'\nimport type { ResolvedColorPreset } from '../options'\nimport type { PresetReference } from '../presetReference'\nimport { swatchBackground } from '../schemeValue'\nimport { EyedropperIcon } from './icons'\n\nconst baseClass = 'fields-color'\nconst FORMATS: ColorFormat[] = ['hex', 'rgb', 'hsl', 'oklch']\n\nexport type Hsva = { a: number; h: number; s: number; v: number }\n\ntype EyeDropperConstructor = new () => { open: () => Promise<{ sRGBHex: string }> }\n\nconst getEyeDropper = (): EyeDropperConstructor | null => {\n\tif (typeof window === 'undefined') return null\n\treturn (window as Window & { EyeDropper?: EyeDropperConstructor }).EyeDropper ?? null\n}\n\nconst clamp01 = (value: number): number => Math.min(1, Math.max(0, value))\n\nexport type ColorPickerPanelProps = {\n\t/** The stored preset reference when one is active; alpha edits then keep the reference. */\n\tactiveReference: null | PresetReference\n\talphaEnabled: boolean\n\tclose: () => void\n\tdisplayFormat: ColorFormat\n\tenableEyedropper: boolean\n\tinitial: Hsva | null\n\tonPickAlpha: (alpha: number) => void\n\tonPickCss: (css: string) => void\n\tonPickPreset: (preset: ResolvedColorPreset) => void\n\tpresetMissing: boolean\n\tpresets: ResolvedColorPreset[]\n\tpresetsLabel: string\n\tsetDisplayFormat: (format: ColorFormat) => void\n}\n\nexport const ColorPickerPanel: React.FC<ColorPickerPanelProps> = (props) => {\n\tconst {\n\t\tactiveReference,\n\t\talphaEnabled,\n\t\tclose,\n\t\tdisplayFormat,\n\t\tenableEyedropper,\n\t\tinitial,\n\t\tonPickAlpha,\n\t\tonPickCss,\n\t\tonPickPreset,\n\t\tpresetMissing,\n\t\tpresets,\n\t\tpresetsLabel,\n\t\tsetDisplayFormat,\n\t} = props\n\tconst { t } = useTranslation()\n\n\t// A missing preset resolves no color (initial is null) but its stored alpha\n\t// must still seed the slider so dragging it edits the reference in place\n\tconst [hsva, setHsva] = useState<Hsva>(\n\t\tinitial ?? { a: activeReference ? activeReference.alpha / 100 : 1, h: 0, s: 1, v: 1 }\n\t)\n\tconst hsvaRef = useRef(hsva)\n\thsvaRef.current = hsva\n\tconst draggingRef = useRef(false)\n\tconst svRef = useRef<HTMLDivElement>(null)\n\tconst rafRef = useRef<null | number>(null)\n\tconst pendingRef = useRef<Hsva | null>(null)\n\tconst lastEmittedRef = useRef<null | string>(null)\n\n\tconst initialKey = initial ? `${initial.h}|${initial.s}|${initial.v}|${initial.a}` : ''\n\t// biome-ignore lint/correctness/useExhaustiveDependencies: resync only when the committed color changes, not on every initial object identity change\n\tuseEffect(() => {\n\t\tif (!initial) {\n\t\t\tlastEmittedRef.current = null\n\t\t\treturn\n\t\t}\n\t\tif (draggingRef.current) return\n\t\t// Skip echoes of our own commit: achromatic values round-trip with h/s zeroed and would clobber the local hue/saturation.\n\t\t// Compared opaque (alpha quantizes through hex storage) and one-shot (a stale ref must not suppress a later genuine match)\n\t\tconst incomingCss = formatColor(\n\t\t\thsvToRgb({ h: initial.h, s: initial.s, v: initial.v }, 1),\n\t\t\t'rgb'\n\t\t)\n\t\tconst skip = incomingCss === lastEmittedRef.current\n\t\tlastEmittedRef.current = null\n\t\tif (skip) return\n\t\tsetHsva(initial)\n\t}, [initialKey])\n\n\tconst alphaRafRef = useRef<null | number>(null)\n\tconst pendingAlphaRef = useRef(100)\n\n\tuseEffect(\n\t\t() => () => {\n\t\t\tif (rafRef.current !== null) cancelAnimationFrame(rafRef.current)\n\t\t\tif (alphaRafRef.current !== null) cancelAnimationFrame(alphaRafRef.current)\n\t\t},\n\t\t[]\n\t)\n\n\t// Commits are rAF-throttled: pointermove floods would otherwise dispatch a form update per event\n\tconst commit = useCallback(\n\t\t(next: Hsva) => {\n\t\t\tpendingRef.current = next\n\t\t\tif (rafRef.current !== null) return\n\t\t\trafRef.current = requestAnimationFrame(() => {\n\t\t\t\trafRef.current = null\n\t\t\t\tconst pending = pendingRef.current\n\t\t\t\tif (!pending) return\n\t\t\t\tlastEmittedRef.current = formatColor(\n\t\t\t\t\thsvToRgb({ h: pending.h, s: pending.s, v: pending.v }, 1),\n\t\t\t\t\t'rgb'\n\t\t\t\t)\n\t\t\t\tonPickCss(\n\t\t\t\t\tformatColor(\n\t\t\t\t\t\thsvToRgb({ h: pending.h, s: pending.s, v: pending.v }, alphaEnabled ? pending.a : 1),\n\t\t\t\t\t\t'rgb'\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t})\n\t\t},\n\t\t[alphaEnabled, onPickCss]\n\t)\n\n\tconst applyPartial = useCallback(\n\t\t(patch: Partial<Hsva>) => {\n\t\t\tconst next = { ...hsvaRef.current, ...patch }\n\t\t\tsetHsva(next)\n\t\t\tcommit(next)\n\t\t},\n\t\t[commit]\n\t)\n\n\t// Reference-preserving alpha path: while a preset is active, the slider\n\t// rewrites the stored `/<alpha>` suffix instead of committing a concrete\n\t// color. Same rAF throttling and echo suppression as the concrete path\n\t// (the opaque css is unchanged by alpha, so the resync effect skips it).\n\tconst commitReferenceAlpha = useCallback(\n\t\t(next: Hsva) => {\n\t\t\tsetHsva(next)\n\t\t\tpendingAlphaRef.current = Math.round(next.a * 100)\n\t\t\tif (alphaRafRef.current !== null) return\n\t\t\talphaRafRef.current = requestAnimationFrame(() => {\n\t\t\t\talphaRafRef.current = null\n\t\t\t\tconst current = hsvaRef.current\n\t\t\t\tlastEmittedRef.current = formatColor(\n\t\t\t\t\thsvToRgb({ h: current.h, s: current.s, v: current.v }, 1),\n\t\t\t\t\t'rgb'\n\t\t\t\t)\n\t\t\t\tonPickAlpha(pendingAlphaRef.current)\n\t\t\t})\n\t\t},\n\t\t[onPickAlpha]\n\t)\n\n\tconst svPointer = useCallback(\n\t\t(event: React.PointerEvent<HTMLDivElement>) => {\n\t\t\tconst rect = svRef.current?.getBoundingClientRect()\n\t\t\tif (!rect) return\n\t\t\tapplyPartial({\n\t\t\t\ts: clamp01((event.clientX - rect.left) / rect.width),\n\t\t\t\tv: clamp01(1 - (event.clientY - rect.top) / rect.height),\n\t\t\t})\n\t\t},\n\t\t[applyPartial]\n\t)\n\n\tconst onSvKeyDown = useCallback(\n\t\t(event: React.KeyboardEvent<HTMLDivElement>) => {\n\t\t\tif (!event.key.startsWith('Arrow')) return\n\t\t\t// Popup preventDefaults ArrowUp/ArrowDown at document level for focus cycling; consume first\n\t\t\tevent.stopPropagation()\n\t\t\tevent.preventDefault()\n\t\t\tconst step = event.shiftKey ? 0.1 : 0.01\n\t\t\tconst current = hsvaRef.current\n\t\t\tif (event.key === 'ArrowLeft') applyPartial({ s: clamp01(current.s - step) })\n\t\t\tif (event.key === 'ArrowRight') applyPartial({ s: clamp01(current.s + step) })\n\t\t\tif (event.key === 'ArrowUp') applyPartial({ v: clamp01(current.v + step) })\n\t\t\tif (event.key === 'ArrowDown') applyPartial({ v: clamp01(current.v - step) })\n\t\t},\n\t\t[applyPartial]\n\t)\n\n\t// Without this the Popup's document keydown handler preventDefaults native range stepping\n\tconst stopArrowKeys = useCallback((event: React.KeyboardEvent) => {\n\t\tif (event.key.startsWith('Arrow')) event.stopPropagation()\n\t}, [])\n\n\t// Fires after pointerup AND pointercancel, so an interrupted drag never leaves draggingRef stuck\n\tconst endDrag = useCallback(() => {\n\t\tdraggingRef.current = false\n\t}, [])\n\n\t// Detected after mount: the panel is server-rendered inside the closed Popup,\n\t// and the server never has window.EyeDropper, so reading it during render\n\t// makes the hydrated button tree differ from the server HTML\n\tconst [eyeDropperSupported, setEyeDropperSupported] = useState(false)\n\tuseEffect(() => setEyeDropperSupported(getEyeDropper() !== null), [])\n\n\tconst opaqueCss = formatColor(hsvToRgb({ h: hsva.h, s: hsva.s, v: hsva.v }, 1), 'rgb')\n\n\treturn (\n\t\t<div className={`${baseClass}__panel`} data-popup-prevent-close>\n\t\t\t<div\n\t\t\t\taria-label={t(keys.saturationBrightness)}\n\t\t\t\taria-valuemax={100}\n\t\t\t\taria-valuemin={0}\n\t\t\t\taria-valuenow={Math.round(hsva.v * 100)}\n\t\t\t\taria-valuetext={`${Math.round(hsva.s * 100)}% / ${Math.round(hsva.v * 100)}%`}\n\t\t\t\tclassName={`${baseClass}__sv`}\n\t\t\t\tonKeyDown={onSvKeyDown}\n\t\t\t\tonPointerDown={(event) => {\n\t\t\t\t\tdraggingRef.current = true\n\t\t\t\t\tevent.currentTarget.setPointerCapture(event.pointerId)\n\t\t\t\t\tsvPointer(event)\n\t\t\t\t}}\n\t\t\t\tonLostPointerCapture={endDrag}\n\t\t\t\tonPointerMove={(event) => {\n\t\t\t\t\tif (draggingRef.current) svPointer(event)\n\t\t\t\t}}\n\t\t\t\tonPointerUp={endDrag}\n\t\t\t\tref={svRef}\n\t\t\t\trole=\"slider\"\n\t\t\t\tstyle={{ backgroundColor: `hsl(${Math.round(hsva.h)} 100% 50%)` }}\n\t\t\t\ttabIndex={0}\n\t\t\t>\n\t\t\t\t<span\n\t\t\t\t\tclassName={`${baseClass}__sv-thumb`}\n\t\t\t\t\tstyle={{ left: `${hsva.s * 100}%`, top: `${(1 - hsva.v) * 100}%` }}\n\t\t\t\t/>\n\t\t\t</div>\n\n\t\t\t<input\n\t\t\t\taria-label={t(keys.hue)}\n\t\t\t\tclassName={`${baseClass}__slider ${baseClass}__slider--hue`}\n\t\t\t\tmax={360}\n\t\t\t\tmin={0}\n\t\t\t\tonChange={(event) => applyPartial({ h: Number(event.target.value) })}\n\t\t\t\tonKeyDown={stopArrowKeys}\n\t\t\t\tonLostPointerCapture={endDrag}\n\t\t\t\tstep={1}\n\t\t\t\ttype=\"range\"\n\t\t\t\tvalue={Math.round(hsva.h)}\n\t\t\t/>\n\n\t\t\t{alphaEnabled ? (\n\t\t\t\t<input\n\t\t\t\t\taria-label={t(keys.opacity)}\n\t\t\t\t\tclassName={`${baseClass}__slider ${baseClass}__slider--alpha`}\n\t\t\t\t\tmax={100}\n\t\t\t\t\tmin={0}\n\t\t\t\t\tonChange={(event) => {\n\t\t\t\t\t\tconst a = Number(event.target.value) / 100\n\t\t\t\t\t\tif (activeReference) commitReferenceAlpha({ ...hsvaRef.current, a })\n\t\t\t\t\t\telse applyPartial({ a })\n\t\t\t\t\t}}\n\t\t\t\t\tonKeyDown={stopArrowKeys}\n\t\t\t\t\tonLostPointerCapture={endDrag}\n\t\t\t\t\tstep={1}\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tbackgroundImage: `linear-gradient(to right, transparent, ${opaqueCss}), conic-gradient(var(--color-bg-tertiary) 0 25%, transparent 0 50%, var(--color-bg-tertiary) 0 75%, transparent 0)`,\n\t\t\t\t\t\tbackgroundSize: '100% 100%, 8px 8px',\n\t\t\t\t\t}}\n\t\t\t\t\ttype=\"range\"\n\t\t\t\t\tvalue={Math.round(hsva.a * 100)}\n\t\t\t\t/>\n\t\t\t) : null}\n\n\t\t\t<div className={`${baseClass}__controls`}>\n\t\t\t\t{/* biome-ignore lint/a11y/useSemanticElements: fieldset breaks flex layout in Safari; this is a toggle-button group, not a form fieldset */}\n\t\t\t\t<div aria-label={t(keys.format)} className={`${baseClass}__formats`} role=\"group\">\n\t\t\t\t\t{FORMATS.map((entry) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\taria-pressed={entry === displayFormat}\n\t\t\t\t\t\t\tbuttonStyle={entry === displayFormat ? 'pill' : 'ghost'}\n\t\t\t\t\t\t\tclassName={`${baseClass}__format`}\n\t\t\t\t\t\t\tkey={entry}\n\t\t\t\t\t\t\tmargin={false}\n\t\t\t\t\t\t\tonClick={() => setDisplayFormat(entry)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{entry.toUpperCase()}\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t))}\n\t\t\t\t</div>\n\t\t\t\t{enableEyedropper && eyeDropperSupported ? (\n\t\t\t\t\t<Button\n\t\t\t\t\t\taria-label={t(keys.eyedropperPick)}\n\t\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\t\tclassName={`${baseClass}__eyedropper`}\n\t\t\t\t\t\ticon={<EyedropperIcon />}\n\t\t\t\t\t\tmargin={false}\n\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\tconst EyeDropper = getEyeDropper()\n\t\t\t\t\t\t\tif (!EyeDropper) return\n\t\t\t\t\t\t\tvoid new EyeDropper().open().then(\n\t\t\t\t\t\t\t\t(result) => onPickCss(result.sRGBHex),\n\t\t\t\t\t\t\t\t// open() rejects when the user presses Escape; nothing to do\n\t\t\t\t\t\t\t\t() => undefined\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t) : null}\n\t\t\t</div>\n\n\t\t\t{presets.length > 0 ? (\n\t\t\t\t<div className={`${baseClass}__presets`}>\n\t\t\t\t\t<div className={`${baseClass}__presets-label`}>{presetsLabel}</div>\n\t\t\t\t\t{presetMissing ? (\n\t\t\t\t\t\t<p className={`${baseClass}__missing`}>{t(keys.missingPresetHint)}</p>\n\t\t\t\t\t) : null}\n\t\t\t\t\t<div className={`${baseClass}__presets-grid`}>\n\t\t\t\t\t\t{presets.map((preset) => (\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\taria-label={preset.label}\n\t\t\t\t\t\t\t\taria-pressed={preset.key === activeReference?.key}\n\t\t\t\t\t\t\t\tclassName={`${baseClass}__preset ${baseClass}__checker`}\n\t\t\t\t\t\t\t\tkey={preset.key}\n\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\tonPickPreset(preset)\n\t\t\t\t\t\t\t\t\tclose()\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\ttitle={preset.label}\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<span style={{ background: swatchBackground(preset.value) ?? undefined }} />\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;;;;;;;;AAaA,MAAM,YAAY;AAClB,MAAM,UAAyB;CAAC;CAAO;CAAO;CAAO;AAAO;AAM5D,MAAM,sBAAoD;CACzD,IAAI,OAAO,WAAW,aAAa,OAAO;CAC1C,OAAQ,OAA2D,cAAc;AAClF;AAEA,MAAM,WAAW,UAA0B,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC;AAmBzE,MAAa,oBAAqD,UAAU;CAC3E,MAAM,EACL,iBACA,cACA,OACA,eACA,kBACA,SACA,aACA,WACA,cACA,eACA,SACA,cACA,qBACG;CACJ,MAAM,EAAE,MAAMA,iBAAe;CAI7B,MAAM,CAAC,MAAM,WAAW,SACvB,WAAW;EAAE,GAAG,kBAAkB,gBAAgB,QAAQ,MAAM;EAAG,GAAG;EAAG,GAAG;EAAG,GAAG;CAAE,CACrF;CACA,MAAM,UAAU,OAAO,IAAI;CAC3B,QAAQ,UAAU;CAClB,MAAM,cAAc,OAAO,KAAK;CAChC,MAAM,QAAQ,OAAuB,IAAI;CACzC,MAAM,SAAS,OAAsB,IAAI;CACzC,MAAM,aAAa,OA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