@braineet/ui
Version:
Braineet design system
37 lines • 1.78 kB
JavaScript
var _excluded = ["name", "colors"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
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;