@tw1934/mui-material 7.3.7 → 7.3.8

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.
@@ -2,43 +2,11 @@ import * as React from 'react';
2
2
  type ClickAwayMouseEventHandler = 'onClick' | 'onMouseDown' | 'onMouseUp' | 'onPointerDown' | 'onPointerUp';
3
3
  type ClickAwayTouchEventHandler = 'onTouchStart' | 'onTouchEnd';
4
4
  export interface ClickAwayListenerProps {
5
- /**
6
- * The wrapped element.
7
- */
8
5
  children: React.ReactElement<any>;
9
- /**
10
- * If `true`, the React tree is ignored and only the DOM tree is considered.
11
- * This prop changes how portaled elements are handled.
12
- * @default false
13
- */
14
6
  disableReactTree?: boolean;
15
- /**
16
- * The mouse event to listen to. You can disable the listener by providing `false`.
17
- * @default 'onClick'
18
- */
19
7
  mouseEvent?: ClickAwayMouseEventHandler | false;
20
- /**
21
- * Callback fired when a "click away" event is detected.
22
- */
23
8
  onClickAway: (event: MouseEvent | TouchEvent) => void;
24
- /**
25
- * The touch event to listen to. You can disable the listener by providing `false`.
26
- * @default 'onTouchEnd'
27
- */
28
9
  touchEvent?: ClickAwayTouchEventHandler | false;
29
10
  }
30
- /**
31
- * Listen for click events that occur somewhere in the document, outside of the element itself.
32
- * For instance, if you need to hide a menu when people click anywhere else on your page.
33
- *
34
- * Demos:
35
- *
36
- * - [Click-Away Listener](https://mui.com/material-ui/react-click-away-listener/)
37
- * - [Menu](https://mui.com/material-ui/react-menu/)
38
- *
39
- * API:
40
- *
41
- * - [ClickAwayListener API](https://mui.com/material-ui/api/click-away-listener/)
42
- */
43
11
  declare function ClickAwayListener(props: ClickAwayListenerProps): React.JSX.Element;
44
12
  export { ClickAwayListener };
@@ -12,26 +12,12 @@ var _ownerDocument = _interopRequireDefault(require("@mui/utils/ownerDocument"))
12
12
  var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
13
13
  var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
14
14
  var _getReactElementRef = _interopRequireDefault(require("@mui/utils/getReactElementRef"));
15
- // TODO: return `EventHandlerName extends `on${infer EventName}` ? Lowercase<EventName> : never` once generatePropTypes runs with TS 4.1
16
15
  function mapEventPropToEvent(eventProp) {
17
16
  return eventProp.substring(2).toLowerCase();
18
17
  }
19
18
  function clickedRootScrollbar(event, doc) {
20
19
  return doc.documentElement.clientWidth < event.clientX || doc.documentElement.clientHeight < event.clientY;
21
20
  }
