intlayer-editor 2.0.0 → 2.1.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 (136) hide show
  1. package/README.md +51 -135
  2. package/dist/cjs/client/ContentEditionLayout.cjs +21 -13
  3. package/dist/cjs/client/ContentEditionLayout.cjs.map +1 -1
  4. package/dist/cjs/client/ContentEditionLayout.d.ts +1 -0
  5. package/dist/cjs/client/ContentEditorProvider.cjs +47 -0
  6. package/dist/cjs/client/ContentEditorProvider.cjs.map +1 -0
  7. package/dist/cjs/client/ContentEditorProvider.d.ts +23 -0
  8. package/dist/cjs/client/ContentSelectorWrapper.cjs +27 -10
  9. package/dist/cjs/client/ContentSelectorWrapper.cjs.map +1 -1
  10. package/dist/cjs/client/ContentSelectorWrapper.d.ts +2 -2
  11. package/dist/cjs/client/DictionaryEditionDrawer/DictionaryEditionDrawer.cjs +135 -0
  12. package/dist/cjs/client/DictionaryEditionDrawer/DictionaryEditionDrawer.cjs.map +1 -0
  13. package/dist/cjs/client/DictionaryEditionDrawer/DictionaryEditionDrawer.d.ts +28 -0
  14. package/dist/cjs/client/DictionaryEditionDrawer/index.cjs +27 -0
  15. package/dist/cjs/client/DictionaryEditionDrawer/index.cjs.map +1 -0
  16. package/dist/cjs/client/DictionaryEditionDrawer/index.d.ts +9 -0
  17. package/dist/cjs/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.cjs +103 -0
  18. package/dist/cjs/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.cjs.map +1 -0
  19. package/dist/cjs/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.d.ts +32 -0
  20. package/dist/cjs/client/{EditionPanel → DictionaryEditionDrawer}/useEditedContentStore.cjs +19 -11
  21. package/dist/cjs/client/DictionaryEditionDrawer/useEditedContentStore.cjs.map +1 -0
  22. package/dist/cjs/client/{EditionPanel → DictionaryEditionDrawer}/useEditedContentStore.d.ts +1 -1
  23. package/dist/cjs/client/{EditionPanel/useEditionPanelStore.cjs → DictionaryEditionDrawer/useFocusContentStore.cjs} +4 -4
  24. package/dist/cjs/client/DictionaryEditionDrawer/useFocusContentStore.cjs.map +1 -0
  25. package/dist/cjs/client/{EditionPanel/useEditionPanelStore.d.ts → DictionaryEditionDrawer/useFocusContentStore.d.ts} +1 -1
  26. package/dist/cjs/client/DictionaryListDrawer/DictionaryListDrawer.cjs +74 -0
  27. package/dist/cjs/client/DictionaryListDrawer/DictionaryListDrawer.cjs.map +1 -0
  28. package/dist/cjs/client/DictionaryListDrawer/DictionaryListDrawer.d.ts +5 -0
  29. package/dist/cjs/client/{EditionPanel → DictionaryListDrawer}/index.cjs +6 -8
  30. package/dist/cjs/client/DictionaryListDrawer/index.cjs.map +1 -0
  31. package/dist/cjs/client/DictionaryListDrawer/index.d.ts +3 -0
  32. package/dist/cjs/client/{renderContentSelector.cjs → DictionaryListDrawer/useDictionaryListDrawer.cjs} +11 -17
  33. package/dist/cjs/client/DictionaryListDrawer/useDictionaryListDrawer.cjs.map +1 -0
  34. package/dist/cjs/client/DictionaryListDrawer/useDictionaryListDrawer.d.ts +8 -0
  35. package/dist/cjs/client/index.cjs +9 -5
  36. package/dist/cjs/client/index.cjs.map +1 -1
  37. package/dist/cjs/client/index.d.ts +9 -7
  38. package/dist/cjs/client/renderContentEditor.cjs +48 -0
  39. package/dist/cjs/client/renderContentEditor.cjs.map +1 -0
  40. package/dist/cjs/client/renderContentEditor.d.ts +15 -0
  41. package/dist/cjs/client/useEditorServer.cjs +5 -2
  42. package/dist/cjs/client/useEditorServer.cjs.map +1 -1
  43. package/dist/cjs/server/formatPrettier.cjs +51 -0
  44. package/dist/cjs/server/formatPrettier.cjs.map +1 -0
  45. package/dist/cjs/server/formatPrettier.d.ts +6 -0
  46. package/dist/cjs/server/index.cjs +2 -2
  47. package/dist/cjs/server/index.cjs.map +1 -1
  48. package/dist/cjs/server/{content-editor.cjs → processEdition.cjs} +69 -68
  49. package/dist/cjs/server/processEdition.cjs.map +1 -0
  50. package/dist/cjs/server/processEdition.d.ts +12 -0
  51. package/dist/esm/client/ContentEditionLayout.d.mts +1 -0
  52. package/dist/esm/client/ContentEditionLayout.mjs +21 -13
  53. package/dist/esm/client/ContentEditionLayout.mjs.map +1 -1
  54. package/dist/esm/client/ContentEditorProvider.d.mts +23 -0
  55. package/dist/esm/client/ContentEditorProvider.mjs +24 -0
  56. package/dist/esm/client/ContentEditorProvider.mjs.map +1 -0
  57. package/dist/esm/client/ContentSelectorWrapper.d.mts +2 -2
  58. package/dist/esm/client/ContentSelectorWrapper.mjs +27 -10
  59. package/dist/esm/client/ContentSelectorWrapper.mjs.map +1 -1
  60. package/dist/esm/client/DictionaryEditionDrawer/DictionaryEditionDrawer.d.mts +28 -0
  61. package/dist/esm/client/DictionaryEditionDrawer/DictionaryEditionDrawer.mjs +104 -0
  62. package/dist/esm/client/DictionaryEditionDrawer/DictionaryEditionDrawer.mjs.map +1 -0
  63. package/dist/esm/client/DictionaryEditionDrawer/index.d.mts +9 -0
  64. package/dist/esm/client/DictionaryEditionDrawer/index.mjs +4 -0
  65. package/dist/esm/client/DictionaryEditionDrawer/index.mjs.map +1 -0
  66. package/dist/esm/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.d.mts +32 -0
  67. package/dist/esm/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.mjs +80 -0
  68. package/dist/esm/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.mjs.map +1 -0
  69. package/dist/esm/client/{EditionPanel → DictionaryEditionDrawer}/useEditedContentStore.d.mts +1 -1
  70. package/dist/esm/client/{EditionPanel → DictionaryEditionDrawer}/useEditedContentStore.mjs +17 -9
  71. package/dist/esm/client/DictionaryEditionDrawer/useEditedContentStore.mjs.map +1 -0
  72. package/dist/esm/client/{EditionPanel/useEditionPanelStore.d.mts → DictionaryEditionDrawer/useFocusContentStore.d.mts} +1 -1
  73. package/dist/esm/client/{EditionPanel/useEditionPanelStore.mjs → DictionaryEditionDrawer/useFocusContentStore.mjs} +1 -1
  74. package/dist/esm/client/DictionaryEditionDrawer/useFocusContentStore.mjs.map +1 -0
  75. package/dist/esm/client/DictionaryListDrawer/DictionaryListDrawer.d.mts +5 -0
  76. package/dist/esm/client/DictionaryListDrawer/DictionaryListDrawer.mjs +46 -0
  77. package/dist/esm/client/DictionaryListDrawer/DictionaryListDrawer.mjs.map +1 -0
  78. package/dist/esm/client/DictionaryListDrawer/index.d.mts +3 -0
  79. package/dist/esm/client/DictionaryListDrawer/index.mjs +3 -0
  80. package/dist/esm/client/DictionaryListDrawer/index.mjs.map +1 -0
  81. package/dist/esm/client/DictionaryListDrawer/useDictionaryListDrawer.d.mts +8 -0
  82. package/dist/esm/client/DictionaryListDrawer/useDictionaryListDrawer.mjs +8 -0
  83. package/dist/esm/client/DictionaryListDrawer/useDictionaryListDrawer.mjs.map +1 -0
  84. package/dist/esm/client/index.d.mts +9 -7
  85. package/dist/esm/client/index.mjs +4 -2
  86. package/dist/esm/client/index.mjs.map +1 -1
  87. package/dist/esm/client/renderContentEditor.d.mts +15 -0
  88. package/dist/esm/client/renderContentEditor.mjs +24 -0
  89. package/dist/esm/client/renderContentEditor.mjs.map +1 -0
  90. package/dist/esm/client/useEditorServer.mjs +5 -2
  91. package/dist/esm/client/useEditorServer.mjs.map +1 -1
  92. package/dist/esm/server/formatPrettier.d.mts +6 -0
  93. package/dist/esm/server/formatPrettier.mjs +17 -0
  94. package/dist/esm/server/formatPrettier.mjs.map +1 -0
  95. package/dist/esm/server/index.mjs +2 -2
  96. package/dist/esm/server/index.mjs.map +1 -1
  97. package/dist/esm/server/processEdition.d.mts +12 -0
  98. package/dist/esm/server/processEdition.mjs +134 -0
  99. package/dist/esm/server/processEdition.mjs.map +1 -0
  100. package/package.json +17 -18
  101. package/dist/cjs/client/EditionPanel/EditionPanel.cjs +0 -101
  102. package/dist/cjs/client/EditionPanel/EditionPanel.cjs.map +0 -1
  103. package/dist/cjs/client/EditionPanel/EditionPanel.d.ts +0 -11
  104. package/dist/cjs/client/EditionPanel/index.cjs.map +0 -1
  105. package/dist/cjs/client/EditionPanel/index.d.ts +0 -9
  106. package/dist/cjs/client/EditionPanel/useEditedContentStore.cjs.map +0 -1
  107. package/dist/cjs/client/EditionPanel/useEditionPanelStore.cjs.map +0 -1
  108. package/dist/cjs/client/renderContentSelector.cjs.map +0 -1
  109. package/dist/cjs/client/renderContentSelector.d.ts +0 -6
  110. package/dist/cjs/server/content-editor.cjs.map +0 -1
  111. package/dist/cjs/server/content-editor.d.ts +0 -12
  112. package/dist/esm/client/EditionPanel/EditionPanel.d.mts +0 -11
  113. package/dist/esm/client/EditionPanel/EditionPanel.mjs +0 -72
  114. package/dist/esm/client/EditionPanel/EditionPanel.mjs.map +0 -1
  115. package/dist/esm/client/EditionPanel/index.d.mts +0 -9
  116. package/dist/esm/client/EditionPanel/index.mjs +0 -4
  117. package/dist/esm/client/EditionPanel/index.mjs.map +0 -1
  118. package/dist/esm/client/EditionPanel/useEditedContentStore.mjs.map +0 -1
  119. package/dist/esm/client/EditionPanel/useEditionPanelStore.mjs.map +0 -1
  120. package/dist/esm/client/renderContentSelector.d.mts +0 -6
  121. package/dist/esm/client/renderContentSelector.mjs +0 -15
  122. package/dist/esm/client/renderContentSelector.mjs.map +0 -1
  123. package/dist/esm/server/content-editor.d.mts +0 -12
  124. package/dist/esm/server/content-editor.mjs +0 -123
  125. package/dist/esm/server/content-editor.mjs.map +0 -1
  126. package/src/client/ContentEditionLayout.tsx +0 -26
  127. package/src/client/ContentSelectorWrapper.tsx +0 -38
  128. package/src/client/EditionPanel/EditionPanel.tsx +0 -90
  129. package/src/client/EditionPanel/index.ts +0 -3
  130. package/src/client/EditionPanel/useEditedContentStore.ts +0 -98
  131. package/src/client/EditionPanel/useEditionPanelStore.ts +0 -19
  132. package/src/client/index.ts +0 -4
  133. package/src/client/renderContentSelector.tsx +0 -17
  134. package/src/client/useEditorServer.ts +0 -31
  135. package/src/server/content-editor.ts +0 -209
  136. package/src/server/index.ts +0 -40
