intlayer-editor 3.5.0 → 3.5.1

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.
Files changed (65) hide show
  1. package/dist/cjs/ContentSelectorWrapper.cjs +67 -0
  2. package/dist/cjs/ContentSelectorWrapper.cjs.map +1 -0
  3. package/dist/cjs/DictionaryEditionDrawer/DictionaryEditionDrawer.cjs +156 -0
  4. package/dist/cjs/DictionaryEditionDrawer/DictionaryEditionDrawer.cjs.map +1 -0
  5. package/dist/cjs/DictionaryEditionDrawer/index.cjs +25 -0
  6. package/dist/cjs/DictionaryEditionDrawer/index.cjs.map +1 -0
  7. package/dist/cjs/DictionaryEditionDrawer/useDictionaryEditionDrawer.cjs +79 -0
  8. package/dist/cjs/DictionaryEditionDrawer/useDictionaryEditionDrawer.cjs.map +1 -0
  9. package/dist/cjs/DictionaryListDrawer/DictionaryListDrawer.cjs +89 -0
  10. package/dist/cjs/DictionaryListDrawer/DictionaryListDrawer.cjs.map +1 -0
  11. package/dist/cjs/DictionaryListDrawer/dictionaryListDrawerIdentifier.cjs +29 -0
  12. package/dist/cjs/DictionaryListDrawer/dictionaryListDrawerIdentifier.cjs.map +1 -0
  13. package/dist/cjs/DictionaryListDrawer/index.cjs +25 -0
  14. package/dist/cjs/DictionaryListDrawer/index.cjs.map +1 -0
  15. package/dist/cjs/IntlayerEditorProvider.cjs +92 -0
  16. package/dist/cjs/IntlayerEditorProvider.cjs.map +1 -0
  17. package/dist/cjs/index.cjs +27 -0
  18. package/dist/cjs/index.cjs.map +1 -0
  19. package/dist/cjs/styles/style.css +2 -0
  20. package/dist/cjs/styles/style.css.map +1 -0
  21. package/dist/cjs/styles/tailwind.cjs +41 -0
  22. package/dist/cjs/styles/tailwind.cjs.map +1 -0
  23. package/dist/esm/ContentSelectorWrapper.mjs +48 -0
  24. package/dist/esm/ContentSelectorWrapper.mjs.map +1 -0
  25. package/dist/esm/DictionaryEditionDrawer/DictionaryEditionDrawer.mjs +141 -0
  26. package/dist/esm/DictionaryEditionDrawer/DictionaryEditionDrawer.mjs.map +1 -0
  27. package/dist/esm/DictionaryEditionDrawer/index.mjs +3 -0
  28. package/dist/esm/DictionaryEditionDrawer/index.mjs.map +1 -0
  29. package/dist/esm/DictionaryEditionDrawer/useDictionaryEditionDrawer.mjs +58 -0
  30. package/dist/esm/DictionaryEditionDrawer/useDictionaryEditionDrawer.mjs.map +1 -0
  31. package/dist/esm/DictionaryListDrawer/DictionaryListDrawer.mjs +71 -0
  32. package/dist/esm/DictionaryListDrawer/DictionaryListDrawer.mjs.map +1 -0
  33. package/dist/esm/DictionaryListDrawer/dictionaryListDrawerIdentifier.mjs +5 -0
  34. package/dist/esm/DictionaryListDrawer/dictionaryListDrawerIdentifier.mjs.map +1 -0
  35. package/dist/esm/DictionaryListDrawer/index.mjs +3 -0
  36. package/dist/esm/DictionaryListDrawer/index.mjs.map +1 -0
  37. package/dist/esm/IntlayerEditorProvider.mjs +71 -0
  38. package/dist/esm/IntlayerEditorProvider.mjs.map +1 -0
  39. package/dist/esm/index.mjs +4 -0
  40. package/dist/esm/index.mjs.map +1 -0
  41. package/dist/esm/styles/style.css +2 -0
  42. package/dist/esm/styles/style.css.map +1 -0
  43. package/dist/esm/styles/tailwind.mjs +9 -0
  44. package/dist/esm/styles/tailwind.mjs.map +1 -0
  45. package/dist/types/ContentSelectorWrapper.d.ts +11 -0
  46. package/dist/types/ContentSelectorWrapper.d.ts.map +1 -0
  47. package/dist/types/DictionaryEditionDrawer/DictionaryEditionDrawer.d.ts +22 -0
  48. package/dist/types/DictionaryEditionDrawer/DictionaryEditionDrawer.d.ts.map +1 -0
  49. package/dist/types/DictionaryEditionDrawer/index.d.ts +3 -0
  50. package/dist/types/DictionaryEditionDrawer/index.d.ts.map +1 -0
  51. package/dist/types/DictionaryEditionDrawer/useDictionaryEditionDrawer.d.ts +20 -0
  52. package/dist/types/DictionaryEditionDrawer/useDictionaryEditionDrawer.d.ts.map +1 -0
  53. package/dist/types/DictionaryListDrawer/DictionaryListDrawer.d.ts +3 -0
  54. package/dist/types/DictionaryListDrawer/DictionaryListDrawer.d.ts.map +1 -0
  55. package/dist/types/DictionaryListDrawer/dictionaryListDrawerIdentifier.d.ts +2 -0
  56. package/dist/types/DictionaryListDrawer/dictionaryListDrawerIdentifier.d.ts.map +1 -0
  57. package/dist/types/DictionaryListDrawer/index.d.ts +3 -0
  58. package/dist/types/DictionaryListDrawer/index.d.ts.map +1 -0
  59. package/dist/types/IntlayerEditorProvider.d.ts +21 -0
  60. package/dist/types/IntlayerEditorProvider.d.ts.map +1 -0
  61. package/dist/types/index.d.ts +4 -0
  62. package/dist/types/index.d.ts.map +1 -0
  63. package/dist/types/styles/tailwind.d.ts +4 -0
  64. package/dist/types/styles/tailwind.d.ts.map +1 -0
  65. package/package.json +8 -8
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var ContentSelectorWrapper_exports = {};
21
+ __export(ContentSelectorWrapper_exports, {
22
+ ContentSelectorWrapper: () => ContentSelectorWrapper
23
+ });
24
+ module.exports = __toCommonJS(ContentSelectorWrapper_exports);
25
+ var import_jsx_runtime = require("react/jsx-runtime");
26
+ var import_core = require("@intlayer/core");
27
+ var import_design_system = require("@intlayer/design-system");
28
+ var import_react = require("react");
29
+ var import_IntlayerEditorProvider = require('./IntlayerEditorProvider.cjs');
30
+ var import_useDictionaryEditionDrawer = require('./DictionaryEditionDrawer/useDictionaryEditionDrawer.cjs');
31
+ const ContentSelectorWrapper = ({
32
+ children,
33
+ dictionaryId,
34
+ dictionaryPath,
35
+ keyPath
36
+ }) => {
37
+ const { open, getEditedContentValue, focusedContent, isOpen } = (0, import_useDictionaryEditionDrawer.useDictionaryEditionDrawer)(dictionaryId);
38
+ const editedValue = getEditedContentValue(dictionaryId, keyPath);
39
+ const { isEditorEnabled } = (0, import_IntlayerEditorProvider.useIntlayerEditorContext)();
40
+ const [displayedChildren, setDisplayedChildren] = (0, import_react.useState)(children);
41
+ const handleSelect = (0, import_react.useCallback)(
42
+ () => open({
43
+ dictionaryId,
44
+ dictionaryPath,
45
+ keyPath
46
+ }),
47
+ [dictionaryId, dictionaryPath, keyPath, open]
48
+ );
49
+ const isSelected = (0, import_react.useMemo)(
50
+ () => (isOpen && (focusedContent?.keyPath?.length ?? 0) > 0 && (0, import_core.isSameKeyPath)(focusedContent?.keyPath ?? [], keyPath)) ?? false,
51
+ [focusedContent, isOpen, keyPath]
52
+ );
53
+ (0, import_react.useEffect)(() => {
54
+ if (isEditorEnabled && editedValue && typeof editedValue === "string") {
55
+ setDisplayedChildren(editedValue);
56
+ }
57
+ }, [editedValue, isEditorEnabled]);
58
+ if (!isEditorEnabled) {
59
+ return children;
60
+ }
61
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_design_system.ContentSelector, { onSelect: handleSelect, isSelecting: isSelected, children: displayedChildren });
62
+ };
63
+ // Annotate the CommonJS export names for ESM import in node:
64
+ 0 && (module.exports = {
65
+ ContentSelectorWrapper
66
+ });
67
+ //# sourceMappingURL=ContentSelectorWrapper.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { isSameKeyPath, type KeyPath } from '@intlayer/core';\nimport { ContentSelector } from '@intlayer/design-system';\nimport {\n useCallback,\n useEffect,\n useState,\n useMemo,\n type FC,\n type ReactNode,\n} from 'react';\nimport { useIntlayerEditorContext } from './IntlayerEditorProvider';\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 { isEditorEnabled } = useIntlayerEditorContext();\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 = useMemo(\n () =>\n (isOpen &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], keyPath)) ??\n false,\n [focusedContent, isOpen, keyPath]\n );\n\n useEffect(() => {\n // Use useEffect to avoid 'Text content does not match server-rendered HTML' error\n if (isEditorEnabled && editedValue && typeof editedValue === 'string') {\n setDisplayedChildren(editedValue);\n }\n }, [editedValue, isEditorEnabled]);\n\n if (!isEditorEnabled) {\n return children;\n }\n\n return (\n <ContentSelector onSelect={handleSelect} isSelecting={isSelected}>\n {displayedChildren}\n </ContentSelector>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkEI;AAhEJ,kBAA4C;AAC5C,2BAAgC;AAChC,mBAOO;AACP,oCAAyC;AACzC,wCAA2C;AASpC,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,MAAM,uBAAuB,gBAAgB,OAAO,QAC1D,8DAA2B,YAAY;AACzC,QAAM,cAAc,sBAAsB,cAAc,OAAO;AAC/D,QAAM,EAAE,gBAAgB,QAAI,wDAAyB;AACrD,QAAM,CAAC,mBAAmB,oBAAoB,QAC5C,uBAAoB,QAAQ;AAE9B,QAAM,mBAAe;AAAA,IACnB,MACE,KAAK;AAAA,MACH;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,cAAc,gBAAgB,SAAS,IAAI;AAAA,EAC9C;AAEA,QAAM,iBAAa;AAAA,IACjB,OACG,WACE,gBAAgB,SAAS,UAAU,KAAK,SACzC,2BAAc,gBAAgB,WAAW,CAAC,GAAG,OAAO,MACtD;AAAA,IACF,CAAC,gBAAgB,QAAQ,OAAO;AAAA,EAClC;AAEA,8BAAU,MAAM;AAEd,QAAI,mBAAmB,eAAe,OAAO,gBAAgB,UAAU;AACrE,2BAAqB,WAAW;AAAA,IAClC;AAAA,EACF,GAAG,CAAC,aAAa,eAAe,CAAC;AAEjC,MAAI,CAAC,iBAAiB;AACpB,WAAO;AAAA,EACT;AAEA,SACE,4CAAC,wCAAgB,UAAU,cAAc,aAAa,YACnD,6BACH;AAEJ;","names":[]}
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var DictionaryEditionDrawer_exports = {};
21
+ __export(DictionaryEditionDrawer_exports, {
22
+ DictionaryEditionDrawer: () => DictionaryEditionDrawer,
23
+ DictionaryEditionDrawerContent: () => DictionaryEditionDrawerContent,
24
+ DictionaryEditionDrawerController: () => DictionaryEditionDrawerController
25
+ });
26
+ module.exports = __toCommonJS(DictionaryEditionDrawer_exports);
27
+ var import_jsx_runtime = require("react/jsx-runtime");
28
+ var import_design_system = require("@intlayer/design-system");
29
+ var import_hooks = require("@intlayer/design-system/hooks");
30
+ var import_react = require("react");
31
+ var import_react_intlayer = require("react-intlayer");
32
+ var import_shallow = require("zustand/shallow");
33
+ var import_dictionaryListDrawerIdentifier = require('../DictionaryListDrawer/dictionaryListDrawerIdentifier.cjs');
34
+ var import_useDictionaryEditionDrawer = require('./useDictionaryEditionDrawer.cjs');
35
+ const DictionaryEditionDrawerContent = ({ locale, identifier, handleOnBack }) => {
36
+ const [keyPathEditionModal, setKeyPathEditionModal] = (0, import_react.useState)(null);
37
+ const { setDictionariesRecord, focusedContent } = (0, import_useDictionaryEditionDrawer.useDictionaryEditionDrawer)(identifier);
38
+ const { all: dictionaries } = (0, import_hooks.useGetAllDictionaries)();
39
+ const onClickDictionaryList = (0, import_react.useCallback)(() => {
40
+ setKeyPathEditionModal(null);
41
+ handleOnBack();
42
+ }, [handleOnBack]);
43
+ (0, import_react.useEffect)(() => {
44
+ if (dictionaries) {
45
+ setDictionariesRecord(dictionaries);
46
+ }
47
+ }, [setDictionariesRecord, dictionaries]);
48
+ const dictionaryId = focusedContent?.dictionaryId;
49
+ if (!dictionaryId) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: "No dictionary focused" });
50
+ const dictionary = dictionaries[dictionaryId];
51
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
52
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
53
+ import_design_system.Modal,
54
+ {
55
+ isOpen: keyPathEditionModal !== null,
56
+ onClose: () => setKeyPathEditionModal(null),
57
+ hasCloseButton: true,
58
+ title: (0, import_react_intlayer.t)({
59
+ en: "Edit field",
60
+ fr: "Modifier le champ",
61
+ es: "Editar campo"
62
+ }),
63
+ size: "xl",
64
+ transparency: "lg",
65
+ children: dictionary && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
66
+ import_design_system.DictionaryFieldEditor,
67
+ {
68
+ dictionary,
69
+ onClickDictionaryList
70
+ }
71
+ )
72
+ }
73
+ ),
74
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
75
+ import_design_system.DictionaryEditor,
76
+ {
77
+ dictionary,
78
+ locale,
79
+ onClickEdit: setKeyPathEditionModal
80
+ }
81
+ )
82
+ ] });
83
+ };
84
+ const DictionaryEditionDrawer = ({
85
+ locale,
86
+ localeList,
87
+ setLocale,
88
+ dictionaryId
89
+ }) => {
90
+ const id = (0, import_useDictionaryEditionDrawer.getDrawerIdentifier)(dictionaryId);
91
+ const { focusedContent, close } = (0, import_useDictionaryEditionDrawer.useDictionaryEditionDrawer)(dictionaryId);
92
+ const { openDictionaryListDrawer } = (0, import_design_system.useRightDrawerStore)((s) => ({
93
+ openDictionaryListDrawer: () => s.open(import_dictionaryListDrawerIdentifier.dictionaryListDrawerIdentifier)
94
+ }));
95
+ const handleOnBack = () => {
96
+ close();
97
+ openDictionaryListDrawer();
98
+ };
99
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
100
+ import_design_system.RightDrawer,
101
+ {
102
+ title: dictionaryId,
103
+ identifier: id,
104
+ header: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
105
+ import_design_system.LocaleSwitcher,
106
+ {
107
+ setLocale,
108
+ locale,
109
+ localeList
110
+ }
111
+ ),
112
+ backButton: {
113
+ onBack: handleOnBack,
114
+ text: (0, import_react_intlayer.t)({
115
+ en: "Dictionary list",
116
+ fr: "Liste des dictionnaires",
117
+ es: "Lista de diccionarios"
118
+ })
119
+ },
120
+ children: focusedContent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
121
+ DictionaryEditionDrawerContent,
122
+ {
123
+ focusedContent,
124
+ locale,
125
+ identifier: id,
126
+ handleOnBack
127
+ }
128
+ )
129
+ }
130
+ );
131
+ };
132
+ const DictionaryEditionDrawerController = ({ locale, localeList, setLocale }) => {
133
+ const focusedContent = (0, import_design_system.useEditionPanelStore)(
134
+ (0, import_shallow.useShallow)((s) => s.focusedContent)
135
+ );
136
+ const dictionaryId = focusedContent?.dictionaryId;
137
+ if (!dictionaryId) {
138
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
139
+ }
140
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
141
+ DictionaryEditionDrawer,
142
+ {
143
+ locale,
144
+ localeList,
145
+ setLocale,
146
+ dictionaryId
147
+ }
148
+ );
149
+ };
150
+ // Annotate the CommonJS export names for ESM import in node:
151
+ 0 && (module.exports = {
152
+ DictionaryEditionDrawer,
153
+ DictionaryEditionDrawerContent,
154
+ DictionaryEditionDrawerController
155
+ });
156
+ //# sourceMappingURL=DictionaryEditionDrawer.cjs.map
@@ -0,0 +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 useRightDrawerStore,\n} from '@intlayer/design-system';\nimport { useGetAllDictionaries } from '@intlayer/design-system/hooks';\nimport { useCallback, useEffect, useState, type FC } from 'react';\nimport { t } from 'react-intlayer';\nimport { useShallow } from 'zustand/shallow';\nimport { dictionaryListDrawerIdentifier } from '../DictionaryListDrawer/dictionaryListDrawerIdentifier';\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={t({\n en: 'Edit field',\n fr: 'Modifier le champ',\n es: 'Editar campo',\n })}\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 { openDictionaryListDrawer } = useRightDrawerStore((s) => ({\n openDictionaryListDrawer: () => s.open(dictionaryListDrawerIdentifier),\n }));\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: t({\n en: 'Dictionary list',\n fr: 'Liste des dictionnaires',\n es: 'Lista de diccionarios',\n }),\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;AAsD4B;AAlD5B,2BAQO;AACP,mBAAsC;AACtC,mBAA0D;AAC1D,4BAAkB;AAClB,qBAA2B;AAC3B,4CAA+C;AAC/C,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,WAAO,yBAAE;AAAA,UACP,IAAI;AAAA,UACJ,IAAI;AAAA,UACJ,IAAI;AAAA,QACN,CAAC;AAAA,QACD,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,yBAAyB,QAAI,0CAAoB,CAAC,OAAO;AAAA,IAC/D,0BAA0B,MAAM,EAAE,KAAK,oEAA8B;AAAA,EACvE,EAAE;AAEF,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,UAAM,yBAAE;AAAA,UACN,IAAI;AAAA,UACJ,IAAI;AAAA,UACJ,IAAI;AAAA,QACN,CAAC;AAAA,MACH;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":[]}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var DictionaryEditionDrawer_exports = {};
17
+ module.exports = __toCommonJS(DictionaryEditionDrawer_exports);
18
+ __reExport(DictionaryEditionDrawer_exports, require('./DictionaryEditionDrawer.cjs'), module.exports);
19
+ __reExport(DictionaryEditionDrawer_exports, require('./useDictionaryEditionDrawer.cjs'), module.exports);
20
+ // Annotate the CommonJS export names for ESM import in node:
21
+ 0 && (module.exports = {
22
+ ...require('./DictionaryEditionDrawer.cjs'),
23
+ ...require('./useDictionaryEditionDrawer.cjs')
24
+ });
25
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/DictionaryEditionDrawer/index.ts"],"sourcesContent":["export * from './DictionaryEditionDrawer';\nexport * from './useDictionaryEditionDrawer';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,4CAAc,sCAAd;AACA,4CAAc,yCADd;","names":[]}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var useDictionaryEditionDrawer_exports = {};
20
+ __export(useDictionaryEditionDrawer_exports, {
21
+ getDrawerIdentifier: () => getDrawerIdentifier,
22
+ useDictionaryEditionDrawer: () => useDictionaryEditionDrawer
23
+ });
24
+ module.exports = __toCommonJS(useDictionaryEditionDrawer_exports);
25
+ var import_design_system = require("@intlayer/design-system");
26
+ var import_react = require("react");
27
+ var import_shallow = require("zustand/shallow");
28
+ const getDrawerIdentifier = (dictionaryId) => `dictionary_edition_${dictionaryId}`;
29
+ const useDictionaryEditionDrawer = (dictionaryId) => {
30
+ const id = getDrawerIdentifier(dictionaryId);
31
+ const { isOpenDrawer, openDrawer, closeDrawer } = (0, import_design_system.useRightDrawerStore)(
32
+ (0, import_shallow.useShallow)((e) => ({
33
+ isOpenDrawer: e.isOpen,
34
+ openDrawer: e.open,
35
+ closeDrawer: 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
+ ({
52
+ dictionaryId: dictionaryId2,
53
+ dictionaryPath,
54
+ keyPath = []
55
+ }) => {
56
+ setFocusedContent({
57
+ dictionaryId: dictionaryId2,
58
+ dictionaryPath,
59
+ keyPath
60
+ });
61
+ openDrawer(id);
62
+ },
63
+ [openDrawer, setFocusedContent]
64
+ );
65
+ return {
66
+ isOpen: isOpenDrawer(id),
67
+ focusedContent,
68
+ setDictionariesRecord,
69
+ getEditedContentValue,
70
+ open: openDictionaryEditionDrawer,
71
+ close: () => closeDrawer(id)
72
+ };
73
+ };
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ getDrawerIdentifier,
77
+ useDictionaryEditionDrawer
78
+ });
79
+ //# sourceMappingURL=useDictionaryEditionDrawer.cjs.map
@@ -0,0 +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';\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 { isOpenDrawer, openDrawer, closeDrawer } = useRightDrawerStore(\n useShallow((e) => ({\n isOpenDrawer: e.isOpen,\n openDrawer: e.open,\n closeDrawer: 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 openDrawer(id);\n },\n [openDrawer, setFocusedContent]\n );\n\n return {\n isOpen: isOpenDrawer(id),\n focusedContent,\n setDictionariesRecord,\n getEditedContentValue,\n open: openDictionaryEditionDrawer,\n close: () => closeDrawer(id),\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,cAAc,YAAY,YAAY,QAAI;AAAA,QAChD,2BAAW,CAAC,OAAO;AAAA,MACjB,cAAc,EAAE;AAAA,MAChB,YAAY,EAAE;AAAA,MACd,aAAa,EAAE;AAAA,IACjB,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,iBAAW,EAAE;AAAA,IACf;AAAA,IACA,CAAC,YAAY,iBAAiB;AAAA,EAChC;AAEA,SAAO;AAAA,IACL,QAAQ,aAAa,EAAE;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,OAAO,MAAM,YAAY,EAAE;AAAA,EAC7B;AACF;","names":["dictionaryId"]}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var DictionaryListDrawer_exports = {};
21
+ __export(DictionaryListDrawer_exports, {
22
+ DictionaryListDrawer: () => DictionaryListDrawer
23
+ });
24
+ module.exports = __toCommonJS(DictionaryListDrawer_exports);
25
+ var import_jsx_runtime = require("react/jsx-runtime");
26
+ var import_design_system = require("@intlayer/design-system");
27
+ var import_hooks = require("@intlayer/design-system/hooks");
28
+ var import_lucide_react = require("lucide-react");
29
+ var import_react = require("react");
30
+ var import_shallow = require("zustand/shallow");
31
+ var import_useDictionaryEditionDrawer = require('../DictionaryEditionDrawer/useDictionaryEditionDrawer.cjs');
32
+ var import_dictionaryListDrawerIdentifier = require('./dictionaryListDrawerIdentifier.cjs');
33
+ const DictionaryListDrawer = () => {
34
+ const { all: dictionaries } = (0, import_hooks.useGetAllDictionaries)();
35
+ const dictionaryKeyList = (0, import_react.useMemo)(
36
+ () => Object.keys(dictionaries),
37
+ [dictionaries]
38
+ );
39
+ const { closeDrawer, openDrawer } = (0, import_design_system.useRightDrawerStore)(
40
+ (0, import_shallow.useShallow)((s) => ({
41
+ closeDrawer: s.close,
42
+ openDrawer: s.open
43
+ }))
44
+ );
45
+ const editedContent = (0, import_design_system.useEditedContentStore)(
46
+ (0, import_shallow.useShallow)((s) => s.editedContent)
47
+ );
48
+ const setFocusedContent = (0, import_design_system.useEditionPanelStore)(
49
+ (0, import_shallow.useShallow)((s) => s.setFocusedContent)
50
+ );
51
+ const handleClickDictionary = (dictionaryId) => {
52
+ closeDrawer(import_dictionaryListDrawerIdentifier.dictionaryListDrawerIdentifier);
53
+ const { filePath } = dictionaries[dictionaryId];
54
+ setFocusedContent({
55
+ dictionaryId,
56
+ dictionaryPath: filePath
57
+ });
58
+ openDrawer((0, import_useDictionaryEditionDrawer.getDrawerIdentifier)(dictionaryId));
59
+ };
60
+ const isDictionaryEdited = (0, import_react.useCallback)(
61
+ (dictionaryId) => Object.keys(editedContent).includes(dictionaryId),
62
+ [editedContent]
63
+ );
64
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
65
+ import_design_system.RightDrawer,
66
+ {
67
+ title: "Dictionary list",
68
+ identifier: import_dictionaryListDrawerIdentifier.dictionaryListDrawerIdentifier,
69
+ children: dictionaryKeyList.map((dictionaryId) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
70
+ import_design_system.Button,
71
+ {
72
+ label: `Open dictionary editor ${dictionaryId}`,
73
+ onClick: () => handleClickDictionary(dictionaryId),
74
+ variant: "hoverable",
75
+ color: "text",
76
+ IconRight: import_lucide_react.ChevronRight,
77
+ size: "md",
78
+ isFullWidth: true,
79
+ children: isDictionaryEdited(dictionaryId) ? `\u270E ${dictionaryId}` : dictionaryId
80
+ }
81
+ ) }, dictionaryId))
82
+ }
83
+ ) });
84
+ };
85
+ // Annotate the CommonJS export names for ESM import in node:
86
+ 0 && (module.exports = {
87
+ DictionaryListDrawer
88
+ });
89
+ //# sourceMappingURL=DictionaryListDrawer.cjs.map
@@ -0,0 +1 @@
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 { useCallback, useMemo, FC } from 'react';\nimport { useShallow } from 'zustand/shallow';\nimport { getDrawerIdentifier } from '../DictionaryEditionDrawer/useDictionaryEditionDrawer';\nimport { dictionaryListDrawerIdentifier } from './dictionaryListDrawerIdentifier';\n\nexport const DictionaryListDrawer: FC = () => {\n const { all: dictionaries } = useGetAllDictionaries();\n const dictionaryKeyList = useMemo(\n () => Object.keys(dictionaries) as Locales[],\n [dictionaries]\n );\n\n const { closeDrawer, openDrawer } = useRightDrawerStore(\n useShallow((s) => ({\n closeDrawer: s.close,\n openDrawer: s.open,\n }))\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 handleClickDictionary = (dictionaryId: string) => {\n closeDrawer(dictionaryListDrawerIdentifier);\n\n const { filePath } = dictionaries[dictionaryId];\n setFocusedContent({\n dictionaryId,\n dictionaryPath: filePath,\n });\n\n openDrawer(getDrawerIdentifier(dictionaryId));\n };\n\n const isDictionaryEdited = useCallback(\n (dictionaryId: string) => Object.keys(editedContent).includes(dictionaryId),\n [editedContent]\n );\n\n return (\n <>\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};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwDI;AArDJ,2BAMO;AACP,mBAAsC;AACtC,0BAA6B;AAC7B,mBAAyC;AACzC,qBAA2B;AAC3B,wCAAoC;AACpC,4CAA+C;AAExC,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;AAEA,QAAM,EAAE,aAAa,WAAW,QAAI;AAAA,QAClC,2BAAW,CAAC,OAAO;AAAA,MACjB,aAAa,EAAE;AAAA,MACf,YAAY,EAAE;AAAA,IAChB,EAAE;AAAA,EACJ;AAEA,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,wBAAwB,CAAC,iBAAyB;AACtD,gBAAY,oEAA8B;AAE1C,UAAM,EAAE,SAAS,IAAI,aAAa,YAAY;AAC9C,sBAAkB;AAAA,MAChB;AAAA,MACA,gBAAgB;AAAA,IAClB,CAAC;AAED,mBAAW,uDAAoB,YAAY,CAAC;AAAA,EAC9C;AAEA,QAAM,yBAAqB;AAAA,IACzB,CAAC,iBAAyB,OAAO,KAAK,aAAa,EAAE,SAAS,YAAY;AAAA,IAC1E,CAAC,aAAa;AAAA,EAChB;AAEA,SACE,2EACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAM;AAAA,MACN,YAAY;AAAA,MAEX,4BAAkB,IAAI,CAAC,iBACtB,4CAAC,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,GACF;AAEJ;","names":[]}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var dictionaryListDrawerIdentifier_exports = {};
20
+ __export(dictionaryListDrawerIdentifier_exports, {
21
+ dictionaryListDrawerIdentifier: () => dictionaryListDrawerIdentifier
22
+ });
23
+ module.exports = __toCommonJS(dictionaryListDrawerIdentifier_exports);
24
+ const dictionaryListDrawerIdentifier = "dictionaryList";
25
+ // Annotate the CommonJS export names for ESM import in node:
26
+ 0 && (module.exports = {
27
+ dictionaryListDrawerIdentifier
28
+ });
29
+ //# sourceMappingURL=dictionaryListDrawerIdentifier.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/DictionaryListDrawer/dictionaryListDrawerIdentifier.ts"],"sourcesContent":["export const dictionaryListDrawerIdentifier = 'dictionaryList';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,iCAAiC;","names":[]}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var DictionaryListDrawer_exports = {};
17
+ module.exports = __toCommonJS(DictionaryListDrawer_exports);
18
+ __reExport(DictionaryListDrawer_exports, require('./DictionaryListDrawer.cjs'), module.exports);
19
+ __reExport(DictionaryListDrawer_exports, require('./dictionaryListDrawerIdentifier.cjs'), module.exports);
20
+ // Annotate the CommonJS export names for ESM import in node:
21
+ 0 && (module.exports = {
22
+ ...require('./DictionaryListDrawer.cjs'),
23
+ ...require('./dictionaryListDrawerIdentifier.cjs')
24
+ });
25
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/DictionaryListDrawer/index.ts"],"sourcesContent":["export * from './DictionaryListDrawer';\nexport * from './dictionaryListDrawerIdentifier';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,yCAAc,mCAAd;AACA,yCAAc,6CADd;","names":[]}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var IntlayerEditorProvider_exports = {};
21
+ __export(IntlayerEditorProvider_exports, {
22
+ IntlayerEditorContext: () => IntlayerEditorContext,
23
+ IntlayerEditorProvider: () => IntlayerEditorProvider,
24
+ useIntlayerEditorContext: () => useIntlayerEditorContext
25
+ });
26
+ module.exports = __toCommonJS(IntlayerEditorProvider_exports);
27
+ var import_jsx_runtime = require("react/jsx-runtime");
28
+ var import_client = require("@intlayer/config/client");
29
+ var import_DictionaryEditionDrawer = require('./DictionaryEditionDrawer/index.cjs');
30
+ var import_DictionaryListDrawer = require('./DictionaryListDrawer/index.cjs');
31
+ var import_react_intlayer = require("react-intlayer");
32
+ var import_editor = require("react-intlayer/editor");
33
+ var import_ContentSelectorWrapper = require('./ContentSelectorWrapper.cjs');
34
+ var import_react = require("react");
35
+ const IntlayerEditorContext = (0, import_react.createContext)({
36
+ isEditorEnabled: false
37
+ });
38
+ const useIntlayerEditorContext = () => (0, import_react.useContext)(IntlayerEditorContext);
39
+ const IntlayerEditorProvider = ({
40
+ children,
41
+ isEnabled = true
42
+ }) => {
43
+ const { editor, internationalization } = (0, import_client.getConfiguration)();
44
+ const { setState } = (0, import_editor.useContentSelectorContext)();
45
+ const { locale, setLocale } = (0, import_react_intlayer.useIntlayerContext)();
46
+ const isEditorEnabled = (0, import_react.useMemo)(
47
+ () => Boolean(
48
+ editor.enabled && editor.clientId && editor.clientSecret && isEnabled
49
+ ),
50
+ [editor.enabled && editor.clientId && editor.clientSecret && isEnabled]
51
+ );
52
+ (0, import_react.useEffect)(() => {
53
+ setState({
54
+ ContentSelectorWrapper: import_ContentSelectorWrapper.ContentSelectorWrapper
55
+ });
56
+ }, [setState]);
57
+ (0, import_react.useEffect)(() => {
58
+ if (isEnabled && editor.enabled) {
59
+ if (!editor.clientId) {
60
+ console.error(
61
+ "Editor is enabled but clientId is not set. Please set it in the editor configuration. See http://localhost:3000/doc/concept/editor."
62
+ );
63
+ }
64
+ if (!editor.clientSecret) {
65
+ console.error(
66
+ "Editor is enabled but clientSecret is not set. Please set it in the editor configuration. See http://localhost:3000/doc/concept/editor."
67
+ );
68
+ }
69
+ }
70
+ }, [isEnabled, editor.enabled, editor.clientId, editor.clientSecret]);
71
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(IntlayerEditorContext.Provider, { value: { isEditorEnabled }, children: [
72
+ children,
73
+ isEditorEnabled && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
74
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
75
+ import_DictionaryEditionDrawer.DictionaryEditionDrawerController,
76
+ {
77
+ locale,
78
+ localeList: internationalization.locales,
79
+ setLocale
80
+ }
81
+ ),
82
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DictionaryListDrawer.DictionaryListDrawer, {})
83
+ ] })
84
+ ] });
85
+ };
86
+ // Annotate the CommonJS export names for ESM import in node:
87
+ 0 && (module.exports = {
88
+ IntlayerEditorContext,
89
+ IntlayerEditorProvider,
90
+ useIntlayerEditorContext
91
+ });
92
+ //# sourceMappingURL=IntlayerEditorProvider.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/IntlayerEditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration } from '@intlayer/config/client';\nimport { DictionaryEditionDrawerController } from './DictionaryEditionDrawer/index';\nimport { DictionaryListDrawer } from './DictionaryListDrawer/index';\nimport { useIntlayerContext } from 'react-intlayer';\nimport { useContentSelectorContext } from 'react-intlayer/editor';\nimport { ContentSelectorWrapper } from './ContentSelectorWrapper';\nimport {\n type FC,\n type PropsWithChildren,\n createContext,\n useContext,\n useEffect,\n useMemo,\n} from 'react';\n\ntype IntlayerEditorValue = {\n isEditorEnabled: boolean;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerEditorContext = createContext<IntlayerEditorValue>({\n isEditorEnabled: false,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerEditorContext = () => useContext(IntlayerEditorContext);\n\nexport type IntlayerEditorProviderProps = PropsWithChildren<{\n isEnabled?: boolean;\n}>;\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerEditorProvider: FC<IntlayerEditorProviderProps> = ({\n children,\n isEnabled = true,\n}) => {\n const { editor, internationalization } = getConfiguration();\n\n const { setState } = useContentSelectorContext();\n\n const { locale, setLocale } = useIntlayerContext();\n\n const isEditorEnabled = useMemo(\n () =>\n Boolean(\n editor.enabled && editor.clientId && editor.clientSecret && isEnabled\n ),\n [editor.enabled && editor.clientId && editor.clientSecret && isEnabled]\n );\n\n useEffect(() => {\n setState({\n ContentSelectorWrapper,\n });\n }, [setState]);\n\n useEffect(() => {\n if (isEnabled && editor.enabled) {\n if (!editor.clientId) {\n console.error(\n 'Editor is enabled but clientId is not set. Please set it in the editor configuration. See http://localhost:3000/doc/concept/editor.'\n );\n }\n\n if (!editor.clientSecret) {\n console.error(\n 'Editor is enabled but clientSecret is not set. Please set it in the editor configuration. See http://localhost:3000/doc/concept/editor.'\n );\n }\n }\n }, [isEnabled, editor.enabled, editor.clientId, editor.clientSecret]);\n\n return (\n <IntlayerEditorContext.Provider value={{ isEditorEnabled }}>\n {children}\n\n {isEditorEnabled && (\n <>\n <DictionaryEditionDrawerController\n locale={locale}\n localeList={internationalization.locales}\n setLocale={setLocale}\n />\n <DictionaryListDrawer />\n </>\n )}\n </IntlayerEditorContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqFQ;AAnFR,oBAAiC;AACjC,qCAAkD;AAClD,kCAAqC;AACrC,4BAAmC;AACnC,oBAA0C;AAC1C,oCAAuC;AACvC,mBAOO;AASA,MAAM,4BAAwB,4BAAmC;AAAA,EACtE,iBAAiB;AACnB,CAAC;AAKM,MAAM,2BAA2B,UAAM,yBAAW,qBAAqB;AASvE,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA,YAAY;AACd,MAAM;AACJ,QAAM,EAAE,QAAQ,qBAAqB,QAAI,gCAAiB;AAE1D,QAAM,EAAE,SAAS,QAAI,yCAA0B;AAE/C,QAAM,EAAE,QAAQ,UAAU,QAAI,0CAAmB;AAEjD,QAAM,sBAAkB;AAAA,IACtB,MACE;AAAA,MACE,OAAO,WAAW,OAAO,YAAY,OAAO,gBAAgB;AAAA,IAC9D;AAAA,IACF,CAAC,OAAO,WAAW,OAAO,YAAY,OAAO,gBAAgB,SAAS;AAAA,EACxE;AAEA,8BAAU,MAAM;AACd,aAAS;AAAA,MACP;AAAA,IACF,CAAC;AAAA,EACH,GAAG,CAAC,QAAQ,CAAC;AAEb,8BAAU,MAAM;AACd,QAAI,aAAa,OAAO,SAAS;AAC/B,UAAI,CAAC,OAAO,UAAU;AACpB,gBAAQ;AAAA,UACN;AAAA,QACF;AAAA,MACF;AAEA,UAAI,CAAC,OAAO,cAAc;AACxB,gBAAQ;AAAA,UACN;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF,GAAG,CAAC,WAAW,OAAO,SAAS,OAAO,UAAU,OAAO,YAAY,CAAC;AAEpE,SACE,6CAAC,sBAAsB,UAAtB,EAA+B,OAAO,EAAE,gBAAgB,GACtD;AAAA;AAAA,IAEA,mBACC,4EACE;AAAA;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA,YAAY,qBAAqB;AAAA,UACjC;AAAA;AAAA,MACF;AAAA,MACA,4CAAC,oDAAqB;AAAA,OACxB;AAAA,KAEJ;AAEJ;","names":[]}