@bigbinary/neetoui
Version:
neetoUI drives the experience at all neeto products
90 lines (87 loc) • 3.93 kB
JavaScript
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import { forwardRef } from 'react';
import classnames from 'classnames';
import { u as useId } from './useId-Jj9hXm-g.js';
import '@babel/runtime/helpers/slicedToArray';
import 'react-router-dom';
import '@bigbinary/neeto-hotkeys';
import './overlayManager.js';
import { h as hyphenize } from './index-DzZtLRHp.js';
import 'qs';
import Label from './Label.js';
import { jsxs, jsx } from 'react/jsx-runtime';
import '@babel/runtime/helpers/classCallCheck';
import '@babel/runtime/helpers/createClass';
import '@bigbinary/neeto-cist';
import 'ramda';
import './en-DVlE9xuu.js';
import './index-DyUNP5G9.js';
import '@babel/runtime/helpers/toConsumableArray';
import 'dayjs';
import 'dayjs/plugin/localeData';
import 'dayjs/plugin/utc';
import 'dayjs/plugin/weekday';
import 'dayjs/plugin/weekOfYear';
import 'i18next';
import '@bigbinary/neeto-icons/Help';
import './Button.js';
import './Spinner.js';
import './Tooltip.js';
import '@tippyjs/react';
import 'tippy.js';
import './usePrefersReducedMotion-n4ZJtExQ.js';
import './Popover.js';
import './Typography.js';
var _excluded = ["label", "error", "className", "required", "labelProps", "children"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var Checkbox = /*#__PURE__*/forwardRef(function (_ref, ref) {
var _ref$label = _ref.label,
label = _ref$label === void 0 ? "" : _ref$label,
_ref$error = _ref.error,
error = _ref$error === void 0 ? "" : _ref$error,
_ref$className = _ref.className,
className = _ref$className === void 0 ? "" : _ref$className,
_ref$required = _ref.required,
required = _ref$required === void 0 ? false : _ref$required,
labelProps = _ref.labelProps,
children = _ref.children,
otherProps = _objectWithoutProperties(_ref, _excluded);
var id = useId(otherProps.id);
var errorId = "error_".concat(id);
var renderLabel = label || children;
return /*#__PURE__*/jsxs("div", {
className: classnames(["neeto-ui-checkbox__wrapper", className]),
children: [/*#__PURE__*/jsxs("div", {
className: "neeto-ui-checkbox__container",
"data-testid": "nui-checkbox-container",
children: [/*#__PURE__*/jsx("input", _objectSpread({
id: id,
ref: ref,
required: required,
"aria-describedby": error ? errorId : undefined,
"aria-invalid": !!error,
"aria-required": required,
className: "neeto-ui-checkbox",
"data-testid": "".concat(hyphenize(renderLabel), "-checkbox-input"),
name: id,
type: "checkbox"
}, otherProps)), renderLabel && /*#__PURE__*/jsx(Label, _objectSpread(_objectSpread({
required: required,
"data-testid": "".concat(hyphenize(renderLabel), "-checkbox-label"),
htmlFor: id
}, labelProps), {}, {
children: renderLabel
}))]
}), !!error && /*#__PURE__*/jsx("p", {
className: "neeto-ui-input__error",
"data-testid": "".concat(hyphenize(renderLabel), "-checkbox-error"),
id: errorId,
children: error
})]
});
});
Checkbox.displayName = "Checkbox";
export { Checkbox as default };
//# sourceMappingURL=Checkbox.js.map