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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +9 -4
  3. package/dist/fields/color/client/ColorInput.js +17 -6
  4. package/dist/fields/color/client/ColorInput.js.map +1 -1
  5. package/dist/fields/color/client/ColorPickerPanel.js +18 -12
  6. package/dist/fields/color/client/ColorPickerPanel.js.map +1 -1
  7. package/dist/fields/color/client/colorField.css +131 -178
  8. package/dist/fields/color/client/icons.js +17 -24
  9. package/dist/fields/color/client/icons.js.map +1 -1
  10. package/dist/fields/color/colorField.js +5 -3
  11. package/dist/fields/color/colorField.js.map +1 -1
  12. package/dist/fields/color/server/colorCell.css +8 -9
  13. package/dist/fields/encrypted/components/EncryptedInput.js +44 -26
  14. package/dist/fields/encrypted/components/EncryptedInput.js.map +1 -1
  15. package/dist/fields/encrypted/components/EncryptedTextarea.js +29 -29
  16. package/dist/fields/encrypted/components/EncryptedTextarea.js.map +1 -1
  17. package/dist/fields/encrypted/components/EyeToggle.js +14 -35
  18. package/dist/fields/encrypted/components/EyeToggle.js.map +1 -1
  19. package/dist/fields/encrypted/components/ProtectedField.css +107 -159
  20. package/dist/fields/encrypted/components/ProtectedField.js +6 -2
  21. package/dist/fields/encrypted/components/ProtectedField.js.map +1 -1
  22. package/dist/fields/encrypted/components/RichTextRevealGate.js +3 -3
  23. package/dist/fields/encrypted/components/RichTextRevealGate.js.map +1 -1
  24. package/dist/fields/encrypted/components/WriteOnlyActions.js +58 -53
  25. package/dist/fields/encrypted/components/WriteOnlyActions.js.map +1 -1
  26. package/dist/fields/encrypted/components/WriteOnlyField.js +39 -21
  27. package/dist/fields/encrypted/components/WriteOnlyField.js.map +1 -1
  28. package/dist/fields/encrypted/components/facsimiles.js +70 -79
  29. package/dist/fields/encrypted/components/facsimiles.js.map +1 -1
  30. package/dist/fields/encrypted/components/placement.js.map +1 -1
  31. package/dist/fields/encrypted/encryptedField.js +25 -12
  32. package/dist/fields/encrypted/encryptedField.js.map +1 -1
  33. package/dist/fields/encrypted/{typescriptSchema.js → jsonSchema.js} +4 -4
  34. package/dist/fields/encrypted/jsonSchema.js.map +1 -0
  35. package/dist/fields/encrypted/queryRewrite.js +20 -0
  36. package/dist/fields/encrypted/queryRewrite.js.map +1 -1
  37. package/dist/fields/encrypted/validators.js +1 -1
  38. package/dist/fields/encrypted/validators.js.map +1 -1
  39. package/dist/fields/icon/adapters/tabler/generated/nodes.js +1 -1
  40. package/dist/fields/icon/adapters/tabler/generated/nodes.js.map +1 -1
  41. package/dist/fields/icon/client/IconDrawerContent.js +8 -6
  42. package/dist/fields/icon/client/IconDrawerContent.js.map +1 -1
  43. package/dist/fields/icon/client/IconFieldClient.js +15 -37
  44. package/dist/fields/icon/client/IconFieldClient.js.map +1 -1
  45. package/dist/fields/icon/client/icon-field.css +137 -233
  46. package/dist/fields/icon/codegen/sources/tabler.js +25 -6
  47. package/dist/fields/icon/codegen/sources/tabler.js.map +1 -1
  48. package/dist/fields/icon/layers/upload.js +3 -0
  49. package/dist/fields/icon/layers/upload.js.map +1 -1
  50. package/dist/fields/icon/react/createIcon.js +4 -4
  51. package/dist/fields/icon/react/createIcon.js.map +1 -1
  52. package/dist/fields/measurement/client/MeasurementInput.js +18 -32
  53. package/dist/fields/measurement/client/MeasurementInput.js.map +1 -1
  54. package/dist/fields/measurement/client/editModel.js +12 -3
  55. package/dist/fields/measurement/client/editModel.js.map +1 -1
  56. package/dist/fields/measurement/client/measurementField.css +58 -105
  57. package/dist/fields/measurement/server/getUserUnits.js +2 -1
  58. package/dist/fields/measurement/server/getUserUnits.js.map +1 -1
  59. package/dist/fields/phoneNumber/client/CountryPicker.js +14 -9
  60. package/dist/fields/phoneNumber/client/CountryPicker.js.map +1 -1
  61. package/dist/fields/phoneNumber/client/PhoneNumberField.d.ts +1 -1
  62. package/dist/fields/phoneNumber/client/PhoneNumberField.js +22 -4
  63. package/dist/fields/phoneNumber/client/PhoneNumberField.js.map +1 -1
  64. package/dist/fields/phoneNumber/client/phoneNumberField.css +109 -142
  65. package/dist/fields/phoneNumber/phoneNumberField.js +1 -1
  66. package/dist/fields/phoneNumber/phoneNumberField.js.map +1 -1
  67. package/dist/fields/phoneNumber/server/PhoneNumberCellServer.js +2 -1
  68. package/dist/fields/phoneNumber/server/PhoneNumberCellServer.js.map +1 -1
  69. package/dist/index.d.ts +3 -2
  70. package/dist/index.js +5 -4
  71. package/dist/index.js.map +1 -1
  72. package/dist/plugin/companionSelect.d.ts +12 -0
  73. package/dist/plugin/companionSelect.js +107 -0
  74. package/dist/plugin/companionSelect.js.map +1 -0
  75. package/package.json +15 -15
  76. package/dist/fields/encrypted/typescriptSchema.js.map +0 -1
