intlayer-editor 2.0.0 → 2.1.0

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 (127) hide show
  1. package/README.md +51 -135
  2. package/dist/cjs/client/ContentEditionLayout.cjs +5 -3
  3. package/dist/cjs/client/ContentEditionLayout.cjs.map +1 -1
  4. package/dist/cjs/client/ContentSelectorWrapper.cjs +14 -10
  5. package/dist/cjs/client/ContentSelectorWrapper.cjs.map +1 -1
  6. package/dist/cjs/client/ContentSelectorWrapper.d.ts +2 -2
  7. package/dist/cjs/client/DictionaryEditionDrawer/DictionaryEditionDrawer.cjs +135 -0
  8. package/dist/cjs/client/DictionaryEditionDrawer/DictionaryEditionDrawer.cjs.map +1 -0
  9. package/dist/cjs/client/DictionaryEditionDrawer/DictionaryEditionDrawer.d.ts +28 -0
  10. package/dist/cjs/client/DictionaryEditionDrawer/index.cjs +27 -0
  11. package/dist/cjs/client/DictionaryEditionDrawer/index.cjs.map +1 -0
  12. package/dist/cjs/client/DictionaryEditionDrawer/index.d.ts +9 -0
  13. package/dist/cjs/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.cjs +103 -0
  14. package/dist/cjs/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.cjs.map +1 -0
  15. package/dist/cjs/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.d.ts +32 -0
  16. package/dist/cjs/client/{EditionPanel → DictionaryEditionDrawer}/useEditedContentStore.cjs +19 -11
  17. package/dist/cjs/client/DictionaryEditionDrawer/useEditedContentStore.cjs.map +1 -0
  18. package/dist/cjs/client/{EditionPanel/useEditionPanelStore.cjs → DictionaryEditionDrawer/useFocusContentStore.cjs} +4 -4
  19. package/dist/cjs/client/DictionaryEditionDrawer/useFocusContentStore.cjs.map +1 -0
  20. package/dist/cjs/client/{EditionPanel/useEditionPanelStore.d.ts → DictionaryEditionDrawer/useFocusContentStore.d.ts} +1 -1
  21. package/dist/cjs/client/DictionaryListDrawer/DictionaryListDrawer.cjs +74 -0
  22. package/dist/cjs/client/DictionaryListDrawer/DictionaryListDrawer.cjs.map +1 -0
  23. package/dist/cjs/client/DictionaryListDrawer/DictionaryListDrawer.d.ts +5 -0
  24. package/dist/cjs/client/{EditionPanel → DictionaryListDrawer}/index.cjs +6 -8
  25. package/dist/cjs/client/DictionaryListDrawer/index.cjs.map +1 -0
  26. package/dist/cjs/client/DictionaryListDrawer/index.d.ts +3 -0
  27. package/dist/cjs/client/{renderContentSelector.cjs → DictionaryListDrawer/useDictionaryListDrawer.cjs} +11 -17
  28. package/dist/cjs/client/DictionaryListDrawer/useDictionaryListDrawer.cjs.map +1 -0
  29. package/dist/cjs/client/DictionaryListDrawer/useDictionaryListDrawer.d.ts +8 -0
  30. package/dist/cjs/client/index.cjs +7 -5
  31. package/dist/cjs/client/index.cjs.map +1 -1
  32. package/dist/cjs/client/index.d.ts +8 -7
  33. package/dist/cjs/client/renderContentEditor.cjs +48 -0
  34. package/dist/cjs/client/renderContentEditor.cjs.map +1 -0
  35. package/dist/cjs/client/renderContentEditor.d.ts +15 -0
  36. package/dist/cjs/client/useEditorServer.cjs +5 -2
  37. package/dist/cjs/client/useEditorServer.cjs.map +1 -1
  38. package/dist/cjs/server/formatPrettier.cjs +51 -0
  39. package/dist/cjs/server/formatPrettier.cjs.map +1 -0
  40. package/dist/cjs/server/formatPrettier.d.ts +6 -0
  41. package/dist/cjs/server/index.cjs +2 -2
  42. package/dist/cjs/server/index.cjs.map +1 -1
  43. package/dist/cjs/server/{content-editor.cjs → processEdition.cjs} +41 -38
  44. package/dist/cjs/server/processEdition.cjs.map +1 -0
  45. package/dist/cjs/server/processEdition.d.ts +12 -0
  46. package/dist/esm/client/ContentEditionLayout.mjs +5 -3
  47. package/dist/esm/client/ContentEditionLayout.mjs.map +1 -1
  48. package/dist/esm/client/ContentSelectorWrapper.d.mts +2 -2
  49. package/dist/esm/client/ContentSelectorWrapper.mjs +14 -10
  50. package/dist/esm/client/ContentSelectorWrapper.mjs.map +1 -1
  51. package/dist/esm/client/DictionaryEditionDrawer/DictionaryEditionDrawer.d.mts +28 -0
  52. package/dist/esm/client/DictionaryEditionDrawer/DictionaryEditionDrawer.mjs +104 -0
  53. package/dist/esm/client/DictionaryEditionDrawer/DictionaryEditionDrawer.mjs.map +1 -0
  54. package/dist/esm/client/DictionaryEditionDrawer/index.d.mts +9 -0
  55. package/dist/esm/client/DictionaryEditionDrawer/index.mjs +4 -0
  56. package/dist/esm/client/DictionaryEditionDrawer/index.mjs.map +1 -0
  57. package/dist/esm/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.d.mts +32 -0
  58. package/dist/esm/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.mjs +80 -0
  59. package/dist/esm/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.mjs.map +1 -0
  60. package/dist/esm/client/{EditionPanel → DictionaryEditionDrawer}/useEditedContentStore.mjs +17 -9
  61. package/dist/esm/client/DictionaryEditionDrawer/useEditedContentStore.mjs.map +1 -0
  62. package/dist/esm/client/{EditionPanel/useEditionPanelStore.d.mts → DictionaryEditionDrawer/useFocusContentStore.d.mts} +1 -1
  63. package/dist/esm/client/{EditionPanel/useEditionPanelStore.mjs → DictionaryEditionDrawer/useFocusContentStore.mjs} +1 -1
  64. package/dist/esm/client/DictionaryEditionDrawer/useFocusContentStore.mjs.map +1 -0
  65. package/dist/esm/client/DictionaryListDrawer/DictionaryListDrawer.d.mts +5 -0
  66. package/dist/esm/client/DictionaryListDrawer/DictionaryListDrawer.mjs +46 -0
  67. package/dist/esm/client/DictionaryListDrawer/DictionaryListDrawer.mjs.map +1 -0
  68. package/dist/esm/client/DictionaryListDrawer/index.d.mts +3 -0
  69. package/dist/esm/client/DictionaryListDrawer/index.mjs +3 -0
  70. package/dist/esm/client/DictionaryListDrawer/index.mjs.map +1 -0
  71. package/dist/esm/client/DictionaryListDrawer/useDictionaryListDrawer.d.mts +8 -0
  72. package/dist/esm/client/DictionaryListDrawer/useDictionaryListDrawer.mjs +8 -0
  73. package/dist/esm/client/DictionaryListDrawer/useDictionaryListDrawer.mjs.map +1 -0
  74. package/dist/esm/client/index.d.mts +8 -7
  75. package/dist/esm/client/index.mjs +3 -2
  76. package/dist/esm/client/index.mjs.map +1 -1
  77. package/dist/esm/client/renderContentEditor.d.mts +15 -0
  78. package/dist/esm/client/renderContentEditor.mjs +24 -0
  79. package/dist/esm/client/renderContentEditor.mjs.map +1 -0
  80. package/dist/esm/client/useEditorServer.mjs +5 -2
  81. package/dist/esm/client/useEditorServer.mjs.map +1 -1
  82. package/dist/esm/server/formatPrettier.d.mts +6 -0
  83. package/dist/esm/server/formatPrettier.mjs +17 -0
  84. package/dist/esm/server/formatPrettier.mjs.map +1 -0
  85. package/dist/esm/server/index.mjs +2 -2
  86. package/dist/esm/server/index.mjs.map +1 -1
  87. package/dist/esm/server/processEdition.d.mts +12 -0
  88. package/dist/esm/server/{content-editor.mjs → processEdition.mjs} +36 -23
  89. package/dist/esm/server/processEdition.mjs.map +1 -0
  90. package/package.json +6 -7
  91. package/dist/cjs/client/EditionPanel/EditionPanel.cjs +0 -101
  92. package/dist/cjs/client/EditionPanel/EditionPanel.cjs.map +0 -1
  93. package/dist/cjs/client/EditionPanel/EditionPanel.d.ts +0 -11
  94. package/dist/cjs/client/EditionPanel/index.cjs.map +0 -1
  95. package/dist/cjs/client/EditionPanel/index.d.ts +0 -9
  96. package/dist/cjs/client/EditionPanel/useEditedContentStore.cjs.map +0 -1
  97. package/dist/cjs/client/EditionPanel/useEditionPanelStore.cjs.map +0 -1
  98. package/dist/cjs/client/renderContentSelector.cjs.map +0 -1
  99. package/dist/cjs/client/renderContentSelector.d.ts +0 -6
  100. package/dist/cjs/server/content-editor.cjs.map +0 -1
  101. package/dist/cjs/server/content-editor.d.ts +0 -12
  102. package/dist/esm/client/EditionPanel/EditionPanel.d.mts +0 -11
  103. package/dist/esm/client/EditionPanel/EditionPanel.mjs +0 -72
  104. package/dist/esm/client/EditionPanel/EditionPanel.mjs.map +0 -1
  105. package/dist/esm/client/EditionPanel/index.d.mts +0 -9
  106. package/dist/esm/client/EditionPanel/index.mjs +0 -4
  107. package/dist/esm/client/EditionPanel/index.mjs.map +0 -1
  108. package/dist/esm/client/EditionPanel/useEditedContentStore.mjs.map +0 -1
  109. package/dist/esm/client/EditionPanel/useEditionPanelStore.mjs.map +0 -1
  110. package/dist/esm/client/renderContentSelector.d.mts +0 -6
  111. package/dist/esm/client/renderContentSelector.mjs +0 -15
  112. package/dist/esm/client/renderContentSelector.mjs.map +0 -1
  113. package/dist/esm/server/content-editor.d.mts +0 -12
  114. package/dist/esm/server/content-editor.mjs.map +0 -1
  115. package/src/client/ContentEditionLayout.tsx +0 -26
  116. package/src/client/ContentSelectorWrapper.tsx +0 -38
  117. package/src/client/EditionPanel/EditionPanel.tsx +0 -90
  118. package/src/client/EditionPanel/index.ts +0 -3
  119. package/src/client/EditionPanel/useEditedContentStore.ts +0 -98
  120. package/src/client/EditionPanel/useEditionPanelStore.ts +0 -19
  121. package/src/client/index.ts +0 -4
  122. package/src/client/renderContentSelector.tsx +0 -17
  123. package/src/client/useEditorServer.ts +0 -31
  124. package/src/server/content-editor.ts +0 -209
  125. package/src/server/index.ts +0 -40
  126. /package/dist/cjs/client/{EditionPanel → DictionaryEditionDrawer}/useEditedContentStore.d.ts +0 -0
  127. /package/dist/esm/client/{EditionPanel → DictionaryEditionDrawer}/useEditedContentStore.d.mts +0 -0
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/intlayer_with_nextjs.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/intlayer_with_create_react_app.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/intlayer_with_vite+react.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/content_declaration/get_started.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/configuration.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,7 +22,8 @@ __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_DictionaryEditionDrawer = require('./DictionaryEditionDrawer/index.cjs');
26
+ var import_DictionaryListDrawer = require('./DictionaryListDrawer/index.cjs');
26
27
  const ContentEditionLayout = ({
27
28
  children,
28
29
  locale,
@@ -31,13 +32,14 @@ const ContentEditionLayout = ({
31
32
  }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
32
33
  children,
33
34
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
34
- import_EditionPanel.EditionPanel,
35
+ import_DictionaryEditionDrawer.DictionaryEditionDrawerController,
35
36
  {
36
37
  locale,
37
38
  localeList,
38
39
  setLocale
39
40
  }
40
- )
41
+ ),
42
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DictionaryListDrawer.DictionaryListDrawer, {})
41
43
  ] });
