@10x-media/fields 0.1.0-beta.0 → 0.1.0-beta.10
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.
- package/CHANGELOG.md +173 -0
- package/README.md +8 -4
- package/dist/exports/client.d.ts +10 -1
- package/dist/exports/client.js +9 -1
- package/dist/exports/color-utils.d.ts +4 -2
- package/dist/exports/color-utils.js +3 -1
- package/dist/exports/color.d.ts +5 -2
- package/dist/exports/color.js +4 -1
- package/dist/exports/encrypted.d.ts +7 -4
- package/dist/exports/encrypted.js +6 -3
- package/dist/exports/icon-adapters/radix.d.ts +2 -2
- package/dist/exports/icon-adapters/radix.js +2 -2
- package/dist/exports/icon-react.d.ts +2 -2
- package/dist/exports/icon.d.ts +6 -2
- package/dist/exports/icon.js +6 -2
- package/dist/exports/measurement-utils.d.ts +9 -0
- package/dist/exports/measurement-utils.js +8 -0
- package/dist/exports/measurement.d.ts +11 -0
- package/dist/exports/measurement.js +10 -0
- package/dist/exports/phone-utils.d.ts +4 -0
- package/dist/exports/phone-utils.js +4 -0
- package/dist/exports/phone.d.ts +6 -0
- package/dist/exports/phone.js +3 -0
- package/dist/exports/rsc.d.ts +5 -1
- package/dist/exports/rsc.js +5 -1
- package/dist/exports/types.d.ts +3 -2
- package/dist/fields/color/client/ColorField.d.ts +2 -0
- package/dist/fields/color/client/ColorField.js +35 -288
- package/dist/fields/color/client/ColorField.js.map +1 -1
- package/dist/fields/color/client/ColorInput.d.ts +44 -0
- package/dist/fields/color/client/ColorInput.js +374 -0
- package/dist/fields/color/client/ColorInput.js.map +1 -0
- package/dist/fields/color/client/ColorPickerPanel.d.ts +3 -1
- package/dist/fields/color/client/ColorPickerPanel.js +31 -5
- package/dist/fields/color/client/ColorPickerPanel.js.map +1 -1
- package/dist/fields/color/client/colorField.css +30 -0
- package/dist/fields/color/colorField.d.ts +9 -2
- package/dist/fields/color/colorField.js +68 -15
- package/dist/fields/color/colorField.js.map +1 -1
- package/dist/fields/color/engine/index.d.ts +2 -1
- package/dist/fields/color/engine/scheme.d.ts +13 -0
- package/dist/fields/color/engine/scheme.js +12 -0
- package/dist/fields/color/engine/scheme.js.map +1 -0
- package/dist/fields/color/options.d.ts +5 -4
- package/dist/fields/color/options.js.map +1 -1
- package/dist/fields/color/paths.d.ts +1 -0
- package/dist/fields/color/paths.js +32 -0
- package/dist/fields/color/paths.js.map +1 -0
- package/dist/fields/color/presetChip.js +10 -9
- package/dist/fields/color/presetChip.js.map +1 -1
- package/dist/fields/color/presetReference.d.ts +13 -0
- package/dist/fields/color/presetReference.js +94 -0
- package/dist/fields/color/presetReference.js.map +1 -0
- package/dist/fields/color/presetsFromArray.d.ts +30 -0
- package/dist/fields/color/presetsFromArray.js +58 -0
- package/dist/fields/color/presetsFromArray.js.map +1 -0
- package/dist/fields/color/presetsFromDoc.js +1 -23
- package/dist/fields/color/presetsFromDoc.js.map +1 -1
- package/dist/fields/color/resolvePresets.d.ts +2 -2
- package/dist/fields/color/resolvePresets.js +38 -8
- package/dist/fields/color/resolvePresets.js.map +1 -1
- package/dist/fields/color/schemeValue.js +30 -0
- package/dist/fields/color/schemeValue.js.map +1 -0
- package/dist/fields/color/server/ColorCell.js +9 -3
- package/dist/fields/color/server/ColorCell.js.map +1 -1
- package/dist/fields/color/server/colorCell.css +5 -0
- package/dist/fields/color/valueIssue.js +23 -0
- package/dist/fields/color/valueIssue.js.map +1 -0
- package/dist/fields/encrypted/boot.js +2 -1
- package/dist/fields/encrypted/boot.js.map +1 -1
- package/dist/fields/encrypted/components/EncryptedInput.js +4 -1
- package/dist/fields/encrypted/components/EncryptedInput.js.map +1 -1
- package/dist/fields/encrypted/components/EncryptedTextarea.js +6 -2
- package/dist/fields/encrypted/components/EncryptedTextarea.js.map +1 -1
- package/dist/fields/encrypted/components/ProtectedCell.d.ts +15 -6
- package/dist/fields/encrypted/components/ProtectedCell.js +37 -8
- package/dist/fields/encrypted/components/ProtectedCell.js.map +1 -1
- package/dist/fields/encrypted/components/ProtectedField.css +134 -39
- package/dist/fields/encrypted/components/ProtectedField.d.ts +3 -0
- package/dist/fields/encrypted/components/ProtectedField.js +14 -0
- package/dist/fields/encrypted/components/ProtectedField.js.map +1 -1
- package/dist/fields/encrypted/components/WriteOnlyActions.js +65 -0
- package/dist/fields/encrypted/components/WriteOnlyActions.js.map +1 -0
- package/dist/fields/encrypted/components/WriteOnlyField.js +286 -0
- package/dist/fields/encrypted/components/WriteOnlyField.js.map +1 -0
- package/dist/fields/encrypted/components/writeOnlyIntent.js +69 -0
- package/dist/fields/encrypted/components/writeOnlyIntent.js.map +1 -0
- package/dist/fields/encrypted/crypto/wire.d.ts +10 -1
- package/dist/fields/encrypted/crypto/wire.js +1 -1
- package/dist/fields/encrypted/encryptedField.js +63 -6
- package/dist/fields/encrypted/encryptedField.js.map +1 -1
- package/dist/fields/encrypted/generateSecret.d.ts +10 -0
- package/dist/fields/encrypted/generateSecret.js +41 -0
- package/dist/fields/encrypted/generateSecret.js.map +1 -0
- package/dist/fields/encrypted/hint.js +67 -0
- package/dist/fields/encrypted/hint.js.map +1 -0
- package/dist/fields/encrypted/hooks.js +59 -31
- package/dist/fields/encrypted/hooks.js.map +1 -1
- package/dist/fields/encrypted/queryRewrite.d.ts +10 -2
- package/dist/fields/encrypted/queryRewrite.js +34 -8
- package/dist/fields/encrypted/queryRewrite.js.map +1 -1
- package/dist/fields/encrypted/rawRead.d.ts +24 -0
- package/dist/fields/encrypted/rawRead.js +40 -0
- package/dist/fields/encrypted/rawRead.js.map +1 -0
- package/dist/fields/encrypted/scan.js +21 -4
- package/dist/fields/encrypted/scan.js.map +1 -1
- package/dist/fields/encrypted/types.d.ts +67 -2
- package/dist/fields/encrypted/types.js +8 -1
- package/dist/fields/encrypted/types.js.map +1 -1
- package/dist/fields/encrypted/utils/decryptAllData.js +2 -2
- package/dist/fields/encrypted/utils/decryptAllData.js.map +1 -1
- package/dist/fields/encrypted/utils/decryptFieldValue.d.ts +30 -0
- package/dist/fields/encrypted/utils/decryptFieldValue.js +56 -0
- package/dist/fields/encrypted/utils/decryptFieldValue.js.map +1 -0
- package/dist/fields/encrypted/utils/readEncryptedField.d.ts +51 -0
- package/dist/fields/encrypted/utils/readEncryptedField.js +96 -0
- package/dist/fields/encrypted/utils/readEncryptedField.js.map +1 -0
- package/dist/fields/icon/adapters/lucide/generated/manifest.js.map +1 -1
- package/dist/fields/icon/adapters/lucide/generated/nodes.js.map +1 -1
- package/dist/fields/icon/adapters/radix/adapter.js +7 -0
- package/dist/fields/icon/adapters/radix/adapter.js.map +1 -1
- package/dist/fields/icon/adapters/radix/client.d.ts +3 -2
- package/dist/fields/icon/adapters/radix/client.js +3 -2
- package/dist/fields/icon/adapters/radix/client.js.map +1 -1
- package/dist/fields/icon/adapters/radix/generated/manifest.js.map +1 -1
- package/dist/fields/icon/adapters/radix/generated/nodes.js +3625 -0
- package/dist/fields/icon/adapters/radix/generated/nodes.js.map +1 -0
- package/dist/fields/icon/adapters/tabler/generated/manifest.js.map +1 -1
- package/dist/fields/icon/adapters/tabler/generated/nodes.js.map +1 -1
- package/dist/fields/icon/client/DrawerGlyph.js +34 -17
- package/dist/fields/icon/client/DrawerGlyph.js.map +1 -1
- package/dist/fields/icon/client/IconDrawerContent.js +9 -45
- package/dist/fields/icon/client/IconDrawerContent.js.map +1 -1
- package/dist/fields/icon/client/IconFieldClient.d.ts +7 -0
- package/dist/fields/icon/client/IconFieldClient.js +15 -7
- package/dist/fields/icon/client/IconFieldClient.js.map +1 -1
- package/dist/fields/icon/client/IconGridCell.js +67 -0
- package/dist/fields/icon/client/IconGridCell.js.map +1 -0
- package/dist/fields/icon/client/icon-field.css +12 -2
- package/dist/fields/icon/codegen/emit.js +5 -4
- package/dist/fields/icon/codegen/emit.js.map +1 -1
- package/dist/fields/icon/codegen/generate.js +32 -6
- package/dist/fields/icon/codegen/generate.js.map +1 -1
- package/dist/fields/icon/layers/coalesce.js +41 -0
- package/dist/fields/icon/layers/coalesce.js.map +1 -0
- package/dist/fields/icon/layers/manifestCache.d.ts +6 -0
- package/dist/fields/icon/layers/manifestCache.js +49 -0
- package/dist/fields/icon/layers/manifestCache.js.map +1 -0
- package/dist/fields/icon/layers/resolve.d.ts +20 -0
- package/dist/fields/icon/layers/resolve.js +63 -0
- package/dist/fields/icon/layers/resolve.js.map +1 -0
- package/dist/fields/icon/layers/upload.d.ts +52 -0
- package/dist/fields/icon/layers/upload.js +116 -0
- package/dist/fields/icon/layers/upload.js.map +1 -0
- package/dist/fields/icon/plugin.js +24 -0
- package/dist/fields/icon/plugin.js.map +1 -1
- package/dist/fields/icon/react/createIcon.d.ts +5 -0
- package/dist/fields/icon/react/createIcon.js +22 -4
- package/dist/fields/icon/react/createIcon.js.map +1 -1
- package/dist/fields/icon/react/createRscIcon.js +22 -1
- package/dist/fields/icon/react/createRscIcon.js.map +1 -1
- package/dist/fields/icon/react/resolveRendered.js +21 -0
- package/dist/fields/icon/react/resolveRendered.js.map +1 -0
- package/dist/fields/icon/react/types.d.ts +15 -1
- package/dist/fields/icon/rsc/IconCell.d.ts +2 -2
- package/dist/fields/icon/rsc/IconCell.js +12 -5
- package/dist/fields/icon/rsc/IconCell.js.map +1 -1
- package/dist/fields/icon/rsc/IconFieldServer.js +16 -2
- package/dist/fields/icon/rsc/IconFieldServer.js.map +1 -1
- package/dist/fields/icon/rsc/IconLibrarySelectServer.js +1 -1
- package/dist/fields/icon/rsc/IconLibrarySelectServer.js.map +1 -1
- package/dist/fields/icon/server/endpoint.d.ts +12 -0
- package/dist/fields/icon/server/endpoint.js +52 -0
- package/dist/fields/icon/server/endpoint.js.map +1 -0
- package/dist/fields/icon/server/manifestCache.js +9 -4
- package/dist/fields/icon/server/manifestCache.js.map +1 -1
- package/dist/fields/icon/server/resolveIconMeta.js +31 -0
- package/dist/fields/icon/server/resolveIconMeta.js.map +1 -0
- package/dist/fields/icon/server/validate.js +5 -2
- package/dist/fields/icon/server/validate.js.map +1 -1
- package/dist/fields/icon/shared/adapterComponents.d.ts +3 -2
- package/dist/fields/icon/shared/iconLabel.js +26 -0
- package/dist/fields/icon/shared/iconLabel.js.map +1 -0
- package/dist/fields/measurement/client/MeasurementCell.d.ts +18 -0
- package/dist/fields/measurement/client/MeasurementCell.js +47 -0
- package/dist/fields/measurement/client/MeasurementCell.js.map +1 -0
- package/dist/fields/measurement/client/MeasurementField.d.ts +13 -0
- package/dist/fields/measurement/client/MeasurementField.js +70 -0
- package/dist/fields/measurement/client/MeasurementField.js.map +1 -0
- package/dist/fields/measurement/client/MeasurementInput.d.ts +42 -0
- package/dist/fields/measurement/client/MeasurementInput.js +327 -0
- package/dist/fields/measurement/client/MeasurementInput.js.map +1 -0
- package/dist/fields/measurement/client/MeasurementUnitsProvider.d.ts +24 -0
- package/dist/fields/measurement/client/MeasurementUnitsProvider.js +61 -0
- package/dist/fields/measurement/client/MeasurementUnitsProvider.js.map +1 -0
- package/dist/fields/measurement/client/editModel.js +124 -0
- package/dist/fields/measurement/client/editModel.js.map +1 -0
- package/dist/fields/measurement/client/measurementCell.css +4 -0
- package/dist/fields/measurement/client/measurementField.css +215 -0
- package/dist/fields/measurement/client/useMeasurementModel.d.ts +19 -0
- package/dist/fields/measurement/client/useMeasurementModel.js +85 -0
- package/dist/fields/measurement/client/useMeasurementModel.js.map +1 -0
- package/dist/fields/measurement/engine/convert.d.ts +8 -0
- package/dist/fields/measurement/engine/convert.js +21 -0
- package/dist/fields/measurement/engine/convert.js.map +1 -0
- package/dist/fields/measurement/engine/format.d.ts +37 -0
- package/dist/fields/measurement/engine/format.js +156 -0
- package/dist/fields/measurement/engine/format.js.map +1 -0
- package/dist/fields/measurement/engine/locale.d.ts +25 -0
- package/dist/fields/measurement/engine/locale.js +79 -0
- package/dist/fields/measurement/engine/locale.js.map +1 -0
- package/dist/fields/measurement/engine/precision.d.ts +34 -0
- package/dist/fields/measurement/engine/precision.js +63 -0
- package/dist/fields/measurement/engine/precision.js.map +1 -0
- package/dist/fields/measurement/engine/registry.d.ts +55 -0
- package/dist/fields/measurement/engine/registry.js +117 -0
- package/dist/fields/measurement/engine/registry.js.map +1 -0
- package/dist/fields/measurement/engine/units.d.ts +178 -0
- package/dist/fields/measurement/engine/units.js +198 -0
- package/dist/fields/measurement/engine/units.js.map +1 -0
- package/dist/fields/measurement/measurementField.d.ts +17 -0
- package/dist/fields/measurement/measurementField.js +139 -0
- package/dist/fields/measurement/measurementField.js.map +1 -0
- package/dist/fields/measurement/options.d.ts +76 -0
- package/dist/fields/measurement/options.js +9 -0
- package/dist/fields/measurement/options.js.map +1 -0
- package/dist/fields/measurement/presets.d.ts +117 -0
- package/dist/fields/measurement/presets.js +136 -0
- package/dist/fields/measurement/presets.js.map +1 -0
- package/dist/fields/measurement/server/MeasurementCellServer.d.ts +21 -0
- package/dist/fields/measurement/server/MeasurementCellServer.js +53 -0
- package/dist/fields/measurement/server/MeasurementCellServer.js.map +1 -0
- package/dist/fields/measurement/server/MeasurementFieldServer.d.ts +16 -0
- package/dist/fields/measurement/server/MeasurementFieldServer.js +45 -0
- package/dist/fields/measurement/server/MeasurementFieldServer.js.map +1 -0
- package/dist/fields/measurement/server/getUserUnits.js +39 -0
- package/dist/fields/measurement/server/getUserUnits.js.map +1 -0
- package/dist/fields/measurement/server/resolvePrecisionSafe.js +24 -0
- package/dist/fields/measurement/server/resolvePrecisionSafe.js.map +1 -0
- package/dist/fields/measurement/server/resolveRegistryDefault.js +26 -0
- package/dist/fields/measurement/server/resolveRegistryDefault.js.map +1 -0
- package/dist/fields/phoneNumber/client/CountryFlag.d.ts +16 -0
- package/dist/fields/phoneNumber/client/CountryFlag.js +40 -0
- package/dist/fields/phoneNumber/client/CountryFlag.js.map +1 -0
- package/dist/fields/phoneNumber/client/CountryPicker.d.ts +21 -0
- package/dist/fields/phoneNumber/client/CountryPicker.js +255 -0
- package/dist/fields/phoneNumber/client/CountryPicker.js.map +1 -0
- package/dist/fields/phoneNumber/client/PhoneNumberField.d.ts +26 -0
- package/dist/fields/phoneNumber/client/PhoneNumberField.js +318 -0
- package/dist/fields/phoneNumber/client/PhoneNumberField.js.map +1 -0
- package/dist/fields/phoneNumber/client/editModel.js +86 -0
- package/dist/fields/phoneNumber/client/editModel.js.map +1 -0
- package/dist/fields/phoneNumber/client/phoneNumberField.css +305 -0
- package/dist/fields/phoneNumber/engine/countries.d.ts +36 -0
- package/dist/fields/phoneNumber/engine/countries.js +68 -0
- package/dist/fields/phoneNumber/engine/countries.js.map +1 -0
- package/dist/fields/phoneNumber/engine/draft.d.ts +13 -0
- package/dist/fields/phoneNumber/engine/draft.js +72 -0
- package/dist/fields/phoneNumber/engine/draft.js.map +1 -0
- package/dist/fields/phoneNumber/engine/metadata.d.ts +11 -0
- package/dist/fields/phoneNumber/engine/metadata.js +32 -0
- package/dist/fields/phoneNumber/engine/metadata.js.map +1 -0
- package/dist/fields/phoneNumber/engine/phone.d.ts +37 -0
- package/dist/fields/phoneNumber/engine/phone.js +59 -0
- package/dist/fields/phoneNumber/engine/phone.js.map +1 -0
- package/dist/fields/phoneNumber/options.d.ts +72 -0
- package/dist/fields/phoneNumber/options.js +37 -0
- package/dist/fields/phoneNumber/options.js.map +1 -0
- package/dist/fields/phoneNumber/phoneNumberField.d.ts +14 -0
- package/dist/fields/phoneNumber/phoneNumberField.js +167 -0
- package/dist/fields/phoneNumber/phoneNumberField.js.map +1 -0
- package/dist/fields/phoneNumber/server/PhoneNumberCellServer.d.ts +19 -0
- package/dist/fields/phoneNumber/server/PhoneNumberCellServer.js +73 -0
- package/dist/fields/phoneNumber/server/PhoneNumberCellServer.js.map +1 -0
- package/dist/fields/phoneNumber/server/PhoneNumberFieldServer.d.ts +16 -0
- package/dist/fields/phoneNumber/server/PhoneNumberFieldServer.js +57 -0
- package/dist/fields/phoneNumber/server/PhoneNumberFieldServer.js.map +1 -0
- package/dist/fields/phoneNumber/server/flagsEndpoint.js +51 -0
- package/dist/fields/phoneNumber/server/flagsEndpoint.js.map +1 -0
- package/dist/fields/phoneNumber/server/readPhoneOptions.js +18 -0
- package/dist/fields/phoneNumber/server/readPhoneOptions.js.map +1 -0
- package/dist/fields/phoneNumber/server/resolvePhoneOptionsSafe.js +33 -0
- package/dist/fields/phoneNumber/server/resolvePhoneOptionsSafe.js.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +35 -1
- package/dist/index.js.map +1 -1
- package/dist/translations/ar.js +62 -0
- package/dist/translations/ar.js.map +1 -0
- package/dist/translations/de.js +19 -1
- package/dist/translations/de.js.map +1 -1
- package/dist/translations/en.js +19 -1
- package/dist/translations/en.js.map +1 -1
- package/dist/translations/es.js +62 -0
- package/dist/translations/es.js.map +1 -0
- package/dist/translations/fr.js +62 -0
- package/dist/translations/fr.js.map +1 -0
- package/dist/translations/id.js +62 -0
- package/dist/translations/id.js.map +1 -0
- package/dist/translations/index.d.ts +10 -1
- package/dist/translations/index.js +19 -1
- package/dist/translations/index.js.map +1 -1
- package/dist/translations/keys.d.ts +19 -1
- package/dist/translations/keys.js +20 -2
- package/dist/translations/keys.js.map +1 -1
- package/dist/translations/ko.js +62 -0
- package/dist/translations/ko.js.map +1 -0
- package/dist/translations/pt.js +62 -0
- package/dist/translations/pt.js.map +1 -0
- package/dist/translations/ru.js +62 -0
- package/dist/translations/ru.js.map +1 -0
- package/dist/translations/uk.js +62 -0
- package/dist/translations/uk.js.map +1 -0
- package/dist/translations/zh.js +62 -0
- package/dist/translations/zh.js.map +1 -0
- package/dist/types.d.ts +165 -8
- package/dist/utils/resolveStaticLabel.js +13 -0
- package/dist/utils/resolveStaticLabel.js.map +1 -0
- package/package.json +31 -7
- package/dist/fields/icon/rsc/resolveStaticLabel.js +0 -16
- package/dist/fields/icon/rsc/resolveStaticLabel.js.map +0 -1
|
@@ -1,29 +1,7 @@
|
|
|
1
1
|
import "./options.js";
|
|
2
|
+
import { findNamedField, readPath } from "./paths.js";
|
|
2
3
|
//#region src/fields/color/presetsFromDoc.ts
|
|
3
4
|
/**
|
|
4
|
-
* Rows, collapsibles, and unnamed tabs are already inlined by Payload's
|
|
5
|
-
* flattening, so each dot segment only ever names a data field or a named
|
|
6
|
-
* container (group, named tab, array) carrying nested flattenedFields.
|
|
7
|
-
*/
|
|
8
|
-
const findNamedField = (fields, path) => {
|
|
9
|
-
let scope = fields;
|
|
10
|
-
let found;
|
|
11
|
-
for (const segment of path.split(".")) {
|
|
12
|
-
found = scope?.find((field) => field.name === segment);
|
|
13
|
-
if (!found) return void 0;
|
|
14
|
-
scope = "flattenedFields" in found ? found.flattenedFields : void 0;
|
|
15
|
-
}
|
|
16
|
-
return found;
|
|
17
|
-
};
|
|
18
|
-
const readPath = (doc, path) => {
|
|
19
|
-
let value = doc;
|
|
20
|
-
for (const segment of path.split(".")) {
|
|
21
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
22
|
-
value = value[segment];
|
|
23
|
-
}
|
|
24
|
-
return value;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
5
|
* Function labels resolve here with the same args Payload's own
|
|
28
6
|
* `getTranslation` passes (`{ i18n, t }` from the request), since the
|
|
29
7
|
* resulting preset must be a plain value. Static labels pass through untouched
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presetsFromDoc.js","names":[],"sources":["../../../src/fields/color/presetsFromDoc.ts"],"sourcesContent":["import type {\n\tCollectionSlug,\n\tFlattenedField,\n\tLabelFunction,\n\tPayloadRequest,\n\tStaticLabel,\n} from 'payload'\nimport type { ColorPreset } from '../../types'\nimport { PRESET_PREFIX } from './options'\n\nexport type PresetsFromDocArgs = {\n\t/** Collection whose sanitized field configs supply the labels. */\n\tcollection: CollectionSlug\n\t/** The fetched doc holding the color values. */\n\tdoc: Record<string, unknown>\n\t/** Field names to lift; dot paths reach into groups and named tabs. */\n\tfields: string[]\n\t/** Prepended to every preset key, e.g. `${tenant.slug}/` to namespace per doc. */\n\tkeyPrefix?: string\n\treq: PayloadRequest\n}\n\
|
|
1
|
+
{"version":3,"file":"presetsFromDoc.js","names":[],"sources":["../../../src/fields/color/presetsFromDoc.ts"],"sourcesContent":["import type {\n\tCollectionSlug,\n\tFlattenedField,\n\tLabelFunction,\n\tPayloadRequest,\n\tStaticLabel,\n} from 'payload'\nimport type { ColorPreset } from '../../types'\nimport { PRESET_PREFIX } from './options'\nimport { findNamedField, readPath } from './paths'\n\nexport type PresetsFromDocArgs = {\n\t/** Collection whose sanitized field configs supply the labels. */\n\tcollection: CollectionSlug\n\t/** The fetched doc holding the color values. */\n\tdoc: Record<string, unknown>\n\t/** Field names to lift; dot paths reach into groups and named tabs. */\n\tfields: string[]\n\t/** Prepended to every preset key, e.g. `${tenant.slug}/` to namespace per doc. */\n\tkeyPrefix?: string\n\treq: PayloadRequest\n}\n\nexport { findNamedField } from './paths'\n\n/**\n * Function labels resolve here with the same args Payload's own\n * `getTranslation` passes (`{ i18n, t }` from the request), since the\n * resulting preset must be a plain value. Static labels pass through untouched\n * so the admin localizes records per request language at render time.\n */\nconst labelForField = (field: FlattenedField, req: PayloadRequest): StaticLabel => {\n\tconst label = field.label\n\tif (typeof label === 'function') {\n\t\treturn label({ i18n: req.i18n, t: req.i18n.t } as Parameters<LabelFunction>[0])\n\t}\n\tif (label === undefined || label === false) return field.name\n\treturn label\n}\n\n/**\n * Lifts individual color fields off a fetched doc into linked-mode presets, so\n * a fixed set of brand colors can live as plain fields instead of an\n * array/repeater. Each preset reuses the field's admin identity: key is\n * `keyPrefix + fieldPath` and the label is the field config's own label\n * (localized records untouched, functions resolved via `req.i18n`), keeping\n * picker chips consistent with the source document's edit view. Sanitized\n * configs humanize missing labels already, so the raw-name fallback only\n * fires for `label: false`. Missing fields and empty, non-string, or\n * `preset:` values are skipped rather than thrown so partial docs degrade to\n * fewer presets.\n */\nexport const presetsFromDoc = (args: PresetsFromDocArgs): ColorPreset[] => {\n\tconst { collection, doc, fields, keyPrefix = '', req } = args\n\tconst config = req.payload.collections[collection]?.config\n\tif (!config) {\n\t\tthrow new Error(`presetsFromDoc: unknown collection \"${collection}\"`)\n\t}\n\tconst presets: ColorPreset[] = []\n\tfor (const name of fields) {\n\t\tconst field = findNamedField(config.flattenedFields, name)\n\t\tif (!field) continue\n\t\tconst value = readPath(doc, name)\n\t\tif (typeof value !== 'string' || value === '' || value.startsWith(PRESET_PREFIX)) continue\n\t\tpresets.push({ key: `${keyPrefix}${name}`, label: labelForField(field, req), value })\n\t}\n\treturn presets\n}\n"],"mappings":";;;;;;;;;AA+BA,MAAM,iBAAiB,OAAuB,QAAqC;CAClF,MAAM,QAAQ,MAAM;CACpB,IAAI,OAAO,UAAU,YACpB,OAAO,MAAM;EAAE,MAAM,IAAI;EAAM,GAAG,IAAI,KAAK;CAAE,CAAiC;CAE/E,IAAI,UAAU,KAAA,KAAa,UAAU,OAAO,OAAO,MAAM;CACzD,OAAO;AACR;;;;;;;;;;;;;AAcA,MAAa,kBAAkB,SAA4C;CAC1E,MAAM,EAAE,YAAY,KAAK,QAAQ,YAAY,IAAI,QAAQ;CACzD,MAAM,SAAS,IAAI,QAAQ,YAAY,aAAa;CACpD,IAAI,CAAC,QACJ,MAAM,IAAI,MAAM,uCAAuC,WAAW,EAAE;CAErE,MAAM,UAAyB,CAAC;CAChC,KAAK,MAAM,QAAQ,QAAQ;EAC1B,MAAM,QAAQ,eAAe,OAAO,iBAAiB,IAAI;EACzD,IAAI,CAAC,OAAO;EACZ,MAAM,QAAQ,SAAS,KAAK,IAAI;EAChC,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,MAAM,WAAA,SAAwB,GAAG;EAClF,QAAQ,KAAK;GAAE,KAAK,GAAG,YAAY;GAAQ,OAAO,cAAc,OAAO,GAAG;GAAG;EAAM,CAAC;CACrF;CACA,OAAO;AACR"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColorPreset } from "../../types.js";
|
|
1
|
+
import { ColorPreset, ColorSchemeValue } from "../../types.js";
|
|
2
2
|
import { ColorPresetsSource } from "./options.js";
|
|
3
3
|
import { PayloadRequest, StaticLabel } from "payload";
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ import { PayloadRequest, StaticLabel } from "payload";
|
|
|
6
6
|
type NormalizedColorPreset = {
|
|
7
7
|
key: string;
|
|
8
8
|
label?: StaticLabel;
|
|
9
|
-
value: string;
|
|
9
|
+
value: string | ColorSchemeValue;
|
|
10
10
|
};
|
|
11
11
|
/** String presets use the CSS value as both key and value; linked mode should prefer object presets. */
|
|
12
12
|
declare const normalizePresets: (presets: ColorPreset[]) => NormalizedColorPreset[];
|
|
@@ -1,15 +1,45 @@
|
|
|
1
1
|
import { getFieldsRegistry } from "../../plugin/registry.js";
|
|
2
2
|
import { memoForRequest } from "../../utils/memoForRequest.js";
|
|
3
3
|
//#region src/fields/color/resolvePresets.ts
|
|
4
|
+
/**
|
|
5
|
+
* One value rule for every layer: a scheme value with one member present is
|
|
6
|
+
* that color in both schemes; with neither it is not a preset. Filling rather
|
|
7
|
+
* than dropping keeps a mid-authored palette row pickable, and matches what a
|
|
8
|
+
* plain string preset already resolves to under `resolve: 'schemes'`.
|
|
9
|
+
*/
|
|
10
|
+
const normalizeValue = (value) => {
|
|
11
|
+
if (typeof value === "string") return value === "" ? null : value;
|
|
12
|
+
if (typeof value !== "object" || value === null) return null;
|
|
13
|
+
const { dark, light } = value;
|
|
14
|
+
const usableLight = typeof light === "string" && light !== "" ? light : null;
|
|
15
|
+
const usableDark = typeof dark === "string" && dark !== "" ? dark : null;
|
|
16
|
+
if (!usableLight && !usableDark) return null;
|
|
17
|
+
return {
|
|
18
|
+
dark: usableDark ?? usableLight,
|
|
19
|
+
light: usableLight ?? usableDark
|
|
20
|
+
};
|
|
21
|
+
};
|
|
4
22
|
/** String presets use the CSS value as both key and value; linked mode should prefer object presets. */
|
|
5
|
-
const normalizePresets = (presets) =>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
23
|
+
const normalizePresets = (presets) => {
|
|
24
|
+
const normalized = [];
|
|
25
|
+
for (const preset of presets) {
|
|
26
|
+
if (typeof preset === "string") {
|
|
27
|
+
if (preset !== "") normalized.push({
|
|
28
|
+
key: preset,
|
|
29
|
+
value: preset
|
|
30
|
+
});
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const value = normalizeValue(preset.value);
|
|
34
|
+
if (value === null) continue;
|
|
35
|
+
normalized.push({
|
|
36
|
+
key: preset.key,
|
|
37
|
+
label: preset.label,
|
|
38
|
+
value
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return normalized;
|
|
42
|
+
};
|
|
13
43
|
/**
|
|
14
44
|
* Resolves a field's preset source. Falls back to the plugin registry
|
|
15
45
|
* (static `presets` wins over `resolvePresets`) when the field has none.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvePresets.js","names":[],"sources":["../../../src/fields/color/resolvePresets.ts"],"sourcesContent":["import type { PayloadRequest, StaticLabel } from 'payload'\nimport { getFieldsRegistry } from '../../plugin/registry'\nimport type { ColorPreset } from '../../types'\nimport { memoForRequest } from '../../utils/memoForRequest'\nimport type { ColorPresetsSource } from './options'\n\nexport type NormalizedColorPreset = {
|
|
1
|
+
{"version":3,"file":"resolvePresets.js","names":[],"sources":["../../../src/fields/color/resolvePresets.ts"],"sourcesContent":["import type { PayloadRequest, StaticLabel } from 'payload'\nimport { getFieldsRegistry } from '../../plugin/registry'\nimport type { ColorPreset, ColorSchemeValue } from '../../types'\nimport { memoForRequest } from '../../utils/memoForRequest'\nimport type { ColorPresetsSource } from './options'\n\nexport type NormalizedColorPreset = {\n\tkey: string\n\tlabel?: StaticLabel\n\tvalue: string | ColorSchemeValue\n}\n\n/**\n * One value rule for every layer: a scheme value with one member present is\n * that color in both schemes; with neither it is not a preset. Filling rather\n * than dropping keeps a mid-authored palette row pickable, and matches what a\n * plain string preset already resolves to under `resolve: 'schemes'`.\n */\nconst normalizeValue = (value: unknown): null | string | ColorSchemeValue => {\n\tif (typeof value === 'string') return value === '' ? null : value\n\tif (typeof value !== 'object' || value === null) return null\n\tconst { dark, light } = value as Partial<ColorSchemeValue>\n\tconst usableLight = typeof light === 'string' && light !== '' ? light : null\n\tconst usableDark = typeof dark === 'string' && dark !== '' ? dark : null\n\tif (!usableLight && !usableDark) return null\n\treturn {\n\t\tdark: usableDark ?? (usableLight as string),\n\t\tlight: usableLight ?? (usableDark as string),\n\t}\n}\n\n/** String presets use the CSS value as both key and value; linked mode should prefer object presets. */\nexport const normalizePresets = (presets: ColorPreset[]): NormalizedColorPreset[] => {\n\tconst normalized: NormalizedColorPreset[] = []\n\tfor (const preset of presets) {\n\t\tif (typeof preset === 'string') {\n\t\t\tif (preset !== '') normalized.push({ key: preset, value: preset })\n\t\t\tcontinue\n\t\t}\n\t\tconst value = normalizeValue(preset.value)\n\t\tif (value === null) continue\n\t\tnormalized.push({ key: preset.key, label: preset.label, value })\n\t}\n\treturn normalized\n}\n\n/**\n * Resolves a field's preset source. Falls back to the plugin registry\n * (static `presets` wins over `resolvePresets`) when the field has none.\n * Resolver calls are memoized per request via `memoKey`, so a find across\n * many docs resolves once; resolvers must therefore derive from `req`,\n * not per-doc data (documented limitation).\n */\nexport const resolvePresets = async (args: {\n\tdata?: Record<string, unknown>\n\tmemoKey: symbol\n\treq: PayloadRequest\n\tsiblingData?: Record<string, unknown>\n\tsource?: ColorPresetsSource\n}): Promise<NormalizedColorPreset[]> => {\n\tconst { data, memoKey, req, siblingData } = args\n\tlet source = args.source\n\tif (!source) {\n\t\tconst registry = getFieldsRegistry(req.payload.config)?.color\n\t\tsource = registry?.presets ?? registry?.resolvePresets\n\t}\n\tif (!source) return []\n\tif (Array.isArray(source)) return normalizePresets(source)\n\tconst resolver = source\n\tconst resolved = await memoForRequest(req, memoKey, () => resolver({ data, req, siblingData }))\n\treturn normalizePresets(resolved)\n}\n"],"mappings":";;;;;;;;;AAkBA,MAAM,kBAAkB,UAAqD;CAC5E,IAAI,OAAO,UAAU,UAAU,OAAO,UAAU,KAAK,OAAO;CAC5D,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,MAAM,EAAE,MAAM,UAAU;CACxB,MAAM,cAAc,OAAO,UAAU,YAAY,UAAU,KAAK,QAAQ;CACxE,MAAM,aAAa,OAAO,SAAS,YAAY,SAAS,KAAK,OAAO;CACpE,IAAI,CAAC,eAAe,CAAC,YAAY,OAAO;CACxC,OAAO;EACN,MAAM,cAAe;EACrB,OAAO,eAAgB;CACxB;AACD;;AAGA,MAAa,oBAAoB,YAAoD;CACpF,MAAM,aAAsC,CAAC;CAC7C,KAAK,MAAM,UAAU,SAAS;EAC7B,IAAI,OAAO,WAAW,UAAU;GAC/B,IAAI,WAAW,IAAI,WAAW,KAAK;IAAE,KAAK;IAAQ,OAAO;GAAO,CAAC;GACjE;EACD;EACA,MAAM,QAAQ,eAAe,OAAO,KAAK;EACzC,IAAI,UAAU,MAAM;EACpB,WAAW,KAAK;GAAE,KAAK,OAAO;GAAK,OAAO,OAAO;GAAO;EAAM,CAAC;CAChE;CACA,OAAO;AACR;;;;;;;;AASA,MAAa,iBAAiB,OAAO,SAMG;CACvC,MAAM,EAAE,MAAM,SAAS,KAAK,gBAAgB;CAC5C,IAAI,SAAS,KAAK;CAClB,IAAI,CAAC,QAAQ;EACZ,MAAM,WAAW,kBAAkB,IAAI,QAAQ,MAAM,GAAG;EACxD,SAAS,UAAU,WAAW,UAAU;CACzC;CACA,IAAI,CAAC,QAAQ,OAAO,CAAC;CACrB,IAAI,MAAM,QAAQ,MAAM,GAAG,OAAO,iBAAiB,MAAM;CACzD,MAAM,WAAW;CAEjB,OAAO,iBAAiB,MADD,eAAe,KAAK,eAAe,SAAS;EAAE;EAAM;EAAK;CAAY,CAAC,CAAC,CAC9D;AACjC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { parseColor } from "./engine/parse.js";
|
|
2
|
+
import { formatColor } from "./engine/format.js";
|
|
3
|
+
import { isColorSchemeValue } from "./engine/scheme.js";
|
|
4
|
+
//#region src/fields/color/schemeValue.ts
|
|
5
|
+
/** The single color a flat context uses for a scheme value. */
|
|
6
|
+
const flatValue = (value) => {
|
|
7
|
+
if (isColorSchemeValue(value)) return value.light;
|
|
8
|
+
if (typeof value !== "string" || value === "") return null;
|
|
9
|
+
return value;
|
|
10
|
+
};
|
|
11
|
+
const normalizedCss = (value) => {
|
|
12
|
+
const parsed = parseColor(value);
|
|
13
|
+
return parsed ? formatColor(parsed, "rgb") : value;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Background for a swatch. A scheme value renders as a diagonal split so an
|
|
17
|
+
* editor sees the color is mode-responsive without visiting the site.
|
|
18
|
+
*/
|
|
19
|
+
const swatchBackground = (value) => {
|
|
20
|
+
if (isColorSchemeValue(value)) {
|
|
21
|
+
const { dark, light } = value;
|
|
22
|
+
return `linear-gradient(135deg, ${normalizedCss(light)} 0 50%, ${normalizedCss(dark)} 50% 100%)`;
|
|
23
|
+
}
|
|
24
|
+
const flat = flatValue(value);
|
|
25
|
+
return flat === null ? null : normalizedCss(flat);
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { flatValue, swatchBackground };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=schemeValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemeValue.js","names":[],"sources":["../../../src/fields/color/schemeValue.ts"],"sourcesContent":["import type { ColorSchemeValue } from '../../types'\nimport { formatColor, isColorSchemeValue, parseColor } from './engine'\n\n/** The single color a flat context uses for a scheme value. */\nexport const flatValue = (value: unknown): null | string => {\n\tif (isColorSchemeValue(value)) return value.light\n\tif (typeof value !== 'string' || value === '') return null\n\treturn value\n}\n\nconst normalizedCss = (value: string): string => {\n\tconst parsed = parseColor(value)\n\treturn parsed ? formatColor(parsed, 'rgb') : value\n}\n\n/**\n * Background for a swatch. A scheme value renders as a diagonal split so an\n * editor sees the color is mode-responsive without visiting the site.\n */\nexport const swatchBackground = (value: unknown): null | string => {\n\tif (isColorSchemeValue(value)) {\n\t\tconst { dark, light } = value as ColorSchemeValue\n\t\treturn `linear-gradient(135deg, ${normalizedCss(light)} 0 50%, ${normalizedCss(dark)} 50% 100%)`\n\t}\n\tconst flat = flatValue(value)\n\treturn flat === null ? null : normalizedCss(flat)\n}\n"],"mappings":";;;;;AAIA,MAAa,aAAa,UAAkC;CAC3D,IAAI,mBAAmB,KAAK,GAAG,OAAO,MAAM;CAC5C,IAAI,OAAO,UAAU,YAAY,UAAU,IAAI,OAAO;CACtD,OAAO;AACR;AAEA,MAAM,iBAAiB,UAA0B;CAChD,MAAM,SAAS,WAAW,KAAK;CAC/B,OAAO,SAAS,YAAY,QAAQ,KAAK,IAAI;AAC9C;;;;;AAMA,MAAa,oBAAoB,UAAkC;CAClE,IAAI,mBAAmB,KAAK,GAAG;EAC9B,MAAM,EAAE,MAAM,UAAU;EACxB,OAAO,2BAA2B,cAAc,KAAK,EAAE,UAAU,cAAc,IAAI,EAAE;CACtF;CACA,MAAM,OAAO,UAAU,KAAK;CAC5B,OAAO,SAAS,OAAO,OAAO,cAAc,IAAI;AACjD"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { keys } from "../../../translations/keys.js";
|
|
2
2
|
import { PRESET_PREFIX } from "../options.js";
|
|
3
|
+
import { parsePresetReference } from "../presetReference.js";
|
|
4
|
+
import { swatchBackground } from "../schemeValue.js";
|
|
3
5
|
import { asTranslate } from "../../../translations/server.js";
|
|
4
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
7
|
import "./colorCell.css";
|
|
@@ -9,9 +11,9 @@ const ColorCell = (props) => {
|
|
|
9
11
|
if (typeof cellData !== "string" || cellData === "") return null;
|
|
10
12
|
const isPreset = cellData.startsWith(PRESET_PREFIX);
|
|
11
13
|
const name = "name" in field ? String(field.name) : "";
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const label = isPreset ? cellData.slice(
|
|
14
|
+
const swatch = swatchBackground(isPreset ? rowData?.[`${name}Resolved`] : cellData);
|
|
15
|
+
const ref = isPreset ? parsePresetReference(cellData) : null;
|
|
16
|
+
const label = isPreset ? ref?.key ?? cellData.slice(7) : cellData;
|
|
15
17
|
return /* @__PURE__ */ jsxs("span", {
|
|
16
18
|
className: "fields-color-cell",
|
|
17
19
|
children: [
|
|
@@ -21,6 +23,10 @@ const ColorCell = (props) => {
|
|
|
21
23
|
children: swatch ? /* @__PURE__ */ jsx("span", { style: { background: swatch } }) : null
|
|
22
24
|
}),
|
|
23
25
|
/* @__PURE__ */ jsx("span", { children: label }),
|
|
26
|
+
ref && ref.alpha !== 100 ? /* @__PURE__ */ jsxs("span", {
|
|
27
|
+
className: "fields-color-cell__alpha",
|
|
28
|
+
children: [ref.alpha, "%"]
|
|
29
|
+
}) : null,
|
|
24
30
|
isPreset && !swatch ? /* @__PURE__ */ jsx("span", {
|
|
25
31
|
className: "fields-color-cell__missing",
|
|
26
32
|
children: asTranslate(i18n.t)(keys.missingPreset)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorCell.js","names":[],"sources":["../../../../src/fields/color/server/ColorCell.tsx"],"sourcesContent":["import type { DefaultServerCellComponentProps } from 'payload'\nimport { keys } from '../../../translations/keys'\nimport { asTranslate } from '../../../translations/server'\nimport { PRESET_PREFIX } from '../options'\nimport './colorCell.css'\n\nexport const ColorCell = (props: DefaultServerCellComponentProps) => {\n\tconst { cellData, field, i18n, rowData } = props\n\tif (typeof cellData !== 'string' || cellData === '') return null\n\tconst isPreset = cellData.startsWith(PRESET_PREFIX)\n\tconst name = 'name' in field ? String(field.name) : ''\n\tconst resolvedRaw = isPreset\n\t\t? (rowData as Record<string, unknown>)?.[`${name}Resolved`]\n\t\t: cellData\n\tconst swatch =
|
|
1
|
+
{"version":3,"file":"ColorCell.js","names":[],"sources":["../../../../src/fields/color/server/ColorCell.tsx"],"sourcesContent":["import type { DefaultServerCellComponentProps } from 'payload'\nimport { keys } from '../../../translations/keys'\nimport { asTranslate } from '../../../translations/server'\nimport { PRESET_PREFIX } from '../options'\nimport { parsePresetReference } from '../presetReference'\nimport { swatchBackground } from '../schemeValue'\nimport './colorCell.css'\n\nexport const ColorCell = (props: DefaultServerCellComponentProps) => {\n\tconst { cellData, field, i18n, rowData } = props\n\tif (typeof cellData !== 'string' || cellData === '') return null\n\tconst isPreset = cellData.startsWith(PRESET_PREFIX)\n\tconst name = 'name' in field ? String(field.name) : ''\n\t// The resolved sibling already carries the reference alpha, so the swatch\n\t// renders at the stored opacity without reapplying it here\n\tconst resolvedRaw = isPreset\n\t\t? (rowData as Record<string, unknown>)?.[`${name}Resolved`]\n\t\t: cellData\n\tconst swatch = swatchBackground(resolvedRaw)\n\tconst ref = isPreset ? parsePresetReference(cellData) : null\n\tconst label = isPreset ? (ref?.key ?? cellData.slice(PRESET_PREFIX.length)) : cellData\n\treturn (\n\t\t<span className=\"fields-color-cell\">\n\t\t\t<span aria-hidden=\"true\" className=\"fields-color-cell__swatch\">\n\t\t\t\t{swatch ? <span style={{ background: swatch }} /> : null}\n\t\t\t</span>\n\t\t\t<span>{label}</span>\n\t\t\t{ref && ref.alpha !== 100 ? (\n\t\t\t\t<span className=\"fields-color-cell__alpha\">{ref.alpha}%</span>\n\t\t\t) : null}\n\t\t\t{isPreset && !swatch ? (\n\t\t\t\t<span className=\"fields-color-cell__missing\">\n\t\t\t\t\t{asTranslate(i18n.t)(keys.missingPreset)}\n\t\t\t\t</span>\n\t\t\t) : null}\n\t\t</span>\n\t)\n}\n"],"mappings":";;;;;;;;AAQA,MAAa,aAAa,UAA2C;CACpE,MAAM,EAAE,UAAU,OAAO,MAAM,YAAY;CAC3C,IAAI,OAAO,aAAa,YAAY,aAAa,IAAI,OAAO;CAC5D,MAAM,WAAW,SAAS,WAAW,aAAa;CAClD,MAAM,OAAO,UAAU,QAAQ,OAAO,MAAM,IAAI,IAAI;CAMpD,MAAM,SAAS,iBAHK,WAChB,UAAsC,GAAG,KAAK,aAC/C,QACwC;CAC3C,MAAM,MAAM,WAAW,qBAAqB,QAAQ,IAAI;CACxD,MAAM,QAAQ,WAAY,KAAK,OAAO,SAAS,MAAA,CAA0B,IAAK;CAC9E,OACC,qBAAC,QAAD;EAAM,WAAU;YAAhB;GACC,oBAAC,QAAD;IAAM,eAAY;IAAO,WAAU;cACjC,SAAS,oBAAC,QAAD,EAAM,OAAO,EAAE,YAAY,OAAO,EAAI,CAAA,IAAI;GAC/C,CAAA;GACN,oBAAC,QAAD,EAAA,UAAO,MAAY,CAAA;GAClB,OAAO,IAAI,UAAU,MACrB,qBAAC,QAAD;IAAM,WAAU;cAAhB,CAA4C,IAAI,OAAM,GAAO;QAC1D;GACH,YAAY,CAAC,SACb,oBAAC,QAAD;IAAM,WAAU;cACd,YAAY,KAAK,CAAC,EAAE,KAAK,aAAa;GAClC,CAAA,IACH;EACC;;AAER"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { parseColor } from "./engine/parse.js";
|
|
2
|
+
import "./options.js";
|
|
3
|
+
import { presetReferenceIssue } from "./presetReference.js";
|
|
4
|
+
//#region src/fields/color/valueIssue.ts
|
|
5
|
+
/**
|
|
6
|
+
* Format-level problem with a stored or typed color value, shared by the form-bound
|
|
7
|
+
* field's validate and the standalone input's own error display. Empty values have
|
|
8
|
+
* no issue here; `required` is the caller's concern.
|
|
9
|
+
*/
|
|
10
|
+
const colorValueIssue = (value, args) => {
|
|
11
|
+
if (typeof value !== "string" || value === "") return null;
|
|
12
|
+
const { linked, presets } = args;
|
|
13
|
+
if (linked && value.startsWith("preset:")) {
|
|
14
|
+
const issue = presetReferenceIssue(value, presets.length > 0 ? (key) => presets.some((preset) => preset.key === key) : null);
|
|
15
|
+
if (issue === "invalidAlpha") return "invalidColor";
|
|
16
|
+
return issue === null ? null : "missingPreset";
|
|
17
|
+
}
|
|
18
|
+
return parseColor(value) ? null : "invalidColor";
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { colorValueIssue };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=valueIssue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valueIssue.js","names":[],"sources":["../../../src/fields/color/valueIssue.ts"],"sourcesContent":["import { parseColor } from './engine'\nimport { PRESET_PREFIX, type ResolvedColorPreset } from './options'\nimport { presetReferenceIssue } from './presetReference'\n\nexport type ColorValueIssue = 'invalidColor' | 'missingPreset'\n\n/**\n * Format-level problem with a stored or typed color value, shared by the form-bound\n * field's validate and the standalone input's own error display. Empty values have\n * no issue here; `required` is the caller's concern.\n */\nexport const colorValueIssue = (\n\tvalue: unknown,\n\targs: { linked: boolean; presets: readonly ResolvedColorPreset[] }\n): ColorValueIssue | null => {\n\tif (typeof value !== 'string' || value === '') return null\n\tconst { linked, presets } = args\n\tif (linked && value.startsWith(PRESET_PREFIX)) {\n\t\tconst hasKey =\n\t\t\tpresets.length > 0 ? (key: string) => presets.some((preset) => preset.key === key) : null\n\t\tconst issue = presetReferenceIssue(value, hasKey)\n\t\tif (issue === 'invalidAlpha') return 'invalidColor'\n\t\treturn issue === null ? null : 'missingPreset'\n\t}\n\treturn parseColor(value) ? null : 'invalidColor'\n}\n"],"mappings":";;;;;;;;;AAWA,MAAa,mBACZ,OACA,SAC4B;CAC5B,IAAI,OAAO,UAAU,YAAY,UAAU,IAAI,OAAO;CACtD,MAAM,EAAE,QAAQ,YAAY;CAC5B,IAAI,UAAU,MAAM,WAAA,SAAwB,GAAG;EAG9C,MAAM,QAAQ,qBAAqB,OADlC,QAAQ,SAAS,KAAK,QAAgB,QAAQ,MAAM,WAAW,OAAO,QAAQ,GAAG,IAAI,IACtC;EAChD,IAAI,UAAU,gBAAgB,OAAO;EACrC,OAAO,UAAU,OAAO,OAAO;CAChC;CACA,OAAO,WAAW,KAAK,IAAI,OAAO;AACnC"}
|
|
@@ -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
|
-
|
|
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\
|
|
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 {
|
|
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":"
|
|
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,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;CAIJ,MAAM,SAAS,cAAc,iBAAiB,KAAK,GAAG,CAAC,KAAK,CAAC;CAE7D,OACC,qBAAC,OAAD;EACC,WAAW;GACV;GACA;GACA,kBAAkB;GAClB;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;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"}
|
|
@@ -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 {
|
|
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
|
-
|
|
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":"
|
|
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:
|
|
6
|
-
* been decrypted by afterRead
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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:
|
|
8
|
-
* been decrypted by afterRead
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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 }) =>
|
|
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
|
-
|
|
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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProtectedCell.js","names":[],"sources":["../../../../src/fields/encrypted/components/ProtectedCell.tsx"],"sourcesContent":["import type { DefaultServerCellComponentProps } from 'payload'\nimport { keys } from '../../../translations/keys'\nimport { asTranslate } from '../../../translations/server'\nimport { clampMaskDots } from '../maskDots'\n\n/**\n * List cell for masked encrypted fields. Never renders cellData
|
|
1
|
+
{"version":3,"file":"ProtectedCell.js","names":[],"sources":["../../../../src/fields/encrypted/components/ProtectedCell.tsx"],"sourcesContent":["import type { DefaultServerCellComponentProps } from 'payload'\nimport { keys } from '../../../translations/keys'\nimport { asTranslate } from '../../../translations/server'\nimport { formatHint } from '../hint'\nimport { clampMaskDots } from '../maskDots'\n\n/**\n * List cell for masked and write-only encrypted fields. Never renders cellData:\n * list data has been decrypted by afterRead (masked) or stripped (write-only),\n * and the list surface must not leak it. Server cell, so it translates the\n * accessible label per the admin's locale. The dot count mirrors the field's\n * `maskDots` (forwarded via clientProps) for list consistency, defaulting to\n * the same 8 as the field. `setName` (write-only fields) points at the virtual\n * set-indicator sibling in rowData; an unset secret renders an em dash instead\n * of dots that would imply a stored value. `hintName` points at the stored\n * identification hint, which replaces the dots when present.\n */\nexport const ProtectedCell = ({\n\thintName,\n\ti18n,\n\tmaskDots,\n\trowData,\n\tsetName,\n}: DefaultServerCellComponentProps & {\n\thintName?: string\n\tmaskDots?: number\n\tsetName?: string\n}) => {\n\tconst row = rowData as Record<string, unknown> | undefined\n\tif (setName && row?.[setName] !== true) {\n\t\treturn (\n\t\t\t<span\n\t\t\t\taria-label={asTranslate(i18n.t)(keys.secretNotSet)}\n\t\t\t\tclassName=\"tenx-protected-cell\"\n\t\t\t\trole=\"img\"\n\t\t\t>\n\t\t\t\t—\n\t\t\t</span>\n\t\t)\n\t}\n\tconst hint = hintName ? row?.[hintName] : undefined\n\treturn renderLocked({\n\t\ti18n,\n\t\ttext:\n\t\t\ttypeof hint === 'string' && hint.length > 0\n\t\t\t\t? formatHint(hint, clampMaskDots(maskDots))\n\t\t\t\t: undefined,\n\t\tmaskDots,\n\t})\n}\n\nconst renderLocked = ({\n\ti18n,\n\tmaskDots,\n\ttext,\n}: Pick<DefaultServerCellComponentProps, 'i18n'> & { maskDots?: number; text?: string }) => (\n\t// Styled inline rather than through ProtectedField.css: that stylesheet is\n\t// imported by the field components, and a list view renders this cell\n\t// without mounting one, so a rule living there would not be loaded here.\n\t<span\n\t\tclassName=\"tenx-protected-cell\"\n\t\tstyle={{\n\t\t\talignItems: 'center',\n\t\t\tdisplay: 'inline-flex',\n\t\t\tgap: '0.4em',\n\t\t\tmaxWidth: '100%',\n\t\t\tminWidth: 0,\n\t\t}}\n\t>\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tfill=\"none\"\n\t\t\theight=\"12\"\n\t\t\t// Without this the badge squashes to a sliver before the text yields.\n\t\t\tstyle={{ flexShrink: 0 }}\n\t\t\tstroke=\"currentColor\"\n\t\t\tstrokeWidth=\"2\"\n\t\t\tviewBox=\"0 0 24 24\"\n\t\t\twidth=\"12\"\n\t\t>\n\t\t\t<rect height=\"10\" rx=\"2\" width=\"14\" x=\"5\" y=\"11\" />\n\t\t\t<path d=\"M8 11V7a4 4 0 0 1 8 0v4\" />\n\t\t</svg>\n\t\t<span\n\t\t\taria-label={asTranslate(i18n.t)(keys.encryptedValue)}\n\t\t\trole=\"img\"\n\t\t\tstyle={{ minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}\n\t\t>\n\t\t\t{text ?? '•'.repeat(clampMaskDots(maskDots))}\n\t\t</span>\n\t</span>\n)\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,iBAAiB,EAC7B,UACA,MACA,UACA,SACA,cAKK;CACL,MAAM,MAAM;CACZ,IAAI,WAAW,MAAM,aAAa,MACjC,OACC,oBAAC,QAAD;EACC,cAAY,YAAY,KAAK,CAAC,EAAE,KAAK,YAAY;EACjD,WAAU;EACV,MAAK;YACL;CAEK,CAAA;CAGR,MAAM,OAAO,WAAW,MAAM,YAAY,KAAA;CAC1C,OAAO,aAAa;EACnB;EACA,MACC,OAAO,SAAS,YAAY,KAAK,SAAS,IACvC,WAAW,MAAM,cAAc,QAAQ,CAAC,IACxC,KAAA;EACJ;CACD,CAAC;AACF;AAEA,MAAM,gBAAgB,EACrB,MACA,UACA,WAKA,qBAAC,QAAD;CACC,WAAU;CACV,OAAO;EACN,YAAY;EACZ,SAAS;EACT,KAAK;EACL,UAAU;EACV,UAAU;CACX;WARD,CAUC,qBAAC,OAAD;EACC,eAAY;EACZ,MAAK;EACL,QAAO;EAEP,OAAO,EAAE,YAAY,EAAE;EACvB,QAAO;EACP,aAAY;EACZ,SAAQ;EACR,OAAM;YATP,CAWC,oBAAC,QAAD;GAAM,QAAO;GAAK,IAAG;GAAI,OAAM;GAAK,GAAE;GAAI,GAAE;EAAM,CAAA,GAClD,oBAAC,QAAD,EAAM,GAAE,0BAA2B,CAAA,CAC/B;KACL,oBAAC,QAAD;EACC,cAAY,YAAY,KAAK,CAAC,EAAE,KAAK,cAAc;EACnD,MAAK;EACL,OAAO;GAAE,UAAU;GAAG,UAAU;GAAU,cAAc;GAAY,YAAY;EAAS;YAExF,QAAQ,IAAI,OAAO,cAAc,QAAQ,CAAC;CACtC,CAAA,CACD"}
|