@10x-media/fields 0.1.0-beta.3 → 0.1.0-beta.5

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 (66) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +2 -0
  3. package/dist/exports/encrypted.d.ts +7 -4
  4. package/dist/exports/encrypted.js +6 -3
  5. package/dist/fields/color/client/ColorField.js +55 -35
  6. package/dist/fields/color/client/ColorField.js.map +1 -1
  7. package/dist/fields/color/client/colorField.css +23 -0
  8. package/dist/fields/encrypted/boot.js +2 -1
  9. package/dist/fields/encrypted/boot.js.map +1 -1
  10. package/dist/fields/encrypted/components/EncryptedInput.js +4 -1
  11. package/dist/fields/encrypted/components/EncryptedInput.js.map +1 -1
  12. package/dist/fields/encrypted/components/EncryptedTextarea.js +6 -2
  13. package/dist/fields/encrypted/components/EncryptedTextarea.js.map +1 -1
  14. package/dist/fields/encrypted/components/ProtectedCell.d.ts +15 -6
  15. package/dist/fields/encrypted/components/ProtectedCell.js +37 -8
  16. package/dist/fields/encrypted/components/ProtectedCell.js.map +1 -1
  17. package/dist/fields/encrypted/components/ProtectedField.css +134 -39
  18. package/dist/fields/encrypted/components/ProtectedField.d.ts +3 -0
  19. package/dist/fields/encrypted/components/ProtectedField.js +14 -0
  20. package/dist/fields/encrypted/components/ProtectedField.js.map +1 -1
  21. package/dist/fields/encrypted/components/WriteOnlyActions.js +65 -0
  22. package/dist/fields/encrypted/components/WriteOnlyActions.js.map +1 -0
  23. package/dist/fields/encrypted/components/WriteOnlyField.js +286 -0
  24. package/dist/fields/encrypted/components/WriteOnlyField.js.map +1 -0
  25. package/dist/fields/encrypted/components/writeOnlyIntent.js +69 -0
  26. package/dist/fields/encrypted/components/writeOnlyIntent.js.map +1 -0
  27. package/dist/fields/encrypted/crypto/wire.d.ts +10 -1
  28. package/dist/fields/encrypted/crypto/wire.js +1 -1
  29. package/dist/fields/encrypted/encryptedField.js +63 -6
  30. package/dist/fields/encrypted/encryptedField.js.map +1 -1
  31. package/dist/fields/encrypted/generateSecret.d.ts +10 -0
  32. package/dist/fields/encrypted/generateSecret.js +41 -0
  33. package/dist/fields/encrypted/generateSecret.js.map +1 -0
  34. package/dist/fields/encrypted/hint.js +67 -0
  35. package/dist/fields/encrypted/hint.js.map +1 -0
  36. package/dist/fields/encrypted/hooks.js +59 -31
  37. package/dist/fields/encrypted/hooks.js.map +1 -1
  38. package/dist/fields/encrypted/queryRewrite.d.ts +10 -2
  39. package/dist/fields/encrypted/queryRewrite.js +34 -8
  40. package/dist/fields/encrypted/queryRewrite.js.map +1 -1
  41. package/dist/fields/encrypted/rawRead.d.ts +24 -0
  42. package/dist/fields/encrypted/rawRead.js +40 -0
  43. package/dist/fields/encrypted/rawRead.js.map +1 -0
  44. package/dist/fields/encrypted/scan.js +21 -4
  45. package/dist/fields/encrypted/scan.js.map +1 -1
  46. package/dist/fields/encrypted/types.d.ts +67 -2
  47. package/dist/fields/encrypted/types.js +8 -1
  48. package/dist/fields/encrypted/types.js.map +1 -1
  49. package/dist/fields/encrypted/utils/decryptAllData.js +2 -2
  50. package/dist/fields/encrypted/utils/decryptAllData.js.map +1 -1
  51. package/dist/fields/encrypted/utils/decryptFieldValue.d.ts +30 -0
  52. package/dist/fields/encrypted/utils/decryptFieldValue.js +56 -0
  53. package/dist/fields/encrypted/utils/decryptFieldValue.js.map +1 -0
  54. package/dist/fields/encrypted/utils/readEncryptedField.d.ts +51 -0
  55. package/dist/fields/encrypted/utils/readEncryptedField.js +96 -0
  56. package/dist/fields/encrypted/utils/readEncryptedField.js.map +1 -0
  57. package/dist/index.js +2 -1
  58. package/dist/index.js.map +1 -1
  59. package/dist/translations/de.js +8 -1
  60. package/dist/translations/de.js.map +1 -1
  61. package/dist/translations/en.js +8 -1
  62. package/dist/translations/en.js.map +1 -1
  63. package/dist/translations/keys.d.ts +7 -0
  64. package/dist/translations/keys.js +8 -1
  65. package/dist/translations/keys.js.map +1 -1
  66. package/package.json +6 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # @10x-media/fields
2
2
 
3
+ ## 0.1.0-beta.5
4
+
5
+ ### Minor Changes
6
+
7
+ - New `aadScope` option on `encryptedField` pins the first component of the ciphertext's AAD binding, which otherwise is the collection or global slug. The slug is the right binding until it can change: a plugin-owned collection whose slug the consumer configures, or a collection renamed with its data kept in place, turns every stored value into an authentication failure that no utility can recover, because reads resolve the binding from the current slug too. A pinned scope survives the rename.
8
+
9
+ The scope flows through every construction site (sealing, document reads, `decryptFieldValue`, `readEncryptedField`, key rotation, the removal utility), must not contain `.` (the AAD component separator; rejected at the factory), and should be unique per logical schema. Decide it before data exists: changing it later is the re-keying event it exists to prevent.
10
+
11
+ - `readEncryptedField` now takes a `req`. Given one, the read joins that request's transaction and locale, so a secret written earlier in the same operation is visible to the code that needs it; without one the read still runs on its own request, outside any transaction in progress. The request is restored exactly as it was handed over.
12
+
13
+ New `withRawEncrypted(req, read)` for recovering an encrypted field across many rows. `readEncryptedField` issues one query per document, which is the wrong shape for a hook or a job that needs the same secret on every row a query returns, and the rest of each row with it. Inside the window the write-only response strip and the decrypt-on-read step both stand down, so the caller's own `find` returns each encrypted field as its stored wire string for `decryptFieldValue`. The previous mode is restored on the way out, so windows nest, and the request's dataloader is isolated for the duration: its cache key does not include the context, so a related document pulled in at `depth > 0` would otherwise be cached as ciphertext and served that way to an ordinary read later in the same request.
14
+
15
+ `CorruptPlaintextError` is now exported alongside the other decrypt failures, so a caller can tell authenticated-but-corrupt data (non-retryable) from a wrong key or a malformed wire string.
16
+
17
+ Encrypted field scans are cached per schema. `decryptFieldValue` walks the field tree to find its marker, so decrypting a page of rows used to repeat that walk once per row.
18
+
19
+ - An encrypted field's identification `hint` may now expose up to 32 characters, up from 8. Every credential format in use carries a constant prefix (`sk_live_`, `whsec_`, `ghp_`, `xoxb-`), and a budget of 8 was spent on that prefix before reaching anything that identifies a particular key.
20
+
21
+ The cap was doing a job it cannot do, so the real guard is now the value being sliced rather than the config asking for the slice: a hint is stored only when the plaintext keeps at least as many characters hidden as the hint exposes, and at least 8 hidden characters regardless. One field can therefore serve a collection holding both long tokens and short ones, hinting the first and declining the second instead of exposing half of it. No configuration valid before this release changes behaviour, since 8 exposed already required 8 hidden.
22
+
23
+ The bullet run stays exactly `maskDots` wide, with the hint's ends added around it, so a hinted value shows the same run as every other concealed span and the count remains a pure presentation choice. A hint too wide for a narrow field clamps with an ellipsis, in the input and in the list cell, with the lock badge held at its size.
24
+
25
+ `admin.width` and `admin.style` now reach encrypted fields. A custom Field component short-circuits the path where Payload applies them, so an encrypted field in a row ignored its width while a native sibling honoured it, and the two rendered at different widths.
26
+
27
+ - Add `protection: 'writeOnly'` to `encryptedField`: a mode for credentials that are written and used server-side but never returned to any API caller. Read results (REST, GraphQL, Local API) omit the field entirely; a virtual `<name>_set` sibling exposes set-ness only. The admin renders one always-editable input at native height: a stored value is only a placeholder, typing stages a replacement, an isClearable-style `×` clears (with undo), and `clearable`/`required` govern the `×`. `queryable` and `richText` are rejected on write-only fields.
28
+
29
+ Two write-only companions: `hint` stores an identification slice (`sk_l····9d3f`) beside the ciphertext at seal time, shown in the admin, list cells, and API responses as `<name>_hint`, capped and length-guarded so it can identify a key but never reconstruct a short secret. `generate` adds a crypto-random generate/rotate action (default 32-char base62, configurable length/prefix/charset) whose value is visible and copyable exactly until the save succeeds, the GitHub-token reveal-once model.
30
+
31
+ New server-side helpers `readEncryptedField` and `decryptFieldValue` make reading a stored secret a deliberate act: fetch a handle with cacheable ciphertext and on-demand `decrypt()`, or decrypt a cached wire string given only the field path. Both work on every encrypted field, collections and globals, with locale support.
32
+
33
+ The response strip now also covers globals, closing a gap where a global's encrypted richText ciphertext sibling (and blind-index hashes) surfaced in read results. Boot key validation now scans globals too.
34
+
35
+ ## 0.1.0-beta.4
36
+
37
+ ### Patch Changes
38
+
39
+ - `colorField` no longer overflows its input border when squeezed by `admin.width` in a row. The chip, text entry, and format badge now live in a clipping region that fades out at the right edge when (and only when) the run actually overflows, and the clear control keeps its place inside the border at every width. The fade is a CSS mask rather than a background-colored overlay, so it renders correctly over the error, read-only, and hover backgrounds in both themes.
40
+
3
41
  ## 0.1.0-beta.3
