From cda2e0eab1e2425312de19ecf1bc3c4e2be5e6fb Mon Sep 17 00:00:00 2001 From: soupette Date: Wed, 27 Nov 2019 11:34:11 +0100 Subject: [PATCH] Created WrapperSelect --- .../src/components/ComponentSelect/index.js | 145 ++++++------------ .../src/components/CreatableSelect/index.js | 47 +----- .../src/components/WrapperSelect/index.js | 60 ++++++++ .../admin/src/containers/FormModal/index.js | 8 +- 4 files changed, 118 insertions(+), 142 deletions(-) create mode 100644 packages/strapi-plugin-content-type-builder/admin/src/components/WrapperSelect/index.js 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 index 966396e8af..db2a090ae6 100644 --- 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 @@ -1,140 +1,87 @@ 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, +// const SingleValue = ({ children, ...props }) => { +// console.log({ propss: props }); +// return
{children}
; +// }; - border: '1px solid #78caff !important', - borderColor: '#78caff !important', - borderTopColor: '#E3E9F3 !important', - }; - }, +const ComponentSelect = ({ onChange, name, value, styles }) => { + const { componentsGroupedByCategory } = useDataManager(); + + const handleChange = (inputValue, actionMeta) => { + const { action } = actionMeta; + + if (action === 'clear') { + onChange({ target: { name, value: '' } }); + } }; + const Menu = props => { console.log({ props }); return ( -
-