diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/ComponentSelect/index.js b/packages/strapi-plugin-content-type-builder/admin/src/components/ComponentSelect/index.js new file mode 100644 index 0000000000..966396e8af --- /dev/null +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/ComponentSelect/index.js @@ -0,0 +1,140 @@ +import React from 'react'; +import Select from 'react-select'; +import PropTypes from 'prop-types'; +import { SelectWrapper, SelectNav } from 'strapi-helper-plugin'; +import { ErrorMessage } from '@buffetjs/styles'; +import useDataManager from '../../hooks/useDataManager'; + +const ComponentSelect = ({ error, label, onChange, name }) => { + const { componentsGroupedByCategory, components } = useDataManager(); + console.log({ componentsGroupedByCategory }); + const styles = { + container: base => ({ + ...base, + 'z-index': 9999, + // padding: 0, + }), + control: (base, state) => ({ + ...base, + 'z-index': 9999, + border: state.isFocused + ? '1px solid #78caff !important' + : error + ? '1px solid red !important' + : '1px solid #E3E9F3 !important', + }), + menu: base => { + return { + ...base, + + border: '1px solid #78caff !important', + borderColor: '#78caff !important', + borderTopColor: '#E3E9F3 !important', + }; + }, + }; + const Menu = props => { + console.log({ props }); + + return ( +
+ + {/* */} +
+ ); + }; + const formattedOptions = Object.keys(componentsGroupedByCategory).reduce( + (acc, current) => { + const optionValueObject = componentsGroupedByCategory[current]; + const option = { + label: current, + value: optionValueObject.map(val => val.uid), + // value: + options: optionValueObject.map(val => ({ + label: val.schema.name, + value: val.uid, + })), + }; + + acc.push(option); + return acc; + }, + [] + ); + const formattedOptions2 = Object.keys(components).reduce((acc, current) => { + const option = { + label: `${current} - ${components[current].schema.name}`, + value: current, + }; + + acc.push(option); + + return acc; + }, []); + + console.log(formattedOptions); + return ( + + +
+ +
+
+