@mui/x-data-grid 7.10.0 → 7.11.0

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 (47) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/components/panel/GridPanel.d.ts +1 -1
  3. package/components/panel/GridPanel.js +4 -1
  4. package/components/panel/filterPanel/GridFilterForm.js +1 -12
  5. package/components/panel/filterPanel/GridFilterInputMultipleValue.d.ts +1 -1
  6. package/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
  7. package/hooks/core/useGridApiInitialization.js +1 -1
  8. package/hooks/features/columnResize/useGridColumnResize.js +1 -0
  9. package/hooks/features/editing/gridEditingSelectors.d.ts +3 -0
  10. package/hooks/features/editing/gridEditingSelectors.js +3 -1
  11. package/hooks/features/editing/index.d.ts +1 -0
  12. package/hooks/features/editing/index.js +1 -0
  13. package/hooks/features/index.d.ts +1 -0
  14. package/hooks/features/index.js +1 -0
  15. package/hooks/utils/useGridApiEventHandler.d.ts +1 -1
  16. package/index.js +1 -1
  17. package/locales/ruRU.js +4 -5
  18. package/models/api/gridCoreApi.d.ts +1 -1
  19. package/modern/components/panel/GridPanel.js +4 -1
  20. package/modern/components/panel/filterPanel/GridFilterForm.js +1 -12
  21. package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
  22. package/modern/hooks/core/useGridApiInitialization.js +1 -1
  23. package/modern/hooks/features/columnResize/useGridColumnResize.js +1 -0
  24. package/modern/hooks/features/editing/gridEditingSelectors.js +3 -1
  25. package/modern/hooks/features/editing/index.js +1 -0
  26. package/modern/hooks/features/index.js +1 -0
  27. package/modern/index.js +1 -1
  28. package/modern/locales/ruRU.js +4 -5
  29. package/modern/utils/createSelector.js +2 -2
  30. package/node/components/panel/GridPanel.js +4 -1
  31. package/node/components/panel/filterPanel/GridFilterForm.js +1 -12
  32. package/node/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
  33. package/node/hooks/core/useGridApiInitialization.js +1 -1
  34. package/node/hooks/features/columnResize/useGridColumnResize.js +1 -0
  35. package/node/hooks/features/editing/gridEditingSelectors.js +3 -1
  36. package/node/hooks/features/editing/index.js +16 -0
  37. package/node/hooks/features/index.js +11 -0
  38. package/node/index.js +1 -1
  39. package/node/locales/ruRU.js +4 -5
  40. package/node/utils/createSelector.js +2 -2
  41. package/package.json +5 -5
  42. package/utils/createSelector.d.ts +1 -1
  43. package/utils/createSelector.js +2 -2
  44. package/modern/utils/EventManager.js +0 -69
  45. package/node/utils/EventManager.js +0 -76
  46. package/utils/EventManager.d.ts +0 -29
  47. package/utils/EventManager.js +0 -69
