payload-intl 0.3.0 → 1.1.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.
- package/README.md +5 -8
- package/dist/components/MessageController.js +5 -5
- package/dist/components/MessageController.js.map +1 -1
- package/dist/components/MessagesForm.js +28 -32
- package/dist/components/MessagesForm.js.map +1 -1
- package/dist/components/actions/JsonImport.js +4 -4
- package/dist/components/actions/JsonImport.js.map +1 -1
- package/dist/components/inputs/InputWrapper.js.map +1 -1
- package/dist/components/inputs/MessageInput.js +1 -1
- package/dist/components/inputs/MessageInput.js.map +1 -1
- package/dist/components/inputs/variables/VariableChip.js +3 -3
- package/dist/components/inputs/variables/VariableChip.js.map +1 -1
- package/dist/components/inputs/variables/VariableSuggestion.js +2 -2
- package/dist/components/inputs/variables/VariableSuggestion.js.map +1 -1
- package/dist/components/inputs/variables/editors/PluralVariableEditor.js +31 -34
- package/dist/components/inputs/variables/editors/PluralVariableEditor.js.map +1 -1
- package/dist/components/inputs/variables/editors/SelectVariableEditor.js +17 -10
- package/dist/components/inputs/variables/editors/SelectVariableEditor.js.map +1 -1
- package/dist/components/inputs/variables/editors/TagVariableEditor.js.map +1 -1
- package/dist/components/inputs/variables/extension.js.map +1 -1
- package/dist/components/inputs/variables/pickers/NumericVariablePicker.js +4 -4
- package/dist/components/inputs/variables/pickers/NumericVariablePicker.js.map +1 -1
- package/dist/components/layout/MessageField.js +6 -6
- package/dist/components/layout/MessageField.js.map +1 -1
- package/dist/components/layout/MessagesTabs.js +3 -3
- package/dist/components/layout/MessagesTabs.js.map +1 -1
- package/dist/components/layout/MessagesTree.js +2 -2
- package/dist/components/layout/MessagesTree.js.map +1 -1
- package/dist/const.js +14 -0
- package/dist/const.js.map +1 -0
- package/dist/context/messages-form.js.map +1 -1
- package/dist/endpoints/get-messages.js +9 -9
- package/dist/endpoints/get-messages.js.map +1 -1
- package/dist/endpoints/set-messages.js +28 -28
- package/dist/endpoints/set-messages.js.map +1 -1
- package/dist/exports/link.js.map +1 -1
- package/dist/exports/view.js +26 -30
- package/dist/exports/view.js.map +1 -1
- package/dist/index.js +19 -34
- package/dist/index.js.map +1 -1
- package/dist/requests/fetchMessages.js +30 -21
- package/dist/requests/fetchMessages.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utils/cn.js.map +1 -1
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/error-handling.js.map +1 -1
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/guards.js +14 -11
- package/dist/utils/guards.js.map +1 -1
- package/dist/utils/icu-tranform.js +32 -27
- package/dist/utils/icu-tranform.js.map +1 -1
- package/dist/utils/sanitize.js.map +1 -1
- package/dist/utils/schema.js.map +1 -1
- package/dist/utils/validate.js.map +1 -1
- package/package.json +55 -72
- package/dist/components/MessageController.d.ts +0 -14
- package/dist/components/MessagesForm.d.ts +0 -10
- package/dist/components/actions/JsonImport.d.ts +0 -1
- package/dist/components/actions/Move.d.ts +0 -3
- package/dist/components/inputs/InputWrapper.d.ts +0 -7
- package/dist/components/inputs/LexicalInput.d.ts +0 -19
- package/dist/components/inputs/MessageInput.d.ts +0 -10
- package/dist/components/inputs/variables/VariableChip.d.ts +0 -2
- package/dist/components/inputs/variables/VariableIcon.d.ts +0 -6
- package/dist/components/inputs/variables/VariableSuggestion.d.ts +0 -8
- package/dist/components/inputs/variables/editors/DateVariableEditor.d.ts +0 -9
- package/dist/components/inputs/variables/editors/PluralVariableEditor.d.ts +0 -9
- package/dist/components/inputs/variables/editors/SelectVariableEditor.d.ts +0 -6
- package/dist/components/inputs/variables/editors/TagVariableEditor.d.ts +0 -6
- package/dist/components/inputs/variables/editors/TimeVariableEditor.d.ts +0 -9
- package/dist/components/inputs/variables/extension.d.ts +0 -3
- package/dist/components/inputs/variables/pickers/NumericVariablePicker.d.ts +0 -6
- package/dist/components/inputs/variables/pickers/TemporalElementEditor.d.ts +0 -6
- package/dist/components/layout/MessageField.d.ts +0 -9
- package/dist/components/layout/MessagesTabs.d.ts +0 -8
- package/dist/components/layout/MessagesTree.d.ts +0 -9
- package/dist/context/messages-form.d.ts +0 -28
- package/dist/endpoints/get-messages.d.ts +0 -2
- package/dist/endpoints/set-messages.d.ts +0 -2
- package/dist/exports/link.d.ts +0 -7
- package/dist/exports/rsc.d.ts +0 -2
- package/dist/exports/view.d.ts +0 -9
- package/dist/index.d.ts +0 -5
- package/dist/requests/fetchMessages.d.ts +0 -3
- package/dist/types.d.ts +0 -40
- package/dist/utils/cn.d.ts +0 -2
- package/dist/utils/config.d.ts +0 -11
- package/dist/utils/error-handling.d.ts +0 -1
- package/dist/utils/format.d.ts +0 -3
- package/dist/utils/guards.d.ts +0 -4
- package/dist/utils/icu-tranform.d.ts +0 -30
- package/dist/utils/sanitize.d.ts +0 -15
- package/dist/utils/schema.d.ts +0 -9
- package/dist/utils/validate.d.ts +0 -5
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
|
}),
|
|
@@ -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
|
-
|
|
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
|
|
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,18 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
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
|
|
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
|
|
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((
|
|
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
|
|
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 (!
|
|
43
|
-
const n = await F(
|
|
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 (
|
|
43
|
+
} catch (s) {
|
|
48
44
|
d.error(
|
|
49
|
-
`Failed to save: ${
|
|
45
|
+
`Failed to save: ${s instanceof Error ? s.message : "Unknown error"}`,
|
|
50
46
|
{ id: r }
|
|
51
47
|
);
|
|
52
48
|
}
|
|
53
49
|
};
|
|
54
|
-
return /* @__PURE__ */
|
|
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__ */
|
|
58
|
+
/* @__PURE__ */ t("h1", { className: "text-4xl", children: "Messages" }),
|
|
63
59
|
/* @__PURE__ */ o("div", { className: "flex items-center gap-2", children: [
|
|
64
|
-
/* @__PURE__ */
|
|
65
|
-
/* @__PURE__ */
|
|
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__ */
|
|
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__ */
|
|
92
|
-
m && Object.entries(a).map(([e, r]) => typeof r == "string" ? /* @__PURE__ */
|
|
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
|
-
|
|
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__ */
|
|
97
|
+
) : /* @__PURE__ */ t(
|
|
102
98
|
g,
|
|
103
99
|
{
|
|
104
|
-
className:
|
|
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
|
-
|
|
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":["
|
|
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":";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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;"}
|
|
@@ -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
|
-
|
|
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
|
|
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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,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputWrapper.js","sources":["../../../src/components/inputs/InputWrapper.tsx"],"sourcesContent":["import
|
|
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;"}
|
|
@@ -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, {
|
|
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
|
|
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;"}
|
|
@@ -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 {
|
|
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;"}
|
|
@@ -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
|
|
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 {
|
|
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;"}
|
|
@@ -63,8 +63,8 @@ function A({
|
|
|
63
63
|
"button",
|
|
64
64
|
{
|
|
65
65
|
className: "ml-auto flex cursor-pointer items-center justify-center border-none bg-transparent p-0 hover:text-error",
|
|
66
|
-
type: "button",
|
|
67
66
|
onClick: () => a.remove(t),
|
|
67
|
+
type: "button",
|
|
68
68
|
children: /* @__PURE__ */ r(v, { size: 16 })
|
|
69
69
|
}
|
|
70
70
|
)
|
|
@@ -74,8 +74,8 @@ function A({
|
|
|
74
74
|
/* @__PURE__ */ r(
|
|
75
75
|
"input",
|
|
76
76
|
{
|
|
77
|
-
type: "text",
|
|
78
77
|
className: "col-span-2 focus:outline-none",
|
|
78
|
+
type: "text",
|
|
79
79
|
...d("other", { required: !0 })
|
|
80
80
|
}
|
|
81
81
|
)
|
|
@@ -88,8 +88,8 @@ function A({
|
|
|
88
88
|
"input",
|
|
89
89
|
{
|
|
90
90
|
className: "w-8 text-center",
|
|
91
|
-
type: "numeric",
|
|
92
91
|
placeholder: "0",
|
|
92
|
+
type: "numeric",
|
|
93
93
|
...d("offset")
|
|
94
94
|
}
|
|
95
95
|
)
|
|
@@ -99,8 +99,8 @@ function A({
|
|
|
99
99
|
/* @__PURE__ */ r(i.Portal, { children: /* @__PURE__ */ o(
|
|
100
100
|
i.Content,
|
|
101
101
|
{
|
|
102
|
+
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 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-y-auto overflow-x-hidden rounded-md border border-border bg-elevation-50 shadow-md data-[state=closed]:animate-out data-[state=open]:animate-in",
|
|
102
103
|
sideOffset: 4,
|
|
103
|
-
className: "z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border bg-elevation-50 shadow-md 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",
|
|
104
104
|
children: [
|
|
105
105
|
/* @__PURE__ */ r("div", { className: "flex flex-col", children: z.filter(
|
|
106
106
|
(e) => a.fields.every((t) => t.name !== e)
|
|
@@ -125,42 +125,39 @@ function A({
|
|
|
125
125
|
},
|
|
126
126
|
e
|
|
127
127
|
)) }),
|
|
128
|
-
/* @__PURE__ */ o("div", { className: "flex items-center justify-between gap-2 border-
|
|
128
|
+
/* @__PURE__ */ o("div", { className: "flex items-center justify-between gap-2 border-border border-t p-2", children: [
|
|
129
129
|
/* @__PURE__ */ r("label", { htmlFor: "customValue", children: "custom" }),
|
|
130
130
|
/* @__PURE__ */ r(
|
|
131
131
|
F,
|
|
132
132
|
{
|
|
133
133
|
control: c,
|
|
134
134
|
name: "customValue",
|
|
135
|
-
render: ({ field: e }) => (
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
"
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
)
|
|
135
|
+
render: ({ field: e }) => /* @__PURE__ */ r(
|
|
136
|
+
"input",
|
|
137
|
+
{
|
|
138
|
+
className: "w-8 rounded-sm border-transparent text-center focus:border-border focus:outline-none",
|
|
139
|
+
min: 0,
|
|
140
|
+
onChange: ({ currentTarget: { value: t } }) => {
|
|
141
|
+
const n = Number(t);
|
|
142
|
+
isNaN(n) || n < 0 || e.onChange(n);
|
|
143
|
+
},
|
|
144
|
+
onKeyDown: (t) => {
|
|
145
|
+
t.key !== "Enter" || e.value === void 0 || a.fields.some(
|
|
146
|
+
(s) => s.name === `=${e.value}`
|
|
147
|
+
) || (a.append(
|
|
148
|
+
{
|
|
149
|
+
name: `=${e.value}`,
|
|
150
|
+
content: ""
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
shouldFocus: !0
|
|
154
|
+
}
|
|
155
|
+
), e.onChange(void 0));
|
|
156
|
+
},
|
|
157
|
+
placeholder: "=0",
|
|
158
|
+
type: "numeric",
|
|
159
|
+
value: e.value ?? ""
|
|
160
|
+
}
|
|
164
161
|
)
|
|
165
162
|
}
|
|
166
163
|
)
|