// Global whitelist props for all LUI components const whitelist = ['id', 'data-component', 'data-testid', 'data-tracking-event'] as const; export type Whitelist = typeof whitelist[any]; export type GlobalProps = Partial>; // Global props should always apply to the outermost component export const filterGlobalProps = (props: { [key: string]: any }): GlobalProps => { return Object.keys(props) .filter((propKey) => whitelist.includes(propKey as Whitelist)) .reduce((obj: GlobalProps, propKey: string) => { obj[propKey as Whitelist] = props[propKey]; return obj; }, {}); };