@akemona-org/strapi-plugin-content-type-builder 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 +19 -0
- package/admin/src/InjectedComponents/ContentManager/EditSettingViewButton.js +76 -0
- package/admin/src/InjectedComponents/ContentManager/EditViewLink.js +44 -0
- package/admin/src/assets/images/logo.svg +1 -0
- package/admin/src/components/AllowedTypesSelect/MenuList.js +115 -0
- package/admin/src/components/AllowedTypesSelect/Text.js +26 -0
- package/admin/src/components/AllowedTypesSelect/index.js +55 -0
- package/admin/src/components/AttributeOption/Button.js +50 -0
- package/admin/src/components/AttributeOption/Card.js +26 -0
- package/admin/src/components/AttributeOption/index.js +127 -0
- package/admin/src/components/BooleanBox/CT.js +21 -0
- package/admin/src/components/BooleanBox/Enumeration.js +10 -0
- package/admin/src/components/BooleanBox/EnumerationWrapper.js +14 -0
- package/admin/src/components/BooleanBox/Label.js +9 -0
- package/admin/src/components/BooleanBox/ST.js +21 -0
- package/admin/src/components/BooleanBox/Wrapper.js +75 -0
- package/admin/src/components/BooleanBox/icons/CTSelected.js +136 -0
- package/admin/src/components/BooleanBox/icons/CTUnselected.js +136 -0
- package/admin/src/components/BooleanBox/icons/STSelected.js +80 -0
- package/admin/src/components/BooleanBox/icons/STUnselected.js +76 -0
- package/admin/src/components/BooleanBox/index.js +103 -0
- package/admin/src/components/CheckboxWithDescription/Wrapper.js +12 -0
- package/admin/src/components/CheckboxWithDescription/index.js +40 -0
- package/admin/src/components/ComponentCard/Close.js +12 -0
- package/admin/src/components/ComponentCard/Wrapper.js +84 -0
- package/admin/src/components/ComponentCard/index.js +62 -0
- package/admin/src/components/ComponentIconPicker/Cell.js +40 -0
- package/admin/src/components/ComponentIconPicker/CellRenderer.js +36 -0
- package/admin/src/components/ComponentIconPicker/Search.js +12 -0
- package/admin/src/components/ComponentIconPicker/SearchWrapper.js +34 -0
- package/admin/src/components/ComponentIconPicker/Wrapper.js +60 -0
- package/admin/src/components/ComponentIconPicker/index.js +143 -0
- package/admin/src/components/ComponentList/index.js +78 -0
- package/admin/src/components/ComponentSelect/Category.js +20 -0
- package/admin/src/components/ComponentSelect/CategoryName.js +11 -0
- package/admin/src/components/ComponentSelect/MenuList.js +110 -0
- package/admin/src/components/ComponentSelect/MultipleMenuList.js +271 -0
- package/admin/src/components/ComponentSelect/Value.js +83 -0
- package/admin/src/components/ComponentSelect/index.js +83 -0
- package/admin/src/components/ComponentSelect/utils/HasSomeSubArray.js +5 -0
- package/admin/src/components/ComponentSelect/utils/hasSubArray.js +5 -0
- package/admin/src/components/CreatableSelect/index.js +58 -0
- package/admin/src/components/CustomCheckbox/StyledCustomCheckbox.js +25 -0
- package/admin/src/components/CustomCheckbox/index.js +71 -0
- package/admin/src/components/CustomLink/P.js +17 -0
- package/admin/src/components/CustomLink/StyledCustomLink.js +20 -0
- package/admin/src/components/CustomLink/index.js +31 -0
- package/admin/src/components/DynamicZoneList/ComponentButton.js +39 -0
- package/admin/src/components/DynamicZoneList/index.js +124 -0
- package/admin/src/components/HeaderModalNavContainer/index.js +25 -0
- package/admin/src/components/HeaderNavLink/Wrapper.js +21 -0
- package/admin/src/components/HeaderNavLink/index.js +50 -0
- package/admin/src/components/List/List.js +131 -0
- package/admin/src/components/List/index.js +295 -0
- package/admin/src/components/ListButton/index.js +9 -0
- package/admin/src/components/ListHeader/Title.js +19 -0
- package/admin/src/components/ListHeader/Wrapper.js +24 -0
- package/admin/src/components/ListHeader/index.js +37 -0
- package/admin/src/components/ListRow/Wrapper.js +76 -0
- package/admin/src/components/ListRow/index.js +334 -0
- package/admin/src/components/ModalHeader/ComponentIcon.js +21 -0
- package/admin/src/components/ModalHeader/ComponentInfos.js +22 -0
- package/admin/src/components/ModalHeader/ComponentInfosWrapper.js +9 -0
- package/admin/src/components/ModalHeader/DropdownInfos.js +50 -0
- package/admin/src/components/ModalHeader/Icon.js +26 -0
- package/admin/src/components/ModalHeader/IconWrapper.js +11 -0
- package/admin/src/components/ModalHeader/Item.js +19 -0
- package/admin/src/components/ModalHeader/Menu.js +8 -0
- package/admin/src/components/ModalHeader/Toggle.js +14 -0
- package/admin/src/components/ModalHeader/Wrapper.js +12 -0
- package/admin/src/components/ModalHeader/index.js +105 -0
- package/admin/src/components/RelationForm/Wrapper.js +9 -0
- package/admin/src/components/RelationForm/index.js +66 -0
- package/admin/src/components/RelationFormBox/Wrapper.js +34 -0
- package/admin/src/components/RelationFormBox/index.js +85 -0
- package/admin/src/components/RelationFormNaturePicker/Wrapper.js +53 -0
- package/admin/src/components/RelationFormNaturePicker/index.js +112 -0
- package/admin/src/components/RelationTargetPicker/Item.js +62 -0
- package/admin/src/components/RelationTargetPicker/Wrapper.js +89 -0
- package/admin/src/components/RelationTargetPicker/index.js +88 -0
- package/admin/src/components/SelectCheckbox/index.js +8 -0
- package/admin/src/components/SelectMenuSubUl/ToggleUl.js +23 -0
- package/admin/src/components/SelectMenuSubUl/index.js +23 -0
- package/admin/src/components/SelectMenuUl/index.js +66 -0
- package/admin/src/components/Td/index.js +37 -0
- package/admin/src/components/UpperFirst/index.js +14 -0
- package/admin/src/components/WrapperSelect/index.js +89 -0
- package/admin/src/containers/App/Wrapper.js +14 -0
- package/admin/src/containers/App/index.js +39 -0
- package/admin/src/containers/App/utils/icons.json +962 -0
- package/admin/src/containers/DataManagerProvider/constants.js +15 -0
- package/admin/src/containers/DataManagerProvider/index.js +610 -0
- package/admin/src/containers/DataManagerProvider/reducer.js +461 -0
- package/admin/src/containers/DataManagerProvider/selectors.js +25 -0
- package/admin/src/containers/DataManagerProvider/utils/cleanData.js +167 -0
- package/admin/src/containers/DataManagerProvider/utils/createDataObject.js +8 -0
- package/admin/src/containers/DataManagerProvider/utils/createModifiedDataSchema.js +91 -0
- package/admin/src/containers/DataManagerProvider/utils/retrieveComponentsFromSchema.js +55 -0
- package/admin/src/containers/DataManagerProvider/utils/retrieveComponentsThatHaveComponents.js +35 -0
- package/admin/src/containers/DataManagerProvider/utils/retrieveNestedComponents.js +34 -0
- package/admin/src/containers/DataManagerProvider/utils/retrieveSpecificInfoFromComponents.js +12 -0
- package/admin/src/containers/FormModal/CustomButton.js +12 -0
- package/admin/src/containers/FormModal/attributes/advancedForm.js +269 -0
- package/admin/src/containers/FormModal/attributes/attributeOptions.js +99 -0
- package/admin/src/containers/FormModal/attributes/baseForm.js +322 -0
- package/admin/src/containers/FormModal/attributes/commonBaseForm.js +7 -0
- package/admin/src/containers/FormModal/attributes/form.js +9 -0
- package/admin/src/containers/FormModal/attributes/index.js +4 -0
- package/admin/src/containers/FormModal/attributes/nameField.js +19 -0
- package/admin/src/containers/FormModal/attributes/types.js +309 -0
- package/admin/src/containers/FormModal/attributes/uiHelpers.js +11 -0
- package/admin/src/containers/FormModal/attributes/validation/common.js +151 -0
- package/admin/src/containers/FormModal/category/createCategorySchema.js +28 -0
- package/admin/src/containers/FormModal/category/form.js +27 -0
- package/admin/src/containers/FormModal/category/index.js +3 -0
- package/admin/src/containers/FormModal/category/regex.js +3 -0
- package/admin/src/containers/FormModal/component/componentField.js +25 -0
- package/admin/src/containers/FormModal/component/createComponentSchema.js +49 -0
- package/admin/src/containers/FormModal/component/form.js +67 -0
- package/admin/src/containers/FormModal/component/index.js +4 -0
- package/admin/src/containers/FormModal/constants.js +11 -0
- package/admin/src/containers/FormModal/contentType/createContentTypeSchema.js +44 -0
- package/admin/src/containers/FormModal/contentType/form.js +116 -0
- package/admin/src/containers/FormModal/contentType/index.js +2 -0
- package/admin/src/containers/FormModal/dynamicZone/form.js +45 -0
- package/admin/src/containers/FormModal/dynamicZone/index.js +2 -0
- package/admin/src/containers/FormModal/forms/index.js +164 -0
- package/admin/src/containers/FormModal/index.js +1552 -0
- package/admin/src/containers/FormModal/reducer.js +293 -0
- package/admin/src/containers/FormModal/selectors.js +24 -0
- package/admin/src/containers/FormModal/utils/canEditContentType.js +19 -0
- package/admin/src/containers/FormModal/utils/createHeadersArray.js +37 -0
- package/admin/src/containers/FormModal/utils/createHeadersObjectFromArray.js +27 -0
- package/admin/src/containers/FormModal/utils/createUid.js +17 -0
- package/admin/src/containers/FormModal/utils/getAttributesToDisplay.js +35 -0
- package/admin/src/containers/FormModal/utils/getModalTitleSubHeader.js +25 -0
- package/admin/src/containers/FormModal/utils/getNextSearch.js +17 -0
- package/admin/src/containers/FormModal/utils/index.js +6 -0
- package/admin/src/containers/FormModal/utils/relations.js +9 -0
- package/admin/src/containers/FormModal/utils/staticData.js +43 -0
- package/admin/src/containers/Initializer/index.js +26 -0
- package/admin/src/containers/LeftMenu/Wrapper.js +14 -0
- package/admin/src/containers/LeftMenu/index.js +220 -0
- package/admin/src/containers/ListView/Wrapper.js +16 -0
- package/admin/src/containers/ListView/index.js +322 -0
- package/admin/src/containers/NotFoundPage/index.js +20 -0
- package/admin/src/containers/RecursivePath/index.js +22 -0
- package/admin/src/contexts/DataManagerContext.js +5 -0
- package/admin/src/contexts/ListViewContext.js +5 -0
- package/admin/src/hooks/useDataManager.js +6 -0
- package/admin/src/hooks/useListView.js +6 -0
- package/admin/src/icons/Curve.js +26 -0
- package/admin/src/icons/ManyToMany.js +98 -0
- package/admin/src/icons/ManyToOne.js +64 -0
- package/admin/src/icons/ManyWay.js +36 -0
- package/admin/src/icons/OneToMany.js +65 -0
- package/admin/src/icons/OneToOne.js +47 -0
- package/admin/src/icons/OneWay.js +38 -0
- package/admin/src/index.js +83 -0
- package/admin/src/lifecycles.js +13 -0
- package/admin/src/permissions.js +9 -0
- package/admin/src/pluginId.js +5 -0
- package/admin/src/reducers.js +10 -0
- package/admin/src/translations/ar.json +48 -0
- package/admin/src/translations/cs.json +151 -0
- package/admin/src/translations/de.json +187 -0
- package/admin/src/translations/dk.json +181 -0
- package/admin/src/translations/en.json +188 -0
- package/admin/src/translations/es.json +188 -0
- package/admin/src/translations/fr.json +87 -0
- package/admin/src/translations/id.json +187 -0
- package/admin/src/translations/index.js +51 -0
- package/admin/src/translations/it.json +187 -0
- package/admin/src/translations/ja.json +50 -0
- package/admin/src/translations/ko.json +57 -0
- package/admin/src/translations/ms.json +179 -0
- package/admin/src/translations/nl.json +171 -0
- package/admin/src/translations/pl.json +152 -0
- package/admin/src/translations/pt-BR.json +51 -0
- package/admin/src/translations/pt.json +51 -0
- package/admin/src/translations/ru.json +188 -0
- package/admin/src/translations/sk.json +186 -0
- package/admin/src/translations/th.json +181 -0
- package/admin/src/translations/tr.json +51 -0
- package/admin/src/translations/uk.json +180 -0
- package/admin/src/translations/zh-Hans.json +188 -0
- package/admin/src/translations/zh.json +178 -0
- package/admin/src/utils/convertAttrObjToArray.js +7 -0
- package/admin/src/utils/formAPI.js +112 -0
- package/admin/src/utils/getAttributeDisplayedType.js +31 -0
- package/admin/src/utils/getComponents.js +31 -0
- package/admin/src/utils/getTrad.js +5 -0
- package/admin/src/utils/makeSearch.js +15 -0
- package/admin/src/utils/makeUnique.js +3 -0
- package/config/functions/bootstrap.js +14 -0
- package/config/routes.json +144 -0
- package/controllers/Builder.js +7 -0
- package/controllers/ComponentCategories.js +43 -0
- package/controllers/Components.js +152 -0
- package/controllers/Connections.js +9 -0
- package/controllers/ContentTypes.js +143 -0
- package/controllers/validation/common.js +118 -0
- package/controllers/validation/component-category.js +21 -0
- package/controllers/validation/component.js +89 -0
- package/controllers/validation/content-type.js +161 -0
- package/controllers/validation/data-transform.js +32 -0
- package/controllers/validation/model-schema.js +91 -0
- package/controllers/validation/relations.js +56 -0
- package/controllers/validation/types.js +277 -0
- package/package.json +63 -0
- package/services/Builder.js +7 -0
- package/services/ComponentCategories.js +88 -0
- package/services/Components.js +103 -0
- package/services/ContentTypes.js +263 -0
- package/services/api-handler.js +158 -0
- package/services/constants.js +59 -0
- package/services/schema-builder/component-builder.js +137 -0
- package/services/schema-builder/content-type-builder.js +256 -0
- package/services/schema-builder/index.js +196 -0
- package/services/schema-builder/schema-handler.js +297 -0
- package/utils/attributes.js +154 -0
- package/utils/helpers.js +31 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Checkbox, Text } from '@buffetjs/core';
|
|
4
|
+
import Wrapper from './Wrapper';
|
|
5
|
+
|
|
6
|
+
const CheckboxWithDescription = ({ description, error, label, value, ...rest }) => {
|
|
7
|
+
return (
|
|
8
|
+
<>
|
|
9
|
+
<Wrapper>
|
|
10
|
+
<Checkbox {...rest} message={label} label={label} type="checkbox" value={value} />
|
|
11
|
+
{description && (
|
|
12
|
+
<Text color="grey" title={description} fontSize="sm" ellipsis>
|
|
13
|
+
{description}
|
|
14
|
+
</Text>
|
|
15
|
+
)}
|
|
16
|
+
{error && (
|
|
17
|
+
<Text color="lightOrange" lineHeight="18px">
|
|
18
|
+
{error}
|
|
19
|
+
</Text>
|
|
20
|
+
)}
|
|
21
|
+
</Wrapper>
|
|
22
|
+
</>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
CheckboxWithDescription.defaultProps = {
|
|
27
|
+
description: null,
|
|
28
|
+
error: null,
|
|
29
|
+
label: null,
|
|
30
|
+
value: false,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
CheckboxWithDescription.propTypes = {
|
|
34
|
+
description: PropTypes.string,
|
|
35
|
+
error: PropTypes.string,
|
|
36
|
+
label: PropTypes.string,
|
|
37
|
+
value: PropTypes.bool,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default CheckboxWithDescription;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Wrapper
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
|
|
9
|
+
const Wrapper = styled.button`
|
|
10
|
+
width: 139px;
|
|
11
|
+
height: 90px;
|
|
12
|
+
position: relative;
|
|
13
|
+
padding: 0;
|
|
14
|
+
padding-top: 5px;
|
|
15
|
+
border-radius: 2px;
|
|
16
|
+
text-align: center;
|
|
17
|
+
border: solid 1px #fafafb;
|
|
18
|
+
background-color: #fafafb;
|
|
19
|
+
|
|
20
|
+
&:focus {
|
|
21
|
+
outline: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
div:first-of-type {
|
|
25
|
+
display: flex;
|
|
26
|
+
width: 35px;
|
|
27
|
+
height: 35px;
|
|
28
|
+
margin: auto;
|
|
29
|
+
border-radius: 18px;
|
|
30
|
+
background-color: #e9eaeb;
|
|
31
|
+
color: #919bae;
|
|
32
|
+
font-size: 12px;
|
|
33
|
+
|
|
34
|
+
svg {
|
|
35
|
+
margin: auto;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
div:last-of-type {
|
|
40
|
+
position: absolute;
|
|
41
|
+
padding: 0 7px;
|
|
42
|
+
top: 0;
|
|
43
|
+
right: 0;
|
|
44
|
+
display: none;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
p {
|
|
48
|
+
margin-top: 5px;
|
|
49
|
+
padding-left: 5px;
|
|
50
|
+
padding-right: 5px;
|
|
51
|
+
line-height: normal;
|
|
52
|
+
font-size: 13px;
|
|
53
|
+
font-weight: bold;
|
|
54
|
+
color: #919bae;
|
|
55
|
+
overflow: hidden;
|
|
56
|
+
text-overflow: ellipsis;
|
|
57
|
+
white-space: nowrap;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
&.active {
|
|
61
|
+
cursor: initial;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&:hover,
|
|
65
|
+
&.active {
|
|
66
|
+
border-color: #aed4fb;
|
|
67
|
+
background-color: #e6f0fb;
|
|
68
|
+
|
|
69
|
+
div:first-of-type {
|
|
70
|
+
background-color: #aed4fb;
|
|
71
|
+
color: #007eff;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
div:last-of-type {
|
|
75
|
+
display: block;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
p {
|
|
79
|
+
color: #007eff;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
|
|
84
|
+
export default Wrapper;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* ComponentCard
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { get } from 'lodash';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
11
|
+
|
|
12
|
+
import useDataManager from '../../hooks/useDataManager';
|
|
13
|
+
import Wrapper from './Wrapper';
|
|
14
|
+
import Close from './Close';
|
|
15
|
+
|
|
16
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
17
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
18
|
+
|
|
19
|
+
function ComponentCard({ component, dzName, index, isActive, isInDevelopmentMode, onClick }) {
|
|
20
|
+
const { modifiedData, removeComponentFromDynamicZone } = useDataManager();
|
|
21
|
+
const {
|
|
22
|
+
schema: { icon, name },
|
|
23
|
+
} = get(modifiedData, ['components', component], {
|
|
24
|
+
schema: { icon: null },
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<Wrapper onClick={onClick} className={isActive ? 'active' : ''}>
|
|
29
|
+
<div>
|
|
30
|
+
<FontAwesomeIcon icon={icon} />
|
|
31
|
+
</div>
|
|
32
|
+
<p>{name}</p>
|
|
33
|
+
<div
|
|
34
|
+
className="close-btn"
|
|
35
|
+
onClick={e => {
|
|
36
|
+
e.stopPropagation();
|
|
37
|
+
removeComponentFromDynamicZone(dzName, index);
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
{isInDevelopmentMode && <Close width="7px" height="7px" />}
|
|
41
|
+
</div>
|
|
42
|
+
</Wrapper>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
ComponentCard.defaultProps = {
|
|
47
|
+
component: null,
|
|
48
|
+
isActive: false,
|
|
49
|
+
isInDevelopmentMode: false,
|
|
50
|
+
onClick: () => {},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
ComponentCard.propTypes = {
|
|
54
|
+
component: PropTypes.string,
|
|
55
|
+
dzName: PropTypes.string.isRequired,
|
|
56
|
+
index: PropTypes.number.isRequired,
|
|
57
|
+
isActive: PropTypes.bool,
|
|
58
|
+
isInDevelopmentMode: PropTypes.bool,
|
|
59
|
+
onClick: PropTypes.func,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default ComponentCard;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable indent */
|
|
4
|
+
const Cell = styled.div`
|
|
5
|
+
width: 54px;
|
|
6
|
+
height: 100%;
|
|
7
|
+
display: flex;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
align-items: center;
|
|
10
|
+
position: absolute;
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
|
|
13
|
+
${({ isSelected }) => {
|
|
14
|
+
if (isSelected) {
|
|
15
|
+
return `
|
|
16
|
+
&::after {
|
|
17
|
+
content: '';
|
|
18
|
+
position: absolute;
|
|
19
|
+
top: 4px;
|
|
20
|
+
left: 6px;
|
|
21
|
+
border-radius: 50%;
|
|
22
|
+
width: 40px;
|
|
23
|
+
height: 40px;
|
|
24
|
+
background-color: #AED4FB;
|
|
25
|
+
z-index: 1;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return '';
|
|
31
|
+
}}
|
|
32
|
+
|
|
33
|
+
> svg {
|
|
34
|
+
z-index: 9;
|
|
35
|
+
font-size: 18px;
|
|
36
|
+
color: ${({ isSelected }) => (isSelected ? '#007EFF' : '#b4b6ba')};
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
export default Cell;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
4
|
+
import Cell from './Cell';
|
|
5
|
+
|
|
6
|
+
const CellRenderer = ({ icon, name, onChange, style, value }) => {
|
|
7
|
+
const isSelected = icon === value;
|
|
8
|
+
const handleClick = () => {
|
|
9
|
+
onChange({ target: { name, value: icon } });
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<Cell
|
|
14
|
+
className="cell"
|
|
15
|
+
style={style}
|
|
16
|
+
isSelected={isSelected}
|
|
17
|
+
onClick={handleClick}
|
|
18
|
+
>
|
|
19
|
+
<FontAwesomeIcon icon={icon} />
|
|
20
|
+
</Cell>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
CellRenderer.defaultProps = {
|
|
25
|
+
value: '',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
CellRenderer.propTypes = {
|
|
29
|
+
icon: PropTypes.string.isRequired,
|
|
30
|
+
name: PropTypes.string.isRequired,
|
|
31
|
+
onChange: PropTypes.func.isRequired,
|
|
32
|
+
style: PropTypes.object.isRequired,
|
|
33
|
+
value: PropTypes.string,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default CellRenderer;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { colors } from 'strapi-helper-plugin';
|
|
3
|
+
|
|
4
|
+
const SearchWrapper = styled.div`
|
|
5
|
+
position: relative;
|
|
6
|
+
margin-top: -2px;
|
|
7
|
+
&::after {
|
|
8
|
+
display: block;
|
|
9
|
+
content: '';
|
|
10
|
+
height: 2px;
|
|
11
|
+
width: calc(100% - 20px);
|
|
12
|
+
background: ${colors.leftMenu.lightGrey};
|
|
13
|
+
}
|
|
14
|
+
> svg {
|
|
15
|
+
position: absolute;
|
|
16
|
+
bottom: 15px;
|
|
17
|
+
left: 0;
|
|
18
|
+
font-size: 11px;
|
|
19
|
+
}
|
|
20
|
+
button {
|
|
21
|
+
position: absolute;
|
|
22
|
+
top: 1px;
|
|
23
|
+
right: 0;
|
|
24
|
+
padding: 5px 0 0px 5px;
|
|
25
|
+
line-height: 11px;
|
|
26
|
+
outline: 0;
|
|
27
|
+
i,
|
|
28
|
+
svg {
|
|
29
|
+
font-size: 11px;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
export default SearchWrapper;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { colors } from '@buffetjs/styles';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
/* eslint-disable indent */
|
|
6
|
+
|
|
7
|
+
const Wrapper = styled.div`
|
|
8
|
+
min-height: 198px;
|
|
9
|
+
.collection {
|
|
10
|
+
background-color: #fafafb;
|
|
11
|
+
${({ error }) => {
|
|
12
|
+
if (error) {
|
|
13
|
+
return `
|
|
14
|
+
border: 1px solid ${colors.darkOrange};
|
|
15
|
+
border-radius: 2px;
|
|
16
|
+
`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return '';
|
|
20
|
+
}}
|
|
21
|
+
|
|
22
|
+
&:focus,
|
|
23
|
+
:active {
|
|
24
|
+
outline: 0;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.noCells {
|
|
29
|
+
position: absolute;
|
|
30
|
+
top: 0;
|
|
31
|
+
bottom: 0;
|
|
32
|
+
left: 0;
|
|
33
|
+
right: 0;
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
font-size: 1em;
|
|
38
|
+
color: #bdbdbd;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.search {
|
|
42
|
+
display: flex;
|
|
43
|
+
color: #919bae;
|
|
44
|
+
> button {
|
|
45
|
+
margin-top: -8px;
|
|
46
|
+
font-size: 1.3rem;
|
|
47
|
+
outline: 0;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
Wrapper.defaultProps = {
|
|
53
|
+
error: false,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
Wrapper.propTypes = {
|
|
57
|
+
error: PropTypes.bool,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default Wrapper;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import React, { useEffect, useState, useRef } from 'react';
|
|
2
|
+
import { useClickAwayListener } from '@buffetjs/hooks';
|
|
3
|
+
import { Label, ErrorMessage } from '@buffetjs/styles';
|
|
4
|
+
import { AutoSizer, Collection } from 'react-virtualized';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
7
|
+
import useDataManager from '../../hooks/useDataManager';
|
|
8
|
+
import CellRenderer from './CellRenderer';
|
|
9
|
+
import Search from './Search';
|
|
10
|
+
import SearchWrapper from './SearchWrapper';
|
|
11
|
+
import Wrapper from './Wrapper';
|
|
12
|
+
|
|
13
|
+
/* eslint-disable jsx-a11y/control-has-associated-label */
|
|
14
|
+
|
|
15
|
+
const ComponentIconPicker = ({ error, isCreating, label, name, onChange, value }) => {
|
|
16
|
+
const { allIcons, allComponentsIconAlreadyTaken } = useDataManager();
|
|
17
|
+
const [originalIcon] = useState(value);
|
|
18
|
+
const initialIcons = allIcons.filter(ico => {
|
|
19
|
+
if (isCreating) {
|
|
20
|
+
return !allComponentsIconAlreadyTaken.includes(ico);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Edition
|
|
24
|
+
return !allComponentsIconAlreadyTaken.filter(icon => icon !== originalIcon).includes(ico);
|
|
25
|
+
});
|
|
26
|
+
const ref = useRef();
|
|
27
|
+
const searchWrapperRef = useRef();
|
|
28
|
+
const [showSearch, setShowSearch] = useState(false);
|
|
29
|
+
const [search, setSearch] = useState('');
|
|
30
|
+
const [icons, setIcons] = useState(initialIcons);
|
|
31
|
+
const toggleSearch = () => setShowSearch(prev => !prev);
|
|
32
|
+
|
|
33
|
+
useClickAwayListener(searchWrapperRef, () => {
|
|
34
|
+
setShowSearch(false);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (showSearch && ref.current) {
|
|
39
|
+
ref.current.focus();
|
|
40
|
+
}
|
|
41
|
+
}, [ref, showSearch]);
|
|
42
|
+
|
|
43
|
+
const cellCount = icons.length;
|
|
44
|
+
|
|
45
|
+
const cellSizeAndPositionGetter = ({ index }) => {
|
|
46
|
+
const columnCount = 16;
|
|
47
|
+
const columnPosition = index % (columnCount || 1);
|
|
48
|
+
|
|
49
|
+
const height = 48;
|
|
50
|
+
const width = 52;
|
|
51
|
+
let x = columnPosition * width;
|
|
52
|
+
|
|
53
|
+
if (x === 0) {
|
|
54
|
+
x = 8;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const y = parseInt(index / 16, 10) * 48;
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
height,
|
|
61
|
+
width,
|
|
62
|
+
x,
|
|
63
|
+
y,
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const handleChangeSearch = ({ target: { value } }) => {
|
|
68
|
+
setSearch(value);
|
|
69
|
+
setIcons(() => initialIcons.filter(icon => icon.includes(value)));
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<Wrapper error={error !== null}>
|
|
74
|
+
<div className="search">
|
|
75
|
+
<Label htmlFor={name} style={{ marginBottom: 12 }}>
|
|
76
|
+
{label}
|
|
77
|
+
</Label>
|
|
78
|
+
{!showSearch ? (
|
|
79
|
+
<button onClick={toggleSearch} type="button">
|
|
80
|
+
<FontAwesomeIcon icon="search" />
|
|
81
|
+
</button>
|
|
82
|
+
) : (
|
|
83
|
+
<SearchWrapper ref={searchWrapperRef}>
|
|
84
|
+
<FontAwesomeIcon icon="search" />
|
|
85
|
+
<button onClick={toggleSearch} type="button" />
|
|
86
|
+
<Search ref={ref} onChange={handleChangeSearch} value={search} placeholder="Search…" />
|
|
87
|
+
<button
|
|
88
|
+
onClick={() => {
|
|
89
|
+
setSearch('');
|
|
90
|
+
setIcons(initialIcons);
|
|
91
|
+
toggleSearch();
|
|
92
|
+
}}
|
|
93
|
+
type="button"
|
|
94
|
+
>
|
|
95
|
+
<FontAwesomeIcon icon="times" />
|
|
96
|
+
</button>
|
|
97
|
+
</SearchWrapper>
|
|
98
|
+
)}
|
|
99
|
+
</div>
|
|
100
|
+
<AutoSizer disableHeight>
|
|
101
|
+
{({ width }) => {
|
|
102
|
+
return (
|
|
103
|
+
<Collection
|
|
104
|
+
cellCount={cellCount}
|
|
105
|
+
cellRenderer={({ key, index, ...rest }) => {
|
|
106
|
+
return (
|
|
107
|
+
<CellRenderer
|
|
108
|
+
{...rest}
|
|
109
|
+
key={key}
|
|
110
|
+
icon={icons[index]}
|
|
111
|
+
name={name}
|
|
112
|
+
value={value}
|
|
113
|
+
onChange={onChange}
|
|
114
|
+
/>
|
|
115
|
+
);
|
|
116
|
+
}}
|
|
117
|
+
cellSizeAndPositionGetter={cellSizeAndPositionGetter}
|
|
118
|
+
className="collection"
|
|
119
|
+
height={144}
|
|
120
|
+
width={width + 4}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
}}
|
|
124
|
+
</AutoSizer>
|
|
125
|
+
{error && <ErrorMessage style={{ marginTop: 5, marginBottom: 16 }}>{error}</ErrorMessage>}
|
|
126
|
+
</Wrapper>
|
|
127
|
+
);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
ComponentIconPicker.defaultProps = {
|
|
131
|
+
error: null,
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
ComponentIconPicker.propTypes = {
|
|
135
|
+
error: PropTypes.string,
|
|
136
|
+
isCreating: PropTypes.bool.isRequired,
|
|
137
|
+
label: PropTypes.string.isRequired,
|
|
138
|
+
name: PropTypes.string.isRequired,
|
|
139
|
+
onChange: PropTypes.func.isRequired,
|
|
140
|
+
value: PropTypes.string.isRequired,
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export default ComponentIconPicker;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* ComponentList
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
/* eslint-disable import/no-cycle */
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { get } from 'lodash';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import List from '../List';
|
|
11
|
+
import useDataManager from '../../hooks/useDataManager';
|
|
12
|
+
import convertAttrObjToArray from '../../utils/convertAttrObjToArray';
|
|
13
|
+
import Td from '../Td';
|
|
14
|
+
|
|
15
|
+
function ComponentList({
|
|
16
|
+
customRowComponent,
|
|
17
|
+
component,
|
|
18
|
+
dzName,
|
|
19
|
+
mainTypeName,
|
|
20
|
+
isFromDynamicZone,
|
|
21
|
+
isNestedInDZComponent,
|
|
22
|
+
firstLoopComponentName,
|
|
23
|
+
firstLoopComponentUid,
|
|
24
|
+
}) {
|
|
25
|
+
const { modifiedData } = useDataManager();
|
|
26
|
+
const {
|
|
27
|
+
schema: { name: componentName, attributes },
|
|
28
|
+
} = get(modifiedData, ['components', component], {
|
|
29
|
+
schema: { attributes: {} },
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<tr className="component-row">
|
|
34
|
+
<Td colSpan={12} isChildOfDynamicZone={isFromDynamicZone}>
|
|
35
|
+
<List
|
|
36
|
+
customRowComponent={customRowComponent}
|
|
37
|
+
dzName={dzName}
|
|
38
|
+
items={convertAttrObjToArray(attributes)}
|
|
39
|
+
targetUid={component}
|
|
40
|
+
mainTypeName={mainTypeName}
|
|
41
|
+
firstLoopComponentName={firstLoopComponentName || componentName}
|
|
42
|
+
firstLoopComponentUid={firstLoopComponentUid || component}
|
|
43
|
+
editTarget="components"
|
|
44
|
+
isFromDynamicZone={isFromDynamicZone}
|
|
45
|
+
isNestedInDZComponent={isNestedInDZComponent}
|
|
46
|
+
isSub
|
|
47
|
+
secondLoopComponentName={
|
|
48
|
+
firstLoopComponentName ? componentName : null
|
|
49
|
+
}
|
|
50
|
+
secondLoopComponentUid={firstLoopComponentUid ? component : null}
|
|
51
|
+
/>
|
|
52
|
+
</Td>
|
|
53
|
+
</tr>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
ComponentList.defaultProps = {
|
|
58
|
+
component: null,
|
|
59
|
+
customRowComponent: null,
|
|
60
|
+
dzName: null,
|
|
61
|
+
firstLoopComponentName: null,
|
|
62
|
+
firstLoopComponentUid: null,
|
|
63
|
+
isFromDynamicZone: false,
|
|
64
|
+
isNestedInDZComponent: false,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
ComponentList.propTypes = {
|
|
68
|
+
component: PropTypes.string,
|
|
69
|
+
customRowComponent: PropTypes.func,
|
|
70
|
+
dzName: PropTypes.string,
|
|
71
|
+
firstLoopComponentName: PropTypes.string,
|
|
72
|
+
firstLoopComponentUid: PropTypes.string,
|
|
73
|
+
isFromDynamicZone: PropTypes.bool,
|
|
74
|
+
isNestedInDZComponent: PropTypes.bool,
|
|
75
|
+
mainTypeName: PropTypes.string.isRequired,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export default ComponentList;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import UpperFirst from '../UpperFirst';
|
|
4
|
+
import CategoryName from './CategoryName';
|
|
5
|
+
|
|
6
|
+
const Category = ({ categoryName }) => (
|
|
7
|
+
<CategoryName>
|
|
8
|
+
<UpperFirst content={categoryName} />
|
|
9
|
+
</CategoryName>
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
Category.defaultProps = {
|
|
13
|
+
categoryName: '',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
Category.propTypes = {
|
|
17
|
+
categoryName: PropTypes.string,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default Category;
|