UNPKG

@braineet/ui

Version:

Braineet design system

37 lines 1.61 kB
var _excluded = ["name", "colors"]; function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; } import React, { useState } from 'react'; import { nanoid } from 'nanoid'; import Box from '../box'; import Field from '../field'; import CheckboxColor from './CheckboxColor'; import { jsx as _jsx } from "react/jsx-runtime"; var SelectColor = function SelectColor(_ref) { var name = _ref.name, colors = _ref.colors, restProps = _objectWithoutPropertiesLoose(_ref, _excluded); var _useState = useState(nanoid()), uniqd = _useState[0]; return /*#__PURE__*/_jsx(Box, _extends({ display: "flex", flexWrap: "wrap" }, restProps, { children: colors.map(function (color, index) { return /*#__PURE__*/_jsx(Field, { name: name, uniqd: uniqd, component: CheckboxColor, colorValue: color, fieldStyle: { marginBottom: 8, marginRight: index + 1 < colors.length ? 8 : 0 } }, color); }) })); }; SelectColor.defaultProps = { colors: ['#FCC419', '#FF922B', '#FF6B6B', '#F06595', '#CC5DE8', '#845EF7', '#5C7CFA', '#339AF0', '#22B8CF', '#20C997', '#51CF66', '#94D82D'] }; export default SelectColor;