@mui/material 5.15.4 → 5.15.5

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.
Files changed (53) hide show
  1. package/Accordion/Accordion.d.ts +30 -2
  2. package/Accordion/Accordion.js +39 -6
  3. package/AccordionSummary/accordionSummaryClasses.d.ts +4 -1
  4. package/Alert/Alert.d.ts +4 -2
  5. package/Alert/Alert.js +1 -1
  6. package/Badge/Badge.js +1 -1
  7. package/CHANGELOG.md +98 -0
  8. package/Divider/Divider.d.ts +1 -0
  9. package/Divider/Divider.js +1 -0
  10. package/Divider/dividerClasses.d.ts +6 -2
  11. package/Rating/Rating.js +1 -10
  12. package/SpeedDial/SpeedDial.js +1 -9
  13. package/index.js +1 -1
  14. package/legacy/Accordion/Accordion.js +44 -7
  15. package/legacy/Alert/Alert.js +1 -1
  16. package/legacy/Badge/Badge.js +1 -1
  17. package/legacy/Divider/Divider.js +1 -0
  18. package/legacy/Rating/Rating.js +1 -10
  19. package/legacy/SpeedDial/SpeedDial.js +1 -9
  20. package/legacy/index.js +1 -1
  21. package/legacy/utils/types.js +1 -0
  22. package/legacy/utils/useSlot.js +71 -0
  23. package/legacy/zero-styled/index.js +2 -0
  24. package/modern/Accordion/Accordion.js +39 -6
  25. package/modern/Alert/Alert.js +1 -1
  26. package/modern/Badge/Badge.js +1 -1
  27. package/modern/Divider/Divider.js +1 -0
  28. package/modern/Rating/Rating.js +1 -10
  29. package/modern/SpeedDial/SpeedDial.js +1 -9
  30. package/modern/index.js +1 -1
  31. package/modern/utils/types.js +1 -0
  32. package/modern/utils/useSlot.js +82 -0
  33. package/modern/zero-styled/index.js +2 -0
  34. package/node/Accordion/Accordion.js +39 -6
  35. package/node/Alert/Alert.js +1 -1
  36. package/node/Badge/Badge.js +3 -3
  37. package/node/Divider/Divider.js +1 -0
  38. package/node/Rating/Rating.js +1 -10
  39. package/node/SpeedDial/SpeedDial.js +2 -10
  40. package/node/index.js +1 -1
  41. package/node/utils/types.js +5 -0
  42. package/node/utils/useSlot.js +88 -0
  43. package/node/zero-styled/index.js +13 -0
  44. package/package.json +7 -7
  45. package/umd/material-ui.development.js +600 -499
  46. package/umd/material-ui.production.min.js +4 -4
  47. package/utils/types.d.ts +27 -0
  48. package/utils/types.js +1 -0
  49. package/utils/useSlot.d.ts +84 -0
  50. package/utils/useSlot.js +82 -0
  51. package/zero-styled/index.d.ts +2 -0
  52. package/zero-styled/index.js +2 -0
  53. package/zero-styled/package.json +6 -0
