@strapi/content-type-builder 5.8.1 → 5.10.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 (210) hide show
  1. package/dist/admin/chunks/ListView-CDnrvVrV.mjs +1184 -0
  2. package/dist/admin/chunks/ListView-CDnrvVrV.mjs.map +1 -0
  3. package/dist/admin/chunks/ListView-CQwvSbZH.js +1186 -0
  4. package/dist/admin/chunks/ListView-CQwvSbZH.js.map +1 -0
  5. package/dist/admin/chunks/ar-Df0f0-PT.js +52 -0
  6. package/dist/admin/chunks/ar-Df0f0-PT.js.map +1 -0
  7. package/dist/admin/chunks/ar-sRW9VFC-.mjs +49 -0
  8. package/dist/admin/chunks/ar-sRW9VFC-.mjs.map +1 -0
  9. package/dist/admin/chunks/cs-BpQ26jiq.mjs +136 -0
  10. package/dist/{_chunks/cs-ChL4LaFY.mjs.map → admin/chunks/cs-BpQ26jiq.mjs.map} +1 -1
  11. package/dist/admin/chunks/cs-DeTwqc7p.js +140 -0
  12. package/dist/{_chunks/cs-Ci3js5EC.js.map → admin/chunks/cs-DeTwqc7p.js.map} +1 -1
  13. package/dist/admin/chunks/de-BJkS06jF.js +194 -0
  14. package/dist/{_chunks/de-DnlblIOh.js.map → admin/chunks/de-BJkS06jF.js.map} +1 -1
  15. package/dist/admin/chunks/de-DSxx5_x-.mjs +190 -0
  16. package/dist/{_chunks/de-DsHQNzp2.mjs.map → admin/chunks/de-DSxx5_x-.mjs.map} +1 -1
  17. package/dist/admin/chunks/dk-BnjVZ7A_.mjs +180 -0
  18. package/dist/{_chunks/es-BE_zx2_w.mjs.map → admin/chunks/dk-BnjVZ7A_.mjs.map} +1 -1
  19. package/dist/admin/chunks/dk-CGm-qVH7.js +184 -0
  20. package/dist/{_chunks/dk-D3XnOjYz.js.map → admin/chunks/dk-CGm-qVH7.js.map} +1 -1
  21. package/dist/admin/chunks/en-BJUu34b0.js +217 -0
  22. package/dist/{_chunks/en-CXG5y_vo.js.map → admin/chunks/en-BJUu34b0.js.map} +1 -1
  23. package/dist/admin/chunks/en-Bhut8Yay.mjs +213 -0
  24. package/dist/{_chunks/en-jBwb53yg.mjs.map → admin/chunks/en-Bhut8Yay.mjs.map} +1 -1
  25. package/dist/admin/chunks/es-DG8g9igJ.mjs +180 -0
  26. package/dist/admin/chunks/es-DG8g9igJ.mjs.map +1 -0
  27. package/dist/admin/chunks/es-J8kvHlNy.js +184 -0
  28. package/dist/{_chunks/es-DL8lez9W.js.map → admin/chunks/es-J8kvHlNy.js.map} +1 -1
  29. package/dist/admin/chunks/fr-C6y35iY7.js +76 -0
  30. package/dist/admin/chunks/fr-C6y35iY7.js.map +1 -0
  31. package/dist/admin/chunks/fr-UpV34MHY.mjs +73 -0
  32. package/dist/admin/chunks/fr-UpV34MHY.mjs.map +1 -0
  33. package/dist/admin/chunks/id-BWM18ljw.mjs +163 -0
  34. package/dist/{_chunks/ru-DGSjru5m.mjs.map → admin/chunks/id-BWM18ljw.mjs.map} +1 -1
  35. package/dist/admin/chunks/id-BvxV6wLP.js +167 -0
  36. package/dist/{_chunks/ru-C8A_4j0w.js.map → admin/chunks/id-BvxV6wLP.js.map} +1 -1
  37. package/dist/admin/chunks/index-BQ2VO38W.js +7781 -0
  38. package/dist/admin/chunks/index-BQ2VO38W.js.map +1 -0
  39. package/dist/admin/chunks/index-BZeN5KRn.js +1421 -0
  40. package/dist/admin/chunks/index-BZeN5KRn.js.map +1 -0
  41. package/dist/admin/chunks/index-BhX2euW0.mjs +1384 -0
  42. package/dist/admin/chunks/index-BhX2euW0.mjs.map +1 -0
  43. package/dist/admin/chunks/index-Cr5tfW7U.mjs +7754 -0
  44. package/dist/admin/chunks/index-Cr5tfW7U.mjs.map +1 -0
  45. package/dist/admin/chunks/it-1_vd9gV4.mjs +164 -0
  46. package/dist/{_chunks/tr-DsUerr-c.mjs.map → admin/chunks/it-1_vd9gV4.mjs.map} +1 -1
  47. package/dist/admin/chunks/it-C_IgFU-G.js +168 -0
  48. package/dist/{_chunks/sk-raWRcmPT.js.map → admin/chunks/it-C_IgFU-G.js.map} +1 -1
  49. package/dist/admin/chunks/ja-CWo4Qqq6.js +51 -0
  50. package/dist/admin/chunks/ja-CWo4Qqq6.js.map +1 -0
  51. package/dist/admin/chunks/ja-Cx23a2Ui.mjs +48 -0
  52. package/dist/admin/chunks/ja-Cx23a2Ui.mjs.map +1 -0
  53. package/dist/admin/chunks/ko-BsByJNEl.js +184 -0
  54. package/dist/admin/chunks/ko-BsByJNEl.js.map +1 -0
  55. package/dist/admin/chunks/ko-DC7paEx5.mjs +180 -0
  56. package/dist/admin/chunks/ko-DC7paEx5.mjs.map +1 -0
  57. package/dist/admin/chunks/ms-C3s4kxq6.mjs +160 -0
  58. package/dist/{_chunks/id-W1sKBFEw.mjs.map → admin/chunks/ms-C3s4kxq6.mjs.map} +1 -1
  59. package/dist/admin/chunks/ms-DPTzS7SH.js +164 -0
  60. package/dist/{_chunks/th-C83Bb_kR.js.map → admin/chunks/ms-DPTzS7SH.js.map} +1 -1
  61. package/dist/admin/chunks/nl-TzvfktV_.mjs +153 -0
  62. package/dist/{_chunks/nl-BaTAuelQ.mjs.map → admin/chunks/nl-TzvfktV_.mjs.map} +1 -1
  63. package/dist/admin/chunks/nl-db29QMOx.js +157 -0
  64. package/dist/{_chunks/nl-DQjrDEw0.js.map → admin/chunks/nl-db29QMOx.js.map} +1 -1
  65. package/dist/admin/chunks/pl-BdvupIN_.mjs +190 -0
  66. package/dist/admin/chunks/pl-BdvupIN_.mjs.map +1 -0
  67. package/dist/admin/chunks/pl-pYy1djj3.js +194 -0
  68. package/dist/admin/chunks/pl-pYy1djj3.js.map +1 -0
  69. package/dist/admin/chunks/pt-BQmWcdeG.js +52 -0
  70. package/dist/admin/chunks/pt-BQmWcdeG.js.map +1 -0
  71. package/dist/admin/chunks/pt-BR-CTPuXGWF.js +194 -0
  72. package/dist/{_chunks/pt-BR-DPd5nRnl.js.map → admin/chunks/pt-BR-CTPuXGWF.js.map} +1 -1
  73. package/dist/admin/chunks/pt-BR-DPrVmKeZ.mjs +190 -0
  74. package/dist/{_chunks/pt-BR-CCQGwXs0.mjs.map → admin/chunks/pt-BR-DPrVmKeZ.mjs.map} +1 -1
  75. package/dist/admin/chunks/pt-BTLIwmCv.mjs +49 -0
  76. package/dist/admin/chunks/pt-BTLIwmCv.mjs.map +1 -0
  77. package/dist/admin/chunks/ru-D46no502.mjs +165 -0
  78. package/dist/{_chunks/dk-BC7NAQR2.mjs.map → admin/chunks/ru-D46no502.mjs.map} +1 -1
  79. package/dist/admin/chunks/ru-DQiDXgUV.js +169 -0
  80. package/dist/admin/chunks/ru-DQiDXgUV.js.map +1 -0
  81. package/dist/admin/chunks/sk-Byr_l4Jc.mjs +164 -0
  82. package/dist/{_chunks/ko-DoNsXHXA.mjs.map → admin/chunks/sk-Byr_l4Jc.mjs.map} +1 -1
  83. package/dist/admin/chunks/sk-DrnebmXb.js +168 -0
  84. package/dist/{_chunks/it-DS4sM3km.js.map → admin/chunks/sk-DrnebmXb.js.map} +1 -1
  85. package/dist/admin/chunks/sv-Bbam7IDm.mjs +199 -0
  86. package/dist/admin/chunks/sv-Bbam7IDm.mjs.map +1 -0
  87. package/dist/admin/chunks/sv-CrWlNosi.js +203 -0
  88. package/dist/admin/chunks/sv-CrWlNosi.js.map +1 -0
  89. package/dist/admin/chunks/th-BbrCkfgX.js +165 -0
  90. package/dist/{_chunks/id-DYuTgqcc.js.map → admin/chunks/th-BbrCkfgX.js.map} +1 -1
  91. package/dist/admin/chunks/th-hfS0Wmk_.mjs +161 -0
  92. package/dist/{_chunks/it-D04lb2Wc.mjs.map → admin/chunks/th-hfS0Wmk_.mjs.map} +1 -1
  93. package/dist/admin/chunks/tr-CHdMj8m6.js +180 -0
  94. package/dist/admin/chunks/tr-CHdMj8m6.js.map +1 -0
  95. package/dist/admin/chunks/tr-DS7DBOhC.mjs +176 -0
  96. package/dist/admin/chunks/tr-DS7DBOhC.mjs.map +1 -0
  97. package/dist/admin/chunks/uk-BQEQ3weH.js +165 -0
  98. package/dist/{_chunks/uk-VwB0oiuV.js.map → admin/chunks/uk-BQEQ3weH.js.map} +1 -1
  99. package/dist/admin/chunks/uk-Cj8-BKeu.mjs +161 -0
  100. package/dist/{_chunks/sk-DVK4HfSC.mjs.map → admin/chunks/uk-Cj8-BKeu.mjs.map} +1 -1
  101. package/dist/admin/chunks/zh-BUVXH75-.mjs +199 -0
  102. package/dist/admin/chunks/zh-BUVXH75-.mjs.map +1 -0
  103. package/dist/admin/chunks/zh-CWj4avQA.js +203 -0
  104. package/dist/admin/chunks/zh-CWj4avQA.js.map +1 -0
  105. package/dist/admin/chunks/zh-Hans-BElOnuRb.mjs +144 -0
  106. package/dist/{_chunks/zh-Hans-Cc0M5PXr.mjs.map → admin/chunks/zh-Hans-BElOnuRb.mjs.map} +1 -1
  107. package/dist/admin/chunks/zh-Hans-lXbNiMp9.js +148 -0
  108. package/dist/{_chunks/zh-Hans-CLTLm_nt.js.map → admin/chunks/zh-Hans-lXbNiMp9.js.map} +1 -1
  109. package/dist/admin/index.js +24 -4
  110. package/dist/admin/index.js.map +1 -1
  111. package/dist/admin/index.mjs +17 -7
  112. package/dist/admin/index.mjs.map +1 -1
  113. package/dist/admin/src/components/ContentTypeBuilderNav/useContentTypeBuilderMenu.d.ts +5 -2
  114. package/dist/admin/src/components/DataManagerProvider/reducer.d.ts +97 -6
  115. package/dist/admin/src/components/FormModal/reducer.d.ts +110 -4
  116. package/dist/admin/src/components/ListRow.d.ts +2 -1
  117. package/dist/admin/src/contexts/DataManagerContext.d.ts +4 -4
  118. package/dist/admin/src/index.d.ts +2 -1
  119. package/dist/admin/src/pages/ListView/LinkToCMSettingsView.d.ts +1 -2
  120. package/dist/admin/src/pluginId.d.ts +1 -1
  121. package/dist/admin/src/reducers.d.ts +8 -1
  122. package/dist/admin/src/types.d.ts +2 -5
  123. package/dist/server/index.js +2504 -2151
  124. package/dist/server/index.js.map +1 -1
  125. package/dist/server/index.mjs +2500 -2147
  126. package/dist/server/index.mjs.map +1 -1
  127. package/package.json +13 -10
  128. package/dist/_chunks/ListView-CsqdnKp3.mjs +0 -959
  129. package/dist/_chunks/ListView-CsqdnKp3.mjs.map +0 -1
  130. package/dist/_chunks/ListView-tgW460ly.js +0 -964
  131. package/dist/_chunks/ListView-tgW460ly.js.map +0 -1
  132. package/dist/_chunks/ar-BYDB75EB.mjs +0 -51
  133. package/dist/_chunks/ar-BYDB75EB.mjs.map +0 -1
  134. package/dist/_chunks/ar-OCxhAFUy.js +0 -51
  135. package/dist/_chunks/ar-OCxhAFUy.js.map +0 -1
  136. package/dist/_chunks/cs-ChL4LaFY.mjs +0 -139
  137. package/dist/_chunks/cs-Ci3js5EC.js +0 -139
  138. package/dist/_chunks/de-DnlblIOh.js +0 -193
  139. package/dist/_chunks/de-DsHQNzp2.mjs +0 -193
  140. package/dist/_chunks/dk-BC7NAQR2.mjs +0 -183
  141. package/dist/_chunks/dk-D3XnOjYz.js +0 -183
  142. package/dist/_chunks/en-CXG5y_vo.js +0 -216
  143. package/dist/_chunks/en-jBwb53yg.mjs +0 -216
  144. package/dist/_chunks/es-BE_zx2_w.mjs +0 -183
  145. package/dist/_chunks/es-DL8lez9W.js +0 -183
  146. package/dist/_chunks/fr-DnTxugIo.js +0 -75
  147. package/dist/_chunks/fr-DnTxugIo.js.map +0 -1
  148. package/dist/_chunks/fr-lU_OMJma.mjs +0 -75
  149. package/dist/_chunks/fr-lU_OMJma.mjs.map +0 -1
  150. package/dist/_chunks/id-DYuTgqcc.js +0 -166
  151. package/dist/_chunks/id-W1sKBFEw.mjs +0 -166
  152. package/dist/_chunks/index-AjJmuxjv.js +0 -1357
  153. package/dist/_chunks/index-AjJmuxjv.js.map +0 -1
  154. package/dist/_chunks/index-BhIIILgq.mjs +0 -6694
  155. package/dist/_chunks/index-BhIIILgq.mjs.map +0 -1
  156. package/dist/_chunks/index-D79WZLAU.js +0 -6730
  157. package/dist/_chunks/index-D79WZLAU.js.map +0 -1
  158. package/dist/_chunks/index-DIuvDpH9.mjs +0 -1331
  159. package/dist/_chunks/index-DIuvDpH9.mjs.map +0 -1
  160. package/dist/_chunks/it-D04lb2Wc.mjs +0 -167
  161. package/dist/_chunks/it-DS4sM3km.js +0 -167
  162. package/dist/_chunks/ja-BHLK_2_g.mjs +0 -50
  163. package/dist/_chunks/ja-BHLK_2_g.mjs.map +0 -1
  164. package/dist/_chunks/ja-BjouJgZf.js +0 -50
  165. package/dist/_chunks/ja-BjouJgZf.js.map +0 -1
  166. package/dist/_chunks/ko-D_71Pdfn.js +0 -183
  167. package/dist/_chunks/ko-D_71Pdfn.js.map +0 -1
  168. package/dist/_chunks/ko-DoNsXHXA.mjs +0 -183
  169. package/dist/_chunks/ms-BtGFDB9t.mjs +0 -163
  170. package/dist/_chunks/ms-BtGFDB9t.mjs.map +0 -1
  171. package/dist/_chunks/ms-Re1pSHmx.js +0 -163
  172. package/dist/_chunks/ms-Re1pSHmx.js.map +0 -1
  173. package/dist/_chunks/nl-BaTAuelQ.mjs +0 -156
  174. package/dist/_chunks/nl-DQjrDEw0.js +0 -156
  175. package/dist/_chunks/pl-BGwXgwH7.js +0 -193
  176. package/dist/_chunks/pl-BGwXgwH7.js.map +0 -1
  177. package/dist/_chunks/pl-CP2Zgp01.mjs +0 -193
  178. package/dist/_chunks/pl-CP2Zgp01.mjs.map +0 -1
  179. package/dist/_chunks/pt-BR-CCQGwXs0.mjs +0 -193
  180. package/dist/_chunks/pt-BR-DPd5nRnl.js +0 -193
  181. package/dist/_chunks/pt-CJoUDTHQ.js +0 -51
  182. package/dist/_chunks/pt-CJoUDTHQ.js.map +0 -1
  183. package/dist/_chunks/pt-DMeTMW2x.mjs +0 -51
  184. package/dist/_chunks/pt-DMeTMW2x.mjs.map +0 -1
  185. package/dist/_chunks/ru-C8A_4j0w.js +0 -168
  186. package/dist/_chunks/ru-DGSjru5m.mjs +0 -168
  187. package/dist/_chunks/sk-DVK4HfSC.mjs +0 -167
  188. package/dist/_chunks/sk-raWRcmPT.js +0 -167
  189. package/dist/_chunks/sv-BGb12eW3.mjs +0 -202
  190. package/dist/_chunks/sv-BGb12eW3.mjs.map +0 -1
  191. package/dist/_chunks/sv-BNN71SFE.js +0 -202
  192. package/dist/_chunks/sv-BNN71SFE.js.map +0 -1
  193. package/dist/_chunks/th--u3VqsON.mjs +0 -164
  194. package/dist/_chunks/th--u3VqsON.mjs.map +0 -1
  195. package/dist/_chunks/th-C83Bb_kR.js +0 -164
  196. package/dist/_chunks/tr-BW20CfcO.js +0 -179
  197. package/dist/_chunks/tr-BW20CfcO.js.map +0 -1
  198. package/dist/_chunks/tr-DsUerr-c.mjs +0 -179
  199. package/dist/_chunks/uk-Bx5IlOKX.mjs +0 -164
  200. package/dist/_chunks/uk-Bx5IlOKX.mjs.map +0 -1
  201. package/dist/_chunks/uk-VwB0oiuV.js +0 -164
  202. package/dist/_chunks/zh-BiOCwPJu.js +0 -202
  203. package/dist/_chunks/zh-BiOCwPJu.js.map +0 -1
  204. package/dist/_chunks/zh-CsUDN13W.mjs +0 -202
  205. package/dist/_chunks/zh-CsUDN13W.mjs.map +0 -1
  206. package/dist/_chunks/zh-Hans-CLTLm_nt.js +0 -147
  207. package/dist/_chunks/zh-Hans-Cc0M5PXr.mjs +0 -147
  208. package/dist/admin/src/components/DataManagerProvider/constants.d.ts +0 -17
  209. package/dist/admin/src/components/FormModal/constants.d.ts +0 -12
  210. package/dist/admin/src/pages/RecursivePath/RecursivePath.d.ts +0 -1
