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
|
@@ -1,58 +1,61 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TYPE as r, parse as i } from "@formatjs/icu-messageformat-parser";
|
|
2
2
|
import { formatVariableLabel as p } from "./format.js";
|
|
3
|
-
|
|
3
|
+
import { uncaughtSwitchCase as o } from "./guards.js";
|
|
4
|
+
const l = (e) => i(e), c = (e) => e.map((t) => {
|
|
4
5
|
switch (t.type) {
|
|
5
6
|
case r.literal:
|
|
6
7
|
return t.value;
|
|
7
8
|
case r.argument:
|
|
8
|
-
return
|
|
9
|
+
return u(t.value);
|
|
9
10
|
case r.number:
|
|
10
|
-
return
|
|
11
|
+
return u(t.value, "number");
|
|
11
12
|
case r.select:
|
|
12
|
-
return
|
|
13
|
+
return u(
|
|
13
14
|
t.value,
|
|
14
15
|
"select",
|
|
15
16
|
Object.entries(t.options).map(
|
|
16
|
-
([s,
|
|
17
|
+
([s, a]) => `${s} {${a.value.length > 0 ? c(a.value) : s}}`
|
|
17
18
|
)
|
|
18
19
|
);
|
|
19
20
|
case r.plural:
|
|
20
|
-
return
|
|
21
|
+
return u(t.value, "plural", [
|
|
21
22
|
t.offset < 0 && `offset:${t.offset}`,
|
|
22
23
|
...Object.entries(t.options).map(
|
|
23
|
-
([s,
|
|
24
|
+
([s, a]) => `${s} {${a.value.length > 0 ? c(a.value) : s}}`
|
|
24
25
|
)
|
|
25
26
|
]);
|
|
26
27
|
case r.tag:
|
|
27
|
-
return `<${t.value}>${
|
|
28
|
+
return `<${t.value}>${c(t.children)}</${t.value}>`;
|
|
28
29
|
case r.date:
|
|
29
|
-
return
|
|
30
|
+
return u(t.value, "date");
|
|
30
31
|
case r.time:
|
|
31
|
-
return
|
|
32
|
+
return u(t.value, "time");
|
|
32
33
|
case r.pound:
|
|
33
34
|
return "#";
|
|
35
|
+
default:
|
|
36
|
+
return o(t);
|
|
34
37
|
}
|
|
35
|
-
}).join(""),
|
|
36
|
-
if (t === void 0) return `{${
|
|
37
|
-
const
|
|
38
|
+
}).join(""), u = (e, t, s = []) => {
|
|
39
|
+
if (t === void 0) return `{${e}}`;
|
|
40
|
+
const a = s.filter(
|
|
38
41
|
(n) => typeof n == "string" && n.length > 0
|
|
39
42
|
);
|
|
40
|
-
return
|
|
41
|
-
},
|
|
43
|
+
return a.length === 0 ? `{${e}, ${t}}` : `{${e}, ${t}, ${a.join(" ")}}`;
|
|
44
|
+
}, $ = (e) => {
|
|
42
45
|
try {
|
|
43
46
|
return {
|
|
44
47
|
type: "doc",
|
|
45
48
|
content: [
|
|
46
49
|
{
|
|
47
50
|
type: "paragraph",
|
|
48
|
-
content:
|
|
49
|
-
(
|
|
50
|
-
switch (
|
|
51
|
+
content: l(e).flatMap(
|
|
52
|
+
(a) => {
|
|
53
|
+
switch (a.type) {
|
|
51
54
|
case r.literal:
|
|
52
55
|
return [
|
|
53
56
|
{
|
|
54
57
|
type: "text",
|
|
55
|
-
text:
|
|
58
|
+
text: a.value
|
|
56
59
|
}
|
|
57
60
|
];
|
|
58
61
|
case r.pound:
|
|
@@ -73,12 +76,14 @@ const i = (a) => o(a), u = (a) => a.map((t) => {
|
|
|
73
76
|
{
|
|
74
77
|
type: "variable",
|
|
75
78
|
attrs: {
|
|
76
|
-
name:
|
|
77
|
-
label: p(
|
|
78
|
-
icu:
|
|
79
|
+
name: a.value,
|
|
80
|
+
label: p(a),
|
|
81
|
+
icu: c([a])
|
|
79
82
|
}
|
|
80
83
|
}
|
|
81
84
|
];
|
|
85
|
+
default:
|
|
86
|
+
return o(a);
|
|
82
87
|
}
|
|
83
88
|
}
|
|
84
89
|
)
|
|
@@ -94,7 +99,7 @@ const i = (a) => o(a), u = (a) => a.map((t) => {
|
|
|
94
99
|
content: [
|
|
95
100
|
{
|
|
96
101
|
type: "text",
|
|
97
|
-
text:
|
|
102
|
+
text: e
|
|
98
103
|
}
|
|
99
104
|
]
|
|
100
105
|
}
|
|
@@ -103,8 +108,8 @@ const i = (a) => o(a), u = (a) => a.map((t) => {
|
|
|
103
108
|
}
|
|
104
109
|
};
|
|
105
110
|
export {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
111
|
+
l as parseICUMessage,
|
|
112
|
+
$ as parseIcuToProseMirrorJSON,
|
|
113
|
+
c as serializeICUMessage
|
|
109
114
|
};
|
|
110
115
|
//# sourceMappingURL=icu-tranform.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icu-tranform.js","sources":["../../src/utils/icu-tranform.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"icu-tranform.js","sources":["../../src/utils/icu-tranform.ts"],"sourcesContent":["import type { MessageFormatElement } from '@formatjs/icu-messageformat-parser';\nimport { parse, TYPE } from '@formatjs/icu-messageformat-parser';\nimport type { VariableMentionNodeAttrs } from '@/types';\n\nimport { formatVariableLabel } from './format';\nimport { uncaughtSwitchCase } from './guards';\n\n/**\n * Parse an ICU message string into a AST array\n */\nexport const parseICUMessage = (message: string): MessageFormatElement[] =>\n parse(message);\n\n/**\n * Serialize an ICU message AST array into a ICU message string\n */\nexport const serializeICUMessage = (elements: MessageFormatElement[]): string =>\n elements\n .map((element) => {\n switch (element.type) {\n case TYPE.literal:\n return element.value;\n case TYPE.argument:\n return stringifyElement(element.value);\n case TYPE.number:\n // TODO serialize element.style\n return stringifyElement(element.value, 'number');\n case TYPE.select:\n return stringifyElement(\n element.value,\n 'select',\n Object.entries(element.options).map(\n ([key, option]) =>\n `${key} {${option.value.length > 0 ? serializeICUMessage(option.value) : key}}`,\n ),\n );\n case TYPE.plural:\n return stringifyElement(element.value, 'plural', [\n element.offset < 0 && `offset:${element.offset}`,\n ...Object.entries(element.options).map(\n ([key, option]) =>\n `${key} {${\n option.value.length > 0\n ? serializeICUMessage(option.value)\n : key\n }}`,\n ),\n ]);\n case TYPE.tag:\n return `<${element.value}>${serializeICUMessage(element.children)}</${element.value}>`;\n case TYPE.date:\n // TODO serialize element.style\n return stringifyElement(element.value, 'date');\n case TYPE.time:\n // TODO serialize element.style\n return stringifyElement(element.value, 'time');\n case TYPE.pound:\n return '#';\n default:\n return uncaughtSwitchCase(element);\n }\n })\n .join('');\n\nconst stringifyElement = (\n name: string,\n type?: string,\n options: (string | boolean)[] = [],\n) => {\n if (type === undefined) return `{${name}}`;\n\n const filteredOptions = options.filter(\n (option): option is string =>\n typeof option === 'string' && option.length > 0,\n );\n if (filteredOptions.length === 0) return `{${name}, ${type}}`;\n\n return `{${name}, ${type}, ${filteredOptions.join(' ')}}`;\n};\n\ntype TextContent = {\n type: 'text';\n text: string;\n};\n\ntype VariableContent = {\n type: 'variable';\n attrs: VariableMentionNodeAttrs;\n};\n\ntype ProseMirrorJSONRepresentation = {\n type: 'doc';\n content: {\n type: 'paragraph';\n content: (TextContent | VariableContent)[];\n }[];\n};\n\n/**\n * Parse an ICU message string into a ProseMirror JSON representation\n */\nexport const parseIcuToProseMirrorJSON = (\n icuMessage: string,\n): ProseMirrorJSONRepresentation => {\n try {\n const elements = parseICUMessage(icuMessage);\n const content = elements.flatMap<TextContent | VariableContent>(\n (element) => {\n switch (element.type) {\n case TYPE.literal:\n return [\n {\n type: 'text',\n text: element.value,\n },\n ];\n case TYPE.pound:\n return [\n {\n type: 'text',\n text: '#',\n },\n ];\n case TYPE.argument:\n case TYPE.number:\n case TYPE.date:\n case TYPE.time:\n case TYPE.select:\n case TYPE.plural:\n case TYPE.tag:\n return [\n {\n type: 'variable',\n attrs: {\n name: element.value,\n label: formatVariableLabel(element),\n icu: serializeICUMessage([element]),\n },\n },\n ];\n default:\n return uncaughtSwitchCase(element);\n }\n },\n );\n\n return {\n type: 'doc',\n content: [\n {\n type: 'paragraph',\n content,\n },\n ],\n };\n } catch (error) {\n return {\n type: 'doc',\n content: [\n {\n type: 'paragraph',\n content: [\n {\n type: 'text',\n text: icuMessage,\n },\n ],\n },\n ],\n };\n }\n};\n"],"names":["parseICUMessage","message","parse","serializeICUMessage","elements","element","TYPE","stringifyElement","key","option","uncaughtSwitchCase","name","type","options","filteredOptions","parseIcuToProseMirrorJSON","icuMessage","formatVariableLabel"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize.js","sources":["../../src/utils/sanitize.ts"],"sourcesContent":["import type { DeepPartial, Messages } from
|
|
1
|
+
{"version":3,"file":"sanitize.js","sources":["../../src/utils/sanitize.ts"],"sourcesContent":["import type { DeepPartial, Messages } from '@/types';\n\n/**\n * Sanitize messages data to match the schema.\n * Stored messages might contain keys that are not in the config.\n * This happens when messages in the config were (re)moved.\n *\n * Keep exactly the keys from `shape`, fill values from `source` when present.\n * - Leaf present as string -> included\n * - Leaf missing/non-string -> omitted\n * - Empty nested groups -> omitted\n */\n\n/**\n\n */\nexport function sanitizeMessages(\n config: Messages,\n data: unknown,\n): DeepPartial<Messages> {\n const out: Record<string, unknown> = {};\n const src = isObj(data) ? data : {};\n\n for (const key of Object.keys(config)) {\n const shapeVal = (config as Record<string, unknown>)[key];\n const srcVal = src[key];\n\n if (isObj(shapeVal)) {\n const child = sanitizeMessages(shapeVal as Messages, srcVal);\n if (isObj(child) && Object.keys(child).length > 0) {\n out[key] = child;\n }\n // else: omit empty group\n } else {\n // Leaf: only keep if the source has a string\n if (typeof srcVal === 'string') {\n out[key] = srcVal;\n }\n // else: omit leaf\n }\n }\n\n return out as DeepPartial<Messages>;\n}\n\nfunction isObj(x: unknown): x is Record<string, unknown> {\n return !!x && typeof x === 'object' && !Array.isArray(x);\n}\n"],"names":["sanitizeMessages","config","data","out","src","isObj","key","shapeVal","srcVal","child","x"],"mappings":"AAgBO,SAASA,EACdC,GACAC,GACuB;AACvB,QAAMC,IAA+B,CAAA,GAC/BC,IAAMC,EAAMH,CAAI,IAAIA,IAAO,CAAA;AAEjC,aAAWI,KAAO,OAAO,KAAKL,CAAM,GAAG;AACrC,UAAMM,IAAYN,EAAmCK,CAAG,GAClDE,IAASJ,EAAIE,CAAG;AAEtB,QAAID,EAAME,CAAQ,GAAG;AACnB,YAAME,IAAQT,EAAiBO,GAAsBC,CAAM;AAC3D,MAAIH,EAAMI,CAAK,KAAK,OAAO,KAAKA,CAAK,EAAE,SAAS,MAC9CN,EAAIG,CAAG,IAAIG;AAAA,IAGf;AAEE,MAAI,OAAOD,KAAW,aACpBL,EAAIG,CAAG,IAAIE;AAAA,EAIjB;AAEA,SAAOL;AACT;AAEA,SAASE,EAAMK,GAA0C;AACvD,SAAO,CAAC,CAACA,KAAK,OAAOA,KAAM,YAAY,CAAC,MAAM,QAAQA,CAAC;AACzD;"}
|
package/dist/utils/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sources":["../../src/utils/schema.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"schema.js","sources":["../../src/utils/schema.ts"],"sourcesContent":["import type { MessageFormatElement } from '@formatjs/icu-messageformat-parser';\nimport { parse, TYPE } from '@formatjs/icu-messageformat-parser';\nimport type { MessageSchema, TemplateVariable } from '@/types';\n\nexport const parseMessageSchema = (schema: MessageSchema): MessageConfig => {\n const description = schema.match(/^\\[.+\\]/)?.[0];\n // TODO add support for variables description\n // const withoutDescription = schema.replace(description || \"\", \"\").trim();\n // const withoutOptional = withoutDescription.split(\" | \")[0]?.trim();\n\n return {\n description: description?.slice(1, -1),\n // type: schema === \"$RICH$\" ? \"rich\" : \"icu\",\n type: 'icu',\n variables: extractTemplateVariables(schema),\n };\n};\n\nexport const extractTemplateVariables = (\n schema: MessageSchema,\n): TemplateVariable[] => collectTemplateVariables(parse(schema));\n\nconst collectTemplateVariables = (\n parts: MessageFormatElement[],\n): TemplateVariable[] =>\n parts.flatMap<TemplateVariable>((part) => {\n switch (part.type) {\n case TYPE.literal:\n case TYPE.pound:\n return [];\n case TYPE.argument:\n case TYPE.number:\n case TYPE.date:\n case TYPE.time:\n return [part];\n case TYPE.plural:\n case TYPE.select:\n return [\n part,\n ...collectTemplateVariables(\n Object.values(part.options).flatMap(({ value }) => value),\n ),\n ];\n case TYPE.tag:\n return [part, ...collectTemplateVariables(part.children)];\n default:\n return [part];\n }\n });\n\n// MARK: Types\n\nexport type MessageType = 'icu'; // \"rich\";\nexport type MessageConfig = {\n description: string | undefined;\n type: MessageType;\n variables: TemplateVariable[];\n};\n"],"names":["parseMessageSchema","schema","extractTemplateVariables","collectTemplateVariables","parse","parts","part","TYPE","value"],"mappings":";AAIO,MAAMA,IAAqB,CAACC,OAM1B;AAAA,EACL,aANkBA,EAAO,MAAM,SAAS,IAAI,CAAC,GAMnB,MAAM,GAAG,EAAE;AAAA;AAAA,EAErC,MAAM;AAAA,EACN,WAAWC,EAAyBD,CAAM;AAAA,IAIjCC,IAA2B,CACtCD,MACuBE,EAAyBC,EAAMH,CAAM,CAAC,GAEzDE,IAA2B,CAC/BE,MAEAA,EAAM,QAA0B,CAACC,MAAS;AACxC,UAAQA,EAAK,MAAA;AAAA,IACX,KAAKC,EAAK;AAAA,IACV,KAAKA,EAAK;AACR,aAAO,CAAA;AAAA,IACT,KAAKA,EAAK;AAAA,IACV,KAAKA,EAAK;AAAA,IACV,KAAKA,EAAK;AAAA,IACV,KAAKA,EAAK;AACR,aAAO,CAACD,CAAI;AAAA,IACd,KAAKC,EAAK;AAAA,IACV,KAAKA,EAAK;AACR,aAAO;AAAA,QACLD;AAAA,QACA,GAAGH;AAAA,UACD,OAAO,OAAOG,EAAK,OAAO,EAAE,QAAQ,CAAC,EAAE,OAAAE,EAAA,MAAYA,CAAK;AAAA,QAAA;AAAA,MAC1D;AAAA,IAEJ,KAAKD,EAAK;AACR,aAAO,CAACD,GAAM,GAAGH,EAAyBG,EAAK,QAAQ,CAAC;AAAA,IAC1D;AACE,aAAO,CAACA,CAAI;AAAA,EAAA;AAElB,CAAC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sources":["../../src/utils/validate.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"validate.js","sources":["../../src/utils/validate.ts"],"sourcesContent":["import { TYPE } from '@formatjs/icu-messageformat-parser';\nimport type { ValidateResult } from 'react-hook-form';\nimport type { TemplateVariable } from '@/types';\n\nimport { isNumericElement, isTemporalElement } from './guards';\nimport { extractTemplateVariables } from './schema';\n\nexport const validateMessage = (\n value: unknown,\n variables: TemplateVariable[],\n): ValidateResult => {\n if (typeof value !== 'string') return 'Invalid value';\n\n try {\n const variableUsages = extractTemplateVariables(value);\n\n for (const allowedVariable of variables) {\n const variableUsage = variableUsages.find(\n (placeholder) => placeholder.value === allowedVariable.value,\n );\n\n if (!variableUsage) continue;\n\n if (isNumericElement(allowedVariable)) {\n if (isNumericElement(variableUsage)) continue;\n return `{${allowedVariable.value}} has invalid type`;\n }\n\n if (isTemporalElement(allowedVariable)) {\n if (isTemporalElement(variableUsage)) continue;\n return `{${allowedVariable.value}} has invalid type`;\n }\n\n switch (allowedVariable.type) {\n case TYPE.argument:\n if (variableUsage.type === TYPE.argument) continue;\n return `{${allowedVariable.value}} has invalid type`;\n case TYPE.select: {\n if (variableUsage.type !== TYPE.select)\n return `{${allowedVariable.value}} has invalid type`;\n\n const allowedOptions = Object.keys(allowedVariable.options);\n for (const option of allowedOptions) {\n if (variableUsage.options[option]) continue;\n return `{${allowedVariable.value}} has missing option: ${option}`;\n }\n const usedOptions = Object.keys(variableUsage.options);\n for (const option of usedOptions) {\n if (allowedOptions.includes(option)) continue;\n return `{${allowedVariable.value}} has unsupported option: ${option}`;\n }\n continue;\n }\n case TYPE.tag:\n if (variableUsage.type === TYPE.tag) continue;\n return `{${allowedVariable.value}} has invalid type`;\n }\n }\n\n const supportedVariables = new Set(variables.map(({ value }) => value));\n\n for (const variableUsage of variableUsages) {\n if (supportedVariables.has(variableUsage.value)) continue;\n return `{${variableUsage.value}} is not supported`;\n }\n\n return true;\n } catch (error) {\n if (!(error instanceof Error)) return false;\n return `Invalid syntax: ${error.message}`;\n }\n};\n\nexport const createValidator =\n (variables: TemplateVariable[]): MessageValidator =>\n (value: unknown) =>\n validateMessage(value, variables);\n\nexport type MessageValidator = (value: unknown) => ValidateResult;\n"],"names":["validateMessage","value","variables","variableUsages","extractTemplateVariables","allowedVariable","variableUsage","placeholder","isNumericElement","isTemporalElement","TYPE","allowedOptions","option","usedOptions","supportedVariables","error","createValidator"],"mappings":";;;AAOO,MAAMA,IAAkB,CAC7BC,GACAC,MACmB;AACnB,MAAI,OAAOD,KAAU,SAAU,QAAO;AAEtC,MAAI;AACF,UAAME,IAAiBC,EAAyBH,CAAK;AAErD,eAAWI,KAAmBH,GAAW;AACvC,YAAMI,IAAgBH,EAAe;AAAA,QACnC,CAACI,MAAgBA,EAAY,UAAUF,EAAgB;AAAA,MAAA;AAGzD,UAAKC,GAEL;AAAA,YAAIE,EAAiBH,CAAe,GAAG;AACrC,cAAIG,EAAiBF,CAAa,EAAG;AACrC,iBAAO,IAAID,EAAgB,KAAK;AAAA,QAClC;AAEA,YAAII,EAAkBJ,CAAe,GAAG;AACtC,cAAII,EAAkBH,CAAa,EAAG;AACtC,iBAAO,IAAID,EAAgB,KAAK;AAAA,QAClC;AAEA,gBAAQA,EAAgB,MAAA;AAAA,UACtB,KAAKK,EAAK;AACR,gBAAIJ,EAAc,SAASI,EAAK,SAAU;AAC1C,mBAAO,IAAIL,EAAgB,KAAK;AAAA,UAClC,KAAKK,EAAK,QAAQ;AAChB,gBAAIJ,EAAc,SAASI,EAAK;AAC9B,qBAAO,IAAIL,EAAgB,KAAK;AAElC,kBAAMM,IAAiB,OAAO,KAAKN,EAAgB,OAAO;AAC1D,uBAAWO,KAAUD;AACnB,kBAAI,CAAAL,EAAc,QAAQM,CAAM;AAChC,uBAAO,IAAIP,EAAgB,KAAK,yBAAyBO,CAAM;AAEjE,kBAAMC,IAAc,OAAO,KAAKP,EAAc,OAAO;AACrD,uBAAWM,KAAUC;AACnB,kBAAI,CAAAF,EAAe,SAASC,CAAM;AAClC,uBAAO,IAAIP,EAAgB,KAAK,6BAA6BO,CAAM;AAErE;AAAA,UACF;AAAA,UACA,KAAKF,EAAK;AACR,gBAAIJ,EAAc,SAASI,EAAK,IAAK;AACrC,mBAAO,IAAIL,EAAgB,KAAK;AAAA,QAAA;AAAA;AAAA,IAEtC;AAEA,UAAMS,IAAqB,IAAI,IAAIZ,EAAU,IAAI,CAAC,EAAE,OAAAD,QAAYA,CAAK,CAAC;AAEtE,eAAWK,KAAiBH;AAC1B,UAAI,CAAAW,EAAmB,IAAIR,EAAc,KAAK;AAC9C,eAAO,IAAIA,EAAc,KAAK;AAGhC,WAAO;AAAA,EACT,SAASS,GAAO;AACd,WAAMA,aAAiB,QAChB,mBAAmBA,EAAM,OAAO,KADD;AAAA,EAExC;AACF,GAEaC,IACX,CAACd,MACD,CAACD,MACCD,EAAgBC,GAAOC,CAAS;"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload-intl",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Payload Plugin for I18N using ICU Messages",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"author": "Michael Zeltner",
|
|
7
5
|
"keywords": [
|
|
8
6
|
"payload",
|
|
9
7
|
"intl",
|
|
@@ -16,16 +14,23 @@
|
|
|
16
14
|
"translations",
|
|
17
15
|
"icu"
|
|
18
16
|
],
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/davincicoding-org/payload-plugins.git",
|
|
20
|
+
"directory": "packages/intl"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": "Michael Zeltner",
|
|
19
24
|
"type": "module",
|
|
20
25
|
"exports": {
|
|
21
26
|
".": {
|
|
22
|
-
"import": "./dist/index.js",
|
|
23
27
|
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js",
|
|
24
29
|
"default": "./dist/index.js"
|
|
25
30
|
},
|
|
26
31
|
"./rsc": {
|
|
27
|
-
"import": "./dist/exports/rsc.js",
|
|
28
32
|
"types": "./dist/exports/rsc.d.ts",
|
|
33
|
+
"import": "./dist/exports/rsc.js",
|
|
29
34
|
"default": "./dist/exports/rsc.js"
|
|
30
35
|
},
|
|
31
36
|
"./styles.css": "./dist/styles.css"
|
|
@@ -35,62 +40,9 @@
|
|
|
35
40
|
"files": [
|
|
36
41
|
"dist"
|
|
37
42
|
],
|
|
38
|
-
"devDependencies": {
|
|
39
|
-
"@eslint/eslintrc": "^3.2.0",
|
|
40
|
-
"@ianvs/prettier-plugin-sort-imports": "^4.5.1",
|
|
41
|
-
"@payloadcms/db-postgres": "3.72.0",
|
|
42
|
-
"@payloadcms/eslint-config": "3.28.0",
|
|
43
|
-
"@payloadcms/next": "3.72.0",
|
|
44
|
-
"@payloadcms/richtext-lexical": "3.72.0",
|
|
45
|
-
"@payloadcms/storage-uploadthing": "3.72.0",
|
|
46
|
-
"@payloadcms/ui": "3.72.0",
|
|
47
|
-
"@playwright/test": "^1.52.0",
|
|
48
|
-
"@tailwindcss/typography": "^0.5.16",
|
|
49
|
-
"@tailwindcss/vite": "^4.1.11",
|
|
50
|
-
"@tiptap/suggestion": "^3.16.0",
|
|
51
|
-
"@types/lodash-es": "^4.17.12",
|
|
52
|
-
"@types/node": "^22.5.4",
|
|
53
|
-
"@types/react": "19.1.0",
|
|
54
|
-
"@types/react-dom": "19.1.2",
|
|
55
|
-
"concurrently": "^9.2.0",
|
|
56
|
-
"cross-env": "^7.0.3",
|
|
57
|
-
"eslint": "^9.23.0",
|
|
58
|
-
"eslint-config-next": "15.3.0",
|
|
59
|
-
"graphql": "^16.8.1",
|
|
60
|
-
"next": "15.5.9",
|
|
61
|
-
"next-intl": "^4.3.4",
|
|
62
|
-
"open": "^10.1.0",
|
|
63
|
-
"payload": "3.72.0",
|
|
64
|
-
"prettier": "^3.4.2",
|
|
65
|
-
"prettier-plugin-tailwindcss": "^0.6.14",
|
|
66
|
-
"react": "19.1.0",
|
|
67
|
-
"react-dom": "19.1.0",
|
|
68
|
-
"rollup-preserve-directives": "^1.1.3",
|
|
69
|
-
"sharp": "0.32.6",
|
|
70
|
-
"sort-package-json": "^2.10.0",
|
|
71
|
-
"tailwindcss": "^4.1.11",
|
|
72
|
-
"tw-animate-css": "^1.3.6",
|
|
73
|
-
"typescript": "5.7.3",
|
|
74
|
-
"vite": "^7.0.6",
|
|
75
|
-
"vite-plugin-dts": "^4.5.4",
|
|
76
|
-
"vite-tsconfig-paths": "^5.1.4",
|
|
77
|
-
"vitest": "^3.1.2"
|
|
78
|
-
},
|
|
79
|
-
"peerDependencies": {
|
|
80
|
-
"@payloadcms/next": ">=3.72.0",
|
|
81
|
-
"@payloadcms/ui": ">=3.72.0",
|
|
82
|
-
"next": ">=15.2.3",
|
|
83
|
-
"payload": ">=3.72.0"
|
|
84
|
-
},
|
|
85
|
-
"engines": {
|
|
86
|
-
"node": "^18.20.2 || >=20.9.0",
|
|
87
|
-
"pnpm": "^9 || ^10"
|
|
88
|
-
},
|
|
89
|
-
"registry": "https://registry.npmjs.org/",
|
|
90
43
|
"dependencies": {
|
|
91
44
|
"@floating-ui/dom": "^1.7.3",
|
|
92
45
|
"@formatjs/icu-messageformat-parser": "^2.11.2",
|
|
93
|
-
"@payloadcms/storage-vercel-blob": "^3.72.0",
|
|
94
46
|
"@radix-ui/react-dropdown-menu": "^2.1.15",
|
|
95
47
|
"@radix-ui/react-hover-card": "^1.1.14",
|
|
96
48
|
"@radix-ui/react-popover": "^1.1.14",
|
|
@@ -105,28 +57,59 @@
|
|
|
105
57
|
"@tiptap/extension-text": "^3.16.0",
|
|
106
58
|
"@tiptap/pm": "^3.16.0",
|
|
107
59
|
"@tiptap/react": "^3.16.0",
|
|
60
|
+
"@tiptap/suggestion": "^3.16.0",
|
|
108
61
|
"clsx": "^2.1.1",
|
|
109
62
|
"lodash-es": "^4.17.21",
|
|
110
63
|
"radix-ui": "^1.4.2",
|
|
111
64
|
"react-hook-form": "^7.58.1",
|
|
112
|
-
"sonner": "^2.0.6",
|
|
113
65
|
"tailwind-merge": "^3.3.1",
|
|
114
66
|
"zod": "^4.0.14"
|
|
115
67
|
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@payloadcms/richtext-lexical": "3.72.0",
|
|
70
|
+
"@payloadcms/ui": "3.72.0",
|
|
71
|
+
"@tailwindcss/typography": "^0.5.16",
|
|
72
|
+
"@tailwindcss/vite": "^4.1.11",
|
|
73
|
+
"@types/lodash-es": "^4.17.12",
|
|
74
|
+
"@types/node": "^22.5.4",
|
|
75
|
+
"@types/react": "19.2.1",
|
|
76
|
+
"@types/react-dom": "19.2.1",
|
|
77
|
+
"next": "15.5.9",
|
|
78
|
+
"payload": "3.72.0",
|
|
79
|
+
"react": "19.2.1",
|
|
80
|
+
"react-dom": "19.2.1",
|
|
81
|
+
"rollup-preserve-directives": "1.1.3",
|
|
82
|
+
"tailwindcss": "^4.1.11",
|
|
83
|
+
"tw-animate-css": "^1.3.6",
|
|
84
|
+
"typescript": "5.7.3",
|
|
85
|
+
"vite": "7.0.6",
|
|
86
|
+
"vite-plugin-dts": "4.5.4",
|
|
87
|
+
"vite-tsconfig-paths": "5.1.4",
|
|
88
|
+
"vitest": "^3.1.2",
|
|
89
|
+
"@repo/configs": "0.0.1"
|
|
90
|
+
},
|
|
91
|
+
"peerDependencies": {
|
|
92
|
+
"@payloadcms/next": ">=3.72.0",
|
|
93
|
+
"@payloadcms/ui": ">=3.72.0",
|
|
94
|
+
"next": ">=15.2.3",
|
|
95
|
+
"payload": ">=3.72.0"
|
|
96
|
+
},
|
|
97
|
+
"engines": {
|
|
98
|
+
"node": "^18.20.2 || >=20.9.0",
|
|
99
|
+
"pnpm": "^9 || ^10"
|
|
100
|
+
},
|
|
101
|
+
"publishConfig": {
|
|
102
|
+
"access": "public"
|
|
103
|
+
},
|
|
116
104
|
"scripts": {
|
|
105
|
+
"prebuild": "pnpm typecheck",
|
|
117
106
|
"build": "vite build",
|
|
118
|
-
"
|
|
119
|
-
"dev
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
"
|
|
125
|
-
"lint": "eslint",
|
|
126
|
-
"lint:fix": "eslint ./src --fix",
|
|
127
|
-
"release": "pnpm publish --access public",
|
|
128
|
-
"test": "pnpm test:int && pnpm test:e2e",
|
|
129
|
-
"test:e2e": "playwright test",
|
|
130
|
-
"test:int": "vitest"
|
|
107
|
+
"clean": "rm -rf dist && rm -rf node_modules",
|
|
108
|
+
"dev": "vite build --watch",
|
|
109
|
+
"lint": "biome check .",
|
|
110
|
+
"lint:fix": "biome check --write .",
|
|
111
|
+
"test": "vitest run",
|
|
112
|
+
"test:watch": "vitest",
|
|
113
|
+
"typecheck": "tsc --noEmit"
|
|
131
114
|
}
|
|
132
115
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { TemplateVariable } from '../types.ts';
|
|
2
|
-
import { MessageType } from '../utils/schema';
|
|
3
|
-
import { MessageValidator } from '../utils/validate';
|
|
4
|
-
interface MessageControllerProps {
|
|
5
|
-
type: MessageType;
|
|
6
|
-
label?: string;
|
|
7
|
-
locale: string;
|
|
8
|
-
name: string;
|
|
9
|
-
className?: string;
|
|
10
|
-
variables: TemplateVariable[];
|
|
11
|
-
validate: MessageValidator;
|
|
12
|
-
}
|
|
13
|
-
export declare function MessageController({ type, name, variables, label, locale, validate, className, }: MessageControllerProps): React.ReactNode;
|
|
14
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { DeepPartial, Locales, Messages, MessagesSchema, Translations } from '../types.ts';
|
|
2
|
-
interface MessagesFormProps {
|
|
3
|
-
locales: Locales;
|
|
4
|
-
schema: MessagesSchema;
|
|
5
|
-
tabs?: boolean;
|
|
6
|
-
values: Translations<DeepPartial<Messages>>;
|
|
7
|
-
endpointUrl: string;
|
|
8
|
-
}
|
|
9
|
-
export declare function MessagesForm({ locales, schema, tabs, values, endpointUrl, }: MessagesFormProps): React.ReactNode;
|
|
10
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function JsonImport(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { FieldError } from 'react-hook-form';
|
|
2
|
-
export interface InputWrapperProps {
|
|
3
|
-
label?: string;
|
|
4
|
-
error: FieldError | undefined;
|
|
5
|
-
className?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare function InputWrapper({ label, error, className, children, }: React.PropsWithChildren<InputWrapperProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { DefaultNodeTypes, TypedEditorState } from '@payloadcms/richtext-lexical';
|
|
2
|
-
import { SerializedEditorState } from '@payloadcms/richtext-lexical/lexical';
|
|
3
|
-
import { InputWrapperProps } from './InputWrapper';
|
|
4
|
-
export interface LexicalInputProps extends InputWrapperProps {
|
|
5
|
-
lang: string;
|
|
6
|
-
value: string;
|
|
7
|
-
onChange: (value: string) => void;
|
|
8
|
-
onBlur: () => void;
|
|
9
|
-
}
|
|
10
|
-
export declare function LexicalInput({ error, label, value, onChange, className, }: LexicalInputProps): React.ReactNode;
|
|
11
|
-
interface UseHtmlLexicalAdapterProps {
|
|
12
|
-
html: string;
|
|
13
|
-
onChange: (html: string) => void;
|
|
14
|
-
}
|
|
15
|
-
export declare function useHtmlLexicalAdapter({ html, onChange, }: UseHtmlLexicalAdapterProps): {
|
|
16
|
-
value: TypedEditorState<DefaultNodeTypes>;
|
|
17
|
-
setValue: (serializedState: SerializedEditorState) => void;
|
|
18
|
-
};
|
|
19
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { TemplateVariable } from '../../types.ts';
|
|
2
|
-
import { InputWrapperProps } from './InputWrapper';
|
|
3
|
-
export interface MessageInputProps extends InputWrapperProps {
|
|
4
|
-
value: string;
|
|
5
|
-
lang: string;
|
|
6
|
-
variables: TemplateVariable[];
|
|
7
|
-
onChange: (value: string) => void;
|
|
8
|
-
onBlur: () => void;
|
|
9
|
-
}
|
|
10
|
-
export declare function MessageInput({ label, value, lang, error, variables, onChange, onBlur, className, }: MessageInputProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { IconProps } from '@tabler/icons-react';
|
|
2
|
-
import { TYPE } from '@formatjs/icu-messageformat-parser';
|
|
3
|
-
export interface VariableIconProps extends Omit<IconProps, "type"> {
|
|
4
|
-
type: TYPE;
|
|
5
|
-
}
|
|
6
|
-
export declare function VariableIcon({ type, ...props }: VariableIconProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { VariableMentionNodeAttrs } from '../../../types.ts';
|
|
2
|
-
import { SuggestionKeyDownProps, SuggestionProps } from '@tiptap/suggestion';
|
|
3
|
-
export interface VariableSuggestionProps extends SuggestionProps<VariableMentionNodeAttrs, VariableMentionNodeAttrs> {
|
|
4
|
-
ref: React.RefObject<{
|
|
5
|
-
onKeyDown: (props: SuggestionKeyDownProps) => boolean;
|
|
6
|
-
}>;
|
|
7
|
-
}
|
|
8
|
-
export declare function VariableSuggestion({ items, command, ref, }: VariableSuggestionProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DateElement } from '../../../../types.ts';
|
|
2
|
-
export interface DateVariableEditorProps {
|
|
3
|
-
name: string;
|
|
4
|
-
element: DateElement | undefined;
|
|
5
|
-
ref: React.Ref<{
|
|
6
|
-
getValue: () => string;
|
|
7
|
-
}>;
|
|
8
|
-
}
|
|
9
|
-
export declare function DateVariableEditor({ name, element, ref, }: DateVariableEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { PluralElement } from '../../../../types.ts';
|
|
2
|
-
export interface PluralVariableEditorProps {
|
|
3
|
-
variableName: string;
|
|
4
|
-
element: PluralElement | undefined;
|
|
5
|
-
ref: React.Ref<{
|
|
6
|
-
getValue: () => string;
|
|
7
|
-
}>;
|
|
8
|
-
}
|
|
9
|
-
export declare function PluralVariableEditor({ variableName, element, ref, }: PluralVariableEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { SelectElement } from '../../../../types.ts';
|
|
2
|
-
export interface SelectVariableEditorProps {
|
|
3
|
-
element: SelectElement;
|
|
4
|
-
onUpdate: (value: string) => void;
|
|
5
|
-
}
|
|
6
|
-
export declare function SelectVariableEditor({ element, onUpdate, }: SelectVariableEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { TagElement } from '../../../../types.ts';
|
|
2
|
-
export interface TagVariableEditorProps {
|
|
3
|
-
element: TagElement;
|
|
4
|
-
onUpdate: (value: string) => void;
|
|
5
|
-
}
|
|
6
|
-
export declare function TagVariableEditor({ element, onUpdate, }: TagVariableEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { TimeElement } from '../../../../types.ts';
|
|
2
|
-
export interface TimeElementEditorProps {
|
|
3
|
-
name: string;
|
|
4
|
-
element: TimeElement | undefined;
|
|
5
|
-
ref: React.Ref<{
|
|
6
|
-
getValue: () => string;
|
|
7
|
-
}>;
|
|
8
|
-
}
|
|
9
|
-
export declare function TimeElementEditor({ name, element, ref, }: TimeElementEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { TemplateVariable, VariableMentionNodeAttrs } from '../../../types.ts';
|
|
2
|
-
import { MentionOptions } from '@tiptap/extension-mention';
|
|
3
|
-
export declare function VariableMention(variables: TemplateVariable[]): import('@tiptap/core').Node<MentionOptions<VariableMentionNodeAttrs, VariableMentionNodeAttrs>, any>;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { NumberElement, PluralElement } from '../../../../types.ts';
|
|
2
|
-
export interface NumericVariablePickerProps {
|
|
3
|
-
element: NumberElement | PluralElement;
|
|
4
|
-
onUpdate: (value: string) => void;
|
|
5
|
-
}
|
|
6
|
-
export declare function NumericVariablePicker({ element, onUpdate, }: NumericVariablePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { DateElement, TimeElement } from '../../../../types.ts';
|
|
2
|
-
export interface TemporalElementEditorProps {
|
|
3
|
-
element: DateElement | TimeElement;
|
|
4
|
-
onUpdate: (value: string) => void;
|
|
5
|
-
}
|
|
6
|
-
export declare function TemporalElementEditor({ element, onUpdate, }: TemporalElementEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { MessageSchema } from '../../types.ts';
|
|
2
|
-
interface MessageFieldProps {
|
|
3
|
-
schema: MessageSchema;
|
|
4
|
-
messageKey: string;
|
|
5
|
-
path: string;
|
|
6
|
-
className?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function MessageField({ schema, messageKey, path, className, }: MessageFieldProps): React.ReactNode;
|
|
9
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { MessagesSchema } from '../../types.ts';
|
|
2
|
-
interface MessagesTabsProps {
|
|
3
|
-
schema: MessagesSchema;
|
|
4
|
-
activeTab: string | undefined;
|
|
5
|
-
setActiveTab: (tab: string) => void;
|
|
6
|
-
}
|
|
7
|
-
export declare function MessagesTabs({ schema, activeTab, setActiveTab, }: MessagesTabsProps): React.ReactNode;
|
|
8
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Messages } from '../../types.ts';
|
|
2
|
-
interface MessagesTreeProps {
|
|
3
|
-
path: string;
|
|
4
|
-
nestingLevel: number;
|
|
5
|
-
schema: Messages;
|
|
6
|
-
className?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function MessagesTree({ path, schema, nestingLevel, className, }: MessagesTreeProps): React.ReactNode;
|
|
9
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Locales, Messages, Translations } from '../types.ts';
|
|
2
|
-
import { UseFormReturn } from 'react-hook-form';
|
|
3
|
-
export type FormValues = Translations<Messages>;
|
|
4
|
-
interface MessagesFormProviderProps {
|
|
5
|
-
locales: Locales;
|
|
6
|
-
form: UseFormReturn<FormValues>;
|
|
7
|
-
}
|
|
8
|
-
export declare function MessagesFormProvider({ locales, form, children, }: React.PropsWithChildren<MessagesFormProviderProps>): import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
export declare const useMessagesForm: () => {
|
|
10
|
-
watch: import('react-hook-form').UseFormWatch<FormValues>;
|
|
11
|
-
getValues: import('react-hook-form').UseFormGetValues<FormValues>;
|
|
12
|
-
getFieldState: import('react-hook-form').UseFormGetFieldState<FormValues>;
|
|
13
|
-
setError: import('react-hook-form').UseFormSetError<FormValues>;
|
|
14
|
-
clearErrors: import('react-hook-form').UseFormClearErrors<FormValues>;
|
|
15
|
-
setValue: import('react-hook-form').UseFormSetValue<FormValues>;
|
|
16
|
-
trigger: import('react-hook-form').UseFormTrigger<FormValues>;
|
|
17
|
-
formState: import('react-hook-form').FormState<FormValues>;
|
|
18
|
-
resetField: import('react-hook-form').UseFormResetField<FormValues>;
|
|
19
|
-
reset: import('react-hook-form').UseFormReset<FormValues>;
|
|
20
|
-
handleSubmit: import('react-hook-form').UseFormHandleSubmit<FormValues, FormValues>;
|
|
21
|
-
unregister: import('react-hook-form').UseFormUnregister<FormValues>;
|
|
22
|
-
control: import('react-hook-form').Control<FormValues, any, FormValues>;
|
|
23
|
-
register: import('react-hook-form').UseFormRegister<FormValues>;
|
|
24
|
-
setFocus: import('react-hook-form').UseFormSetFocus<FormValues>;
|
|
25
|
-
subscribe: import('react-hook-form').UseFormSubscribe<FormValues>;
|
|
26
|
-
locales: Locales;
|
|
27
|
-
};
|
|
28
|
-
export {};
|