@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,1184 @@
1
+ import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
2
+ import { useTracking, useRBAC, Layouts, BackButton } from '@strapi/admin/strapi-admin';
3
+ import { Box, Flex, Typography, Table, Thead, Tr as Tr$1, Th, Tbody, Td, EmptyStateLayout, Button, TFooter, IconButton } from '@strapi/design-system';
4
+ import { Cross, Plus, Pencil, Trash, Lock, ListPlus, Check } from '@strapi/icons';
5
+ import get from 'lodash/get';
6
+ import has from 'lodash/has';
7
+ import isEqual from 'lodash/isEqual';
8
+ import upperFirst from 'lodash/upperFirst';
9
+ import { useIntl } from 'react-intl';
10
+ import { useNavigate, useMatch, unstable_usePrompt } from 'react-router-dom';
11
+ import { styled } from 'styled-components';
12
+ import { useState, createElement, Fragment, memo } from 'react';
13
+ import { EmptyDocuments } from '@strapi/icons/symbols';
14
+ import { u as useDataManager, C as COMPONENT_ICONS, g as getTrad, a as useFormModalNavigation, A as AttributeIcon } from './index-Cr5tfW7U.mjs';
15
+ import './index-BhX2euW0.mjs';
16
+ import '@reduxjs/toolkit';
17
+ import 'immer';
18
+ import 'lodash/set';
19
+ import 'lodash/snakeCase';
20
+ import 'pluralize';
21
+ import '@sindresorhus/slugify';
22
+ import 'lodash/cloneDeep';
23
+ import 'yup';
24
+ import 'react-dom';
25
+ import 'lodash/groupBy';
26
+ import 'lodash/size';
27
+ import 'react-redux';
28
+ import 'lodash/toLower';
29
+ import 'qs';
30
+ import 'date-fns/formatISO';
31
+ import 'lodash/truncate';
32
+ import 'lodash/uniq';
33
+ import 'lodash/fp';
34
+ import 'lodash/toNumber';
35
+ import 'lodash/camelCase';
36
+ import 'lodash/omit';
37
+ import 'lodash/sortBy';
38
+
39
+ const BoxWrapper$1 = styled(Box)`
40
+ table {
41
+ width: 100%;
42
+ white-space: nowrap;
43
+ }
44
+
45
+ thead {
46
+ border-bottom: 1px solid ${({ theme })=>theme.colors.neutral150};
47
+
48
+ tr {
49
+ border-top: 0;
50
+ }
51
+ }
52
+
53
+ tr {
54
+ border-top: 1px solid ${({ theme })=>theme.colors.neutral150};
55
+
56
+ & td,
57
+ & th {
58
+ padding: ${({ theme })=>theme.spaces[4]};
59
+ }
60
+
61
+ & td:first-of-type,
62
+ & th:first-of-type {
63
+ padding: 0 ${({ theme })=>theme.spaces[1]};
64
+ }
65
+ }
66
+
67
+ th,
68
+ td {
69
+ vertical-align: middle;
70
+ text-align: left;
71
+ color: ${({ theme })=>theme.colors.neutral600};
72
+ outline-offset: -4px;
73
+ }
74
+ `;
75
+
76
+ // Keep component-row for css specificity
77
+ const Tr = styled.tr`
78
+ &.component-row,
79
+ &.dynamiczone-row {
80
+ position: relative;
81
+ border-top: none !important;
82
+
83
+ table tr:first-child {
84
+ border-top: none;
85
+ }
86
+
87
+ > td:first-of-type {
88
+ padding: 0 0 0 2rem;
89
+ position: relative;
90
+
91
+ &::before {
92
+ content: '';
93
+ width: 0.4rem;
94
+ height: calc(100% - 40px);
95
+ position: absolute;
96
+ top: -7px;
97
+ left: 2.6rem;
98
+ border-radius: 4px;
99
+
100
+ ${({ $isFromDynamicZone, $isChildOfDynamicZone, theme })=>{
101
+ if ($isChildOfDynamicZone) {
102
+ return `background-color: ${theme.colors.primary200};`;
103
+ }
104
+ if ($isFromDynamicZone) {
105
+ return `background-color: ${theme.colors.primary200};`;
106
+ }
107
+ return `background: ${theme.colors.neutral150};`;
108
+ }}
109
+ }
110
+ }
111
+ }
112
+
113
+ &.dynamiczone-row > td:first-of-type {
114
+ padding: 0;
115
+ }
116
+ `;
117
+
118
+ const ComponentList = ({ customRowComponent, component, isFromDynamicZone = false, isNestedInDZComponent = false, firstLoopComponentUid })=>{
119
+ const { modifiedData } = useDataManager();
120
+ const { schema: { attributes } } = get(modifiedData, [
121
+ 'components',
122
+ component
123
+ ], {
124
+ schema: {
125
+ attributes: []
126
+ }
127
+ });
128
+ return /*#__PURE__*/ jsx(Tr, {
129
+ $isChildOfDynamicZone: isFromDynamicZone,
130
+ className: "component-row",
131
+ children: /*#__PURE__*/ jsx("td", {
132
+ colSpan: 12,
133
+ children: /*#__PURE__*/ jsx(List, {
134
+ customRowComponent: customRowComponent,
135
+ items: attributes,
136
+ targetUid: component,
137
+ firstLoopComponentUid: firstLoopComponentUid || component,
138
+ editTarget: "components",
139
+ isFromDynamicZone: isFromDynamicZone,
140
+ isNestedInDZComponent: isNestedInDZComponent,
141
+ isSub: true,
142
+ secondLoopComponentUid: firstLoopComponentUid ? component : null
143
+ })
144
+ })
145
+ });
146
+ };
147
+
148
+ const ComponentIcon = ({ isActive = false, icon = 'dashboard' })=>{
149
+ const Icon = COMPONENT_ICONS[icon] || COMPONENT_ICONS.dashboard;
150
+ return /*#__PURE__*/ jsx(Flex, {
151
+ alignItems: "center",
152
+ background: isActive ? 'primary200' : 'neutral200',
153
+ justifyContent: "center",
154
+ height: 8,
155
+ width: 8,
156
+ borderRadius: "50%",
157
+ children: /*#__PURE__*/ jsx(Icon, {
158
+ height: "2rem",
159
+ width: "2rem"
160
+ })
161
+ });
162
+ };
163
+
164
+ const CloseButton = styled(Box)`
165
+ position: absolute;
166
+ display: none;
167
+ top: 5px;
168
+ right: 0.8rem;
169
+
170
+ svg {
171
+ width: 1rem;
172
+ height: 1rem;
173
+
174
+ path {
175
+ fill: ${({ theme })=>theme.colors.primary600};
176
+ }
177
+ }
178
+ `;
179
+ const ComponentBox = styled(Flex)`
180
+ width: 14rem;
181
+ height: 8rem;
182
+ position: relative;
183
+ border: 1px solid ${({ theme })=>theme.colors.neutral200};
184
+ background: ${({ theme })=>theme.colors.neutral100};
185
+ border-radius: ${({ theme })=>theme.borderRadius};
186
+ max-width: 100%;
187
+
188
+ &.active,
189
+ &:focus,
190
+ &:hover {
191
+ border: 1px solid ${({ theme })=>theme.colors.primary200};
192
+ background: ${({ theme })=>theme.colors.primary100};
193
+ color: ${({ theme })=>theme.colors.primary600};
194
+
195
+ ${CloseButton} {
196
+ display: block;
197
+ }
198
+
199
+ /* > ComponentIcon */
200
+ > div:first-child {
201
+ background: ${({ theme })=>theme.colors.primary200};
202
+ color: ${({ theme })=>theme.colors.primary600};
203
+
204
+ svg {
205
+ path {
206
+ fill: ${({ theme })=>theme.colors.primary600};
207
+ }
208
+ }
209
+ }
210
+ }
211
+ `;
212
+ const ComponentCard = ({ component, dzName, index, isActive = false, isInDevelopmentMode = false, onClick })=>{
213
+ const { modifiedData, removeComponentFromDynamicZone } = useDataManager();
214
+ const { schema: { icon, displayName } } = get(modifiedData, [
215
+ 'components',
216
+ component
217
+ ], {
218
+ schema: {}
219
+ });
220
+ const onClose = (e)=>{
221
+ e.stopPropagation();
222
+ removeComponentFromDynamicZone(dzName, index);
223
+ };
224
+ return /*#__PURE__*/ jsxs(ComponentBox, {
225
+ alignItems: "center",
226
+ direction: "column",
227
+ className: isActive ? 'active' : '',
228
+ borderRadius: "borderRadius",
229
+ justifyContent: "center",
230
+ paddingLeft: 4,
231
+ paddingRight: 4,
232
+ shrink: 0,
233
+ onClick: onClick,
234
+ role: "tab",
235
+ tabIndex: isActive ? 0 : -1,
236
+ cursor: "pointer",
237
+ "aria-selected": isActive,
238
+ "aria-controls": `dz-${dzName}-panel-${index}`,
239
+ id: `dz-${dzName}-tab-${index}`,
240
+ children: [
241
+ /*#__PURE__*/ jsx(ComponentIcon, {
242
+ icon: icon,
243
+ isActive: isActive
244
+ }),
245
+ /*#__PURE__*/ jsx(Box, {
246
+ marginTop: 1,
247
+ maxWidth: "100%",
248
+ children: /*#__PURE__*/ jsx(Typography, {
249
+ variant: "pi",
250
+ fontWeight: "bold",
251
+ ellipsis: true,
252
+ children: displayName
253
+ })
254
+ }),
255
+ isInDevelopmentMode && /*#__PURE__*/ jsx(CloseButton, {
256
+ tag: "button",
257
+ onClick: onClose,
258
+ children: /*#__PURE__*/ jsx(Cross, {})
259
+ })
260
+ ]
261
+ });
262
+ };
263
+
264
+ const StyledAddIcon = styled(Plus)`
265
+ width: 3.2rem;
266
+ height: 3.2rem;
267
+ padding: 0.9rem;
268
+ border-radius: 6.4rem;
269
+ background: ${({ theme })=>theme.colors.primary100};
270
+ path {
271
+ fill: ${({ theme })=>theme.colors.primary600};
272
+ }
273
+ `;
274
+ const FixedBox = styled(Box)`
275
+ height: 9rem;
276
+ position: absolute;
277
+ width: 100%;
278
+ top: 0;
279
+ left: 0;
280
+ `;
281
+ const ScrollableStack = styled(Flex)`
282
+ width: 100%;
283
+ overflow-x: auto;
284
+ `;
285
+ const ComponentContentBox = styled(Box)`
286
+ padding-top: 9rem;
287
+ `;
288
+ const ComponentStack = styled(Flex)`
289
+ flex-shrink: 0;
290
+ width: 14rem;
291
+ height: 8rem;
292
+ justify-content: center;
293
+ align-items: center;
294
+ `;
295
+ const DynamicZoneList = ({ customRowComponent, components = [], addComponent, name, targetUid })=>{
296
+ const { isInDevelopmentMode } = useDataManager();
297
+ const [activeTab, setActiveTab] = useState(0);
298
+ const { formatMessage } = useIntl();
299
+ const toggle = (tab)=>{
300
+ if (activeTab !== tab) {
301
+ setActiveTab(tab);
302
+ }
303
+ };
304
+ const handleClickAdd = ()=>{
305
+ addComponent(name);
306
+ };
307
+ return /*#__PURE__*/ jsx(Tr, {
308
+ className: "dynamiczone-row",
309
+ $isFromDynamicZone: true,
310
+ children: /*#__PURE__*/ jsxs("td", {
311
+ colSpan: 12,
312
+ children: [
313
+ /*#__PURE__*/ jsx(FixedBox, {
314
+ paddingLeft: 8,
315
+ children: /*#__PURE__*/ jsxs(ScrollableStack, {
316
+ gap: 2,
317
+ children: [
318
+ isInDevelopmentMode && /*#__PURE__*/ jsx("button", {
319
+ type: "button",
320
+ onClick: handleClickAdd,
321
+ children: /*#__PURE__*/ jsxs(ComponentStack, {
322
+ direction: "column",
323
+ alignItems: "stretch",
324
+ gap: 1,
325
+ children: [
326
+ /*#__PURE__*/ jsx(StyledAddIcon, {}),
327
+ /*#__PURE__*/ jsx(Typography, {
328
+ variant: "pi",
329
+ fontWeight: "bold",
330
+ textColor: "primary600",
331
+ children: formatMessage({
332
+ id: getTrad('button.component.add'),
333
+ defaultMessage: 'Add a component'
334
+ })
335
+ })
336
+ ]
337
+ })
338
+ }),
339
+ /*#__PURE__*/ jsx(Flex, {
340
+ role: "tablist",
341
+ gap: 2,
342
+ children: components.map((component, index)=>{
343
+ return /*#__PURE__*/ jsx(ComponentCard, {
344
+ dzName: name || '',
345
+ index: index,
346
+ component: component,
347
+ isActive: activeTab === index,
348
+ isInDevelopmentMode: isInDevelopmentMode,
349
+ onClick: ()=>toggle(index)
350
+ }, component);
351
+ })
352
+ })
353
+ ]
354
+ })
355
+ }),
356
+ /*#__PURE__*/ jsx(ComponentContentBox, {
357
+ children: components.map((component, index)=>{
358
+ const props = {
359
+ customRowComponent,
360
+ component
361
+ };
362
+ return /*#__PURE__*/ jsx(Box, {
363
+ id: `dz-${name}-panel-${index}`,
364
+ role: "tabpanel",
365
+ "aria-labelledby": `dz-${name}-tab-${index}`,
366
+ style: {
367
+ display: activeTab === index ? 'block' : 'none'
368
+ },
369
+ children: /*#__PURE__*/ jsx("table", {
370
+ children: /*#__PURE__*/ jsx("tbody", {
371
+ children: /*#__PURE__*/ createElement(ComponentList, {
372
+ ...props,
373
+ isFromDynamicZone: true,
374
+ component: targetUid,
375
+ key: component
376
+ })
377
+ })
378
+ })
379
+ }, component);
380
+ })
381
+ })
382
+ ]
383
+ })
384
+ });
385
+ };
386
+
387
+ const IconBox = styled(Box)`
388
+ height: 2.4rem;
389
+ width: 2.4rem;
390
+ border-radius: 50%;
391
+ display: flex;
392
+ justify-content: center;
393
+ align-items: center;
394
+
395
+ svg {
396
+ height: 1rem;
397
+ width: 1rem;
398
+ }
399
+
400
+ svg path {
401
+ fill: ${({ theme, color })=>theme.colors[`${color}600`]};
402
+ }
403
+ `;
404
+ const ButtonBox = styled(Box)`
405
+ border-radius: 0 0 ${({ theme })=>theme.borderRadius} ${({ theme })=>theme.borderRadius};
406
+ display: block;
407
+ width: 100%;
408
+ border: none;
409
+ position: relative;
410
+ left: -0.4rem;
411
+ `;
412
+ const NestedTFooter = ({ children, icon, color, ...props })=>{
413
+ return /*#__PURE__*/ jsx(ButtonBox, {
414
+ paddingBottom: 4,
415
+ paddingTop: 4,
416
+ tag: "button",
417
+ type: "button",
418
+ ...props,
419
+ children: /*#__PURE__*/ jsxs(Flex, {
420
+ children: [
421
+ /*#__PURE__*/ jsx(IconBox, {
422
+ color: color,
423
+ "aria-hidden": true,
424
+ background: `${color}200`,
425
+ children: icon
426
+ }),
427
+ /*#__PURE__*/ jsx(Box, {
428
+ paddingLeft: 3,
429
+ children: /*#__PURE__*/ jsx(Typography, {
430
+ variant: "pi",
431
+ fontWeight: "bold",
432
+ textColor: `${color}600`,
433
+ children: children
434
+ })
435
+ })
436
+ ]
437
+ })
438
+ });
439
+ };
440
+
441
+ const List = ({ addComponentToDZ, customRowComponent, editTarget, firstLoopComponentUid, isFromDynamicZone = false, isMain = false, isNestedInDZComponent = false, isSub = false, items = [], secondLoopComponentUid, targetUid })=>{
442
+ const { formatMessage } = useIntl();
443
+ const { trackUsage } = useTracking();
444
+ const { isInDevelopmentMode, modifiedData, isInContentTypeView } = useDataManager();
445
+ const { onOpenModalAddField } = useFormModalNavigation();
446
+ const onClickAddField = ()=>{
447
+ trackUsage('hasClickedCTBAddFieldBanner');
448
+ onOpenModalAddField({
449
+ forTarget: editTarget,
450
+ targetUid
451
+ });
452
+ };
453
+ if (!targetUid) {
454
+ return /*#__PURE__*/ jsxs(Table, {
455
+ colCount: 2,
456
+ rowCount: 2,
457
+ children: [
458
+ /*#__PURE__*/ jsx(Thead, {
459
+ children: /*#__PURE__*/ jsxs(Tr$1, {
460
+ children: [
461
+ /*#__PURE__*/ jsx(Th, {
462
+ children: /*#__PURE__*/ jsx(Typography, {
463
+ variant: "sigma",
464
+ textColor: "neutral600",
465
+ children: formatMessage({
466
+ id: 'global.name',
467
+ defaultMessage: 'Name'
468
+ })
469
+ })
470
+ }),
471
+ /*#__PURE__*/ jsx(Th, {
472
+ children: /*#__PURE__*/ jsx(Typography, {
473
+ variant: "sigma",
474
+ textColor: "neutral600",
475
+ children: formatMessage({
476
+ id: 'global.type',
477
+ defaultMessage: 'Type'
478
+ })
479
+ })
480
+ })
481
+ ]
482
+ })
483
+ }),
484
+ /*#__PURE__*/ jsx(Tbody, {
485
+ children: /*#__PURE__*/ jsx(Tr$1, {
486
+ children: /*#__PURE__*/ jsx(Td, {
487
+ colSpan: 2,
488
+ children: /*#__PURE__*/ jsx(EmptyStateLayout, {
489
+ content: formatMessage({
490
+ id: getTrad('table.content.create-first-content-type'),
491
+ defaultMessage: 'Create your first Collection-Type'
492
+ }),
493
+ hasRadius: true,
494
+ icon: /*#__PURE__*/ jsx(EmptyDocuments, {
495
+ width: "16rem"
496
+ })
497
+ })
498
+ })
499
+ })
500
+ })
501
+ ]
502
+ });
503
+ }
504
+ if (items.length === 0 && isMain) {
505
+ return /*#__PURE__*/ jsxs(Table, {
506
+ colCount: 2,
507
+ rowCount: 2,
508
+ children: [
509
+ /*#__PURE__*/ jsx(Thead, {
510
+ children: /*#__PURE__*/ jsxs(Tr$1, {
511
+ children: [
512
+ /*#__PURE__*/ jsx(Th, {
513
+ children: /*#__PURE__*/ jsx(Typography, {
514
+ variant: "sigma",
515
+ textColor: "neutral600",
516
+ children: formatMessage({
517
+ id: 'global.name',
518
+ defaultMessage: 'Name'
519
+ })
520
+ })
521
+ }),
522
+ /*#__PURE__*/ jsx(Th, {
523
+ children: /*#__PURE__*/ jsx(Typography, {
524
+ variant: "sigma",
525
+ textColor: "neutral600",
526
+ children: formatMessage({
527
+ id: 'global.type',
528
+ defaultMessage: 'Type'
529
+ })
530
+ })
531
+ })
532
+ ]
533
+ })
534
+ }),
535
+ /*#__PURE__*/ jsx(Tbody, {
536
+ children: /*#__PURE__*/ jsx(Tr$1, {
537
+ children: /*#__PURE__*/ jsx(Td, {
538
+ colSpan: 2,
539
+ children: /*#__PURE__*/ jsx(EmptyStateLayout, {
540
+ action: /*#__PURE__*/ jsx(Button, {
541
+ onClick: onClickAddField,
542
+ size: "L",
543
+ startIcon: /*#__PURE__*/ jsx(Plus, {}),
544
+ variant: "secondary",
545
+ children: formatMessage({
546
+ id: getTrad('table.button.no-fields'),
547
+ defaultMessage: 'Add new field'
548
+ })
549
+ }),
550
+ content: formatMessage(isInContentTypeView ? {
551
+ id: getTrad('table.content.no-fields.collection-type'),
552
+ defaultMessage: 'Add your first field to this Collection-Type'
553
+ } : {
554
+ id: getTrad('table.content.no-fields.component'),
555
+ defaultMessage: 'Add your first field to this component'
556
+ }),
557
+ hasRadius: true,
558
+ icon: /*#__PURE__*/ jsx(EmptyDocuments, {
559
+ width: "16rem"
560
+ })
561
+ })
562
+ })
563
+ })
564
+ })
565
+ ]
566
+ });
567
+ }
568
+ return /*#__PURE__*/ jsxs(BoxWrapper$1, {
569
+ children: [
570
+ /*#__PURE__*/ jsx(Box, {
571
+ paddingLeft: 6,
572
+ paddingRight: isMain ? 6 : 0,
573
+ ...isMain && {
574
+ style: {
575
+ overflowX: 'auto'
576
+ }
577
+ },
578
+ children: /*#__PURE__*/ jsxs("table", {
579
+ children: [
580
+ isMain && /*#__PURE__*/ jsx("thead", {
581
+ children: /*#__PURE__*/ jsxs("tr", {
582
+ children: [
583
+ /*#__PURE__*/ jsx("th", {
584
+ children: /*#__PURE__*/ jsx(Typography, {
585
+ variant: "sigma",
586
+ textColor: "neutral800",
587
+ children: formatMessage({
588
+ id: 'global.name',
589
+ defaultMessage: 'Name'
590
+ })
591
+ })
592
+ }),
593
+ /*#__PURE__*/ jsx("th", {
594
+ colSpan: 2,
595
+ children: /*#__PURE__*/ jsx(Typography, {
596
+ variant: "sigma",
597
+ textColor: "neutral800",
598
+ children: formatMessage({
599
+ id: 'global.type',
600
+ defaultMessage: 'Type'
601
+ })
602
+ })
603
+ })
604
+ ]
605
+ })
606
+ }),
607
+ /*#__PURE__*/ jsx("tbody", {
608
+ children: items.map((item)=>{
609
+ const { type } = item;
610
+ const CustomRow = customRowComponent;
611
+ return /*#__PURE__*/ jsxs(Fragment, {
612
+ children: [
613
+ /*#__PURE__*/ jsx(CustomRow, {
614
+ ...item,
615
+ isNestedInDZComponent: isNestedInDZComponent,
616
+ targetUid: targetUid,
617
+ editTarget: editTarget,
618
+ firstLoopComponentUid: firstLoopComponentUid,
619
+ isFromDynamicZone: isFromDynamicZone,
620
+ secondLoopComponentUid: secondLoopComponentUid
621
+ }),
622
+ type === 'component' && /*#__PURE__*/ jsx(ComponentList, {
623
+ ...item,
624
+ customRowComponent: customRowComponent,
625
+ targetUid: targetUid,
626
+ isNestedInDZComponent: isFromDynamicZone,
627
+ editTarget: editTarget,
628
+ firstLoopComponentUid: firstLoopComponentUid
629
+ }),
630
+ type === 'dynamiczone' && /*#__PURE__*/ jsx(DynamicZoneList, {
631
+ ...item,
632
+ customRowComponent: customRowComponent,
633
+ addComponent: addComponentToDZ,
634
+ targetUid: targetUid
635
+ })
636
+ ]
637
+ }, item.name);
638
+ })
639
+ })
640
+ ]
641
+ })
642
+ }),
643
+ isMain && isInDevelopmentMode && /*#__PURE__*/ jsx(TFooter, {
644
+ cursor: "pointer",
645
+ icon: /*#__PURE__*/ jsx(Plus, {}),
646
+ onClick: onClickAddField,
647
+ children: formatMessage({
648
+ id: getTrad(`form.button.add.field.to.${modifiedData.contentType ? modifiedData.contentType.schema.kind : editTarget || 'collectionType'}`),
649
+ defaultMessage: 'Add another field'
650
+ })
651
+ }),
652
+ isSub && isInDevelopmentMode && !isFromDynamicZone && /*#__PURE__*/ jsx(NestedTFooter, {
653
+ icon: /*#__PURE__*/ jsx(Plus, {}),
654
+ onClick: onClickAddField,
655
+ color: isFromDynamicZone ? 'primary' : 'neutral',
656
+ children: formatMessage({
657
+ id: getTrad(`form.button.add.field.to.component`),
658
+ defaultMessage: 'Add another field'
659
+ })
660
+ })
661
+ ]
662
+ });
663
+ };
664
+
665
+ const StyledBox = styled(Box)`
666
+ position: absolute;
667
+ left: -1.8rem;
668
+ top: 0px;
669
+
670
+ &:before {
671
+ content: '';
672
+ width: 0.4rem;
673
+ height: 1.2rem;
674
+ background: ${({ theme, color })=>theme.colors[color]};
675
+ display: block;
676
+ }
677
+ `;
678
+ const Svg = styled.svg`
679
+ position: relative;
680
+ flex-shrink: 0;
681
+ transform: translate(-0.5px, -1px);
682
+
683
+ * {
684
+ fill: ${({ theme, color })=>theme.colors[color]};
685
+ }
686
+ `;
687
+ const Curve = (props)=>/*#__PURE__*/ jsx(StyledBox, {
688
+ children: /*#__PURE__*/ jsx(Svg, {
689
+ width: "20",
690
+ height: "23",
691
+ viewBox: "0 0 20 23",
692
+ fill: "none",
693
+ xmlns: "http://www.w3.org/2000/svg",
694
+ ...props,
695
+ children: /*#__PURE__*/ jsx("path", {
696
+ fillRule: "evenodd",
697
+ clipRule: "evenodd",
698
+ d: "M7.02477 14.7513C8.65865 17.0594 11.6046 18.6059 17.5596 18.8856C18.6836 18.9384 19.5976 19.8435 19.5976 20.9688V20.9688C19.5976 22.0941 18.6841 23.0125 17.5599 22.9643C10.9409 22.6805 6.454 20.9387 3.75496 17.1258C0.937988 13.1464 0.486328 7.39309 0.486328 0.593262H4.50974C4.50974 7.54693 5.06394 11.9813 7.02477 14.7513Z"
699
+ })
700
+ })
701
+ });
702
+
703
+ const DisplayedType = ({ type, customField = null, repeatable = false })=>{
704
+ const { formatMessage } = useIntl();
705
+ let readableType = type;
706
+ if ([
707
+ 'integer',
708
+ 'biginteger',
709
+ 'float',
710
+ 'decimal'
711
+ ].includes(type)) {
712
+ readableType = 'number';
713
+ } else if ([
714
+ 'string'
715
+ ].includes(type)) {
716
+ readableType = 'text';
717
+ }
718
+ if (customField) {
719
+ return /*#__PURE__*/ jsx(Typography, {
720
+ children: formatMessage({
721
+ id: getTrad('attribute.customField'),
722
+ defaultMessage: 'Custom field'
723
+ })
724
+ });
725
+ }
726
+ return /*#__PURE__*/ jsxs(Typography, {
727
+ textColor: "neutral800",
728
+ children: [
729
+ formatMessage({
730
+ id: getTrad(`attribute.${readableType}`),
731
+ defaultMessage: type
732
+ }),
733
+ " ",
734
+ repeatable && formatMessage({
735
+ id: getTrad('component.repeatable'),
736
+ defaultMessage: '(repeatable)'
737
+ })
738
+ ]
739
+ });
740
+ };
741
+
742
+ const UpperFirst = ({ content })=>/*#__PURE__*/ jsx(Fragment$1, {
743
+ children: upperFirst(content)
744
+ });
745
+
746
+ const BoxWrapper = styled(Box)`
747
+ position: relative;
748
+ `;
749
+ const ListRow = /*#__PURE__*/ memo(({ configurable = true, customField = null, editTarget, firstLoopComponentUid = null, isFromDynamicZone = false, name, onClick, relation = '', repeatable = false, secondLoopComponentUid = null, target = null, targetUid = null, type })=>{
750
+ const { contentTypes, isInDevelopmentMode, removeAttribute } = useDataManager();
751
+ const { formatMessage } = useIntl();
752
+ const isMorph = type === 'relation' && relation.includes('morph');
753
+ const ico = [
754
+ 'integer',
755
+ 'biginteger',
756
+ 'float',
757
+ 'decimal'
758
+ ].includes(type) ? 'number' : type;
759
+ const contentType = get(contentTypes, [
760
+ target
761
+ ], {});
762
+ const contentTypeFriendlyName = get(contentType, [
763
+ 'schema',
764
+ 'displayName'
765
+ ], '');
766
+ const isPluginContentType = get(contentType, 'plugin');
767
+ const src = target ? 'relation' : ico;
768
+ const handleClick = ()=>{
769
+ if (isMorph) {
770
+ return;
771
+ }
772
+ if (configurable !== false) {
773
+ const attrType = type;
774
+ onClick(// Tells where the attribute is located in the main modifiedData object : contentType, component or components
775
+ editTarget, // main data type uid
776
+ secondLoopComponentUid || firstLoopComponentUid || targetUid, // Name of the attribute
777
+ name, // Type of the attribute
778
+ attrType, customField);
779
+ }
780
+ };
781
+ let loopNumber;
782
+ if (secondLoopComponentUid && firstLoopComponentUid) {
783
+ loopNumber = 2;
784
+ } else if (firstLoopComponentUid) {
785
+ loopNumber = 1;
786
+ } else {
787
+ loopNumber = 0;
788
+ }
789
+ return /*#__PURE__*/ jsxs(BoxWrapper, {
790
+ tag: "tr",
791
+ onClick: isInDevelopmentMode && configurable && !isMorph ? handleClick : undefined,
792
+ children: [
793
+ /*#__PURE__*/ jsxs("td", {
794
+ style: {
795
+ position: 'relative'
796
+ },
797
+ children: [
798
+ loopNumber !== 0 && /*#__PURE__*/ jsx(Curve, {
799
+ color: isFromDynamicZone ? 'primary200' : 'neutral150'
800
+ }),
801
+ /*#__PURE__*/ jsxs(Flex, {
802
+ paddingLeft: 2,
803
+ gap: 4,
804
+ children: [
805
+ /*#__PURE__*/ jsx(AttributeIcon, {
806
+ type: src,
807
+ customField: customField
808
+ }),
809
+ /*#__PURE__*/ jsx(Typography, {
810
+ textColor: "neutral800",
811
+ fontWeight: "bold",
812
+ children: name
813
+ })
814
+ ]
815
+ })
816
+ ]
817
+ }),
818
+ /*#__PURE__*/ jsx("td", {
819
+ children: target ? /*#__PURE__*/ jsxs(Typography, {
820
+ textColor: "neutral800",
821
+ children: [
822
+ formatMessage({
823
+ id: getTrad(`modelPage.attribute.${isMorph ? 'relation-polymorphic' : 'relationWith'}`),
824
+ defaultMessage: 'Relation with'
825
+ }),
826
+ " ",
827
+ /*#__PURE__*/ jsxs("span", {
828
+ style: {
829
+ fontStyle: 'italic'
830
+ },
831
+ children: [
832
+ /*#__PURE__*/ jsx(UpperFirst, {
833
+ content: contentTypeFriendlyName
834
+ }),
835
+ " ",
836
+ isPluginContentType && `(${formatMessage({
837
+ id: getTrad(`from`),
838
+ defaultMessage: 'from'
839
+ })}: ${isPluginContentType})`
840
+ ]
841
+ })
842
+ ]
843
+ }) : /*#__PURE__*/ jsx(DisplayedType, {
844
+ type: type,
845
+ customField: customField,
846
+ repeatable: repeatable
847
+ })
848
+ }),
849
+ /*#__PURE__*/ jsx("td", {
850
+ children: isInDevelopmentMode ? /*#__PURE__*/ jsx(Flex, {
851
+ justifyContent: "flex-end",
852
+ onClick: (e)=>e.stopPropagation(),
853
+ children: configurable ? /*#__PURE__*/ jsxs(Flex, {
854
+ gap: 1,
855
+ children: [
856
+ !isMorph && /*#__PURE__*/ jsx(IconButton, {
857
+ onClick: handleClick,
858
+ label: `${formatMessage({
859
+ id: 'app.utils.edit',
860
+ defaultMessage: 'Edit'
861
+ })} ${name}`,
862
+ variant: "ghost",
863
+ children: /*#__PURE__*/ jsx(Pencil, {})
864
+ }),
865
+ /*#__PURE__*/ jsx(IconButton, {
866
+ onClick: (e)=>{
867
+ e.stopPropagation();
868
+ removeAttribute(editTarget, name, secondLoopComponentUid || firstLoopComponentUid || '');
869
+ },
870
+ label: `${formatMessage({
871
+ id: 'global.delete',
872
+ defaultMessage: 'Delete'
873
+ })} ${name}`,
874
+ variant: "ghost",
875
+ children: /*#__PURE__*/ jsx(Trash, {})
876
+ })
877
+ ]
878
+ }) : /*#__PURE__*/ jsx(Lock, {})
879
+ }) : /*
880
+ In production mode the edit icons aren't visible, therefore
881
+ we need to reserve the same space, otherwise the height of the
882
+ row might collapse, leading to bad positioned curve icons
883
+ */ /*#__PURE__*/ jsx(Box, {
884
+ height: "3.2rem"
885
+ })
886
+ })
887
+ ]
888
+ });
889
+ });
890
+
891
+ const getAttributeDisplayedType = (type)=>{
892
+ let displayedType;
893
+ switch(type){
894
+ case 'date':
895
+ case 'datetime':
896
+ case 'time':
897
+ case 'timestamp':
898
+ displayedType = 'date';
899
+ break;
900
+ case 'integer':
901
+ case 'biginteger':
902
+ case 'decimal':
903
+ case 'float':
904
+ displayedType = 'number';
905
+ break;
906
+ case 'string':
907
+ case 'text':
908
+ displayedType = 'text';
909
+ break;
910
+ case '':
911
+ displayedType = 'relation';
912
+ break;
913
+ default:
914
+ displayedType = type;
915
+ }
916
+ return displayedType;
917
+ };
918
+
919
+ const cmPermissions = {
920
+ collectionTypesConfigurations: [
921
+ {
922
+ action: 'plugin::content-manager.collection-types.configure-view',
923
+ subject: null
924
+ }
925
+ ],
926
+ componentsConfigurations: [
927
+ {
928
+ action: 'plugin::content-manager.components.configure-layout',
929
+ subject: null
930
+ }
931
+ ],
932
+ singleTypesConfigurations: [
933
+ {
934
+ action: 'plugin::content-manager.single-types.configure-view',
935
+ subject: null
936
+ }
937
+ ]
938
+ };
939
+ const getPermission = ({ isInContentTypeView, contentTypeKind })=>{
940
+ if (isInContentTypeView) {
941
+ if (contentTypeKind === 'singleType') {
942
+ return cmPermissions.singleTypesConfigurations;
943
+ }
944
+ return cmPermissions.collectionTypesConfigurations;
945
+ }
946
+ return cmPermissions.componentsConfigurations;
947
+ };
948
+ const LinkToCMSettingsView = /*#__PURE__*/ memo(({ disabled, isInContentTypeView = true, contentTypeKind = 'collectionType', targetUid = '' })=>{
949
+ const { formatMessage } = useIntl();
950
+ const navigate = useNavigate();
951
+ const permissionsToApply = getPermission({
952
+ isInContentTypeView,
953
+ contentTypeKind
954
+ });
955
+ const label = formatMessage({
956
+ id: 'content-type-builder.form.button.configure-view',
957
+ defaultMessage: 'Configure the view'
958
+ });
959
+ const handleClick = ()=>{
960
+ if (disabled) {
961
+ return false;
962
+ }
963
+ if (isInContentTypeView) {
964
+ navigate(`/content-manager/collection-types/${targetUid}/configurations/edit`);
965
+ } else {
966
+ navigate(`/content-manager/components/${targetUid}/configurations/edit`);
967
+ }
968
+ return false;
969
+ };
970
+ const { isLoading, allowedActions } = useRBAC({
971
+ viewConfig: permissionsToApply
972
+ });
973
+ if (isLoading) {
974
+ return null;
975
+ }
976
+ if (!allowedActions.canConfigureView && !allowedActions.canConfigureLayout) {
977
+ return null;
978
+ }
979
+ return /*#__PURE__*/ jsx(Button, {
980
+ startIcon: /*#__PURE__*/ jsx(ListPlus, {}),
981
+ variant: "tertiary",
982
+ onClick: handleClick,
983
+ disabled: disabled,
984
+ children: label
985
+ });
986
+ });
987
+
988
+ const LayoutsHeaderCustom = styled(Layouts.Header)`
989
+ overflow-wrap: anywhere;
990
+ `;
991
+ const ListView = ()=>{
992
+ const { initialData, modifiedData, isInDevelopmentMode, isInContentTypeView, submitData } = useDataManager();
993
+ const { formatMessage } = useIntl();
994
+ const { trackUsage } = useTracking();
995
+ const match = useMatch('/plugins/content-type-builder/:kind/:currentUID');
996
+ const { onOpenModalAddComponentsToDZ, onOpenModalAddField, onOpenModalEditField, onOpenModalEditSchema, onOpenModalEditCustomField } = useFormModalNavigation();
997
+ const firstMainDataPath = isInContentTypeView ? 'contentType' : 'component';
998
+ const mainDataTypeAttributesPath = [
999
+ firstMainDataPath,
1000
+ 'schema',
1001
+ 'attributes'
1002
+ ];
1003
+ const targetUid = get(modifiedData, [
1004
+ firstMainDataPath,
1005
+ 'uid'
1006
+ ]);
1007
+ const isTemporary = get(modifiedData, [
1008
+ firstMainDataPath,
1009
+ 'isTemporary'
1010
+ ], false);
1011
+ const contentTypeKind = get(modifiedData, [
1012
+ firstMainDataPath,
1013
+ 'schema',
1014
+ 'kind'
1015
+ ], null);
1016
+ const attributes = get(modifiedData, mainDataTypeAttributesPath, []);
1017
+ const isFromPlugin = has(initialData, [
1018
+ firstMainDataPath,
1019
+ 'plugin'
1020
+ ]);
1021
+ const hasModelBeenModified = !isEqual(modifiedData, initialData);
1022
+ const forTarget = isInContentTypeView ? 'contentType' : 'component';
1023
+ const handleClickAddComponentToDZ = (dynamicZoneTarget)=>{
1024
+ onOpenModalAddComponentsToDZ({
1025
+ dynamicZoneTarget,
1026
+ targetUid
1027
+ });
1028
+ };
1029
+ const handleClickEditField = async (forTarget, targetUid, attributeName, type, customField)=>{
1030
+ const attributeType = getAttributeDisplayedType(type);
1031
+ const step = type === 'component' ? '2' : null;
1032
+ if (customField) {
1033
+ onOpenModalEditCustomField({
1034
+ forTarget,
1035
+ targetUid,
1036
+ attributeName,
1037
+ attributeType,
1038
+ customFieldUid: customField
1039
+ });
1040
+ } else {
1041
+ onOpenModalEditField({
1042
+ forTarget,
1043
+ targetUid,
1044
+ attributeName,
1045
+ attributeType,
1046
+ step
1047
+ });
1048
+ }
1049
+ };
1050
+ let label = get(modifiedData, [
1051
+ firstMainDataPath,
1052
+ 'schema',
1053
+ 'displayName'
1054
+ ], '');
1055
+ const kind = get(modifiedData, [
1056
+ firstMainDataPath,
1057
+ 'schema',
1058
+ 'kind'
1059
+ ], '');
1060
+ const isCreatingFirstContentType = match?.params.currentUID === 'create-content-type';
1061
+ if (!label && isCreatingFirstContentType) {
1062
+ label = formatMessage({
1063
+ id: getTrad('button.model.create'),
1064
+ defaultMessage: 'Create new collection type'
1065
+ });
1066
+ }
1067
+ const onEdit = ()=>{
1068
+ const contentType = kind || firstMainDataPath;
1069
+ if (contentType === 'collectionType') {
1070
+ trackUsage('willEditNameOfContentType');
1071
+ }
1072
+ if (contentType === 'singleType') {
1073
+ trackUsage('willEditNameOfSingleType');
1074
+ }
1075
+ onOpenModalEditSchema({
1076
+ modalType: firstMainDataPath,
1077
+ forTarget: firstMainDataPath,
1078
+ targetUid,
1079
+ kind: contentType
1080
+ });
1081
+ };
1082
+ unstable_usePrompt({
1083
+ when: hasModelBeenModified,
1084
+ message: formatMessage({
1085
+ id: getTrad('prompt.unsaved'),
1086
+ defaultMessage: 'Are you sure?'
1087
+ })
1088
+ });
1089
+ const primaryAction = isInDevelopmentMode && /*#__PURE__*/ jsxs(Flex, {
1090
+ gap: 2,
1091
+ marginLeft: 2,
1092
+ children: [
1093
+ !isCreatingFirstContentType && /*#__PURE__*/ jsx(Button, {
1094
+ startIcon: /*#__PURE__*/ jsx(Plus, {}),
1095
+ variant: "secondary",
1096
+ minWidth: "max-content",
1097
+ onClick: ()=>{
1098
+ onOpenModalAddField({
1099
+ forTarget,
1100
+ targetUid
1101
+ });
1102
+ },
1103
+ children: formatMessage({
1104
+ id: getTrad('button.attributes.add.another'),
1105
+ defaultMessage: 'Add another field'
1106
+ })
1107
+ }),
1108
+ /*#__PURE__*/ jsx(Button, {
1109
+ startIcon: /*#__PURE__*/ jsx(Check, {}),
1110
+ onClick: async ()=>await submitData(),
1111
+ type: "submit",
1112
+ disabled: isEqual(modifiedData, initialData),
1113
+ children: formatMessage({
1114
+ id: 'global.save',
1115
+ defaultMessage: 'Save'
1116
+ })
1117
+ })
1118
+ ]
1119
+ });
1120
+ const secondaryAction = isInDevelopmentMode && !isFromPlugin && !isCreatingFirstContentType && /*#__PURE__*/ jsx(Button, {
1121
+ startIcon: /*#__PURE__*/ jsx(Pencil, {}),
1122
+ variant: "tertiary",
1123
+ onClick: onEdit,
1124
+ children: formatMessage({
1125
+ id: 'app.utils.edit',
1126
+ defaultMessage: 'Edit'
1127
+ })
1128
+ });
1129
+ return /*#__PURE__*/ jsxs(Fragment$1, {
1130
+ children: [
1131
+ /*#__PURE__*/ jsx(LayoutsHeaderCustom, {
1132
+ id: "title",
1133
+ primaryAction: primaryAction,
1134
+ secondaryAction: secondaryAction,
1135
+ title: upperFirst(label),
1136
+ subtitle: formatMessage({
1137
+ id: getTrad('listView.headerLayout.description'),
1138
+ defaultMessage: 'Build the data architecture of your content'
1139
+ }),
1140
+ navigationAction: /*#__PURE__*/ jsx(BackButton, {})
1141
+ }),
1142
+ /*#__PURE__*/ jsx(Layouts.Content, {
1143
+ children: /*#__PURE__*/ jsxs(Flex, {
1144
+ direction: "column",
1145
+ alignItems: "stretch",
1146
+ gap: 4,
1147
+ children: [
1148
+ /*#__PURE__*/ jsx(Flex, {
1149
+ justifyContent: "flex-end",
1150
+ children: /*#__PURE__*/ jsx(Flex, {
1151
+ gap: 2,
1152
+ children: /*#__PURE__*/ jsx(LinkToCMSettingsView, {
1153
+ targetUid: targetUid,
1154
+ isInContentTypeView: isInContentTypeView,
1155
+ contentTypeKind: contentTypeKind,
1156
+ disabled: isCreatingFirstContentType || isTemporary
1157
+ }, "link-to-cm-settings-view")
1158
+ })
1159
+ }),
1160
+ /*#__PURE__*/ jsx(Box, {
1161
+ background: "neutral0",
1162
+ shadow: "filterShadow",
1163
+ hasRadius: true,
1164
+ children: /*#__PURE__*/ jsx(List, {
1165
+ items: attributes,
1166
+ customRowComponent: (props)=>/*#__PURE__*/ jsx(ListRow, {
1167
+ ...props,
1168
+ onClick: handleClickEditField
1169
+ }),
1170
+ addComponentToDZ: handleClickAddComponentToDZ,
1171
+ targetUid: targetUid,
1172
+ editTarget: forTarget,
1173
+ isMain: true
1174
+ })
1175
+ })
1176
+ ]
1177
+ })
1178
+ })
1179
+ ]
1180
+ });
1181
+ };
1182
+
1183
+ export { ListView as default };
1184
+ //# sourceMappingURL=ListView-CDnrvVrV.mjs.map