@intlayer/design-system 5.3.8 → 5.3.9

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.
@@ -56,7 +56,8 @@ const NavigationViewNode = ({
56
56
  keyPath: childKeyPath,
57
57
  section: sectionProp,
58
58
  dictionaryKey
59
- }
59
+ },
60
+ translationKey
60
61
  );
61
62
  }) });
62
63
  }
@@ -74,7 +75,8 @@ const NavigationViewNode = ({
74
75
  keyPath: childKeyPath,
75
76
  section: sectionProp,
76
77
  dictionaryKey
77
- }
78
+ },
79
+ key
78
80
  );
79
81
  }) });
80
82
  }
@@ -91,7 +93,8 @@ const NavigationViewNode = ({
91
93
  keyPath: childKeyPath,
92
94
  section: sectionProp,
93
95
  dictionaryKey
94
- }
96
+ },
97
+ JSON.stringify(childKeyPath)
95
98
  );
96
99
  }),
97
100
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1 +1 @@
1
- {"version":3,"file":"NavigationViewNode.cjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\n\nimport {\n NodeType,\n type KeyPath,\n type ContentNode,\n isSameKeyPath,\n getContentNodeByKeyPath,\n getNodeType,\n getEmptyNode,\n} from '@intlayer/core';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport type { FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = configuration?.internationalization;\n const section = getContentNodeByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const { addNewElement, goToField } = useDictionary(navigationViewContent);\n const nodeType = getNodeType(section);\n const getIsSelected = (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []);\n const isEditableSubSection = getIsEditableSection(section);\n\n if (!section) return <></>;\n\n if (isEditableSubSection) {\n return (\n <Button\n label={goToField.label.value}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(keyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(keyPath[keyPath.length - 1].key as string)}\n </Button>\n );\n }\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration || nodeType === NodeType.Condition) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as unknown as ContentNode[]).map((_, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const emptySectionEl =\n getEmptyNode(\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] as ContentNode\n ) ?? '';\n addEditedContent(\n dictionaryKey,\n emptySectionEl,\n newKeyPath,\n false\n );\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n if (typeof section.nodeType === 'string') {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: section.nodeType } as KeyPath,\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label.value} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label.value} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["configuration","getContentNodeByKeyPath","useEditedContentActions","useFocusDictionary","useDictionary","navigationViewContent","getNodeType","keyPath","isSameKeyPath","getIsEditableSection","jsx","Fragment","Button","ChevronRight","NodeType","jsxs","sectionArray","getEmptyNode","Plus","isEditableSubSection","Accordion","camelCaseToSentence"],"mappings":";;;;;;;;;;;;;AAwBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACE,QAAA,EAAE,YAAYA,sBAAe;AAC7B,QAAA,UAAUC,KAAAA,wBAAwB,aAAa,OAAO;AACtD,QAAA,EAAE,iBAAiB,IAAIC,oCAAwB;AACrD,QAAM,EAAE,0BAA0B,eAAe,IAAIC,+BAAmB;AACxE,QAAM,EAAE,eAAe,cAAcC,cAAAA,cAAcC,2EAAAA,qBAAqB;AAClE,QAAA,WAAWC,iBAAY,OAAO;AACpC,QAAM,gBAAgB,CAACC,cACpB,gBAAgB,SAAS,UAAU,KAAK,KACzCC,KAAAA,cAAcD,UAAS,gBAAgB,WAAW,CAAA,CAAE;AAChD,QAAA,uBAAuBE,2EAAqB,OAAO;AAErD,MAAA,CAAC,QAAS,QAASC,+BAAAC,WAAAA,UAAA,CAAA,CAAA;AAEvB,MAAI,sBAAsB;AAEtB,WAAAD,2BAAA;AAAA,MAACE,yBAAA;AAAA,MAAA;AAAA,QACC,OAAO,UAAU,MAAM;AAAA,QACvB,SAAQ;AAAA,QACR,OAAM;AAA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/B;AAEM,YAAA,aAAab,KAAAA,wBAAwB,aAAa,YAAY;AAC9DkB,YAAAA,wBAAuBV,2EAAqB,UAAU;AAE5D,UAAIU,uBAAsB;AAEtB,eAAAT,2BAAA;AAAA,UAACE,yBAAA;AAAA,UAAA;AAAA,YACC,OAAO,GAAG,UAAU,MAAM,KAAK,IAAI,GAAG;AAAA,YAEtC,UAAU,cAAc,YAAY;AAAA,YACpC,SAAQ;AAAA,YACR,OAAM;AAAA,YACN,WAAU;AAAA,YACV,SAAS,MAAM,yBAAyB,YAAY;AAAA,YACpD,WAAWC,YAAA;AAAA,YAEV,8CAAoB,GAAG;AAAA,UAAA;AAAA,UARnB;AAAA,QASP;AAAA,MAAA;AAKF,aAAAH,2BAAA;AAAA,QAACU,+BAAA;AAAA,QAAA;AAAA,UAEC,OAAO,GAAG,UAAU,MAAM,KAAK,IAAI,GAAG;AAAA,UACtC,UAAU,cAAc,YAAY;AAAA,UACpC,SAAS,MAAM,yBAAyB,YAAY;AAAA,UACpD,QAAQC,oCAAoB,GAAG;AAAA,UAE/B,yCAAC,OAAI,EAAA,WAAU,+BACb,UAACX,2BAAA,IAAA,OAAA,EAAI,WAAU,gBACb,UAAAA,2BAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,SAAS;AAAA,cACT,SAAS;AAAA,cACT;AAAA,YAAA;AAAA,aAEJ,EACF,CAAA;AAAA,QAAA;AAAA,QAdK;AAAA,MAeP;AAAA,IAEH,CAAA,GACH;AAAA,EAAA;AAIJ,SACIK,2BAAA,KAAAJ,qBAAA,EAAA,UAAA;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EAAA,GACzB;AAEJ;;;"}
1
+ {"version":3,"file":"NavigationViewNode.cjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\n\nimport {\n NodeType,\n type KeyPath,\n type ContentNode,\n isSameKeyPath,\n getContentNodeByKeyPath,\n getNodeType,\n getEmptyNode,\n} from '@intlayer/core';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport type { FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = configuration?.internationalization;\n const section = getContentNodeByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const { addNewElement, goToField } = useDictionary(navigationViewContent);\n const nodeType = getNodeType(section);\n const getIsSelected = (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []);\n const isEditableSubSection = getIsEditableSection(section);\n\n if (!section) return <></>;\n\n if (isEditableSubSection) {\n return (\n <Button\n label={goToField.label.value}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(keyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(keyPath[keyPath.length - 1].key as string)}\n </Button>\n );\n }\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n\n return (\n <NavigationViewNode\n key={translationKey}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration || nodeType === NodeType.Condition) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n\n return (\n <NavigationViewNode\n key={key}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as unknown as ContentNode[]).map((_, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n return (\n <NavigationViewNode\n key={JSON.stringify(childKeyPath)}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const emptySectionEl =\n getEmptyNode(\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] as ContentNode\n ) ?? '';\n addEditedContent(\n dictionaryKey,\n emptySectionEl,\n newKeyPath,\n false\n );\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n if (typeof section.nodeType === 'string') {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: section.nodeType } as KeyPath,\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label.value} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label.value} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["configuration","getContentNodeByKeyPath","useEditedContentActions","useFocusDictionary","useDictionary","navigationViewContent","getNodeType","keyPath","isSameKeyPath","getIsEditableSection","jsx","Fragment","Button","ChevronRight","NodeType","jsxs","sectionArray","getEmptyNode","Plus","isEditableSubSection","Accordion","camelCaseToSentence"],"mappings":";;;;;;;;;;;;;AAwBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACE,QAAA,EAAE,YAAYA,sBAAe;AAC7B,QAAA,UAAU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,yBAAyB,YAAY;AAAA,UACpD,QAAQC,oCAAoB,GAAG;AAAA,UAE/B,yCAAC,OAAI,EAAA,WAAU,+BACb,UAACX,2BAAA,IAAA,OAAA,EAAI,WAAU,gBACb,UAAAA,2BAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,SAAS;AAAA,cACT,SAAS;AAAA,cACT;AAAA,YAAA;AAAA,aAEJ,EACF,CAAA;AAAA,QAAA;AAAA,QAdK;AAAA,MAeP;AAAA,IAEH,CAAA,GACH;AAAA,EAAA;AAIJ,SACIK,2BAAA,KAAAJ,qBAAA,EAAA,UAAA;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EAAA,GACzB;AAEJ;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"NavigationViewNode.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,WAAW,EAKjB,MAAM,gBAAgB,CAAC;AAMxB,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAQhC,eAAO,MAAM,SAAS,EAAE,MAAM,EAAmC,CAAC;AAElE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,gBAAgB,CAsNnD,CAAC"}
1
+ {"version":3,"file":"NavigationViewNode.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,WAAW,EAKjB,MAAM,gBAAgB,CAAC;AAMxB,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAQhC,eAAO,MAAM,SAAS,EAAE,MAAM,EAAmC,CAAC;AAElE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,gBAAgB,CAyNnD,CAAC"}
@@ -54,7 +54,8 @@ const NavigationViewNode = ({
54
54
  keyPath: childKeyPath,
55
55
  section: sectionProp,
56
56
  dictionaryKey
57
- }
57
+ },
58
+ translationKey
58
59
  );
