payload-intl 0.3.0 → 1.0.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 (128) hide show
  1. package/README.md +5 -8
  2. package/dist/components/MessageController.d.ts +2 -1
  3. package/dist/components/MessageController.d.ts.map +1 -0
  4. package/dist/components/MessageController.js +5 -5
  5. package/dist/components/MessageController.js.map +1 -1
  6. package/dist/components/MessagesForm.d.ts +2 -1
  7. package/dist/components/MessagesForm.d.ts.map +1 -0
  8. package/dist/components/MessagesForm.js +28 -32
  9. package/dist/components/MessagesForm.js.map +1 -1
  10. package/dist/components/actions/JsonImport.d.ts +1 -0
  11. package/dist/components/actions/JsonImport.d.ts.map +1 -0
  12. package/dist/components/actions/JsonImport.js +4 -4
  13. package/dist/components/actions/JsonImport.js.map +1 -1
  14. package/dist/components/actions/Move.d.ts +2 -3
  15. package/dist/components/actions/Move.d.ts.map +1 -0
  16. package/dist/components/inputs/InputWrapper.d.ts +1 -0
  17. package/dist/components/inputs/InputWrapper.d.ts.map +1 -0
  18. package/dist/components/inputs/InputWrapper.js.map +1 -1
  19. package/dist/components/inputs/LexicalInput.d.ts +1 -0
  20. package/dist/components/inputs/LexicalInput.d.ts.map +1 -0
  21. package/dist/components/inputs/MessageInput.d.ts +2 -1
  22. package/dist/components/inputs/MessageInput.d.ts.map +1 -0
  23. package/dist/components/inputs/MessageInput.js +1 -1
  24. package/dist/components/inputs/MessageInput.js.map +1 -1
  25. package/dist/components/inputs/variables/VariableChip.d.ts +1 -0
  26. package/dist/components/inputs/variables/VariableChip.d.ts.map +1 -0
  27. package/dist/components/inputs/variables/VariableChip.js +3 -3
  28. package/dist/components/inputs/variables/VariableChip.js.map +1 -1
  29. package/dist/components/inputs/variables/VariableIcon.d.ts +3 -2
  30. package/dist/components/inputs/variables/VariableIcon.d.ts.map +1 -0
  31. package/dist/components/inputs/variables/VariableSuggestion.d.ts +2 -1
  32. package/dist/components/inputs/variables/VariableSuggestion.d.ts.map +1 -0
  33. package/dist/components/inputs/variables/VariableSuggestion.js +2 -2
  34. package/dist/components/inputs/variables/VariableSuggestion.js.map +1 -1
  35. package/dist/components/inputs/variables/editors/DateVariableEditor.d.ts +2 -1
  36. package/dist/components/inputs/variables/editors/DateVariableEditor.d.ts.map +1 -0
  37. package/dist/components/inputs/variables/editors/PluralVariableEditor.d.ts +2 -1
  38. package/dist/components/inputs/variables/editors/PluralVariableEditor.d.ts.map +1 -0
  39. package/dist/components/inputs/variables/editors/PluralVariableEditor.js +31 -34
  40. package/dist/components/inputs/variables/editors/PluralVariableEditor.js.map +1 -1
  41. package/dist/components/inputs/variables/editors/SelectVariableEditor.d.ts +2 -1
  42. package/dist/components/inputs/variables/editors/SelectVariableEditor.d.ts.map +1 -0
  43. package/dist/components/inputs/variables/editors/SelectVariableEditor.js +17 -10
  44. package/dist/components/inputs/variables/editors/SelectVariableEditor.js.map +1 -1
  45. package/dist/components/inputs/variables/editors/TagVariableEditor.d.ts +2 -1
  46. package/dist/components/inputs/variables/editors/TagVariableEditor.d.ts.map +1 -0
  47. package/dist/components/inputs/variables/editors/TagVariableEditor.js.map +1 -1
  48. package/dist/components/inputs/variables/editors/TimeVariableEditor.d.ts +2 -1
  49. package/dist/components/inputs/variables/editors/TimeVariableEditor.d.ts.map +1 -0
  50. package/dist/components/inputs/variables/extension.d.ts +2 -1
  51. package/dist/components/inputs/variables/extension.d.ts.map +1 -0
  52. package/dist/components/inputs/variables/extension.js.map +1 -1
  53. package/dist/components/inputs/variables/pickers/NumericVariablePicker.d.ts +2 -1
  54. package/dist/components/inputs/variables/pickers/NumericVariablePicker.d.ts.map +1 -0
  55. package/dist/components/inputs/variables/pickers/NumericVariablePicker.js +4 -4
  56. package/dist/components/inputs/variables/pickers/NumericVariablePicker.js.map +1 -1
  57. package/dist/components/inputs/variables/pickers/TemporalElementEditor.d.ts +2 -1
  58. package/dist/components/inputs/variables/pickers/TemporalElementEditor.d.ts.map +1 -0
  59. package/dist/components/layout/MessageField.d.ts +2 -1
  60. package/dist/components/layout/MessageField.d.ts.map +1 -0
  61. package/dist/components/layout/MessageField.js +6 -6
  62. package/dist/components/layout/MessageField.js.map +1 -1
  63. package/dist/components/layout/MessagesTabs.d.ts +2 -1
  64. package/dist/components/layout/MessagesTabs.d.ts.map +1 -0
  65. package/dist/components/layout/MessagesTabs.js +3 -3
  66. package/dist/components/layout/MessagesTabs.js.map +1 -1
  67. package/dist/components/layout/MessagesTree.d.ts +2 -1
  68. package/dist/components/layout/MessagesTree.d.ts.map +1 -0
  69. package/dist/components/layout/MessagesTree.js +2 -2
  70. package/dist/components/layout/MessagesTree.js.map +1 -1
  71. package/dist/context/messages-form.d.ts +2 -1
  72. package/dist/context/messages-form.d.ts.map +1 -0
  73. package/dist/context/messages-form.js.map +1 -1
  74. package/dist/endpoints/get-messages.d.ts +1 -0
  75. package/dist/endpoints/get-messages.d.ts.map +1 -0
  76. package/dist/endpoints/get-messages.js.map +1 -1
  77. package/dist/endpoints/set-messages.d.ts +1 -0
  78. package/dist/endpoints/set-messages.d.ts.map +1 -0
  79. package/dist/endpoints/set-messages.js.map +1 -1
  80. package/dist/exports/link.d.ts +2 -1
  81. package/dist/exports/link.d.ts.map +1 -0
  82. package/dist/exports/link.js.map +1 -1
  83. package/dist/exports/rsc.d.ts +1 -0
  84. package/dist/exports/rsc.d.ts.map +1 -0
  85. package/dist/exports/view.d.ts +2 -1
  86. package/dist/exports/view.d.ts.map +1 -0
  87. package/dist/exports/view.js +26 -30
  88. package/dist/exports/view.js.map +1 -1
  89. package/dist/index.d.ts +2 -1
  90. package/dist/index.d.ts.map +1 -0
  91. package/dist/index.js +19 -34
  92. package/dist/index.js.map +1 -1
  93. package/dist/requests/fetchMessages.d.ts +1 -0
  94. package/dist/requests/fetchMessages.d.ts.map +1 -0
  95. package/dist/requests/fetchMessages.js.map +1 -1
  96. package/dist/styles.css +1 -1
  97. package/dist/types.d.ts +5 -4
  98. package/dist/types.d.ts.map +1 -0
  99. package/dist/utils/cn.d.ts +1 -0
  100. package/dist/utils/cn.d.ts.map +1 -0
  101. package/dist/utils/cn.js.map +1 -1
  102. package/dist/utils/config.d.ts +2 -1
  103. package/dist/utils/config.d.ts.map +1 -0
  104. package/dist/utils/config.js.map +1 -1
  105. package/dist/utils/error-handling.d.ts +1 -0
  106. package/dist/utils/error-handling.d.ts.map +1 -0
  107. package/dist/utils/error-handling.js.map +1 -1
  108. package/dist/utils/format.d.ts +2 -1
  109. package/dist/utils/format.d.ts.map +1 -0
  110. package/dist/utils/format.js.map +1 -1
  111. package/dist/utils/guards.d.ts +2 -0
  112. package/dist/utils/guards.d.ts.map +1 -0
  113. package/dist/utils/guards.js +14 -11
  114. package/dist/utils/guards.js.map +1 -1
  115. package/dist/utils/icu-tranform.d.ts +6 -5
  116. package/dist/utils/icu-tranform.d.ts.map +1 -0
  117. package/dist/utils/icu-tranform.js +32 -27
  118. package/dist/utils/icu-tranform.js.map +1 -1
  119. package/dist/utils/sanitize.d.ts +2 -1
  120. package/dist/utils/sanitize.d.ts.map +1 -0
  121. package/dist/utils/sanitize.js.map +1 -1
  122. package/dist/utils/schema.d.ts +3 -2
  123. package/dist/utils/schema.d.ts.map +1 -0
  124. package/dist/utils/schema.js.map +1 -1
  125. package/dist/utils/validate.d.ts +2 -1
  126. package/dist/utils/validate.d.ts.map +1 -0
  127. package/dist/utils/validate.js.map +1 -1
  128. package/package.json +57 -72
package/README.md CHANGED
@@ -108,13 +108,13 @@ The `intlPlugin` accepts the following configuration:
108
108
  | `hooks` | - | Collection hooks with and additional `afterUpdate` hook |
109
109
  | `tabs` | - | Enable tabbed interface |
110
110
 
111
- ## Storage Adapter Requirements
111
+ <!-- ## Storage Adapter Requirements
112
112
 
113
113
  The plugin creates a "messages" upload collection that stores translations as JSON files.
114
114
 
115
- You must ensure that the storage provider returns the direct URL to the uploaded files and read access is guaranteed.
115
+ You must ensure that the storage provider returns the direct URL to the uploaded files and read access is guaranteed. -->
116
116
 
117
- ## Message Schema Definition
117
+ <!-- ## Message Schema Definition
118
118
 
119
119
  ### Message Descriptions
120
120
 
@@ -128,7 +128,7 @@ export default {
128
128
  "[Subtitle with user's name and message count] Welcome back, {firstName}! You have {count} new messages.",
129
129
  },
130
130
  } as const;
131
- ```
131
+ ``` -->
132
132
 
133
133
  <!-- ### Rich Text Messages
134
134
 