@@ -0,0 +1,27 @@
1
+ /// <reference types="react" />
2
+ import { SxProps } from '@mui/system';
3
+ import { SlotComponentProps } from '@mui/base';
4
+ export type SlotCommonProps = {
5
+ component?: React.ElementType;
6
+ sx?: SxProps;
7
+ };
8
+ export type SlotProps<TSlotComponent extends React.ElementType, TOverrides, TOwnerState> = SlotComponentProps<TSlotComponent, SlotCommonProps & TOverrides, TOwnerState>;
9
+ /**
10
+ * Use the keys of `Slots` to make sure that K contains all of the keys
11
+ *
12
+ * @example CreateSlotsAndSlotProps<{ root: React.ElementType, decorator: React.ElementType }, { root: ..., decorator: ... }>
13
+ */
14
+ export type CreateSlotsAndSlotProps<Slots, K extends Record<keyof Slots, any>> = {
15
+ /**
16
+ * The components used for each slot inside.
17
+ * @default {}
18
+ */
19
+ slots?: Slots;
20
+ /**
21
+ * The props used for each slot inside.
22
+ * @default {}
23
+ */
24
+ slotProps?: {
25
+ [P in keyof K]?: K[P];
26
+ };
27
+ };
package/utils/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,84 @@
1
+ import * as React from 'react';
2
+ import { ClassValue } from 'clsx';
3
+ export type WithCommonProps<T> = T & {
4
+ className?: string;
5
+ style?: React.CSSProperties;
6
+ ref?: React.Ref<any>;
7
+ };
8
+ type EventHandlers = Record<string, React.EventHandler<any>>;
9
+ type ExtractComponentProps<P> = P extends infer T | ((ownerState: any) => infer T) ? T : never;
10
+ /**
11
+ * An internal function to create a Material UI slot.
12
+ *
13
+ * This is an advanced version of Base UI `useSlotProps` because Material UI allows leaf component to be customized via `component` prop
14
+ * while Base UI does not need to support leaf component customization.
15
+ *
16
+ * @param {string} name: name of the slot
17
+ * @param {object} parameters
18
+ * @returns {[Slot, slotProps]} The slot's React component and the slot's props
19
+ *
20
+ * Note: the returned slot's props
21
+ * - will never contain `component` prop.
22
+ * - might contain `as` prop.
23
+ */
24
+ export default function useSlot<T extends string, ElementType extends React.ElementType, SlotProps, OwnerState extends {}, ExternalSlotProps extends {
25
+ component?: React.ElementType;
26
+ ref?: React.Ref<any>;
27
+ }, ExternalForwardedProps extends {
28
+ component?: React.ElementType;
29
+ slots?: {
30
+ [k in T]?: React.ElementType;
31
+ };
32
+ slotProps?: {
33
+ [k in T]?: ExternalSlotProps | ((ownerState: OwnerState) => ExternalSlotProps);
34
+ };
35
+ }, AdditionalProps, SlotOwnerState extends {}>(
36
+ /**
37
+ * The slot's name. All Material UI components should have `root` slot.
38
+ *
39
+ * If the name is `root`, the logic behaves differently from other slots,
40
+ * e.g. the `externalForwardedProps` are spread to `root` slot but not other slots.
41
+ */
42
+ name: T, parameters: (T extends 'root' ? {
43
+ ref: React.ForwardedRef<any>;
44
+ } : {
45
+ ref?: React.ForwardedRef<any>;
46
+ }) & {
47
+ /**
48
+ * The slot's className
49
+ */
50
+ className: ClassValue | ClassValue[];
51
+ /**
52
+ * The slot's default styled-component
53
+ */
54
+ elementType: ElementType;
55
+ /**
56
+ * The component's ownerState
57
+ */
58
+ ownerState: OwnerState;
59
+ /**
60
+ * The `other` props from the consumer. It has to contain `component`, `slots`, and `slotProps`.
61
+ * The function will use those props to calculate the final rendered element and the returned props.
62
+ *
63
+ * If the slot is not `root`, the rest of the `externalForwardedProps` are neglected.
64
+ */
65
+ externalForwardedProps: ExternalForwardedProps;
66
+ getSlotProps?: (other: EventHandlers) => WithCommonProps<SlotProps>;
67
+ additionalProps?: WithCommonProps<AdditionalProps>;
68
+ /**
69
+ * For overriding the component's ownerState for the slot.
70
+ * This is required for some components that need styling via `ownerState`.
71
+ *
72
+ * It is a function because `slotProps.{slot}` can be a function which has to be resolved first.
73
+ */
74
+ getSlotOwnerState?: (mergedProps: AdditionalProps & SlotProps & ExternalSlotProps & ExtractComponentProps<Exclude<Exclude<ExternalForwardedProps['slotProps'], undefined>[T], undefined>>) => SlotOwnerState;
75
+ /**
76
+ * props forward to `T` only if the `slotProps.*.component` is not provided.
77
+ * e.g. Autocomplete's listbox uses Popper + StyledComponent
78
+ */
79
+ internalForwardedProps?: any;
80
+ }): [ElementType, {
81
+ className: string;
82
+ ownerState: OwnerState & SlotOwnerState;
83
+ } & AdditionalProps & SlotProps & ExternalSlotProps & ExtractComponentProps<Exclude<Exclude<ExternalForwardedProps["slotProps"], undefined>[T], undefined>>];
84
+ export {};
@@ -0,0 +1,82 @@
1
+ 'use client';
2
+
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
+ const _excluded = ["className", "elementType", "ownerState", "externalForwardedProps", "getSlotOwnerState", "internalForwardedProps"],
6
+ _excluded2 = ["component", "slots", "slotProps"],
7
+ _excluded3 = ["component"];
8
+ import { unstable_useForkRef as useForkRef } from '@mui/utils';
9
+ import { appendOwnerState, resolveComponentProps, mergeSlotProps } from '@mui/base/utils';
10
+ /**
11
+ * An internal function to create a Material UI slot.
12
+ *
13
+ * This is an advanced version of Base UI `useSlotProps` because Material UI allows leaf component to be customized via `component` prop
14
+ * while Base UI does not need to support leaf component customization.
15
+ *
16
+ * @param {string} name: name of the slot
17
+ * @param {object} parameters
18
+ * @returns {[Slot, slotProps]} The slot's React component and the slot's props
19
+ *
20
+ * Note: the returned slot's props
21
+ * - will never contain `component` prop.
22
+ * - might contain `as` prop.
23
+ */
24
+ export default function useSlot(
25
+ /**
26
+ * The slot's name. All Material UI components should have `root` slot.
27
+ *
28
+ * If the name is `root`, the logic behaves differently from other slots,
29
+ * e.g. the `externalForwardedProps` are spread to `root` slot but not other slots.
30
+ */
31
+ name, parameters) {
32
+ const {
33
+ className,
34
+ elementType: initialElementType,
35
+ ownerState,
36
+ externalForwardedProps,
37
+ getSlotOwnerState,
38
+ internalForwardedProps
39
+ } = parameters,
40
+ useSlotPropsParams = _objectWithoutPropertiesLoose(parameters, _excluded);
41
+ const {
42
+ component: rootComponent,
43
+ slots = {
44
+ [name]: undefined
45
+ },
46
+ slotProps = {
47
+ [name]: undefined
48
+ }
49
+ } = externalForwardedProps,
50
+ other = _objectWithoutPropertiesLoose(externalForwardedProps, _excluded2);
51
+ const elementType = slots[name] || initialElementType;
52
+
53
+ // `slotProps[name]` can be a callback that receives the component's ownerState.
54
+ // `resolvedComponentsProps` is always a plain object.
55
+ const resolvedComponentsProps = resolveComponentProps(slotProps[name], ownerState);
56
+ const _mergeSlotProps = mergeSlotProps(_extends({
57
+ className
58
+ }, useSlotPropsParams, {
59
+ externalForwardedProps: name === 'root' ? other : undefined,
60
+ externalSlotProps: resolvedComponentsProps
61
+ })),
62
+ {
63
+ props: {
64
+ component: slotComponent
65
+ },
66
+ internalRef
67
+ } = _mergeSlotProps,
68
+ mergedProps = _objectWithoutPropertiesLoose(_mergeSlotProps.props, _excluded3);
69
+ const ref = useForkRef(internalRef, resolvedComponentsProps == null ? void 0 : resolvedComponentsProps.ref, parameters.ref);
70
+ const slotOwnerState = getSlotOwnerState ? getSlotOwnerState(mergedProps) : {};
71
+ const finalOwnerState = _extends({}, ownerState, slotOwnerState);
72
+ const LeafComponent = name === 'root' ? slotComponent || rootComponent : slotComponent;
73
+ const props = appendOwnerState(elementType, _extends({}, name === 'root' && !rootComponent && !slots[name] && internalForwardedProps, name !== 'root' && !slots[name] && internalForwardedProps, mergedProps, LeafComponent && {
74
+ as: LeafComponent
75
+ }, {
76
+ ref
77
+ }), finalOwnerState);
78
+ Object.keys(slotOwnerState).forEach(propName => {
79
+ delete props[propName];
80
+ });
81
+ return [elementType, props];
82
+ }
@@ -0,0 +1,2 @@
1
+ // eslint-disable-next-line import/prefer-default-export
2
+ export { default as styled } from '../styles/styled';
@@ -0,0 +1,2 @@
1
+ // eslint-disable-next-line import/prefer-default-export
2
+ export { default as styled } from '../styles/styled';
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "module": "./index.js",
4
+ "main": "../node/zero-styled/index.js",
5
+ "types": "./index.d.ts"
6
+ }