@base-ui-components/react
Version:
Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.
29 lines (28 loc) • 1.59 kB
JavaScript
;
'use client';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useCustomStyleHookMapping = useCustomStyleHookMapping;
var React = _interopRequireWildcard(require("react"));
var _CheckboxRootDataAttributes = require("../root/CheckboxRootDataAttributes");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function useCustomStyleHookMapping(state) {
return React.useMemo(() => ({
checked(value) {
if (state.indeterminate) {
// `data-indeterminate` is already handled by the `indeterminate` prop.
return {};
}
if (value) {
return {
[_CheckboxRootDataAttributes.CheckboxRootDataAttributes.checked]: ''
};
}
return {
[_CheckboxRootDataAttributes.CheckboxRootDataAttributes.unchecked]: ''
};
}
}), [state.indeterminate]);
}