@ariakit/react-core
Version:
Ariakit React core
67 lines (56 loc) • 1.84 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true});
var _IRJEBRAWcjs = require('./IRJEBRAW.cjs');
var _WBFXWJUHcjs = require('./WBFXWJUH.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 = _WBFXWJUHcjs.createHook.call(void 0,
function useCheckboxCheck2({ store, checked, ...props }) {
const context = _react.useContext.call(void 0, _IRJEBRAWcjs.CheckboxCheckedContext);
checked = checked != null ? checked : context;
const children = getChildren({ checked, children: props.children });
props = {
"aria-hidden": true,
...props,
children,
style: {
width: "1em",
height: "1em",
pointerEvents: "none",
...props.style
}
};
return _misc.removeUndefinedValues.call(void 0, props);
}
);
var CheckboxCheck = _WBFXWJUHcjs.forwardRef.call(void 0, function CheckboxCheck2(props) {
const htmlProps = useCheckboxCheck(props);
return _WBFXWJUHcjs.createElement.call(void 0, TagName, htmlProps);
});
exports.useCheckboxCheck = useCheckboxCheck; exports.CheckboxCheck = CheckboxCheck;