UNPKG

@ariakit/react-core

Version:

Ariakit React core

72 lines (57 loc) 2.09 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _IRJEBRAWcjs = require('./IRJEBRAW.cjs'); var _WULEED4Qcjs = require('./WULEED4Q.cjs'); var _7EQBAZ46cjs = require('./7EQBAZ46.cjs'); // src/checkbox/checkbox-check.tsx var _misc = require('@ariakit/core/utils/misc'); var _react = require('react'); var _jsxruntime = require('react/jsx-runtime'); var TagName = "span"; var checkmark = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { display: "block", fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, viewBox: "0 0 16 16", height: "1em", width: "1em", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "polyline", { points: "4,8 7,12 12,4" }) } ); function getChildren(props) { if (props.checked) { return props.children || checkmark; } if (typeof props.children === "function") { return props.children; } return null; } var useCheckboxCheck = _WULEED4Qcjs.createHook.call(void 0, function useCheckboxCheck2(_a) { var _b = _a, { store, checked } = _b, props = _7EQBAZ46cjs.__objRest.call(void 0, _b, ["store", "checked"]); const context = _react.useContext.call(void 0, _IRJEBRAWcjs.CheckboxCheckedContext); checked = checked != null ? checked : context; const children = getChildren({ checked, children: props.children }); props = _7EQBAZ46cjs.__spreadProps.call(void 0, _7EQBAZ46cjs.__spreadValues.call(void 0, { "aria-hidden": true }, props), { children, style: _7EQBAZ46cjs.__spreadValues.call(void 0, { width: "1em", height: "1em", pointerEvents: "none" }, props.style) }); return _misc.removeUndefinedValues.call(void 0, props); } ); var CheckboxCheck = _WULEED4Qcjs.forwardRef.call(void 0, function CheckboxCheck2(props) { const htmlProps = useCheckboxCheck(props); return _WULEED4Qcjs.createElement.call(void 0, TagName, htmlProps); }); exports.useCheckboxCheck = useCheckboxCheck; exports.CheckboxCheck = CheckboxCheck;