22
- /**
23
- * Listen for click events that occur somewhere in the document, outside of the element itself.
24
- * For instance, if you need to hide a menu when people click anywhere else on your page.
25
- *
26
- * Demos:
27
- *
28
- * - [Click-Away Listener](https://mui.com/material-ui/react-click-away-listener/)
29
- * - [Menu](https://mui.com/material-ui/react-menu/)
30
- *
31
- * API:
32
- *
33
- * - [ClickAwayListener API](https://mui.com/material-ui/api/click-away-listener/)
34
- */
35
21
  function ClickAwayListener(props) {
36
22
  const {
37
23
  children,
@@ -45,8 +31,6 @@ function ClickAwayListener(props) {
45
31
  const activatedRef = React.useRef(false);
46
32
  const syntheticEventRef = React.useRef(false);
47
33
  React.useEffect(() => {
48
- // Ensure that this component is not "activated" synchronously.
49
- // https://github.com/facebook/react/issues/20074
50
34
  setTimeout(() => {
51
35
  activatedRef.current = true;
52
36
  }, 0);
@@ -55,55 +39,32 @@ function ClickAwayListener(props) {
55
39
  };
56
40
  }, []);
57
41
  const handleRef = (0, _useForkRef.default)((0, _getReactElementRef.default)(children), nodeRef);
58
-
59
- // The handler doesn't take event.defaultPrevented into account:
60
- //
61
- // event.preventDefault() is meant to stop default behaviors like
62
- // clicking a checkbox to check it, hitting a button to submit a form,
63
- // and hitting left arrow to move the cursor in a text input etc.
64
- // Only special HTML elements have these default behaviors.
65
42
  const handleClickAway = (0, _useEventCallback.default)(event => {
66
- // Given developers can stop the propagation of the synthetic event,
67
- // we can only be confident with a positive value.
68
43
  const insideReactTree = syntheticEventRef.current;
69
44
  syntheticEventRef.current = false;
70
45
  const doc = (0, _ownerDocument.default)(nodeRef.current);
71
-
72
- // 1. IE11 support, which trigger the handleClickAway even after the unbind
73
- // 2. The child might render null.
74
- // 3. Behave like a blur listener.
75
46
  if (!activatedRef.current || !nodeRef.current || 'clientX' in event && clickedRootScrollbar(event, doc)) {
76
47
  return;
77
48
  }
78
-
79
- // Do not act if user performed touchmove
80
49
  if (movedRef.current) {
81
50
  movedRef.current = false;
82
51
  return;
83
52
  }
84
53
  let insideDOM;
85
-
86
- // If not enough, can use https://github.com/DieterHolvoet/event-propagation-path/blob/master/propagationPath.js
87
54
  if (event.composedPath) {
88
55
  insideDOM = event.composedPath().includes(nodeRef.current);
89
56
  } else {
90
- insideDOM = !doc.documentElement.contains(
91
- // @ts-expect-error returns `false` as intended when not dispatched from a Node
92
- event.target) || nodeRef.current.contains(
93
- // @ts-expect-error returns `false` as intended when not dispatched from a Node
94
- event.target);
57
+ insideDOM = !doc.documentElement.contains(event.target) || nodeRef.current.contains(event.target);
95
58
  }
96
59
  if (!insideDOM && (disableReactTree || !insideReactTree)) {
97
60
  onClickAway(event);
98
61
  }
99
62
  });
100
-
101
- // Keep track of mouse/touch events that bubbled up through the portal.
102
63
  const createHandleSynthetic = handlerName => event => {
103
64
  syntheticEventRef.current = true;
104
- const childrenPropsHandler = children.props[handlerName];
105
- if (childrenPropsHandler) {
106
- childrenPropsHandler(event);
65
+ const handler = children.props[handlerName];
66
+ if (handler) {
67
+ handler(event);
107
68
  }
108
69
  };
109
70
  const childrenProps = {
@@ -114,15 +75,15 @@ function ClickAwayListener(props) {
114
75
  }
115
76
  React.useEffect(() => {
116
77
  if (touchEvent !== false) {
117
- const mappedTouchEvent = mapEventPropToEvent(touchEvent);
78
+ const mapped = mapEventPropToEvent(touchEvent);
118
79
  const doc = (0, _ownerDocument.default)(nodeRef.current);
119
80
  const handleTouchMove = () => {
120
81
  movedRef.current = true;
121
82
  };
122
- doc.addEventListener(mappedTouchEvent, handleClickAway);
83
+ doc.addEventListener(mapped, handleClickAway);
123
84
  doc.addEventListener('touchmove', handleTouchMove);
124
85
  return () => {
125
- doc.removeEventListener(mappedTouchEvent, handleClickAway);
86
+ doc.removeEventListener(mapped, handleClickAway);
126
87
  doc.removeEventListener('touchmove', handleTouchMove);
127
88
  };
128
89
  }
@@ -133,11 +94,11 @@ function ClickAwayListener(props) {
133
94
  }
134
95
  React.useEffect(() => {
135
96
  if (mouseEvent !== false) {
136
- const mappedMouseEvent = mapEventPropToEvent(mouseEvent);
97
+ const mapped = mapEventPropToEvent(mouseEvent);
137
98
  const doc = (0, _ownerDocument.default)(nodeRef.current);
138
- doc.addEventListener(mappedMouseEvent, handleClickAway);
99
+ doc.addEventListener(mapped, handleClickAway);
139
100
  return () => {
140
- doc.removeEventListener(mappedMouseEvent, handleClickAway);
101
+ doc.removeEventListener(mapped, handleClickAway);
141
102
  };
142
103
  }
143
104
  return undefined;
@@ -5,5 +5,5 @@ import { SliderValueLabelProps } from "./SliderValueLabel.types.js";
5
5
  */
6
6
  export default function SliderValueLabel(props: SliderValueLabelProps): React.ReactElement<{
7
7
  className?: string;
8
- children?: React.ReactNode;
8
+ children?: import("react").ReactNode;
9
9
  }, string | React.JSXElementConstructor<any>> | null;
@@ -72,7 +72,7 @@ export type TextFieldSlotsAndSlotProps<InputPropsType> = CreateSlotsAndSlotProps
72
72
  * Props forwarded to the html input slot.
73
73
  * By default, the available props are based on the html input element.
74
74
  */
75
- htmlInput: SlotProps<React.ElementType<InputBaseProps['inputProps']>, {}, TextFieldOwnerState>;
75
+ htmlInput: SlotProps<React.ElementType<InputBaseProps>, {}, TextFieldOwnerState>;
76
76
  /**
77
77
  * Props forwarded to the form helper text slot.
78
78
  * By default, the available props are based on the [FormHelperText](https://mui.com/material-ui/api/form-helper-text/#props) component.
@@ -2,43 +2,11 @@ import * as React from 'react';
2
2
  type ClickAwayMouseEventHandler = 'onClick' | 'onMouseDown' | 'onMouseUp' | 'onPointerDown' | 'onPointerUp';
3
3
  type ClickAwayTouchEventHandler = 'onTouchStart' | 'onTouchEnd';
4
4
  export interface ClickAwayListenerProps {
5
- /**
6
- * The wrapped element.
7
- */
8
5
  children: React.ReactElement<any>;
9
- /**
10
- * If `true`, the React tree is ignored and only the DOM tree is considered.
11
- * This prop changes how portaled elements are handled.
12
- * @default false
13
- */
14
6
  disableReactTree?: boolean;
15
- /**
16
- * The mouse event to listen to. You can disable the listener by providing `false`.
17
- * @default 'onClick'
18
- */
19
7
  mouseEvent?: ClickAwayMouseEventHandler | false;
20
- /**
21
- * Callback fired when a "click away" event is detected.
22
- */
23
8
  onClickAway: (event: MouseEvent | TouchEvent) => void;
24
- /**
25
- * The touch event to listen to. You can disable the listener by providing `false`.
26
- * @default 'onTouchEnd'
27
- */
28
9
  touchEvent?: ClickAwayTouchEventHandler | false;
29
10
  }
30
- /**
31
- * Listen for click events that occur somewhere in the document, outside of the element itself.
32
- * For instance, if you need to hide a menu when people click anywhere else on your page.
33
- *
34
- * Demos:
35
- *
36
- * - [Click-Away Listener](https://mui.com/material-ui/react-click-away-listener/)
37
- * - [Menu](https://mui.com/material-ui/react-menu/)
38
- *
39
- * API:
40
- *
41
- * - [ClickAwayListener API](https://mui.com/material-ui/api/click-away-listener/)
42
- */
43
11
  declare function ClickAwayListener(props: ClickAwayListenerProps): React.JSX.Element;
44
12
  export { ClickAwayListener };
@@ -5,27 +5,12 @@ import ownerDocument from '@mui/utils/ownerDocument';
5
5
  import useForkRef from '@mui/utils/useForkRef';
6
6
  import useEventCallback from '@mui/utils/useEventCallback';
7
7
  import getReactElementRef from '@mui/utils/getReactElementRef';
8
-
9
- // TODO: return `EventHandlerName extends `on${infer EventName}` ? Lowercase<EventName> : never` once generatePropTypes runs with TS 4.1
10
8
  function mapEventPropToEvent(eventProp) {
11
9
  return eventProp.substring(2).toLowerCase();
12
10
  }
13
11
  function clickedRootScrollbar(event, doc) {
14
12
  return doc.documentElement.clientWidth < event.clientX || doc.documentElement.clientHeight < event.clientY;
15
13
  }
16
- /**
17
- * Listen for click events that occur somewhere in the document, outside of the element itself.
18
- * For instance, if you need to hide a menu when people click anywhere else on your page.
19
- *
20
- * Demos:
21
- *
22
- * - [Click-Away Listener](https://mui.com/material-ui/react-click-away-listener/)
23
- * - [Menu](https://mui.com/material-ui/react-menu/)
24
- *
25
- * API:
26
- *
27
- * - [ClickAwayListener API](https://mui.com/material-ui/api/click-away-listener/)
28
- */
29
14
  function ClickAwayListener(props) {
30
15
  const {
31
16
  children,
@@ -39,8 +24,6 @@ function ClickAwayListener(props) {
39
24
  const activatedRef = React.useRef(false);
40
25
  const syntheticEventRef = React.useRef(false);
41
26
  React.useEffect(() => {
42
- // Ensure that this component is not "activated" synchronously.
43
- // https://github.com/facebook/react/issues/20074
44
27
  setTimeout(() => {
45
28
  activatedRef.current = true;
46
29
  }, 0);
@@ -49,55 +32,32 @@ function ClickAwayListener(props) {
49
32
  };
50
33
  }, []);
51
34
  const handleRef = useForkRef(getReactElementRef(children), nodeRef);
52
-
53
- // The handler doesn't take event.defaultPrevented into account:
54
- //
55
- // event.preventDefault() is meant to stop default behaviors like
56
- // clicking a checkbox to check it, hitting a button to submit a form,
57
- // and hitting left arrow to move the cursor in a text input etc.
58
- // Only special HTML elements have these default behaviors.
59
35
  const handleClickAway = useEventCallback(event => {
60
- // Given developers can stop the propagation of the synthetic event,
61
- // we can only be confident with a positive value.
62
36
  const insideReactTree = syntheticEventRef.current;
63
37
  syntheticEventRef.current = false;
64
38
  const doc = ownerDocument(nodeRef.current);
65
-
66
- // 1. IE11 support, which trigger the handleClickAway even after the unbind
67
- // 2. The child might render null.
68
- // 3. Behave like a blur listener.
69
39
  if (!activatedRef.current || !nodeRef.current || 'clientX' in event && clickedRootScrollbar(event, doc)) {
70
40
  return;
71
41
  }
72
-
73
- // Do not act if user performed touchmove
74
42
  if (movedRef.current) {
75
43
  movedRef.current = false;
76
44
  return;
77
45
  }
78
46
  let insideDOM;
79
-
80
- // If not enough, can use https://github.com/DieterHolvoet/event-propagation-path/blob/master/propagationPath.js
81
47
  if (event.composedPath) {
82
48
  insideDOM = event.composedPath().includes(nodeRef.current);
83
49
  } else {
84
- insideDOM = !doc.documentElement.contains(
85
- // @ts-expect-error returns `false` as intended when not dispatched from a Node
86
- event.target) || nodeRef.current.contains(
87
- // @ts-expect-error returns `false` as intended when not dispatched from a Node
88
- event.target);
50
+ insideDOM = !doc.documentElement.contains(event.target) || nodeRef.current.contains(event.target);
89
51
  }
90
52
  if (!insideDOM && (disableReactTree || !insideReactTree)) {
91
53
  onClickAway(event);
92
54
  }
93
55
  });
94
-
95
- // Keep track of mouse/touch events that bubbled up through the portal.
96
56
  const createHandleSynthetic = handlerName => event => {
97
57
  syntheticEventRef.current = true;
98
- const childrenPropsHandler = children.props[handlerName];
99
- if (childrenPropsHandler) {
100
- childrenPropsHandler(event);
58
+ const handler = children.props[handlerName];
59
+ if (handler) {
60
+ handler(event);
101
61
  }
102
62
  };
103
63
  const childrenProps = {
@@ -108,15 +68,15 @@ function ClickAwayListener(props) {
108
68
  }
109
69
  React.useEffect(() => {
110
70
  if (touchEvent !== false) {
111
- const mappedTouchEvent = mapEventPropToEvent(touchEvent);
71
+ const mapped = mapEventPropToEvent(touchEvent);
112
72
  const doc = ownerDocument(nodeRef.current);
113
73
  const handleTouchMove = () => {
114
74
  movedRef.current = true;
115
75
  };
116
- doc.addEventListener(mappedTouchEvent, handleClickAway);
76
+ doc.addEventListener(mapped, handleClickAway);
117
77
  doc.addEventListener('touchmove', handleTouchMove);
118
78
  return () => {
119
- doc.removeEventListener(mappedTouchEvent, handleClickAway);
79
+ doc.removeEventListener(mapped, handleClickAway);
120
80
  doc.removeEventListener('touchmove', handleTouchMove);
121
81
  };
122
82
  }
@@ -127,11 +87,11 @@ function ClickAwayListener(props) {
127
87
  }
128
88
  React.useEffect(() => {
129
89
  if (mouseEvent !== false) {
130
- const mappedMouseEvent = mapEventPropToEvent(mouseEvent);
90
+ const mapped = mapEventPropToEvent(mouseEvent);
131
91
  const doc = ownerDocument(nodeRef.current);
132
- doc.addEventListener(mappedMouseEvent, handleClickAway);
92
+ doc.addEventListener(mapped, handleClickAway);
133
93
  return () => {
134
- doc.removeEventListener(mappedMouseEvent, handleClickAway);
94
+ doc.removeEventListener(mapped, handleClickAway);
135
95
  };
136
96
  }
137
97
  return undefined;
@@ -5,5 +5,5 @@ import { SliderValueLabelProps } from "./SliderValueLabel.types.js";
5
5
  */
6
6
  export default function SliderValueLabel(props: SliderValueLabelProps): React.ReactElement<{
7
7
  className?: string;
8
- children?: React.ReactNode;
8
+ children?: import("react").ReactNode;
9
9
  }, string | React.JSXElementConstructor<any>> | null;
@@ -72,7 +72,7 @@ export type TextFieldSlotsAndSlotProps<InputPropsType> = CreateSlotsAndSlotProps
72
72
  * Props forwarded to the html input slot.
73
73
  * By default, the available props are based on the html input element.
74
74
  */
75
- htmlInput: SlotProps<React.ElementType<InputBaseProps['inputProps']>, {}, TextFieldOwnerState>;
75
+ htmlInput: SlotProps<React.ElementType<InputBaseProps>, {}, TextFieldOwnerState>;
76
76
  /**
77
77
  * Props forwarded to the form helper text slot.
78
78
  * By default, the available props are based on the [FormHelperText](https://mui.com/material-ui/api/form-helper-text/#props) component.
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @tw1934/mui-material v7.3.7
2
+ * @tw1934/mui-material v7.3.8
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -60,6 +60,7 @@ name, parameters) {
60
60
  className,
61
61
  ...useSlotPropsParams,
62
62
  externalForwardedProps: name === 'root' ? other : undefined,
63
+ // @ts-ignore
63
64
  externalSlotProps: resolvedComponentsProps
64
65
  });
65
66
  const ref = useForkRef(internalRef, resolvedComponentsProps?.ref, parameters.ref);
@@ -1,6 +1,6 @@
1
- export const version = "7.3.7";
1
+ export const version = "7.3.8";
2
2
  export const major = Number("7");
3
3
  export const minor = Number("3");
4
- export const patch = Number("7");
4
+ export const patch = Number("8");
5
5
  export const prerelease = undefined;
6
6
  export default version;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @tw1934/mui-material v7.3.7
2
+ * @tw1934/mui-material v7.3.8
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tw1934/mui-material",
3
- "version": "7.3.7",
3
+ "version": "7.3.8",
4
4
  "author": "MUI Team",
5
5
  "description": "Material UI is an open-source React component library that implements Google's Material Design. It's comprehensive and can be used in production out of the box.",
6
6
  "keywords": [
@@ -26,24 +26,24 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@babel/runtime": "^7.28.6",
29
- "@mui/utils": "@tw1934/mui-utils",
29
+ "@mui/core-downloads-tracker": "^7.3.7",
30
+ "@mui/system": "npm:@tw1934/mui-system",
31
+ "@mui/types": "^7.4.10",
32
+ "@mui/utils": "npm:@tw1934/mui-utils",
30
33
  "@popperjs/core": "^2.11.8",
31
34
  "@types/react-transition-group": "^4.4.12",
32
35
  "clsx": "^2.1.1",
33
36
  "csstype": "^3.2.3",
34
37
  "react-is": "^19.2.3",
35
- "react-transition-group": "@tw1934/react-transition-group",
36
- "@mui/core-downloads-tracker": "^7.3.7",
37
- "@mui/types": "^7.4.10",
38
- "@mui/system": "npm:@tw1934/mui-system@^7.3.7"
38
+ "react-transition-group": "npm:@tw1934/react-transition-group"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "@emotion/react": "^11.5.0",
42
42
  "@emotion/styled": "^11.3.0",
43
+ "@mui/material-pigment-css": "^7.3.7",
43
44
  "@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0",
44
45
  "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
45
- "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0",
46
- "@mui/material-pigment-css": "^7.3.7"
46
+ "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
47
47
  },
48
48
  "peerDependenciesMeta": {
49
49
  "@types/react": {
package/utils/useSlot.js CHANGED
@@ -66,6 +66,7 @@ name, parameters) {
66
66
  className,
67
67
  ...useSlotPropsParams,
68
68
  externalForwardedProps: name === 'root' ? other : undefined,
69
+ // @ts-ignore
69
70
  externalSlotProps: resolvedComponentsProps
70
71
  });
71
72
  const ref = (0, _useForkRef.default)(internalRef, resolvedComponentsProps?.ref, parameters.ref);
package/version/index.js CHANGED
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.version = exports.prerelease = exports.patch = exports.minor = exports.major = exports.default = void 0;
7
- const version = exports.version = "7.3.7";
7
+ const version = exports.version = "7.3.8";
8
8
  const major = exports.major = Number("7");
9
9
  const minor = exports.minor = Number("3");
10
- const patch = exports.patch = Number("7");
10
+ const patch = exports.patch = Number("8");
11
11
  const prerelease = exports.prerelease = undefined;
12
12
  var _default = exports.default = version;