@strapi/admin 4.6.0-alpha.1 → 4.6.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/src/components/AuthenticatedApp/index.js +13 -2
- package/admin/src/components/GlobalStyle/index.js +0 -5
- package/admin/src/content-manager/components/ComponentIcon/ComponentIcon.js +49 -0
- package/admin/src/content-manager/components/ComponentIcon/index.js +1 -0
- package/admin/src/content-manager/components/ComponentInitializer/index.js +1 -7
- package/admin/src/content-manager/components/{RepeatableComponent/DragPreview.js → DragLayer/ComponentDragPreview.js} +10 -11
- package/admin/src/content-manager/components/DragLayer/RelationDragPreview.js +75 -0
- package/admin/src/content-manager/components/DragLayer/index.js +23 -7
- package/admin/src/content-manager/components/DynamicZone/components/ComponentCard.js +17 -31
- package/admin/src/content-manager/components/DynamicZone/components/ComponentCategory.js +2 -2
- package/admin/src/content-manager/components/DynamicZone/components/DynamicComponent.js +129 -85
- package/admin/src/content-manager/components/DynamicZone/index.js +99 -24
- package/admin/src/content-manager/components/DynamicZone/utils/select.js +9 -5
- package/admin/src/content-manager/components/EditViewDataManagerProvider/index.js +76 -14
- package/admin/src/content-manager/components/EditViewDataManagerProvider/reducer.js +42 -25
- package/admin/src/content-manager/components/EditViewDataManagerProvider/utils/cleanData.js +24 -5
- package/admin/src/content-manager/components/EditViewDataManagerProvider/utils/recursivelyFindPathsBasedOnCondition.js +8 -1
- package/admin/src/content-manager/components/InputJSON/FieldWrapper.js +10 -2
- package/admin/src/content-manager/components/InputJSON/Label.js +2 -18
- package/admin/src/content-manager/components/InputJSON/index.js +7 -3
- package/admin/src/content-manager/components/NonRepeatableComponent/index.js +4 -0
- package/admin/src/content-manager/components/RelationInput/RelationInput.js +205 -74
- package/admin/src/content-manager/components/RelationInput/components/RelationItem.js +136 -21
- package/admin/src/content-manager/components/RelationInput/components/RelationList.js +1 -2
- package/admin/src/content-manager/components/RelationInput/constants.js +1 -0
- package/admin/src/content-manager/components/RelationInput/index.js +1 -0
- package/admin/src/content-manager/components/RelationInputDataManager/RelationInputDataManager.js +132 -10
- package/admin/src/content-manager/components/RepeatableComponent/components/Accordion.js +77 -0
- package/admin/src/content-manager/components/RepeatableComponent/components/Component.js +262 -0
- package/admin/src/content-manager/components/RepeatableComponent/{DraggedItem → components}/Preview.js +0 -0
- package/admin/src/content-manager/components/RepeatableComponent/index.js +148 -90
- package/admin/src/content-manager/components/RepeatableComponent/utils/getComponentErrorKeys.js +1 -1
- package/admin/src/content-manager/components/SingleTypeFormWrapper/index.js +1 -1
- package/admin/src/content-manager/components/Wysiwyg/Editor.js +1 -1
- package/admin/src/content-manager/hooks/index.js +2 -0
- package/admin/src/content-manager/hooks/useDragAndDrop.js +134 -0
- package/admin/src/content-manager/hooks/useKeyboardDragAndDrop.js +98 -0
- package/admin/src/content-manager/hooks/useLazyComponents/index.js +40 -15
- package/admin/src/content-manager/pages/EditSettingsView/components/DynamicZoneList.js +18 -38
- package/admin/src/content-manager/sharedReducers/crudReducer/actions.js +5 -0
- package/admin/src/content-manager/sharedReducers/crudReducer/constants.js +2 -0
- package/admin/src/content-manager/sharedReducers/crudReducer/reducer.js +7 -0
- package/admin/src/content-manager/utils/ItemTypes.js +1 -1
- package/admin/src/content-manager/utils/composeRefs.js +28 -0
- package/admin/src/content-manager/utils/getMaxTempKey.js +1 -1
- package/admin/src/content-manager/utils/index.js +7 -0
- package/admin/src/core/utils/axiosInstance.js +4 -2
- package/admin/src/hooks/index.js +1 -0
- package/admin/src/hooks/useFetchClient/index.js +23 -0
- package/admin/src/hooks/useSettingsMenu/init.js +0 -7
- package/admin/src/pages/Admin/Onboarding/index.js +42 -44
- package/admin/src/pages/App/index.js +20 -13
- package/admin/src/pages/AuthPage/components/Register/index.js +1 -1
- package/admin/src/pages/AuthPage/components/ResetPassword/index.js +1 -1
- package/admin/src/pages/HomePage/SocialLinks.js +4 -4
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/index.js +2 -3
- package/admin/src/pages/SettingsPage/pages/Users/ListPage/ModalForm/index.js +23 -18
- package/admin/src/pages/SettingsPage/utils/defaultRoutes.js +0 -11
- package/admin/src/permissions/defaultPermissions.js +0 -4
- package/admin/src/translations/en.json +8 -8
- package/admin/src/translations/sk.json +274 -52
- package/admin/src/translations/tr.json +485 -5
- package/admin/src/utils/fetchClient.js +45 -0
- package/admin/src/utils/getFetchClient.js +10 -0
- package/admin/src/utils/index.js +1 -0
- package/admin/src/utils/uniqueAdminHash.js +22 -0
- package/build/2235.06c13219.chunk.js +106 -0
- package/build/2598.962797b2.chunk.js +159 -0
- package/build/4318.0bbd3f4b.chunk.js +30 -0
- package/build/4958.7c118f5e.chunk.js +276 -0
- package/build/5052.712419ea.chunk.js +65 -0
- package/build/7295.04ac49dc.chunk.js +114 -0
- package/build/805.ddcead70.chunk.js +138 -0
- package/build/{8633.8da5488a.chunk.js → 8633.59223842.chunk.js} +1 -1
- package/build/874.bde3ea04.chunk.js +104 -0
- package/build/{1233.80b05d66.chunk.js → 9159.ac968e72.chunk.js} +67 -67
- package/build/9707.77e475ee.chunk.js +101 -0
- package/build/Admin-authenticatedApp.9dd415b8.chunk.js +72 -0
- package/build/{Admin_homePage.54e33c2d.chunk.js → Admin_homePage.8945f71a.chunk.js} +5 -5
- package/build/{Admin_marketplace.8219fda6.chunk.js → Admin_marketplace.ed754a4a.chunk.js} +1 -1
- package/build/Admin_pluginsPage.67728975.chunk.js +6 -0
- package/build/{Admin_profilePage.e9fcce92.chunk.js → Admin_profilePage.60ab80bb.chunk.js} +1 -1
- package/build/{Admin_settingsPage.d3f48e9e.chunk.js → Admin_settingsPage.9ce40fed.chunk.js} +15 -15
- package/build/Upload_ConfigureTheView.7cb2a3fd.chunk.js +1 -0
- package/build/admin-app.d8fc7c4d.chunk.js +112 -0
- package/build/admin-edit-roles-page.f407538c.chunk.js +1 -0
- package/build/admin-edit-users.5547b126.chunk.js +10 -0
- package/build/{admin-users.a0748674.chunk.js → admin-users.4b6b47f8.chunk.js} +2 -2
- package/build/api-tokens-create-page.dd4ddfcb.chunk.js +1 -0
- package/build/api-tokens-edit-page.821c5a6c.chunk.js +1 -0
- package/build/{api-tokens-list-page.700e575f.chunk.js → api-tokens-list-page.50519ed7.chunk.js} +1 -1
- package/build/content-manager.f2214e32.chunk.js +1166 -0
- package/build/content-type-builder-list-view.4aea46fa.chunk.js +198 -0
- package/build/content-type-builder-translation-de-json.a52482c7.chunk.js +1 -0
- package/build/content-type-builder-translation-dk-json.a8616510.chunk.js +1 -0
- package/build/content-type-builder-translation-en-json.1d9a3c14.chunk.js +1 -0
- package/build/content-type-builder-translation-es-json.c3ea46fb.chunk.js +1 -0
- package/build/content-type-builder-translation-ko-json.3fb7ddc8.chunk.js +1 -0
- package/build/content-type-builder-translation-pl-json.9b2993b2.chunk.js +1 -0
- package/build/content-type-builder-translation-pt-BR-json.6d255441.chunk.js +1 -0
- package/build/content-type-builder-translation-sv-json.c608b9ca.chunk.js +1 -0
- package/build/content-type-builder-translation-tr-json.949e22eb.chunk.js +1 -0
- package/build/content-type-builder-translation-zh-json.b79513e4.chunk.js +1 -0
- package/build/content-type-builder.8a9a77f9.chunk.js +127 -0
- package/build/email-settings-page.c6e62f6b.chunk.js +15 -0
- package/build/email-translation-tr-json.8aa034bb.chunk.js +1 -0
- package/build/en-json.1abdade9.chunk.js +1 -0
- package/build/{i18n-settings-page.195d42fe.chunk.js → i18n-settings-page.ee572037.chunk.js} +1 -1
- package/build/i18n-translation-tr-json.34ca9d61.chunk.js +1 -0
- package/build/index.html +1 -1
- package/build/main.91f6e21e.js +4099 -0
- package/build/runtime~main.447b0382.js +2 -0
- package/build/sk-json.2af48064.chunk.js +1 -0
- package/build/sso-settings-page.91924df1.chunk.js +41 -0
- package/build/tr-json.eac8bd79.chunk.js +1 -0
- package/build/upload-settings.326cd9fd.chunk.js +89 -0
- package/build/upload-translation-en-json.32cf9aff.chunk.js +1 -0
- package/build/upload-translation-sk-json.fe86c53b.chunk.js +1 -0
- package/build/upload-translation-tr-json.b173223a.chunk.js +1 -0
- package/build/upload.2977cb13.chunk.js +38 -0
- package/build/users-advanced-settings-page.0c0b8230.chunk.js +13 -0
- package/build/users-email-settings-page.18d4a475.chunk.js +28 -0
- package/build/{users-permissions-translation-dk-json.fe39c74b.chunk.js → users-permissions-translation-dk-json.bad0b786.chunk.js} +1 -1
- package/build/{users-permissions-translation-en-json.765abf48.chunk.js → users-permissions-translation-en-json.aeab388a.chunk.js} +1 -1
- package/build/{users-permissions-translation-es-json.1bb9cde2.chunk.js → users-permissions-translation-es-json.152a923f.chunk.js} +1 -1
- package/build/{users-permissions-translation-ko-json.3be77775.chunk.js → users-permissions-translation-ko-json.6bd0ae22.chunk.js} +1 -1
- package/build/{users-permissions-translation-pl-json.1dbdd4a1.chunk.js → users-permissions-translation-pl-json.c6a02992.chunk.js} +1 -1
- package/build/{users-permissions-translation-sv-json.d5d11648.chunk.js → users-permissions-translation-sv-json.370d6eee.chunk.js} +1 -1
- package/build/users-permissions-translation-tr-json.9bebc250.chunk.js +1 -0
- package/build/{users-permissions-translation-zh-json.92f406f9.chunk.js → users-permissions-translation-zh-json.1fea833f.chunk.js} +1 -1
- package/build/users-providers-settings-page.25dd858e.chunk.js +1 -0
- package/build/users-roles-settings-page.8482a999.chunk.js +30 -0
- package/build/{webhook-edit-page.14ad1e6e.chunk.js → webhook-edit-page.dcc3d145.chunk.js} +4 -4
- package/build/{webhook-list-page.b87821f2.chunk.js → webhook-list-page.894e6959.chunk.js} +1 -1
- package/ee/server/services/passport/provider-registry.js +1 -1
- package/package.json +16 -22
- package/server/controllers/admin.js +2 -0
- package/server/routes/admin.js +1 -1
- package/server/services/metrics.js +5 -2
- package/server/services/role.js +1 -0
- package/utils/get-plugins-path.js +17 -3
- package/webpack.alias.js +0 -2
- package/admin/src/content-manager/components/BackHeader/index.js +0 -8
- package/admin/src/content-manager/components/Block/components.js +0 -28
- package/admin/src/content-manager/components/Block/index.js +0 -43
- package/admin/src/content-manager/components/Container/index.js +0 -7
- package/admin/src/content-manager/components/CustomInputCheckbox/components.js +0 -77
- package/admin/src/content-manager/components/CustomInputCheckbox/index.js +0 -53
- package/admin/src/content-manager/components/DynamicComponentCard/Wrapper.js +0 -63
- package/admin/src/content-manager/components/FilterOptionsCTA/index.js +0 -14
- package/admin/src/content-manager/components/FormTitle/index.js +0 -22
- package/admin/src/content-manager/components/FormWrapper/index.js +0 -20
- package/admin/src/content-manager/components/InputJSON/FieldError.js +0 -38
- package/admin/src/content-manager/components/LayoutTitle/index.js +0 -19
- package/admin/src/content-manager/components/PlusButton/index.js +0 -52
- package/admin/src/content-manager/components/PreviewCarret/components.js +0 -27
- package/admin/src/content-manager/components/PreviewCarret/index.js +0 -22
- package/admin/src/content-manager/components/RepeatableComponent/AccordionGroupCustom/index.js +0 -122
- package/admin/src/content-manager/components/RepeatableComponent/AddFieldButton.js +0 -58
- package/admin/src/content-manager/components/RepeatableComponent/DraggedItem/DraggingSibling.js +0 -72
- package/admin/src/content-manager/components/RepeatableComponent/DraggedItem/IconButtonCustoms.js +0 -32
- package/admin/src/content-manager/components/RepeatableComponent/DraggedItem/index.js +0 -322
- package/admin/src/content-manager/components/RepeatableComponent/DraggedItem/utils/connect.js +0 -11
- package/admin/src/content-manager/components/RepeatableComponent/DraggedItem/utils/index.js +0 -2
- package/admin/src/content-manager/components/RepeatableComponent/DraggedItem/utils/select.js +0 -30
- package/admin/src/content-manager/components/RepeatableComponent/utils/connect.js +0 -11
- package/admin/src/content-manager/components/RepeatableComponent/utils/select.js +0 -12
- package/admin/src/content-manager/components/SectionTitle/Title.js +0 -11
- package/admin/src/content-manager/components/SectionTitle/index.js +0 -26
- package/admin/src/content-manager/hooks/__test__/usePrev.test.js +0 -26
- package/admin/src/pages/SettingsPage/pages/AuditLogs/ListView/DynamicTable/TableRows/CellValue.js +0 -19
- package/admin/src/pages/SettingsPage/pages/AuditLogs/ListView/DynamicTable/TableRows/index.js +0 -65
- package/admin/src/pages/SettingsPage/pages/AuditLogs/ListView/ModalDialog/ActionItem.js +0 -25
- package/admin/src/pages/SettingsPage/pages/AuditLogs/ListView/ModalDialog/index.js +0 -76
- package/admin/src/pages/SettingsPage/pages/AuditLogs/ListView/hooks/useFormatTimeStamp.js +0 -24
- package/admin/src/pages/SettingsPage/pages/AuditLogs/ListView/index.js +0 -84
- package/admin/src/pages/SettingsPage/pages/AuditLogs/ListView/utils/tableHeaders.js +0 -37
- package/admin/src/pages/SettingsPage/pages/AuditLogs/ProtectedListPage/index.js +0 -12
- package/build/1551f4f60c37af51121f.woff2 +0 -0
- package/build/1920.74a262e7.chunk.js +0 -245
- package/build/1e59d2330b4c6deb84b3.ttf +0 -0
- package/build/20fd1704ea223900efa9.woff2 +0 -0
- package/build/2285773e6b4b172f07d9.woff +0 -0
- package/build/23f19bb08961f37aaf69.eot +0 -0
- package/build/2438.61291207.chunk.js +0 -2183
- package/build/2517.9b4940f3.chunk.js +0 -117
- package/build/2f517e09eb2ca6650ff5.svg +0 -3717
- package/build/4306.f03c2b46.chunk.js +0 -98
- package/build/4318.7931eee7.chunk.js +0 -30
- package/build/4689f52cc96215721344.svg +0 -801
- package/build/491974d108fe4002b2aa.ttf +0 -0
- package/build/4986.3820d11d.chunk.js +0 -145
- package/build/504.9aeff724.chunk.js +0 -758
- package/build/527940b104eb2ea366c8.ttf +0 -0
- package/build/77206a6bb316fa0aded5.eot +0 -0
- package/build/7a3337626410ca2f4071.woff2 +0 -0
- package/build/7a8b4f130182d19a2d7c.svg +0 -5034
- package/build/805.e991a370.chunk.js +0 -138
- package/build/8b43027f47b20503057d.eot +0 -0
- package/build/9707.a0cc4ad8.chunk.js +0 -70
- package/build/9bbb245e67a133f6e486.eot +0 -0
- package/build/Admin-authenticatedApp.ac85652e.chunk.js +0 -80
- package/build/Admin_pluginsPage.3c872de7.chunk.js +0 -6
- package/build/admin-app.77179e07.chunk.js +0 -112
- package/build/admin-audit-logs.334ee871.chunk.js +0 -1
- package/build/admin-edit-roles-page.23f15909.chunk.js +0 -1
- package/build/admin-edit-users.283b49ed.chunk.js +0 -10
- package/build/api-tokens-create-page.93dd0689.chunk.js +0 -1
- package/build/api-tokens-edit-page.b0adac81.chunk.js +0 -1
- package/build/bb58e57c48a3e911f15f.woff +0 -0
- package/build/be9ee23c0c6390141475.ttf +0 -0
- package/build/c1e38fd9e0e74ba58f7a.svg +0 -2671
- package/build/content-manager.01e04e11.chunk.js +0 -1200
- package/build/content-type-builder-list-view.4412efc3.chunk.js +0 -201
- package/build/content-type-builder-translation-de-json.0d7696b9.chunk.js +0 -1
- package/build/content-type-builder-translation-dk-json.4729f055.chunk.js +0 -1
- package/build/content-type-builder-translation-en-json.f985c9c4.chunk.js +0 -1
- package/build/content-type-builder-translation-es-json.333cf47f.chunk.js +0 -1
- package/build/content-type-builder-translation-ko-json.51201b12.chunk.js +0 -1
- package/build/content-type-builder-translation-pl-json.4a42349b.chunk.js +0 -1
- package/build/content-type-builder-translation-pt-BR-json.6fe3b8d1.chunk.js +0 -1
- package/build/content-type-builder-translation-sv-json.6deff030.chunk.js +0 -1
- package/build/content-type-builder-translation-tr-json.2e52bc60.chunk.js +0 -1
- package/build/content-type-builder-translation-zh-json.3b0afd31.chunk.js +0 -1
- package/build/content-type-builder.aa4ec633.chunk.js +0 -145
- package/build/d878b0a6a1144760244f.woff2 +0 -0
- package/build/eeccf4f66002c6f2ba24.woff +0 -0
- package/build/email-settings-page.d44a57cb.chunk.js +0 -15
- package/build/email-translation-tr-json.87f2feb3.chunk.js +0 -1
- package/build/en-json.57917cb1.chunk.js +0 -1
- package/build/f691f37e57f04c152e23.woff +0 -0
- package/build/fontawesome-css-all.15068c6e.chunk.js +0 -4618
- package/build/fontawesome-css.418f40da.chunk.js +0 -6
- package/build/fontawesome-js.252cc5f3.chunk.js +0 -7
- package/build/main.f31112a5.js +0 -2034
- package/build/runtime~main.81f05721.js +0 -2
- package/build/sk-json.7ba4b330.chunk.js +0 -1
- package/build/sso-settings-page.9f091262.chunk.js +0 -1
- package/build/tr-json.9c44ea0c.chunk.js +0 -1
- package/build/upload-settings.450cab1a.chunk.js +0 -18
- package/build/upload-translation-en-json.86da7b0a.chunk.js +0 -1
- package/build/upload-translation-sk-json.b03d4904.chunk.js +0 -1
- package/build/upload.a73936d9.chunk.js +0 -64
- package/build/users-advanced-settings-page.dc23bc56.chunk.js +0 -13
- package/build/users-email-settings-page.6541d372.chunk.js +0 -28
- package/build/users-permissions-translation-tr-json.cdc49a3c.chunk.js +0 -1
- package/build/users-providers-settings-page.e11a2f64.chunk.js +0 -33
- package/build/users-roles-settings-page.445e5e16.chunk.js +0 -30
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
fetchUserRoles,
|
|
21
21
|
} from './utils/api';
|
|
22
22
|
import checkLatestStrapiVersion from './utils/checkLatestStrapiVersion';
|
|
23
|
-
import { getFullName } from '../../utils';
|
|
23
|
+
import { getFullName, hashAdminUserEmail } from '../../utils';
|
|
24
24
|
|
|
25
25
|
const strapiVersion = packageJSON.version;
|
|
26
26
|
|
|
@@ -31,6 +31,7 @@ const AuthenticatedApp = () => {
|
|
|
31
31
|
const userInfo = auth.getUserInfo();
|
|
32
32
|
const userName = get(userInfo, 'username') || getFullName(userInfo.firstname, userInfo.lastname);
|
|
33
33
|
const [userDisplayName, setUserDisplayName] = useState(userName);
|
|
34
|
+
const [userId, setUserId] = useState(null);
|
|
34
35
|
const { showReleaseNotification } = useConfigurations();
|
|
35
36
|
const [
|
|
36
37
|
{ data: appInfos, status },
|
|
@@ -71,6 +72,15 @@ const AuthenticatedApp = () => {
|
|
|
71
72
|
}
|
|
72
73
|
}, [userRoles, appInfos]);
|
|
73
74
|
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
const getUserId = async () => {
|
|
77
|
+
const userId = await hashAdminUserEmail(userInfo);
|
|
78
|
+
setUserId(userId);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
getUserId();
|
|
82
|
+
}, [userInfo]);
|
|
83
|
+
|
|
74
84
|
// We don't need to wait for the release query to be fetched before rendering the plugins
|
|
75
85
|
// however, we need the appInfos and the permissions
|
|
76
86
|
const shouldShowNotDependentQueriesLoader =
|
|
@@ -81,12 +91,13 @@ const AuthenticatedApp = () => {
|
|
|
81
91
|
const appInfosValue = useMemo(() => {
|
|
82
92
|
return {
|
|
83
93
|
...appInfos,
|
|
94
|
+
userId,
|
|
84
95
|
latestStrapiReleaseTag: tag_name,
|
|
85
96
|
setUserDisplayName,
|
|
86
97
|
shouldUpdateStrapi,
|
|
87
98
|
userDisplayName,
|
|
88
99
|
};
|
|
89
|
-
}, [appInfos, tag_name, shouldUpdateStrapi, userDisplayName]);
|
|
100
|
+
}, [appInfos, tag_name, shouldUpdateStrapi, userDisplayName, userId]);
|
|
90
101
|
|
|
91
102
|
if (shouldShowLoader) {
|
|
92
103
|
return <LoadingIndicatorPage />;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { createGlobalStyle } from 'styled-components';
|
|
2
2
|
|
|
3
3
|
const loadCss = async () => {
|
|
4
|
-
await import(/* webpackChunkName: "fontawesome-css" */ 'font-awesome/css/font-awesome.min.css');
|
|
5
|
-
await import(
|
|
6
|
-
/* webpackChunkName: "fontawesome-css-all" */ '@fortawesome/fontawesome-free/css/all.css'
|
|
7
|
-
);
|
|
8
|
-
await import(/* webpackChunkName: "fontawesome-js" */ '@fortawesome/fontawesome-free/js/all.min');
|
|
9
4
|
await import(/* webpackChunkName: "cropper-css" */ 'cropperjs/dist/cropper.css');
|
|
10
5
|
};
|
|
11
6
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
|
|
5
|
+
import { Flex } from '@strapi/design-system';
|
|
6
|
+
|
|
7
|
+
const WIDTH_S = 5;
|
|
8
|
+
const WIDTH_M = 8;
|
|
9
|
+
|
|
10
|
+
const Wrapper = styled(Flex)`
|
|
11
|
+
border-radius: ${({ showBackground }) => (showBackground ? `50%` : 0)};
|
|
12
|
+
color: ${({ theme }) => theme.colors.neutral600};
|
|
13
|
+
height: ${({ theme, size }) => theme.spaces[size === 'S' ? WIDTH_S : WIDTH_M]};
|
|
14
|
+
width: ${({ theme, size }) => theme.spaces[size === 'S' ? WIDTH_S : WIDTH_M]};
|
|
15
|
+
|
|
16
|
+
svg {
|
|
17
|
+
height: ${({ theme, size }) => theme.spaces[size === 'S' ? WIDTH_S - 2 : WIDTH_M - 3]};
|
|
18
|
+
width: ${({ theme, size }) => theme.spaces[size === 'S' ? WIDTH_S - 2 : WIDTH_M - 3]};
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
export function ComponentIcon({ showBackground = true, size = 'M' }) {
|
|
23
|
+
return (
|
|
24
|
+
<Wrapper
|
|
25
|
+
alignItems="center"
|
|
26
|
+
background={showBackground ? 'neutral200' : null}
|
|
27
|
+
justifyContent="center"
|
|
28
|
+
size={size}
|
|
29
|
+
showBackground={showBackground}
|
|
30
|
+
>
|
|
31
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
|
|
32
|
+
<path
|
|
33
|
+
d="M216.3 2c4.8-2.6 10.5-2.6 15.3 0L422.3 106c5.1 2.8 8.3 8.2 8.3 14s-3.2 11.2-8.3 14L231.7 238c-4.8 2.6-10.5 2.6-15.3 0L25.7 134c-5.1-2.8-8.3-8.2-8.3-14s3.2-11.2 8.3-14L216.3 2zM23.7 170l176 96c5.1 2.8 8.3 8.2 8.3 14V496c0 5.6-3 10.9-7.8 13.8s-10.9 3-15.8 .3L8.3 414C3.2 411.2 0 405.9 0 400V184c0-5.6 3-10.9 7.8-13.8s10.9-3 15.8-.3zm400.7 0c5-2.7 11-2.6 15.8 .3s7.8 8.1 7.8 13.8V400c0 5.9-3.2 11.2-8.3 14l-176 96c-5 2.7-11 2.6-15.8-.3s-7.8-8.1-7.8-13.8V280c0-5.9 3.2-11.2 8.3-14l176-96z"
|
|
34
|
+
fill="currentColor"
|
|
35
|
+
/>
|
|
36
|
+
</svg>
|
|
37
|
+
</Wrapper>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
ComponentIcon.defaultProps = {
|
|
42
|
+
showBackground: true,
|
|
43
|
+
size: 'M',
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
ComponentIcon.propTypes = {
|
|
47
|
+
showBackground: PropTypes.bool,
|
|
48
|
+
size: PropTypes.string,
|
|
49
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ComponentIcon';
|
|
@@ -57,13 +57,7 @@ const ComponentInitializer = ({ error, isReadOnly, onClick }) => {
|
|
|
57
57
|
</Box>
|
|
58
58
|
{error?.id && (
|
|
59
59
|
<Typography textColor="danger600" variant="pi">
|
|
60
|
-
{formatMessage(
|
|
61
|
-
{
|
|
62
|
-
id: error.id,
|
|
63
|
-
defaultMessage: error.id,
|
|
64
|
-
},
|
|
65
|
-
{ ...error.values }
|
|
66
|
-
)}
|
|
60
|
+
{formatMessage(error, { ...error.values })}
|
|
67
61
|
</Typography>
|
|
68
62
|
)}
|
|
69
63
|
</>
|
|
@@ -2,13 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { pxToRem } from '@strapi/helper-plugin';
|
|
5
|
-
import { Box } from '@strapi/design-system
|
|
6
|
-
import {
|
|
7
|
-
import { Typography } from '@strapi/design-system/Typography';
|
|
8
|
-
import { IconButton } from '@strapi/design-system/IconButton';
|
|
9
|
-
import Trash from '@strapi/icons/Trash';
|
|
10
|
-
import DragHandle from '@strapi/icons/Drag';
|
|
11
|
-
import CarretDown from '@strapi/icons/CarretDown';
|
|
5
|
+
import { Box, Flex, Typography, IconButton } from '@strapi/design-system';
|
|
6
|
+
import { Trash, Drag, CarretDown } from '@strapi/icons';
|
|
12
7
|
|
|
13
8
|
const DragPreviewBox = styled(Box)`
|
|
14
9
|
border: 1px solid ${({ theme }) => theme.colors.neutral200};
|
|
@@ -57,18 +52,22 @@ const DragPreview = ({ displayedValue }) => {
|
|
|
57
52
|
<DropdownIconWrapper background="neutral200">
|
|
58
53
|
<CarretDown />
|
|
59
54
|
</DropdownIconWrapper>
|
|
60
|
-
<
|
|
55
|
+
<Flex gap={2} paddingLeft={6} maxWidth={pxToRem(150)}>
|
|
61
56
|
<Typography textColor="neutral700" ellipsis>
|
|
62
57
|
{displayedValue}
|
|
63
58
|
</Typography>
|
|
64
|
-
</
|
|
59
|
+
</Flex>
|
|
65
60
|
</Flex>
|
|
66
61
|
</ToggleButton>
|
|
67
62
|
<Box paddingLeft={3}>
|
|
68
63
|
<Flex>
|
|
69
|
-
<IconButton
|
|
64
|
+
<IconButton noBorder>
|
|
65
|
+
<Trash />
|
|
66
|
+
</IconButton>
|
|
70
67
|
<Box paddingLeft={2}>
|
|
71
|
-
<IconButton
|
|
68
|
+
<IconButton noBorder>
|
|
69
|
+
<Drag />
|
|
70
|
+
</IconButton>
|
|
72
71
|
</Box>
|
|
73
72
|
</Flex>
|
|
74
73
|
</Box>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { Box, Flex, IconButton, Typography, Status, Icon } from '@strapi/design-system';
|
|
5
|
+
import { Drag, Cross } from '@strapi/icons';
|
|
6
|
+
|
|
7
|
+
import { getTrad } from '../../utils';
|
|
8
|
+
import { PUBLICATION_STATES } from '../RelationInputDataManager/constants';
|
|
9
|
+
import { ChildrenWrapper, StackWrapper } from '../RelationInput/components/RelationItem';
|
|
10
|
+
import { LinkEllipsis, DisconnectButton } from '../RelationInput';
|
|
11
|
+
|
|
12
|
+
export const RelationDragPreview = ({ status, displayedValue, width }) => {
|
|
13
|
+
const { formatMessage } = useIntl();
|
|
14
|
+
|
|
15
|
+
const stateMessage = {
|
|
16
|
+
[PUBLICATION_STATES.DRAFT]: formatMessage({
|
|
17
|
+
id: getTrad('relation.publicationState.draft'),
|
|
18
|
+
defaultMessage: 'Draft',
|
|
19
|
+
}),
|
|
20
|
+
|
|
21
|
+
[PUBLICATION_STATES.PUBLISHED]: formatMessage({
|
|
22
|
+
id: getTrad('relation.publicationState.published'),
|
|
23
|
+
defaultMessage: 'Published',
|
|
24
|
+
}),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const statusColor = status === PUBLICATION_STATES.DRAFT ? 'secondary' : 'success';
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Box style={{ width }}>
|
|
31
|
+
<Flex
|
|
32
|
+
paddingTop={2}
|
|
33
|
+
paddingBottom={2}
|
|
34
|
+
paddingLeft={2}
|
|
35
|
+
paddingRight={4}
|
|
36
|
+
hasRadius
|
|
37
|
+
borderSize={1}
|
|
38
|
+
background="neutral0"
|
|
39
|
+
borderColor="neutral200"
|
|
40
|
+
justifyContent="space-between"
|
|
41
|
+
>
|
|
42
|
+
<StackWrapper spacing={1} horizontal>
|
|
43
|
+
<IconButton noBorder>
|
|
44
|
+
<Drag />
|
|
45
|
+
</IconButton>
|
|
46
|
+
<ChildrenWrapper justifyContent="space-between">
|
|
47
|
+
<LinkEllipsis minWidth={0} paddingTop={1} paddingBottom={1} paddingRight={4}>
|
|
48
|
+
<Typography textColor="primary600" ellipsis>
|
|
49
|
+
{displayedValue}
|
|
50
|
+
</Typography>
|
|
51
|
+
</LinkEllipsis>
|
|
52
|
+
{status && (
|
|
53
|
+
<Status variant={statusColor} showBullet={false} size="S">
|
|
54
|
+
<Typography fontWeight="bold" textColor={`${statusColor}700`}>
|
|
55
|
+
{stateMessage[status]}
|
|
56
|
+
</Typography>
|
|
57
|
+
</Status>
|
|
58
|
+
)}
|
|
59
|
+
</ChildrenWrapper>
|
|
60
|
+
</StackWrapper>
|
|
61
|
+
<Box paddingLeft={4}>
|
|
62
|
+
<DisconnectButton type="button">
|
|
63
|
+
<Icon width="12px" as={Cross} />
|
|
64
|
+
</DisconnectButton>
|
|
65
|
+
</Box>
|
|
66
|
+
</Flex>
|
|
67
|
+
</Box>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
RelationDragPreview.propTypes = {
|
|
72
|
+
status: PropTypes.string.isRequired,
|
|
73
|
+
displayedValue: PropTypes.string.isRequired,
|
|
74
|
+
width: PropTypes.number.isRequired,
|
|
75
|
+
};
|
|
@@ -3,11 +3,10 @@ import { useDragLayer } from 'react-dnd';
|
|
|
3
3
|
import LayoutDndProvider from '../LayoutDndProvider';
|
|
4
4
|
|
|
5
5
|
import ItemTypes from '../../utils/ItemTypes';
|
|
6
|
-
import RepeatableComponentPreview from '../RepeatableComponent/DragPreview';
|
|
7
6
|
import CardPreview from '../../pages/ListSettingsView/components/CardPreview';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
|
|
8
|
+
import ComponentPreview from './ComponentDragPreview';
|
|
9
|
+
import { RelationDragPreview } from './RelationDragPreview';
|
|
11
10
|
|
|
12
11
|
const layerStyles = {
|
|
13
12
|
position: 'fixed',
|
|
@@ -50,15 +49,32 @@ const CustomDragLayer = () => {
|
|
|
50
49
|
return null;
|
|
51
50
|
}
|
|
52
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Because a user may have multiple relations / dynamic zones / repeable fields in the same content type,
|
|
54
|
+
* we append the fieldName for the item type to make them unique, however, we then want to extract that
|
|
55
|
+
* first type to apply the correct preview.
|
|
56
|
+
*/
|
|
57
|
+
const [actualType] = itemType.split('_');
|
|
58
|
+
|
|
53
59
|
return (
|
|
54
60
|
<LayoutDndProvider>
|
|
55
61
|
<div style={layerStyles}>
|
|
56
62
|
<div style={getItemStyles(initialOffset, currentOffset, mouseOffset)} className="col-md-2">
|
|
57
|
-
{[ItemTypes.
|
|
63
|
+
{[ItemTypes.EDIT_FIELD, ItemTypes.FIELD].includes(itemType) && (
|
|
58
64
|
<CardPreview labelField={item.labelField} />
|
|
59
65
|
)}
|
|
60
|
-
{
|
|
61
|
-
<
|
|
66
|
+
{actualType === ItemTypes.COMPONENT && (
|
|
67
|
+
<ComponentPreview displayedValue={item.displayedValue} />
|
|
68
|
+
)}
|
|
69
|
+
{actualType === ItemTypes.DYNAMIC_ZONE && (
|
|
70
|
+
<ComponentPreview displayedValue={item.displayedValue} />
|
|
71
|
+
)}
|
|
72
|
+
{actualType === ItemTypes.RELATION && (
|
|
73
|
+
<RelationDragPreview
|
|
74
|
+
displayedValue={item.displayedValue}
|
|
75
|
+
status={item.status}
|
|
76
|
+
width={item.width}
|
|
77
|
+
/>
|
|
62
78
|
)}
|
|
63
79
|
</div>
|
|
64
80
|
</div>
|
|
@@ -7,23 +7,13 @@
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import styled from 'styled-components';
|
|
10
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
11
10
|
|
|
12
11
|
import { Box } from '@strapi/design-system/Box';
|
|
13
12
|
import { Typography } from '@strapi/design-system/Typography';
|
|
14
13
|
import { Stack } from '@strapi/design-system/Stack';
|
|
15
14
|
import { pxToRem } from '@strapi/helper-plugin';
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
width: ${pxToRem(32)} !important;
|
|
19
|
-
height: ${pxToRem(32)} !important;
|
|
20
|
-
padding: ${pxToRem(9)};
|
|
21
|
-
border-radius: ${pxToRem(64)};
|
|
22
|
-
background: ${({ theme }) => theme.colors.neutral150};
|
|
23
|
-
path {
|
|
24
|
-
fill: ${({ theme }) => theme.colors.neutral500};
|
|
25
|
-
}
|
|
26
|
-
`;
|
|
16
|
+
import { ComponentIcon } from '../../ComponentIcon';
|
|
27
17
|
|
|
28
18
|
const ComponentBox = styled(Box)`
|
|
29
19
|
flex-shrink: 0;
|
|
@@ -35,46 +25,42 @@ const ComponentBox = styled(Box)`
|
|
|
35
25
|
justify-content: center;
|
|
36
26
|
align-items: center;
|
|
37
27
|
|
|
38
|
-
|
|
28
|
+
&:focus,
|
|
39
29
|
&:hover {
|
|
40
30
|
border: 1px solid ${({ theme }) => theme.colors.primary200};
|
|
41
31
|
background: ${({ theme }) => theme.colors.primary100};
|
|
42
32
|
|
|
43
|
-
${
|
|
44
|
-
|
|
45
|
-
path {
|
|
46
|
-
fill: ${({ theme }) => theme.colors.primary600};
|
|
47
|
-
}
|
|
33
|
+
${Typography} {
|
|
34
|
+
color: ${({ theme }) => theme.colors.primary600};
|
|
48
35
|
}
|
|
49
36
|
|
|
50
|
-
|
|
37
|
+
/* > Stack > ComponentIcon */
|
|
38
|
+
> div > div:first-child {
|
|
39
|
+
background: ${({ theme }) => theme.colors.primary200};
|
|
51
40
|
color: ${({ theme }) => theme.colors.primary600};
|
|
52
41
|
}
|
|
53
42
|
}
|
|
54
43
|
`;
|
|
55
44
|
|
|
56
|
-
export default function ComponentCard({ children,
|
|
45
|
+
export default function ComponentCard({ children, onClick }) {
|
|
57
46
|
return (
|
|
58
|
-
<button type="button" onClick={onClick}>
|
|
59
|
-
<
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
</button>
|
|
47
|
+
<ComponentBox as="button" type="button" onClick={onClick} hasRadius>
|
|
48
|
+
<Stack spacing={1} alignItems="center" justifyContent="center">
|
|
49
|
+
<ComponentIcon />
|
|
50
|
+
|
|
51
|
+
<Typography variant="pi" fontWeight="bold" textColor="neutral600">
|
|
52
|
+
{children}
|
|
53
|
+
</Typography>
|
|
54
|
+
</Stack>
|
|
55
|
+
</ComponentBox>
|
|
68
56
|
);
|
|
69
57
|
}
|
|
70
58
|
|
|
71
59
|
ComponentCard.defaultProps = {
|
|
72
|
-
icon: 'dice-d6',
|
|
73
60
|
onClick() {},
|
|
74
61
|
};
|
|
75
62
|
|
|
76
63
|
ComponentCard.propTypes = {
|
|
77
64
|
children: PropTypes.node.isRequired,
|
|
78
|
-
icon: PropTypes.string,
|
|
79
65
|
onClick: PropTypes.func,
|
|
80
66
|
};
|
|
@@ -30,8 +30,8 @@ const ComponentCategory = ({ category, components, variant, isOpen, onAddCompone
|
|
|
30
30
|
<AccordionContent>
|
|
31
31
|
<Box paddingTop={4} paddingBottom={4} paddingLeft={3} paddingRight={3}>
|
|
32
32
|
<Grid>
|
|
33
|
-
{components.map(({ componentUid, info: { displayName
|
|
34
|
-
<ComponentCard key={componentUid}
|
|
33
|
+
{components.map(({ componentUid, info: { displayName } }) => (
|
|
34
|
+
<ComponentCard key={componentUid} onClick={onAddComponent(componentUid)}>
|
|
35
35
|
{formatMessage({ id: displayName, defaultMessage: displayName })}
|
|
36
36
|
</ComponentCard>
|
|
37
37
|
))}
|
|
@@ -1,27 +1,38 @@
|
|
|
1
|
-
import React, { useMemo, useState } from 'react';
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { useIntl } from 'react-intl';
|
|
5
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
6
5
|
import get from 'lodash/get';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
import { getEmptyImage } from 'react-dnd-html5-backend';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
Accordion,
|
|
10
|
+
AccordionToggle,
|
|
11
|
+
AccordionContent,
|
|
12
|
+
IconButton,
|
|
13
|
+
Box,
|
|
14
|
+
Flex,
|
|
15
|
+
Stack,
|
|
16
|
+
} from '@strapi/design-system';
|
|
14
17
|
import { useCMEditViewDataManager } from '@strapi/helper-plugin';
|
|
18
|
+
import { Trash, Drag } from '@strapi/icons';
|
|
15
19
|
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import ArrowUp from '@strapi/icons/ArrowUp';
|
|
19
|
-
|
|
20
|
-
import { useContentTypeLayout } from '../../../hooks';
|
|
21
|
-
import { getTrad } from '../../../utils';
|
|
20
|
+
import { useContentTypeLayout, useDragAndDrop } from '../../../hooks';
|
|
21
|
+
import { composeRefs, getTrad, ItemTypes } from '../../../utils';
|
|
22
22
|
|
|
23
23
|
import FieldComponent from '../../FieldComponent';
|
|
24
24
|
|
|
25
|
+
const ActionsStack = styled(Stack)`
|
|
26
|
+
/*
|
|
27
|
+
we need to remove the background from the button but we can't
|
|
28
|
+
wrap the element in styled because it breaks the forwardedAs which
|
|
29
|
+
we need for drag handler to work on firefox
|
|
30
|
+
*/
|
|
31
|
+
div[role='button'] {
|
|
32
|
+
background: transparent;
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
|
|
25
36
|
const IconButtonCustom = styled(IconButton)`
|
|
26
37
|
background-color: transparent;
|
|
27
38
|
|
|
@@ -46,17 +57,31 @@ const Rectangle = styled(Box)`
|
|
|
46
57
|
height: ${({ theme }) => theme.spaces[4]};
|
|
47
58
|
`;
|
|
48
59
|
|
|
60
|
+
const Preview = styled.span`
|
|
61
|
+
display: block;
|
|
62
|
+
background-color: ${({ theme }) => theme.colors.primary100};
|
|
63
|
+
outline: 1px dashed ${({ theme }) => theme.colors.primary500};
|
|
64
|
+
outline-offset: -1px;
|
|
65
|
+
padding: ${({ theme }) => theme.spaces[6]};
|
|
66
|
+
`;
|
|
67
|
+
|
|
68
|
+
const ComponentContainer = styled(Box)`
|
|
69
|
+
list-style: none;
|
|
70
|
+
padding: 0;
|
|
71
|
+
margin: 0;
|
|
72
|
+
`;
|
|
73
|
+
|
|
49
74
|
const DynamicZoneComponent = ({
|
|
50
75
|
componentUid,
|
|
51
76
|
formErrors,
|
|
52
77
|
index,
|
|
53
78
|
isFieldAllowed,
|
|
54
|
-
onMoveComponentDownClick,
|
|
55
|
-
onMoveComponentUpClick,
|
|
56
79
|
name,
|
|
57
80
|
onRemoveComponentClick,
|
|
58
|
-
|
|
59
|
-
|
|
81
|
+
onMoveComponent,
|
|
82
|
+
onGrabItem,
|
|
83
|
+
onDropItem,
|
|
84
|
+
onCancel,
|
|
60
85
|
}) => {
|
|
61
86
|
const [isOpen, setIsOpen] = useState(true);
|
|
62
87
|
const { formatMessage } = useIntl();
|
|
@@ -103,71 +128,89 @@ const DynamicZoneComponent = ({
|
|
|
103
128
|
setIsOpen((s) => !s);
|
|
104
129
|
};
|
|
105
130
|
|
|
131
|
+
const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] =
|
|
132
|
+
useDragAndDrop(isFieldAllowed, {
|
|
133
|
+
type: `${ItemTypes.DYNAMIC_ZONE}_${name}`,
|
|
134
|
+
index,
|
|
135
|
+
item: {
|
|
136
|
+
displayedValue: `${friendlyName}${mainValue}`,
|
|
137
|
+
icon,
|
|
138
|
+
},
|
|
139
|
+
onMoveItem: onMoveComponent,
|
|
140
|
+
onGrabItem,
|
|
141
|
+
onDropItem,
|
|
142
|
+
onCancel,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
dragPreviewRef(getEmptyImage(), { captureDraggingState: false });
|
|
147
|
+
}, [dragPreviewRef, index]);
|
|
148
|
+
|
|
149
|
+
const composedBoxRefs = composeRefs(boxRef, dropRef);
|
|
150
|
+
|
|
151
|
+
const accordionActions = !isFieldAllowed ? null : (
|
|
152
|
+
<ActionsStack horizontal spacing={0} expanded={isOpen}>
|
|
153
|
+
<IconButtonCustom
|
|
154
|
+
noBorder
|
|
155
|
+
label={formatMessage(
|
|
156
|
+
{
|
|
157
|
+
id: getTrad('components.DynamicZone.delete-label'),
|
|
158
|
+
defaultMessage: 'Delete {name}',
|
|
159
|
+
},
|
|
160
|
+
{ name: friendlyName }
|
|
161
|
+
)}
|
|
162
|
+
onClick={onRemoveComponentClick}
|
|
163
|
+
>
|
|
164
|
+
<Trash />
|
|
165
|
+
</IconButtonCustom>
|
|
166
|
+
<IconButton
|
|
167
|
+
forwardedAs="div"
|
|
168
|
+
role="button"
|
|
169
|
+
noBorder
|
|
170
|
+
tabIndex={0}
|
|
171
|
+
onClick={(e) => e.stopPropagation()}
|
|
172
|
+
data-handler-id={handlerId}
|
|
173
|
+
ref={dragRef}
|
|
174
|
+
label={formatMessage({
|
|
175
|
+
id: getTrad('components.DragHandle-label'),
|
|
176
|
+
defaultMessage: 'Drag',
|
|
177
|
+
})}
|
|
178
|
+
onKeyDown={handleKeyDown}
|
|
179
|
+
>
|
|
180
|
+
<Drag />
|
|
181
|
+
</IconButton>
|
|
182
|
+
</ActionsStack>
|
|
183
|
+
);
|
|
184
|
+
|
|
106
185
|
return (
|
|
107
|
-
<
|
|
186
|
+
<ComponentContainer as="li">
|
|
108
187
|
<Flex justifyContent="center">
|
|
109
188
|
<Rectangle background="neutral200" />
|
|
110
189
|
</Flex>
|
|
111
|
-
<StyledBox hasRadius>
|
|
112
|
-
|
|
113
|
-
<
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
defaultMessage: 'Move component up',
|
|
134
|
-
})}
|
|
135
|
-
onClick={onMoveComponentUpClick}
|
|
136
|
-
icon={<ArrowUp />}
|
|
137
|
-
/>
|
|
138
|
-
)}
|
|
139
|
-
{isFieldAllowed && (
|
|
140
|
-
<IconButtonCustom
|
|
141
|
-
noBorder
|
|
142
|
-
label={formatMessage(
|
|
143
|
-
{
|
|
144
|
-
id: getTrad('components.DynamicZone.delete-label'),
|
|
145
|
-
defaultMessage: 'Delete {name}',
|
|
146
|
-
},
|
|
147
|
-
{ name: friendlyName }
|
|
148
|
-
)}
|
|
149
|
-
onClick={onRemoveComponentClick}
|
|
150
|
-
icon={<Trash />}
|
|
151
|
-
/>
|
|
152
|
-
)}
|
|
153
|
-
</Stack>
|
|
154
|
-
}
|
|
155
|
-
title={`${friendlyName}${mainValue}`}
|
|
156
|
-
togglePosition="left"
|
|
157
|
-
/>
|
|
158
|
-
<AccordionContent>
|
|
159
|
-
<AccordionContentRadius background="neutral0">
|
|
160
|
-
<FieldComponent
|
|
161
|
-
componentUid={componentUid}
|
|
162
|
-
icon={icon}
|
|
163
|
-
name={`${name}.${index}`}
|
|
164
|
-
isFromDynamicZone
|
|
165
|
-
/>
|
|
166
|
-
</AccordionContentRadius>
|
|
167
|
-
</AccordionContent>
|
|
168
|
-
</Accordion>
|
|
190
|
+
<StyledBox ref={composedBoxRefs} hasRadius>
|
|
191
|
+
{isDragging ? (
|
|
192
|
+
<Preview padding={6} background="primary100" />
|
|
193
|
+
) : (
|
|
194
|
+
<Accordion expanded={isOpen} onToggle={handleToggle} size="S" error={errorMessage}>
|
|
195
|
+
<AccordionToggle
|
|
196
|
+
action={accordionActions}
|
|
197
|
+
title={`${friendlyName}${mainValue}`}
|
|
198
|
+
togglePosition="left"
|
|
199
|
+
/>
|
|
200
|
+
<AccordionContent>
|
|
201
|
+
<AccordionContentRadius background="neutral0">
|
|
202
|
+
<FieldComponent
|
|
203
|
+
componentUid={componentUid}
|
|
204
|
+
icon={icon}
|
|
205
|
+
name={`${name}.${index}`}
|
|
206
|
+
isFromDynamicZone
|
|
207
|
+
/>
|
|
208
|
+
</AccordionContentRadius>
|
|
209
|
+
</AccordionContent>
|
|
210
|
+
</Accordion>
|
|
211
|
+
)}
|
|
169
212
|
</StyledBox>
|
|
170
|
-
</
|
|
213
|
+
</ComponentContainer>
|
|
171
214
|
);
|
|
172
215
|
};
|
|
173
216
|
|
|
@@ -175,8 +218,9 @@ DynamicZoneComponent.defaultProps = {
|
|
|
175
218
|
formErrors: {},
|
|
176
219
|
index: 0,
|
|
177
220
|
isFieldAllowed: true,
|
|
178
|
-
|
|
179
|
-
|
|
221
|
+
onGrabItem: undefined,
|
|
222
|
+
onDropItem: undefined,
|
|
223
|
+
onCancel: undefined,
|
|
180
224
|
};
|
|
181
225
|
|
|
182
226
|
DynamicZoneComponent.propTypes = {
|
|
@@ -185,11 +229,11 @@ DynamicZoneComponent.propTypes = {
|
|
|
185
229
|
index: PropTypes.number,
|
|
186
230
|
isFieldAllowed: PropTypes.bool,
|
|
187
231
|
name: PropTypes.string.isRequired,
|
|
188
|
-
|
|
189
|
-
|
|
232
|
+
onGrabItem: PropTypes.func,
|
|
233
|
+
onDropItem: PropTypes.func,
|
|
234
|
+
onCancel: PropTypes.func,
|
|
235
|
+
onMoveComponent: PropTypes.func.isRequired,
|
|
190
236
|
onRemoveComponentClick: PropTypes.func.isRequired,
|
|
191
|
-
showDownIcon: PropTypes.bool,
|
|
192
|
-
showUpIcon: PropTypes.bool,
|
|
193
237
|
};
|
|
194
238
|
|
|
195
239
|
export default DynamicZoneComponent;
|