Files
Vlad Durnea cffdf8af86
Some checks failed
CI/CD Pipeline / unit-tests (push) Failing after 1m16s
CI/CD Pipeline / integration-tests (push) Failing after 2m32s
CI/CD Pipeline / lint (push) Successful in 5m22s
CI/CD Pipeline / e2e-tests (push) Has been skipped
CI/CD Pipeline / build (push) Has been skipped
wip:milestone 0 fixes
2026-03-15 12:35:42 +02:00

33 lines
1.2 KiB
JavaScript

import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["components", "componentsProps"];
import * as React from 'react';
/** Gathers props for the root element into a single `.forwardedProps` field */
function groupForwardedProps(props) {
var _props$forwardedProps;
const keys = Object.keys(props);
if (!keys.some(key => key.startsWith('aria-') || key.startsWith('data-'))) {
return props;
}
const newProps = {};
const forwardedProps = (_props$forwardedProps = props.forwardedProps) != null ? _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;
}
export function useProps(allProps) {
return React.useMemo(() => {
const {
components,
componentsProps
} = allProps,
themedProps = _objectWithoutPropertiesLoose(allProps, _excluded);
return [components, componentsProps, groupForwardedProps(themedProps)];
}, [allProps]);
}