payload-intl 1.3.2 → 1.4.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 (276) hide show
  1. package/README.md +23 -3
  2. package/dist/components/MessagesField.d.ts +12 -0
  3. package/dist/components/MessagesField.d.ts.map +1 -0
  4. package/dist/components/MessagesField.js +36 -0
  5. package/dist/components/MessagesField.js.map +1 -0
  6. package/dist/components/MessagesImport.d.ts +2 -0
  7. package/dist/components/MessagesImport.d.ts.map +1 -0
  8. package/dist/components/MessagesImport.js +68 -0
  9. package/dist/components/MessagesImport.js.map +1 -0
  10. package/dist/components/MessagesImport.module.css +8 -0
  11. package/dist/components/input/LexicalInput.d.ts +8 -0
  12. package/dist/components/input/LexicalInput.d.ts.map +1 -0
  13. package/dist/components/input/LexicalInput.js +21 -0
  14. package/dist/components/input/LexicalInput.js.map +1 -0
  15. package/dist/components/input/MessageInput.d.ts +12 -0
  16. package/dist/components/input/MessageInput.d.ts.map +1 -0
  17. package/dist/components/{inputs → input}/MessageInput.js +31 -38
  18. package/dist/components/input/MessageInput.js.map +1 -0
  19. package/dist/components/{inputs → input}/MessageInput.module.css +14 -19
  20. package/dist/components/{inputs → input}/ReferencePopover.d.ts +1 -1
  21. package/dist/components/input/ReferencePopover.d.ts.map +1 -0
  22. package/dist/components/{inputs → input}/ReferencePopover.js +20 -5
  23. package/dist/components/input/ReferencePopover.js.map +1 -0
  24. package/dist/components/input/SingleLinePlugin.d.ts.map +1 -0
  25. package/dist/components/input/SingleLinePlugin.js.map +1 -0
  26. package/dist/components/{hooks → input}/useHtmlLexicalAdapter.d.ts.map +1 -1
  27. package/dist/components/{hooks → input}/useHtmlLexicalAdapter.js.map +1 -1
  28. package/dist/{utils/format.d.ts → components/input/utils.d.ts} +2 -2
  29. package/dist/components/input/utils.d.ts.map +1 -0
  30. package/dist/{utils/format.js → components/input/utils.js} +2 -2
  31. package/dist/components/input/utils.js.map +1 -0
  32. package/dist/components/input/variables/VariableChip.d.ts.map +1 -0
  33. package/dist/components/{inputs → input}/variables/VariableChip.js +1 -2
  34. package/dist/components/input/variables/VariableChip.js.map +1 -0
  35. package/dist/components/input/variables/VariableIcon.d.ts.map +1 -0
  36. package/dist/components/input/variables/VariableIcon.js.map +1 -0
  37. package/dist/components/input/variables/VariableNode.d.ts.map +1 -0
  38. package/dist/components/input/variables/VariableNode.js.map +1 -0
  39. package/dist/components/input/variables/VariableSuggestion.d.ts.map +1 -0
  40. package/dist/components/input/variables/VariableSuggestion.js.map +1 -0
  41. package/dist/components/input/variables/editors/PluralVariableEditor.d.ts.map +1 -0
  42. package/dist/components/{inputs → input}/variables/editors/PluralVariableEditor.js +1 -1
  43. package/dist/components/input/variables/editors/PluralVariableEditor.js.map +1 -0
  44. package/dist/components/input/variables/editors/SelectVariableEditor.d.ts.map +1 -0
  45. package/dist/components/{inputs → input}/variables/editors/SelectVariableEditor.js +1 -1
  46. package/dist/components/input/variables/editors/SelectVariableEditor.js.map +1 -0
  47. package/dist/components/input/variables/editors/TagVariableEditor.d.ts.map +1 -0
  48. package/dist/components/{inputs → input}/variables/editors/TagVariableEditor.js +1 -1
  49. package/dist/components/input/variables/editors/TagVariableEditor.js.map +1 -0
  50. package/dist/components/input/variables/editors/TemporalVariableEditor.d.ts.map +1 -0
  51. package/dist/components/input/variables/editors/TemporalVariableEditor.js.map +1 -0
  52. package/dist/components/input/variables/pickers/NumericVariableEditor.d.ts.map +1 -0
  53. package/dist/components/{inputs → input}/variables/pickers/NumericVariableEditor.js +1 -1
  54. package/dist/components/input/variables/pickers/NumericVariableEditor.js.map +1 -0
  55. package/dist/components/input/variables/pickers/TemporalVariablePicker.d.ts.map +1 -0
  56. package/dist/components/{inputs → input}/variables/pickers/TemporalVariablePicker.js +1 -1
  57. package/dist/components/input/variables/pickers/TemporalVariablePicker.js.map +1 -0
  58. package/dist/components/layout/MessageField.d.ts +5 -4
  59. package/dist/components/layout/MessageField.d.ts.map +1 -1
  60. package/dist/components/layout/MessageField.js +44 -51
  61. package/dist/components/layout/MessageField.js.map +1 -1
  62. package/dist/components/layout/MessageField.module.css +17 -5
  63. package/dist/components/layout/MessagesTabs.d.ts.map +1 -1
  64. package/dist/components/layout/MessagesTabs.js +9 -19
  65. package/dist/components/layout/MessagesTabs.js.map +1 -1
  66. package/dist/components/layout/MessagesTree.d.ts +7 -5
  67. package/dist/components/layout/MessagesTree.d.ts.map +1 -1
  68. package/dist/components/layout/MessagesTree.js +12 -22
  69. package/dist/components/layout/MessagesTree.js.map +1 -1
  70. package/dist/components/layout/MessagesTree.module.css +7 -3
  71. package/dist/{utils/config.d.ts → config.d.ts} +1 -1
  72. package/dist/config.d.ts.map +1 -0
  73. package/dist/config.js.map +1 -0
  74. package/dist/const.d.ts +3 -9
  75. package/dist/const.d.ts.map +1 -1
  76. package/dist/const.js +3 -12
  77. package/dist/const.js.map +1 -1
  78. package/dist/exports/client.d.ts +3 -1
  79. package/dist/exports/client.d.ts.map +1 -1
  80. package/dist/exports/client.js +3 -1
  81. package/dist/exports/client.js.map +1 -1
  82. package/dist/exports/fetchMessages.d.ts +4 -0
  83. package/dist/exports/fetchMessages.d.ts.map +1 -0
  84. package/dist/exports/fetchMessages.js +18 -0
  85. package/dist/exports/fetchMessages.js.map +1 -0
  86. package/dist/exports/rsc.d.ts +0 -2
  87. package/dist/exports/rsc.d.ts.map +1 -1
  88. package/dist/exports/rsc.js +0 -2
  89. package/dist/exports/rsc.js.map +1 -1
  90. package/dist/file-storage-hooks.d.ts +17 -0
  91. package/dist/file-storage-hooks.d.ts.map +1 -0
  92. package/dist/file-storage-hooks.js +37 -0
  93. package/dist/file-storage-hooks.js.map +1 -0
  94. package/dist/hooks.d.ts +19 -3
  95. package/dist/hooks.d.ts.map +1 -1
  96. package/dist/hooks.js +41 -20
  97. package/dist/hooks.js.map +1 -1
  98. package/dist/icu/guards.d.ts.map +1 -0
  99. package/dist/icu/guards.js.map +1 -0
  100. package/dist/icu/index.d.ts +6 -0
  101. package/dist/icu/index.d.ts.map +1 -0
  102. package/dist/icu/index.js +7 -0
  103. package/dist/icu/index.js.map +1 -0
  104. package/dist/{utils/icu-tranform.d.ts → icu/lexical.d.ts} +1 -10
  105. package/dist/icu/lexical.d.ts.map +1 -0
  106. package/dist/{utils/icu-tranform.js → icu/lexical.js} +4 -44
  107. package/dist/icu/lexical.js.map +1 -0
  108. package/dist/icu/schema.d.ts +4 -0
  109. package/dist/icu/schema.d.ts.map +1 -0
  110. package/dist/icu/schema.js +43 -0
  111. package/dist/icu/schema.js.map +1 -0
  112. package/dist/icu/serialize.d.ts +11 -0
  113. package/dist/icu/serialize.d.ts.map +1 -0
  114. package/dist/icu/serialize.js +45 -0
  115. package/dist/icu/serialize.js.map +1 -0
  116. package/dist/icu/validate.d.ts.map +1 -0
  117. package/dist/icu/validate.js.map +1 -0
  118. package/dist/index.d.ts +23 -22
  119. package/dist/index.d.ts.map +1 -1
  120. package/dist/index.js +181 -37
  121. package/dist/index.js.map +1 -1
  122. package/dist/payload-types.d.ts +43 -16
  123. package/dist/payload-types.d.ts.map +1 -1
  124. package/dist/types.d.ts +24 -8
  125. package/dist/types.d.ts.map +1 -1
  126. package/dist/types.js.map +1 -1
  127. package/dist/utils/file-storage.d.ts +26 -0
  128. package/dist/utils/file-storage.d.ts.map +1 -0
  129. package/dist/utils/file-storage.js +61 -0
  130. package/dist/utils/file-storage.js.map +1 -0
  131. package/dist/utils/sanitize.d.ts +5 -3
  132. package/dist/utils/sanitize.d.ts.map +1 -1
  133. package/dist/utils/sanitize.js +4 -2
  134. package/dist/utils/sanitize.js.map +1 -1
  135. package/dist/utils/schema.d.ts +5 -7
  136. package/dist/utils/schema.d.ts.map +1 -1
  137. package/dist/utils/schema.js +11 -39
  138. package/dist/utils/schema.js.map +1 -1
  139. package/dist/utils/scopes.d.ts +3 -0
  140. package/dist/utils/scopes.d.ts.map +1 -0
  141. package/dist/utils/scopes.js +24 -0
  142. package/dist/utils/scopes.js.map +1 -0
  143. package/package.json +5 -5
  144. package/dist/components/MessageFormField.d.ts +0 -14
  145. package/dist/components/MessageFormField.d.ts.map +0 -1
  146. package/dist/components/MessageFormField.js +0 -28
  147. package/dist/components/MessageFormField.js.map +0 -1
  148. package/dist/components/MessagesForm.d.ts +0 -13
  149. package/dist/components/MessagesForm.d.ts.map +0 -1
  150. package/dist/components/MessagesForm.js +0 -120
  151. package/dist/components/MessagesForm.js.map +0 -1
  152. package/dist/components/MessagesForm.module.css +0 -41
  153. package/dist/components/MessagesFormProvider.d.ts +0 -33
  154. package/dist/components/MessagesFormProvider.d.ts.map +0 -1
  155. package/dist/components/MessagesFormProvider.js +0 -34
  156. package/dist/components/MessagesFormProvider.js.map +0 -1
  157. package/dist/components/MessagesLink.d.ts +0 -8
  158. package/dist/components/MessagesLink.d.ts.map +0 -1
  159. package/dist/components/MessagesLink.js +0 -22
  160. package/dist/components/MessagesLink.js.map +0 -1
  161. package/dist/components/MessagesView.d.ts +0 -10
  162. package/dist/components/MessagesView.d.ts.map +0 -1
  163. package/dist/components/MessagesView.js +0 -57
  164. package/dist/components/MessagesView.js.map +0 -1
  165. package/dist/components/actions/CopyMessages.d.ts +0 -2
  166. package/dist/components/actions/CopyMessages.d.ts.map +0 -1
  167. package/dist/components/actions/CopyMessages.js +0 -41
  168. package/dist/components/actions/CopyMessages.js.map +0 -1
  169. package/dist/components/actions/CopyMessages.module.css +0 -8
  170. package/dist/components/actions/JsonImport.d.ts +0 -5
  171. package/dist/components/actions/JsonImport.d.ts.map +0 -1
  172. package/dist/components/actions/JsonImport.js +0 -52
  173. package/dist/components/actions/JsonImport.js.map +0 -1
  174. package/dist/components/actions/JsonImport.module.css +0 -14
  175. package/dist/components/hooks/useMessagesFormSubmit.d.ts +0 -11
  176. package/dist/components/hooks/useMessagesFormSubmit.d.ts.map +0 -1
  177. package/dist/components/hooks/useMessagesFormSubmit.js +0 -44
  178. package/dist/components/hooks/useMessagesFormSubmit.js.map +0 -1
  179. package/dist/components/inputs/FieldWrapper.d.ts +0 -8
  180. package/dist/components/inputs/FieldWrapper.d.ts.map +0 -1
  181. package/dist/components/inputs/FieldWrapper.js +0 -24
  182. package/dist/components/inputs/FieldWrapper.js.map +0 -1
  183. package/dist/components/inputs/FieldWrapper.module.css +0 -24
  184. package/dist/components/inputs/LexicalInput.d.ts +0 -9
  185. package/dist/components/inputs/LexicalInput.d.ts.map +0 -1
  186. package/dist/components/inputs/LexicalInput.js +0 -26
  187. package/dist/components/inputs/LexicalInput.js.map +0 -1
  188. package/dist/components/inputs/MessageInput.d.ts +0 -14
  189. package/dist/components/inputs/MessageInput.d.ts.map +0 -1
  190. package/dist/components/inputs/MessageInput.js.map +0 -1
  191. package/dist/components/inputs/ReferencePopover.d.ts.map +0 -1
  192. package/dist/components/inputs/ReferencePopover.js.map +0 -1
  193. package/dist/components/inputs/SingleLinePlugin.d.ts.map +0 -1
  194. package/dist/components/inputs/SingleLinePlugin.js.map +0 -1
  195. package/dist/components/inputs/variables/VariableChip.d.ts.map +0 -1
  196. package/dist/components/inputs/variables/VariableChip.js.map +0 -1
  197. package/dist/components/inputs/variables/VariableIcon.d.ts.map +0 -1
  198. package/dist/components/inputs/variables/VariableIcon.js.map +0 -1
  199. package/dist/components/inputs/variables/VariableNode.d.ts.map +0 -1
  200. package/dist/components/inputs/variables/VariableNode.js.map +0 -1
  201. package/dist/components/inputs/variables/VariableSuggestion.d.ts.map +0 -1
  202. package/dist/components/inputs/variables/VariableSuggestion.js.map +0 -1
  203. package/dist/components/inputs/variables/editors/PluralVariableEditor.d.ts.map +0 -1
  204. package/dist/components/inputs/variables/editors/PluralVariableEditor.js.map +0 -1
  205. package/dist/components/inputs/variables/editors/SelectVariableEditor.d.ts.map +0 -1
  206. package/dist/components/inputs/variables/editors/SelectVariableEditor.js.map +0 -1
  207. package/dist/components/inputs/variables/editors/TagVariableEditor.d.ts.map +0 -1
  208. package/dist/components/inputs/variables/editors/TagVariableEditor.js.map +0 -1
  209. package/dist/components/inputs/variables/editors/TemporalVariableEditor.d.ts.map +0 -1
  210. package/dist/components/inputs/variables/editors/TemporalVariableEditor.js.map +0 -1
  211. package/dist/components/inputs/variables/pickers/NumericVariableEditor.d.ts.map +0 -1
  212. package/dist/components/inputs/variables/pickers/NumericVariableEditor.js.map +0 -1
  213. package/dist/components/inputs/variables/pickers/TemporalVariablePicker.d.ts.map +0 -1
  214. package/dist/components/inputs/variables/pickers/TemporalVariablePicker.js.map +0 -1
  215. package/dist/components/layout/GroupStatusDot.d.ts +0 -6
  216. package/dist/components/layout/GroupStatusDot.d.ts.map +0 -1
  217. package/dist/components/layout/GroupStatusDot.js +0 -24
  218. package/dist/components/layout/GroupStatusDot.js.map +0 -1
  219. package/dist/components/layout/StatusDot.d.ts +0 -7
  220. package/dist/components/layout/StatusDot.d.ts.map +0 -1
  221. package/dist/components/layout/StatusDot.js +0 -12
  222. package/dist/components/layout/StatusDot.js.map +0 -1
  223. package/dist/components/layout/StatusDot.module.css +0 -16
  224. package/dist/endpoints/set-messages.d.ts +0 -3
  225. package/dist/endpoints/set-messages.d.ts.map +0 -1
  226. package/dist/endpoints/set-messages.js +0 -105
  227. package/dist/endpoints/set-messages.js.map +0 -1
  228. package/dist/entities.d.ts +0 -5
  229. package/dist/entities.d.ts.map +0 -1
  230. package/dist/entities.js +0 -42
  231. package/dist/entities.js.map +0 -1
  232. package/dist/requests/fetchMessages.d.ts +0 -3
  233. package/dist/requests/fetchMessages.d.ts.map +0 -1
  234. package/dist/requests/fetchMessages.js +0 -40
  235. package/dist/requests/fetchMessages.js.map +0 -1
  236. package/dist/utils/config.d.ts.map +0 -1
  237. package/dist/utils/config.js.map +0 -1
  238. package/dist/utils/format.d.ts.map +0 -1
  239. package/dist/utils/format.js.map +0 -1
  240. package/dist/utils/guards.d.ts.map +0 -1
  241. package/dist/utils/guards.js.map +0 -1
  242. package/dist/utils/icu-tranform.d.ts.map +0 -1
  243. package/dist/utils/icu-tranform.js.map +0 -1
  244. package/dist/utils/validate.d.ts.map +0 -1
  245. package/dist/utils/validate.js.map +0 -1
  246. /package/dist/components/{inputs → input}/ReferencePopover.module.css +0 -0
  247. /package/dist/components/{inputs → input}/SingleLinePlugin.d.ts +0 -0
  248. /package/dist/components/{inputs → input}/SingleLinePlugin.js +0 -0
  249. /package/dist/components/{hooks → input}/useHtmlLexicalAdapter.d.ts +0 -0
  250. /package/dist/components/{hooks → input}/useHtmlLexicalAdapter.js +0 -0
  251. /package/dist/components/{inputs → input}/variables/VariableChip.d.ts +0 -0
  252. /package/dist/components/{inputs → input}/variables/VariableChip.module.css +0 -0
  253. /package/dist/components/{inputs → input}/variables/VariableIcon.d.ts +0 -0
  254. /package/dist/components/{inputs → input}/variables/VariableIcon.js +0 -0
  255. /package/dist/components/{inputs → input}/variables/VariableNode.d.ts +0 -0
  256. /package/dist/components/{inputs → input}/variables/VariableNode.js +0 -0
  257. /package/dist/components/{inputs → input}/variables/VariableSuggestion.d.ts +0 -0
  258. /package/dist/components/{inputs → input}/variables/VariableSuggestion.js +0 -0
  259. /package/dist/components/{inputs → input}/variables/VariableSuggestion.module.css +0 -0
  260. /package/dist/components/{inputs → input}/variables/editors/PluralVariableEditor.d.ts +0 -0
  261. /package/dist/components/{inputs → input}/variables/editors/PluralVariableEditor.module.css +0 -0
  262. /package/dist/components/{inputs → input}/variables/editors/SelectVariableEditor.d.ts +0 -0
  263. /package/dist/components/{inputs → input}/variables/editors/SelectVariableEditor.module.css +0 -0
  264. /package/dist/components/{inputs → input}/variables/editors/TagVariableEditor.d.ts +0 -0
  265. /package/dist/components/{inputs → input}/variables/editors/TagVariableEditor.module.css +0 -0
  266. /package/dist/components/{inputs → input}/variables/editors/TemporalVariableEditor.d.ts +0 -0
  267. /package/dist/components/{inputs → input}/variables/editors/TemporalVariableEditor.js +0 -0
  268. /package/dist/components/{inputs → input}/variables/pickers/NumericVariableEditor.d.ts +0 -0
  269. /package/dist/components/{inputs → input}/variables/pickers/NumericVariableEditor.module.css +0 -0
  270. /package/dist/components/{inputs → input}/variables/pickers/TemporalVariablePicker.d.ts +0 -0
  271. /package/dist/components/{inputs → input}/variables/pickers/TemporalVariablePicker.module.css +0 -0
  272. /package/dist/{utils/config.js → config.js} +0 -0
  273. /package/dist/{utils → icu}/guards.d.ts +0 -0
  274. /package/dist/{utils → icu}/guards.js +0 -0
  275. /package/dist/{utils → icu}/validate.d.ts +0 -0
  276. /package/dist/{utils → icu}/validate.js +0 -0
