@intlayer/design-system 5.3.3 → 5.3.4
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/dist/.vite/manifest.json +72 -54
- package/dist/{Form-MjLzPGze.js → Form-CriPBaZk.js} +11 -1
- package/dist/Form-CriPBaZk.js.map +1 -0
- package/dist/{Form-BpxW17v4.cjs → Form-DJrUK3mm.cjs} +11 -1
- package/dist/Form-DJrUK3mm.cjs.map +1 -0
- package/dist/components/Auth/ChangePasswordForm/ChangePasswordForm.cjs +1 -1
- package/dist/components/Auth/ChangePasswordForm/ChangePasswordForm.mjs +1 -1
- package/dist/components/Auth/DefineNewPasswordForm/DefineNewPasswordForm.cjs +1 -1
- package/dist/components/Auth/DefineNewPasswordForm/DefineNewPasswordForm.mjs +1 -1
- package/dist/components/Auth/ResetPasswordForm/ResetPasswordForm.cjs +1 -1
- package/dist/components/Auth/ResetPasswordForm/ResetPasswordForm.mjs +1 -1
- package/dist/components/Auth/SignInForm/SignInForm.cjs +1 -1
- package/dist/components/Auth/SignInForm/SignInForm.mjs +1 -1
- package/dist/components/Auth/SignUpForm/SignUpForm.cjs +1 -1
- package/dist/components/Auth/SignUpForm/SignUpForm.mjs +1 -1
- package/dist/components/Auth/VerifyEmailForm/VerifyEmailForm.cjs +1 -1
- package/dist/components/Auth/VerifyEmailForm/VerifyEmailForm.mjs +1 -1
- package/dist/components/ContentEditor/ContentEditor.cjs.map +1 -1
- package/dist/components/ContentEditor/ContentEditor.d.ts +3 -2
- package/dist/components/ContentEditor/ContentEditor.d.ts.map +1 -1
- package/dist/components/ContentEditor/ContentEditor.mjs.map +1 -1
- package/dist/components/ContentEditor/ContentEditorTextArea.cjs +1 -1
- package/dist/components/ContentEditor/ContentEditorTextArea.mjs +1 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.cjs +2 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.cjs.map +1 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.mjs +2 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.mjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.cjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.mjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/ConditionWrapper.cjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/ConditionWrapper.mjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.cjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.mjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/FileWrapper.cjs +58 -0
- package/dist/components/DictionaryEditor/NodeWrapper/FileWrapper.cjs.map +1 -0
- package/dist/components/DictionaryEditor/NodeWrapper/FileWrapper.d.ts +9 -0
- package/dist/components/DictionaryEditor/NodeWrapper/FileWrapper.d.ts.map +1 -0
- package/dist/components/DictionaryEditor/NodeWrapper/FileWrapper.mjs +58 -0
- package/dist/components/DictionaryEditor/NodeWrapper/FileWrapper.mjs.map +1 -0
- package/dist/components/DictionaryEditor/NodeWrapper/InsertionWrapper.cjs +21 -0
- package/dist/components/DictionaryEditor/NodeWrapper/InsertionWrapper.cjs.map +1 -0
- package/dist/components/DictionaryEditor/NodeWrapper/InsertionWrapper.d.ts +9 -0
- package/dist/components/DictionaryEditor/NodeWrapper/InsertionWrapper.d.ts.map +1 -0
- package/dist/components/DictionaryEditor/NodeWrapper/InsertionWrapper.mjs +21 -0
- package/dist/components/DictionaryEditor/NodeWrapper/InsertionWrapper.mjs.map +1 -0
- package/dist/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.cjs +4 -15
- package/dist/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.cjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.d.ts +2 -2
- package/dist/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.mjs +4 -15
- package/dist/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.mjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.cjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.mjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.cjs +8 -5
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.cjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.d.ts +2 -2
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs +8 -5
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/TranslationWrapper.cjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/TranslationWrapper.mjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/index.cjs +2 -2
- package/dist/components/DictionaryEditor/NodeWrapper/index.d.ts +4 -2
- package/dist/components/DictionaryEditor/NodeWrapper/index.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/index.mjs +2 -2
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs +102 -22
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts +3 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +102 -22
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs +48 -114
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +49 -115
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.cjs +0 -51
- package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.d.ts +0 -105
- package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.mjs +0 -51
- package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs +6 -5
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs +7 -6
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.cjs +10 -2
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.mjs +11 -3
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/nodeTypeSelector.content.cjs +30 -0
- package/dist/components/DictionaryFieldEditor/nodeTypeSelector.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/nodeTypeSelector.content.d.ts +66 -0
- package/dist/components/DictionaryFieldEditor/nodeTypeSelector.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/nodeTypeSelector.content.mjs +30 -0
- package/dist/components/DictionaryFieldEditor/nodeTypeSelector.content.mjs.map +1 -1
- package/dist/components/Form/Form.cjs +1 -1
- package/dist/components/Form/Form.mjs +1 -1
- package/dist/components/Form/elements/AutoSizeTextAreaElement.cjs +1 -1
- package/dist/components/Form/elements/AutoSizeTextAreaElement.mjs +1 -1
- package/dist/components/Form/elements/CheckboxElement.cjs +1 -1
- package/dist/components/Form/elements/CheckboxElement.mjs +1 -1
- package/dist/components/Form/elements/EditableFieldInputElement.cjs +1 -1
- package/dist/components/Form/elements/EditableFieldInputElement.d.ts +2 -2
- package/dist/components/Form/elements/EditableFieldInputElement.d.ts.map +1 -1
- package/dist/components/Form/elements/EditableFieldInputElement.mjs +1 -1
- package/dist/components/Form/elements/EditableFieldTextAreaElement.cjs +1 -1
- package/dist/components/Form/elements/EditableFieldTextAreaElement.d.ts +2 -2
- package/dist/components/Form/elements/EditableFieldTextAreaElement.d.ts.map +1 -1
- package/dist/components/Form/elements/EditableFieldTextAreaElement.mjs +1 -1
- package/dist/components/Form/elements/FormElement.cjs +1 -1
- package/dist/components/Form/elements/FormElement.mjs +1 -1
- package/dist/components/Form/elements/InputElement.cjs +1 -1
- package/dist/components/Form/elements/InputElement.d.ts +2 -2
- package/dist/components/Form/elements/InputElement.d.ts.map +1 -1
- package/dist/components/Form/elements/InputElement.mjs +1 -1
- package/dist/components/Form/elements/InputPasswordElement.cjs +1 -1
- package/dist/components/Form/elements/InputPasswordElement.d.ts +2 -2
- package/dist/components/Form/elements/InputPasswordElement.d.ts.map +1 -1
- package/dist/components/Form/elements/InputPasswordElement.mjs +1 -1
- package/dist/components/Form/elements/MultiselectElement.cjs +1 -1
- package/dist/components/Form/elements/MultiselectElement.mjs +1 -1
- package/dist/components/Form/elements/SelectElement.cjs +1 -1
- package/dist/components/Form/elements/SelectElement.mjs +1 -1
- package/dist/components/Form/elements/SwitchSelectorElement.cjs +1 -1
- package/dist/components/Form/elements/SwitchSelectorElement.mjs +1 -1
- package/dist/components/Form/elements/TextAreaElement.cjs +1 -1
- package/dist/components/Form/elements/TextAreaElement.d.ts +3 -3
- package/dist/components/Form/elements/TextAreaElement.d.ts.map +1 -1
- package/dist/components/Form/elements/TextAreaElement.mjs +1 -1
- package/dist/components/Form/elements/index.cjs +1 -1
- package/dist/components/Form/elements/index.mjs +1 -1
- package/dist/components/Form/index.cjs +1 -1
- package/dist/components/Form/index.mjs +1 -1
- package/dist/components/Form/layout/FormItemLayout.cjs +1 -1
- package/dist/components/Form/layout/FormItemLayout.mjs +1 -1
- package/dist/components/Form/layout/FormLabelLayout.cjs +12 -4
- package/dist/components/Form/layout/FormLabelLayout.cjs.map +1 -1
- package/dist/components/Form/layout/FormLabelLayout.d.ts.map +1 -1
- package/dist/components/Form/layout/FormLabelLayout.mjs +12 -4
- package/dist/components/Form/layout/FormLabelLayout.mjs.map +1 -1
- package/dist/components/Form/layout/index.cjs +1 -1
- package/dist/components/Form/layout/index.mjs +1 -1
- package/dist/components/Input/Input.cjs.map +1 -1
- package/dist/components/Input/Input.d.ts +1 -7
- package/dist/components/Input/Input.d.ts.map +1 -1
- package/dist/components/Input/Input.mjs.map +1 -1
- package/dist/components/TextArea/TextArea.cjs.map +1 -1
- package/dist/components/TextArea/TextArea.d.ts +1 -7
- package/dist/components/TextArea/TextArea.d.ts.map +1 -1
- package/dist/components/TextArea/TextArea.mjs.map +1 -1
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.mjs +1 -1
- package/dist/hooks/intlayerAPIHooks.cjs.map +1 -1
- package/dist/hooks/intlayerAPIHooks.d.ts +54 -54
- package/dist/hooks/intlayerAPIHooks.d.ts.map +1 -1
- package/dist/hooks/intlayerAPIHooks.mjs.map +1 -1
- package/dist/hooks/useIntlayerAPI.d.ts +1 -1
- package/dist/hooks/useIntlayerAPI.d.ts.map +1 -1
- package/dist/{index-CVTE3oHq.js → index-Au2tP3vA.js} +27 -3
- package/dist/index-Au2tP3vA.js.map +1 -0
- package/dist/{index-BpCAhDMe.cjs → index-DbyCRREy.cjs} +27 -3
- package/dist/index-DbyCRREy.cjs.map +1 -0
- package/dist/utils/camelCase.cjs +2 -2
- package/dist/utils/camelCase.cjs.map +1 -1
- package/dist/utils/camelCase.d.ts +1 -1
- package/dist/utils/camelCase.d.ts.map +1 -1
- package/dist/utils/camelCase.mjs +2 -2
- package/dist/utils/camelCase.mjs.map +1 -1
- package/package.json +16 -18
- package/dist/Form-BpxW17v4.cjs.map +0 -1
- package/dist/Form-MjLzPGze.js.map +0 -1
- package/dist/index-BpCAhDMe.cjs.map +0 -1
- package/dist/index-CVTE3oHq.js.map +0 -1
|
@@ -3,8 +3,8 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
|
3
3
|
import { NodeType, isSameKeyPath, getNodeType } from "@intlayer/core";
|
|
4
4
|
import { ItemLayout } from "./components/DictionaryEditor/ItemLayout.mjs";
|
|
5
5
|
import { createElement } from "react";
|
|
6
|
-
import { MarkdownWrapper } from "./components/DictionaryEditor/NodeWrapper/MarkdownWrapper.mjs";
|
|
7
6
|
import { StringWrapper } from "./components/DictionaryEditor/NodeWrapper/StringWrapper.mjs";
|
|
7
|
+
import { FileWrapper } from "./components/DictionaryEditor/NodeWrapper/FileWrapper.mjs";
|
|
8
8
|
const ArrayWrapper = (props) => {
|
|
9
9
|
const { keyPath, section, onFocusKeyPath, focusedKeyPath = [] } = props;
|
|
10
10
|
return section.map((subSection, key) => {
|
|
@@ -76,6 +76,17 @@ const EnumerationWrapper = (props) => {
|
|
|
76
76
|
] });
|
|
77
77
|
}) });
|
|
78
78
|
};
|
|
79
|
+
const MarkdownWrapper = (props) => {
|
|
80
|
+
const { keyPath, section } = props;
|
|
81
|
+
const newKeyPath = [
|
|
82
|
+
...keyPath,
|
|
83
|
+
{
|
|
84
|
+
type: NodeType.Markdown
|
|
85
|
+
}
|
|
86
|
+
];
|
|
87
|
+
const subSection = section[NodeType.Markdown];
|
|
88
|
+
return /* @__PURE__ */ jsx("div", { className: "ml-2 grid grid-cols-[auto,1fr] gap-2", children: /* @__PURE__ */ jsx(NodeWrapper, { ...props, keyPath: newKeyPath, section: subSection }) });
|
|
89
|
+
};
|
|
79
90
|
const NestedObjectWrapper = (props) => {
|
|
80
91
|
const { keyPath, section, focusedKeyPath = [], onFocusKeyPath } = props;
|
|
81
92
|
return Object.keys(section).filter((key) => !traceKeys.includes(key)).map((key) => {
|
|
@@ -120,7 +131,13 @@ const NodeWrapper = (props) => {
|
|
|
120
131
|
return /* @__PURE__ */ jsx("div", { className: "ml-2 grid grid-cols-[auto,1fr] gap-2", children: "[Nested] Dictionary" });
|
|
121
132
|
}
|
|
122
133
|
if (nodeType === NodeType.Markdown) {
|
|
123
|
-
return /* @__PURE__ */ jsx(
|
|
134
|
+
return /* @__PURE__ */ jsx(
|
|
135
|
+
MarkdownWrapper,
|
|
136
|
+
{
|
|
137
|
+
...props,
|
|
138
|
+
section
|
|
139
|
+
}
|
|
140
|
+
);
|
|
124
141
|
}
|
|
125
142
|
if (nodeType === NodeType.Translation) {
|
|
126
143
|
return /* @__PURE__ */ jsx(
|
|
@@ -149,6 +166,9 @@ const NodeWrapper = (props) => {
|
|
|
149
166
|
}
|
|
150
167
|
);
|
|
151
168
|
}
|
|
169
|
+
if (nodeType === NodeType.Insertion) {
|
|
170
|
+
return /* @__PURE__ */ jsx("span", { className: "text-neutral text-xs", children: "Insertion not editable" });
|
|
171
|
+
}
|
|
152
172
|
if (nodeType === NodeType.Array) {
|
|
153
173
|
return /* @__PURE__ */ jsx(
|
|
154
174
|
ArrayWrapper,
|
|
@@ -158,6 +178,9 @@ const NodeWrapper = (props) => {
|
|
|
158
178
|
}
|
|
159
179
|
);
|
|
160
180
|
}
|
|
181
|
+
if (nodeType === NodeType.File) {
|
|
182
|
+
return /* @__PURE__ */ jsx(FileWrapper, { ...props, section });
|
|
183
|
+
}
|
|
161
184
|
return /* @__PURE__ */ jsx(
|
|
162
185
|
NestedObjectWrapper,
|
|
163
186
|
{
|
|
@@ -174,9 +197,10 @@ export {
|
|
|
174
197
|
ArrayWrapper as A,
|
|
175
198
|
ConditionWrapper as C,
|
|
176
199
|
EnumerationWrapper as E,
|
|
200
|
+
MarkdownWrapper as M,
|
|
177
201
|
NodeWrapper as N,
|
|
178
202
|
TranslationWrapper as T,
|
|
179
203
|
NestedObjectWrapper as a,
|
|
180
204
|
traceKeys as t
|
|
181
205
|
};
|
|
182
|
-
//# sourceMappingURL=index-
|
|
206
|
+
//# sourceMappingURL=index-Au2tP3vA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-Au2tP3vA.js","sources":["../src/components/DictionaryEditor/NodeWrapper/ArrayWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/ConditionWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/TranslationWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/index.tsx"],"sourcesContent":["import {\n isSameKeyPath,\n NodeType,\n type ContentNode,\n type KeyPath,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { ItemLayout } from '../ItemLayout';\nimport { NodeWrapper, type NodeWrapperProps } from './index';\n\ntype ArrayWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: ContentNode[];\n};\n\nexport const ArrayWrapper: FC<ArrayWrapperProps> = (props) => {\n const { keyPath, section, onFocusKeyPath, focusedKeyPath = [] } = props;\n\n return section.map((subSection, key) => {\n const newKeyPathEl: KeyPath = {\n key,\n type: NodeType.Array,\n };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n return (\n <ItemLayout\n level={keyPath.length}\n key={JSON.stringify(subSection)}\n title={`${key}`}\n description=\"\"\n isSelected={isSameKeyPath(newKeyPath, focusedKeyPath)}\n onClick={(e) => {\n e.stopPropagation();\n onFocusKeyPath(newKeyPath);\n }}\n >\n <NodeWrapper {...props} keyPath={newKeyPath} section={subSection} />\n </ItemLayout>\n );\n });\n};\n","import {\n type KeyPath,\n NodeType,\n type ConditionContent,\n type ContentNode,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { NodeWrapper, traceKeys, type NodeWrapperProps } from './index';\n\ntype ConditionWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: ConditionContent<ContentNode>;\n};\n\nexport const ConditionWrapper: FC<ConditionWrapperProps> = (props) => {\n const { keyPath, section } = props;\n\n return (\n <div className=\"ml-2 grid grid-cols-[auto,1fr] gap-2\">\n {Object.keys(section)\n .filter((key) => !traceKeys.includes(key))\n .map((key) => {\n const newKeyPathEl: KeyPath = {\n type: NodeType.Condition,\n key,\n };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n const subSection =\n section[NodeType.Condition][\n key as keyof (typeof section)[NodeType.Condition]\n ]!;\n\n return (\n <>\n <span className=\"flex items-center font-bold\">{key}</span>\n <NodeWrapper\n {...props}\n key={key}\n keyPath={newKeyPath}\n section={subSection}\n />\n </>\n );\n })}\n </div>\n );\n};\n","import {\n type KeyPath,\n NodeType,\n type EnumerationContent,\n type ContentNode,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { NodeWrapper, traceKeys, type NodeWrapperProps } from './index';\n\ntype EnumerationWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: EnumerationContent<ContentNode>;\n};\n\nexport const EnumerationWrapper: FC<EnumerationWrapperProps> = (props) => {\n const { keyPath, section } = props;\n\n return (\n <div className=\"ml-2 grid grid-cols-[auto,1fr] gap-2\">\n {Object.keys(section)\n .filter((key) => !traceKeys.includes(key))\n .map((key) => {\n const newKeyPathEl: KeyPath = {\n type: NodeType.Enumeration,\n key,\n };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n const subSection =\n section[NodeType.Enumeration][\n key as keyof (typeof section)[NodeType.Enumeration]\n ]!;\n\n return (\n <>\n <span className=\"flex items-center font-bold\">{key}</span>\n <NodeWrapper\n {...props}\n key={key}\n keyPath={newKeyPath}\n section={subSection}\n />\n </>\n );\n })}\n </div>\n );\n};\n","import {\n type KeyPath,\n NodeType,\n type MarkdownContent,\n type ContentNode,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { NodeWrapper, type NodeWrapperProps } from './index';\n\ntype MarkdownWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: MarkdownContent<ContentNode>;\n};\n\nexport const MarkdownWrapper: FC<MarkdownWrapperProps> = (props) => {\n const { keyPath, section } = props;\n\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const subSection = section[NodeType.Markdown] as ContentNode;\n\n return (\n <div className=\"ml-2 grid grid-cols-[auto,1fr] gap-2\">\n <NodeWrapper {...props} keyPath={newKeyPath} section={subSection} />\n </div>\n );\n};\n","import {\n type KeyPath,\n isSameKeyPath,\n type ContentNode,\n NodeType,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { ItemLayout } from '../ItemLayout';\nimport { NodeWrapper, traceKeys, type NodeWrapperProps } from './index';\n\ntype NestedObjectWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: Record<string, ContentNode>;\n};\n\nexport const NestedObjectWrapper: FC<NestedObjectWrapperProps> = (props) => {\n const { keyPath, section, focusedKeyPath = [], onFocusKeyPath } = props;\n\n return Object.keys(section)\n .filter((key) => !traceKeys.includes(key))\n .map((key) => {\n const newKeyPathEl: KeyPath = { key, type: NodeType.Object };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n return (\n <ItemLayout\n level={keyPath.length}\n key={key}\n title={key}\n description=\"\"\n isSelected={isSameKeyPath(newKeyPath, focusedKeyPath)}\n onClick={(e) => {\n e.stopPropagation();\n\n onFocusKeyPath(newKeyPath);\n }}\n >\n <NodeWrapper {...props} keyPath={newKeyPath} section={section[key]} />\n </ItemLayout>\n );\n });\n};\n","import {\n type KeyPath,\n NodeType,\n type TranslationContent,\n type ContentNode,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { NodeWrapper, type NodeWrapperProps } from './index';\n\ntype TranslationWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: TranslationContent<ContentNode>;\n};\n\nexport const TranslationWrapper: FC<TranslationWrapperProps> = (props) => {\n const { keyPath, section, locale } = props;\n\n const newKeyPathEl: KeyPath = {\n type: NodeType.Translation,\n key: locale,\n };\n\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n const subSection =\n section.translation[\n locale as unknown as keyof (typeof section)['translation']\n ]!;\n\n return <NodeWrapper {...props} keyPath={newKeyPath} section={subSection} />;\n};\n","'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport {\n getNodeType,\n NodeType,\n type ConditionContent,\n type MarkdownContent,\n type EnumerationContent,\n type TranslationContent,\n type KeyPath,\n type ContentNode,\n type FileContent,\n type Dictionary,\n} from '@intlayer/core';\nimport { ReactNode, type FC } from 'react';\nimport { ArrayWrapper } from './ArrayWrapper';\nimport { ConditionWrapper } from './ConditionWrapper';\nimport { EnumerationWrapper } from './EnumerationWrapper';\nimport { MarkdownWrapper } from './MarkdownWrapper';\nimport { NestedObjectWrapper } from './NestedObjectWrapper';\nimport { StringWrapper } from './StringWrapper';\nimport { TranslationWrapper } from './TranslationWrapper';\nimport { FileWrapper } from './FileWrapper';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n section: ContentNode;\n onContentChange: (content: { keyPath: KeyPath[]; newValue: string }) => void;\n locale: Locales;\n editedContent: ContentNode;\n focusedKeyPath: KeyPath[] | undefined;\n onFocusKeyPath: (keyPath: KeyPath[]) => void;\n onClickEdit?: (keyPath: KeyPath[]) => void;\n renderSection?: (content: string) => ReactNode;\n};\n\nexport const NodeWrapper: FC<NodeWrapperProps> = (props) => {\n const { section } = props;\n const nodeType = getNodeType(section);\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return (\n <span className=\"text-neutral text-xs\">React node not editable</span>\n );\n }\n\n if (nodeType === NodeType.Nested) {\n return (\n <div className=\"ml-2 grid grid-cols-[auto,1fr] gap-2\">\n [Nested] Dictionary\n </div>\n );\n }\n\n if (nodeType === NodeType.Markdown) {\n return (\n <MarkdownWrapper\n {...props}\n section={section as MarkdownContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationWrapper\n {...props}\n section={section as TranslationContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationWrapper\n {...props}\n section={section as EnumerationContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Condition) {\n return (\n <ConditionWrapper\n {...props}\n section={section as ConditionContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Insertion) {\n return (\n <span className=\"text-neutral text-xs\">Insertion not editable</span>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayWrapper\n {...props}\n section={section as unknown as ContentNode[]}\n />\n );\n }\n\n if (nodeType === NodeType.File) {\n return <FileWrapper {...props} section={section as FileContent} />;\n }\n\n return (\n <NestedObjectWrapper\n {...props}\n section={section as Record<string, ContentNode>}\n />\n );\n }\n\n if (typeof section === 'string') {\n return <StringWrapper {...props} section={section} />;\n }\n};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A;AAIA,QAAA,aAAa,SAAS,aAAa;AAEnC,aAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACE,GAAG;AAAA,UACJ;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAIA,QAAA,aAAa,SAAS,aAAa;AAEnC,aAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACE,GAAG;AAAA,UACJ;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAIA,QAAA,aAAa,SAAS,WAAW;AAEjC,aAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACE,GAAG;AAAA,UACJ;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAIA,QAAA,aAAa,SAAS,WAAW;AACnC,aACG,oBAAA,QAAA,EAAK,WAAU,wBAAuB,UAAsB,0BAAA;AAAA,IAAA;AAI7D,QAAA,aAAa,SAAS,OAAO;AAE7B,aAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACE,GAAG;AAAA,UACJ;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAIA,QAAA,aAAa,SAAS,MAAM;AAC9B,aAAQ,oBAAA,aAAA,EAAa,GAAG,OAAO,QAAiC,CAAA;AAAA,IAAA;AAIhE,WAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACE,GAAG;AAAA,QACJ;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAIA,MAAA,OAAO,YAAY,UAAU;AAC/B,WAAQ,oBAAA,eAAA,EAAe,GAAG,OAAO,QAAkB,CAAA;AAAA,EAAA;AAEvD;"}
|
|
@@ -4,8 +4,8 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
4
4
|
const core = require("@intlayer/core");
|
|
5
5
|
const components_DictionaryEditor_ItemLayout = require("./components/DictionaryEditor/ItemLayout.cjs");
|
|
6
6
|
const ReactExports = require("react");
|
|
7
|
-
const components_DictionaryEditor_NodeWrapper_MarkdownWrapper = require("./components/DictionaryEditor/NodeWrapper/MarkdownWrapper.cjs");
|
|
8
7
|
const components_DictionaryEditor_NodeWrapper_StringWrapper = require("./components/DictionaryEditor/NodeWrapper/StringWrapper.cjs");
|
|
8
|
+
const components_DictionaryEditor_NodeWrapper_FileWrapper = require("./components/DictionaryEditor/NodeWrapper/FileWrapper.cjs");
|
|
9
9
|
const ArrayWrapper = (props) => {
|
|
10
10
|
const { keyPath, section, onFocusKeyPath, focusedKeyPath = [] } = props;
|
|
11
11
|
return section.map((subSection, key) => {
|
|
@@ -77,6 +77,17 @@ const EnumerationWrapper = (props) => {
|
|
|
77
77
|
] });
|
|
78
78
|
}) });
|
|
79
79
|
};
|
|
80
|
+
const MarkdownWrapper = (props) => {
|
|
81
|
+
const { keyPath, section } = props;
|
|
82
|
+
const newKeyPath = [
|
|
83
|
+
...keyPath,
|
|
84
|
+
{
|
|
85
|
+
type: core.NodeType.Markdown
|
|
86
|
+
}
|
|
87
|
+
];
|
|
88
|
+
const subSection = section[core.NodeType.Markdown];
|
|
89
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-2 grid grid-cols-[auto,1fr] gap-2", children: /* @__PURE__ */ jsxRuntime.jsx(NodeWrapper, { ...props, keyPath: newKeyPath, section: subSection }) });
|
|
90
|
+
};
|
|
80
91
|
const NestedObjectWrapper = (props) => {
|
|
81
92
|
const { keyPath, section, focusedKeyPath = [], onFocusKeyPath } = props;
|
|
82
93
|
return Object.keys(section).filter((key) => !traceKeys.includes(key)).map((key) => {
|
|
@@ -121,7 +132,13 @@ const NodeWrapper = (props) => {
|
|
|
121
132
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-2 grid grid-cols-[auto,1fr] gap-2", children: "[Nested] Dictionary" });
|
|
122
133
|
}
|
|
123
134
|
if (nodeType === core.NodeType.Markdown) {
|
|
124
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
135
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
136
|
+
MarkdownWrapper,
|
|
137
|
+
{
|
|
138
|
+
...props,
|
|
139
|
+
section
|
|
140
|
+
}
|
|
141
|
+
);
|
|
125
142
|
}
|
|
126
143
|
if (nodeType === core.NodeType.Translation) {
|
|
127
144
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -150,6 +167,9 @@ const NodeWrapper = (props) => {
|
|
|
150
167
|
}
|
|
151
168
|
);
|
|
152
169
|
}
|
|
170
|
+
if (nodeType === core.NodeType.Insertion) {
|
|
171
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-neutral text-xs", children: "Insertion not editable" });
|
|
172
|
+
}
|
|
153
173
|
if (nodeType === core.NodeType.Array) {
|
|
154
174
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
155
175
|
ArrayWrapper,
|
|
@@ -159,6 +179,9 @@ const NodeWrapper = (props) => {
|
|
|
159
179
|
}
|
|
160
180
|
);
|
|
161
181
|
}
|
|
182
|
+
if (nodeType === core.NodeType.File) {
|
|
183
|
+
return /* @__PURE__ */ jsxRuntime.jsx(components_DictionaryEditor_NodeWrapper_FileWrapper.FileWrapper, { ...props, section });
|
|
184
|
+
}
|
|
162
185
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
163
186
|
NestedObjectWrapper,
|
|
164
187
|
{
|
|
@@ -174,8 +197,9 @@ const NodeWrapper = (props) => {
|
|
|
174
197
|
exports.ArrayWrapper = ArrayWrapper;
|
|
175
198
|
exports.ConditionWrapper = ConditionWrapper;
|
|
176
199
|
exports.EnumerationWrapper = EnumerationWrapper;
|
|
200
|
+
exports.MarkdownWrapper = MarkdownWrapper;
|
|
177
201
|
exports.NestedObjectWrapper = NestedObjectWrapper;
|
|
178
202
|
exports.NodeWrapper = NodeWrapper;
|
|
179
203
|
exports.TranslationWrapper = TranslationWrapper;
|
|
180
204
|
exports.traceKeys = traceKeys;
|
|
181
|
-
//# sourceMappingURL=index-
|
|
205
|
+
//# sourceMappingURL=index-DbyCRREy.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DbyCRREy.cjs","sources":["../src/components/DictionaryEditor/NodeWrapper/ArrayWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/ConditionWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/TranslationWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/index.tsx"],"sourcesContent":["import {\n isSameKeyPath,\n NodeType,\n type ContentNode,\n type KeyPath,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { ItemLayout } from '../ItemLayout';\nimport { NodeWrapper, type NodeWrapperProps } from './index';\n\ntype ArrayWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: ContentNode[];\n};\n\nexport const ArrayWrapper: FC<ArrayWrapperProps> = (props) => {\n const { keyPath, section, onFocusKeyPath, focusedKeyPath = [] } = props;\n\n return section.map((subSection, key) => {\n const newKeyPathEl: KeyPath = {\n key,\n type: NodeType.Array,\n };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n return (\n <ItemLayout\n level={keyPath.length}\n key={JSON.stringify(subSection)}\n title={`${key}`}\n description=\"\"\n isSelected={isSameKeyPath(newKeyPath, focusedKeyPath)}\n onClick={(e) => {\n e.stopPropagation();\n onFocusKeyPath(newKeyPath);\n }}\n >\n <NodeWrapper {...props} keyPath={newKeyPath} section={subSection} />\n </ItemLayout>\n );\n });\n};\n","import {\n type KeyPath,\n NodeType,\n type ConditionContent,\n type ContentNode,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { NodeWrapper, traceKeys, type NodeWrapperProps } from './index';\n\ntype ConditionWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: ConditionContent<ContentNode>;\n};\n\nexport const ConditionWrapper: FC<ConditionWrapperProps> = (props) => {\n const { keyPath, section } = props;\n\n return (\n <div className=\"ml-2 grid grid-cols-[auto,1fr] gap-2\">\n {Object.keys(section)\n .filter((key) => !traceKeys.includes(key))\n .map((key) => {\n const newKeyPathEl: KeyPath = {\n type: NodeType.Condition,\n key,\n };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n const subSection =\n section[NodeType.Condition][\n key as keyof (typeof section)[NodeType.Condition]\n ]!;\n\n return (\n <>\n <span className=\"flex items-center font-bold\">{key}</span>\n <NodeWrapper\n {...props}\n key={key}\n keyPath={newKeyPath}\n section={subSection}\n />\n </>\n );\n })}\n </div>\n );\n};\n","import {\n type KeyPath,\n NodeType,\n type EnumerationContent,\n type ContentNode,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { NodeWrapper, traceKeys, type NodeWrapperProps } from './index';\n\ntype EnumerationWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: EnumerationContent<ContentNode>;\n};\n\nexport const EnumerationWrapper: FC<EnumerationWrapperProps> = (props) => {\n const { keyPath, section } = props;\n\n return (\n <div className=\"ml-2 grid grid-cols-[auto,1fr] gap-2\">\n {Object.keys(section)\n .filter((key) => !traceKeys.includes(key))\n .map((key) => {\n const newKeyPathEl: KeyPath = {\n type: NodeType.Enumeration,\n key,\n };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n const subSection =\n section[NodeType.Enumeration][\n key as keyof (typeof section)[NodeType.Enumeration]\n ]!;\n\n return (\n <>\n <span className=\"flex items-center font-bold\">{key}</span>\n <NodeWrapper\n {...props}\n key={key}\n keyPath={newKeyPath}\n section={subSection}\n />\n </>\n );\n })}\n </div>\n );\n};\n","import {\n type KeyPath,\n NodeType,\n type MarkdownContent,\n type ContentNode,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { NodeWrapper, type NodeWrapperProps } from './index';\n\ntype MarkdownWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: MarkdownContent<ContentNode>;\n};\n\nexport const MarkdownWrapper: FC<MarkdownWrapperProps> = (props) => {\n const { keyPath, section } = props;\n\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const subSection = section[NodeType.Markdown] as ContentNode;\n\n return (\n <div className=\"ml-2 grid grid-cols-[auto,1fr] gap-2\">\n <NodeWrapper {...props} keyPath={newKeyPath} section={subSection} />\n </div>\n );\n};\n","import {\n type KeyPath,\n isSameKeyPath,\n type ContentNode,\n NodeType,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { ItemLayout } from '../ItemLayout';\nimport { NodeWrapper, traceKeys, type NodeWrapperProps } from './index';\n\ntype NestedObjectWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: Record<string, ContentNode>;\n};\n\nexport const NestedObjectWrapper: FC<NestedObjectWrapperProps> = (props) => {\n const { keyPath, section, focusedKeyPath = [], onFocusKeyPath } = props;\n\n return Object.keys(section)\n .filter((key) => !traceKeys.includes(key))\n .map((key) => {\n const newKeyPathEl: KeyPath = { key, type: NodeType.Object };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n return (\n <ItemLayout\n level={keyPath.length}\n key={key}\n title={key}\n description=\"\"\n isSelected={isSameKeyPath(newKeyPath, focusedKeyPath)}\n onClick={(e) => {\n e.stopPropagation();\n\n onFocusKeyPath(newKeyPath);\n }}\n >\n <NodeWrapper {...props} keyPath={newKeyPath} section={section[key]} />\n </ItemLayout>\n );\n });\n};\n","import {\n type KeyPath,\n NodeType,\n type TranslationContent,\n type ContentNode,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { NodeWrapper, type NodeWrapperProps } from './index';\n\ntype TranslationWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: TranslationContent<ContentNode>;\n};\n\nexport const TranslationWrapper: FC<TranslationWrapperProps> = (props) => {\n const { keyPath, section, locale } = props;\n\n const newKeyPathEl: KeyPath = {\n type: NodeType.Translation,\n key: locale,\n };\n\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n const subSection =\n section.translation[\n locale as unknown as keyof (typeof section)['translation']\n ]!;\n\n return <NodeWrapper {...props} keyPath={newKeyPath} section={subSection} />;\n};\n","'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport {\n getNodeType,\n NodeType,\n type ConditionContent,\n type MarkdownContent,\n type EnumerationContent,\n type TranslationContent,\n type KeyPath,\n type ContentNode,\n type FileContent,\n type Dictionary,\n} from '@intlayer/core';\nimport { ReactNode, type FC } from 'react';\nimport { ArrayWrapper } from './ArrayWrapper';\nimport { ConditionWrapper } from './ConditionWrapper';\nimport { EnumerationWrapper } from './EnumerationWrapper';\nimport { MarkdownWrapper } from './MarkdownWrapper';\nimport { NestedObjectWrapper } from './NestedObjectWrapper';\nimport { StringWrapper } from './StringWrapper';\nimport { TranslationWrapper } from './TranslationWrapper';\nimport { FileWrapper } from './FileWrapper';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n section: ContentNode;\n onContentChange: (content: { keyPath: KeyPath[]; newValue: string }) => void;\n locale: Locales;\n editedContent: ContentNode;\n focusedKeyPath: KeyPath[] | undefined;\n onFocusKeyPath: (keyPath: KeyPath[]) => void;\n onClickEdit?: (keyPath: KeyPath[]) => void;\n renderSection?: (content: string) => ReactNode;\n};\n\nexport const NodeWrapper: FC<NodeWrapperProps> = (props) => {\n const { section } = props;\n const nodeType = getNodeType(section);\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return (\n <span className=\"text-neutral text-xs\">React node not editable</span>\n );\n }\n\n if (nodeType === NodeType.Nested) {\n return (\n <div className=\"ml-2 grid grid-cols-[auto,1fr] gap-2\">\n [Nested] Dictionary\n </div>\n );\n }\n\n if (nodeType === NodeType.Markdown) {\n return (\n <MarkdownWrapper\n {...props}\n section={section as MarkdownContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationWrapper\n {...props}\n section={section as TranslationContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationWrapper\n {...props}\n section={section as EnumerationContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Condition) {\n return (\n <ConditionWrapper\n {...props}\n section={section as ConditionContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Insertion) {\n return (\n <span className=\"text-neutral text-xs\">Insertion not editable</span>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayWrapper\n {...props}\n section={section as unknown as ContentNode[]}\n />\n );\n }\n\n if (nodeType === NodeType.File) {\n return <FileWrapper {...props} section={section as FileContent} />;\n }\n\n return (\n <NestedObjectWrapper\n {...props}\n section={section as Record<string, ContentNode>}\n />\n );\n }\n\n if (typeof section === 'string') {\n return <StringWrapper {...props} section={section} />;\n }\n};\n"],"names":["NodeType","jsx","ItemLayout","isSameKeyPath","jsxs","Fragment","createElement","getNodeType","FileWrapper","StringWrapper"],"mappings":";;;;;;;;AAca,MAAA,eAAsC,CAAC,UAAU;AAC5D,QAAM,EAAE,SAAS,SAAS,gBAAgB,iBAAiB,OAAO;AAElE,SAAO,QAAQ,IAAI,CAAC,YAAY,QAAQ;AACtC,UAAM,eAAwB;AAAA,MAC5B;AAAA,MACA,MAAMA,KAAAA,SAAS;AAAA,IACjB;AACA,UAAM,aAAwB,CAAC,GAAG,SAAS,YAAY;AAGrD,WAAAC,2BAAA;AAAA,MAACC,uCAAA;AAAA,MAAA;AAAA,QACC,OAAO,QAAQ;AAAA,QAEf,OAAO,GAAG,GAAG;AAAA,QACb,aAAY;AAAA,QACZ,YAAYC,KAAAA,cAAc,YAAY,cAAc;AAAA,QACpD,SAAS,CAAC,MAAM;AACd,YAAE,gBAAgB;AAClB,yBAAe,UAAU;AAAA,QAC3B;AAAA,QAEA,yCAAC,aAAa,EAAA,GAAG,OAAO,SAAS,YAAY,SAAS,WAAY,CAAA;AAAA,MAAA;AAAA,MAT7D,KAAK,UAAU,UAAU;AAAA,IAUhC;AAAA,EA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AW;AACnC,aACGC,2BAAAA,IAAA,QAAA,EAAK,WAAU,wBAAuB,UAAsB,0BAAA;AAAA,IAAA;AAI7D,QAAA,aAAaD,cAAS,OAAO;AAE7B,aAAAC,2BAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACE,GAAG;AAAA,UACJ;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAIA,QAAA,aAAaD,cAAS,MAAM;AAC9B,aAAQC,2BAAA,IAAAO,oDAAA,aAAA,EAAa,GAAG,OAAO,QAAiC,CAAA;AAAA,IAAA;AAIhE,WAAAP,2BAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACE,GAAG;AAAA,QACJ;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAIA,MAAA,OAAO,YAAY,UAAU;AAC/B,WAAQA,2BAAA,IAAAQ,sDAAA,eAAA,EAAe,GAAG,OAAO,QAAkB,CAAA;AAAA,EAAA;AAEvD;;;;;;;;;"}
|
package/dist/utils/camelCase.cjs
CHANGED
|
@@ -6,8 +6,8 @@ const sentenceToCamelCase = (string) => {
|
|
|
6
6
|
).join("");
|
|
7
7
|
return `${sentence.charAt(0).toLowerCase()}${sentence.slice(1)}`;
|
|
8
8
|
};
|
|
9
|
-
const camelCaseToSentence = (
|
|
10
|
-
const result =
|
|
9
|
+
const camelCaseToSentence = (content) => {
|
|
10
|
+
const result = String(content).replace(/([A-Z])/g, " $1");
|
|
11
11
|
return result.toLowerCase().trim();
|
|
12
12
|
};
|
|
13
13
|
exports.camelCaseToSentence = camelCaseToSentence;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camelCase.cjs","sources":["../../src/utils/camelCase.ts"],"sourcesContent":["export const sentenceToCamelCase = (string: string): string => {\n const sentence = string\n .split(' ')\n .map(\n (word) => `${word.charAt(0).toUpperCase()}${word.slice(1).toLowerCase()}`\n )\n .join('');\n\n return `${sentence.charAt(0).toLowerCase()}${sentence.slice(1)}`;\n};\n\nexport const camelCaseToSentence = (
|
|
1
|
+
{"version":3,"file":"camelCase.cjs","sources":["../../src/utils/camelCase.ts"],"sourcesContent":["export const sentenceToCamelCase = (string: string): string => {\n const sentence = string\n .split(' ')\n .map(\n (word) => `${word.charAt(0).toUpperCase()}${word.slice(1).toLowerCase()}`\n )\n .join('');\n\n return `${sentence.charAt(0).toLowerCase()}${sentence.slice(1)}`;\n};\n\nexport const camelCaseToSentence = (content: string): string => {\n const result = String(content).replace(/([A-Z])/g, ' $1');\n return result.toLowerCase().trim();\n};\n"],"names":[],"mappings":";;AAAa,MAAA,sBAAsB,CAAC,WAA2B;AAC7D,QAAM,WAAW,OACd,MAAM,GAAG,EACT;AAAA,IACC,CAAC,SAAS,GAAG,KAAK,OAAO,CAAC,EAAE,YAAa,CAAA,GAAG,KAAK,MAAM,CAAC,EAAE,aAAa;AAAA,EAAA,EAExE,KAAK,EAAE;AAEH,SAAA,GAAG,SAAS,OAAO,CAAC,EAAE,YAAa,CAAA,GAAG,SAAS,MAAM,CAAC,CAAC;AAChE;AAEa,MAAA,sBAAsB,CAAC,YAA4B;AAC9D,QAAM,SAAS,OAAO,OAAO,EAAE,QAAQ,YAAY,KAAK;AACjD,SAAA,OAAO,YAAY,EAAE,KAAK;AACnC;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camelCase.d.ts","sourceRoot":"","sources":["../../src/utils/camelCase.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,GAAI,QAAQ,MAAM,KAAG,MASpD,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,
|
|
1
|
+
{"version":3,"file":"camelCase.d.ts","sourceRoot":"","sources":["../../src/utils/camelCase.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,GAAI,QAAQ,MAAM,KAAG,MASpD,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,SAAS,MAAM,KAAG,MAGrD,CAAC"}
|
package/dist/utils/camelCase.mjs
CHANGED
|
@@ -4,8 +4,8 @@ const sentenceToCamelCase = (string) => {
|
|
|
4
4
|
).join("");
|
|
5
5
|
return `${sentence.charAt(0).toLowerCase()}${sentence.slice(1)}`;
|
|
6
6
|
};
|
|
7
|
-
const camelCaseToSentence = (
|
|
8
|
-
const result =
|
|
7
|
+
const camelCaseToSentence = (content) => {
|
|
8
|
+
const result = String(content).replace(/([A-Z])/g, " $1");
|
|
9
9
|
return result.toLowerCase().trim();
|
|
10
10
|
};
|
|
11
11
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camelCase.mjs","sources":["../../src/utils/camelCase.ts"],"sourcesContent":["export const sentenceToCamelCase = (string: string): string => {\n const sentence = string\n .split(' ')\n .map(\n (word) => `${word.charAt(0).toUpperCase()}${word.slice(1).toLowerCase()}`\n )\n .join('');\n\n return `${sentence.charAt(0).toLowerCase()}${sentence.slice(1)}`;\n};\n\nexport const camelCaseToSentence = (
|
|
1
|
+
{"version":3,"file":"camelCase.mjs","sources":["../../src/utils/camelCase.ts"],"sourcesContent":["export const sentenceToCamelCase = (string: string): string => {\n const sentence = string\n .split(' ')\n .map(\n (word) => `${word.charAt(0).toUpperCase()}${word.slice(1).toLowerCase()}`\n )\n .join('');\n\n return `${sentence.charAt(0).toLowerCase()}${sentence.slice(1)}`;\n};\n\nexport const camelCaseToSentence = (content: string): string => {\n const result = String(content).replace(/([A-Z])/g, ' $1');\n return result.toLowerCase().trim();\n};\n"],"names":[],"mappings":"AAAa,MAAA,sBAAsB,CAAC,WAA2B;AAC7D,QAAM,WAAW,OACd,MAAM,GAAG,EACT;AAAA,IACC,CAAC,SAAS,GAAG,KAAK,OAAO,CAAC,EAAE,YAAa,CAAA,GAAG,KAAK,MAAM,CAAC,EAAE,aAAa;AAAA,EAAA,EAExE,KAAK,EAAE;AAEH,SAAA,GAAG,SAAS,OAAO,CAAC,EAAE,YAAa,CAAA,GAAG,SAAS,MAAM,CAAC,CAAC;AAChE;AAEa,MAAA,sBAAsB,CAAC,YAA4B;AAC9D,QAAM,SAAS,OAAO,OAAO,EAAE,QAAQ,YAAY,KAAK;AACjD,SAAA,OAAO,YAAY,EAAE,KAAK;AACnC;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/design-system",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Intlayer design system, including UI components used in the Intlayer editor, website, and visual editor/CMS.",
|
|
6
6
|
"keywords": [
|
|
@@ -78,13 +78,12 @@
|
|
|
78
78
|
"tailwind-merge": "^3.0.2",
|
|
79
79
|
"zod": "^3.24.1",
|
|
80
80
|
"zustand": "^4.5.6",
|
|
81
|
-
"@intlayer/api": "5.3.
|
|
82
|
-
"@intlayer/config": "5.3.
|
|
83
|
-
"@intlayer/
|
|
84
|
-
"@intlayer/
|
|
85
|
-
"@intlayer/editor": "5.3.
|
|
86
|
-
"
|
|
87
|
-
"react-intlayer": "5.3.3"
|
|
81
|
+
"@intlayer/api": "5.3.4",
|
|
82
|
+
"@intlayer/config": "5.3.4",
|
|
83
|
+
"@intlayer/core": "5.3.4",
|
|
84
|
+
"@intlayer/dictionaries-entry": "5.3.4",
|
|
85
|
+
"@intlayer/editor-react": "5.3.4",
|
|
86
|
+
"react-intlayer": "5.3.4"
|
|
88
87
|
},
|
|
89
88
|
"devDependencies": {
|
|
90
89
|
"@chromatic-com/storybook": "^3.2.3",
|
|
@@ -124,8 +123,8 @@
|
|
|
124
123
|
"@intlayer/backend": "5.3.3",
|
|
125
124
|
"@utils/eslint-config": "1.0.4",
|
|
126
125
|
"@utils/ts-config": "1.0.4",
|
|
127
|
-
"@utils/
|
|
128
|
-
"@utils/
|
|
126
|
+
"@utils/tsup-config": "1.0.4",
|
|
127
|
+
"@utils/ts-config-types": "1.0.4"
|
|
129
128
|
},
|
|
130
129
|
"peerDependencies": {
|
|
131
130
|
"@monaco-editor/react": "^4.6.0",
|
|
@@ -136,14 +135,13 @@
|
|
|
136
135
|
"react-dom": ">=16.0.0",
|
|
137
136
|
"tailwind-merge": "^3.0.2",
|
|
138
137
|
"zustand": "^4.5.6",
|
|
139
|
-
"@intlayer/api": "5.3.
|
|
140
|
-
"@intlayer/config": "5.3.
|
|
141
|
-
"@intlayer/core": "5.3.
|
|
142
|
-
"@intlayer/dictionaries-entry": "5.3.
|
|
143
|
-
"@intlayer/editor": "5.3.
|
|
144
|
-
"
|
|
145
|
-
"intlayer": "5.3.
|
|
146
|
-
"react-intlayer": "5.3.3"
|
|
138
|
+
"@intlayer/api": "5.3.4",
|
|
139
|
+
"@intlayer/config": "5.3.4",
|
|
140
|
+
"@intlayer/core": "5.3.4",
|
|
141
|
+
"@intlayer/dictionaries-entry": "5.3.4",
|
|
142
|
+
"@intlayer/editor-react": "5.3.4",
|
|
143
|
+
"intlayer": "5.3.4",
|
|
144
|
+
"react-intlayer": "5.3.4"
|
|
147
145
|
},
|
|
148
146
|
"scripts": {
|
|
149
147
|
"build": "pnpm build:package && pnpm build:css",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Form-BpxW17v4.cjs","sources":["../src/components/Form/layout/FormItemLayout.tsx","../src/components/Form/elements/FormElement.tsx","../src/components/Form/elements/InputElement.tsx","../src/components/Form/elements/InputPasswordElement.tsx","../src/components/Form/elements/TextAreaElement.tsx","../src/components/Form/elements/EditableFieldInputElement.tsx","../src/components/Form/elements/EditableFieldTextAreaElement.tsx","../src/components/Form/elements/AutoSizeTextAreaElement.tsx","../src/components/Form/elements/CheckboxElement.tsx","../src/components/Form/elements/MultiselectElement.tsx","../src/components/Form/elements/SelectElement.tsx","../src/components/Form/elements/SwitchSelectorElement.tsx","../src/components/Form/Form.tsx"],"sourcesContent":["import type { FC, ReactNode } from 'react';\nimport { Form } from '../Form';\nimport { FormLabelLayout, type FormLabelLayoutProps } from './FormLabelLayout';\n\nexport type FormItemLayoutProps = Omit<FormLabelLayoutProps, 'children'> & {\n label?: ReactNode;\n description?: ReactNode;\n children: ReactNode;\n showErrorMessage?: boolean;\n};\n\nexport const FormItemLayout: FC<FormItemLayoutProps> = ({\n label,\n description,\n isRequired,\n info,\n children,\n showErrorMessage = true,\n htmlFor,\n}) => (\n <Form.Item className=\"flex w-full flex-col gap-2 p-2\">\n {(description || label) && (\n <div className=\"flex flex-col gap-1 p-1 leading-none\">\n {label && (\n <FormLabelLayout\n isRequired={isRequired}\n info={info}\n htmlFor={htmlFor}\n >\n {label}\n </FormLabelLayout>\n )}\n {description && <Form.Description>{description}</Form.Description>}\n </div>\n )}\n <Form.Control>{children}</Form.Control>\n\n {showErrorMessage && <Form.Message data-testid=\"error-message\" />}\n </Form.Item>\n);\n","'use client';\n\nimport type { ComponentProps, ElementType, ReactNode } from 'react';\nimport {\n useFormContext,\n type ControllerRenderProps,\n type FieldValues,\n} from 'react-hook-form';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { type FormItemLayoutProps, FormItemLayout } from '../layout';\n\nexport type FormElementProps<T extends ElementType> = {\n name: string;\n Element: T;\n label?: ReactNode;\n isRequired?: boolean;\n info?: string;\n showErrorMessage?: boolean;\n focus?: boolean;\n} & Omit<FormItemLayoutProps, 'children'>;\n\ntype FormFieldElementProps<T extends ElementType> = FormElementProps<T> &\n ComponentProps<T> & {\n field: ControllerRenderProps<FieldValues, string>;\n };\n\nconst FormFieldElement = <T extends ElementType>({\n field,\n name,\n label,\n Element,\n isRequired = false,\n info,\n description,\n showErrorMessage = true,\n ...props\n}: FormFieldElementProps<T>) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <Element data-testid=\"element\" id={name} {...field} {...props}>\n {props.children}\n </Element>\n </FormItemLayout>\n );\n};\n\n/**\n * FormElement is a component that allows you to create a form element with a label, description, error message, and validation.\n *\n * The Element prop is the type of the element that will be rendered.\n * This element will interact with the FormContext and will be controlled by the FormControl component.\n * The props used to control the element will be `value` and `onChange`.\n */\nexport const FormElement = <T extends ElementType>(\n props: FormElementProps<T> & ComponentProps<T>\n) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={props.name}\n render={({ field }) => <FormFieldElement {...props} field={field} />}\n />\n );\n};\n","import type { ComponentProps, FC } from 'react';\nimport { Input } from '../../../components/Input';\nimport { type FormElementProps, FormElement } from './FormElement';\n\ntype InputElementProps = Omit<FormElementProps<typeof Input>, 'Element'> &\n ComponentProps<typeof Input> & {\n name: string;\n };\n\nexport const InputElement: FC<InputElementProps> = (props) => (\n <FormElement\n id={props.name}\n data-testid={props.name}\n Element={Input}\n {...props}\n />\n);\n","import type { ComponentProps, FC } from 'react';\nimport { InputPassword } from '../../Input';\nimport { type FormElementProps, FormElement } from './FormElement';\n\ntype InputPasswordElementProps = Omit<\n FormElementProps<typeof InputPassword>,\n 'Element'\n> &\n ComponentProps<typeof InputPassword> & {\n name: string;\n autoComplete: 'current-password' | 'new-password';\n };\n\nexport const InputPasswordElement: FC<InputPasswordElementProps> = ({\n autoComplete,\n ...props\n}) => (\n <FormElement\n Element={InputPassword}\n id={props.name}\n data-testid={props.name}\n autoComplete={autoComplete}\n minLength={6}\n maxLength={255}\n {...props}\n />\n);\n","import type { FC } from 'react';\nimport { TextArea } from '../../TextArea/TextArea';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype TextAreaElementsProps = Omit<\n FormElementProps<typeof TextArea>,\n 'Element'\n> &\n React.ComponentProps<typeof TextArea> & {\n name: string;\n };\n\nexport const TextAreaElement: FC<TextAreaElementsProps> = (props) => (\n <FormElement\n Element={TextArea}\n id={props.name}\n data-testid={props.name}\n {...props}\n />\n);\n","import type { ComponentProps, ReactNode } from 'react';\nimport { EditableFieldInput } from '../../EditableField/EditableFieldInput';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype EditableFieldInputElementProps = Omit<\n FormElementProps<typeof EditableFieldInput>,\n 'Element'\n> &\n ComponentProps<typeof EditableFieldInput> & {\n name: string;\n description?: ReactNode;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const EditableFieldInputElement = (\n props: EditableFieldInputElementProps\n) => (\n <FormElement\n id={props.name}\n data-testid={props.name}\n Element={EditableFieldInput}\n {...props}\n />\n);\n","import type { ComponentProps, ReactNode } from 'react';\nimport { EditableFieldTextArea } from '../../EditableField/EditableFieldTextArea';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype EditableFieldTextAreaElementProps = Omit<\n FormElementProps<typeof EditableFieldTextArea>,\n 'Element'\n> &\n ComponentProps<typeof EditableFieldTextArea> & {\n name: string;\n description?: ReactNode;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const EditableFieldTextAreaElement = (\n props: EditableFieldTextAreaElementProps\n) => (\n <FormElement\n id={props.name}\n data-testid={props.name}\n Element={EditableFieldTextArea}\n {...props}\n />\n);\n","import type { FC } from 'react';\nimport { AutoSizedTextArea } from '../../TextArea/AutoSizeTextArea';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype AutoSizedTextAreaElementsProps = Omit<\n FormElementProps<typeof AutoSizedTextArea>,\n 'Element'\n> &\n React.ComponentProps<typeof AutoSizedTextArea> & {\n name: string;\n };\n\nexport const AutoSizedTextAreaElement: FC<AutoSizedTextAreaElementsProps> = (\n props\n) => (\n <FormElement\n Element={AutoSizedTextArea}\n id={props.name}\n data-testid={props.name}\n {...props}\n />\n);\n","import { type ComponentProps, type FC } from 'react';\nimport { Checkbox } from '../../Input';\nimport { type FormElementProps, FormElement } from './FormElement';\n\ntype CheckboxElementProps = Omit<FormElementProps<typeof Checkbox>, 'Element'> &\n ComponentProps<typeof Checkbox> & {\n name: string;\n inputLabel?: string;\n };\n\ntype CheckboxComponentProps = Omit<ComponentProps<typeof Checkbox>, 'label'> & {\n name: string;\n inputLabel?: ComponentProps<typeof Checkbox>['label'];\n};\n\nconst CheckboxComponent: FC<CheckboxComponentProps> = ({\n inputLabel,\n ...props\n}) => <Checkbox {...props} label={inputLabel} />;\n\nexport const CheckboxElement: FC<CheckboxElementProps> = ({\n autoComplete,\n ...props\n}) => (\n <FormElement\n Element={CheckboxComponent}\n id={props.name}\n data-testid={props.name}\n autoComplete={autoComplete}\n minLength={6}\n maxLength={255}\n {...props}\n />\n);\n","/* eslint-disable react-hooks/rules-of-hooks */\nimport type { ComponentProps, ReactNode } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { MultiSelect } from '../../Select/Multiselect';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { FormItemLayout } from '../layout/FormItemLayout';\nimport type { FormElementProps } from './FormElement';\n\ntype SelectElementsProps = Omit<\n FormElementProps<typeof MultiSelect>,\n 'Element'\n> &\n ComponentProps<typeof MultiSelect> & {\n name: string;\n description?: string;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const MultiSelectElement = ({\n name,\n description,\n label,\n isRequired,\n info,\n showErrorMessage,\n children,\n ...props\n}: SelectElementsProps) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={name}\n render={({ field }) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <MultiSelect\n onValueChange={field.onChange}\n values={field.value}\n {...props}\n >\n {children}\n </MultiSelect>\n </FormItemLayout>\n );\n }}\n />\n );\n};\n","/* eslint-disable react-hooks/rules-of-hooks */\n\nimport type { ComponentProps, ReactNode } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { Select } from '../../Select/Select';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { FormItemLayout } from '../layout/FormItemLayout';\nimport type { FormElementProps } from './FormElement';\n\ntype SelectElementsProps = Omit<FormElementProps<typeof Select>, 'Element'> &\n ComponentProps<typeof Select> & {\n name: string;\n description?: string;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const SelectElement = ({\n name,\n description,\n label,\n isRequired,\n info,\n showErrorMessage,\n children,\n ...props\n}: SelectElementsProps) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={name}\n render={({ field }) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <Select\n onValueChange={field.onChange}\n defaultValue={field.value}\n {...props}\n >\n {children}\n </Select>\n </FormItemLayout>\n );\n }}\n />\n );\n};\n","/* eslint-disable react-hooks/rules-of-hooks */\n\nimport type { ComponentProps, ReactNode } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { SwitchSelector } from '../../SwitchSelector';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { FormItemLayout } from '../layout/FormItemLayout';\nimport type { FormElementProps } from './FormElement';\n\ntype SwitchSelectorElementProps = Omit<\n FormElementProps<typeof SwitchSelector>,\n 'Element'\n> &\n ComponentProps<typeof SwitchSelector> & {\n name: string;\n description?: string;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const SwitchSelectorElement = ({\n name,\n description,\n label,\n isRequired,\n info,\n showErrorMessage,\n children,\n ...props\n}: SwitchSelectorElementProps) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={name}\n render={({ field }) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <SwitchSelector {...field} {...props}>\n {children}\n </SwitchSelector>\n </FormItemLayout>\n );\n }}\n />\n );\n};\n","import { Button } from '../Button';\nimport {\n FormElement,\n InputElement,\n InputPasswordElement,\n TextAreaElement,\n} from './elements';\nimport { AutoSizedTextAreaElement } from './elements/AutoSizeTextAreaElement';\nimport { CheckboxElement } from './elements/CheckboxElement';\nimport { EditableFieldInputElement } from './elements/EditableFieldInputElement';\nimport { EditableFieldTextAreaElement } from './elements/EditableFieldTextAreaElement';\nimport { MultiSelectElement } from './elements/MultiselectElement';\nimport { SelectElement } from './elements/SelectElement';\nimport { SwitchSelectorElement } from './elements/SwitchSelectorElement';\nimport { Form as FormRoot } from './FormBase';\nimport { FormControl } from './FormControl';\nimport { FormDescription } from './FormDescription';\nimport { FormField } from './FormField';\nimport { FormItem } from './FormItem';\nimport { FormMessage } from './FormMessage';\nimport { FormLabelLayout } from './layout';\n\ntype FormType = typeof FormRoot & {\n Description: typeof FormDescription;\n Control: typeof FormControl;\n Field: typeof FormField;\n Item: typeof FormItem;\n Label: typeof FormLabelLayout;\n Message: typeof FormMessage;\n Element: typeof FormElement;\n Button: typeof Button;\n Input: typeof InputElement;\n InputPassword: typeof InputPasswordElement;\n Checkbox: typeof CheckboxElement;\n TextArea: typeof TextAreaElement;\n AutoSizedTextArea: typeof AutoSizedTextAreaElement;\n MultiSelect: typeof MultiSelectElement;\n Select: typeof SelectElement;\n EditableFieldInput: typeof EditableFieldInputElement;\n EditableFieldTextArea: typeof EditableFieldTextAreaElement;\n SwitchSelector: typeof SwitchSelectorElement;\n};\n\n/**\n * Form components\n *\n * Example of usage:\n * ```jsx\n * <Form\n * schema={ZodSchema}\n * onSubmitSuccess={onSubmitSuccess}\n * onSubmitError={onSubmitError}\n * autoComplete\n * >\n * <Form.Input name=\"name\" label=\"Name\" />\n * <Form.Button type=\"submit\" label=\"Click to submit\">\n * Submit\n * </Form.Button>\n * </Form>\n * ```\n */\nexport const Form = FormRoot as FormType;\nForm.Description = FormDescription;\nForm.Control = FormControl;\nForm.Field = FormField;\nForm.Item = FormItem;\nForm.Label = FormLabelLayout;\nForm.Message = FormMessage;\nForm.Element = FormElement;\nForm.Input = InputElement;\nForm.InputPassword = InputPasswordElement;\nForm.Checkbox = CheckboxElement;\nForm.TextArea = TextAreaElement;\nForm.AutoSizedTextArea = AutoSizedTextAreaElement;\nForm.Button = Button;\nForm.Select = SelectElement;\nForm.MultiSelect = MultiSelectElement;\nForm.EditableFieldInput = EditableFieldInputElement;\nForm.EditableFieldTextArea = EditableFieldTextAreaElement;\nForm.SwitchSelector = SwitchSelectorElement;\n"],"names":["jsxs","jsx","FormLabelLayout","useFormField","useFormContext","Input","InputPassword","TextArea","EditableFieldInput","EditableFieldTextArea","AutoSizedTextArea","Checkbox","MultiSelect","Select","SwitchSelector","FormRoot","FormDescription","FormControl","FormField","FormItem","FormMessage","Button"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAWO,MAAM,iBAA0C,CAAC;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,mBAAmB;AAAA,EACnB;AACF,MACGA,2BAAAA,KAAA,KAAK,MAAL,EAAU,WAAU,kCACjB,UAAA;AAAA,GAAA,eAAe,UACfA,2BAAA,KAAC,OAAI,EAAA,WAAU,wCACZ,UAAA;AAAA,IACC,SAAAC,2BAAA;AAAA,MAACC,uCAAA;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QAEC,UAAA;AAAA,MAAA;AAAA,IACH;AAAA,IAED,eAAeD,2BAAA,IAAC,KAAK,aAAL,EAAkB,UAAY,YAAA,CAAA;AAAA,EAAA,GACjD;AAAA,EAEDA,2BAAAA,IAAA,KAAK,SAAL,EAAc,SAAS,CAAA;AAAA,EAEvB,oBAAqBA,2BAAA,IAAA,KAAK,SAAL,EAAa,eAAY,gBAAgB,CAAA;AAAA,EACjE,CAAA;ACXF,MAAM,mBAAmB,CAAwB;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA,mBAAmB;AAAA,EACnB,GAAG;AACL,MAAgC;AACxB,QAAA,EAAE,MAAM,IAAIE,uCAAa;AAG7B,SAAAF,2BAAA;AAAA,IAAC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AAE,MAAM,IAAIE,uCAAa;AAG7B,eAAAF,2BAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,SAAS;AAAA,YACT;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,gBAAc,CAAC,CAAC;AAAA,YAEhB,yCAACa,gDAAgB,EAAA,GAAG,OAAQ,GAAG,OAC5B,SACH,CAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IAEJ;AAAA,EACF;AAEJ;ACEO,MAAM,OAAOC,yBAAAA;AACpB,KAAK,cAAcC,gCAAA;AACnB,KAAK,UAAUC,4BAAA;AACf,KAAK,QAAQC,0BAAA;AACb,KAAK,OAAOC,yBAAA;AACZ,KAAK,QAAQjB,uCAAA;AACb,KAAK,UAAUkB,4BAAA;AACf,KAAK,UAAU;AACf,KAAK,QAAQ;AACb,KAAK,gBAAgB;AACrB,KAAK,WAAW;AAChB,KAAK,WAAW;AAChB,KAAK,oBAAoB;AACzB,KAAK,SAASC,yBAAA;AACd,KAAK,SAAS;AACd,KAAK,cAAc;AACnB,KAAK,qBAAqB;AAC1B,KAAK,wBAAwB;AAC7B,KAAK,iBAAiB;;;;;;;;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Form-MjLzPGze.js","sources":["../src/components/Form/layout/FormItemLayout.tsx","../src/components/Form/elements/FormElement.tsx","../src/components/Form/elements/InputElement.tsx","../src/components/Form/elements/InputPasswordElement.tsx","../src/components/Form/elements/TextAreaElement.tsx","../src/components/Form/elements/EditableFieldInputElement.tsx","../src/components/Form/elements/EditableFieldTextAreaElement.tsx","../src/components/Form/elements/AutoSizeTextAreaElement.tsx","../src/components/Form/elements/CheckboxElement.tsx","../src/components/Form/elements/MultiselectElement.tsx","../src/components/Form/elements/SelectElement.tsx","../src/components/Form/elements/SwitchSelectorElement.tsx","../src/components/Form/Form.tsx"],"sourcesContent":["import type { FC, ReactNode } from 'react';\nimport { Form } from '../Form';\nimport { FormLabelLayout, type FormLabelLayoutProps } from './FormLabelLayout';\n\nexport type FormItemLayoutProps = Omit<FormLabelLayoutProps, 'children'> & {\n label?: ReactNode;\n description?: ReactNode;\n children: ReactNode;\n showErrorMessage?: boolean;\n};\n\nexport const FormItemLayout: FC<FormItemLayoutProps> = ({\n label,\n description,\n isRequired,\n info,\n children,\n showErrorMessage = true,\n htmlFor,\n}) => (\n <Form.Item className=\"flex w-full flex-col gap-2 p-2\">\n {(description || label) && (\n <div className=\"flex flex-col gap-1 p-1 leading-none\">\n {label && (\n <FormLabelLayout\n isRequired={isRequired}\n info={info}\n htmlFor={htmlFor}\n >\n {label}\n </FormLabelLayout>\n )}\n {description && <Form.Description>{description}</Form.Description>}\n </div>\n )}\n <Form.Control>{children}</Form.Control>\n\n {showErrorMessage && <Form.Message data-testid=\"error-message\" />}\n </Form.Item>\n);\n","'use client';\n\nimport type { ComponentProps, ElementType, ReactNode } from 'react';\nimport {\n useFormContext,\n type ControllerRenderProps,\n type FieldValues,\n} from 'react-hook-form';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { type FormItemLayoutProps, FormItemLayout } from '../layout';\n\nexport type FormElementProps<T extends ElementType> = {\n name: string;\n Element: T;\n label?: ReactNode;\n isRequired?: boolean;\n info?: string;\n showErrorMessage?: boolean;\n focus?: boolean;\n} & Omit<FormItemLayoutProps, 'children'>;\n\ntype FormFieldElementProps<T extends ElementType> = FormElementProps<T> &\n ComponentProps<T> & {\n field: ControllerRenderProps<FieldValues, string>;\n };\n\nconst FormFieldElement = <T extends ElementType>({\n field,\n name,\n label,\n Element,\n isRequired = false,\n info,\n description,\n showErrorMessage = true,\n ...props\n}: FormFieldElementProps<T>) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <Element data-testid=\"element\" id={name} {...field} {...props}>\n {props.children}\n </Element>\n </FormItemLayout>\n );\n};\n\n/**\n * FormElement is a component that allows you to create a form element with a label, description, error message, and validation.\n *\n * The Element prop is the type of the element that will be rendered.\n * This element will interact with the FormContext and will be controlled by the FormControl component.\n * The props used to control the element will be `value` and `onChange`.\n */\nexport const FormElement = <T extends ElementType>(\n props: FormElementProps<T> & ComponentProps<T>\n) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={props.name}\n render={({ field }) => <FormFieldElement {...props} field={field} />}\n />\n );\n};\n","import type { ComponentProps, FC } from 'react';\nimport { Input } from '../../../components/Input';\nimport { type FormElementProps, FormElement } from './FormElement';\n\ntype InputElementProps = Omit<FormElementProps<typeof Input>, 'Element'> &\n ComponentProps<typeof Input> & {\n name: string;\n };\n\nexport const InputElement: FC<InputElementProps> = (props) => (\n <FormElement\n id={props.name}\n data-testid={props.name}\n Element={Input}\n {...props}\n />\n);\n","import type { ComponentProps, FC } from 'react';\nimport { InputPassword } from '../../Input';\nimport { type FormElementProps, FormElement } from './FormElement';\n\ntype InputPasswordElementProps = Omit<\n FormElementProps<typeof InputPassword>,\n 'Element'\n> &\n ComponentProps<typeof InputPassword> & {\n name: string;\n autoComplete: 'current-password' | 'new-password';\n };\n\nexport const InputPasswordElement: FC<InputPasswordElementProps> = ({\n autoComplete,\n ...props\n}) => (\n <FormElement\n Element={InputPassword}\n id={props.name}\n data-testid={props.name}\n autoComplete={autoComplete}\n minLength={6}\n maxLength={255}\n {...props}\n />\n);\n","import type { FC } from 'react';\nimport { TextArea } from '../../TextArea/TextArea';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype TextAreaElementsProps = Omit<\n FormElementProps<typeof TextArea>,\n 'Element'\n> &\n React.ComponentProps<typeof TextArea> & {\n name: string;\n };\n\nexport const TextAreaElement: FC<TextAreaElementsProps> = (props) => (\n <FormElement\n Element={TextArea}\n id={props.name}\n data-testid={props.name}\n {...props}\n />\n);\n","import type { ComponentProps, ReactNode } from 'react';\nimport { EditableFieldInput } from '../../EditableField/EditableFieldInput';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype EditableFieldInputElementProps = Omit<\n FormElementProps<typeof EditableFieldInput>,\n 'Element'\n> &\n ComponentProps<typeof EditableFieldInput> & {\n name: string;\n description?: ReactNode;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const EditableFieldInputElement = (\n props: EditableFieldInputElementProps\n) => (\n <FormElement\n id={props.name}\n data-testid={props.name}\n Element={EditableFieldInput}\n {...props}\n />\n);\n","import type { ComponentProps, ReactNode } from 'react';\nimport { EditableFieldTextArea } from '../../EditableField/EditableFieldTextArea';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype EditableFieldTextAreaElementProps = Omit<\n FormElementProps<typeof EditableFieldTextArea>,\n 'Element'\n> &\n ComponentProps<typeof EditableFieldTextArea> & {\n name: string;\n description?: ReactNode;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const EditableFieldTextAreaElement = (\n props: EditableFieldTextAreaElementProps\n) => (\n <FormElement\n id={props.name}\n data-testid={props.name}\n Element={EditableFieldTextArea}\n {...props}\n />\n);\n","import type { FC } from 'react';\nimport { AutoSizedTextArea } from '../../TextArea/AutoSizeTextArea';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype AutoSizedTextAreaElementsProps = Omit<\n FormElementProps<typeof AutoSizedTextArea>,\n 'Element'\n> &\n React.ComponentProps<typeof AutoSizedTextArea> & {\n name: string;\n };\n\nexport const AutoSizedTextAreaElement: FC<AutoSizedTextAreaElementsProps> = (\n props\n) => (\n <FormElement\n Element={AutoSizedTextArea}\n id={props.name}\n data-testid={props.name}\n {...props}\n />\n);\n","import { type ComponentProps, type FC } from 'react';\nimport { Checkbox } from '../../Input';\nimport { type FormElementProps, FormElement } from './FormElement';\n\ntype CheckboxElementProps = Omit<FormElementProps<typeof Checkbox>, 'Element'> &\n ComponentProps<typeof Checkbox> & {\n name: string;\n inputLabel?: string;\n };\n\ntype CheckboxComponentProps = Omit<ComponentProps<typeof Checkbox>, 'label'> & {\n name: string;\n inputLabel?: ComponentProps<typeof Checkbox>['label'];\n};\n\nconst CheckboxComponent: FC<CheckboxComponentProps> = ({\n inputLabel,\n ...props\n}) => <Checkbox {...props} label={inputLabel} />;\n\nexport const CheckboxElement: FC<CheckboxElementProps> = ({\n autoComplete,\n ...props\n}) => (\n <FormElement\n Element={CheckboxComponent}\n id={props.name}\n data-testid={props.name}\n autoComplete={autoComplete}\n minLength={6}\n maxLength={255}\n {...props}\n />\n);\n","/* eslint-disable react-hooks/rules-of-hooks */\nimport type { ComponentProps, ReactNode } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { MultiSelect } from '../../Select/Multiselect';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { FormItemLayout } from '../layout/FormItemLayout';\nimport type { FormElementProps } from './FormElement';\n\ntype SelectElementsProps = Omit<\n FormElementProps<typeof MultiSelect>,\n 'Element'\n> &\n ComponentProps<typeof MultiSelect> & {\n name: string;\n description?: string;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const MultiSelectElement = ({\n name,\n description,\n label,\n isRequired,\n info,\n showErrorMessage,\n children,\n ...props\n}: SelectElementsProps) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={name}\n render={({ field }) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <MultiSelect\n onValueChange={field.onChange}\n values={field.value}\n {...props}\n >\n {children}\n </MultiSelect>\n </FormItemLayout>\n );\n }}\n />\n );\n};\n","/* eslint-disable react-hooks/rules-of-hooks */\n\nimport type { ComponentProps, ReactNode } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { Select } from '../../Select/Select';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { FormItemLayout } from '../layout/FormItemLayout';\nimport type { FormElementProps } from './FormElement';\n\ntype SelectElementsProps = Omit<FormElementProps<typeof Select>, 'Element'> &\n ComponentProps<typeof Select> & {\n name: string;\n description?: string;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const SelectElement = ({\n name,\n description,\n label,\n isRequired,\n info,\n showErrorMessage,\n children,\n ...props\n}: SelectElementsProps) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={name}\n render={({ field }) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <Select\n onValueChange={field.onChange}\n defaultValue={field.value}\n {...props}\n >\n {children}\n </Select>\n </FormItemLayout>\n );\n }}\n />\n );\n};\n","/* eslint-disable react-hooks/rules-of-hooks */\n\nimport type { ComponentProps, ReactNode } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { SwitchSelector } from '../../SwitchSelector';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { FormItemLayout } from '../layout/FormItemLayout';\nimport type { FormElementProps } from './FormElement';\n\ntype SwitchSelectorElementProps = Omit<\n FormElementProps<typeof SwitchSelector>,\n 'Element'\n> &\n ComponentProps<typeof SwitchSelector> & {\n name: string;\n description?: string;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const SwitchSelectorElement = ({\n name,\n description,\n label,\n isRequired,\n info,\n showErrorMessage,\n children,\n ...props\n}: SwitchSelectorElementProps) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={name}\n render={({ field }) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <SwitchSelector {...field} {...props}>\n {children}\n </SwitchSelector>\n </FormItemLayout>\n );\n }}\n />\n );\n};\n","import { Button } from '../Button';\nimport {\n FormElement,\n InputElement,\n InputPasswordElement,\n TextAreaElement,\n} from './elements';\nimport { AutoSizedTextAreaElement } from './elements/AutoSizeTextAreaElement';\nimport { CheckboxElement } from './elements/CheckboxElement';\nimport { EditableFieldInputElement } from './elements/EditableFieldInputElement';\nimport { EditableFieldTextAreaElement } from './elements/EditableFieldTextAreaElement';\nimport { MultiSelectElement } from './elements/MultiselectElement';\nimport { SelectElement } from './elements/SelectElement';\nimport { SwitchSelectorElement } from './elements/SwitchSelectorElement';\nimport { Form as FormRoot } from './FormBase';\nimport { FormControl } from './FormControl';\nimport { FormDescription } from './FormDescription';\nimport { FormField } from './FormField';\nimport { FormItem } from './FormItem';\nimport { FormMessage } from './FormMessage';\nimport { FormLabelLayout } from './layout';\n\ntype FormType = typeof FormRoot & {\n Description: typeof FormDescription;\n Control: typeof FormControl;\n Field: typeof FormField;\n Item: typeof FormItem;\n Label: typeof FormLabelLayout;\n Message: typeof FormMessage;\n Element: typeof FormElement;\n Button: typeof Button;\n Input: typeof InputElement;\n InputPassword: typeof InputPasswordElement;\n Checkbox: typeof CheckboxElement;\n TextArea: typeof TextAreaElement;\n AutoSizedTextArea: typeof AutoSizedTextAreaElement;\n MultiSelect: typeof MultiSelectElement;\n Select: typeof SelectElement;\n EditableFieldInput: typeof EditableFieldInputElement;\n EditableFieldTextArea: typeof EditableFieldTextAreaElement;\n SwitchSelector: typeof SwitchSelectorElement;\n};\n\n/**\n * Form components\n *\n * Example of usage:\n * ```jsx\n * <Form\n * schema={ZodSchema}\n * onSubmitSuccess={onSubmitSuccess}\n * onSubmitError={onSubmitError}\n * autoComplete\n * >\n * <Form.Input name=\"name\" label=\"Name\" />\n * <Form.Button type=\"submit\" label=\"Click to submit\">\n * Submit\n * </Form.Button>\n * </Form>\n * ```\n */\nexport const Form = FormRoot as FormType;\nForm.Description = FormDescription;\nForm.Control = FormControl;\nForm.Field = FormField;\nForm.Item = FormItem;\nForm.Label = FormLabelLayout;\nForm.Message = FormMessage;\nForm.Element = FormElement;\nForm.Input = InputElement;\nForm.InputPassword = InputPasswordElement;\nForm.Checkbox = CheckboxElement;\nForm.TextArea = TextAreaElement;\nForm.AutoSizedTextArea = AutoSizedTextAreaElement;\nForm.Button = Button;\nForm.Select = SelectElement;\nForm.MultiSelect = MultiSelectElement;\nForm.EditableFieldInput = EditableFieldInputElement;\nForm.EditableFieldTextArea = EditableFieldTextAreaElement;\nForm.SwitchSelector = SwitchSelectorElement;\n"],"names":["FormRoot"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAWO,MAAM,iBAA0C,CAAC;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,mBAAmB;AAAA,EACnB;AACF,MACG,qBAAA,KAAK,MAAL,EAAU,WAAU,kCACjB,UAAA;AAAA,GAAA,eAAe,UACf,qBAAC,OAAI,EAAA,WAAU,wCACZ,UAAA;AAAA,IACC,SAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QAEC,UAAA;AAAA,MAAA;AAAA,IACH;AAAA,IAED,eAAe,oBAAC,KAAK,aAAL,EAAkB,UAAY,YAAA,CAAA;AAAA,EAAA,GACjD;AAAA,EAED,oBAAA,KAAK,SAAL,EAAc,SAAS,CAAA;AAAA,EAEvB,oBAAqB,oBAAA,KAAK,SAAL,EAAa,eAAY,gBAAgB,CAAA;AAAA,EACjE,CAAA;ACXF,MAAM,mBAAmB,CAAwB;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA,mBAAmB;AAAA,EACnB,GAAG;AACL,MAAgC;AACxB,QAAA,EAAE,MAAM,IAAI,aAAa;AAG7B,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAc,CAAC,CAAC;AAAA,MAE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KAAK,QAAQ;AACb,KAAK,OAAO;AACZ,KAAK,QAAQ;AACb,KAAK,UAAU;AACf,KAAK,UAAU;AACf,KAAK,QAAQ;AACb,KAAK,gBAAgB;AACrB,KAAK,WAAW;AAChB,KAAK,WAAW;AAChB,KAAK,oBAAoB;AACzB,KAAK,SAAS;AACd,KAAK,SAAS;AACd,KAAK,cAAc;AACnB,KAAK,qBAAqB;AAC1B,KAAK,wBAAwB;AAC7B,KAAK,iBAAiB;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-BpCAhDMe.cjs","sources":["../src/components/DictionaryEditor/NodeWrapper/ArrayWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/ConditionWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/TranslationWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/index.tsx"],"sourcesContent":["import {\n isSameKeyPath,\n NodeType,\n type ContentNode,\n type KeyPath,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { ItemLayout } from '../ItemLayout';\nimport { NodeWrapper, type NodeWrapperProps } from './index';\n\ntype ArrayWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: ContentNode[];\n};\n\nexport const ArrayWrapper: FC<ArrayWrapperProps> = (props) => {\n const { keyPath, section, onFocusKeyPath, focusedKeyPath = [] } = props;\n\n return section.map((subSection, key) => {\n const newKeyPathEl: KeyPath = {\n key,\n type: NodeType.Array,\n };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n return (\n <ItemLayout\n level={keyPath.length}\n key={JSON.stringify(subSection)}\n title={`${key}`}\n description=\"\"\n isSelected={isSameKeyPath(newKeyPath, focusedKeyPath)}\n onClick={(e) => {\n e.stopPropagation();\n onFocusKeyPath(newKeyPath);\n }}\n >\n <NodeWrapper {...props} keyPath={newKeyPath} section={subSection} />\n </ItemLayout>\n );\n });\n};\n","import {\n type KeyPath,\n NodeType,\n type ConditionContent,\n type ContentNode,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { NodeWrapper, traceKeys, type NodeWrapperProps } from './index';\n\ntype ConditionWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: ConditionContent<ContentNode>;\n};\n\nexport const ConditionWrapper: FC<ConditionWrapperProps> = (props) => {\n const { keyPath, section } = props;\n\n return (\n <div className=\"ml-2 grid grid-cols-[auto,1fr] gap-2\">\n {Object.keys(section)\n .filter((key) => !traceKeys.includes(key))\n .map((key) => {\n const newKeyPathEl: KeyPath = {\n type: NodeType.Condition,\n key,\n };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n const subSection =\n section[NodeType.Condition][\n key as keyof (typeof section)[NodeType.Condition]\n ]!;\n\n return (\n <>\n <span className=\"flex items-center font-bold\">{key}</span>\n <NodeWrapper\n {...props}\n key={key}\n keyPath={newKeyPath}\n section={subSection}\n />\n </>\n );\n })}\n </div>\n );\n};\n","import {\n type KeyPath,\n NodeType,\n type EnumerationContent,\n type ContentNode,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { NodeWrapper, traceKeys, type NodeWrapperProps } from './index';\n\ntype EnumerationWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: EnumerationContent<ContentNode>;\n};\n\nexport const EnumerationWrapper: FC<EnumerationWrapperProps> = (props) => {\n const { keyPath, section } = props;\n\n return (\n <div className=\"ml-2 grid grid-cols-[auto,1fr] gap-2\">\n {Object.keys(section)\n .filter((key) => !traceKeys.includes(key))\n .map((key) => {\n const newKeyPathEl: KeyPath = {\n type: NodeType.Enumeration,\n key,\n };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n const subSection =\n section[NodeType.Enumeration][\n key as keyof (typeof section)[NodeType.Enumeration]\n ]!;\n\n return (\n <>\n <span className=\"flex items-center font-bold\">{key}</span>\n <NodeWrapper\n {...props}\n key={key}\n keyPath={newKeyPath}\n section={subSection}\n />\n </>\n );\n })}\n </div>\n );\n};\n","import {\n type KeyPath,\n isSameKeyPath,\n type ContentNode,\n NodeType,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { ItemLayout } from '../ItemLayout';\nimport { NodeWrapper, traceKeys, type NodeWrapperProps } from './index';\n\ntype NestedObjectWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: Record<string, ContentNode>;\n};\n\nexport const NestedObjectWrapper: FC<NestedObjectWrapperProps> = (props) => {\n const { keyPath, section, focusedKeyPath = [], onFocusKeyPath } = props;\n\n return Object.keys(section)\n .filter((key) => !traceKeys.includes(key))\n .map((key) => {\n const newKeyPathEl: KeyPath = { key, type: NodeType.Object };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n return (\n <ItemLayout\n level={keyPath.length}\n key={key}\n title={key}\n description=\"\"\n isSelected={isSameKeyPath(newKeyPath, focusedKeyPath)}\n onClick={(e) => {\n e.stopPropagation();\n\n onFocusKeyPath(newKeyPath);\n }}\n >\n <NodeWrapper {...props} keyPath={newKeyPath} section={section[key]} />\n </ItemLayout>\n );\n });\n};\n","import {\n type KeyPath,\n NodeType,\n type TranslationContent,\n type ContentNode,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { NodeWrapper, type NodeWrapperProps } from './index';\n\ntype TranslationWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: TranslationContent<ContentNode>;\n};\n\nexport const TranslationWrapper: FC<TranslationWrapperProps> = (props) => {\n const { keyPath, section, locale } = props;\n\n const newKeyPathEl: KeyPath = {\n type: NodeType.Translation,\n key: locale,\n };\n\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n const subSection =\n section.translation[\n locale as unknown as keyof (typeof section)['translation']\n ]!;\n\n return <NodeWrapper {...props} keyPath={newKeyPath} section={subSection} />;\n};\n","'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport {\n type ConditionContent,\n type MarkdownContent,\n type EnumerationContent,\n type TranslationContent,\n NodeType,\n type KeyPath,\n type ContentNode,\n getNodeType,\n} from '@intlayer/core';\nimport { type FC } from 'react';\nimport { ArrayWrapper } from './ArrayWrapper';\nimport { ConditionWrapper } from './ConditionWrapper';\nimport { EnumerationWrapper } from './EnumerationWrapper';\nimport { MarkdownWrapper } from './MarkdownWrapper';\nimport { NestedObjectWrapper } from './NestedObjectWrapper';\nimport { StringWrapper } from './StringWrapper';\nimport { TranslationWrapper } from './TranslationWrapper';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n keyPath: KeyPath[];\n section: ContentNode;\n onContentChange: (content: { keyPath: KeyPath[]; newValue: string }) => void;\n locale: Locales;\n editedContent: ContentNode;\n focusedKeyPath: KeyPath[] | undefined;\n onFocusKeyPath: (keyPath: KeyPath[]) => void;\n onClickEdit?: (keyPath: KeyPath[]) => void;\n};\n\nexport const NodeWrapper: FC<NodeWrapperProps> = (props) => {\n const { section } = props;\n const nodeType = getNodeType(section);\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return (\n <span className=\"text-neutral text-xs\">React node not editable</span>\n );\n }\n\n if (nodeType === NodeType.Nested) {\n return (\n <div className=\"ml-2 grid grid-cols-[auto,1fr] gap-2\">\n [Nested] Dictionary\n </div>\n );\n }\n\n if (nodeType === NodeType.Markdown) {\n return (\n <MarkdownWrapper {...props} section={section as MarkdownContent} />\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationWrapper\n {...props}\n section={section as TranslationContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationWrapper\n {...props}\n section={section as EnumerationContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Condition) {\n return (\n <ConditionWrapper\n {...props}\n section={section as ConditionContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayWrapper\n {...props}\n section={section as unknown as ContentNode[]}\n />\n );\n }\n\n return (\n <NestedObjectWrapper\n {...props}\n section={section as Record<string, ContentNode>}\n />\n );\n }\n\n if (typeof section === 'string') {\n return <StringWrapper {...props} section={section} />;\n }\n};\n"],"names":["NodeType","jsx","ItemLayout","isSameKeyPath","jsxs","Fragment","createElement","getNodeType","MarkdownWrapper","StringWrapper"],"mappings":";;;;;;;;AAca,MAAA,eAAsC,CAAC,UAAU;AAC5D,QAAM,EAAE,SAAS,SAAS,gBAAgB,iBAAiB,OAAO;AAElE,SAAO,QAAQ,IAAI,CAAC,YAAY,QAAQ;AACtC,UAAM,eAAwB;AAAA,MAC5B;AAAA,MACA,MAAMA,KAAAA,SAAS;AAAA,IACjB;AACA,UAAM,aAAwB,CAAC,GAAG,SAAS,YAAY;AAGrD,WAAAC,2BAAA;AAAA,MAACC,uCAAA;AAAA,MAAA;AAAA,QACC,OAAO,QAAQ;AAAA,QAEf,OAAO,GAAG,GAAG;AAAA,QACb,aAAY;AAAA,QACZ,YAAYC,KAAAA,cAAc,YAAY,cAAc;AAAA,QACpD,SAAS,CAAC,MAAM;AACd,YAAE,gBAAgB;AAClB,yBAAe,UAAU;AAAA,QAC3B;AAAA,QAEA,yCAAC,aAAa,EAAA,GAAG,OAAO,SAAS,YAAY,SAAS,WAAY,CAAA;AAAA,MAAA;AAAA,MAT7D,KAAK,UAAU,UAAU;AAAA,IAUhC;AAAA,EAAA,CAEH;AACH;AC3Ba,MAAA,mBAA8C,CAAC,UAAU;AAC9D,QAAA,EAAE,SAAS,QAAA,IAAY;AAE7B,wCACG,OAAI,EAAA,WAAU,wCACZ,UAAO,OAAA,KAAK,OAAO,EACjB,OAAO,CAAC,QAAQ,CAAC,UAAU,SAAS,GAAG,CAAC,EACxC,IAAI,CAAC,QAAQ;AACZ,UAAM,eAAwB;AAAA,MAC5B,MAAMH,KAAS,SAAA;AAAA,MACf;AAAA,IACF;AACA,UAAM,aAAwB,CAAC,GAAG,SAAS,YAAY;AAEvD,UAAM,aACJ,QAA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AG,OAAO,QAAqC,CAAA;AAAA,IAAA;AAIjE,QAAA,aAAaR,cAAS,aAAa;AAEnC,aAAAC,2BAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACE,GAAG;AAAA,UACJ;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAIA,QAAA,aAAaD,cAAS,aAAa;AAEnC,aAAAC,2BAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACE,GAAG;AAAA,UACJ;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAIA,QAAA,aAAaD,cAAS,WAAW;AAEjC,aAAAC,2BAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACE,GAAG;AAAA,UACJ;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAIA,QAAA,aAAaD,cAAS,OAAO;AAE7B,aAAAC,2BAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACE,GAAG;AAAA,UACJ;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAKF,WAAAA,2BAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACE,GAAG;AAAA,QACJ;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAIA,MAAA,OAAO,YAAY,UAAU;AAC/B,WAAQA,2BAAA,IAAAQ,sDAAA,eAAA,EAAe,GAAG,OAAO,QAAkB,CAAA;AAAA,EAAA;AAEvD;;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-CVTE3oHq.js","sources":["../src/components/DictionaryEditor/NodeWrapper/ArrayWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/ConditionWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/TranslationWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/index.tsx"],"sourcesContent":["import {\n isSameKeyPath,\n NodeType,\n type ContentNode,\n type KeyPath,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { ItemLayout } from '../ItemLayout';\nimport { NodeWrapper, type NodeWrapperProps } from './index';\n\ntype ArrayWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: ContentNode[];\n};\n\nexport const ArrayWrapper: FC<ArrayWrapperProps> = (props) => {\n const { keyPath, section, onFocusKeyPath, focusedKeyPath = [] } = props;\n\n return section.map((subSection, key) => {\n const newKeyPathEl: KeyPath = {\n key,\n type: NodeType.Array,\n };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n return (\n <ItemLayout\n level={keyPath.length}\n key={JSON.stringify(subSection)}\n title={`${key}`}\n description=\"\"\n isSelected={isSameKeyPath(newKeyPath, focusedKeyPath)}\n onClick={(e) => {\n e.stopPropagation();\n onFocusKeyPath(newKeyPath);\n }}\n >\n <NodeWrapper {...props} keyPath={newKeyPath} section={subSection} />\n </ItemLayout>\n );\n });\n};\n","import {\n type KeyPath,\n NodeType,\n type ConditionContent,\n type ContentNode,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { NodeWrapper, traceKeys, type NodeWrapperProps } from './index';\n\ntype ConditionWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: ConditionContent<ContentNode>;\n};\n\nexport const ConditionWrapper: FC<ConditionWrapperProps> = (props) => {\n const { keyPath, section } = props;\n\n return (\n <div className=\"ml-2 grid grid-cols-[auto,1fr] gap-2\">\n {Object.keys(section)\n .filter((key) => !traceKeys.includes(key))\n .map((key) => {\n const newKeyPathEl: KeyPath = {\n type: NodeType.Condition,\n key,\n };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n const subSection =\n section[NodeType.Condition][\n key as keyof (typeof section)[NodeType.Condition]\n ]!;\n\n return (\n <>\n <span className=\"flex items-center font-bold\">{key}</span>\n <NodeWrapper\n {...props}\n key={key}\n keyPath={newKeyPath}\n section={subSection}\n />\n </>\n );\n })}\n </div>\n );\n};\n","import {\n type KeyPath,\n NodeType,\n type EnumerationContent,\n type ContentNode,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { NodeWrapper, traceKeys, type NodeWrapperProps } from './index';\n\ntype EnumerationWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: EnumerationContent<ContentNode>;\n};\n\nexport const EnumerationWrapper: FC<EnumerationWrapperProps> = (props) => {\n const { keyPath, section } = props;\n\n return (\n <div className=\"ml-2 grid grid-cols-[auto,1fr] gap-2\">\n {Object.keys(section)\n .filter((key) => !traceKeys.includes(key))\n .map((key) => {\n const newKeyPathEl: KeyPath = {\n type: NodeType.Enumeration,\n key,\n };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n const subSection =\n section[NodeType.Enumeration][\n key as keyof (typeof section)[NodeType.Enumeration]\n ]!;\n\n return (\n <>\n <span className=\"flex items-center font-bold\">{key}</span>\n <NodeWrapper\n {...props}\n key={key}\n keyPath={newKeyPath}\n section={subSection}\n />\n </>\n );\n })}\n </div>\n );\n};\n","import {\n type KeyPath,\n isSameKeyPath,\n type ContentNode,\n NodeType,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { ItemLayout } from '../ItemLayout';\nimport { NodeWrapper, traceKeys, type NodeWrapperProps } from './index';\n\ntype NestedObjectWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: Record<string, ContentNode>;\n};\n\nexport const NestedObjectWrapper: FC<NestedObjectWrapperProps> = (props) => {\n const { keyPath, section, focusedKeyPath = [], onFocusKeyPath } = props;\n\n return Object.keys(section)\n .filter((key) => !traceKeys.includes(key))\n .map((key) => {\n const newKeyPathEl: KeyPath = { key, type: NodeType.Object };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n return (\n <ItemLayout\n level={keyPath.length}\n key={key}\n title={key}\n description=\"\"\n isSelected={isSameKeyPath(newKeyPath, focusedKeyPath)}\n onClick={(e) => {\n e.stopPropagation();\n\n onFocusKeyPath(newKeyPath);\n }}\n >\n <NodeWrapper {...props} keyPath={newKeyPath} section={section[key]} />\n </ItemLayout>\n );\n });\n};\n","import {\n type KeyPath,\n NodeType,\n type TranslationContent,\n type ContentNode,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { NodeWrapper, type NodeWrapperProps } from './index';\n\ntype TranslationWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: TranslationContent<ContentNode>;\n};\n\nexport const TranslationWrapper: FC<TranslationWrapperProps> = (props) => {\n const { keyPath, section, locale } = props;\n\n const newKeyPathEl: KeyPath = {\n type: NodeType.Translation,\n key: locale,\n };\n\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n const subSection =\n section.translation[\n locale as unknown as keyof (typeof section)['translation']\n ]!;\n\n return <NodeWrapper {...props} keyPath={newKeyPath} section={subSection} />;\n};\n","'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport {\n type ConditionContent,\n type MarkdownContent,\n type EnumerationContent,\n type TranslationContent,\n NodeType,\n type KeyPath,\n type ContentNode,\n getNodeType,\n} from '@intlayer/core';\nimport { type FC } from 'react';\nimport { ArrayWrapper } from './ArrayWrapper';\nimport { ConditionWrapper } from './ConditionWrapper';\nimport { EnumerationWrapper } from './EnumerationWrapper';\nimport { MarkdownWrapper } from './MarkdownWrapper';\nimport { NestedObjectWrapper } from './NestedObjectWrapper';\nimport { StringWrapper } from './StringWrapper';\nimport { TranslationWrapper } from './TranslationWrapper';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n keyPath: KeyPath[];\n section: ContentNode;\n onContentChange: (content: { keyPath: KeyPath[]; newValue: string }) => void;\n locale: Locales;\n editedContent: ContentNode;\n focusedKeyPath: KeyPath[] | undefined;\n onFocusKeyPath: (keyPath: KeyPath[]) => void;\n onClickEdit?: (keyPath: KeyPath[]) => void;\n};\n\nexport const NodeWrapper: FC<NodeWrapperProps> = (props) => {\n const { section } = props;\n const nodeType = getNodeType(section);\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return (\n <span className=\"text-neutral text-xs\">React node not editable</span>\n );\n }\n\n if (nodeType === NodeType.Nested) {\n return (\n <div className=\"ml-2 grid grid-cols-[auto,1fr] gap-2\">\n [Nested] Dictionary\n </div>\n );\n }\n\n if (nodeType === NodeType.Markdown) {\n return (\n <MarkdownWrapper {...props} section={section as MarkdownContent} />\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationWrapper\n {...props}\n section={section as TranslationContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationWrapper\n {...props}\n section={section as EnumerationContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Condition) {\n return (\n <ConditionWrapper\n {...props}\n section={section as ConditionContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayWrapper\n {...props}\n section={section as unknown as ContentNode[]}\n />\n );\n }\n\n return (\n <NestedObjectWrapper\n {...props}\n section={section as Record<string, ContentNode>}\n />\n );\n }\n\n if (typeof section === 'string') {\n return <StringWrapper {...props} section={section} />;\n }\n};\n"],"names":[],"mappings":";;;;;;;AAca,MAAA,eAAsC,CAAC,UAAU;AAC5D,QAAM,EAAE,SAAS,SAAS,gBAAgB,iBAAiB,OAAO;AAElE,SAAO,QAAQ,IAAI,CAAC,YAAY,QAAQ;AACtC,UAAM,eAAwB;AAAA,MAC5B;AAAA,MACA,MAAM,SAAS;AAAA,IACjB;AACA,UAAM,aAAwB,CAAC,GAAG,SAAS,YAAY;AAGrD,WAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,OAAO,QAAQ;AAAA,QAEf,OAAO,GAAG,GAAG;AAAA,QACb,aAAY;AAAA,QACZ,YAAY,cAAc,YAAY,cAAc;AAAA,QACpD,SAAS,CAAC,MAAM;AACd,YAAE,gBAAgB;AAClB,yBAAe,UAAU;AAAA,QAC3B;AAAA,QAEA,8BAAC,aAAa,EAAA,GAAG,OAAO,SAAS,YAAY,SAAS,WAAY,CA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