4
42
 
5
43
  ### Minor Changes
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ ![Banner](./assets/banner.jpg)
2
+
1
3
  # @10x-media/fields
2
4
 
3
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, and encrypted fields with key rotation and opt-in exact-match querying. Built from `@payloadcms/ui` primitives on Payload design tokens, indistinguishable from Payload's own fields.
@@ -1,12 +1,15 @@
1
1
  import { DecryptFailurePolicy, EncryptedGlobalConfig, KeysConfig } from "../types.js";
2
- import { EncryptedFieldOptions, EncryptedProtection, EncryptedSourceField } from "../fields/encrypted/types.js";
2
+ import { EncryptedFieldOptions, EncryptedGenerateConfig, EncryptedHintConfig, EncryptedProtection, EncryptedSourceField } from "../fields/encrypted/types.js";
3
3
  import { DEFAULT_KEY_ID, InvalidKeysConfigError } from "../fields/encrypted/crypto/keys.js";
4
4
  import { validateEncryptedBoot } from "../fields/encrypted/boot.js";
5
- import { AuthenticationFailedError, MalformedCiphertextError, UnknownKeyIdError, isSealed } from "../fields/encrypted/crypto/wire.js";
5
+ import { AuthenticationFailedError, CorruptPlaintextError, MalformedCiphertextError, UnknownKeyIdError, isSealed } from "../fields/encrypted/crypto/wire.js";
6
6
  import { encryptedField } from "../fields/encrypted/encryptedField.js";
7
7
  import { DecryptFailedError } from "../fields/encrypted/hooks.js";
8
- import { withEncryptedQueryRewrite } from "../fields/encrypted/queryRewrite.js";
8
+ import { withEncryptedQueryRewrite, withEncryptedResponseStrip } from "../fields/encrypted/queryRewrite.js";
9
+ import { withRawEncrypted } from "../fields/encrypted/rawRead.js";
9
10
  import { rotateEncryptedFields } from "../fields/encrypted/utils/rotateEncryptedFields.js";
10
11
  import { decryptAllData } from "../fields/encrypted/utils/decryptAllData.js";
12
+ import { DecryptFieldValueArgs, EncryptedFieldTarget, decryptFieldValue } from "../fields/encrypted/utils/decryptFieldValue.js";
11
13
  import { encryptExistingData } from "../fields/encrypted/utils/encryptExistingData.js";
12
- export { AuthenticationFailedError, DEFAULT_KEY_ID, DecryptFailedError, type DecryptFailurePolicy, type EncryptedFieldOptions, type EncryptedGlobalConfig, type EncryptedProtection, type EncryptedSourceField, InvalidKeysConfigError, type KeysConfig, MalformedCiphertextError, UnknownKeyIdError, decryptAllData, encryptExistingData, encryptedField, isSealed, rotateEncryptedFields, validateEncryptedBoot, withEncryptedQueryRewrite };
14
+ import { EncryptedFieldHandle, ReadEncryptedFieldArgs, readEncryptedField } from "../fields/encrypted/utils/readEncryptedField.js";
15
+ export { AuthenticationFailedError, CorruptPlaintextError, DEFAULT_KEY_ID, DecryptFailedError, type DecryptFailurePolicy, type DecryptFieldValueArgs, type EncryptedFieldHandle, type EncryptedFieldOptions, type EncryptedFieldTarget, type EncryptedGenerateConfig, type EncryptedGlobalConfig, type EncryptedHintConfig, type EncryptedProtection, type EncryptedSourceField, InvalidKeysConfigError, type KeysConfig, MalformedCiphertextError, type ReadEncryptedFieldArgs, UnknownKeyIdError, decryptAllData, decryptFieldValue, encryptExistingData, encryptedField, isSealed, readEncryptedField, rotateEncryptedFields, validateEncryptedBoot, withEncryptedQueryRewrite, withEncryptedResponseStrip, withRawEncrypted };
@@ -1,10 +1,13 @@
1
1
  import { DEFAULT_KEY_ID, InvalidKeysConfigError } from "../fields/encrypted/crypto/keys.js";
2
2
  import { validateEncryptedBoot } from "../fields/encrypted/boot.js";
3
- import { AuthenticationFailedError, MalformedCiphertextError, UnknownKeyIdError, isSealed } from "../fields/encrypted/crypto/wire.js";
3
+ import { AuthenticationFailedError, CorruptPlaintextError, MalformedCiphertextError, UnknownKeyIdError, isSealed } from "../fields/encrypted/crypto/wire.js";
4
4
  import { DecryptFailedError } from "../fields/encrypted/hooks.js";
5
- import { withEncryptedQueryRewrite } from "../fields/encrypted/queryRewrite.js";
5
+ import { withEncryptedQueryRewrite, withEncryptedResponseStrip } from "../fields/encrypted/queryRewrite.js";
6
6
  import { encryptedField } from "../fields/encrypted/encryptedField.js";
7
+ import { withRawEncrypted } from "../fields/encrypted/rawRead.js";
7
8
  import { decryptAllData } from "../fields/encrypted/utils/decryptAllData.js";
9
+ import { decryptFieldValue } from "../fields/encrypted/utils/decryptFieldValue.js";
8
10
  import { encryptExistingData } from "../fields/encrypted/utils/encryptExistingData.js";
11
+ import { readEncryptedField } from "../fields/encrypted/utils/readEncryptedField.js";
9
12
  import { rotateEncryptedFields } from "../fields/encrypted/utils/rotateEncryptedFields.js";
10
- export { AuthenticationFailedError, DEFAULT_KEY_ID, DecryptFailedError, InvalidKeysConfigError, MalformedCiphertextError, UnknownKeyIdError, decryptAllData, encryptExistingData, encryptedField, isSealed, rotateEncryptedFields, validateEncryptedBoot, withEncryptedQueryRewrite };
13
+ export { AuthenticationFailedError, CorruptPlaintextError, DEFAULT_KEY_ID, DecryptFailedError, InvalidKeysConfigError, MalformedCiphertextError, UnknownKeyIdError, decryptAllData, decryptFieldValue, encryptExistingData, encryptedField, isSealed, readEncryptedField, rotateEncryptedFields, validateEncryptedBoot, withEncryptedQueryRewrite, withEncryptedResponseStrip, withRawEncrypted };
@@ -197,6 +197,20 @@ const ColorField = (props) => {
197
197
  if (presetKey === null) return;
198
198
  setValue(formatPresetReference(presetKey, alpha100));
199
199
  }, [presetKey, setValue]);
200
+ const contentRef = useRef(null);
201
+ const [contentClipped, setContentClipped] = useState(false);
202
+ const measureClip = useCallback(() => {
203
+ const el = contentRef.current;
204
+ if (el) setContentClipped(el.scrollWidth > el.clientWidth + 1);
205
+ }, []);
206
+ useEffect(measureClip);
207
+ useEffect(() => {
208
+ const el = contentRef.current;
209
+ if (!el) return;
210
+ const observer = new ResizeObserver(measureClip);
211
+ observer.observe(el);
212
+ return () => observer.disconnect();
213
+ }, [measureClip]);
200
214
  const styles = useMemo(() => mergeFieldStyles(field), [field]);
201
215
  const swatchCss = swatchBackground(referenceAlpha !== 100 && (typeof rawValue === "string" || isColorSchemeValue(rawValue)) ? applyReferenceAlpha(rawValue, referenceAlpha, "rgb") : rawValue);
