UNPKG

@react-md/form

Version:

This package is for creating all the different form input types.

35 lines 2.77 kB
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 __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; }; import { jsx as _jsx } from "react/jsx-runtime"; import { forwardRef } from "react"; import cn from "classnames"; import { TextIconSpacing } from "@react-md/icon"; import { Label } from "../label/Label"; import { ToggleContainer } from "./ToggleContainer"; import { SwitchTrack } from "./SwitchTrack"; export var Switch = forwardRef(function Switch(_a, ref) { var style = _a.style, className = _a.className, ballStyle = _a.ballStyle, ballClassName = _a.ballClassName, trackStyle = _a.trackStyle, trackClassName = _a.trackClassName, label = _a.label, labelStyle = _a.labelStyle, labelClassName = _a.labelClassName, labelDisabled = _a.labelDisabled, _b = _a.error, error = _b === void 0 ? false : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.stacked, stacked = _d === void 0 ? false : _d, _e = _a.inline, inline = _e === void 0 ? false : _e, _f = _a.iconAfter, iconAfter = _f === void 0 ? false : _f, children = _a.children, props = __rest(_a, ["style", "className", "ballStyle", "ballClassName", "trackStyle", "trackClassName", "label", "labelStyle", "labelClassName", "labelDisabled", "error", "disabled", "stacked", "inline", "iconAfter", "children"]); var id = props.id; return (_jsx(ToggleContainer, __assign({ style: style, className: cn("rmd-switch-container", className), inline: inline, stacked: stacked }, { children: _jsx(TextIconSpacing, __assign({ icon: _jsx(Label, __assign({ style: labelStyle, className: labelClassName, htmlFor: id, error: error, disabled: labelDisabled !== null && labelDisabled !== void 0 ? labelDisabled : disabled }, { children: label })), iconAfter: !iconAfter }, { children: _jsx(SwitchTrack, __assign({}, props, { ref: ref, style: trackStyle, className: trackClassName, disabled: disabled, ballStyle: ballStyle, ballClassName: ballClassName }, { children: children })) })) }))); }); //# sourceMappingURL=Switch.js.map