UNPKG

lucid-ui

Version:

A UI component library from Xandr.

106 lines 5.99 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.RadioButtonLabeled = void 0; var lodash_1 = __importDefault(require("lodash")); var react_1 = __importDefault(require("react")); var prop_types_1 = __importDefault(require("prop-types")); var style_helpers_1 = require("../../util/style-helpers"); var component_types_1 = require("../../util/component-types"); var RadioButton_1 = __importStar(require("../RadioButton/RadioButton")); var cx = style_helpers_1.lucidClassNames.bind('&-RadioButtonLabeled'); var any = prop_types_1.default.any, object = prop_types_1.default.object, string = prop_types_1.default.string; var RadioButtonLabeledLabel = function (_props) { return null; }; RadioButtonLabeledLabel.displayName = 'RadioButtonLabeled.Label'; RadioButtonLabeledLabel.peek = { description: "Used to identify the purpose of this radio button to the user -- can be any renderable content.", }; RadioButtonLabeledLabel.propName = 'Label'; /** TODO: Remove nonPassThroughs when the component is converted to a functional component */ var nonPassThroughs = ['className', 'style', 'Label']; var RadioButtonLabeled = function (props) { var className = props.className, isDisabled = props.isDisabled, isSelected = props.isSelected, onSelect = props.onSelect, style = props.style, passThroughs = __rest(props, ["className", "isDisabled", "isSelected", "onSelect", "style"]); var labelChildProps = lodash_1.default.first(lodash_1.default.map((0, component_types_1.findTypes)(props, exports.RadioButtonLabeled.Label), 'props')); return (react_1.default.createElement("label", { className: cx('&', { '&-is-disabled': isDisabled, '&-is-selected': isSelected, }, className), style: style }, react_1.default.createElement(RadioButton_1.default, __assign({ className: className, isDisabled: isDisabled, isSelected: isSelected, onSelect: onSelect }, lodash_1.default.omit(passThroughs, nonPassThroughs))), react_1.default.createElement("div", __assign({}, labelChildProps, { className: cx('&-label') })))); }; exports.RadioButtonLabeled = RadioButtonLabeled; exports.RadioButtonLabeled.displayName = 'RadioButtonLabeled'; exports.RadioButtonLabeled.defaultProps = RadioButton_1.defaultProps; exports.RadioButtonLabeled.peek = { description: "A composite of the `RadioButton` component and the native `label` element.", notes: { overview: "\n\t\t\tA round two-state toggle with a label that explains the action or selection. This is a composite of `RadioButton` and the native\n\t\t\t`label` element.\t\t", intendedUse: "\n\t\t\t- Use radio button to allow users to select one item. Commonly used to select filters or settings. For interactions where users can select mutiple options, use `CheckboxLabeled`. \n\t\t\t- Use radio buttons for 2-3 options where you want to expose all options.\n\t\t\t- Use `SingleSelect` for 3-10 options where it is not a priority to expose all options.\n\t\t\t- Use `RadioButtonLabeled` for vertical lists of options. Use `RadioGroup` for horizontal lists of options.\n\t\t", technicalRecommendations: "\n\t\t\t- Use the styles on the parent container of `RadioButtonLabeled` to ensure only the radio buttons and their labels are clickable.\n\t\t\t- Any props that are not explicitly defined in `propTypes` are passed to the native radio button control.\n\t\t\t", }, categories: ['controls', 'toggles'], extend: 'RadioButton', madeFrom: ['RadioButton'], }; exports.RadioButtonLabeled.propTypes = __assign(__assign({}, RadioButton_1.default.propTypes), { /** Appended to the component-specific class names set on the root element. */ className: string, /** Passed through to the root element. */ style: object, /** Child element whose children are used to identify the purpose of this radio button to the user. */ Label: any }); exports.RadioButtonLabeled.Label = RadioButtonLabeledLabel; exports.default = exports.RadioButtonLabeled; //# sourceMappingURL=RadioButtonLabeled.js.map