@10x-media/fields 0.1.0-beta.0

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 (299) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE +21 -0
  3. package/README.md +62 -0
  4. package/dist/exports/client.d.ts +7 -0
  5. package/dist/exports/client.js +8 -0
  6. package/dist/exports/color-utils.d.ts +9 -0
  7. package/dist/exports/color-utils.js +7 -0
  8. package/dist/exports/color.d.ts +6 -0
  9. package/dist/exports/color.js +5 -0
  10. package/dist/exports/encrypted.d.ts +12 -0
  11. package/dist/exports/encrypted.js +10 -0
  12. package/dist/exports/i18n.d.ts +3 -0
  13. package/dist/exports/i18n.js +3 -0
  14. package/dist/exports/icon-adapters/lucide.d.ts +5 -0
  15. package/dist/exports/icon-adapters/lucide.js +4 -0
  16. package/dist/exports/icon-adapters/radix.d.ts +5 -0
  17. package/dist/exports/icon-adapters/radix.js +4 -0
  18. package/dist/exports/icon-adapters/tabler.d.ts +5 -0
  19. package/dist/exports/icon-adapters/tabler.js +4 -0
  20. package/dist/exports/icon-codegen.d.ts +4 -0
  21. package/dist/exports/icon-codegen.js +2 -0
  22. package/dist/exports/icon-react.d.ts +4 -0
  23. package/dist/exports/icon-react.js +3 -0
  24. package/dist/exports/icon.d.ts +8 -0
  25. package/dist/exports/icon.js +7 -0
  26. package/dist/exports/rsc.d.ts +10 -0
  27. package/dist/exports/rsc.js +9 -0
  28. package/dist/exports/types.d.ts +4 -0
  29. package/dist/exports/types.js +1 -0
  30. package/dist/fields/color/client/ColorField.d.ts +13 -0
  31. package/dist/fields/color/client/ColorField.js +321 -0
  32. package/dist/fields/color/client/ColorField.js.map +1 -0
  33. package/dist/fields/color/client/ColorPickerPanel.d.ts +29 -0
  34. package/dist/fields/color/client/ColorPickerPanel.js +233 -0
  35. package/dist/fields/color/client/ColorPickerPanel.js.map +1 -0
  36. package/dist/fields/color/client/colorField.css +411 -0
  37. package/dist/fields/color/client/icons.js +38 -0
  38. package/dist/fields/color/client/icons.js.map +1 -0
  39. package/dist/fields/color/colorField.d.ts +20 -0
  40. package/dist/fields/color/colorField.js +102 -0
  41. package/dist/fields/color/colorField.js.map +1 -0
  42. package/dist/fields/color/commitValue.js +29 -0
  43. package/dist/fields/color/commitValue.js.map +1 -0
  44. package/dist/fields/color/engine/contrast.d.ts +10 -0
  45. package/dist/fields/color/engine/contrast.js +25 -0
  46. package/dist/fields/color/engine/contrast.js.map +1 -0
  47. package/dist/fields/color/engine/convert.d.ts +28 -0
  48. package/dist/fields/color/engine/convert.js +232 -0
  49. package/dist/fields/color/engine/convert.js.map +1 -0
  50. package/dist/fields/color/engine/format.d.ts +15 -0
  51. package/dist/fields/color/engine/format.js +53 -0
  52. package/dist/fields/color/engine/format.js.map +1 -0
  53. package/dist/fields/color/engine/index.d.ts +8 -0
  54. package/dist/fields/color/engine/namedColors.d.ts +9 -0
  55. package/dist/fields/color/engine/namedColors.js +159 -0
  56. package/dist/fields/color/engine/namedColors.js.map +1 -0
  57. package/dist/fields/color/engine/parse.d.ts +12 -0
  58. package/dist/fields/color/engine/parse.js +151 -0
  59. package/dist/fields/color/engine/parse.js.map +1 -0
  60. package/dist/fields/color/engine/salvage.d.ts +13 -0
  61. package/dist/fields/color/engine/salvage.js +75 -0
  62. package/dist/fields/color/engine/salvage.js.map +1 -0
  63. package/dist/fields/color/engine/types.d.ts +34 -0
  64. package/dist/fields/color/options.d.ts +55 -0
  65. package/dist/fields/color/options.js +8 -0
  66. package/dist/fields/color/options.js.map +1 -0
  67. package/dist/fields/color/presetChip.js +27 -0
  68. package/dist/fields/color/presetChip.js.map +1 -0
  69. package/dist/fields/color/presetsFromDoc.d.ts +27 -0
  70. package/dist/fields/color/presetsFromDoc.js +74 -0
  71. package/dist/fields/color/presetsFromDoc.js.map +1 -0
  72. package/dist/fields/color/resolveFormat.js +16 -0
  73. package/dist/fields/color/resolveFormat.js.map +1 -0
  74. package/dist/fields/color/resolvePresets.d.ts +29 -0
  75. package/dist/fields/color/resolvePresets.js +39 -0
  76. package/dist/fields/color/resolvePresets.js.map +1 -0
  77. package/dist/fields/color/server/ColorCell.d.ts +6 -0
  78. package/dist/fields/color/server/ColorCell.js +34 -0
  79. package/dist/fields/color/server/ColorCell.js.map +1 -0
  80. package/dist/fields/color/server/ColorFieldServer.d.ts +18 -0
  81. package/dist/fields/color/server/ColorFieldServer.js +69 -0
  82. package/dist/fields/color/server/ColorFieldServer.js.map +1 -0
  83. package/dist/fields/color/server/colorCell.css +32 -0
  84. package/dist/fields/encrypted/boot.d.ts +14 -0
  85. package/dist/fields/encrypted/boot.js +22 -0
  86. package/dist/fields/encrypted/boot.js.map +1 -0
  87. package/dist/fields/encrypted/components/EncryptedInput.js +89 -0
  88. package/dist/fields/encrypted/components/EncryptedInput.js.map +1 -0
  89. package/dist/fields/encrypted/components/EncryptedTextarea.js +86 -0
  90. package/dist/fields/encrypted/components/EncryptedTextarea.js.map +1 -0
  91. package/dist/fields/encrypted/components/EyeToggle.js +51 -0
  92. package/dist/fields/encrypted/components/EyeToggle.js.map +1 -0
  93. package/dist/fields/encrypted/components/MaskDots.js +20 -0
  94. package/dist/fields/encrypted/components/MaskDots.js.map +1 -0
  95. package/dist/fields/encrypted/components/ProtectedCell.d.ts +19 -0
  96. package/dist/fields/encrypted/components/ProtectedCell.js +44 -0
  97. package/dist/fields/encrypted/components/ProtectedCell.js.map +1 -0
  98. package/dist/fields/encrypted/components/ProtectedField.css +180 -0
  99. package/dist/fields/encrypted/components/ProtectedField.d.ts +30 -0
  100. package/dist/fields/encrypted/components/ProtectedField.js +95 -0
  101. package/dist/fields/encrypted/components/ProtectedField.js.map +1 -0
  102. package/dist/fields/encrypted/components/ProtectedRichText.d.ts +21 -0
  103. package/dist/fields/encrypted/components/ProtectedRichText.js +35 -0
  104. package/dist/fields/encrypted/components/ProtectedRichText.js.map +1 -0
  105. package/dist/fields/encrypted/components/RichTextRevealGate.d.ts +24 -0
  106. package/dist/fields/encrypted/components/RichTextRevealGate.js +87 -0
  107. package/dist/fields/encrypted/components/RichTextRevealGate.js.map +1 -0
  108. package/dist/fields/encrypted/components/StructuralField.js +64 -0
  109. package/dist/fields/encrypted/components/StructuralField.js.map +1 -0
  110. package/dist/fields/encrypted/components/facsimiles.js +219 -0
  111. package/dist/fields/encrypted/components/facsimiles.js.map +1 -0
  112. package/dist/fields/encrypted/components/placement.js +21 -0
  113. package/dist/fields/encrypted/components/placement.js.map +1 -0
  114. package/dist/fields/encrypted/crypto/aad.js +29 -0
  115. package/dist/fields/encrypted/crypto/aad.js.map +1 -0
  116. package/dist/fields/encrypted/crypto/bidx.js +26 -0
  117. package/dist/fields/encrypted/crypto/bidx.js.map +1 -0
  118. package/dist/fields/encrypted/crypto/keys.d.ts +31 -0
  119. package/dist/fields/encrypted/crypto/keys.js +113 -0
  120. package/dist/fields/encrypted/crypto/keys.js.map +1 -0
  121. package/dist/fields/encrypted/crypto/wire.d.ts +23 -0
  122. package/dist/fields/encrypted/crypto/wire.js +135 -0
  123. package/dist/fields/encrypted/crypto/wire.js.map +1 -0
  124. package/dist/fields/encrypted/encryptedField.d.ts +15 -0
  125. package/dist/fields/encrypted/encryptedField.js +187 -0
  126. package/dist/fields/encrypted/encryptedField.js.map +1 -0
  127. package/dist/fields/encrypted/hooks.d.ts +21 -0
  128. package/dist/fields/encrypted/hooks.js +326 -0
  129. package/dist/fields/encrypted/hooks.js.map +1 -0
  130. package/dist/fields/encrypted/maskDots.js +16 -0
  131. package/dist/fields/encrypted/maskDots.js.map +1 -0
  132. package/dist/fields/encrypted/plaintextStash.js +57 -0
  133. package/dist/fields/encrypted/plaintextStash.js.map +1 -0
  134. package/dist/fields/encrypted/queryRewrite.d.ts +12 -0
  135. package/dist/fields/encrypted/queryRewrite.js +134 -0
  136. package/dist/fields/encrypted/queryRewrite.js.map +1 -0
  137. package/dist/fields/encrypted/scan.js +36 -0
  138. package/dist/fields/encrypted/scan.js.map +1 -0
  139. package/dist/fields/encrypted/types.d.ts +35 -0
  140. package/dist/fields/encrypted/types.js +12 -0
  141. package/dist/fields/encrypted/types.js.map +1 -0
  142. package/dist/fields/encrypted/typescriptSchema.js +41 -0
  143. package/dist/fields/encrypted/typescriptSchema.js.map +1 -0
  144. package/dist/fields/encrypted/utils/decryptAllData.d.ts +17 -0
  145. package/dist/fields/encrypted/utils/decryptAllData.js +98 -0
  146. package/dist/fields/encrypted/utils/decryptAllData.js.map +1 -0
  147. package/dist/fields/encrypted/utils/encryptExistingData.d.ts +14 -0
  148. package/dist/fields/encrypted/utils/encryptExistingData.js +72 -0
  149. package/dist/fields/encrypted/utils/encryptExistingData.js.map +1 -0
  150. package/dist/fields/encrypted/utils/pageThrough.js +42 -0
  151. package/dist/fields/encrypted/utils/pageThrough.js.map +1 -0
  152. package/dist/fields/encrypted/utils/rotateEncryptedFields.d.ts +27 -0
  153. package/dist/fields/encrypted/utils/rotateEncryptedFields.js +92 -0
  154. package/dist/fields/encrypted/utils/rotateEncryptedFields.js.map +1 -0
  155. package/dist/fields/encrypted/validators.js +111 -0
  156. package/dist/fields/encrypted/validators.js.map +1 -0
  157. package/dist/fields/icon/adapters/lucide/adapter.d.ts +8 -0
  158. package/dist/fields/icon/adapters/lucide/adapter.js +15 -0
  159. package/dist/fields/icon/adapters/lucide/adapter.js.map +1 -0
  160. package/dist/fields/icon/adapters/lucide/client.d.ts +10 -0
  161. package/dist/fields/icon/adapters/lucide/client.js +41 -0
  162. package/dist/fields/icon/adapters/lucide/client.js.map +1 -0
  163. package/dist/fields/icon/adapters/lucide/generated/manifest.js +23338 -0
  164. package/dist/fields/icon/adapters/lucide/generated/manifest.js.map +1 -0
  165. package/dist/fields/icon/adapters/lucide/generated/nodes.js +14296 -0
  166. package/dist/fields/icon/adapters/lucide/generated/nodes.js.map +1 -0
  167. package/dist/fields/icon/adapters/lucide/renderer.d.ts +7 -0
  168. package/dist/fields/icon/adapters/lucide/renderer.js +13 -0
  169. package/dist/fields/icon/adapters/lucide/renderer.js.map +1 -0
  170. package/dist/fields/icon/adapters/radix/adapter.d.ts +8 -0
  171. package/dist/fields/icon/adapters/radix/adapter.js +14 -0
  172. package/dist/fields/icon/adapters/radix/adapter.js.map +1 -0
  173. package/dist/fields/icon/adapters/radix/client.d.ts +8 -0
  174. package/dist/fields/icon/adapters/radix/client.js +20 -0
  175. package/dist/fields/icon/adapters/radix/client.js.map +1 -0
  176. package/dist/fields/icon/adapters/radix/generated/imports.js +324 -0
  177. package/dist/fields/icon/adapters/radix/generated/imports.js.map +1 -0
  178. package/dist/fields/icon/adapters/radix/generated/manifest.js +1805 -0
  179. package/dist/fields/icon/adapters/radix/generated/manifest.js.map +1 -0
  180. package/dist/fields/icon/adapters/radix/renderer.d.ts +7 -0
  181. package/dist/fields/icon/adapters/radix/renderer.js +23 -0
  182. package/dist/fields/icon/adapters/radix/renderer.js.map +1 -0
  183. package/dist/fields/icon/adapters/tabler/adapter.d.ts +8 -0
  184. package/dist/fields/icon/adapters/tabler/adapter.js +15 -0
  185. package/dist/fields/icon/adapters/tabler/adapter.js.map +1 -0
  186. package/dist/fields/icon/adapters/tabler/client.d.ts +9 -0
  187. package/dist/fields/icon/adapters/tabler/client.js +18 -0
  188. package/dist/fields/icon/adapters/tabler/client.js.map +1 -0
  189. package/dist/fields/icon/adapters/tabler/generated/imports.js +4942 -0
  190. package/dist/fields/icon/adapters/tabler/generated/imports.js.map +1 -0
  191. package/dist/fields/icon/adapters/tabler/generated/manifest.js +61269 -0
  192. package/dist/fields/icon/adapters/tabler/generated/manifest.js.map +1 -0
  193. package/dist/fields/icon/adapters/tabler/generated/nodes.js +26749 -0
  194. package/dist/fields/icon/adapters/tabler/generated/nodes.js.map +1 -0
  195. package/dist/fields/icon/adapters/tabler/renderer.d.ts +7 -0
  196. package/dist/fields/icon/adapters/tabler/renderer.js +13 -0
  197. package/dist/fields/icon/adapters/tabler/renderer.js.map +1 -0
  198. package/dist/fields/icon/client/DrawerGlyph.js +32 -0
  199. package/dist/fields/icon/client/DrawerGlyph.js.map +1 -0
  200. package/dist/fields/icon/client/IconDrawerContent.js +294 -0
  201. package/dist/fields/icon/client/IconDrawerContent.js.map +1 -0
  202. package/dist/fields/icon/client/IconFieldClient.d.ts +19 -0
  203. package/dist/fields/icon/client/IconFieldClient.js +245 -0
  204. package/dist/fields/icon/client/IconFieldClient.js.map +1 -0
  205. package/dist/fields/icon/client/IconLibrarySelect.d.ts +14 -0
  206. package/dist/fields/icon/client/IconLibrarySelect.js +36 -0
  207. package/dist/fields/icon/client/IconLibrarySelect.js.map +1 -0
  208. package/dist/fields/icon/client/availableLibraries.js +25 -0
  209. package/dist/fields/icon/client/availableLibraries.js.map +1 -0
  210. package/dist/fields/icon/client/generatedAdapter.js +88 -0
  211. package/dist/fields/icon/client/generatedAdapter.js.map +1 -0
  212. package/dist/fields/icon/client/icon-field.css +524 -0
  213. package/dist/fields/icon/client/useRecentIcons.js +32 -0
  214. package/dist/fields/icon/client/useRecentIcons.js.map +1 -0
  215. package/dist/fields/icon/codegen/emit.js +81 -0
  216. package/dist/fields/icon/codegen/emit.js.map +1 -0
  217. package/dist/fields/icon/codegen/generate.d.ts +10 -0
  218. package/dist/fields/icon/codegen/generate.js +59 -0
  219. package/dist/fields/icon/codegen/generate.js.map +1 -0
  220. package/dist/fields/icon/codegen/sources/lucide.js +52 -0
  221. package/dist/fields/icon/codegen/sources/lucide.js.map +1 -0
  222. package/dist/fields/icon/codegen/sources/radix.js +33 -0
  223. package/dist/fields/icon/codegen/sources/radix.js.map +1 -0
  224. package/dist/fields/icon/codegen/sources/tabler.js +31 -0
  225. package/dist/fields/icon/codegen/sources/tabler.js.map +1 -0
  226. package/dist/fields/icon/codegen/types.d.ts +36 -0
  227. package/dist/fields/icon/defineIconAdapter.d.ts +8 -0
  228. package/dist/fields/icon/defineIconAdapter.js +10 -0
  229. package/dist/fields/icon/defineIconAdapter.js.map +1 -0
  230. package/dist/fields/icon/plugin.js +55 -0
  231. package/dist/fields/icon/plugin.js.map +1 -0
  232. package/dist/fields/icon/react/createIcon.d.ts +15 -0
  233. package/dist/fields/icon/react/createIcon.js +47 -0
  234. package/dist/fields/icon/react/createIcon.js.map +1 -0
  235. package/dist/fields/icon/react/createRscIcon.d.ts +12 -0
  236. package/dist/fields/icon/react/createRscIcon.js +27 -0
  237. package/dist/fields/icon/react/createRscIcon.js.map +1 -0
  238. package/dist/fields/icon/react/types.d.ts +24 -0
  239. package/dist/fields/icon/rsc/IconCell.d.ts +14 -0
  240. package/dist/fields/icon/rsc/IconCell.js +32 -0
  241. package/dist/fields/icon/rsc/IconCell.js.map +1 -0
  242. package/dist/fields/icon/rsc/IconFieldServer.d.ts +24 -0
  243. package/dist/fields/icon/rsc/IconFieldServer.js +74 -0
  244. package/dist/fields/icon/rsc/IconFieldServer.js.map +1 -0
  245. package/dist/fields/icon/rsc/IconLibrarySelectServer.d.ts +13 -0
  246. package/dist/fields/icon/rsc/IconLibrarySelectServer.js +24 -0
  247. package/dist/fields/icon/rsc/IconLibrarySelectServer.js.map +1 -0
  248. package/dist/fields/icon/rsc/resolveStaticLabel.js +16 -0
  249. package/dist/fields/icon/rsc/resolveStaticLabel.js.map +1 -0
  250. package/dist/fields/icon/server/availability.d.ts +32 -0
  251. package/dist/fields/icon/server/availability.js +58 -0
  252. package/dist/fields/icon/server/availability.js.map +1 -0
  253. package/dist/fields/icon/server/iconField.d.ts +32 -0
  254. package/dist/fields/icon/server/iconField.js +48 -0
  255. package/dist/fields/icon/server/iconField.js.map +1 -0
  256. package/dist/fields/icon/server/iconLibraryField.d.ts +23 -0
  257. package/dist/fields/icon/server/iconLibraryField.js +50 -0
  258. package/dist/fields/icon/server/iconLibraryField.js.map +1 -0
  259. package/dist/fields/icon/server/libraryOptions.d.ts +12 -0
  260. package/dist/fields/icon/server/libraryOptions.js +13 -0
  261. package/dist/fields/icon/server/libraryOptions.js.map +1 -0
  262. package/dist/fields/icon/server/manifestCache.js +17 -0
  263. package/dist/fields/icon/server/manifestCache.js.map +1 -0
  264. package/dist/fields/icon/server/validate.js +37 -0
  265. package/dist/fields/icon/server/validate.js.map +1 -0
  266. package/dist/fields/icon/shared/adapterComponents.d.ts +23 -0
  267. package/dist/fields/icon/shared/formatIconLabel.js +16 -0
  268. package/dist/fields/icon/shared/formatIconLabel.js.map +1 -0
  269. package/dist/fields/icon/shared/search.js +58 -0
  270. package/dist/fields/icon/shared/search.js.map +1 -0
  271. package/dist/fields/icon/shared/value.d.ts +16 -0
  272. package/dist/fields/icon/shared/value.js +27 -0
  273. package/dist/fields/icon/shared/value.js.map +1 -0
  274. package/dist/index.d.ts +39 -0
  275. package/dist/index.js +41 -0
  276. package/dist/index.js.map +1 -0
  277. package/dist/plugin/registerTranslations.js +19 -0
  278. package/dist/plugin/registerTranslations.js.map +1 -0
  279. package/dist/plugin/registry.d.ts +9 -0
  280. package/dist/plugin/registry.js +14 -0
  281. package/dist/plugin/registry.js.map +1 -0
  282. package/dist/translations/de.js +49 -0
  283. package/dist/translations/de.js.map +1 -0
  284. package/dist/translations/en.js +49 -0
  285. package/dist/translations/en.js.map +1 -0
  286. package/dist/translations/index.d.ts +15 -0
  287. package/dist/translations/index.js +30 -0
  288. package/dist/translations/index.js.map +1 -0
  289. package/dist/translations/keys.d.ts +48 -0
  290. package/dist/translations/keys.js +48 -0
  291. package/dist/translations/keys.js.map +1 -0
  292. package/dist/translations/server.js +13 -0
  293. package/dist/translations/server.js.map +1 -0
  294. package/dist/translations/useTranslation.js +12 -0
  295. package/dist/translations/useTranslation.js.map +1 -0
  296. package/dist/types.d.ts +105 -0
  297. package/dist/utils/memoForRequest.js +25 -0
  298. package/dist/utils/memoForRequest.js.map +1 -0
  299. package/package.json +196 -0