package/README.md CHANGED
@@ -1,175 +1,91 @@
1
- # Intlayer: Next-Level Content Management in JavaScript
1
+ # Intlayer Editor Documentation
2
2
 
3
- **Intlayer** is an innovative Content Management System (CMS) designed specifically for JavaScript developers. It enables seamless transpilation of JavaScript content into structured dictionaries, making integration into your codebase straightforward and efficient.
3
+ The Intlayer Editor is a tool that transforms your application into a visual editor. With Intlayer Editor, your teams can manage your site's content in all configured languages.
4
4
 
5
- ## Why Choose Intlayer?
5
+ ![Intlayer Editor Interface](https://github.com/aypineau/intlayer/blob/main/docs/assets/enabledpletion.png)
6
6
 
7
- - **JavaScript-Powered Content Management**: Harness the flexibility of JavaScript to define and manage your content efficiently.
8
- - **Type-Safe Environment**: Leverage TypeScript to ensure all your content definitions are precise and error-free.
9
- - **Integrated Content Files**: Keep your translations close to their respective components, enhancing maintainability and clarity.
7
+ The `intlayer-editor` package is based on Intlayer and is available for JavaScript applications, such as React (Create React App), Vite + React, and Next.js.
10
8
 
11
- ## intlayer package
9
+ For more details on how to install the package, see the relevant section below:
12
10
 
13
- `intlayer` package intend to declare your content in a structured way, using JavaScript.
11
+ ### Integrating with Next.js
14
12
 
15
- To build dictionaries from this declaration, you can use [intlayer-cli](https://github.com/aypineau/intlayer/blob/main/packages/intlayer-cli/readme.md).
16
- And to interpret intlayer dictionaries you can interpreters, such as [react-intlayer](https://github.com/aypineau/intlayer/blob/main/packages/react-intlayer/readme.md), or [next-intlayer](https://github.com/aypineau/intlayer/blob/main/packages/next-intlayer/readme.md)
13
+ For integration with Next.js, refer to the [setup guide](https://github.com/aypineau/intlayer/blob/main/docs/docs/intlayer_with_nextjs_en.md).
17
14
 
18
- ## Getting Started with Intlayer
15
+ ### Integrating with Create React App
19
16
 
20
- [See how to use intlayer with NextJS](https://github.com/aypineau/intlayer/blob/main/readme.md)
17
+ For integration with Create React App, refer to the [setup guide](https://github.com/aypineau/intlayer/blob/main/docs/docs/intlayer_with_create_react_app_en.md).
21
18
 
22
- ### Install Package
19
+ ### Integrating with Vite + React
23
20
 
24
- Install the necessary packages using npm:
21
+ For integration with Vite + React, refer to the [setup guide](https://github.com/aypineau/intlayer/blob/main/docs/docs/intlayer_with_vite+react_en.md).
22
+
23
+ ## How Intlayer Editor Works
24
+
25
+ Each time you make a change using Intlayer Editor, the server automatically inserts your changes into your [Intlayer declaration files](https://github.com/aypineau/intlayer/blob/main/docs/docs/content_declaration/get_started_en.md), wherever these files are declared in your project.
26
+
27
+ In this way, you don't have to worry about where the file is declared or about finding your key in your dictionary collection.
28
+
29
+ ## Installation
30
+
31
+ Once Intlayer is configured in your project, simply install `intlayer-editor` as a development dependency:
25
32
 
26
33
  ```bash
27
- npm install intlayer
34
+ npm install intlayer-editor -D
28
35
  ```
29
36
 
30
37
  ```bash
31
- yarn install intlayer
38
+ yarn install intlayer-editor -D
32
39
  ```
33
40
 
34
41
  ```bash
35
- pnpm install intlayer
42
+ pnpm install intlayer-editor -D
36
43
  ```
37
44
 
38
- ### Manage Your Content
39
-
40
- Create and manage your content dictionaries:
41
-
42
- #### Using typescript
45
+ In your Intlayer configuration file, you can customize the editor settings:
43
46
 
44
47
  ```typescript
45
- // src/app/[locale]/page.content.ts
46
- import { t, enu, type ContentModule } from "intlayer";
47
-
48
- const pageContent: ContentModule = {
49
- id: "page",
50
- getStarted: {
51
- main: t({
52
- en: "Get started by editing",
53
- fr: "Commencez par éditer",
54
- es: "Comience por editar",
55
- }),
56
- pageLink: "src/app/page.tsx",
57
- },
58
- nestedContent: {
59
- id: "enumeration",
60
- numberOfCar: enu({
61
- "<-1": "Less than minus one car",
62
- "-1": "Minus one car",
63
- "0": "No cars",
64
- "1": "One car",
65
- ">5": "Some cars",
66
- ">19": "Many cars",
67
- }),
48
+ const config: IntlayerConfig = {
49
+ // ... other configuration settings
50
+ editor: {
51
+ enabled: process.env.NODE_ENV === "development", // If false, the editor is inactive and cannot be accessed.
52
+ port: 3000, // Port of the intlayer-editor backend
68
53
  },
69
54
  };
70
-
71
- // Content should be exported as default
72
- export default pageContent;
73
55
  ```
74
56
 
75
- #### Using ECMAScript modules
57
+ To see all available parameters, refer to the [configuration documentation](https://github.com/aypineau/intlayer/blob/main/docs/docs/configuration_en.md).
76
58
 
77
- ```javascript
78
- // src/app/[locale]/page.content.mjs
59
+ ### Start Editing
79
60
 
80
- import { t } from "intlayer";
61
+ To start editing, launch the editor server using `npx intlayer-editor start`.
81
62
 
82
- /** @type {import('intlayer').ContentModule} */
83
- const pageContent = {
84
- id: "page",
85
- getStarted: {
86
- main: t({
87
- en: "Get started by editing",
88
- fr: "Commencez par éditer",
89
- es: "Comience por editar",
90
- }),
91
- pageLink: "src/app/page.tsx",
92
- },
93
- nestedContent: {
94
- id: "enumeration",
95
- numberOfCar: enu({
96
- "<-1": "Less than minus one car",
97
- "-1": "Minus one car",
98
- "0": "No cars",
99
- "1": "One car",
100
- ">5": "Some cars",
101
- ">19": "Many cars",
102
- }),
103
- },
104
- };
105
-
106
- // Content should be exported as default
107
- export default pageContent;
108
- ```
63
+ You can also create a custom script in your `package.json` file:
109
64
 
110
- #### Using CommonJS modules
111
-
112
- ```javascript
113
- // src/app/[locale]/page.content.cjs
114
-
115
- const { t } = require("intlayer");
116
-
117
- /** @type {import('intlayer').ContentModule} */
118
- const pageContent = {
119
- id: "page",
120
- getStarted: {
121
- main: t({
122
- en: "Get started by editing",
123
- fr: "Commencez par éditer",
124
- es: "Comience por editar",
125
- }),
126
- pageLink: "src/app/page.tsx",
127
- },
128
- nestedContent: {
129
- id: "enumeration",
130
- numberOfCar: enu({
131
- "<-1": "Less than minus one car",
132
- "-1": "Minus one car",
133
- "0": "No cars",
134
- "1": "One car",
135
- ">5": "Some cars",
136
- ">19": "Many cars",
137
- }),
65
+ ```json5
66
+ {
67
+ scripts: {
68
+ "start:editor": "npx intlayer-editor start",
138
69
  },
139
- };
140
-
141
- // Content should be exported as default
142
- module.exports = pageContent;
70
+ }
143
71
  ```
144
72
 
145
- #### Using JSON
73
+ To start both the Next.js server and the Intlayer Editor simultaneously, you can use the [concurrently](https://github.com/open-cli-tools/concurrently) tool:
146
74
 
147
75
  ```json5
148
- // src/app/[locale]/page.content.json
149
76
  {
150
- "id": "page",
151
- "getStarted": {
152
- "main": {
153
- "nodeType": "translation",
154
- "en": "Get started by editing",
155
- "fr": "Commencez par éditer",
156
- "es": "Comience por editar",
157
- },
158
- "pageLink": "src/app/page.tsx",
159
- },
160
- "nestedContent": {
161
- "id": "enumeration",
162
- "nodeType": "enumeration",
163
- "numberOfCar": {
164
- "<-1": "Less than minus one car",
165
- "-1": "Minus one car",
166
- "0": "No cars",
167
- "1": "One car",
168
- ">5": "Some cars",
169
- ">19": "Many cars",
170
- },
77
+ scripts: {
78
+ dev: "next dev",
79
+ "start:editor": "npx intlayer-editor start",
80
+ "dev:all": "concurrently \"npm run dev:nextjs\" \"npm run dev:intlayer-editor\"",
171
81
  },
172
82
  }
173
83
  ```
174
84
 
175
- This version emphasizes ease of use, practical steps, and the professional application of Intlayer in a Next.js environment.
85
+ ## Using the Editor
86
+
87
+ When the editor is installed, enabled, and started, you can view each field indexed by Intlayer by hovering over your content with your cursor.
88
+
89
+ ![Hovering over content](https://github.com/aypineau/intlayer/blob/main/docs/assets/intlayer_editor_hover_content.png)
90
+
91
+ If your content is outlined, you can long-press it to display the edit drawer.
@@ -22,23 +22,31 @@ __export(ContentEditionLayout_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(ContentEditionLayout_exports);
24
24
  var import_jsx_runtime = require("react/jsx-runtime");
25
- var import_EditionPanel = require('./EditionPanel/index.cjs');
25
+ var import_ContentEditorProvider = require('./ContentEditorProvider.cjs');
26
+ var import_DictionaryEditionDrawer = require('./DictionaryEditionDrawer/index.cjs');
27
+ var import_DictionaryListDrawer = require('./DictionaryListDrawer/index.cjs');
26
28
  const ContentEditionLayout = ({
27
29
  children,
28
30
  locale,
29
31
  setLocale,
30
- localeList
31
- }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
32
- children,
33
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
34
- import_EditionPanel.EditionPanel,
35
- {
36
- locale,
37
- localeList,
38
- setLocale
39
- }
40
- )
41
- ] });
32
+ localeList,
33
+ editorEnabled = true
34
+ }) => {
35
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ContentEditorProvider.IntlayerEditorProvider, { editorEnabled, children: [
36
+ children,
37
+ editorEnabled && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
38
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
39
+ import_DictionaryEditionDrawer.DictionaryEditionDrawerController,
40
+ {
41
+ locale,
42
+ localeList,
43
+ setLocale
44
+ }
45
+ ),
46
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DictionaryListDrawer.DictionaryListDrawer, {})
47
+ ] })
48
+ ] }) });
49
+ };
42
50
  // Annotate the CommonJS export names for ESM import in node:
43
51
  0 && (module.exports = {
44
52
  ContentEditionLayout
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/ContentEditionLayout.tsx"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport type { FC, ReactNode } from 'react';\nimport { EditionPanel } from './EditionPanel/index';\n\nexport type ContentEditionLayoutProps = {\n children?: ReactNode;\n locale: Locales;\n localeList: Locales[];\n setLocale: (locale: Locales) => void;\n};\n\nexport const ContentEditionLayout: FC<ContentEditionLayoutProps> = ({\n children,\n locale,\n setLocale,\n localeList,\n}) => (\n <>\n {children}\n <EditionPanel\n locale={locale}\n localeList={localeList}\n setLocale={setLocale}\n />\n </>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBE;AAfF,0BAA6B;AAStB,MAAM,uBAAsD,CAAC;AAAA,EAClE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MACE,4EACG;AAAA;AAAA,EACD;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF;AAAA,GACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/ContentEditionLayout.tsx"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport type { FC, ReactNode } from 'react';\nimport { IntlayerEditorProvider } from './ContentEditorProvider';\nimport { DictionaryEditionDrawerController } from './DictionaryEditionDrawer/index';\nimport { DictionaryListDrawer } from './DictionaryListDrawer/index';\n\nexport type ContentEditionLayoutProps = {\n children?: ReactNode;\n locale: Locales;\n localeList: Locales[];\n setLocale: (locale: Locales) => void;\n editorEnabled?: boolean;\n};\n\nexport const ContentEditionLayout: FC<ContentEditionLayoutProps> = ({\n children,\n locale,\n setLocale,\n localeList,\n editorEnabled = true,\n}) => {\n return (\n <>\n <IntlayerEditorProvider editorEnabled={editorEnabled}>\n {children}\n\n {editorEnabled && (\n <>\n <DictionaryEditionDrawerController\n locale={locale}\n localeList={localeList}\n setLocale={setLocale}\n />\n <DictionaryListDrawer />\n </>\n )}\n </IntlayerEditorProvider>\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BU;AAzBV,mCAAuC;AACvC,qCAAkD;AAClD,kCAAqC;AAU9B,MAAM,uBAAsD,CAAC;AAAA,EAClE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB;AAClB,MAAM;AACJ,SACE,2EACE,uDAAC,uDAAuB,eACrB;AAAA;AAAA,IAEA,iBACC,4EACE;AAAA;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACF;AAAA,MACA,4CAAC,oDAAqB;AAAA,OACxB;AAAA,KAEJ,GACF;AAEJ;","names":[]}
@@ -6,6 +6,7 @@ type ContentEditionLayoutProps = {
6
6
  locale: Locales;
7
7
  localeList: Locales[];
8
8
  setLocale: (locale: Locales) => void;
9
+ editorEnabled?: boolean;
9
10
  };
10
11
  declare const ContentEditionLayout: FC<ContentEditionLayoutProps>;
11
12
 
@@ -0,0 +1,47 @@
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 ContentEditorProvider_exports = {};
21
+ __export(ContentEditorProvider_exports, {
22
+ IntlayerEditorContext: () => IntlayerEditorContext,
23
+ IntlayerEditorProvider: () => IntlayerEditorProvider,
24
+ useIntlayerEditorContext: () => useIntlayerEditorContext
25
+ });
26
+ module.exports = __toCommonJS(ContentEditorProvider_exports);
27
+ var import_jsx_runtime = require("react/jsx-runtime");
28
+ var import_client = require("@intlayer/config/client");
29
+ var import_react = require("react");
30
+ const IntlayerEditorContext = (0, import_react.createContext)({
31
+ editorEnabled: false
32
+ });
33
+ const useIntlayerEditorContext = () => (0, import_react.useContext)(IntlayerEditorContext);
34
+ const {
35
+ editor: { enabled }
36
+ } = (0, import_client.getConfiguration)();
37
+ const IntlayerEditorProvider = ({
38
+ children,
39
+ editorEnabled = enabled
40
+ }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerEditorContext.Provider, { value: { editorEnabled }, children });
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ IntlayerEditorContext,
44
+ IntlayerEditorProvider,
45
+ useIntlayerEditorContext
46
+ });
47
+ //# sourceMappingURL=ContentEditorProvider.cjs.map
@@ -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} 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 <IntlayerEditorContext.Provider value={{ editorEnabled }}>\n {children}\n </IntlayerEditorContext.Provider>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyCE;AAvCF,oBAAiC;AACjC,mBAKO;AASA,MAAM,4BAAwB,4BAAmC;AAAA,EACtE,eAAe;AACjB,CAAC;AAKM,MAAM,2BAA2B,UAAM,yBAAW,qBAAqB;AAM9E,MAAM;AAAA,EACJ,QAAQ,EAAE,QAAQ;AACpB,QAAI,gCAAiB;AAKd,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA,gBAAgB;AAClB,MACE,4CAAC,sBAAsB,UAAtB,EAA+B,OAAO,EAAE,cAAc,GACpD,UACH;","names":[]}
@@ -0,0 +1,23 @@
1
+ import * as react from 'react';
2
+ import { PropsWithChildren, FC } from 'react';
3
+
4
+ type IntlayerEditorValue = {
5
+ editorEnabled: boolean;
6
+ };
7
+ /**
8
+ * Context that store the current locale on the client side
9
+ */
10
+ declare const IntlayerEditorContext: react.Context<IntlayerEditorValue>;
11
+ /**
12
+ * Hook that provides the current locale
13
+ */
14
+ declare const useIntlayerEditorContext: () => IntlayerEditorValue;
15
+ type IntlayerEditorProviderProps = PropsWithChildren & {
16
+ editorEnabled?: boolean;
17
+ };
18
+ /**
19
+ * Provider that store the current locale on the client side
20
+ */
21
+ declare const IntlayerEditorProvider: FC<IntlayerEditorProviderProps>;
22
+
23
+ export { IntlayerEditorContext, IntlayerEditorProvider, type IntlayerEditorProviderProps, useIntlayerEditorContext };
@@ -23,24 +23,41 @@ __export(ContentSelectorWrapper_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(ContentSelectorWrapper_exports);
25
25
  var import_jsx_runtime = require("react/jsx-runtime");
26
+ var import_core = require("@intlayer/core");
26
27
  var import_design_system = require("@intlayer/design-system");
27
- var import_useEditedContentStore = require('./EditionPanel/useEditedContentStore.cjs');
28
- var import_useEditionPanelStore = require('./EditionPanel/useEditionPanelStore.cjs');
28
+ var import_react = require("react");
29
+ var import_ContentEditorProvider = require('./ContentEditorProvider.cjs');
30
+ var import_useDictionaryEditionDrawer = require('./DictionaryEditionDrawer/useDictionaryEditionDrawer.cjs');
29
31
  const ContentSelectorWrapper = ({
30
32
  children,
31
33
  dictionaryId,
32
34
  dictionaryPath,
33
35
  keyPath
34
36
  }) => {
35
- const { setFocusedContent } = (0, import_useEditionPanelStore.useEditionPanelStore)();
36
- const handleSelect = () => setFocusedContent({
37
- dictionaryId,
38
- dictionaryPath,
39
- keyPath
40
- });
41
- const { getEditedContentValue } = (0, import_useEditedContentStore.useEditedContentStore)();
37
+ const { open, getEditedContentValue, focusedContent, isOpen } = (0, import_useDictionaryEditionDrawer.useDictionaryEditionDrawer)(dictionaryId);
42
38
  const editedValue = getEditedContentValue(dictionaryPath, keyPath);
43
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_design_system.ContentSelector, { onSelect: handleSelect, children: editedValue ?? children });
39
+ const { editorEnabled } = (0, import_react.useContext)(import_ContentEditorProvider.IntlayerEditorContext);
40
+ const handleSelect = (0, import_react.useCallback)(
41
+ () => open({
42
+ dictionaryId,
43
+ dictionaryPath,
44
+ keyPath
45
+ }),
46
+ [dictionaryId, dictionaryPath, keyPath, open]
47
+ );
48
+ const isSelected = (isOpen && (focusedContent?.keyPath?.length ?? 0) > 0 && (0, import_core.isSameKeyPath)(focusedContent?.keyPath ?? [], keyPath)) ?? false;
49
+ if (!editorEnabled) {
50
+ return children;
51
+ }
52
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
53
+ import_design_system.ContentSelector,
54
+ {
55
+ onSelect: handleSelect,
56
+ isSelecting: isSelected,
57
+ popoverContent: "Long press to edit",
58
+ children: editedValue ?? children
59
+ }
60
+ );
44
61
  };
45
62
  // Annotate the CommonJS export names for ESM import in node:
46
63
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport type { KeyPath } from '@intlayer/core';\nimport { ContentSelector } from '@intlayer/design-system';\nimport type { FC } from 'react';\nimport { useEditedContentStore } from './EditionPanel/useEditedContentStore';\nimport { useEditionPanelStore } from './EditionPanel/useEditionPanelStore';\n\ntype ContentSelectorWrapperProps = {\n children: string;\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 { setFocusedContent } = useEditionPanelStore();\n const handleSelect = () =>\n setFocusedContent({\n dictionaryId,\n dictionaryPath,\n keyPath,\n });\n\n const { getEditedContentValue } = useEditedContentStore();\n const editedValue = getEditedContentValue(dictionaryPath, keyPath);\n\n return (\n <ContentSelector onSelect={handleSelect}>\n {editedValue ?? children}\n </ContentSelector>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiCI;AA9BJ,2BAAgC;AAEhC,mCAAsC;AACtC,kCAAqC;AAS9B,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,kBAAkB,QAAI,kDAAqB;AACnD,QAAM,eAAe,MACnB,kBAAkB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAEH,QAAM,EAAE,sBAAsB,QAAI,oDAAsB;AACxD,QAAM,cAAc,sBAAsB,gBAAgB,OAAO;AAEjE,SACE,4CAAC,wCAAgB,UAAU,cACxB,yBAAe,UAClB;AAEJ;","names":[]}
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 { useCallback, useContext, type FC, type ReactNode } 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(dictionaryPath, keyPath);\n const { editorEnabled } = useContext(IntlayerEditorContext);\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 if (!editorEnabled) {\n return children;\n }\n\n return (\n <ContentSelector\n onSelect={handleSelect}\n isSelecting={isSelected}\n popoverContent=\"Long press to edit\"\n >\n {editedValue ?? children}\n </ContentSelector>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA+CI;AA7CJ,kBAA4C;AAC5C,2BAAgC;AAChC,mBAAiE;AACjE,mCAAsC;AACtC,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,gBAAgB,OAAO;AACjE,QAAM,EAAE,cAAc,QAAI,yBAAW,kDAAqB;AAE1D,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,cACH,WACE,gBAAgB,SAAS,UAAU,KAAK,SACzC,2BAAc,gBAAgB,WAAW,CAAC,GAAG,OAAO,MACtD;AAEF,MAAI,CAAC,eAAe;AAClB,WAAO;AAAA,EACT;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU;AAAA,MACV,aAAa;AAAA,MACb,gBAAe;AAAA,MAEd,yBAAe;AAAA;AAAA,EAClB;AAEJ;","names":[]}
@@ -1,8 +1,8 @@
1
1
  import { KeyPath } from '@intlayer/core';
2
- import { FC } from 'react';
2
+ import { FC, ReactNode } from 'react';
3
3
 
4
4
  type ContentSelectorWrapperProps = {
5
- children: string;
5
+ children: ReactNode;
6
6
  dictionaryId: string;
7
7
  dictionaryPath: string;
8
8
  keyPath: KeyPath[];
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var DictionaryEditionDrawer_exports = {};
31
+ __export(DictionaryEditionDrawer_exports, {
32
+ DictionaryEditionDrawer: () => DictionaryEditionDrawer,
33
+ DictionaryEditionDrawerContent: () => DictionaryEditionDrawerContent,
34
+ DictionaryEditionDrawerController: () => DictionaryEditionDrawerController,
35
+ getDrawerIdentifier: () => getDrawerIdentifier
36
+ });
37
+ module.exports = __toCommonJS(DictionaryEditionDrawer_exports);
38
+ var import_jsx_runtime = require("react/jsx-runtime");
39
+ var import_design_system = require("@intlayer/design-system");
40
+ var import_dictionaries_entry = __toESM(require("@intlayer/dictionaries-entry"));
41
+ var import_DictionaryListDrawer = require('../DictionaryListDrawer/index.cjs');
42
+ var import_useDictionaryEditionDrawer = require('./useDictionaryEditionDrawer.cjs');
43
+ var import_useFocusContentStore = require('./useFocusContentStore.cjs');
44
+ const DictionaryEditionDrawerContent = ({ focusedContent, locale, identifier }) => {
45
+ const {
46
+ setFocusedContent,
47
+ editContentRequest,
48
+ editedContent,
49
+ addEditedContent,
50
+ clearEditedDictionaryContent
51
+ } = (0, import_useDictionaryEditionDrawer.useDictionaryEditionDrawer)(identifier);
52
+ const dictionaryId = focusedContent.dictionaryId;
53
+ const dictionary = import_dictionaries_entry.default[dictionaryId];
54
+ const dictionaryPath = dictionary.filePath;
55
+ const editedDictionaryContent = editedContent[dictionaryPath];
56
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
57
+ import_design_system.DictionaryEditor,
58
+ {
59
+ dictionary,
60
+ locale,
61
+ focusedKeyPath: focusedContent.keyPath,
62
+ editedContent: editedDictionaryContent,
63
+ onFocusKeyPath: (keyPath) => setFocusedContent({ ...focusedContent, keyPath }),
64
+ onContentChange: (keyPath, newValue) => addEditedContent(dictionaryPath, keyPath, newValue),
65
+ onValidEdition: editContentRequest,
66
+ onCancelEdition: () => clearEditedDictionaryContent(dictionaryPath)
67
+ }
68
+ );
69
+ };
70
+ const getDrawerIdentifier = (dictionaryId) => `dictionary_edition_${dictionaryId}`;
71
+ const DictionaryEditionDrawer = ({
72
+ locale,
73
+ localeList,
74
+ setLocale,
75
+ dictionaryId
76
+ }) => {
77
+ const id = getDrawerIdentifier(dictionaryId);
78
+ const { focusedContent, close } = (0, import_useDictionaryEditionDrawer.useDictionaryEditionDrawer)(dictionaryId);
79
+ const { open: openDictionaryListDrawer } = (0, import_DictionaryListDrawer.useDictionaryListDrawer)();
80
+ const handleOnBack = () => {
81
+ close();
82
+ openDictionaryListDrawer();
83
+ };
84
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
85
+ import_design_system.RightDrawer,
86
+ {
87
+ title: dictionaryId,
88
+ identifier: id,
89
+ header: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
90
+ import_design_system.LocaleSwitcher,
91
+ {
92
+ setLocale,
93
+ locale,
94
+ localeList
95
+ }
96
+ ),
97
+ backButton: {
98
+ onBack: handleOnBack,
99
+ text: "Dictionary list"
100
+ },
101
+ children: focusedContent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
102
+ DictionaryEditionDrawerContent,
103
+ {
104
+ focusedContent,
105
+ locale,
106
+ identifier: id
107
+ }
108
+ )
109
+ }
110
+ );
111
+ };
112
+ const DictionaryEditionDrawerController = ({ locale, localeList, setLocale }) => {
113
+ const focusedContent = (0, import_useFocusContentStore.useEditionPanelStore)((s) => s.focusedContent);
114
+ const dictionaryId = focusedContent?.dictionaryId;
115
+ if (!dictionaryId) {
116
+ return null;
117
+ }
118
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
119
+ DictionaryEditionDrawer,
120
+ {
121
+ locale,
122
+ localeList,
123
+ setLocale,
124
+ dictionaryId
125
+ }
126
+ );
127
+ };
128
+ // Annotate the CommonJS export names for ESM import in node:
129
+ 0 && (module.exports = {
130
+ DictionaryEditionDrawer,
131
+ DictionaryEditionDrawerContent,
132
+ DictionaryEditionDrawerController,
133
+ getDrawerIdentifier
134
+ });
135
+ //# sourceMappingURL=DictionaryEditionDrawer.cjs.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 } from '@intlayer/core';\nimport {\n RightDrawer,\n DictionaryEditor,\n LocaleSwitcher,\n type FileContent,\n} from '@intlayer/design-system';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport type { FC } from 'react';\nimport { useDictionaryListDrawer } from '../DictionaryListDrawer/index';\nimport {\n type FileContent as FileContentWithDictionaryPath,\n useDictionaryEditionDrawer,\n} from './useDictionaryEditionDrawer';\nimport { useEditionPanelStore } from './useFocusContentStore';\n\ntype DictionaryEditionDrawerContentProps = {\n focusedContent: FileContentWithDictionaryPath;\n locale: Locales;\n identifier: string;\n};\n\nexport const DictionaryEditionDrawerContent: FC<\n DictionaryEditionDrawerContentProps\n> = ({ focusedContent, locale, identifier }) => {\n const {\n setFocusedContent,\n editContentRequest,\n editedContent,\n addEditedContent,\n clearEditedDictionaryContent,\n } = useDictionaryEditionDrawer(identifier);\n\n const dictionaryId: string = focusedContent.dictionaryId;\n const dictionary: Dictionary = dictionaries[dictionaryId];\n const dictionaryPath: string = dictionary.filePath;\n const editedDictionaryContent: FileContent[] = editedContent[dictionaryPath];\n\n return (\n <DictionaryEditor\n dictionary={dictionary}\n locale={locale}\n focusedKeyPath={focusedContent.keyPath}\n editedContent={editedDictionaryContent}\n onFocusKeyPath={(keyPath) =>\n setFocusedContent({ ...focusedContent, keyPath })\n }\n onContentChange={(keyPath, newValue) =>\n addEditedContent(dictionaryPath, keyPath, newValue)\n }\n onValidEdition={editContentRequest}\n onCancelEdition={() => clearEditedDictionaryContent(dictionaryPath)}\n />\n );\n};\n\ntype DictionaryEditionDrawerProps = DictionaryEditionDrawerControllerProps & {\n dictionaryId: string;\n};\n\nexport const getDrawerIdentifier = (dictionaryId: string) =>\n `dictionary_edition_${dictionaryId}`;\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 null;\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;AAAA;AA+CI;AA3CJ,2BAKO;AAMP,gCAAyB;AAEzB,kCAAwC;AACxC,wCAGO;AACP,kCAAqC;AAQ9B,MAAM,iCAET,CAAC,EAAE,gBAAgB,QAAQ,WAAW,MAAM;AAC9C,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,8DAA2B,UAAU;AAEzC,QAAM,eAAuB,eAAe;AAC5C,QAAM,aAAyB,0BAAAA,QAAa,YAAY;AACxD,QAAM,iBAAyB,WAAW;AAC1C,QAAM,0BAAyC,cAAc,cAAc;AAE3E,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,gBAAgB,eAAe;AAAA,MAC/B,eAAe;AAAA,MACf,gBAAgB,CAAC,YACf,kBAAkB,EAAE,GAAG,gBAAgB,QAAQ,CAAC;AAAA,MAElD,iBAAiB,CAAC,SAAS,aACzB,iBAAiB,gBAAgB,SAAS,QAAQ;AAAA,MAEpD,gBAAgB;AAAA,MAChB,iBAAiB,MAAM,6BAA6B,cAAc;AAAA;AAAA,EACpE;AAEJ;AAMO,MAAM,sBAAsB,CAAC,iBAClC,sBAAsB,YAAY;AAE7B,MAAM,0BAA4D,CAAC;AAAA,EACxE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,KAAK,oBAAoB,YAAY;AAE3C,QAAM,EAAE,gBAAgB,MAAM,QAAI,8DAA2B,YAAY;AACzE,QAAM,EAAE,MAAM,yBAAyB,QAAI,qDAAwB;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,qBAAiB,kDAAqB,CAAC,MAAM,EAAE,cAAc;AACnE,QAAM,eAAmC,gBAAgB;AAEzD,MAAI,CAAC,cAAc;AACjB,WAAO;AAAA,EACT;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;","names":["dictionaries"]}
@@ -0,0 +1,28 @@
1
+ import { Locales } from '@intlayer/config/client';
2
+ import { FC } from 'react';
3
+ import { FileContent } from './useDictionaryEditionDrawer.js';
4
+ import './useEditedContentStore.js';
5
+ import '@intlayer/core';
6
+ import 'zustand/middleware';
7
+ import 'zustand';
8
+ import '@intlayer/design-system';
9
+
10
+ type DictionaryEditionDrawerContentProps = {
11
+ focusedContent: FileContent;
12
+ locale: Locales;
13
+ identifier: string;
14
+ };
15
+ declare const DictionaryEditionDrawerContent: FC<DictionaryEditionDrawerContentProps>;
16
+ type DictionaryEditionDrawerProps = DictionaryEditionDrawerControllerProps & {
17
+ dictionaryId: string;
18
+ };
19
+ declare const getDrawerIdentifier: (dictionaryId: string) => string;
20
+ declare const DictionaryEditionDrawer: FC<DictionaryEditionDrawerProps>;
21
+ type DictionaryEditionDrawerControllerProps = {
22
+ locale: Locales;
23
+ localeList: Locales[];
24
+ setLocale: (locale: Locales) => void;
25
+ };
26
+ declare const DictionaryEditionDrawerController: FC<DictionaryEditionDrawerControllerProps>;
27
+
28
+ export { DictionaryEditionDrawer, DictionaryEditionDrawerContent, DictionaryEditionDrawerController, getDrawerIdentifier };