UNPKG

@drivy/cobalt

Version:

Opinionated design system for Drivy's projects.

57 lines (56 loc) 2.18 kB
import { jsx, jsxs } from "react/jsx-runtime"; import classnames from "classnames"; import { withFieldLabelAndHint } from "./field.js"; import { Hint } from "./Hint.js"; const Checkmark = ({ label, status, hint, ...inputProps })=>/*#__PURE__*/ jsxs("div", { className: classnames("cobalt-CheckmarkField", { "cobalt-CheckmarkField--success": "success" === status, "cobalt-CheckmarkField--error": "error" === status }), children: [ /*#__PURE__*/ jsxs("label", { className: "cobalt-CheckmarkField__LabelWrapper", children: [ /*#__PURE__*/ jsx("input", { ...inputProps, className: "cobalt-CheckmarkField__Input" }), /*#__PURE__*/ jsx("span", { className: "cobalt-CheckmarkField__Checkmark" }), /*#__PURE__*/ jsx("span", { className: "cobalt-CheckmarkField__Label", children: label }) ] }), hint && /*#__PURE__*/ jsx(Hint, { status: status, children: /*#__PURE__*/ jsx("span", { dangerouslySetInnerHTML: { __html: hint } }) }) ] }); const Checkbox = ({ label, ...props })=>/*#__PURE__*/ jsx(Checkmark, { ...props, label: label, type: "checkbox" }); Checkbox.displayName = "CobaltCheckbox"; const Radio = ({ label, ...props })=>/*#__PURE__*/ jsx(Checkmark, { ...props, label: label, type: "radio" }); Radio.displayName = "CobaltRadio"; const ChoiceList = ({ children })=>/*#__PURE__*/ jsx("div", { className: "cobalt-ChoiceList", children: "function" == typeof children ? children() : children }); const wrappedChoiceList = withFieldLabelAndHint(ChoiceList); wrappedChoiceList.displayName = "ChoiceList"; export { Checkbox, Radio, wrappedChoiceList as ChoiceList }; //# sourceMappingURL=Checkmark.js.map