@@ -0,0 +1,1384 @@
1
+ import { ArrowClockwise, Clock, Layout } from '@strapi/icons';
2
+ import { createSlice } from '@reduxjs/toolkit';
3
+ import { current } from 'immer';
4
+ import get from 'lodash/get';
5
+ import set from 'lodash/set';
6
+ import snakeCase from 'lodash/snakeCase';
7
+ import pluralize from 'pluralize';
8
+ import slugify from '@sindresorhus/slugify';
9
+ import cloneDeep from 'lodash/cloneDeep';
10
+ import * as yup from 'yup';
11
+ import { jsxs, jsx } from 'react/jsx-runtime';
12
+ import * as React from 'react';
13
+ import { Flex, Box, Typography, Link } from '@strapi/design-system';
14
+ import { createPortal } from 'react-dom';
15
+ import { useIntl } from 'react-intl';
16
+ import { keyframes, styled } from 'styled-components';
17
+
18
+ const PERMISSIONS = {
19
+ // This permission regards the main component (App) and is used to tell
20
+ // If the plugin link should be displayed in the menu
21
+ // And also if the plugin is accessible. This use case is found when a user types the url of the
22
+ // plugin directly in the browser
23
+ main: [
24
+ {
25
+ action: 'plugin::content-type-builder.read',
26
+ subject: null
27
+ }
28
+ ]
29
+ };
30
+ const MAX_COMPONENT_DEPTH = 6;
31
+
32
+ const pluginId = 'content-type-builder';
33
+
34
+ /**
35
+ *
36
+ * Retrieves the relation type
37
+ */ const getRelationType = (relation, targetAttribute)=>{
38
+ const hasNotTargetAttribute = targetAttribute === undefined || targetAttribute === null;
39
+ if (relation === 'oneToOne' && hasNotTargetAttribute) {
40
+ return 'oneWay';
41
+ }
42
+ if (relation === 'oneToMany' && hasNotTargetAttribute) {
43
+ return 'manyWay';
44
+ }
45
+ return relation;
46
+ };
47
+
48
+ const makeUnique = (array)=>[
49
+ ...new Set(array)
50
+ ];
51
+
52
+ const retrieveComponentsFromSchema = (attributes, allComponentsData)=>{
53
+ const allComponents = attributes.reduce((acc, current)=>{
54
+ const type = current.type;
55
+ if (type === 'component') {
56
+ const currentComponentName = current.component;
57
+ // Push the existing compo
58
+ acc.push(currentComponentName);
59
+ const currentComponentAttributes = get(allComponentsData, [
60
+ currentComponentName,
61
+ 'schema',
62
+ 'attributes'
63
+ ], []);
64
+ // Retrieve the nested ones
65
+ acc.push(...retrieveComponentsFromSchema(currentComponentAttributes, allComponentsData));
66
+ }
67
+ if (type === 'dynamiczone') {
68
+ const dynamicZoneComponents = current.components;
69
+ const componentsFromDZComponents = dynamicZoneComponents.reduce((acc2, currentUid)=>{
70
+ const compoAttrs = get(allComponentsData, [
71
+ currentUid,
72
+ 'schema',
73
+ 'attributes'
74
+ ], []);
75
+ return [
76
+ ...acc2,
77
+ ...retrieveComponentsFromSchema(compoAttrs, allComponentsData)
78
+ ];
79
+ }, []);
80
+ return [
81
+ ...acc,
82
+ ...dynamicZoneComponents,
83
+ ...componentsFromDZComponents
84
+ ];
85
+ }
86
+ return acc;
87
+ }, []);
88
+ return makeUnique(allComponents);
89
+ };
90
+
91
+ const DEFAULT_MODIFIED_DATA = {
92
+ components: {},
93
+ contentTypes: {}
94
+ };
95
+ const initialState$1 = {
96
+ components: {},
97
+ contentTypes: {},
98
+ initialComponents: {},
99
+ initialContentTypes: {},
100
+ initialData: {},
101
+ modifiedData: {
102
+ ...DEFAULT_MODIFIED_DATA
103
+ },
104
+ reservedNames: {},
105
+ isLoading: true
106
+ };
107
+ const ONE_SIDE_RELATIONS = [
108
+ 'oneWay',
109
+ 'manyWay'
110
+ ];
111
+ const getOppositeRelation = (originalRelation)=>{
112
+ if (originalRelation === 'manyToOne') {
113
+ return 'oneToMany';
114
+ }
115
+ if (originalRelation === 'oneToMany') {
116
+ return 'manyToOne';
117
+ }
118
+ return originalRelation;
119
+ };
120
+ const findAttributeIndex = (schema, attributeToFind)=>{
121
+ return schema.schema.attributes.findIndex(({ name })=>name === attributeToFind);
122
+ };
123
+ const slice$1 = createSlice({
124
+ name: 'data-manager',
125
+ initialState: initialState$1,
126
+ reducers: {
127
+ init: (state, action)=>{
128
+ const { components, contentTypes, reservedNames } = action.payload;
129
+ state.components = components;
130
+ state.initialComponents = components;
131
+ state.initialContentTypes = contentTypes;
132
+ state.contentTypes = contentTypes;
133
+ state.reservedNames = reservedNames;
134
+ state.isLoading = false;
135
+ state.modifiedData = {
136
+ ...DEFAULT_MODIFIED_DATA,
137
+ component: state.modifiedData.component ? components[state.modifiedData.component.uid] : undefined,
138
+ contentType: state.modifiedData.contentType ? contentTypes[state.modifiedData.contentType.uid] : undefined,
139
+ components: state.modifiedData.components ? Object.keys(state.modifiedData.components).reduce((acc, key)=>{
140
+ acc[key] = components[key];
141
+ return acc;
142
+ }, {}) : {},
143
+ contentTypes: state.modifiedData.contentTypes ? Object.keys(state.modifiedData.contentTypes).reduce((acc, key)=>{
144
+ acc[key] = contentTypes[key];
145
+ return acc;
146
+ }, {}) : {}
147
+ };
148
+ state.initialData = state.modifiedData;
149
+ },
150
+ addAttribute: (state, action)=>{
151
+ const { attributeToSet, forTarget, targetUid, shouldAddComponentToData } = action.payload;
152
+ const { name, ...rest } = attributeToSet;
153
+ delete rest.createComponent;
154
+ const pathToDataToEdit = [
155
+ 'component',
156
+ 'contentType'
157
+ ].includes(forTarget) ? [
158
+ forTarget
159
+ ] : [
160
+ forTarget,
161
+ targetUid
162
+ ];
163
+ const currentAttributes = get(state, [
164
+ 'modifiedData',
165
+ ...pathToDataToEdit,
166
+ 'schema',
167
+ 'attributes'
168
+ ], []).slice();
169
+ // Add the createdAttribute
170
+ const updatedAttributes = [
171
+ ...currentAttributes,
172
+ {
173
+ ...rest,
174
+ name
175
+ }
176
+ ];
177
+ set(state, [
178
+ 'modifiedData',
179
+ ...pathToDataToEdit,
180
+ 'schema',
181
+ 'attributes'
182
+ ], updatedAttributes);
183
+ if (shouldAddComponentToData) {
184
+ const componentToAddUID = rest.component;
185
+ const componentToAdd = state.components[componentToAddUID];
186
+ const isTemporaryComponent = componentToAdd?.isTemporary;
187
+ const hasComponentAlreadyBeenAdded = state.modifiedData.components?.[componentToAddUID] !== undefined;
188
+ if (isTemporaryComponent || hasComponentAlreadyBeenAdded) {
189
+ return;
190
+ }
191
+ // Initialize modifiedData.components if it is undefined
192
+ if (!state.modifiedData.components) {
193
+ state.modifiedData.components = {};
194
+ }
195
+ // Add the added component to the modifiedData.components
196
+ state.modifiedData.components[componentToAddUID] = componentToAdd;
197
+ const nestedComponents = retrieveComponentsFromSchema(componentToAdd.schema.attributes, state.components);
198
+ // We dont' need to set the already added components otherwise all modifications will be lost so we need to only add the not modified ones
199
+ const nestedComponentsToAddInModifiedData = nestedComponents.filter((compoUID)=>{
200
+ return get(state, [
201
+ 'modifiedData',
202
+ 'components',
203
+ compoUID
204
+ ]) === undefined;
205
+ });
206
+ nestedComponentsToAddInModifiedData.forEach((compoUID)=>{
207
+ const compoSchema = get(state, [
208
+ 'components',
209
+ compoUID
210
+ ], {});
211
+ const isTemporary = compoSchema.isTemporary || false;
212
+ // If the nested component has not been saved we don't need to add them as they are already in the state
213
+ if (!isTemporary) {
214
+ if (!state.modifiedData.components) {
215
+ state.modifiedData.components = {};
216
+ }
217
+ state.modifiedData.components[compoUID] = compoSchema;
218
+ }
219
+ });
220
+ return;
221
+ }
222
+ const isCreatingRelationAttribute = rest.type === 'relation';
223
+ if (isCreatingRelationAttribute) {
224
+ const target = rest.target;
225
+ const targetAttribute = rest.targetAttribute || null;
226
+ const relation = rest.relation;
227
+ const relationType = getRelationType(relation, targetAttribute);
228
+ const currentUid = get(state, [
229
+ 'modifiedData',
230
+ ...pathToDataToEdit,
231
+ 'uid'
232
+ ]);
233
+ // When the user in creating a relation with the same content type we need to create another attribute
234
+ // that is the opposite of the created one
235
+ if (rest.type === 'relation' && relationType !== 'oneWay' && relationType !== 'manyWay' && target === currentUid) {
236
+ const oppositeAttribute = {
237
+ name: targetAttribute,
238
+ relation: getOppositeRelation(relationType),
239
+ target,
240
+ targetAttribute: name,
241
+ type: 'relation'
242
+ };
243
+ if (rest.private) {
244
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
245
+ oppositeAttribute.private = rest.private;
246
+ }
247
+ const attributesToSet = [
248
+ ...updatedAttributes,
249
+ oppositeAttribute
250
+ ];
251
+ set(state, [
252
+ 'modifiedData',
253
+ ...pathToDataToEdit,
254
+ 'schema',
255
+ 'attributes'
256
+ ], attributesToSet);
257
+ }
258
+ }
259
+ },
260
+ addCreatedComponentToDynamicZone: (state, action)=>{
261
+ const { dynamicZoneTarget, componentsToAdd } = action.payload;
262
+ const dzAttributeIndex = findAttributeIndex(state.modifiedData.contentType, dynamicZoneTarget);
263
+ componentsToAdd.forEach((componentUid)=>{
264
+ if (!state.modifiedData.contentType) {
265
+ return;
266
+ }
267
+ if (!state.modifiedData.contentType.schema.attributes[dzAttributeIndex].components) {
268
+ state.modifiedData.contentType.schema.attributes[dzAttributeIndex].components = [];
269
+ }
270
+ state.modifiedData.contentType.schema.attributes[dzAttributeIndex].components.push(componentUid);
271
+ });
272
+ },
273
+ addCustomFieldAttribute: (state, action)=>{
274
+ const { attributeToSet, forTarget, targetUid } = action.payload;
275
+ const { name, ...rest } = attributeToSet;
276
+ const pathToDataToEdit = [
277
+ 'component',
278
+ 'contentType'
279
+ ].includes(forTarget) ? [
280
+ forTarget
281
+ ] : [
282
+ forTarget,
283
+ targetUid
284
+ ];
285
+ const currentAttributes = get(state, [
286
+ 'modifiedData',
287
+ ...pathToDataToEdit,
288
+ 'schema',
289
+ 'attributes'
290
+ ], []).slice();
291
+ // Add the createdAttribute
292
+ const updatedAttributes = [
293
+ ...currentAttributes,
294
+ {
295
+ ...rest,
296
+ name
297
+ }
298
+ ];
299
+ set(state, [
300
+ 'modifiedData',
301
+ ...pathToDataToEdit,
302
+ 'schema',
303
+ 'attributes'
304
+ ], updatedAttributes);
305
+ },
306
+ changeDynamicZoneComponents: (state, action)=>{
307
+ const { dynamicZoneTarget, newComponents } = action.payload;
308
+ const dzAttributeIndex = findAttributeIndex(state.modifiedData.contentType, dynamicZoneTarget);
309
+ const currentDZComponents = (state.modifiedData.contentType?.schema.attributes[dzAttributeIndex]).components;
310
+ const updatedComponents = makeUnique([
311
+ ...currentDZComponents,
312
+ ...newComponents
313
+ ]);
314
+ (state.modifiedData.contentType?.schema.attributes[dzAttributeIndex]).components = updatedComponents;
315
+ // Retrieve all the components that needs to be added to the modifiedData.components
316
+ const nestedComponents = retrieveComponentsFromSchema(current(state.modifiedData.contentType?.schema.attributes), state.components);
317
+ // We dont' need to set the already added components otherwise all modifications will be lost so we need to only add the not modified ones
318
+ const nestedComponentsToAddInModifiedData = nestedComponents.filter((compoUID)=>{
319
+ return get(state, [
320
+ 'modifiedData',
321
+ 'components',
322
+ compoUID
323
+ ]) === undefined;
324
+ });
325
+ nestedComponentsToAddInModifiedData.forEach((compoUID)=>{
326
+ const compoSchema = get(state, [
327
+ 'components',
328
+ compoUID
329
+ ], {});
330
+ const isTemporary = compoSchema.isTemporary || false;
331
+ // If the nested component has not been saved we don't need to add them as they are already in the state
332
+ if (!isTemporary) {
333
+ if (!state.modifiedData.components) {
334
+ state.modifiedData.components = {};
335
+ }
336
+ state.modifiedData.components[compoUID] = compoSchema;
337
+ }
338
+ });
339
+ },
340
+ createComponentSchema: (state, action)=>{
341
+ const { uid, data, componentCategory, shouldAddComponentToData } = action.payload;
342
+ const newSchema = {
343
+ uid: uid,
344
+ isTemporary: true,
345
+ category: componentCategory,
346
+ schema: {
347
+ ...data,
348
+ attributes: []
349
+ }
350
+ };
351
+ state.components[uid] = newSchema;
352
+ if (shouldAddComponentToData) {
353
+ state.modifiedData.components[uid] = newSchema;
354
+ }
355
+ },
356
+ createSchema: (state, action)=>{
357
+ const { uid, data } = action.payload;
358
+ const newSchema = {
359
+ uid: uid,
360
+ isTemporary: true,
361
+ schema: {
362
+ ...data,
363
+ attributes: []
364
+ }
365
+ };
366
+ state.contentTypes[uid] = newSchema;
367
+ },
368
+ editAttribute: (state, action)=>{
369
+ const { attributeToSet, forTarget, targetUid, initialAttribute } = action.payload;
370
+ const { name, ...rest } = attributeToSet;
371
+ const initialAttributeName = initialAttribute.name;
372
+ const pathToDataToEdit = [
373
+ 'component',
374
+ 'contentType'
375
+ ].includes(forTarget) ? [
376
+ forTarget
377
+ ] : [
378
+ forTarget,
379
+ targetUid
380
+ ];
381
+ const initialAttributeIndex = findAttributeIndex(get(state, [
382
+ 'modifiedData',
383
+ ...pathToDataToEdit
384
+ ]), initialAttributeName);
385
+ const isEditingRelation = rest.type === 'relation';
386
+ if (!isEditingRelation) {
387
+ set(state, [
388
+ 'modifiedData',
389
+ ...pathToDataToEdit,
390
+ 'schema',
391
+ 'attributes',
392
+ initialAttributeIndex
393
+ ], attributeToSet);
394
+ return;
395
+ }
396
+ const updatedAttributes = get(state, [
397
+ 'modifiedData',
398
+ ...pathToDataToEdit,
399
+ 'schema',
400
+ 'attributes'
401
+ ]).slice();
402
+ // First create the current relation attribute updated
403
+ const toSet = {
404
+ name,
405
+ relation: rest.relation,
406
+ target: rest.target,
407
+ targetAttribute: rest.targetAttribute,
408
+ type: 'relation'
409
+ };
410
+ if (rest.private) {
411
+ toSet.private = rest.private;
412
+ }
413
+ if (rest.pluginOptions) {
414
+ toSet.pluginOptions = rest.pluginOptions;
415
+ }
416
+ const currentAttributeIndex = updatedAttributes.findIndex((value)=>{
417
+ return value.name !== undefined && value.name === initialAttribute.name;
418
+ });
419
+ // First set it in the updatedAttributes
420
+ if (currentAttributeIndex !== -1) {
421
+ updatedAttributes.splice(currentAttributeIndex, 1, toSet);
422
+ }
423
+ let oppositeAttributeNameToRemove = null;
424
+ let oppositeAttributeNameToUpdate = null;
425
+ let oppositeAttributeToCreate = null;
426
+ let initialOppositeAttribute = null;
427
+ const currentUid = get(state, [
428
+ 'modifiedData',
429
+ ...pathToDataToEdit,
430
+ 'uid'
431
+ ]);
432
+ const didChangeTargetRelation = initialAttribute.target !== rest.target;
433
+ const didCreateInternalRelation = rest.target === currentUid;
434
+ const relationType = getRelationType(rest.relation, rest.targetAttribute);
435
+ const initialRelationType = getRelationType(initialAttribute.relation, initialAttribute.targetAttribute);
436
+ const hadInternalRelation = initialAttribute.target === currentUid;
437
+ const didChangeRelationType = initialRelationType !== relationType;
438
+ const shouldRemoveOppositeAttributeBecauseOfTargetChange = didChangeTargetRelation && !didCreateInternalRelation && hadInternalRelation && isEditingRelation;
439
+ const shouldRemoveOppositeAttributeBecauseOfRelationTypeChange = didChangeRelationType && hadInternalRelation && [
440
+ 'oneWay',
441
+ 'manyWay'
442
+ ].includes(relationType) && isEditingRelation;
443
+ const shouldUpdateOppositeAttributeBecauseOfRelationTypeChange = !ONE_SIDE_RELATIONS.includes(initialRelationType) && !ONE_SIDE_RELATIONS.includes(relationType) && hadInternalRelation && didCreateInternalRelation && isEditingRelation;
444
+ const shouldCreateOppositeAttributeBecauseOfRelationTypeChange = ONE_SIDE_RELATIONS.includes(initialRelationType) && !ONE_SIDE_RELATIONS.includes(relationType) && hadInternalRelation && didCreateInternalRelation && isEditingRelation;
445
+ const shouldCreateOppositeAttributeBecauseOfTargetChange = didChangeTargetRelation && didCreateInternalRelation && !ONE_SIDE_RELATIONS.includes(relationType);
446
+ // Store opposite attribute name to remove at the end of the loop
447
+ if (shouldRemoveOppositeAttributeBecauseOfTargetChange || shouldRemoveOppositeAttributeBecauseOfRelationTypeChange) {
448
+ oppositeAttributeNameToRemove = initialAttribute.targetAttribute;
449
+ }
450
+ // In case of oneWay or manyWay relation there isn't an opposite attribute
451
+ if (oppositeAttributeNameToRemove) {
452
+ const indexToRemove = updatedAttributes.findIndex((value)=>value.name === oppositeAttributeNameToRemove);
453
+ updatedAttributes.splice(indexToRemove, 1);
454
+ }
455
+ // In order to preserve plugin options need to get the initial opposite attribute settings
456
+ if (!shouldRemoveOppositeAttributeBecauseOfTargetChange) {
457
+ const initialTargetContentType = get(state, [
458
+ 'initialContentTypes',
459
+ initialAttribute.target
460
+ ]);
461
+ if (initialTargetContentType) {
462
+ const oppositeAttributeIndex = findAttributeIndex(initialTargetContentType, initialAttribute.targetAttribute);
463
+ initialOppositeAttribute = get(state, [
464
+ 'initialContentTypes',
465
+ initialAttribute.target,
466
+ 'schema',
467
+ 'attributes',
468
+ oppositeAttributeIndex
469
+ ]);
470
+ }
471
+ }
472
+ // Create the opposite attribute
473
+ if (shouldCreateOppositeAttributeBecauseOfRelationTypeChange || shouldCreateOppositeAttributeBecauseOfTargetChange) {
474
+ oppositeAttributeToCreate = {
475
+ name: rest.targetAttribute,
476
+ relation: getOppositeRelation(relationType),
477
+ target: rest.target,
478
+ targetAttribute: name,
479
+ type: 'relation'
480
+ };
481
+ if (rest.private) {
482
+ oppositeAttributeToCreate.private = rest.private;
483
+ }
484
+ if (initialOppositeAttribute && initialOppositeAttribute.pluginOptions) {
485
+ oppositeAttributeToCreate.pluginOptions = initialOppositeAttribute.pluginOptions;
486
+ }
487
+ const indexOfInitialAttribute = updatedAttributes.findIndex(({ name })=>name === initialAttribute.name);
488
+ const indexOfUpdatedAttribute = updatedAttributes.findIndex(({ name: attrName })=>name === attrName);
489
+ const indexToInsert = (indexOfInitialAttribute === -1 ? indexOfUpdatedAttribute : indexOfInitialAttribute) + 1;
490
+ updatedAttributes.splice(indexToInsert, 0, oppositeAttributeToCreate);
491
+ }
492
+ if (shouldUpdateOppositeAttributeBecauseOfRelationTypeChange) {
493
+ oppositeAttributeNameToUpdate = initialAttribute.targetAttribute;
494
+ oppositeAttributeToCreate = {
495
+ name: rest.targetAttribute,
496
+ relation: getOppositeRelation(relationType),
497
+ target: rest.target,
498
+ targetAttribute: name,
499
+ type: 'relation'
500
+ };
501
+ if (rest.private) {
502
+ oppositeAttributeToCreate.private = rest.private;
503
+ }
504
+ if (initialOppositeAttribute && initialOppositeAttribute.pluginOptions) {
505
+ oppositeAttributeToCreate.pluginOptions = initialOppositeAttribute.pluginOptions;
506
+ }
507
+ if (oppositeAttributeNameToUpdate) {
508
+ const indexToUpdate = updatedAttributes.findIndex(({ name })=>name === oppositeAttributeNameToUpdate);
509
+ updatedAttributes.splice(indexToUpdate, 1, oppositeAttributeToCreate);
510
+ }
511
+ }
512
+ set(state, [
513
+ 'modifiedData',
514
+ ...pathToDataToEdit,
515
+ 'schema',
516
+ 'attributes'
517
+ ], updatedAttributes);
518
+ },
519
+ editCustomFieldAttribute: (state, action)=>{
520
+ const { forTarget, targetUid, initialAttribute, attributeToSet } = action.payload;
521
+ const initialAttributeName = initialAttribute.name;
522
+ const pathToDataToEdit = [
523
+ 'component',
524
+ 'contentType'
525
+ ].includes(forTarget) ? [
526
+ forTarget
527
+ ] : [
528
+ forTarget,
529
+ targetUid
530
+ ];
531
+ const initialAttributeIndex = findAttributeIndex(get(state, [
532
+ 'modifiedData',
533
+ ...pathToDataToEdit
534
+ ]), initialAttributeName);
535
+ set(state, [
536
+ 'modifiedData',
537
+ ...pathToDataToEdit,
538
+ 'schema',
539
+ 'attributes',
540
+ initialAttributeIndex
541
+ ], attributeToSet);
542
+ },
543
+ updateInitialState: (state)=>{
544
+ state.initialData = state.modifiedData;
545
+ },
546
+ deleteNotSavedType: (state)=>{
547
+ // Doing so will also reset the modified and the initial data
548
+ state.contentTypes = state.initialContentTypes;
549
+ state.components = state.initialComponents;
550
+ },
551
+ reloadPlugin: ()=>{
552
+ return initialState$1;
553
+ },
554
+ removeComponentFromDynamicZone: (state, action)=>{
555
+ const { dzName, componentToRemoveIndex } = action.payload;
556
+ const dzAttributeIndex = findAttributeIndex(state.modifiedData.contentType, dzName);
557
+ if (state.modifiedData.contentType) {
558
+ state.modifiedData.contentType.schema.attributes[dzAttributeIndex].components.splice(componentToRemoveIndex, 1);
559
+ }
560
+ },
561
+ removeField: (state, action)=>{
562
+ const { mainDataKey, attributeToRemoveName } = action.payload;
563
+ const pathToAttributes = [
564
+ 'modifiedData',
565
+ mainDataKey,
566
+ 'schema',
567
+ 'attributes'
568
+ ];
569
+ const attributeToRemoveIndex = findAttributeIndex(state.modifiedData[mainDataKey], attributeToRemoveName);
570
+ const pathToAttributeToRemove = [
571
+ ...pathToAttributes,
572
+ attributeToRemoveIndex
573
+ ];
574
+ const attributeToRemoveData = get(state, pathToAttributeToRemove);
575
+ const isRemovingRelationAttribute = attributeToRemoveData.type === 'relation';
576
+ // Only content types can have relations with themselves since
577
+ // components can only have oneWay or manyWay relations
578
+ const canTheAttributeToRemoveHaveARelationWithItself = mainDataKey === 'contentType';
579
+ if (isRemovingRelationAttribute && canTheAttributeToRemoveHaveARelationWithItself) {
580
+ const { target, relation, targetAttribute } = attributeToRemoveData;
581
+ const relationType = getRelationType(relation, targetAttribute);
582
+ const uid = state.modifiedData.contentType?.uid;
583
+ const shouldRemoveOppositeAttribute = target === uid && !ONE_SIDE_RELATIONS.includes(relationType);
584
+ if (shouldRemoveOppositeAttribute) {
585
+ const attributes = state.modifiedData[mainDataKey]?.schema.attributes.slice();
586
+ const nextAttributes = attributes.filter((attribute)=>{
587
+ if (attribute.name === attributeToRemoveName) {
588
+ return false;
589
+ }
590
+ if (attribute.target === uid && attribute.targetAttribute === attributeToRemoveName) {
591
+ return false;
592
+ }
593
+ return true;
594
+ });
595
+ const schema = state.modifiedData[mainDataKey];
596
+ if (schema) {
597
+ schema.schema.attributes = nextAttributes;
598
+ }
599
+ return;
600
+ }
601
+ }
602
+ // Find all uid fields that have the targetField set to the field we are removing
603
+ const uidFieldsToUpdate = state.modifiedData[mainDataKey].schema.attributes.slice().reduce((acc, current)=>{
604
+ if (current.type !== 'uid') {
605
+ return acc;
606
+ }
607
+ if (current.targetField !== attributeToRemoveName) {
608
+ return acc;
609
+ }
610
+ acc.push(current.name);
611
+ return acc;
612
+ }, []);
613
+ uidFieldsToUpdate.forEach((fieldName)=>{
614
+ const fieldIndex = findAttributeIndex(state.modifiedData[mainDataKey], fieldName);
615
+ delete state.modifiedData[mainDataKey]?.schema.attributes[fieldIndex].targetField;
616
+ });
617
+ state.modifiedData[mainDataKey]?.schema.attributes.splice(attributeToRemoveIndex, 1);
618
+ },
619
+ removeFieldFromDisplayedComponent: (state, action)=>{
620
+ const { attributeToRemoveName, componentUid } = action.payload;
621
+ const attributeToRemoveIndex = findAttributeIndex(state.modifiedData.components?.[componentUid], attributeToRemoveName);
622
+ state.modifiedData.components?.[componentUid]?.schema?.attributes?.splice(attributeToRemoveIndex, 1);
623
+ },
624
+ setModifiedData: (state, action)=>{
625
+ const { schemaToSet, hasJustCreatedSchema } = action.payload;
626
+ const schema = {
627
+ ...DEFAULT_MODIFIED_DATA,
628
+ ...schemaToSet
629
+ };
630
+ state.initialData = schema;
631
+ state.modifiedData = schema;
632
+ // Reset the state with the initial data
633
+ // All created components and content types will be lost
634
+ if (!hasJustCreatedSchema) {
635
+ state.components = state.initialComponents;
636
+ state.contentTypes = state.initialContentTypes;
637
+ }
638
+ },
639
+ updateSchema: (state, action)=>{
640
+ const { data, schemaType } = action.payload;
641
+ const schema = state.modifiedData[schemaType];
642
+ if (!schema) {
643
+ return;
644
+ }
645
+ schema.schema.displayName = data.displayName;
646
+ if (schemaType === 'component') {
647
+ const { uid } = action.payload;
648
+ schema.category = data.category;
649
+ schema.schema.icon = data.icon;
650
+ const addedComponent = current(schema);
651
+ state.components[uid] = addedComponent;
652
+ } else {
653
+ schema.schema.kind = data.kind;
654
+ }
655
+ }
656
+ }
657
+ });
658
+ const { reducer: reducer$1, actions: actions$1 } = slice$1;
659
+
660
+ const nameToSlug = (name)=>slugify(name, {
661
+ separator: '-'
662
+ });
663
+
664
+ const createUid = (name)=>{
665
+ const modelName = nameToSlug(name);
666
+ return `api::${modelName}.${modelName}`;
667
+ };
668
+ // From `content-type-builder/services/Components/createComponentUid`
669
+ const createComponentUid = (name, category)=>{
670
+ return `${nameToSlug(category)}.${nameToSlug(name)}`;
671
+ };
672
+
673
+ const customFieldDefaultOptionsReducer = (acc, option)=>{
674
+ if (option.items) {
675
+ return option.items.reduce(customFieldDefaultOptionsReducer, acc);
676
+ }
677
+ if ('defaultValue' in option) {
678
+ const { name, defaultValue } = option;
679
+ acc.push({
680
+ name,
681
+ defaultValue
682
+ });
683
+ }
684
+ return acc;
685
+ };
686
+
687
+ /* eslint-disable no-confusing-arrow */ const shouldPluralizeName = (nature)=>[
688
+ 'manyToMany',
689
+ 'oneToMany',
690
+ 'manyWay'
691
+ ].includes(nature) ? 2 : 1;
692
+ const shouldPluralizeTargetAttribute = (nature)=>[
693
+ 'manyToMany',
694
+ 'manyToOne'
695
+ ].includes(nature) ? 2 : 1;
696
+
697
+ const initialState = {
698
+ formErrors: {},
699
+ modifiedData: {},
700
+ initialData: {},
701
+ componentToCreate: {},
702
+ isCreatingComponentWhileAddingAField: false
703
+ };
704
+ const slice = createSlice({
705
+ name: 'formModal',
706
+ initialState,
707
+ reducers: {
708
+ onChange: (state, action)=>{
709
+ const { keys, value } = action.payload;
710
+ const obj = state.modifiedData;
711
+ const hasDefaultValue = Boolean(obj.default);
712
+ // There is no need to remove the default key if the default value isn't defined
713
+ if (hasDefaultValue && keys.length === 1 && keys.includes('type')) {
714
+ const previousType = obj.type;
715
+ if (previousType && [
716
+ 'date',
717
+ 'datetime',
718
+ 'time'
719
+ ].includes(previousType)) {
720
+ // return obj.updateIn(keys, () => value).remove('default');
721
+ delete state.modifiedData.default;
722
+ }
723
+ }
724
+ set(state, [
725
+ 'modifiedData',
726
+ ...keys
727
+ ], value);
728
+ },
729
+ onChangeRelationTarget: (state, action)=>{
730
+ const { target: { oneThatIsCreatingARelationWithAnother, selectedContentTypeFriendlyName, targetContentTypeAllowedRelations, value } } = action.payload;
731
+ // Special case for the admin user...
732
+ let didChangeRelationTypeBecauseOfRestrictedRelation = false;
733
+ let changedRelationType = null;
734
+ set(state, [
735
+ 'modifiedData',
736
+ 'target'
737
+ ], value);
738
+ const modifiedData = state.modifiedData;
739
+ // Don't change the relation type if the allowed relations are not restricted
740
+ // TODO: replace with an obj { relation: 'x', bidirctional: true|false } when BE ready
741
+ if (Array.isArray(targetContentTypeAllowedRelations)) {
742
+ const currentRelationType = getRelationType(modifiedData.relation, modifiedData.targetAttribute);
743
+ if (currentRelationType && !targetContentTypeAllowedRelations.includes(currentRelationType)) {
744
+ const relationToSet = targetContentTypeAllowedRelations[0];
745
+ didChangeRelationTypeBecauseOfRestrictedRelation = true;
746
+ changedRelationType = relationToSet;
747
+ if (relationToSet === 'oneWay') {
748
+ set(state, [
749
+ 'modifiedData',
750
+ 'relation'
751
+ ], 'oneToOne');
752
+ } else if (relationToSet === 'manyWay') {
753
+ set(state, [
754
+ 'modifiedData',
755
+ 'relation'
756
+ ], 'oneToMany');
757
+ } else {
758
+ set(state, [
759
+ 'modifiedData',
760
+ 'relation'
761
+ ], relationToSet);
762
+ }
763
+ }
764
+ }
765
+ let nameToSet;
766
+ if (didChangeRelationTypeBecauseOfRestrictedRelation && changedRelationType) {
767
+ nameToSet = pluralize(snakeCase(nameToSlug(selectedContentTypeFriendlyName)), shouldPluralizeName(changedRelationType));
768
+ } else {
769
+ nameToSet = pluralize(snakeCase(nameToSlug(selectedContentTypeFriendlyName)), shouldPluralizeName(modifiedData.relation));
770
+ }
771
+ set(state, [
772
+ 'modifiedData',
773
+ 'name'
774
+ ], nameToSet);
775
+ const currentTargetAttribute = state.modifiedData.targetAttribute;
776
+ if (currentTargetAttribute === null) {
777
+ return;
778
+ }
779
+ // Changing the target and the relation is either oneWay or manyWay
780
+ // Case when we need to change the relation to oneWay (ex: admin user)
781
+ if (didChangeRelationTypeBecauseOfRestrictedRelation && changedRelationType && [
782
+ 'oneWay',
783
+ 'manyWay'
784
+ ].includes(changedRelationType)) {
785
+ set(state, [
786
+ 'modifiedData',
787
+ 'targetAttribute'
788
+ ], null);
789
+ return;
790
+ }
791
+ const targetAttributeToSet = pluralize(snakeCase(nameToSlug(oneThatIsCreatingARelationWithAnother)), shouldPluralizeTargetAttribute(modifiedData.relation));
792
+ set(state, [
793
+ 'modifiedData',
794
+ 'targetAttribute'
795
+ ], targetAttributeToSet);
796
+ },
797
+ onChangeRelationType: (state, action)=>{
798
+ const { target: { oneThatIsCreatingARelationWithAnother, value } } = action.payload;
799
+ const currentName = state.modifiedData.name;
800
+ // Switching from oneWay
801
+ if (![
802
+ 'oneWay',
803
+ 'manyWay'
804
+ ].includes(value)) {
805
+ set(state, [
806
+ 'modifiedData',
807
+ 'relation'
808
+ ], value);
809
+ const currentTargetAttribute = state.modifiedData.targetAttribute;
810
+ set(state, [
811
+ 'modifiedData',
812
+ 'name'
813
+ ], pluralize(snakeCase(nameToSlug(currentName)), shouldPluralizeName(value)));
814
+ set(state, [
815
+ 'modifiedData',
816
+ 'targetAttribute'
817
+ ], pluralize(currentTargetAttribute || snakeCase(nameToSlug(oneThatIsCreatingARelationWithAnother)), shouldPluralizeTargetAttribute(value)));
818
+ return;
819
+ }
820
+ if (value === 'oneWay') {
821
+ set(state, [
822
+ 'modifiedData',
823
+ 'relation'
824
+ ], 'oneToOne');
825
+ set(state, [
826
+ 'modifiedData',
827
+ 'targetAttribute'
828
+ ], null);
829
+ set(state, [
830
+ 'modifiedData',
831
+ 'name'
832
+ ], pluralize(snakeCase(currentName), 1));
833
+ return;
834
+ }
835
+ // manyWay
836
+ set(state, [
837
+ 'modifiedData',
838
+ 'relation'
839
+ ], 'oneToMany');
840
+ set(state, [
841
+ 'modifiedData',
842
+ 'targetAttribute'
843
+ ], null);
844
+ set(state, [
845
+ 'modifiedData',
846
+ 'name'
847
+ ], pluralize(snakeCase(currentName), 2));
848
+ },
849
+ resetProps: ()=>{
850
+ return initialState;
851
+ },
852
+ resetPropsAndSetFormForAddingAnExistingCompo: (state, action)=>{
853
+ const { options = {} } = action.payload;
854
+ return {
855
+ ...initialState,
856
+ modifiedData: {
857
+ type: 'component',
858
+ repeatable: true,
859
+ ...options
860
+ }
861
+ };
862
+ },
863
+ resetPropsAndSaveCurrentData: (state, action)=>{
864
+ const { options = {} } = action.payload;
865
+ // This is run when the user has created a new component
866
+ const componentToCreate = state.modifiedData.componentToCreate;
867
+ const modifiedData = {
868
+ displayName: componentToCreate.displayName,
869
+ type: 'component',
870
+ repeatable: false,
871
+ ...options,
872
+ component: createComponentUid(componentToCreate.displayName, componentToCreate.category)
873
+ };
874
+ return {
875
+ ...initialState,
876
+ componentToCreate,
877
+ modifiedData,
878
+ isCreatingComponentWhileAddingAField: state.modifiedData.createComponent
879
+ };
880
+ },
881
+ resetPropsAndSetTheFormForAddingACompoToADz: (state)=>{
882
+ const createdDZ = state.modifiedData;
883
+ const dataToSet = {
884
+ ...createdDZ,
885
+ createComponent: true,
886
+ componentToCreate: {
887
+ type: 'component'
888
+ }
889
+ };
890
+ return {
891
+ ...initialState,
892
+ modifiedData: dataToSet
893
+ };
894
+ },
895
+ setDataToEdit: (state, action)=>{
896
+ const { data } = action.payload;
897
+ state.modifiedData = data;
898
+ state.initialData = data;
899
+ },
900
+ setAttributeDataSchema: (state, action)=>{
901
+ const { isEditing } = action.payload;
902
+ if (isEditing) {
903
+ const { modifiedDataToSetForEditing } = action.payload;
904
+ state.modifiedData = modifiedDataToSetForEditing;
905
+ state.initialData = modifiedDataToSetForEditing;
906
+ return;
907
+ }
908
+ const { attributeType, nameToSetForRelation, targetUid, step, options = {} } = action.payload;
909
+ let dataToSet;
910
+ if (attributeType === 'component') {
911
+ if (step === '1') {
912
+ dataToSet = {
913
+ type: 'component',
914
+ createComponent: true,
915
+ componentToCreate: {
916
+ type: 'component'
917
+ }
918
+ };
919
+ } else {
920
+ dataToSet = {
921
+ ...options,
922
+ type: 'component',
923
+ repeatable: true
924
+ };
925
+ }
926
+ } else if (attributeType === 'dynamiczone') {
927
+ dataToSet = {
928
+ ...options,
929
+ type: 'dynamiczone',
930
+ components: []
931
+ };
932
+ } else if (attributeType === 'text') {
933
+ dataToSet = {
934
+ ...options,
935
+ type: 'string'
936
+ };
937
+ } else if (attributeType === 'number' || attributeType === 'date') {
938
+ dataToSet = options;
939
+ } else if (attributeType === 'media') {
940
+ dataToSet = {
941
+ allowedTypes: [
942
+ 'images',
943
+ 'files',
944
+ 'videos',
945
+ 'audios'
946
+ ],
947
+ type: 'media',
948
+ multiple: true,
949
+ ...options
950
+ };
951
+ } else if (attributeType === 'enumeration') {
952
+ dataToSet = {
953
+ ...options,
954
+ type: 'enumeration',
955
+ enum: []
956
+ };
957
+ } else if (attributeType === 'relation') {
958
+ dataToSet = {
959
+ name: snakeCase(nameToSetForRelation),
960
+ relation: 'oneToOne',
961
+ targetAttribute: null,
962
+ target: targetUid,
963
+ type: 'relation'
964
+ };
965
+ } else {
966
+ dataToSet = {
967
+ ...options,
968
+ type: attributeType,
969
+ default: null
970
+ };
971
+ }
972
+ state.modifiedData = dataToSet;
973
+ },
974
+ setCustomFieldDataSchema: (state, action)=>{
975
+ const { isEditing } = action.payload;
976
+ if (isEditing) {
977
+ const { modifiedDataToSetForEditing } = action.payload;
978
+ state.modifiedData = modifiedDataToSetForEditing;
979
+ state.initialData = modifiedDataToSetForEditing;
980
+ return;
981
+ }
982
+ const { customField, options = {} } = action.payload;
983
+ state.modifiedData = {
984
+ ...options,
985
+ type: customField.type
986
+ };
987
+ const allOptions = [
988
+ ...customField?.options?.base || [],
989
+ ...customField?.options?.advanced || []
990
+ ];
991
+ const optionDefaults = allOptions.reduce(customFieldDefaultOptionsReducer, []);
992
+ if (optionDefaults.length) {
993
+ optionDefaults.forEach(({ name, defaultValue })=>set(state.modifiedData, name, defaultValue));
994
+ }
995
+ },
996
+ setDynamicZoneDataSchema: (state, action)=>{
997
+ const { attributeToEdit } = action.payload;
998
+ state.modifiedData = attributeToEdit;
999
+ state.initialData = attributeToEdit;
1000
+ },
1001
+ setErrors: (state, action)=>{
1002
+ state.formErrors = action.payload.errors;
1003
+ }
1004
+ }
1005
+ });
1006
+ const { actions, reducer } = slice;
1007
+
1008
+ const reducers = {
1009
+ [`${pluginId}_formModal`]: reducer,
1010
+ [`${pluginId}_dataManagerProvider`]: reducer$1
1011
+ };
1012
+
1013
+ // TODO V5 Convert any into real types
1014
+ const formsAPI = {
1015
+ components: {
1016
+ inputs: {},
1017
+ add ({ id, component }) {
1018
+ if (!this.inputs[id]) {
1019
+ this.inputs[id] = component;
1020
+ }
1021
+ }
1022
+ },
1023
+ types: {
1024
+ attribute: {
1025
+ },
1026
+ contentType: {
1027
+ validators: [],
1028
+ form: {
1029
+ advanced: [],
1030
+ base: []
1031
+ }
1032
+ },
1033
+ component: {
1034
+ validators: [],
1035
+ form: {
1036
+ advanced: [],
1037
+ base: []
1038
+ }
1039
+ }
1040
+ },
1041
+ contentTypeSchemaMutations: [],
1042
+ addContentTypeSchemaMutation (cb) {
1043
+ this.contentTypeSchemaMutations.push(cb);
1044
+ },
1045
+ extendContentType ({ validator, form: { advanced, base } }) {
1046
+ const { contentType } = this.types;
1047
+ if (validator) {
1048
+ contentType.validators.push(validator);
1049
+ }
1050
+ contentType.form.advanced.push(advanced);
1051
+ contentType.form.base.push(base);
1052
+ },
1053
+ extendFields (fields, { validator, form: { advanced, base } }) {
1054
+ const formType = this.types.attribute;
1055
+ fields.forEach((field)=>{
1056
+ if (!formType[field]) {
1057
+ formType[field] = {
1058
+ validators: [],
1059
+ form: {
1060
+ advanced: [],
1061
+ base: []
1062
+ }
1063
+ };
1064
+ }
1065
+ if (validator) {
1066
+ formType[field].validators.push(validator);
1067
+ }
1068
+ formType[field].form.advanced.push(advanced);
1069
+ formType[field].form.base.push(base);
1070
+ });
1071
+ },
1072
+ getAdvancedForm (target, props = null) {
1073
+ const sectionsToAdd = get(this.types, [
1074
+ ...target,
1075
+ 'form',
1076
+ 'advanced'
1077
+ ], []).reduce((acc, current)=>{
1078
+ const sections = current(props);
1079
+ return [
1080
+ ...acc,
1081
+ ...sections
1082
+ ];
1083
+ }, []);
1084
+ return sectionsToAdd;
1085
+ },
1086
+ makeCustomFieldValidator (attributeShape, validator, ...validatorArgs) {
1087
+ // When no validator, return the attribute shape
1088
+ if (!validator) return attributeShape;
1089
+ // Otherwise extend the shape with the provided validator
1090
+ return attributeShape.shape({
1091
+ options: yup.object().shape(validator(validatorArgs))
1092
+ });
1093
+ },
1094
+ makeValidator (target, initShape, ...args) {
1095
+ const validators = get(this.types, [
1096
+ ...target,
1097
+ 'validators'
1098
+ ], []);
1099
+ const pluginOptionsShape = validators.reduce((acc, current)=>{
1100
+ const pluginOptionShape = current(args);
1101
+ return {
1102
+ ...acc,
1103
+ ...pluginOptionShape
1104
+ };
1105
+ }, {});
1106
+ return initShape.shape({
1107
+ pluginOptions: yup.object().shape(pluginOptionsShape)
1108
+ });
1109
+ },
1110
+ mutateContentTypeSchema (data, initialData) {
1111
+ let enhancedData = cloneDeep(data);
1112
+ const refData = cloneDeep(initialData);
1113
+ this.contentTypeSchemaMutations.forEach((cb)=>{
1114
+ enhancedData = cb(enhancedData, refData);
1115
+ });
1116
+ return enhancedData;
1117
+ }
1118
+ };
1119
+
1120
+ const prefixPluginTranslations = (trad, pluginId)=>{
1121
+ return Object.keys(trad).reduce((acc, current)=>{
1122
+ acc[`${pluginId}.${current}`] = trad[current];
1123
+ return acc;
1124
+ }, {});
1125
+ };
1126
+
1127
+ const AutoReloadOverlayBlockerContext = /*#__PURE__*/ React.createContext({});
1128
+ const MAX_ELAPSED_TIME = 30 * 1000;
1129
+ const AutoReloadOverlayBlockerProvider = ({ children })=>{
1130
+ const [isOpen, setIsOpen] = React.useState(false);
1131
+ const [config, setConfig] = React.useState({});
1132
+ const [failed, setFailed] = React.useState(false);
1133
+ const lockAppWithAutoreload = React.useCallback((config = {})=>{
1134
+ setIsOpen(true);
1135
+ setConfig(config);
1136
+ }, []);
1137
+ const unlockAppWithAutoreload = React.useCallback(()=>{
1138
+ setIsOpen(false);
1139
+ setConfig({});
1140
+ }, []);
1141
+ // eslint-disable-next-line consistent-return
1142
+ React.useEffect(()=>{
1143
+ if (isOpen) {
1144
+ const timeout = setTimeout(()=>{
1145
+ setFailed(true);
1146
+ }, MAX_ELAPSED_TIME);
1147
+ return ()=>{
1148
+ clearTimeout(timeout);
1149
+ };
1150
+ }
1151
+ }, [
1152
+ isOpen
1153
+ ]);
1154
+ let displayedIcon = config?.icon || 'reload';
1155
+ let description = {
1156
+ id: config?.description || 'components.OverlayBlocker.description',
1157
+ defaultMessage: "You're using a feature that needs the server to restart. The page will reload automatically."
1158
+ };
1159
+ let title = {
1160
+ id: config?.title || 'components.OverlayBlocker.title',
1161
+ defaultMessage: 'Waiting for restart'
1162
+ };
1163
+ if (failed) {
1164
+ displayedIcon = 'time';
1165
+ description = {
1166
+ id: 'components.OverlayBlocker.description.serverError',
1167
+ defaultMessage: 'The server should have restarted, please check your logs in the terminal.'
1168
+ };
1169
+ title = {
1170
+ id: 'components.OverlayBlocker.title.serverError',
1171
+ defaultMessage: 'The restart is taking longer than expected'
1172
+ };
1173
+ }
1174
+ const autoReloadValue = React.useMemo(()=>({
1175
+ lockAppWithAutoreload,
1176
+ unlockAppWithAutoreload
1177
+ }), [
1178
+ lockAppWithAutoreload,
1179
+ unlockAppWithAutoreload
1180
+ ]);
1181
+ return /*#__PURE__*/ jsxs(AutoReloadOverlayBlockerContext.Provider, {
1182
+ value: autoReloadValue,
1183
+ children: [
1184
+ /*#__PURE__*/ jsx(Blocker, {
1185
+ displayedIcon: displayedIcon,
1186
+ isOpen: isOpen,
1187
+ description: description,
1188
+ title: title
1189
+ }),
1190
+ children
1191
+ ]
1192
+ });
1193
+ };
1194
+ const Blocker = ({ displayedIcon, description, title, isOpen })=>{
1195
+ const { formatMessage } = useIntl();
1196
+ // eslint-disable-next-line no-undef
1197
+ return isOpen && globalThis?.document?.body ? /*#__PURE__*/ createPortal(/*#__PURE__*/ jsxs(Overlay, {
1198
+ id: "autoReloadOverlayBlocker",
1199
+ direction: "column",
1200
+ alignItems: "center",
1201
+ gap: 6,
1202
+ children: [
1203
+ /*#__PURE__*/ jsxs(Flex, {
1204
+ direction: "column",
1205
+ alignItems: "center",
1206
+ gap: 2,
1207
+ children: [
1208
+ /*#__PURE__*/ jsx(Typography, {
1209
+ tag: "h1",
1210
+ variant: "alpha",
1211
+ children: formatMessage(title)
1212
+ }),
1213
+ /*#__PURE__*/ jsx(Typography, {
1214
+ tag: "h2",
1215
+ textColor: "neutral600",
1216
+ fontSize: 4,
1217
+ fontWeight: "regular",
1218
+ children: formatMessage(description)
1219
+ })
1220
+ ]
1221
+ }),
1222
+ displayedIcon === 'reload' && /*#__PURE__*/ jsx(IconBox, {
1223
+ padding: 6,
1224
+ background: "primary100",
1225
+ borderColor: "primary200",
1226
+ children: /*#__PURE__*/ jsx(LoaderReload, {
1227
+ width: "4rem",
1228
+ height: "4rem"
1229
+ })
1230
+ }),
1231
+ displayedIcon === 'time' && /*#__PURE__*/ jsx(IconBox, {
1232
+ padding: 6,
1233
+ background: "primary100",
1234
+ borderColor: "primary200",
1235
+ children: /*#__PURE__*/ jsx(Clock, {
1236
+ width: "4rem",
1237
+ height: "4rem"
1238
+ })
1239
+ }),
1240
+ /*#__PURE__*/ jsx(Box, {
1241
+ marginTop: 2,
1242
+ children: /*#__PURE__*/ jsx(Link, {
1243
+ href: "https://docs.strapi.io",
1244
+ isExternal: true,
1245
+ children: formatMessage({
1246
+ id: 'global.documentation',
1247
+ defaultMessage: 'Read the documentation'
1248
+ })
1249
+ })
1250
+ })
1251
+ ]
1252
+ }), // eslint-disable-next-line no-undef
1253
+ globalThis.document.body) : null;
1254
+ };
1255
+ const rotation = keyframes`
1256
+ from {
1257
+ transform: rotate(0deg);
1258
+ }
1259
+ to {
1260
+ transform: rotate(359deg);
1261
+ }
1262
+ `;
1263
+ const LoaderReload = styled(ArrowClockwise)`
1264
+ animation: ${rotation} 1s infinite linear;
1265
+ `;
1266
+ const Overlay = styled(Flex)`
1267
+ position: fixed;
1268
+ top: 0;
1269
+ right: 0;
1270
+ bottom: 0;
1271
+ left: 0;
1272
+ /* TODO: set this up in the theme for consistence z-index values */
1273
+ z-index: 1140;
1274
+ padding-top: 16rem;
1275
+
1276
+ & > * {
1277
+ position: relative;
1278
+ z-index: 1;
1279
+ }
1280
+
1281
+ &:before {
1282
+ content: '';
1283
+ position: fixed;
1284
+ top: 0;
1285
+ right: 0;
1286
+ bottom: 0;
1287
+ left: 0;
1288
+ background: ${({ theme })=>theme.colors.neutral0};
1289
+ opacity: 0.9;
1290
+ }
1291
+ `;
1292
+ const IconBox = styled(Box)`
1293
+ border-radius: 50%;
1294
+ display: flex;
1295
+ align-items: center;
1296
+ justify-content: center;
1297
+ svg {
1298
+ > path {
1299
+ fill: ${({ theme })=>theme.colors.primary600} !important;
1300
+ }
1301
+ }
1302
+ `;
1303
+ /* -------------------------------------------------------------------------------------------------
1304
+ * Hook
1305
+ * -----------------------------------------------------------------------------------------------*/ const useAutoReloadOverlayBlocker = ()=>React.useContext(AutoReloadOverlayBlockerContext);
1306
+
1307
+ function __variableDynamicImportRuntime1__(path) {
1308
+ switch (path) {
1309
+ case './translations/ar.json': return import('./ar-sRW9VFC-.mjs');
1310
+ case './translations/cs.json': return import('./cs-BpQ26jiq.mjs');
1311
+ case './translations/de.json': return import('./de-DSxx5_x-.mjs');
1312
+ case './translations/dk.json': return import('./dk-BnjVZ7A_.mjs');
1313
+ case './translations/en.json': return import('./en-Bhut8Yay.mjs');
1314
+ case './translations/es.json': return import('./es-DG8g9igJ.mjs');
1315
+ case './translations/fr.json': return import('./fr-UpV34MHY.mjs');
1316
+ case './translations/id.json': return import('./id-BWM18ljw.mjs');
1317
+ case './translations/it.json': return import('./it-1_vd9gV4.mjs');
1318
+ case './translations/ja.json': return import('./ja-Cx23a2Ui.mjs');
1319
+ case './translations/ko.json': return import('./ko-DC7paEx5.mjs');
1320
+ case './translations/ms.json': return import('./ms-C3s4kxq6.mjs');
1321
+ case './translations/nl.json': return import('./nl-TzvfktV_.mjs');
1322
+ case './translations/pl.json': return import('./pl-BdvupIN_.mjs');
1323
+ case './translations/pt-BR.json': return import('./pt-BR-DPrVmKeZ.mjs');
1324
+ case './translations/pt.json': return import('./pt-BTLIwmCv.mjs');
1325
+ case './translations/ru.json': return import('./ru-D46no502.mjs');
1326
+ case './translations/sk.json': return import('./sk-Byr_l4Jc.mjs');
1327
+ case './translations/sv.json': return import('./sv-Bbam7IDm.mjs');
1328
+ case './translations/th.json': return import('./th-hfS0Wmk_.mjs');
1329
+ case './translations/tr.json': return import('./tr-DS7DBOhC.mjs');
1330
+ case './translations/uk.json': return import('./uk-Cj8-BKeu.mjs');
1331
+ case './translations/zh-Hans.json': return import('./zh-Hans-BElOnuRb.mjs');
1332
+ case './translations/zh.json': return import('./zh-BUVXH75-.mjs');
1333
+ default: return new Promise(function(resolve, reject) {
1334
+ (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)(
1335
+ reject.bind(null, new Error("Unknown variable dynamic import: " + path))
1336
+ );
1337
+ })
1338
+ }
1339
+ }
1340
+ // eslint-disable-next-line import/no-default-export
1341
+ var index = {
1342
+ register (app) {
1343
+ app.addReducers(reducers);
1344
+ app.addMenuLink({
1345
+ to: `plugins/${pluginId}`,
1346
+ icon: Layout,
1347
+ intlLabel: {
1348
+ id: `${pluginId}.plugin.name`,
1349
+ defaultMessage: 'Content-Type Builder'
1350
+ },
1351
+ permissions: PERMISSIONS.main,
1352
+ Component: ()=>import('./index-Cr5tfW7U.mjs').then(function (n) { return n.i; }),
1353
+ position: 5
1354
+ });
1355
+ app.registerPlugin({
1356
+ id: pluginId,
1357
+ name: pluginId,
1358
+ // Internal APIs exposed by the CTB for the other plugins to use
1359
+ apis: {
1360
+ forms: formsAPI
1361
+ }
1362
+ });
1363
+ },
1364
+ bootstrap () {},
1365
+ async registerTrads ({ locales }) {
1366
+ const importedTrads = await Promise.all(locales.map((locale)=>{
1367
+ return __variableDynamicImportRuntime1__(`./translations/${locale}.json`).then(({ default: data })=>{
1368
+ return {
1369
+ data: prefixPluginTranslations(data, pluginId),
1370
+ locale
1371
+ };
1372
+ }).catch(()=>{
1373
+ return {
1374
+ data: {},
1375
+ locale
1376
+ };
1377
+ });
1378
+ }));
1379
+ return Promise.resolve(importedTrads);
1380
+ }
1381
+ };
1382
+
1383
+ export { AutoReloadOverlayBlockerProvider as A, MAX_COMPONENT_DEPTH as M, PERMISSIONS as P, actions as a, createUid as b, createComponentUid as c, initialState$1 as d, actions$1 as e, index as f, getRelationType as g, initialState as i, makeUnique as m, nameToSlug as n, pluginId as p, retrieveComponentsFromSchema as r, useAutoReloadOverlayBlocker as u };
1384
+ //# sourceMappingURL=index-BhX2euW0.mjs.map