@@ -0,0 +1,107 @@
1
+ //#region src/plugin/companionSelect.ts
2
+ /** `field.custom` key under which a field lists the companions its list Cell reads. */
3
+ const FIELD_CUSTOM_KEY = "@10x-media/fields";
4
+ /** Dot path of a sibling of `path` named `name`. */
5
+ const siblingPath = (path, name) => path.includes(".") ? `${path.slice(0, path.lastIndexOf(".") + 1)}${name}` : name;
6
+ /**
7
+ * Marks `field` so that selecting it also selects the named siblings. A list Cell that reads a
8
+ * virtual sibling from `rowData` needs this: Payload 4's list view selects only visible columns.
9
+ */
10
+ const withCompanions = (field, siblings) => {
11
+ const custom = field.custom ?? {};
12
+ const own = custom[FIELD_CUSTOM_KEY] ?? {};
13
+ return {
14
+ ...field,
15
+ custom: {
16
+ ...custom,
17
+ [FIELD_CUSTOM_KEY]: {
18
+ ...own,
19
+ selectWith: siblings
20
+ }
21
+ }
22
+ };
23
+ };
24
+ const companionsOf = (field) => {
25
+ const own = field.custom?.[FIELD_CUSTOM_KEY];
26
+ return Array.isArray(own?.selectWith) ? own.selectWith.filter((name) => typeof name === "string") : [];
27
+ };
28
+ /** Companion entries by dot path through groups, named tabs, rows, collapsibles and unnamed tabs. */
29
+ const scanCompanions = (fields, prefix = "") => {
30
+ const out = [];
31
+ for (const field of fields ?? []) {
32
+ if ("name" in field && typeof field.name === "string") {
33
+ const siblings = companionsOf(field);
34
+ if (siblings.length > 0) {
35
+ const path = `${prefix}${field.name}`;
36
+ out.push({
37
+ path,
38
+ siblings: siblings.map((name) => siblingPath(path, name))
39
+ });
40
+ }
41
+ }
42
+ if (field.type === "group" && "name" in field && field.name) out.push(...scanCompanions(field.fields, `${prefix}${field.name}.`));
43
+ else if (field.type === "row" || field.type === "collapsible") out.push(...scanCompanions(field.fields, prefix));
44
+ else if (field.type === "tabs") for (const tab of field.tabs) {
45
+ const tabPrefix = "name" in tab && tab.name ? `${prefix}${tab.name}.` : prefix;
46
+ out.push(...scanCompanions(tab.fields, tabPrefix));
47
+ }
48
+ }
49
+ return out;
50
+ };
51
+ const selectedAt = (select, path) => {
52
+ let node = select;
53
+ for (const segment of path.split(".")) {
54
+ if (!node || typeof node !== "object") return false;
55
+ node = node[segment];
56
+ }
57
+ return node === true || typeof node === "object" && node !== null;
58
+ };
59
+ const withSelectedAt = (select, path) => {
60
+ const [head, ...rest] = path.split(".");
61
+ if (rest.length === 0) return {
62
+ ...select,
63
+ [head]: true
64
+ };
65
+ const child = select[head];
66
+ if (child === true) return select;
67
+ return {
68
+ ...select,
69
+ [head]: withSelectedAt(typeof child === "object" ? child : {}, rest.join("."))
70
+ };
71
+ };
72
+ /**
73
+ * A collection `select` function that adds each entry's siblings to an include-mode select that
74
+ * names the entry's field, after running the collection's own `select` function. An exclude-mode
75
+ * select already returns the siblings unless it excludes them by name, so it passes through.
76
+ */
77
+ const companionSelect = (entries, prior) => {
78
+ const selectFn = (args) => {
79
+ const resolved = prior ? prior(args) : void 0;
80
+ const select = resolved === void 0 ? args.select : resolved;
81
+ if (!select || Object.values(select).some((value) => value === false)) return resolved;
82
+ let next = select;
83
+ for (const { path, siblings } of entries) {
84
+ if (!selectedAt(next, path)) continue;
85
+ for (const sibling of siblings) next = withSelectedAt(next, sibling);
86
+ }
87
+ return next === select ? resolved : next;
88
+ };
89
+ return selectFn;
90
+ };
91
+ /**
92
+ * Selects the companions marked with `withCompanions` whenever their field is selected. The
93
+ * fields() plugin applies this to every collection; call it directly only when using the field
94
+ * factories without the plugin.
95
+ */
96
+ const withCompanionSelect = (collection) => {
97
+ const entries = scanCompanions(collection.fields);
98
+ if (entries.length === 0) return collection;
99
+ return {
100
+ ...collection,
101
+ select: companionSelect(entries, collection.select)
102
+ };
103
+ };
104
+ //#endregion
105
+ export { companionSelect, siblingPath, withCompanionSelect, withCompanions };
106
+
107
+ //# sourceMappingURL=companionSelect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"companionSelect.js","names":[],"sources":["../../src/plugin/companionSelect.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\n/** `field.custom` key under which a field lists the companions its list Cell reads. */\nconst FIELD_CUSTOM_KEY = '@10x-media/fields'\n\n/** One selectable field and the sibling names that must be selected with it. */\nexport type CompanionEntry = { path: string; siblings: string[] }\n\n/** Dot path of a sibling of `path` named `name`. */\nexport const siblingPath = (path: string, name: string): string =>\n\tpath.includes('.') ? `${path.slice(0, path.lastIndexOf('.') + 1)}${name}` : name\n\n/**\n * Marks `field` so that selecting it also selects the named siblings. A list Cell that reads a\n * virtual sibling from `rowData` needs this: Payload 4's list view selects only visible columns.\n */\nexport const withCompanions = <TField extends Field>(field: TField, siblings: string[]): TField => {\n\tconst custom = (field.custom ?? {}) as Record<string, unknown>\n\tconst own = (custom[FIELD_CUSTOM_KEY] ?? {}) as Record<string, unknown>\n\treturn {\n\t\t...field,\n\t\tcustom: { ...custom, [FIELD_CUSTOM_KEY]: { ...own, selectWith: siblings } },\n\t}\n}\n\nconst companionsOf = (field: Field): string[] => {\n\tconst own = (field.custom as Record<string, unknown> | undefined)?.[FIELD_CUSTOM_KEY] as\n\t\t| { selectWith?: unknown }\n\t\t| undefined\n\treturn Array.isArray(own?.selectWith)\n\t\t? own.selectWith.filter((name): name is string => typeof name === 'string')\n\t\t: []\n}\n\n/** Companion entries by dot path through groups, named tabs, rows, collapsibles and unnamed tabs. */\nexport const scanCompanions = (fields: Field[] | undefined, prefix = ''): CompanionEntry[] => {\n\tconst out: CompanionEntry[] = []\n\tfor (const field of fields ?? []) {\n\t\tif ('name' in field && typeof field.name === 'string') {\n\t\t\tconst siblings = companionsOf(field)\n\t\t\tif (siblings.length > 0) {\n\t\t\t\tconst path = `${prefix}${field.name}`\n\t\t\t\tout.push({ path, siblings: siblings.map((name) => siblingPath(path, name)) })\n\t\t\t}\n\t\t}\n\t\tif (field.type === 'group' && 'name' in field && field.name) {\n\t\t\tout.push(...scanCompanions(field.fields, `${prefix}${field.name}.`))\n\t\t} else if (field.type === 'row' || field.type === 'collapsible') {\n\t\t\tout.push(...scanCompanions(field.fields, prefix))\n\t\t} else if (field.type === 'tabs') {\n\t\t\tfor (const tab of field.tabs) {\n\t\t\t\tconst tabPrefix = 'name' in tab && tab.name ? `${prefix}${tab.name}.` : prefix\n\t\t\t\tout.push(...scanCompanions(tab.fields, tabPrefix))\n\t\t\t}\n\t\t}\n\t}\n\treturn out\n}\n\ntype SelectNode = { [key: string]: SelectNode | boolean }\n\ntype SelectFunction = (\n\targs: Parameters<NonNullable<CollectionConfig['select']>>[0]\n) => Parameters<NonNullable<CollectionConfig['select']>>[0]['select']\n\nconst selectedAt = (select: SelectNode, path: string): boolean => {\n\tlet node: SelectNode | boolean | undefined = select\n\tfor (const segment of path.split('.')) {\n\t\tif (!node || typeof node !== 'object') return false\n\t\tnode = node[segment]\n\t}\n\treturn node === true || (typeof node === 'object' && node !== null)\n}\n\nconst withSelectedAt = (select: SelectNode, path: string): SelectNode => {\n\tconst [head, ...rest] = path.split('.') as [string, ...string[]]\n\tif (rest.length === 0) return { ...select, [head]: true }\n\tconst child = select[head]\n\tif (child === true) return select\n\treturn {\n\t\t...select,\n\t\t[head]: withSelectedAt(typeof child === 'object' ? child : {}, rest.join('.')),\n\t}\n}\n\n/**\n * A collection `select` function that adds each entry's siblings to an include-mode select that\n * names the entry's field, after running the collection's own `select` function. An exclude-mode\n * select already returns the siblings unless it excludes them by name, so it passes through.\n */\nexport const companionSelect = (\n\tentries: CompanionEntry[],\n\tprior: CollectionConfig['select']\n): NonNullable<CollectionConfig['select']> => {\n\tconst selectFn: SelectFunction = (args) => {\n\t\tconst resolved = prior ? prior(args) : undefined\n\t\tconst select = (resolved === undefined ? args.select : resolved) as SelectNode | undefined\n\t\tif (!select || Object.values(select).some((value) => value === false)) return resolved\n\t\tlet next = select\n\t\tfor (const { path, siblings } of entries) {\n\t\t\tif (!selectedAt(next, path)) continue\n\t\t\tfor (const sibling of siblings) next = withSelectedAt(next, sibling)\n\t\t}\n\t\treturn next === select ? resolved : (next as typeof args.select)\n\t}\n\t// A collection typed against generated types narrows the return to its include shape;\n\t// adding sibling keys keeps an include select an include select.\n\treturn selectFn as NonNullable<CollectionConfig['select']>\n}\n\n/**\n * Selects the companions marked with `withCompanions` whenever their field is selected. The\n * fields() plugin applies this to every collection; call it directly only when using the field\n * factories without the plugin.\n */\nexport const withCompanionSelect = (collection: CollectionConfig): CollectionConfig => {\n\tconst entries = scanCompanions(collection.fields)\n\tif (entries.length === 0) return collection\n\treturn { ...collection, select: companionSelect(entries, collection.select) }\n}\n"],"mappings":";;AAGA,MAAM,mBAAmB;;AAMzB,MAAa,eAAe,MAAc,SACzC,KAAK,SAAS,GAAG,IAAI,GAAG,KAAK,MAAM,GAAG,KAAK,YAAY,GAAG,IAAI,CAAC,IAAI,SAAS;;;;;AAM7E,MAAa,kBAAwC,OAAe,aAA+B;CAClG,MAAM,SAAU,MAAM,UAAU,CAAC;CACjC,MAAM,MAAO,OAAO,qBAAqB,CAAC;CAC1C,OAAO;EACN,GAAG;EACH,QAAQ;GAAE,GAAG;IAAS,mBAAmB;IAAE,GAAG;IAAK,YAAY;GAAS;EAAE;CAC3E;AACD;AAEA,MAAM,gBAAgB,UAA2B;CAChD,MAAM,MAAO,MAAM,SAAiD;CAGpE,OAAO,MAAM,QAAQ,KAAK,UAAU,IACjC,IAAI,WAAW,QAAQ,SAAyB,OAAO,SAAS,QAAQ,IACxE,CAAC;AACL;;AAGA,MAAa,kBAAkB,QAA6B,SAAS,OAAyB;CAC7F,MAAM,MAAwB,CAAC;CAC/B,KAAK,MAAM,SAAS,UAAU,CAAC,GAAG;EACjC,IAAI,UAAU,SAAS,OAAO,MAAM,SAAS,UAAU;GACtD,MAAM,WAAW,aAAa,KAAK;GACnC,IAAI,SAAS,SAAS,GAAG;IACxB,MAAM,OAAO,GAAG,SAAS,MAAM;IAC/B,IAAI,KAAK;KAAE;KAAM,UAAU,SAAS,KAAK,SAAS,YAAY,MAAM,IAAI,CAAC;IAAE,CAAC;GAC7E;EACD;EACA,IAAI,MAAM,SAAS,WAAW,UAAU,SAAS,MAAM,MACtD,IAAI,KAAK,GAAG,eAAe,MAAM,QAAQ,GAAG,SAAS,MAAM,KAAK,EAAE,CAAC;OAC7D,IAAI,MAAM,SAAS,SAAS,MAAM,SAAS,eACjD,IAAI,KAAK,GAAG,eAAe,MAAM,QAAQ,MAAM,CAAC;OAC1C,IAAI,MAAM,SAAS,QACzB,KAAK,MAAM,OAAO,MAAM,MAAM;GAC7B,MAAM,YAAY,UAAU,OAAO,IAAI,OAAO,GAAG,SAAS,IAAI,KAAK,KAAK;GACxE,IAAI,KAAK,GAAG,eAAe,IAAI,QAAQ,SAAS,CAAC;EAClD;CAEF;CACA,OAAO;AACR;AAQA,MAAM,cAAc,QAAoB,SAA0B;CACjE,IAAI,OAAyC;CAC7C,KAAK,MAAM,WAAW,KAAK,MAAM,GAAG,GAAG;EACtC,IAAI,CAAC,QAAQ,OAAO,SAAS,UAAU,OAAO;EAC9C,OAAO,KAAK;CACb;CACA,OAAO,SAAS,QAAS,OAAO,SAAS,YAAY,SAAS;AAC/D;AAEA,MAAM,kBAAkB,QAAoB,SAA6B;CACxE,MAAM,CAAC,MAAM,GAAG,QAAQ,KAAK,MAAM,GAAG;CACtC,IAAI,KAAK,WAAW,GAAG,OAAO;EAAE,GAAG;GAAS,OAAO;CAAK;CACxD,MAAM,QAAQ,OAAO;CACrB,IAAI,UAAU,MAAM,OAAO;CAC3B,OAAO;EACN,GAAG;GACF,OAAO,eAAe,OAAO,UAAU,WAAW,QAAQ,CAAC,GAAG,KAAK,KAAK,GAAG,CAAC;CAC9E;AACD;;;;;;AAOA,MAAa,mBACZ,SACA,UAC6C;CAC7C,MAAM,YAA4B,SAAS;EAC1C,MAAM,WAAW,QAAQ,MAAM,IAAI,IAAI,KAAA;EACvC,MAAM,SAAU,aAAa,KAAA,IAAY,KAAK,SAAS;EACvD,IAAI,CAAC,UAAU,OAAO,OAAO,MAAM,EAAE,MAAM,UAAU,UAAU,KAAK,GAAG,OAAO;EAC9E,IAAI,OAAO;EACX,KAAK,MAAM,EAAE,MAAM,cAAc,SAAS;GACzC,IAAI,CAAC,WAAW,MAAM,IAAI,GAAG;GAC7B,KAAK,MAAM,WAAW,UAAU,OAAO,eAAe,MAAM,OAAO;EACpE;EACA,OAAO,SAAS,SAAS,WAAY;CACtC;CAGA,OAAO;AACR;;;;;;AAOA,MAAa,uBAAuB,eAAmD;CACtF,MAAM,UAAU,eAAe,WAAW,MAAM;CAChD,IAAI,QAAQ,WAAW,GAAG,OAAO;CACjC,OAAO;EAAE,GAAG;EAAY,QAAQ,gBAAgB,SAAS,WAAW,MAAM;CAAE;AAC7E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@10x-media/fields",
3
- "version": "0.1.0-beta.9",
3
+ "version": "4.0.0-alpha.2",
4
4
  "description": "Reusable admin fields for Payload: color picker, icon picker, encrypted fields, and more",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -21,7 +21,7 @@
