2024-05-27 13:19:11 -04:00
|
|
|
import { HTMLAttributes, ReactNode, RefAttributes, FC } from 'react';
|
2022-10-24 20:33:40 -04:00
|
|
|
|
2024-05-12 15:45:26 -04:00
|
|
|
import { Export, findModuleExport } from '../webpack';
|
2022-10-24 20:33:40 -04:00
|
|
|
import { FooterLegendProps } from './FooterLegend';
|
2024-06-26 22:28:58 -04:00
|
|
|
import { createPropListRegex } from '../utils';
|
2022-06-08 21:40:19 -04:00
|
|
|
|
2022-08-26 01:12:21 -04:00
|
|
|
export interface FocusableProps extends HTMLAttributes<HTMLDivElement>, FooterLegendProps {
|
2022-06-10 16:56:39 -04:00
|
|
|
children: ReactNode;
|
2022-10-24 20:33:40 -04:00
|
|
|
'flow-children'?: string;
|
2022-06-10 16:56:39 -04:00
|
|
|
focusClassName?: string;
|
|
|
|
|
focusWithinClassName?: string;
|
2022-12-11 22:18:07 +08:00
|
|
|
noFocusRing?: boolean;
|
2022-06-16 17:26:31 -04:00
|
|
|
onActivate?: (e: CustomEvent) => void;
|
|
|
|
|
onCancel?: (e: CustomEvent) => void;
|
2022-06-08 21:40:19 -04:00
|
|
|
}
|
|
|
|
|
|
2024-06-26 22:28:58 -04:00
|
|
|
const focusableRegex = createPropListRegex(["flow-children", "onActivate", "onCancel", "focusClassName", "focusWithinClassName"]);
|
|
|
|
|
|
2024-05-12 15:48:13 -04:00
|
|
|
export const Focusable = findModuleExport((e: Export) =>
|
2024-06-26 22:28:58 -04:00
|
|
|
e?.render?.toString && focusableRegex.test(e.render.toString())
|
2024-05-27 13:19:11 -04:00
|
|
|
) as FC<FocusableProps & RefAttributes<HTMLDivElement>>;
|