202
216
  const swatch = /* @__PURE__ */ jsxs("span", {
@@ -281,45 +295,51 @@ const ColorField = (props) => {
281
295
  size: "fit-content",
282
296
  verticalAlign: "bottom"
283
297
  }),
284
- chip ? /* @__PURE__ */ jsxs("span", {
285
- className: `${baseClass}__chip`,
298
+ /* @__PURE__ */ jsxs("div", {
299
+ className: [`${baseClass}__content`, contentClipped && `${baseClass}__content--fade`].filter(Boolean).join(" "),
300
+ ref: contentRef,
286
301
  children: [
287
- /* @__PURE__ */ jsxs("span", {
288
- className: `${baseClass}__chip-swatch ${baseClass}__checker`,
289
- children: [swatchCss ? /* @__PURE__ */ jsx("span", {
290
- className: `${baseClass}__chip-color`,
291
- style: { background: swatchCss }
292
- }) : null, chip.missing && !swatchCss ? /* @__PURE__ */ jsx("span", {
293
- className: `${baseClass}__chip-color`,
294
- "data-missing": "true"
295
- }) : null]
302
+ chip ? /* @__PURE__ */ jsxs("span", {
303
+ className: `${baseClass}__chip`,
304
+ children: [
305
+ /* @__PURE__ */ jsxs("span", {
306
+ className: `${baseClass}__chip-swatch ${baseClass}__checker`,
307
+ children: [swatchCss ? /* @__PURE__ */ jsx("span", {
308
+ className: `${baseClass}__chip-color`,
309
+ style: { background: swatchCss }
310
+ }) : null, chip.missing && !swatchCss ? /* @__PURE__ */ jsx("span", {
311
+ className: `${baseClass}__chip-color`,
312
+ "data-missing": "true"
313
+ }) : null]
314
+ }),
315
+ /* @__PURE__ */ jsx("span", {
316
+ className: `${baseClass}__chip-label`,
317
+ children: chip.label
318
+ }),
319
+ alpha && chip.alpha !== 100 ? /* @__PURE__ */ jsxs("span", {
320
+ className: `${baseClass}__chip-alpha`,
321
+ children: [chip.alpha, "%"]
322
+ }) : null
323
+ ]
324
+ }) : null,
325
+ /* @__PURE__ */ jsx("input", {
326
+ className: `${baseClass}__input`,
327
+ id: `field-${path?.replace(/\./g, "__")}`,
328
+ name: path,
329
+ onBlur: onTextBlur,
330
+ onChange: onTextChange,
331
+ onKeyDown: onTextKeyDown,
332
+ placeholder: chip || typeof placeholder !== "string" ? void 0 : placeholder,
333
+ readOnly: isReadOnly,
334
+ type: "text",
335
+ value: chip ? "" : draft
296
336
  }),
297
337
  /* @__PURE__ */ jsx("span", {
298
- className: `${baseClass}__chip-label`,
299
- children: chip.label
300
- }),
301
- alpha && chip.alpha !== 100 ? /* @__PURE__ */ jsxs("span", {
302
- className: `${baseClass}__chip-alpha`,
303
- children: [chip.alpha, "%"]
304
- }) : null
338
+ "aria-hidden": "true",
339
+ className: `${baseClass}__badge`,
340
+ children: chip ? t(keys.preset) : displayFormat
341
+ })
305
342
  ]
306
- }) : null,
307
- /* @__PURE__ */ jsx("input", {
308
- className: `${baseClass}__input`,
309
- id: `field-${path?.replace(/\./g, "__")}`,
310
- name: path,
311
- onBlur: onTextBlur,
312
- onChange: onTextChange,
313
- onKeyDown: onTextKeyDown,
314
- placeholder: chip || typeof placeholder !== "string" ? void 0 : placeholder,
315
- readOnly: isReadOnly,
316
- type: "text",
317
- value: chip ? "" : draft
318
- }),
319
- /* @__PURE__ */ jsx("span", {
320
- "aria-hidden": "true",
321
- className: `${baseClass}__badge`,
322
- children: chip ? t(keys.preset) : displayFormat
323
343
  }),
324
344
  isClearable && !required && !isReadOnly && stringValue !== "" ? /* @__PURE__ */ jsx("button", {
325
345
  "aria-label": t(keys.clearColor),
@@ -1 +1 @@
1
- {"version":3,"file":"ColorField.js","names":["useTranslation"],"sources":["../../../../src/fields/color/client/ColorField.tsx"],"sourcesContent":["'use client'\nimport {\n\tFieldDescription,\n\tFieldError,\n\tFieldLabel,\n\tfieldBaseClass,\n\tPopup,\n\tRenderCustomComponent,\n\tuseField,\n\tXIcon,\n} from '@payloadcms/ui'\nimport { mergeFieldStyles } from '@payloadcms/ui/shared'\nimport type { TextFieldClientProps, Validate } from 'payload'\nimport { text } from 'payload/shared'\nimport type React from 'react'\nimport { useCallback, useEffect, 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\tpresetReferenceIssue,\n\tpresetReferenceParts,\n} from '../presetReference'\nimport { flatValue, swatchBackground } from '../schemeValue'\nimport { ColorPickerPanel, type Hsva } from './ColorPickerPanel'\nimport './colorField.css'\n\nconst baseClass = 'fields-color'\n\nexport type ColorFieldProps = {\n\tcolorOptions: ColorFieldClientOptions\n\tpresetsLabel?: string\n\tresolvedPresets?: ResolvedColorPreset[]\n} & TextFieldClientProps\n\nexport const ColorField: React.FC<ColorFieldProps> = (props) => {\n\tconst {\n\t\tcolorOptions,\n\t\tfield,\n\t\tfield: {\n\t\t\tadmin: { className, description, placeholder, readOnly: readOnlyFromAdmin } = {},\n\t\t\tlabel,\n\t\t\tlocalized,\n\t\t\tname,\n\t\t\trequired,\n\t\t},\n\t\tpath: pathFromProps,\n\t\tpresetsLabel,\n\t\treadOnly: readOnlyFromProps,\n\t\tresolvedPresets = [],\n\t} = props\n\tconst { alpha, enableEyedropper, format, isClearable, linked, linkedFallback } = colorOptions\n\tconst { t } = useTranslation()\n\n\tconst memoizedValidate = useCallback<Validate<string>>(\n\t\t(value, options) => {\n\t\t\tif (typeof value === 'string' && value !== '') {\n\t\t\t\tif (linked && value.startsWith(PRESET_PREFIX)) {\n\t\t\t\t\tconst hasKey =\n\t\t\t\t\t\tresolvedPresets.length > 0\n\t\t\t\t\t\t\t? (key: string) => resolvedPresets.some((preset) => preset.key === key)\n\t\t\t\t\t\t\t: null\n\t\t\t\t\tconst issue = presetReferenceIssue(value, hasKey)\n\t\t\t\t\tif (issue === 'invalidAlpha') return t(keys.invalidColor)\n\t\t\t\t\tif (issue !== null) return t(keys.missingPreset)\n\t\t\t\t} else if (!parseColor(value)) {\n\t\t\t\t\treturn t(keys.invalidColor)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn text(value, { ...options, name, required, type: 'text' })\n\t\t},\n\t\t[linked, name, required, resolvedPresets, t]\n\t)\n\n\tconst {\n\t\tcustomComponents: { AfterInput, BeforeInput, Description, Error: ErrorComponent, Label } = {},\n\t\tdisabled,\n\t\tpath,\n\t\tsetValue,\n\t\tshowError,\n\t\tvalue,\n\t} = useField<string>({ potentiallyStalePath: pathFromProps, validate: memoizedValidate })\n\n\t// renderField only maps permissions into the readOnly clientProp; admin.readOnly\n\t// reaches custom Field components solely via clientField.admin (native fields get\n\t// it merged client-side in RenderFields, a path custom components bypass)\n\tconst isReadOnly = Boolean(readOnlyFromProps || disabled || readOnlyFromAdmin)\n\n\tconst stringValue = typeof value === 'string' ? value : ''\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// 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 to the form 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 form 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\tconst styles = useMemo(() => mergeFieldStyles(field), [field])\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={styles}\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 label={label} localized={localized} path={path} required={required} />\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 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{chip ? (\n\t\t\t\t\t\t<span className={`${baseClass}__chip`}>\n\t\t\t\t\t\t\t<span className={`${baseClass}__chip-swatch ${baseClass}__checker`}>\n\t\t\t\t\t\t\t\t{swatchCss ? (\n\t\t\t\t\t\t\t\t\t<span className={`${baseClass}__chip-color`} style={{ background: swatchCss }} />\n\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t{chip.missing && !swatchCss ? (\n\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) : null}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t<span className={`${baseClass}__chip-label`}>{chip.label}</span>\n\t\t\t\t\t\t\t{alpha && chip.alpha !== 100 ? (\n\t\t\t\t\t\t\t\t<span className={`${baseClass}__chip-alpha`}>{chip.alpha}%</span>\n\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : null}\n\t\t\t\t\t<input\n\t\t\t\t\t\tclassName={`${baseClass}__input`}\n\t\t\t\t\t\tid={`field-${path?.replace(/\\./g, '__')}`}\n\t\t\t\t\t\tname={path}\n\t\t\t\t\t\tonBlur={onTextBlur}\n\t\t\t\t\t\tonChange={onTextChange}\n\t\t\t\t\t\tonKeyDown={onTextKeyDown}\n\t\t\t\t\t\tplaceholder={chip || typeof placeholder !== 'string' ? undefined : placeholder}\n\t\t\t\t\t\treadOnly={isReadOnly}\n\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\tvalue={chip ? '' : draft}\n\t\t\t\t\t/>\n\t\t\t\t\t<span aria-hidden=\"true\" className={`${baseClass}__badge`}>\n\t\t\t\t\t\t{chip ? t(keys.preset) : displayFormat}\n\t\t\t\t\t</span>\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":";;;;;;;;;;;;;;;;;;;;;AAyCA,MAAM,YAAY;AAQlB,MAAa,cAAyC,UAAU;CAC/D,MAAM,EACL,cACA,OACA,OAAO,EACN,OAAO,EAAE,WAAW,aAAa,aAAa,UAAU,sBAAsB,CAAC,GAC/E,OACA,WACA,MACA,YAED,MAAM,eACN,cACA,UAAU,mBACV,kBAAkB,CAAC,MAChB;CACJ,MAAM,EAAE,OAAO,kBAAkB,QAAQ,aAAa,QAAQ,mBAAmB;CACjF,MAAM,EAAE,MAAMA,iBAAe;CAsB7B,MAAM,EACL,kBAAkB,EAAE,YAAY,aAAa,aAAa,OAAO,gBAAgB,UAAU,CAAC,GAC5F,UACA,MACA,UACA,WACA,UACG,SAAiB;EAAE,sBAAsB;EAAe,UA3BnC,aACvB,OAAO,YAAY;GACnB,IAAI,OAAO,UAAU,YAAY,UAAU;QACtC,UAAU,MAAM,WAAA,SAAwB,GAAG;KAK9C,MAAM,QAAQ,qBAAqB,OAHlC,gBAAgB,SAAS,KACrB,QAAgB,gBAAgB,MAAM,WAAW,OAAO,QAAQ,GAAG,IACpE,IAC4C;KAChD,IAAI,UAAU,gBAAgB,OAAO,EAAE,KAAK,YAAY;KACxD,IAAI,UAAU,MAAM,OAAO,EAAE,KAAK,aAAa;IAChD,OAAO,IAAI,CAAC,WAAW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AAC,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,OAAD,CAAQ,CAAA;MACD,CAAA,IACL;KACA;;IACJ;IACD,oBAAC,uBAAD;KACC,iBAAiB;KACjB,UAAU,oBAAC,kBAAD;MAA+B;MAAmB;KAAO,CAAA;IACnE,CAAA;GACG;IACD;;AAEP"}
1
+ {"version":3,"file":"ColorField.js","names":["useTranslation"],"sources":["../../../../src/fields/color/client/ColorField.tsx"],"sourcesContent":["'use client'\nimport {\n\tFieldDescription,\n\tFieldError,\n\tFieldLabel,\n\tfieldBaseClass,\n\tPopup,\n\tRenderCustomComponent,\n\tuseField,\n\tXIcon,\n} from '@payloadcms/ui'\nimport { mergeFieldStyles } from '@payloadcms/ui/shared'\nimport type { TextFieldClientProps, Validate } from 'payload'\nimport { text } from 'payload/shared'\nimport type React from 'react'\nimport { useCallback, useEffect, 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\tpresetReferenceIssue,\n\tpresetReferenceParts,\n} from '../presetReference'\nimport { flatValue, swatchBackground } from '../schemeValue'\nimport { ColorPickerPanel, type Hsva } from './ColorPickerPanel'\nimport './colorField.css'\n\nconst baseClass = 'fields-color'\n\nexport type ColorFieldProps = {\n\tcolorOptions: ColorFieldClientOptions\n\tpresetsLabel?: string\n\tresolvedPresets?: ResolvedColorPreset[]\n} & TextFieldClientProps\n\nexport const ColorField: React.FC<ColorFieldProps> = (props) => {\n\tconst {\n\t\tcolorOptions,\n\t\tfield,\n\t\tfield: {\n\t\t\tadmin: { className, description, placeholder, readOnly: readOnlyFromAdmin } = {},\n\t\t\tlabel,\n\t\t\tlocalized,\n\t\t\tname,\n\t\t\trequired,\n\t\t},\n\t\tpath: pathFromProps,\n\t\tpresetsLabel,\n\t\treadOnly: readOnlyFromProps,\n\t\tresolvedPresets = [],\n\t} = props\n\tconst { alpha, enableEyedropper, format, isClearable, linked, linkedFallback } = colorOptions\n\tconst { t } = useTranslation()\n\n\tconst memoizedValidate = useCallback<Validate<string>>(\n\t\t(value, options) => {\n\t\t\tif (typeof value === 'string' && value !== '') {\n\t\t\t\tif (linked && value.startsWith(PRESET_PREFIX)) {\n\t\t\t\t\tconst hasKey =\n\t\t\t\t\t\tresolvedPresets.length > 0\n\t\t\t\t\t\t\t? (key: string) => resolvedPresets.some((preset) => preset.key === key)\n\t\t\t\t\t\t\t: null\n\t\t\t\t\tconst issue = presetReferenceIssue(value, hasKey)\n\t\t\t\t\tif (issue === 'invalidAlpha') return t(keys.invalidColor)\n\t\t\t\t\tif (issue !== null) return t(keys.missingPreset)\n\t\t\t\t} else if (!parseColor(value)) {\n\t\t\t\t\treturn t(keys.invalidColor)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn text(value, { ...options, name, required, type: 'text' })\n\t\t},\n\t\t[linked, name, required, resolvedPresets, t]\n\t)\n\n\tconst {\n\t\tcustomComponents: { AfterInput, BeforeInput, Description, Error: ErrorComponent, Label } = {},\n\t\tdisabled,\n\t\tpath,\n\t\tsetValue,\n\t\tshowError,\n\t\tvalue,\n\t} = useField<string>({ potentiallyStalePath: pathFromProps, validate: memoizedValidate })\n\n\t// renderField only maps permissions into the readOnly clientProp; admin.readOnly\n\t// reaches custom Field components solely via clientField.admin (native fields get\n\t// it merged client-side in RenderFields, a path custom components bypass)\n\tconst isReadOnly = Boolean(readOnlyFromProps || disabled || readOnlyFromAdmin)\n\n\tconst stringValue = typeof value === 'string' ? value : ''\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// 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 to the form 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 form 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\tconst styles = useMemo(() => mergeFieldStyles(field), [field])\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={styles}\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 label={label} localized={localized} path={path} required={required} />\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 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={`field-${path?.replace(/\\./g, '__')}`}\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 || typeof placeholder !== 'string' ? 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":";;;;;;;;;;;;;;;;;;;;;AAyCA,MAAM,YAAY;AAQlB,MAAa,cAAyC,UAAU;CAC/D,MAAM,EACL,cACA,OACA,OAAO,EACN,OAAO,EAAE,WAAW,aAAa,aAAa,UAAU,sBAAsB,CAAC,GAC/E,OACA,WACA,MACA,YAED,MAAM,eACN,cACA,UAAU,mBACV,kBAAkB,CAAC,MAChB;CACJ,MAAM,EAAE,OAAO,kBAAkB,QAAQ,aAAa,QAAQ,mBAAmB;CACjF,MAAM,EAAE,MAAMA,iBAAe;CAsB7B,MAAM,EACL,kBAAkB,EAAE,YAAY,aAAa,aAAa,OAAO,gBAAgB,UAAU,CAAC,GAC5F,UACA,MACA,UACA,WACA,UACG,SAAiB;EAAE,sBAAsB;EAAe,UA3BnC,aACvB,OAAO,YAAY;GACnB,IAAI,OAAO,UAAU,YAAY,UAAU;QACtC,UAAU,MA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132
132
  }
133
133
 
134
+ /* Clips the chip/input/badge run so fixed-size flex items can never escape the
135
+ container at narrow widths; the swatch and clear button stay outside it, so
136
+ the clear control keeps its place at the right edge. The fade is a mask, not
137
+ a background-colored gradient overlay, so it stays correct over every
138
+ container background (error, read-only, hover transitions, both themes).
139
+ The modifier is toggled from a measured scrollWidth overflow, never applied
140
+ statically: the badge always sits at the run's right edge, so a static mask
141
+ would fade it even with room to spare. */
142
+ .fields-color__content {
143
+ display: flex;
144
+ flex: 1 1 auto;
145
+ min-width: 0;
146
+ align-items: center;
147
+ gap: 7px;
148
+ height: 100%;
149
+ overflow: hidden;
150
+ }
151
+
152
+ .fields-color__content--fade {
153
+ -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
154
+ mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
155
+ }
156
+
134
157
  /* The sibling input's width: 100% basis would otherwise squeeze the chip to nothing;
135
158
  the max-width keeps runaway labels ellipsizing instead of overflowing */
136
159
  .fields-color__chip {
@@ -11,7 +11,8 @@ const validateEncryptedBoot = async (payload, pluginKeys) => {
11
11
  const configs = /* @__PURE__ */ new Set();
12
12
  if (pluginKeys) configs.add(pluginKeys);
13
13
  let usesDefault = false;
14
- for (const collection of payload.config.collections) for (const [, marker] of scanEncryptedFields(collection.fields)) if (marker.keys) configs.add(marker.keys);
14
+ const fieldSets = [...payload.config.collections.map((collection) => collection.fields), ...payload.config.globals.map((global) => global.fields)];
15
+ for (const fields of fieldSets) for (const [, marker] of scanEncryptedFields(fields)) if (marker.keys) configs.add(marker.keys);
15
16
  else if (!pluginKeys) usesDefault = true;
16
17
  await Promise.all([...configs].map((config) => resolveKeys(config, payload.config.secret)));
17
18
  if (usesDefault) await resolveKeys(void 0, payload.config.secret);
@@ -1 +1 @@
1
- {"version":3,"file":"boot.js","names":[],"sources":["../../../src/fields/encrypted/boot.ts"],"sourcesContent":["import type { Payload } from 'payload'\nimport { resolveKeys } from './crypto/keys'\nimport { scanEncryptedFields } from './scan'\n\n/**\n * Fail-fast key validation at boot: resolves every distinct KeysConfig used by\n * encrypted fields (plus the default ring when any field falls back to it) so\n * missing secrets, broken providers, and empty material surface as startup\n * errors, not as runtime surprises on first write.\n */\nexport const validateEncryptedBoot = async (\n\tpayload: Payload,\n\tpluginKeys?: Parameters<typeof resolveKeys>[0]\n): Promise<void> => {\n\tconst configs = new Set<NonNullable<Parameters<typeof resolveKeys>[0]>>()\n\tif (pluginKeys) {\n\t\tconfigs.add(pluginKeys)\n\t}\n\t// The default ring is only reached when a field has no per-field keys AND the\n\t// plugin declared no keys; ringForRequest resolves marker.keys ?? pluginKeys\n\t// and falls back to the secret-derived ring only when both are absent.\n\tlet usesDefault = false\n\tfor (const collection of payload.config.collections) {\n\t\tfor (const [, marker] of scanEncryptedFields(collection.fields)) {\n\t\t\tif (marker.keys) {\n\t\t\t\tconfigs.add(marker.keys)\n\t\t\t} else if (!pluginKeys) {\n\t\t\t\tusesDefault = true\n\t\t\t}\n\t\t}\n\t}\n\tawait Promise.all([...configs].map((config) => resolveKeys(config, payload.config.secret)))\n\tif (usesDefault) {\n\t\tawait resolveKeys(undefined, payload.config.secret)\n\t}\n}\n"],"mappings":";;;;;;;;;AAUA,MAAa,wBAAwB,OACpC,SACA,eACmB;CACnB,MAAM,0BAAU,IAAI,IAAoD;CACxE,IAAI,YACH,QAAQ,IAAI,UAAU;CAKvB,IAAI,cAAc;CAClB,KAAK,MAAM,cAAc,QAAQ,OAAO,aACvC,KAAK,MAAM,GAAG,WAAW,oBAAoB,WAAW,MAAM,GAC7D,IAAI,OAAO,MACV,QAAQ,IAAI,OAAO,IAAI;MACjB,IAAI,CAAC,YACX,cAAc;CAIjB,MAAM,QAAQ,IAAI,CAAC,GAAG,OAAO,EAAE,KAAK,WAAW,YAAY,QAAQ,QAAQ,OAAO,MAAM,CAAC,CAAC;CAC1F,IAAI,aACH,MAAM,YAAY,KAAA,GAAW,QAAQ,OAAO,MAAM;AAEpD"}
1
+ {"version":3,"file":"boot.js","names":[],"sources":["../../../src/fields/encrypted/boot.ts"],"sourcesContent":["import type { Payload } from 'payload'\nimport { resolveKeys } from './crypto/keys'\nimport { scanEncryptedFields } from './scan'\n\n/**\n * Fail-fast key validation at boot: resolves every distinct KeysConfig used by\n * encrypted fields (plus the default ring when any field falls back to it) so\n * missing secrets, broken providers, and empty material surface as startup\n * errors, not as runtime surprises on first write.\n */\nexport const validateEncryptedBoot = async (\n\tpayload: Payload,\n\tpluginKeys?: Parameters<typeof resolveKeys>[0]\n): Promise<void> => {\n\tconst configs = new Set<NonNullable<Parameters<typeof resolveKeys>[0]>>()\n\tif (pluginKeys) {\n\t\tconfigs.add(pluginKeys)\n\t}\n\t// The default ring is only reached when a field has no per-field keys AND the\n\t// plugin declared no keys; ringForRequest resolves marker.keys ?? pluginKeys\n\t// and falls back to the secret-derived ring only when both are absent.\n\tlet usesDefault = false\n\tconst fieldSets = [\n\t\t...payload.config.collections.map((collection) => collection.fields),\n\t\t...payload.config.globals.map((global) => global.fields),\n\t]\n\tfor (const fields of fieldSets) {\n\t\tfor (const [, marker] of scanEncryptedFields(fields)) {\n\t\t\tif (marker.keys) {\n\t\t\t\tconfigs.add(marker.keys)\n\t\t\t} else if (!pluginKeys) {\n\t\t\t\tusesDefault = true\n\t\t\t}\n\t\t}\n\t}\n\tawait Promise.all([...configs].map((config) => resolveKeys(config, payload.config.secret)))\n\tif (usesDefault) {\n\t\tawait resolveKeys(undefined, payload.config.secret)\n\t}\n}\n"],"mappings":";;;;;;;;;AAUA,MAAa,wBAAwB,OACpC,SACA,eACmB;CACnB,MAAM,0BAAU,IAAI,IAAoD;CACxE,IAAI,YACH,QAAQ,IAAI,UAAU;CAKvB,IAAI,cAAc;CAClB,MAAM,YAAY,CACjB,GAAG,QAAQ,OAAO,YAAY,KAAK,eAAe,WAAW,MAAM,GACnE,GAAG,QAAQ,OAAO,QAAQ,KAAK,WAAW,OAAO,MAAM,CACxD;CACA,KAAK,MAAM,UAAU,WACpB,KAAK,MAAM,GAAG,WAAW,oBAAoB,MAAM,GAClD,IAAI,OAAO,MACV,QAAQ,IAAI,OAAO,IAAI;MACjB,IAAI,CAAC,YACX,cAAc;CAIjB,MAAM,QAAQ,IAAI,CAAC,GAAG,OAAO,EAAE,KAAK,WAAW,YAAY,QAAQ,QAAQ,OAAO,MAAM,CAAC,CAAC;CAC1F,IAAI,aACH,MAAM,YAAY,KAAA,GAAW,QAAQ,OAAO,MAAM;AAEpD"}
@@ -2,7 +2,8 @@
2
2
  import { EyeToggle } from "./EyeToggle.js";
3
3
  import { dotString } from "./MaskDots.js";
4
4
  import { FieldDescription, FieldError, FieldLabel, useField, useFormFields, useFormSubmitted } from "@payloadcms/ui";
5
- import { useCallback, useState } from "react";
5
+ import { mergeFieldStyles } from "@payloadcms/ui/shared";
6
+ import { useCallback, useMemo, useState } from "react";
6
7
  import { jsx, jsxs } from "react/jsx-runtime";
7
8
  //#region src/fields/encrypted/components/EncryptedInput.tsx
8
9
  /**
@@ -33,6 +34,7 @@ const EncryptedInput = ({ field, kind, maskDots, path }) => {
33
34
  setValue(event.target.value);
34
35
  };
35
36
  const revealedValue = isNumber ? typeof value === "number" ? value : "" : typeof value === "string" ? value : "";
37
+ const styles = useMemo(() => mergeFieldStyles(field), [field]);
36
38
  return /* @__PURE__ */ jsxs("div", {
37
39
  className: [
38
40
  "field-type",
@@ -41,6 +43,7 @@ const EncryptedInput = ({ field, kind, maskDots, path }) => {
41
43
  "tenx-protected-field",
42
44
  "tenx-protected-field--attached"
43
45
  ].filter(Boolean).join(" "),
46
+ style: styles,
44
47
  children: [/* @__PURE__ */ jsx(FieldLabel, {
45
48
  label: field.label,
46
49
  localized: field.localized,
@@ -1 +1 @@
1
- {"version":3,"file":"EncryptedInput.js","names":[],"sources":["../../../../src/fields/encrypted/components/EncryptedInput.tsx"],"sourcesContent":["'use client'\nimport {\n\tFieldDescription,\n\tFieldError,\n\tFieldLabel,\n\tuseField,\n\tuseFormFields,\n\tuseFormSubmitted,\n} from '@payloadcms/ui'\nimport type React from 'react'\nimport { useCallback, useState } from 'react'\nimport { EyeToggle } from './EyeToggle'\nimport { dotString } from './MaskDots'\nimport type { EncryptedFieldConfig } from './placement'\n\ntype InputKind = 'email' | 'number' | 'text'\n\ninterface EncryptedInputProps {\n\tfield: EncryptedFieldConfig\n\tkind: InputKind\n\tmaskDots: number\n\tpath: string\n}\n\n/**\n * Attached-placement field for single text, email, and number. One input is\n * mounted in both states and only morphs on toggle: a readOnly dots facsimile\n * while concealed, the bound editable input while revealed. Reusing the same\n * element means revealing never remounts the control and never shifts layout.\n * Concealed, the input is readOnly and its value is the dot run, so the decrypted\n * plaintext (already in form state from afterRead) never reaches the DOM and\n * masking cannot mutate form state; setValue only runs while revealed. The eye is\n * a sibling flex segment that stays put across toggles.\n */\nexport const EncryptedInput: React.FC<EncryptedInputProps> = ({ field, kind, maskDots, path }) => {\n\tconst [revealed, setRevealed] = useState(false)\n\tconst { setValue, showError, value } = useField<number | string>({ path })\n\tconst submitted = useFormSubmitted()\n\tconst invalid = useFormFields(([fields]) => fields?.[path]?.valid === false)\n\tconst showFieldError = submitted && invalid\n\tconst toggle = useCallback(() => setRevealed((prev) => !prev), [])\n\tconst inputId = `field-${path.replace(/\\./g, '__')}`\n\tconst isNumber = kind === 'number'\n\n\tconst handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n\t\tif (isNumber) {\n\t\t\tconst parsed = Number.parseFloat(event.target.value)\n\t\t\tsetValue(Number.isNaN(parsed) ? null : parsed)\n\t\t\treturn\n\t\t}\n\t\tsetValue(event.target.value)\n\t}\n\n\tconst revealedValue = isNumber\n\t\t? typeof value === 'number'\n\t\t\t? value\n\t\t\t: ''\n\t\t: typeof value === 'string'\n\t\t\t? value\n\t\t\t: ''\n\n\treturn (\n\t\t<div\n\t\t\tclassName={[\n\t\t\t\t'field-type',\n\t\t\t\tkind,\n\t\t\t\tshowFieldError && 'error',\n\t\t\t\t'tenx-protected-field',\n\t\t\t\t'tenx-protected-field--attached',\n\t\t\t]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(' ')}\n\t\t>\n\t\t\t<FieldLabel\n\t\t\t\tlabel={field.label}\n\t\t\t\tlocalized={field.localized}\n\t\t\t\tpath={path}\n\t\t\t\trequired={field.required}\n\t\t\t/>\n\t\t\t<div className=\"field-type__wrap\">\n\t\t\t\t<FieldError path={path} />\n\t\t\t\t<div className=\"tenx-protected-field__attached-row\">\n\t\t\t\t\t<input\n\t\t\t\t\t\taria-invalid={revealed ? showError : undefined}\n\t\t\t\t\t\tautoComplete={revealed && !isNumber ? field.admin?.autoComplete : undefined}\n\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\trevealed\n\t\t\t\t\t\t\t\t? 'tenx-protected-field__revealed-input'\n\t\t\t\t\t\t\t\t: 'tenx-protected-field__masked-input'\n\t\t\t\t\t\t}\n\t\t\t\t\t\tid={inputId}\n\t\t\t\t\t\tinputMode={revealed && isNumber ? 'decimal' : undefined}\n\t\t\t\t\t\tname={path}\n\t\t\t\t\t\tonChange={revealed ? handleChange : undefined}\n\t\t\t\t\t\tplaceholder={\n\t\t\t\t\t\t\trevealed && !isNumber && typeof field.admin?.placeholder === 'string'\n\t\t\t\t\t\t\t\t? field.admin.placeholder\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\treadOnly={!revealed}\n\t\t\t\t\t\tstep={revealed && isNumber ? field.admin?.step : undefined}\n\t\t\t\t\t\ttabIndex={revealed ? undefined : -1}\n\t\t\t\t\t\ttype={revealed ? (isNumber ? 'number' : kind === 'email' ? 'email' : 'text') : 'text'}\n\t\t\t\t\t\tvalue={revealed ? revealedValue : dotString(maskDots)}\n\t\t\t\t\t/>\n\t\t\t\t\t<div className=\"tenx-protected-field__eye-wrap tenx-protected-field__eye-wrap--attached\">\n\t\t\t\t\t\t<EyeToggle\n\t\t\t\t\t\t\tclassName=\"tenx-protected-field__eye--attached\"\n\t\t\t\t\t\t\tonToggle={toggle}\n\t\t\t\t\t\t\trevealed={revealed}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<FieldDescription description={field.admin?.description} path={path} />\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkCA,MAAa,kBAAiD,EAAE,OAAO,MAAM,UAAU,WAAW;CACjG,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAC9C,MAAM,EAAE,UAAU,WAAW,UAAU,SAA0B,EAAE,KAAK,CAAC;CACzE,MAAM,YAAY,iBAAiB;CACnC,MAAM,UAAU,eAAe,CAAC,YAAY,SAAS,OAAO,UAAU,KAAK;CAC3E,MAAM,iBAAiB,aAAa;CACpC,MAAM,SAAS,kBAAkB,aAAa,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC;CACjE,MAAM,UAAU,SAAS,KAAK,QAAQ,OAAO,IAAI;CACjD,MAAM,WAAW,SAAS;CAE1B,MAAM,gBAAgB,UAA+C;EACpE,IAAI,UAAU;GACb,MAAM,SAAS,OAAO,WAAW,MAAM,OAAO,KAAK;GACnD,SAAS,OAAO,MAAM,MAAM,IAAI,OAAO,MAAM;GAC7C;EACD;EACA,SAAS,MAAM,OAAO,KAAK;CAC5B;CAEA,MAAM,gBAAgB,WACnB,OAAO,UAAU,WAChB,QACA,KACD,OAAO,UAAU,WAChB,QACA;CAEJ,OACC,qBAAC,OAAD;EACC,WAAW;GACV;GACA;GACA,kBAAkB;GAClB;GACA;EACD,EACE,OAAO,OAAO,EACd,KAAK,GAAG;YATX,CAWC,oBAAC,YAAD;GACC,OAAO,MAAM;GACb,WAAW,MAAM;GACX;GACN,UAAU,MAAM;EAChB,CAAA,GACD,qBAAC,OAAD;GAAK,WAAU;aAAf;IACC,oBAAC,YAAD,EAAkB,KAAO,CAAA;IACzB,qBAAC,OAAD;KAAK,WAAU;eAAf,CACC,oBAAC,SAAD;MACC,gBAAc,WAAW,YAAY,KAAA;MACrC,cAAc,YAAY,CAAC,WAAW,MAAM,OAAO,eAAe,KAAA;MAClE,WACC,WACG,yCACA;MAEJ,IAAI;MACJ,WAAW,YAAY,WAAW,YAAY,KAAA;MAC9C,MAAM;MACN,UAAU,WAAW,eAAe,KAAA;MACpC,aACC,YAAY,CAAC,YAAY,OAAO,MAAM,OAAO,gBAAgB,WAC1D,MAAM,MAAM,cACZ,KAAA;MAEJ,UAAU,CAAC;MACX,MAAM,YAAY,WAAW,MAAM,OAAO,OAAO,KAAA;MACjD,UAAU,WAAW,KAAA,IAAY;MACjC,MAAM,WAAY,WAAW,WAAW,SAAS,UAAU,UAAU,SAAU;MAC/E,OAAO,WAAW,gBAAgB,UAAU,QAAQ;KACpD,CAAA,GACD,oBAAC,OAAD;MAAK,WAAU;gBACd,oBAAC,WAAD;OACC,WAAU;OACV,UAAU;OACA;MACV,CAAA;KACG,CAAA,CACD;;IACL,oBAAC,kBAAD;KAAkB,aAAa,MAAM,OAAO;KAAmB;IAAO,CAAA;GAClE;IACD;;AAEP"}
1
+ {"version":3,"file":"EncryptedInput.js","names":[],"sources":["../../../../src/fields/encrypted/components/EncryptedInput.tsx"],"sourcesContent":["'use client'\nimport {\n\tFieldDescription,\n\tFieldError,\n\tFieldLabel,\n\tuseField,\n\tuseFormFields,\n\tuseFormSubmitted,\n} from '@payloadcms/ui'\nimport { mergeFieldStyles } from '@payloadcms/ui/shared'\nimport type React from 'react'\nimport { useCallback, useMemo, useState } from 'react'\nimport { EyeToggle } from './EyeToggle'\nimport { dotString } from './MaskDots'\nimport type { EncryptedFieldConfig } from './placement'\n\ntype InputKind = 'email' | 'number' | 'text'\n\ninterface EncryptedInputProps {\n\tfield: EncryptedFieldConfig\n\tkind: InputKind\n\tmaskDots: number\n\tpath: string\n}\n\n/**\n * Attached-placement field for single text, email, and number. One input is\n * mounted in both states and only morphs on toggle: a readOnly dots facsimile\n * while concealed, the bound editable input while revealed. Reusing the same\n * element means revealing never remounts the control and never shifts layout.\n * Concealed, the input is readOnly and its value is the dot run, so the decrypted\n * plaintext (already in form state from afterRead) never reaches the DOM and\n * masking cannot mutate form state; setValue only runs while revealed. The eye is\n * a sibling flex segment that stays put across toggles.\n */\nexport const EncryptedInput: React.FC<EncryptedInputProps> = ({ field, kind, maskDots, path }) => {\n\tconst [revealed, setRevealed] = useState(false)\n\tconst { setValue, showError, value } = useField<number | string>({ path })\n\tconst submitted = useFormSubmitted()\n\tconst invalid = useFormFields(([fields]) => fields?.[path]?.valid === false)\n\tconst showFieldError = submitted && invalid\n\tconst toggle = useCallback(() => setRevealed((prev) => !prev), [])\n\tconst inputId = `field-${path.replace(/\\./g, '__')}`\n\tconst isNumber = kind === 'number'\n\n\tconst handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n\t\tif (isNumber) {\n\t\t\tconst parsed = Number.parseFloat(event.target.value)\n\t\t\tsetValue(Number.isNaN(parsed) ? null : parsed)\n\t\t\treturn\n\t\t}\n\t\tsetValue(event.target.value)\n\t}\n\n\tconst revealedValue = isNumber\n\t\t? typeof value === 'number'\n\t\t\t? value\n\t\t\t: ''\n\t\t: typeof value === 'string'\n\t\t\t? value\n\t\t\t: ''\n\n\t// A custom Field component short-circuits the path where Payload applies\n\t// admin.width and admin.style, so the field has to carry them itself.\n\tconst styles = useMemo(() => mergeFieldStyles(field), [field])\n\n\treturn (\n\t\t<div\n\t\t\tclassName={[\n\t\t\t\t'field-type',\n\t\t\t\tkind,\n\t\t\t\tshowFieldError && 'error',\n\t\t\t\t'tenx-protected-field',\n\t\t\t\t'tenx-protected-field--attached',\n\t\t\t]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(' ')}\n\t\t\tstyle={styles}\n\t\t>\n\t\t\t<FieldLabel\n\t\t\t\tlabel={field.label}\n\t\t\t\tlocalized={field.localized}\n\t\t\t\tpath={path}\n\t\t\t\trequired={field.required}\n\t\t\t/>\n\t\t\t<div className=\"field-type__wrap\">\n\t\t\t\t<FieldError path={path} />\n\t\t\t\t<div className=\"tenx-protected-field__attached-row\">\n\t\t\t\t\t<input\n\t\t\t\t\t\taria-invalid={revealed ? showError : undefined}\n\t\t\t\t\t\tautoComplete={revealed && !isNumber ? field.admin?.autoComplete : undefined}\n\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\trevealed\n\t\t\t\t\t\t\t\t? 'tenx-protected-field__revealed-input'\n\t\t\t\t\t\t\t\t: 'tenx-protected-field__masked-input'\n\t\t\t\t\t\t}\n\t\t\t\t\t\tid={inputId}\n\t\t\t\t\t\tinputMode={revealed && isNumber ? 'decimal' : undefined}\n\t\t\t\t\t\tname={path}\n\t\t\t\t\t\tonChange={revealed ? handleChange : undefined}\n\t\t\t\t\t\tplaceholder={\n\t\t\t\t\t\t\trevealed && !isNumber && typeof field.admin?.placeholder === 'string'\n\t\t\t\t\t\t\t\t? field.admin.placeholder\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\treadOnly={!revealed}\n\t\t\t\t\t\tstep={revealed && isNumber ? field.admin?.step : undefined}\n\t\t\t\t\t\ttabIndex={revealed ? undefined : -1}\n\t\t\t\t\t\ttype={revealed ? (isNumber ? 'number' : kind === 'email' ? 'email' : 'text') : 'text'}\n\t\t\t\t\t\tvalue={revealed ? revealedValue : dotString(maskDots)}\n\t\t\t\t\t/>\n\t\t\t\t\t<div className=\"tenx-protected-field__eye-wrap tenx-protected-field__eye-wrap--attached\">\n\t\t\t\t\t\t<EyeToggle\n\t\t\t\t\t\t\tclassName=\"tenx-protected-field__eye--attached\"\n\t\t\t\t\t\t\tonToggle={toggle}\n\t\t\t\t\t\t\trevealed={revealed}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<FieldDescription description={field.admin?.description} path={path} />\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmCA,MAAa,kBAAiD,EAAE,OAAO,MAAM,UAAU,WAAW;CACjG,MAAM,CAA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AAC,YAAY,OAAO,MAAM,OAAO,gBAAgB,WAC1D,MAAM,MAAM,cACZ,KAAA;MAEJ,UAAU,CAAC;MACX,MAAM,YAAY,WAAW,MAAM,OAAO,OAAO,KAAA;MACjD,UAAU,WAAW,KAAA,IAAY;MACjC,MAAM,WAAY,WAAW,WAAW,SAAS,UAAU,UAAU,SAAU;MAC/E,OAAO,WAAW,gBAAgB,UAAU,QAAQ;KACpD,CAAA,GACD,oBAAC,OAAD;MAAK,WAAU;gBACd,oBAAC,WAAD;OACC,WAAU;OACV,UAAU;OACA;MACV,CAAA;KACG,CAAA,CACD;;IACL,oBAAC,kBAAD;KAAkB,aAAa,MAAM,OAAO;KAAmB;IAAO,CAAA;GAClE;IACD;;AAEP"}
@@ -2,7 +2,8 @@
2
2
  import { EyeToggle } from "./EyeToggle.js";
3
3
  import { dotString } from "./MaskDots.js";
4
4
  import { FieldDescription, FieldError, FieldLabel, useField, useFormFields, useFormSubmitted } from "@payloadcms/ui";
5
- import { useState } from "react";
5
+ import { mergeFieldStyles } from "@payloadcms/ui/shared";
6
+ import { useMemo, useState } from "react";
6
7
  import { jsx, jsxs } from "react/jsx-runtime";
7
8
  //#region src/fields/encrypted/components/EncryptedTextarea.tsx
8
9
  /**
@@ -34,14 +35,17 @@ const EncryptedTextarea = ({ field, maskDots, path }) => {
34
35
  const [revealed, setRevealed] = useState(false);
35
36
  const submitted = useFormSubmitted();
36
37
  const invalid = useFormFields(([fields]) => fields?.[path]?.valid === false);
38
+ const showError = submitted && invalid;
39
+ const styles = useMemo(() => mergeFieldStyles(field), [field]);
37
40
  return /* @__PURE__ */ jsxs("div", {
38
41
  className: [
39
42
  "field-type",
40
43
  "textarea",
41
- submitted && invalid && "error",
44
+ showError && "error",
42
45
  "tenx-protected-field",
43
46
  "tenx-protected-field--corner"
44
47
  ].filter(Boolean).join(" "),
48
+ style: styles,
45
49
  children: [/* @__PURE__ */ jsx(FieldLabel, {
46
50
  label: field.label,
47
51
  localized: field.localized,
@@ -1 +1 @@
1
- {"version":3,"file":"EncryptedTextarea.js","names":[],"sources":["../../../../src/fields/encrypted/components/EncryptedTextarea.tsx"],"sourcesContent":["'use client'\nimport {\n\tFieldDescription,\n\tFieldError,\n\tFieldLabel,\n\tuseField,\n\tuseFormFields,\n\tuseFormSubmitted,\n} from '@payloadcms/ui'\nimport type React from 'react'\nimport { useState } from 'react'\nimport { EyeToggle } from './EyeToggle'\nimport { dotString } from './MaskDots'\nimport type { EncryptedFieldConfig } from './placement'\n\ninterface EncryptedTextareaProps {\n\tfield: EncryptedFieldConfig\n\tmaskDots: number\n\tpath: string\n}\n\n/**\n * The revealed, bound textarea. The only part that calls `useField`; the\n * concealed state renders a readOnly dots textarea instead, so masking cannot\n * write form state. Validation stays server-side.\n */\nconst BoundTextarea: React.FC<{ field: EncryptedFieldConfig; path: string }> = ({\n\tfield,\n\tpath,\n}) => {\n\tconst { setValue, value } = useField<string>({ path })\n\treturn (\n\t\t<div className=\"textarea-outer\">\n\t\t\t<textarea\n\t\t\t\tclassName=\"tenx-protected-field__revealed-textarea\"\n\t\t\t\tid={`field-${path.replace(/\\./g, '__')}`}\n\t\t\t\tname={path}\n\t\t\t\tonChange={(event) => setValue(event.target.value)}\n\t\t\t\trows={field.admin?.rows}\n\t\t\t\tvalue={typeof value === 'string' ? value : ''}\n\t\t\t/>\n\t\t</div>\n\t)\n}\n\n/**\n * Corner-placement wrapper for textarea. Renders the stable native chrome with\n * the eye pinned to the top-right corner of the field wrap; only the textarea\n * swaps between the concealed dots facsimile and the bound textarea. The wrapper\n * only reads form state (no `useField`, no `setValue`).\n */\nexport const EncryptedTextarea: React.FC<EncryptedTextareaProps> = ({ field, maskDots, path }) => {\n\tconst [revealed, setRevealed] = useState(false)\n\tconst submitted = useFormSubmitted()\n\tconst invalid = useFormFields(([fields]) => fields?.[path]?.valid === false)\n\tconst showError = submitted && invalid\n\treturn (\n\t\t<div\n\t\t\tclassName={[\n\t\t\t\t'field-type',\n\t\t\t\t'textarea',\n\t\t\t\tshowError && 'error',\n\t\t\t\t'tenx-protected-field',\n\t\t\t\t'tenx-protected-field--corner',\n\t\t\t]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(' ')}\n\t\t>\n\t\t\t<FieldLabel\n\t\t\t\tlabel={field.label}\n\t\t\t\tlocalized={field.localized}\n\t\t\t\tpath={path}\n\t\t\t\trequired={field.required}\n\t\t\t/>\n\t\t\t<div className=\"field-type__wrap\">\n\t\t\t\t<FieldError path={path} />\n\t\t\t\t{revealed ? (\n\t\t\t\t\t<BoundTextarea field={field} path={path} />\n\t\t\t\t) : (\n\t\t\t\t\t<div className=\"textarea-outer\">\n\t\t\t\t\t\t<textarea\n\t\t\t\t\t\t\tclassName=\"tenx-protected-field__masked-textarea\"\n\t\t\t\t\t\t\treadOnly\n\t\t\t\t\t\t\trows={field.admin?.rows}\n\t\t\t\t\t\t\ttabIndex={-1}\n\t\t\t\t\t\t\tvalue={dotString(maskDots)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t\t<div className=\"tenx-protected-field__eye-wrap tenx-protected-field__eye-wrap--corner\">\n\t\t\t\t\t<EyeToggle\n\t\t\t\t\t\tclassName=\"tenx-protected-field__eye--floating\"\n\t\t\t\t\t\tonToggle={() => setRevealed((prev) => !prev)}\n\t\t\t\t\t\trevealed={revealed}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<FieldDescription description={field.admin?.description} path={path} />\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;;;;;;;;;AA0BA,MAAM,iBAA0E,EAC/E,OACA,WACK;CACL,MAAM,EAAE,UAAU,UAAU,SAAiB,EAAE,KAAK,CAAC;CACrD,OACC,oBAAC,OAAD;EAAK,WAAU;YACd,oBAAC,YAAD;GACC,WAAU;GACV,IAAI,SAAS,KAAK,QAAQ,OAAO,IAAI;GACrC,MAAM;GACN,WAAW,UAAU,SAAS,MAAM,OAAO,KAAK;GAChD,MAAM,MAAM,OAAO;GACnB,OAAO,OAAO,UAAU,WAAW,QAAQ;EAC3C,CAAA;CACG,CAAA;AAEP;;;;;;;AAQA,MAAa,qBAAuD,EAAE,OAAO,UAAU,WAAW;CACjG,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAC9C,MAAM,YAAY,iBAAiB;CACnC,MAAM,UAAU,eAAe,CAAC,YAAY,SAAS,OAAO,UAAU,KAAK;CAE3E,OACC,qBAAC,OAAD;EACC,WAAW;GACV;GACA;GALe,aAAa,WAMf;GACb;GACA;EACD,EACE,OAAO,OAAO,EACd,KAAK,GAAG;YATX,CAWC,oBAAC,YAAD;GACC,OAAO,MAAM;GACb,WAAW,MAAM;GACX;GACN,UAAU,MAAM;EAChB,CAAA,GACD,qBAAC,OAAD;GAAK,WAAU;aAAf;IACC,oBAAC,YAAD,EAAkB,KAAO,CAAA;IACxB,WACA,oBAAC,eAAD;KAAsB;KAAa;IAAO,CAAA,IAE1C,oBAAC,OAAD;KAAK,WAAU;eACd,oBAAC,YAAD;MACC,WAAU;MACV,UAAA;MACA,MAAM,MAAM,OAAO;MACnB,UAAU;MACV,OAAO,UAAU,QAAQ;KACzB,CAAA;IACG,CAAA;IAEN,oBAAC,OAAD;KAAK,WAAU;eACd,oBAAC,WAAD;MACC,WAAU;MACV,gBAAgB,aAAa,SAAS,CAAC,IAAI;MACjC;KACV,CAAA;IACG,CAAA;IACL,oBAAC,kBAAD;KAAkB,aAAa,MAAM,OAAO;KAAmB;IAAO,CAAA;GAClE;IACD;;AAEP"}
1
+ {"version":3,"file":"EncryptedTextarea.js","names":[],"sources":["../../../../src/fields/encrypted/components/EncryptedTextarea.tsx"],"sourcesContent":["'use client'\nimport {\n\tFieldDescription,\n\tFieldError,\n\tFieldLabel,\n\tuseField,\n\tuseFormFields,\n\tuseFormSubmitted,\n} from '@payloadcms/ui'\nimport { mergeFieldStyles } from '@payloadcms/ui/shared'\nimport type React from 'react'\nimport { useMemo, useState } from 'react'\nimport { EyeToggle } from './EyeToggle'\nimport { dotString } from './MaskDots'\nimport type { EncryptedFieldConfig } from './placement'\n\ninterface EncryptedTextareaProps {\n\tfield: EncryptedFieldConfig\n\tmaskDots: number\n\tpath: string\n}\n\n/**\n * The revealed, bound textarea. The only part that calls `useField`; the\n * concealed state renders a readOnly dots textarea instead, so masking cannot\n * write form state. Validation stays server-side.\n */\nconst BoundTextarea: React.FC<{ field: EncryptedFieldConfig; path: string }> = ({\n\tfield,\n\tpath,\n}) => {\n\tconst { setValue, value } = useField<string>({ path })\n\treturn (\n\t\t<div className=\"textarea-outer\">\n\t\t\t<textarea\n\t\t\t\tclassName=\"tenx-protected-field__revealed-textarea\"\n\t\t\t\tid={`field-${path.replace(/\\./g, '__')}`}\n\t\t\t\tname={path}\n\t\t\t\tonChange={(event) => setValue(event.target.value)}\n\t\t\t\trows={field.admin?.rows}\n\t\t\t\tvalue={typeof value === 'string' ? value : ''}\n\t\t\t/>\n\t\t</div>\n\t)\n}\n\n/**\n * Corner-placement wrapper for textarea. Renders the stable native chrome with\n * the eye pinned to the top-right corner of the field wrap; only the textarea\n * swaps between the concealed dots facsimile and the bound textarea. The wrapper\n * only reads form state (no `useField`, no `setValue`).\n */\nexport const EncryptedTextarea: React.FC<EncryptedTextareaProps> = ({ field, maskDots, path }) => {\n\tconst [revealed, setRevealed] = useState(false)\n\tconst submitted = useFormSubmitted()\n\tconst invalid = useFormFields(([fields]) => fields?.[path]?.valid === false)\n\tconst showError = submitted && invalid\n\t// A custom Field component short-circuits the path where Payload applies\n\t// admin.width and admin.style, so the field has to carry them itself.\n\tconst styles = useMemo(() => mergeFieldStyles(field), [field])\n\n\treturn (\n\t\t<div\n\t\t\tclassName={[\n\t\t\t\t'field-type',\n\t\t\t\t'textarea',\n\t\t\t\tshowError && 'error',\n\t\t\t\t'tenx-protected-field',\n\t\t\t\t'tenx-protected-field--corner',\n\t\t\t]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(' ')}\n\t\t\tstyle={styles}\n\t\t>\n\t\t\t<FieldLabel\n\t\t\t\tlabel={field.label}\n\t\t\t\tlocalized={field.localized}\n\t\t\t\tpath={path}\n\t\t\t\trequired={field.required}\n\t\t\t/>\n\t\t\t<div className=\"field-type__wrap\">\n\t\t\t\t<FieldError path={path} />\n\t\t\t\t{revealed ? (\n\t\t\t\t\t<BoundTextarea field={field} path={path} />\n\t\t\t\t) : (\n\t\t\t\t\t<div className=\"textarea-outer\">\n\t\t\t\t\t\t<textarea\n\t\t\t\t\t\t\tclassName=\"tenx-protected-field__masked-textarea\"\n\t\t\t\t\t\t\treadOnly\n\t\t\t\t\t\t\trows={field.admin?.rows}\n\t\t\t\t\t\t\ttabIndex={-1}\n\t\t\t\t\t\t\tvalue={dotString(maskDots)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t\t<div className=\"tenx-protected-field__eye-wrap tenx-protected-field__eye-wrap--corner\">\n\t\t\t\t\t<EyeToggle\n\t\t\t\t\t\tclassName=\"tenx-protected-field__eye--floating\"\n\t\t\t\t\t\tonToggle={() => setRevealed((prev) => !prev)}\n\t\t\t\t\t\trevealed={revealed}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<FieldDescription description={field.admin?.description} path={path} />\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;;;;;;;;;;AA2BA,MAAM,iBAA0E,EAC/E,OACA,WACK;CACL,MAAM,EAAE,UAAU,UAAU,SAAiB,EAAE,KAAK,CAAC;CACrD,OACC,oBAAC,OAAD;EAAK,WAAU;YACd,oBAAC,YAAD;GACC,WAAU;GACV,IAAI,SAAS,KAAK,QAAQ,OAAO,IAAI;GACrC,MAAM;GACN,WAAW,UAAU,SAAS,MAAM,OAAO,KAAK;GAChD,MAAM,MAAM,OAAO;GACnB,OAAO,OAAO,UAAU,WAAW,QAAQ;EAC3C,CAAA;CACG,CAAA;AAEP;;;;;;;AAQA,MAAa,qBAAuD,EAAE,OAAO,UAAU,WAAW;CACjG,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAC9C,MAAM,YAAY,iBAAiB;CACnC,MAAM,UAAU,eAAe,CAAC,YAAY,SAAS,OAAO,UAAU,KAAK;CAC3E,MAAM,YAAY,aAAa;CAG/B,MAAM,SAAS,cAAc,iBAAiB,KAAK,GAAG,CAAC,KAAK,CAAC;CAE7D,OACC,qBAAC,OAAD;EACC,WAAW;GACV;GACA;GACA,aAAa;GACb;GACA;EACD,EACE,OAAO,OAAO,EACd,KAAK,GAAG;EACV,OAAO;YAVR,CAYC,oBAAC,YAAD;GACC,OAAO,MAAM;GACb,WAAW,MAAM;GACX;GACN,UAAU,MAAM;EAChB,CAAA,GACD,qBAAC,OAAD;GAAK,WAAU;aAAf;IACC,oBAAC,YAAD,EAAkB,KAAO,CAAA;IACxB,WACA,oBAAC,eAAD;KAAsB;KAAa;IAAO,CAAA,IAE1C,oBAAC,OAAD;KAAK,WAAU;eACd,oBAAC,YAAD;MACC,WAAU;MACV,UAAA;MACA,MAAM,MAAM,OAAO;MACnB,UAAU;MACV,OAAO,UAAU,QAAQ;KACzB,CAAA;IACG,CAAA;IAEN,oBAAC,OAAD;KAAK,WAAU;eACd,oBAAC,WAAD;MACC,WAAU;MACV,gBAAgB,aAAa,SAAS,CAAC,IAAI;MACjC;KACV,CAAA;IACG,CAAA;IACL,oBAAC,kBAAD;KAAkB,aAAa,MAAM,OAAO;KAAmB;IAAO,CAAA;GAClE;IACD;;AAEP"}
@@ -2,17 +2,26 @@ import { DefaultServerCellComponentProps } from "payload";
2
2
 
3
3
  //#region src/fields/encrypted/components/ProtectedCell.d.ts
4
4
  /**
5
- * List cell for masked encrypted fields. Never renders cellData: list data has
6
- * been decrypted by afterRead, and the list surface must not leak it. Server
7
- * cell, so it translates the accessible label per the admin's locale. The dot
8
- * count mirrors the field's `maskDots` (forwarded via clientProps) for list
9
- * consistency, defaulting to the same 8 as the field.
5
+ * List cell for masked and write-only encrypted fields. Never renders cellData:
6
+ * list data has been decrypted by afterRead (masked) or stripped (write-only),
7
+ * and the list surface must not leak it. Server cell, so it translates the
8
+ * accessible label per the admin's locale. The dot count mirrors the field's
9
+ * `maskDots` (forwarded via clientProps) for list consistency, defaulting to
10
+ * the same 8 as the field. `setName` (write-only fields) points at the virtual
11
+ * set-indicator sibling in rowData; an unset secret renders an em dash instead
12
+ * of dots that would imply a stored value. `hintName` points at the stored
13
+ * identification hint, which replaces the dots when present.
10
14
  */
11
15
  declare const ProtectedCell: ({
16
+ hintName,
12
17
  i18n,
13
- maskDots
18
+ maskDots,
19
+ rowData,
20
+ setName
14
21
  }: DefaultServerCellComponentProps & {
22
+ hintName?: string;
15
23
  maskDots?: number;
24
+ setName?: string;
16
25
  }) => import("react/jsx-runtime").JSX.Element;
17
26
  //#endregion
18
27
  export { ProtectedCell };
@@ -1,26 +1,49 @@
1
+ import { formatHint } from "../hint.js";
1
2
  import { keys } from "../../../translations/keys.js";
2
3
  import { clampMaskDots } from "../maskDots.js";
3
4
  import { asTranslate } from "../../../translations/server.js";
4
5
  import { jsx, jsxs } from "react/jsx-runtime";
5
6
  //#region src/fields/encrypted/components/ProtectedCell.tsx
6
7
  /**
7
- * List cell for masked encrypted fields. Never renders cellData: list data has
8
- * been decrypted by afterRead, and the list surface must not leak it. Server
9
- * cell, so it translates the accessible label per the admin's locale. The dot
10
- * count mirrors the field's `maskDots` (forwarded via clientProps) for list
11
- * consistency, defaulting to the same 8 as the field.
8
+ * List cell for masked and write-only encrypted fields. Never renders cellData:
9
+ * list data has been decrypted by afterRead (masked) or stripped (write-only),
10
+ * and the list surface must not leak it. Server cell, so it translates the
11
+ * accessible label per the admin's locale. The dot count mirrors the field's
12
+ * `maskDots` (forwarded via clientProps) for list consistency, defaulting to
13
+ * the same 8 as the field. `setName` (write-only fields) points at the virtual
14
+ * set-indicator sibling in rowData; an unset secret renders an em dash instead
15
+ * of dots that would imply a stored value. `hintName` points at the stored
16
+ * identification hint, which replaces the dots when present.
12
17
  */
13
- const ProtectedCell = ({ i18n, maskDots }) => /* @__PURE__ */ jsxs("span", {
18
+ const ProtectedCell = ({ hintName, i18n, maskDots, rowData, setName }) => {
19
+ const row = rowData;
20
+ if (setName && row?.[setName] !== true) return /* @__PURE__ */ jsx("span", {
21
+ "aria-label": asTranslate(i18n.t)(keys.secretNotSet),
22
+ className: "tenx-protected-cell",
23
+ role: "img",
24
+ children: "—"
25
+ });
26
+ const hint = hintName ? row?.[hintName] : void 0;
27
+ return renderLocked({
28
+ i18n,
29
+ text: typeof hint === "string" && hint.length > 0 ? formatHint(hint, clampMaskDots(maskDots)) : void 0,
30
+ maskDots
31
+ });
32
+ };
33
+ const renderLocked = ({ i18n, maskDots, text }) => /* @__PURE__ */ jsxs("span", {
14
34
  className: "tenx-protected-cell",
15
35
  style: {
16
36
  alignItems: "center",
17
37
  display: "inline-flex",
18
- gap: "0.4em"
38
+ gap: "0.4em",
39
+ maxWidth: "100%",
40
+ minWidth: 0
19
41
  },
20
42
  children: [/* @__PURE__ */ jsxs("svg", {
21
43
  "aria-hidden": "true",
22
44
  fill: "none",
23
45
  height: "12",
46
+ style: { flexShrink: 0 },
24
47
  stroke: "currentColor",
25
48
  strokeWidth: "2",
26
49
  viewBox: "0 0 24 24",
@@ -35,7 +58,13 @@ const ProtectedCell = ({ i18n, maskDots }) => /* @__PURE__ */ jsxs("span", {
35
58
  }), /* @__PURE__ */ jsx("span", {
36
59
  "aria-label": asTranslate(i18n.t)(keys.encryptedValue),
37
60
  role: "img",
38
- children: "•".repeat(clampMaskDots(maskDots))
61
+ style: {
62
+ minWidth: 0,
63
+ overflow: "hidden",
64
+ textOverflow: "ellipsis",
65
+ whiteSpace: "nowrap"
66
+ },
67
+ children: text ?? "•".repeat(clampMaskDots(maskDots))
39
68
  })]
40
69
  });
41
70
  //#endregion