Skip to content

Commit ecfe5c0

Browse files
committed
[Chip, ChipDelete, LinearProgress, CircularProgress] Ensure API doc of component prop is generated + improve code
1 parent 307231c commit ecfe5c0

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

packages/mui-joy/src/Chip/Chip.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,9 @@ const Chip = React.forwardRef(function Chip(inProps, ref) {
201201
const {
202202
children,
203203
className,
204-
componentsProps = {},
205204
color = 'primary',
205+
component = 'div',
206+
componentsProps = {},
206207
onClick,
207208
disabled = false,
208209
size = 'md',
@@ -218,6 +219,7 @@ const Chip = React.forwardRef(function Chip(inProps, ref) {
218219
disabled,
219220
size,
220221
color,
222+
component,
221223
variant,
222224
clickable,
223225
focusVisible: false,
@@ -237,19 +239,20 @@ const Chip = React.forwardRef(function Chip(inProps, ref) {
237239
ownerState.focusVisible = focusVisible;
238240

239241
const classes = useUtilityClasses(ownerState);
242+
const externalForwardedProps = { ...other, component, componentsProps };
240243

241244
const [SlotRoot, rootProps] = useSlot('root', {
242245
ref,
243246
className: clsx(classes.root, className),
244247
elementType: ChipRoot,
245-
externalForwardedProps: { ...other, componentsProps },
248+
externalForwardedProps,
246249
ownerState,
247250
});
248251

249252
const [SlotLabel, labelProps] = useSlot('label', {
250253
className: classes.label,
251254
elementType: ChipLabel,
252-
externalForwardedProps: { ...other, componentsProps },
255+
externalForwardedProps,
253256
ownerState,
254257
});
255258

@@ -259,7 +262,7 @@ const Chip = React.forwardRef(function Chip(inProps, ref) {
259262
const [SlotAction, actionProps] = useSlot('action', {
260263
className: classes.action,
261264
elementType: ChipAction,
262-
externalForwardedProps: { ...other, componentsProps },
265+
externalForwardedProps,
263266
ownerState,
264267
getSlotProps: getRootProps,
265268
additionalProps: {
@@ -272,7 +275,7 @@ const Chip = React.forwardRef(function Chip(inProps, ref) {
272275
const [SlotStartDecorator, startDecoratorProps] = useSlot('startDecorator', {
273276
className: classes.startDecorator,
274277
elementType: ChipStartDecorator,
275-
externalForwardedProps: { ...other, componentsProps },
278+
externalForwardedProps,
276279
ownerState,
277280
});
278281

@@ -328,6 +331,11 @@ Chip.propTypes /* remove-proptypes */ = {
328331
PropTypes.oneOf(['danger', 'info', 'neutral', 'primary', 'success', 'warning']),
329332
PropTypes.string,
330333
]),
334+
/**
335+
* The component used for the root node.
336+
* Either a string to use a HTML element or a component.
337+
*/
338+
component: PropTypes.elementType,
331339
/**
332340
* Replace the default slots.
333341
*/

packages/mui-joy/src/ChipDelete/ChipDelete.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ const ChipDelete = React.forwardRef(function ChipDelete(inProps, ref) {
7070
});
7171

7272
const {
73-
component,
7473
children,
74+
component = 'button',
7575
variant: variantProp,
7676
color: colorProp,
7777
disabled: disabledProp,
@@ -93,6 +93,7 @@ const ChipDelete = React.forwardRef(function ChipDelete(inProps, ref) {
9393

9494
const ownerState = {
9595
...props,
96+
component,
9697
disabled,
9798
variant,
9899
color,

packages/mui-joy/src/CircularProgress/CircularProgress.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ const CircularProgress = React.forwardRef(function CircularProgress(inProps, ref
207207
children,
208208
className,
209209
color = 'primary',
210+
component = 'span',
210211
size = 'md',
211212
variant = 'soft',
212213
thickness,
@@ -218,6 +219,7 @@ const CircularProgress = React.forwardRef(function CircularProgress(inProps, ref
218219
const ownerState = {
219220
...props,
220221
color,
222+
component,
221223
size,
222224
variant,
223225
thickness,
@@ -227,12 +229,13 @@ const CircularProgress = React.forwardRef(function CircularProgress(inProps, ref
227229
};
228230

229231
const classes = useUtilityClasses(ownerState);
232+
const externalForwardedProps = { ...other, component };
230233

231234
const [SlotRoot, rootProps] = useSlot('root', {
232235
ref,
233236
className: clsx(classes.root, className),
234237
elementType: CircularProgressRoot,
235-
externalForwardedProps: other,
238+
externalForwardedProps,
236239
ownerState,
237240
additionalProps: {
238241
role: 'progressbar',
@@ -253,21 +256,21 @@ const CircularProgress = React.forwardRef(function CircularProgress(inProps, ref
253256
const [SlotSvg, svgProps] = useSlot('svg', {
254257
className: classes.svg,
255258
elementType: CircularProgressSvg,
256-
externalForwardedProps: other,
259+
externalForwardedProps,
257260
ownerState,
258261
});
259262

260263
const [SlotTrack, trackProps] = useSlot('track', {
261264
className: classes.track,
262265
elementType: CircularProgressTrack,
263-
externalForwardedProps: other,
266+
externalForwardedProps,
264267
ownerState,
265268
});
266269

267270
const [SlotProgress, progressProps] = useSlot('progress', {
268271
className: classes.progress,
269272
elementType: CircularProgressProgress,
270-
externalForwardedProps: other,
273+
externalForwardedProps,
271274
ownerState,
272275
});
273276

@@ -303,6 +306,11 @@ CircularProgress.propTypes /* remove-proptypes */ = {
303306
PropTypes.oneOf(['danger', 'info', 'neutral', 'primary', 'success', 'warning']),
304307
PropTypes.string,
305308
]),
309+
/**
310+
* The component used for the root node.
311+
* Either a string to use a HTML element or a component.
312+
*/
313+
component: PropTypes.elementType,
306314
/**
307315
* Replace the default slots.
308316
*/

packages/mui-joy/src/LinearProgress/LinearProgress.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ const LinearProgress = React.forwardRef(function LinearProgress(inProps, ref) {
145145
});
146146

147147
const {
148-
component,
149148
children,
150149
className,
151150
color = 'primary',
151+
component = 'span',
152152
size = 'md',
153153
variant = 'soft',
154154
thickness,
@@ -160,6 +160,7 @@ const LinearProgress = React.forwardRef(function LinearProgress(inProps, ref) {
160160
const ownerState = {
161161
...props,
162162
color,
163+
component,
163164
size,
164165
variant,
165166
thickness,

0 commit comments

Comments
 (0)