@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,524 @@
1
+ /* Composite input mirrors Payload's formInput mixin (packages/ui/src/scss/vars.scss) so the
2
+ trigger reads as one native text input: glyph, label, marker and clear all live inside one
3
+ container and focus rides :focus-within. Sizes are literal px because Payload compiles scss
4
+ base() to px (native inputs stay 40px at every breakpoint) while the runtime --base var is
5
+ rem-based and shrinks below 1024px, which would leave this shorter than the inputs beside it. */
6
+ .tenx-icon-field__control {
7
+ display: flex;
8
+ align-items: center;
9
+ width: 100%;
10
+ height: 40px;
11
+ padding: 0;
12
+ overflow: hidden;
13
+ border: 1px solid var(--theme-elevation-150);
14
+ border-radius: var(--style-radius-s);
15
+ background: var(--theme-input-bg);
16
+ color: var(--theme-elevation-800);
17
+ font-family: var(--font-body);
18
+ font-size: 1rem;
19
+ box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1);
20
+ transition-property: border, box-shadow, background-color;
21
+ transition-duration: 100ms, 100ms, 500ms;
22
+ transition-timing-function: cubic-bezier(0, 0.2, 0.2, 1);
23
+ }
24
+
25
+ .tenx-icon-field__control:hover {
26
+ border-color: var(--theme-elevation-250);
27
+ box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.2);
28
+ }
29
+
30
+ .tenx-icon-field__control:focus-within {
31
+ border-color: var(--theme-elevation-400);
32
+ outline: 0;
33
+ }
34
+
35
+ html[data-theme="light"] .tenx-icon-field.error .tenx-icon-field__control {
36
+ background-color: var(--theme-error-50);
37
+ border-color: var(--theme-error-500);
38
+ }
39
+
40
+ html[data-theme="dark"] .tenx-icon-field.error .tenx-icon-field__control {
41
+ background-color: var(--theme-error-100);
42
+ border-color: var(--theme-error-400);
43
+ }
44
+
45
+ html[data-theme="dark"] .tenx-icon-field.error .tenx-icon-field__control:hover {
46
+ border-color: var(--theme-error-500);
47
+ }
48
+
49
+ /* Degradation: the stored value's library is gone. A subtle warning tint plus a compact
50
+ marker; the full explanation shows in the drawer banner, not in the trigger. */
51
+ .tenx-icon-field__control--warning,
52
+ .tenx-icon-field__control--warning:hover {
53
+ border-color: var(--theme-warning-250);
54
+ }
55
+
56
+ html[data-theme="light"] .tenx-icon-field__control--warning {
57
+ background-color: var(--theme-warning-50);
58
+ }
59
+
60
+ html[data-theme="dark"] .tenx-icon-field__control--warning {
61
+ background-color: var(--theme-warning-100);
62
+ }
63
+
64
+ .tenx-icon-field.read-only .tenx-icon-field__control,
65
+ .tenx-icon-field.read-only .tenx-icon-field__control:hover {
66
+ border-color: var(--theme-elevation-150);
67
+ background: var(--theme-elevation-100);
68
+ color: var(--theme-elevation-400);
69
+ box-shadow: none;
70
+ }
71
+
72
+ /* Square region at the input's start: the 20px glyph is centered in a 1:1 box the height of
73
+ the input, giving equal padding on every side, and doubles as the drawer-open affordance. */
74
+ .tenx-icon-field__glyph {
75
+ display: flex;
76
+ flex: 0 0 auto;
77
+ align-items: center;
78
+ justify-content: center;
79
+ height: 100%;
80
+ aspect-ratio: 1;
81
+ padding: 0;
82
+ border: 0;
83
+ background: transparent;
84
+ color: inherit;
85
+ cursor: pointer;
86
+ }
87
+
88
+ .tenx-icon-field__glyph--empty {
89
+ color: var(--theme-elevation-300);
90
+ }
91
+
92
+ .tenx-icon-field__glyph:disabled {
93
+ cursor: default;
94
+ }
95
+
96
+ .tenx-icon-field__glyph:focus-visible {
97
+ outline: var(--accessibility-outline);
98
+ outline-offset: -2px;
99
+ }
100
+
101
+ /* Non-text mode: the whole area except the clear button opens the drawer. */
102
+ .tenx-icon-field__open {
103
+ display: flex;
104
+ flex: 1 1 auto;
105
+ align-items: center;
106
+ min-width: 0;
107
+ height: 100%;
108
+ padding: 0;
109
+ border: 0;
110
+ background: transparent;
111
+ color: inherit;
112
+ font-family: inherit;
113
+ font-size: inherit;
114
+ text-align: left;
115
+ cursor: pointer;
116
+ }
117
+
118
+ .tenx-icon-field__open:disabled {
119
+ cursor: default;
120
+ }
121
+
122
+ .tenx-icon-field__open:focus-visible {
123
+ outline: var(--accessibility-outline);
124
+ outline-offset: -2px;
125
+ }
126
+
127
+ .tenx-icon-field__value {
128
+ flex: 1 1 auto;
129
+ min-width: 0;
130
+ overflow: hidden;
131
+ padding-right: 8px;
132
+ white-space: nowrap;
133
+ text-overflow: ellipsis;
134
+ }
135
+
136
+ /* Text mode: the label area is a borderless input flexing inside the container. */
137
+ .tenx-icon-field__value--input {
138
+ height: 100%;
139
+ border: 0;
140
+ background: transparent;
141
+ color: inherit;
142
+ font-family: inherit;
143
+ font-size: inherit;
144
+ appearance: none;
145
+ -webkit-appearance: none;
146
+ }
147
+
148
+ .tenx-icon-field__value--input:focus {
149
+ outline: 0;
150
+ }
151
+
152
+ .tenx-icon-field__value--input::placeholder {
153
+ color: var(--theme-elevation-400);
154
+ }
155
+
156
+ .tenx-icon-field__placeholder {
157
+ color: var(--theme-elevation-400);
158
+ }
159
+
160
+ /* Compact degradation marker, right-aligned inside the input. */
161
+ .tenx-icon-field__marker {
162
+ display: flex;
163
+ flex-shrink: 0;
164
+ align-items: center;
165
+ padding: 0 6px;
166
+ color: var(--theme-warning-600);
167
+ }
168
+
169
+ /* Matches the native select's clear indicator: bare icon, no button chrome. */
170
+ .tenx-icon-field__clear {
171
+ display: flex;
172
+ flex-shrink: 0;
173
+ align-items: center;
174
+ padding: 0 8px;
175
+ border: 0;
176
+ background: transparent;
177
+ color: var(--theme-elevation-500);
178
+ cursor: pointer;
179
+ }
180
+
181
+ .tenx-icon-field__clear:hover {
182
+ color: var(--theme-elevation-800);
183
+ }
184
+
185
+ .tenx-icon-field__clear:focus-visible {
186
+ outline: var(--accessibility-outline);
187
+ }
188
+
189
+ .tenx-icon-field__sr-only {
190
+ position: absolute;
191
+ width: 1px;
192
+ height: 1px;
193
+ margin: -1px;
194
+ padding: 0;
195
+ overflow: hidden;
196
+ clip: rect(0 0 0 0);
197
+ white-space: nowrap;
198
+ border: 0;
199
+ }
200
+
201
+ .tenx-icon-placeholder {
202
+ display: inline-block;
203
+ width: 24px;
204
+ height: 24px;
205
+ background: var(--theme-elevation-100);
206
+ border-radius: var(--style-radius-s);
207
+ }
208
+
209
+ .tenx-icon-cell {
210
+ display: inline-flex;
211
+ align-items: center;
212
+ gap: calc(var(--base) * 0.4);
213
+ }
214
+
215
+ .tenx-icon-drawer {
216
+ display: flex;
217
+ flex-direction: column;
218
+ min-height: 0;
219
+ /* Cell geometry in one place. The cell box is a fixed square that must equal CELL_SIZE in
220
+ IconDrawerContent (it drives the column count and the virtualizer row height); the outlined
221
+ button is smaller and centered, so cell-inset is the gap from each cell-box edge to the
222
+ button outline. The search row and banner align to the button outlines, insetting by
223
+ cell-inset on both sides. */
224
+ --tenx-icon-cell-size: 64px;
225
+ --tenx-icon-cell-button-size: 56px;
226
+ --tenx-icon-cell-inset: calc(
227
+ (var(--tenx-icon-cell-size) - var(--tenx-icon-cell-button-size)) /
228
+ 2
229
+ );
230
+ }
231
+
232
+ /* Payload's Drawer Gutter (.drawer__content-children) is overflow:auto and stacks
233
+ its title header above our content, so a full-height body overflows the Gutter
234
+ and adds a second scrollbar on top of the grid's own. Convert the Gutter to a
235
+ flex column so the native header stays fixed and our body flex-fills, leaving
236
+ the listbox grid as the sole scroller. Scoped to our modal class, same technique
237
+ as the color Popup :has() override. */
238
+ .tenx-icon-drawer-modal .drawer__content-children {
239
+ display: flex;
240
+ flex-direction: column;
241
+ overflow: hidden;
242
+ }
243
+
244
+ .tenx-icon-drawer-modal .drawer__content-children > .tenx-icon-drawer {
245
+ flex: 1 1 auto;
246
+ min-height: 0;
247
+ height: auto;
248
+ }
249
+
250
+ .tenx-icon-drawer-modal .drawer__header {
251
+ flex-shrink: 0;
252
+ }
253
+
254
+ /* Full degradation explanation shown when the stored value's library is unavailable. */
255
+ .tenx-icon-drawer__banner {
256
+ flex-shrink: 0;
257
+ margin-bottom: calc(var(--base) * 0.5);
258
+ padding: calc(var(--base) * 0.4) calc(var(--base) * 0.6);
259
+ border: 1px solid var(--theme-warning-250);
260
+ border-radius: var(--style-radius-s);
261
+ color: var(--theme-warning-800);
262
+ font-size: 0.8rem;
263
+ }
264
+
265
+ html[data-theme="light"] .tenx-icon-drawer__banner {
266
+ background: var(--theme-warning-50);
267
+ }
268
+
269
+ html[data-theme="dark"] .tenx-icon-drawer__banner {
270
+ background: var(--theme-warning-100);
271
+ }
272
+
273
+ /* Right column beside the rail. --tenx-icon-grid-width (set inline from columns * CELL_SIZE) is
274
+ the cell-box span of a full row; aligned-width insets that to the button outlines so the
275
+ banner, the search + switcher row, and the visible grid share one left and one right edge. */
276
+ .tenx-icon-drawer__main {
277
+ display: flex;
278
+ flex-direction: column;
279
+ flex-grow: 1;
280
+ min-width: 0;
281
+ min-height: 0;
282
+ --tenx-icon-aligned-width: calc(var(--tenx-icon-grid-width) - 2 * var(--tenx-icon-cell-inset));
283
+ }
284
+
285
+ /* Banner and search row align to the icon button OUTLINES, not the cell boxes: the outer cells
286
+ leave a cell-inset gap before the first button and after the last, so insetting these by that
287
+ gap lands their left and right edges exactly on the first and last button borders. Both are
288
+ children of __main, sharing its left origin and inheriting the width from it. */
289
+ .tenx-icon-drawer__banner,
290
+ .tenx-icon-drawer__header {
291
+ width: var(--tenx-icon-aligned-width);
292
+ max-width: 100%;
293
+ margin-left: var(--tenx-icon-cell-inset);
294
+ }
295
+
296
+ /* Search grows to fill the row; the switcher sits at the fixed-width right end so its right
297
+ edge is the row's right edge. Width and left inset come from the shared rule above. */
298
+ .tenx-icon-drawer__header {
299
+ display: flex;
300
+ flex-direction: row;
301
+ flex-shrink: 0;
302
+ align-items: center;
303
+ gap: calc(var(--base) * 0.5);
304
+ padding-bottom: calc(var(--base) * 0.5);
305
+ background: var(--theme-bg);
306
+ }
307
+
308
+ /* Bordered control mirroring Payload's formInput: SearchIcon inside-left, borderless input
309
+ flexing beside it, focus riding :focus-within. Grows to fill the header row left of the
310
+ switcher (min-width: 0 lets it shrink below its content). Literal 40px per the field height
311
+ rule (Payload compiles base(2) to px; the --base var shrinks below 1024px). */
312
+ .tenx-icon-drawer__search {
313
+ position: relative;
314
+ display: flex;
315
+ flex: 1 1 auto;
316
+ align-items: center;
317
+ min-width: 0;
318
+ height: 40px;
319
+ border: 1px solid var(--theme-elevation-150);
320
+ border-radius: var(--style-radius-s);
321
+ background: var(--theme-input-bg);
322
+ box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1);
323
+ transition-property: border, box-shadow;
324
+ transition-duration: 100ms;
325
+ transition-timing-function: cubic-bezier(0, 0.2, 0.2, 1);
326
+ }
327
+
328
+ .tenx-icon-drawer__search:hover {
329
+ border-color: var(--theme-elevation-250);
330
+ }
331
+
332
+ .tenx-icon-drawer__search:focus-within {
333
+ border-color: var(--theme-elevation-400);
334
+ }
335
+
336
+ /* Square affordance at the start, sized to the control height like Payload's search. */
337
+ .tenx-icon-drawer__search-icon {
338
+ display: flex;
339
+ flex: 0 0 auto;
340
+ align-items: center;
341
+ justify-content: center;
342
+ height: 100%;
343
+ aspect-ratio: 1;
344
+ color: var(--theme-elevation-400);
345
+ pointer-events: none;
346
+ }
347
+
348
+ .tenx-icon-drawer__search-input {
349
+ flex: 1 1 auto;
350
+ min-width: 0;
351
+ height: 100%;
352
+ padding: 0 calc(var(--base) * 0.5) 0 0;
353
+ border: 0;
354
+ background: transparent;
355
+ color: inherit;
356
+ font-family: inherit;
357
+ font-size: 1rem;
358
+ appearance: none;
359
+ -webkit-appearance: none;
360
+ }
361
+
362
+ .tenx-icon-drawer__search-input:focus {
363
+ outline: 0;
364
+ }
365
+
366
+ .tenx-icon-drawer__search-input::placeholder {
367
+ color: var(--theme-elevation-400);
368
+ }
369
+
370
+ .tenx-icon-drawer__switcher {
371
+ flex: 0 0 auto;
372
+ width: 220px;
373
+ max-width: 100%;
374
+ }
375
+
376
+ .tenx-icon-drawer__sr-only {
377
+ position: absolute;
378
+ width: 1px;
379
+ height: 1px;
380
+ margin: -1px;
381
+ padding: 0;
382
+ overflow: hidden;
383
+ clip: rect(0 0 0 0);
384
+ white-space: nowrap;
385
+ border: 0;
386
+ }
387
+
388
+ .tenx-icon-drawer__body {
389
+ display: flex;
390
+ flex-grow: 1;
391
+ gap: var(--base);
392
+ min-height: 0;
393
+ }
394
+
395
+ .tenx-icon-drawer__rail {
396
+ display: flex;
397
+ flex-direction: column;
398
+ flex-shrink: 0;
399
+ gap: 2px;
400
+ width: 200px;
401
+ overflow-y: auto;
402
+ padding-right: calc(var(--base) * 0.25);
403
+ border-right: 1px solid var(--theme-elevation-100);
404
+ }
405
+
406
+ .tenx-icon-drawer__rail-item {
407
+ padding: calc(var(--base) * 0.25) calc(var(--base) * 0.5);
408
+ background: transparent;
409
+ border: none;
410
+ border-radius: var(--style-radius-s);
411
+ color: var(--theme-elevation-600);
412
+ font-family: inherit;
413
+ font-size: 0.875rem;
414
+ text-align: left;
415
+ text-transform: capitalize;
416
+ cursor: pointer;
417
+ }
418
+
419
+ .tenx-icon-drawer__rail-item:hover {
420
+ background: var(--theme-elevation-50);
421
+ }
422
+
423
+ .tenx-icon-drawer__rail-item--active {
424
+ background: var(--theme-elevation-100);
425
+ color: var(--theme-elevation-800);
426
+ }
427
+
428
+ .tenx-icon-drawer__grid {
429
+ flex-grow: 1;
430
+ min-width: 0;
431
+ overflow-y: auto;
432
+ /* Promote the scroller to its own compositor layer so the virtualizer's
433
+ translateY rows repaint on the GPU during fast scrolls. */
434
+ transform: translateZ(0);
435
+ }
436
+
437
+ .tenx-icon-drawer__row {
438
+ display: flex;
439
+ justify-content: flex-start;
440
+ }
441
+
442
+ /* Fixed cell-size square: width and height both the cell size (the column-count divisor and
443
+ virtualizer row height in IconDrawerContent). Height keeps rows from overlapping or gapping;
444
+ fixing the width instead of growing it left-aligns every row, so a partial last row places its
445
+ cells under the same columns as the full rows above it. Containment is deliberately kept off
446
+ the cell: paint containment (and content-visibility) would clip the hover tooltip, which
447
+ overflows the cell upward; the glyph carries content-visibility instead. */
448
+ .tenx-icon-drawer__cell {
449
+ display: flex;
450
+ flex: 0 0 var(--tenx-icon-cell-size);
451
+ align-items: center;
452
+ justify-content: center;
453
+ height: var(--tenx-icon-cell-size);
454
+ }
455
+
456
+ .tenx-icon-drawer__cell-button {
457
+ position: relative;
458
+ display: flex;
459
+ align-items: center;
460
+ justify-content: center;
461
+ width: var(--tenx-icon-cell-button-size);
462
+ height: var(--tenx-icon-cell-button-size);
463
+ padding: 0;
464
+ background: transparent;
465
+ border: 1px solid var(--theme-elevation-150);
466
+ border-radius: var(--style-radius-s);
467
+ color: var(--theme-elevation-800);
468
+ cursor: pointer;
469
+ transition:
470
+ border-color 100ms,
471
+ background-color 100ms;
472
+ }
473
+
474
+ /* Hover fades the outline (per the reference) and lifts the glyph with a faint fill. */
475
+ .tenx-icon-drawer__cell-button:hover {
476
+ border-color: var(--theme-elevation-100);
477
+ background: var(--theme-elevation-50);
478
+ }
479
+
480
+ .tenx-icon-drawer__cell-button:focus-visible {
481
+ outline: var(--accessibility-outline);
482
+ outline-offset: var(--accessibility-outline-offset);
483
+ }
484
+
485
+ /* Selected uses Payload's success accent (the colour of its focus ring) for a clear active cell. */
486
+ .tenx-icon-drawer__cell-button--selected,
487
+ .tenx-icon-drawer__cell-button--selected:hover {
488
+ border-color: var(--theme-success-500);
489
+ box-shadow: 0 0 0 1px var(--theme-success-500);
490
+ }
491
+
492
+ .tenx-icon-drawer__glyph {
493
+ display: flex;
494
+ align-items: center;
495
+ justify-content: center;
496
+ width: 24px;
497
+ height: 24px;
498
+ /* Skip painting glyphs scrolled just out of view (overscan rows); the fixed size
499
+ keeps layout stable while the SVG paint is deferred. Safe here because the glyph
500
+ never overflows, unlike the cell which hosts the tooltip. */
501
+ content-visibility: auto;
502
+ }
503
+
504
+ .tenx-icon-drawer__empty {
505
+ padding: var(--base);
506
+ color: var(--theme-elevation-500);
507
+ }
508
+
509
+ .tenx-icon-drawer__loading {
510
+ display: flex;
511
+ flex-wrap: wrap;
512
+ gap: calc(var(--base) * 0.5);
513
+ padding: var(--base) 0;
514
+ }
515
+
516
+ .tenx-icon-drawer__footer {
517
+ position: sticky;
518
+ bottom: 0;
519
+ padding-top: calc(var(--base) * 0.5);
520
+ background: var(--theme-bg);
521
+ border-top: 1px solid var(--theme-elevation-100);
522
+ color: var(--theme-elevation-600);
523
+ font-size: 0.75rem;
524
+ }
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import { useCallback, useState } from "react";
3
+ //#region src/fields/icon/client/useRecentIcons.ts
4
+ const RECENT_ICONS_STORAGE_KEY = "10x-fields:icon-recent";
5
+ const MAX_RECENT = 24;
6
+ const readMap = () => {
7
+ if (typeof window === "undefined") return {};
8
+ try {
9
+ return JSON.parse(window.localStorage.getItem("10x-fields:icon-recent") ?? "{}");
10
+ } catch {
11
+ return {};
12
+ }
13
+ };
14
+ const useRecentIcons = (library) => {
15
+ const [recent, setRecent] = useState(() => readMap()[library] ?? []);
16
+ return {
17
+ addRecent: useCallback((name) => {
18
+ const map = readMap();
19
+ const next = [name, ...(map[library] ?? []).filter((entry) => entry !== name)].slice(0, MAX_RECENT);
20
+ map[library] = next;
21
+ try {
22
+ window.localStorage.setItem(RECENT_ICONS_STORAGE_KEY, JSON.stringify(map));
23
+ } catch {}
24
+ setRecent(next);
25
+ }, [library]),
26
+ recent
27
+ };
28
+ };
29
+ //#endregion
30
+ export { useRecentIcons };
31
+
32
+ //# sourceMappingURL=useRecentIcons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRecentIcons.js","names":[],"sources":["../../../../src/fields/icon/client/useRecentIcons.ts"],"sourcesContent":["'use client'\n\nimport { useCallback, useState } from 'react'\n\nexport const RECENT_ICONS_STORAGE_KEY = '10x-fields:icon-recent'\nconst MAX_RECENT = 24\n\ntype RecentMap = Record<string, string[]>\n\nconst readMap = (): RecentMap => {\n\tif (typeof window === 'undefined') return {}\n\ttry {\n\t\treturn JSON.parse(window.localStorage.getItem(RECENT_ICONS_STORAGE_KEY) ?? '{}') as RecentMap\n\t} catch {\n\t\treturn {}\n\t}\n}\n\nexport const useRecentIcons = (\n\tlibrary: string\n): { addRecent: (name: string) => void; recent: string[] } => {\n\tconst [recent, setRecent] = useState<string[]>(() => readMap()[library] ?? [])\n\n\tconst addRecent = useCallback(\n\t\t(name: string) => {\n\t\t\tconst map = readMap()\n\t\t\tconst next = [name, ...(map[library] ?? []).filter((entry) => entry !== name)].slice(\n\t\t\t\t0,\n\t\t\t\tMAX_RECENT\n\t\t\t)\n\t\t\tmap[library] = next\n\t\t\ttry {\n\t\t\t\twindow.localStorage.setItem(RECENT_ICONS_STORAGE_KEY, JSON.stringify(map))\n\t\t\t} catch {\n\t\t\t\t// storage full or blocked: recents silently stop persisting\n\t\t\t}\n\t\t\tsetRecent(next)\n\t\t},\n\t\t[library]\n\t)\n\n\treturn { addRecent, recent }\n}\n"],"mappings":";;;AAIA,MAAa,2BAA2B;AACxC,MAAM,aAAa;AAInB,MAAM,gBAA2B;CAChC,IAAI,OAAO,WAAW,aAAa,OAAO,CAAC;CAC3C,IAAI;EACH,OAAO,KAAK,MAAM,OAAO,aAAa,QAAA,wBAAgC,KAAK,IAAI;CAChF,QAAQ;EACP,OAAO,CAAC;CACT;AACD;AAEA,MAAa,kBACZ,YAC6D;CAC7D,MAAM,CAAC,QAAQ,aAAa,eAAyB,QAAQ,EAAE,YAAY,CAAC,CAAC;CAoB7E,OAAO;EAAE,WAlBS,aAChB,SAAiB;GACjB,MAAM,MAAM,QAAQ;GACpB,MAAM,OAAO,CAAC,MAAM,IAAI,IAAI,YAAY,CAAC,GAAG,QAAQ,UAAU,UAAU,IAAI,CAAC,EAAE,MAC9E,GACA,UACD;GACA,IAAI,WAAW;GACf,IAAI;IACH,OAAO,aAAa,QAAQ,0BAA0B,KAAK,UAAU,GAAG,CAAC;GAC1E,QAAQ,CAER;GACA,UAAU,IAAI;EACf,GACA,CAAC,OAAO,CAGQ;EAAG;CAAO;AAC5B"}
@@ -0,0 +1,81 @@
1
+ //#region src/fields/icon/codegen/emit.ts
2
+ /** Regen command named in the generated-file header when a source does not override it. */
3
+ const DEFAULT_REGEN_COMMAND = "pnpm generate:manifests";
4
+ /** Header line telling a reader the file is generated and which command re-emits it. */
5
+ const generatedHeader = (regenCommand = DEFAULT_REGEN_COMMAND) => `/* GENERATED by @10x-media/fields icon codegen. Do not edit; run \`${regenCommand}\`. */\n`;
6
+ const GENERATED_HEADER = generatedHeader();
7
+ /**
8
+ * Node-data renders straight into the DOM via createElement(tag, attrs), so the
9
+ * tag is restricted to the SVG shape elements lucide and tabler actually emit. An
10
+ * unexpected tag means the upstream node shape changed; fail generation loudly
11
+ * rather than commit data the drawer would render as an unknown element.
12
+ */
13
+ const SVG_NODE_TAGS = new Set([
14
+ "circle",
15
+ "ellipse",
16
+ "g",
17
+ "line",
18
+ "path",
19
+ "polygon",
20
+ "polyline",
21
+ "rect"
22
+ ]);
23
+ /** Interpolated bare into `m.<exportName>`, so nothing but an identifier is safe. */
24
+ const EXPORT_NAME = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
25
+ /**
26
+ * The complete set of characters that can escape a single-quoted JS string:
27
+ * the quote, the escape character, and the four line terminators. Specifiers
28
+ * are validated rather than escaped so a bad one fails generation loudly
29
+ * instead of emitting a module that only breaks at import time.
30
+ */
31
+ const UNSAFE_IN_SPECIFIER = /['\\\n\r\u2028\u2029]/;
32
+ const emitManifestModule = (icons, categories, header = GENERATED_HEADER) => {
33
+ return `${header}export const manifest: {\n\ticons: { name: string; tags: string[]; categories: string[] }[]\n\tcategories: string[]\n} = ${JSON.stringify({
34
+ icons,
35
+ categories
36
+ }, null, " ")}\n`;
37
+ };
38
+ const emitImportsModule = (icons, importFor, header = GENERATED_HEADER) => {
39
+ const lines = [
40
+ header,
41
+ `import type { ComponentType } from 'react'`,
42
+ "",
43
+ `export type GeneratedIconModule = { default: ComponentType<{ className?: string; size?: number | string }> }`,
44
+ "",
45
+ "const map = {"
46
+ ];
47
+ for (const icon of icons) {
48
+ const spec = importFor(icon);
49
+ if (UNSAFE_IN_SPECIFIER.test(spec.module)) throw new Error(`icon "${icon.name}": unsafe module specifier: ${spec.module}`);
50
+ if (spec.exportName !== void 0 && !EXPORT_NAME.test(spec.exportName)) throw new Error(`icon "${icon.name}": export name is not an identifier: ${spec.exportName}`);
51
+ if (spec.exportName) lines.push(`\t'${icon.name}': () => import('${spec.module}').then((m) => ({ default: m.${spec.exportName} })),`);
52
+ else lines.push(`\t'${icon.name}': () => import('${spec.module}'),`);
53
+ }
54
+ lines.push("}");
55
+ lines.push("");
56
+ lines.push("export const iconImports = map as unknown as Record<string, () => Promise<GeneratedIconModule>>");
57
+ lines.push("");
58
+ return lines.join("\n");
59
+ };
60
+ /**
61
+ * Emits a library's bulk glyph node-data, keyed by icon name in the same sorted
62
+ * order as the manifest so a regeneration is byte-stable. The drawer lazily
63
+ * imports this once per library and renders each glyph as inline SVG, which
64
+ * replaces the per-icon dynamic imports that made large libraries scroll poorly.
65
+ * Compact JSON keeps the committed file (thousands of glyphs) as small as the
66
+ * source; the module is admin-only and never enters a frontend bundle.
67
+ */
68
+ const emitNodesModule = (icons, nodes, header = GENERATED_HEADER) => {
69
+ const ordered = {};
70
+ for (const icon of icons) {
71
+ const glyph = nodes[icon.name];
72
+ if (!glyph) throw new Error(`icon "${icon.name}": no node-data for this manifest entry`);
73
+ for (const [tag] of glyph) if (!SVG_NODE_TAGS.has(tag)) throw new Error(`icon "${icon.name}": unexpected SVG node tag "${tag}"`);
74
+ ordered[icon.name] = glyph;
75
+ }
76
+ return `${header}export const nodes: Record<string, [string, Record<string, string>][]> = ${JSON.stringify(ordered)}\n`;
77
+ };
78
+ //#endregion
79
+ export { emitImportsModule, emitManifestModule, emitNodesModule, generatedHeader };
80
+
81
+ //# sourceMappingURL=emit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit.js","names":[],"sources":["../../../../src/fields/icon/codegen/emit.ts"],"sourcesContent":["import type { IconMeta, IconNodeMap } from '../../../types'\nimport type { IconImportSpec } from './types'\n\n/** Regen command named in the generated-file header when a source does not override it. */\nconst DEFAULT_REGEN_COMMAND = 'pnpm generate:manifests'\n\n/** Header line telling a reader the file is generated and which command re-emits it. */\nexport const generatedHeader = (regenCommand: string = DEFAULT_REGEN_COMMAND): string =>\n\t`/* GENERATED by @10x-media/fields icon codegen. Do not edit; run \\`${regenCommand}\\`. */\\n`\n\nexport const GENERATED_HEADER = generatedHeader()\n\n/**\n * Node-data renders straight into the DOM via createElement(tag, attrs), so the\n * tag is restricted to the SVG shape elements lucide and tabler actually emit. An\n * unexpected tag means the upstream node shape changed; fail generation loudly\n * rather than commit data the drawer would render as an unknown element.\n */\nconst SVG_NODE_TAGS = new Set([\n\t'circle',\n\t'ellipse',\n\t'g',\n\t'line',\n\t'path',\n\t'polygon',\n\t'polyline',\n\t'rect',\n])\n\n/** Interpolated bare into `m.<exportName>`, so nothing but an identifier is safe. */\nconst EXPORT_NAME = /^[A-Za-z_$][A-Za-z0-9_$]*$/\n\n/**\n * The complete set of characters that can escape a single-quoted JS string:\n * the quote, the escape character, and the four line terminators. Specifiers\n * are validated rather than escaped so a bad one fails generation loudly\n * instead of emitting a module that only breaks at import time.\n */\nconst UNSAFE_IN_SPECIFIER = /['\\\\\\n\\r\\u2028\\u2029]/\n\nexport const emitManifestModule = (\n\ticons: IconMeta[],\n\tcategories: string[],\n\theader: string = GENERATED_HEADER\n): string => {\n\tconst data = JSON.stringify({ icons, categories }, null, '\\t')\n\treturn `${header}export const manifest: {\\n\\ticons: { name: string; tags: string[]; categories: string[] }[]\\n\\tcategories: string[]\\n} = ${data}\\n`\n}\n\nexport const emitImportsModule = (\n\ticons: IconMeta[],\n\timportFor: (icon: IconMeta) => IconImportSpec,\n\theader: string = GENERATED_HEADER\n): string => {\n\tconst lines: string[] = [\n\t\theader,\n\t\t`import type { ComponentType } from 'react'`,\n\t\t'',\n\t\t`export type GeneratedIconModule = { default: ComponentType<{ className?: string; size?: number | string }> }`,\n\t\t'',\n\t\t'const map = {',\n\t]\n\tfor (const icon of icons) {\n\t\tconst spec = importFor(icon)\n\t\tif (UNSAFE_IN_SPECIFIER.test(spec.module)) {\n\t\t\tthrow new Error(`icon \"${icon.name}\": unsafe module specifier: ${spec.module}`)\n\t\t}\n\t\tif (spec.exportName !== undefined && !EXPORT_NAME.test(spec.exportName)) {\n\t\t\tthrow new Error(`icon \"${icon.name}\": export name is not an identifier: ${spec.exportName}`)\n\t\t}\n\t\tif (spec.exportName) {\n\t\t\tlines.push(\n\t\t\t\t`\\t'${icon.name}': () => import('${spec.module}').then((m) => ({ default: m.${spec.exportName} })),`\n\t\t\t)\n\t\t} else {\n\t\t\tlines.push(`\\t'${icon.name}': () => import('${spec.module}'),`)\n\t\t}\n\t}\n\tlines.push('}')\n\tlines.push('')\n\tlines.push(\n\t\t'export const iconImports = map as unknown as Record<string, () => Promise<GeneratedIconModule>>'\n\t)\n\tlines.push('')\n\treturn lines.join('\\n')\n}\n\n/**\n * Emits a library's bulk glyph node-data, keyed by icon name in the same sorted\n * order as the manifest so a regeneration is byte-stable. The drawer lazily\n * imports this once per library and renders each glyph as inline SVG, which\n * replaces the per-icon dynamic imports that made large libraries scroll poorly.\n * Compact JSON keeps the committed file (thousands of glyphs) as small as the\n * source; the module is admin-only and never enters a frontend bundle.\n */\nexport const emitNodesModule = (\n\ticons: IconMeta[],\n\tnodes: IconNodeMap,\n\theader: string = GENERATED_HEADER\n): string => {\n\tconst ordered: IconNodeMap = {}\n\tfor (const icon of icons) {\n\t\tconst glyph = nodes[icon.name]\n\t\tif (!glyph) throw new Error(`icon \"${icon.name}\": no node-data for this manifest entry`)\n\t\tfor (const [tag] of glyph) {\n\t\t\tif (!SVG_NODE_TAGS.has(tag)) {\n\t\t\t\tthrow new Error(`icon \"${icon.name}\": unexpected SVG node tag \"${tag}\"`)\n\t\t\t}\n\t\t}\n\t\tordered[icon.name] = glyph\n\t}\n\tconst data = JSON.stringify(ordered)\n\treturn `${header}export const nodes: Record<string, [string, Record<string, string>][]> = ${data}\\n`\n}\n"],"mappings":";;AAIA,MAAM,wBAAwB;;AAG9B,MAAa,mBAAmB,eAAuB,0BACtD,sEAAsE,aAAa;AAEpF,MAAa,mBAAmB,gBAAgB;;;;;;;AAQhD,MAAM,gBAAgB,IAAI,IAAI;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;AAGD,MAAM,cAAc;;;;;;;AAQpB,MAAM,sBAAsB;AAE5B,MAAa,sBACZ,OACA,YACA,SAAiB,qBACL;CAEZ,OAAO,GAAG,OAAO,2HADJ,KAAK,UAAU;EAAE;EAAO;CAAW,GAAG,MAAM,GACsF,EAAE;AAClJ;AAEA,MAAa,qBACZ,OACA,WACA,SAAiB,qBACL;CACZ,MAAM,QAAkB;EACvB;EACA;EACA;EACA;EACA;EACA;CACD;CACA,KAAK,MAAM,QAAQ,OAAO;EACzB,MAAM,OAAO,UAAU,IAAI;EAC3B,IAAI,oBAAoB,KAAK,KAAK,MAAM,GACvC,MAAM,IAAI,MAAM,SAAS,KAAK,KAAK,8BAA8B,KAAK,QAAQ;EAE/E,IAAI,KAAK,eAAe,KAAA,KAAa,CAAC,YAAY,KAAK,KAAK,UAAU,GACrE,MAAM,IAAI,MAAM,SAAS,KAAK,KAAK,uCAAuC,KAAK,YAAY;EAE5F,IAAI,KAAK,YACR,MAAM,KACL,MAAM,KAAK,KAAK,mBAAmB,KAAK,OAAO,+BAA+B,KAAK,WAAW,MAC/F;OAEA,MAAM,KAAK,MAAM,KAAK,KAAK,mBAAmB,KAAK,OAAO,IAAI;CAEhE;CACA,MAAM,KAAK,GAAG;CACd,MAAM,KAAK,EAAE;CACb,MAAM,KACL,iGACD;CACA,MAAM,KAAK,EAAE;CACb,OAAO,MAAM,KAAK,IAAI;AACvB;;;;;;;;;AAUA,MAAa,mBACZ,OACA,OACA,SAAiB,qBACL;CACZ,MAAM,UAAuB,CAAC;CAC9B,KAAK,MAAM,QAAQ,OAAO;EACzB,MAAM,QAAQ,MAAM,KAAK;EACzB,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,SAAS,KAAK,KAAK,wCAAwC;EACvF,KAAK,MAAM,CAAC,QAAQ,OACnB,IAAI,CAAC,cAAc,IAAI,GAAG,GACzB,MAAM,IAAI,MAAM,SAAS,KAAK,KAAK,8BAA8B,IAAI,EAAE;EAGzE,QAAQ,KAAK,QAAQ;CACtB;CAEA,OAAO,GAAG,OAAO,2EADJ,KAAK,UAAU,OACmE,EAAE;AAClG"}
@@ -0,0 +1,10 @@
1
+ import { GenerateIconManifestOptions } from "./types.js";
2
+
3
+ //#region src/fields/icon/codegen/generate.d.ts
4
+ declare const generateIconManifest: (options: GenerateIconManifestOptions) => Promise<{
5
+ iconCount: number;
6
+ files: string[];
7
+ }>;
8
+ //#endregion
9
+ export { generateIconManifest };
10
+ //# sourceMappingURL=generate.d.ts.map