59
60
  }) });
60
61
  }
@@ -72,7 +73,8 @@ const NavigationViewNode = ({
72
73
  keyPath: childKeyPath,
73
74
  section: sectionProp,
74
75
  dictionaryKey
75
- }
76
+ },
77
+ key
76
78
  );
77
79
  }) });
78
80
  }
@@ -89,7 +91,8 @@ const NavigationViewNode = ({
89
91
  keyPath: childKeyPath,
90
92
  section: sectionProp,
91
93
  dictionaryKey
92
- }
94
+ },
95
+ JSON.stringify(childKeyPath)
93
96
  );
94
97
  }),
95
98
  /* @__PURE__ */ jsx(
@@ -1 +1 @@
1
- {"version":3,"file":"NavigationViewNode.mjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\n\nimport {\n NodeType,\n type KeyPath,\n type ContentNode,\n isSameKeyPath,\n getContentNodeByKeyPath,\n getNodeType,\n getEmptyNode,\n} from '@intlayer/core';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport type { FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = configuration?.internationalization;\n const section = getContentNodeByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const { addNewElement, goToField } = useDictionary(navigationViewContent);\n const nodeType = getNodeType(section);\n const getIsSelected = (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []);\n const isEditableSubSection = getIsEditableSection(section);\n\n if (!section) return <></>;\n\n if (isEditableSubSection) {\n return (\n <Button\n label={goToField.label.value}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(keyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(keyPath[keyPath.length - 1].key as string)}\n </Button>\n );\n }\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration || nodeType === NodeType.Condition) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as unknown as ContentNode[]).map((_, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const emptySectionEl =\n getEmptyNode(\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] as ContentNode\n ) ?? '';\n addEditedContent(\n dictionaryKey,\n emptySectionEl,\n newKeyPath,\n false\n );\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n if (typeof section.nodeType === 'string') {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: section.nodeType } as KeyPath,\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label.value} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label.value} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["configuration","keyPath","sectionArray","isEditableSubSection"],"mappings":";;;;;;;;;;;AAwBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACE,QAAA,EAAE,YAAYA,sBAAe;AAC7B,QAAA,UAAU,wBAAwB,aAAa,OAAO;AACtD,QAAA,EAAE,iBAAiB,IAAI,wBAAwB;AACrD,QAAM,EAAE,0BAA0B,eAAe,IAAI,mBAAmB;AACxE,QAAM,EAAE,eAAe,cAAc,cAAc,qBAAqB;AAClE,QAAA,WAAW,YAAY,OAAO;AACpC,QAAM,gBAAgB,CAACC,cACpB,gBAAgB,SAAS,UAAU,KAAK,KACzC,cAAcA,UAAS,gBAAgB,WAAW,CAAA,CAAE;AAChD,QAAA,uBAAuB,qBAAqB,OAAO;AAErD,MAAA,CAAC,QAAS,QAAS,oBAAA,UAAA,CAAA,CAAA;AAEvB,MAAI,sBAAsB;AAEtB,WAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,OAAO,UAAU,MAAM;AAAA,QACvB,SAAQ;AAAA,QACR,OAAM;AAAA,QACN,WAAU;AAAA,QACV,SAAS,MAAM,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U,MAAM,KAAK,IAAI,GAAG;AAAA,YAEtC,UAAU,cAAc,YAAY;AAAA,YACpC,SAAQ;AAAA,YACR,OAAM;AAAA,YACN,WAAU;AAAA,YACV,SAAS,MAAM,yBAAyB,YAAY;AAAA,YACpD,WAAW;AAAA,YAEV,8BAAoB,GAAG;AAAA,UAAA;AAAA,UARnB;AAAA,QASP;AAAA,MAAA;AAKF,aAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UAEC,OAAO,GAAG,UAAU,MAAM,KAAK,IAAI,GAAG;AAAA,UACtC,UAAU,cAAc,YAAY;AAAA,UACpC,SAAS,MAAM,yBAAyB,YAAY;AAAA,UACpD,QAAQ,oBAAoB,GAAG;AAAA,UAE/B,8BAAC,OAAI,EAAA,WAAU,+BACb,UAAC,oBAAA,OAAA,EAAI,WAAU,gBACb,UAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,SAAS;AAAA,cACT,SAAS;AAAA,cACT;AAAA,YAAA;AAAA,aAEJ,EACF,CAAA;AAAA,QAAA;AAAA,QAdK;AAAA,MAeP;AAAA,IAEH,CAAA,GACH;AAAA,EAAA;AAIJ,SACI,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EAAA,GACzB;AAEJ;"}
1
+ {"version":3,"file":"NavigationViewNode.mjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\n\nimport {\n NodeType,\n type KeyPath,\n type ContentNode,\n isSameKeyPath,\n getContentNodeByKeyPath,\n getNodeType,\n getEmptyNode,\n} from '@intlayer/core';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport type { FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = configuration?.internationalization;\n const section = getContentNodeByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const { addNewElement, goToField } = useDictionary(navigationViewContent);\n const nodeType = getNodeType(section);\n const getIsSelected = (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []);\n const isEditableSubSection = getIsEditableSection(section);\n\n if (!section) return <></>;\n\n if (isEditableSubSection) {\n return (\n <Button\n label={goToField.label.value}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(keyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(keyPath[keyPath.length - 1].key as string)}\n </Button>\n );\n }\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n\n return (\n <NavigationViewNode\n key={translationKey}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration || nodeType === NodeType.Condition) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n\n return (\n <NavigationViewNode\n key={key}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as unknown as ContentNode[]).map((_, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n return (\n <NavigationViewNode\n key={JSON.stringify(childKeyPath)}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const emptySectionEl =\n getEmptyNode(\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] as ContentNode\n ) ?? '';\n addEditedContent(\n dictionaryKey,\n emptySectionEl,\n newKeyPath,\n false\n );\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n if (typeof section.nodeType === 'string') {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: section.nodeType } as KeyPath,\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label.value} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label.value} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["configuration","keyPath","sectionArray","isEditableSubSection"],"mappings":";;;;;;;;;;;AAwBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACE,QAAA,EAAE,YAAYA,sBAAe;AAC7B,QAAA,UAAU,wBAAwB,aAAa,OAAO;AACtD,QAAA,EAAE,iBAAiB,IAAI,wBAAwB;AACrD,QAAM,EAAE,0BAA0B,eAAe,IAAI,mBAAmB;AACxE,QAAM,EAAE,eAAe,cAAc,cAAc,qBAAqB;AAClE,QAAA,WAAW,YAAY,OAAO;AACpC,QAAM,gBAAgB,CAACC,cACpB,gBAAgB,SAAS,UAAU,KAAK,KACzC,cAAcA,UAAS,gBAAgB,WAAW,CAAA,CAAE;AAChD,QAAA,uBAAuB,qBAAqB,OAAO;AAErD,MAAA,CAAC,QAAS,QAAS,oBAAA,UAAA,CAAA,CAAA;AAEvB,MAAI,sBA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,EAAE,MAAM,SAAS,QAAQ,IAAI;AAAA,MAC/B;AAEM,YAAA,aAAa,wBAAwB,aAAa,YAAY;AAC9DC,YAAAA,wBAAuB,qBAAqB,UAAU;AAE5D,UAAIA,uBAAsB;AAEtB,eAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,OAAO,GAAG,UAAU,MAAM,KAAK,IAAI,GAAG;AAAA,YAEtC,UAAU,cAAc,YAAY;AAAA,YACpC,SAAQ;AAAA,YACR,OAAM;AAAA,YACN,WAAU;AAAA,YACV,SAAS,MAAM,yBAAyB,YAAY;AAAA,YACpD,WAAW;AAAA,YAEV,8BAAoB,GAAG;AAAA,UAAA;AAAA,UARnB;AAAA,QASP;AAAA,MAAA;AAKF,aAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UAEC,OAAO,GAAG,UAAU,MAAM,KAAK,IAAI,GAAG;AAAA,UACtC,UAAU,cAAc,YAAY;AAAA,UACpC,SAAS,MAAM,yBAAyB,YAAY;AAAA,UACpD,QAAQ,oBAAoB,GAAG;AAAA,UAE/B,8BAAC,OAAI,EAAA,WAAU,+BACb,UAAC,oBAAA,OAAA,EAAI,WAAU,gBACb,UAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,SAAS;AAAA,cACT,SAAS;AAAA,cACT;AAAA,YAAA;AAAA,aAEJ,EACF,CAAA;AAAA,QAAA;AAAA,QAdK;AAAA,MAeP;AAAA,IAEH,CAAA,GACH;AAAA,EAAA;AAIJ,SACI,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EAAA,GACzB;AAEJ;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/design-system",
3
- "version": "5.3.8",
3
+ "version": "5.3.9",
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,12 +78,12 @@
78
78
  "tailwind-merge": "^3.0.2",
79
79
  "zod": "^3.24.2",
80
80
  "zustand": "^4.5.6",
81
- "@intlayer/core": "5.3.8",
82
- "@intlayer/dictionaries-entry": "5.3.8",
83
- "react-intlayer": "5.3.8",
84
- "@intlayer/api": "5.3.8",
85
- "@intlayer/config": "5.3.8",
86
- "@intlayer/editor-react": "5.3.8"
81
+ "@intlayer/api": "5.3.9",
82
+ "@intlayer/dictionaries-entry": "5.3.9",
83
+ "@intlayer/config": "5.3.9",
84
+ "@intlayer/editor-react": "5.3.9",
85
+ "react-intlayer": "5.3.9",
86
+ "@intlayer/core": "5.3.9"
87
87
  },
88
88
  "devDependencies": {
89
89
  "@chromatic-com/storybook": "^3.2.3",
@@ -120,10 +120,10 @@
120
120
  "vite": "^6.0.11",
121
121
  "vite-plugin-dts": "^4.5.0",
122
122
  "vitest": "^3.0.5",
123
- "@intlayer/backend": "5.3.8",
124
- "@utils/eslint-config": "1.0.4",
123
+ "@intlayer/backend": "5.3.9",
125
124
  "@utils/tsup-config": "1.0.4",
126
125
  "@utils/ts-config-types": "1.0.4",
126
+ "@utils/eslint-config": "1.0.4",
127
127
  "@utils/ts-config": "1.0.4"
128
128
  },
129
129
  "peerDependencies": {
@@ -135,13 +135,13 @@
135
135
  "react-dom": ">=16.0.0",
136
136
  "tailwind-merge": "^3.0.2",
137
137
  "zustand": "^4.5.6",
138
- "@intlayer/config": "5.3.8",
139
- "@intlayer/core": "5.3.8",
140
- "@intlayer/api": "5.3.8",
141
- "@intlayer/editor-react": "5.3.8",
142
- "@intlayer/dictionaries-entry": "5.3.8",
143
- "react-intlayer": "5.3.8",
144
- "intlayer": "5.3.8"
138
+ "@intlayer/api": "5.3.9",
139
+ "@intlayer/config": "5.3.9",
140
+ "@intlayer/core": "5.3.9",
141
+ "@intlayer/editor-react": "5.3.9",
142
+ "@intlayer/dictionaries-entry": "5.3.9",
143
+ "intlayer": "5.3.9",
144
+ "react-intlayer": "5.3.9"
145
145
  },
146
146
  "scripts": {
147
147
  "build": "pnpm build:package && pnpm build:css",