@momentum-ui/react-collaboration
Version:
Cisco Momentum UI Framework for React Collaboration Applications
46 lines • 2.46 kB
JavaScript
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);
};
import React from 'react';
import classnames from 'classnames';
import { v4 as uuidV4 } from 'uuid';
import { useRadioGroup } from '@react-aria/radio';
import { useRadioGroupState } from '@react-stately/radio';
import { STYLE } from './RadioSimpleGroup.constants';
import './RadioSimpleGroup.style.scss';
import { useSpatialRadioGroupNavigation } from '../SpatialNavigationProvider/SpatialNavigationProvider.utils';
/**
* The RadioSimpleGroup component.
* @deprecated Use the equivalent from momentum.design (NPM: `@momentum-design/components/dist/react`)
*/
export var RadioSimpleGroupContext = React.createContext(null);
/**
* @deprecated Use the equivalent from momentum.design (NPM: `@momentum-design/components/dist/react`)
*/
var RadioSimpleGroup = function (props) {
var className = props.className, description = props.description, id = props.id, label = props.label, children = props.children, style = props.style;
var state = useRadioGroupState(props);
var _a = useRadioGroup(props, state), radioGroupProps = _a.radioGroupProps, labelProps = _a.labelProps;
var radioSimpleGroupId = id || uuidV4();
var descriptionId = description
? "radio-simple-group-description-".concat(radioSimpleGroupId)
: undefined;
var spatialKeyDown = useSpatialRadioGroupNavigation(radioGroupProps.onKeyDown);
return (
// keyboard event handling required for spatial navigation
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
React.createElement("div", __assign({}, radioGroupProps, { onKeyDown: spatialKeyDown, className: classnames(className, STYLE.wrapper), "data-disabled": state.isDisabled, id: radioSimpleGroupId, style: style, "aria-describedby": descriptionId }),
label && React.createElement("span", __assign({}, labelProps), label),
description && React.createElement("span", { id: descriptionId }, description),
React.createElement(RadioSimpleGroupContext.Provider, { value: state }, children)));
};
export default RadioSimpleGroup;
//# sourceMappingURL=RadioSimpleGroup.js.map