@@ -0,0 +1,180 @@
1
+ /* Eyeball masking (all structural types, including the richText reveal gate). */
2
+
3
+ .tenx-protected-field__eye-icon .stroke {
4
+ fill: none;
5
+ stroke: currentColor;
6
+ stroke-width: 0.75;
7
+ vector-effect: non-scaling-stroke;
8
+ }
9
+
10
+ .tenx-protected-field__eye {
11
+ cursor: pointer;
12
+ --btn-icon-size: var(--base);
13
+ }
14
+
15
+ /* Floating eye for corner (textarea) and label-row (structural) placements. */
16
+ .tenx-protected-field__eye--floating {
17
+ color: var(--theme-elevation-500);
18
+ }
19
+
20
+ .tenx-protected-field__eye--floating:hover {
21
+ color: var(--theme-elevation-800);
22
+ }
23
+
24
+ /* Attached eye segment, mirroring Payload's API-key toggle button. Background is
25
+ the input's own --theme-input-bg (not an elevation step) so the segment reads
26
+ as part of the input; the only seam is the input's right border, which the
27
+ segment continues around its top, right, and bottom. Height is a literal 40px
28
+ to match the native input: Payload compiles its formInput mixin to literal px,
29
+ while var(--base) is rem-derived and shrinks below 1024px, so a base-derived
30
+ height renders ~37px next to a 40px input. The doubled class outranks Payload's
31
+ own `.btn { height: base(2) }`, which otherwise wins by cascade order. */
32
+ .tenx-protected-field__eye.tenx-protected-field__eye--attached {
33
+ align-self: stretch;
34
+ height: 40px;
35
+ margin: 0 0 0 -1px;
36
+ padding: 0 calc(var(--base) / 2);
37
+ border: 1px solid var(--theme-elevation-150);
38
+ border-left: 0;
39
+ border-radius: var(--style-radius-s);
40
+ border-top-left-radius: 0;
41
+ border-bottom-left-radius: 0;
42
+ background: var(--theme-input-bg);
43
+ box-shadow: none;
44
+ color: var(--theme-elevation-800);
45
+ transition: border-color 100ms cubic-bezier(0, 0.2, 0.2, 1);
46
+ }
47
+
48
+ .tenx-protected-field__eye--attached:hover {
49
+ background: var(--theme-elevation-100);
50
+ }
51
+
52
+ /* Hover or focus lights the input and eye together, so the focus border never
53
+ cuts off at the seam. Payload shifts an input border to elevation-250 on hover
54
+ and elevation-400 on focus; mirror that onto the eye and drive both from the
55
+ row, so focusing either half highlights the whole control as one. */
56
+ .tenx-protected-field__attached-row:hover input,
57
+ .tenx-protected-field__attached-row:hover .tenx-protected-field__eye--attached {
58
+ border-color: var(--theme-elevation-250);
59
+ }
60
+
61
+ .tenx-protected-field__attached-row:focus-within input,
62
+ .tenx-protected-field__attached-row:focus-within .tenx-protected-field__eye--attached {
63
+ border-color: var(--theme-elevation-400);
64
+ }
65
+
66
+ /* Attached placement: input row with the eye appended as a flex segment. */
67
+ .tenx-protected-field__attached-row {
68
+ display: flex;
69
+ align-items: center;
70
+ }
71
+
72
+ .tenx-protected-field--attached .tenx-protected-field__attached-row input {
73
+ border-top-right-radius: 0;
74
+ border-bottom-right-radius: 0;
75
+ }
76
+
77
+ .tenx-protected-field__eye-wrap--attached {
78
+ display: flex;
79
+ align-self: stretch;
80
+ }
81
+
82
+ /* Corner placement: eye pinned to the top-right of the textarea wrap. */
83
+ .tenx-protected-field--corner .field-type__wrap {
84
+ position: relative;
85
+ }
86
+
87
+ .tenx-protected-field__eye-wrap--corner {
88
+ position: absolute;
89
+ top: 6px;
90
+ right: 6px;
91
+ z-index: 1;
92
+ }
93
+
94
+ /* Label-row placement: eye pinned to the label line. The wrapper (not the
95
+ nested native face) is the direct child of .render-fields, so it must carry
96
+ the native field rhythm itself; the attached/corner types get it free because
97
+ their root IS a .field-type. --spacing-field collapses to 0 inside a row, so
98
+ row layouts stay correct. */
99
+ .tenx-protected-field--label-row {
100
+ position: relative;
101
+ margin-bottom: var(--spacing-field);
102
+ }
103
+
104
+ .tenx-protected-field__eye-wrap--label-row {
105
+ position: absolute;
106
+ top: 0;
107
+ right: 0;
108
+ z-index: 1;
109
+ display: flex;
110
+ align-items: center;
111
+ }
112
+
113
+ /* Reveal slot for the label-row types (structural + richText). The native
114
+ editor mounts on first reveal and then stays mounted; concealing only sets
115
+ display:none on this slot, so re-revealing never remounts. Remounting Lexical
116
+ or react-select is what caused the toggle flicker. */
117
+ .tenx-protected-field__reveal-slot--hidden {
118
+ display: none;
119
+ }
120
+
121
+ /* Concealed dots. */
122
+ .tenx-protected-field__dots {
123
+ color: var(--theme-elevation-500);
124
+ letter-spacing: 0.15em;
125
+ user-select: none;
126
+ white-space: nowrap;
127
+ }
128
+
129
+ .tenx-protected-field__masked-input,
130
+ .tenx-protected-field__masked-textarea {
131
+ color: var(--theme-elevation-500);
132
+ letter-spacing: 0.15em;
133
+ cursor: default;
134
+ }
135
+
136
+ .tenx-protected-field__masked-textarea {
137
+ resize: none;
138
+ }
139
+
140
+ /* Static select face: react-select's flex layout, which emotion supplies at
141
+ runtime, is recreated here since the face never mounts react-select. */
142
+ .tenx-protected-field__face .rs__control {
143
+ display: flex;
144
+ align-items: center;
145
+ }
146
+
147
+ /* A 40px floor on both the concealed face control and the revealed react-select
148
+ control, so toggling a select never changes height. Payload's react-select is
149
+ height:auto (single-value ~40px, multi-value chips ~38px), so without the floor
150
+ a hasMany field shrinks 2px on reveal; the floor keeps both states on the 40px
151
+ input rhythm. */
152
+ .tenx-protected-field--label-row .rs__control {
153
+ min-height: 40px;
154
+ }
155
+
156
+ .tenx-protected-field__face .rs__value-container {
157
+ display: flex;
158
+ align-items: center;
159
+ flex: 1 1 auto;
160
+ overflow: hidden;
161
+ }
162
+
163
+ .tenx-protected-field__face .rs__indicators {
164
+ display: flex;
165
+ align-items: center;
166
+ align-self: stretch;
167
+ }
168
+
169
+ /* Static code/json face: an editor-styled box of dot lines, no Monaco. */
170
+ .tenx-protected-field__editor-box {
171
+ min-height: calc(var(--base) * 4);
172
+ padding: calc(var(--base) * 0.5) calc(var(--base) * 0.75);
173
+ border: 1px solid var(--theme-elevation-150);
174
+ border-radius: var(--style-radius-s);
175
+ background: var(--theme-elevation-50);
176
+ font-family: var(--font-mono);
177
+ color: var(--theme-elevation-500);
178
+ white-space: pre-wrap;
179
+ word-break: break-all;
180
+ }
@@ -0,0 +1,30 @@
1
+ import { EncryptedFieldPatch, EncryptedProtection } from "../types.js";
2
+ import { TextFieldClientProps } from "payload";
3
+ import React from "react";
4
+ //#region src/fields/encrypted/components/ProtectedField.d.ts
5
+ interface ProtectedFieldProps extends TextFieldClientProps {
6
+ componentKey: string;
7
+ fieldPatch: EncryptedFieldPatch;
8
+ maskDots?: number;
9
+ protection: EncryptedProtection;
10
+ }
11
+ /**
12
+ * Single admin dispatcher for scalar and structural encrypted fields (richText
13
+ * is its own virtual-editor field pair, wired to ProtectedRichText). Each type
14
+ * renders as its native variant with a fixed run of dots while concealed, and an
15
+ * inline eye toggle that swaps to the real editable native component on reveal.
16
+ * The fieldPatch restores type-specific config (options, hasMany, date admin) on
17
+ * the revealed component.
18
+ *
19
+ * Masking is visual-only by design. afterRead decrypts server-side, so the
20
+ * field's form value is already plaintext regardless of the mask, and no masked
21
+ * facsimile binds to that value. Two accepted consequences: (a) the plaintext
22
+ * reaches an authorized admin's browser, since that admin already has field read
23
+ * access and masking only stops casual over-the-shoulder display; (b) saving an
24
+ * unchanged document re-seals with a fresh IV (version churn), because the form
25
+ * holds plaintext, not the stored ciphertext.
26
+ */
27
+ declare const ProtectedField: React.FC<ProtectedFieldProps>;
28
+ //#endregion
29
+ export { ProtectedField };
30
+ //# sourceMappingURL=ProtectedField.d.ts.map
@@ -0,0 +1,95 @@
1
+ "use client";
2
+ import { clampMaskDots } from "../maskDots.js";
3
+ import { EncryptedInput } from "./EncryptedInput.js";
4
+ import { EncryptedTextarea } from "./EncryptedTextarea.js";
5
+ import { placementFor } from "./placement.js";
6
+ import { StructuralField } from "./StructuralField.js";
7
+ import { CheckboxField, CodeField, DateTimeField, EmailField, JSONField, NumberField, PointField, RadioGroupField, SelectField, TextField, TextareaField, useFormFields } from "@payloadcms/ui";
8
+ import { useMemo, useState } from "react";
9
+ import { jsx } from "react/jsx-runtime";
10
+ import "./ProtectedField.css";
11
+ //#region src/fields/encrypted/components/ProtectedField.tsx
12
+ const NATIVE = {
13
+ checkbox: CheckboxField,
14
+ code: CodeField,
15
+ date: DateTimeField,
16
+ email: EmailField,
17
+ json: JSONField,
18
+ number: NumberField,
19
+ point: PointField,
20
+ radio: RadioGroupField,
21
+ select: SelectField,
22
+ text: TextField,
23
+ textarea: TextareaField
24
+ };
25
+ /**
26
+ * A field with no stored content has nothing to conceal, so it renders unmasked
27
+ * (the plain native control). Captured once at mount, so characters typed into a
28
+ * field that started empty stay visible and the field never flips to masked
29
+ * mid-entry; a field that already holds content is masked until revealed.
30
+ */
31
+ const isEmptyValue = (value) => {
32
+ if (value == null || value === "") return true;
33
+ if (Array.isArray(value)) return value.length === 0 || value.every((item) => item == null);
34
+ return false;
35
+ };
36
+ /**
37
+ * Single admin dispatcher for scalar and structural encrypted fields (richText
38
+ * is its own virtual-editor field pair, wired to ProtectedRichText). Each type
39
+ * renders as its native variant with a fixed run of dots while concealed, and an
40
+ * inline eye toggle that swaps to the real editable native component on reveal.
41
+ * The fieldPatch restores type-specific config (options, hasMany, date admin) on
42
+ * the revealed component.
43
+ *
44
+ * Masking is visual-only by design. afterRead decrypts server-side, so the
45
+ * field's form value is already plaintext regardless of the mask, and no masked
46
+ * facsimile binds to that value. Two accepted consequences: (a) the plaintext
47
+ * reaches an authorized admin's browser, since that admin already has field read
48
+ * access and masking only stops casual over-the-shoulder display; (b) saving an
49
+ * unchanged document re-seals with a fresh IV (version churn), because the form
50
+ * holds plaintext, not the stored ciphertext.
51
+ */
52
+ const ProtectedField = (props) => {
53
+ const { componentKey, field, fieldPatch, path, protection } = props;
54
+ const maskDots = clampMaskDots(props.maskDots);
55
+ const [startedEmpty] = useState(useFormFields(([fields]) => isEmptyValue(fields?.[path]?.value)));
56
+ const patchedField = useMemo(() => ({
57
+ ...field,
58
+ ...fieldPatch,
59
+ admin: {
60
+ ...field.admin,
61
+ ...fieldPatch.admin
62
+ }
63
+ }), [field, fieldPatch]);
64
+ const Native = NATIVE[componentKey] ?? TextField;
65
+ const nativeProps = {
66
+ ...props,
67
+ field: patchedField
68
+ };
69
+ if (protection === "none" || startedEmpty) return /* @__PURE__ */ jsx(Native, { ...nativeProps });
70
+ const faceField = patchedField;
71
+ const placement = placementFor(componentKey, fieldPatch.hasMany === true);
72
+ if (placement === "attached") return /* @__PURE__ */ jsx(EncryptedInput, {
73
+ field: faceField,
74
+ kind: componentKey,
75
+ maskDots,
76
+ path
77
+ });
78
+ if (placement === "corner") return /* @__PURE__ */ jsx(EncryptedTextarea, {
79
+ field: faceField,
80
+ maskDots,
81
+ path
82
+ });
83
+ return /* @__PURE__ */ jsx(StructuralField, {
84
+ componentKey,
85
+ field: faceField,
86
+ maskDots,
87
+ Native,
88
+ nativeProps,
89
+ path
90
+ });
91
+ };
92
+ //#endregion
93
+ export { ProtectedField };
94
+
95
+ //# sourceMappingURL=ProtectedField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProtectedField.js","names":[],"sources":["../../../../src/fields/encrypted/components/ProtectedField.tsx"],"sourcesContent":["'use client'\nimport {\n\tCheckboxField,\n\tCodeField,\n\tDateTimeField,\n\tEmailField,\n\tJSONField,\n\tNumberField,\n\tPointField,\n\tRadioGroupField,\n\tSelectField,\n\tTextareaField,\n\tTextField,\n\tuseFormFields,\n} from '@payloadcms/ui'\nimport type { TextFieldClientProps } from 'payload'\nimport type React from 'react'\nimport { useMemo, useState } from 'react'\nimport { clampMaskDots } from '../maskDots'\nimport type { EncryptedFieldPatch, EncryptedProtection } from '../types'\nimport { EncryptedInput } from './EncryptedInput'\nimport { EncryptedTextarea } from './EncryptedTextarea'\nimport type { EncryptedFieldConfig } from './placement'\nimport { placementFor } from './placement'\nimport { StructuralField } from './StructuralField'\nimport './ProtectedField.css'\n\n/**\n * Native components accept per-type client props; dispatch is by runtime\n * componentKey, so the map is typed at the erased component boundary.\n */\ntype AnyFieldComponent = React.ComponentType<Record<string, unknown>>\n\nconst NATIVE: Record<string, AnyFieldComponent> = {\n\tcheckbox: CheckboxField as AnyFieldComponent,\n\tcode: CodeField as AnyFieldComponent,\n\tdate: DateTimeField as AnyFieldComponent,\n\temail: EmailField as AnyFieldComponent,\n\tjson: JSONField as AnyFieldComponent,\n\tnumber: NumberField as AnyFieldComponent,\n\tpoint: PointField as AnyFieldComponent,\n\tradio: RadioGroupField as AnyFieldComponent,\n\tselect: SelectField as AnyFieldComponent,\n\ttext: TextField as AnyFieldComponent,\n\ttextarea: TextareaField as AnyFieldComponent,\n}\n\nexport interface ProtectedFieldProps extends TextFieldClientProps {\n\tcomponentKey: string\n\tfieldPatch: EncryptedFieldPatch\n\tmaskDots?: number\n\tprotection: EncryptedProtection\n}\n\n/**\n * A field with no stored content has nothing to conceal, so it renders unmasked\n * (the plain native control). Captured once at mount, so characters typed into a\n * field that started empty stay visible and the field never flips to masked\n * mid-entry; a field that already holds content is masked until revealed.\n */\nconst isEmptyValue = (value: unknown): boolean => {\n\tif (value == null || value === '') {\n\t\treturn true\n\t}\n\tif (Array.isArray(value)) {\n\t\treturn value.length === 0 || value.every((item) => item == null)\n\t}\n\treturn false\n}\n\n/**\n * Single admin dispatcher for scalar and structural encrypted fields (richText\n * is its own virtual-editor field pair, wired to ProtectedRichText). Each type\n * renders as its native variant with a fixed run of dots while concealed, and an\n * inline eye toggle that swaps to the real editable native component on reveal.\n * The fieldPatch restores type-specific config (options, hasMany, date admin) on\n * the revealed component.\n *\n * Masking is visual-only by design. afterRead decrypts server-side, so the\n * field's form value is already plaintext regardless of the mask, and no masked\n * facsimile binds to that value. Two accepted consequences: (a) the plaintext\n * reaches an authorized admin's browser, since that admin already has field read\n * access and masking only stops casual over-the-shoulder display; (b) saving an\n * unchanged document re-seals with a fresh IV (version churn), because the form\n * holds plaintext, not the stored ciphertext.\n */\nexport const ProtectedField: React.FC<ProtectedFieldProps> = (props) => {\n\tconst { componentKey, field, fieldPatch, path, protection } = props\n\tconst maskDots = clampMaskDots(props.maskDots)\n\tconst startedEmptyNow = useFormFields(([fields]) => isEmptyValue(fields?.[path]?.value))\n\tconst [startedEmpty] = useState(startedEmptyNow)\n\n\tconst patchedField = useMemo(\n\t\t() => ({\n\t\t\t...field,\n\t\t\t...fieldPatch,\n\t\t\tadmin: { ...field.admin, ...fieldPatch.admin },\n\t\t}),\n\t\t[field, fieldPatch]\n\t)\n\n\tconst Native = NATIVE[componentKey] ?? (TextField as AnyFieldComponent)\n\tconst nativeProps = { ...(props as unknown as Record<string, unknown>), field: patchedField }\n\n\tif (protection === 'none' || startedEmpty) {\n\t\treturn <Native {...nativeProps} />\n\t}\n\n\tconst faceField = patchedField as unknown as EncryptedFieldConfig\n\tconst hasMany = fieldPatch.hasMany === true\n\tconst placement = placementFor(componentKey, hasMany)\n\n\tif (placement === 'attached') {\n\t\treturn (\n\t\t\t<EncryptedInput\n\t\t\t\tfield={faceField}\n\t\t\t\tkind={componentKey as 'email' | 'number' | 'text'}\n\t\t\t\tmaskDots={maskDots}\n\t\t\t\tpath={path}\n\t\t\t/>\n\t\t)\n\t}\n\n\tif (placement === 'corner') {\n\t\treturn <EncryptedTextarea field={faceField} maskDots={maskDots} path={path} />\n\t}\n\n\treturn (\n\t\t<StructuralField\n\t\t\tcomponentKey={componentKey}\n\t\t\tfield={faceField}\n\t\t\tmaskDots={maskDots}\n\t\t\tNative={Native}\n\t\t\tnativeProps={nativeProps}\n\t\t\tpath={path}\n\t\t/>\n\t)\n}\n"],"mappings":";;;;;;;;;;;AAiCA,MAAM,SAA4C;CACjD,UAAU;CACV,MAAM;CACN,MAAM;CACN,OAAO;CACP,MAAM;CACN,QAAQ;CACR,OAAO;CACP,OAAO;CACP,QAAQ;CACR,MAAM;CACN,UAAU;AACX;;;;;;;AAeA,MAAM,gBAAgB,UAA4B;CACjD,IAAI,SAAS,QAAQ,UAAU,IAC9B,OAAO;CAER,IAAI,MAAM,QAAQ,KAAK,GACtB,OAAO,MAAM,WAAW,KAAK,MAAM,OAAO,SAAS,QAAQ,IAAI;CAEhE,OAAO;AACR;;;;;;;;;;;;;;;;;AAkBA,MAAa,kBAAiD,UAAU;CACvE,MAAM,EAAE,cAAc,OAAO,YAAY,MAAM,eAAe;CAC9D,MAAM,WAAW,cAAc,MAAM,QAAQ;CAE7C,MAAM,CAAC,gBAAgB,SADC,eAAe,CAAC,YAAY,aAAa,SAAS,OAAO,KAAK,CACxC,CAAC;CAE/C,MAAM,eAAe,eACb;EACN,GAAG;EACH,GAAG;EACH,OAAO;GAAE,GAAG,MAAM;GAAO,GAAG,WAAW;EAAM;CAC9C,IACA,CAAC,OAAO,UAAU,CACnB;CAEA,MAAM,SAAS,OAAO,iBAAkB;CACxC,MAAM,cAAc;EAAE,GAAI;EAA8C,OAAO;CAAa;CAE5F,IAAI,eAAe,UAAU,cAC5B,OAAO,oBAAC,QAAD,EAAQ,GAAI,YAAc,CAAA;CAGlC,MAAM,YAAY;CAElB,MAAM,YAAY,aAAa,cADf,WAAW,YAAY,IACa;CAEpD,IAAI,cAAc,YACjB,OACC,oBAAC,gBAAD;EACC,OAAO;EACP,MAAM;EACI;EACJ;CACN,CAAA;CAIH,IAAI,cAAc,UACjB,OAAO,oBAAC,mBAAD;EAAmB,OAAO;EAAqB;EAAgB;CAAO,CAAA;CAG9E,OACC,oBAAC,iBAAD;EACe;EACd,OAAO;EACG;EACF;EACK;EACP;CACN,CAAA;AAEH"}
@@ -0,0 +1,21 @@
1
+ import { EncryptedProtection } from "../types.js";
2
+ import { RichTextFieldServerProps } from "payload";
3
+
4
+ //#region src/fields/encrypted/components/ProtectedRichText.d.ts
5
+ type ProtectedRichTextProps = RichTextFieldServerProps & {
6
+ protection: EncryptedProtection;
7
+ };
8
+ /**
9
+ * Server component for a masked encrypted richText field. Delegates to Payload's
10
+ * own RscEntryLexicalField so the app's complete Lexical node set mounts: the
11
+ * virtual field is a real richText field, so the schema-map and import-map
12
+ * pipeline ran for it. The rendered editor is wrapped in a client reveal gate.
13
+ * The editor's server work runs regardless of reveal state; only its client
14
+ * LexicalComposer is withheld until revealed. Crypto stays server-side, and this
15
+ * file never enters a client bundle (the lexical editor loads via the app import
16
+ * map like any richText field).
17
+ */
18
+ declare const ProtectedRichText: (props: ProtectedRichTextProps) => import("react/jsx-runtime").JSX.Element;
19
+ //#endregion
20
+ export { ProtectedRichText };
21
+ //# sourceMappingURL=ProtectedRichText.d.ts.map
@@ -0,0 +1,35 @@
1
+ import { RichTextRevealGate } from "./RichTextRevealGate.js";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { RscEntryLexicalField } from "@payloadcms/richtext-lexical/rsc";
4
+ //#region src/fields/encrypted/components/ProtectedRichText.tsx
5
+ /**
6
+ * Server component for a masked encrypted richText field. Delegates to Payload's
7
+ * own RscEntryLexicalField so the app's complete Lexical node set mounts: the
8
+ * virtual field is a real richText field, so the schema-map and import-map
9
+ * pipeline ran for it. The rendered editor is wrapped in a client reveal gate.
10
+ * The editor's server work runs regardless of reveal state; only its client
11
+ * LexicalComposer is withheld until revealed. Crypto stays server-side, and this
12
+ * file never enters a client bundle (the lexical editor loads via the app import
13
+ * map like any richText field).
14
+ */
15
+ const ProtectedRichText = (props) => {
16
+ const { protection: _protection, ...serverProps } = props;
17
+ const { editor } = serverProps.field;
18
+ const sanitizedEditorConfig = editor && typeof editor === "object" && "editorConfig" in editor ? editor.editorConfig : void 0;
19
+ const clientField = serverProps.clientField;
20
+ const editorProps = {
21
+ ...serverProps,
22
+ sanitizedEditorConfig
23
+ };
24
+ return /* @__PURE__ */ jsx(RichTextRevealGate, {
25
+ label: clientField?.label,
26
+ localized: clientField?.localized,
27
+ path: serverProps.path,
28
+ required: clientField?.required,
29
+ children: /* @__PURE__ */ jsx(RscEntryLexicalField, { ...editorProps })
30
+ });
31
+ };
32
+ //#endregion
33
+ export { ProtectedRichText };
34
+
35
+ //# sourceMappingURL=ProtectedRichText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProtectedRichText.js","names":[],"sources":["../../../../src/fields/encrypted/components/ProtectedRichText.tsx"],"sourcesContent":["import { RscEntryLexicalField } from '@payloadcms/richtext-lexical/rsc'\nimport type { RichTextFieldClient, RichTextFieldServerProps } from 'payload'\nimport type { ComponentProps } from 'react'\nimport type { EncryptedProtection } from '../types'\nimport { RichTextRevealGate } from './RichTextRevealGate'\n\ntype ProtectedRichTextProps = RichTextFieldServerProps & { protection: EncryptedProtection }\n\ntype SanitizedEditorConfig = ComponentProps<typeof RscEntryLexicalField>['sanitizedEditorConfig']\n\n/**\n * Server component for a masked encrypted richText field. Delegates to Payload's\n * own RscEntryLexicalField so the app's complete Lexical node set mounts: the\n * virtual field is a real richText field, so the schema-map and import-map\n * pipeline ran for it. The rendered editor is wrapped in a client reveal gate.\n * The editor's server work runs regardless of reveal state; only its client\n * LexicalComposer is withheld until revealed. Crypto stays server-side, and this\n * file never enters a client bundle (the lexical editor loads via the app import\n * map like any richText field).\n */\nexport const ProtectedRichText = (props: ProtectedRichTextProps) => {\n\tconst { protection: _protection, ...serverProps } = props\n\tconst { editor } = serverProps.field\n\t// A sanitized richText field always carries the lexical editorConfig (the exact\n\t// value renderField injects for a native richText field); the loose adapter\n\t// type surfaces it as unknown, so assert the component's own prop type.\n\tconst sanitizedEditorConfig = (\n\t\teditor && typeof editor === 'object' && 'editorConfig' in editor\n\t\t\t? editor.editorConfig\n\t\t\t: undefined\n\t) as SanitizedEditorConfig\n\tconst clientField = serverProps.clientField as RichTextFieldClient | undefined\n\t// RscEntryLexicalField's declared props intersect ClientComponentProps and\n\t// ServerComponentProps, whose `field` types are mutually exclusive (client vs\n\t// server), so no non-cast value satisfies it. This is the exact runtime shape\n\t// renderField passes through its own loosely-typed boundary.\n\tconst editorProps = { ...serverProps, sanitizedEditorConfig } as unknown as ComponentProps<\n\t\ttypeof RscEntryLexicalField\n\t>\n\treturn (\n\t\t<RichTextRevealGate\n\t\t\tlabel={clientField?.label}\n\t\t\tlocalized={clientField?.localized}\n\t\t\tpath={serverProps.path}\n\t\t\trequired={clientField?.required}\n\t\t>\n\t\t\t<RscEntryLexicalField {...editorProps} />\n\t\t</RichTextRevealGate>\n\t)\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,MAAa,qBAAqB,UAAkC;CACnE,MAAM,EAAE,YAAY,aAAa,GAAG,gBAAgB;CACpD,MAAM,EAAE,WAAW,YAAY;CAI/B,MAAM,wBACL,UAAU,OAAO,WAAW,YAAY,kBAAkB,SACvD,OAAO,eACP,KAAA;CAEJ,MAAM,cAAc,YAAY;CAKhC,MAAM,cAAc;EAAE,GAAG;EAAa;CAAsB;CAG5D,OACC,oBAAC,oBAAD;EACC,OAAO,aAAa;EACpB,WAAW,aAAa;EACxB,MAAM,YAAY;EAClB,UAAU,aAAa;YAEvB,oBAAC,sBAAD,EAAsB,GAAI,YAAc,CAAA;CACrB,CAAA;AAEtB"}
@@ -0,0 +1,24 @@
1
+ import { StaticLabel } from "payload";
2
+ import React from "react";
3
+ //#region src/fields/encrypted/components/RichTextRevealGate.d.ts
4
+ /**
5
+ * Reveal gate for the encrypted richText editor. The server-passed editor subtree
6
+ * mounts on first reveal and then stays mounted; concealing only sets
7
+ * display:none on its slot, so re-revealing never re-initialises Lexical (that
8
+ * remount was the toggle flicker). Until the first reveal the editor is absent,
9
+ * so the decrypted value only enters the DOM once the admin reveals it. The
10
+ * concealed face is a static, form-unbound mask (the decrypted value is already
11
+ * in form state from the field's afterRead hook, so a concealed submit reseals
12
+ * the untouched plaintext). The eye is pinned to the label line in both states so
13
+ * toggling never moves focus or shifts layout.
14
+ */
15
+ declare const RichTextRevealGate: React.FC<{
16
+ children: React.ReactNode;
17
+ label?: StaticLabel;
18
+ localized?: boolean;
19
+ path: string;
20
+ required?: boolean;
21
+ }>;
22
+ //#endregion
23
+ export { RichTextRevealGate };
24
+ //# sourceMappingURL=RichTextRevealGate.d.ts.map
@@ -0,0 +1,87 @@
1
+ "use client";
2
+ import { keys } from "../../../translations/keys.js";
3
+ import { useTranslation as useTranslation$1 } from "../../../translations/useTranslation.js";
4
+ import { EyeToggle } from "./EyeToggle.js";
5
+ import { MaskDots } from "./MaskDots.js";
6
+ import { FieldLabel, useField } from "@payloadcms/ui";
7
+ import { useCallback, useState } from "react";
8
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
9
+ import "./ProtectedField.css";
10
+ //#region src/fields/encrypted/components/RichTextRevealGate.tsx
11
+ const MASK_DOTS = 8;
12
+ /**
13
+ * Empty rich text has nothing to conceal, so it renders the editor directly (no
14
+ * mask, no eye), matching how empty scalar fields render native. Null, an empty
15
+ * root, and the default single-empty-paragraph state all count as empty.
16
+ */
17
+ const isEmptyRichText = (value) => {
18
+ if (value == null) return true;
19
+ const children = value.root?.children;
20
+ if (!Array.isArray(children) || children.length === 0) return true;
21
+ return children.every((node) => {
22
+ const n = node;
23
+ if (typeof n.text === "string") return n.text.trim() === "";
24
+ return !n.children || n.children.length === 0;
25
+ });
26
+ };
27
+ /**
28
+ * Reveal gate for the encrypted richText editor. The server-passed editor subtree
29
+ * mounts on first reveal and then stays mounted; concealing only sets
30
+ * display:none on its slot, so re-revealing never re-initialises Lexical (that
31
+ * remount was the toggle flicker). Until the first reveal the editor is absent,
32
+ * so the decrypted value only enters the DOM once the admin reveals it. The
33
+ * concealed face is a static, form-unbound mask (the decrypted value is already
34
+ * in form state from the field's afterRead hook, so a concealed submit reseals
35
+ * the untouched plaintext). The eye is pinned to the label line in both states so
36
+ * toggling never moves focus or shifts layout.
37
+ */
38
+ const RichTextRevealGate = ({ children, label, localized, path, required }) => {
39
+ const { t } = useTranslation$1();
40
+ const { value } = useField({ path });
41
+ const [startedEmpty] = useState(() => isEmptyRichText(value));
42
+ const [revealed, setRevealed] = useState(false);
43
+ const [mounted, setMounted] = useState(false);
44
+ const toggle = useCallback(() => {
45
+ setRevealed((prev) => !prev);
46
+ setMounted(true);
47
+ }, []);
48
+ if (startedEmpty) return /* @__PURE__ */ jsx(Fragment$1, { children });
49
+ return /* @__PURE__ */ jsxs("div", {
50
+ className: "tenx-protected-field tenx-protected-field--label-row",
51
+ children: [
52
+ mounted ? /* @__PURE__ */ jsx("div", {
53
+ className: revealed ? void 0 : "tenx-protected-field__reveal-slot--hidden",
54
+ children
55
+ }) : null,
56
+ revealed ? null : /* @__PURE__ */ jsxs("div", {
57
+ className: "field-type tenx-protected-field__face",
58
+ children: [/* @__PURE__ */ jsx(FieldLabel, {
59
+ label,
60
+ localized,
61
+ path,
62
+ required
63
+ }), /* @__PURE__ */ jsx("div", {
64
+ className: "field-type__wrap",
65
+ children: /* @__PURE__ */ jsx("div", {
66
+ "aria-label": t(keys.encryptedValue),
67
+ className: "tenx-protected-field__editor-box",
68
+ role: "img",
69
+ children: /* @__PURE__ */ jsx(MaskDots, { count: MASK_DOTS })
70
+ })
71
+ })]
72
+ }),
73
+ /* @__PURE__ */ jsx("div", {
74
+ className: "tenx-protected-field__eye-wrap tenx-protected-field__eye-wrap--label-row",
75
+ children: /* @__PURE__ */ jsx(EyeToggle, {
76
+ className: "tenx-protected-field__eye--floating",
77
+ onToggle: toggle,
78
+ revealed
79
+ })
80
+ })
81
+ ]
82
+ });
83
+ };
84
+ //#endregion
85
+ export { RichTextRevealGate };
86
+
87
+ //# sourceMappingURL=RichTextRevealGate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RichTextRevealGate.js","names":["useTranslation"],"sources":["../../../../src/fields/encrypted/components/RichTextRevealGate.tsx"],"sourcesContent":["'use client'\nimport { FieldLabel, useField } from '@payloadcms/ui'\nimport type { StaticLabel } from 'payload'\nimport type React from 'react'\nimport { useCallback, useState } from 'react'\nimport { keys } from '../../../translations/keys'\nimport { useTranslation } from '../../../translations/useTranslation'\nimport { EyeToggle } from './EyeToggle'\nimport { MaskDots } from './MaskDots'\nimport './ProtectedField.css'\n\nconst MASK_DOTS = 8\n\n/**\n * Empty rich text has nothing to conceal, so it renders the editor directly (no\n * mask, no eye), matching how empty scalar fields render native. Null, an empty\n * root, and the default single-empty-paragraph state all count as empty.\n */\nconst isEmptyRichText = (value: unknown): boolean => {\n\tif (value == null) {\n\t\treturn true\n\t}\n\tconst children = (value as { root?: { children?: unknown[] } }).root?.children\n\tif (!Array.isArray(children) || children.length === 0) {\n\t\treturn true\n\t}\n\treturn children.every((node) => {\n\t\tconst n = node as { children?: unknown[]; text?: string }\n\t\tif (typeof n.text === 'string') {\n\t\t\treturn n.text.trim() === ''\n\t\t}\n\t\treturn !n.children || n.children.length === 0\n\t})\n}\n\n/**\n * Reveal gate for the encrypted richText editor. The server-passed editor subtree\n * mounts on first reveal and then stays mounted; concealing only sets\n * display:none on its slot, so re-revealing never re-initialises Lexical (that\n * remount was the toggle flicker). Until the first reveal the editor is absent,\n * so the decrypted value only enters the DOM once the admin reveals it. The\n * concealed face is a static, form-unbound mask (the decrypted value is already\n * in form state from the field's afterRead hook, so a concealed submit reseals\n * the untouched plaintext). The eye is pinned to the label line in both states so\n * toggling never moves focus or shifts layout.\n */\nexport const RichTextRevealGate: React.FC<{\n\tchildren: React.ReactNode\n\tlabel?: StaticLabel\n\tlocalized?: boolean\n\tpath: string\n\trequired?: boolean\n}> = ({ children, label, localized, path, required }) => {\n\tconst { t } = useTranslation()\n\tconst { value } = useField<unknown>({ path })\n\tconst [startedEmpty] = useState(() => isEmptyRichText(value))\n\tconst [revealed, setRevealed] = useState(false)\n\tconst [mounted, setMounted] = useState(false)\n\tconst toggle = useCallback(() => {\n\t\tsetRevealed((prev) => !prev)\n\t\tsetMounted(true)\n\t}, [])\n\n\tif (startedEmpty) {\n\t\treturn <>{children}</>\n\t}\n\n\treturn (\n\t\t<div className=\"tenx-protected-field tenx-protected-field--label-row\">\n\t\t\t{mounted ? (\n\t\t\t\t<div className={revealed ? undefined : 'tenx-protected-field__reveal-slot--hidden'}>\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t\t{revealed ? null : (\n\t\t\t\t<div className=\"field-type tenx-protected-field__face\">\n\t\t\t\t\t<FieldLabel label={label} localized={localized} path={path} required={required} />\n\t\t\t\t\t<div className=\"field-type__wrap\">\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\taria-label={t(keys.encryptedValue)}\n\t\t\t\t\t\t\tclassName=\"tenx-protected-field__editor-box\"\n\t\t\t\t\t\t\trole=\"img\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<MaskDots count={MASK_DOTS} />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t\t<div className=\"tenx-protected-field__eye-wrap tenx-protected-field__eye-wrap--label-row\">\n\t\t\t\t<EyeToggle\n\t\t\t\t\tclassName=\"tenx-protected-field__eye--floating\"\n\t\t\t\t\tonToggle={toggle}\n\t\t\t\t\trevealed={revealed}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;;;;;;;AAWA,MAAM,YAAY;;;;;;AAOlB,MAAM,mBAAmB,UAA4B;CACpD,IAAI,SAAS,MACZ,OAAO;CAER,MAAM,WAAY,MAA8C,MAAM;CACtE,IAAI,CAAC,MAAM,QAAQ,QAAQ,KAAK,SAAS,WAAW,GACnD,OAAO;CAER,OAAO,SAAS,OAAO,SAAS;EAC/B,MAAM,IAAI;EACV,IAAI,OAAO,EAAE,SAAS,UACrB,OAAO,EAAE,KAAK,KAAK,MAAM;EAE1B,OAAO,CAAC,EAAE,YAAY,EAAE,SAAS,WAAW;CAC7C,CAAC;AACF;;;;;;;;;;;;AAaA,MAAa,sBAMP,EAAE,UAAU,OAAO,WAAW,MAAM,eAAe;CACxD,MAAM,EAAE,MAAMA,iBAAe;CAC7B,MAAM,EAAE,UAAU,SAAkB,EAAE,KAAK,CAAC;CAC5C,MAAM,CAAC,gBAAgB,eAAe,gBAAgB,KAAK,CAAC;CAC5D,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAC9C,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,SAAS,kBAAkB;EAChC,aAAa,SAAS,CAAC,IAAI;EAC3B,WAAW,IAAI;CAChB,GAAG,CAAC,CAAC;CAEL,IAAI,cACH,OAAO,oBAAA,YAAA,EAAG,SAAW,CAAA;CAGtB,OACC,qBAAC,OAAD;EAAK,WAAU;YAAf;GACE,UACA,oBAAC,OAAD;IAAK,WAAW,WAAW,KAAA,IAAY;IACrC;GACG,CAAA,IACF;GACH,WAAW,OACX,qBAAC,OAAD;IAAK,WAAU;cAAf,CACC,oBAAC,YAAD;KAAmB;KAAkB;KAAiB;KAAgB;IAAW,CAAA,GACjF,oBAAC,OAAD;KAAK,WAAU;eACd,oBAAC,OAAD;MACC,cAAY,EAAE,KAAK,cAAc;MACjC,WAAU;MACV,MAAK;gBAEL,oBAAC,UAAD,EAAU,OAAO,UAAY,CAAA;KACzB,CAAA;IACD,CAAA,CACD;;GAEN,oBAAC,OAAD;IAAK,WAAU;cACd,oBAAC,WAAD;KACC,WAAU;KACV,UAAU;KACA;IACV,CAAA;GACG,CAAA;EACD;;AAEP"}
@@ -0,0 +1,64 @@
1
+ "use client";
2
+ import { EyeToggle } from "./EyeToggle.js";
3
+ import { CheckboxFace, CodeFace, DateFace, JsonFace, PointFace, RadioFace, SelectFace } from "./facsimiles.js";
4
+ import { useCallback, useState } from "react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ //#region src/fields/encrypted/components/StructuralField.tsx
7
+ /**
8
+ * Faces keyed by structural type. Anything absent (a `hasMany` text/email/number
9
+ * field, which Payload renders as a react-select chip surface) falls back to the
10
+ * select face, so the concealed run of dots never leaks the selection count.
11
+ */
12
+ const STRUCTURAL_FACES = {
13
+ checkbox: CheckboxFace,
14
+ code: CodeFace,
15
+ date: DateFace,
16
+ json: JsonFace,
17
+ point: PointFace,
18
+ radio: RadioFace,
19
+ select: SelectFace
20
+ };
21
+ /**
22
+ * Wrapper for every label-row type. The native component mounts on first reveal
23
+ * and then stays mounted; concealing only sets display:none on its slot, so
24
+ * re-revealing a select or datepicker never remounts it (that remount was the
25
+ * toggle flicker). Until the first reveal the native is absent, so the decrypted
26
+ * value only enters the DOM once the admin chooses to reveal it. The concealed
27
+ * face never binds form state, and the eye is pinned to the label line so
28
+ * toggling never shifts layout or moves focus.
29
+ */
30
+ const StructuralField = ({ componentKey, field, maskDots, Native, nativeProps, path }) => {
31
+ const [revealed, setRevealed] = useState(false);
32
+ const [mounted, setMounted] = useState(false);
33
+ const toggle = useCallback(() => {
34
+ setRevealed((prev) => !prev);
35
+ setMounted(true);
36
+ }, []);
37
+ const Face = STRUCTURAL_FACES[componentKey] ?? SelectFace;
38
+ return /* @__PURE__ */ jsxs("div", {
39
+ className: "tenx-protected-field tenx-protected-field--label-row",
40
+ children: [
41
+ mounted ? /* @__PURE__ */ jsx("div", {
42
+ className: revealed ? void 0 : "tenx-protected-field__reveal-slot--hidden",
43
+ children: /* @__PURE__ */ jsx(Native, { ...nativeProps })
44
+ }) : null,
45
+ revealed ? null : /* @__PURE__ */ jsx(Face, {
46
+ field,
47
+ maskDots,
48
+ path
49
+ }),
50
+ /* @__PURE__ */ jsx("div", {
51
+ className: "tenx-protected-field__eye-wrap tenx-protected-field__eye-wrap--label-row",
52
+ children: /* @__PURE__ */ jsx(EyeToggle, {
53
+ className: "tenx-protected-field__eye--floating",
54
+ onToggle: toggle,
55
+ revealed
56
+ })
57
+ })
58
+ ]
59
+ });
60
+ };
61
+ //#endregion
62
+ export { StructuralField };
63
+
64
+ //# sourceMappingURL=StructuralField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StructuralField.js","names":[],"sources":["../../../../src/fields/encrypted/components/StructuralField.tsx"],"sourcesContent":["'use client'\nimport type React from 'react'\nimport { useCallback, useState } from 'react'\nimport { EyeToggle } from './EyeToggle'\nimport {\n\tCheckboxFace,\n\tCodeFace,\n\tDateFace,\n\tJsonFace,\n\tPointFace,\n\tRadioFace,\n\tSelectFace,\n} from './facsimiles'\nimport type { EncryptedFieldConfig } from './placement'\n\ntype NativeComponent = React.ComponentType<Record<string, unknown>>\n\n/**\n * Faces keyed by structural type. Anything absent (a `hasMany` text/email/number\n * field, which Payload renders as a react-select chip surface) falls back to the\n * select face, so the concealed run of dots never leaks the selection count.\n */\nconst STRUCTURAL_FACES: Record<\n\tstring,\n\tReact.FC<{ field: EncryptedFieldConfig; maskDots: number; path: string }>\n> = {\n\tcheckbox: CheckboxFace,\n\tcode: CodeFace,\n\tdate: DateFace,\n\tjson: JsonFace,\n\tpoint: PointFace,\n\tradio: RadioFace,\n\tselect: SelectFace,\n}\n\n/**\n * Wrapper for every label-row type. The native component mounts on first reveal\n * and then stays mounted; concealing only sets display:none on its slot, so\n * re-revealing a select or datepicker never remounts it (that remount was the\n * toggle flicker). Until the first reveal the native is absent, so the decrypted\n * value only enters the DOM once the admin chooses to reveal it. The concealed\n * face never binds form state, and the eye is pinned to the label line so\n * toggling never shifts layout or moves focus.\n */\nexport const StructuralField: React.FC<{\n\tcomponentKey: string\n\tfield: EncryptedFieldConfig\n\tmaskDots: number\n\tNative: NativeComponent\n\tnativeProps: Record<string, unknown>\n\tpath: string\n}> = ({ componentKey, field, maskDots, Native, nativeProps, path }) => {\n\tconst [revealed, setRevealed] = useState(false)\n\tconst [mounted, setMounted] = useState(false)\n\tconst toggle = useCallback(() => {\n\t\tsetRevealed((prev) => !prev)\n\t\tsetMounted(true)\n\t}, [])\n\tconst Face = STRUCTURAL_FACES[componentKey] ?? SelectFace\n\treturn (\n\t\t<div className=\"tenx-protected-field tenx-protected-field--label-row\">\n\t\t\t{mounted ? (\n\t\t\t\t<div className={revealed ? undefined : 'tenx-protected-field__reveal-slot--hidden'}>\n\t\t\t\t\t<Native {...nativeProps} />\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t\t{revealed ? null : <Face field={field} maskDots={maskDots} path={path} />}\n\t\t\t<div className=\"tenx-protected-field__eye-wrap tenx-protected-field__eye-wrap--label-row\">\n\t\t\t\t<EyeToggle\n\t\t\t\t\tclassName=\"tenx-protected-field__eye--floating\"\n\t\t\t\t\tonToggle={toggle}\n\t\t\t\t\trevealed={revealed}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;;;;;;;;AAsBA,MAAM,mBAGF;CACH,UAAU;CACV,MAAM;CACN,MAAM;CACN,MAAM;CACN,OAAO;CACP,OAAO;CACP,QAAQ;AACT;;;;;;;;;;AAWA,MAAa,mBAOP,EAAE,cAAc,OAAO,UAAU,QAAQ,aAAa,WAAW;CACtE,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAC9C,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,SAAS,kBAAkB;EAChC,aAAa,SAAS,CAAC,IAAI;EAC3B,WAAW,IAAI;CAChB,GAAG,CAAC,CAAC;CACL,MAAM,OAAO,iBAAiB,iBAAiB;CAC/C,OACC,qBAAC,OAAD;EAAK,WAAU;YAAf;GACE,UACA,oBAAC,OAAD;IAAK,WAAW,WAAW,KAAA,IAAY;cACtC,oBAAC,QAAD,EAAQ,GAAI,YAAc,CAAA;GACtB,CAAA,IACF;GACH,WAAW,OAAO,oBAAC,MAAD;IAAa;IAAiB;IAAgB;GAAO,CAAA;GACxE,oBAAC,OAAD;IAAK,WAAU;cACd,oBAAC,WAAD;KACC,WAAU;KACV,UAAU;KACA;IACV,CAAA;GACG,CAAA;EACD;;AAEP"}