Skip to content

Commit

Permalink
fix: allow looser types for deprecated props
Browse files Browse the repository at this point in the history
  • Loading branch information
akdetrick committed Jan 31, 2025
1 parent 84f5790 commit d5eca11
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Alert/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface AlertProps {
/** Variant of Alert to use */
kind?: "info" | "error" | "success" | "warn";
/** Override the default icon of the alert */
icon?: IconName | null;
icon?: IconName | string | null;
/** Message content of the Alert */
children?: React.ReactNode | string;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import type { IconName } from "../types/Icon.types";

interface ButtonProps {
/** Renders the button label */
label: string;
label?: string; // must be optional until `children` is removed
/** style of button to render */
kind?: "primary" | "secondary" | "tonal" | "negative" | "menu" | "plain";
/** Click callback, with event object passed as argument */
onClick?: (e: React.MouseEvent) => void;
onClick?: (e) => void;
/**
* The html element to render as the root node of `Button`.
*
Expand Down
7 changes: 4 additions & 3 deletions src/ContentCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface ContentCardProps {
* Amount of border radius to add on all sides of card.
*/
radiusSize?: "s" | "m" | "l";
onClick?: () => void;
onClick?: (e: React.MouseEvent | React.KeyboardEvent) => void;
/**
* Only applicable for `toggle` type.
* Renders card in visually selected state with appropriate attributes.
Expand Down Expand Up @@ -70,11 +70,12 @@ const ContentCard = ({
props.role = "button";
props.onClick = onClick;
props.tabIndex = "0";
props.onKeyUp = ({ key }) => {
props.onKeyUp = (e) => {
const { key } = e;
// space and Enter should be accepted for both
// toggle and button types
if (key === "Enter" || key === " ") {
onClick();
onClick(e);
}
};
}
Expand Down
7 changes: 4 additions & 3 deletions src/Dialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface DialogProps {
/** Scrollable contents of the Dialog */
children: React.ReactNode;
/** Heading in the top of the Dialog */
title: string;
title?: string;
/** Optional notification content to render pinned under the header */
notification?: React.ReactNode;
/** Contents of Dialog footer, typically reserved for action buttons */
Expand All @@ -42,14 +42,15 @@ export interface DialogProps {
* Callback to handle user taking an action to dismiss the modal
* (click outside, Escape key, click close button)
*/
onUserDismiss: () => void;
onUserDismiss?: () => void;
/**
* Sets a custom modal width.
* Use the full CSS value with the unit (e.g. "400px")
*/
width?: string;
/** Optional value for `data-testid` attribute */
testId?: string;
id?: string;
}

/**
Expand All @@ -61,7 +62,7 @@ export interface DialogProps {
const Dialog = ({
isOpen = false,
onUserDismiss = noop,
title,
title = "",
headerStyle = "bordered",
children,
notification,
Expand Down
10 changes: 2 additions & 8 deletions src/RadioButtons/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@ import React, { useState, useEffect } from "react";
import cc from "classcat";
import Error from "../Error";

type OptionType =
| {
value: string;
details?: string;
}
| string;

interface RadioButtonsProps {
/** Map of label strings to input values
*
* TODO: restore this type when we can do it in a non-breaking way
* ```
* type OptionType = {
* value: string;
Expand All @@ -20,7 +14,7 @@ interface RadioButtonsProps {
* | string;
* ```
* */
options: Record<string, OptionType>;
options?: object;
/** name of radiogroup */
name: string;
/** initially selected option by input value (uncontrolled) */
Expand Down

0 comments on commit d5eca11

Please sign in to comment.