intlayer-editor 3.3.4 → 3.3.6
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/cjs/DictionaryEditionDrawer/DictionaryEditionDrawer.cjs +4 -1
- package/dist/cjs/DictionaryEditionDrawer/DictionaryEditionDrawer.cjs.map +1 -1
- package/dist/cjs/DictionaryEditionDrawer/useDictionaryEditionDrawer.cjs +36 -47
- package/dist/cjs/DictionaryEditionDrawer/useDictionaryEditionDrawer.cjs.map +1 -1
- package/dist/cjs/DictionaryListDrawer/DictionaryListDrawer.cjs +54 -27
- package/dist/cjs/DictionaryListDrawer/DictionaryListDrawer.cjs.map +1 -1
- package/dist/cjs/DictionaryListDrawer/useDictionaryListDrawer.cjs +3 -1
- package/dist/cjs/DictionaryListDrawer/useDictionaryListDrawer.cjs.map +1 -1
- package/dist/esm/DictionaryEditionDrawer/DictionaryEditionDrawer.mjs +4 -1
- package/dist/esm/DictionaryEditionDrawer/DictionaryEditionDrawer.mjs.map +1 -1
- package/dist/esm/DictionaryEditionDrawer/useDictionaryEditionDrawer.mjs +35 -45
- package/dist/esm/DictionaryEditionDrawer/useDictionaryEditionDrawer.mjs.map +1 -1
- package/dist/esm/DictionaryListDrawer/DictionaryListDrawer.mjs +59 -33
- package/dist/esm/DictionaryListDrawer/DictionaryListDrawer.mjs.map +1 -1
- package/dist/esm/DictionaryListDrawer/useDictionaryListDrawer.mjs +3 -1
- package/dist/esm/DictionaryListDrawer/useDictionaryListDrawer.mjs.map +1 -1
- package/dist/types/DictionaryEditionDrawer/DictionaryEditionDrawer.d.ts.map +1 -1
- package/dist/types/DictionaryEditionDrawer/useDictionaryEditionDrawer.d.ts +0 -5
- package/dist/types/DictionaryEditionDrawer/useDictionaryEditionDrawer.d.ts.map +1 -1
- package/dist/types/DictionaryListDrawer/DictionaryListDrawer.d.ts +1 -1
- package/dist/types/DictionaryListDrawer/DictionaryListDrawer.d.ts.map +1 -1
- package/dist/types/DictionaryListDrawer/useDictionaryListDrawer.d.ts +2 -2
- package/dist/types/DictionaryListDrawer/useDictionaryListDrawer.d.ts.map +1 -1
- package/package.json +11 -16
|
@@ -28,6 +28,7 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
28
28
|
var import_design_system = require("@intlayer/design-system");
|
|
29
29
|
var import_hooks = require("@intlayer/design-system/hooks");
|
|
30
30
|
var import_react = require("react");
|
|
31
|
+
var import_shallow = require("zustand/shallow");
|
|
31
32
|
var import_useDictionaryListDrawer = require('../DictionaryListDrawer/useDictionaryListDrawer.cjs');
|
|
32
33
|
var import_useDictionaryEditionDrawer = require('./useDictionaryEditionDrawer.cjs');
|
|
33
34
|
const DictionaryEditionDrawerContent = ({ locale, identifier, handleOnBack }) => {
|
|
@@ -118,7 +119,9 @@ const DictionaryEditionDrawer = ({
|
|
|
118
119
|
);
|
|
119
120
|
};
|
|
120
121
|
const DictionaryEditionDrawerController = ({ locale, localeList, setLocale }) => {
|
|
121
|
-
const focusedContent = (0, import_design_system.useEditionPanelStore)(
|
|
122
|
+
const focusedContent = (0, import_design_system.useEditionPanelStore)(
|
|
123
|
+
(0, import_shallow.useShallow)((s) => s.focusedContent)
|
|
124
|
+
);
|
|
122
125
|
const dictionaryId = focusedContent?.dictionaryId;
|
|
123
126
|
if (!dictionaryId) {
|
|
124
127
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/DictionaryEditionDrawer/DictionaryEditionDrawer.tsx"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport type { Dictionary, KeyPath } from '@intlayer/core';\nimport {\n RightDrawer,\n DictionaryEditor,\n LocaleSwitcher,\n Modal,\n useEditionPanelStore,\n DictionaryFieldEditor,\n} from '@intlayer/design-system';\nimport { useGetAllDictionaries } from '@intlayer/design-system/hooks';\nimport { useCallback, useEffect, useState, type FC } from 'react';\nimport { useDictionaryListDrawer } from '../DictionaryListDrawer/useDictionaryListDrawer';\nimport {\n type FileContent as FileContentWithDictionaryPath,\n useDictionaryEditionDrawer,\n getDrawerIdentifier,\n} from './useDictionaryEditionDrawer';\n\ntype DictionaryEditionDrawerContentProps = {\n focusedContent: FileContentWithDictionaryPath;\n locale: Locales;\n identifier: string;\n handleOnBack: () => void;\n};\n\nexport const DictionaryEditionDrawerContent: FC<\n DictionaryEditionDrawerContentProps\n> = ({ locale, identifier, handleOnBack }) => {\n const [keyPathEditionModal, setKeyPathEditionModal] = useState<\n KeyPath[] | null\n >(null);\n const { setDictionariesRecord, focusedContent } =\n useDictionaryEditionDrawer(identifier);\n const { all: dictionaries } = useGetAllDictionaries();\n\n const onClickDictionaryList = useCallback(() => {\n setKeyPathEditionModal(null);\n handleOnBack();\n }, [handleOnBack]);\n\n useEffect(() => {\n if (dictionaries) {\n setDictionariesRecord(dictionaries);\n }\n }, [setDictionariesRecord, dictionaries]);\n\n const dictionaryId = focusedContent?.dictionaryId;\n\n if (!dictionaryId) return <>No dictionary focused</>;\n\n const dictionary: Dictionary = dictionaries[dictionaryId];\n\n return (\n <>\n <Modal\n isOpen={keyPathEditionModal !== null}\n onClose={() => setKeyPathEditionModal(null)}\n hasCloseButton\n title=\"Edit field\"\n size=\"xl\"\n transparency=\"lg\"\n >\n {dictionary && (\n <DictionaryFieldEditor\n dictionary={dictionary}\n onClickDictionaryList={onClickDictionaryList}\n />\n )}\n </Modal>\n <DictionaryEditor\n dictionary={dictionary}\n locale={locale}\n onClickEdit={setKeyPathEditionModal}\n />\n </>\n );\n};\n\ntype DictionaryEditionDrawerProps = DictionaryEditionDrawerControllerProps & {\n dictionaryId: string;\n};\n\nexport const DictionaryEditionDrawer: FC<DictionaryEditionDrawerProps> = ({\n locale,\n localeList,\n setLocale,\n dictionaryId,\n}) => {\n const id = getDrawerIdentifier(dictionaryId);\n\n const { focusedContent, close } = useDictionaryEditionDrawer(dictionaryId);\n const { open: openDictionaryListDrawer } = useDictionaryListDrawer();\n\n const handleOnBack = () => {\n close();\n openDictionaryListDrawer();\n };\n\n return (\n <RightDrawer\n title={dictionaryId}\n identifier={id}\n header={\n <LocaleSwitcher\n setLocale={setLocale}\n locale={locale}\n localeList={localeList}\n />\n }\n backButton={{\n onBack: handleOnBack,\n text: 'Dictionary list',\n }}\n >\n {focusedContent && (\n <DictionaryEditionDrawerContent\n focusedContent={focusedContent}\n locale={locale}\n identifier={id}\n handleOnBack={handleOnBack}\n />\n )}\n </RightDrawer>\n );\n};\n\ntype DictionaryEditionDrawerControllerProps = {\n locale: Locales;\n localeList: Locales[];\n setLocale: (locale: Locales) => void;\n};\n\nexport const DictionaryEditionDrawerController: FC<\n DictionaryEditionDrawerControllerProps\n> = ({ locale, localeList, setLocale }) => {\n const focusedContent = useEditionPanelStore((s) => s.focusedContent);\n const dictionaryId: string | undefined = focusedContent?.dictionaryId;\n\n if (!dictionaryId) {\n return <></>;\n }\n\n return (\n <DictionaryEditionDrawer\n locale={locale}\n localeList={localeList}\n setLocale={setLocale}\n dictionaryId={dictionaryId}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../../src/DictionaryEditionDrawer/DictionaryEditionDrawer.tsx"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport type { Dictionary, KeyPath } from '@intlayer/core';\nimport {\n RightDrawer,\n DictionaryEditor,\n LocaleSwitcher,\n Modal,\n useEditionPanelStore,\n DictionaryFieldEditor,\n} from '@intlayer/design-system';\nimport { useGetAllDictionaries } from '@intlayer/design-system/hooks';\nimport { useCallback, useEffect, useState, type FC } from 'react';\nimport { useShallow } from 'zustand/shallow';\nimport { useDictionaryListDrawer } from '../DictionaryListDrawer/useDictionaryListDrawer';\nimport {\n type FileContent as FileContentWithDictionaryPath,\n useDictionaryEditionDrawer,\n getDrawerIdentifier,\n} from './useDictionaryEditionDrawer';\n\ntype DictionaryEditionDrawerContentProps = {\n focusedContent: FileContentWithDictionaryPath;\n locale: Locales;\n identifier: string;\n handleOnBack: () => void;\n};\n\nexport const DictionaryEditionDrawerContent: FC<\n DictionaryEditionDrawerContentProps\n> = ({ locale, identifier, handleOnBack }) => {\n const [keyPathEditionModal, setKeyPathEditionModal] = useState<\n KeyPath[] | null\n >(null);\n const { setDictionariesRecord, focusedContent } =\n useDictionaryEditionDrawer(identifier);\n const { all: dictionaries } = useGetAllDictionaries();\n\n const onClickDictionaryList = useCallback(() => {\n setKeyPathEditionModal(null);\n handleOnBack();\n }, [handleOnBack]);\n\n useEffect(() => {\n if (dictionaries) {\n setDictionariesRecord(dictionaries);\n }\n }, [setDictionariesRecord, dictionaries]);\n\n const dictionaryId = focusedContent?.dictionaryId;\n\n if (!dictionaryId) return <>No dictionary focused</>;\n\n const dictionary: Dictionary = dictionaries[dictionaryId];\n\n return (\n <>\n <Modal\n isOpen={keyPathEditionModal !== null}\n onClose={() => setKeyPathEditionModal(null)}\n hasCloseButton\n title=\"Edit field\"\n size=\"xl\"\n transparency=\"lg\"\n >\n {dictionary && (\n <DictionaryFieldEditor\n dictionary={dictionary}\n onClickDictionaryList={onClickDictionaryList}\n />\n )}\n </Modal>\n <DictionaryEditor\n dictionary={dictionary}\n locale={locale}\n onClickEdit={setKeyPathEditionModal}\n />\n </>\n );\n};\n\ntype DictionaryEditionDrawerProps = DictionaryEditionDrawerControllerProps & {\n dictionaryId: string;\n};\n\nexport const DictionaryEditionDrawer: FC<DictionaryEditionDrawerProps> = ({\n locale,\n localeList,\n setLocale,\n dictionaryId,\n}) => {\n const id = getDrawerIdentifier(dictionaryId);\n\n const { focusedContent, close } = useDictionaryEditionDrawer(dictionaryId);\n const { open: openDictionaryListDrawer } = useDictionaryListDrawer();\n\n const handleOnBack = () => {\n close();\n openDictionaryListDrawer();\n };\n\n return (\n <RightDrawer\n title={dictionaryId}\n identifier={id}\n header={\n <LocaleSwitcher\n setLocale={setLocale}\n locale={locale}\n localeList={localeList}\n />\n }\n backButton={{\n onBack: handleOnBack,\n text: 'Dictionary list',\n }}\n >\n {focusedContent && (\n <DictionaryEditionDrawerContent\n focusedContent={focusedContent}\n locale={locale}\n identifier={id}\n handleOnBack={handleOnBack}\n />\n )}\n </RightDrawer>\n );\n};\n\ntype DictionaryEditionDrawerControllerProps = {\n locale: Locales;\n localeList: Locales[];\n setLocale: (locale: Locales) => void;\n};\n\nexport const DictionaryEditionDrawerController: FC<\n DictionaryEditionDrawerControllerProps\n> = ({ locale, localeList, setLocale }) => {\n const focusedContent = useEditionPanelStore(\n useShallow((s) => s.focusedContent)\n );\n const dictionaryId: string | undefined = focusedContent?.dictionaryId;\n\n if (!dictionaryId) {\n return <></>;\n }\n\n return (\n <DictionaryEditionDrawer\n locale={locale}\n localeList={localeList}\n setLocale={setLocale}\n dictionaryId={dictionaryId}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoD4B;AAhD5B,2BAOO;AACP,mBAAsC;AACtC,mBAA0D;AAC1D,qBAA2B;AAC3B,qCAAwC;AACxC,wCAIO;AASA,MAAM,iCAET,CAAC,EAAE,QAAQ,YAAY,aAAa,MAAM;AAC5C,QAAM,CAAC,qBAAqB,sBAAsB,QAAI,uBAEpD,IAAI;AACN,QAAM,EAAE,uBAAuB,eAAe,QAC5C,8DAA2B,UAAU;AACvC,QAAM,EAAE,KAAK,aAAa,QAAI,oCAAsB;AAEpD,QAAM,4BAAwB,0BAAY,MAAM;AAC9C,2BAAuB,IAAI;AAC3B,iBAAa;AAAA,EACf,GAAG,CAAC,YAAY,CAAC;AAEjB,8BAAU,MAAM;AACd,QAAI,cAAc;AAChB,4BAAsB,YAAY;AAAA,IACpC;AAAA,EACF,GAAG,CAAC,uBAAuB,YAAY,CAAC;AAExC,QAAM,eAAe,gBAAgB;AAErC,MAAI,CAAC,aAAc,QAAO,2EAAE,mCAAqB;AAEjD,QAAM,aAAyB,aAAa,YAAY;AAExD,SACE,4EACE;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,QAAQ,wBAAwB;AAAA,QAChC,SAAS,MAAM,uBAAuB,IAAI;AAAA,QAC1C,gBAAc;AAAA,QACd,OAAM;AAAA,QACN,MAAK;AAAA,QACL,cAAa;AAAA,QAEZ,wBACC;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA;AAAA;AAAA,QACF;AAAA;AAAA,IAEJ;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA,aAAa;AAAA;AAAA,IACf;AAAA,KACF;AAEJ;AAMO,MAAM,0BAA4D,CAAC;AAAA,EACxE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,SAAK,uDAAoB,YAAY;AAE3C,QAAM,EAAE,gBAAgB,MAAM,QAAI,8DAA2B,YAAY;AACzE,QAAM,EAAE,MAAM,yBAAyB,QAAI,wDAAwB;AAEnE,QAAM,eAAe,MAAM;AACzB,UAAM;AACN,6BAAyB;AAAA,EAC3B;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,MACP,YAAY;AAAA,MACZ,QACE;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACF;AAAA,MAEF,YAAY;AAAA,QACV,QAAQ;AAAA,QACR,MAAM;AAAA,MACR;AAAA,MAEC,4BACC;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA,YAAY;AAAA,UACZ;AAAA;AAAA,MACF;AAAA;AAAA,EAEJ;AAEJ;AAQO,MAAM,oCAET,CAAC,EAAE,QAAQ,YAAY,UAAU,MAAM;AACzC,QAAM,qBAAiB;AAAA,QACrB,2BAAW,CAAC,MAAM,EAAE,cAAc;AAAA,EACpC;AACA,QAAM,eAAmC,gBAAgB;AAEzD,MAAI,CAAC,cAAc;AACjB,WAAO,2EAAE;AAAA,EACX;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -19,35 +19,49 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var useDictionaryEditionDrawer_exports = {};
|
|
20
20
|
__export(useDictionaryEditionDrawer_exports, {
|
|
21
21
|
getDrawerIdentifier: () => getDrawerIdentifier,
|
|
22
|
-
useDictionaryEditionDrawer: () => useDictionaryEditionDrawer
|
|
23
|
-
useDictionaryEditionDrawerControl: () => useDictionaryEditionDrawerControl
|
|
22
|
+
useDictionaryEditionDrawer: () => useDictionaryEditionDrawer
|
|
24
23
|
});
|
|
25
24
|
module.exports = __toCommonJS(useDictionaryEditionDrawer_exports);
|
|
26
25
|
var import_design_system = require("@intlayer/design-system");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_shallow = require("zustand/shallow");
|
|
27
28
|
const getDrawerIdentifier = (dictionaryId) => `dictionary_edition_${dictionaryId}`;
|
|
28
29
|
const useDictionaryEditionDrawer = (dictionaryId) => {
|
|
29
30
|
const id = getDrawerIdentifier(dictionaryId);
|
|
30
|
-
const { isOpen, open, close } = (0, import_design_system.useRightDrawerStore)(id)(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
31
|
+
const { isOpen, open, close } = (0, import_design_system.useRightDrawerStore)(id)(
|
|
32
|
+
(0, import_shallow.useShallow)((e) => ({
|
|
33
|
+
isOpen: e.isOpen,
|
|
34
|
+
open: e.open,
|
|
35
|
+
close: e.close
|
|
36
|
+
}))
|
|
37
|
+
);
|
|
38
|
+
const { setDictionariesRecord, getEditedContentValue } = (0, import_design_system.useEditedContentStore)(
|
|
39
|
+
(0, import_shallow.useShallow)((s) => ({
|
|
40
|
+
setDictionariesRecord: s.setDictionariesRecord,
|
|
41
|
+
getEditedContentValue: s.getEditedContentValue
|
|
42
|
+
}))
|
|
43
|
+
);
|
|
44
|
+
const { setFocusedContent, focusedContent } = (0, import_design_system.useEditionPanelStore)(
|
|
45
|
+
(0, import_shallow.useShallow)((s) => ({
|
|
46
|
+
focusedContent: s.focusedContent,
|
|
47
|
+
setFocusedContent: s.setFocusedContent
|
|
48
|
+
}))
|
|
49
|
+
);
|
|
50
|
+
const openDictionaryEditionDrawer = (0, import_react.useCallback)(
|
|
51
|
+
({
|
|
45
52
|
dictionaryId: dictionaryId2,
|
|
46
53
|
dictionaryPath,
|
|
47
|
-
keyPath
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
keyPath = []
|
|
55
|
+
}) => {
|
|
56
|
+
setFocusedContent({
|
|
57
|
+
dictionaryId: dictionaryId2,
|
|
58
|
+
dictionaryPath,
|
|
59
|
+
keyPath
|
|
60
|
+
});
|
|
61
|
+
open();
|
|
62
|
+
},
|
|
63
|
+
[open, setFocusedContent]
|
|
64
|
+
);
|
|
51
65
|
return {
|
|
52
66
|
isOpen,
|
|
53
67
|
focusedContent,
|
|
@@ -57,34 +71,9 @@ const useDictionaryEditionDrawer = (dictionaryId) => {
|
|
|
57
71
|
close
|
|
58
72
|
};
|
|
59
73
|
};
|
|
60
|
-
const useDictionaryEditionDrawerControl = () => {
|
|
61
|
-
const setFocusedContent = (0, import_design_system.useEditionPanelStore)((s) => s.setFocusedContent);
|
|
62
|
-
const open = ({
|
|
63
|
-
dictionaryId,
|
|
64
|
-
dictionaryPath,
|
|
65
|
-
keyPath = []
|
|
66
|
-
}) => {
|
|
67
|
-
setFocusedContent({
|
|
68
|
-
dictionaryId,
|
|
69
|
-
dictionaryPath,
|
|
70
|
-
keyPath
|
|
71
|
-
});
|
|
72
|
-
const id = getDrawerIdentifier(dictionaryId);
|
|
73
|
-
(0, import_design_system.useRightDrawerStore)(id).getState().open();
|
|
74
|
-
};
|
|
75
|
-
const close = (dictionaryId) => {
|
|
76
|
-
const id = getDrawerIdentifier(dictionaryId);
|
|
77
|
-
(0, import_design_system.useRightDrawerStore)(id).getState().close();
|
|
78
|
-
};
|
|
79
|
-
return {
|
|
80
|
-
open,
|
|
81
|
-
close
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
74
|
// Annotate the CommonJS export names for ESM import in node:
|
|
85
75
|
0 && (module.exports = {
|
|
86
76
|
getDrawerIdentifier,
|
|
87
|
-
useDictionaryEditionDrawer
|
|
88
|
-
useDictionaryEditionDrawerControl
|
|
77
|
+
useDictionaryEditionDrawer
|
|
89
78
|
});
|
|
90
79
|
//# sourceMappingURL=useDictionaryEditionDrawer.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/DictionaryEditionDrawer/useDictionaryEditionDrawer.ts"],"sourcesContent":["import type { Dictionary, DictionaryValue, KeyPath } from '@intlayer/core';\nimport {\n useRightDrawerStore,\n useEditedContentStore,\n useEditionPanelStore,\n} from '@intlayer/design-system';\n\nexport const getDrawerIdentifier = (dictionaryId: string) =>\n `dictionary_edition_${dictionaryId}`;\n\ntype DictionaryId = string;\ntype DictionaryPath = string;\n\nexport type FileContent = {\n dictionaryPath?: DictionaryPath;\n dictionaryId: string;\n keyPath?: KeyPath[];\n};\n\ntype DictionaryEditionDrawer = {\n focusedContent: FileContent | null;\n isOpen: boolean;\n open: (content: FileContent) => void;\n close: () => void;\n setDictionariesRecord: (\n dictionariesRecord: Record<DictionaryId, Dictionary>\n ) => void;\n getEditedContentValue: (\n dictionaryId: DictionaryId,\n keyPath: KeyPath[]\n ) => DictionaryValue | undefined;\n};\n\ntype OpenDictionaryEditionDrawerProps = {\n dictionaryId: string;\n dictionaryPath?: string;\n keyPath?: KeyPath[];\n};\n\nexport const useDictionaryEditionDrawer = (\n dictionaryId: string\n): DictionaryEditionDrawer => {\n const id = getDrawerIdentifier(dictionaryId);\n const { isOpen, open, close } = useRightDrawerStore(id)();\n const { setDictionariesRecord, getEditedContentValue } =\n useEditedContentStore((s) => ({\n
|
|
1
|
+
{"version":3,"sources":["../../../src/DictionaryEditionDrawer/useDictionaryEditionDrawer.ts"],"sourcesContent":["import type { Dictionary, DictionaryValue, KeyPath } from '@intlayer/core';\nimport {\n useRightDrawerStore,\n useEditedContentStore,\n useEditionPanelStore,\n} from '@intlayer/design-system';\nimport { useCallback } from 'react';\nimport { useShallow } from 'zustand/shallow';\n\nexport const getDrawerIdentifier = (dictionaryId: string) =>\n `dictionary_edition_${dictionaryId}`;\n\ntype DictionaryId = string;\ntype DictionaryPath = string;\n\nexport type FileContent = {\n dictionaryPath?: DictionaryPath;\n dictionaryId: string;\n keyPath?: KeyPath[];\n};\n\ntype DictionaryEditionDrawer = {\n focusedContent: FileContent | null;\n isOpen: boolean;\n open: (content: FileContent) => void;\n close: () => void;\n setDictionariesRecord: (\n dictionariesRecord: Record<DictionaryId, Dictionary>\n ) => void;\n getEditedContentValue: (\n dictionaryId: DictionaryId,\n keyPath: KeyPath[]\n ) => DictionaryValue | undefined;\n};\n\ntype OpenDictionaryEditionDrawerProps = {\n dictionaryId: string;\n dictionaryPath?: string;\n keyPath?: KeyPath[];\n};\n\nexport const useDictionaryEditionDrawer = (\n dictionaryId: string\n): DictionaryEditionDrawer => {\n const id = getDrawerIdentifier(dictionaryId);\n const { isOpen, open, close } = useRightDrawerStore(id)(\n useShallow((e) => ({\n isOpen: e.isOpen,\n open: e.open,\n close: e.close,\n }))\n );\n const { setDictionariesRecord, getEditedContentValue } =\n useEditedContentStore(\n useShallow((s) => ({\n setDictionariesRecord: s.setDictionariesRecord,\n getEditedContentValue: s.getEditedContentValue,\n }))\n );\n const { setFocusedContent, focusedContent } = useEditionPanelStore(\n useShallow((s) => ({\n focusedContent: s.focusedContent,\n setFocusedContent: s.setFocusedContent,\n }))\n );\n\n const openDictionaryEditionDrawer = useCallback(\n ({\n dictionaryId,\n dictionaryPath,\n keyPath = [],\n }: OpenDictionaryEditionDrawerProps) => {\n setFocusedContent({\n dictionaryId,\n dictionaryPath,\n keyPath,\n });\n\n open();\n },\n [open, setFocusedContent]\n );\n\n return {\n isOpen,\n focusedContent,\n setDictionariesRecord,\n getEditedContentValue,\n open: openDictionaryEditionDrawer,\n close,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,2BAIO;AACP,mBAA4B;AAC5B,qBAA2B;AAEpB,MAAM,sBAAsB,CAAC,iBAClC,sBAAsB,YAAY;AA+B7B,MAAM,6BAA6B,CACxC,iBAC4B;AAC5B,QAAM,KAAK,oBAAoB,YAAY;AAC3C,QAAM,EAAE,QAAQ,MAAM,MAAM,QAAI,0CAAoB,EAAE;AAAA,QACpD,2BAAW,CAAC,OAAO;AAAA,MACjB,QAAQ,EAAE;AAAA,MACV,MAAM,EAAE;AAAA,MACR,OAAO,EAAE;AAAA,IACX,EAAE;AAAA,EACJ;AACA,QAAM,EAAE,uBAAuB,sBAAsB,QACnD;AAAA,QACE,2BAAW,CAAC,OAAO;AAAA,MACjB,uBAAuB,EAAE;AAAA,MACzB,uBAAuB,EAAE;AAAA,IAC3B,EAAE;AAAA,EACJ;AACF,QAAM,EAAE,mBAAmB,eAAe,QAAI;AAAA,QAC5C,2BAAW,CAAC,OAAO;AAAA,MACjB,gBAAgB,EAAE;AAAA,MAClB,mBAAmB,EAAE;AAAA,IACvB,EAAE;AAAA,EACJ;AAEA,QAAM,kCAA8B;AAAA,IAClC,CAAC;AAAA,MACC,cAAAA;AAAA,MACA;AAAA,MACA,UAAU,CAAC;AAAA,IACb,MAAwC;AACtC,wBAAkB;AAAA,QAChB,cAAAA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAED,WAAK;AAAA,IACP;AAAA,IACA,CAAC,MAAM,iBAAiB;AAAA,EAC1B;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,EACF;AACF;","names":["dictionaryId"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
"use client";
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -25,40 +26,66 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
25
26
|
var import_design_system = require("@intlayer/design-system");
|
|
26
27
|
var import_hooks = require("@intlayer/design-system/hooks");
|
|
27
28
|
var import_lucide_react = require("lucide-react");
|
|
28
|
-
var
|
|
29
|
+
var import_react = require("react");
|
|
30
|
+
var import_shallow = require("zustand/shallow");
|
|
31
|
+
var import_useDictionaryEditionDrawer = require('../DictionaryEditionDrawer/useDictionaryEditionDrawer.cjs');
|
|
29
32
|
var import_useDictionaryListDrawer = require('./useDictionaryListDrawer.cjs');
|
|
33
|
+
const DictionaryDrawerConnector = ({
|
|
34
|
+
dictionaryId
|
|
35
|
+
}) => {
|
|
36
|
+
const rightDrawerStore = (0, import_design_system.useRightDrawerStore)(dictionaryId)();
|
|
37
|
+
(0, import_react.useEffect)(() => {
|
|
38
|
+
rightDrawerStore.open();
|
|
39
|
+
}, [rightDrawerStore]);
|
|
40
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
|
|
41
|
+
};
|
|
30
42
|
const DictionaryListDrawer = () => {
|
|
31
43
|
const { all: dictionaries } = (0, import_hooks.useGetAllDictionaries)();
|
|
32
|
-
const dictionaryKeyList =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
44
|
+
const dictionaryKeyList = (0, import_react.useMemo)(
|
|
45
|
+
() => Object.keys(dictionaries),
|
|
46
|
+
[dictionaries]
|
|
47
|
+
);
|
|
48
|
+
const { closeDictionaryListDrawer } = (0, import_useDictionaryListDrawer.useDictionaryListDrawer)(
|
|
49
|
+
(0, import_shallow.useShallow)((s) => ({
|
|
50
|
+
closeDictionaryListDrawer: s.close
|
|
51
|
+
}))
|
|
52
|
+
);
|
|
53
|
+
const editedContent = (0, import_design_system.useEditedContentStore)(
|
|
54
|
+
(0, import_shallow.useShallow)((s) => s.editedContent)
|
|
55
|
+
);
|
|
56
|
+
const setFocusedContent = (0, import_design_system.useEditionPanelStore)(
|
|
57
|
+
(0, import_shallow.useShallow)((s) => s.setFocusedContent)
|
|
58
|
+
);
|
|
59
|
+
const [clickedDictionaryId, setClickedDictionaryId] = (0, import_react.useState)();
|
|
36
60
|
const handleClickDictionary = (dictionaryId) => {
|
|
61
|
+
closeDictionaryListDrawer();
|
|
37
62
|
const { filePath } = dictionaries[dictionaryId];
|
|
38
|
-
|
|
39
|
-
|
|
63
|
+
setFocusedContent({
|
|
64
|
+
dictionaryId,
|
|
65
|
+
dictionaryPath: filePath
|
|
66
|
+
});
|
|
67
|
+
setClickedDictionaryId((0, import_useDictionaryEditionDrawer.getDrawerIdentifier)(dictionaryId));
|
|
40
68
|
};
|
|
41
|
-
const isDictionaryEdited = (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
{
|
|
45
|
-
title: "Dictionary list",
|
|
46
|
-
identifier: import_useDictionaryListDrawer.dictionaryListDrawerIdentifier,
|
|
47
|
-
children: dictionaryKeyList.map((dictionaryId) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
48
|
-
import_design_system.Button,
|
|
49
|
-
{
|
|
50
|
-
label: `Open dictionary editor ${dictionaryId}`,
|
|
51
|
-
onClick: () => handleClickDictionary(dictionaryId),
|
|
52
|
-
variant: "hoverable",
|
|
53
|
-
color: "text",
|
|
54
|
-
IconRight: import_lucide_react.ChevronRight,
|
|
55
|
-
size: "md",
|
|
56
|
-
isFullWidth: true,
|
|
57
|
-
children: isDictionaryEdited(dictionaryId) ? `\u270E ${dictionaryId}` : dictionaryId
|
|
58
|
-
}
|
|
59
|
-
) }, dictionaryId))
|
|
60
|
-
}
|
|
69
|
+
const isDictionaryEdited = (0, import_react.useCallback)(
|
|
70
|
+
(dictionaryId) => Object.keys(editedContent).includes(dictionaryId),
|
|
71
|
+
[editedContent]
|
|
61
72
|
);
|
|
73
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
74
|
+
clickedDictionaryId && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DictionaryDrawerConnector, { dictionaryId: clickedDictionaryId }),
|
|
75
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_design_system.RightDrawer, { title: "Dictionary list", identifier: "dictionaryListDrawer", children: dictionaryKeyList.map((dictionaryId) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
76
|
+
import_design_system.Button,
|
|
77
|
+
{
|
|
78
|
+
label: `Open dictionary editor ${dictionaryId}`,
|
|
79
|
+
onClick: () => handleClickDictionary(dictionaryId),
|
|
80
|
+
variant: "hoverable",
|
|
81
|
+
color: "text",
|
|
82
|
+
IconRight: import_lucide_react.ChevronRight,
|
|
83
|
+
size: "md",
|
|
84
|
+
isFullWidth: true,
|
|
85
|
+
children: isDictionaryEdited(dictionaryId) ? `\u270E ${dictionaryId}` : dictionaryId
|
|
86
|
+
}
|
|
87
|
+
) }, dictionaryId)) })
|
|
88
|
+
] });
|
|
62
89
|
};
|
|
63
90
|
// Annotate the CommonJS export names for ESM import in node:
|
|
64
91
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/DictionaryListDrawer/DictionaryListDrawer.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/DictionaryListDrawer/DictionaryListDrawer.tsx"],"sourcesContent":["'use client';\n\nimport { Locales } from '@intlayer/config';\nimport {\n RightDrawer,\n Button,\n useEditedContentStore,\n useEditionPanelStore,\n useRightDrawerStore,\n} from '@intlayer/design-system';\nimport { useGetAllDictionaries } from '@intlayer/design-system/hooks';\nimport { ChevronRight } from 'lucide-react';\nimport { useState, useEffect, useCallback, useMemo, FC } from 'react';\nimport { useShallow } from 'zustand/shallow';\nimport { getDrawerIdentifier } from '../DictionaryEditionDrawer/useDictionaryEditionDrawer';\nimport { useDictionaryListDrawer } from './useDictionaryListDrawer';\n\ntype DictionaryDrawerConnectorProps = {\n dictionaryId: string;\n};\nconst DictionaryDrawerConnector: FC<DictionaryDrawerConnectorProps> = ({\n dictionaryId,\n}) => {\n const rightDrawerStore = useRightDrawerStore(dictionaryId)();\n\n useEffect(() => {\n rightDrawerStore.open();\n }, [rightDrawerStore]);\n\n return <></>;\n};\n\nexport const DictionaryListDrawer: FC = () => {\n const { all: dictionaries } = useGetAllDictionaries();\n const dictionaryKeyList = useMemo(\n () => Object.keys(dictionaries) as Locales[],\n [dictionaries]\n );\n const { closeDictionaryListDrawer } = useDictionaryListDrawer(\n useShallow((s) => ({\n closeDictionaryListDrawer: s.close,\n }))\n );\n const editedContent = useEditedContentStore(\n useShallow((s) => s.editedContent)\n );\n const setFocusedContent = useEditionPanelStore(\n useShallow((s) => s.setFocusedContent)\n );\n\n const [clickedDictionaryId, setClickedDictionaryId] = useState<string>();\n\n const handleClickDictionary = (dictionaryId: string) => {\n closeDictionaryListDrawer();\n\n const { filePath } = dictionaries[dictionaryId];\n setFocusedContent({\n dictionaryId,\n dictionaryPath: filePath,\n });\n\n setClickedDictionaryId(getDrawerIdentifier(dictionaryId));\n };\n\n const isDictionaryEdited = useCallback(\n (dictionaryId: string) => Object.keys(editedContent).includes(dictionaryId),\n [editedContent]\n );\n\n return (\n <>\n {clickedDictionaryId && (\n <DictionaryDrawerConnector dictionaryId={clickedDictionaryId} />\n )}\n <RightDrawer title=\"Dictionary list\" identifier=\"dictionaryListDrawer\">\n {dictionaryKeyList.map((dictionaryId) => (\n <div key={dictionaryId}>\n <Button\n label={`Open dictionary editor ${dictionaryId}`}\n onClick={() => handleClickDictionary(dictionaryId)}\n variant=\"hoverable\"\n color=\"text\"\n IconRight={ChevronRight}\n size=\"md\"\n isFullWidth\n >\n {isDictionaryEdited(dictionaryId)\n ? `✎ ${dictionaryId}`\n : dictionaryId}\n </Button>\n </div>\n ))}\n </RightDrawer>\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BS;AA1BT,2BAMO;AACP,mBAAsC;AACtC,0BAA6B;AAC7B,mBAA8D;AAC9D,qBAA2B;AAC3B,wCAAoC;AACpC,qCAAwC;AAKxC,MAAM,4BAAgE,CAAC;AAAA,EACrE;AACF,MAAM;AACJ,QAAM,uBAAmB,0CAAoB,YAAY,EAAE;AAE3D,8BAAU,MAAM;AACd,qBAAiB,KAAK;AAAA,EACxB,GAAG,CAAC,gBAAgB,CAAC;AAErB,SAAO,2EAAE;AACX;AAEO,MAAM,uBAA2B,MAAM;AAC5C,QAAM,EAAE,KAAK,aAAa,QAAI,oCAAsB;AACpD,QAAM,wBAAoB;AAAA,IACxB,MAAM,OAAO,KAAK,YAAY;AAAA,IAC9B,CAAC,YAAY;AAAA,EACf;AACA,QAAM,EAAE,0BAA0B,QAAI;AAAA,QACpC,2BAAW,CAAC,OAAO;AAAA,MACjB,2BAA2B,EAAE;AAAA,IAC/B,EAAE;AAAA,EACJ;AACA,QAAM,oBAAgB;AAAA,QACpB,2BAAW,CAAC,MAAM,EAAE,aAAa;AAAA,EACnC;AACA,QAAM,wBAAoB;AAAA,QACxB,2BAAW,CAAC,MAAM,EAAE,iBAAiB;AAAA,EACvC;AAEA,QAAM,CAAC,qBAAqB,sBAAsB,QAAI,uBAAiB;AAEvE,QAAM,wBAAwB,CAAC,iBAAyB;AACtD,8BAA0B;AAE1B,UAAM,EAAE,SAAS,IAAI,aAAa,YAAY;AAC9C,sBAAkB;AAAA,MAChB;AAAA,MACA,gBAAgB;AAAA,IAClB,CAAC;AAED,+BAAuB,uDAAoB,YAAY,CAAC;AAAA,EAC1D;AAEA,QAAM,yBAAqB;AAAA,IACzB,CAAC,iBAAyB,OAAO,KAAK,aAAa,EAAE,SAAS,YAAY;AAAA,IAC1E,CAAC,aAAa;AAAA,EAChB;AAEA,SACE,4EACG;AAAA,2BACC,4CAAC,6BAA0B,cAAc,qBAAqB;AAAA,IAEhE,4CAAC,oCAAY,OAAM,mBAAkB,YAAW,wBAC7C,4BAAkB,IAAI,CAAC,iBACtB,4CAAC,SACC;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,0BAA0B,YAAY;AAAA,QAC7C,SAAS,MAAM,sBAAsB,YAAY;AAAA,QACjD,SAAQ;AAAA,QACR,OAAM;AAAA,QACN,WAAW;AAAA,QACX,MAAK;AAAA,QACL,aAAW;AAAA,QAEV,6BAAmB,YAAY,IAC5B,UAAK,YAAY,KACjB;AAAA;AAAA,IACN,KAbQ,YAcV,CACD,GACH;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -24,7 +24,9 @@ __export(useDictionaryListDrawer_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(useDictionaryListDrawer_exports);
|
|
25
25
|
var import_design_system = require("@intlayer/design-system");
|
|
26
26
|
const dictionaryListDrawerIdentifier = "dictionaryList";
|
|
27
|
-
const useDictionaryListDrawer = (
|
|
27
|
+
const useDictionaryListDrawer = (0, import_design_system.useRightDrawerStore)(
|
|
28
|
+
dictionaryListDrawerIdentifier
|
|
29
|
+
);
|
|
28
30
|
// Annotate the CommonJS export names for ESM import in node:
|
|
29
31
|
0 && (module.exports = {
|
|
30
32
|
dictionaryListDrawerIdentifier,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/DictionaryListDrawer/useDictionaryListDrawer.ts"],"sourcesContent":["import { useRightDrawerStore } from '@intlayer/design-system';\n\nexport const dictionaryListDrawerIdentifier = 'dictionaryList';\n\nexport const useDictionaryListDrawer = (
|
|
1
|
+
{"version":3,"sources":["../../../src/DictionaryListDrawer/useDictionaryListDrawer.ts"],"sourcesContent":["import { useRightDrawerStore } from '@intlayer/design-system';\n\nexport const dictionaryListDrawerIdentifier = 'dictionaryList';\n\nexport const useDictionaryListDrawer = useRightDrawerStore(\n dictionaryListDrawerIdentifier\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAoC;AAE7B,MAAM,iCAAiC;AAEvC,MAAM,8BAA0B;AAAA,EACrC;AACF;","names":[]}
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from "@intlayer/design-system";
|
|
11
11
|
import { useGetAllDictionaries } from "@intlayer/design-system/hooks";
|
|
12
12
|
import { useCallback, useEffect, useState } from "react";
|
|
13
|
+
import { useShallow } from "zustand/shallow";
|
|
13
14
|
import { useDictionaryListDrawer } from '../DictionaryListDrawer/useDictionaryListDrawer.mjs';
|
|
14
15
|
import {
|
|
15
16
|
useDictionaryEditionDrawer,
|
|
@@ -103,7 +104,9 @@ const DictionaryEditionDrawer = ({
|
|
|
103
104
|
);
|
|
104
105
|
};
|
|
105
106
|
const DictionaryEditionDrawerController = ({ locale, localeList, setLocale }) => {
|
|
106
|
-
const focusedContent = useEditionPanelStore(
|
|
107
|
+
const focusedContent = useEditionPanelStore(
|
|
108
|
+
useShallow((s) => s.focusedContent)
|
|
109
|
+
);
|
|
107
110
|
const dictionaryId = focusedContent?.dictionaryId;
|
|
108
111
|
if (!dictionaryId) {
|
|
109
112
|
return /* @__PURE__ */ jsx(Fragment, {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/DictionaryEditionDrawer/DictionaryEditionDrawer.tsx"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport type { Dictionary, KeyPath } from '@intlayer/core';\nimport {\n RightDrawer,\n DictionaryEditor,\n LocaleSwitcher,\n Modal,\n useEditionPanelStore,\n DictionaryFieldEditor,\n} from '@intlayer/design-system';\nimport { useGetAllDictionaries } from '@intlayer/design-system/hooks';\nimport { useCallback, useEffect, useState, type FC } from 'react';\nimport { useDictionaryListDrawer } from '../DictionaryListDrawer/useDictionaryListDrawer';\nimport {\n type FileContent as FileContentWithDictionaryPath,\n useDictionaryEditionDrawer,\n getDrawerIdentifier,\n} from './useDictionaryEditionDrawer';\n\ntype DictionaryEditionDrawerContentProps = {\n focusedContent: FileContentWithDictionaryPath;\n locale: Locales;\n identifier: string;\n handleOnBack: () => void;\n};\n\nexport const DictionaryEditionDrawerContent: FC<\n DictionaryEditionDrawerContentProps\n> = ({ locale, identifier, handleOnBack }) => {\n const [keyPathEditionModal, setKeyPathEditionModal] = useState<\n KeyPath[] | null\n >(null);\n const { setDictionariesRecord, focusedContent } =\n useDictionaryEditionDrawer(identifier);\n const { all: dictionaries } = useGetAllDictionaries();\n\n const onClickDictionaryList = useCallback(() => {\n setKeyPathEditionModal(null);\n handleOnBack();\n }, [handleOnBack]);\n\n useEffect(() => {\n if (dictionaries) {\n setDictionariesRecord(dictionaries);\n }\n }, [setDictionariesRecord, dictionaries]);\n\n const dictionaryId = focusedContent?.dictionaryId;\n\n if (!dictionaryId) return <>No dictionary focused</>;\n\n const dictionary: Dictionary = dictionaries[dictionaryId];\n\n return (\n <>\n <Modal\n isOpen={keyPathEditionModal !== null}\n onClose={() => setKeyPathEditionModal(null)}\n hasCloseButton\n title=\"Edit field\"\n size=\"xl\"\n transparency=\"lg\"\n >\n {dictionary && (\n <DictionaryFieldEditor\n dictionary={dictionary}\n onClickDictionaryList={onClickDictionaryList}\n />\n )}\n </Modal>\n <DictionaryEditor\n dictionary={dictionary}\n locale={locale}\n onClickEdit={setKeyPathEditionModal}\n />\n </>\n );\n};\n\ntype DictionaryEditionDrawerProps = DictionaryEditionDrawerControllerProps & {\n dictionaryId: string;\n};\n\nexport const DictionaryEditionDrawer: FC<DictionaryEditionDrawerProps> = ({\n locale,\n localeList,\n setLocale,\n dictionaryId,\n}) => {\n const id = getDrawerIdentifier(dictionaryId);\n\n const { focusedContent, close } = useDictionaryEditionDrawer(dictionaryId);\n const { open: openDictionaryListDrawer } = useDictionaryListDrawer();\n\n const handleOnBack = () => {\n close();\n openDictionaryListDrawer();\n };\n\n return (\n <RightDrawer\n title={dictionaryId}\n identifier={id}\n header={\n <LocaleSwitcher\n setLocale={setLocale}\n locale={locale}\n localeList={localeList}\n />\n }\n backButton={{\n onBack: handleOnBack,\n text: 'Dictionary list',\n }}\n >\n {focusedContent && (\n <DictionaryEditionDrawerContent\n focusedContent={focusedContent}\n locale={locale}\n identifier={id}\n handleOnBack={handleOnBack}\n />\n )}\n </RightDrawer>\n );\n};\n\ntype DictionaryEditionDrawerControllerProps = {\n locale: Locales;\n localeList: Locales[];\n setLocale: (locale: Locales) => void;\n};\n\nexport const DictionaryEditionDrawerController: FC<\n DictionaryEditionDrawerControllerProps\n> = ({ locale, localeList, setLocale }) => {\n const focusedContent = useEditionPanelStore((s) => s.focusedContent);\n const dictionaryId: string | undefined = focusedContent?.dictionaryId;\n\n if (!dictionaryId) {\n return <></>;\n }\n\n return (\n <DictionaryEditionDrawer\n locale={locale}\n localeList={localeList}\n setLocale={setLocale}\n dictionaryId={dictionaryId}\n />\n );\n};\n"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../../src/DictionaryEditionDrawer/DictionaryEditionDrawer.tsx"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport type { Dictionary, KeyPath } from '@intlayer/core';\nimport {\n RightDrawer,\n DictionaryEditor,\n LocaleSwitcher,\n Modal,\n useEditionPanelStore,\n DictionaryFieldEditor,\n} from '@intlayer/design-system';\nimport { useGetAllDictionaries } from '@intlayer/design-system/hooks';\nimport { useCallback, useEffect, useState, type FC } from 'react';\nimport { useShallow } from 'zustand/shallow';\nimport { useDictionaryListDrawer } from '../DictionaryListDrawer/useDictionaryListDrawer';\nimport {\n type FileContent as FileContentWithDictionaryPath,\n useDictionaryEditionDrawer,\n getDrawerIdentifier,\n} from './useDictionaryEditionDrawer';\n\ntype DictionaryEditionDrawerContentProps = {\n focusedContent: FileContentWithDictionaryPath;\n locale: Locales;\n identifier: string;\n handleOnBack: () => void;\n};\n\nexport const DictionaryEditionDrawerContent: FC<\n DictionaryEditionDrawerContentProps\n> = ({ locale, identifier, handleOnBack }) => {\n const [keyPathEditionModal, setKeyPathEditionModal] = useState<\n KeyPath[] | null\n >(null);\n const { setDictionariesRecord, focusedContent } =\n useDictionaryEditionDrawer(identifier);\n const { all: dictionaries } = useGetAllDictionaries();\n\n const onClickDictionaryList = useCallback(() => {\n setKeyPathEditionModal(null);\n handleOnBack();\n }, [handleOnBack]);\n\n useEffect(() => {\n if (dictionaries) {\n setDictionariesRecord(dictionaries);\n }\n }, [setDictionariesRecord, dictionaries]);\n\n const dictionaryId = focusedContent?.dictionaryId;\n\n if (!dictionaryId) return <>No dictionary focused</>;\n\n const dictionary: Dictionary = dictionaries[dictionaryId];\n\n return (\n <>\n <Modal\n isOpen={keyPathEditionModal !== null}\n onClose={() => setKeyPathEditionModal(null)}\n hasCloseButton\n title=\"Edit field\"\n size=\"xl\"\n transparency=\"lg\"\n >\n {dictionary && (\n <DictionaryFieldEditor\n dictionary={dictionary}\n onClickDictionaryList={onClickDictionaryList}\n />\n )}\n </Modal>\n <DictionaryEditor\n dictionary={dictionary}\n locale={locale}\n onClickEdit={setKeyPathEditionModal}\n />\n </>\n );\n};\n\ntype DictionaryEditionDrawerProps = DictionaryEditionDrawerControllerProps & {\n dictionaryId: string;\n};\n\nexport const DictionaryEditionDrawer: FC<DictionaryEditionDrawerProps> = ({\n locale,\n localeList,\n setLocale,\n dictionaryId,\n}) => {\n const id = getDrawerIdentifier(dictionaryId);\n\n const { focusedContent, close } = useDictionaryEditionDrawer(dictionaryId);\n const { open: openDictionaryListDrawer } = useDictionaryListDrawer();\n\n const handleOnBack = () => {\n close();\n openDictionaryListDrawer();\n };\n\n return (\n <RightDrawer\n title={dictionaryId}\n identifier={id}\n header={\n <LocaleSwitcher\n setLocale={setLocale}\n locale={locale}\n localeList={localeList}\n />\n }\n backButton={{\n onBack: handleOnBack,\n text: 'Dictionary list',\n }}\n >\n {focusedContent && (\n <DictionaryEditionDrawerContent\n focusedContent={focusedContent}\n locale={locale}\n identifier={id}\n handleOnBack={handleOnBack}\n />\n )}\n </RightDrawer>\n );\n};\n\ntype DictionaryEditionDrawerControllerProps = {\n locale: Locales;\n localeList: Locales[];\n setLocale: (locale: Locales) => void;\n};\n\nexport const DictionaryEditionDrawerController: FC<\n DictionaryEditionDrawerControllerProps\n> = ({ locale, localeList, setLocale }) => {\n const focusedContent = useEditionPanelStore(\n useShallow((s) => s.focusedContent)\n );\n const dictionaryId: string | undefined = focusedContent?.dictionaryId;\n\n if (!dictionaryId) {\n return <></>;\n }\n\n return (\n <DictionaryEditionDrawer\n locale={locale}\n localeList={localeList}\n setLocale={setLocale}\n dictionaryId={dictionaryId}\n />\n );\n};\n"],"mappings":";AAoD4B,wBAKxB,YALwB;AAhD5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAA6B;AACtC,SAAS,aAAa,WAAW,gBAAyB;AAC1D,SAAS,kBAAkB;AAC3B,SAAS,+BAA+B;AACxC;AAAA,EAEE;AAAA,EACA;AAAA,OACK;AASA,MAAM,iCAET,CAAC,EAAE,QAAQ,YAAY,aAAa,MAAM;AAC5C,QAAM,CAAC,qBAAqB,sBAAsB,IAAI,SAEpD,IAAI;AACN,QAAM,EAAE,uBAAuB,eAAe,IAC5C,2BAA2B,UAAU;AACvC,QAAM,EAAE,KAAK,aAAa,IAAI,sBAAsB;AAEpD,QAAM,wBAAwB,YAAY,MAAM;AAC9C,2BAAuB,IAAI;AAC3B,iBAAa;AAAA,EACf,GAAG,CAAC,YAAY,CAAC;AAEjB,YAAU,MAAM;AACd,QAAI,cAAc;AAChB,4BAAsB,YAAY;AAAA,IACpC;AAAA,EACF,GAAG,CAAC,uBAAuB,YAAY,CAAC;AAExC,QAAM,eAAe,gBAAgB;AAErC,MAAI,CAAC,aAAc,QAAO,gCAAE,mCAAqB;AAEjD,QAAM,aAAyB,aAAa,YAAY;AAExD,SACE,iCACE;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,QAAQ,wBAAwB;AAAA,QAChC,SAAS,MAAM,uBAAuB,IAAI;AAAA,QAC1C,gBAAc;AAAA,QACd,OAAM;AAAA,QACN,MAAK;AAAA,QACL,cAAa;AAAA,QAEZ,wBACC;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA;AAAA;AAAA,QACF;AAAA;AAAA,IAEJ;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA,aAAa;AAAA;AAAA,IACf;AAAA,KACF;AAEJ;AAMO,MAAM,0BAA4D,CAAC;AAAA,EACxE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,KAAK,oBAAoB,YAAY;AAE3C,QAAM,EAAE,gBAAgB,MAAM,IAAI,2BAA2B,YAAY;AACzE,QAAM,EAAE,MAAM,yBAAyB,IAAI,wBAAwB;AAEnE,QAAM,eAAe,MAAM;AACzB,UAAM;AACN,6BAAyB;AAAA,EAC3B;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,MACP,YAAY;AAAA,MACZ,QACE;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACF;AAAA,MAEF,YAAY;AAAA,QACV,QAAQ;AAAA,QACR,MAAM;AAAA,MACR;AAAA,MAEC,4BACC;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA,YAAY;AAAA,UACZ;AAAA;AAAA,MACF;AAAA;AAAA,EAEJ;AAEJ;AAQO,MAAM,oCAET,CAAC,EAAE,QAAQ,YAAY,UAAU,MAAM;AACzC,QAAM,iBAAiB;AAAA,IACrB,WAAW,CAAC,MAAM,EAAE,cAAc;AAAA,EACpC;AACA,QAAM,eAAmC,gBAAgB;AAEzD,MAAI,CAAC,cAAc;AACjB,WAAO,gCAAE;AAAA,EACX;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -3,30 +3,45 @@ import {
|
|
|
3
3
|
useEditedContentStore,
|
|
4
4
|
useEditionPanelStore
|
|
5
5
|
} from "@intlayer/design-system";
|
|
6
|
+
import { useCallback } from "react";
|
|
7
|
+
import { useShallow } from "zustand/shallow";
|
|
6
8
|
const getDrawerIdentifier = (dictionaryId) => `dictionary_edition_${dictionaryId}`;
|
|
7
9
|
const useDictionaryEditionDrawer = (dictionaryId) => {
|
|
8
10
|
const id = getDrawerIdentifier(dictionaryId);
|
|
9
|
-
const { isOpen, open, close } = useRightDrawerStore(id)(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
11
|
+
const { isOpen, open, close } = useRightDrawerStore(id)(
|
|
12
|
+
useShallow((e) => ({
|
|
13
|
+
isOpen: e.isOpen,
|
|
14
|
+
open: e.open,
|
|
15
|
+
close: e.close
|
|
16
|
+
}))
|
|
17
|
+
);
|
|
18
|
+
const { setDictionariesRecord, getEditedContentValue } = useEditedContentStore(
|
|
19
|
+
useShallow((s) => ({
|
|
20
|
+
setDictionariesRecord: s.setDictionariesRecord,
|
|
21
|
+
getEditedContentValue: s.getEditedContentValue
|
|
22
|
+
}))
|
|
23
|
+
);
|
|
24
|
+
const { setFocusedContent, focusedContent } = useEditionPanelStore(
|
|
25
|
+
useShallow((s) => ({
|
|
26
|
+
focusedContent: s.focusedContent,
|
|
27
|
+
setFocusedContent: s.setFocusedContent
|
|
28
|
+
}))
|
|
29
|
+
);
|
|
30
|
+
const openDictionaryEditionDrawer = useCallback(
|
|
31
|
+
({
|
|
24
32
|
dictionaryId: dictionaryId2,
|
|
25
33
|
dictionaryPath,
|
|
26
|
-
keyPath
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
keyPath = []
|
|
35
|
+
}) => {
|
|
36
|
+
setFocusedContent({
|
|
37
|
+
dictionaryId: dictionaryId2,
|
|
38
|
+
dictionaryPath,
|
|
39
|
+
keyPath
|
|
40
|
+
});
|
|
41
|
+
open();
|
|
42
|
+
},
|
|
43
|
+
[open, setFocusedContent]
|
|
44
|
+
);
|
|
30
45
|
return {
|
|
31
46
|
isOpen,
|
|
32
47
|
focusedContent,
|
|
@@ -36,33 +51,8 @@ const useDictionaryEditionDrawer = (dictionaryId) => {
|
|
|
36
51
|
close
|
|
37
52
|
};
|
|
38
53
|
};
|
|
39
|
-
const useDictionaryEditionDrawerControl = () => {
|
|
40
|
-
const setFocusedContent = useEditionPanelStore((s) => s.setFocusedContent);
|
|
41
|
-
const open = ({
|
|
42
|
-
dictionaryId,
|
|
43
|
-
dictionaryPath,
|
|
44
|
-
keyPath = []
|
|
45
|
-
}) => {
|
|
46
|
-
setFocusedContent({
|
|
47
|
-
dictionaryId,
|
|
48
|
-
dictionaryPath,
|
|
49
|
-
keyPath
|
|
50
|
-
});
|
|
51
|
-
const id = getDrawerIdentifier(dictionaryId);
|
|
52
|
-
useRightDrawerStore(id).getState().open();
|
|
53
|
-
};
|
|
54
|
-
const close = (dictionaryId) => {
|
|
55
|
-
const id = getDrawerIdentifier(dictionaryId);
|
|
56
|
-
useRightDrawerStore(id).getState().close();
|
|
57
|
-
};
|
|
58
|
-
return {
|
|
59
|
-
open,
|
|
60
|
-
close
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
54
|
export {
|
|
64
55
|
getDrawerIdentifier,
|
|
65
|
-
useDictionaryEditionDrawer
|
|
66
|
-
useDictionaryEditionDrawerControl
|
|
56
|
+
useDictionaryEditionDrawer
|
|
67
57
|
};
|
|
68
58
|
//# sourceMappingURL=useDictionaryEditionDrawer.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/DictionaryEditionDrawer/useDictionaryEditionDrawer.ts"],"sourcesContent":["import type { Dictionary, DictionaryValue, KeyPath } from '@intlayer/core';\nimport {\n useRightDrawerStore,\n useEditedContentStore,\n useEditionPanelStore,\n} from '@intlayer/design-system';\n\nexport const getDrawerIdentifier = (dictionaryId: string) =>\n `dictionary_edition_${dictionaryId}`;\n\ntype DictionaryId = string;\ntype DictionaryPath = string;\n\nexport type FileContent = {\n dictionaryPath?: DictionaryPath;\n dictionaryId: string;\n keyPath?: KeyPath[];\n};\n\ntype DictionaryEditionDrawer = {\n focusedContent: FileContent | null;\n isOpen: boolean;\n open: (content: FileContent) => void;\n close: () => void;\n setDictionariesRecord: (\n dictionariesRecord: Record<DictionaryId, Dictionary>\n ) => void;\n getEditedContentValue: (\n dictionaryId: DictionaryId,\n keyPath: KeyPath[]\n ) => DictionaryValue | undefined;\n};\n\ntype OpenDictionaryEditionDrawerProps = {\n dictionaryId: string;\n dictionaryPath?: string;\n keyPath?: KeyPath[];\n};\n\nexport const useDictionaryEditionDrawer = (\n dictionaryId: string\n): DictionaryEditionDrawer => {\n const id = getDrawerIdentifier(dictionaryId);\n const { isOpen, open, close } = useRightDrawerStore(id)();\n const { setDictionariesRecord, getEditedContentValue } =\n useEditedContentStore((s) => ({\n
|
|
1
|
+
{"version":3,"sources":["../../../src/DictionaryEditionDrawer/useDictionaryEditionDrawer.ts"],"sourcesContent":["import type { Dictionary, DictionaryValue, KeyPath } from '@intlayer/core';\nimport {\n useRightDrawerStore,\n useEditedContentStore,\n useEditionPanelStore,\n} from '@intlayer/design-system';\nimport { useCallback } from 'react';\nimport { useShallow } from 'zustand/shallow';\n\nexport const getDrawerIdentifier = (dictionaryId: string) =>\n `dictionary_edition_${dictionaryId}`;\n\ntype DictionaryId = string;\ntype DictionaryPath = string;\n\nexport type FileContent = {\n dictionaryPath?: DictionaryPath;\n dictionaryId: string;\n keyPath?: KeyPath[];\n};\n\ntype DictionaryEditionDrawer = {\n focusedContent: FileContent | null;\n isOpen: boolean;\n open: (content: FileContent) => void;\n close: () => void;\n setDictionariesRecord: (\n dictionariesRecord: Record<DictionaryId, Dictionary>\n ) => void;\n getEditedContentValue: (\n dictionaryId: DictionaryId,\n keyPath: KeyPath[]\n ) => DictionaryValue | undefined;\n};\n\ntype OpenDictionaryEditionDrawerProps = {\n dictionaryId: string;\n dictionaryPath?: string;\n keyPath?: KeyPath[];\n};\n\nexport const useDictionaryEditionDrawer = (\n dictionaryId: string\n): DictionaryEditionDrawer => {\n const id = getDrawerIdentifier(dictionaryId);\n const { isOpen, open, close } = useRightDrawerStore(id)(\n useShallow((e) => ({\n isOpen: e.isOpen,\n open: e.open,\n close: e.close,\n }))\n );\n const { setDictionariesRecord, getEditedContentValue } =\n useEditedContentStore(\n useShallow((s) => ({\n setDictionariesRecord: s.setDictionariesRecord,\n getEditedContentValue: s.getEditedContentValue,\n }))\n );\n const { setFocusedContent, focusedContent } = useEditionPanelStore(\n useShallow((s) => ({\n focusedContent: s.focusedContent,\n setFocusedContent: s.setFocusedContent,\n }))\n );\n\n const openDictionaryEditionDrawer = useCallback(\n ({\n dictionaryId,\n dictionaryPath,\n keyPath = [],\n }: OpenDictionaryEditionDrawerProps) => {\n setFocusedContent({\n dictionaryId,\n dictionaryPath,\n keyPath,\n });\n\n open();\n },\n [open, setFocusedContent]\n );\n\n return {\n isOpen,\n focusedContent,\n setDictionariesRecord,\n getEditedContentValue,\n open: openDictionaryEditionDrawer,\n close,\n };\n};\n"],"mappings":"AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAEpB,MAAM,sBAAsB,CAAC,iBAClC,sBAAsB,YAAY;AA+B7B,MAAM,6BAA6B,CACxC,iBAC4B;AAC5B,QAAM,KAAK,oBAAoB,YAAY;AAC3C,QAAM,EAAE,QAAQ,MAAM,MAAM,IAAI,oBAAoB,EAAE;AAAA,IACpD,WAAW,CAAC,OAAO;AAAA,MACjB,QAAQ,EAAE;AAAA,MACV,MAAM,EAAE;AAAA,MACR,OAAO,EAAE;AAAA,IACX,EAAE;AAAA,EACJ;AACA,QAAM,EAAE,uBAAuB,sBAAsB,IACnD;AAAA,IACE,WAAW,CAAC,OAAO;AAAA,MACjB,uBAAuB,EAAE;AAAA,MACzB,uBAAuB,EAAE;AAAA,IAC3B,EAAE;AAAA,EACJ;AACF,QAAM,EAAE,mBAAmB,eAAe,IAAI;AAAA,IAC5C,WAAW,CAAC,OAAO;AAAA,MACjB,gBAAgB,EAAE;AAAA,MAClB,mBAAmB,EAAE;AAAA,IACvB,EAAE;AAAA,EACJ;AAEA,QAAM,8BAA8B;AAAA,IAClC,CAAC;AAAA,MACC,cAAAA;AAAA,MACA;AAAA,MACA,UAAU,CAAC;AAAA,IACb,MAAwC;AACtC,wBAAkB;AAAA,QAChB,cAAAA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAED,WAAK;AAAA,IACP;AAAA,IACA,CAAC,MAAM,iBAAiB;AAAA,EAC1B;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,EACF;AACF;","names":["dictionaryId"]}
|
|
@@ -1,48 +1,74 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
3
|
import {
|
|
3
4
|
RightDrawer,
|
|
4
5
|
Button,
|
|
5
|
-
useEditedContentStore
|
|
6
|
+
useEditedContentStore,
|
|
7
|
+
useEditionPanelStore,
|
|
8
|
+
useRightDrawerStore
|
|
6
9
|
} from "@intlayer/design-system";
|
|
7
10
|
import { useGetAllDictionaries } from "@intlayer/design-system/hooks";
|
|
8
11
|
import { ChevronRight } from "lucide-react";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
import { useState, useEffect, useCallback, useMemo } from "react";
|
|
13
|
+
import { useShallow } from "zustand/shallow";
|
|
14
|
+
import { getDrawerIdentifier } from '../DictionaryEditionDrawer/useDictionaryEditionDrawer.mjs';
|
|
15
|
+
import { useDictionaryListDrawer } from './useDictionaryListDrawer.mjs';
|
|
16
|
+
const DictionaryDrawerConnector = ({
|
|
17
|
+
dictionaryId
|
|
18
|
+
}) => {
|
|
19
|
+
const rightDrawerStore = useRightDrawerStore(dictionaryId)();
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
rightDrawerStore.open();
|
|
22
|
+
}, [rightDrawerStore]);
|
|
23
|
+
return /* @__PURE__ */ jsx(Fragment, {});
|
|
24
|
+
};
|
|
14
25
|
const DictionaryListDrawer = () => {
|
|
15
26
|
const { all: dictionaries } = useGetAllDictionaries();
|
|
16
|
-
const dictionaryKeyList =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
27
|
+
const dictionaryKeyList = useMemo(
|
|
28
|
+
() => Object.keys(dictionaries),
|
|
29
|
+
[dictionaries]
|
|
30
|
+
);
|
|
31
|
+
const { closeDictionaryListDrawer } = useDictionaryListDrawer(
|
|
32
|
+
useShallow((s) => ({
|
|
33
|
+
closeDictionaryListDrawer: s.close
|
|
34
|
+
}))
|
|
35
|
+
);
|
|
36
|
+
const editedContent = useEditedContentStore(
|
|
37
|
+
useShallow((s) => s.editedContent)
|
|
38
|
+
);
|
|
39
|
+
const setFocusedContent = useEditionPanelStore(
|
|
40
|
+
useShallow((s) => s.setFocusedContent)
|
|
41
|
+
);
|
|
42
|
+
const [clickedDictionaryId, setClickedDictionaryId] = useState();
|
|
20
43
|
const handleClickDictionary = (dictionaryId) => {
|
|
44
|
+
closeDictionaryListDrawer();
|
|
21
45
|
const { filePath } = dictionaries[dictionaryId];
|
|
22
|
-
|
|
23
|
-
|
|
46
|
+
setFocusedContent({
|
|
47
|
+
dictionaryId,
|
|
48
|
+
dictionaryPath: filePath
|
|
49
|
+
});
|
|
50
|
+
setClickedDictionaryId(getDrawerIdentifier(dictionaryId));
|
|
24
51
|
};
|
|
25
|
-
const isDictionaryEdited = (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
{
|
|
29
|
-
title: "Dictionary list",
|
|
30
|
-
identifier: dictionaryListDrawerIdentifier,
|
|
31
|
-
children: dictionaryKeyList.map((dictionaryId) => /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
32
|
-
Button,
|
|
33
|
-
{
|
|
34
|
-
label: `Open dictionary editor ${dictionaryId}`,
|
|
35
|
-
onClick: () => handleClickDictionary(dictionaryId),
|
|
36
|
-
variant: "hoverable",
|
|
37
|
-
color: "text",
|
|
38
|
-
IconRight: ChevronRight,
|
|
39
|
-
size: "md",
|
|
40
|
-
isFullWidth: true,
|
|
41
|
-
children: isDictionaryEdited(dictionaryId) ? `\u270E ${dictionaryId}` : dictionaryId
|
|
42
|
-
}
|
|
43
|
-
) }, dictionaryId))
|
|
44
|
-
}
|
|
52
|
+
const isDictionaryEdited = useCallback(
|
|
53
|
+
(dictionaryId) => Object.keys(editedContent).includes(dictionaryId),
|
|
54
|
+
[editedContent]
|
|
45
55
|
);
|
|
56
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
57
|
+
clickedDictionaryId && /* @__PURE__ */ jsx(DictionaryDrawerConnector, { dictionaryId: clickedDictionaryId }),
|
|
58
|
+
/* @__PURE__ */ jsx(RightDrawer, { title: "Dictionary list", identifier: "dictionaryListDrawer", children: dictionaryKeyList.map((dictionaryId) => /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
59
|
+
Button,
|
|
60
|
+
{
|
|
61
|
+
label: `Open dictionary editor ${dictionaryId}`,
|
|
62
|
+
onClick: () => handleClickDictionary(dictionaryId),
|
|
63
|
+
variant: "hoverable",
|
|
64
|
+
color: "text",
|
|
65
|
+
IconRight: ChevronRight,
|
|
66
|
+
size: "md",
|
|
67
|
+
isFullWidth: true,
|
|
68
|
+
children: isDictionaryEdited(dictionaryId) ? `\u270E ${dictionaryId}` : dictionaryId
|
|
69
|
+
}
|
|
70
|
+
) }, dictionaryId)) })
|
|
71
|
+
] });
|
|
46
72
|
};
|
|
47
73
|
export {
|
|
48
74
|
DictionaryListDrawer
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/DictionaryListDrawer/DictionaryListDrawer.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/DictionaryListDrawer/DictionaryListDrawer.tsx"],"sourcesContent":["'use client';\n\nimport { Locales } from '@intlayer/config';\nimport {\n RightDrawer,\n Button,\n useEditedContentStore,\n useEditionPanelStore,\n useRightDrawerStore,\n} from '@intlayer/design-system';\nimport { useGetAllDictionaries } from '@intlayer/design-system/hooks';\nimport { ChevronRight } from 'lucide-react';\nimport { useState, useEffect, useCallback, useMemo, FC } from 'react';\nimport { useShallow } from 'zustand/shallow';\nimport { getDrawerIdentifier } from '../DictionaryEditionDrawer/useDictionaryEditionDrawer';\nimport { useDictionaryListDrawer } from './useDictionaryListDrawer';\n\ntype DictionaryDrawerConnectorProps = {\n dictionaryId: string;\n};\nconst DictionaryDrawerConnector: FC<DictionaryDrawerConnectorProps> = ({\n dictionaryId,\n}) => {\n const rightDrawerStore = useRightDrawerStore(dictionaryId)();\n\n useEffect(() => {\n rightDrawerStore.open();\n }, [rightDrawerStore]);\n\n return <></>;\n};\n\nexport const DictionaryListDrawer: FC = () => {\n const { all: dictionaries } = useGetAllDictionaries();\n const dictionaryKeyList = useMemo(\n () => Object.keys(dictionaries) as Locales[],\n [dictionaries]\n );\n const { closeDictionaryListDrawer } = useDictionaryListDrawer(\n useShallow((s) => ({\n closeDictionaryListDrawer: s.close,\n }))\n );\n const editedContent = useEditedContentStore(\n useShallow((s) => s.editedContent)\n );\n const setFocusedContent = useEditionPanelStore(\n useShallow((s) => s.setFocusedContent)\n );\n\n const [clickedDictionaryId, setClickedDictionaryId] = useState<string>();\n\n const handleClickDictionary = (dictionaryId: string) => {\n closeDictionaryListDrawer();\n\n const { filePath } = dictionaries[dictionaryId];\n setFocusedContent({\n dictionaryId,\n dictionaryPath: filePath,\n });\n\n setClickedDictionaryId(getDrawerIdentifier(dictionaryId));\n };\n\n const isDictionaryEdited = useCallback(\n (dictionaryId: string) => Object.keys(editedContent).includes(dictionaryId),\n [editedContent]\n );\n\n return (\n <>\n {clickedDictionaryId && (\n <DictionaryDrawerConnector dictionaryId={clickedDictionaryId} />\n )}\n <RightDrawer title=\"Dictionary list\" identifier=\"dictionaryListDrawer\">\n {dictionaryKeyList.map((dictionaryId) => (\n <div key={dictionaryId}>\n <Button\n label={`Open dictionary editor ${dictionaryId}`}\n onClick={() => handleClickDictionary(dictionaryId)}\n variant=\"hoverable\"\n color=\"text\"\n IconRight={ChevronRight}\n size=\"md\"\n isFullWidth\n >\n {isDictionaryEdited(dictionaryId)\n ? `✎ ${dictionaryId}`\n : dictionaryId}\n </Button>\n </div>\n ))}\n </RightDrawer>\n </>\n );\n};\n"],"mappings":";AA6BS,wBAyCL,YAzCK;AA1BT;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAA6B;AACtC,SAAS,oBAAoB;AAC7B,SAAS,UAAU,WAAW,aAAa,eAAmB;AAC9D,SAAS,kBAAkB;AAC3B,SAAS,2BAA2B;AACpC,SAAS,+BAA+B;AAKxC,MAAM,4BAAgE,CAAC;AAAA,EACrE;AACF,MAAM;AACJ,QAAM,mBAAmB,oBAAoB,YAAY,EAAE;AAE3D,YAAU,MAAM;AACd,qBAAiB,KAAK;AAAA,EACxB,GAAG,CAAC,gBAAgB,CAAC;AAErB,SAAO,gCAAE;AACX;AAEO,MAAM,uBAA2B,MAAM;AAC5C,QAAM,EAAE,KAAK,aAAa,IAAI,sBAAsB;AACpD,QAAM,oBAAoB;AAAA,IACxB,MAAM,OAAO,KAAK,YAAY;AAAA,IAC9B,CAAC,YAAY;AAAA,EACf;AACA,QAAM,EAAE,0BAA0B,IAAI;AAAA,IACpC,WAAW,CAAC,OAAO;AAAA,MACjB,2BAA2B,EAAE;AAAA,IAC/B,EAAE;AAAA,EACJ;AACA,QAAM,gBAAgB;AAAA,IACpB,WAAW,CAAC,MAAM,EAAE,aAAa;AAAA,EACnC;AACA,QAAM,oBAAoB;AAAA,IACxB,WAAW,CAAC,MAAM,EAAE,iBAAiB;AAAA,EACvC;AAEA,QAAM,CAAC,qBAAqB,sBAAsB,IAAI,SAAiB;AAEvE,QAAM,wBAAwB,CAAC,iBAAyB;AACtD,8BAA0B;AAE1B,UAAM,EAAE,SAAS,IAAI,aAAa,YAAY;AAC9C,sBAAkB;AAAA,MAChB;AAAA,MACA,gBAAgB;AAAA,IAClB,CAAC;AAED,2BAAuB,oBAAoB,YAAY,CAAC;AAAA,EAC1D;AAEA,QAAM,qBAAqB;AAAA,IACzB,CAAC,iBAAyB,OAAO,KAAK,aAAa,EAAE,SAAS,YAAY;AAAA,IAC1E,CAAC,aAAa;AAAA,EAChB;AAEA,SACE,iCACG;AAAA,2BACC,oBAAC,6BAA0B,cAAc,qBAAqB;AAAA,IAEhE,oBAAC,eAAY,OAAM,mBAAkB,YAAW,wBAC7C,4BAAkB,IAAI,CAAC,iBACtB,oBAAC,SACC;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,0BAA0B,YAAY;AAAA,QAC7C,SAAS,MAAM,sBAAsB,YAAY;AAAA,QACjD,SAAQ;AAAA,QACR,OAAM;AAAA,QACN,WAAW;AAAA,QACX,MAAK;AAAA,QACL,aAAW;AAAA,QAEV,6BAAmB,YAAY,IAC5B,UAAK,YAAY,KACjB;AAAA;AAAA,IACN,KAbQ,YAcV,CACD,GACH;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { useRightDrawerStore } from "@intlayer/design-system";
|
|
2
2
|
const dictionaryListDrawerIdentifier = "dictionaryList";
|
|
3
|
-
const useDictionaryListDrawer =
|
|
3
|
+
const useDictionaryListDrawer = useRightDrawerStore(
|
|
4
|
+
dictionaryListDrawerIdentifier
|
|
5
|
+
);
|
|
4
6
|
export {
|
|
5
7
|
dictionaryListDrawerIdentifier,
|
|
6
8
|
useDictionaryListDrawer
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/DictionaryListDrawer/useDictionaryListDrawer.ts"],"sourcesContent":["import { useRightDrawerStore } from '@intlayer/design-system';\n\nexport const dictionaryListDrawerIdentifier = 'dictionaryList';\n\nexport const useDictionaryListDrawer = (
|
|
1
|
+
{"version":3,"sources":["../../../src/DictionaryListDrawer/useDictionaryListDrawer.ts"],"sourcesContent":["import { useRightDrawerStore } from '@intlayer/design-system';\n\nexport const dictionaryListDrawerIdentifier = 'dictionaryList';\n\nexport const useDictionaryListDrawer = useRightDrawerStore(\n dictionaryListDrawerIdentifier\n);\n"],"mappings":"AAAA,SAAS,2BAA2B;AAE7B,MAAM,iCAAiC;AAEvC,MAAM,0BAA0B;AAAA,EACrC;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryEditionDrawer.d.ts","sourceRoot":"","sources":["../../../src/DictionaryEditionDrawer/DictionaryEditionDrawer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAWvD,OAAO,EAAoC,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"DictionaryEditionDrawer.d.ts","sourceRoot":"","sources":["../../../src/DictionaryEditionDrawer/DictionaryEditionDrawer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAWvD,OAAO,EAAoC,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAGlE,OAAO,EACL,KAAK,WAAW,IAAI,6BAA6B,EAGlD,MAAM,8BAA8B,CAAC;AAEtC,KAAK,mCAAmC,GAAG;IACzC,cAAc,EAAE,6BAA6B,CAAC;IAC9C,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,EAAE,CAC7C,mCAAmC,CAkDpC,CAAC;AAEF,KAAK,4BAA4B,GAAG,sCAAsC,GAAG;IAC3E,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,4BAA4B,CA0CpE,CAAC;AAEF,KAAK,sCAAsC,GAAG;IAC5C,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,EAAE,CAAC;IACtB,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACtC,CAAC;AAEF,eAAO,MAAM,iCAAiC,EAAE,EAAE,CAChD,sCAAsC,CAmBvC,CAAC"}
|
|
@@ -16,10 +16,5 @@ type DictionaryEditionDrawer = {
|
|
|
16
16
|
getEditedContentValue: (dictionaryId: DictionaryId, keyPath: KeyPath[]) => DictionaryValue | undefined;
|
|
17
17
|
};
|
|
18
18
|
export declare const useDictionaryEditionDrawer: (dictionaryId: string) => DictionaryEditionDrawer;
|
|
19
|
-
type DictionaryEditionDrawerControl = {
|
|
20
|
-
open: (content: FileContent) => void;
|
|
21
|
-
close: (dictionaryId: string) => void;
|
|
22
|
-
};
|
|
23
|
-
export declare const useDictionaryEditionDrawerControl: () => DictionaryEditionDrawerControl;
|
|
24
19
|
export {};
|
|
25
20
|
//# sourceMappingURL=useDictionaryEditionDrawer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryEditionDrawer.d.ts","sourceRoot":"","sources":["../../../src/DictionaryEditionDrawer/useDictionaryEditionDrawer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"useDictionaryEditionDrawer.d.ts","sourceRoot":"","sources":["../../../src/DictionaryEditionDrawer/useDictionaryEditionDrawer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAS3E,eAAO,MAAM,mBAAmB,iBAAkB,MAAM,WAClB,CAAC;AAEvC,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,cAAc,GAAG,MAAM,CAAC;AAE7B,MAAM,MAAM,WAAW,GAAG;IACxB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;CACrB,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAC7B,cAAc,EAAE,WAAW,GAAG,IAAI,CAAC;IACnC,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;IACrC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,qBAAqB,EAAE,CACrB,kBAAkB,EAAE,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,KACjD,IAAI,CAAC;IACV,qBAAqB,EAAE,CACrB,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,OAAO,EAAE,KACf,eAAe,GAAG,SAAS,CAAC;CAClC,CAAC;AAQF,eAAO,MAAM,0BAA0B,iBACvB,MAAM,KACnB,uBAgDF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryListDrawer.d.ts","sourceRoot":"","sources":["../../../src/DictionaryListDrawer/DictionaryListDrawer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DictionaryListDrawer.d.ts","sourceRoot":"","sources":["../../../src/DictionaryListDrawer/DictionaryListDrawer.tsx"],"names":[],"mappings":"AAYA,OAAO,EAA6C,EAAE,EAAE,MAAM,OAAO,CAAC;AAoBtE,eAAO,MAAM,oBAAoB,EAAE,EA+DlC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const dictionaryListDrawerIdentifier = "dictionaryList";
|
|
2
|
-
export declare const useDictionaryListDrawer: ()
|
|
2
|
+
export declare const useDictionaryListDrawer: import("zustand").UseBoundStore<import("zustand").StoreApi<{
|
|
3
3
|
isOpen: boolean;
|
|
4
4
|
open: () => void;
|
|
5
5
|
close: () => void;
|
|
6
|
-
}
|
|
6
|
+
}>>;
|
|
7
7
|
//# sourceMappingURL=useDictionaryListDrawer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryListDrawer.d.ts","sourceRoot":"","sources":["../../../src/DictionaryListDrawer/useDictionaryListDrawer.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,8BAA8B,mBAAmB,CAAC;AAE/D,eAAO,MAAM,uBAAuB;;;;
|
|
1
|
+
{"version":3,"file":"useDictionaryListDrawer.d.ts","sourceRoot":"","sources":["../../../src/DictionaryListDrawer/useDictionaryListDrawer.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,8BAA8B,mBAAmB,CAAC;AAE/D,eAAO,MAAM,uBAAuB;;;;GAEnC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intlayer-editor",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "IntLayer Editor is a tool that allow you to edit your IntLayer declaration files using a graphical interface.",
|
|
6
6
|
"keywords": [
|
|
@@ -73,11 +73,10 @@
|
|
|
73
73
|
"magic-regexp": "^0.8.0",
|
|
74
74
|
"react": "^18.3.1",
|
|
75
75
|
"react-dom": "^18.3.1",
|
|
76
|
-
"webpack": "^5.96.1",
|
|
77
76
|
"zustand": "^5.0.1",
|
|
78
|
-
"@intlayer/config": "^3.3.
|
|
79
|
-
"@intlayer/design-system": "^3.3.
|
|
80
|
-
"@intlayer/core": "^3.3.
|
|
77
|
+
"@intlayer/config": "^3.3.6",
|
|
78
|
+
"@intlayer/design-system": "^3.3.6",
|
|
79
|
+
"@intlayer/core": "^3.3.6"
|
|
81
80
|
},
|
|
82
81
|
"devDependencies": {
|
|
83
82
|
"@babel/generator": "7.26.2",
|
|
@@ -99,15 +98,15 @@
|
|
|
99
98
|
"tsup": "^8.3.5",
|
|
100
99
|
"typescript": "^5.7.2",
|
|
101
100
|
"@utils/eslint-config": "^1.0.4",
|
|
102
|
-
"@utils/ts-config": "^1.0.4",
|
|
103
101
|
"@utils/ts-config-types": "^1.0.4",
|
|
104
|
-
"@utils/tsup-config": "^1.0.4"
|
|
102
|
+
"@utils/tsup-config": "^1.0.4",
|
|
103
|
+
"@utils/ts-config": "^1.0.4"
|
|
105
104
|
},
|
|
106
105
|
"peerDependencies": {
|
|
107
|
-
"@intlayer/config": "^3.3.
|
|
108
|
-
"@intlayer/core": "^3.3.
|
|
109
|
-
"@intlayer/design-system": "^3.3.
|
|
110
|
-
"react-intlayer": "^3.3.
|
|
106
|
+
"@intlayer/config": "^3.3.6",
|
|
107
|
+
"@intlayer/core": "^3.3.6",
|
|
108
|
+
"@intlayer/design-system": "^3.3.6",
|
|
109
|
+
"react-intlayer": "^3.3.6"
|
|
111
110
|
},
|
|
112
111
|
"engines": {
|
|
113
112
|
"node": ">=14.18"
|
|
@@ -125,10 +124,6 @@
|
|
|
125
124
|
"lint:fix": "eslint . --cache --fix",
|
|
126
125
|
"prettier": "prettier . --check",
|
|
127
126
|
"prettier:fix": "prettier . --write",
|
|
128
|
-
"
|
|
129
|
-
"start:dev": "node --experimental-specifier-resolution=node --loader ts-node/esm --watch src/index.ts",
|
|
130
|
-
"transpile": "webpack --config ./webpack.config.ts",
|
|
131
|
-
"typecheck": "tsup --project ./tsconfig.json --noEmit",
|
|
132
|
-
"watch": "webpack --config ./webpack.config.ts --watch"
|
|
127
|
+
"typecheck": "tsup --project ./tsconfig.json --noEmit"
|
|
133
128
|
}
|
|
134
129
|
}
|