package/CHANGELOG.md CHANGED
@@ -3,6 +3,91 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 7.11.0
7
+
8
+ _Jul 18, 2024_
9
+
10
+ We'd like to offer a big thanks to the 13 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🎨 Add [color legend](https://mui.com/x/react-charts/legend/#color-legend) for charts (#13700) @alexfauquette
13
+ - 🌍 Improve Korean (ko-KR) locale on the Date and Time Pickers
14
+ - 🌍 Improve Russian (ru-RU) locale on the Date and Time Pickers and Data Grid
15
+ - 🐞 Bugfixes
16
+ - 📚 Documentation improvements
17
+
18
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
19
+
20
+ ### Data Grid
21
+
22
+ #### `@mui/x-data-grid@7.11.0`
23
+
24
+ - [DataGrid] Expose `gridEditRowsStateSelector` (#13877) @romgrk
25
+ - [DataGrid] Fix `columnResizeStop` event not emitted when column is not resized (#13307) @mateuseap
26
+ - [DataGrid] Fix delete filter inconsistent behavior (#13353) @oukunan
27
+ - [DataGrid] Enable flip on preferences panel (#13803) @romgrk
28
+ - [DataGrid] Support `date` and `datetime-local` input types in `GridFilterInputMultipleValue` type (#13411) @karudedios
29
+ - [l10n] Improve Russian (ru-RU) locale (#13735) @diro-atk
30
+
31
+ #### `@mui/x-data-grid-pro@7.11.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
32
+
33
+ Same changes as in `@mui/x-data-grid@7.11.0`.
34
+
35
+ #### `@mui/x-data-grid-premium@7.11.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
36
+
37
+ Same changes as in `@mui/x-data-grid-pro@7.11.0`.
38
+
39
+ ### Date and Time Pickers
40
+
41
+ #### `@mui/x-date-pickers@7.11.0`
42
+
43
+ - [l10n] Improve Korean (ko-KR) locale (#13651) @100pearlcent
44
+ - [l10n] Improve Russian (ru-RU) locale (#13871) @Inv1x
45
+ - [pickers] Add more conformance tests improving API docs precision (#13800) @LukasTy
46
+ - [TimePicker] Add `Mui-selected` class to `TimeClock` meridiem buttons (#13848) @LukasTy
47
+
48
+ #### `@mui/x-date-pickers-pro@7.11.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
49
+
50
+ Same changes as in `@mui/x-date-pickers@7.11.0`, plus:
51
+
52
+ - [DateRangePicker] Fix `name` prop propagation regression (#13821) @LukasTy
53
+
54
+ ### Charts
55
+
56
+ #### `@mui/x-charts@7.11.0`
57
+
58
+ - [charts] Create color legend (#13700) @alexfauquette
59
+ - [charts] Defaultize axis on top level `useChartContainerProps` (#13817) @JCQuintas
60
+ - [charts] Fix charts not passing `className` to root element (#13647) @JCQuintas
61
+ - [charts] Generate API documentation for pro components (#13822) @alexfauquette
62
+ - [charts] Improve zoomed highlight behaviour (unreleased) (#13868) @JCQuintas
63
+ - [charts] Allow zoom on Y axis and add zoom options to configure zooming behaviour (unreleased) (#13726) @JCQuintas
64
+ - [charts] Disable animations while zooming (unreleased) (#13807) @JCQuintas
65
+
66
+ ### Tree View
67
+
68
+ #### `@mui/x-tree-view@7.11.0`
69
+
70
+ - [TreeView] Extract some logic outside of the `useTreeView` hook (#13845) @flaviendelangle
71
+
72
+ ### Docs
73
+
74
+ - [docs] Add warning about `process.env.NODE_ENV` in production (#13869) @cherniavskii
75
+ - [docs] Allow controlling the demo form from the example (#13796) @JCQuintas
76
+ - [docs] Clarify Pickers clearable behavior not working on mobile (#13786) @lnhrdt
77
+ - [docs] Improve the documentation of the picker's `onChange` and `onAccept` props (#13543) @flaviendelangle
78
+ - [docs] Replace company name with project name @oliviertassinari
79
+ - [docs] Sort Pickers & Charts API slots alphabetically (#13843) @LukasTy
80
+
81
+ ### Core
82
+
83
+ - [core] Add MUI Internal `renovate` group (#13846) @LukasTy
84
+ - [core] Link GitHub issue for `import/prefer-default-export` rule @oliviertassinari
85
+ - [core] Normalize `...other` and test imports in charts (#13844) @JCQuintas
86
+ - [core] Normalize rest / other to match the most common used @oliviertassinari
87
+ - [code-infra] Follow `next` tag for `@mui/docs` package bumps (#13813) @LukasTy
88
+ - [code-infra] Use specific version for `@mui/docs` dependency (#13760) @LukasTy
89
+ - [internals] Move `EventManager` to `@mui/x-internals` package (#13815) @flaviendelangle
90
+
6
91
  ## 7.10.0
7
92
 
8
93
  _Jul 11, 2024_
@@ -16,7 +16,7 @@ export interface GridPanelProps extends Partial<React.ComponentProps<typeof Grid
16
16
  open: boolean;
17
17
  }
18
18
  export declare const gridPanelClasses: Record<keyof GridPanelClasses, string>;
19
- declare const GridPanelRoot: import("@emotion/styled").StyledComponent<Pick<import("@mui/material/Popper").PopperProps & React.RefAttributes<HTMLDivElement>, "hidden" | "color" | "content" | "style" | "open" | "translate" | "container" | "transition" | "slot" | "title" | "ref" | "suppressHydrationWarning" | "className" | "id" | "lang" | "role" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "accessKey" | "autoFocus" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "nonce" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "component" | "sx" | "components" | "slotProps" | "slots" | "placement" | "disablePortal" | "keepMounted" | "modifiers" | "anchorEl" | "popperOptions" | "popperRef" | "componentsProps"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
19
+ declare const GridPanelRoot: import("@emotion/styled").StyledComponent<Pick<import("@mui/material/Popper").PopperProps & React.RefAttributes<HTMLDivElement>, "hidden" | "color" | "content" | "style" | "open" | "translate" | "container" | "transition" | "slot" | "title" | "ref" | "suppressHydrationWarning" | "className" | "id" | "lang" | "role" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "accessKey" | "autoFocus" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "nonce" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "component" | "sx" | "components" | "slots" | "slotProps" | "componentsProps" | "placement" | "disablePortal" | "modifiers" | "anchorEl" | "keepMounted" | "popperOptions" | "popperRef"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
20
20
  ownerState: OwnerState;
21
21
  }, {}, {}>;
22
22
  declare const GridPanel: React.ForwardRefExoticComponent<Omit<GridPanelProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
@@ -57,7 +57,10 @@ const GridPanel = /*#__PURE__*/React.forwardRef((props, ref) => {
57
57
  }, [apiRef]);
58
58
  const modifiers = React.useMemo(() => [{
59
59
  name: 'flip',
60
- enabled: false
60
+ enabled: true,
61
+ options: {
62
+ rootBoundary: 'document'
63
+ }
61
64
  }, {
62
65
  name: 'isPlaced',
63
66
  enabled: true,
@@ -243,18 +243,7 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
243
243
  applyMultiFilterOperatorChanges(logicOperator);
244
244
  }, [applyMultiFilterOperatorChanges]);
245
245
  const handleDeleteFilter = () => {
246
- if (rootProps.disableMultipleColumnsFiltering) {
247
- if (item.value === undefined) {
248
- deleteFilter(item);
249
- } else {
250
- // TODO v6: simplify the behavior by always remove the filter form
251
- applyFilterChanges(_extends({}, item, {
252
- value: undefined
253
- }));
254
- }
255
- } else {
256
- deleteFilter(item);
257
- }
246
+ deleteFilter(item);
258
247
  };
259
248
  React.useImperativeHandle(focusElementRef, () => ({
260
249
  focus: () => {
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { AutocompleteProps } from '@mui/material/Autocomplete';
3
3
  import { GridFilterInputValueProps } from './GridFilterInputValueProps';
4
4
  export type GridFilterInputMultipleValueProps = {
5
- type?: 'text' | 'number';
5
+ type?: 'text' | 'number' | 'date' | 'datetime-local';
6
6
  } & GridFilterInputValueProps & Omit<AutocompleteProps<string, true, false, true>, 'options' | 'renderInput'>;
7
7
  declare function GridFilterInputMultipleValue(props: GridFilterInputMultipleValueProps): React.JSX.Element;
8
8
  declare namespace GridFilterInputMultipleValue {
@@ -88,6 +88,6 @@ process.env.NODE_ENV !== "production" ? GridFilterInputMultipleValue.propTypes =
88
88
  operator: PropTypes.string.isRequired,
89
89
  value: PropTypes.any
90
90
  }).isRequired,
91
- type: PropTypes.oneOf(['number', 'text'])
91
+ type: PropTypes.oneOf(['date', 'datetime-local', 'number', 'text'])
92
92
  } : void 0;
93
93
  export { GridFilterInputMultipleValue };
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
+ import { EventManager } from '@mui/x-internals/EventManager';
2
3
  import { Store } from '../../utils/Store';
3
4
  import { useGridApiMethod } from '../utils/useGridApiMethod';
4
5
  import { GridSignature } from '../utils/useGridApiEventHandler';
5
- import { EventManager } from '../../utils/EventManager';
6
6
  const SYMBOL_API_PRIVATE = Symbol('mui.api_private');
7
7
  const isSyntheticEvent = event => {
8
8
  return event.isPropagationStopped !== undefined;
@@ -267,6 +267,7 @@ export const useGridColumnResize = (apiRef, props) => {
267
267
  // Check if the current event is part of a double-click
268
268
  if (nativeEvent.timeStamp - prevTimeStamp < 300 && nativeEvent.clientX === prevClientX && nativeEvent.clientY === prevClientY) {
269
269
  refs.previousMouseClickEvent = undefined;
270
+ apiRef.current.publishEvent('columnResizeStop', null, nativeEvent);
270
271
  return;
271
272
  }
272
273
  }
@@ -1,2 +1,5 @@
1
1
  import { GridStateCommunity } from '../../../models/gridStateCommunity';
2
+ /**
3
+ * Select the row editing state.
4
+ */
2
5
  export declare const gridEditRowsStateSelector: (state: GridStateCommunity) => import("../../..").GridEditingState;
@@ -1,2 +1,4 @@
1
- // TODO v6: rename to gridEditingStateSelector
1
+ /**
2
+ * Select the row editing state.
3
+ */
2
4
  export const gridEditRowsStateSelector = state => state.editRows;
@@ -0,0 +1 @@
1
+ export * from './gridEditingSelectors';
@@ -0,0 +1 @@
1
+ export * from './gridEditingSelectors';
@@ -3,6 +3,7 @@ export * from './columns';
3
3
  export * from './columnGrouping';
4
4
  export * from './columnResize';
5
5
  export * from './density';
6
+ export * from './editing';
6
7
  export * from './filter';
7
8
  export * from './focus';
8
9
  export * from './pagination';
@@ -4,6 +4,7 @@ export * from './columns';
4
4
  export * from './columnGrouping';
5
5
  export * from './columnResize';
6
6
  export * from './density';
7
+ export * from './editing';
7
8
  export * from './filter';
8
9
  export * from './focus';
9
10
  export * from './pagination';
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
+ import { EventListenerOptions } from '@mui/x-internals/EventManager';
2
3
  import { GridEventListener, GridEvents } from '../../models/events';
3
4
  import { CleanupTracking } from '../../utils/cleanupTracking/CleanupTracking';
4
- import { EventListenerOptions } from '../../utils/EventManager';
5
5
  import type { GridApiCommon } from '../../models';
6
6
  /**
7
7
  * Signal to the underlying logic what version of the public component API
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.10.0
2
+ * @mui/x-data-grid v7.11.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/locales/ruRU.js CHANGED
@@ -45,11 +45,10 @@ const ruRUGrid = {
45
45
  toolbarExportPrint: 'Печать',
46
46
  toolbarExportExcel: 'Скачать в формате Excel',
47
47
  // Columns management text
48
- // columnsManagementSearchTitle: 'Search',
49
- // columnsManagementNoColumns: 'No columns',
50
- // columnsManagementShowHideAllText: 'Show/Hide All',
51
- // columnsManagementReset: 'Reset',
52
-
48
+ columnsManagementSearchTitle: 'Поиск',
49
+ columnsManagementNoColumns: 'Нет столбцов',
50
+ columnsManagementShowHideAllText: 'Показать/Скрыть Всё',
51
+ columnsManagementReset: 'Сбросить',
53
52
  // Filter panel text
54
53
  filterPanelAddFilter: 'Добавить фильтр',
55
54
  filterPanelRemoveAll: 'Очистить фильтр',
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
+ import { EventManager, EventListenerOptions } from '@mui/x-internals/EventManager';
2
3
  import { GridEventPublisher, GridEventListener, GridEvents } from '../events';
3
4
  import { Store } from '../../utils/Store';
4
- import { EventManager, EventListenerOptions } from '../../utils/EventManager';
5
5
  import { GridApiCaches } from '../gridApiCaches';
6
6
  import type { GridApiCommon, GridPrivateApiCommon } from './gridApiCommon';
7
7
  import type { DataGridProcessedProps } from '../props/DataGridProps';
@@ -57,7 +57,10 @@ const GridPanel = /*#__PURE__*/React.forwardRef((props, ref) => {
57
57
  }, [apiRef]);
58
58
  const modifiers = React.useMemo(() => [{
59
59
  name: 'flip',
60
- enabled: false
60
+ enabled: true,
61
+ options: {
62
+ rootBoundary: 'document'
63
+ }
61
64
  }, {
62
65
  name: 'isPlaced',
63
66
  enabled: true,
@@ -243,18 +243,7 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
243
243
  applyMultiFilterOperatorChanges(logicOperator);
244
244
  }, [applyMultiFilterOperatorChanges]);
245
245
  const handleDeleteFilter = () => {
246
- if (rootProps.disableMultipleColumnsFiltering) {
247
- if (item.value === undefined) {
248
- deleteFilter(item);
249
- } else {
250
- // TODO v6: simplify the behavior by always remove the filter form
251
- applyFilterChanges(_extends({}, item, {
252
- value: undefined
253
- }));
254
- }
255
- } else {
256
- deleteFilter(item);
257
- }
246
+ deleteFilter(item);
258
247
  };
259
248
  React.useImperativeHandle(focusElementRef, () => ({
260
249
  focus: () => {
@@ -88,6 +88,6 @@ process.env.NODE_ENV !== "production" ? GridFilterInputMultipleValue.propTypes =
88
88
  operator: PropTypes.string.isRequired,
89
89
  value: PropTypes.any
90
90
  }).isRequired,
91
- type: PropTypes.oneOf(['number', 'text'])
91
+ type: PropTypes.oneOf(['date', 'datetime-local', 'number', 'text'])
92
92
  } : void 0;
93
93
  export { GridFilterInputMultipleValue };
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
+ import { EventManager } from '@mui/x-internals/EventManager';
2
3
  import { Store } from '../../utils/Store';
3
4
  import { useGridApiMethod } from '../utils/useGridApiMethod';
4
5
  import { GridSignature } from '../utils/useGridApiEventHandler';
5
- import { EventManager } from '../../utils/EventManager';
6
6
  const SYMBOL_API_PRIVATE = Symbol('mui.api_private');
7
7
  const isSyntheticEvent = event => {
8
8
  return event.isPropagationStopped !== undefined;
@@ -267,6 +267,7 @@ export const useGridColumnResize = (apiRef, props) => {
267
267
  // Check if the current event is part of a double-click
268
268
  if (nativeEvent.timeStamp - prevTimeStamp < 300 && nativeEvent.clientX === prevClientX && nativeEvent.clientY === prevClientY) {
269
269
  refs.previousMouseClickEvent = undefined;
270
+ apiRef.current.publishEvent('columnResizeStop', null, nativeEvent);
270
271
  return;
271
272
  }
272
273
  }
@@ -1,2 +1,4 @@
1
- // TODO v6: rename to gridEditingStateSelector
1
+ /**
2
+ * Select the row editing state.
3
+ */
2
4
  export const gridEditRowsStateSelector = state => state.editRows;
@@ -0,0 +1 @@
1
+ export * from './gridEditingSelectors';
@@ -4,6 +4,7 @@ export * from './columns';
4
4
  export * from './columnGrouping';
5
5
  export * from './columnResize';
6
6
  export * from './density';
7
+ export * from './editing';
7
8
  export * from './filter';
8
9
  export * from './focus';
9
10
  export * from './pagination';
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.10.0
2
+ * @mui/x-data-grid v7.11.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -45,11 +45,10 @@ const ruRUGrid = {
45
45
  toolbarExportPrint: 'Печать',
46
46
  toolbarExportExcel: 'Скачать в формате Excel',
47
47
  // Columns management text
48
- // columnsManagementSearchTitle: 'Search',
49
- // columnsManagementNoColumns: 'No columns',
50
- // columnsManagementShowHideAllText: 'Show/Hide All',
51
- // columnsManagementReset: 'Reset',
52
-
48
+ columnsManagementSearchTitle: 'Поиск',
49
+ columnsManagementNoColumns: 'Нет столбцов',
50
+ columnsManagementShowHideAllText: 'Показать/Скрыть Всё',
51
+ columnsManagementReset: 'Сбросить',
53
52
  // Filter panel text
54
53
  filterPanelAddFilter: 'Добавить фильтр',
55
54
  filterPanelRemoveAll: 'Очистить фильтр',
@@ -8,8 +8,8 @@ function checkIsAPIRef(value) {
8
8
  const DEFAULT_INSTANCE_ID = {
9
9
  id: 'default'
10
10
  };
11
- export const createSelector = (a, b, c, d, e, f, ...rest) => {
12
- if (rest.length > 0) {
11
+ export const createSelector = (a, b, c, d, e, f, ...other) => {
12
+ if (other.length > 0) {
13
13
  throw new Error('Unsupported number of selectors');
14
14
  }
15
15
  let selector;
@@ -66,7 +66,10 @@ const GridPanel = exports.GridPanel = /*#__PURE__*/React.forwardRef((props, ref)
66
66
  }, [apiRef]);
67
67
  const modifiers = React.useMemo(() => [{
68
68
  name: 'flip',
69
- enabled: false
69
+ enabled: true,
70
+ options: {
71
+ rootBoundary: 'document'
72
+ }
70
73
  }, {
71
74
  name: 'isPlaced',
72
75
  enabled: true,
@@ -252,18 +252,7 @@ const GridFilterForm = exports.GridFilterForm = /*#__PURE__*/React.forwardRef(fu
252
252
  applyMultiFilterOperatorChanges(logicOperator);
253
253
  }, [applyMultiFilterOperatorChanges]);
254
254
  const handleDeleteFilter = () => {
255
- if (rootProps.disableMultipleColumnsFiltering) {
256
- if (item.value === undefined) {
257
- deleteFilter(item);
258
- } else {
259
- // TODO v6: simplify the behavior by always remove the filter form
260
- applyFilterChanges((0, _extends2.default)({}, item, {
261
- value: undefined
262
- }));
263
- }
264
- } else {
265
- deleteFilter(item);
266
- }
255
+ deleteFilter(item);
267
256
  };
268
257
  React.useImperativeHandle(focusElementRef, () => ({
269
258
  focus: () => {
@@ -97,5 +97,5 @@ process.env.NODE_ENV !== "production" ? GridFilterInputMultipleValue.propTypes =
97
97
  operator: _propTypes.default.string.isRequired,
98
98
  value: _propTypes.default.any
99
99
  }).isRequired,
100
- type: _propTypes.default.oneOf(['number', 'text'])
100
+ type: _propTypes.default.oneOf(['date', 'datetime-local', 'number', 'text'])
101
101
  } : void 0;
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.unwrapPrivateAPI = unwrapPrivateAPI;
7
7
  exports.useGridApiInitialization = useGridApiInitialization;
8
8
  var React = _interopRequireWildcard(require("react"));
9
+ var _EventManager = require("@mui/x-internals/EventManager");
9
10
  var _Store = require("../../utils/Store");
10
11
  var _useGridApiMethod = require("../utils/useGridApiMethod");
11
12
  var _useGridApiEventHandler = require("../utils/useGridApiEventHandler");
12
- var _EventManager = require("../../utils/EventManager");
13
13
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
14
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
15
  const SYMBOL_API_PRIVATE = Symbol('mui.api_private');
@@ -277,6 +277,7 @@ const useGridColumnResize = (apiRef, props) => {
277
277
  // Check if the current event is part of a double-click
278
278
  if (nativeEvent.timeStamp - prevTimeStamp < 300 && nativeEvent.clientX === prevClientX && nativeEvent.clientY === prevClientY) {
279
279
  refs.previousMouseClickEvent = undefined;
280
+ apiRef.current.publishEvent('columnResizeStop', null, nativeEvent);
280
281
  return;
281
282
  }
282
283
  }
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.gridEditRowsStateSelector = void 0;
7
- // TODO v6: rename to gridEditingStateSelector
7
+ /**
8
+ * Select the row editing state.
9
+ */
8
10
  const gridEditRowsStateSelector = state => state.editRows;
9
11
  exports.gridEditRowsStateSelector = gridEditRowsStateSelector;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _gridEditingSelectors = require("./gridEditingSelectors");
7
+ Object.keys(_gridEditingSelectors).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _gridEditingSelectors[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _gridEditingSelectors[key];
14
+ }
15
+ });
16
+ });
@@ -58,6 +58,17 @@ Object.keys(_density).forEach(function (key) {
58
58
  }
59
59
  });
60
60
  });
61
+ var _editing = require("./editing");
62
+ Object.keys(_editing).forEach(function (key) {
63
+ if (key === "default" || key === "__esModule") return;
64
+ if (key in exports && exports[key] === _editing[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function () {
68
+ return _editing[key];
69
+ }
70
+ });
71
+ });
61
72
  var _filter = require("./filter");
62
73
  Object.keys(_filter).forEach(function (key) {
63
74
  if (key === "default" || key === "__esModule") return;
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.10.0
2
+ * @mui/x-data-grid v7.11.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -51,11 +51,10 @@ const ruRUGrid = {
51
51
  toolbarExportPrint: 'Печать',
52
52
  toolbarExportExcel: 'Скачать в формате Excel',
53
53
  // Columns management text
54
- // columnsManagementSearchTitle: 'Search',
55
- // columnsManagementNoColumns: 'No columns',
56
- // columnsManagementShowHideAllText: 'Show/Hide All',
57
- // columnsManagementReset: 'Reset',
58
-
54
+ columnsManagementSearchTitle: 'Поиск',
55
+ columnsManagementNoColumns: 'Нет столбцов',
56
+ columnsManagementShowHideAllText: 'Показать/Скрыть Всё',
57
+ columnsManagementReset: 'Сбросить',
59
58
  // Filter panel text
60
59
  filterPanelAddFilter: 'Добавить фильтр',
61
60
  filterPanelRemoveAll: 'Очистить фильтр',
@@ -14,8 +14,8 @@ function checkIsAPIRef(value) {
14
14
  const DEFAULT_INSTANCE_ID = {
15
15
  id: 'default'
16
16
  };
17
- const createSelector = (a, b, c, d, e, f, ...rest) => {
18
- if (rest.length > 0) {
17
+ const createSelector = (a, b, c, d, e, f, ...other) => {
18
+ if (other.length > 0) {
19
19
  throw new Error('Unsupported number of selectors');
20
20
  }
21
21
  let selector;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "7.10.0",
3
+ "version": "7.11.0",
4
4
  "description": "The Community plan edition of the Data Grid components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -37,13 +37,13 @@
37
37
  "directory": "packages/x-data-grid"
38
38
  },
39
39
  "dependencies": {
40
- "@babel/runtime": "^7.24.7",
41
- "@mui/system": "^5.16.0",
42
- "@mui/utils": "^5.16.0",
40
+ "@babel/runtime": "^7.24.8",
41
+ "@mui/system": "^5.16.2",
42
+ "@mui/utils": "^5.16.2",
43
43
  "clsx": "^2.1.1",
44
44
  "prop-types": "^15.8.1",
45
45
  "reselect": "^4.1.8",
46
- "@mui/x-internals": "7.10.0"
46
+ "@mui/x-internals": "7.11.0"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@mui/material": "^5.15.14",
@@ -14,7 +14,7 @@ type StateFromSelector<T> = T extends (first: infer F, ...args: any[]) => any ?
14
14
  } ? F2 : F : never;
15
15
  type StateFromSelectorList<Selectors extends readonly any[]> = Selectors extends [
16
16
  f: infer F,
17
- ...rest: infer R
17
+ ...other: infer R
18
18
  ] ? StateFromSelector<F> extends StateFromSelectorList<R> ? StateFromSelector<F> : StateFromSelectorList<R> : {};
19
19
  type SelectorArgs<Selectors extends ReadonlyArray<Selector<any>>, Result> = [selectors: [...Selectors], combiner: (...args: SelectorResultArray<Selectors>) => Result] | [...Selectors, (...args: SelectorResultArray<Selectors>) => Result];
20
20
  type CreateSelectorFunction = <Selectors extends ReadonlyArray<Selector<any>>, Result>(...items: SelectorArgs<Selectors, Result>) => OutputSelector<StateFromSelectorList<Selectors>, Result>;
@@ -8,8 +8,8 @@ function checkIsAPIRef(value) {
8
8
  const DEFAULT_INSTANCE_ID = {
9
9
  id: 'default'
10
10
  };
11
- export const createSelector = (a, b, c, d, e, f, ...rest) => {
12
- if (rest.length > 0) {
11
+ export const createSelector = (a, b, c, d, e, f, ...other) => {
12
+ if (other.length > 0) {
13
13
  throw new Error('Unsupported number of selectors');
14
14
  }
15
15
  let selector;
@@ -1,69 +0,0 @@
1
- // Used https://gist.github.com/mudge/5830382 as a starting point.
2
- // See https://github.com/browserify/events/blob/master/events.js for
3
- // the Node.js (https://nodejs.org/api/events.html) polyfill used by webpack.
4
- export class EventManager {
5
- constructor() {
6
- this.maxListeners = 20;
7
- this.warnOnce = false;
8
- this.events = {};
9
- }
10
- on(eventName, listener, options = {}) {
11
- let collection = this.events[eventName];
12
- if (!collection) {
13
- collection = {
14
- highPriority: new Map(),
15
- regular: new Map()
16
- };
17
- this.events[eventName] = collection;
18
- }
19
- if (options.isFirst) {
20
- collection.highPriority.set(listener, true);
21
- } else {
22
- collection.regular.set(listener, true);
23
- }
24
- if (process.env.NODE_ENV !== 'production') {
25
- const collectionSize = collection.highPriority.size + collection.regular.size;
26
- if (collectionSize > this.maxListeners && !this.warnOnce) {
27
- this.warnOnce = true;
28
- console.warn([`Possible EventEmitter memory leak detected. ${collectionSize} ${eventName} listeners added.`].join('\n'));
29
- }
30
- }
31
- }
32
- removeListener(eventName, listener) {
33
- if (this.events[eventName]) {
34
- this.events[eventName].regular.delete(listener);
35
- this.events[eventName].highPriority.delete(listener);
36
- }
37
- }
38
- removeAllListeners() {
39
- this.events = {};
40
- }
41
- emit(eventName, ...args) {
42
- const collection = this.events[eventName];
43
- if (!collection) {
44
- return;
45
- }
46
- const highPriorityListeners = Array.from(collection.highPriority.keys());
47
- const regularListeners = Array.from(collection.regular.keys());
48
- for (let i = highPriorityListeners.length - 1; i >= 0; i -= 1) {
49
- const listener = highPriorityListeners[i];
50
- if (collection.highPriority.has(listener)) {
51
- listener.apply(this, args);
52
- }
53
- }
54
- for (let i = 0; i < regularListeners.length; i += 1) {
55
- const listener = regularListeners[i];
56
- if (collection.regular.has(listener)) {
57
- listener.apply(this, args);
58
- }
59
- }
60
- }
61
- once(eventName, listener) {
62
- // eslint-disable-next-line consistent-this
63
- const that = this;
64
- this.on(eventName, function oneTimeListener(...args) {
65
- that.removeListener(eventName, oneTimeListener);
66
- listener.apply(that, args);
67
- });
68
- }
69
- }
@@ -1,76 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.EventManager = void 0;
7
- // Used https://gist.github.com/mudge/5830382 as a starting point.
8
- // See https://github.com/browserify/events/blob/master/events.js for
9
- // the Node.js (https://nodejs.org/api/events.html) polyfill used by webpack.
10
- class EventManager {
11
- constructor() {
12
- this.maxListeners = 20;
13
- this.warnOnce = false;
14
- this.events = {};
15
- }
16
- on(eventName, listener, options = {}) {
17
- let collection = this.events[eventName];
18
- if (!collection) {
19
- collection = {
20
- highPriority: new Map(),
21
- regular: new Map()
22
- };
23
- this.events[eventName] = collection;
24
- }
25
- if (options.isFirst) {
26
- collection.highPriority.set(listener, true);
27
- } else {
28
- collection.regular.set(listener, true);
29
- }
30
- if (process.env.NODE_ENV !== 'production') {
31
- const collectionSize = collection.highPriority.size + collection.regular.size;
32
- if (collectionSize > this.maxListeners && !this.warnOnce) {
33
- this.warnOnce = true;
34
- console.warn([`Possible EventEmitter memory leak detected. ${collectionSize} ${eventName} listeners added.`].join('\n'));
35
- }
36
- }
37
- }
38
- removeListener(eventName, listener) {
39
- if (this.events[eventName]) {
40
- this.events[eventName].regular.delete(listener);
41
- this.events[eventName].highPriority.delete(listener);
42
- }
43
- }
44
- removeAllListeners() {
45
- this.events = {};
46
- }
47
- emit(eventName, ...args) {
48
- const collection = this.events[eventName];
49
- if (!collection) {
50
- return;
51
- }
52
- const highPriorityListeners = Array.from(collection.highPriority.keys());
53
- const regularListeners = Array.from(collection.regular.keys());
54
- for (let i = highPriorityListeners.length - 1; i >= 0; i -= 1) {
55
- const listener = highPriorityListeners[i];
56
- if (collection.highPriority.has(listener)) {
57
- listener.apply(this, args);
58
- }
59
- }
60
- for (let i = 0; i < regularListeners.length; i += 1) {
61
- const listener = regularListeners[i];
62
- if (collection.regular.has(listener)) {
63
- listener.apply(this, args);
64
- }
65
- }
66
- }
67
- once(eventName, listener) {
68
- // eslint-disable-next-line consistent-this
69
- const that = this;
70
- this.on(eventName, function oneTimeListener(...args) {
71
- that.removeListener(eventName, oneTimeListener);
72
- listener.apply(that, args);
73
- });
74
- }
75
- }
76
- exports.EventManager = EventManager;
@@ -1,29 +0,0 @@
1
- export type EventListener = (...args: any[]) => void;
2
- export interface EventListenerOptions {
3
- isFirst?: boolean;
4
- }
5
- interface EventListenerCollection {
6
- /**
7
- * List of listeners to run before the others
8
- * They are run in the opposite order of the registration order
9
- */
10
- highPriority: Map<EventListener, true>;
11
- /**
12
- * List of events to run after the high priority listeners
13
- * They are run in the registration order
14
- */
15
- regular: Map<EventListener, true>;
16
- }
17
- export declare class EventManager {
18
- maxListeners: number;
19
- warnOnce: boolean;
20
- events: {
21
- [eventName: string]: EventListenerCollection;
22
- };
23
- on(eventName: string, listener: EventListener, options?: EventListenerOptions): void;
24
- removeListener(eventName: string, listener: EventListener): void;
25
- removeAllListeners(): void;
26
- emit(eventName: string, ...args: any[]): void;
27
- once(eventName: string, listener: EventListener): void;
28
- }
29
- export {};
@@ -1,69 +0,0 @@
1
- // Used https://gist.github.com/mudge/5830382 as a starting point.
2
- // See https://github.com/browserify/events/blob/master/events.js for
3
- // the Node.js (https://nodejs.org/api/events.html) polyfill used by webpack.
4
- export class EventManager {
5
- constructor() {
6
- this.maxListeners = 20;
7
- this.warnOnce = false;
8
- this.events = {};
9
- }
10
- on(eventName, listener, options = {}) {
11
- let collection = this.events[eventName];
12
- if (!collection) {
13
- collection = {
14
- highPriority: new Map(),
15
- regular: new Map()
16
- };
17
- this.events[eventName] = collection;
18
- }
19
- if (options.isFirst) {
20
- collection.highPriority.set(listener, true);
21
- } else {
22
- collection.regular.set(listener, true);
23
- }
24
- if (process.env.NODE_ENV !== 'production') {
25
- const collectionSize = collection.highPriority.size + collection.regular.size;
26
- if (collectionSize > this.maxListeners && !this.warnOnce) {
27
- this.warnOnce = true;
28
- console.warn([`Possible EventEmitter memory leak detected. ${collectionSize} ${eventName} listeners added.`].join('\n'));
29
- }
30
- }
31
- }
32
- removeListener(eventName, listener) {
33
- if (this.events[eventName]) {
34
- this.events[eventName].regular.delete(listener);
35
- this.events[eventName].highPriority.delete(listener);
36
- }
37
- }
38
- removeAllListeners() {
39
- this.events = {};
40
- }
41
- emit(eventName, ...args) {
42
- const collection = this.events[eventName];
43
- if (!collection) {
44
- return;
45
- }
46
- const highPriorityListeners = Array.from(collection.highPriority.keys());
47
- const regularListeners = Array.from(collection.regular.keys());
48
- for (let i = highPriorityListeners.length - 1; i >= 0; i -= 1) {
49
- const listener = highPriorityListeners[i];
50
- if (collection.highPriority.has(listener)) {
51
- listener.apply(this, args);
52
- }
53
- }
54
- for (let i = 0; i < regularListeners.length; i += 1) {
55
- const listener = regularListeners[i];
56
- if (collection.regular.has(listener)) {
57
- listener.apply(this, args);
58
- }
59
- }
60
- }
61
- once(eventName, listener) {
62
- // eslint-disable-next-line consistent-this
63
- const that = this;
64
- this.on(eventName, function oneTimeListener(...args) {
65
- that.removeListener(eventName, oneTimeListener);
66
- listener.apply(that, args);
67
- });
68
- }
69
- }