21
21
  ],
22
22
  "author": "10x-media",
23
23
  "engines": {
24
- "node": ">=22.18.0"
24
+ "node": ">=24.22.1"
25
25
  },
26
26
  "type": "module",
27
27
  "sideEffects": false,
@@ -124,12 +124,12 @@
124
124
  "LICENSE"
125
125
  ],
126
126
  "peerDependencies": {
127
- "@payloadcms/richtext-lexical": "^3.83.0",
128
- "@payloadcms/ui": "^3.83.0",
127
+ "@payloadcms/richtext-lexical": "^4.0.0-beta.6",
128
+ "@payloadcms/ui": "^4.0.0-beta.6",
129
129
  "@radix-ui/react-icons": "^1.3.0",
130
130
  "@tabler/icons-react": "^3.0.0",
131
131
  "lucide-react": ">=0.500.0",
132
- "payload": "^3.83.0",
132
+ "payload": "^4.0.0-beta.6",
133
133
  "react": "^19.0.0",
134
134
  "react-dom": "^19.0.0"
135
135
  },
@@ -155,10 +155,10 @@
155
155
  },
156
156
  "devDependencies": {
157
157
  "@axe-core/playwright": "^4.11.3",
158
- "@payloadcms/db-mongodb": "3.85.0",
159
- "@payloadcms/db-postgres": "3.85.0",
160
- "@payloadcms/richtext-lexical": "3.85.0",
161
- "@payloadcms/ui": "3.85.0",
158
+ "@payloadcms/db-mongodb": "4.0.0-beta.7",
159
+ "@payloadcms/db-postgres": "4.0.0-beta.7",
160
+ "@payloadcms/richtext-lexical": "4.0.0-beta.7",
161
+ "@payloadcms/ui": "4.0.0-beta.7",
162
162
  "@playwright/test": "1.60.0",
163
163
  "@radix-ui/react-icons": "1.3.2",
164
164
  "@tabler/icons": "3.31.0",
@@ -166,14 +166,14 @@
166
166
  "@testing-library/react": "^16.1.0",
167
167
  "@types/jsdom": "^21.1.7",
168
168
  "@types/json-schema": "^7.0.15",
169
- "@types/node": "22.19.19",
169
+ "@types/node": "24.19.2",
170
170
  "@types/react": "19.2.15",
171
171
  "@types/react-dom": "19.2.3",
172
172
  "axe-core": "^4.12.1",
173
173
  "jsdom": "^25.0.1",
174
174
  "lucide-react": "0.561.0",
175
175
  "lucide-static": "0.561.0",
176
- "payload": "3.85.0",
176
+ "payload": "4.0.0-beta.7",
177
177
  "playwright": "1.60.0",
178
178
  "react": "19.2.6",
179
179
  "react-dom": "19.2.6",
@@ -181,18 +181,18 @@
181
181
  "tsx": "^4.19.2",
182
182
  "typescript": "5.9.3",
183
183
  "vitest": "4.1.7",
184
+ "@10x-media/payload-test-harness": "0.0.0",
184
185
  "@10x-media/tsconfig": "0.0.0",
185
186
  "@10x-media/tsdown-config": "0.0.0",
186
- "@10x-media/vitest-config": "0.0.0",
187
- "@10x-media/payload-test-harness": "0.0.0"
187
+ "@10x-media/vitest-config": "0.0.0"
188
188
  },