42
44
  // Annotate the CommonJS export names for ESM import in node:
43
45
  0 && (module.exports = {
@@ -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 { 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};\n\nexport const ContentEditionLayout: FC<ContentEditionLayoutProps> = ({\n children,\n locale,\n setLocale,\n localeList,\n}) => (\n <>\n {children}\n <DictionaryEditionDrawerController\n locale={locale}\n localeList={localeList}\n setLocale={setLocale}\n />\n <DictionaryListDrawer />\n </>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBE;AAhBF,qCAAkD;AAClD,kCAAqC;AAS9B,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,EACA,4CAAC,oDAAqB;AAAA,GACxB;","names":[]}
@@ -23,24 +23,28 @@ __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_useDictionaryEditionDrawer = require('./DictionaryEditionDrawer/useDictionaryEditionDrawer.cjs');
29
30
  const ContentSelectorWrapper = ({
30
31
  children,
31
32
  dictionaryId,
32
33
  dictionaryPath,
33
34
  keyPath
34
35
  }) => {
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)();
36
+ const { open, getEditedContentValue, focusedContent, isOpen } = (0, import_useDictionaryEditionDrawer.useDictionaryEditionDrawer)(dictionaryId);
42
37
  const editedValue = getEditedContentValue(dictionaryPath, keyPath);
43
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_design_system.ContentSelector, { onSelect: handleSelect, children: editedValue ?? children });
38
+ const handleSelect = (0, import_react.useCallback)(
39
+ () => open({
40
+ dictionaryId,
41
+ dictionaryPath,
42
+ keyPath
43
+ }),
44
+ [dictionaryId, dictionaryPath, keyPath, open]
45
+ );
46
+ const isSelected = (isOpen && (focusedContent?.keyPath?.length ?? 0) > 0 && (0, import_core.isSameKeyPath)(focusedContent?.keyPath ?? [], keyPath)) ?? false;
47
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_design_system.ContentSelector, { onSelect: handleSelect, isSelecting: isSelected, children: editedValue ?? children });
44
48
  };
