@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,59 @@
1
+ import { emitImportsModule, emitManifestModule, emitNodesModule, generatedHeader } from "./emit.js";
2
+ import { loadLucideSource } from "./sources/lucide.js";
3
+ import { loadRadixSource } from "./sources/radix.js";
4
+ import { loadTablerSource } from "./sources/tabler.js";
5
+ import { mkdir, writeFile } from "node:fs/promises";
6
+ import path from "node:path";
7
+ //#region src/fields/icon/codegen/generate.ts
8
+ /** The stored value format (`library:icon-name`) and every picker lookup assume kebab-case. */
9
+ const ICON_NAME = /^[a-z0-9]+(-[a-z0-9]+)*$/;
10
+ /** Codepoint order, so committed output does not depend on the generating machine's locale. */
11
+ const byCodepoint = (a, b) => a < b ? -1 : a > b ? 1 : 0;
12
+ const loadSource = async (options) => {
13
+ const { source } = options;
14
+ if (source === "lucide") return loadLucideSource({ allowMissingCategories: options.allowMissingCategories });
15
+ if (source === "radix") return loadRadixSource();
16
+ if (source === "tabler") return loadTablerSource();
17
+ return source;
18
+ };
19
+ const generateIconManifest = async (options) => {
20
+ const { icons: rawIcons, importFor, nodes } = await loadSource(options);
21
+ const icons = rawIcons.map((icon) => ({
22
+ ...icon,
23
+ categories: [...icon.categories].sort(byCodepoint)
24
+ })).sort((a, b) => byCodepoint(a.name, b.name));
25
+ const seen = /* @__PURE__ */ new Set();
26
+ for (const icon of icons) {
27
+ if (!ICON_NAME.test(icon.name)) throw new Error(`invalid icon name: "${icon.name}" (expected kebab-case, e.g. "arrow-up")`);
28
+ if (seen.has(icon.name)) throw new Error(`duplicate icon name: ${icon.name}`);
29
+ seen.add(icon.name);
30
+ }
31
+ const categories = [...new Set(icons.flatMap((icon) => icon.categories))].sort(byCodepoint);
32
+ const header = generatedHeader(options.regenCommand);
33
+ const manifestSource = emitManifestModule(icons, categories, header);
34
+ const importsSource = importFor ? emitImportsModule(icons, importFor, header) : void 0;
35
+ const nodesSource = nodes ? emitNodesModule(icons, nodes, header) : void 0;
36
+ await mkdir(options.outDir, { recursive: true });
37
+ const files = [];
38
+ const manifestPath = path.join(options.outDir, "manifest.ts");
39
+ await writeFile(manifestPath, manifestSource);
40
+ files.push(manifestPath);
41
+ if (importsSource !== void 0) {
42
+ const importsPath = path.join(options.outDir, "imports.ts");
43
+ await writeFile(importsPath, importsSource);
44
+ files.push(importsPath);
45
+ }
46
+ if (nodesSource !== void 0) {
47
+ const nodesPath = path.join(options.outDir, "nodes.ts");
48
+ await writeFile(nodesPath, nodesSource);
49
+ files.push(nodesPath);
50
+ }
51
+ return {
52
+ files,
53
+ iconCount: icons.length
54
+ };
55
+ };
56
+ //#endregion
57
+ export { generateIconManifest };
58
+
59
+ //# sourceMappingURL=generate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.js","names":[],"sources":["../../../../src/fields/icon/codegen/generate.ts"],"sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises'\nimport path from 'node:path'\nimport { emitImportsModule, emitManifestModule, emitNodesModule, generatedHeader } from './emit'\nimport { loadLucideSource } from './sources/lucide'\nimport { loadRadixSource } from './sources/radix'\nimport { loadTablerSource } from './sources/tabler'\nimport type { GenerateIconManifestOptions, LoadedIconSource } from './types'\n\n/** The stored value format (`library:icon-name`) and every picker lookup assume kebab-case. */\nconst ICON_NAME = /^[a-z0-9]+(-[a-z0-9]+)*$/\n\n/** Codepoint order, so committed output does not depend on the generating machine's locale. */\nconst byCodepoint = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0)\n\nconst loadSource = async (options: GenerateIconManifestOptions): Promise<LoadedIconSource> => {\n\tconst { source } = options\n\tif (source === 'lucide') {\n\t\treturn loadLucideSource({ allowMissingCategories: options.allowMissingCategories })\n\t}\n\tif (source === 'radix') return loadRadixSource()\n\tif (source === 'tabler') return loadTablerSource()\n\treturn source\n}\n\nexport const generateIconManifest = async (\n\toptions: GenerateIconManifestOptions\n): Promise<{ iconCount: number; files: string[] }> => {\n\tconst { icons: rawIcons, importFor, nodes } = await loadSource(options)\n\tconst icons = rawIcons\n\t\t.map((icon) => ({ ...icon, categories: [...icon.categories].sort(byCodepoint) }))\n\t\t.sort((a, b) => byCodepoint(a.name, b.name))\n\tconst seen = new Set<string>()\n\tfor (const icon of icons) {\n\t\tif (!ICON_NAME.test(icon.name)) {\n\t\t\tthrow new Error(`invalid icon name: \"${icon.name}\" (expected kebab-case, e.g. \"arrow-up\")`)\n\t\t}\n\t\tif (seen.has(icon.name)) throw new Error(`duplicate icon name: ${icon.name}`)\n\t\tseen.add(icon.name)\n\t}\n\tconst categories = [...new Set(icons.flatMap((icon) => icon.categories))].sort(byCodepoint)\n\t// Emit every module before writing any, so a specifier or node the emitter\n\t// rejects cannot leave the directory holding a new manifest beside a stale\n\t// imports map or node-data.\n\tconst header = generatedHeader(options.regenCommand)\n\tconst manifestSource = emitManifestModule(icons, categories, header)\n\tconst importsSource = importFor ? emitImportsModule(icons, importFor, header) : undefined\n\tconst nodesSource = nodes ? emitNodesModule(icons, nodes, header) : undefined\n\tawait mkdir(options.outDir, { recursive: true })\n\tconst files: string[] = []\n\tconst manifestPath = path.join(options.outDir, 'manifest.ts')\n\tawait writeFile(manifestPath, manifestSource)\n\tfiles.push(manifestPath)\n\tif (importsSource !== undefined) {\n\t\tconst importsPath = path.join(options.outDir, 'imports.ts')\n\t\tawait writeFile(importsPath, importsSource)\n\t\tfiles.push(importsPath)\n\t}\n\tif (nodesSource !== undefined) {\n\t\tconst nodesPath = path.join(options.outDir, 'nodes.ts')\n\t\tawait writeFile(nodesPath, nodesSource)\n\t\tfiles.push(nodesPath)\n\t}\n\treturn { files, iconCount: icons.length }\n}\n"],"mappings":";;;;;;;;AASA,MAAM,YAAY;;AAGlB,MAAM,eAAe,GAAW,MAAuB,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI;AAEhF,MAAM,aAAa,OAAO,YAAoE;CAC7F,MAAM,EAAE,WAAW;CACnB,IAAI,WAAW,UACd,OAAO,iBAAiB,EAAE,wBAAwB,QAAQ,uBAAuB,CAAC;CAEnF,IAAI,WAAW,SAAS,OAAO,gBAAgB;CAC/C,IAAI,WAAW,UAAU,OAAO,iBAAiB;CACjD,OAAO;AACR;AAEA,MAAa,uBAAuB,OACnC,YACqD;CACrD,MAAM,EAAE,OAAO,UAAU,WAAW,UAAU,MAAM,WAAW,OAAO;CACtE,MAAM,QAAQ,SACZ,KAAK,UAAU;EAAE,GAAG;EAAM,YAAY,CAAC,GAAG,KAAK,UAAU,EAAE,KAAK,WAAW;CAAE,EAAE,EAC/E,MAAM,GAAG,MAAM,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC;CAC5C,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,QAAQ,OAAO;EACzB,IAAI,CAAC,UAAU,KAAK,KAAK,IAAI,GAC5B,MAAM,IAAI,MAAM,uBAAuB,KAAK,KAAK,yCAAyC;EAE3F,IAAI,KAAK,IAAI,KAAK,IAAI,GAAG,MAAM,IAAI,MAAM,wBAAwB,KAAK,MAAM;EAC5E,KAAK,IAAI,KAAK,IAAI;CACnB;CACA,MAAM,aAAa,CAAC,GAAG,IAAI,IAAI,MAAM,SAAS,SAAS,KAAK,UAAU,CAAC,CAAC,EAAE,KAAK,WAAW;CAI1F,MAAM,SAAS,gBAAgB,QAAQ,YAAY;CACnD,MAAM,iBAAiB,mBAAmB,OAAO,YAAY,MAAM;CACnE,MAAM,gBAAgB,YAAY,kBAAkB,OAAO,WAAW,MAAM,IAAI,KAAA;CAChF,MAAM,cAAc,QAAQ,gBAAgB,OAAO,OAAO,MAAM,IAAI,KAAA;CACpE,MAAM,MAAM,QAAQ,QAAQ,EAAE,WAAW,KAAK,CAAC;CAC/C,MAAM,QAAkB,CAAC;CACzB,MAAM,eAAe,KAAK,KAAK,QAAQ,QAAQ,aAAa;CAC5D,MAAM,UAAU,cAAc,cAAc;CAC5C,MAAM,KAAK,YAAY;CACvB,IAAI,kBAAkB,KAAA,GAAW;EAChC,MAAM,cAAc,KAAK,KAAK,QAAQ,QAAQ,YAAY;EAC1D,MAAM,UAAU,aAAa,aAAa;EAC1C,MAAM,KAAK,WAAW;CACvB;CACA,IAAI,gBAAgB,KAAA,GAAW;EAC9B,MAAM,YAAY,KAAK,KAAK,QAAQ,QAAQ,UAAU;EACtD,MAAM,UAAU,WAAW,WAAW;EACtC,MAAM,KAAK,SAAS;CACrB;CACA,OAAO;EAAE;EAAO,WAAW,MAAM;CAAO;AACzC"}
@@ -0,0 +1,52 @@
1
+ import { createRequire } from "node:module";
2
+ //#region src/fields/icon/codegen/sources/lucide.ts
3
+ const require = createRequire(import.meta.url);
4
+ const CATEGORIES_URL = "https://lucide.dev/api/categories";
5
+ const FETCH_TIMEOUT_MS = 1e4;
6
+ /**
7
+ * Lucide publishes names and tags to npm (lucide-static/tags.json) but not
8
+ * categories; those exist only in the repo and on lucide.dev. Throws rather
9
+ * than returning a partial result, so the caller decides what a miss means.
10
+ */
11
+ const fetchCategories = async () => {
12
+ const response = await fetch(CATEGORIES_URL, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
13
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
14
+ const payload = await response.json();
15
+ if (typeof payload !== "object" || payload === null || Array.isArray(payload)) throw new Error("expected a JSON object keyed by icon name");
16
+ return payload;
17
+ };
18
+ /**
19
+ * Lucide ships icons named `map` and `slice`, so an unexpected array payload
20
+ * would resolve those keys to Array.prototype methods. Only real arrays of
21
+ * strings count as categories.
22
+ */
23
+ const categoriesFor = (payload, name) => {
24
+ const value = payload[name];
25
+ if (!Array.isArray(value)) return [];
26
+ return value.filter((entry) => typeof entry === "string");
27
+ };
28
+ const loadLucideSource = async (options = {}) => {
29
+ const tags = require("lucide-static/tags.json");
30
+ const allowMissing = options.allowMissingCategories === true;
31
+ let payload = {};
32
+ try {
33
+ payload = await fetchCategories();
34
+ } catch (error) {
35
+ if (!allowMissing) throw new Error(`lucide categories unavailable from ${CATEGORIES_URL} (${String(error)}). Pass allowMissingCategories to generate without them.`);
36
+ console.warn(`[fields codegen] lucide categories unavailable (${String(error)}); emitting empty categories`);
37
+ }
38
+ const icons = Object.keys(tags).sort().map((name) => ({
39
+ name,
40
+ tags: tags[name] ?? [],
41
+ categories: categoriesFor(payload, name)
42
+ }));
43
+ if (!allowMissing && icons.every((icon) => icon.categories.length === 0)) throw new Error(`lucide categories from ${CATEGORIES_URL} matched no installed icon, so the response shape has likely changed. Pass allowMissingCategories to generate without them.`);
44
+ return {
45
+ icons,
46
+ nodes: require("lucide-static/icon-nodes.json")
47
+ };
48
+ };
49
+ //#endregion
50
+ export { loadLucideSource };
51
+
52
+ //# sourceMappingURL=lucide.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lucide.js","names":[],"sources":["../../../../../src/fields/icon/codegen/sources/lucide.ts"],"sourcesContent":["import { createRequire } from 'node:module'\nimport type { IconMeta, IconNodeMap } from '../../../../types'\nimport type { LoadedIconSource } from '../types'\n\nconst require = createRequire(import.meta.url)\n\nconst CATEGORIES_URL = 'https://lucide.dev/api/categories'\nconst FETCH_TIMEOUT_MS = 10_000\n\nexport type LucideSourceOptions = {\n\t/** Emit icons with no categories when lucide.dev is unreachable (offline generation). */\n\tallowMissingCategories?: boolean\n}\n\n/**\n * Lucide publishes names and tags to npm (lucide-static/tags.json) but not\n * categories; those exist only in the repo and on lucide.dev. Throws rather\n * than returning a partial result, so the caller decides what a miss means.\n */\nconst fetchCategories = async (): Promise<Record<string, unknown>> => {\n\tconst response = await fetch(CATEGORIES_URL, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) })\n\tif (!response.ok) throw new Error(`HTTP ${response.status}`)\n\tconst payload: unknown = await response.json()\n\tif (typeof payload !== 'object' || payload === null || Array.isArray(payload)) {\n\t\tthrow new Error('expected a JSON object keyed by icon name')\n\t}\n\treturn payload as Record<string, unknown>\n}\n\n/**\n * Lucide ships icons named `map` and `slice`, so an unexpected array payload\n * would resolve those keys to Array.prototype methods. Only real arrays of\n * strings count as categories.\n */\nconst categoriesFor = (payload: Record<string, unknown>, name: string): string[] => {\n\tconst value = payload[name]\n\tif (!Array.isArray(value)) return []\n\treturn value.filter((entry): entry is string => typeof entry === 'string')\n}\n\nexport const loadLucideSource = async (\n\toptions: LucideSourceOptions = {}\n): Promise<LoadedIconSource> => {\n\tconst tags = require('lucide-static/tags.json') as Record<string, string[]>\n\tconst allowMissing = options.allowMissingCategories === true\n\tlet payload: Record<string, unknown> = {}\n\ttry {\n\t\tpayload = await fetchCategories()\n\t} catch (error) {\n\t\tif (!allowMissing) {\n\t\t\tthrow new Error(\n\t\t\t\t`lucide categories unavailable from ${CATEGORIES_URL} (${String(error)}). Pass allowMissingCategories to generate without them.`\n\t\t\t)\n\t\t}\n\t\tconsole.warn(\n\t\t\t`[fields codegen] lucide categories unavailable (${String(error)}); emitting empty categories`\n\t\t)\n\t}\n\tconst icons: IconMeta[] = Object.keys(tags)\n\t\t.sort()\n\t\t.map((name) => ({ name, tags: tags[name] ?? [], categories: categoriesFor(payload, name) }))\n\t// A fetch that succeeds but matches nothing means the response shape moved.\n\t// Without this the manifest would be rewritten with every category dropped.\n\tif (!allowMissing && icons.every((icon) => icon.categories.length === 0)) {\n\t\tthrow new Error(\n\t\t\t`lucide categories from ${CATEGORIES_URL} matched no installed icon, so the response shape has likely changed. Pass allowMissingCategories to generate without them.`\n\t\t)\n\t}\n\t// lucide-static/icon-nodes.json is the exact shape lucide-react consumes\n\t// (name -> [tag, attrs][]) and is keyed by the same bare kebab names as tags.json.\n\tconst nodes = require('lucide-static/icon-nodes.json') as IconNodeMap\n\treturn { icons, nodes }\n}\n"],"mappings":";;AAIA,MAAM,UAAU,cAAc,OAAO,KAAK,GAAG;AAE7C,MAAM,iBAAiB;AACvB,MAAM,mBAAmB;;;;;;AAYzB,MAAM,kBAAkB,YAA8C;CACrE,MAAM,WAAW,MAAM,MAAM,gBAAgB,EAAE,QAAQ,YAAY,QAAQ,gBAAgB,EAAE,CAAC;CAC9F,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,MAAM,QAAQ,SAAS,QAAQ;CAC3D,MAAM,UAAmB,MAAM,SAAS,KAAK;CAC7C,IAAI,OAAO,YAAY,YAAY,YAAY,QAAQ,MAAM,QAAQ,OAAO,GAC3E,MAAM,IAAI,MAAM,2CAA2C;CAE5D,OAAO;AACR;;;;;;AAOA,MAAM,iBAAiB,SAAkC,SAA2B;CACnF,MAAM,QAAQ,QAAQ;CACtB,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC;CACnC,OAAO,MAAM,QAAQ,UAA2B,OAAO,UAAU,QAAQ;AAC1E;AAEA,MAAa,mBAAmB,OAC/B,UAA+B,CAAC,MACD;CAC/B,MAAM,OAAO,QAAQ,yBAAyB;CAC9C,MAAM,eAAe,QAAQ,2BAA2B;CACxD,IAAI,UAAmC,CAAC;CACxC,IAAI;EACH,UAAU,MAAM,gBAAgB;CACjC,SAAS,OAAO;EACf,IAAI,CAAC,cACJ,MAAM,IAAI,MACT,sCAAsC,eAAe,IAAI,OAAO,KAAK,EAAE,yDACxE;EAED,QAAQ,KACP,mDAAmD,OAAO,KAAK,EAAE,6BAClE;CACD;CACA,MAAM,QAAoB,OAAO,KAAK,IAAI,EACxC,KAAK,EACL,KAAK,UAAU;EAAE;EAAM,MAAM,KAAK,SAAS,CAAC;EAAG,YAAY,cAAc,SAAS,IAAI;CAAE,EAAE;CAG5F,IAAI,CAAC,gBAAgB,MAAM,OAAO,SAAS,KAAK,WAAW,WAAW,CAAC,GACtE,MAAM,IAAI,MACT,0BAA0B,eAAe,4HAC1C;CAKD,OAAO;EAAE;EAAO,OADF,QAAQ,+BACF;CAAE;AACvB"}
@@ -0,0 +1,33 @@
1
+ import { createRequire } from "node:module";
2
+ //#region src/fields/icon/codegen/sources/radix.ts
3
+ const require = createRequire(import.meta.url);
4
+ const kebab = (pascal) => pascal.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z])([A-Z][a-z])/g, "$1-$2").toLowerCase();
5
+ /** Radix ships no metadata; names come from the module's export list, tags from name tokens. */
6
+ const loadRadixSource = () => {
7
+ const mod = require("@radix-ui/react-icons");
8
+ const exportNames = Object.keys(mod).filter((name) => name.endsWith("Icon")).sort();
9
+ const exportByName = /* @__PURE__ */ new Map();
10
+ return {
11
+ icons: exportNames.map((exportName) => {
12
+ const name = kebab(exportName.slice(0, -4));
13
+ exportByName.set(name, exportName);
14
+ return {
15
+ name,
16
+ tags: name.split("-"),
17
+ categories: []
18
+ };
19
+ }),
20
+ importFor: (icon) => {
21
+ const exportName = exportByName.get(icon.name);
22
+ if (!exportName) throw new Error(`radix: no export for icon "${icon.name}"`);
23
+ return {
24
+ module: "@radix-ui/react-icons",
25
+ exportName
26
+ };
27
+ }
28
+ };
29
+ };
30
+ //#endregion
31
+ export { loadRadixSource };
32
+
33
+ //# sourceMappingURL=radix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"radix.js","names":[],"sources":["../../../../../src/fields/icon/codegen/sources/radix.ts"],"sourcesContent":["import { createRequire } from 'node:module'\nimport type { IconMeta } from '../../../../types'\nimport type { LoadedIconSource } from '../types'\n\nconst require = createRequire(import.meta.url)\n\nconst kebab = (pascal: string): string =>\n\tpascal\n\t\t.replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n\t\t.replace(/([A-Z])([A-Z][a-z])/g, '$1-$2')\n\t\t.toLowerCase()\n\n/** Radix ships no metadata; names come from the module's export list, tags from name tokens. */\nexport const loadRadixSource = (): LoadedIconSource => {\n\tconst mod = require('@radix-ui/react-icons') as Record<string, unknown>\n\tconst exportNames = Object.keys(mod)\n\t\t.filter((name) => name.endsWith('Icon'))\n\t\t.sort()\n\tconst exportByName = new Map<string, string>()\n\tconst icons: IconMeta[] = exportNames.map((exportName) => {\n\t\tconst name = kebab(exportName.slice(0, -'Icon'.length))\n\t\texportByName.set(name, exportName)\n\t\treturn { name, tags: name.split('-'), categories: [] }\n\t})\n\treturn {\n\t\ticons,\n\t\timportFor: (icon) => {\n\t\t\tconst exportName = exportByName.get(icon.name)\n\t\t\tif (!exportName) throw new Error(`radix: no export for icon \"${icon.name}\"`)\n\t\t\treturn { module: '@radix-ui/react-icons', exportName }\n\t\t},\n\t}\n}\n"],"mappings":";;AAIA,MAAM,UAAU,cAAc,OAAO,KAAK,GAAG;AAE7C,MAAM,SAAS,WACd,OACE,QAAQ,sBAAsB,OAAO,EACrC,QAAQ,wBAAwB,OAAO,EACvC,YAAY;;AAGf,MAAa,wBAA0C;CACtD,MAAM,MAAM,QAAQ,uBAAuB;CAC3C,MAAM,cAAc,OAAO,KAAK,GAAG,EACjC,QAAQ,SAAS,KAAK,SAAS,MAAM,CAAC,EACtC,KAAK;CACP,MAAM,+BAAe,IAAI,IAAoB;CAM7C,OAAO;EACN,OANyB,YAAY,KAAK,eAAe;GACzD,MAAM,OAAO,MAAM,WAAW,MAAM,GAAG,EAAc,CAAC;GACtD,aAAa,IAAI,MAAM,UAAU;GACjC,OAAO;IAAE;IAAM,MAAM,KAAK,MAAM,GAAG;IAAG,YAAY,CAAC;GAAE;EACtD,CAEK;EACJ,YAAY,SAAS;GACpB,MAAM,aAAa,aAAa,IAAI,KAAK,IAAI;GAC7C,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,8BAA8B,KAAK,KAAK,EAAE;GAC3E,OAAO;IAAE,QAAQ;IAAyB;GAAW;EACtD;CACD;AACD"}
@@ -0,0 +1,31 @@
1
+ import { createRequire } from "node:module";
2
+ import path from "node:path";
3
+ //#region src/fields/icon/codegen/sources/tabler.ts
4
+ const require = createRequire(import.meta.url);
5
+ const pascal = (name) => name.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
6
+ /**
7
+ * `@tabler/icons` maps every subpath to `./icons/*`, so root JSON files are not
8
+ * reachable by bare specifier. Anchor on a file the map does expose and walk
9
+ * back to the package root for `file`.
10
+ */
11
+ const rootJsonPath = (file) => {
12
+ const anchor = require.resolve("@tabler/icons/outline/heart.svg");
13
+ return path.join(path.dirname(anchor), "..", "..", file);
14
+ };
15
+ /** Outline set only in v1; filled variants would double the manifest for little picker value. */
16
+ const loadTablerSource = () => {
17
+ const json = require(rootJsonPath("icons.json"));
18
+ return {
19
+ icons: Object.values(json).filter((entry) => "outline" in entry.styles).map((entry) => ({
20
+ name: entry.name,
21
+ tags: entry.tags.filter((tag) => typeof tag === "string"),
22
+ categories: entry.category ? [entry.category.toLowerCase()] : []
23
+ })),
24
+ importFor: (icon) => ({ module: `@tabler/icons-react/dist/esm/icons/Icon${pascal(icon.name)}.mjs` }),
25
+ nodes: require(rootJsonPath("tabler-nodes-outline.json"))
26
+ };
27
+ };
28
+ //#endregion
29
+ export { loadTablerSource };
30
+
31
+ //# sourceMappingURL=tabler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabler.js","names":[],"sources":["../../../../../src/fields/icon/codegen/sources/tabler.ts"],"sourcesContent":["import { createRequire } from 'node:module'\nimport path from 'node:path'\nimport type { IconMeta, IconNodeMap } from '../../../../types'\nimport type { LoadedIconSource } from '../types'\n\nconst require = createRequire(import.meta.url)\n\ntype TablerIconEntry = {\n\tname: string\n\tcategory: string\n\ttags: unknown[]\n\tstyles: Record<string, unknown>\n}\n\nconst pascal = (name: string): string =>\n\tname\n\t\t.split('-')\n\t\t.map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n\t\t.join('')\n\n/**\n * `@tabler/icons` maps every subpath to `./icons/*`, so root JSON files are not\n * reachable by bare specifier. Anchor on a file the map does expose and walk\n * back to the package root for `file`.\n */\nconst rootJsonPath = (file: string): string => {\n\tconst anchor = require.resolve('@tabler/icons/outline/heart.svg')\n\treturn path.join(path.dirname(anchor), '..', '..', file)\n}\n\n/** Outline set only in v1; filled variants would double the manifest for little picker value. */\nexport const loadTablerSource = (): LoadedIconSource => {\n\tconst json = require(rootJsonPath('icons.json')) as Record<string, TablerIconEntry>\n\tconst entries = Object.values(json).filter((entry) => 'outline' in entry.styles)\n\tconst icons: IconMeta[] = entries.map((entry) => ({\n\t\tname: entry.name,\n\t\ttags: entry.tags.filter((tag): tag is string => typeof tag === 'string'),\n\t\tcategories: entry.category ? [entry.category.toLowerCase()] : [],\n\t}))\n\t// The outline node-data is keyed by the same bare kebab names as icons.json,\n\t// so no prefix normalization is needed for this package version.\n\tconst nodes = require(rootJsonPath('tabler-nodes-outline.json')) as IconNodeMap\n\treturn {\n\t\ticons,\n\t\timportFor: (icon) => ({\n\t\t\tmodule: `@tabler/icons-react/dist/esm/icons/Icon${pascal(icon.name)}.mjs`,\n\t\t}),\n\t\tnodes,\n\t}\n}\n"],"mappings":";;;AAKA,MAAM,UAAU,cAAc,OAAO,KAAK,GAAG;AAS7C,MAAM,UAAU,SACf,KACE,MAAM,GAAG,EACT,KAAK,SAAS,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,CAAC,EAC1D,KAAK,EAAE;;;;;;AAOV,MAAM,gBAAgB,SAAyB;CAC9C,MAAM,SAAS,QAAQ,QAAQ,iCAAiC;CAChE,OAAO,KAAK,KAAK,KAAK,QAAQ,MAAM,GAAG,MAAM,MAAM,IAAI;AACxD;;AAGA,MAAa,yBAA2C;CACvD,MAAM,OAAO,QAAQ,aAAa,YAAY,CAAC;CAU/C,OAAO;EACN,OAVe,OAAO,OAAO,IAAI,EAAE,QAAQ,UAAU,aAAa,MAAM,MACzC,EAAE,KAAK,WAAW;GACjD,MAAM,MAAM;GACZ,MAAM,MAAM,KAAK,QAAQ,QAAuB,OAAO,QAAQ,QAAQ;GACvE,YAAY,MAAM,WAAW,CAAC,MAAM,SAAS,YAAY,CAAC,IAAI,CAAC;EAChE,EAKK;EACJ,YAAY,UAAU,EACrB,QAAQ,0CAA0C,OAAO,KAAK,IAAI,EAAE,MACrE;EACA,OANa,QAAQ,aAAa,2BAA2B,CAMzD;CACL;AACD"}
@@ -0,0 +1,36 @@
1
+ import { IconMeta, IconNodeMap } from "../../../types.js";
2
+
3
+ //#region src/fields/icon/codegen/types.d.ts
4
+ type IconImportSpec = {
5
+ module: string;
6
+ exportName?: string;
7
+ };
8
+ type CustomIconSource = {
9
+ icons: IconMeta[]; /** Omit when the library has its own dynamic loader (no imports.ts is emitted). */
10
+ importFor?: (icon: IconMeta) => IconImportSpec;
11
+ /**
12
+ * Bulk glyph node-data keyed by icon name. Present emits `nodes.ts` for the
13
+ * drawer to render inline SVG without per-icon imports; omit for libraries the
14
+ * drawer renders through the per-icon `Icon` component (e.g. radix).
15
+ */
16
+ nodes?: IconNodeMap;
17
+ };
18
+ type IconManifestSource = 'lucide' | 'radix' | 'tabler' | CustomIconSource;
19
+ type GenerateIconManifestOptions = {
20
+ source: IconManifestSource; /** Directory receiving `manifest.ts` (+ `imports.ts` when the source maps imports). */
21
+ outDir: string;
22
+ /**
23
+ * Emit icons without categories when a source cannot fetch its category
24
+ * metadata. Off by default so an offline or upstream-changed run fails loudly
25
+ * instead of quietly overwriting committed output with the categories dropped.
26
+ */
27
+ allowMissingCategories?: boolean;
28
+ /**
29
+ * Command named in the generated-file header so a reader runs the right regen.
30
+ * Defaults to `pnpm generate:manifests`; a BYO source pass its own script.
31
+ */
32
+ regenCommand?: string;
33
+ };
34
+ //#endregion
35
+ export { CustomIconSource, GenerateIconManifestOptions, IconImportSpec, IconManifestSource };
36
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,8 @@
1
+ import { IconAdapter } from "../../types.js";
2
+
3
+ //#region src/fields/icon/defineIconAdapter.d.ts
4
+ /** Identity helper for BYO libraries; pins the adapter contract version. */
5
+ declare const defineIconAdapter: (adapter: Omit<IconAdapter, "version">) => IconAdapter;
6
+ //#endregion
7
+ export { defineIconAdapter };
8
+ //# sourceMappingURL=defineIconAdapter.d.ts.map
@@ -0,0 +1,10 @@
1
+ //#region src/fields/icon/defineIconAdapter.ts
2
+ /** Identity helper for BYO libraries; pins the adapter contract version. */
3
+ const defineIconAdapter = (adapter) => ({
4
+ ...adapter,
5
+ version: 1
6
+ });
7
+ //#endregion
8
+ export { defineIconAdapter };
9
+
10
+ //# sourceMappingURL=defineIconAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineIconAdapter.js","names":[],"sources":["../../../src/fields/icon/defineIconAdapter.ts"],"sourcesContent":["import type { IconAdapter } from '../../types'\n\n/** Identity helper for BYO libraries; pins the adapter contract version. */\nexport const defineIconAdapter = (adapter: Omit<IconAdapter, 'version'>): IconAdapter => ({\n\t...adapter,\n\tversion: 1,\n})\n"],"mappings":";;AAGA,MAAa,qBAAqB,aAAwD;CACzF,GAAG;CACH,SAAS;AACV"}
@@ -0,0 +1,55 @@
1
+ import { FIELDS_REGISTRY_KEY } from "../../plugin/registry.js";
2
+ //#region src/fields/icon/plugin.ts
3
+ /**
4
+ * Slugs prefix every stored value (`<slug>:<icon-name>`), so a slug carrying a
5
+ * `:` would parse back as a different library and name. Same shape as the icon
6
+ * names codegen accepts.
7
+ */
8
+ const ADAPTER_SLUG = /^[a-z0-9]+(-[a-z0-9]+)*$/;
9
+ /**
10
+ * Writes normalized icon globals to the plugin registry and forces the
11
+ * adapters' client components into the importMap via admin.dependencies
12
+ * (registry strings are not scanned by generate:importmap).
13
+ */
14
+ const registerIcon = (config, icon) => {
15
+ if (!icon?.adapters) return;
16
+ const [firstAdapter] = icon.adapters;
17
+ if (!firstAdapter) return;
18
+ const slugs = /* @__PURE__ */ new Set();
19
+ for (const adapter of icon.adapters) {
20
+ if (!ADAPTER_SLUG.test(adapter.slug)) throw new Error(`[fields] invalid icon adapter slug: "${adapter.slug}" (expected kebab-case, e.g. "my-icons")`);
21
+ if (slugs.has(adapter.slug)) throw new Error(`[fields] duplicate icon adapter slug: ${adapter.slug}`);
22
+ slugs.add(adapter.slug);
23
+ }
24
+ const defaultLibrary = icon.defaultLibrary ?? firstAdapter.slug;
25
+ if (!slugs.has(defaultLibrary)) throw new Error(`[fields] defaultLibrary "${defaultLibrary}" is not a registered icon adapter`);
26
+ config.custom ??= {};
27
+ const registry = config.custom["@10x-media/fields"] ?? {};
28
+ registry.icon = {
29
+ adapters: icon.adapters,
30
+ alwaysAvailable: icon.alwaysAvailable,
31
+ defaultLibrary,
32
+ resolveAvailable: icon.resolveAvailable
33
+ };
34
+ config.custom[FIELDS_REGISTRY_KEY] = registry;
35
+ config.admin ??= {};
36
+ config.admin.dependencies ??= {};
37
+ for (const adapter of icon.adapters) {
38
+ config.admin.dependencies[`fields-icon-${adapter.slug}-Icon`] = {
39
+ path: adapter.Icon,
40
+ type: "component"
41
+ };
42
+ config.admin.dependencies[`fields-icon-${adapter.slug}-Assets`] = {
43
+ path: adapter.Assets,
44
+ type: "component"
45
+ };
46
+ if (adapter.Nodes) config.admin.dependencies[`fields-icon-${adapter.slug}-Nodes`] = {
47
+ path: adapter.Nodes,
48
+ type: "component"
49
+ };
50
+ }
51
+ };
52
+ //#endregion
53
+ export { registerIcon };
54
+
55
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","names":[],"sources":["../../../src/fields/icon/plugin.ts"],"sourcesContent":["import type { Config } from 'payload'\nimport { FIELDS_REGISTRY_KEY } from '../../plugin/registry'\nimport type { FieldsPluginRegistry, IconGlobalConfig } from '../../types'\n\n/**\n * Slugs prefix every stored value (`<slug>:<icon-name>`), so a slug carrying a\n * `:` would parse back as a different library and name. Same shape as the icon\n * names codegen accepts.\n */\nconst ADAPTER_SLUG = /^[a-z0-9]+(-[a-z0-9]+)*$/\n\n/**\n * Writes normalized icon globals to the plugin registry and forces the\n * adapters' client components into the importMap via admin.dependencies\n * (registry strings are not scanned by generate:importmap).\n */\nexport const registerIcon = (config: Config, icon: IconGlobalConfig | undefined): void => {\n\tif (!icon?.adapters) {\n\t\treturn\n\t}\n\tconst [firstAdapter] = icon.adapters\n\tif (!firstAdapter) {\n\t\treturn\n\t}\n\tconst slugs = new Set<string>()\n\tfor (const adapter of icon.adapters) {\n\t\tif (!ADAPTER_SLUG.test(adapter.slug)) {\n\t\t\tthrow new Error(\n\t\t\t\t`[fields] invalid icon adapter slug: \"${adapter.slug}\" (expected kebab-case, e.g. \"my-icons\")`\n\t\t\t)\n\t\t}\n\t\tif (slugs.has(adapter.slug)) {\n\t\t\tthrow new Error(`[fields] duplicate icon adapter slug: ${adapter.slug}`)\n\t\t}\n\t\tslugs.add(adapter.slug)\n\t}\n\tconst defaultLibrary = icon.defaultLibrary ?? firstAdapter.slug\n\tif (!slugs.has(defaultLibrary)) {\n\t\tthrow new Error(`[fields] defaultLibrary \"${defaultLibrary}\" is not a registered icon adapter`)\n\t}\n\tconfig.custom ??= {}\n\tconst registry = (config.custom[FIELDS_REGISTRY_KEY] ?? {}) as FieldsPluginRegistry\n\tregistry.icon = {\n\t\tadapters: icon.adapters,\n\t\talwaysAvailable: icon.alwaysAvailable,\n\t\tdefaultLibrary,\n\t\tresolveAvailable: icon.resolveAvailable,\n\t}\n\tconfig.custom[FIELDS_REGISTRY_KEY] = registry\n\tconfig.admin ??= {}\n\tconfig.admin.dependencies ??= {}\n\tfor (const adapter of icon.adapters) {\n\t\tconfig.admin.dependencies[`fields-icon-${adapter.slug}-Icon`] = {\n\t\t\tpath: adapter.Icon,\n\t\t\ttype: 'component',\n\t\t}\n\t\tconfig.admin.dependencies[`fields-icon-${adapter.slug}-Assets`] = {\n\t\t\tpath: adapter.Assets,\n\t\t\ttype: 'component',\n\t\t}\n\t\t// generate:importmap scans admin.dependencies, not registry strings, so the\n\t\t// optional Nodes loader must be registered here too or a regeneration drops\n\t\t// it and the drawer silently loses the bulk node-data fast path.\n\t\tif (adapter.Nodes) {\n\t\t\tconfig.admin.dependencies[`fields-icon-${adapter.slug}-Nodes`] = {\n\t\t\t\tpath: adapter.Nodes,\n\t\t\t\ttype: 'component',\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;AASA,MAAM,eAAe;;;;;;AAOrB,MAAa,gBAAgB,QAAgB,SAA6C;CACzF,IAAI,CAAC,MAAM,UACV;CAED,MAAM,CAAC,gBAAgB,KAAK;CAC5B,IAAI,CAAC,cACJ;CAED,MAAM,wBAAQ,IAAI,IAAY;CAC9B,KAAK,MAAM,WAAW,KAAK,UAAU;EACpC,IAAI,CAAC,aAAa,KAAK,QAAQ,IAAI,GAClC,MAAM,IAAI,MACT,wCAAwC,QAAQ,KAAK,yCACtD;EAED,IAAI,MAAM,IAAI,QAAQ,IAAI,GACzB,MAAM,IAAI,MAAM,yCAAyC,QAAQ,MAAM;EAExE,MAAM,IAAI,QAAQ,IAAI;CACvB;CACA,MAAM,iBAAiB,KAAK,kBAAkB,aAAa;CAC3D,IAAI,CAAC,MAAM,IAAI,cAAc,GAC5B,MAAM,IAAI,MAAM,4BAA4B,eAAe,mCAAmC;CAE/F,OAAO,WAAW,CAAC;CACnB,MAAM,WAAY,OAAO,OAAA,wBAA+B,CAAC;CACzD,SAAS,OAAO;EACf,UAAU,KAAK;EACf,iBAAiB,KAAK;EACtB;EACA,kBAAkB,KAAK;CACxB;CACA,OAAO,OAAO,uBAAuB;CACrC,OAAO,UAAU,CAAC;CAClB,OAAO,MAAM,iBAAiB,CAAC;CAC/B,KAAK,MAAM,WAAW,KAAK,UAAU;EACpC,OAAO,MAAM,aAAa,eAAe,QAAQ,KAAK,UAAU;GAC/D,MAAM,QAAQ;GACd,MAAM;EACP;EACA,OAAO,MAAM,aAAa,eAAe,QAAQ,KAAK,YAAY;GACjE,MAAM,QAAQ;GACd,MAAM;EACP;EAIA,IAAI,QAAQ,OACX,OAAO,MAAM,aAAa,eAAe,QAAQ,KAAK,WAAW;GAChE,MAAM,QAAQ;GACd,MAAM;EACP;CAEF;AACD"}
@@ -0,0 +1,15 @@
1
+ import { IconProps, IconRendererAdapter } from "./types.js";
2
+ import React from "react";
3
+
4
+ //#region src/fields/icon/react/createIcon.d.ts
5
+ /**
6
+ * Client dispatcher: per-value React.lazy components cached module-wide so a
7
+ * value renders one stable lazy component (per-icon chunks, loaded once).
8
+ */
9
+ declare const createIcon: (args: {
10
+ adapters: IconRendererAdapter[];
11
+ defaultLibrary?: string;
12
+ }) => React.FC<IconProps>;
13
+ //#endregion
14
+ export { createIcon };
15
+ //# sourceMappingURL=createIcon.d.ts.map
@@ -0,0 +1,47 @@
1
+ "use client";
2
+ import { resolveIconValue } from "../shared/value.js";
3
+ import React, { Suspense } from "react";
4
+ import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
5
+ //#region src/fields/icon/react/createIcon.tsx
6
+ const Empty = () => null;
7
+ /**
8
+ * Client dispatcher: per-value React.lazy components cached module-wide so a
9
+ * value renders one stable lazy component (per-icon chunks, loaded once).
10
+ */
11
+ const createIcon = (args) => {
12
+ const bySlug = new Map(args.adapters.map((adapter) => [adapter.slug, adapter]));
13
+ const defaultLibrary = args.defaultLibrary ?? args.adapters[0]?.slug ?? "";
14
+ const cache = /* @__PURE__ */ new Map();
15
+ const lazyFor = (library, name) => {
16
+ const adapter = bySlug.get(library);
17
+ if (!adapter) return null;
18
+ const key = `${library}:${name}`;
19
+ let component = cache.get(key);
20
+ if (!component) {
21
+ component = React.lazy(async () => ({ default: await adapter.loadIcon(name) ?? Empty }));
22
+ cache.set(key, component);
23
+ }
24
+ return component;
25
+ };
26
+ const Icon = ({ className, fallback = null, icon, label, size = 20 }) => {
27
+ if (!icon) return /* @__PURE__ */ jsx(Fragment$1, { children: fallback });
28
+ const { library, name } = resolveIconValue(icon, defaultLibrary);
29
+ const Component = lazyFor(library, name);
30
+ if (!Component) return /* @__PURE__ */ jsx(Fragment$1, { children: fallback });
31
+ return /* @__PURE__ */ jsx(Suspense, {
32
+ fallback,
33
+ children: /* @__PURE__ */ jsx(Component, {
34
+ "aria-hidden": label ? void 0 : true,
35
+ "aria-label": label,
36
+ className,
37
+ role: label ? "img" : void 0,
38
+ size
39
+ })
40
+ });
41
+ };
42
+ return Icon;
43
+ };
44
+ //#endregion
45
+ export { createIcon };
46
+
47
+ //# sourceMappingURL=createIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createIcon.js","names":[],"sources":["../../../../src/fields/icon/react/createIcon.tsx"],"sourcesContent":["'use client'\n\nimport type { ComponentType } from 'react'\nimport React, { Suspense } from 'react'\nimport { resolveIconValue } from '../shared/value'\nimport type { IconProps, IconRendererAdapter, IconRenderProps } from './types'\n\nconst Empty: ComponentType<IconRenderProps> = () => null\n\n/**\n * Client dispatcher: per-value React.lazy components cached module-wide so a\n * value renders one stable lazy component (per-icon chunks, loaded once).\n */\nexport const createIcon = (args: {\n\tadapters: IconRendererAdapter[]\n\tdefaultLibrary?: string\n}): React.FC<IconProps> => {\n\tconst bySlug = new Map(args.adapters.map((adapter) => [adapter.slug, adapter]))\n\tconst defaultLibrary = args.defaultLibrary ?? args.adapters[0]?.slug ?? ''\n\tconst cache = new Map<string, ComponentType<IconRenderProps>>()\n\n\tconst lazyFor = (library: string, name: string): ComponentType<IconRenderProps> | null => {\n\t\tconst adapter = bySlug.get(library)\n\t\tif (!adapter) return null\n\t\tconst key = `${library}:${name}`\n\t\tlet component = cache.get(key)\n\t\tif (!component) {\n\t\t\tcomponent = React.lazy(async () => ({\n\t\t\t\tdefault: (await adapter.loadIcon(name)) ?? Empty,\n\t\t\t})) as unknown as ComponentType<IconRenderProps>\n\t\t\tcache.set(key, component)\n\t\t}\n\t\treturn component\n\t}\n\n\tconst Icon: React.FC<IconProps> = ({ className, fallback = null, icon, label, size = 20 }) => {\n\t\tif (!icon) return <>{fallback}</>\n\t\tconst { library, name } = resolveIconValue(icon, defaultLibrary)\n\t\tconst Component = lazyFor(library, name)\n\t\tif (!Component) return <>{fallback}</>\n\t\treturn (\n\t\t\t<Suspense fallback={fallback}>\n\t\t\t\t<Component\n\t\t\t\t\taria-hidden={label ? undefined : true}\n\t\t\t\t\taria-label={label}\n\t\t\t\t\tclassName={className}\n\t\t\t\t\trole={label ? 'img' : undefined}\n\t\t\t\t\tsize={size}\n\t\t\t\t/>\n\t\t\t</Suspense>\n\t\t)\n\t}\n\treturn Icon\n}\n"],"mappings":";;;;;AAOA,MAAM,cAA8C;;;;;AAMpD,MAAa,cAAc,SAGA;CAC1B,MAAM,SAAS,IAAI,IAAI,KAAK,SAAS,KAAK,YAAY,CAAC,QAAQ,MAAM,OAAO,CAAC,CAAC;CAC9E,MAAM,iBAAiB,KAAK,kBAAkB,KAAK,SAAS,IAAI,QAAQ;CACxE,MAAM,wBAAQ,IAAI,IAA4C;CAE9D,MAAM,WAAW,SAAiB,SAAwD;EACzF,MAAM,UAAU,OAAO,IAAI,OAAO;EAClC,IAAI,CAAC,SAAS,OAAO;EACrB,MAAM,MAAM,GAAG,QAAQ,GAAG;EAC1B,IAAI,YAAY,MAAM,IAAI,GAAG;EAC7B,IAAI,CAAC,WAAW;GACf,YAAY,MAAM,KAAK,aAAa,EACnC,SAAU,MAAM,QAAQ,SAAS,IAAI,KAAM,MAC5C,EAAE;GACF,MAAM,IAAI,KAAK,SAAS;EACzB;EACA,OAAO;CACR;CAEA,MAAM,QAA6B,EAAE,WAAW,WAAW,MAAM,MAAM,OAAO,OAAO,SAAS;EAC7F,IAAI,CAAC,MAAM,OAAO,oBAAA,YAAA,EAAA,UAAG,SAAW,CAAA;EAChC,MAAM,EAAE,SAAS,SAAS,iBAAiB,MAAM,cAAc;EAC/D,MAAM,YAAY,QAAQ,SAAS,IAAI;EACvC,IAAI,CAAC,WAAW,OAAO,oBAAA,YAAA,EAAA,UAAG,SAAW,CAAA;EACrC,OACC,oBAAC,UAAD;GAAoB;aACnB,oBAAC,WAAD;IACC,eAAa,QAAQ,KAAA,IAAY;IACjC,cAAY;IACD;IACX,MAAM,QAAQ,QAAQ,KAAA;IAChB;GACN,CAAA;EACQ,CAAA;CAEZ;CACA,OAAO;AACR"}
@@ -0,0 +1,12 @@
1
+ import { IconProps, IconRendererAdapter } from "./types.js";
2
+ import { ReactNode } from "react";
3
+
4
+ //#region src/fields/icon/react/createRscIcon.d.ts
5
+ /** Async server component factory: the per-icon import is awaited server-side and the SVG streams with zero client JS. */
6
+ declare const createRscIcon: (args: {
7
+ adapters: IconRendererAdapter[];
8
+ defaultLibrary?: string;
9
+ }) => ((props: IconProps) => Promise<ReactNode>);
10
+ //#endregion
11
+ export { createRscIcon };
12
+ //# sourceMappingURL=createRscIcon.d.ts.map
@@ -0,0 +1,27 @@
1
+ import { resolveIconValue } from "../shared/value.js";
2
+ import { jsx } from "react/jsx-runtime";
3
+ //#region src/fields/icon/react/createRscIcon.tsx
4
+ /** Async server component factory: the per-icon import is awaited server-side and the SVG streams with zero client JS. */
5
+ const createRscIcon = (args) => {
6
+ const bySlug = new Map(args.adapters.map((adapter) => [adapter.slug, adapter]));
7
+ const defaultLibrary = args.defaultLibrary ?? args.adapters[0]?.slug ?? "";
8
+ return async ({ className, fallback = null, icon, label, size = 20 }) => {
9
+ if (!icon) return fallback;
10
+ const { library, name } = resolveIconValue(icon, defaultLibrary);
11
+ const adapter = bySlug.get(library);
12
+ if (!adapter) return fallback;
13
+ const Component = await adapter.loadIcon(name);
14
+ if (!Component) return fallback;
15
+ return /* @__PURE__ */ jsx(Component, {
16
+ "aria-hidden": label ? void 0 : true,
17
+ "aria-label": label,
18
+ className,
19
+ role: label ? "img" : void 0,
20
+ size
21
+ });
22
+ };
23
+ };
24
+ //#endregion
25
+ export { createRscIcon };
26
+
27
+ //# sourceMappingURL=createRscIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createRscIcon.js","names":[],"sources":["../../../../src/fields/icon/react/createRscIcon.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { resolveIconValue } from '../shared/value'\nimport type { IconProps, IconRendererAdapter } from './types'\n\n/** Async server component factory: the per-icon import is awaited server-side and the SVG streams with zero client JS. */\nexport const createRscIcon = (args: {\n\tadapters: IconRendererAdapter[]\n\tdefaultLibrary?: string\n}): ((props: IconProps) => Promise<ReactNode>) => {\n\tconst bySlug = new Map(args.adapters.map((adapter) => [adapter.slug, adapter]))\n\tconst defaultLibrary = args.defaultLibrary ?? args.adapters[0]?.slug ?? ''\n\n\treturn async ({ className, fallback = null, icon, label, size = 20 }: IconProps) => {\n\t\tif (!icon) return fallback\n\t\tconst { library, name } = resolveIconValue(icon, defaultLibrary)\n\t\tconst adapter = bySlug.get(library)\n\t\tif (!adapter) return fallback\n\t\tconst Component = await adapter.loadIcon(name)\n\t\tif (!Component) return fallback\n\t\treturn (\n\t\t\t<Component\n\t\t\t\taria-hidden={label ? undefined : true}\n\t\t\t\taria-label={label}\n\t\t\t\tclassName={className}\n\t\t\t\trole={label ? 'img' : undefined}\n\t\t\t\tsize={size}\n\t\t\t/>\n\t\t)\n\t}\n}\n"],"mappings":";;;;AAKA,MAAa,iBAAiB,SAGoB;CACjD,MAAM,SAAS,IAAI,IAAI,KAAK,SAAS,KAAK,YAAY,CAAC,QAAQ,MAAM,OAAO,CAAC,CAAC;CAC9E,MAAM,iBAAiB,KAAK,kBAAkB,KAAK,SAAS,IAAI,QAAQ;CAExE,OAAO,OAAO,EAAE,WAAW,WAAW,MAAM,MAAM,OAAO,OAAO,SAAoB;EACnF,IAAI,CAAC,MAAM,OAAO;EAClB,MAAM,EAAE,SAAS,SAAS,iBAAiB,MAAM,cAAc;EAC/D,MAAM,UAAU,OAAO,IAAI,OAAO;EAClC,IAAI,CAAC,SAAS,OAAO;EACrB,MAAM,YAAY,MAAM,QAAQ,SAAS,IAAI;EAC7C,IAAI,CAAC,WAAW,OAAO;EACvB,OACC,oBAAC,WAAD;GACC,eAAa,QAAQ,KAAA,IAAY;GACjC,cAAY;GACD;GACX,MAAM,QAAQ,QAAQ,KAAA;GAChB;EACN,CAAA;CAEH;AACD"}
@@ -0,0 +1,24 @@
1
+ import { ComponentType, ReactNode } from "react";
2
+
3
+ //#region src/fields/icon/react/types.d.ts
4
+ type IconRenderProps = {
5
+ 'aria-hidden'?: boolean;
6
+ 'aria-label'?: string;
7
+ className?: string;
8
+ role?: string;
9
+ size?: number | string;
10
+ };
11
+ type IconRendererAdapter = {
12
+ slug: string; /** Resolves one icon component by name, or null when unknown. Must import per icon (or per library where the package is single-module). */
13
+ loadIcon: (name: string) => Promise<ComponentType<IconRenderProps> | null>;
14
+ };
15
+ type IconProps = {
16
+ className?: string;
17
+ fallback?: ReactNode;
18
+ icon?: null | string; /** Accessible label; omitted renders aria-hidden decorative output. */
19
+ label?: string;
20
+ size?: number | string;
21
+ };
22
+ //#endregion
23
+ export { IconProps, IconRenderProps, IconRendererAdapter };
24
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { IconAdapter } from "../../../types.js";
2
+ import { DefaultServerCellComponentProps } from "payload";
3
+ import { ReactNode } from "react";
4
+
5
+ //#region src/fields/icon/rsc/IconCell.d.ts
6
+ type IconCellProps = {
7
+ adapters?: IconAdapter[];
8
+ defaultLibrary?: string;
9
+ } & DefaultServerCellComponentProps;
10
+ /** List cell: the selected glyph plus its formatted name, degrading to name-only for unavailable or removed libraries. */
11
+ declare const IconCell: (props: IconCellProps) => ReactNode;
12
+ //#endregion
13
+ export { IconCell };
14
+ //# sourceMappingURL=IconCell.d.ts.map
@@ -0,0 +1,32 @@
1
+ import { getFieldsRegistry } from "../../../plugin/registry.js";
2
+ import { formatIconLabel } from "../shared/formatIconLabel.js";
3
+ import { resolveIconValue } from "../shared/value.js";
4
+ import { getFromImportMap } from "payload/shared";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ //#region src/fields/icon/rsc/IconCell.tsx
7
+ /** List cell: the selected glyph plus its formatted name, degrading to name-only for unavailable or removed libraries. */
8
+ const IconCell = (props) => {
9
+ const { cellData, payload } = props;
10
+ if (typeof cellData !== "string" || cellData === "") return null;
11
+ const registryIcon = getFieldsRegistry(payload.config)?.icon;
12
+ const adapters = props.adapters ?? registryIcon?.adapters ?? [];
13
+ const { library, name } = resolveIconValue(cellData, props.defaultLibrary ?? registryIcon?.defaultLibrary ?? adapters[0]?.slug ?? "");
14
+ const adapter = adapters.find((candidate) => candidate.slug === library);
15
+ const Icon = adapter ? getFromImportMap({
16
+ importMap: payload.importMap,
17
+ PayloadComponent: adapter.Icon,
18
+ schemaPath: "fields-icon-cell",
19
+ silent: true
20
+ }) : null;
21
+ return /* @__PURE__ */ jsxs("span", {
22
+ className: "tenx-icon-cell",
23
+ children: [Icon ? /* @__PURE__ */ jsx(Icon, {
24
+ name,
25
+ size: 16
26
+ }) : null, /* @__PURE__ */ jsx("span", { children: formatIconLabel(name) })]
27
+ });
28
+ };
29
+ //#endregion
30
+ export { IconCell };
31
+
32
+ //# sourceMappingURL=IconCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IconCell.js","names":[],"sources":["../../../../src/fields/icon/rsc/IconCell.tsx"],"sourcesContent":["import type { DefaultServerCellComponentProps } from 'payload'\nimport { getFromImportMap } from 'payload/shared'\nimport type { ReactNode } from 'react'\nimport { getFieldsRegistry } from '../../../plugin/registry'\nimport type { IconAdapter } from '../../../types'\nimport type { AdapterComponentsEntry } from '../shared/adapterComponents'\nimport { formatIconLabel } from '../shared/formatIconLabel'\nimport { resolveIconValue } from '../shared/value'\n\ntype IconCellProps = {\n\tadapters?: IconAdapter[]\n\tdefaultLibrary?: string\n} & DefaultServerCellComponentProps\n\n/** List cell: the selected glyph plus its formatted name, degrading to name-only for unavailable or removed libraries. */\nexport const IconCell = (props: IconCellProps): ReactNode => {\n\tconst { cellData, payload } = props\n\tif (typeof cellData !== 'string' || cellData === '') return null\n\tconst registryIcon = getFieldsRegistry(payload.config)?.icon\n\tconst adapters = props.adapters ?? registryIcon?.adapters ?? []\n\tconst defaultLibrary =\n\t\tprops.defaultLibrary ?? registryIcon?.defaultLibrary ?? adapters[0]?.slug ?? ''\n\tconst { library, name } = resolveIconValue(cellData, defaultLibrary)\n\tconst adapter = adapters.find((candidate) => candidate.slug === library)\n\tconst Icon = adapter\n\t\t? getFromImportMap<AdapterComponentsEntry['Icon']>({\n\t\t\t\timportMap: payload.importMap,\n\t\t\t\tPayloadComponent: adapter.Icon,\n\t\t\t\tschemaPath: 'fields-icon-cell',\n\t\t\t\tsilent: true,\n\t\t\t})\n\t\t: null\n\treturn (\n\t\t<span className=\"tenx-icon-cell\">\n\t\t\t{Icon ? <Icon name={name} size={16} /> : null}\n\t\t\t<span>{formatIconLabel(name)}</span>\n\t\t</span>\n\t)\n}\n"],"mappings":";;;;;;;AAeA,MAAa,YAAY,UAAoC;CAC5D,MAAM,EAAE,UAAU,YAAY;CAC9B,IAAI,OAAO,aAAa,YAAY,aAAa,IAAI,OAAO;CAC5D,MAAM,eAAe,kBAAkB,QAAQ,MAAM,GAAG;CACxD,MAAM,WAAW,MAAM,YAAY,cAAc,YAAY,CAAC;CAG9D,MAAM,EAAE,SAAS,SAAS,iBAAiB,UAD1C,MAAM,kBAAkB,cAAc,kBAAkB,SAAS,IAAI,QAAQ,EACX;CACnE,MAAM,UAAU,SAAS,MAAM,cAAc,UAAU,SAAS,OAAO;CACvE,MAAM,OAAO,UACV,iBAAiD;EACjD,WAAW,QAAQ;EACnB,kBAAkB,QAAQ;EAC1B,YAAY;EACZ,QAAQ;CACT,CAAC,IACA;CACH,OACC,qBAAC,QAAD;EAAM,WAAU;YAAhB,CACE,OAAO,oBAAC,MAAD;GAAY;GAAM,MAAM;EAAK,CAAA,IAAI,MACzC,oBAAC,QAAD,EAAA,UAAO,gBAAgB,IAAI,EAAQ,CAAA,CAC9B;;AAER"}
@@ -0,0 +1,24 @@
1
+ import { IconAdapter, IconAvailabilityResolver } from "../../../types.js";
2
+ import { TextFieldServerProps } from "payload";
3
+ import { ReactNode } from "react";
4
+
5
+ //#region src/fields/icon/rsc/IconFieldServer.d.ts
6
+ type IconFieldServerExtraProps = {
7
+ adapters?: IconAdapter[];
8
+ alwaysAvailable?: string[];
9
+ defaultLibrary?: string;
10
+ resolveAvailable?: IconAvailabilityResolver;
11
+ showTextInput?: boolean;
12
+ };
13
+ type ServerProps = IconFieldServerExtraProps & TextFieldServerProps;
14
+ /**
15
+ * Resolves adapters (inline beats registry), availability (memoized per request,
16
+ * fails open), and adapter client components from the importMap, then renders the
17
+ * client field with those component references as props. A missing importMap entry
18
+ * degrades to no glyph for that library rather than throwing, so the edit view
19
+ * never 500s over a mis-registered adapter.
20
+ */
21
+ declare const IconFieldServer: (props: ServerProps) => Promise<ReactNode>;
22
+ //#endregion
23
+ export { IconFieldServer };
24
+ //# sourceMappingURL=IconFieldServer.d.ts.map