@akemona-org/strapi-plugin-content-manager 3.7.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.
- package/LICENSE +22 -0
- package/README.md +27 -0
- package/admin/src/InjectedComponents/ContentTypeBuilder/ConfigureViewButton/index.js +78 -0
- package/admin/src/assets/images/background_input.svg +1 -0
- package/admin/src/assets/images/icon-cross-blue.svg +1 -0
- package/admin/src/assets/images/icon_remove.svg +19 -0
- package/admin/src/assets/images/logo.svg +1 -0
- package/admin/src/components/AddDropdown/components.js +113 -0
- package/admin/src/components/AddDropdown/index.js +76 -0
- package/admin/src/components/Block/components.js +28 -0
- package/admin/src/components/Block/index.js +45 -0
- package/admin/src/components/ComponentInitializer/P.js +9 -0
- package/admin/src/components/ComponentInitializer/index.js +43 -0
- package/admin/src/components/Container/index.js +7 -0
- package/admin/src/components/CustomInputCheckbox/components.js +77 -0
- package/admin/src/components/CustomInputCheckbox/index.js +53 -0
- package/admin/src/components/CustomTable/ActionCollapse/Delete.js +14 -0
- package/admin/src/components/CustomTable/ActionCollapse/DeleteAll.js +18 -0
- package/admin/src/components/CustomTable/ActionCollapse/Wrapper.js +20 -0
- package/admin/src/components/CustomTable/ActionCollapse/index.js +38 -0
- package/admin/src/components/CustomTable/Headers/Header.js +59 -0
- package/admin/src/components/CustomTable/Headers/Thead.js +35 -0
- package/admin/src/components/CustomTable/Headers/index.js +46 -0
- package/admin/src/components/CustomTable/Row/ActionContainer.js +19 -0
- package/admin/src/components/CustomTable/Row/Cell.js +55 -0
- package/admin/src/components/CustomTable/Row/index.js +112 -0
- package/admin/src/components/CustomTable/index.js +162 -0
- package/admin/src/components/CustomTable/styledComponents.js +85 -0
- package/admin/src/components/DragLayer/index.js +102 -0
- package/admin/src/components/DraggedField/Close/index.js +10 -0
- package/admin/src/components/DraggedField/GrabWrapper.js +38 -0
- package/admin/src/components/DraggedField/Link.js +17 -0
- package/admin/src/components/DraggedField/NameWrapper.js +29 -0
- package/admin/src/components/DraggedField/RemoveWrapper.js +32 -0
- package/admin/src/components/DraggedField/SubWrapper.js +36 -0
- package/admin/src/components/DraggedField/Wrapper.js +134 -0
- package/admin/src/components/DraggedField/index.js +196 -0
- package/admin/src/components/DraggedField/utils/getColor.js +12 -0
- package/admin/src/components/DraggedField/utils/getHeight.js +3 -0
- package/admin/src/components/DraggedFieldWithPreview/Carret.js +24 -0
- package/admin/src/components/DraggedFieldWithPreview/DynamicComponent.js +70 -0
- package/admin/src/components/DraggedFieldWithPreview/DynamicZoneWrapper.js +10 -0
- package/admin/src/components/DraggedFieldWithPreview/Tooltip.js +19 -0
- package/admin/src/components/DraggedFieldWithPreview/Wrapper.js +24 -0
- package/admin/src/components/DraggedFieldWithPreview/index.js +194 -0
- package/admin/src/components/DynamicComponentCard/Wrapper.js +63 -0
- package/admin/src/components/DynamicComponentCard/index.js +49 -0
- package/admin/src/components/DynamicZone/BaselineAlignement.js +11 -0
- package/admin/src/components/DynamicZone/Button.js +31 -0
- package/admin/src/components/DynamicZone/Component/RoundCTA.js +45 -0
- package/admin/src/components/DynamicZone/Component/index.js +79 -0
- package/admin/src/components/DynamicZone/ComponentWrapper.js +44 -0
- package/admin/src/components/DynamicZone/DynamicZoneWrapper.js +12 -0
- package/admin/src/components/DynamicZone/Label.js +42 -0
- package/admin/src/components/DynamicZone/Picker/Category/Banner/Wrapper.js +78 -0
- package/admin/src/components/DynamicZone/Picker/Category/Banner/index.js +33 -0
- package/admin/src/components/DynamicZone/Picker/Category/index.js +53 -0
- package/admin/src/components/DynamicZone/Picker/Wrapper.js +32 -0
- package/admin/src/components/DynamicZone/Picker/index.js +88 -0
- package/admin/src/components/DynamicZone/Wrapper.js +34 -0
- package/admin/src/components/DynamicZone/index.js +238 -0
- package/admin/src/components/DynamicZone/utils/connect.js +12 -0
- package/admin/src/components/DynamicZone/utils/select.js +49 -0
- package/admin/src/components/FieldComponent/ComponentIcon.js +44 -0
- package/admin/src/components/FieldComponent/EmptyComponent.js +19 -0
- package/admin/src/components/FieldComponent/Label.js +10 -0
- package/admin/src/components/FieldComponent/ResetComponent.js +41 -0
- package/admin/src/components/FieldComponent/Wrapper.js +18 -0
- package/admin/src/components/FieldComponent/index.js +171 -0
- package/admin/src/components/FieldComponent/utils/connect.js +12 -0
- package/admin/src/components/FieldComponent/utils/select.js +123 -0
- package/admin/src/components/FieldsReorder/Item.js +249 -0
- package/admin/src/components/FieldsReorder/components.js +8 -0
- package/admin/src/components/FieldsReorder/index.js +102 -0
- package/admin/src/components/FilterOptionsCTA/index.js +14 -0
- package/admin/src/components/FilterPicker/components.js +56 -0
- package/admin/src/components/FilterPicker/index.js +258 -0
- package/admin/src/components/FilterPicker/init.js +25 -0
- package/admin/src/components/FilterPicker/reducer.js +58 -0
- package/admin/src/components/FilterPickerOption/Input.js +58 -0
- package/admin/src/components/FilterPickerOption/Option.js +18 -0
- package/admin/src/components/FilterPickerOption/components.js +60 -0
- package/admin/src/components/FilterPickerOption/index.js +101 -0
- package/admin/src/components/FormTitle/index.js +26 -0
- package/admin/src/components/FormWrapper/index.js +20 -0
- package/admin/src/components/InputJSON/components.js +30 -0
- package/admin/src/components/InputJSON/index.js +184 -0
- package/admin/src/components/InputJSON/jsonlint.js +424 -0
- package/admin/src/components/InputJSONWithErrors/Wrapper.js +32 -0
- package/admin/src/components/InputJSONWithErrors/index.js +168 -0
- package/admin/src/components/InputUID/InputUID.js +26 -0
- package/admin/src/components/InputUID/Options/Option.js +22 -0
- package/admin/src/components/InputUID/Options/OptionsTitle.js +12 -0
- package/admin/src/components/InputUID/Options/RightOptionLabel.js +10 -0
- package/admin/src/components/InputUID/Options/index.js +34 -0
- package/admin/src/components/InputUID/Options/wrapper.js +13 -0
- package/admin/src/components/InputUID/RegenerateButton.js +18 -0
- package/admin/src/components/InputUID/RightContent.js +14 -0
- package/admin/src/components/InputUID/RightContentLabel.js +10 -0
- package/admin/src/components/InputUID/RightLabel.js +42 -0
- package/admin/src/components/InputUID/SubLabel.js +9 -0
- package/admin/src/components/InputUID/Wrapper.js +8 -0
- package/admin/src/components/InputUID/index.js +325 -0
- package/admin/src/components/InputUID/regex.js +3 -0
- package/admin/src/components/Inputs/index.js +283 -0
- package/admin/src/components/Inputs/utils/VALIDATIONS_TO_OMIT.js +12 -0
- package/admin/src/components/Inputs/utils/connect.js +12 -0
- package/admin/src/components/Inputs/utils/generateOptions.js +19 -0
- package/admin/src/components/Inputs/utils/getInputType.js +44 -0
- package/admin/src/components/Inputs/utils/getStep.js +15 -0
- package/admin/src/components/Inputs/utils/index.js +6 -0
- package/admin/src/components/Inputs/utils/select.js +38 -0
- package/admin/src/components/LayoutTitle/index.js +19 -0
- package/admin/src/components/MediaPreviewList/StyledMediaPreviewList.js +171 -0
- package/admin/src/components/MediaPreviewList/index.js +110 -0
- package/admin/src/components/NonRepeatableComponent/index.js +73 -0
- package/admin/src/components/NonRepeatableWrapper/index.js +73 -0
- package/admin/src/components/PlusButton/index.js +52 -0
- package/admin/src/components/PopupForm/index.js +93 -0
- package/admin/src/components/PreviewCarret/components.js +27 -0
- package/admin/src/components/PreviewCarret/index.js +22 -0
- package/admin/src/components/PreviewWysiwyg/Wrapper.js +133 -0
- package/admin/src/components/PreviewWysiwyg/index.js +34 -0
- package/admin/src/components/PreviewWysiwyg/utils/mdRenderer.js +72 -0
- package/admin/src/components/PreviewWysiwyg/utils/satinizeHtml.js +16 -0
- package/admin/src/components/RelationPreviewList/CountWrapper.js +7 -0
- package/admin/src/components/RelationPreviewList/RelationPreviewTooltip.js +117 -0
- package/admin/src/components/RelationPreviewList/index.js +111 -0
- package/admin/src/components/RepeatableComponent/AddFieldButton.js +64 -0
- package/admin/src/components/RepeatableComponent/Banner.js +112 -0
- package/admin/src/components/RepeatableComponent/BannerWrapper.js +194 -0
- package/admin/src/components/RepeatableComponent/CarretTop.js +14 -0
- package/admin/src/components/RepeatableComponent/DraggedItem/index.js +245 -0
- package/admin/src/components/RepeatableComponent/DraggedItem/utils/connect.js +11 -0
- package/admin/src/components/RepeatableComponent/DraggedItem/utils/index.js +2 -0
- package/admin/src/components/RepeatableComponent/DraggedItem/utils/select.js +30 -0
- package/admin/src/components/RepeatableComponent/EmptyComponent.js +27 -0
- package/admin/src/components/RepeatableComponent/FormWrapper.js +27 -0
- package/admin/src/components/RepeatableComponent/index.js +187 -0
- package/admin/src/components/RepeatableComponent/reducer.js +73 -0
- package/admin/src/components/RepeatableComponent/utils/connect.js +11 -0
- package/admin/src/components/RepeatableComponent/utils/select.js +12 -0
- package/admin/src/components/Search/index.js +88 -0
- package/admin/src/components/SectionTitle/Title.js +11 -0
- package/admin/src/components/SectionTitle/index.js +29 -0
- package/admin/src/components/SelectMany/ListItem.js +107 -0
- package/admin/src/components/SelectMany/Relation.js +106 -0
- package/admin/src/components/SelectMany/components.js +153 -0
- package/admin/src/components/SelectMany/index.js +159 -0
- package/admin/src/components/SelectOne/SingleValue.js +58 -0
- package/admin/src/components/SelectOne/index.js +71 -0
- package/admin/src/components/SelectWrapper/ClearIndicator.js +15 -0
- package/admin/src/components/SelectWrapper/IndicatorSeparator.js +3 -0
- package/admin/src/components/SelectWrapper/Option.js +76 -0
- package/admin/src/components/SelectWrapper/components.js +14 -0
- package/admin/src/components/SelectWrapper/index.js +393 -0
- package/admin/src/components/SelectWrapper/utils/connect.js +12 -0
- package/admin/src/components/SelectWrapper/utils/index.js +3 -0
- package/admin/src/components/SelectWrapper/utils/select.js +45 -0
- package/admin/src/components/SelectWrapper/utils/styles.js +105 -0
- package/admin/src/components/Separator/index.js +9 -0
- package/admin/src/components/SettingFormWrapper/index.js +9 -0
- package/admin/src/components/SettingsViewWrapper/index.js +283 -0
- package/admin/src/components/SortWrapper/index.js +9 -0
- package/admin/src/components/SortableList/Item.js +126 -0
- package/admin/src/components/SortableList/index.js +60 -0
- package/admin/src/components/State/Wrapper.js +30 -0
- package/admin/src/components/State/index.js +26 -0
- package/admin/src/components/Truncate/index.js +5 -0
- package/admin/src/components/Truncated/index.js +10 -0
- package/admin/src/components/Wysiwyg/EditorWrapper.js +122 -0
- package/admin/src/components/Wysiwyg/MediaLib.js +71 -0
- package/admin/src/components/Wysiwyg/PreviewControlWrapper.js +30 -0
- package/admin/src/components/Wysiwyg/SelectWrapper.js +24 -0
- package/admin/src/components/Wysiwyg/ToggleModeWrapper.js +30 -0
- package/admin/src/components/Wysiwyg/constants.js +98 -0
- package/admin/src/components/Wysiwyg/customSelect.js +39 -0
- package/admin/src/components/Wysiwyg/helpers.js +116 -0
- package/admin/src/components/Wysiwyg/index.js +819 -0
- package/admin/src/components/Wysiwyg/previewControl.js +29 -0
- package/admin/src/components/Wysiwyg/toggleMode.js +44 -0
- package/admin/src/components/Wysiwyg/utils.js +70 -0
- package/admin/src/components/WysiwygBottomControls/components.js +44 -0
- package/admin/src/components/WysiwygBottomControls/index.js +33 -0
- package/admin/src/components/WysiwygDropUpload/Label.js +16 -0
- package/admin/src/components/WysiwygDropUpload/index.js +18 -0
- package/admin/src/components/WysiwygEditor/index.js +26 -0
- package/admin/src/components/WysiwygInlineControls/Button.js +77 -0
- package/admin/src/components/WysiwygInlineControls/StyledButton.js +54 -0
- package/admin/src/components/WysiwygInlineControls/Wrapper.js +25 -0
- package/admin/src/components/WysiwygInlineControls/index.js +66 -0
- package/admin/src/components/WysiwygWithErrors/Wrapper.js +38 -0
- package/admin/src/components/WysiwygWithErrors/index.js +158 -0
- package/admin/src/containers/CollectionTypeFormWrapper/index.js +376 -0
- package/admin/src/containers/CollectionTypeFormWrapper/utils/getRequestUrl.js +5 -0
- package/admin/src/containers/CollectionTypeFormWrapper/utils/index.js +2 -0
- package/admin/src/containers/CollectionTypeRecursivePath/index.js +125 -0
- package/admin/src/containers/ComponentSetttingsView/index.js +55 -0
- package/admin/src/containers/EditSettingsView/index.js +408 -0
- package/admin/src/containers/EditSettingsView/init.js +18 -0
- package/admin/src/containers/EditSettingsView/reducer.js +126 -0
- package/admin/src/containers/EditSettingsView/utils/createPossibleMainFieldsForModelsAndComponents.js +26 -0
- package/admin/src/containers/EditSettingsView/utils/getInputProps.js +30 -0
- package/admin/src/containers/EditSettingsView/utils/index.js +2 -0
- package/admin/src/containers/EditSettingsView/utils/layout.js +98 -0
- package/admin/src/containers/EditView/DeleteLink/index.js +94 -0
- package/admin/src/containers/EditView/DeleteLink/utils/connect.js +12 -0
- package/admin/src/containers/EditView/DeleteLink/utils/index.js +2 -0
- package/admin/src/containers/EditView/DeleteLink/utils/select.js +21 -0
- package/admin/src/containers/EditView/Header/index.js +258 -0
- package/admin/src/containers/EditView/Header/utils/connect.js +12 -0
- package/admin/src/containers/EditView/Header/utils/getDraftRelations.js +62 -0
- package/admin/src/containers/EditView/Header/utils/index.js +3 -0
- package/admin/src/containers/EditView/Header/utils/select.js +31 -0
- package/admin/src/containers/EditView/InformationCard.js +100 -0
- package/admin/src/containers/EditView/components.js +74 -0
- package/admin/src/containers/EditView/index.js +297 -0
- package/admin/src/containers/EditView/utils/createAttributesLayout.js +39 -0
- package/admin/src/containers/EditView/utils/getFieldsActionMatchingPermissions.js +23 -0
- package/admin/src/containers/EditView/utils/index.js +3 -0
- package/admin/src/containers/EditViewDataManagerProvider/index.js +519 -0
- package/admin/src/containers/EditViewDataManagerProvider/reducer.js +218 -0
- package/admin/src/containers/EditViewDataManagerProvider/utils/cleanData.js +88 -0
- package/admin/src/containers/EditViewDataManagerProvider/utils/getYupInnerErrors.js +17 -0
- package/admin/src/containers/EditViewDataManagerProvider/utils/index.js +3 -0
- package/admin/src/containers/EditViewDataManagerProvider/utils/schema.js +368 -0
- package/admin/src/containers/EditViewLayoutManager/Permissions.js +30 -0
- package/admin/src/containers/EditViewLayoutManager/actions.js +9 -0
- package/admin/src/containers/EditViewLayoutManager/constants.js +2 -0
- package/admin/src/containers/EditViewLayoutManager/index.js +44 -0
- package/admin/src/containers/EditViewLayoutManager/reducer.js +30 -0
- package/admin/src/containers/EditViewLayoutManager/selectors.js +5 -0
- package/admin/src/containers/LayoutDndProvider/index.js +75 -0
- package/admin/src/containers/ListSettingsView/DragWrapper.js +21 -0
- package/admin/src/containers/ListSettingsView/DropdownButton.js +8 -0
- package/admin/src/containers/ListSettingsView/Label.js +91 -0
- package/admin/src/containers/ListSettingsView/MenuDropdown.js +41 -0
- package/admin/src/containers/ListSettingsView/Toggle.js +51 -0
- package/admin/src/containers/ListSettingsView/forms.json +64 -0
- package/admin/src/containers/ListSettingsView/index.js +298 -0
- package/admin/src/containers/ListSettingsView/init.js +11 -0
- package/admin/src/containers/ListSettingsView/reducer.js +77 -0
- package/admin/src/containers/ListView/FieldPicker/ConfigureLink/StyledLink.js +28 -0
- package/admin/src/containers/ListView/FieldPicker/ConfigureLink/Wrapper.js +8 -0
- package/admin/src/containers/ListView/FieldPicker/ConfigureLink/index.js +29 -0
- package/admin/src/containers/ListView/FieldPicker/Field/Wrapper.js +15 -0
- package/admin/src/containers/ListView/FieldPicker/Field/index.js +24 -0
- package/admin/src/containers/ListView/FieldPicker/Fields/Wrapper.js +18 -0
- package/admin/src/containers/ListView/FieldPicker/Fields/index.js +27 -0
- package/admin/src/containers/ListView/FieldPicker/Header/Reset.js +8 -0
- package/admin/src/containers/ListView/FieldPicker/Header/index.js +42 -0
- package/admin/src/containers/ListView/FieldPicker/Wrapper.js +9 -0
- package/admin/src/containers/ListView/FieldPicker/index.js +46 -0
- package/admin/src/containers/ListView/Filter.js +83 -0
- package/admin/src/containers/ListView/Footer.js +60 -0
- package/admin/src/containers/ListView/actions.js +91 -0
- package/admin/src/containers/ListView/components.js +138 -0
- package/admin/src/containers/ListView/constants.js +16 -0
- package/admin/src/containers/ListView/index.js +573 -0
- package/admin/src/containers/ListView/reducer.js +182 -0
- package/admin/src/containers/ListView/selectors.js +24 -0
- package/admin/src/containers/ListView/utils/buildQueryString.js +26 -0
- package/admin/src/containers/ListView/utils/createPluginsFilter.js +13 -0
- package/admin/src/containers/ListView/utils/getAllAllowedHeaders.js +17 -0
- package/admin/src/containers/ListView/utils/getFirstSortableHeader.js +14 -0
- package/admin/src/containers/ListView/utils/index.js +3 -0
- package/admin/src/containers/ListViewLayoutManager/Permissions.js +29 -0
- package/admin/src/containers/ListViewLayoutManager/index.js +60 -0
- package/admin/src/containers/ListViewProvider/index.js +16 -0
- package/admin/src/containers/Main/actions.js +13 -0
- package/admin/src/containers/Main/constants.js +3 -0
- package/admin/src/containers/Main/index.js +100 -0
- package/admin/src/containers/Main/reducer.js +37 -0
- package/admin/src/containers/Main/selectors.js +20 -0
- package/admin/src/containers/RBACManager/actions.js +14 -0
- package/admin/src/containers/RBACManager/constants.js +2 -0
- package/admin/src/containers/RBACManager/reducer.js +32 -0
- package/admin/src/containers/RBACManager/useSyncRbac.js +28 -0
- package/admin/src/containers/SingleTypeFormWrapper/index.js +317 -0
- package/admin/src/containers/SingleTypeFormWrapper/utils/getRequestUrl.js +5 -0
- package/admin/src/containers/SingleTypeFormWrapper/utils/index.js +2 -0
- package/admin/src/containers/SingleTypeRecursivePath/index.js +84 -0
- package/admin/src/containers/WysiwygProvider/index.js +16 -0
- package/admin/src/contexts/ContentTypeLayout.js +5 -0
- package/admin/src/contexts/LayoutDnd.js +5 -0
- package/admin/src/contexts/ListView.js +5 -0
- package/admin/src/contexts/Wysiwyg.js +5 -0
- package/admin/src/contexts/index.js +4 -0
- package/admin/src/hooks/index.js +6 -0
- package/admin/src/hooks/useContentTypeLayout/index.js +19 -0
- package/admin/src/hooks/useFetchContentTypeLayout/index.js +83 -0
- package/admin/src/hooks/useFetchContentTypeLayout/reducer.js +56 -0
- package/admin/src/hooks/useFetchContentTypeLayout/utils/formatLayouts.js +235 -0
- package/admin/src/hooks/useFindRedirectionLink/index.js +14 -0
- package/admin/src/hooks/useFindRedirectionLink/selectors.js +7 -0
- package/admin/src/hooks/useFindRedirectionLink/utils/getRedirectionLink.js +45 -0
- package/admin/src/hooks/useLayoutDnd.js +6 -0
- package/admin/src/hooks/useListView.js +6 -0
- package/admin/src/hooks/useWysiwyg.js +6 -0
- package/admin/src/icons/Bold/index.js +22 -0
- package/admin/src/icons/Code/index.js +13 -0
- package/admin/src/icons/Cross/index.js +33 -0
- package/admin/src/icons/Italic/index.js +23 -0
- package/admin/src/icons/Link/index.js +21 -0
- package/admin/src/icons/Media/index.js +14 -0
- package/admin/src/icons/Na/index.js +58 -0
- package/admin/src/icons/Ol/index.js +13 -0
- package/admin/src/icons/Quote/index.js +13 -0
- package/admin/src/icons/Striked/index.js +24 -0
- package/admin/src/icons/Ul/index.js +15 -0
- package/admin/src/icons/Underline/index.js +22 -0
- package/admin/src/index.js +52 -0
- package/admin/src/lifecycles.js +19 -0
- package/admin/src/permissions.js +27 -0
- package/admin/src/pluginId.js +5 -0
- package/admin/src/reducers.js +16 -0
- package/admin/src/selectors.js +6 -0
- package/admin/src/sharedReducers/crudReducer/actions.js +44 -0
- package/admin/src/sharedReducers/crudReducer/constants.js +7 -0
- package/admin/src/sharedReducers/crudReducer/reducer.js +75 -0
- package/admin/src/sharedReducers/crudReducer/selectors.js +5 -0
- package/admin/src/testUtils/data.js +305 -0
- package/admin/src/testUtils/index.js +4 -0
- package/admin/src/translations/ar.json +94 -0
- package/admin/src/translations/cs.json +130 -0
- package/admin/src/translations/de.json +177 -0
- package/admin/src/translations/dk.json +180 -0
- package/admin/src/translations/en.json +177 -0
- package/admin/src/translations/es.json +177 -0
- package/admin/src/translations/fr.json +162 -0
- package/admin/src/translations/id.json +175 -0
- package/admin/src/translations/index.js +53 -0
- package/admin/src/translations/it.json +177 -0
- package/admin/src/translations/ja.json +94 -0
- package/admin/src/translations/ko.json +110 -0
- package/admin/src/translations/ms.json +148 -0
- package/admin/src/translations/nl.json +94 -0
- package/admin/src/translations/pl.json +142 -0
- package/admin/src/translations/pt-BR.json +94 -0
- package/admin/src/translations/pt.json +94 -0
- package/admin/src/translations/ru.json +177 -0
- package/admin/src/translations/sk.json +172 -0
- package/admin/src/translations/th.json +155 -0
- package/admin/src/translations/tr.json +177 -0
- package/admin/src/translations/uk.json +148 -0
- package/admin/src/translations/vi.json +110 -0
- package/admin/src/translations/zh-Hans.json +177 -0
- package/admin/src/translations/zh.json +94 -0
- package/admin/src/utils/ItemTypes.js +7 -0
- package/admin/src/utils/checkIfAttributeIsDisplayable.js +13 -0
- package/admin/src/utils/createDefaultForm.js +50 -0
- package/admin/src/utils/dateFormats.js +18 -0
- package/admin/src/utils/formatFiltersFromQuery.js +55 -0
- package/admin/src/utils/formatFiltersToQuery.js +27 -0
- package/admin/src/utils/formatLayoutToApi.js +44 -0
- package/admin/src/utils/generatePermissionsObject.js +20 -0
- package/admin/src/utils/getComponents.js +50 -0
- package/admin/src/utils/getDisplayedValue.js +61 -0
- package/admin/src/utils/getFieldName.js +6 -0
- package/admin/src/utils/getMaxTempKey.js +12 -0
- package/admin/src/utils/getRequestUrl.js +5 -0
- package/admin/src/utils/getTrad.js +5 -0
- package/admin/src/utils/index.js +17 -0
- package/admin/src/utils/mergeMetasWithSchema.js +20 -0
- package/admin/src/utils/removeKeyInObject.js +45 -0
- package/admin/src/utils/removePasswordFieldsFromData.js +54 -0
- package/config/admin.json +5 -0
- package/config/functions/bootstrap.js +9 -0
- package/config/policies/has-draft-and-publish.js +19 -0
- package/config/policies/hasPermissions.js +34 -0
- package/config/policies/routing.js +27 -0
- package/config/routes.json +275 -0
- package/controllers/collection-types.js +282 -0
- package/controllers/components.js +66 -0
- package/controllers/content-types.js +112 -0
- package/controllers/relations.js +63 -0
- package/controllers/single-types.js +170 -0
- package/controllers/uid.js +41 -0
- package/controllers/validation/index.js +104 -0
- package/controllers/validation/model-configuration.js +114 -0
- package/oas.yml +757 -0
- package/package.json +77 -0
- package/services/components.js +92 -0
- package/services/configuration.js +79 -0
- package/services/content-types.js +73 -0
- package/services/data-mapper.js +98 -0
- package/services/entity-manager.js +140 -0
- package/services/metrics.js +34 -0
- package/services/permission-checker.js +69 -0
- package/services/permission.js +95 -0
- package/services/uid.js +63 -0
- package/services/utils/configuration/attributes.js +175 -0
- package/services/utils/configuration/index.js +43 -0
- package/services/utils/configuration/layouts.js +185 -0
- package/services/utils/configuration/metadatas.js +142 -0
- package/services/utils/configuration/settings.js +52 -0
- package/services/utils/store.js +93 -0
- package/utils/index.js +16 -0
- package/utils/pick-writable-attributes.js +6 -0
- package/utils/wrap-bad-request.js +15 -0
- package/validation/policies/hasPermissions.js +17 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
const ResetComponent = styled.div`
|
|
4
|
+
position: absolute;
|
|
5
|
+
top: 0;
|
|
6
|
+
right: 15px;
|
|
7
|
+
display: flex;
|
|
8
|
+
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
color: #4b515a;
|
|
11
|
+
|
|
12
|
+
> span {
|
|
13
|
+
margin-right: 10px;
|
|
14
|
+
display: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&:hover {
|
|
18
|
+
> div {
|
|
19
|
+
background-color: #faa684;
|
|
20
|
+
}
|
|
21
|
+
color: #f64d0a;
|
|
22
|
+
> span {
|
|
23
|
+
display: initial;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
> div {
|
|
28
|
+
width: 24px;
|
|
29
|
+
height: 24px;
|
|
30
|
+
background-color: #f3f4f4;
|
|
31
|
+
text-align: center;
|
|
32
|
+
border-radius: 2px;
|
|
33
|
+
&:after {
|
|
34
|
+
content: '\f2ed';
|
|
35
|
+
font-size: 10px;
|
|
36
|
+
font-family: FontAwesome;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
export default ResetComponent;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable indent */
|
|
4
|
+
const Wrapper = styled.div`
|
|
5
|
+
position: relative;
|
|
6
|
+
|
|
7
|
+
${({ isFromDynamicZone }) => {
|
|
8
|
+
if (isFromDynamicZone) {
|
|
9
|
+
return `
|
|
10
|
+
background-color: #fff;
|
|
11
|
+
`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return '';
|
|
15
|
+
}}
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
export default Wrapper;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/* eslint-disable import/no-cycle */
|
|
2
|
+
import React, { memo } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { size } from 'lodash';
|
|
5
|
+
import { FormattedMessage, useIntl } from 'react-intl';
|
|
6
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
7
|
+
import isEqual from 'react-fast-compare';
|
|
8
|
+
import { NotAllowedInput, LabelIconWrapper } from 'strapi-helper-plugin';
|
|
9
|
+
import pluginId from '../../pluginId';
|
|
10
|
+
import ComponentInitializer from '../ComponentInitializer';
|
|
11
|
+
import NonRepeatableComponent from '../NonRepeatableComponent';
|
|
12
|
+
import RepeatableComponent from '../RepeatableComponent';
|
|
13
|
+
import connect from './utils/connect';
|
|
14
|
+
import select from './utils/select';
|
|
15
|
+
import ComponentIcon from './ComponentIcon';
|
|
16
|
+
import Label from './Label';
|
|
17
|
+
import Reset from './ResetComponent';
|
|
18
|
+
import Wrapper from './Wrapper';
|
|
19
|
+
|
|
20
|
+
const FieldComponent = ({
|
|
21
|
+
componentFriendlyName,
|
|
22
|
+
componentUid,
|
|
23
|
+
icon,
|
|
24
|
+
isCreatingEntry,
|
|
25
|
+
isFromDynamicZone,
|
|
26
|
+
isRepeatable,
|
|
27
|
+
isNested,
|
|
28
|
+
label,
|
|
29
|
+
labelIcon,
|
|
30
|
+
max,
|
|
31
|
+
min,
|
|
32
|
+
name,
|
|
33
|
+
// Passed thanks to the connect function
|
|
34
|
+
hasChildrenAllowedFields,
|
|
35
|
+
hasChildrenReadableFields,
|
|
36
|
+
isReadOnly,
|
|
37
|
+
componentValue,
|
|
38
|
+
removeComponentFromField,
|
|
39
|
+
}) => {
|
|
40
|
+
const { formatMessage } = useIntl();
|
|
41
|
+
const componentValueLength = size(componentValue);
|
|
42
|
+
const isInitialized = componentValue !== null || isFromDynamicZone;
|
|
43
|
+
const showResetComponent =
|
|
44
|
+
!isRepeatable && isInitialized && !isFromDynamicZone && hasChildrenAllowedFields;
|
|
45
|
+
|
|
46
|
+
const formattedLabelIcon = labelIcon
|
|
47
|
+
? { icon: labelIcon.icon, title: formatMessage(labelIcon.title) }
|
|
48
|
+
: null;
|
|
49
|
+
|
|
50
|
+
if (!hasChildrenAllowedFields && isCreatingEntry) {
|
|
51
|
+
return (
|
|
52
|
+
<div className="col-12">
|
|
53
|
+
<NotAllowedInput label={label} labelIcon={formattedLabelIcon} />
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!hasChildrenAllowedFields && !isCreatingEntry && !hasChildrenReadableFields) {
|
|
59
|
+
return (
|
|
60
|
+
<div className="col-12">
|
|
61
|
+
<NotAllowedInput label={label} labelIcon={formattedLabelIcon} />
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<Wrapper className="col-12" isFromDynamicZone={isFromDynamicZone}>
|
|
68
|
+
{isFromDynamicZone && (
|
|
69
|
+
<ComponentIcon title={componentFriendlyName}>
|
|
70
|
+
<div className="component_name">
|
|
71
|
+
<div className="component_icon">
|
|
72
|
+
<FontAwesomeIcon icon={icon} title={componentFriendlyName} />
|
|
73
|
+
</div>
|
|
74
|
+
<p>{componentFriendlyName}</p>
|
|
75
|
+
</div>
|
|
76
|
+
</ComponentIcon>
|
|
77
|
+
)}
|
|
78
|
+
<Label>
|
|
79
|
+
<span>
|
|
80
|
+
{label}
|
|
81
|
+
{isRepeatable && `(${componentValueLength})`}
|
|
82
|
+
</span>
|
|
83
|
+
{formattedLabelIcon && (
|
|
84
|
+
<LabelIconWrapper title={formattedLabelIcon.title}>
|
|
85
|
+
{formattedLabelIcon.icon}
|
|
86
|
+
</LabelIconWrapper>
|
|
87
|
+
)}
|
|
88
|
+
</Label>
|
|
89
|
+
{showResetComponent && (
|
|
90
|
+
<Reset
|
|
91
|
+
onClick={e => {
|
|
92
|
+
e.preventDefault();
|
|
93
|
+
e.stopPropagation();
|
|
94
|
+
removeComponentFromField(name, componentUid);
|
|
95
|
+
}}
|
|
96
|
+
>
|
|
97
|
+
<FormattedMessage id={`${pluginId}.components.reset-entry`} />
|
|
98
|
+
<div />
|
|
99
|
+
</Reset>
|
|
100
|
+
)}
|
|
101
|
+
{!isRepeatable && !isInitialized && (
|
|
102
|
+
<ComponentInitializer componentUid={componentUid} name={name} isReadOnly={isReadOnly} />
|
|
103
|
+
)}
|
|
104
|
+
|
|
105
|
+
{!isRepeatable && isInitialized && (
|
|
106
|
+
<NonRepeatableComponent
|
|
107
|
+
componentUid={componentUid}
|
|
108
|
+
isFromDynamicZone={isFromDynamicZone}
|
|
109
|
+
name={name}
|
|
110
|
+
/>
|
|
111
|
+
)}
|
|
112
|
+
{isRepeatable && (
|
|
113
|
+
<RepeatableComponent
|
|
114
|
+
componentValue={componentValue}
|
|
115
|
+
componentValueLength={componentValueLength}
|
|
116
|
+
componentUid={componentUid}
|
|
117
|
+
isNested={isNested}
|
|
118
|
+
isReadOnly={isReadOnly}
|
|
119
|
+
max={max}
|
|
120
|
+
min={min}
|
|
121
|
+
name={name}
|
|
122
|
+
/>
|
|
123
|
+
)}
|
|
124
|
+
</Wrapper>
|
|
125
|
+
);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
FieldComponent.defaultProps = {
|
|
129
|
+
componentValue: null,
|
|
130
|
+
componentFriendlyName: null,
|
|
131
|
+
hasChildrenAllowedFields: false,
|
|
132
|
+
hasChildrenReadableFields: false,
|
|
133
|
+
icon: 'smile',
|
|
134
|
+
isFromDynamicZone: false,
|
|
135
|
+
isReadOnly: false,
|
|
136
|
+
isRepeatable: false,
|
|
137
|
+
isNested: false,
|
|
138
|
+
labelIcon: null,
|
|
139
|
+
max: Infinity,
|
|
140
|
+
min: -Infinity,
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
FieldComponent.propTypes = {
|
|
144
|
+
componentFriendlyName: PropTypes.string,
|
|
145
|
+
componentUid: PropTypes.string.isRequired,
|
|
146
|
+
componentValue: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
147
|
+
hasChildrenAllowedFields: PropTypes.bool,
|
|
148
|
+
hasChildrenReadableFields: PropTypes.bool,
|
|
149
|
+
icon: PropTypes.string,
|
|
150
|
+
isCreatingEntry: PropTypes.bool.isRequired,
|
|
151
|
+
isFromDynamicZone: PropTypes.bool,
|
|
152
|
+
isReadOnly: PropTypes.bool,
|
|
153
|
+
isRepeatable: PropTypes.bool,
|
|
154
|
+
isNested: PropTypes.bool,
|
|
155
|
+
label: PropTypes.string.isRequired,
|
|
156
|
+
labelIcon: PropTypes.shape({
|
|
157
|
+
icon: PropTypes.node.isRequired,
|
|
158
|
+
title: PropTypes.shape({
|
|
159
|
+
id: PropTypes.string.isRequired,
|
|
160
|
+
defaultMessage: PropTypes.string.isRequired,
|
|
161
|
+
}),
|
|
162
|
+
}),
|
|
163
|
+
max: PropTypes.number,
|
|
164
|
+
min: PropTypes.number,
|
|
165
|
+
name: PropTypes.string.isRequired,
|
|
166
|
+
removeComponentFromField: PropTypes.func.isRequired,
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const Memoized = memo(FieldComponent, isEqual);
|
|
170
|
+
|
|
171
|
+
export default connect(Memoized, select);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
function connect(WrappedComponent, select) {
|
|
4
|
+
return function(props) {
|
|
5
|
+
// eslint-disable-next-line react/prop-types
|
|
6
|
+
const selectors = select(props);
|
|
7
|
+
|
|
8
|
+
return <WrappedComponent {...props} {...selectors} />;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default connect;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { get, take } from 'lodash';
|
|
3
|
+
import { useContentManagerEditViewDataManager } from 'strapi-helper-plugin';
|
|
4
|
+
|
|
5
|
+
import { getFieldName } from '../../../utils';
|
|
6
|
+
import { useContentTypeLayout } from '../../../hooks';
|
|
7
|
+
|
|
8
|
+
function useSelect({ isFromDynamicZone, name }) {
|
|
9
|
+
const {
|
|
10
|
+
createActionAllowedFields,
|
|
11
|
+
isCreatingEntry,
|
|
12
|
+
modifiedData,
|
|
13
|
+
removeComponentFromField,
|
|
14
|
+
readActionAllowedFields,
|
|
15
|
+
updateActionAllowedFields,
|
|
16
|
+
} = useContentManagerEditViewDataManager();
|
|
17
|
+
const { contentType } = useContentTypeLayout();
|
|
18
|
+
|
|
19
|
+
// This is used for the readonly mode when updating an entry
|
|
20
|
+
const allDynamicZoneFields = useMemo(() => {
|
|
21
|
+
const attributes = get(contentType, ['attributes'], {});
|
|
22
|
+
|
|
23
|
+
const dynamicZoneFields = Object.keys(attributes).filter(attrName => {
|
|
24
|
+
return get(attributes, [attrName, 'type'], '') === 'dynamiczone';
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return dynamicZoneFields;
|
|
28
|
+
}, [contentType]);
|
|
29
|
+
|
|
30
|
+
const allowedFields = useMemo(() => {
|
|
31
|
+
return isCreatingEntry ? createActionAllowedFields : updateActionAllowedFields;
|
|
32
|
+
}, [isCreatingEntry, createActionAllowedFields, updateActionAllowedFields]);
|
|
33
|
+
|
|
34
|
+
const componentValue = get(modifiedData, name, null);
|
|
35
|
+
const compoName = useMemo(() => {
|
|
36
|
+
return getFieldName(name);
|
|
37
|
+
}, [name]);
|
|
38
|
+
|
|
39
|
+
const hasChildrenAllowedFields = useMemo(() => {
|
|
40
|
+
if (isFromDynamicZone && isCreatingEntry) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const includedDynamicZoneFields = allowedFields.filter(name => name === compoName[0]);
|
|
45
|
+
|
|
46
|
+
if (includedDynamicZoneFields.length > 0) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const relatedChildrenAllowedFields = allowedFields
|
|
51
|
+
.map(fieldName => {
|
|
52
|
+
return fieldName.split('.');
|
|
53
|
+
})
|
|
54
|
+
.filter(fieldName => {
|
|
55
|
+
if (fieldName.length < compoName.length) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const joined = take(fieldName, compoName.length).join('.');
|
|
60
|
+
|
|
61
|
+
return joined === compoName.join('.');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return relatedChildrenAllowedFields.length > 0;
|
|
65
|
+
}, [isFromDynamicZone, isCreatingEntry, allowedFields, compoName]);
|
|
66
|
+
|
|
67
|
+
// This is used only when updating an entry
|
|
68
|
+
const hasChildrenReadableFields = useMemo(() => {
|
|
69
|
+
if (isFromDynamicZone) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
if (allDynamicZoneFields.includes(compoName[0])) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const allowedFields = isCreatingEntry ? [] : readActionAllowedFields;
|
|
77
|
+
|
|
78
|
+
const relatedChildrenAllowedFields = allowedFields
|
|
79
|
+
.map(fieldName => {
|
|
80
|
+
return fieldName.split('.');
|
|
81
|
+
})
|
|
82
|
+
.filter(fieldName => {
|
|
83
|
+
if (fieldName.length < compoName.length) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const joined = take(fieldName, compoName.length).join('.');
|
|
88
|
+
|
|
89
|
+
return joined === compoName.join('.');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
return relatedChildrenAllowedFields.length > 0;
|
|
93
|
+
}, [
|
|
94
|
+
isFromDynamicZone,
|
|
95
|
+
allDynamicZoneFields,
|
|
96
|
+
compoName,
|
|
97
|
+
isCreatingEntry,
|
|
98
|
+
readActionAllowedFields,
|
|
99
|
+
]);
|
|
100
|
+
|
|
101
|
+
const isReadOnly = useMemo(() => {
|
|
102
|
+
if (isCreatingEntry) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (hasChildrenAllowedFields) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return hasChildrenReadableFields;
|
|
111
|
+
}, [hasChildrenAllowedFields, hasChildrenReadableFields, isCreatingEntry]);
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
hasChildrenAllowedFields,
|
|
115
|
+
hasChildrenReadableFields,
|
|
116
|
+
isCreatingEntry,
|
|
117
|
+
isReadOnly,
|
|
118
|
+
removeComponentFromField,
|
|
119
|
+
componentValue,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export default useSelect;
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { useDrag, useDrop } from 'react-dnd';
|
|
3
|
+
import { getEmptyImage } from 'react-dnd-html5-backend';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { get } from 'lodash';
|
|
6
|
+
|
|
7
|
+
import useLayoutDnd from '../../hooks/useLayoutDnd';
|
|
8
|
+
import DraggedFieldWithPreview from '../DraggedFieldWithPreview';
|
|
9
|
+
|
|
10
|
+
import ItemTypes from '../../utils/ItemTypes';
|
|
11
|
+
|
|
12
|
+
const Item = ({
|
|
13
|
+
componentUid,
|
|
14
|
+
dynamicZoneComponents,
|
|
15
|
+
itemIndex,
|
|
16
|
+
moveItem,
|
|
17
|
+
moveRow,
|
|
18
|
+
name,
|
|
19
|
+
removeField,
|
|
20
|
+
rowIndex,
|
|
21
|
+
size,
|
|
22
|
+
type,
|
|
23
|
+
}) => {
|
|
24
|
+
const {
|
|
25
|
+
goTo,
|
|
26
|
+
componentLayouts,
|
|
27
|
+
metadatas,
|
|
28
|
+
setEditFieldToSelect,
|
|
29
|
+
selectedItemName,
|
|
30
|
+
setIsDraggingSibling,
|
|
31
|
+
} = useLayoutDnd();
|
|
32
|
+
const dragRef = useRef(null);
|
|
33
|
+
const dropRef = useRef(null);
|
|
34
|
+
const [{ clientOffset, isOver }, drop] = useDrop({
|
|
35
|
+
// Source code from http://react-dnd.github.io/react-dnd/examples/sortable/simple
|
|
36
|
+
// And also from https://codesandbox.io/s/6v7l7z68jk
|
|
37
|
+
accept: ItemTypes.EDIT_FIELD,
|
|
38
|
+
hover(item, monitor) {
|
|
39
|
+
if (!dropRef.current) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// We use the hover only to reorder full size items
|
|
44
|
+
if (item.size !== 12) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const dragIndex = monitor.getItem().itemIndex;
|
|
49
|
+
const hoverIndex = itemIndex;
|
|
50
|
+
const dragRow = monitor.getItem().rowIndex;
|
|
51
|
+
const targetRow = rowIndex;
|
|
52
|
+
|
|
53
|
+
// Don't replace item with themselves
|
|
54
|
+
if (dragIndex === hoverIndex && dragRow === targetRow) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Determine rectangle on screen
|
|
59
|
+
const hoverBoundingRect = dropRef.current.getBoundingClientRect();
|
|
60
|
+
|
|
61
|
+
// Get vertical middle
|
|
62
|
+
const hoverMiddleY =
|
|
63
|
+
(hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;
|
|
64
|
+
// Determine mouse position
|
|
65
|
+
const clientOffset = monitor.getClientOffset();
|
|
66
|
+
|
|
67
|
+
// Get pixels to the top
|
|
68
|
+
const hoverClientY = clientOffset.y - hoverBoundingRect.top;
|
|
69
|
+
|
|
70
|
+
// Only perform the move when the mouse has crossed half of the items height
|
|
71
|
+
// When dragging downwards, only move when the cursor is below 50%
|
|
72
|
+
// When dragging upwards, only move when the cursor is above 50%
|
|
73
|
+
|
|
74
|
+
// Dragging downwards
|
|
75
|
+
if (dragRow < targetRow && hoverClientY < hoverMiddleY) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Dragging upwards
|
|
80
|
+
if (dragRow > targetRow && hoverClientY > hoverMiddleY) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
moveRow(dragRow, targetRow);
|
|
85
|
+
|
|
86
|
+
item.rowIndex = targetRow;
|
|
87
|
+
item.itemIndex = hoverIndex;
|
|
88
|
+
},
|
|
89
|
+
drop(item, monitor) {
|
|
90
|
+
if (!dropRef.current) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const dragIndex = monitor.getItem().itemIndex;
|
|
95
|
+
const hoverIndex = itemIndex;
|
|
96
|
+
const dragRow = monitor.getItem().rowIndex;
|
|
97
|
+
const targetRow = rowIndex;
|
|
98
|
+
|
|
99
|
+
// Don't reorder on drop for full size elements since it is already done in the hover
|
|
100
|
+
if (item.size === 12) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Don't replace item with themselves
|
|
105
|
+
if (dragIndex === hoverIndex && dragRow === targetRow) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Determine rectangle on screen
|
|
110
|
+
const hoverBoundingRect = dropRef.current.getBoundingClientRect();
|
|
111
|
+
|
|
112
|
+
// Scroll window if mouse near vertical edge(100px)
|
|
113
|
+
|
|
114
|
+
// Horizontal Check --
|
|
115
|
+
if (
|
|
116
|
+
Math.abs(monitor.getClientOffset().x - hoverBoundingRect.left) >
|
|
117
|
+
hoverBoundingRect.width / 1.8
|
|
118
|
+
) {
|
|
119
|
+
moveItem(dragIndex, hoverIndex + 1, dragRow, targetRow);
|
|
120
|
+
|
|
121
|
+
item.itemIndex = hoverIndex + 1;
|
|
122
|
+
item.rowIndex = targetRow;
|
|
123
|
+
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Vertical Check |
|
|
128
|
+
|
|
129
|
+
// Time to actually perform the action
|
|
130
|
+
moveItem(dragIndex, hoverIndex, dragRow, targetRow);
|
|
131
|
+
// Note: we're mutating the monitor item here!
|
|
132
|
+
// Generally it's better to avoid mutations,
|
|
133
|
+
// but it's good here for the sake of performance
|
|
134
|
+
// to avoid expensive index searches.
|
|
135
|
+
|
|
136
|
+
item.itemIndex = hoverIndex;
|
|
137
|
+
item.rowIndex = targetRow;
|
|
138
|
+
},
|
|
139
|
+
collect: monitor => ({
|
|
140
|
+
canDrop: monitor.canDrop(),
|
|
141
|
+
clientOffset: monitor.getClientOffset(),
|
|
142
|
+
isOver: monitor.isOver(),
|
|
143
|
+
isOverCurrent: monitor.isOver({ shallow: true }),
|
|
144
|
+
itemType: monitor.getItemType(),
|
|
145
|
+
}),
|
|
146
|
+
});
|
|
147
|
+
const [{ isDragging, getItem }, drag, preview] = useDrag({
|
|
148
|
+
begin: () => {
|
|
149
|
+
setIsDraggingSibling(true);
|
|
150
|
+
},
|
|
151
|
+
canDrag() {
|
|
152
|
+
// Each row of the layout has a max size of 12 (based on bootstrap grid system)
|
|
153
|
+
// So in order to offer a better drop zone we add the _TEMP_ div to complete the remaining substract (12 - existing)
|
|
154
|
+
// Those divs cannot be dragged
|
|
155
|
+
// If we wanted to offer the ability to create new lines in the layout (which will come later)
|
|
156
|
+
// We will need to add a 12 size _TEMP_ div to offer a drop target between each existing row.
|
|
157
|
+
return name !== '_TEMP_';
|
|
158
|
+
},
|
|
159
|
+
collect: monitor => ({
|
|
160
|
+
isDragging: monitor.isDragging(),
|
|
161
|
+
getItem: monitor.getItem(),
|
|
162
|
+
}),
|
|
163
|
+
end: () => {
|
|
164
|
+
setIsDraggingSibling(false);
|
|
165
|
+
},
|
|
166
|
+
item: { type: ItemTypes.EDIT_FIELD, itemIndex, rowIndex, name, size },
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// Remove the default preview when the item is being dragged
|
|
170
|
+
// The preview is handled by the DragLayer
|
|
171
|
+
useEffect(() => {
|
|
172
|
+
preview(getEmptyImage(), { captureDraggingState: true });
|
|
173
|
+
}, [preview]);
|
|
174
|
+
|
|
175
|
+
// Create the refs
|
|
176
|
+
// We need 1 for the drop target
|
|
177
|
+
// 1 for the drag target
|
|
178
|
+
const refs = {
|
|
179
|
+
dragRef: drag(dragRef),
|
|
180
|
+
dropRef: drop(dropRef),
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
let showLeftCarret = false;
|
|
184
|
+
let showRightCarret = false;
|
|
185
|
+
|
|
186
|
+
if (dropRef.current && clientOffset) {
|
|
187
|
+
const hoverBoundingRect = dropRef.current.getBoundingClientRect();
|
|
188
|
+
|
|
189
|
+
showLeftCarret =
|
|
190
|
+
isOver &&
|
|
191
|
+
getItem.size !== 12 &&
|
|
192
|
+
Math.abs(clientOffset.x - hoverBoundingRect.left) <
|
|
193
|
+
hoverBoundingRect.width / 2;
|
|
194
|
+
showRightCarret =
|
|
195
|
+
isOver &&
|
|
196
|
+
getItem.size !== 12 &&
|
|
197
|
+
Math.abs(clientOffset.x - hoverBoundingRect.left) >
|
|
198
|
+
hoverBoundingRect.width / 2;
|
|
199
|
+
|
|
200
|
+
if (name === '_TEMP_') {
|
|
201
|
+
showLeftCarret = isOver && getItem.size !== 12;
|
|
202
|
+
showRightCarret = false;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return (
|
|
207
|
+
<DraggedFieldWithPreview
|
|
208
|
+
goTo={goTo}
|
|
209
|
+
componentUid={componentUid}
|
|
210
|
+
componentLayouts={componentLayouts}
|
|
211
|
+
dynamicZoneComponents={dynamicZoneComponents}
|
|
212
|
+
isDragging={isDragging}
|
|
213
|
+
label={get(metadatas, [name, 'edit', 'label'], '')}
|
|
214
|
+
name={name}
|
|
215
|
+
onClickEdit={setEditFieldToSelect}
|
|
216
|
+
onClickRemove={e => {
|
|
217
|
+
e.stopPropagation();
|
|
218
|
+
removeField(rowIndex, itemIndex);
|
|
219
|
+
}}
|
|
220
|
+
selectedItem={selectedItemName}
|
|
221
|
+
showLeftCarret={showLeftCarret}
|
|
222
|
+
showRightCarret={showRightCarret}
|
|
223
|
+
size={size}
|
|
224
|
+
type={type}
|
|
225
|
+
ref={refs}
|
|
226
|
+
/>
|
|
227
|
+
);
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
Item.defaultProps = {
|
|
231
|
+
componentUid: '',
|
|
232
|
+
dynamicZoneComponents: [],
|
|
233
|
+
type: 'string',
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
Item.propTypes = {
|
|
237
|
+
componentUid: PropTypes.string,
|
|
238
|
+
dynamicZoneComponents: PropTypes.array,
|
|
239
|
+
itemIndex: PropTypes.number.isRequired,
|
|
240
|
+
moveItem: PropTypes.func.isRequired,
|
|
241
|
+
moveRow: PropTypes.func.isRequired,
|
|
242
|
+
name: PropTypes.string.isRequired,
|
|
243
|
+
removeField: PropTypes.func.isRequired,
|
|
244
|
+
rowIndex: PropTypes.number.isRequired,
|
|
245
|
+
size: PropTypes.number.isRequired,
|
|
246
|
+
type: PropTypes.string,
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
export default Item;
|