45
49
  // Annotate the CommonJS export names for ESM import in node:
46
50
  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, type FC, type ReactNode } from 'react';\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\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 return (\n <ContentSelector onSelect={handleSelect} isSelecting={isSelected}>\n {editedValue ?? children}\n </ContentSelector>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAyCI;AAvCJ,kBAA4C;AAC5C,2BAAgC;AAChC,mBAAqD;AACrD,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;AAEjE,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,SACE,4CAAC,wCAAgB,UAAU,cAAc,aAAa,YACnD,yBAAe,UAClB;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 };
@@ -0,0 +1,27 @@
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
+ __reExport(DictionaryEditionDrawer_exports, require('./useEditedContentStore.cjs'), module.exports);
21
+ // Annotate the CommonJS export names for ESM import in node:
22
+ 0 && (module.exports = {
23
+ ...require('./DictionaryEditionDrawer.cjs'),
24
+ ...require('./useDictionaryEditionDrawer.cjs'),
25
+ ...require('./useEditedContentStore.cjs')
26
+ });
27
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/client/DictionaryEditionDrawer/index.ts"],"sourcesContent":["export * from './DictionaryEditionDrawer';\nexport * from './useDictionaryEditionDrawer';\nexport * from './useEditedContentStore';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,4CAAc,sCAAd;AACA,4CAAc,yCADd;AAEA,4CAAc,oCAFd;","names":[]}
@@ -0,0 +1,9 @@
1
+ export { DictionaryEditionDrawer, DictionaryEditionDrawerContent, DictionaryEditionDrawerController, getDrawerIdentifier } from './DictionaryEditionDrawer.js';
2
+ export { FileContent, useDictionaryEditionDrawer, useDictionaryEditionDrawerControl } from './useDictionaryEditionDrawer.js';
3
+ export { EditedContent, useEditedContentStore } from './useEditedContentStore.js';
4
+ import '@intlayer/config/client';
5
+ import 'react';
6
+ import '@intlayer/core';
7
+ import 'zustand/middleware';
8
+ import 'zustand';
9
+ import '@intlayer/design-system';
@@ -0,0 +1,103 @@
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
+ useDictionaryEditionDrawer: () => useDictionaryEditionDrawer,
22
+ useDictionaryEditionDrawerControl: () => useDictionaryEditionDrawerControl
23
+ });
24
+ module.exports = __toCommonJS(useDictionaryEditionDrawer_exports);
25
+ var import_design_system = require("@intlayer/design-system");
26
+ var import_useEditorServer = require('../useEditorServer.cjs');
27
+ var import_DictionaryEditionDrawer = require('./DictionaryEditionDrawer.cjs');
28
+ var import_useEditedContentStore = require('./useEditedContentStore.cjs');
29
+ var import_useFocusContentStore = require('./useFocusContentStore.cjs');
30
+ const useDictionaryEditionDrawer = (dictionaryId) => {
31
+ const id = (0, import_DictionaryEditionDrawer.getDrawerIdentifier)(dictionaryId);
32
+ const { isOpen, open, close } = (0, import_design_system.useRightDrawerStore)(id)();
33
+ const {
34
+ editedContent,
35
+ getEditedContentValue,
36
+ addEditedContent,
37
+ clearEditedDictionaryContent
38
+ } = (0, import_useEditedContentStore.useEditedContentStore)((s) => ({
39
+ editedContent: s.editedContent,
40
+ addEditedContent: s.addEditedContent,
41
+ getEditedContentValue: s.getEditedContentValue,
42
+ clearEditedDictionaryContent: s.clearEditedDictionaryContent
43
+ }));
44
+ const { setFocusedContent, focusedContent } = (0, import_useFocusContentStore.useEditionPanelStore)((s) => ({
45
+ focusedContent: s.focusedContent,
46
+ setFocusedContent: s.setFocusedContent
47
+ }));
48
+ const { editContentRequest } = (0, import_useEditorServer.useEditorServer)();
49
+ const openDictionaryEditionDrawer = ({
50
+ dictionaryId: dictionaryId2,
51
+ dictionaryPath,
52
+ keyPath = []
53
+ }) => {
54
+ setFocusedContent({
55
+ dictionaryId: dictionaryId2,
56
+ dictionaryPath,
57
+ keyPath
58
+ });
59
+ open();
60
+ };
61
+ return {
62
+ isOpen,
63
+ focusedContent,
64
+ setFocusedContent,
65
+ open: openDictionaryEditionDrawer,
66
+ close,
67
+ getEditedContentValue,
68
+ editContentRequest,
69
+ editedContent,
70
+ addEditedContent,
71
+ clearEditedDictionaryContent
72
+ };
73
+ };
74
+ const useDictionaryEditionDrawerControl = () => {
75
+ const setFocusedContent = (0, import_useFocusContentStore.useEditionPanelStore)((s) => s.setFocusedContent);
76
+ const open = ({
77
+ dictionaryId,
78
+ dictionaryPath,
79
+ keyPath = []
80
+ }) => {
81
+ setFocusedContent({
82
+ dictionaryId,
83
+ dictionaryPath,
84
+ keyPath
85
+ });
86
+ const id = (0, import_DictionaryEditionDrawer.getDrawerIdentifier)(dictionaryId);
87
+ (0, import_design_system.useRightDrawerStore)(id).getState().open();
88
+ };
89
+ const close = (dictionaryId) => {
90
+ const id = (0, import_DictionaryEditionDrawer.getDrawerIdentifier)(dictionaryId);
91
+ (0, import_design_system.useRightDrawerStore)(id).getState().close();
92
+ };
93
+ return {
94
+ open,
95
+ close
96
+ };
97
+ };
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ useDictionaryEditionDrawer,
101
+ useDictionaryEditionDrawerControl
102
+ });
103
+ //# sourceMappingURL=useDictionaryEditionDrawer.cjs.map