UNPKG

@mui/x-data-grid

Version:

The Community plan edition of the Data Grid components (MUI X).

33 lines (32 loc) 1.04 kB
"use strict"; var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default; Object.defineProperty(exports, "__esModule", { value: true }); exports.useProps = useProps; var React = _interopRequireWildcard(require("react")); /** Gathers props for the root element into a single `.forwardedProps` field */ function groupForwardedProps(props) { if (props.slotProps?.root) { return props; } const keys = Object.keys(props); if (!keys.some(key => key.startsWith('aria-') || key.startsWith('data-'))) { return props; } const newProps = {}; const forwardedProps = props.forwardedProps ?? {}; for (let i = 0; i < keys.length; i += 1) { const key = keys[i]; if (key.startsWith('aria-') || key.startsWith('data-')) { forwardedProps[key] = props[key]; } else { newProps[key] = props[key]; } } newProps.forwardedProps = forwardedProps; return newProps; } function useProps(allProps) { return React.useMemo(() => groupForwardedProps(allProps), [allProps]); }