@@ -165,16 +165,13 @@ export default buildConfig({
165
165
  intlPlugin({
166
166
  schema: messages,
167
167
  hooks: {
168
- afterUpdate: () => revalidateTag("messages"),
168
+ afterUpdate: () => revalidateTag("messages"), // or anything else you want
169
169
  },
170
170
  }),
171
171
  s3Storage({
172
172
  collections: {
173
173
  messages: {
174
174
  prefix: "messages", // or anything else you want
175
- // generate a publicly available URL to the file
176
- generateFileURL: async ({ filename, prefix }) =>
177
- `.../${prefix}/${filename}`,
178
175
  },
179
176
  },
180
177
  }),
@@ -1,4 +1,4 @@
1
- import { TemplateVariable } from '../types.ts';
1
+ import { TemplateVariable } from '../types';
2
2
  import { MessageType } from '../utils/schema';
3
3
  import { MessageValidator } from '../utils/validate';
4
4
  interface MessageControllerProps {
@@ -12,3 +12,4 @@ interface MessageControllerProps {
12
12
  }
13
13
  export declare function MessageController({ type, name, variables, label, locale, validate, className, }: MessageControllerProps): React.ReactNode;
14
14
  export {};
15
+ //# sourceMappingURL=MessageController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessageController.d.ts","sourceRoot":"","sources":["../../src/components/MessageController.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAIzD,UAAU,sBAAsB;IAC9B,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,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;CAC5B;AAED,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,KAAK,EACL,MAAM,EACN,QAAQ,EACR,SAAS,GACV,EAAE,sBAAsB,GAAG,KAAK,CAAC,SAAS,CAgD1C"}
@@ -20,14 +20,14 @@ function v({
20
20
  render: ({ field: r, fieldState: a }) => /* @__PURE__ */ o(
21
21
  i,
22
22
  {
23
- label: t,
24
- lang: s,
25
23
  className: l,
26
- value: r.value || "",
27
- variables: n,
28
24
  error: a.error,
25
+ label: t,
26
+ lang: s,
27
+ onBlur: r.onBlur,
29
28
  onChange: r.onChange,
30
- onBlur: r.onBlur
29
+ value: r.value || "",
30
+ variables: n
31
31
  }
32
32
  ),
33
33
  rules: {
@@ -1 +1 @@
1
- {"version":3,"file":"MessageController.js","sources":["../../src/components/MessageController.tsx"],"sourcesContent":["import type { TemplateVariable } from \"@/types\";\nimport type { MessageType } from \"@/utils/schema\";\nimport type { MessageValidator } from \"@/utils/validate\";\nimport { Controller } from \"react-hook-form\";\n\nimport { useMessagesForm } from \"@/context/messages-form\";\n\nimport { MessageInput } from \"./inputs/MessageInput\";\n\ninterface MessageControllerProps {\n type: MessageType;\n label?: string;\n locale: string;\n name: string;\n className?: string;\n variables: TemplateVariable[];\n validate: MessageValidator;\n}\n\nexport function MessageController({\n type,\n name,\n variables,\n label,\n locale,\n validate,\n className,\n}: MessageControllerProps): React.ReactNode {\n const { control } = useMessagesForm();\n\n // if (type === \"rich\") {\n // return (\n // <Controller\n // control={control}\n // name={name}\n // render={({ field, fieldState }) => (\n // <LexicalInput\n // className={className}\n // error={fieldState.error}\n // label={label}\n // lang={locale}\n // onChange={field.onChange}\n // onBlur={field.onBlur}\n // value={(field.value as unknown as string) || \"\"}\n // />\n // )}\n // rules={{\n // required: true,\n // }}\n // />\n // );\n // }\n\n return (\n <Controller\n control={control}\n name={name}\n render={({ field, fieldState }) => (\n <MessageInput\n label={label}\n lang={locale}\n className={className}\n value={(field.value as unknown as string) || \"\"}\n variables={variables}\n error={fieldState.error}\n onChange={field.onChange}\n onBlur={field.onBlur}\n />\n )}\n rules={{\n required: true,\n validate,\n }}\n />\n );\n}\n"],"names":["MessageController","type","name","variables","label","locale","validate","className","control","useMessagesForm","jsx","Controller","field","fieldState","MessageInput"],"mappings":";;;;AAmBO,SAASA,EAAkB;AAAA,EAChC,MAAAC;AAAA,EACA,MAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AACF,GAA4C;AAC1C,QAAM,EAAE,SAAAC,EAAA,IAAYC,EAAA;AAyBpB,SACE,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,SAAAH;AAAA,MACA,MAAAN;AAAA,MACA,QAAQ,CAAC,EAAE,OAAAU,GAAO,YAAAC,QAChB,gBAAAH;AAAA,QAACI;AAAA,QAAA;AAAA,UACC,OAAAV;AAAA,UACA,MAAMC;AAAA,UACN,WAAAE;AAAA,UACA,OAAQK,EAAM,SAA+B;AAAA,UAC7C,WAAAT;AAAA,UACA,OAAOU,EAAW;AAAA,UAClB,UAAUD,EAAM;AAAA,UAChB,QAAQA,EAAM;AAAA,QAAA;AAAA,MAAA;AAAA,MAGlB,OAAO;AAAA,QACL,UAAU;AAAA,QACV,UAAAN;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"MessageController.js","sources":["../../src/components/MessageController.tsx"],"sourcesContent":["import { Controller } from 'react-hook-form';\nimport { useMessagesForm } from '@/context/messages-form';\nimport type { TemplateVariable } from '@/types';\nimport type { MessageType } from '@/utils/schema';\nimport type { MessageValidator } from '@/utils/validate';\n\nimport { MessageInput } from './inputs/MessageInput';\n\ninterface MessageControllerProps {\n type: MessageType;\n label?: string;\n locale: string;\n name: string;\n className?: string;\n variables: TemplateVariable[];\n validate: MessageValidator;\n}\n\nexport function MessageController({\n type,\n name,\n variables,\n label,\n locale,\n validate,\n className,\n}: MessageControllerProps): React.ReactNode {\n const { control } = useMessagesForm();\n\n // if (type === \"rich\") {\n // return (\n // <Controller\n // control={control}\n // name={name}\n // render={({ field, fieldState }) => (\n // <LexicalInput\n // className={className}\n // error={fieldState.error}\n // label={label}\n // lang={locale}\n // onChange={field.onChange}\n // onBlur={field.onBlur}\n // value={(field.value as unknown as string) || \"\"}\n // />\n // )}\n // rules={{\n // required: true,\n // }}\n // />\n // );\n // }\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 label={label}\n lang={locale}\n onBlur={field.onBlur}\n onChange={field.onChange}\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":["MessageController","type","name","variables","label","locale","validate","className","control","useMessagesForm","jsx","Controller","field","fieldState","MessageInput"],"mappings":";;;;AAkBO,SAASA,EAAkB;AAAA,EAChC,MAAAC;AAAA,EACA,MAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AACF,GAA4C;AAC1C,QAAM,EAAE,SAAAC,EAAA,IAAYC,EAAA;AAyBpB,SACE,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,SAAAH;AAAA,MACA,MAAAN;AAAA,MACA,QAAQ,CAAC,EAAE,OAAAU,GAAO,YAAAC,QAChB,gBAAAH;AAAA,QAACI;AAAA,QAAA;AAAA,UACC,WAAAP;AAAA,UACA,OAAOM,EAAW;AAAA,UAClB,OAAAT;AAAA,UACA,MAAMC;AAAA,UACN,QAAQO,EAAM;AAAA,UACd,UAAUA,EAAM;AAAA,UAChB,OAAQA,EAAM,SAA+B;AAAA,UAC7C,WAAAT;AAAA,QAAA;AAAA,MAAA;AAAA,MAGJ,OAAO;AAAA,QACL,UAAU;AAAA,QACV,UAAAG;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN;"}
@@ -1,4 +1,4 @@
1
- import { DeepPartial, Locales, Messages, MessagesSchema, Translations } from '../types.ts';
1
+ import { DeepPartial, Locales, Messages, MessagesSchema, Translations } from '../types';
2
2
  interface MessagesFormProps {
3
3
  locales: Locales;
4
4
  schema: MessagesSchema;
@@ -8,3 +8,4 @@ interface MessagesFormProps {
8
8
  }
9
9
  export declare function MessagesForm({ locales, schema, tabs, values, endpointUrl, }: MessagesFormProps): React.ReactNode;
10
10
  export {};
11
+ //# sourceMappingURL=MessagesForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessagesForm.d.ts","sourceRoot":"","sources":["../../src/components/MessagesForm.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,WAAW,EACX,OAAO,EACP,QAAQ,EACR,cAAc,EACd,YAAY,EACb,MAAM,SAAS,CAAC;AAQjB,UAAU,iBAAiB;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,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,MAAM,EACN,IAAY,EACZ,MAAM,EACN,WAAW,GACZ,EAAE,iBAAiB,GAAG,KAAK,CAAC,SAAS,CA6GrC"}
@@ -1,18 +1,17 @@
1
1
  "use client";
2
- import { jsx as s, jsxs as o } from "react/jsx-runtime";
3
- import { useStepNav as x, Button as M } from "@payloadcms/ui";
2
+ import { jsx as t, jsxs as o } from "react/jsx-runtime";
3
+ import { useStepNav as x, Button as M, toast as d } from "@payloadcms/ui";
4
4
  import { isEqual as y } from "lodash-es";
5
5
  import { useEffect as j, useState as w } from "react";
6
6
  import { useForm as T } from "react-hook-form";
7
- import { toast as d } from "sonner";
8
7
  import { MessagesFormProvider as E } from "../context/messages-form.js";
9
- import { cn as h } from "../utils/cn.js";
8
+ import { cn as p } from "../utils/cn.js";
10
9
  import { getErrorMessage as F } from "../utils/error-handling.js";
11
10
  import { JsonImport as C } from "./actions/JsonImport.js";
12
11
  import { MessageField as O } from "./layout/MessageField.js";
13
12
  import { MessagesTabs as I } from "./layout/MessagesTabs.js";
14
13
  import { MessagesTree as g } from "./layout/MessagesTree.js";
15
- function Q({
14
+ function H({
16
15
  locales: u,
17
16
  schema: a,
18
17
  tabs: m = !1,
@@ -27,31 +26,28 @@ function Q({
27
26
  defaultValues: l,
28
27
  reValidateMode: "onChange"
29
28
  }), [c, v] = w(Object.keys(a)[0]), N = async (e) => {
30
- const r = d.loading("Saving..."), S = Object.entries(e).reduce((t, [n, p]) => y(p, l[n]) ? t : {
31
- ...t,
32
- [n]: p
33
- }, {});
29
+ const r = d.loading("Saving..."), S = Object.entries(e).reduce((s, [n, h]) => (y(h, l[n]) || (s[n] = h), s), {});
34
30
  try {
35
- const t = await fetch(b, {
31
+ const s = await fetch(b, {
36
32
  method: "PUT",
37
33
  headers: {
38
34
  "Content-Type": "application/json"
39
35
  },
40
36
  body: JSON.stringify(S)
41
37
  });
42
- if (!t.ok) {
43
- const n = await F(t);
38
+ if (!s.ok) {
39
+ const n = await F(s);
44
40
  throw new Error(n);
45
41
  }
46
42
  i.reset(e), d.success("Saved", { id: r });
47
- } catch (t) {
43
+ } catch (s) {
48
44
  d.error(
49
- `Failed to save: ${t instanceof Error ? t.message : "Unknown error"}`,
45
+ `Failed to save: ${s instanceof Error ? s.message : "Unknown error"}`,
50
46
  { id: r }
51
47
  );
52
48
  }
53
49
  };
54
- return /* @__PURE__ */ s(E, { form: i, locales: u, children: /* @__PURE__ */ o(
50
+ return /* @__PURE__ */ t(E, { form: i, locales: u, children: /* @__PURE__ */ o(
55
51
  "form",
56
52
  {
57
53
  className: "flex h-[calc(100vh-var(--app-header-height))] flex-col",
@@ -59,25 +55,25 @@ function Q({
59
55
  children: [
60
56
  /* @__PURE__ */ o("div", { className: "sticky top-0 z-10 bg-background", children: [
61
57
  /* @__PURE__ */ o("header", { className: "mb-6 flex items-center justify-between gap-4", children: [
62
- /* @__PURE__ */ s("h1", { className: "text-4xl", children: "Messages" }),
58
+ /* @__PURE__ */ t("h1", { className: "text-4xl", children: "Messages" }),
63
59
  /* @__PURE__ */ o("div", { className: "flex items-center gap-2", children: [
64
- /* @__PURE__ */ s(C, {}),
65
- /* @__PURE__ */ s(
60
+ /* @__PURE__ */ t(C, {}),
61
+ /* @__PURE__ */ t(
66
62
  M,
67
63
  {
68
64
  className: "my-0",
69
- type: "submit",
70
65
  disabled: !i.formState.isDirty,
66
+ type: "submit",
71
67
  children: "Save"
72
68
  }
73
69
  )
74
70
  ] })
75
71
  ] }),
76
- m && /* @__PURE__ */ s(
72
+ m && /* @__PURE__ */ t(
77
73
  I,
78
74
  {
79
- schema: a,
80
75
  activeTab: c,
76
+ schema: a,
81
77
  setActiveTab: v
82
78
  }
83
79
  )
@@ -85,26 +81,26 @@ function Q({
85
81
  /* @__PURE__ */ o(
86
82
  "div",
87
83
  {
88
- id: "messages-form-content",
89
84
  className: "min-h-0 overflow-y-auto pt-8 pb-16",
85
+ id: "messages-form-content",
90
86
  children: [
91
- !m && /* @__PURE__ */ s(g, { path: "", schema: a, nestingLevel: 0 }),
92
- m && Object.entries(a).map(([e, r]) => typeof r == "string" ? /* @__PURE__ */ s(
87
+ !m && /* @__PURE__ */ t(g, { nestingLevel: 0, path: "", schema: a }),
88
+ m && Object.entries(a).map(([e, r]) => typeof r == "string" ? /* @__PURE__ */ t(
93
89
  O,
94
90
  {
95
- schema: r,
96
- className: h({ hidden: c !== e }),
91
+ className: p({ hidden: c !== e }),
97
92
  messageKey: e,
98
- path: e
93
+ path: e,
94
+ schema: r
99
95
  },
100
96
  e
101
- ) : /* @__PURE__ */ s(
97
+ ) : /* @__PURE__ */ t(
102
98
  g,
103
99
  {
104
- className: h({ hidden: c !== e }),
100
+ className: p({ hidden: c !== e }),
101
+ nestingLevel: 0,
105
102
  path: e,
106
- schema: r,
107
- nestingLevel: 0
103
+ schema: r
108
104
  },
109
105
  e
110
106
  ))
@@ -116,6 +112,6 @@ function Q({
116
112
  ) });
117
113
  }
118
114
  export {
119
- Q as MessagesForm
115
+ H as MessagesForm
120
116
  };
121
117
  //# sourceMappingURL=MessagesForm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MessagesForm.js","sources":["../../src/components/MessagesForm.tsx"],"sourcesContent":["\"use client\";\n\nimport type { FormValues } from \"@/context/messages-form\";\nimport type {\n DeepPartial,\n Locales,\n Messages,\n MessagesSchema,\n Translations,\n} from \"@/types\";\nimport { Button, useStepNav } from \"@payloadcms/ui\";\nimport { isEqual } from \"lodash-es\";\nimport { useEffect, useState } from \"react\";\nimport { useForm } from \"react-hook-form\";\nimport { toast } from \"sonner\";\n\nimport { MessagesFormProvider } from \"@/context/messages-form\";\nimport { cn } from \"@/utils/cn\";\nimport { getErrorMessage } from \"@/utils/error-handling\";\n\nimport { JsonImport } from \"./actions/JsonImport\";\nimport { MessageField } from \"./layout/MessageField\";\nimport { MessagesTabs } from \"./layout/MessagesTabs\";\nimport { MessagesTree } from \"./layout/MessagesTree\";\n\ninterface MessagesFormProps {\n locales: Locales;\n schema: MessagesSchema;\n tabs?: boolean;\n values: Translations<DeepPartial<Messages>>;\n endpointUrl: string;\n}\n\nexport function MessagesForm({\n locales,\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: \"onChange\",\n });\n const [activeTab, setActiveTab] = useState(Object.keys(schema)[0]);\n\n const handleSubmit = async (currentValues: FormValues) => {\n const toastId = toast.loading(\"Saving...\");\n const changes = Object.entries(currentValues).reduce<\n Translations<Messages>\n >((acc, [locale, value]) => {\n const hasChanged = !isEqual(value, values[locale]);\n if (!hasChanged) {\n return acc;\n }\n return {\n ...acc,\n [locale]: value,\n };\n }, {});\n\n try {\n const response = await fetch(endpointUrl, {\n method: \"PUT\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(changes),\n });\n\n if (!response.ok) {\n const error = await getErrorMessage(response);\n throw new Error(error);\n }\n\n form.reset(currentValues);\n toast.success(\"Saved\", { id: toastId });\n } catch (error) {\n toast.error(\n `Failed to save: ${error instanceof Error ? error.message : \"Unknown error\"}`,\n { id: toastId },\n );\n }\n };\n\n return (\n <MessagesFormProvider form={form} locales={locales}>\n <form\n className=\"flex h-[calc(100vh-var(--app-header-height))] flex-col\"\n onSubmit={form.handleSubmit(handleSubmit)}\n >\n <div className=\"sticky top-0 z-10 bg-background\">\n <header className=\"mb-6 flex items-center justify-between gap-4\">\n <h1 className=\"text-4xl\">Messages</h1>\n <div className=\"flex items-center gap-2\">\n <JsonImport />\n <Button\n className=\"my-0\"\n type=\"submit\"\n disabled={!form.formState.isDirty}\n >\n Save\n </Button>\n </div>\n </header>\n\n {tabs && (\n <MessagesTabs\n schema={schema}\n activeTab={activeTab}\n setActiveTab={setActiveTab}\n />\n )}\n </div>\n\n <div\n id=\"messages-form-content\"\n className=\"min-h-0 overflow-y-auto pt-8 pb-16\"\n >\n {!tabs && <MessagesTree path=\"\" schema={schema} nestingLevel={0} />}\n {tabs &&\n Object.entries(schema).map(([key, value]) => {\n if (typeof value === \"string\") {\n return (\n <MessageField\n schema={value}\n key={key}\n className={cn({ hidden: activeTab !== key })}\n messageKey={key}\n path={key}\n />\n );\n }\n return (\n <MessagesTree\n className={cn({ hidden: activeTab !== key })}\n key={key}\n path={key}\n schema={value}\n nestingLevel={0}\n />\n );\n })}\n </div>\n </form>\n </MessagesFormProvider>\n );\n}\n"],"names":["MessagesForm","locales","schema","tabs","values","endpointUrl","setStepNav","useStepNav","useEffect","form","useForm","activeTab","setActiveTab","useState","handleSubmit","currentValues","toastId","toast","changes","acc","locale","value","isEqual","response","error","getErrorMessage","jsx","MessagesFormProvider","jsxs","JsonImport","Button","MessagesTabs","MessagesTree","key","MessageField","cn"],"mappings":"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"}
1
+ {"version":3,"file":"MessagesForm.js","sources":["../../src/components/MessagesForm.tsx"],"sourcesContent":["'use client';\n\nimport { Button, toast, useStepNav } from '@payloadcms/ui';\nimport { isEqual } from 'lodash-es';\nimport { useEffect, useState } from 'react';\nimport { useForm } from 'react-hook-form';\nimport type { FormValues } from '@/context/messages-form';\nimport { MessagesFormProvider } from '@/context/messages-form';\nimport type {\n DeepPartial,\n Locales,\n Messages,\n MessagesSchema,\n Translations,\n} from '@/types';\nimport { cn } from '@/utils/cn';\nimport { getErrorMessage } from '@/utils/error-handling';\nimport { JsonImport } from './actions/JsonImport';\nimport { MessageField } from './layout/MessageField';\nimport { MessagesTabs } from './layout/MessagesTabs';\nimport { MessagesTree } from './layout/MessagesTree';\n\ninterface MessagesFormProps {\n locales: Locales;\n schema: MessagesSchema;\n tabs?: boolean;\n values: Translations<DeepPartial<Messages>>;\n endpointUrl: string;\n}\n\nexport function MessagesForm({\n locales,\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: 'onChange',\n });\n const [activeTab, setActiveTab] = useState(Object.keys(schema)[0]);\n\n const handleSubmit = async (currentValues: FormValues) => {\n const toastId = toast.loading('Saving...');\n const changes = Object.entries(currentValues).reduce<\n Translations<Messages>\n >((acc, [locale, value]) => {\n const hasChanged = !isEqual(value, values[locale]);\n if (!hasChanged) return acc;\n acc[locale] = value;\n return acc;\n }, {});\n\n try {\n const response = await fetch(endpointUrl, {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(changes),\n });\n\n if (!response.ok) {\n const error = await getErrorMessage(response);\n throw new Error(error);\n }\n\n form.reset(currentValues);\n toast.success('Saved', { id: toastId });\n } catch (error) {\n toast.error(\n `Failed to save: ${error instanceof Error ? error.message : 'Unknown error'}`,\n { id: toastId },\n );\n }\n };\n\n return (\n <MessagesFormProvider form={form} locales={locales}>\n <form\n className=\"flex h-[calc(100vh-var(--app-header-height))] flex-col\"\n onSubmit={form.handleSubmit(handleSubmit)}\n >\n <div className=\"sticky top-0 z-10 bg-background\">\n <header className=\"mb-6 flex items-center justify-between gap-4\">\n <h1 className=\"text-4xl\">Messages</h1>\n <div className=\"flex items-center gap-2\">\n <JsonImport />\n <Button\n className=\"my-0\"\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\n className=\"min-h-0 overflow-y-auto pt-8 pb-16\"\n id=\"messages-form-content\"\n >\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 className={cn({ hidden: activeTab !== key })}\n key={key}\n messageKey={key}\n path={key}\n schema={value}\n />\n );\n }\n return (\n <MessagesTree\n className={cn({ 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":["MessagesForm","locales","schema","tabs","values","endpointUrl","setStepNav","useStepNav","useEffect","form","useForm","activeTab","setActiveTab","useState","handleSubmit","currentValues","toastId","toast","changes","acc","locale","value","isEqual","response","error","getErrorMessage","jsx","MessagesFormProvider","jsxs","JsonImport","Button","MessagesTabs","MessagesTree","key","MessageField","cn"],"mappings":";;;;;;;;;;;;;AA8BO,SAASA,EAAa;AAAA,EAC3B,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,QAAAC;AAAA,EACA,aAAAC;AACF,GAAuC;AACrC,QAAM,EAAE,YAAAC,EAAA,IAAeC,EAAA;AACvB,EAAAC,EAAU,MAAM;AACd,IAAAF,EAAW,CAAC,EAAE,OAAO,iBAAiB,KAAK,QAAA,CAAS,CAAC;AAAA,EACvD,GAAG,CAACA,CAAU,CAAC;AAEf,QAAMG,IAAOC,EAAoB;AAAA,IAC/B,eAAeN;AAAA,IACf,gBAAgB;AAAA,EAAA,CACjB,GACK,CAACO,GAAWC,CAAY,IAAIC,EAAS,OAAO,KAAKX,CAAM,EAAE,CAAC,CAAC,GAE3DY,IAAe,OAAOC,MAA8B;AACxD,UAAMC,IAAUC,EAAM,QAAQ,WAAW,GACnCC,IAAU,OAAO,QAAQH,CAAa,EAAE,OAE5C,CAACI,GAAK,CAACC,GAAQC,CAAK,OACAC,EAAQD,GAAOjB,EAAOgB,CAAM,CAAC,MAEjDD,EAAIC,CAAM,IAAIC,IACPF,IACN,CAAA,CAAE;AAEL,QAAI;AACF,YAAMI,IAAW,MAAM,MAAMlB,GAAa;AAAA,QACxC,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,gBAAgB;AAAA,QAAA;AAAA,QAElB,MAAM,KAAK,UAAUa,CAAO;AAAA,MAAA,CAC7B;AAED,UAAI,CAACK,EAAS,IAAI;AAChB,cAAMC,IAAQ,MAAMC,EAAgBF,CAAQ;AAC5C,cAAM,IAAI,MAAMC,CAAK;AAAA,MACvB;AAEA,MAAAf,EAAK,MAAMM,CAAa,GACxBE,EAAM,QAAQ,SAAS,EAAE,IAAID,GAAS;AAAA,IACxC,SAASQ,GAAO;AACd,MAAAP,EAAM;AAAA,QACJ,mBAAmBO,aAAiB,QAAQA,EAAM,UAAU,eAAe;AAAA,QAC3E,EAAE,IAAIR,EAAA;AAAA,MAAQ;AAAA,IAElB;AAAA,EACF;AAEA,SACE,gBAAAU,EAACC,GAAA,EAAqB,MAAAlB,GAAY,SAAAR,GAChC,UAAA,gBAAA2B;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACV,UAAUnB,EAAK,aAAaK,CAAY;AAAA,MAExC,UAAA;AAAA,QAAA,gBAAAc,EAAC,OAAA,EAAI,WAAU,mCACb,UAAA;AAAA,UAAA,gBAAAA,EAAC,UAAA,EAAO,WAAU,gDAChB,UAAA;AAAA,YAAA,gBAAAF,EAAC,MAAA,EAAG,WAAU,YAAW,UAAA,YAAQ;AAAA,YACjC,gBAAAE,EAAC,OAAA,EAAI,WAAU,2BACb,UAAA;AAAA,cAAA,gBAAAF,EAACG,GAAA,EAAW;AAAA,cACZ,gBAAAH;AAAA,gBAACI;AAAA,gBAAA;AAAA,kBACC,WAAU;AAAA,kBACV,UAAU,CAACrB,EAAK,UAAU;AAAA,kBAC1B,MAAK;AAAA,kBACN,UAAA;AAAA,gBAAA;AAAA,cAAA;AAAA,YAED,EAAA,CACF;AAAA,UAAA,GACF;AAAA,UAECN,KACC,gBAAAuB;AAAA,YAACK;AAAA,YAAA;AAAA,cACC,WAAApB;AAAA,cACA,QAAAT;AAAA,cACA,cAAAU;AAAA,YAAA;AAAA,UAAA;AAAA,QACF,GAEJ;AAAA,QAEA,gBAAAgB;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,IAAG;AAAA,YAEF,UAAA;AAAA,cAAA,CAACzB,KAAQ,gBAAAuB,EAACM,GAAA,EAAa,cAAc,GAAG,MAAK,IAAG,QAAA9B,GAAgB;AAAA,cAChEC,KACC,OAAO,QAAQD,CAAM,EAAE,IAAI,CAAC,CAAC+B,GAAKZ,CAAK,MACjC,OAAOA,KAAU,WAEjB,gBAAAK;AAAA,gBAACQ;AAAA,gBAAA;AAAA,kBACC,WAAWC,EAAG,EAAE,QAAQxB,MAAcsB,GAAK;AAAA,kBAE3C,YAAYA;AAAA,kBACZ,MAAMA;AAAA,kBACN,QAAQZ;AAAA,gBAAA;AAAA,gBAHHY;AAAA,cAAA,IAQT,gBAAAP;AAAA,gBAACM;AAAA,gBAAA;AAAA,kBACC,WAAWG,EAAG,EAAE,QAAQxB,MAAcsB,GAAK;AAAA,kBAE3C,cAAc;AAAA,kBACd,MAAMA;AAAA,kBACN,QAAQZ;AAAA,gBAAA;AAAA,gBAHHY;AAAA,cAAA,CAMV;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACL;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;"}
@@ -1 +1,2 @@
1
1
  export declare function JsonImport(): import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=JsonImport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JsonImport.d.ts","sourceRoot":"","sources":["../../../src/components/actions/JsonImport.tsx"],"names":[],"mappings":"AAMA,wBAAgB,UAAU,4CAiEzB"}
@@ -9,7 +9,6 @@ function C() {
9
9
  /* @__PURE__ */ o(
10
10
  "input",
11
11
  {
12
- ref: r,
13
12
  accept: ".json",
14
13
  hidden: !0,
15
14
  onChange: (t) => {
@@ -27,24 +26,25 @@ function C() {
27
26
  }), n(void 0), t.target.value = "";
28
27
  }, l.readAsText(e);
29
28
  },
29
+ ref: r,
30
30
  type: "file"
31
31
  }
32
32
  ),
33
33
  /* @__PURE__ */ o(
34
34
  c,
35
35
  {
36
- className: "my-0",
37
36
  buttonStyle: "subtle",
38
- iconPosition: "left",
37
+ className: "my-0",
39
38
  icon: /* @__PURE__ */ o(h, { className: "size-5" }),
39
+ iconPosition: "left",
40
40
  SubMenuPopupContent: ({ close: t }) => /* @__PURE__ */ o("div", { className: "flex flex-col gap-2", children: i.map((e) => /* @__PURE__ */ a(
41
41
  c,
42
42
  {
43
43
  buttonStyle: "subtle",
44
- size: "small",
45
44
  onClick: () => {
46
45
  n(e), r.current?.click(), t();
47
46
  },
47
+ size: "small",
48
48
  children: [
49
49
  e,
50
50
  ".json"
@@ -1 +1 @@
1
- {"version":3,"file":"JsonImport.js","sources":["../../../src/components/actions/JsonImport.tsx"],"sourcesContent":["import { Button } from \"@payloadcms/ui\";\nimport { IconBraces } from \"@tabler/icons-react\";\nimport { useRef, useState } from \"react\";\n\nimport { useMessagesForm } from \"@/context/messages-form\";\n\nexport function JsonImport() {\n const { locales, setValue } = useMessagesForm();\n const inputRef = useRef<HTMLInputElement>(null);\n const [selectedLocale, setSelectedLocale] = useState<string>();\n\n const handleImportJSON = (event: React.ChangeEvent<HTMLInputElement>) => {\n const file = event.target.files?.[0];\n if (!selectedLocale || !file) {\n event.target.value = \"\";\n return;\n }\n\n const reader = new FileReader();\n reader.onload = (readerEvent) => {\n const text = readerEvent.target?.result as string;\n const data = JSON.parse(text);\n // FIMXE this does not cause the form to re-render\n setValue(selectedLocale, data, {\n shouldDirty: true,\n shouldValidate: true,\n });\n setSelectedLocale(undefined);\n // Clear the input value to allow re-selection of the same or different file\n event.target.value = \"\";\n };\n reader.readAsText(file);\n };\n\n return (\n <>\n <input\n ref={inputRef}\n accept=\".json\"\n hidden\n onChange={handleImportJSON}\n type=\"file\"\n />\n <Button\n className=\"my-0\"\n buttonStyle=\"subtle\"\n iconPosition=\"left\"\n icon={<IconBraces className=\"size-5\" />}\n SubMenuPopupContent={({ close }) => (\n <div className=\"flex flex-col gap-2\">\n {locales.map((locale) => (\n <Button\n key={locale}\n buttonStyle=\"subtle\"\n size=\"small\"\n onClick={() => {\n setSelectedLocale(locale);\n inputRef.current?.click();\n close();\n }}\n >\n {locale}.json\n </Button>\n ))}\n </div>\n )}\n >\n Import\n </Button>\n </>\n );\n}\n"],"names":["JsonImport","locales","setValue","useMessagesForm","inputRef","useRef","selectedLocale","setSelectedLocale","useState","jsxs","Fragment","jsx","event","file","reader","readerEvent","text","data","Button","IconBraces","close","locale"],"mappings":";;;;;AAMO,SAASA,IAAa;AAC3B,QAAM,EAAE,SAAAC,GAAS,UAAAC,EAAA,IAAaC,EAAA,GACxBC,IAAWC,EAAyB,IAAI,GACxC,CAACC,GAAgBC,CAAiB,IAAIC,EAAA;AAyB5C,SACE,gBAAAC,EAAAC,GAAA,EACE,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAKP;AAAA,QACL,QAAO;AAAA,QACP,QAAM;AAAA,QACN,UA7BmB,CAACQ,MAA+C;AACvE,gBAAMC,IAAOD,EAAM,OAAO,QAAQ,CAAC;AACnC,cAAI,CAACN,KAAkB,CAACO,GAAM;AAC5B,YAAAD,EAAM,OAAO,QAAQ;AACrB;AAAA,UACF;AAEA,gBAAME,IAAS,IAAI,WAAA;AACnB,UAAAA,EAAO,SAAS,CAACC,MAAgB;AAC/B,kBAAMC,IAAOD,EAAY,QAAQ,QAC3BE,IAAO,KAAK,MAAMD,CAAI;AAE5B,YAAAd,EAASI,GAAgBW,GAAM;AAAA,cAC7B,aAAa;AAAA,cACb,gBAAgB;AAAA,YAAA,CACjB,GACDV,EAAkB,MAAS,GAE3BK,EAAM,OAAO,QAAQ;AAAA,UACvB,GACAE,EAAO,WAAWD,CAAI;AAAA,QACxB;AAAA,QASM,MAAK;AAAA,MAAA;AAAA,IAAA;AAAA,IAEP,gBAAAF;AAAA,MAACO;AAAA,MAAA;AAAA,QACC,WAAU;AAAA,QACV,aAAY;AAAA,QACZ,cAAa;AAAA,QACb,MAAM,gBAAAP,EAACQ,GAAA,EAAW,WAAU,SAAA,CAAS;AAAA,QACrC,qBAAqB,CAAC,EAAE,OAAAC,QACtB,gBAAAT,EAAC,OAAA,EAAI,WAAU,uBACZ,UAAAV,EAAQ,IAAI,CAACoB,MACZ,gBAAAZ;AAAA,UAACS;AAAA,UAAA;AAAA,YAEC,aAAY;AAAA,YACZ,MAAK;AAAA,YACL,SAAS,MAAM;AACb,cAAAX,EAAkBc,CAAM,GACxBjB,EAAS,SAAS,MAAA,GAClBgB,EAAA;AAAA,YACF;AAAA,YAEC,UAAA;AAAA,cAAAC;AAAA,cAAO;AAAA,YAAA;AAAA,UAAA;AAAA,UATHA;AAAA,QAAA,CAWR,GACH;AAAA,QAEH,UAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAED,GACF;AAEJ;"}
1
+ {"version":3,"file":"JsonImport.js","sources":["../../../src/components/actions/JsonImport.tsx"],"sourcesContent":["import { Button } from '@payloadcms/ui';\nimport { IconBraces } from '@tabler/icons-react';\nimport { useRef, useState } from 'react';\n\nimport { useMessagesForm } from '@/context/messages-form';\n\nexport function JsonImport() {\n const { locales, setValue } = useMessagesForm();\n const inputRef = useRef<HTMLInputElement>(null);\n const [selectedLocale, setSelectedLocale] = useState<string>();\n\n const handleImportJSON = (event: React.ChangeEvent<HTMLInputElement>) => {\n const file = event.target.files?.[0];\n if (!selectedLocale || !file) {\n event.target.value = '';\n return;\n }\n\n const reader = new FileReader();\n reader.onload = (readerEvent) => {\n const text = readerEvent.target?.result as string;\n const data = JSON.parse(text);\n // FIMXE this does not cause the form to re-render\n setValue(selectedLocale, data, {\n shouldDirty: true,\n shouldValidate: true,\n });\n setSelectedLocale(undefined);\n // Clear the input value to allow re-selection of the same or different file\n event.target.value = '';\n };\n reader.readAsText(file);\n };\n\n return (\n <>\n <input\n accept=\".json\"\n hidden\n onChange={handleImportJSON}\n ref={inputRef}\n type=\"file\"\n />\n <Button\n buttonStyle=\"subtle\"\n className=\"my-0\"\n icon={<IconBraces className=\"size-5\" />}\n iconPosition=\"left\"\n SubMenuPopupContent={({ close }) => (\n <div className=\"flex flex-col gap-2\">\n {locales.map((locale) => (\n <Button\n buttonStyle=\"subtle\"\n key={locale}\n onClick={() => {\n setSelectedLocale(locale);\n inputRef.current?.click();\n close();\n }}\n size=\"small\"\n >\n {locale}.json\n </Button>\n ))}\n </div>\n )}\n >\n Import\n </Button>\n </>\n );\n}\n"],"names":["JsonImport","locales","setValue","useMessagesForm","inputRef","useRef","selectedLocale","setSelectedLocale","useState","jsxs","Fragment","jsx","event","file","reader","readerEvent","text","data","Button","IconBraces","close","locale"],"mappings":";;;;;AAMO,SAASA,IAAa;AAC3B,QAAM,EAAE,SAAAC,GAAS,UAAAC,EAAA,IAAaC,EAAA,GACxBC,IAAWC,EAAyB,IAAI,GACxC,CAACC,GAAgBC,CAAiB,IAAIC,EAAA;AAyB5C,SACE,gBAAAC,EAAAC,GAAA,EACE,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,QAAO;AAAA,QACP,QAAM;AAAA,QACN,UA5BmB,CAACC,MAA+C;AACvE,gBAAMC,IAAOD,EAAM,OAAO,QAAQ,CAAC;AACnC,cAAI,CAACN,KAAkB,CAACO,GAAM;AAC5B,YAAAD,EAAM,OAAO,QAAQ;AACrB;AAAA,UACF;AAEA,gBAAME,IAAS,IAAI,WAAA;AACnB,UAAAA,EAAO,SAAS,CAACC,MAAgB;AAC/B,kBAAMC,IAAOD,EAAY,QAAQ,QAC3BE,IAAO,KAAK,MAAMD,CAAI;AAE5B,YAAAd,EAASI,GAAgBW,GAAM;AAAA,cAC7B,aAAa;AAAA,cACb,gBAAgB;AAAA,YAAA,CACjB,GACDV,EAAkB,MAAS,GAE3BK,EAAM,OAAO,QAAQ;AAAA,UACvB,GACAE,EAAO,WAAWD,CAAI;AAAA,QACxB;AAAA,QAQM,KAAKT;AAAA,QACL,MAAK;AAAA,MAAA;AAAA,IAAA;AAAA,IAEP,gBAAAO;AAAA,MAACO;AAAA,MAAA;AAAA,QACC,aAAY;AAAA,QACZ,WAAU;AAAA,QACV,MAAM,gBAAAP,EAACQ,GAAA,EAAW,WAAU,SAAA,CAAS;AAAA,QACrC,cAAa;AAAA,QACb,qBAAqB,CAAC,EAAE,OAAAC,QACtB,gBAAAT,EAAC,OAAA,EAAI,WAAU,uBACZ,UAAAV,EAAQ,IAAI,CAACoB,MACZ,gBAAAZ;AAAA,UAACS;AAAA,UAAA;AAAA,YACC,aAAY;AAAA,YAEZ,SAAS,MAAM;AACb,cAAAX,EAAkBc,CAAM,GACxBjB,EAAS,SAAS,MAAA,GAClBgB,EAAA;AAAA,YACF;AAAA,YACA,MAAK;AAAA,YAEJ,UAAA;AAAA,cAAAC;AAAA,cAAO;AAAA,YAAA;AAAA,UAAA;AAAA,UARHA;AAAA,QAAA,CAUR,GACH;AAAA,QAEH,UAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAED,GACF;AAEJ;"}
@@ -1,3 +1,2 @@
1
- export interface MoveProps {
2
- }
3
- export declare function Move({}: MoveProps): import("react/jsx-runtime").JSX.Element;
1
+ export declare function Move(): import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=Move.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Move.d.ts","sourceRoot":"","sources":["../../../src/components/actions/Move.tsx"],"names":[],"mappings":"AAMA,wBAAgB,IAAI,4CA4BnB"}
@@ -5,3 +5,4 @@ export interface InputWrapperProps {
5
5
  className?: string;
6
6
  }
7
7
  export declare function InputWrapper({ label, error, className, children, }: React.PropsWithChildren<InputWrapperProps>): import("react/jsx-runtime").JSX.Element;
8
+ //# sourceMappingURL=InputWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InputWrapper.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/InputWrapper.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,KAAK,EACL,SAAS,EACT,QAAQ,GACT,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,2CAqB5C"}
@@ -1 +1 @@
1
- {"version":3,"file":"InputWrapper.js","sources":["../../../src/components/inputs/InputWrapper.tsx"],"sourcesContent":["import type { FieldError } from \"react-hook-form\";\nimport { FieldLabel } from \"@payloadcms/ui\";\n\nimport { cn } from \"@/utils/cn\";\n\nexport interface InputWrapperProps {\n label?: string;\n error: FieldError | undefined;\n className?: string;\n}\n\nexport function InputWrapper({\n label,\n error,\n className,\n children,\n}: React.PropsWithChildren<InputWrapperProps>) {\n return (\n <div className={cn(\"flex h-full min-w-5 flex-col gap-1\", className)}>\n <fieldset\n className={cn(\n \"mx-0 flex-1 rounded-md focus-within:border-elevation-400\",\n {\n \"border-error bg-error\": error,\n },\n )}\n >\n {label && (\n <legend className=\"-ml-2 px-1.5 text-base\">\n <FieldLabel label={label} />\n </legend>\n )}\n {children}\n </fieldset>\n <p className=\"text-base text-error\">{error?.message}</p>\n </div>\n );\n}\n"],"names":["InputWrapper","label","error","className","children","cn","jsxs","jsx","FieldLabel"],"mappings":";;;AAWO,SAASA,EAAa;AAAA,EAC3B,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AACF,GAA+C;AAC7C,2BACG,OAAA,EAAI,WAAWC,EAAG,sCAAsCF,CAAS,GAChE,UAAA;AAAA,IAAA,gBAAAG;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAWD;AAAA,UACT;AAAA,UACA;AAAA,YACE,yBAAyBH;AAAA,UAAA;AAAA,QAC3B;AAAA,QAGD,UAAA;AAAA,UAAAD,uBACE,UAAA,EAAO,WAAU,0BAChB,UAAA,gBAAAM,EAACC,GAAA,EAAW,OAAAP,GAAc,EAAA,CAC5B;AAAA,UAEDG;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,IAEH,gBAAAG,EAAC,KAAA,EAAE,WAAU,wBAAwB,aAAO,QAAA,CAAQ;AAAA,EAAA,GACtD;AAEJ;"}
1
+ {"version":3,"file":"InputWrapper.js","sources":["../../../src/components/inputs/InputWrapper.tsx"],"sourcesContent":["import { FieldLabel } from '@payloadcms/ui';\nimport type { FieldError } from 'react-hook-form';\n\nimport { cn } from '@/utils/cn';\n\nexport interface InputWrapperProps {\n label?: string;\n error: FieldError | undefined;\n className?: string;\n}\n\nexport function InputWrapper({\n label,\n error,\n className,\n children,\n}: React.PropsWithChildren<InputWrapperProps>) {\n return (\n <div className={cn('flex h-full min-w-5 flex-col gap-1', className)}>\n <fieldset\n className={cn(\n 'mx-0 flex-1 rounded-md focus-within:border-elevation-400',\n {\n 'border-error bg-error': error,\n },\n )}\n >\n {label && (\n <legend className=\"-ml-2 px-1.5 text-base\">\n <FieldLabel label={label} />\n </legend>\n )}\n {children}\n </fieldset>\n <p className=\"text-base text-error\">{error?.message}</p>\n </div>\n );\n}\n"],"names":["InputWrapper","label","error","className","children","cn","jsxs","jsx","FieldLabel"],"mappings":";;;AAWO,SAASA,EAAa;AAAA,EAC3B,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AACF,GAA+C;AAC7C,2BACG,OAAA,EAAI,WAAWC,EAAG,sCAAsCF,CAAS,GAChE,UAAA;AAAA,IAAA,gBAAAG;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAWD;AAAA,UACT;AAAA,UACA;AAAA,YACE,yBAAyBH;AAAA,UAAA;AAAA,QAC3B;AAAA,QAGD,UAAA;AAAA,UAAAD,uBACE,UAAA,EAAO,WAAU,0BAChB,UAAA,gBAAAM,EAACC,GAAA,EAAW,OAAAP,GAAc,EAAA,CAC5B;AAAA,UAEDG;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,IAEH,gBAAAG,EAAC,KAAA,EAAE,WAAU,wBAAwB,aAAO,QAAA,CAAQ;AAAA,EAAA,GACtD;AAEJ;"}
@@ -17,3 +17,4 @@ export declare function useHtmlLexicalAdapter({ html, onChange, }: UseHtmlLexica
17
17
  setValue: (serializedState: SerializedEditorState) => void;
18
18
  };
19
19
  export {};
20
+ //# sourceMappingURL=LexicalInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LexicalInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/LexicalInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAWtC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AASlF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGxD,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,KAAK,EACL,KAAK,EACL,QAAQ,EACR,SAAS,GACV,EAAE,iBAAiB,GAAG,KAAK,CAAC,SAAS,CAoBrC;AAID,UAAU,0BAA0B;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED,wBAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,QAAQ,GACT,EAAE,0BAA0B;WAiEF,gBAAgB,CAAC,gBAAgB,CAAC;gCAjBvC,qBAAqB;EAkB1C"}
@@ -1,4 +1,4 @@
1
- import { TemplateVariable } from '../../types.ts';
1
+ import { TemplateVariable } from '../../types';
2
2
  import { InputWrapperProps } from './InputWrapper';
3
3
  export interface MessageInputProps extends InputWrapperProps {
4
4
  value: string;
@@ -8,3 +8,4 @@ export interface MessageInputProps extends InputWrapperProps {
8
8
  onBlur: () => void;
9
9
  }
10
10
  export declare function MessageInput({ label, value, lang, error, variables, onChange, onBlur, className, }: MessageInputProps): import("react/jsx-runtime").JSX.Element;
11
+ //# sourceMappingURL=MessageInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessageInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/MessageInput.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAIhD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIxD,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAKD,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,KAAK,EACL,IAAI,EACJ,KAAK,EACL,SAAS,EACT,QAAQ,EACR,MAAM,EACN,SAAS,GACV,EAAE,iBAAiB,2CAkBnB"}
@@ -22,7 +22,7 @@ function C({
22
22
  extensions: [d, c, u, I(m)],
23
23
  onUpdate: ({ editor: f }) => n(f.getText())
24
24
  });
25
- return /* @__PURE__ */ r(h, { label: o, error: i, className: a, children: /* @__PURE__ */ r(
25
+ return /* @__PURE__ */ r(h, { className: a, error: i, label: o, children: /* @__PURE__ */ r(
26
26
  x,
27
27
  {
28
28
  className: "tiptap-editor min-h-8",
@@ -1 +1 @@
1
- {"version":3,"file":"MessageInput.js","sources":["../../../src/components/inputs/MessageInput.tsx"],"sourcesContent":["import type { TemplateVariable } from \"@/types\";\nimport Document from \"@tiptap/extension-document\";\nimport Paragraph from \"@tiptap/extension-paragraph\";\nimport Text from \"@tiptap/extension-text\";\nimport { EditorContent, useEditor } from \"@tiptap/react\";\n\nimport { parseIcuToProseMirrorJSON } from \"@/utils/icu-tranform\";\n\nimport type { InputWrapperProps } from \"./InputWrapper\";\nimport { InputWrapper } from \"./InputWrapper\";\nimport { VariableMention } from \"./variables/extension\";\n\nexport interface MessageInputProps extends InputWrapperProps {\n value: string;\n lang: string;\n variables: TemplateVariable[];\n onChange: (value: string) => void;\n onBlur: () => void;\n}\n\n// TODO add variable editor (style, options, etc)\n// TODO add tooltip to show all variables\n\nexport function MessageInput({\n label,\n value,\n lang,\n error,\n variables,\n onChange,\n onBlur,\n className,\n}: MessageInputProps) {\n const editor = useEditor({\n immediatelyRender: false,\n content: parseIcuToProseMirrorJSON(value),\n extensions: [Document, Paragraph, Text, VariableMention(variables)],\n onUpdate: ({ editor }) => onChange(editor.getText()),\n });\n\n return (\n <InputWrapper label={label} error={error} className={className}>\n <EditorContent\n className=\"tiptap-editor min-h-8\"\n editor={editor}\n lang={lang}\n onBlur={onBlur}\n />\n </InputWrapper>\n );\n}\n"],"names":["MessageInput","label","value","lang","error","variables","onChange","onBlur","className","editor","useEditor","parseIcuToProseMirrorJSON","Document","Paragraph","Text","VariableMention","jsx","InputWrapper","EditorContent"],"mappings":";;;;;;;;AAuBO,SAASA,EAAa;AAAA,EAC3B,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,WAAAC;AACF,GAAsB;AACpB,QAAMC,IAASC,EAAU;AAAA,IACvB,mBAAmB;AAAA,IACnB,SAASC,EAA0BT,CAAK;AAAA,IACxC,YAAY,CAACU,GAAUC,GAAWC,GAAMC,EAAgBV,CAAS,CAAC;AAAA,IAClE,UAAU,CAAC,EAAE,QAAAI,QAAaH,EAASG,EAAO,QAAA,CAAS;AAAA,EAAA,CACpD;AAED,SACE,gBAAAO,EAACC,GAAA,EAAa,OAAAhB,GAAc,OAAAG,GAAc,WAAAI,GACxC,UAAA,gBAAAQ;AAAA,IAACE;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACV,QAAAT;AAAA,MACA,MAAAN;AAAA,MACA,QAAAI;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;"}
1
+ {"version":3,"file":"MessageInput.js","sources":["../../../src/components/inputs/MessageInput.tsx"],"sourcesContent":["import Document from '@tiptap/extension-document';\nimport Paragraph from '@tiptap/extension-paragraph';\nimport Text from '@tiptap/extension-text';\nimport { EditorContent, useEditor } from '@tiptap/react';\nimport type { TemplateVariable } from '@/types';\n\nimport { parseIcuToProseMirrorJSON } from '@/utils/icu-tranform';\n\nimport type { InputWrapperProps } from './InputWrapper';\nimport { InputWrapper } from './InputWrapper';\nimport { VariableMention } from './variables/extension';\n\nexport interface MessageInputProps extends InputWrapperProps {\n value: string;\n lang: string;\n variables: TemplateVariable[];\n onChange: (value: string) => void;\n onBlur: () => void;\n}\n\n// TODO add variable editor (style, options, etc)\n// TODO add tooltip to show all variables\n\nexport function MessageInput({\n label,\n value,\n lang,\n error,\n variables,\n onChange,\n onBlur,\n className,\n}: MessageInputProps) {\n const editor = useEditor({\n immediatelyRender: false,\n content: parseIcuToProseMirrorJSON(value),\n extensions: [Document, Paragraph, Text, VariableMention(variables)],\n onUpdate: ({ editor }) => onChange(editor.getText()),\n });\n\n return (\n <InputWrapper className={className} error={error} label={label}>\n <EditorContent\n className=\"tiptap-editor min-h-8\"\n editor={editor}\n lang={lang}\n onBlur={onBlur}\n />\n </InputWrapper>\n );\n}\n"],"names":["MessageInput","label","value","lang","error","variables","onChange","onBlur","className","editor","useEditor","parseIcuToProseMirrorJSON","Document","Paragraph","Text","VariableMention","jsx","InputWrapper","EditorContent"],"mappings":";;;;;;;;AAuBO,SAASA,EAAa;AAAA,EAC3B,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,WAAAC;AACF,GAAsB;AACpB,QAAMC,IAASC,EAAU;AAAA,IACvB,mBAAmB;AAAA,IACnB,SAASC,EAA0BT,CAAK;AAAA,IACxC,YAAY,CAACU,GAAUC,GAAWC,GAAMC,EAAgBV,CAAS,CAAC;AAAA,IAClE,UAAU,CAAC,EAAE,QAAAI,QAAaH,EAASG,EAAO,QAAA,CAAS;AAAA,EAAA,CACpD;AAED,SACE,gBAAAO,EAACC,GAAA,EAAa,WAAAT,GAAsB,OAAAJ,GAAc,OAAAH,GAChD,UAAA,gBAAAe;AAAA,IAACE;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACV,QAAAT;AAAA,MACA,MAAAN;AAAA,MACA,QAAAI;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;"}
@@ -1,2 +1,3 @@
1
1
  import { ReactNodeViewProps } from '@tiptap/react';
2
2
  export declare function VariableChip({ node, updateAttributes, }: ReactNodeViewProps<HTMLElement>): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=VariableChip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VariableChip.d.ts","sourceRoot":"","sources":["../../../../src/components/inputs/variables/VariableChip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AA0BxD,wBAAgB,YAAY,CAAC,EAC3B,IAAI,EACJ,gBAAgB,GACjB,EAAE,kBAAkB,CAAC,WAAW,CAAC,2CAiEjC"}
@@ -37,8 +37,8 @@ function S({
37
37
  }
38
38
  ),
39
39
  contentEditable: !1,
40
- "data-variable": o.name,
41
40
  "data-icu": o.icu,
41
+ "data-variable": o.name,
42
42
  role: "button",
43
43
  tabIndex: 0,
44
44
  children: o.label
@@ -47,10 +47,10 @@ function S({
47
47
  /* @__PURE__ */ r(a.Portal, { children: /* @__PURE__ */ n(
48
48
  a.Content,
49
49
  {
50
+ align: "start",
51
+ className: "data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 z-50 grid origin-(--radix-hover-card-content-transform-origin) overflow-clip rounded-md border border-border bg-elevation-50 shadow-md outline-hidden empty:hidden data-[state=closed]:animate-out data-[state=open]:animate-in",
50
52
  side: "bottom",
51
53
  sideOffset: 5,
52
- align: "start",
53
- className: "z-50 grid origin-(--radix-hover-card-content-transform-origin) overflow-clip rounded-md border border-border bg-elevation-50 shadow-md outline-hidden empty:hidden data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
54
54
  children: [
55
55
  u(e) && /* @__PURE__ */ r(E, { element: e, onUpdate: i }),
56
56
  w(e) && /* @__PURE__ */ r(h, { element: e, onUpdate: i }),
@@ -1 +1 @@
1
- {"version":3,"file":"VariableChip.js","sources":["../../../../src/components/inputs/variables/VariableChip.tsx"],"sourcesContent":["import type { VariableMentionNodeAttrs } from \"@/types\";\nimport type { ReactNodeViewProps } from \"@tiptap/react\";\nimport { NodeViewWrapper } from \"@tiptap/react\";\nimport { Popover } from \"radix-ui\";\nimport { useMemo } from \"react\";\n\nimport { cn } from \"@/utils/cn\";\nimport {\n isArgumentElement,\n isNumericElement,\n isSelectElement,\n isTagElement,\n isTemporalElement,\n} from \"@/utils/guards\";\nimport { parseICUMessage } from \"@/utils/icu-tranform\";\n\nimport { SelectVariableEditor } from \"./editors/SelectVariableEditor\";\nimport { TagVariableEditor } from \"./editors/TagVariableEditor\";\nimport { NumericVariablePicker } from \"./pickers/NumericVariablePicker\";\nimport { TemporalElementEditor } from \"./pickers/TemporalElementEditor\";\nimport { VariableIcon } from \"./VariableIcon\";\n\nconst TEMPORAL_ELEMENTS_FLAG = false;\n\n// TODO replace popover with portal below input field\n\nexport function VariableChip({\n node,\n updateAttributes,\n}: ReactNodeViewProps<HTMLElement>) {\n const attrs = node.attrs as VariableMentionNodeAttrs;\n const handleUpdate = (value: string) =>\n updateAttributes({\n icu: value,\n });\n\n const element = useMemo(() => {\n try {\n const [part] = parseICUMessage(attrs.icu);\n if (!part) throw new Error(\"No part found\");\n return part;\n } catch (error) {\n console.error(error);\n throw new Error(`Invalid ICU: ${attrs.icu}`, { cause: error });\n }\n }, [attrs.icu]);\n\n return (\n <Popover.Root>\n <Popover.Trigger asChild>\n <NodeViewWrapper\n as=\"span\"\n className={cn(\n \"inline-flex cursor-pointer items-center rounded-md bg-elevation-250 px-1 hover:bg-elevation-400\",\n {\n \"pointer-events-none\":\n isArgumentElement(element) ||\n (isTemporalElement(element) && !TEMPORAL_ELEMENTS_FLAG),\n },\n )}\n contentEditable={false}\n data-variable={attrs.name}\n data-icu={attrs.icu}\n role=\"button\"\n tabIndex={0}\n >\n {/* <VariableIcon type={element.type} className=\"size-4\" /> */}\n {attrs.label}\n </NodeViewWrapper>\n </Popover.Trigger>\n <Popover.Portal>\n <Popover.Content\n side=\"bottom\"\n sideOffset={5}\n align=\"start\"\n className=\"z-50 grid origin-(--radix-hover-card-content-transform-origin) overflow-clip rounded-md border border-border bg-elevation-50 shadow-md outline-hidden empty:hidden data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95\"\n >\n {isNumericElement(element) && (\n <NumericVariablePicker element={element} onUpdate={handleUpdate} />\n )}\n {isSelectElement(element) && (\n <SelectVariableEditor element={element} onUpdate={handleUpdate} />\n )}\n {TEMPORAL_ELEMENTS_FLAG && isTemporalElement(element) && (\n <TemporalElementEditor element={element} onUpdate={handleUpdate} />\n )}\n\n {isTagElement(element) && (\n <TagVariableEditor element={element} onUpdate={handleUpdate} />\n )}\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n );\n}\n"],"names":["TEMPORAL_ELEMENTS_FLAG","VariableChip","node","updateAttributes","attrs","handleUpdate","value","element","useMemo","part","parseICUMessage","error","jsxs","Popover","jsx","NodeViewWrapper","cn","isArgumentElement","isTemporalElement","isNumericElement","NumericVariablePicker","isSelectElement","SelectVariableEditor","isTagElement","TagVariableEditor"],"mappings":";;;;;;;;;;;AAsBA,MAAMA,IAAyB;AAIxB,SAASC,EAAa;AAAA,EAC3B,MAAAC;AAAA,EACA,kBAAAC;AACF,GAAoC;AAClC,QAAMC,IAAQF,EAAK,OACbG,IAAe,CAACC,MACpBH,EAAiB;AAAA,IACf,KAAKG;AAAA,EAAA,CACN,GAEGC,IAAUC,EAAQ,MAAM;AAC5B,QAAI;AACF,YAAM,CAACC,CAAI,IAAIC,EAAgBN,EAAM,GAAG;AACxC,UAAI,CAACK,EAAM,OAAM,IAAI,MAAM,eAAe;AAC1C,aAAOA;AAAA,IACT,SAASE,GAAO;AACd,oBAAQ,MAAMA,CAAK,GACb,IAAI,MAAM,gBAAgBP,EAAM,GAAG,IAAI,EAAE,OAAOO,GAAO;AAAA,IAC/D;AAAA,EACF,GAAG,CAACP,EAAM,GAAG,CAAC;AAEd,SACE,gBAAAQ,EAACC,EAAQ,MAAR,EACC,UAAA;AAAA,IAAA,gBAAAC,EAACD,EAAQ,SAAR,EAAgB,SAAO,IACtB,UAAA,gBAAAC;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,IAAG;AAAA,QACH,WAAWC;AAAA,UACT;AAAA,UACA;AAAA,YACE,uBACEC,EAAkBV,CAAO,KACxBW,EAAkBX,CAAO,KAAK,CAACP;AAAA,UAAA;AAAA,QACpC;AAAA,QAEF,iBAAiB;AAAA,QACjB,iBAAeI,EAAM;AAAA,QACrB,YAAUA,EAAM;AAAA,QAChB,MAAK;AAAA,QACL,UAAU;AAAA,QAGT,UAAAA,EAAM;AAAA,MAAA;AAAA,IAAA,GAEX;AAAA,IACA,gBAAAU,EAACD,EAAQ,QAAR,EACC,UAAA,gBAAAD;AAAA,MAACC,EAAQ;AAAA,MAAR;AAAA,QACC,MAAK;AAAA,QACL,YAAY;AAAA,QACZ,OAAM;AAAA,QACN,WAAU;AAAA,QAET,UAAA;AAAA,UAAAM,EAAiBZ,CAAO,KACvB,gBAAAO,EAACM,GAAA,EAAsB,SAAAb,GAAkB,UAAUF,GAAc;AAAA,UAElEgB,EAAgBd,CAAO,uBACrBe,GAAA,EAAqB,SAAAf,GAAkB,UAAUF,GAAc;AAAA,UAEjEL;AAAA,UAIAuB,EAAahB,CAAO,uBAClBiB,GAAA,EAAkB,SAAAjB,GAAkB,UAAUF,EAAA,CAAc;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA,EAEjE,CACF;AAAA,EAAA,GACF;AAEJ;"}
1
+ {"version":3,"file":"VariableChip.js","sources":["../../../../src/components/inputs/variables/VariableChip.tsx"],"sourcesContent":["import type { ReactNodeViewProps } from '@tiptap/react';\nimport { NodeViewWrapper } from '@tiptap/react';\nimport { Popover } from 'radix-ui';\nimport { useMemo } from 'react';\nimport type { VariableMentionNodeAttrs } from '@/types';\n\nimport { cn } from '@/utils/cn';\nimport {\n isArgumentElement,\n isNumericElement,\n isSelectElement,\n isTagElement,\n isTemporalElement,\n} from '@/utils/guards';\nimport { parseICUMessage } from '@/utils/icu-tranform';\n\nimport { SelectVariableEditor } from './editors/SelectVariableEditor';\nimport { TagVariableEditor } from './editors/TagVariableEditor';\nimport { NumericVariablePicker } from './pickers/NumericVariablePicker';\nimport { TemporalElementEditor } from './pickers/TemporalElementEditor';\nimport { VariableIcon } from './VariableIcon';\n\nconst TEMPORAL_ELEMENTS_FLAG = false;\n\n// TODO replace popover with portal below input field\n\nexport function VariableChip({\n node,\n updateAttributes,\n}: ReactNodeViewProps<HTMLElement>) {\n const attrs = node.attrs as VariableMentionNodeAttrs;\n const handleUpdate = (value: string) =>\n updateAttributes({\n icu: value,\n });\n\n const element = useMemo(() => {\n try {\n const [part] = parseICUMessage(attrs.icu);\n if (!part) throw new Error('No part found');\n return part;\n } catch (error) {\n console.error(error);\n throw new Error(`Invalid ICU: ${attrs.icu}`, { cause: error });\n }\n }, [attrs.icu]);\n\n return (\n <Popover.Root>\n <Popover.Trigger asChild>\n <NodeViewWrapper\n as=\"span\"\n className={cn(\n 'inline-flex cursor-pointer items-center rounded-md bg-elevation-250 px-1 hover:bg-elevation-400',\n {\n 'pointer-events-none':\n isArgumentElement(element) ||\n (isTemporalElement(element) && !TEMPORAL_ELEMENTS_FLAG),\n },\n )}\n contentEditable={false}\n data-icu={attrs.icu}\n data-variable={attrs.name}\n role=\"button\"\n tabIndex={0}\n >\n {/* <VariableIcon type={element.type} className=\"size-4\" /> */}\n {attrs.label}\n </NodeViewWrapper>\n </Popover.Trigger>\n <Popover.Portal>\n <Popover.Content\n align=\"start\"\n className=\"data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 z-50 grid origin-(--radix-hover-card-content-transform-origin) overflow-clip rounded-md border border-border bg-elevation-50 shadow-md outline-hidden empty:hidden data-[state=closed]:animate-out data-[state=open]:animate-in\"\n side=\"bottom\"\n sideOffset={5}\n >\n {isNumericElement(element) && (\n <NumericVariablePicker element={element} onUpdate={handleUpdate} />\n )}\n {isSelectElement(element) && (\n <SelectVariableEditor element={element} onUpdate={handleUpdate} />\n )}\n {TEMPORAL_ELEMENTS_FLAG && isTemporalElement(element) && (\n <TemporalElementEditor element={element} onUpdate={handleUpdate} />\n )}\n\n {isTagElement(element) && (\n <TagVariableEditor element={element} onUpdate={handleUpdate} />\n )}\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n );\n}\n"],"names":["TEMPORAL_ELEMENTS_FLAG","VariableChip","node","updateAttributes","attrs","handleUpdate","value","element","useMemo","part","parseICUMessage","error","jsxs","Popover","jsx","NodeViewWrapper","cn","isArgumentElement","isTemporalElement","isNumericElement","NumericVariablePicker","isSelectElement","SelectVariableEditor","isTagElement","TagVariableEditor"],"mappings":";;;;;;;;;;;AAsBA,MAAMA,IAAyB;AAIxB,SAASC,EAAa;AAAA,EAC3B,MAAAC;AAAA,EACA,kBAAAC;AACF,GAAoC;AAClC,QAAMC,IAAQF,EAAK,OACbG,IAAe,CAACC,MACpBH,EAAiB;AAAA,IACf,KAAKG;AAAA,EAAA,CACN,GAEGC,IAAUC,EAAQ,MAAM;AAC5B,QAAI;AACF,YAAM,CAACC,CAAI,IAAIC,EAAgBN,EAAM,GAAG;AACxC,UAAI,CAACK,EAAM,OAAM,IAAI,MAAM,eAAe;AAC1C,aAAOA;AAAA,IACT,SAASE,GAAO;AACd,oBAAQ,MAAMA,CAAK,GACb,IAAI,MAAM,gBAAgBP,EAAM,GAAG,IAAI,EAAE,OAAOO,GAAO;AAAA,IAC/D;AAAA,EACF,GAAG,CAACP,EAAM,GAAG,CAAC;AAEd,SACE,gBAAAQ,EAACC,EAAQ,MAAR,EACC,UAAA;AAAA,IAAA,gBAAAC,EAACD,EAAQ,SAAR,EAAgB,SAAO,IACtB,UAAA,gBAAAC;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,IAAG;AAAA,QACH,WAAWC;AAAA,UACT;AAAA,UACA;AAAA,YACE,uBACEC,EAAkBV,CAAO,KACxBW,EAAkBX,CAAO,KAAK,CAACP;AAAA,UAAA;AAAA,QACpC;AAAA,QAEF,iBAAiB;AAAA,QACjB,YAAUI,EAAM;AAAA,QAChB,iBAAeA,EAAM;AAAA,QACrB,MAAK;AAAA,QACL,UAAU;AAAA,QAGT,UAAAA,EAAM;AAAA,MAAA;AAAA,IAAA,GAEX;AAAA,IACA,gBAAAU,EAACD,EAAQ,QAAR,EACC,UAAA,gBAAAD;AAAA,MAACC,EAAQ;AAAA,MAAR;AAAA,QACC,OAAM;AAAA,QACN,WAAU;AAAA,QACV,MAAK;AAAA,QACL,YAAY;AAAA,QAEX,UAAA;AAAA,UAAAM,EAAiBZ,CAAO,KACvB,gBAAAO,EAACM,GAAA,EAAsB,SAAAb,GAAkB,UAAUF,GAAc;AAAA,UAElEgB,EAAgBd,CAAO,uBACrBe,GAAA,EAAqB,SAAAf,GAAkB,UAAUF,GAAc;AAAA,UAEjEL;AAAA,UAIAuB,EAAahB,CAAO,uBAClBiB,GAAA,EAAkB,SAAAjB,GAAkB,UAAUF,EAAA,CAAc;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA,EAEjE,CACF;AAAA,EAAA,GACF;AAEJ;"}
@@ -1,6 +1,7 @@
1
- import { IconProps } from '@tabler/icons-react';
2
1
  import { TYPE } from '@formatjs/icu-messageformat-parser';
3
- export interface VariableIconProps extends Omit<IconProps, "type"> {
2
+ import { IconProps } from '@tabler/icons-react';
3
+ export interface VariableIconProps extends Omit<IconProps, 'type'> {
4
4
  type: TYPE;
5
5
  }
6
6
  export declare function VariableIcon({ type, ...props }: VariableIconProps): import("react/jsx-runtime").JSX.Element | null;
7
+ //# sourceMappingURL=VariableIcon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VariableIcon.d.ts","sourceRoot":"","sources":["../../../../src/components/inputs/variables/VariableIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAUrD,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC;IAChE,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,iBAAiB,kDAmBjE"}
@@ -1,8 +1,9 @@
1
- import { VariableMentionNodeAttrs } from '../../../types.ts';
2
1
  import { SuggestionKeyDownProps, SuggestionProps } from '@tiptap/suggestion';
2
+ import { VariableMentionNodeAttrs } from '../../../types';
3
3
  export interface VariableSuggestionProps extends SuggestionProps<VariableMentionNodeAttrs, VariableMentionNodeAttrs> {
4
4
  ref: React.RefObject<{
5
5
  onKeyDown: (props: SuggestionKeyDownProps) => boolean;
6
6
  }>;
7
7
  }
8
8
  export declare function VariableSuggestion({ items, command, ref, }: VariableSuggestionProps): import("react/jsx-runtime").JSX.Element;
9
+ //# sourceMappingURL=VariableSuggestion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VariableSuggestion.d.ts","sourceRoot":"","sources":["../../../../src/components/inputs/variables/VariableSuggestion.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAIxD,MAAM,WAAW,uBACf,SAAQ,eAAe,CAAC,wBAAwB,EAAE,wBAAwB,CAAC;IAC3E,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC;QACnB,SAAS,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,OAAO,CAAC;KACvD,CAAC,CAAC;CACJ;AAED,wBAAgB,kBAAkB,CAAC,EACjC,KAAK,EACL,OAAO,EACP,GAAG,GACJ,EAAE,uBAAuB,2CAiEzB"}
@@ -21,15 +21,15 @@ function x({
21
21
  })), /* @__PURE__ */ a("div", { className: "flex flex-col overflow-clip rounded-md bg-elevation-100 empty:hidden", children: n.map((e, t) => /* @__PURE__ */ a(
22
22
  "button",
23
23
  {
24
- type: "button",
25
24
  className: b(
26
- "cursor-pointer rounded-none border-none bg-transparent px-3 py-1 text-lg text-nowrap",
25
+ "cursor-pointer text-nowrap rounded-none border-none bg-transparent px-3 py-1 text-lg",
27
26
  {
28
27
  "bg-elevation-800 text-elevation-0": t === r,
29
28
  "hover:bg-elevation-250": t !== r
30
29
  }
31
30
  ),
32
31
  onClick: () => l(t),
32
+ type: "button",
33
33
  children: e.label
34
34
  },
35
35
  t
@@ -1 +1 @@
1
- {"version":3,"file":"VariableSuggestion.js","sources":["../../../../src/components/inputs/variables/VariableSuggestion.tsx"],"sourcesContent":["import type { VariableMentionNodeAttrs } from \"@/types\";\nimport type {\n SuggestionKeyDownProps,\n SuggestionProps,\n} from \"@tiptap/suggestion\";\nimport { useEffect, useImperativeHandle, useState } from \"react\";\n\nimport { cn } from \"@/utils/cn\";\n\nexport interface VariableSuggestionProps extends SuggestionProps<\n VariableMentionNodeAttrs,\n VariableMentionNodeAttrs\n> {\n ref: React.RefObject<{\n onKeyDown: (props: SuggestionKeyDownProps) => boolean;\n }>;\n}\n\nexport function VariableSuggestion({\n items,\n command,\n ref,\n}: VariableSuggestionProps) {\n const [selectedIndex, setSelectedIndex] = useState(0);\n\n const selectItem = (index: number) => {\n const item = items[index];\n\n if (item) command(item);\n };\n\n const upHandler = () => {\n setSelectedIndex((selectedIndex + items.length - 1) % items.length);\n };\n\n const downHandler = () => {\n setSelectedIndex((selectedIndex + 1) % items.length);\n };\n\n const enterHandler = () => {\n selectItem(selectedIndex);\n };\n\n useEffect(() => setSelectedIndex(0), [items]);\n\n useImperativeHandle(ref, () => ({\n onKeyDown: ({ event }) => {\n if (event.key === \"ArrowUp\") {\n upHandler();\n return true;\n }\n\n if (event.key === \"ArrowDown\") {\n downHandler();\n return true;\n }\n\n if (event.key === \"Enter\") {\n enterHandler();\n return true;\n }\n\n return false;\n },\n }));\n\n return (\n <div className=\"flex flex-col overflow-clip rounded-md bg-elevation-100 empty:hidden\">\n {items.map((item, index) => (\n <button\n key={index}\n type=\"button\"\n className={cn(\n \"cursor-pointer rounded-none border-none bg-transparent px-3 py-1 text-lg text-nowrap\",\n {\n \"bg-elevation-800 text-elevation-0\": index === selectedIndex,\n \"hover:bg-elevation-250\": index !== selectedIndex,\n },\n )}\n onClick={() => selectItem(index)}\n >\n {item.label}\n </button>\n ))}\n </div>\n );\n}\n"],"names":["VariableSuggestion","items","command","ref","selectedIndex","setSelectedIndex","useState","selectItem","index","item","upHandler","downHandler","enterHandler","useEffect","useImperativeHandle","event","jsx","cn"],"mappings":";;;AAkBO,SAASA,EAAmB;AAAA,EACjC,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,KAAAC;AACF,GAA4B;AAC1B,QAAM,CAACC,GAAeC,CAAgB,IAAIC,EAAS,CAAC,GAE9CC,IAAa,CAACC,MAAkB;AACpC,UAAMC,IAAOR,EAAMO,CAAK;AAExB,IAAIC,OAAcA,CAAI;AAAA,EACxB,GAEMC,IAAY,MAAM;AACtB,IAAAL,GAAkBD,IAAgBH,EAAM,SAAS,KAAKA,EAAM,MAAM;AAAA,EACpE,GAEMU,IAAc,MAAM;AACxB,IAAAN,GAAkBD,IAAgB,KAAKH,EAAM,MAAM;AAAA,EACrD,GAEMW,IAAe,MAAM;AACzB,IAAAL,EAAWH,CAAa;AAAA,EAC1B;AAEA,SAAAS,EAAU,MAAMR,EAAiB,CAAC,GAAG,CAACJ,CAAK,CAAC,GAE5Ca,EAAoBX,GAAK,OAAO;AAAA,IAC9B,WAAW,CAAC,EAAE,OAAAY,QACRA,EAAM,QAAQ,aAChBL,EAAA,GACO,MAGLK,EAAM,QAAQ,eAChBJ,EAAA,GACO,MAGLI,EAAM,QAAQ,WAChBH,EAAA,GACO,MAGF;AAAA,EACT,EACA,GAGA,gBAAAI,EAAC,SAAI,WAAU,wEACZ,YAAM,IAAI,CAACP,GAAMD,MAChB,gBAAAQ;AAAA,IAAC;AAAA,IAAA;AAAA,MAEC,MAAK;AAAA,MACL,WAAWC;AAAA,QACT;AAAA,QACA;AAAA,UACE,qCAAqCT,MAAUJ;AAAA,UAC/C,0BAA0BI,MAAUJ;AAAA,QAAA;AAAA,MACtC;AAAA,MAEF,SAAS,MAAMG,EAAWC,CAAK;AAAA,MAE9B,UAAAC,EAAK;AAAA,IAAA;AAAA,IAXDD;AAAA,EAAA,CAaR,GACH;AAEJ;"}
1
+ {"version":3,"file":"VariableSuggestion.js","sources":["../../../../src/components/inputs/variables/VariableSuggestion.tsx"],"sourcesContent":["import type {\n SuggestionKeyDownProps,\n SuggestionProps,\n} from '@tiptap/suggestion';\nimport { useEffect, useImperativeHandle, useState } from 'react';\nimport type { VariableMentionNodeAttrs } from '@/types';\n\nimport { cn } from '@/utils/cn';\n\nexport interface VariableSuggestionProps\n extends SuggestionProps<VariableMentionNodeAttrs, VariableMentionNodeAttrs> {\n ref: React.RefObject<{\n onKeyDown: (props: SuggestionKeyDownProps) => boolean;\n }>;\n}\n\nexport function VariableSuggestion({\n items,\n command,\n ref,\n}: VariableSuggestionProps) {\n const [selectedIndex, setSelectedIndex] = useState(0);\n\n const selectItem = (index: number) => {\n const item = items[index];\n\n if (item) command(item);\n };\n\n const upHandler = () => {\n setSelectedIndex((selectedIndex + items.length - 1) % items.length);\n };\n\n const downHandler = () => {\n setSelectedIndex((selectedIndex + 1) % items.length);\n };\n\n const enterHandler = () => {\n selectItem(selectedIndex);\n };\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>\n useEffect(() => setSelectedIndex(0), [items]);\n\n useImperativeHandle(ref, () => ({\n onKeyDown: ({ event }) => {\n if (event.key === 'ArrowUp') {\n upHandler();\n return true;\n }\n\n if (event.key === 'ArrowDown') {\n downHandler();\n return true;\n }\n\n if (event.key === 'Enter') {\n enterHandler();\n return true;\n }\n\n return false;\n },\n }));\n\n return (\n <div className=\"flex flex-col overflow-clip rounded-md bg-elevation-100 empty:hidden\">\n {items.map((item, index) => (\n <button\n className={cn(\n 'cursor-pointer text-nowrap rounded-none border-none bg-transparent px-3 py-1 text-lg',\n {\n 'bg-elevation-800 text-elevation-0': index === selectedIndex,\n 'hover:bg-elevation-250': index !== selectedIndex,\n },\n )}\n key={index}\n onClick={() => selectItem(index)}\n type=\"button\"\n >\n {item.label}\n </button>\n ))}\n </div>\n );\n}\n"],"names":["VariableSuggestion","items","command","ref","selectedIndex","setSelectedIndex","useState","selectItem","index","item","upHandler","downHandler","enterHandler","useEffect","useImperativeHandle","event","jsx","cn"],"mappings":";;;AAgBO,SAASA,EAAmB;AAAA,EACjC,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,KAAAC;AACF,GAA4B;AAC1B,QAAM,CAACC,GAAeC,CAAgB,IAAIC,EAAS,CAAC,GAE9CC,IAAa,CAACC,MAAkB;AACpC,UAAMC,IAAOR,EAAMO,CAAK;AAExB,IAAIC,OAAcA,CAAI;AAAA,EACxB,GAEMC,IAAY,MAAM;AACtB,IAAAL,GAAkBD,IAAgBH,EAAM,SAAS,KAAKA,EAAM,MAAM;AAAA,EACpE,GAEMU,IAAc,MAAM;AACxB,IAAAN,GAAkBD,IAAgB,KAAKH,EAAM,MAAM;AAAA,EACrD,GAEMW,IAAe,MAAM;AACzB,IAAAL,EAAWH,CAAa;AAAA,EAC1B;AAGA,SAAAS,EAAU,MAAMR,EAAiB,CAAC,GAAG,CAACJ,CAAK,CAAC,GAE5Ca,EAAoBX,GAAK,OAAO;AAAA,IAC9B,WAAW,CAAC,EAAE,OAAAY,QACRA,EAAM,QAAQ,aAChBL,EAAA,GACO,MAGLK,EAAM,QAAQ,eAChBJ,EAAA,GACO,MAGLI,EAAM,QAAQ,WAChBH,EAAA,GACO,MAGF;AAAA,EACT,EACA,GAGA,gBAAAI,EAAC,SAAI,WAAU,wEACZ,YAAM,IAAI,CAACP,GAAMD,MAChB,gBAAAQ;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC;AAAA,QACT;AAAA,QACA;AAAA,UACE,qCAAqCT,MAAUJ;AAAA,UAC/C,0BAA0BI,MAAUJ;AAAA,QAAA;AAAA,MACtC;AAAA,MAGF,SAAS,MAAMG,EAAWC,CAAK;AAAA,MAC/B,MAAK;AAAA,MAEJ,UAAAC,EAAK;AAAA,IAAA;AAAA,IAJDD;AAAA,EAAA,CAMR,GACH;AAEJ;"}