@@ -0,0 +1,26 @@
1
+ import type { BasePayload } from 'payload';
2
+ import type { Messages } from '../types';
3
+ interface PersistOptions {
4
+ readonly payload: BasePayload;
5
+ readonly collection: string;
6
+ readonly data: Messages;
7
+ readonly locale: string;
8
+ readonly existingFileId?: number | string;
9
+ }
10
+ /**
11
+ * Serializes messages to a JSON file and uploads it via Payload's
12
+ * `filePath` API. Creates a new document or updates an existing one.
13
+ */
14
+ export declare function persistDataToFile({ payload, collection, data, locale, existingFileId, }: PersistOptions): Promise<number | string>;
15
+ interface ReadOptions {
16
+ readonly payload: BasePayload;
17
+ readonly collection: string;
18
+ readonly fileId: number | string | undefined;
19
+ }
20
+ /**
21
+ * Reads and parses a JSON messages file from the upload collection's
22
+ * local filesystem path.
23
+ */
24
+ export declare function readDataFromFile({ payload, collection, fileId, }: ReadOptions): Promise<Messages>;
25
+ export {};
26
+ //# sourceMappingURL=file-storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-storage.d.ts","sourceRoot":"","sources":["../../src/utils/file-storage.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,SAAS,CAAC;AAE3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,UAAU,cAAc;IACtB,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3C;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,UAAU,EACV,IAAI,EACJ,MAAM,EACN,cAAc,GACf,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,CA6B3C;AAED,UAAU,WAAW;IACnB,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAC9C;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,OAAO,EACP,UAAU,EACV,MAAM,GACP,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAoBjC"}
@@ -0,0 +1,61 @@
1
+ import { readFile, unlink, writeFile } from 'node:fs/promises';
2
+ import os from 'node:os';
3
+ import path from 'node:path';
4
+ /**
5
+ * Serializes messages to a JSON file and uploads it via Payload's
6
+ * `filePath` API. Creates a new document or updates an existing one.
7
+ */ export async function persistDataToFile({ payload, collection, data, locale, existingFileId }) {
8
+ const jsonString = JSON.stringify(data, null, 2);
9
+ const tmpPath = path.join(os.tmpdir(), `intl-messages-${locale}-${Date.now()}.json`);
10
+ await writeFile(tmpPath, jsonString, 'utf-8');
11
+ try {
12
+ if (existingFileId) {
13
+ const doc = await payload.update({
14
+ collection: collection,
15
+ id: existingFileId,
16
+ data: {},
17
+ filePath: tmpPath
18
+ });
19
+ return doc.id;
20
+ }
21
+ const doc = await payload.create({
22
+ collection: collection,
23
+ data: {},
24
+ filePath: tmpPath
25
+ });
26
+ return doc.id;
27
+ } finally{
28
+ await unlink(tmpPath).catch(()=>{});
29
+ }
30
+ }
31
+ /**
32
+ * Reads and parses a JSON messages file from the upload collection's
33
+ * local filesystem path.
34
+ */ export async function readDataFromFile({ payload, collection, fileId }) {
35
+ if (!fileId) return {};
36
+ const uploadDoc = await payload.findByID({
37
+ collection: collection,
38
+ id: fileId,
39
+ depth: 0
40
+ });
41
+ const filename = uploadDoc.filename;
42
+ if (typeof filename !== 'string') return {};
43
+ const filePath = resolveUploadPath(payload, collection, filename);
44
+ try {
45
+ const content = await readFile(filePath, 'utf-8');
46
+ return JSON.parse(content);
47
+ } catch {
48
+ return {};
49
+ }
50
+ }
51
+ /** Resolves the absolute filesystem path for a file in an upload collection. */ function resolveUploadPath(payload, collectionSlug, filename) {
52
+ const collectionConfig = payload.config.collections.find((c)=>c.slug === collectionSlug);
53
+ let staticDir = collectionSlug;
54
+ if (typeof collectionConfig?.upload === 'object' && collectionConfig.upload.staticDir) {
55
+ staticDir = collectionConfig.upload.staticDir;
56
+ }
57
+ const resolvedDir = path.isAbsolute(staticDir) ? staticDir : path.resolve(process.cwd(), staticDir);
58
+ return path.join(resolvedDir, filename);
59
+ }
60
+
61
+ //# sourceMappingURL=file-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/file-storage.ts"],"sourcesContent":["import { readFile, unlink, writeFile } from 'node:fs/promises';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport type { BasePayload, CollectionSlug } from 'payload';\n\nimport type { Messages } from '../types';\n\ninterface PersistOptions {\n readonly payload: BasePayload;\n readonly collection: string;\n readonly data: Messages;\n readonly locale: string;\n readonly existingFileId?: number | string;\n}\n\n/**\n * Serializes messages to a JSON file and uploads it via Payload's\n * `filePath` API. Creates a new document or updates an existing one.\n */\nexport async function persistDataToFile({\n payload,\n collection,\n data,\n locale,\n existingFileId,\n}: PersistOptions): Promise<number | string> {\n const jsonString = JSON.stringify(data, null, 2);\n const tmpPath = path.join(\n os.tmpdir(),\n `intl-messages-${locale}-${Date.now()}.json`,\n );\n\n await writeFile(tmpPath, jsonString, 'utf-8');\n\n try {\n if (existingFileId) {\n const doc = await payload.update({\n collection: collection as CollectionSlug,\n id: existingFileId,\n data: {},\n filePath: tmpPath,\n });\n return doc.id;\n }\n\n const doc = await payload.create({\n collection: collection as CollectionSlug,\n data: {},\n filePath: tmpPath,\n });\n return doc.id;\n } finally {\n await unlink(tmpPath).catch(() => {});\n }\n}\n\ninterface ReadOptions {\n readonly payload: BasePayload;\n readonly collection: string;\n readonly fileId: number | string | undefined;\n}\n\n/**\n * Reads and parses a JSON messages file from the upload collection's\n * local filesystem path.\n */\nexport async function readDataFromFile({\n payload,\n collection,\n fileId,\n}: ReadOptions): Promise<Messages> {\n if (!fileId) return {};\n\n const uploadDoc = await payload.findByID({\n collection: collection as CollectionSlug,\n id: fileId,\n depth: 0,\n });\n\n const filename = (uploadDoc as unknown as Record<string, unknown>).filename;\n if (typeof filename !== 'string') return {};\n\n const filePath = resolveUploadPath(payload, collection, filename);\n\n try {\n const content = await readFile(filePath, 'utf-8');\n return JSON.parse(content) as Messages;\n } catch {\n return {};\n }\n}\n\n/** Resolves the absolute filesystem path for a file in an upload collection. */\nfunction resolveUploadPath(\n payload: BasePayload,\n collectionSlug: string,\n filename: string,\n): string {\n const collectionConfig = payload.config.collections.find(\n (c) => c.slug === collectionSlug,\n );\n\n let staticDir = collectionSlug;\n if (\n typeof collectionConfig?.upload === 'object' &&\n collectionConfig.upload.staticDir\n ) {\n staticDir = collectionConfig.upload.staticDir;\n }\n\n const resolvedDir = path.isAbsolute(staticDir)\n ? staticDir\n : path.resolve(process.cwd(), staticDir);\n\n return path.join(resolvedDir, filename);\n}\n"],"names":["readFile","unlink","writeFile","os","path","persistDataToFile","payload","collection","data","locale","existingFileId","jsonString","JSON","stringify","tmpPath","join","tmpdir","Date","now","doc","update","id","filePath","create","catch","readDataFromFile","fileId","uploadDoc","findByID","depth","filename","resolveUploadPath","content","parse","collectionSlug","collectionConfig","config","collections","find","c","slug","staticDir","upload","resolvedDir","isAbsolute","resolve","process","cwd"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,SAAS,QAAQ,mBAAmB;AAC/D,OAAOC,QAAQ,UAAU;AACzB,OAAOC,UAAU,YAAY;AAc7B;;;CAGC,GACD,OAAO,eAAeC,kBAAkB,EACtCC,OAAO,EACPC,UAAU,EACVC,IAAI,EACJC,MAAM,EACNC,cAAc,EACC;IACf,MAAMC,aAAaC,KAAKC,SAAS,CAACL,MAAM,MAAM;IAC9C,MAAMM,UAAUV,KAAKW,IAAI,CACvBZ,GAAGa,MAAM,IACT,CAAC,cAAc,EAAEP,OAAO,CAAC,EAAEQ,KAAKC,GAAG,GAAG,KAAK,CAAC;IAG9C,MAAMhB,UAAUY,SAASH,YAAY;IAErC,IAAI;QACF,IAAID,gBAAgB;YAClB,MAAMS,MAAM,MAAMb,QAAQc,MAAM,CAAC;gBAC/Bb,YAAYA;gBACZc,IAAIX;gBACJF,MAAM,CAAC;gBACPc,UAAUR;YACZ;YACA,OAAOK,IAAIE,EAAE;QACf;QAEA,MAAMF,MAAM,MAAMb,QAAQiB,MAAM,CAAC;YAC/BhB,YAAYA;YACZC,MAAM,CAAC;YACPc,UAAUR;QACZ;QACA,OAAOK,IAAIE,EAAE;IACf,SAAU;QACR,MAAMpB,OAAOa,SAASU,KAAK,CAAC,KAAO;IACrC;AACF;AAQA;;;CAGC,GACD,OAAO,eAAeC,iBAAiB,EACrCnB,OAAO,EACPC,UAAU,EACVmB,MAAM,EACM;IACZ,IAAI,CAACA,QAAQ,OAAO,CAAC;IAErB,MAAMC,YAAY,MAAMrB,QAAQsB,QAAQ,CAAC;QACvCrB,YAAYA;QACZc,IAAIK;QACJG,OAAO;IACT;IAEA,MAAMC,WAAW,AAACH,UAAiDG,QAAQ;IAC3E,IAAI,OAAOA,aAAa,UAAU,OAAO,CAAC;IAE1C,MAAMR,WAAWS,kBAAkBzB,SAASC,YAAYuB;IAExD,IAAI;QACF,MAAME,UAAU,MAAMhC,SAASsB,UAAU;QACzC,OAAOV,KAAKqB,KAAK,CAACD;IACpB,EAAE,OAAM;QACN,OAAO,CAAC;IACV;AACF;AAEA,8EAA8E,GAC9E,SAASD,kBACPzB,OAAoB,EACpB4B,cAAsB,EACtBJ,QAAgB;IAEhB,MAAMK,mBAAmB7B,QAAQ8B,MAAM,CAACC,WAAW,CAACC,IAAI,CACtD,CAACC,IAAMA,EAAEC,IAAI,KAAKN;IAGpB,IAAIO,YAAYP;IAChB,IACE,OAAOC,kBAAkBO,WAAW,YACpCP,iBAAiBO,MAAM,CAACD,SAAS,EACjC;QACAA,YAAYN,iBAAiBO,MAAM,CAACD,SAAS;IAC/C;IAEA,MAAME,cAAcvC,KAAKwC,UAAU,CAACH,aAChCA,YACArC,KAAKyC,OAAO,CAACC,QAAQC,GAAG,IAAIN;IAEhC,OAAOrC,KAAKW,IAAI,CAAC4B,aAAab;AAChC"}
@@ -1,4 +1,4 @@
1
- import type { DeepPartial, Messages } from '../types';
1
+ import type { Messages } from '../types';
2
2
  /**
3
3
  * Sanitize messages data to match the schema.
4
4
  * Stored messages might contain keys that are not in the config.
@@ -11,7 +11,9 @@ import type { DeepPartial, Messages } from '../types';
11
11
  * - Leaf missing/non-string + !useSchemaDefaults -> omitted
12
12
  * - Empty nested groups -> omitted (unless filled by defaults)
13
13
  */
