UNPKG

@ariakit/react

Version:

Toolkit for building accessible web apps with React

63 lines (44 loc) 2.03 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _LZ6L3ECGcjs = require('./LZ6L3ECG.cjs'); // ../ariakit-react-components/dist/group/group-label-context.js var _react = require('react'); var GroupLabelContext = _react.createContext.call(void 0, void 0); // ../ariakit-react-components/dist/group/group.js var _jsxruntime = require('react/jsx-runtime'); var TagName = "div"; var useGroup = _LZ6L3ECGcjs.createHook.call(void 0, function useGroup2(props) { const [labelId, setLabelId] = _react.useState.call(void 0, ); props = _LZ6L3ECGcjs.useWrapElement.call(void 0, props, (element) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, GroupLabelContext.Provider, { value: setLabelId, children: element }), []); props = { role: "group", "aria-labelledby": props["aria-label"] != null ? void 0 : labelId, ...props }; return _LZ6L3ECGcjs.removeUndefinedValues.call(void 0, props); }); var Group = _LZ6L3ECGcjs.forwardRef.call(void 0, function Group2(props) { return _LZ6L3ECGcjs.createElement.call(void 0, TagName, useGroup(props)); }); // ../ariakit-react-components/dist/group/group-label.js var TagName2 = "div"; var useGroupLabel = _LZ6L3ECGcjs.createHook.call(void 0, function useGroupLabel2(props) { const setLabelId = _react.useContext.call(void 0, GroupLabelContext); const id = _LZ6L3ECGcjs.useId.call(void 0, props.id); _LZ6L3ECGcjs.useSafeLayoutEffect.call(void 0, () => { setLabelId == null ? void 0 : setLabelId(id); return () => setLabelId == null ? void 0 : setLabelId(void 0); }, [setLabelId, id]); props = { "aria-hidden": true, ...props, id }; return _LZ6L3ECGcjs.removeUndefinedValues.call(void 0, props); }); var GroupLabel = _LZ6L3ECGcjs.forwardRef.call(void 0, function GroupLabel2(props) { return _LZ6L3ECGcjs.createElement.call(void 0, TagName2, useGroupLabel(props)); }); exports.useGroup = useGroup; exports.Group = Group; exports.useGroupLabel = useGroupLabel; exports.GroupLabel = GroupLabel;