Skip to content

Commit

Permalink
chore: Expose component configuration in DOM metadata property (#1391)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorlanigan authored Aug 2, 2023
1 parent 392b450 commit 232149b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const Button = React.forwardRef(
}: ButtonProps,
ref: React.Ref<ButtonProps.Ref>
) => {
const baseComponentProps = useBaseComponent('Button');
const baseComponentProps = useBaseComponent('Button', { variant, disabled, loading });
const baseProps = getBaseProps(props);
return (
<InternalButton
Expand Down
4 changes: 2 additions & 2 deletions src/internal/hooks/use-base-component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export interface InternalBaseComponentProps {
* attached to the (internal) component's root DOM node. The hook takes care of attaching the metadata to this
* root DOM node and emits the telemetry for this component.
*/
export default function useBaseComponent<T = any>(componentName: string) {
export default function useBaseComponent<T = any>(componentName: string, componentConfiguration?: Record<string, any>) {
useTelemetry(componentName);
useFocusVisible();
const elementRef = useComponentMetadata<T>(componentName, PACKAGE_VERSION);
const elementRef = useComponentMetadata<T>(componentName, PACKAGE_VERSION, componentConfiguration);
return { __internalRootRef: elementRef };
}
5 changes: 4 additions & 1 deletion src/select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ const Select = React.forwardRef(
}: SelectProps,
ref: React.Ref<SelectProps.Ref>
) => {
const baseComponentProps = useBaseComponent('Select');
const baseComponentProps = useBaseComponent('Select', {
placeholder: restProps.placeholder,
disabled: restProps.disabled,
});
const externalProps = getExternalProps(restProps);
return (
<InternalSelect
Expand Down

0 comments on commit 232149b

Please sign in to comment.