14
- export declare function sanitizeMessages(config: Messages, data: unknown, { useSchemaDefaults }?: {
14
+ export declare function sanitizeMessages({ config, data, useSchemaDefaults, }: {
15
+ config: Messages;
16
+ data: unknown;
15
17
  useSchemaDefaults?: boolean;
16
- }): DeepPartial<Messages>;
18
+ }): Messages;
17
19
  //# sourceMappingURL=sanitize.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/utils/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAErD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,QAAQ,EAChB,IAAI,EAAE,OAAO,EACb,EAAE,iBAAyB,EAAE,GAAE;IAAE,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAO,GAClE,WAAW,CAAC,QAAQ,CAAC,CA2BvB"}
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/utils/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,QAAQ,EAAE,MAAM,SAAS,CAAC;AAErD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,IAAI,EACJ,iBAAyB,GAC1B,EAAE;IACD,MAAM,EAAE,QAAQ,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,GAAG,QAAQ,CA6BX"}
@@ -9,14 +9,16 @@
9
9
  * - Leaf missing/non-string + useSchemaDefaults -> schema value used
10
10
  * - Leaf missing/non-string + !useSchemaDefaults -> omitted
11
11
  * - Empty nested groups -> omitted (unless filled by defaults)
12
- */ export function sanitizeMessages(config, data, { useSchemaDefaults = false } = {}) {
12
+ */ export function sanitizeMessages({ config, data, useSchemaDefaults = false }) {
13
13
  const out = {};
14
14
  const src = isObj(data) ? data : {};
15
15
  for (const key of Object.keys(config)){
16
16
  const shapeVal = config[key];
17
17
  const srcVal = src[key];
18
18
  if (isObj(shapeVal)) {
19
- const child = sanitizeMessages(shapeVal, srcVal, {
19
+ const child = sanitizeMessages({
20
+ config: shapeVal,
21
+ data: srcVal,
20
22
  useSchemaDefaults
21
23
  });
22
24
  if (isObj(child) && Object.keys(child).length > 0) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/sanitize.ts"],"sourcesContent":["import type { DeepPartial, Messages } from '@/types';\n\n/**\n * Sanitize messages data to match the schema.\n * Stored messages might contain keys that are not in the config.\n * This happens when messages in the config were (re)moved.\n *\n * Keep exactly the keys from `shape`, fill values from `source` when present.\n * When `useSchemaDefaults` is true, missing leaves fall back to the schema value.\n * - Leaf present as string -> included\n * - Leaf missing/non-string + useSchemaDefaults -> schema value used\n * - Leaf missing/non-string + !useSchemaDefaults -> omitted\n * - Empty nested groups -> omitted (unless filled by defaults)\n */\nexport function sanitizeMessages(\n config: Messages,\n data: unknown,\n { useSchemaDefaults = false }: { useSchemaDefaults?: boolean } = {},\n): DeepPartial<Messages> {\n const out: Record<string, unknown> = {};\n const src = isObj(data) ? data : {};\n\n for (const key of Object.keys(config)) {\n const shapeVal = (config as Record<string, unknown>)[key];\n const srcVal = src[key];\n\n if (isObj(shapeVal)) {\n const child = sanitizeMessages(shapeVal as Messages, srcVal, {\n useSchemaDefaults,\n });\n if (isObj(child) && Object.keys(child).length > 0) {\n out[key] = child;\n }\n // else: omit empty group\n } else {\n // Leaf: keep source string, or fall back to schema value\n if (typeof srcVal === 'string') {\n out[key] = srcVal;\n } else if (useSchemaDefaults && typeof shapeVal === 'string') {\n out[key] = shapeVal;\n }\n }\n }\n\n return out as DeepPartial<Messages>;\n}\n\nfunction isObj(x: unknown): x is Record<string, unknown> {\n return !!x && typeof x === 'object' && !Array.isArray(x);\n}\n"],"names":["sanitizeMessages","config","data","useSchemaDefaults","out","src","isObj","key","Object","keys","shapeVal","srcVal","child","length","x","Array","isArray"],"mappings":"AAEA;;;;;;;;;;;CAWC,GACD,OAAO,SAASA,iBACdC,MAAgB,EAChBC,IAAa,EACb,EAAEC,oBAAoB,KAAK,EAAmC,GAAG,CAAC,CAAC;IAEnE,MAAMC,MAA+B,CAAC;IACtC,MAAMC,MAAMC,MAAMJ,QAAQA,OAAO,CAAC;IAElC,KAAK,MAAMK,OAAOC,OAAOC,IAAI,CAACR,QAAS;QACrC,MAAMS,WAAW,AAACT,MAAkC,CAACM,IAAI;QACzD,MAAMI,SAASN,GAAG,CAACE,IAAI;QAEvB,IAAID,MAAMI,WAAW;YACnB,MAAME,QAAQZ,iBAAiBU,UAAsBC,QAAQ;gBAC3DR;YACF;YACA,IAAIG,MAAMM,UAAUJ,OAAOC,IAAI,CAACG,OAAOC,MAAM,GAAG,GAAG;gBACjDT,GAAG,CAACG,IAAI,GAAGK;YACb;QACA,yBAAyB;QAC3B,OAAO;YACL,yDAAyD;YACzD,IAAI,OAAOD,WAAW,UAAU;gBAC9BP,GAAG,CAACG,IAAI,GAAGI;YACb,OAAO,IAAIR,qBAAqB,OAAOO,aAAa,UAAU;gBAC5DN,GAAG,CAACG,IAAI,GAAGG;YACb;QACF;IACF;IAEA,OAAON;AACT;AAEA,SAASE,MAAMQ,CAAU;IACvB,OAAO,CAAC,CAACA,KAAK,OAAOA,MAAM,YAAY,CAACC,MAAMC,OAAO,CAACF;AACxD"}
1
+ {"version":3,"sources":["../../src/utils/sanitize.ts"],"sourcesContent":["import type { DeepPartial, Messages } from '@/types';\n\n/**\n * Sanitize messages data to match the schema.\n * Stored messages might contain keys that are not in the config.\n * This happens when messages in the config were (re)moved.\n *\n * Keep exactly the keys from `shape`, fill values from `source` when present.\n * When `useSchemaDefaults` is true, missing leaves fall back to the schema value.\n * - Leaf present as string -> included\n * - Leaf missing/non-string + useSchemaDefaults -> schema value used\n * - Leaf missing/non-string + !useSchemaDefaults -> omitted\n * - Empty nested groups -> omitted (unless filled by defaults)\n */\nexport function sanitizeMessages({\n config,\n data,\n useSchemaDefaults = false,\n}: {\n config: Messages;\n data: unknown;\n useSchemaDefaults?: boolean;\n}): Messages {\n const out: Record<string, unknown> = {};\n const src = isObj(data) ? data : {};\n\n for (const key of Object.keys(config)) {\n const shapeVal = (config as Record<string, unknown>)[key];\n const srcVal = src[key];\n\n if (isObj(shapeVal)) {\n const child = sanitizeMessages({\n config: shapeVal as Messages,\n data: srcVal,\n useSchemaDefaults,\n });\n if (isObj(child) && Object.keys(child).length > 0) {\n out[key] = child;\n }\n // else: omit empty group\n } else {\n // Leaf: keep source string, or fall back to schema value\n if (typeof srcVal === 'string') {\n out[key] = srcVal;\n } else if (useSchemaDefaults && typeof shapeVal === 'string') {\n out[key] = shapeVal;\n }\n }\n }\n\n return out as Messages;\n}\n\nfunction isObj(x: unknown): x is Record<string, unknown> {\n return !!x && typeof x === 'object' && !Array.isArray(x);\n}\n"],"names":["sanitizeMessages","config","data","useSchemaDefaults","out","src","isObj","key","Object","keys","shapeVal","srcVal","child","length","x","Array","isArray"],"mappings":"AAEA;;;;;;;;;;;CAWC,GACD,OAAO,SAASA,iBAAiB,EAC/BC,MAAM,EACNC,IAAI,EACJC,oBAAoB,KAAK,EAK1B;IACC,MAAMC,MAA+B,CAAC;IACtC,MAAMC,MAAMC,MAAMJ,QAAQA,OAAO,CAAC;IAElC,KAAK,MAAMK,OAAOC,OAAOC,IAAI,CAACR,QAAS;QACrC,MAAMS,WAAW,AAACT,MAAkC,CAACM,IAAI;QACzD,MAAMI,SAASN,GAAG,CAACE,IAAI;QAEvB,IAAID,MAAMI,WAAW;YACnB,MAAME,QAAQZ,iBAAiB;gBAC7BC,QAAQS;gBACRR,MAAMS;gBACNR;YACF;YACA,IAAIG,MAAMM,UAAUJ,OAAOC,IAAI,CAACG,OAAOC,MAAM,GAAG,GAAG;gBACjDT,GAAG,CAACG,IAAI,GAAGK;YACb;QACA,yBAAyB;QAC3B,OAAO;YACL,yDAAyD;YACzD,IAAI,OAAOD,WAAW,UAAU;gBAC9BP,GAAG,CAACG,IAAI,GAAGI;YACb,OAAO,IAAIR,qBAAqB,OAAOO,aAAa,UAAU;gBAC5DN,GAAG,CAACG,IAAI,GAAGG;YACb;QACF;IACF;IAEA,OAAON;AACT;AAEA,SAASE,MAAMQ,CAAU;IACvB,OAAO,CAAC,CAACA,KAAK,OAAOA,MAAM,YAAY,CAACC,MAAMC,OAAO,CAACF;AACxD"}
@@ -1,8 +1,6 @@
1
- import type { MessageSchema, TemplateVariable } from '../types';
2
- export declare const parseMessageSchema: (schema: MessageSchema) => MessageConfig;
3
- export declare const extractTemplateVariables: (schema: MessageSchema) => TemplateVariable[];
4
- export type MessageConfig = {
5
- description: string | undefined;
6
- variables: TemplateVariable[];
7
- };
1
+ import type { JSONField } from 'payload';
2
+ import type { MessagesSchema } from '../types';
3
+ type Schema = NonNullable<JSONField['jsonSchema']>['schema'];
4
+ export declare function messagesToJsonSchema(messages: MessagesSchema): Schema;
5
+ export {};
8
6
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/utils/schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE/D,eAAO,MAAM,kBAAkB,WAAY,aAAa,KAAG,aAU1D,CAAC;AAEF,eAAO,MAAM,wBAAwB,WAC3B,aAAa,KACpB,gBAAgB,EAA6C,CAAC;AAgCjE,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,EAAE,gBAAgB,EAAE,CAAC;CAC/B,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/utils/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,KAAK,MAAM,GAAG,WAAW,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AAE7D,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAerE"}
@@ -1,43 +1,15 @@
1
- import { parse, TYPE } from '@formatjs/icu-messageformat-parser';
2
- export const parseMessageSchema = (schema)=>{
3
- const description = schema.match(/^\[.+\]/)?.[0];
4
- // TODO add support for variables description
5
- // const withoutDescription = schema.replace(description || "", "").trim();
6
- // const withoutOptional = withoutDescription.split(" | ")[0]?.trim();
1
+ export function messagesToJsonSchema(messages) {
2
+ const properties = {};
3
+ for (const [key, value] of Object.entries(messages)){
4
+ properties[key] = typeof value === 'string' ? {
5
+ type: 'string'
6
+ } : messagesToJsonSchema(value);
7
+ }
7
8
  return {
8
- description: description?.slice(1, -1),
9
- variables: extractTemplateVariables(schema)
9
+ type: 'object',
10
+ properties,
11
+ required: Object.keys(messages)
10
12
  };
11
- };
12
- export const extractTemplateVariables = (schema)=>collectTemplateVariables(parse(schema));
13
- const collectTemplateVariables = (parts)=>parts.flatMap((part)=>{
14
- switch(part.type){
15
- case TYPE.literal:
16
- case TYPE.pound:
17
- return [];
18
- case TYPE.argument:
19
- case TYPE.number:
20
- case TYPE.date:
21
- case TYPE.time:
22
- return [
23
- part
24
- ];
25
- case TYPE.plural:
26
- case TYPE.select:
27
- return [
28
- part,
29
- ...collectTemplateVariables(Object.values(part.options).flatMap(({ value })=>value))
30
- ];
31
- case TYPE.tag:
32
- return [
33
- part,
34
- ...collectTemplateVariables(part.children)
35
- ];
36
- default:
37
- return [
38
- part
39
- ];
40
- }
41
- });
13
+ }
42
14
 
43
15
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/schema.ts"],"sourcesContent":["import type { MessageFormatElement } from '@formatjs/icu-messageformat-parser';\nimport { parse, TYPE } from '@formatjs/icu-messageformat-parser';\nimport type { MessageSchema, TemplateVariable } from '@/types';\n\nexport const parseMessageSchema = (schema: MessageSchema): MessageConfig => {\n const description = schema.match(/^\\[.+\\]/)?.[0];\n // TODO add support for variables description\n // const withoutDescription = schema.replace(description || \"\", \"\").trim();\n // const withoutOptional = withoutDescription.split(\" | \")[0]?.trim();\n\n return {\n description: description?.slice(1, -1),\n variables: extractTemplateVariables(schema),\n };\n};\n\nexport const extractTemplateVariables = (\n schema: MessageSchema,\n): TemplateVariable[] => collectTemplateVariables(parse(schema));\n\nconst collectTemplateVariables = (\n parts: MessageFormatElement[],\n): TemplateVariable[] =>\n parts.flatMap<TemplateVariable>((part) => {\n switch (part.type) {\n case TYPE.literal:\n case TYPE.pound:\n return [];\n case TYPE.argument:\n case TYPE.number:\n case TYPE.date:\n case TYPE.time:\n return [part];\n case TYPE.plural:\n case TYPE.select:\n return [\n part,\n ...collectTemplateVariables(\n Object.values(part.options).flatMap(({ value }) => value),\n ),\n ];\n case TYPE.tag:\n return [part, ...collectTemplateVariables(part.children)];\n default:\n return [part];\n }\n });\n\n// MARK: Types\n\nexport type MessageConfig = {\n description: string | undefined;\n variables: TemplateVariable[];\n};\n"],"names":["parse","TYPE","parseMessageSchema","schema","description","match","slice","variables","extractTemplateVariables","collectTemplateVariables","parts","flatMap","part","type","literal","pound","argument","number","date","time","plural","select","Object","values","options","value","tag","children"],"mappings":"AACA,SAASA,KAAK,EAAEC,IAAI,QAAQ,qCAAqC;AAGjE,OAAO,MAAMC,qBAAqB,CAACC;IACjC,MAAMC,cAAcD,OAAOE,KAAK,CAAC,YAAY,CAAC,EAAE;IAChD,6CAA6C;IAC7C,2EAA2E;IAC3E,sEAAsE;IAEtE,OAAO;QACLD,aAAaA,aAAaE,MAAM,GAAG,CAAC;QACpCC,WAAWC,yBAAyBL;IACtC;AACF,EAAE;AAEF,OAAO,MAAMK,2BAA2B,CACtCL,SACuBM,yBAAyBT,MAAMG,SAAS;AAEjE,MAAMM,2BAA2B,CAC/BC,QAEAA,MAAMC,OAAO,CAAmB,CAACC;QAC/B,OAAQA,KAAKC,IAAI;YACf,KAAKZ,KAAKa,OAAO;YACjB,KAAKb,KAAKc,KAAK;gBACb,OAAO,EAAE;YACX,KAAKd,KAAKe,QAAQ;YAClB,KAAKf,KAAKgB,MAAM;YAChB,KAAKhB,KAAKiB,IAAI;YACd,KAAKjB,KAAKkB,IAAI;gBACZ,OAAO;oBAACP;iBAAK;YACf,KAAKX,KAAKmB,MAAM;YAChB,KAAKnB,KAAKoB,MAAM;gBACd,OAAO;oBACLT;uBACGH,yBACDa,OAAOC,MAAM,CAACX,KAAKY,OAAO,EAAEb,OAAO,CAAC,CAAC,EAAEc,KAAK,EAAE,GAAKA;iBAEtD;YACH,KAAKxB,KAAKyB,GAAG;gBACX,OAAO;oBAACd;uBAASH,yBAAyBG,KAAKe,QAAQ;iBAAE;YAC3D;gBACE,OAAO;oBAACf;iBAAK;QACjB;IACF"}
1
+ {"version":3,"sources":["../../src/utils/schema.ts"],"sourcesContent":["import type { JSONField } from 'payload';\nimport type { MessagesSchema } from '@/types';\n\ntype Schema = NonNullable<JSONField['jsonSchema']>['schema'];\n\nexport function messagesToJsonSchema(messages: MessagesSchema): Schema {\n const properties: Record<string, Schema | { type: 'string' }> = {};\n\n for (const [key, value] of Object.entries(messages)) {\n properties[key] =\n typeof value === 'string'\n ? { type: 'string' }\n : messagesToJsonSchema(value);\n }\n\n return {\n type: 'object',\n properties,\n required: Object.keys(messages),\n };\n}\n"],"names":["messagesToJsonSchema","messages","properties","key","value","Object","entries","type","required","keys"],"mappings":"AAKA,OAAO,SAASA,qBAAqBC,QAAwB;IAC3D,MAAMC,aAA0D,CAAC;IAEjE,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACL,UAAW;QACnDC,UAAU,CAACC,IAAI,GACb,OAAOC,UAAU,WACb;YAAEG,MAAM;QAAS,IACjBP,qBAAqBI;IAC7B;IAEA,OAAO;QACLG,MAAM;QACNL;QACAM,UAAUH,OAAOI,IAAI,CAACR;IACxB;AACF"}
@@ -0,0 +1,3 @@
1
+ import type { MessagesScopesConfig, ScopeConfig } from '../types';
2
+ export declare function normalizeScopes(scopes: MessagesScopesConfig | undefined): Map<string, ScopeConfig>;
3
+ //# sourceMappingURL=scopes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../../src/utils/scopes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAElE,wBAAgB,eAAe,CAC7B,MAAM,EAAE,oBAAoB,GAAG,SAAS,GACvC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAmB1B"}
@@ -0,0 +1,24 @@
1
+ export function normalizeScopes(scopes) {
2
+ const result = new Map();
3
+ if (!scopes) return result;
4
+ if (Array.isArray(scopes)) {
5
+ for (const slug of scopes){
6
+ result.set(slug, {
7
+ position: 'tab'
8
+ });
9
+ }
10
+ return result;
11
+ }
12
+ for (const [slug, config] of Object.entries(scopes)){
13
+ if (typeof config === 'string') {
14
+ result.set(slug, {
15
+ position: config
16
+ });
17
+ } else {
18
+ result.set(slug, config);
19
+ }
20
+ }
21
+ return result;
22
+ }
23
+
24
+ //# sourceMappingURL=scopes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/scopes.ts"],"sourcesContent":["import type { MessagesScopesConfig, ScopeConfig } from '../types';\n\nexport function normalizeScopes(\n scopes: MessagesScopesConfig | undefined,\n): Map<string, ScopeConfig> {\n const result = new Map<string, ScopeConfig>();\n if (!scopes) return result;\n\n if (Array.isArray(scopes)) {\n for (const slug of scopes) {\n result.set(slug, { position: 'tab' });\n }\n return result;\n }\n\n for (const [slug, config] of Object.entries(scopes)) {\n if (typeof config === 'string') {\n result.set(slug, { position: config });\n } else {\n result.set(slug, config);\n }\n }\n return result;\n}\n"],"names":["normalizeScopes","scopes","result","Map","Array","isArray","slug","set","position","config","Object","entries"],"mappings":"AAEA,OAAO,SAASA,gBACdC,MAAwC;IAExC,MAAMC,SAAS,IAAIC;IACnB,IAAI,CAACF,QAAQ,OAAOC;IAEpB,IAAIE,MAAMC,OAAO,CAACJ,SAAS;QACzB,KAAK,MAAMK,QAAQL,OAAQ;YACzBC,OAAOK,GAAG,CAACD,MAAM;gBAAEE,UAAU;YAAM;QACrC;QACA,OAAON;IACT;IAEA,KAAK,MAAM,CAACI,MAAMG,OAAO,IAAIC,OAAOC,OAAO,CAACV,QAAS;QACnD,IAAI,OAAOQ,WAAW,UAAU;YAC9BP,OAAOK,GAAG,CAACD,MAAM;gBAAEE,UAAUC;YAAO;QACtC,OAAO;YACLP,OAAOK,GAAG,CAACD,MAAMG;QACnB;IACF;IACA,OAAOP;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload-intl",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
4
4
  "description": "Payload Plugin for I18N using ICU Messages",
5
5
  "keywords": [
6
6
  "payload",
@@ -53,7 +53,7 @@
53
53
  "lodash-es": "^4.17.21",
54
54
  "react-hook-form": "^7.58.1",
55
55
  "zod": "4.3.5",
56
- "@davincicoding/payload-utils": "0.0.3"
56
+ "@davincicoding/payload-plugin-kit": "0.0.3"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@payloadcms/richtext-lexical": "3.72.0",
@@ -62,14 +62,14 @@
62
62
  "@types/node": "^22.5.4",
63
63
  "@types/react": "19.2.1",
64
64
  "@types/react-dom": "19.2.1",
65
+ "json-schema": "^0.4.0",
65
66
  "next": "15.5.9",
66
67
  "payload": "3.72.0",
67
68
  "react": "19.2.1",
68
69
  "react-dom": "19.2.1",
69
70
  "typescript": "5.7.3",
70
71
  "vite": "7.0.6",
71
- "vitest": "^3.1.2",
72
- "@davincicoding/payload-plugin-kit": "0.0.3"
72
+ "vitest": "^3.1.2"
73
73
  },
74
74
  "peerDependencies": {
75
75
  "@payloadcms/next": ">=3.72.0",
@@ -91,7 +91,7 @@
91
91
  "check:types": "tsc --noEmit",
92
92
  "clean": "rm -rf dist && rm -rf node_modules",
93
93
  "dev": "plugin-build --watch",
94
- "generate:types": "generate-types --opt storage=upload",
94
+ "generate:types": "generate-types --opt uploadCollection=uploads",
95
95
  "lint": "biome check .",
96
96
  "lint:fix": "biome check --write .",
97
97
  "test": "vitest run",
@@ -1,14 +0,0 @@
1
- import type { Locale, TemplateVariable } from '../types';
2
- import type { MessageValidator } from '../utils/validate';
3
- interface MessageFormFieldProps {
4
- locale: Locale;
5
- name: string;
6
- className?: string;
7
- variables: TemplateVariable[];
8
- validate: MessageValidator;
9
- multiline?: boolean;
10
- reference?: string;
11
- }
12
- export declare function MessageFormField({ name, variables, locale, validate, className, multiline, reference, }: MessageFormFieldProps): React.ReactNode;
13
- export {};
14
- //# sourceMappingURL=MessageFormField.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MessageFormField.d.ts","sourceRoot":"","sources":["../../src/components/MessageFormField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAIzD,UAAU,qBAAqB;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,IAAI,EACJ,SAAS,EACT,MAAM,EACN,QAAQ,EACR,SAAS,EACT,SAAS,EACT,SAAS,GACV,EAAE,qBAAqB,GAAG,KAAK,CAAC,SAAS,CA0BzC"}
@@ -1,28 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Controller } from 'react-hook-form';
3
- import { useMessagesForm } from '../components/MessagesFormProvider';
4
- import { MessageInput } from './inputs/MessageInput';
5
- export function MessageFormField({ name, variables, locale, validate, className, multiline, reference }) {
6
- const { control } = useMessagesForm();
7
- return /*#__PURE__*/ _jsx(Controller, {
8
- control: control,
9
- name: name,
10
- render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(MessageInput, {
11
- className: className,
12
- error: fieldState.error,
13
- lang: locale,
14
- multiline: multiline,
15
- onBlur: field.onBlur,
16
- onChange: field.onChange,
17
- reference: reference,
18
- value: field.value || '',
19
- variables: variables
20
- }),
21
- rules: {
22
- required: true,
23
- validate
24
- }
25
- });
26
- }
27
-
28
- //# sourceMappingURL=MessageFormField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/components/MessageFormField.tsx"],"sourcesContent":["import { Controller } from 'react-hook-form';\nimport { useMessagesForm } from '@/components/MessagesFormProvider';\nimport type { Locale, TemplateVariable } from '@/types';\nimport type { MessageValidator } from '@/utils/validate';\n\nimport { MessageInput } from './inputs/MessageInput';\n\ninterface MessageFormFieldProps {\n locale: Locale;\n name: string;\n className?: string;\n variables: TemplateVariable[];\n validate: MessageValidator;\n multiline?: boolean;\n reference?: string;\n}\n\nexport function MessageFormField({\n name,\n variables,\n locale,\n validate,\n className,\n multiline,\n reference,\n}: MessageFormFieldProps): React.ReactNode {\n const { control } = useMessagesForm();\n\n return (\n <Controller\n control={control}\n name={name}\n render={({ field, fieldState }) => (\n <MessageInput\n className={className}\n error={fieldState.error}\n lang={locale}\n multiline={multiline}\n onBlur={field.onBlur}\n onChange={field.onChange}\n reference={reference}\n value={(field.value as unknown as string) || ''}\n variables={variables}\n />\n )}\n rules={{\n required: true,\n validate,\n }}\n />\n );\n}\n"],"names":["Controller","useMessagesForm","MessageInput","MessageFormField","name","variables","locale","validate","className","multiline","reference","control","render","field","fieldState","error","lang","onBlur","onChange","value","rules","required"],"mappings":";AAAA,SAASA,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,eAAe,QAAQ,oCAAoC;AAIpE,SAASC,YAAY,QAAQ,wBAAwB;AAYrD,OAAO,SAASC,iBAAiB,EAC/BC,IAAI,EACJC,SAAS,EACTC,MAAM,EACNC,QAAQ,EACRC,SAAS,EACTC,SAAS,EACTC,SAAS,EACa;IACtB,MAAM,EAAEC,OAAO,EAAE,GAAGV;IAEpB,qBACE,KAACD;QACCW,SAASA;QACTP,MAAMA;QACNQ,QAAQ,CAAC,EAAEC,KAAK,EAAEC,UAAU,EAAE,iBAC5B,KAACZ;gBACCM,WAAWA;gBACXO,OAAOD,WAAWC,KAAK;gBACvBC,MAAMV;gBACNG,WAAWA;gBACXQ,QAAQJ,MAAMI,MAAM;gBACpBC,UAAUL,MAAMK,QAAQ;gBACxBR,WAAWA;gBACXS,OAAO,AAACN,MAAMM,KAAK,IAA0B;gBAC7Cd,WAAWA;;QAGfe,OAAO;YACLC,UAAU;YACVd;QACF;;AAGN"}
@@ -1,13 +0,0 @@
1
- import type { DeepPartial, Locale, Messages, MessagesSchema, Translations } from '../types';
2
- interface MessagesFormProps {
3
- locales: Locale[];
4
- defaultLocale: Locale;
5
- activeLocale: Locale;
6
- schema: MessagesSchema;
7
- tabs?: boolean;
8
- values: Translations<DeepPartial<Messages>>;
9
- endpointUrl: string;
10
- }
11
- export declare function MessagesForm({ locales, defaultLocale, activeLocale, schema, tabs, values, endpointUrl, }: MessagesFormProps): React.ReactNode;
12
- export {};
13
- //# sourceMappingURL=MessagesForm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MessagesForm.d.ts","sourceRoot":"","sources":["../../src/components/MessagesForm.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,QAAQ,EACR,cAAc,EACd,YAAY,EACb,MAAM,SAAS,CAAC;AAQjB,UAAU,iBAAiB;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,cAAc,CAAC;IACvB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC5C,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,aAAa,EACb,YAAY,EACZ,MAAM,EACN,IAAY,EACZ,MAAM,EACN,WAAW,GACZ,EAAE,iBAAiB,GAAG,KAAK,CAAC,SAAS,CAyFrC"}
@@ -1,120 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { Button, useStepNav } from '@payloadcms/ui';
4
- import { useEffect, useState } from 'react';
5
- import { useForm } from 'react-hook-form';
6
- import { MessagesFormProvider } from '../components/MessagesFormProvider';
7
- import { JsonImport } from './actions/JsonImport';
8
- import { useMessagesFormSubmit } from './hooks/useMessagesFormSubmit';
9
- import { MessageField } from './layout/MessageField';
10
- import { MessagesTabs } from './layout/MessagesTabs';
11
- import { MessagesTree } from './layout/MessagesTree';
12
- import styles from './MessagesForm.module.css';
13
- export function MessagesForm({ locales, defaultLocale, activeLocale, schema, tabs = false, values, endpointUrl }) {
14
- const { setStepNav } = useStepNav();
15
- useEffect(()=>{
16
- setStepNav([
17
- {
18
- label: 'Intl Messages',
19
- url: '/intl'
20
- }
21
- ]);
22
- }, [
23
- setStepNav
24
- ]);
25
- const form = useForm({
26
- defaultValues: values,
27
- reValidateMode: 'onBlur'
28
- });
29
- const [activeTab, setActiveTab] = useState(Object.keys(schema)[0]);
30
- useEffect(()=>{
31
- const handler = (e)=>{
32
- if (form.formState.isDirty) {
33
- e.preventDefault();
34
- }
35
- };
36
- window.addEventListener('beforeunload', handler);
37
- return ()=>window.removeEventListener('beforeunload', handler);
38
- }, [
39
- form
40
- ]);
41
- const handleSubmit = useMessagesFormSubmit({
42
- endpointUrl,
43
- defaultValues: values,
44
- form
45
- });
46
- return /*#__PURE__*/ _jsx(MessagesFormProvider, {
47
- activeLocale: activeLocale,
48
- defaultLocale: defaultLocale,
49
- form: form,
50
- locales: locales,
51
- children: /*#__PURE__*/ _jsxs("form", {
52
- className: styles.form,
53
- onSubmit: form.handleSubmit(handleSubmit),
54
- children: [
55
- /*#__PURE__*/ _jsxs("div", {
56
- className: styles.stickyHeader,
57
- children: [
58
- /*#__PURE__*/ _jsxs("header", {
59
- className: styles.header,
60
- children: [
61
- /*#__PURE__*/ _jsx("h1", {
62
- className: styles.title,
63
- children: "Messages"
64
- }),
65
- /*#__PURE__*/ _jsxs("div", {
66
- className: styles.actions,
67
- children: [
68
- /*#__PURE__*/ _jsx(JsonImport, {
69
- activeLocale: activeLocale
70
- }),
71
- /*#__PURE__*/ _jsx(Button, {
72
- className: styles.saveButton,
73
- disabled: !form.formState.isDirty,
74
- type: "submit",
75
- children: "Save"
76
- })
77
- ]
78
- })
79
- ]
80
- }),
81
- tabs && /*#__PURE__*/ _jsx(MessagesTabs, {
82
- activeTab: activeTab,
83
- schema: schema,
84
- setActiveTab: setActiveTab
85
- })
86
- ]
87
- }),
88
- /*#__PURE__*/ _jsxs("div", {
89
- className: styles.content,
90
- id: "messages-form-content",
91
- children: [
92
- !tabs && /*#__PURE__*/ _jsx(MessagesTree, {
93
- nestingLevel: 0,
94
- path: "",
95
- schema: schema
96
- }),
97
- tabs && Object.entries(schema).map(([key, value])=>{
98
- if (typeof value === 'string') {
99
- return /*#__PURE__*/ _jsx(MessageField, {
100
- hidden: activeTab !== key,
101
- messageKey: key,
102
- path: key,
103
- schema: value
104
- }, key);
105
- }
106
- return /*#__PURE__*/ _jsx(MessagesTree, {
107
- hidden: activeTab !== key,
108
- nestingLevel: 0,
109
- path: key,
110
- schema: value
111
- }, key);
112
- })
113
- ]
114
- })
115
- ]
116
- })
117
- });
118
- }
119
-
120
- //# sourceMappingURL=MessagesForm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/components/MessagesForm.tsx"],"sourcesContent":["'use client';\n\nimport { Button, useStepNav } from '@payloadcms/ui';\nimport { useEffect, useState } from 'react';\nimport { useForm } from 'react-hook-form';\nimport type { FormValues } from '@/components/MessagesFormProvider';\nimport { MessagesFormProvider } from '@/components/MessagesFormProvider';\nimport type {\n DeepPartial,\n Locale,\n Messages,\n MessagesSchema,\n Translations,\n} from '@/types';\nimport { JsonImport } from './actions/JsonImport';\nimport { useMessagesFormSubmit } from './hooks/useMessagesFormSubmit';\nimport { MessageField } from './layout/MessageField';\nimport { MessagesTabs } from './layout/MessagesTabs';\nimport { MessagesTree } from './layout/MessagesTree';\nimport styles from './MessagesForm.module.css';\n\ninterface MessagesFormProps {\n locales: Locale[];\n defaultLocale: Locale;\n activeLocale: Locale;\n schema: MessagesSchema;\n tabs?: boolean;\n values: Translations<DeepPartial<Messages>>;\n endpointUrl: string;\n}\n\nexport function MessagesForm({\n locales,\n defaultLocale,\n activeLocale,\n schema,\n tabs = false,\n values,\n endpointUrl,\n}: MessagesFormProps): React.ReactNode {\n const { setStepNav } = useStepNav();\n useEffect(() => {\n setStepNav([{ label: 'Intl Messages', url: '/intl' }]);\n }, [setStepNav]);\n\n const form = useForm<FormValues>({\n defaultValues: values,\n reValidateMode: 'onBlur',\n });\n const [activeTab, setActiveTab] = useState(Object.keys(schema)[0]);\n\n useEffect(() => {\n const handler = (e: BeforeUnloadEvent) => {\n if (form.formState.isDirty) {\n e.preventDefault();\n }\n };\n window.addEventListener('beforeunload', handler);\n return () => window.removeEventListener('beforeunload', handler);\n }, [form]);\n\n const handleSubmit = useMessagesFormSubmit({\n endpointUrl,\n defaultValues: values,\n form,\n });\n\n return (\n <MessagesFormProvider\n activeLocale={activeLocale}\n defaultLocale={defaultLocale}\n form={form}\n locales={locales}\n >\n <form className={styles.form} onSubmit={form.handleSubmit(handleSubmit)}>\n <div className={styles.stickyHeader}>\n <header className={styles.header}>\n <h1 className={styles.title}>Messages</h1>\n <div className={styles.actions}>\n <JsonImport activeLocale={activeLocale} />\n <Button\n className={styles.saveButton}\n disabled={!form.formState.isDirty}\n type=\"submit\"\n >\n Save\n </Button>\n </div>\n </header>\n\n {tabs && (\n <MessagesTabs\n activeTab={activeTab}\n schema={schema}\n setActiveTab={setActiveTab}\n />\n )}\n </div>\n\n <div className={styles.content} id=\"messages-form-content\">\n {!tabs && <MessagesTree nestingLevel={0} path=\"\" schema={schema} />}\n {tabs &&\n Object.entries(schema).map(([key, value]) => {\n if (typeof value === 'string') {\n return (\n <MessageField\n hidden={activeTab !== key}\n key={key}\n messageKey={key}\n path={key}\n schema={value}\n />\n );\n }\n return (\n <MessagesTree\n hidden={activeTab !== key}\n key={key}\n nestingLevel={0}\n path={key}\n schema={value}\n />\n );\n })}\n </div>\n </form>\n </MessagesFormProvider>\n );\n}\n"],"names":["Button","useStepNav","useEffect","useState","useForm","MessagesFormProvider","JsonImport","useMessagesFormSubmit","MessageField","MessagesTabs","MessagesTree","styles","MessagesForm","locales","defaultLocale","activeLocale","schema","tabs","values","endpointUrl","setStepNav","label","url","form","defaultValues","reValidateMode","activeTab","setActiveTab","Object","keys","handler","e","formState","isDirty","preventDefault","window","addEventListener","removeEventListener","handleSubmit","className","onSubmit","div","stickyHeader","header","h1","title","actions","saveButton","disabled","type","content","id","nestingLevel","path","entries","map","key","value","hidden","messageKey"],"mappings":"AAAA;;AAEA,SAASA,MAAM,EAAEC,UAAU,QAAQ,iBAAiB;AACpD,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAC5C,SAASC,OAAO,QAAQ,kBAAkB;AAE1C,SAASC,oBAAoB,QAAQ,oCAAoC;AAQzE,SAASC,UAAU,QAAQ,uBAAuB;AAClD,SAASC,qBAAqB,QAAQ,gCAAgC;AACtE,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,YAAY,QAAQ,wBAAwB;AACrD,OAAOC,YAAY,4BAA4B;AAY/C,OAAO,SAASC,aAAa,EAC3BC,OAAO,EACPC,aAAa,EACbC,YAAY,EACZC,MAAM,EACNC,OAAO,KAAK,EACZC,MAAM,EACNC,WAAW,EACO;IAClB,MAAM,EAAEC,UAAU,EAAE,GAAGnB;IACvBC,UAAU;QACRkB,WAAW;YAAC;gBAAEC,OAAO;gBAAiBC,KAAK;YAAQ;SAAE;IACvD,GAAG;QAACF;KAAW;IAEf,MAAMG,OAAOnB,QAAoB;QAC/BoB,eAAeN;QACfO,gBAAgB;IAClB;IACA,MAAM,CAACC,WAAWC,aAAa,GAAGxB,SAASyB,OAAOC,IAAI,CAACb,OAAO,CAAC,EAAE;IAEjEd,UAAU;QACR,MAAM4B,UAAU,CAACC;YACf,IAAIR,KAAKS,SAAS,CAACC,OAAO,EAAE;gBAC1BF,EAAEG,cAAc;YAClB;QACF;QACAC,OAAOC,gBAAgB,CAAC,gBAAgBN;QACxC,OAAO,IAAMK,OAAOE,mBAAmB,CAAC,gBAAgBP;IAC1D,GAAG;QAACP;KAAK;IAET,MAAMe,eAAe/B,sBAAsB;QACzCY;QACAK,eAAeN;QACfK;IACF;IAEA,qBACE,KAAClB;QACCU,cAAcA;QACdD,eAAeA;QACfS,MAAMA;QACNV,SAASA;kBAET,cAAA,MAACU;YAAKgB,WAAW5B,OAAOY,IAAI;YAAEiB,UAAUjB,KAAKe,YAAY,CAACA;;8BACxD,MAACG;oBAAIF,WAAW5B,OAAO+B,YAAY;;sCACjC,MAACC;4BAAOJ,WAAW5B,OAAOgC,MAAM;;8CAC9B,KAACC;oCAAGL,WAAW5B,OAAOkC,KAAK;8CAAE;;8CAC7B,MAACJ;oCAAIF,WAAW5B,OAAOmC,OAAO;;sDAC5B,KAACxC;4CAAWS,cAAcA;;sDAC1B,KAACf;4CACCuC,WAAW5B,OAAOoC,UAAU;4CAC5BC,UAAU,CAACzB,KAAKS,SAAS,CAACC,OAAO;4CACjCgB,MAAK;sDACN;;;;;;wBAMJhC,sBACC,KAACR;4BACCiB,WAAWA;4BACXV,QAAQA;4BACRW,cAAcA;;;;8BAKpB,MAACc;oBAAIF,WAAW5B,OAAOuC,OAAO;oBAAEC,IAAG;;wBAChC,CAAClC,sBAAQ,KAACP;4BAAa0C,cAAc;4BAAGC,MAAK;4BAAGrC,QAAQA;;wBACxDC,QACCW,OAAO0B,OAAO,CAACtC,QAAQuC,GAAG,CAAC,CAAC,CAACC,KAAKC,MAAM;4BACtC,IAAI,OAAOA,UAAU,UAAU;gCAC7B,qBACE,KAACjD;oCACCkD,QAAQhC,cAAc8B;oCAEtBG,YAAYH;oCACZH,MAAMG;oCACNxC,QAAQyC;mCAHHD;4BAMX;4BACA,qBACE,KAAC9C;gCACCgD,QAAQhC,cAAc8B;gCAEtBJ,cAAc;gCACdC,MAAMG;gCACNxC,QAAQyC;+BAHHD;wBAMX;;;;;;AAKZ"}
@@ -1,41 +0,0 @@
1
- .form {
2
- display: flex;
3
- height: calc(100vh - var(--app-header-height));
4
- flex-direction: column;
5
- }
6
-
7
- .stickyHeader {
8
- position: sticky;
9
- top: 0;
10
- z-index: 10;
11
- background-color: var(--theme-bg);
12
- }
13
-
14
- .header {
15
- margin-bottom: 1.5rem;
16
- display: flex;
17
- align-items: center;
18
- justify-content: space-between;
19
- gap: 1rem;
20
- }
21
-
22
- .title {
23
- font-size: var(--font-size-2xl);
24
- }
25
-
26
- .actions {
27
- display: flex;
28
- align-items: center;
29
- gap: 0.5rem;
30
- }
31
-
32
- .saveButton {
33
- margin-block: 0;
34
- }
35
-
36
- .content {
37
- min-height: 0;
38
- overflow-y: auto;
39
- padding-top: 2rem;
40
- padding-bottom: 4rem;
41
- }