Skip to content

Commit 4562801

Browse files
react-tags: rename dismissable to dismissible (#27798)
* rename * fix * api
1 parent fd626b3 commit 4562801

15 files changed

+60
-67
lines changed

packages/react-components/react-tags/etc/react-tags.api.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ export const tagClassNames: SlotClassNames<TagSlots>;
4444

4545
// @public
4646
export type TagProps = ComponentProps<Partial<TagSlots>> & {
47-
size?: 'extra-small' | 'small' | 'medium';
48-
shape?: 'rounded' | 'circular';
4947
appearance?: 'filled-darker' | 'filled-lighter' | 'tint' | 'outline';
5048
disabled?: boolean;
51-
checked?: boolean;
52-
dismissable?: boolean;
49+
dismissible?: boolean;
50+
shape?: 'rounded' | 'circular';
51+
size?: 'extra-small' | 'small' | 'medium';
5352
};
5453

5554
// @public (undocumented)
@@ -64,7 +63,7 @@ export type TagSlots = {
6463
};
6564

6665
// @public
67-
export type TagState = ComponentState<TagSlots> & Required<Pick<TagProps, 'appearance' | 'checked' | 'disabled' | 'dismissable' | 'shape' | 'size'> & {
66+
export type TagState = ComponentState<TagSlots> & Required<Pick<TagProps, 'appearance' | 'disabled' | 'dismissible' | 'shape' | 'size'> & {
6867
avatarSize: AvatarSize | undefined;
6968
avatarShape: AvatarShape | undefined;
7069
}>;

packages/react-components/react-tags/src/components/Tag/Tag.test.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { Tag } from './Tag';
22
import { isConformant } from '../../testing/isConformant';
3+
import { TagProps } from './Tag.types';
34

4-
const requiredProps = {
5-
media: 'media',
5+
const requiredProps: TagProps = {
6+
dismissible: true,
67
icon: 'i',
8+
media: 'media',
79
primaryText: 'Primary text',
810
secondaryText: 'Secondary text',
9-
dismissable: true,
1011
};
1112

1213
describe('Tag', () => {

packages/react-components/react-tags/src/components/Tag/Tag.types.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,21 @@ export type TagSlots = {
4040
* Tag Props
4141
*/
4242
export type TagProps = ComponentProps<Partial<TagSlots>> & {
43-
size?: 'extra-small' | 'small' | 'medium';
44-
shape?: 'rounded' | 'circular';
4543
appearance?: 'filled-darker' | 'filled-lighter' | 'tint' | 'outline';
44+
// TODO implement tag checked state
45+
// checked?: boolean;
4646
disabled?: boolean;
47-
checked?: boolean;
48-
dismissable?: boolean;
47+
dismissible?: boolean;
48+
shape?: 'rounded' | 'circular';
49+
size?: 'extra-small' | 'small' | 'medium';
4950
};
5051

5152
/**
5253
* State used in rendering Tag
5354
*/
5455
export type TagState = ComponentState<TagSlots> &
5556
Required<
56-
Pick<TagProps, 'appearance' | 'checked' | 'disabled' | 'dismissable' | 'shape' | 'size'> & {
57+
Pick<TagProps, 'appearance' | 'disabled' | 'dismissible' | 'shape' | 'size'> & {
5758
avatarSize: AvatarSize | undefined;
5859
avatarShape: AvatarShape | undefined;
5960
}

packages/react-components/react-tags/src/components/Tag/renderTag.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const renderTag_unstable = (state: TagState, contextValues: TagContextVal
2929
{slots.secondaryText && <slots.secondaryText {...slotProps.secondaryText} />}
3030
</slots.content>
3131
)}
32-
{slots.dismissButton && state.dismissable && <slots.dismissButton {...slotProps.dismissButton} />}
32+
{slots.dismissButton && state.dismissible && <slots.dismissButton {...slotProps.dismissButton} />}
3333
</slots.root>
3434
);
3535
};

packages/react-components/react-tags/src/components/Tag/useTag.tsx

+13-14
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,22 @@ const DismissIcon = bundleIcon(DismissFilled, DismissRegular);
2828
*/
2929
export const useTag_unstable = (props: TagProps, ref: React.Ref<HTMLElement>): TagState => {
3030
const {
31-
checked = false,
31+
appearance = 'filled-lighter',
3232
disabled = false,
33-
dismissable = false,
33+
dismissible = false,
3434
shape = 'rounded',
3535
size = 'medium',
36-
appearance = 'filled-lighter',
3736
} = props;
3837

3938
return {
39+
appearance,
40+
avatarShape: tagAvatarShapeMap[shape],
41+
avatarSize: tagAvatarSizeMap[size],
42+
disabled,
43+
dismissible,
44+
shape,
45+
size,
46+
4047
components: {
4148
root: 'div',
4249
content: 'div',
@@ -46,27 +53,19 @@ export const useTag_unstable = (props: TagProps, ref: React.Ref<HTMLElement>): T
4653
secondaryText: 'span',
4754
dismissButton: 'button',
4855
},
49-
checked,
50-
disabled,
51-
dismissable,
52-
shape,
53-
size,
54-
appearance,
56+
5557
root: getNativeElementProps('div', {
5658
ref,
5759
...props,
5860
}),
59-
avatarSize: tagAvatarSizeMap[size],
60-
avatarShape: tagAvatarShapeMap[shape],
61-
media: resolveShorthand(props.media),
6261

6362
content: resolveShorthand(props.content, { required: true }),
63+
media: resolveShorthand(props.media),
6464
icon: resolveShorthand(props.icon),
6565
primaryText: resolveShorthand(props.primaryText, { required: true }),
6666
secondaryText: resolveShorthand(props.secondaryText),
67-
6867
dismissButton: useARIAButtonShorthand(props.dismissButton, {
69-
required: props.dismissable,
68+
required: props.dismissible,
7069
defaultProps: {
7170
disabled,
7271
type: 'button',

packages/react-components/react-tags/src/components/Tag/useTagStyles.styles.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export const useTagBaseStyles = makeStyles({
113113
});
114114

115115
const useTagStyles = makeStyles({
116-
dismissableContent: {
116+
dismissibleContent: {
117117
paddingRight: '2px',
118118
},
119119
dismissButton: {
@@ -140,7 +140,7 @@ export const useTagStyles_unstable = (state: TagState): TagState => {
140140
baseStyles.content,
141141
!state.media && !state.icon && baseStyles.textOnlyContent,
142142

143-
state.dismissButton && styles.dismissableContent,
143+
state.dismissButton && styles.dismissibleContent,
144144
state.content.className,
145145
);
146146
}

packages/react-components/react-tags/src/components/TagButton/TagButton.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const requiredProps = {
66
icon: 'i',
77
primaryText: 'Primary text',
88
secondaryText: 'Secondary text',
9-
dismissable: true,
9+
dismissible: true,
1010
};
1111

1212
describe('TagButton', () => {

packages/react-components/react-tags/src/components/TagButton/renderTagButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const renderTagButton_unstable = (state: TagButtonState, contextValues: T
2929
{slots.secondaryText && <slots.secondaryText {...slotProps.secondaryText} />}
3030
</slots.content>
3131
)}
32-
{slots.dismissButton && state.dismissable && <slots.dismissButton {...slotProps.dismissButton} />}
32+
{slots.dismissButton && state.dismissible && <slots.dismissButton {...slotProps.dismissButton} />}
3333
</slots.root>
3434
);
3535
};

packages/react-components/react-tags/src/components/TagButton/useTagButtonStyles.styles.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const useStyles = makeStyles({
3333
circularContent: createCustomFocusIndicatorStyle(shorthands.borderRadius(tokens.borderRadiusCircular), {
3434
enableOutline: true,
3535
}),
36-
dismissableContent: {
36+
dismissibleContent: {
3737
...createCustomFocusIndicatorStyle({
3838
borderTopRightRadius: tokens.borderRadiusNone,
3939
borderBottomRightRadius: tokens.borderRadiusNone,
@@ -79,7 +79,7 @@ export const useTagButtonStyles_unstable = (state: TagButtonState): TagButtonSta
7979

8080
styles.content,
8181
state.shape === 'circular' && styles.circularContent,
82-
state.dismissButton && styles.dismissableContent,
82+
state.dismissButton && styles.dismissibleContent,
8383

8484
state.content.className,
8585
);

packages/react-components/react-tags/stories/Tag/TagDefault.stories.tsx

+8-15
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const Default = (props: Partial<TagProps>) => (
2020
/>
2121
}
2222
secondaryText="Secondary text"
23-
dismissable={true}
23+
dismissible
2424
{...props}
2525
>
2626
Primary text
@@ -37,7 +37,7 @@ export const Default = (props: Partial<TagProps>) => (
3737
}}
3838
/>
3939
}
40-
dismissable={true}
40+
dismissible
4141
{...props}
4242
>
4343
Primary text
@@ -58,10 +58,10 @@ export const Default = (props: Partial<TagProps>) => (
5858
>
5959
Primary text
6060
</Tag>
61-
<Tag icon={<Calendar3Day20Regular />} secondaryText="Secondary text" dismissable={true} {...props} {...props}>
61+
<Tag icon={<Calendar3Day20Regular />} secondaryText="Secondary text" dismissible {...props}>
6262
Primary text
6363
</Tag>
64-
<Tag icon={<Calendar3Day20Regular />} dismissable={true} {...props}>
64+
<Tag icon={<Calendar3Day20Regular />} dismissible {...props}>
6565
Primary text
6666
</Tag>
6767
<Tag icon={<Calendar3Day20Regular />} {...props}>
@@ -84,7 +84,7 @@ export const Default = (props: Partial<TagProps>) => (
8484
/>
8585
}
8686
secondaryText="Secondary text"
87-
dismissable={true}
87+
dismissible
8888
{...props}
8989
>
9090
Primary text
@@ -102,7 +102,7 @@ export const Default = (props: Partial<TagProps>) => (
102102
}}
103103
/>
104104
}
105-
dismissable={true}
105+
dismissible
106106
{...props}
107107
>
108108
Primary text
@@ -124,17 +124,10 @@ export const Default = (props: Partial<TagProps>) => (
124124
>
125125
Primary text
126126
</Tag>
127-
<Tag
128-
shape="circular"
129-
icon={<Calendar3Day20Regular />}
130-
secondaryText="Secondary text"
131-
dismissable={true}
132-
{...props}
133-
{...props}
134-
>
127+
<Tag shape="circular" icon={<Calendar3Day20Regular />} secondaryText="Secondary text" dismissible {...props}>
135128
Primary text
136129
</Tag>
137-
<Tag shape="circular" icon={<Calendar3Day20Regular />} dismissable={true} {...props}>
130+
<Tag shape="circular" icon={<Calendar3Day20Regular />} dismissible {...props}>
138131
Primary text
139132
</Tag>
140133
<Tag shape="circular" icon={<Calendar3Day20Regular />} {...props}>

packages/react-components/react-tags/stories/Tag/TagDismiss.stories.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ export const Dismiss = () => {
1616
const containerStyles = useContainerStyles();
1717
return (
1818
<div className={containerStyles.root}>
19-
<Tag dismissable>Primary text</Tag>
20-
<Tag dismissable icon={<Calendar3Day20Regular />}>
19+
<Tag dismissible>Primary text</Tag>
20+
<Tag dismissible icon={<Calendar3Day20Regular />}>
2121
Primary text
2222
</Tag>
2323
<Tag
24-
dismissable
24+
dismissible
2525
media={<Avatar name="Katri Athokas" badge={{ status: 'busy' }} />}
2626
secondaryText="Secondary text"
2727
>

packages/react-components/react-tags/stories/Tag/TagShape.stories.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ export const Shape = () => {
2222
Circular
2323
</Tag>
2424

25-
<Tag dismissable icon={<Calendar3Day20Regular />} secondaryText="Secondary text">
25+
<Tag dismissible icon={<Calendar3Day20Regular />} secondaryText="Secondary text">
2626
Rounded
2727
</Tag>
28-
<Tag shape="circular" dismissable icon={<Calendar3Day20Regular />} secondaryText="Secondary text">
28+
<Tag shape="circular" dismissible icon={<Calendar3Day20Regular />} secondaryText="Secondary text">
2929
Circular
3030
</Tag>
3131
</div>

packages/react-components/react-tags/stories/TagButton/TagButtonDefault.stories.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const Default = (props: Partial<TagButtonProps>) => (
2020
/>
2121
}
2222
secondaryText="Secondary text"
23-
dismissable={true}
23+
dismissible={true}
2424
{...props}
2525
>
2626
Primary text
@@ -37,7 +37,7 @@ export const Default = (props: Partial<TagButtonProps>) => (
3737
}}
3838
/>
3939
}
40-
dismissable={true}
40+
dismissible={true}
4141
{...props}
4242
>
4343
Primary text
@@ -61,13 +61,13 @@ export const Default = (props: Partial<TagButtonProps>) => (
6161
<TagButton
6262
icon={<Calendar3Day20Regular />}
6363
secondaryText="Secondary text"
64-
dismissable={true}
64+
dismissible={true}
6565
{...props}
6666
{...props}
6767
>
6868
Primary text
6969
</TagButton>
70-
<TagButton icon={<Calendar3Day20Regular />} dismissable={true} {...props}>
70+
<TagButton icon={<Calendar3Day20Regular />} dismissible={true} {...props}>
7171
Primary text
7272
</TagButton>
7373
<TagButton icon={<Calendar3Day20Regular />} {...props}>
@@ -90,7 +90,7 @@ export const Default = (props: Partial<TagButtonProps>) => (
9090
/>
9191
}
9292
secondaryText="Secondary text"
93-
dismissable={true}
93+
dismissible={true}
9494
{...props}
9595
>
9696
Primary text
@@ -108,7 +108,7 @@ export const Default = (props: Partial<TagButtonProps>) => (
108108
}}
109109
/>
110110
}
111-
dismissable={true}
111+
dismissible={true}
112112
{...props}
113113
>
114114
Primary text
@@ -134,13 +134,13 @@ export const Default = (props: Partial<TagButtonProps>) => (
134134
shape="circular"
135135
icon={<Calendar3Day20Regular />}
136136
secondaryText="Secondary text"
137-
dismissable={true}
137+
dismissible={true}
138138
{...props}
139139
{...props}
140140
>
141141
Primary text
142142
</TagButton>
143-
<TagButton shape="circular" icon={<Calendar3Day20Regular />} dismissable={true} {...props}>
143+
<TagButton shape="circular" icon={<Calendar3Day20Regular />} dismissible={true} {...props}>
144144
Primary text
145145
</TagButton>
146146
<TagButton shape="circular" icon={<Calendar3Day20Regular />} {...props}>

packages/react-components/react-tags/stories/TagButton/TagButtonDismiss.stories.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ export const Dismiss = () => {
1616
const containerStyles = useContainerStyles();
1717
return (
1818
<div className={containerStyles.root}>
19-
<TagButton dismissable>Primary text</TagButton>
20-
<TagButton dismissable icon={<Calendar3Day20Regular />}>
19+
<TagButton dismissible>Primary text</TagButton>
20+
<TagButton dismissible icon={<Calendar3Day20Regular />}>
2121
Primary text
2222
</TagButton>
2323
<TagButton
24-
dismissable
24+
dismissible
2525
media={<Avatar name="Katri Athokas" badge={{ status: 'busy' }} />}
2626
secondaryText="Secondary text"
2727
>

packages/react-components/react-tags/stories/TagButton/TagButtonShape.stories.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ export const Shape = () => {
2222
Circular
2323
</TagButton>
2424

25-
<TagButton dismissable icon={<Calendar3Day20Regular />} secondaryText="Secondary text">
25+
<TagButton dismissible icon={<Calendar3Day20Regular />} secondaryText="Secondary text">
2626
Rounded
2727
</TagButton>
28-
<TagButton shape="circular" dismissable icon={<Calendar3Day20Regular />} secondaryText="Secondary text">
28+
<TagButton shape="circular" dismissible icon={<Calendar3Day20Regular />} secondaryText="Secondary text">
2929
Circular
3030
</TagButton>
3131
</div>

0 commit comments

Comments
 (0)