@mui/material 6.3.1 → 6.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Alert/Alert.d.ts +69 -0
- package/Alert/Alert.js +53 -21
- package/Autocomplete/Autocomplete.d.ts +1 -1
- package/Button/Button.d.ts +18 -0
- package/Button/Button.js +233 -15
- package/Button/buttonClasses.d.ts +14 -0
- package/Button/buttonClasses.js +1 -1
- package/ButtonBase/ButtonBase.d.ts +2 -0
- package/ButtonGroup/ButtonGroupButtonContext.js +2 -0
- package/ButtonGroup/ButtonGroupContext.js +2 -0
- package/CHANGELOG.md +91 -0
- package/CardHeader/CardHeader.d.ts +114 -1
- package/CardHeader/CardHeader.js +99 -32
- package/CircularProgress/CircularProgress.js +2 -2
- package/Dialog/Dialog.d.ts +85 -1
- package/Dialog/Dialog.js +91 -20
- package/Dialog/DialogContext.js +2 -0
- package/Drawer/Drawer.js +1 -1
- package/Drawer/drawerClasses.d.ts +32 -8
- package/Drawer/drawerClasses.js +1 -1
- package/FormControl/FormControl.js +9 -7
- package/FormControl/FormControlContext.js +2 -0
- package/Hidden/withWidth.js +2 -0
- package/IconButton/IconButton.d.ts +13 -0
- package/IconButton/IconButton.js +80 -7
- package/IconButton/iconButtonClasses.d.ts +6 -0
- package/IconButton/iconButtonClasses.js +1 -1
- package/LinearProgress/LinearProgress.js +4 -4
- package/LinearProgress/linearProgressClasses.d.ts +31 -9
- package/LinearProgress/linearProgressClasses.js +1 -1
- package/Link/getTextDecoration.js +3 -2
- package/RadioGroup/RadioGroupContext.js +2 -0
- package/Select/Select.js +10 -1
- package/Select/SelectInput.js +1 -1
- package/Slider/useSlider.js +5 -2
- package/Step/StepContext.js +2 -0
- package/StepLabel/StepLabel.d.ts +1 -1
- package/Stepper/StepperContext.js +2 -0
- package/Table/Tablelvl2Context.js +2 -0
- package/ToggleButtonGroup/ToggleButtonGroupButtonContext.js +2 -0
- package/ToggleButtonGroup/ToggleButtonGroupContext.js +2 -0
- package/Tooltip/Tooltip.d.ts +1 -1
- package/index.js +1 -1
- package/modern/Alert/Alert.js +53 -21
- package/modern/Button/Button.js +233 -15
- package/modern/Button/buttonClasses.js +1 -1
- package/modern/ButtonGroup/ButtonGroupButtonContext.js +2 -0
- package/modern/ButtonGroup/ButtonGroupContext.js +2 -0
- package/modern/CardHeader/CardHeader.js +99 -32
- package/modern/CircularProgress/CircularProgress.js +2 -2
- package/modern/Dialog/Dialog.js +91 -20
- package/modern/Dialog/DialogContext.js +2 -0
- package/modern/Drawer/Drawer.js +1 -1
- package/modern/Drawer/drawerClasses.js +1 -1
- package/modern/FormControl/FormControl.js +9 -7
- package/modern/FormControl/FormControlContext.js +2 -0
- package/modern/Hidden/withWidth.js +2 -0
- package/modern/IconButton/IconButton.js +80 -7
- package/modern/IconButton/iconButtonClasses.js +1 -1
- package/modern/LinearProgress/LinearProgress.js +4 -4
- package/modern/LinearProgress/linearProgressClasses.js +1 -1
- package/modern/Link/getTextDecoration.js +3 -2
- package/modern/RadioGroup/RadioGroupContext.js +2 -0
- package/modern/Select/Select.js +10 -1
- package/modern/Select/SelectInput.js +1 -1
- package/modern/Slider/useSlider.js +5 -2
- package/modern/Step/StepContext.js +2 -0
- package/modern/Stepper/StepperContext.js +2 -0
- package/modern/Table/Tablelvl2Context.js +2 -0
- package/modern/ToggleButtonGroup/ToggleButtonGroupButtonContext.js +2 -0
- package/modern/ToggleButtonGroup/ToggleButtonGroupContext.js +2 -0
- package/modern/index.js +1 -1
- package/modern/utils/index.js +1 -0
- package/modern/utils/mergeSlotProps.js +43 -0
- package/modern/utils/useSlot.js +5 -1
- package/modern/version/index.js +2 -2
- package/node/Alert/Alert.js +53 -21
- package/node/Button/Button.js +233 -15
- package/node/Button/buttonClasses.js +1 -1
- package/node/ButtonGroup/ButtonGroupButtonContext.js +1 -0
- package/node/ButtonGroup/ButtonGroupContext.js +1 -0
- package/node/CardHeader/CardHeader.js +99 -32
- package/node/CircularProgress/CircularProgress.js +2 -2
- package/node/Dialog/Dialog.js +91 -20
- package/node/Dialog/DialogContext.js +1 -0
- package/node/Drawer/Drawer.js +1 -1
- package/node/Drawer/drawerClasses.js +1 -1
- package/node/FormControl/FormControl.js +9 -7
- package/node/FormControl/FormControlContext.js +1 -0
- package/node/Hidden/withWidth.js +1 -0
- package/node/IconButton/IconButton.js +79 -6
- package/node/IconButton/iconButtonClasses.js +1 -1
- package/node/LinearProgress/LinearProgress.js +4 -4
- package/node/LinearProgress/linearProgressClasses.js +1 -1
- package/node/Link/getTextDecoration.js +3 -2
- package/node/RadioGroup/RadioGroupContext.js +1 -0
- package/node/Select/Select.js +10 -1
- package/node/Select/SelectInput.js +1 -1
- package/node/Slider/useSlider.js +5 -2
- package/node/Step/StepContext.js +1 -0
- package/node/Stepper/StepperContext.js +1 -0
- package/node/Table/Tablelvl2Context.js +1 -0
- package/node/ToggleButtonGroup/ToggleButtonGroupButtonContext.js +1 -0
- package/node/ToggleButtonGroup/ToggleButtonGroupContext.js +1 -0
- package/node/index.js +1 -1
- package/node/utils/index.js +7 -0
- package/node/utils/mergeSlotProps.js +50 -0
- package/node/utils/useSlot.js +5 -1
- package/node/version/index.js +2 -2
- package/package.json +5 -5
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/mergeSlotProps.d.ts +2 -0
- package/utils/mergeSlotProps.js +43 -0
- package/utils/useSlot.d.ts +8 -0
- package/utils/useSlot.js +5 -1
- package/version/index.js +2 -2
package/node/Button/Button.js
CHANGED
|
@@ -13,11 +13,13 @@ var _clsx = _interopRequireDefault(require("clsx"));
|
|
|
13
13
|
var _resolveProps = _interopRequireDefault(require("@mui/utils/resolveProps"));
|
|
14
14
|
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
|
15
15
|
var _colorManipulator = require("@mui/system/colorManipulator");
|
|
16
|
+
var _utils = require("@mui/material/utils");
|
|
16
17
|
var _rootShouldForwardProp = _interopRequireDefault(require("../styles/rootShouldForwardProp"));
|
|
17
18
|
var _zeroStyled = require("../zero-styled");
|
|
18
19
|
var _memoTheme = _interopRequireDefault(require("../utils/memoTheme"));
|
|
19
20
|
var _DefaultPropsProvider = require("../DefaultPropsProvider");
|
|
20
21
|
var _ButtonBase = _interopRequireDefault(require("../ButtonBase"));
|
|
22
|
+
var _CircularProgress = _interopRequireDefault(require("../CircularProgress"));
|
|
21
23
|
var _capitalize = _interopRequireDefault(require("../utils/capitalize"));
|
|
22
24
|
var _createSimplePaletteValueFilter = _interopRequireDefault(require("../utils/createSimplePaletteValueFilter"));
|
|
23
25
|
var _buttonClasses = _interopRequireWildcard(require("./buttonClasses"));
|
|
@@ -31,13 +33,16 @@ const useUtilityClasses = ownerState => {
|
|
|
31
33
|
fullWidth,
|
|
32
34
|
size,
|
|
33
35
|
variant,
|
|
36
|
+
loading,
|
|
37
|
+
loadingPosition,
|
|
34
38
|
classes
|
|
35
39
|
} = ownerState;
|
|
36
40
|
const slots = {
|
|
37
|
-
root: ['root', variant, `${variant}${(0, _capitalize.default)(color)}`, `size${(0, _capitalize.default)(size)}`, `${variant}Size${(0, _capitalize.default)(size)}`, `color${(0, _capitalize.default)(color)}`, disableElevation && 'disableElevation', fullWidth && 'fullWidth'],
|
|
38
|
-
label: ['label'],
|
|
41
|
+
root: ['root', loading && 'loading', variant, `${variant}${(0, _capitalize.default)(color)}`, `size${(0, _capitalize.default)(size)}`, `${variant}Size${(0, _capitalize.default)(size)}`, `color${(0, _capitalize.default)(color)}`, disableElevation && 'disableElevation', fullWidth && 'fullWidth', loading && `loadingPosition${(0, _capitalize.default)(loadingPosition)}`],
|
|
39
42
|
startIcon: ['icon', 'startIcon', `iconSize${(0, _capitalize.default)(size)}`],
|
|
40
|
-
endIcon: ['icon', 'endIcon', `iconSize${(0, _capitalize.default)(size)}`]
|
|
43
|
+
endIcon: ['icon', 'endIcon', `iconSize${(0, _capitalize.default)(size)}`],
|
|
44
|
+
loadingIndicator: ['loadingIndicator'],
|
|
45
|
+
loadingWrapper: ['loadingWrapper']
|
|
41
46
|
};
|
|
42
47
|
const composedClasses = (0, _composeClasses.default)(slots, _buttonClasses.getButtonUtilityClass, classes);
|
|
43
48
|
return {
|
|
@@ -82,7 +87,7 @@ const ButtonRoot = (0, _zeroStyled.styled)(_ButtonBase.default, {
|
|
|
82
87
|
const {
|
|
83
88
|
ownerState
|
|
84
89
|
} = props;
|
|
85
|
-
return [styles.root, styles[ownerState.variant], styles[`${ownerState.variant}${(0, _capitalize.default)(ownerState.color)}`], styles[`size${(0, _capitalize.default)(ownerState.size)}`], styles[`${ownerState.variant}Size${(0, _capitalize.default)(ownerState.size)}`], ownerState.color === 'inherit' && styles.colorInherit, ownerState.disableElevation && styles.disableElevation, ownerState.fullWidth && styles.fullWidth];
|
|
90
|
+
return [styles.root, styles[ownerState.variant], styles[`${ownerState.variant}${(0, _capitalize.default)(ownerState.color)}`], styles[`size${(0, _capitalize.default)(ownerState.size)}`], styles[`${ownerState.variant}Size${(0, _capitalize.default)(ownerState.size)}`], ownerState.color === 'inherit' && styles.colorInherit, ownerState.disableElevation && styles.disableElevation, ownerState.fullWidth && styles.fullWidth, ownerState.loading && styles.loading];
|
|
86
91
|
}
|
|
87
92
|
})((0, _memoTheme.default)(({
|
|
88
93
|
theme
|
|
@@ -269,6 +274,18 @@ const ButtonRoot = (0, _zeroStyled.styled)(_ButtonBase.default, {
|
|
|
269
274
|
style: {
|
|
270
275
|
width: '100%'
|
|
271
276
|
}
|
|
277
|
+
}, {
|
|
278
|
+
props: {
|
|
279
|
+
loadingPosition: 'center'
|
|
280
|
+
},
|
|
281
|
+
style: {
|
|
282
|
+
transition: theme.transitions.create(['background-color', 'box-shadow', 'border-color'], {
|
|
283
|
+
duration: theme.transitions.duration.short
|
|
284
|
+
}),
|
|
285
|
+
[`&.${_buttonClasses.default.loading}`]: {
|
|
286
|
+
color: 'transparent'
|
|
287
|
+
}
|
|
288
|
+
}
|
|
272
289
|
}]
|
|
273
290
|
};
|
|
274
291
|
}));
|
|
@@ -279,9 +296,11 @@ const ButtonStartIcon = (0, _zeroStyled.styled)('span', {
|
|
|
279
296
|
const {
|
|
280
297
|
ownerState
|
|
281
298
|
} = props;
|
|
282
|
-
return [styles.startIcon, styles[`iconSize${(0, _capitalize.default)(ownerState.size)}`]];
|
|
299
|
+
return [styles.startIcon, ownerState.loading && styles.startIconLoadingStart, styles[`iconSize${(0, _capitalize.default)(ownerState.size)}`]];
|
|
283
300
|
}
|
|
284
|
-
})({
|
|
301
|
+
})(({
|
|
302
|
+
theme
|
|
303
|
+
}) => ({
|
|
285
304
|
display: 'inherit',
|
|
286
305
|
marginRight: 8,
|
|
287
306
|
marginLeft: -4,
|
|
@@ -292,8 +311,28 @@ const ButtonStartIcon = (0, _zeroStyled.styled)('span', {
|
|
|
292
311
|
style: {
|
|
293
312
|
marginLeft: -2
|
|
294
313
|
}
|
|
314
|
+
}, {
|
|
315
|
+
props: {
|
|
316
|
+
loadingPosition: 'start',
|
|
317
|
+
loading: true
|
|
318
|
+
},
|
|
319
|
+
style: {
|
|
320
|
+
transition: theme.transitions.create(['opacity'], {
|
|
321
|
+
duration: theme.transitions.duration.short
|
|
322
|
+
}),
|
|
323
|
+
opacity: 0
|
|
324
|
+
}
|
|
325
|
+
}, {
|
|
326
|
+
props: {
|
|
327
|
+
loadingPosition: 'start',
|
|
328
|
+
loading: true,
|
|
329
|
+
fullWidth: true
|
|
330
|
+
},
|
|
331
|
+
style: {
|
|
332
|
+
marginRight: -8
|
|
333
|
+
}
|
|
295
334
|
}, ...commonIconStyles]
|
|
296
|
-
});
|
|
335
|
+
}));
|
|
297
336
|
const ButtonEndIcon = (0, _zeroStyled.styled)('span', {
|
|
298
337
|
name: 'MuiButton',
|
|
299
338
|
slot: 'EndIcon',
|
|
@@ -301,9 +340,11 @@ const ButtonEndIcon = (0, _zeroStyled.styled)('span', {
|
|
|
301
340
|
const {
|
|
302
341
|
ownerState
|
|
303
342
|
} = props;
|
|
304
|
-
return [styles.endIcon, styles[`iconSize${(0, _capitalize.default)(ownerState.size)}`]];
|
|
343
|
+
return [styles.endIcon, ownerState.loading && styles.endIconLoadingEnd, styles[`iconSize${(0, _capitalize.default)(ownerState.size)}`]];
|
|
305
344
|
}
|
|
306
|
-
})({
|
|
345
|
+
})(({
|
|
346
|
+
theme
|
|
347
|
+
}) => ({
|
|
307
348
|
display: 'inherit',
|
|
308
349
|
marginRight: -4,
|
|
309
350
|
marginLeft: 8,
|
|
@@ -314,7 +355,128 @@ const ButtonEndIcon = (0, _zeroStyled.styled)('span', {
|
|
|
314
355
|
style: {
|
|
315
356
|
marginRight: -2
|
|
316
357
|
}
|
|
358
|
+
}, {
|
|
359
|
+
props: {
|
|
360
|
+
loadingPosition: 'end',
|
|
361
|
+
loading: true
|
|
362
|
+
},
|
|
363
|
+
style: {
|
|
364
|
+
transition: theme.transitions.create(['opacity'], {
|
|
365
|
+
duration: theme.transitions.duration.short
|
|
366
|
+
}),
|
|
367
|
+
opacity: 0
|
|
368
|
+
}
|
|
369
|
+
}, {
|
|
370
|
+
props: {
|
|
371
|
+
loadingPosition: 'end',
|
|
372
|
+
loading: true,
|
|
373
|
+
fullWidth: true
|
|
374
|
+
},
|
|
375
|
+
style: {
|
|
376
|
+
marginLeft: -8
|
|
377
|
+
}
|
|
317
378
|
}, ...commonIconStyles]
|
|
379
|
+
}));
|
|
380
|
+
const ButtonLoadingIndicator = (0, _zeroStyled.styled)('span', {
|
|
381
|
+
name: 'MuiButton',
|
|
382
|
+
slot: 'LoadingIndicator',
|
|
383
|
+
overridesResolver: (props, styles) => styles.loadingIndicator
|
|
384
|
+
})(({
|
|
385
|
+
theme
|
|
386
|
+
}) => ({
|
|
387
|
+
display: 'none',
|
|
388
|
+
position: 'absolute',
|
|
389
|
+
visibility: 'visible',
|
|
390
|
+
variants: [{
|
|
391
|
+
props: {
|
|
392
|
+
loading: true
|
|
393
|
+
},
|
|
394
|
+
style: {
|
|
395
|
+
display: 'flex'
|
|
396
|
+
}
|
|
397
|
+
}, {
|
|
398
|
+
props: {
|
|
399
|
+
loadingPosition: 'start'
|
|
400
|
+
},
|
|
401
|
+
style: {
|
|
402
|
+
left: 14
|
|
403
|
+
}
|
|
404
|
+
}, {
|
|
405
|
+
props: {
|
|
406
|
+
loadingPosition: 'start',
|
|
407
|
+
size: 'small'
|
|
408
|
+
},
|
|
409
|
+
style: {
|
|
410
|
+
left: 10
|
|
411
|
+
}
|
|
412
|
+
}, {
|
|
413
|
+
props: {
|
|
414
|
+
variant: 'text',
|
|
415
|
+
loadingPosition: 'start'
|
|
416
|
+
},
|
|
417
|
+
style: {
|
|
418
|
+
left: 6
|
|
419
|
+
}
|
|
420
|
+
}, {
|
|
421
|
+
props: {
|
|
422
|
+
loadingPosition: 'center'
|
|
423
|
+
},
|
|
424
|
+
style: {
|
|
425
|
+
left: '50%',
|
|
426
|
+
transform: 'translate(-50%)',
|
|
427
|
+
color: (theme.vars || theme).palette.action.disabled
|
|
428
|
+
}
|
|
429
|
+
}, {
|
|
430
|
+
props: {
|
|
431
|
+
loadingPosition: 'end'
|
|
432
|
+
},
|
|
433
|
+
style: {
|
|
434
|
+
right: 14
|
|
435
|
+
}
|
|
436
|
+
}, {
|
|
437
|
+
props: {
|
|
438
|
+
loadingPosition: 'end',
|
|
439
|
+
size: 'small'
|
|
440
|
+
},
|
|
441
|
+
style: {
|
|
442
|
+
right: 10
|
|
443
|
+
}
|
|
444
|
+
}, {
|
|
445
|
+
props: {
|
|
446
|
+
variant: 'text',
|
|
447
|
+
loadingPosition: 'end'
|
|
448
|
+
},
|
|
449
|
+
style: {
|
|
450
|
+
right: 6
|
|
451
|
+
}
|
|
452
|
+
}, {
|
|
453
|
+
props: {
|
|
454
|
+
loadingPosition: 'start',
|
|
455
|
+
fullWidth: true
|
|
456
|
+
},
|
|
457
|
+
style: {
|
|
458
|
+
position: 'relative',
|
|
459
|
+
left: -10
|
|
460
|
+
}
|
|
461
|
+
}, {
|
|
462
|
+
props: {
|
|
463
|
+
loadingPosition: 'end',
|
|
464
|
+
fullWidth: true
|
|
465
|
+
},
|
|
466
|
+
style: {
|
|
467
|
+
position: 'relative',
|
|
468
|
+
right: -10
|
|
469
|
+
}
|
|
470
|
+
}]
|
|
471
|
+
}));
|
|
472
|
+
const ButtonLoadingIconPlaceholder = (0, _zeroStyled.styled)('span', {
|
|
473
|
+
name: 'MuiButton',
|
|
474
|
+
slot: 'LoadingIconPlaceholder',
|
|
475
|
+
overridesResolver: (props, styles) => styles.loadingIconPlaceholder
|
|
476
|
+
})({
|
|
477
|
+
display: 'inline-block',
|
|
478
|
+
width: '1em',
|
|
479
|
+
height: '1em'
|
|
318
480
|
});
|
|
319
481
|
const Button = /*#__PURE__*/React.forwardRef(function Button(inProps, ref) {
|
|
320
482
|
// props priority: `inProps` > `contextProps` > `themeDefaultProps`
|
|
@@ -336,12 +498,22 @@ const Button = /*#__PURE__*/React.forwardRef(function Button(inProps, ref) {
|
|
|
336
498
|
endIcon: endIconProp,
|
|
337
499
|
focusVisibleClassName,
|
|
338
500
|
fullWidth = false,
|
|
501
|
+
id: idProp,
|
|
502
|
+
loading = null,
|
|
503
|
+
loadingIndicator: loadingIndicatorProp,
|
|
504
|
+
loadingPosition = 'center',
|
|
339
505
|
size = 'medium',
|
|
340
506
|
startIcon: startIconProp,
|
|
341
507
|
type,
|
|
342
508
|
variant = 'text',
|
|
343
509
|
...other
|
|
344
510
|
} = props;
|
|
511
|
+
const id = (0, _utils.unstable_useId)(idProp);
|
|
512
|
+
const loadingIndicator = loadingIndicatorProp ?? /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
|
|
513
|
+
"aria-labelledby": id,
|
|
514
|
+
color: "inherit",
|
|
515
|
+
size: 16
|
|
516
|
+
});
|
|
345
517
|
const ownerState = {
|
|
346
518
|
...props,
|
|
347
519
|
color,
|
|
@@ -350,34 +522,58 @@ const Button = /*#__PURE__*/React.forwardRef(function Button(inProps, ref) {
|
|
|
350
522
|
disableElevation,
|
|
351
523
|
disableFocusRipple,
|
|
352
524
|
fullWidth,
|
|
525
|
+
loading,
|
|
526
|
+
loadingIndicator,
|
|
527
|
+
loadingPosition,
|
|
353
528
|
size,
|
|
354
529
|
type,
|
|
355
530
|
variant
|
|
356
531
|
};
|
|
357
532
|
const classes = useUtilityClasses(ownerState);
|
|
358
|
-
const startIcon = startIconProp && /*#__PURE__*/(0, _jsxRuntime.jsx)(ButtonStartIcon, {
|
|
533
|
+
const startIcon = (startIconProp || loading && loadingPosition === 'start') && /*#__PURE__*/(0, _jsxRuntime.jsx)(ButtonStartIcon, {
|
|
359
534
|
className: classes.startIcon,
|
|
360
535
|
ownerState: ownerState,
|
|
361
|
-
children: startIconProp
|
|
536
|
+
children: startIconProp || /*#__PURE__*/(0, _jsxRuntime.jsx)(ButtonLoadingIconPlaceholder, {
|
|
537
|
+
className: classes.loadingIconPlaceholder,
|
|
538
|
+
ownerState: ownerState
|
|
539
|
+
})
|
|
362
540
|
});
|
|
363
|
-
const endIcon = endIconProp && /*#__PURE__*/(0, _jsxRuntime.jsx)(ButtonEndIcon, {
|
|
541
|
+
const endIcon = (endIconProp || loading && loadingPosition === 'end') && /*#__PURE__*/(0, _jsxRuntime.jsx)(ButtonEndIcon, {
|
|
364
542
|
className: classes.endIcon,
|
|
365
543
|
ownerState: ownerState,
|
|
366
|
-
children: endIconProp
|
|
544
|
+
children: endIconProp || /*#__PURE__*/(0, _jsxRuntime.jsx)(ButtonLoadingIconPlaceholder, {
|
|
545
|
+
className: classes.loadingIconPlaceholder,
|
|
546
|
+
ownerState: ownerState
|
|
547
|
+
})
|
|
367
548
|
});
|
|
368
549
|
const positionClassName = buttonGroupButtonContextPositionClassName || '';
|
|
550
|
+
const loader = typeof loading === 'boolean' ?
|
|
551
|
+
/*#__PURE__*/
|
|
552
|
+
// use plain HTML span to minimize the runtime overhead
|
|
553
|
+
(0, _jsxRuntime.jsx)("span", {
|
|
554
|
+
className: classes.loadingWrapper,
|
|
555
|
+
style: {
|
|
556
|
+
display: 'contents'
|
|
557
|
+
},
|
|
558
|
+
children: loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(ButtonLoadingIndicator, {
|
|
559
|
+
className: classes.loadingIndicator,
|
|
560
|
+
ownerState: ownerState,
|
|
561
|
+
children: loadingIndicator
|
|
562
|
+
})
|
|
563
|
+
}) : null;
|
|
369
564
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(ButtonRoot, {
|
|
370
565
|
ownerState: ownerState,
|
|
371
566
|
className: (0, _clsx.default)(contextProps.className, classes.root, className, positionClassName),
|
|
372
567
|
component: component,
|
|
373
|
-
disabled: disabled,
|
|
568
|
+
disabled: disabled || loading,
|
|
374
569
|
focusRipple: !disableFocusRipple,
|
|
375
570
|
focusVisibleClassName: (0, _clsx.default)(classes.focusVisible, focusVisibleClassName),
|
|
376
571
|
ref: ref,
|
|
377
572
|
type: type,
|
|
573
|
+
id: id,
|
|
378
574
|
...other,
|
|
379
575
|
classes: classes,
|
|
380
|
-
children: [startIcon, children, endIcon]
|
|
576
|
+
children: [startIcon, loadingPosition !== 'end' && loader, children, loadingPosition === 'end' && loader, endIcon]
|
|
381
577
|
});
|
|
382
578
|
});
|
|
383
579
|
process.env.NODE_ENV !== "production" ? Button.propTypes /* remove-proptypes */ = {
|
|
@@ -450,6 +646,28 @@ process.env.NODE_ENV !== "production" ? Button.propTypes /* remove-proptypes */
|
|
|
450
646
|
* If defined, an `a` element will be used as the root node.
|
|
451
647
|
*/
|
|
452
648
|
href: _propTypes.default.string,
|
|
649
|
+
/**
|
|
650
|
+
* @ignore
|
|
651
|
+
*/
|
|
652
|
+
id: _propTypes.default.string,
|
|
653
|
+
/**
|
|
654
|
+
* If `true`, the loading indicator is visible and the button is disabled.
|
|
655
|
+
* If `true | false`, the loading wrapper is always rendered before the children to prevent [Google Translation Crash](https://github.com/mui/material-ui/issues/27853).
|
|
656
|
+
* @default null
|
|
657
|
+
*/
|
|
658
|
+
loading: _propTypes.default.bool,
|
|
659
|
+
/**
|
|
660
|
+
* Element placed before the children if the button is in loading state.
|
|
661
|
+
* The node should contain an element with `role="progressbar"` with an accessible name.
|
|
662
|
+
* By default, it renders a `CircularProgress` that is labeled by the button itself.
|
|
663
|
+
* @default <CircularProgress color="inherit" size={16} />
|
|
664
|
+
*/
|
|
665
|
+
loadingIndicator: _propTypes.default.node,
|
|
666
|
+
/**
|
|
667
|
+
* The loading indicator can be positioned on the start, end, or the center of the button.
|
|
668
|
+
* @default 'center'
|
|
669
|
+
*/
|
|
670
|
+
loadingPosition: _propTypes.default.oneOf(['center', 'end', 'start']),
|
|
453
671
|
/**
|
|
454
672
|
* The size of the component.
|
|
455
673
|
* `small` is equivalent to the dense button styling.
|
|
@@ -11,5 +11,5 @@ var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateU
|
|
|
11
11
|
function getButtonUtilityClass(slot) {
|
|
12
12
|
return (0, _generateUtilityClass.default)('MuiButton', slot);
|
|
13
13
|
}
|
|
14
|
-
const buttonClasses = (0, _generateUtilityClasses.default)('MuiButton', ['root', 'text', 'textInherit', 'textPrimary', 'textSecondary', 'textSuccess', 'textError', 'textInfo', 'textWarning', 'outlined', 'outlinedInherit', 'outlinedPrimary', 'outlinedSecondary', 'outlinedSuccess', 'outlinedError', 'outlinedInfo', 'outlinedWarning', 'contained', 'containedInherit', 'containedPrimary', 'containedSecondary', 'containedSuccess', 'containedError', 'containedInfo', 'containedWarning', 'disableElevation', 'focusVisible', 'disabled', 'colorInherit', 'colorPrimary', 'colorSecondary', 'colorSuccess', 'colorError', 'colorInfo', 'colorWarning', 'textSizeSmall', 'textSizeMedium', 'textSizeLarge', 'outlinedSizeSmall', 'outlinedSizeMedium', 'outlinedSizeLarge', 'containedSizeSmall', 'containedSizeMedium', 'containedSizeLarge', 'sizeMedium', 'sizeSmall', 'sizeLarge', 'fullWidth', 'startIcon', 'endIcon', 'icon', 'iconSizeSmall', 'iconSizeMedium', 'iconSizeLarge']);
|
|
14
|
+
const buttonClasses = (0, _generateUtilityClasses.default)('MuiButton', ['root', 'text', 'textInherit', 'textPrimary', 'textSecondary', 'textSuccess', 'textError', 'textInfo', 'textWarning', 'outlined', 'outlinedInherit', 'outlinedPrimary', 'outlinedSecondary', 'outlinedSuccess', 'outlinedError', 'outlinedInfo', 'outlinedWarning', 'contained', 'containedInherit', 'containedPrimary', 'containedSecondary', 'containedSuccess', 'containedError', 'containedInfo', 'containedWarning', 'disableElevation', 'focusVisible', 'disabled', 'colorInherit', 'colorPrimary', 'colorSecondary', 'colorSuccess', 'colorError', 'colorInfo', 'colorWarning', 'textSizeSmall', 'textSizeMedium', 'textSizeLarge', 'outlinedSizeSmall', 'outlinedSizeMedium', 'outlinedSizeLarge', 'containedSizeSmall', 'containedSizeMedium', 'containedSizeLarge', 'sizeMedium', 'sizeSmall', 'sizeLarge', 'fullWidth', 'startIcon', 'endIcon', 'icon', 'iconSizeSmall', 'iconSizeMedium', 'iconSizeLarge', 'loading', 'loadingWrapper', 'loadingIconPlaceholder', 'loadingIndicator', 'loadingPositionCenter', 'loadingPositionStart', 'loadingPositionEnd']);
|
|
15
15
|
var _default = exports.default = buttonClasses;
|
|
@@ -9,12 +9,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
exports.default = void 0;
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
-
var _clsx = _interopRequireDefault(require("clsx"));
|
|
13
12
|
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
|
14
13
|
var _Typography = _interopRequireWildcard(require("../Typography"));
|
|
15
14
|
var _zeroStyled = require("../zero-styled");
|
|
16
15
|
var _DefaultPropsProvider = require("../DefaultPropsProvider");
|
|
17
16
|
var _cardHeaderClasses = _interopRequireWildcard(require("./cardHeaderClasses"));
|
|
17
|
+
var _useSlot = _interopRequireDefault(require("../utils/useSlot"));
|
|
18
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
19
|
const useUtilityClasses = ownerState => {
|
|
20
20
|
const {
|
|
@@ -86,13 +86,14 @@ const CardHeader = /*#__PURE__*/React.forwardRef(function CardHeader(inProps, re
|
|
|
86
86
|
const {
|
|
87
87
|
action,
|
|
88
88
|
avatar,
|
|
89
|
-
className,
|
|
90
89
|
component = 'div',
|
|
91
90
|
disableTypography = false,
|
|
92
91
|
subheader: subheaderProp,
|
|
93
92
|
subheaderTypographyProps,
|
|
94
93
|
title: titleProp,
|
|
95
94
|
titleTypographyProps,
|
|
95
|
+
slots = {},
|
|
96
|
+
slotProps = {},
|
|
96
97
|
...other
|
|
97
98
|
} = props;
|
|
98
99
|
const ownerState = {
|
|
@@ -101,44 +102,88 @@ const CardHeader = /*#__PURE__*/React.forwardRef(function CardHeader(inProps, re
|
|
|
101
102
|
disableTypography
|
|
102
103
|
};
|
|
103
104
|
const classes = useUtilityClasses(ownerState);
|
|
105
|
+
const externalForwardedProps = {
|
|
106
|
+
slots,
|
|
107
|
+
slotProps: {
|
|
108
|
+
title: titleTypographyProps,
|
|
109
|
+
subheader: subheaderTypographyProps,
|
|
110
|
+
...slotProps
|
|
111
|
+
}
|
|
112
|
+
};
|
|
104
113
|
let title = titleProp;
|
|
105
|
-
|
|
106
|
-
|
|
114
|
+
const [TitleSlot, titleSlotProps] = (0, _useSlot.default)('title', {
|
|
115
|
+
className: classes.title,
|
|
116
|
+
elementType: _Typography.default,
|
|
117
|
+
externalForwardedProps,
|
|
118
|
+
ownerState,
|
|
119
|
+
additionalProps: {
|
|
107
120
|
variant: avatar ? 'body2' : 'h5',
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
121
|
+
component: 'span'
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
if (title != null && title.type !== _Typography.default && !disableTypography) {
|
|
125
|
+
title = /*#__PURE__*/(0, _jsxRuntime.jsx)(TitleSlot, {
|
|
126
|
+
...titleSlotProps,
|
|
111
127
|
children: title
|
|
112
128
|
});
|
|
113
129
|
}
|
|
114
130
|
let subheader = subheaderProp;
|
|
115
|
-
|
|
116
|
-
|
|
131
|
+
const [SubheaderSlot, subheaderSlotProps] = (0, _useSlot.default)('subheader', {
|
|
132
|
+
className: classes.subheader,
|
|
133
|
+
elementType: _Typography.default,
|
|
134
|
+
externalForwardedProps,
|
|
135
|
+
ownerState,
|
|
136
|
+
additionalProps: {
|
|
117
137
|
variant: avatar ? 'body2' : 'body1',
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
138
|
+
color: 'textSecondary',
|
|
139
|
+
component: 'span'
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
if (subheader != null && subheader.type !== _Typography.default && !disableTypography) {
|
|
143
|
+
subheader = /*#__PURE__*/(0, _jsxRuntime.jsx)(SubheaderSlot, {
|
|
144
|
+
...subheaderSlotProps,
|
|
122
145
|
children: subheader
|
|
123
146
|
});
|
|
124
147
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
148
|
+
const [RootSlot, rootSlotProps] = (0, _useSlot.default)('root', {
|
|
149
|
+
ref,
|
|
150
|
+
className: classes.root,
|
|
151
|
+
elementType: CardHeaderRoot,
|
|
152
|
+
externalForwardedProps: {
|
|
153
|
+
...externalForwardedProps,
|
|
154
|
+
...other,
|
|
155
|
+
component
|
|
156
|
+
},
|
|
157
|
+
ownerState
|
|
158
|
+
});
|
|
159
|
+
const [AvatarSlot, avatarSlotProps] = (0, _useSlot.default)('avatar', {
|
|
160
|
+
className: classes.avatar,
|
|
161
|
+
elementType: CardHeaderAvatar,
|
|
162
|
+
externalForwardedProps,
|
|
163
|
+
ownerState
|
|
164
|
+
});
|
|
165
|
+
const [ContentSlot, contentSlotProps] = (0, _useSlot.default)('content', {
|
|
166
|
+
className: classes.content,
|
|
167
|
+
elementType: CardHeaderContent,
|
|
168
|
+
externalForwardedProps,
|
|
169
|
+
ownerState
|
|
170
|
+
});
|
|
171
|
+
const [ActionSlot, actionSlotProps] = (0, _useSlot.default)('action', {
|
|
172
|
+
className: classes.action,
|
|
173
|
+
elementType: CardHeaderAction,
|
|
174
|
+
externalForwardedProps,
|
|
175
|
+
ownerState
|
|
176
|
+
});
|
|
177
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(RootSlot, {
|
|
178
|
+
...rootSlotProps,
|
|
179
|
+
children: [avatar && /*#__PURE__*/(0, _jsxRuntime.jsx)(AvatarSlot, {
|
|
180
|
+
...avatarSlotProps,
|
|
134
181
|
children: avatar
|
|
135
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(
|
|
136
|
-
|
|
137
|
-
ownerState: ownerState,
|
|
182
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(ContentSlot, {
|
|
183
|
+
...contentSlotProps,
|
|
138
184
|
children: [title, subheader]
|
|
139
|
-
}), action && /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
140
|
-
|
|
141
|
-
ownerState: ownerState,
|
|
185
|
+
}), action && /*#__PURE__*/(0, _jsxRuntime.jsx)(ActionSlot, {
|
|
186
|
+
...actionSlotProps,
|
|
142
187
|
children: action
|
|
143
188
|
})]
|
|
144
189
|
});
|
|
@@ -164,10 +209,6 @@ process.env.NODE_ENV !== "production" ? CardHeader.propTypes /* remove-proptypes
|
|
|
164
209
|
* Override or extend the styles applied to the component.
|
|
165
210
|
*/
|
|
166
211
|
classes: _propTypes.default.object,
|
|
167
|
-
/**
|
|
168
|
-
* @ignore
|
|
169
|
-
*/
|
|
170
|
-
className: _propTypes.default.string,
|
|
171
212
|
/**
|
|
172
213
|
* The component used for the root node.
|
|
173
214
|
* Either a string to use a HTML element or a component.
|
|
@@ -181,6 +222,30 @@ process.env.NODE_ENV !== "production" ? CardHeader.propTypes /* remove-proptypes
|
|
|
181
222
|
* @default false
|
|
182
223
|
*/
|
|
183
224
|
disableTypography: _propTypes.default.bool,
|
|
225
|
+
/**
|
|
226
|
+
* The props used for each slot inside.
|
|
227
|
+
* @default {}
|
|
228
|
+
*/
|
|
229
|
+
slotProps: _propTypes.default.shape({
|
|
230
|
+
action: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
|
|
231
|
+
avatar: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
|
|
232
|
+
content: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
|
|
233
|
+
root: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
|
|
234
|
+
subheader: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
|
|
235
|
+
title: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object])
|
|
236
|
+
}),
|
|
237
|
+
/**
|
|
238
|
+
* The components used for each slot inside.
|
|
239
|
+
* @default {}
|
|
240
|
+
*/
|
|
241
|
+
slots: _propTypes.default.shape({
|
|
242
|
+
action: _propTypes.default.elementType,
|
|
243
|
+
avatar: _propTypes.default.elementType,
|
|
244
|
+
content: _propTypes.default.elementType,
|
|
245
|
+
root: _propTypes.default.elementType,
|
|
246
|
+
subheader: _propTypes.default.elementType,
|
|
247
|
+
title: _propTypes.default.elementType
|
|
248
|
+
}),
|
|
184
249
|
/**
|
|
185
250
|
* The content of the component.
|
|
186
251
|
*/
|
|
@@ -188,6 +253,7 @@ process.env.NODE_ENV !== "production" ? CardHeader.propTypes /* remove-proptypes
|
|
|
188
253
|
/**
|
|
189
254
|
* These props will be forwarded to the subheader
|
|
190
255
|
* (as long as disableTypography is not `true`).
|
|
256
|
+
* @deprecated Use `slotProps.subheader` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
191
257
|
*/
|
|
192
258
|
subheaderTypographyProps: _propTypes.default.object,
|
|
193
259
|
/**
|
|
@@ -201,6 +267,7 @@ process.env.NODE_ENV !== "production" ? CardHeader.propTypes /* remove-proptypes
|
|
|
201
267
|
/**
|
|
202
268
|
* These props will be forwarded to the title
|
|
203
269
|
* (as long as disableTypography is not `true`).
|
|
270
|
+
* @deprecated Use `slotProps.title` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
204
271
|
*/
|
|
205
272
|
titleTypographyProps: _propTypes.default.object
|
|
206
273
|
} : void 0;
|