import { default as React } from 'react'; /** * TypeScript allows hyphenated attributes on *intrinsic* elements only, so a component's props * interface has to declare these itself — no React attribute type provides them. */ type DataAttributes = { [K in `data-${string}`]?: string; }; /** * HTML pass-through props accepted on the root element of every component: the full native * attribute set for that element, plus `data-*`. * * Pass the root's element type for correctly-typed event handlers (`HtmlProps`); * the default is the loose `HTMLElement`. Where the root is not a plain container, extend the * matching React type instead and add `DataProps` for the `data-*` half — `Button` does this * with `React.ButtonHTMLAttributes`. * * `ref` is deliberately *not* here. `Ref` is invariant, so a shared `Ref` is not * assignable to the `
` it would be spread onto, and narrowing the default to `HTMLDivElement` * re-types every event handler with it — which breaks `Dropdown` and `SplitButton`, whose `onClick` * is typed for the `