189
189
  "publishConfig": {
190
190
  "access": "public"
191
191
  },
192
192
  "scripts": {
193
193
  "build": "tsdown",
194
- "lint": "biome check src tests dev",
195
- "lint:fix": "biome check --write src tests dev",
194
+ "lint": "biome check src tests dev dev-tanstack",
195
+ "lint:fix": "biome check --write src tests dev dev-tanstack",
196
196
  "typecheck": "tsc -p tsconfig.json --noEmit",
197
197
  "test": "vitest run",
198
198
  "test:unit": "vitest run src",
@@ -1 +0,0 @@
1
- {"version":3,"file":"typescriptSchema.js","names":[],"sources":["../../../src/fields/encrypted/typescriptSchema.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\nimport type { EncryptedSourceField } from './types'\n\nconst optionValues = (source: EncryptedSourceField): string[] =>\n\t'options' in source\n\t\t? source.options.map((option) => (typeof option === 'string' ? option : option.value))\n\t\t: []\n\nconst baseSchema = (source: EncryptedSourceField): JSONSchema4 => {\n\tswitch (source.type) {\n\t\tcase 'checkbox':\n\t\t\treturn { type: 'boolean' }\n\t\tcase 'number':\n\t\t\treturn { type: 'number' }\n\t\tcase 'json':\n\t\tcase 'richText':\n\t\t\treturn { additionalProperties: true, type: 'object' }\n\t\tcase 'point':\n\t\t\treturn { items: { type: 'number' }, maxItems: 2, minItems: 2, type: 'array' }\n\t\tcase 'radio':\n\t\tcase 'select':\n\t\t\treturn { enum: optionValues(source), type: 'string' }\n\t\tdefault:\n\t\t\treturn { type: 'string' }\n\t}\n}\n\n/**\n * The stored field is text, but generated TypeScript must keep the source\n * type's shape (number stays number, checkbox stays boolean, ...).\n */\nexport const typescriptSchemaFor = (\n\tsource: EncryptedSourceField\n): Array<(args: { jsonSchema: JSONSchema4 }) => JSONSchema4> => {\n\tconst single = baseSchema(source)\n\tconst schema: JSONSchema4 =\n\t\t'hasMany' in source && source.hasMany === true ? { items: single, type: 'array' } : single\n\treturn [() => schema]\n}\n"],"mappings":";AAGA,MAAM,gBAAgB,WACrB,aAAa,SACV,OAAO,QAAQ,KAAK,WAAY,OAAO,WAAW,WAAW,SAAS,OAAO,KAAM,IACnF,CAAC;AAEL,MAAM,cAAc,WAA8C;CACjE,QAAQ,OAAO,MAAf;EACC,KAAK,YACJ,OAAO,EAAE,MAAM,UAAU;EAC1B,KAAK,UACJ,OAAO,EAAE,MAAM,SAAS;EACzB,KAAK;EACL,KAAK,YACJ,OAAO;GAAE,sBAAsB;GAAM,MAAM;EAAS;EACrD,KAAK,SACJ,OAAO;GAAE,OAAO,EAAE,MAAM,SAAS;GAAG,UAAU;GAAG,UAAU;GAAG,MAAM;EAAQ;EAC7E,KAAK;EACL,KAAK,UACJ,OAAO;GAAE,MAAM,aAAa,MAAM;GAAG,MAAM;EAAS;EACrD,SACC,OAAO,EAAE,MAAM,SAAS;CAC1B;AACD;;;;;AAMA,MAAa,uBACZ,WAC+D;CAC/D,MAAM,SAAS,WAAW,MAAM;CAChC,MAAM,SACL,aAAa,UAAU,OAAO,YAAY,OAAO;EAAE,OAAO;EAAQ,MAAM;CAAQ,IAAI;CACrF,OAAO,OAAO,MAAM;AACrB"}