UNPKG

2.56 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.ButtonGridBase = void 0;
4var tslib_1 = require("tslib");
5var React = require("react");
6var Utilities_1 = require("../../Utilities");
7var FocusZone_1 = require("../../FocusZone");
8var react_hooks_1 = require("@fluentui/react-hooks");
9var getClassNames = Utilities_1.classNamesFunction();
10exports.ButtonGridBase = React.forwardRef(function (props, forwardedRef) {
11 var id = react_hooks_1.useId(undefined, props.id);
12 var items = props.items, columnCount = props.columnCount, onRenderItem = props.onRenderItem, isSemanticRadio = props.isSemanticRadio,
13 // eslint-disable-next-line deprecation/deprecation
14 _a = props.ariaPosInSet,
15 // eslint-disable-next-line deprecation/deprecation
16 ariaPosInSet = _a === void 0 ? props.positionInSet : _a,
17 // eslint-disable-next-line deprecation/deprecation
18 _b = props.ariaSetSize,
19 // eslint-disable-next-line deprecation/deprecation
20 ariaSetSize = _b === void 0 ? props.setSize : _b, styles = props.styles, doNotContainWithinFocusZone = props.doNotContainWithinFocusZone;
21 var htmlProps = Utilities_1.getNativeProps(props, Utilities_1.htmlElementProperties,
22 // avoid applying onBlur on the table if it's being used in the FocusZone
23 doNotContainWithinFocusZone ? [] : ['onBlur']);
24 var classNames = getClassNames(styles, { theme: props.theme });
25 // Array to store the cells in the correct row index
26 var rowsOfItems = Utilities_1.toMatrix(items, columnCount);
27 var content = (React.createElement("table", tslib_1.__assign({ "aria-posinset": ariaPosInSet, "aria-setsize": ariaSetSize, id: id, role: isSemanticRadio ? 'radiogroup' : 'grid' }, htmlProps, { className: classNames.root }),
28 React.createElement("tbody", { role: isSemanticRadio ? 'presentation' : 'rowgroup' }, rowsOfItems.map(function (rows, rowIndex) {
29 return (React.createElement("tr", { role: isSemanticRadio ? 'presentation' : 'row', key: rowIndex }, rows.map(function (cell, cellIndex) {
30 return (React.createElement("td", { role: "presentation", key: cellIndex + '-cell', className: classNames.tableCell }, onRenderItem(cell, cellIndex)));
31 })));
32 }))));
33 return doNotContainWithinFocusZone ? (content) : (React.createElement(FocusZone_1.FocusZone, { elementRef: forwardedRef, isCircularNavigation: props.shouldFocusCircularNavigate, className: classNames.focusedContainer, onBlur: props.onBlur }, content));
34});
35//# sourceMappingURL=ButtonGrid.base.js.map
\No newline at end of file