intlayer-editor 2.1.12 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -9
- package/dist/cjs/{client/ContentEditionLayout.cjs → ContentEditionLayout.cjs} +2 -2
- package/dist/cjs/ContentEditionLayout.cjs.map +1 -0
- package/dist/cjs/{client/ContentEditorProvider.cjs → ContentEditorProvider.cjs} +9 -1
- package/dist/cjs/ContentEditorProvider.cjs.map +1 -0
- package/dist/cjs/{client/ContentSelectorWrapper.cjs → ContentSelectorWrapper.cjs} +8 -10
- package/dist/cjs/ContentSelectorWrapper.cjs.map +1 -0
- package/dist/cjs/{client/DictionaryEditionDrawer → DictionaryEditionDrawer}/DictionaryEditionDrawer.cjs +47 -38
- package/dist/cjs/DictionaryEditionDrawer/DictionaryEditionDrawer.cjs.map +1 -0
- package/dist/cjs/{client/DictionaryEditionDrawer → DictionaryEditionDrawer}/index.cjs +1 -3
- package/dist/cjs/DictionaryEditionDrawer/index.cjs.map +1 -0
- package/dist/cjs/{client/DictionaryEditionDrawer → DictionaryEditionDrawer}/useDictionaryEditionDrawer.cjs +12 -9
- package/dist/cjs/DictionaryEditionDrawer/useDictionaryEditionDrawer.cjs.map +1 -0
- package/dist/cjs/{client/DictionaryListDrawer → DictionaryListDrawer}/DictionaryListDrawer.cjs +16 -23
- package/dist/cjs/DictionaryListDrawer/DictionaryListDrawer.cjs.map +1 -0
- package/dist/cjs/DictionaryListDrawer/index.cjs.map +1 -0
- package/dist/cjs/DictionaryListDrawer/useDictionaryListDrawer.cjs.map +1 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/{client/renderContentEditor.cjs → renderContentEditor.cjs} +10 -4
- package/dist/cjs/renderContentEditor.cjs.map +1 -0
- package/dist/cjs/{client/useEditorServer.cjs → useEditorServer.cjs} +4 -4
- package/dist/cjs/useEditorServer.cjs.map +1 -0
- package/dist/esm/{client/ContentEditionLayout.mjs → ContentEditionLayout.mjs} +2 -2
- package/dist/esm/ContentEditionLayout.mjs.map +1 -0
- package/dist/esm/{client/ContentEditorProvider.mjs → ContentEditorProvider.mjs} +11 -2
- package/dist/esm/ContentEditorProvider.mjs.map +1 -0
- package/dist/esm/{client/ContentSelectorWrapper.mjs → ContentSelectorWrapper.mjs} +14 -11
- package/dist/esm/ContentSelectorWrapper.mjs.map +1 -0
- package/dist/esm/{client/DictionaryEditionDrawer → DictionaryEditionDrawer}/DictionaryEditionDrawer.mjs +50 -26
- package/dist/esm/DictionaryEditionDrawer/DictionaryEditionDrawer.mjs.map +1 -0
- package/dist/esm/{client/DictionaryEditionDrawer → DictionaryEditionDrawer}/index.mjs +0 -1
- package/dist/esm/DictionaryEditionDrawer/index.mjs.map +1 -0
- package/dist/esm/{client/DictionaryEditionDrawer → DictionaryEditionDrawer}/useDictionaryEditionDrawer.mjs +10 -6
- package/dist/esm/DictionaryEditionDrawer/useDictionaryEditionDrawer.mjs.map +1 -0
- package/dist/esm/{client/DictionaryListDrawer → DictionaryListDrawer}/DictionaryListDrawer.mjs +17 -13
- package/dist/esm/DictionaryListDrawer/DictionaryListDrawer.mjs.map +1 -0
- package/dist/esm/DictionaryListDrawer/index.mjs.map +1 -0
- package/dist/esm/DictionaryListDrawer/useDictionaryListDrawer.mjs.map +1 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/{client/renderContentEditor.mjs → renderContentEditor.mjs} +10 -4
- package/dist/esm/renderContentEditor.mjs.map +1 -0
- package/dist/esm/{client/useEditorServer.mjs → useEditorServer.mjs} +3 -3
- package/dist/esm/useEditorServer.mjs.map +1 -0
- package/dist/types/ContentEditionLayout.d.ts +11 -0
- package/dist/types/ContentEditionLayout.d.ts.map +1 -0
- package/dist/types/ContentEditorProvider.d.ts +21 -0
- package/dist/types/ContentEditorProvider.d.ts.map +1 -0
- package/dist/types/ContentSelectorWrapper.d.ts +11 -0
- package/dist/types/ContentSelectorWrapper.d.ts.map +1 -0
- package/dist/types/DictionaryEditionDrawer/DictionaryEditionDrawer.d.ts +21 -0
- package/dist/types/DictionaryEditionDrawer/DictionaryEditionDrawer.d.ts.map +1 -0
- package/dist/types/DictionaryEditionDrawer/index.d.ts +3 -0
- package/dist/types/DictionaryEditionDrawer/index.d.ts.map +1 -0
- package/dist/types/DictionaryEditionDrawer/useDictionaryEditionDrawer.d.ts +31 -0
- package/dist/types/DictionaryEditionDrawer/useDictionaryEditionDrawer.d.ts.map +1 -0
- package/dist/types/DictionaryListDrawer/DictionaryListDrawer.d.ts +3 -0
- package/dist/types/DictionaryListDrawer/DictionaryListDrawer.d.ts.map +1 -0
- package/dist/types/DictionaryListDrawer/index.d.ts +3 -0
- package/dist/types/DictionaryListDrawer/index.d.ts.map +1 -0
- package/dist/types/DictionaryListDrawer/useDictionaryListDrawer.d.ts +7 -0
- package/dist/types/DictionaryListDrawer/useDictionaryListDrawer.d.ts.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/renderContentEditor.d.ts +14 -0
- package/dist/types/renderContentEditor.d.ts.map +1 -0
- package/dist/types/useEditorServer.d.ts +4 -0
- package/dist/types/useEditorServer.d.ts.map +1 -0
- package/package.json +38 -34
- package/dist/cjs/client/ContentEditionLayout.cjs.map +0 -1
- package/dist/cjs/client/ContentEditionLayout.d.ts +0 -13
- package/dist/cjs/client/ContentEditorProvider.cjs.map +0 -1
- package/dist/cjs/client/ContentEditorProvider.d.ts +0 -23
- package/dist/cjs/client/ContentSelectorWrapper.cjs.map +0 -1
- package/dist/cjs/client/ContentSelectorWrapper.d.ts +0 -12
- package/dist/cjs/client/DictionaryEditionDrawer/DictionaryEditionDrawer.cjs.map +0 -1
- package/dist/cjs/client/DictionaryEditionDrawer/DictionaryEditionDrawer.d.ts +0 -28
- package/dist/cjs/client/DictionaryEditionDrawer/index.cjs.map +0 -1
- package/dist/cjs/client/DictionaryEditionDrawer/index.d.ts +0 -9
- package/dist/cjs/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.cjs.map +0 -1
- package/dist/cjs/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.d.ts +0 -32
- package/dist/cjs/client/DictionaryEditionDrawer/useEditedContentStore.cjs +0 -98
- package/dist/cjs/client/DictionaryEditionDrawer/useEditedContentStore.cjs.map +0 -1
- package/dist/cjs/client/DictionaryEditionDrawer/useEditedContentStore.d.ts +0 -28
- package/dist/cjs/client/DictionaryEditionDrawer/useFocusContentStore.cjs +0 -33
- package/dist/cjs/client/DictionaryEditionDrawer/useFocusContentStore.cjs.map +0 -1
- package/dist/cjs/client/DictionaryEditionDrawer/useFocusContentStore.d.ts +0 -16
- package/dist/cjs/client/DictionaryListDrawer/DictionaryListDrawer.cjs.map +0 -1
- package/dist/cjs/client/DictionaryListDrawer/DictionaryListDrawer.d.ts +0 -5
- package/dist/cjs/client/DictionaryListDrawer/index.cjs.map +0 -1
- package/dist/cjs/client/DictionaryListDrawer/index.d.ts +0 -3
- package/dist/cjs/client/DictionaryListDrawer/useDictionaryListDrawer.cjs.map +0 -1
- package/dist/cjs/client/DictionaryListDrawer/useDictionaryListDrawer.d.ts +0 -8
- package/dist/cjs/client/index.cjs.map +0 -1
- package/dist/cjs/client/index.d.ts +0 -15
- package/dist/cjs/client/renderContentEditor.cjs.map +0 -1
- package/dist/cjs/client/renderContentEditor.d.ts +0 -15
- package/dist/cjs/client/useEditorServer.cjs.map +0 -1
- package/dist/cjs/client/useEditorServer.d.ts +0 -5
- package/dist/cjs/server/formatPrettier.cjs +0 -51
- package/dist/cjs/server/formatPrettier.cjs.map +0 -1
- package/dist/cjs/server/formatPrettier.d.ts +0 -6
- package/dist/cjs/server/index.cjs +0 -68
- package/dist/cjs/server/index.cjs.map +0 -1
- package/dist/cjs/server/index.d.ts +0 -3
- package/dist/cjs/server/processEdition.cjs +0 -157
- package/dist/cjs/server/processEdition.cjs.map +0 -1
- package/dist/cjs/server/processEdition.d.ts +0 -12
- package/dist/esm/client/ContentEditionLayout.d.mts +0 -13
- package/dist/esm/client/ContentEditionLayout.mjs.map +0 -1
- package/dist/esm/client/ContentEditorProvider.d.mts +0 -23
- package/dist/esm/client/ContentEditorProvider.mjs.map +0 -1
- package/dist/esm/client/ContentSelectorWrapper.d.mts +0 -12
- package/dist/esm/client/ContentSelectorWrapper.mjs.map +0 -1
- package/dist/esm/client/DictionaryEditionDrawer/DictionaryEditionDrawer.d.mts +0 -28
- package/dist/esm/client/DictionaryEditionDrawer/DictionaryEditionDrawer.mjs.map +0 -1
- package/dist/esm/client/DictionaryEditionDrawer/index.d.mts +0 -9
- package/dist/esm/client/DictionaryEditionDrawer/index.mjs.map +0 -1
- package/dist/esm/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.d.mts +0 -32
- package/dist/esm/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.mjs.map +0 -1
- package/dist/esm/client/DictionaryEditionDrawer/useEditedContentStore.d.mts +0 -28
- package/dist/esm/client/DictionaryEditionDrawer/useEditedContentStore.mjs +0 -74
- package/dist/esm/client/DictionaryEditionDrawer/useEditedContentStore.mjs.map +0 -1
- package/dist/esm/client/DictionaryEditionDrawer/useFocusContentStore.d.mts +0 -16
- package/dist/esm/client/DictionaryEditionDrawer/useFocusContentStore.mjs +0 -9
- package/dist/esm/client/DictionaryEditionDrawer/useFocusContentStore.mjs.map +0 -1
- package/dist/esm/client/DictionaryListDrawer/DictionaryListDrawer.d.mts +0 -5
- package/dist/esm/client/DictionaryListDrawer/DictionaryListDrawer.mjs.map +0 -1
- package/dist/esm/client/DictionaryListDrawer/index.d.mts +0 -3
- package/dist/esm/client/DictionaryListDrawer/index.mjs.map +0 -1
- package/dist/esm/client/DictionaryListDrawer/useDictionaryListDrawer.d.mts +0 -8
- package/dist/esm/client/DictionaryListDrawer/useDictionaryListDrawer.mjs.map +0 -1
- package/dist/esm/client/index.d.mts +0 -15
- package/dist/esm/client/index.mjs.map +0 -1
- package/dist/esm/client/renderContentEditor.d.mts +0 -15
- package/dist/esm/client/renderContentEditor.mjs.map +0 -1
- package/dist/esm/client/useEditorServer.d.mts +0 -5
- package/dist/esm/client/useEditorServer.mjs.map +0 -1
- package/dist/esm/server/formatPrettier.d.mts +0 -6
- package/dist/esm/server/formatPrettier.mjs +0 -17
- package/dist/esm/server/formatPrettier.mjs.map +0 -1
- package/dist/esm/server/index.d.mts +0 -3
- package/dist/esm/server/index.mjs +0 -34
- package/dist/esm/server/index.mjs.map +0 -1
- package/dist/esm/server/processEdition.d.mts +0 -12
- package/dist/esm/server/processEdition.mjs +0 -134
- package/dist/esm/server/processEdition.mjs.map +0 -1
- /package/dist/cjs/{client/DictionaryListDrawer → DictionaryListDrawer}/index.cjs +0 -0
- /package/dist/cjs/{client/DictionaryListDrawer → DictionaryListDrawer}/useDictionaryListDrawer.cjs +0 -0
- /package/dist/cjs/{client/index.cjs → index.cjs} +0 -0
- /package/dist/esm/{client/DictionaryListDrawer → DictionaryListDrawer}/index.mjs +0 -0
- /package/dist/esm/{client/DictionaryListDrawer → DictionaryListDrawer}/useDictionaryListDrawer.mjs +0 -0
- /package/dist/esm/{client/index.mjs → index.mjs} +0 -0
|
@@ -3,7 +3,8 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { getConfiguration } from "@intlayer/config/client";
|
|
4
4
|
import {
|
|
5
5
|
createContext,
|
|
6
|
-
useContext
|
|
6
|
+
useContext,
|
|
7
|
+
useMemo
|
|
7
8
|
} from "react";
|
|
8
9
|
const IntlayerEditorContext = createContext({
|
|
9
10
|
editorEnabled: false
|
|
@@ -15,7 +16,15 @@ const {
|
|
|
15
16
|
const IntlayerEditorProvider = ({
|
|
16
17
|
children,
|
|
17
18
|
editorEnabled = enabled
|
|
18
|
-
}) =>
|
|
19
|
+
}) => {
|
|
20
|
+
const memoValue = useMemo(
|
|
21
|
+
() => ({
|
|
22
|
+
editorEnabled
|
|
23
|
+
}),
|
|
24
|
+
[editorEnabled]
|
|
25
|
+
);
|
|
26
|
+
return /* @__PURE__ */ jsx(IntlayerEditorContext.Provider, { value: memoValue, children });
|
|
27
|
+
};
|
|
19
28
|
export {
|
|
20
29
|
IntlayerEditorContext,
|
|
21
30
|
IntlayerEditorProvider,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/client/ContentEditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration } from '@intlayer/config/client';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n type FC,\n useMemo,\n} from 'react';\n\ntype IntlayerEditorValue = {\n editorEnabled: boolean;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerEditorContext = createContext<IntlayerEditorValue>({\n editorEnabled: false,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerEditorContext = () => useContext(IntlayerEditorContext);\n\nexport type IntlayerEditorProviderProps = PropsWithChildren<{\n editorEnabled?: boolean;\n}>;\n\nconst {\n editor: { enabled },\n} = getConfiguration();\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerEditorProvider: FC<IntlayerEditorProviderProps> = ({\n children,\n editorEnabled = enabled,\n}) => {\n const memoValue = useMemo(\n () => ({\n editorEnabled,\n }),\n [editorEnabled]\n );\n\n return (\n <IntlayerEditorContext.Provider value={memoValue}>\n {children}\n </IntlayerEditorContext.Provider>\n );\n};\n"],"mappings":";AAkDI;AAhDJ,SAAS,wBAAwB;AACjC;AAAA,EAEE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AASA,MAAM,wBAAwB,cAAmC;AAAA,EACtE,eAAe;AACjB,CAAC;AAKM,MAAM,2BAA2B,MAAM,WAAW,qBAAqB;AAM9E,MAAM;AAAA,EACJ,QAAQ,EAAE,QAAQ;AACpB,IAAI,iBAAiB;AAKd,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA,gBAAgB;AAClB,MAAM;AACJ,QAAM,YAAY;AAAA,IAChB,OAAO;AAAA,MACL;AAAA,IACF;AAAA,IACA,CAAC,aAAa;AAAA,EAChB;AAEA,SACE,oBAAC,sBAAsB,UAAtB,EAA+B,OAAO,WACpC,UACH;AAEJ;","names":[]}
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { isSameKeyPath } from "@intlayer/core";
|
|
4
4
|
import { ContentSelector } from "@intlayer/design-system";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
useCallback,
|
|
7
|
+
useContext,
|
|
8
|
+
useEffect,
|
|
9
|
+
useState
|
|
10
|
+
} from "react";
|
|
6
11
|
import { IntlayerEditorContext } from './ContentEditorProvider.mjs';
|
|
7
12
|
import { useDictionaryEditionDrawer } from './DictionaryEditionDrawer/useDictionaryEditionDrawer.mjs';
|
|
8
13
|
const ContentSelectorWrapper = ({
|
|
@@ -12,8 +17,9 @@ const ContentSelectorWrapper = ({
|
|
|
12
17
|
keyPath
|
|
13
18
|
}) => {
|
|
14
19
|
const { open, getEditedContentValue, focusedContent, isOpen } = useDictionaryEditionDrawer(dictionaryId);
|
|
15
|
-
const editedValue = getEditedContentValue(
|
|
20
|
+
const editedValue = getEditedContentValue(dictionaryId, keyPath);
|
|
16
21
|
const { editorEnabled } = useContext(IntlayerEditorContext);
|
|
22
|
+
const [displayedChildren, setDisplayedChildren] = useState(children);
|
|
17
23
|
const handleSelect = useCallback(
|
|
18
24
|
() => open({
|
|
19
25
|
dictionaryId,
|
|
@@ -23,18 +29,15 @@ const ContentSelectorWrapper = ({
|
|
|
23
29
|
[dictionaryId, dictionaryPath, keyPath, open]
|
|
24
30
|
);
|
|
25
31
|
const isSelected = (isOpen && (focusedContent?.keyPath?.length ?? 0) > 0 && isSameKeyPath(focusedContent?.keyPath ?? [], keyPath)) ?? false;
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (editorEnabled && editedValue && typeof editedValue === "string") {
|
|
34
|
+
setDisplayedChildren(editedValue);
|
|
35
|
+
}
|
|
36
|
+
}, [editedValue, editorEnabled]);
|
|
26
37
|
if (!editorEnabled) {
|
|
27
38
|
return children;
|
|
28
39
|
}
|
|
29
|
-
return /* @__PURE__ */ jsx(
|
|
30
|
-
ContentSelector,
|
|
31
|
-
{
|
|
32
|
-
onSelect: handleSelect,
|
|
33
|
-
isSelecting: isSelected,
|
|
34
|
-
popoverContent: "Long press to edit",
|
|
35
|
-
children: editedValue ?? children
|
|
36
|
-
}
|
|
37
|
-
);
|
|
40
|
+
return /* @__PURE__ */ jsx(ContentSelector, { onSelect: handleSelect, isSelecting: isSelected, children: displayedChildren });
|
|
38
41
|
};
|
|
39
42
|
export {
|
|
40
43
|
ContentSelectorWrapper
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/client/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { isSameKeyPath, type KeyPath } from '@intlayer/core';\nimport { ContentSelector } from '@intlayer/design-system';\nimport {\n useCallback,\n useContext,\n useEffect,\n useState,\n type FC,\n type ReactNode,\n} from 'react';\nimport { IntlayerEditorContext } from './ContentEditorProvider';\nimport { useDictionaryEditionDrawer } from './DictionaryEditionDrawer/useDictionaryEditionDrawer';\n\ntype ContentSelectorWrapperProps = {\n children: ReactNode;\n dictionaryId: string;\n dictionaryPath: string;\n keyPath: KeyPath[];\n};\n\nexport const ContentSelectorWrapper: FC<ContentSelectorWrapperProps> = ({\n children,\n dictionaryId,\n dictionaryPath,\n keyPath,\n}) => {\n const { open, getEditedContentValue, focusedContent, isOpen } =\n useDictionaryEditionDrawer(dictionaryId);\n const editedValue = getEditedContentValue(dictionaryId, keyPath);\n const { editorEnabled } = useContext(IntlayerEditorContext);\n const [displayedChildren, setDisplayedChildren] =\n useState<ReactNode>(children);\n\n const handleSelect = useCallback(\n () =>\n open({\n dictionaryId,\n dictionaryPath,\n keyPath,\n }),\n [dictionaryId, dictionaryPath, keyPath, open]\n );\n\n const isSelected =\n (isOpen &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], keyPath)) ??\n false;\n\n useEffect(() => {\n // Use useEffect to avoid 'Text content does not match server-rendered HTML' error\n if (editorEnabled && editedValue && typeof editedValue === 'string') {\n setDisplayedChildren(editedValue);\n }\n }, [editedValue, editorEnabled]);\n\n if (!editorEnabled) {\n return children;\n }\n\n return (\n <ContentSelector onSelect={handleSelect} isSelecting={isSelected}>\n {displayedChildren}\n </ContentSelector>\n );\n};\n"],"mappings":";AA+DI;AA7DJ,SAAS,qBAAmC;AAC5C,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,6BAA6B;AACtC,SAAS,kCAAkC;AASpC,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,MAAM,uBAAuB,gBAAgB,OAAO,IAC1D,2BAA2B,YAAY;AACzC,QAAM,cAAc,sBAAsB,cAAc,OAAO;AAC/D,QAAM,EAAE,cAAc,IAAI,WAAW,qBAAqB;AAC1D,QAAM,CAAC,mBAAmB,oBAAoB,IAC5C,SAAoB,QAAQ;AAE9B,QAAM,eAAe;AAAA,IACnB,MACE,KAAK;AAAA,MACH;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,cAAc,gBAAgB,SAAS,IAAI;AAAA,EAC9C;AAEA,QAAM,cACH,WACE,gBAAgB,SAAS,UAAU,KAAK,KACzC,cAAc,gBAAgB,WAAW,CAAC,GAAG,OAAO,MACtD;AAEF,YAAU,MAAM;AAEd,QAAI,iBAAiB,eAAe,OAAO,gBAAgB,UAAU;AACnE,2BAAqB,WAAW;AAAA,IAClC;AAAA,EACF,GAAG,CAAC,aAAa,aAAa,CAAC;AAE/B,MAAI,CAAC,eAAe;AAClB,WAAO;AAAA,EACT;AAEA,SACE,oBAAC,mBAAgB,UAAU,cAAc,aAAa,YACnD,6BACH;AAEJ;","names":[]}
|
|
@@ -1,43 +1,68 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import {
|
|
4
4
|
RightDrawer,
|
|
5
5
|
DictionaryEditor,
|
|
6
|
-
LocaleSwitcher
|
|
6
|
+
LocaleSwitcher,
|
|
7
|
+
Modal,
|
|
8
|
+
useEditionPanelStore,
|
|
9
|
+
DictionaryFieldEditor
|
|
7
10
|
} from "@intlayer/design-system";
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
11
|
+
import { useGetAllDictionaries } from "@intlayer/design-system/hooks";
|
|
12
|
+
import { useEffect, useState } from "react";
|
|
13
|
+
import { useDictionaryListDrawer } from '../DictionaryListDrawer/useDictionaryListDrawer.mjs';
|
|
10
14
|
import {
|
|
11
|
-
useDictionaryEditionDrawer
|
|
15
|
+
useDictionaryEditionDrawer,
|
|
16
|
+
getDrawerIdentifier
|
|
12
17
|
} from './useDictionaryEditionDrawer.mjs';
|
|
13
|
-
|
|
14
|
-
const
|
|
18
|
+
const DictionaryEditionDrawerContent = ({ locale, identifier }) => {
|
|
19
|
+
const [keyPathEditionModal, setKeyPathEditionModal] = useState(null);
|
|
15
20
|
const {
|
|
16
21
|
setFocusedContent,
|
|
22
|
+
setDictionariesRecord,
|
|
17
23
|
editContentRequest,
|
|
18
24
|
editedContent,
|
|
25
|
+
focusedContent,
|
|
19
26
|
addEditedContent,
|
|
20
27
|
clearEditedDictionaryContent
|
|
21
28
|
} = useDictionaryEditionDrawer(identifier);
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return /* @__PURE__ */ jsx(
|
|
27
|
-
DictionaryEditor,
|
|
28
|
-
{
|
|
29
|
-
dictionary,
|
|
30
|
-
locale,
|
|
31
|
-
focusedKeyPath: focusedContent.keyPath,
|
|
32
|
-
editedContent: editedDictionaryContent,
|
|
33
|
-
onFocusKeyPath: (keyPath) => setFocusedContent({ ...focusedContent, keyPath }),
|
|
34
|
-
onContentChange: (keyPath, newValue) => addEditedContent(dictionaryPath, keyPath, newValue),
|
|
35
|
-
onValidEdition: editContentRequest,
|
|
36
|
-
onCancelEdition: () => clearEditedDictionaryContent(dictionaryPath)
|
|
29
|
+
const { all: dictionaries } = useGetAllDictionaries();
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (dictionaries) {
|
|
32
|
+
setDictionariesRecord(dictionaries);
|
|
37
33
|
}
|
|
38
|
-
);
|
|
34
|
+
}, [setDictionariesRecord, dictionaries]);
|
|
35
|
+
const dictionaryId = focusedContent?.dictionaryId;
|
|
36
|
+
if (!dictionaryId) return /* @__PURE__ */ jsx(Fragment, { children: "No dictionary focused" });
|
|
37
|
+
const dictionary = dictionaries[dictionaryId];
|
|
38
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
39
|
+
/* @__PURE__ */ jsx(
|
|
40
|
+
Modal,
|
|
41
|
+
{
|
|
42
|
+
isOpen: keyPathEditionModal !== null,
|
|
43
|
+
onClose: () => setKeyPathEditionModal(null),
|
|
44
|
+
hasCloseButton: true,
|
|
45
|
+
title: "Edit field",
|
|
46
|
+
size: "xl",
|
|
47
|
+
children: dictionary && /* @__PURE__ */ jsx(DictionaryFieldEditor, { dictionary })
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
/* @__PURE__ */ jsx(
|
|
51
|
+
DictionaryEditor,
|
|
52
|
+
{
|
|
53
|
+
dictionary,
|
|
54
|
+
locale,
|
|
55
|
+
focusedKeyPath: focusedContent.keyPath,
|
|
56
|
+
editedContent: editedContent[dictionaryId],
|
|
57
|
+
onFocusKeyPath: (keyPath) => setFocusedContent({ ...focusedContent, keyPath }),
|
|
58
|
+
onContentChange: (keyPath, newValue) => addEditedContent(dictionaryId, newValue, keyPath),
|
|
59
|
+
onValidEdition: editContentRequest,
|
|
60
|
+
onCancelEdition: () => clearEditedDictionaryContent(dictionaryId),
|
|
61
|
+
onClickEdit: setKeyPathEditionModal
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
] });
|
|
39
65
|
};
|
|
40
|
-
const getDrawerIdentifier = (dictionaryId) => `dictionary_edition_${dictionaryId}`;
|
|
41
66
|
const DictionaryEditionDrawer = ({
|
|
42
67
|
locale,
|
|
43
68
|
localeList,
|
|
@@ -98,7 +123,6 @@ const DictionaryEditionDrawerController = ({ locale, localeList, setLocale }) =>
|
|
|
98
123
|
export {
|
|
99
124
|
DictionaryEditionDrawer,
|
|
100
125
|
DictionaryEditionDrawerContent,
|
|
101
|
-
DictionaryEditionDrawerController
|
|
102
|
-
getDrawerIdentifier
|
|
126
|
+
DictionaryEditionDrawerController
|
|
103
127
|
};
|
|
104
128
|
//# sourceMappingURL=DictionaryEditionDrawer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/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 { 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};\n\nexport const DictionaryEditionDrawerContent: FC<\n DictionaryEditionDrawerContentProps\n> = ({ locale, identifier }) => {\n const [keyPathEditionModal, setKeyPathEditionModal] = useState<\n KeyPath[] | null\n >(null);\n const {\n setFocusedContent,\n setDictionariesRecord,\n editContentRequest,\n editedContent,\n focusedContent,\n addEditedContent,\n clearEditedDictionaryContent,\n } = useDictionaryEditionDrawer(identifier);\n const { all: dictionaries } = useGetAllDictionaries();\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 >\n {dictionary && <DictionaryFieldEditor dictionary={dictionary} />}\n </Modal>\n <DictionaryEditor\n dictionary={dictionary}\n locale={locale}\n focusedKeyPath={focusedContent.keyPath}\n editedContent={editedContent[dictionaryId]}\n onFocusKeyPath={(keyPath) =>\n setFocusedContent({ ...focusedContent, keyPath })\n }\n onContentChange={(keyPath, newValue) =>\n addEditedContent(dictionaryId, newValue, keyPath)\n }\n onValidEdition={editContentRequest}\n onCancelEdition={() => clearEditedDictionaryContent(dictionaryId)}\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 />\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":";AAoD4B,wBAKxB,YALwB;AAhD5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAA6B;AACtC,SAAS,WAAW,gBAAyB;AAC7C,SAAS,+BAA+B;AACxC;AAAA,EAEE;AAAA,EACA;AAAA,OACK;AAQA,MAAM,iCAET,CAAC,EAAE,QAAQ,WAAW,MAAM;AAC9B,QAAM,CAAC,qBAAqB,sBAAsB,IAAI,SAEpD,IAAI;AACN,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,2BAA2B,UAAU;AACzC,QAAM,EAAE,KAAK,aAAa,IAAI,sBAAsB;AAEpD,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,QAEJ,wBAAc,oBAAC,yBAAsB,YAAwB;AAAA;AAAA,IAChE;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA,gBAAgB,eAAe;AAAA,QAC/B,eAAe,cAAc,YAAY;AAAA,QACzC,gBAAgB,CAAC,YACf,kBAAkB,EAAE,GAAG,gBAAgB,QAAQ,CAAC;AAAA,QAElD,iBAAiB,CAAC,SAAS,aACzB,iBAAiB,cAAc,UAAU,OAAO;AAAA,QAElD,gBAAgB;AAAA,QAChB,iBAAiB,MAAM,6BAA6B,YAAY;AAAA,QAChE,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;AAAA,MACd;AAAA;AAAA,EAEJ;AAEJ;AAQO,MAAM,oCAET,CAAC,EAAE,QAAQ,YAAY,UAAU,MAAM;AACzC,QAAM,iBAAiB,qBAAqB,CAAC,MAAM,EAAE,cAAc;AACnE,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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/DictionaryEditionDrawer/index.ts"],"sourcesContent":["export * from './DictionaryEditionDrawer';\nexport * from './useDictionaryEditionDrawer';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import { useRightDrawerStore } from "@intlayer/design-system";
|
|
2
|
-
import { useEditorServer } from '../useEditorServer.mjs';
|
|
3
|
-
import { getDrawerIdentifier } from './DictionaryEditionDrawer.mjs';
|
|
4
1
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
useRightDrawerStore,
|
|
3
|
+
useEditedContentStore,
|
|
4
|
+
useEditionPanelStore
|
|
5
|
+
} from "@intlayer/design-system";
|
|
6
|
+
import { useEditorServer } from '../useEditorServer.mjs';
|
|
7
|
+
const getDrawerIdentifier = (dictionaryId) => `dictionary_edition_${dictionaryId}`;
|
|
8
8
|
const useDictionaryEditionDrawer = (dictionaryId) => {
|
|
9
9
|
const id = getDrawerIdentifier(dictionaryId);
|
|
10
10
|
const { isOpen, open, close } = useRightDrawerStore(id)();
|
|
11
11
|
const {
|
|
12
12
|
editedContent,
|
|
13
|
+
setDictionariesRecord,
|
|
13
14
|
getEditedContentValue,
|
|
14
15
|
addEditedContent,
|
|
15
16
|
clearEditedDictionaryContent
|
|
16
17
|
} = useEditedContentStore((s) => ({
|
|
17
18
|
editedContent: s.editedContent,
|
|
19
|
+
setDictionariesRecord: s.setDictionariesRecord,
|
|
18
20
|
addEditedContent: s.addEditedContent,
|
|
19
21
|
getEditedContentValue: s.getEditedContentValue,
|
|
20
22
|
clearEditedDictionaryContent: s.clearEditedDictionaryContent
|
|
@@ -40,6 +42,7 @@ const useDictionaryEditionDrawer = (dictionaryId) => {
|
|
|
40
42
|
isOpen,
|
|
41
43
|
focusedContent,
|
|
42
44
|
setFocusedContent,
|
|
45
|
+
setDictionariesRecord,
|
|
43
46
|
open: openDictionaryEditionDrawer,
|
|
44
47
|
close,
|
|
45
48
|
getEditedContentValue,
|
|
@@ -74,6 +77,7 @@ const useDictionaryEditionDrawerControl = () => {
|
|
|
74
77
|
};
|
|
75
78
|
};
|
|
76
79
|
export {
|
|
80
|
+
getDrawerIdentifier,
|
|
77
81
|
useDictionaryEditionDrawer,
|
|
78
82
|
useDictionaryEditionDrawerControl
|
|
79
83
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.ts"],"sourcesContent":["import type { Dictionary, DictionaryValue, KeyPath } from '@intlayer/core';\nimport {\n useRightDrawerStore,\n useEditedContentStore,\n useEditionPanelStore,\n type DictionaryContent,\n} from '@intlayer/design-system';\nimport { useEditorServer } from '../useEditorServer';\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 setFocusedContent: (content: FileContent | null) => void;\n isOpen: boolean;\n open: (content: FileContent) => void;\n close: () => void;\n editContentRequest: () => Promise<void>;\n editedContent: DictionaryContent;\n addEditedContent: (\n dictionaryId: DictionaryId,\n newValue: DictionaryValue,\n keyPath: KeyPath[]\n ) => void;\n setDictionariesRecord: (\n dictionariesRecord: Record<DictionaryId, Dictionary>\n ) => void;\n getEditedContentValue: (\n dictionaryId: DictionaryId,\n keyPath: KeyPath[]\n ) => DictionaryValue | undefined;\n clearEditedDictionaryContent: (dictionaryPath: DictionaryPath) => void;\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 {\n editedContent,\n setDictionariesRecord,\n getEditedContentValue,\n addEditedContent,\n clearEditedDictionaryContent,\n } = useEditedContentStore((s) => ({\n editedContent: s.editedContent,\n setDictionariesRecord: s.setDictionariesRecord,\n addEditedContent: s.addEditedContent,\n getEditedContentValue: s.getEditedContentValue,\n clearEditedDictionaryContent: s.clearEditedDictionaryContent,\n }));\n const { setFocusedContent, focusedContent } = useEditionPanelStore((s) => ({\n focusedContent: s.focusedContent,\n setFocusedContent: s.setFocusedContent,\n }));\n const { editContentRequest } = useEditorServer();\n\n const openDictionaryEditionDrawer = ({\n dictionaryId,\n dictionaryPath,\n keyPath = [],\n }: OpenDictionaryEditionDrawerProps) => {\n setFocusedContent({\n dictionaryId,\n dictionaryPath,\n keyPath,\n });\n\n open();\n };\n\n return {\n isOpen,\n focusedContent,\n setFocusedContent,\n setDictionariesRecord,\n open: openDictionaryEditionDrawer,\n close,\n getEditedContentValue,\n editContentRequest,\n editedContent,\n addEditedContent,\n clearEditedDictionaryContent,\n };\n};\n\ntype DictionaryEditionDrawerControl = {\n open: (content: FileContent) => void;\n close: (dictionaryId: string) => void;\n};\n\nexport const useDictionaryEditionDrawerControl =\n (): DictionaryEditionDrawerControl => {\n const setFocusedContent = useEditionPanelStore((s) => s.setFocusedContent);\n\n const open = ({\n dictionaryId,\n dictionaryPath,\n keyPath = [],\n }: OpenDictionaryEditionDrawerProps) => {\n setFocusedContent({\n dictionaryId,\n dictionaryPath,\n keyPath,\n });\n\n const id = getDrawerIdentifier(dictionaryId);\n\n useRightDrawerStore(id).getState().open();\n };\n\n const close = (dictionaryId: string) => {\n const id = getDrawerIdentifier(dictionaryId);\n\n useRightDrawerStore(id).getState().close();\n };\n\n return {\n open,\n close,\n };\n };\n"],"mappings":"AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,uBAAuB;AAEzB,MAAM,sBAAsB,CAAC,iBAClC,sBAAsB,YAAY;AAwC7B,MAAM,6BAA6B,CACxC,iBAC4B;AAC5B,QAAM,KAAK,oBAAoB,YAAY;AAC3C,QAAM,EAAE,QAAQ,MAAM,MAAM,IAAI,oBAAoB,EAAE,EAAE;AACxD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,sBAAsB,CAAC,OAAO;AAAA,IAChC,eAAe,EAAE;AAAA,IACjB,uBAAuB,EAAE;AAAA,IACzB,kBAAkB,EAAE;AAAA,IACpB,uBAAuB,EAAE;AAAA,IACzB,8BAA8B,EAAE;AAAA,EAClC,EAAE;AACF,QAAM,EAAE,mBAAmB,eAAe,IAAI,qBAAqB,CAAC,OAAO;AAAA,IACzE,gBAAgB,EAAE;AAAA,IAClB,mBAAmB,EAAE;AAAA,EACvB,EAAE;AACF,QAAM,EAAE,mBAAmB,IAAI,gBAAgB;AAE/C,QAAM,8BAA8B,CAAC;AAAA,IACnC,cAAAA;AAAA,IACA;AAAA,IACA,UAAU,CAAC;AAAA,EACb,MAAwC;AACtC,sBAAkB;AAAA,MAChB,cAAAA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,SAAK;AAAA,EACP;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAOO,MAAM,oCACX,MAAsC;AACpC,QAAM,oBAAoB,qBAAqB,CAAC,MAAM,EAAE,iBAAiB;AAEzE,QAAM,OAAO,CAAC;AAAA,IACZ;AAAA,IACA;AAAA,IACA,UAAU,CAAC;AAAA,EACb,MAAwC;AACtC,sBAAkB;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,UAAM,KAAK,oBAAoB,YAAY;AAE3C,wBAAoB,EAAE,EAAE,SAAS,EAAE,KAAK;AAAA,EAC1C;AAEA,QAAM,QAAQ,CAAC,iBAAyB;AACtC,UAAM,KAAK,oBAAoB,YAAY;AAE3C,wBAAoB,EAAE,EAAE,SAAS,EAAE,MAAM;AAAA,EAC3C;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":["dictionaryId"]}
|
package/dist/esm/{client/DictionaryListDrawer → DictionaryListDrawer}/DictionaryListDrawer.mjs
RENAMED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { RightDrawer, RedirectionButton } from "@intlayer/design-system";
|
|
3
|
-
import dictionaries from "@intlayer/dictionaries-entry";
|
|
4
2
|
import {
|
|
5
|
-
|
|
3
|
+
RightDrawer,
|
|
4
|
+
Button,
|
|
6
5
|
useEditedContentStore
|
|
7
|
-
} from
|
|
6
|
+
} from "@intlayer/design-system";
|
|
7
|
+
import { useGetAllDictionaries } from "@intlayer/design-system/hooks";
|
|
8
|
+
import { ChevronRight } from "lucide-react";
|
|
9
|
+
import { useDictionaryEditionDrawerControl } from '../DictionaryEditionDrawer/index.mjs';
|
|
8
10
|
import {
|
|
9
11
|
dictionaryListDrawerIdentifier,
|
|
10
12
|
useDictionaryListDrawer
|
|
11
13
|
} from './useDictionaryListDrawer.mjs';
|
|
12
14
|
const DictionaryListDrawer = () => {
|
|
15
|
+
const { all: dictionaries } = useGetAllDictionaries();
|
|
13
16
|
const dictionaryKeyList = Object.keys(dictionaries);
|
|
14
17
|
const { open: openDictionaryEditionDrawer } = useDictionaryEditionDrawerControl();
|
|
15
18
|
const { close } = useDictionaryListDrawer();
|
|
@@ -19,24 +22,25 @@ const DictionaryListDrawer = () => {
|
|
|
19
22
|
close();
|
|
20
23
|
openDictionaryEditionDrawer({ dictionaryId, dictionaryPath: filePath });
|
|
21
24
|
};
|
|
22
|
-
const isDictionaryEdited = (dictionaryId) =>
|
|
23
|
-
const dictionaryPath = dictionaries[dictionaryId].filePath;
|
|
24
|
-
return Object.keys(editedContent).includes(dictionaryPath);
|
|
25
|
-
};
|
|
25
|
+
const isDictionaryEdited = (dictionaryId) => Object.keys(editedContent).includes(dictionaryId);
|
|
26
26
|
return /* @__PURE__ */ jsx(
|
|
27
27
|
RightDrawer,
|
|
28
28
|
{
|
|
29
29
|
title: "Dictionary list",
|
|
30
30
|
identifier: dictionaryListDrawerIdentifier,
|
|
31
|
-
children: dictionaryKeyList.map((dictionaryId) => /* @__PURE__ */ jsx(
|
|
32
|
-
|
|
31
|
+
children: dictionaryKeyList.map((dictionaryId) => /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
32
|
+
Button,
|
|
33
33
|
{
|
|
34
34
|
label: `Open dictionary editor ${dictionaryId}`,
|
|
35
35
|
onClick: () => handleClickDictionary(dictionaryId),
|
|
36
|
+
variant: "hoverable",
|
|
37
|
+
color: "text",
|
|
38
|
+
IconRight: ChevronRight,
|
|
39
|
+
size: "md",
|
|
40
|
+
isFullWidth: true,
|
|
36
41
|
children: isDictionaryEdited(dictionaryId) ? `\u270E ${dictionaryId}` : dictionaryId
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
))
|
|
42
|
+
}
|
|
43
|
+
) }, dictionaryId))
|
|
40
44
|
}
|
|
41
45
|
);
|
|
42
46
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/DictionaryListDrawer/DictionaryListDrawer.tsx"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport {\n RightDrawer,\n Button,\n useEditedContentStore,\n} from '@intlayer/design-system';\nimport { useGetAllDictionaries } from '@intlayer/design-system/hooks';\nimport { ChevronRight } from 'lucide-react';\nimport type { FC } from 'react';\nimport { useDictionaryEditionDrawerControl } from '../DictionaryEditionDrawer/index';\nimport {\n dictionaryListDrawerIdentifier,\n useDictionaryListDrawer,\n} from './useDictionaryListDrawer';\n\nexport const DictionaryListDrawer: FC = () => {\n const { all: dictionaries } = useGetAllDictionaries();\n const dictionaryKeyList = Object.keys(dictionaries) as Locales[];\n const { open: openDictionaryEditionDrawer } =\n useDictionaryEditionDrawerControl();\n const { close } = useDictionaryListDrawer();\n const editedContent = useEditedContentStore((s) => s.editedContent);\n\n const handleClickDictionary = (dictionaryId: string) => {\n const { filePath } = dictionaries[dictionaryId];\n\n close();\n openDictionaryEditionDrawer({ dictionaryId, dictionaryPath: filePath });\n };\n\n const isDictionaryEdited = (dictionaryId: string) =>\n Object.keys(editedContent).includes(dictionaryId);\n\n return (\n <RightDrawer\n title=\"Dictionary list\"\n identifier={dictionaryListDrawerIdentifier}\n >\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"],"mappings":"AAwCU;AAvCV;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAA6B;AACtC,SAAS,oBAAoB;AAE7B,SAAS,yCAAyC;AAClD;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEA,MAAM,uBAA2B,MAAM;AAC5C,QAAM,EAAE,KAAK,aAAa,IAAI,sBAAsB;AACpD,QAAM,oBAAoB,OAAO,KAAK,YAAY;AAClD,QAAM,EAAE,MAAM,4BAA4B,IACxC,kCAAkC;AACpC,QAAM,EAAE,MAAM,IAAI,wBAAwB;AAC1C,QAAM,gBAAgB,sBAAsB,CAAC,MAAM,EAAE,aAAa;AAElE,QAAM,wBAAwB,CAAC,iBAAyB;AACtD,UAAM,EAAE,SAAS,IAAI,aAAa,YAAY;AAE9C,UAAM;AACN,gCAA4B,EAAE,cAAc,gBAAgB,SAAS,CAAC;AAAA,EACxE;AAEA,QAAM,qBAAqB,CAAC,iBAC1B,OAAO,KAAK,aAAa,EAAE,SAAS,YAAY;AAElD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAM;AAAA,MACN,YAAY;AAAA,MAEX,4BAAkB,IAAI,CAAC,iBACtB,oBAAC,SACC;AAAA,QAAC;AAAA;AAAA,UACC,OAAO,0BAA0B,YAAY;AAAA,UAC7C,SAAS,MAAM,sBAAsB,YAAY;AAAA,UACjD,SAAQ;AAAA,UACR,OAAM;AAAA,UACN,WAAW;AAAA,UACX,MAAK;AAAA,UACL,aAAW;AAAA,UAEV,6BAAmB,YAAY,IAC5B,UAAK,YAAY,KACjB;AAAA;AAAA,MACN,KAbQ,YAcV,CACD;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/DictionaryListDrawer/index.ts"],"sourcesContent":["export * from './DictionaryListDrawer';\nexport * from './useDictionaryListDrawer';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/DictionaryListDrawer/useDictionaryListDrawer.ts"],"sourcesContent":["import { useRightDrawerStore } from '@intlayer/design-system';\n\nexport const dictionaryListDrawerIdentifier = 'dictionaryList';\n\nexport const useDictionaryListDrawer = () =>\n useRightDrawerStore(dictionaryListDrawerIdentifier)();\n"],"mappings":"AAAA,SAAS,2BAA2B;AAE7B,MAAM,iCAAiC;AAEvC,MAAM,0BAA0B,MACrC,oBAAoB,8BAA8B,EAAE;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/client/index.ts"],"sourcesContent":["export * from './DictionaryEditionDrawer/index';\nexport * from './DictionaryListDrawer/index';\nexport * from './ContentEditionLayout';\nexport * from './useEditorServer';\nexport * from './renderContentEditor';\nexport * from './ContentEditorProvider';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -6,16 +6,22 @@ const {
|
|
|
6
6
|
} = getConfiguration();
|
|
7
7
|
const IntlayerEditorElement = ({
|
|
8
8
|
content,
|
|
9
|
+
isContentSelectable,
|
|
9
10
|
...props
|
|
10
11
|
}) => {
|
|
11
|
-
if (enabled) {
|
|
12
|
+
if (enabled && isContentSelectable) {
|
|
12
13
|
return /* @__PURE__ */ jsx(ContentSelectorWrapper, { ...props, children: content });
|
|
13
14
|
}
|
|
14
15
|
return content;
|
|
15
16
|
};
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
17
|
+
const renderIntlayerEditor = (data, isContentSelectable) => {
|
|
18
|
+
const Result = /* @__PURE__ */ jsx(
|
|
19
|
+
IntlayerEditorElement,
|
|
20
|
+
{
|
|
21
|
+
...data,
|
|
22
|
+
isContentSelectable
|
|
23
|
+
}
|
|
24
|
+
);
|
|
19
25
|
return { ...Result, value: data.content };
|
|
20
26
|
};
|
|
21
27
|
export {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/client/renderContentEditor.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport type { KeyPath } from '@intlayer/core';\nimport type { FC, ReactNode } from 'react';\nimport { ContentSelectorWrapper } from './ContentSelectorWrapper';\n\nconst {\n editor: { enabled },\n} = getConfiguration();\n\nexport type IntlayerEditorElementProps = {\n content: string;\n dictionaryId: string;\n dictionaryPath: string;\n keyPath: KeyPath[];\n isContentSelectable: boolean;\n};\n\nconst IntlayerEditorElement: FC<IntlayerEditorElementProps> = ({\n content,\n isContentSelectable,\n ...props\n}) => {\n if (enabled && isContentSelectable) {\n return (\n <ContentSelectorWrapper {...props}>{content}</ContentSelectorWrapper>\n );\n }\n return content;\n};\n\nexport type RenderIntlayerEditorResult = ReactNode & { value: string };\n\nexport const renderIntlayerEditor = (\n data: IntlayerEditorElementProps,\n isContentSelectable: boolean\n): RenderIntlayerEditorResult => {\n const Result = (\n <IntlayerEditorElement\n {...data}\n isContentSelectable={isContentSelectable}\n />\n );\n\n return { ...Result, value: data.content };\n};\n"],"mappings":"AAwBM;AAxBN,SAAS,wBAAwB;AAGjC,SAAS,8BAA8B;AAEvC,MAAM;AAAA,EACJ,QAAQ,EAAE,QAAQ;AACpB,IAAI,iBAAiB;AAUrB,MAAM,wBAAwD,CAAC;AAAA,EAC7D;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,MAAI,WAAW,qBAAqB;AAClC,WACE,oBAAC,0BAAwB,GAAG,OAAQ,mBAAQ;AAAA,EAEhD;AACA,SAAO;AACT;AAIO,MAAM,uBAAuB,CAClC,MACA,wBAC+B;AAC/B,QAAM,SACJ;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA;AAAA,EACF;AAGF,SAAO,EAAE,GAAG,QAAQ,OAAO,KAAK,QAAQ;AAC1C;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getConfiguration } from "@intlayer/config/client";
|
|
2
|
-
import { useEditedContentStore } from
|
|
2
|
+
import { useEditedContentStore } from "@intlayer/design-system";
|
|
3
3
|
const useEditorServer = () => {
|
|
4
4
|
const { editedContent, clearEditedContent } = useEditedContentStore((s) => ({
|
|
5
5
|
editedContent: s.editedContent,
|
|
@@ -7,9 +7,9 @@ const useEditorServer = () => {
|
|
|
7
7
|
}));
|
|
8
8
|
const editContentRequest = async () => {
|
|
9
9
|
const {
|
|
10
|
-
editor: {
|
|
10
|
+
editor: { backendURL }
|
|
11
11
|
} = getConfiguration();
|
|
12
|
-
await fetch(
|
|
12
|
+
await fetch(backendURL, {
|
|
13
13
|
method: "POST",
|
|
14
14
|
headers: {
|
|
15
15
|
"Content-Type": "application/json"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/client/useEditorServer.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport { useEditedContentStore } from '@intlayer/design-system';\n\nexport const useEditorServer = () => {\n const { editedContent, clearEditedContent } = useEditedContentStore((s) => ({\n editedContent: s.editedContent,\n clearEditedContent: s.clearEditedContent,\n }));\n\n const editContentRequest = async () => {\n const {\n editor: { backendURL },\n } = getConfiguration();\n\n await fetch(backendURL, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(editedContent),\n })\n .then((response) => {\n if (!response.ok) {\n throw new Error('Failed to edit content');\n }\n clearEditedContent();\n })\n .catch((error) => {\n console.error('Failed to edit content:', error);\n });\n };\n\n return { editContentRequest };\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AACjC,SAAS,6BAA6B;AAE/B,MAAM,kBAAkB,MAAM;AACnC,QAAM,EAAE,eAAe,mBAAmB,IAAI,sBAAsB,CAAC,OAAO;AAAA,IAC1E,eAAe,EAAE;AAAA,IACjB,oBAAoB,EAAE;AAAA,EACxB,EAAE;AAEF,QAAM,qBAAqB,YAAY;AACrC,UAAM;AAAA,MACJ,QAAQ,EAAE,WAAW;AAAA,IACvB,IAAI,iBAAiB;AAErB,UAAM,MAAM,YAAY;AAAA,MACtB,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM,KAAK,UAAU,aAAa;AAAA,IACpC,CAAC,EACE,KAAK,CAAC,aAAa;AAClB,UAAI,CAAC,SAAS,IAAI;AAChB,cAAM,IAAI,MAAM,wBAAwB;AAAA,MAC1C;AACA,yBAAmB;AAAA,IACrB,CAAC,EACA,MAAM,CAAC,UAAU;AAChB,cAAQ,MAAM,2BAA2B,KAAK;AAAA,IAChD,CAAC;AAAA,EACL;AAEA,SAAO,EAAE,mBAAmB;AAC9B;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Locales } from '@intlayer/config/client';
|
|
2
|
+
import type { FC, ReactNode } from 'react';
|
|
3
|
+
export type ContentEditionLayoutProps = {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
locale: Locales;
|
|
6
|
+
localeList: Locales[];
|
|
7
|
+
setLocale: (locale: Locales) => void;
|
|
8
|
+
editorEnabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const ContentEditionLayout: FC<ContentEditionLayoutProps>;
|
|
11
|
+
//# sourceMappingURL=ContentEditionLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentEditionLayout.d.ts","sourceRoot":"","sources":["../../src/client/ContentEditionLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAK3C,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,EAAE,CAAC;IACtB,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,EAAE,CAAC,yBAAyB,CAuB9D,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type PropsWithChildren, type FC } from 'react';
|
|
2
|
+
type IntlayerEditorValue = {
|
|
3
|
+
editorEnabled: boolean;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Context that store the current locale on the client side
|
|
7
|
+
*/
|
|
8
|
+
export declare const IntlayerEditorContext: import("react").Context<IntlayerEditorValue>;
|
|
9
|
+
/**
|
|
10
|
+
* Hook that provides the current locale
|
|
11
|
+
*/
|
|
12
|
+
export declare const useIntlayerEditorContext: () => IntlayerEditorValue;
|
|
13
|
+
export type IntlayerEditorProviderProps = PropsWithChildren<{
|
|
14
|
+
editorEnabled?: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* Provider that store the current locale on the client side
|
|
18
|
+
*/
|
|
19
|
+
export declare const IntlayerEditorProvider: FC<IntlayerEditorProviderProps>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=ContentEditorProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentEditorProvider.d.ts","sourceRoot":"","sources":["../../src/client/ContentEditorProvider.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,iBAAiB,EAGtB,KAAK,EAAE,EAER,MAAM,OAAO,CAAC;AAEf,KAAK,mBAAmB,GAAG;IACzB,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,8CAEhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,wBAAwB,2BAA0C,CAAC;AAEhF,MAAM,MAAM,2BAA2B,GAAG,iBAAiB,CAAC;IAC1D,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC,CAAC;AAMH;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CAgBlE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type KeyPath } from '@intlayer/core';
|
|
2
|
+
import { type FC, type ReactNode } from 'react';
|
|
3
|
+
type ContentSelectorWrapperProps = {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
dictionaryId: string;
|
|
6
|
+
dictionaryPath: string;
|
|
7
|
+
keyPath: KeyPath[];
|
|
8
|
+
};
|
|
9
|
+
export declare const ContentSelectorWrapper: FC<ContentSelectorWrapperProps>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=ContentSelectorWrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentSelectorWrapper.d.ts","sourceRoot":"","sources":["../../src/client/ContentSelectorWrapper.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,EAKL,KAAK,EAAE,EACP,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAIf,KAAK,2BAA2B,GAAG;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CA6ClE,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Locales } from '@intlayer/config/client';
|
|
2
|
+
import { type FC } from 'react';
|
|
3
|
+
import { type FileContent as FileContentWithDictionaryPath } from './useDictionaryEditionDrawer';
|
|
4
|
+
type DictionaryEditionDrawerContentProps = {
|
|
5
|
+
focusedContent: FileContentWithDictionaryPath;
|
|
6
|
+
locale: Locales;
|
|
7
|
+
identifier: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const DictionaryEditionDrawerContent: FC<DictionaryEditionDrawerContentProps>;
|
|
10
|
+
type DictionaryEditionDrawerProps = DictionaryEditionDrawerControllerProps & {
|
|
11
|
+
dictionaryId: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const DictionaryEditionDrawer: FC<DictionaryEditionDrawerProps>;
|
|
14
|
+
type DictionaryEditionDrawerControllerProps = {
|
|
15
|
+
locale: Locales;
|
|
16
|
+
localeList: Locales[];
|
|
17
|
+
setLocale: (locale: Locales) => void;
|
|
18
|
+
};
|
|
19
|
+
export declare const DictionaryEditionDrawerController: FC<DictionaryEditionDrawerControllerProps>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=DictionaryEditionDrawer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DictionaryEditionDrawer.d.ts","sourceRoot":"","sources":["../../../src/client/DictionaryEditionDrawer/DictionaryEditionDrawer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAWvD,OAAO,EAAuB,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAErD,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;CACpB,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,EAAE,CAC7C,mCAAmC,CAwDpC,CAAC;AAEF,KAAK,4BAA4B,GAAG,sCAAsC,GAAG;IAC3E,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,4BAA4B,CAyCpE,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,CAiBvC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/DictionaryEditionDrawer/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Dictionary, DictionaryValue, KeyPath } from '@intlayer/core';
|
|
2
|
+
import { type DictionaryContent } from '@intlayer/design-system';
|
|
3
|
+
export declare const getDrawerIdentifier: (dictionaryId: string) => string;
|
|
4
|
+
type DictionaryId = string;
|
|
5
|
+
type DictionaryPath = string;
|
|
6
|
+
export type FileContent = {
|
|
7
|
+
dictionaryPath?: DictionaryPath;
|
|
8
|
+
dictionaryId: string;
|
|
9
|
+
keyPath?: KeyPath[];
|
|
10
|
+
};
|
|
11
|
+
type DictionaryEditionDrawer = {
|
|
12
|
+
focusedContent: FileContent | null;
|
|
13
|
+
setFocusedContent: (content: FileContent | null) => void;
|
|
14
|
+
isOpen: boolean;
|
|
15
|
+
open: (content: FileContent) => void;
|
|
16
|
+
close: () => void;
|
|
17
|
+
editContentRequest: () => Promise<void>;
|
|
18
|
+
editedContent: DictionaryContent;
|
|
19
|
+
addEditedContent: (dictionaryId: DictionaryId, newValue: DictionaryValue, keyPath: KeyPath[]) => void;
|
|
20
|
+
setDictionariesRecord: (dictionariesRecord: Record<DictionaryId, Dictionary>) => void;
|
|
21
|
+
getEditedContentValue: (dictionaryId: DictionaryId, keyPath: KeyPath[]) => DictionaryValue | undefined;
|
|
22
|
+
clearEditedDictionaryContent: (dictionaryPath: DictionaryPath) => void;
|
|
23
|
+
};
|
|
24
|
+
export declare const useDictionaryEditionDrawer: (dictionaryId: string) => DictionaryEditionDrawer;
|
|
25
|
+
type DictionaryEditionDrawerControl = {
|
|
26
|
+
open: (content: FileContent) => void;
|
|
27
|
+
close: (dictionaryId: string) => void;
|
|
28
|
+
};
|
|
29
|
+
export declare const useDictionaryEditionDrawerControl: () => DictionaryEditionDrawerControl;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=useDictionaryEditionDrawer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDictionaryEditionDrawer.d.ts","sourceRoot":"","sources":["../../../src/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAC;AAGjC,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,iBAAiB,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IACzD,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;IACrC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,kBAAkB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,aAAa,EAAE,iBAAiB,CAAC;IACjC,gBAAgB,EAAE,CAChB,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,OAAO,EAAE,KACf,IAAI,CAAC;IACV,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;IACjC,4BAA4B,EAAE,CAAC,cAAc,EAAE,cAAc,KAAK,IAAI,CAAC;CACxE,CAAC;AAQF,eAAO,MAAM,0BAA0B,iBACvB,MAAM,KACnB,uBAiDF,CAAC;AAEF,KAAK,8BAA8B,GAAG;IACpC,IAAI,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;IACrC,KAAK,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC,CAAC;AAEF,eAAO,MAAM,iCAAiC,QACxC,8BA6BH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DictionaryListDrawer.d.ts","sourceRoot":"","sources":["../../../src/client/DictionaryListDrawer/DictionaryListDrawer.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAOhC,eAAO,MAAM,oBAAoB,EAAE,EA0ClC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/DictionaryListDrawer/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDictionaryListDrawer.d.ts","sourceRoot":"","sources":["../../../src/client/DictionaryListDrawer/useDictionaryListDrawer.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,8BAA8B,mBAAmB,CAAC;AAE/D,eAAO,MAAM,uBAAuB;;;;CACmB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './DictionaryEditionDrawer/index';
|
|
2
|
+
export * from './DictionaryListDrawer/index';
|
|
3
|
+
export * from './ContentEditionLayout';
|
|
4
|
+
export * from './useEditorServer';
|
|
5
|
+
export * from './renderContentEditor';
|
|
6
|
+
export * from './ContentEditorProvider';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { KeyPath } from '@intlayer/core';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
export type IntlayerEditorElementProps = {
|
|
4
|
+
content: string;
|
|
5
|
+
dictionaryId: string;
|
|
6
|
+
dictionaryPath: string;
|
|
7
|
+
keyPath: KeyPath[];
|
|
8
|
+
isContentSelectable: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type RenderIntlayerEditorResult = ReactNode & {
|
|
11
|
+
value: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const renderIntlayerEditor: (data: IntlayerEditorElementProps, isContentSelectable: boolean) => RenderIntlayerEditorResult;
|
|
14
|
+
//# sourceMappingURL=renderContentEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderContentEditor.d.ts","sourceRoot":"","sources":["../../src/client/renderContentEditor.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAM,SAAS,EAAE,MAAM,OAAO,CAAC;AAO3C,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC;AAeF,MAAM,MAAM,0BAA0B,GAAG,SAAS,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvE,eAAO,MAAM,oBAAoB,SACzB,0BAA0B,uBACX,OAAO,KAC3B,0BASF,CAAC"}
|