material-react-table 0.8.12 → 0.8.13

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.
@@ -496,1483 +496,772 @@ var MRT_FilterOptionMenu = function MRT_FilterOptionMenu(_ref) {
496
496
  }));
497
497
  };
498
498
 
499
- var MRT_ColumnPinningButtons = function MRT_ColumnPinningButtons(_ref) {
500
- var column = _ref.column,
501
- tableInstance = _ref.tableInstance;
502
- var _tableInstance$option = tableInstance.options,
503
- PushPinIcon = _tableInstance$option.icons.PushPinIcon,
504
- localization = _tableInstance$option.localization;
499
+ /**
500
+ * Create the React Context
501
+ */ const DndContext = React.createContext({
502
+ dragDropManager: undefined
503
+ });
505
504
 
506
- var handlePinColumn = function handlePinColumn(pinDirection) {
507
- column.pin(pinDirection);
508
- };
505
+ // Inlined version of the `symbol-observable` polyfill
506
+ var $$observable = (function () {
507
+ return typeof Symbol === 'function' && Symbol.observable || '@@observable';
508
+ })();
509
509
 
510
- return React__default.createElement(material.Box, {
511
- sx: {
512
- mr: '8px'
513
- }
514
- }, column.getIsPinned() ? React__default.createElement(material.Tooltip, {
515
- arrow: true,
516
- title: localization.unpin
517
- }, React__default.createElement(material.IconButton, {
518
- onClick: function onClick() {
519
- return handlePinColumn(false);
520
- },
521
- size: "small"
522
- }, React__default.createElement(PushPinIcon, null))) : React__default.createElement(React__default.Fragment, null, React__default.createElement(material.Tooltip, {
523
- arrow: true,
524
- title: localization.pinToLeft
525
- }, React__default.createElement(material.IconButton, {
526
- onClick: function onClick() {
527
- return handlePinColumn('left');
528
- },
529
- size: "small"
530
- }, React__default.createElement(PushPinIcon, {
531
- style: {
532
- transform: 'rotate(90deg)'
533
- }
534
- }))), React__default.createElement(material.Tooltip, {
535
- arrow: true,
536
- title: localization.pinToRight
537
- }, React__default.createElement(material.IconButton, {
538
- onClick: function onClick() {
539
- return handlePinColumn('right');
540
- },
541
- size: "small"
542
- }, React__default.createElement(PushPinIcon, {
543
- style: {
544
- transform: 'rotate(-90deg)'
545
- }
546
- })))));
510
+ /**
511
+ * These are private action types reserved by Redux.
512
+ * For any unknown actions, you must return the current state.
513
+ * If the current state is undefined, you must return the initial state.
514
+ * Do not reference these action types directly in your code.
515
+ */
516
+ var randomString = function randomString() {
517
+ return Math.random().toString(36).substring(7).split('').join('.');
547
518
  };
548
519
 
549
- var MRT_ShowHideColumnsMenuItems = function MRT_ShowHideColumnsMenuItems(_ref) {
550
- var _column$columns2;
520
+ var ActionTypes = {
521
+ INIT: "@@redux/INIT" + randomString(),
522
+ REPLACE: "@@redux/REPLACE" + randomString(),
523
+ PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
524
+ return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
525
+ }
526
+ };
551
527
 
552
- var column = _ref.column,
553
- isSubMenu = _ref.isSubMenu,
554
- tableInstance = _ref.tableInstance;
555
- var getState = tableInstance.getState,
556
- onToggleColumnVisibility = tableInstance.options.onToggleColumnVisibility;
528
+ /**
529
+ * @param {any} obj The object to inspect.
530
+ * @returns {boolean} True if the argument appears to be a plain object.
531
+ */
532
+ function isPlainObject(obj) {
533
+ if (typeof obj !== 'object' || obj === null) return false;
534
+ var proto = obj;
557
535
 
558
- var _getState = getState(),
559
- columnVisibility = _getState.columnVisibility;
536
+ while (Object.getPrototypeOf(proto) !== null) {
537
+ proto = Object.getPrototypeOf(proto);
538
+ }
560
539
 
561
- var columnDef = column.columnDef,
562
- columnDefType = column.columnDefType;
563
- var switchChecked = columnDefType !== 'group' && column.getIsVisible() || columnDefType === 'group' && column.getLeafColumns().some(function (col) {
564
- return col.getIsVisible();
565
- });
540
+ return Object.getPrototypeOf(obj) === proto;
541
+ }
566
542
 
567
- var handleToggleColumnHidden = function handleToggleColumnHidden(column) {
568
- if (columnDefType === 'group') {
569
- var _column$columns;
543
+ // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
544
+ function miniKindOf(val) {
545
+ if (val === void 0) return 'undefined';
546
+ if (val === null) return 'null';
547
+ var type = typeof val;
570
548
 
571
- column == null ? void 0 : (_column$columns = column.columns) == null ? void 0 : _column$columns.forEach == null ? void 0 : _column$columns.forEach(function (childColumn) {
572
- childColumn.toggleVisibility(!switchChecked);
573
- });
574
- } else {
575
- column.toggleVisibility();
576
- }
549
+ switch (type) {
550
+ case 'boolean':
551
+ case 'string':
552
+ case 'number':
553
+ case 'symbol':
554
+ case 'function':
555
+ {
556
+ return type;
557
+ }
558
+ }
577
559
 
578
- onToggleColumnVisibility == null ? void 0 : onToggleColumnVisibility({
579
- column: column,
580
- columnVisibility: columnVisibility,
581
- tableInstance: tableInstance
582
- });
583
- };
560
+ if (Array.isArray(val)) return 'array';
561
+ if (isDate(val)) return 'date';
562
+ if (isError(val)) return 'error';
563
+ var constructorName = ctorName(val);
584
564
 
585
- return React__default.createElement(React__default.Fragment, null, React__default.createElement(material.MenuItem, {
586
- sx: {
587
- alignItems: 'center',
588
- justifyContent: 'flex-start',
589
- my: 0,
590
- pl: (column.depth + 0.5) * 2 + "rem",
591
- py: '6px'
592
- }
593
- }, !isSubMenu && column.getCanPin() && React__default.createElement(MRT_ColumnPinningButtons, {
594
- column: column,
595
- tableInstance: tableInstance
596
- }), React__default.createElement(material.FormControlLabel, {
597
- componentsProps: {
598
- typography: {
599
- sx: {
600
- marginBottom: 0,
601
- opacity: columnDefType !== 'display' ? 1 : 0.5
602
- }
603
- }
604
- },
605
- checked: switchChecked,
606
- control: React__default.createElement(material.Switch, null),
607
- disabled: isSubMenu && switchChecked || !column.getCanHide(),
608
- label: columnDef.header,
609
- onChange: function onChange() {
610
- return handleToggleColumnHidden(column);
611
- }
612
- })), (_column$columns2 = column.columns) == null ? void 0 : _column$columns2.map(function (c, i) {
613
- return React__default.createElement(MRT_ShowHideColumnsMenuItems, {
614
- key: i + "-" + c.id,
615
- column: c,
616
- isSubMenu: isSubMenu,
617
- tableInstance: tableInstance
618
- });
619
- }));
620
- };
565
+ switch (constructorName) {
566
+ case 'Symbol':
567
+ case 'Promise':
568
+ case 'WeakMap':
569
+ case 'WeakSet':
570
+ case 'Map':
571
+ case 'Set':
572
+ return constructorName;
573
+ } // other
621
574
 
622
- var MRT_ShowHideColumnsMenu = function MRT_ShowHideColumnsMenu(_ref) {
623
- var anchorEl = _ref.anchorEl,
624
- isSubMenu = _ref.isSubMenu,
625
- setAnchorEl = _ref.setAnchorEl,
626
- tableInstance = _ref.tableInstance;
627
- var getAllColumns = tableInstance.getAllColumns,
628
- getAllLeafColumns = tableInstance.getAllLeafColumns,
629
- getIsAllColumnsVisible = tableInstance.getIsAllColumnsVisible,
630
- getIsSomeColumnsPinned = tableInstance.getIsSomeColumnsPinned,
631
- getIsSomeColumnsVisible = tableInstance.getIsSomeColumnsVisible,
632
- getState = tableInstance.getState,
633
- toggleAllColumnsVisible = tableInstance.toggleAllColumnsVisible,
634
- _tableInstance$option = tableInstance.options,
635
- localization = _tableInstance$option.localization,
636
- enablePinning = _tableInstance$option.enablePinning,
637
- enableColumnOrdering = _tableInstance$option.enableColumnOrdering;
638
575
 
639
- var _getState = getState(),
640
- isDensePadding = _getState.isDensePadding,
641
- columnOrder = _getState.columnOrder,
642
- columnPinning = _getState.columnPinning;
576
+ return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
577
+ }
643
578
 
644
- var hideAllColumns = function hideAllColumns() {
645
- getAllLeafColumns().filter(function (col) {
646
- return col.columnDef.enableHiding !== false;
647
- }).forEach(function (col) {
648
- return col.toggleVisibility(false);
649
- });
650
- };
579
+ function ctorName(val) {
580
+ return typeof val.constructor === 'function' ? val.constructor.name : null;
581
+ }
651
582
 
652
- var allColumns = React.useMemo(function () {
653
- var columns = getAllColumns();
583
+ function isError(val) {
584
+ return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
585
+ }
654
586
 
655
- if (columnOrder.length > 0 && !columns.some(function (col) {
656
- return col.columnDefType === 'group';
657
- })) {
658
- var _columnOrder$map;
587
+ function isDate(val) {
588
+ if (val instanceof Date) return true;
589
+ return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
590
+ }
659
591
 
660
- return (_columnOrder$map = columnOrder.map(function (colId) {
661
- return columns.find(function (col) {
662
- return col.id === colId;
663
- });
664
- })) != null ? _columnOrder$map : columns;
665
- }
592
+ function kindOf(val) {
593
+ var typeOfVal = typeof val;
666
594
 
667
- return columns;
668
- }, [getAllColumns(), columnOrder, columnPinning]);
669
- return React__default.createElement(material.Menu, {
670
- anchorEl: anchorEl,
671
- open: !!anchorEl,
672
- onClose: function onClose() {
673
- return setAnchorEl(null);
674
- },
675
- MenuListProps: {
676
- dense: isDensePadding
677
- }
678
- }, React__default.createElement(material.Box, {
679
- sx: {
680
- display: 'flex',
681
- justifyContent: isSubMenu ? 'center' : 'space-between',
682
- p: '0.5rem',
683
- pt: 0
684
- }
685
- }, !isSubMenu && React__default.createElement(material.Button, {
686
- disabled: !getIsSomeColumnsVisible(),
687
- onClick: hideAllColumns
688
- }, localization.hideAll), !isSubMenu && enableColumnOrdering && React__default.createElement(material.Button, {
689
- onClick: function onClick() {
690
- return tableInstance.resetColumnOrder();
691
- }
692
- }, localization.resetOrder), !isSubMenu && enablePinning && React__default.createElement(material.Button, {
693
- disabled: !getIsSomeColumnsPinned(),
694
- onClick: function onClick() {
695
- return tableInstance.resetColumnPinning(true);
696
- }
697
- }, localization.unpinAll), React__default.createElement(material.Button, {
698
- disabled: getIsAllColumnsVisible(),
699
- onClick: function onClick() {
700
- return toggleAllColumnsVisible(true);
701
- }
702
- }, localization.showAll)), React__default.createElement(material.Divider, null), allColumns.map(function (column, index) {
703
- return React__default.createElement(MRT_ShowHideColumnsMenuItems, {
704
- column: column,
705
- isSubMenu: isSubMenu,
706
- key: index + "-" + column.id,
707
- tableInstance: tableInstance
708
- });
709
- }));
710
- };
595
+ {
596
+ typeOfVal = miniKindOf(val);
597
+ }
711
598
 
712
- var commonMenuItemStyles$1 = {
713
- py: '6px',
714
- my: 0,
715
- justifyContent: 'space-between',
716
- alignItems: 'center'
717
- };
718
- var commonListItemStyles = {
719
- display: 'flex',
720
- alignItems: 'center'
721
- };
722
- var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
723
- var _localization$sortByC, _localization$sortByC2, _localization$filterB, _localization, _localization$hideCol, _localization$showAll;
599
+ return typeOfVal;
600
+ }
724
601
 
725
- var anchorEl = _ref.anchorEl,
726
- header = _ref.header,
727
- setAnchorEl = _ref.setAnchorEl,
728
- tableInstance = _ref.tableInstance;
729
- var getState = tableInstance.getState,
730
- toggleAllColumnsVisible = tableInstance.toggleAllColumnsVisible,
731
- setColumnOrder = tableInstance.setColumnOrder,
732
- _tableInstance$option = tableInstance.options,
733
- enableColumnFilters = _tableInstance$option.enableColumnFilters,
734
- enableColumnResizing = _tableInstance$option.enableColumnResizing,
735
- enableGrouping = _tableInstance$option.enableGrouping,
736
- enableHiding = _tableInstance$option.enableHiding,
737
- enablePinning = _tableInstance$option.enablePinning,
738
- enableSorting = _tableInstance$option.enableSorting,
739
- _tableInstance$option2 = _tableInstance$option.icons,
740
- ArrowRightIcon = _tableInstance$option2.ArrowRightIcon,
741
- ClearAllIcon = _tableInstance$option2.ClearAllIcon,
742
- ViewColumnIcon = _tableInstance$option2.ViewColumnIcon,
743
- DynamicFeedIcon = _tableInstance$option2.DynamicFeedIcon,
744
- FilterListIcon = _tableInstance$option2.FilterListIcon,
745
- FilterListOffIcon = _tableInstance$option2.FilterListOffIcon,
746
- PushPinIcon = _tableInstance$option2.PushPinIcon,
747
- SortIcon = _tableInstance$option2.SortIcon,
748
- RestartAltIcon = _tableInstance$option2.RestartAltIcon,
749
- VisibilityOffIcon = _tableInstance$option2.VisibilityOffIcon,
750
- idPrefix = _tableInstance$option.idPrefix,
751
- localization = _tableInstance$option.localization,
752
- setShowFilters = tableInstance.setShowFilters;
753
- var column = header.column;
754
- var columnDef = column.columnDef;
602
+ /**
603
+ * @deprecated
604
+ *
605
+ * **We recommend using the `configureStore` method
606
+ * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
607
+ *
608
+ * Redux Toolkit is our recommended approach for writing Redux logic today,
609
+ * including store setup, reducers, data fetching, and more.
610
+ *
611
+ * **For more details, please read this Redux docs page:**
612
+ * **https://redux.js.org/introduction/why-rtk-is-redux-today**
613
+ *
614
+ * `configureStore` from Redux Toolkit is an improved version of `createStore` that
615
+ * simplifies setup and helps avoid common bugs.
616
+ *
617
+ * You should not be using the `redux` core package by itself today, except for learning purposes.
618
+ * The `createStore` method from the core `redux` package will not be removed, but we encourage
619
+ * all users to migrate to using Redux Toolkit for all Redux code.
620
+ *
621
+ * If you want to use `createStore` without this visual deprecation warning, use
622
+ * the `legacy_createStore` import instead:
623
+ *
624
+ * `import { legacy_createStore as createStore} from 'redux'`
625
+ *
626
+ */
755
627
 
756
- var _getState = getState(),
757
- columnSizing = _getState.columnSizing,
758
- columnVisibility = _getState.columnVisibility,
759
- isDensePadding = _getState.isDensePadding;
628
+ function createStore(reducer, preloadedState, enhancer) {
629
+ var _ref2;
760
630
 
761
- var _useState = React.useState(null),
762
- filterMenuAnchorEl = _useState[0],
763
- setFilterMenuAnchorEl = _useState[1];
631
+ if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
632
+ throw new Error( 'It looks like you are passing several store enhancers to ' + 'createStore(). This is not supported. Instead, compose them ' + 'together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.');
633
+ }
764
634
 
765
- var _useState2 = React.useState(null),
766
- showHideColumnsMenuAnchorEl = _useState2[0],
767
- setShowHideColumnsMenuAnchorEl = _useState2[1];
635
+ if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
636
+ enhancer = preloadedState;
637
+ preloadedState = undefined;
638
+ }
768
639
 
769
- var handleClearSort = function handleClearSort() {
770
- column.clearSorting();
771
- setAnchorEl(null);
772
- };
640
+ if (typeof enhancer !== 'undefined') {
641
+ if (typeof enhancer !== 'function') {
642
+ throw new Error( "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
643
+ }
773
644
 
774
- var handleSortAsc = function handleSortAsc() {
775
- column.toggleSorting(false);
776
- setAnchorEl(null);
777
- };
645
+ return enhancer(createStore)(reducer, preloadedState);
646
+ }
778
647
 
779
- var handleSortDesc = function handleSortDesc() {
780
- column.toggleSorting(true);
781
- setAnchorEl(null);
782
- };
648
+ if (typeof reducer !== 'function') {
649
+ throw new Error( "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
650
+ }
783
651
 
784
- var handleResetColumnSize = function handleResetColumnSize() {
785
- column.resetSize();
786
- setAnchorEl(null);
787
- };
652
+ var currentReducer = reducer;
653
+ var currentState = preloadedState;
654
+ var currentListeners = [];
655
+ var nextListeners = currentListeners;
656
+ var isDispatching = false;
657
+ /**
658
+ * This makes a shallow copy of currentListeners so we can use
659
+ * nextListeners as a temporary list while dispatching.
660
+ *
661
+ * This prevents any bugs around consumers calling
662
+ * subscribe/unsubscribe in the middle of a dispatch.
663
+ */
788
664
 
789
- var handleHideColumn = function handleHideColumn() {
790
- column.toggleVisibility(false);
791
- setAnchorEl(null);
792
- };
665
+ function ensureCanMutateNextListeners() {
666
+ if (nextListeners === currentListeners) {
667
+ nextListeners = currentListeners.slice();
668
+ }
669
+ }
670
+ /**
671
+ * Reads the state tree managed by the store.
672
+ *
673
+ * @returns {any} The current state tree of your application.
674
+ */
793
675
 
794
- var handlePinColumn = function handlePinColumn(pinDirection) {
795
- column.pin(pinDirection);
796
- setAnchorEl(null);
797
- };
798
676
 
799
- var handleGroupByColumn = function handleGroupByColumn() {
800
- column.toggleGrouping();
801
- setColumnOrder(function (old) {
802
- return ['mrt-expand'].concat(old);
803
- });
804
- setAnchorEl(null);
805
- };
677
+ function getState() {
678
+ if (isDispatching) {
679
+ throw new Error( 'You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.');
680
+ }
806
681
 
807
- var handleClearFilter = function handleClearFilter() {
808
- column.setFilterValue('');
809
- setAnchorEl(null);
810
- };
682
+ return currentState;
683
+ }
684
+ /**
685
+ * Adds a change listener. It will be called any time an action is dispatched,
686
+ * and some part of the state tree may potentially have changed. You may then
687
+ * call `getState()` to read the current state tree inside the callback.
688
+ *
689
+ * You may call `dispatch()` from a change listener, with the following
690
+ * caveats:
691
+ *
692
+ * 1. The subscriptions are snapshotted just before every `dispatch()` call.
693
+ * If you subscribe or unsubscribe while the listeners are being invoked, this
694
+ * will not have any effect on the `dispatch()` that is currently in progress.
695
+ * However, the next `dispatch()` call, whether nested or not, will use a more
696
+ * recent snapshot of the subscription list.
697
+ *
698
+ * 2. The listener should not expect to see all state changes, as the state
699
+ * might have been updated multiple times during a nested `dispatch()` before
700
+ * the listener is called. It is, however, guaranteed that all subscribers
701
+ * registered before the `dispatch()` started will be called with the latest
702
+ * state by the time it exits.
703
+ *
704
+ * @param {Function} listener A callback to be invoked on every dispatch.
705
+ * @returns {Function} A function to remove this change listener.
706
+ */
811
707
 
812
- var handleFilterByColumn = function handleFilterByColumn() {
813
- setShowFilters(true);
814
- setTimeout(function () {
815
- var _document$getElementB, _header$muiTableHeadC, _header$muiTableHeadC2;
816
708
 
817
- return (_document$getElementB = document.getElementById( // @ts-ignore
818
- (_header$muiTableHeadC = (_header$muiTableHeadC2 = header.muiTableHeadCellFilterTextFieldProps) == null ? void 0 : _header$muiTableHeadC2.id) != null ? _header$muiTableHeadC : "mrt-" + idPrefix + "-" + header.id + "-filter-text-field")) == null ? void 0 : _document$getElementB.focus();
819
- }, 200);
820
- setAnchorEl(null);
821
- };
709
+ function subscribe(listener) {
710
+ if (typeof listener !== 'function') {
711
+ throw new Error( "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
712
+ }
822
713
 
823
- var handleShowAllColumns = function handleShowAllColumns() {
824
- toggleAllColumnsVisible(true);
825
- setAnchorEl(null);
826
- };
714
+ if (isDispatching) {
715
+ throw new Error( 'You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
716
+ }
827
717
 
828
- var handleOpenFilterModeMenu = function handleOpenFilterModeMenu(event) {
829
- event.stopPropagation();
830
- setFilterMenuAnchorEl(event.currentTarget);
831
- };
718
+ var isSubscribed = true;
719
+ ensureCanMutateNextListeners();
720
+ nextListeners.push(listener);
721
+ return function unsubscribe() {
722
+ if (!isSubscribed) {
723
+ return;
724
+ }
832
725
 
833
- var handleOpenShowHideColumnsMenu = function handleOpenShowHideColumnsMenu(event) {
834
- event.stopPropagation();
835
- setShowHideColumnsMenuAnchorEl(event.currentTarget);
836
- };
726
+ if (isDispatching) {
727
+ throw new Error( 'You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
728
+ }
837
729
 
838
- return React__default.createElement(material.Menu, {
839
- anchorEl: anchorEl,
840
- open: !!anchorEl,
841
- onClose: function onClose() {
842
- return setAnchorEl(null);
843
- },
844
- MenuListProps: {
845
- dense: isDensePadding
846
- }
847
- }, enableSorting && column.getCanSort() && [React__default.createElement(material.MenuItem, {
848
- disabled: !column.getIsSorted(),
849
- key: 0,
850
- onClick: handleClearSort,
851
- sx: commonMenuItemStyles$1
852
- }, React__default.createElement(material.Box, {
853
- sx: commonListItemStyles
854
- }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(ClearAllIcon, null)), localization.clearSort)), React__default.createElement(material.MenuItem, {
855
- disabled: column.getIsSorted() === 'asc',
856
- key: 1,
857
- onClick: handleSortAsc,
858
- sx: commonMenuItemStyles$1
859
- }, React__default.createElement(material.Box, {
860
- sx: commonListItemStyles
861
- }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(SortIcon, null)), (_localization$sortByC = localization.sortByColumnAsc) == null ? void 0 : _localization$sortByC.replace('{column}', String(columnDef.header)))), React__default.createElement(material.MenuItem, {
862
- divider: enableColumnFilters || enableGrouping || enableHiding,
863
- key: 2,
864
- disabled: column.getIsSorted() === 'desc',
865
- onClick: handleSortDesc,
866
- sx: commonMenuItemStyles$1
867
- }, React__default.createElement(material.Box, {
868
- sx: commonListItemStyles
869
- }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(SortIcon, {
870
- style: {
871
- transform: 'rotate(180deg) scaleX(-1)'
872
- }
873
- })), (_localization$sortByC2 = localization.sortByColumnDesc) == null ? void 0 : _localization$sortByC2.replace('{column}', String(columnDef.header))))], enableColumnFilters && column.getCanFilter() && [React__default.createElement(material.MenuItem, {
874
- disabled: !column.getFilterValue(),
875
- key: 0,
876
- onClick: handleClearFilter,
877
- sx: commonMenuItemStyles$1
878
- }, React__default.createElement(material.Box, {
879
- sx: commonListItemStyles
880
- }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(FilterListOffIcon, null)), localization.clearFilter)), React__default.createElement(material.MenuItem, {
881
- divider: enableGrouping || enableHiding,
882
- key: 1,
883
- onClick: handleFilterByColumn,
884
- sx: commonMenuItemStyles$1
885
- }, React__default.createElement(material.Box, {
886
- sx: commonListItemStyles
887
- }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(FilterListIcon, null)), (_localization$filterB = localization.filterByColumn) == null ? void 0 : _localization$filterB.replace('{column}', String(columnDef.header))), !columnDef.filterSelectOptions && React__default.createElement(material.IconButton, {
888
- onClick: handleOpenFilterModeMenu,
889
- onMouseEnter: handleOpenFilterModeMenu,
890
- size: "small",
891
- sx: {
892
- p: 0
893
- }
894
- }, React__default.createElement(ArrowRightIcon, null))), React__default.createElement(MRT_FilterOptionMenu, {
895
- anchorEl: filterMenuAnchorEl,
896
- header: header,
897
- key: 2,
898
- onSelect: handleFilterByColumn,
899
- setAnchorEl: setFilterMenuAnchorEl,
900
- tableInstance: tableInstance
901
- })], enableGrouping && column.getCanGroup() && [React__default.createElement(material.MenuItem, {
902
- divider: enablePinning,
903
- key: 0,
904
- onClick: handleGroupByColumn,
905
- sx: commonMenuItemStyles$1
906
- }, React__default.createElement(material.Box, {
907
- sx: commonListItemStyles
908
- }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(DynamicFeedIcon, null)), (_localization = localization[column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn']) == null ? void 0 : _localization.replace('{column}', String(columnDef.header))))], enablePinning && column.getCanPin() && [React__default.createElement(material.MenuItem, {
909
- disabled: column.getIsPinned() === 'left' || !column.getCanPin(),
910
- key: 0,
911
- onClick: function onClick() {
912
- return handlePinColumn('left');
913
- },
914
- sx: commonMenuItemStyles$1
915
- }, React__default.createElement(material.Box, {
916
- sx: commonListItemStyles
917
- }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(PushPinIcon, {
918
- style: {
919
- transform: 'rotate(90deg)'
730
+ isSubscribed = false;
731
+ ensureCanMutateNextListeners();
732
+ var index = nextListeners.indexOf(listener);
733
+ nextListeners.splice(index, 1);
734
+ currentListeners = null;
735
+ };
736
+ }
737
+ /**
738
+ * Dispatches an action. It is the only way to trigger a state change.
739
+ *
740
+ * The `reducer` function, used to create the store, will be called with the
741
+ * current state tree and the given `action`. Its return value will
742
+ * be considered the **next** state of the tree, and the change listeners
743
+ * will be notified.
744
+ *
745
+ * The base implementation only supports plain object actions. If you want to
746
+ * dispatch a Promise, an Observable, a thunk, or something else, you need to
747
+ * wrap your store creating function into the corresponding middleware. For
748
+ * example, see the documentation for the `redux-thunk` package. Even the
749
+ * middleware will eventually dispatch plain object actions using this method.
750
+ *
751
+ * @param {Object} action A plain object representing “what changed”. It is
752
+ * a good idea to keep actions serializable so you can record and replay user
753
+ * sessions, or use the time travelling `redux-devtools`. An action must have
754
+ * a `type` property which may not be `undefined`. It is a good idea to use
755
+ * string constants for action types.
756
+ *
757
+ * @returns {Object} For convenience, the same action object you dispatched.
758
+ *
759
+ * Note that, if you use a custom middleware, it may wrap `dispatch()` to
760
+ * return something else (for example, a Promise you can await).
761
+ */
762
+
763
+
764
+ function dispatch(action) {
765
+ if (!isPlainObject(action)) {
766
+ throw new Error( "Actions must be plain objects. Instead, the actual type was: '" + kindOf(action) + "'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.");
920
767
  }
921
- })), localization.pinToLeft)), React__default.createElement(material.MenuItem, {
922
- disabled: column.getIsPinned() === 'right' || !column.getCanPin(),
923
- key: 1,
924
- onClick: function onClick() {
925
- return handlePinColumn('right');
926
- },
927
- sx: commonMenuItemStyles$1
928
- }, React__default.createElement(material.Box, {
929
- sx: commonListItemStyles
930
- }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(PushPinIcon, {
931
- style: {
932
- transform: 'rotate(-90deg)'
768
+
769
+ if (typeof action.type === 'undefined') {
770
+ throw new Error( 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
933
771
  }
934
- })), localization.pinToRight)), React__default.createElement(material.MenuItem, {
935
- disabled: !column.getIsPinned(),
936
- divider: enableHiding,
937
- key: 2,
938
- onClick: function onClick() {
939
- return handlePinColumn(false);
940
- },
941
- sx: commonMenuItemStyles$1
942
- }, React__default.createElement(material.Box, {
943
- sx: commonListItemStyles
944
- }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(PushPinIcon, null)), localization.unpin))], enableColumnResizing && [React__default.createElement(material.MenuItem, {
945
- disabled: !column.getCanResize() || !columnSizing[column.id],
946
- key: 0,
947
- onClick: handleResetColumnSize,
948
- sx: commonMenuItemStyles$1
949
- }, React__default.createElement(material.Box, {
950
- sx: commonListItemStyles
951
- }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(RestartAltIcon, null)), localization.resetColumnSize))], enableHiding && [React__default.createElement(material.MenuItem, {
952
- disabled: columnDef.enableHiding === false,
953
- key: 0,
954
- onClick: handleHideColumn,
955
- sx: commonMenuItemStyles$1
956
- }, React__default.createElement(material.Box, {
957
- sx: commonListItemStyles
958
- }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(VisibilityOffIcon, null)), (_localization$hideCol = localization.hideColumn) == null ? void 0 : _localization$hideCol.replace('{column}', String(columnDef.header)))), React__default.createElement(material.MenuItem, {
959
- disabled: !Object.values(columnVisibility).filter(function (visible) {
960
- return !visible;
961
- }).length,
962
- key: 1,
963
- onClick: handleShowAllColumns,
964
- sx: commonMenuItemStyles$1
965
- }, React__default.createElement(material.Box, {
966
- sx: commonListItemStyles
967
- }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(ViewColumnIcon, null)), (_localization$showAll = localization.showAllColumns) == null ? void 0 : _localization$showAll.replace('{column}', String(columnDef.header))), React__default.createElement(material.IconButton, {
968
- onClick: handleOpenShowHideColumnsMenu,
969
- onMouseEnter: handleOpenShowHideColumnsMenu,
970
- size: "small",
971
- sx: {
972
- p: 0
772
+
773
+ if (isDispatching) {
774
+ throw new Error( 'Reducers may not dispatch actions.');
973
775
  }
974
- }, React__default.createElement(ArrowRightIcon, null))), React__default.createElement(MRT_ShowHideColumnsMenu, {
975
- anchorEl: showHideColumnsMenuAnchorEl,
976
- isSubMenu: true,
977
- key: 2,
978
- setAnchorEl: setShowHideColumnsMenuAnchorEl,
979
- tableInstance: tableInstance
980
- })]);
981
- };
982
776
 
983
- var MRT_RowActionMenu = function MRT_RowActionMenu(_ref) {
984
- var anchorEl = _ref.anchorEl,
985
- handleEdit = _ref.handleEdit,
986
- row = _ref.row,
987
- setAnchorEl = _ref.setAnchorEl,
988
- tableInstance = _ref.tableInstance;
989
- var getState = tableInstance.getState,
990
- _tableInstance$option = tableInstance.options,
991
- EditIcon = _tableInstance$option.icons.EditIcon,
992
- enableEditing = _tableInstance$option.enableEditing,
993
- localization = _tableInstance$option.localization,
994
- renderRowActionMenuItems = _tableInstance$option.renderRowActionMenuItems;
777
+ try {
778
+ isDispatching = true;
779
+ currentState = currentReducer(currentState, action);
780
+ } finally {
781
+ isDispatching = false;
782
+ }
995
783
 
996
- var _getState = getState(),
997
- isDensePadding = _getState.isDensePadding;
784
+ var listeners = currentListeners = nextListeners;
998
785
 
999
- return React__default.createElement(material.Menu, {
1000
- anchorEl: anchorEl,
1001
- open: !!anchorEl,
1002
- onClose: function onClose() {
1003
- return setAnchorEl(null);
1004
- },
1005
- MenuListProps: {
1006
- dense: isDensePadding
1007
- }
1008
- }, enableEditing && React__default.createElement(material.MenuItem, {
1009
- onClick: handleEdit,
1010
- sx: commonMenuItemStyles$1
1011
- }, React__default.createElement(material.Box, {
1012
- sx: commonListItemStyles
1013
- }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(EditIcon, null)), localization.edit)), renderRowActionMenuItems == null ? void 0 : renderRowActionMenuItems({
1014
- row: row,
1015
- tableInstance: tableInstance,
1016
- closeMenu: function closeMenu() {
1017
- return setAnchorEl(null);
786
+ for (var i = 0; i < listeners.length; i++) {
787
+ var listener = listeners[i];
788
+ listener();
1018
789
  }
1019
- }));
1020
- };
1021
790
 
1022
- var MRT_EditActionButtons = function MRT_EditActionButtons(_ref) {
1023
- var row = _ref.row,
1024
- tableInstance = _ref.tableInstance;
1025
- var getState = tableInstance.getState,
1026
- _tableInstance$option = tableInstance.options,
1027
- _tableInstance$option2 = _tableInstance$option.icons,
1028
- CancelIcon = _tableInstance$option2.CancelIcon,
1029
- SaveIcon = _tableInstance$option2.SaveIcon,
1030
- localization = _tableInstance$option.localization,
1031
- onEditSubmit = _tableInstance$option.onEditSubmit,
1032
- setCurrentEditingRow = tableInstance.setCurrentEditingRow;
791
+ return action;
792
+ }
793
+ /**
794
+ * Replaces the reducer currently used by the store to calculate the state.
795
+ *
796
+ * You might need this if your app implements code splitting and you want to
797
+ * load some of the reducers dynamically. You might also need this if you
798
+ * implement a hot reloading mechanism for Redux.
799
+ *
800
+ * @param {Function} nextReducer The reducer for the store to use instead.
801
+ * @returns {void}
802
+ */
1033
803
 
1034
- var _getState = getState(),
1035
- currentEditingRow = _getState.currentEditingRow;
1036
804
 
1037
- var handleCancel = function handleCancel() {
1038
- var _row$original;
805
+ function replaceReducer(nextReducer) {
806
+ if (typeof nextReducer !== 'function') {
807
+ throw new Error( "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
808
+ }
1039
809
 
1040
- row._valuesCache = (_row$original = row.original) != null ? _row$original : {};
1041
- setCurrentEditingRow(null);
1042
- };
810
+ currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
811
+ // Any reducers that existed in both the new and old rootReducer
812
+ // will receive the previous state. This effectively populates
813
+ // the new state tree with any relevant data from the old one.
1043
814
 
1044
- var handleSave = function handleSave() {
1045
- onEditSubmit == null ? void 0 : onEditSubmit({
1046
- row: currentEditingRow != null ? currentEditingRow : row,
1047
- tableInstance: tableInstance
815
+ dispatch({
816
+ type: ActionTypes.REPLACE
1048
817
  });
1049
- setCurrentEditingRow(null);
1050
- };
1051
-
1052
- return React__default.createElement(material.Box, {
1053
- sx: {
1054
- display: 'flex',
1055
- gap: '0.75rem'
1056
- }
1057
- }, React__default.createElement(material.Tooltip, {
1058
- arrow: true,
1059
- title: localization.cancel
1060
- }, React__default.createElement(material.IconButton, {
1061
- "aria-label": localization.cancel,
1062
- onClick: handleCancel
1063
- }, React__default.createElement(CancelIcon, null))), React__default.createElement(material.Tooltip, {
1064
- arrow: true,
1065
- title: localization.save
1066
- }, React__default.createElement(material.IconButton, {
1067
- "aria-label": localization.save,
1068
- color: "info",
1069
- onClick: handleSave
1070
- }, React__default.createElement(SaveIcon, null))));
1071
- };
1072
-
1073
- var commonIconButtonStyles = {
1074
- height: '2rem',
1075
- ml: '10px',
1076
- opacity: 0.5,
1077
- transition: 'opacity 0.2s',
1078
- width: '2rem',
1079
- '&:hover': {
1080
- opacity: 1
1081
818
  }
1082
- };
1083
- var MRT_ToggleRowActionMenuButton = function MRT_ToggleRowActionMenuButton(_ref) {
1084
- var row = _ref.row,
1085
- tableInstance = _ref.tableInstance;
1086
- var getState = tableInstance.getState,
1087
- _tableInstance$option = tableInstance.options,
1088
- enableEditing = _tableInstance$option.enableEditing,
1089
- _tableInstance$option2 = _tableInstance$option.icons,
1090
- EditIcon = _tableInstance$option2.EditIcon,
1091
- MoreHorizIcon = _tableInstance$option2.MoreHorizIcon,
1092
- localization = _tableInstance$option.localization,
1093
- renderRowActionMenuItems = _tableInstance$option.renderRowActionMenuItems,
1094
- renderRowActions = _tableInstance$option.renderRowActions,
1095
- setCurrentEditingRow = tableInstance.setCurrentEditingRow;
1096
-
1097
- var _getState = getState(),
1098
- currentEditingRow = _getState.currentEditingRow;
1099
-
1100
- var _useState = React.useState(null),
1101
- anchorEl = _useState[0],
1102
- setAnchorEl = _useState[1];
819
+ /**
820
+ * Interoperability point for observable/reactive libraries.
821
+ * @returns {observable} A minimal observable of state changes.
822
+ * For more information, see the observable proposal:
823
+ * https://github.com/tc39/proposal-observable
824
+ */
1103
825
 
1104
- var handleOpenRowActionMenu = function handleOpenRowActionMenu(event) {
1105
- event.stopPropagation();
1106
- event.preventDefault();
1107
- setAnchorEl(event.currentTarget);
1108
- };
1109
826
 
1110
- var handleStartEditMode = function handleStartEditMode() {
1111
- setCurrentEditingRow(_extends({}, row));
1112
- setAnchorEl(null);
1113
- };
827
+ function observable() {
828
+ var _ref;
1114
829
 
1115
- return React__default.createElement(React__default.Fragment, null, renderRowActions ? React__default.createElement(React__default.Fragment, null, renderRowActions({
1116
- row: row,
1117
- tableInstance: tableInstance
1118
- })) : row.id === (currentEditingRow == null ? void 0 : currentEditingRow.id) ? React__default.createElement(MRT_EditActionButtons, {
1119
- row: row,
1120
- tableInstance: tableInstance
1121
- }) : !renderRowActionMenuItems && enableEditing ? React__default.createElement(material.Tooltip, {
1122
- placement: "right",
1123
- arrow: true,
1124
- title: localization.edit
1125
- }, React__default.createElement(material.IconButton, {
1126
- sx: commonIconButtonStyles,
1127
- onClick: handleStartEditMode
1128
- }, React__default.createElement(EditIcon, null))) : renderRowActionMenuItems ? React__default.createElement(React__default.Fragment, null, React__default.createElement(material.Tooltip, {
1129
- arrow: true,
1130
- enterDelay: 1000,
1131
- enterNextDelay: 1000,
1132
- title: localization.rowActions
1133
- }, React__default.createElement(material.IconButton, {
1134
- "aria-label": localization.rowActions,
1135
- onClick: handleOpenRowActionMenu,
1136
- size: "small",
1137
- sx: commonIconButtonStyles
1138
- }, React__default.createElement(MoreHorizIcon, null))), React__default.createElement(MRT_RowActionMenu, {
1139
- anchorEl: anchorEl,
1140
- handleEdit: handleStartEditMode,
1141
- row: row,
1142
- setAnchorEl: setAnchorEl,
1143
- tableInstance: tableInstance
1144
- })) : null);
1145
- };
830
+ var outerSubscribe = subscribe;
831
+ return _ref = {
832
+ /**
833
+ * The minimal observable subscription method.
834
+ * @param {Object} observer Any object that can be used as an observer.
835
+ * The observer object should have a `next` method.
836
+ * @returns {subscription} An object with an `unsubscribe` method that can
837
+ * be used to unsubscribe the observable from the store, and prevent further
838
+ * emission of values from the observable.
839
+ */
840
+ subscribe: function subscribe(observer) {
841
+ if (typeof observer !== 'object' || observer === null) {
842
+ throw new Error( "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
843
+ }
1146
844
 
1147
- var MRT_SelectCheckbox = function MRT_SelectCheckbox(_ref) {
1148
- var row = _ref.row,
1149
- selectAll = _ref.selectAll,
1150
- tableInstance = _ref.tableInstance;
1151
- var getRowModel = tableInstance.getRowModel,
1152
- getSelectedRowModel = tableInstance.getSelectedRowModel,
1153
- getState = tableInstance.getState,
1154
- _tableInstance$option = tableInstance.options,
1155
- localization = _tableInstance$option.localization,
1156
- muiSelectCheckboxProps = _tableInstance$option.muiSelectCheckboxProps,
1157
- onSelectChange = _tableInstance$option.onSelectChange,
1158
- onSelectAllChange = _tableInstance$option.onSelectAllChange;
845
+ function observeState() {
846
+ if (observer.next) {
847
+ observer.next(getState());
848
+ }
849
+ }
1159
850
 
1160
- var _getState = getState(),
1161
- isDensePadding = _getState.isDensePadding;
851
+ observeState();
852
+ var unsubscribe = outerSubscribe(observeState);
853
+ return {
854
+ unsubscribe: unsubscribe
855
+ };
856
+ }
857
+ }, _ref[$$observable] = function () {
858
+ return this;
859
+ }, _ref;
860
+ } // When a store is created, an "INIT" action is dispatched so that every
861
+ // reducer returns their initial state. This effectively populates
862
+ // the initial state tree.
1162
863
 
1163
- var handleSelectChange = function handleSelectChange(event) {
1164
- if (selectAll) {
1165
- tableInstance.getToggleAllRowsSelectedHandler()(event);
1166
- onSelectAllChange == null ? void 0 : onSelectAllChange({
1167
- event: event,
1168
- selectedRows: event.target.checked ? getRowModel().flatRows : [],
1169
- tableInstance: tableInstance
1170
- });
1171
- } else if (row) {
1172
- row == null ? void 0 : row.getToggleSelectedHandler()(event);
1173
- onSelectChange == null ? void 0 : onSelectChange({
1174
- event: event,
1175
- row: row,
1176
- selectedRows: event.target.checked ? [].concat(getSelectedRowModel().flatRows, [row]) : getSelectedRowModel().flatRows.filter(function (selectedRow) {
1177
- return selectedRow.id !== row.id;
1178
- }),
1179
- tableInstance: tableInstance
1180
- });
1181
- }
1182
- };
1183
864
 
1184
- var checkboxProps = muiSelectCheckboxProps instanceof Function ? muiSelectCheckboxProps({
1185
- isSelectAll: !!selectAll,
1186
- row: row,
1187
- tableInstance: tableInstance
1188
- }) : muiSelectCheckboxProps;
1189
- return React__default.createElement(material.Tooltip, {
1190
- arrow: true,
1191
- enterDelay: 1000,
1192
- enterNextDelay: 1000,
1193
- title: selectAll ? localization.toggleSelectAll : localization.toggleSelectRow
1194
- }, React__default.createElement(material.Checkbox, Object.assign({
1195
- checked: selectAll ? tableInstance.getIsAllRowsSelected() : row == null ? void 0 : row.getIsSelected(),
1196
- indeterminate: selectAll ? tableInstance.getIsSomeRowsSelected() : row == null ? void 0 : row.getIsSomeSelected(),
1197
- inputProps: {
1198
- 'aria-label': selectAll ? localization.toggleSelectAll : localization.toggleSelectRow
1199
- },
1200
- onChange: handleSelectChange,
1201
- size: isDensePadding ? 'small' : 'medium'
1202
- }, checkboxProps, {
1203
- sx: _extends({
1204
- height: isDensePadding ? '1.75rem' : '2.25rem',
1205
- width: isDensePadding ? '1.75rem' : '2.25rem'
1206
- }, checkboxProps == null ? void 0 : checkboxProps.sx)
1207
- })));
1208
- };
865
+ dispatch({
866
+ type: ActionTypes.INIT
867
+ });
868
+ return _ref2 = {
869
+ dispatch: dispatch,
870
+ subscribe: subscribe,
871
+ getState: getState,
872
+ replaceReducer: replaceReducer
873
+ }, _ref2[$$observable] = observable, _ref2;
874
+ }
1209
875
 
1210
876
  /**
1211
- * Create the React Context
1212
- */ const DndContext = React.createContext({
1213
- dragDropManager: undefined
1214
- });
877
+ * Prints a warning in the console if it exists.
878
+ *
879
+ * @param {String} message The warning message.
880
+ * @returns {void}
881
+ */
882
+ function warning(message) {
883
+ /* eslint-disable no-console */
884
+ if (typeof console !== 'undefined' && typeof console.error === 'function') {
885
+ console.error(message);
886
+ }
887
+ /* eslint-enable no-console */
1215
888
 
1216
- // Inlined version of the `symbol-observable` polyfill
1217
- var $$observable = (function () {
1218
- return typeof Symbol === 'function' && Symbol.observable || '@@observable';
1219
- })();
1220
889
 
1221
- /**
1222
- * These are private action types reserved by Redux.
1223
- * For any unknown actions, you must return the current state.
1224
- * If the current state is undefined, you must return the initial state.
1225
- * Do not reference these action types directly in your code.
1226
- */
1227
- var randomString = function randomString() {
1228
- return Math.random().toString(36).substring(7).split('').join('.');
1229
- };
890
+ try {
891
+ // This error was thrown as a convenience so that if you enable
892
+ // "break on all exceptions" in your console,
893
+ // it would pause the execution at this line.
894
+ throw new Error(message);
895
+ } catch (e) {} // eslint-disable-line no-empty
1230
896
 
1231
- var ActionTypes = {
1232
- INIT: "@@redux/INIT" + randomString(),
1233
- REPLACE: "@@redux/REPLACE" + randomString(),
1234
- PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
1235
- return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
1236
- }
1237
- };
897
+ }
1238
898
 
1239
- /**
1240
- * @param {any} obj The object to inspect.
1241
- * @returns {boolean} True if the argument appears to be a plain object.
899
+ /*
900
+ * This is a dummy function to check if the function name has been altered by minification.
901
+ * If the function has been minified and NODE_ENV !== 'production', warn the user.
1242
902
  */
1243
- function isPlainObject(obj) {
1244
- if (typeof obj !== 'object' || obj === null) return false;
1245
- var proto = obj;
1246
903
 
1247
- while (Object.getPrototypeOf(proto) !== null) {
1248
- proto = Object.getPrototypeOf(proto);
1249
- }
904
+ function isCrushed() {}
1250
905
 
1251
- return Object.getPrototypeOf(obj) === proto;
906
+ if ( typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') {
907
+ warning('You are currently using minified code outside of NODE_ENV === "production". ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or setting mode to production in webpack (https://webpack.js.org/concepts/mode/) ' + 'to ensure you have the correct code for your production build.');
1252
908
  }
1253
909
 
1254
- // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
1255
- function miniKindOf(val) {
1256
- if (val === void 0) return 'undefined';
1257
- if (val === null) return 'null';
1258
- var type = typeof val;
1259
-
1260
- switch (type) {
1261
- case 'boolean':
1262
- case 'string':
1263
- case 'number':
1264
- case 'symbol':
1265
- case 'function':
1266
- {
1267
- return type;
1268
- }
1269
- }
1270
-
1271
- if (Array.isArray(val)) return 'array';
1272
- if (isDate(val)) return 'date';
1273
- if (isError(val)) return 'error';
1274
- var constructorName = ctorName(val);
1275
-
1276
- switch (constructorName) {
1277
- case 'Symbol':
1278
- case 'Promise':
1279
- case 'WeakMap':
1280
- case 'WeakSet':
1281
- case 'Map':
1282
- case 'Set':
1283
- return constructorName;
1284
- } // other
1285
-
1286
-
1287
- return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
910
+ /**
911
+ * Use invariant() to assert state which your program assumes to be true.
912
+ *
913
+ * Provide sprintf-style format (only %s is supported) and arguments
914
+ * to provide information about what broke and what you were
915
+ * expecting.
916
+ *
917
+ * The invariant message will be stripped in production, but the invariant
918
+ * will remain to ensure logic does not differ in production.
919
+ */ function invariant(condition, format, ...args) {
920
+ if (isProduction()) {
921
+ if (format === undefined) {
922
+ throw new Error('invariant requires an error message argument');
923
+ }
924
+ }
925
+ if (!condition) {
926
+ let error;
927
+ if (format === undefined) {
928
+ error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
929
+ } else {
930
+ let argIndex = 0;
931
+ error = new Error(format.replace(/%s/g, function() {
932
+ return args[argIndex++];
933
+ }));
934
+ error.name = 'Invariant Violation';
935
+ }
936
+ error.framesToPop = 1 // we don't care about invariant's own frame
937
+ ;
938
+ throw error;
939
+ }
1288
940
  }
1289
-
1290
- function ctorName(val) {
1291
- return typeof val.constructor === 'function' ? val.constructor.name : null;
941
+ function isProduction() {
942
+ return typeof process !== 'undefined' && process.env['NODE_ENV'] === 'production';
1292
943
  }
1293
944
 
1294
- function isError(val) {
1295
- return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
945
+ // cheap lodash replacements
946
+ /**
947
+ * drop-in replacement for _.get
948
+ * @param obj
949
+ * @param path
950
+ * @param defaultValue
951
+ */ function get(obj, path, defaultValue) {
952
+ return path.split('.').reduce((a, c)=>a && a[c] ? a[c] : defaultValue || null
953
+ , obj);
1296
954
  }
1297
-
1298
- function isDate(val) {
1299
- if (val instanceof Date) return true;
1300
- return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
955
+ /**
956
+ * drop-in replacement for _.without
957
+ */ function without(items, item) {
958
+ return items.filter((i)=>i !== item
959
+ );
1301
960
  }
1302
-
1303
- function kindOf(val) {
1304
- var typeOfVal = typeof val;
1305
-
1306
- {
1307
- typeOfVal = miniKindOf(val);
1308
- }
1309
-
1310
- return typeOfVal;
961
+ /**
962
+ * drop-in replacement for _.isString
963
+ * @param input
964
+ */ function isObject(input) {
965
+ return typeof input === 'object';
1311
966
  }
1312
-
1313
967
  /**
1314
- * @deprecated
1315
- *
1316
- * **We recommend using the `configureStore` method
1317
- * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
1318
- *
1319
- * Redux Toolkit is our recommended approach for writing Redux logic today,
1320
- * including store setup, reducers, data fetching, and more.
1321
- *
1322
- * **For more details, please read this Redux docs page:**
1323
- * **https://redux.js.org/introduction/why-rtk-is-redux-today**
1324
- *
1325
- * `configureStore` from Redux Toolkit is an improved version of `createStore` that
1326
- * simplifies setup and helps avoid common bugs.
1327
- *
1328
- * You should not be using the `redux` core package by itself today, except for learning purposes.
1329
- * The `createStore` method from the core `redux` package will not be removed, but we encourage
1330
- * all users to migrate to using Redux Toolkit for all Redux code.
1331
- *
1332
- * If you want to use `createStore` without this visual deprecation warning, use
1333
- * the `legacy_createStore` import instead:
1334
- *
1335
- * `import { legacy_createStore as createStore} from 'redux'`
1336
- *
1337
- */
1338
-
1339
- function createStore(reducer, preloadedState, enhancer) {
1340
- var _ref2;
1341
-
1342
- if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
1343
- throw new Error( 'It looks like you are passing several store enhancers to ' + 'createStore(). This is not supported. Instead, compose them ' + 'together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.');
1344
- }
1345
-
1346
- if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
1347
- enhancer = preloadedState;
1348
- preloadedState = undefined;
1349
- }
1350
-
1351
- if (typeof enhancer !== 'undefined') {
1352
- if (typeof enhancer !== 'function') {
1353
- throw new Error( "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
1354
- }
1355
-
1356
- return enhancer(createStore)(reducer, preloadedState);
1357
- }
1358
-
1359
- if (typeof reducer !== 'function') {
1360
- throw new Error( "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
1361
- }
1362
-
1363
- var currentReducer = reducer;
1364
- var currentState = preloadedState;
1365
- var currentListeners = [];
1366
- var nextListeners = currentListeners;
1367
- var isDispatching = false;
1368
- /**
1369
- * This makes a shallow copy of currentListeners so we can use
1370
- * nextListeners as a temporary list while dispatching.
1371
- *
1372
- * This prevents any bugs around consumers calling
1373
- * subscribe/unsubscribe in the middle of a dispatch.
1374
- */
1375
-
1376
- function ensureCanMutateNextListeners() {
1377
- if (nextListeners === currentListeners) {
1378
- nextListeners = currentListeners.slice();
1379
- }
1380
- }
1381
- /**
1382
- * Reads the state tree managed by the store.
1383
- *
1384
- * @returns {any} The current state tree of your application.
1385
- */
1386
-
1387
-
1388
- function getState() {
1389
- if (isDispatching) {
1390
- throw new Error( 'You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.');
1391
- }
968
+ * replacement for _.xor
969
+ * @param itemsA
970
+ * @param itemsB
971
+ */ function xor(itemsA, itemsB) {
972
+ const map = new Map();
973
+ const insertItem = (item)=>{
974
+ map.set(item, map.has(item) ? map.get(item) + 1 : 1);
975
+ };
976
+ itemsA.forEach(insertItem);
977
+ itemsB.forEach(insertItem);
978
+ const result = [];
979
+ map.forEach((count, key)=>{
980
+ if (count === 1) {
981
+ result.push(key);
982
+ }
983
+ });
984
+ return result;
985
+ }
986
+ /**
987
+ * replacement for _.intersection
988
+ * @param itemsA
989
+ * @param itemsB
990
+ */ function intersection(itemsA, itemsB) {
991
+ return itemsA.filter((t)=>itemsB.indexOf(t) > -1
992
+ );
993
+ }
1392
994
 
1393
- return currentState;
1394
- }
1395
- /**
1396
- * Adds a change listener. It will be called any time an action is dispatched,
1397
- * and some part of the state tree may potentially have changed. You may then
1398
- * call `getState()` to read the current state tree inside the callback.
1399
- *
1400
- * You may call `dispatch()` from a change listener, with the following
1401
- * caveats:
1402
- *
1403
- * 1. The subscriptions are snapshotted just before every `dispatch()` call.
1404
- * If you subscribe or unsubscribe while the listeners are being invoked, this
1405
- * will not have any effect on the `dispatch()` that is currently in progress.
1406
- * However, the next `dispatch()` call, whether nested or not, will use a more
1407
- * recent snapshot of the subscription list.
1408
- *
1409
- * 2. The listener should not expect to see all state changes, as the state
1410
- * might have been updated multiple times during a nested `dispatch()` before
1411
- * the listener is called. It is, however, guaranteed that all subscribers
1412
- * registered before the `dispatch()` started will be called with the latest
1413
- * state by the time it exits.
1414
- *
1415
- * @param {Function} listener A callback to be invoked on every dispatch.
1416
- * @returns {Function} A function to remove this change listener.
1417
- */
995
+ const INIT_COORDS = 'dnd-core/INIT_COORDS';
996
+ const BEGIN_DRAG = 'dnd-core/BEGIN_DRAG';
997
+ const PUBLISH_DRAG_SOURCE = 'dnd-core/PUBLISH_DRAG_SOURCE';
998
+ const HOVER = 'dnd-core/HOVER';
999
+ const DROP = 'dnd-core/DROP';
1000
+ const END_DRAG = 'dnd-core/END_DRAG';
1418
1001
 
1002
+ function setClientOffset(clientOffset, sourceClientOffset) {
1003
+ return {
1004
+ type: INIT_COORDS,
1005
+ payload: {
1006
+ sourceClientOffset: sourceClientOffset || null,
1007
+ clientOffset: clientOffset || null
1008
+ }
1009
+ };
1010
+ }
1419
1011
 
1420
- function subscribe(listener) {
1421
- if (typeof listener !== 'function') {
1422
- throw new Error( "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
1012
+ const ResetCoordinatesAction = {
1013
+ type: INIT_COORDS,
1014
+ payload: {
1015
+ clientOffset: null,
1016
+ sourceClientOffset: null
1423
1017
  }
1424
-
1425
- if (isDispatching) {
1426
- throw new Error( 'You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
1427
- }
1428
-
1429
- var isSubscribed = true;
1430
- ensureCanMutateNextListeners();
1431
- nextListeners.push(listener);
1432
- return function unsubscribe() {
1433
- if (!isSubscribed) {
1434
- return;
1435
- }
1436
-
1437
- if (isDispatching) {
1438
- throw new Error( 'You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
1439
- }
1440
-
1441
- isSubscribed = false;
1442
- ensureCanMutateNextListeners();
1443
- var index = nextListeners.indexOf(listener);
1444
- nextListeners.splice(index, 1);
1445
- currentListeners = null;
1018
+ };
1019
+ function createBeginDrag(manager) {
1020
+ return function beginDrag(sourceIds = [], options = {
1021
+ publishSource: true
1022
+ }) {
1023
+ const { publishSource =true , clientOffset , getSourceClientOffset , } = options;
1024
+ const monitor = manager.getMonitor();
1025
+ const registry = manager.getRegistry();
1026
+ // Initialize the coordinates using the client offset
1027
+ manager.dispatch(setClientOffset(clientOffset));
1028
+ verifyInvariants(sourceIds, monitor, registry);
1029
+ // Get the draggable source
1030
+ const sourceId = getDraggableSource(sourceIds, monitor);
1031
+ if (sourceId == null) {
1032
+ manager.dispatch(ResetCoordinatesAction);
1033
+ return;
1034
+ }
1035
+ // Get the source client offset
1036
+ let sourceClientOffset = null;
1037
+ if (clientOffset) {
1038
+ if (!getSourceClientOffset) {
1039
+ throw new Error('getSourceClientOffset must be defined');
1040
+ }
1041
+ verifyGetSourceClientOffsetIsFunction(getSourceClientOffset);
1042
+ sourceClientOffset = getSourceClientOffset(sourceId);
1043
+ }
1044
+ // Initialize the full coordinates
1045
+ manager.dispatch(setClientOffset(clientOffset, sourceClientOffset));
1046
+ const source = registry.getSource(sourceId);
1047
+ const item = source.beginDrag(monitor, sourceId);
1048
+ // If source.beginDrag returns null, this is an indicator to cancel the drag
1049
+ if (item == null) {
1050
+ return undefined;
1051
+ }
1052
+ verifyItemIsObject(item);
1053
+ registry.pinSource(sourceId);
1054
+ const itemType = registry.getSourceType(sourceId);
1055
+ return {
1056
+ type: BEGIN_DRAG,
1057
+ payload: {
1058
+ itemType,
1059
+ item,
1060
+ sourceId,
1061
+ clientOffset: clientOffset || null,
1062
+ sourceClientOffset: sourceClientOffset || null,
1063
+ isSourcePublic: !!publishSource
1064
+ }
1065
+ };
1446
1066
  };
1447
- }
1448
- /**
1449
- * Dispatches an action. It is the only way to trigger a state change.
1450
- *
1451
- * The `reducer` function, used to create the store, will be called with the
1452
- * current state tree and the given `action`. Its return value will
1453
- * be considered the **next** state of the tree, and the change listeners
1454
- * will be notified.
1455
- *
1456
- * The base implementation only supports plain object actions. If you want to
1457
- * dispatch a Promise, an Observable, a thunk, or something else, you need to
1458
- * wrap your store creating function into the corresponding middleware. For
1459
- * example, see the documentation for the `redux-thunk` package. Even the
1460
- * middleware will eventually dispatch plain object actions using this method.
1461
- *
1462
- * @param {Object} action A plain object representing “what changed”. It is
1463
- * a good idea to keep actions serializable so you can record and replay user
1464
- * sessions, or use the time travelling `redux-devtools`. An action must have
1465
- * a `type` property which may not be `undefined`. It is a good idea to use
1466
- * string constants for action types.
1467
- *
1468
- * @returns {Object} For convenience, the same action object you dispatched.
1469
- *
1470
- * Note that, if you use a custom middleware, it may wrap `dispatch()` to
1471
- * return something else (for example, a Promise you can await).
1472
- */
1473
-
1474
-
1475
- function dispatch(action) {
1476
- if (!isPlainObject(action)) {
1477
- throw new Error( "Actions must be plain objects. Instead, the actual type was: '" + kindOf(action) + "'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.");
1478
- }
1479
-
1480
- if (typeof action.type === 'undefined') {
1481
- throw new Error( 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
1067
+ }
1068
+ function verifyInvariants(sourceIds, monitor, registry) {
1069
+ invariant(!monitor.isDragging(), 'Cannot call beginDrag while dragging.');
1070
+ sourceIds.forEach(function(sourceId) {
1071
+ invariant(registry.getSource(sourceId), 'Expected sourceIds to be registered.');
1072
+ });
1073
+ }
1074
+ function verifyGetSourceClientOffsetIsFunction(getSourceClientOffset) {
1075
+ invariant(typeof getSourceClientOffset === 'function', 'When clientOffset is provided, getSourceClientOffset must be a function.');
1076
+ }
1077
+ function verifyItemIsObject(item) {
1078
+ invariant(isObject(item), 'Item must be an object.');
1079
+ }
1080
+ function getDraggableSource(sourceIds, monitor) {
1081
+ let sourceId = null;
1082
+ for(let i = sourceIds.length - 1; i >= 0; i--){
1083
+ if (monitor.canDragSource(sourceIds[i])) {
1084
+ sourceId = sourceIds[i];
1085
+ break;
1086
+ }
1482
1087
  }
1088
+ return sourceId;
1089
+ }
1483
1090
 
1484
- if (isDispatching) {
1485
- throw new Error( 'Reducers may not dispatch actions.');
1091
+ function _defineProperty(obj, key, value) {
1092
+ if (key in obj) {
1093
+ Object.defineProperty(obj, key, {
1094
+ value: value,
1095
+ enumerable: true,
1096
+ configurable: true,
1097
+ writable: true
1098
+ });
1099
+ } else {
1100
+ obj[key] = value;
1486
1101
  }
1487
-
1488
- try {
1489
- isDispatching = true;
1490
- currentState = currentReducer(currentState, action);
1491
- } finally {
1492
- isDispatching = false;
1102
+ return obj;
1103
+ }
1104
+ function _objectSpread(target) {
1105
+ for(var i = 1; i < arguments.length; i++){
1106
+ var source = arguments[i] != null ? arguments[i] : {};
1107
+ var ownKeys = Object.keys(source);
1108
+ if (typeof Object.getOwnPropertySymbols === 'function') {
1109
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
1110
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1111
+ }));
1112
+ }
1113
+ ownKeys.forEach(function(key) {
1114
+ _defineProperty(target, key, source[key]);
1115
+ });
1493
1116
  }
1494
-
1495
- var listeners = currentListeners = nextListeners;
1496
-
1497
- for (var i = 0; i < listeners.length; i++) {
1498
- var listener = listeners[i];
1499
- listener();
1117
+ return target;
1118
+ }
1119
+ function createDrop(manager) {
1120
+ return function drop(options = {}) {
1121
+ const monitor = manager.getMonitor();
1122
+ const registry = manager.getRegistry();
1123
+ verifyInvariants$1(monitor);
1124
+ const targetIds = getDroppableTargets(monitor);
1125
+ // Multiple actions are dispatched here, which is why this doesn't return an action
1126
+ targetIds.forEach((targetId, index)=>{
1127
+ const dropResult = determineDropResult(targetId, index, registry, monitor);
1128
+ const action = {
1129
+ type: DROP,
1130
+ payload: {
1131
+ dropResult: _objectSpread({}, options, dropResult)
1132
+ }
1133
+ };
1134
+ manager.dispatch(action);
1135
+ });
1136
+ };
1137
+ }
1138
+ function verifyInvariants$1(monitor) {
1139
+ invariant(monitor.isDragging(), 'Cannot call drop while not dragging.');
1140
+ invariant(!monitor.didDrop(), 'Cannot call drop twice during one drag operation.');
1141
+ }
1142
+ function determineDropResult(targetId, index, registry, monitor) {
1143
+ const target = registry.getTarget(targetId);
1144
+ let dropResult = target ? target.drop(monitor, targetId) : undefined;
1145
+ verifyDropResultType(dropResult);
1146
+ if (typeof dropResult === 'undefined') {
1147
+ dropResult = index === 0 ? {} : monitor.getDropResult();
1500
1148
  }
1149
+ return dropResult;
1150
+ }
1151
+ function verifyDropResultType(dropResult) {
1152
+ invariant(typeof dropResult === 'undefined' || isObject(dropResult), 'Drop result must either be an object or undefined.');
1153
+ }
1154
+ function getDroppableTargets(monitor) {
1155
+ const targetIds = monitor.getTargetIds().filter(monitor.canDropOnTarget, monitor);
1156
+ targetIds.reverse();
1157
+ return targetIds;
1158
+ }
1501
1159
 
1502
- return action;
1503
- }
1504
- /**
1505
- * Replaces the reducer currently used by the store to calculate the state.
1506
- *
1507
- * You might need this if your app implements code splitting and you want to
1508
- * load some of the reducers dynamically. You might also need this if you
1509
- * implement a hot reloading mechanism for Redux.
1510
- *
1511
- * @param {Function} nextReducer The reducer for the store to use instead.
1512
- * @returns {void}
1513
- */
1514
-
1160
+ function createEndDrag(manager) {
1161
+ return function endDrag() {
1162
+ const monitor = manager.getMonitor();
1163
+ const registry = manager.getRegistry();
1164
+ verifyIsDragging(monitor);
1165
+ const sourceId = monitor.getSourceId();
1166
+ if (sourceId != null) {
1167
+ const source = registry.getSource(sourceId, true);
1168
+ source.endDrag(monitor, sourceId);
1169
+ registry.unpinSource();
1170
+ }
1171
+ return {
1172
+ type: END_DRAG
1173
+ };
1174
+ };
1175
+ }
1176
+ function verifyIsDragging(monitor) {
1177
+ invariant(monitor.isDragging(), 'Cannot call endDrag while not dragging.');
1178
+ }
1515
1179
 
1516
- function replaceReducer(nextReducer) {
1517
- if (typeof nextReducer !== 'function') {
1518
- throw new Error( "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
1180
+ function matchesType(targetType, draggedItemType) {
1181
+ if (draggedItemType === null) {
1182
+ return targetType === null;
1519
1183
  }
1184
+ return Array.isArray(targetType) ? targetType.some((t)=>t === draggedItemType
1185
+ ) : targetType === draggedItemType;
1186
+ }
1520
1187
 
1521
- currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
1522
- // Any reducers that existed in both the new and old rootReducer
1523
- // will receive the previous state. This effectively populates
1524
- // the new state tree with any relevant data from the old one.
1525
-
1526
- dispatch({
1527
- type: ActionTypes.REPLACE
1528
- });
1529
- }
1530
- /**
1531
- * Interoperability point for observable/reactive libraries.
1532
- * @returns {observable} A minimal observable of state changes.
1533
- * For more information, see the observable proposal:
1534
- * https://github.com/tc39/proposal-observable
1535
- */
1536
-
1537
-
1538
- function observable() {
1539
- var _ref;
1540
-
1541
- var outerSubscribe = subscribe;
1542
- return _ref = {
1543
- /**
1544
- * The minimal observable subscription method.
1545
- * @param {Object} observer Any object that can be used as an observer.
1546
- * The observer object should have a `next` method.
1547
- * @returns {subscription} An object with an `unsubscribe` method that can
1548
- * be used to unsubscribe the observable from the store, and prevent further
1549
- * emission of values from the observable.
1550
- */
1551
- subscribe: function subscribe(observer) {
1552
- if (typeof observer !== 'object' || observer === null) {
1553
- throw new Error( "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
1554
- }
1555
-
1556
- function observeState() {
1557
- if (observer.next) {
1558
- observer.next(getState());
1559
- }
1560
- }
1561
-
1562
- observeState();
1563
- var unsubscribe = outerSubscribe(observeState);
1188
+ function createHover(manager) {
1189
+ return function hover(targetIdsArg, { clientOffset } = {}) {
1190
+ verifyTargetIdsIsArray(targetIdsArg);
1191
+ const targetIds = targetIdsArg.slice(0);
1192
+ const monitor = manager.getMonitor();
1193
+ const registry = manager.getRegistry();
1194
+ const draggedItemType = monitor.getItemType();
1195
+ removeNonMatchingTargetIds(targetIds, registry, draggedItemType);
1196
+ checkInvariants(targetIds, monitor, registry);
1197
+ hoverAllTargets(targetIds, monitor, registry);
1564
1198
  return {
1565
- unsubscribe: unsubscribe
1199
+ type: HOVER,
1200
+ payload: {
1201
+ targetIds,
1202
+ clientOffset: clientOffset || null
1203
+ }
1566
1204
  };
1567
- }
1568
- }, _ref[$$observable] = function () {
1569
- return this;
1570
- }, _ref;
1571
- } // When a store is created, an "INIT" action is dispatched so that every
1572
- // reducer returns their initial state. This effectively populates
1573
- // the initial state tree.
1574
-
1575
-
1576
- dispatch({
1577
- type: ActionTypes.INIT
1578
- });
1579
- return _ref2 = {
1580
- dispatch: dispatch,
1581
- subscribe: subscribe,
1582
- getState: getState,
1583
- replaceReducer: replaceReducer
1584
- }, _ref2[$$observable] = observable, _ref2;
1585
- }
1586
-
1587
- /**
1588
- * Prints a warning in the console if it exists.
1589
- *
1590
- * @param {String} message The warning message.
1591
- * @returns {void}
1592
- */
1593
- function warning(message) {
1594
- /* eslint-disable no-console */
1595
- if (typeof console !== 'undefined' && typeof console.error === 'function') {
1596
- console.error(message);
1597
- }
1598
- /* eslint-enable no-console */
1599
-
1600
-
1601
- try {
1602
- // This error was thrown as a convenience so that if you enable
1603
- // "break on all exceptions" in your console,
1604
- // it would pause the execution at this line.
1605
- throw new Error(message);
1606
- } catch (e) {} // eslint-disable-line no-empty
1607
-
1205
+ };
1608
1206
  }
1609
-
1610
- /*
1611
- * This is a dummy function to check if the function name has been altered by minification.
1612
- * If the function has been minified and NODE_ENV !== 'production', warn the user.
1613
- */
1614
-
1615
- function isCrushed() {}
1616
-
1617
- if ( typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') {
1618
- warning('You are currently using minified code outside of NODE_ENV === "production". ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or setting mode to production in webpack (https://webpack.js.org/concepts/mode/) ' + 'to ensure you have the correct code for your production build.');
1207
+ function verifyTargetIdsIsArray(targetIdsArg) {
1208
+ invariant(Array.isArray(targetIdsArg), 'Expected targetIds to be an array.');
1619
1209
  }
1620
-
1621
- /**
1622
- * Use invariant() to assert state which your program assumes to be true.
1623
- *
1624
- * Provide sprintf-style format (only %s is supported) and arguments
1625
- * to provide information about what broke and what you were
1626
- * expecting.
1627
- *
1628
- * The invariant message will be stripped in production, but the invariant
1629
- * will remain to ensure logic does not differ in production.
1630
- */ function invariant(condition, format, ...args) {
1631
- if (isProduction()) {
1632
- if (format === undefined) {
1633
- throw new Error('invariant requires an error message argument');
1634
- }
1210
+ function checkInvariants(targetIds, monitor, registry) {
1211
+ invariant(monitor.isDragging(), 'Cannot call hover while not dragging.');
1212
+ invariant(!monitor.didDrop(), 'Cannot call hover after drop.');
1213
+ for(let i = 0; i < targetIds.length; i++){
1214
+ const targetId = targetIds[i];
1215
+ invariant(targetIds.lastIndexOf(targetId) === i, 'Expected targetIds to be unique in the passed array.');
1216
+ const target = registry.getTarget(targetId);
1217
+ invariant(target, 'Expected targetIds to be registered.');
1635
1218
  }
1636
- if (!condition) {
1637
- let error;
1638
- if (format === undefined) {
1639
- error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
1640
- } else {
1641
- let argIndex = 0;
1642
- error = new Error(format.replace(/%s/g, function() {
1643
- return args[argIndex++];
1644
- }));
1645
- error.name = 'Invariant Violation';
1219
+ }
1220
+ function removeNonMatchingTargetIds(targetIds, registry, draggedItemType) {
1221
+ // Remove those targetIds that don't match the targetType. This
1222
+ // fixes shallow isOver which would only be non-shallow because of
1223
+ // non-matching targets.
1224
+ for(let i = targetIds.length - 1; i >= 0; i--){
1225
+ const targetId = targetIds[i];
1226
+ const targetType = registry.getTargetType(targetId);
1227
+ if (!matchesType(targetType, draggedItemType)) {
1228
+ targetIds.splice(i, 1);
1646
1229
  }
1647
- error.framesToPop = 1 // we don't care about invariant's own frame
1648
- ;
1649
- throw error;
1650
1230
  }
1651
1231
  }
1652
- function isProduction() {
1653
- return typeof process !== 'undefined' && process.env['NODE_ENV'] === 'production';
1232
+ function hoverAllTargets(targetIds, monitor, registry) {
1233
+ // Finally call hover on all matching targets.
1234
+ targetIds.forEach(function(targetId) {
1235
+ const target = registry.getTarget(targetId);
1236
+ target.hover(monitor, targetId);
1237
+ });
1654
1238
  }
1655
1239
 
1656
- // cheap lodash replacements
1657
- /**
1658
- * drop-in replacement for _.get
1659
- * @param obj
1660
- * @param path
1661
- * @param defaultValue
1662
- */ function get(obj, path, defaultValue) {
1663
- return path.split('.').reduce((a, c)=>a && a[c] ? a[c] : defaultValue || null
1664
- , obj);
1665
- }
1666
- /**
1667
- * drop-in replacement for _.without
1668
- */ function without(items, item) {
1669
- return items.filter((i)=>i !== item
1670
- );
1671
- }
1672
- /**
1673
- * drop-in replacement for _.isString
1674
- * @param input
1675
- */ function isObject(input) {
1676
- return typeof input === 'object';
1677
- }
1678
- /**
1679
- * replacement for _.xor
1680
- * @param itemsA
1681
- * @param itemsB
1682
- */ function xor(itemsA, itemsB) {
1683
- const map = new Map();
1684
- const insertItem = (item)=>{
1685
- map.set(item, map.has(item) ? map.get(item) + 1 : 1);
1686
- };
1687
- itemsA.forEach(insertItem);
1688
- itemsB.forEach(insertItem);
1689
- const result = [];
1690
- map.forEach((count, key)=>{
1691
- if (count === 1) {
1692
- result.push(key);
1240
+ function createPublishDragSource(manager) {
1241
+ return function publishDragSource() {
1242
+ const monitor = manager.getMonitor();
1243
+ if (monitor.isDragging()) {
1244
+ return {
1245
+ type: PUBLISH_DRAG_SOURCE
1246
+ };
1693
1247
  }
1694
- });
1695
- return result;
1696
- }
1697
- /**
1698
- * replacement for _.intersection
1699
- * @param itemsA
1700
- * @param itemsB
1701
- */ function intersection(itemsA, itemsB) {
1702
- return itemsA.filter((t)=>itemsB.indexOf(t) > -1
1703
- );
1248
+ return;
1249
+ };
1704
1250
  }
1705
1251
 
1706
- const INIT_COORDS = 'dnd-core/INIT_COORDS';
1707
- const BEGIN_DRAG = 'dnd-core/BEGIN_DRAG';
1708
- const PUBLISH_DRAG_SOURCE = 'dnd-core/PUBLISH_DRAG_SOURCE';
1709
- const HOVER = 'dnd-core/HOVER';
1710
- const DROP = 'dnd-core/DROP';
1711
- const END_DRAG = 'dnd-core/END_DRAG';
1712
-
1713
- function setClientOffset(clientOffset, sourceClientOffset) {
1252
+ function createDragDropActions(manager) {
1714
1253
  return {
1715
- type: INIT_COORDS,
1716
- payload: {
1717
- sourceClientOffset: sourceClientOffset || null,
1718
- clientOffset: clientOffset || null
1719
- }
1254
+ beginDrag: createBeginDrag(manager),
1255
+ publishDragSource: createPublishDragSource(manager),
1256
+ hover: createHover(manager),
1257
+ drop: createDrop(manager),
1258
+ endDrag: createEndDrag(manager)
1720
1259
  };
1721
1260
  }
1722
1261
 
1723
- const ResetCoordinatesAction = {
1724
- type: INIT_COORDS,
1725
- payload: {
1726
- clientOffset: null,
1727
- sourceClientOffset: null
1728
- }
1729
- };
1730
- function createBeginDrag(manager) {
1731
- return function beginDrag(sourceIds = [], options = {
1732
- publishSource: true
1733
- }) {
1734
- const { publishSource =true , clientOffset , getSourceClientOffset , } = options;
1735
- const monitor = manager.getMonitor();
1736
- const registry = manager.getRegistry();
1737
- // Initialize the coordinates using the client offset
1738
- manager.dispatch(setClientOffset(clientOffset));
1739
- verifyInvariants(sourceIds, monitor, registry);
1740
- // Get the draggable source
1741
- const sourceId = getDraggableSource(sourceIds, monitor);
1742
- if (sourceId == null) {
1743
- manager.dispatch(ResetCoordinatesAction);
1744
- return;
1745
- }
1746
- // Get the source client offset
1747
- let sourceClientOffset = null;
1748
- if (clientOffset) {
1749
- if (!getSourceClientOffset) {
1750
- throw new Error('getSourceClientOffset must be defined');
1751
- }
1752
- verifyGetSourceClientOffsetIsFunction(getSourceClientOffset);
1753
- sourceClientOffset = getSourceClientOffset(sourceId);
1754
- }
1755
- // Initialize the full coordinates
1756
- manager.dispatch(setClientOffset(clientOffset, sourceClientOffset));
1757
- const source = registry.getSource(sourceId);
1758
- const item = source.beginDrag(monitor, sourceId);
1759
- // If source.beginDrag returns null, this is an indicator to cancel the drag
1760
- if (item == null) {
1761
- return undefined;
1762
- }
1763
- verifyItemIsObject(item);
1764
- registry.pinSource(sourceId);
1765
- const itemType = registry.getSourceType(sourceId);
1766
- return {
1767
- type: BEGIN_DRAG,
1768
- payload: {
1769
- itemType,
1770
- item,
1771
- sourceId,
1772
- clientOffset: clientOffset || null,
1773
- sourceClientOffset: sourceClientOffset || null,
1774
- isSourcePublic: !!publishSource
1775
- }
1776
- };
1777
- };
1778
- }
1779
- function verifyInvariants(sourceIds, monitor, registry) {
1780
- invariant(!monitor.isDragging(), 'Cannot call beginDrag while dragging.');
1781
- sourceIds.forEach(function(sourceId) {
1782
- invariant(registry.getSource(sourceId), 'Expected sourceIds to be registered.');
1783
- });
1784
- }
1785
- function verifyGetSourceClientOffsetIsFunction(getSourceClientOffset) {
1786
- invariant(typeof getSourceClientOffset === 'function', 'When clientOffset is provided, getSourceClientOffset must be a function.');
1787
- }
1788
- function verifyItemIsObject(item) {
1789
- invariant(isObject(item), 'Item must be an object.');
1790
- }
1791
- function getDraggableSource(sourceIds, monitor) {
1792
- let sourceId = null;
1793
- for(let i = sourceIds.length - 1; i >= 0; i--){
1794
- if (monitor.canDragSource(sourceIds[i])) {
1795
- sourceId = sourceIds[i];
1796
- break;
1797
- }
1798
- }
1799
- return sourceId;
1800
- }
1801
-
1802
- function _defineProperty(obj, key, value) {
1803
- if (key in obj) {
1804
- Object.defineProperty(obj, key, {
1805
- value: value,
1806
- enumerable: true,
1807
- configurable: true,
1808
- writable: true
1809
- });
1810
- } else {
1811
- obj[key] = value;
1812
- }
1813
- return obj;
1814
- }
1815
- function _objectSpread(target) {
1816
- for(var i = 1; i < arguments.length; i++){
1817
- var source = arguments[i] != null ? arguments[i] : {};
1818
- var ownKeys = Object.keys(source);
1819
- if (typeof Object.getOwnPropertySymbols === 'function') {
1820
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
1821
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1822
- }));
1823
- }
1824
- ownKeys.forEach(function(key) {
1825
- _defineProperty(target, key, source[key]);
1826
- });
1827
- }
1828
- return target;
1829
- }
1830
- function createDrop(manager) {
1831
- return function drop(options = {}) {
1832
- const monitor = manager.getMonitor();
1833
- const registry = manager.getRegistry();
1834
- verifyInvariants$1(monitor);
1835
- const targetIds = getDroppableTargets(monitor);
1836
- // Multiple actions are dispatched here, which is why this doesn't return an action
1837
- targetIds.forEach((targetId, index)=>{
1838
- const dropResult = determineDropResult(targetId, index, registry, monitor);
1839
- const action = {
1840
- type: DROP,
1841
- payload: {
1842
- dropResult: _objectSpread({}, options, dropResult)
1843
- }
1844
- };
1845
- manager.dispatch(action);
1846
- });
1847
- };
1848
- }
1849
- function verifyInvariants$1(monitor) {
1850
- invariant(monitor.isDragging(), 'Cannot call drop while not dragging.');
1851
- invariant(!monitor.didDrop(), 'Cannot call drop twice during one drag operation.');
1852
- }
1853
- function determineDropResult(targetId, index, registry, monitor) {
1854
- const target = registry.getTarget(targetId);
1855
- let dropResult = target ? target.drop(monitor, targetId) : undefined;
1856
- verifyDropResultType(dropResult);
1857
- if (typeof dropResult === 'undefined') {
1858
- dropResult = index === 0 ? {} : monitor.getDropResult();
1859
- }
1860
- return dropResult;
1861
- }
1862
- function verifyDropResultType(dropResult) {
1863
- invariant(typeof dropResult === 'undefined' || isObject(dropResult), 'Drop result must either be an object or undefined.');
1864
- }
1865
- function getDroppableTargets(monitor) {
1866
- const targetIds = monitor.getTargetIds().filter(monitor.canDropOnTarget, monitor);
1867
- targetIds.reverse();
1868
- return targetIds;
1869
- }
1870
-
1871
- function createEndDrag(manager) {
1872
- return function endDrag() {
1873
- const monitor = manager.getMonitor();
1874
- const registry = manager.getRegistry();
1875
- verifyIsDragging(monitor);
1876
- const sourceId = monitor.getSourceId();
1877
- if (sourceId != null) {
1878
- const source = registry.getSource(sourceId, true);
1879
- source.endDrag(monitor, sourceId);
1880
- registry.unpinSource();
1881
- }
1882
- return {
1883
- type: END_DRAG
1884
- };
1885
- };
1886
- }
1887
- function verifyIsDragging(monitor) {
1888
- invariant(monitor.isDragging(), 'Cannot call endDrag while not dragging.');
1889
- }
1890
-
1891
- function matchesType(targetType, draggedItemType) {
1892
- if (draggedItemType === null) {
1893
- return targetType === null;
1894
- }
1895
- return Array.isArray(targetType) ? targetType.some((t)=>t === draggedItemType
1896
- ) : targetType === draggedItemType;
1897
- }
1898
-
1899
- function createHover(manager) {
1900
- return function hover(targetIdsArg, { clientOffset } = {}) {
1901
- verifyTargetIdsIsArray(targetIdsArg);
1902
- const targetIds = targetIdsArg.slice(0);
1903
- const monitor = manager.getMonitor();
1904
- const registry = manager.getRegistry();
1905
- const draggedItemType = monitor.getItemType();
1906
- removeNonMatchingTargetIds(targetIds, registry, draggedItemType);
1907
- checkInvariants(targetIds, monitor, registry);
1908
- hoverAllTargets(targetIds, monitor, registry);
1909
- return {
1910
- type: HOVER,
1911
- payload: {
1912
- targetIds,
1913
- clientOffset: clientOffset || null
1914
- }
1915
- };
1916
- };
1917
- }
1918
- function verifyTargetIdsIsArray(targetIdsArg) {
1919
- invariant(Array.isArray(targetIdsArg), 'Expected targetIds to be an array.');
1920
- }
1921
- function checkInvariants(targetIds, monitor, registry) {
1922
- invariant(monitor.isDragging(), 'Cannot call hover while not dragging.');
1923
- invariant(!monitor.didDrop(), 'Cannot call hover after drop.');
1924
- for(let i = 0; i < targetIds.length; i++){
1925
- const targetId = targetIds[i];
1926
- invariant(targetIds.lastIndexOf(targetId) === i, 'Expected targetIds to be unique in the passed array.');
1927
- const target = registry.getTarget(targetId);
1928
- invariant(target, 'Expected targetIds to be registered.');
1929
- }
1930
- }
1931
- function removeNonMatchingTargetIds(targetIds, registry, draggedItemType) {
1932
- // Remove those targetIds that don't match the targetType. This
1933
- // fixes shallow isOver which would only be non-shallow because of
1934
- // non-matching targets.
1935
- for(let i = targetIds.length - 1; i >= 0; i--){
1936
- const targetId = targetIds[i];
1937
- const targetType = registry.getTargetType(targetId);
1938
- if (!matchesType(targetType, draggedItemType)) {
1939
- targetIds.splice(i, 1);
1940
- }
1941
- }
1942
- }
1943
- function hoverAllTargets(targetIds, monitor, registry) {
1944
- // Finally call hover on all matching targets.
1945
- targetIds.forEach(function(targetId) {
1946
- const target = registry.getTarget(targetId);
1947
- target.hover(monitor, targetId);
1948
- });
1949
- }
1950
-
1951
- function createPublishDragSource(manager) {
1952
- return function publishDragSource() {
1953
- const monitor = manager.getMonitor();
1954
- if (monitor.isDragging()) {
1955
- return {
1956
- type: PUBLISH_DRAG_SOURCE
1957
- };
1958
- }
1959
- return;
1960
- };
1961
- }
1962
-
1963
- function createDragDropActions(manager) {
1964
- return {
1965
- beginDrag: createBeginDrag(manager),
1966
- publishDragSource: createPublishDragSource(manager),
1967
- hover: createHover(manager),
1968
- drop: createDrop(manager),
1969
- endDrag: createEndDrag(manager)
1970
- };
1971
- }
1972
-
1973
- class DragDropManagerImpl {
1974
- receiveBackend(backend) {
1975
- this.backend = backend;
1262
+ class DragDropManagerImpl {
1263
+ receiveBackend(backend) {
1264
+ this.backend = backend;
1976
1265
  }
1977
1266
  getMonitor() {
1978
1267
  return this.monitor;
@@ -3706,282 +2995,1079 @@ class TargetConnector {
3706
2995
  this.lastConnectedDropTargetOptions = null;
3707
2996
  this.backend = backend;
3708
2997
  }
3709
- }
3710
-
3711
- /**
3712
- * A hook to retrieve the DragDropManager from Context
3713
- */ function useDragDropManager() {
3714
- const { dragDropManager } = React.useContext(DndContext);
3715
- invariant(dragDropManager != null, 'Expected drag drop context');
3716
- return dragDropManager;
3717
- }
2998
+ }
2999
+
3000
+ /**
3001
+ * A hook to retrieve the DragDropManager from Context
3002
+ */ function useDragDropManager() {
3003
+ const { dragDropManager } = React.useContext(DndContext);
3004
+ invariant(dragDropManager != null, 'Expected drag drop context');
3005
+ return dragDropManager;
3006
+ }
3007
+
3008
+ function useDragSourceConnector(dragSourceOptions, dragPreviewOptions) {
3009
+ const manager = useDragDropManager();
3010
+ const connector = React.useMemo(()=>new SourceConnector(manager.getBackend())
3011
+ , [
3012
+ manager
3013
+ ]);
3014
+ useIsomorphicLayoutEffect(()=>{
3015
+ connector.dragSourceOptions = dragSourceOptions || null;
3016
+ connector.reconnect();
3017
+ return ()=>connector.disconnectDragSource()
3018
+ ;
3019
+ }, [
3020
+ connector,
3021
+ dragSourceOptions
3022
+ ]);
3023
+ useIsomorphicLayoutEffect(()=>{
3024
+ connector.dragPreviewOptions = dragPreviewOptions || null;
3025
+ connector.reconnect();
3026
+ return ()=>connector.disconnectDragPreview()
3027
+ ;
3028
+ }, [
3029
+ connector,
3030
+ dragPreviewOptions
3031
+ ]);
3032
+ return connector;
3033
+ }
3034
+
3035
+ function useDragSourceMonitor() {
3036
+ const manager = useDragDropManager();
3037
+ return React.useMemo(()=>new DragSourceMonitorImpl(manager)
3038
+ , [
3039
+ manager
3040
+ ]);
3041
+ }
3042
+
3043
+ class DragSourceImpl {
3044
+ beginDrag() {
3045
+ const spec = this.spec;
3046
+ const monitor = this.monitor;
3047
+ let result = null;
3048
+ if (typeof spec.item === 'object') {
3049
+ result = spec.item;
3050
+ } else if (typeof spec.item === 'function') {
3051
+ result = spec.item(monitor);
3052
+ } else {
3053
+ result = {};
3054
+ }
3055
+ return result !== null && result !== void 0 ? result : null;
3056
+ }
3057
+ canDrag() {
3058
+ const spec = this.spec;
3059
+ const monitor = this.monitor;
3060
+ if (typeof spec.canDrag === 'boolean') {
3061
+ return spec.canDrag;
3062
+ } else if (typeof spec.canDrag === 'function') {
3063
+ return spec.canDrag(monitor);
3064
+ } else {
3065
+ return true;
3066
+ }
3067
+ }
3068
+ isDragging(globalMonitor, target) {
3069
+ const spec = this.spec;
3070
+ const monitor = this.monitor;
3071
+ const { isDragging } = spec;
3072
+ return isDragging ? isDragging(monitor) : target === globalMonitor.getSourceId();
3073
+ }
3074
+ endDrag() {
3075
+ const spec = this.spec;
3076
+ const monitor = this.monitor;
3077
+ const connector = this.connector;
3078
+ const { end } = spec;
3079
+ if (end) {
3080
+ end(monitor.getItem(), monitor);
3081
+ }
3082
+ connector.reconnect();
3083
+ }
3084
+ constructor(spec, monitor, connector){
3085
+ this.spec = spec;
3086
+ this.monitor = monitor;
3087
+ this.connector = connector;
3088
+ }
3089
+ }
3090
+
3091
+ function useDragSource(spec, monitor, connector) {
3092
+ const handler = React.useMemo(()=>new DragSourceImpl(spec, monitor, connector)
3093
+ , [
3094
+ monitor,
3095
+ connector
3096
+ ]);
3097
+ React.useEffect(()=>{
3098
+ handler.spec = spec;
3099
+ }, [
3100
+ spec
3101
+ ]);
3102
+ return handler;
3103
+ }
3104
+
3105
+ function useDragType(spec) {
3106
+ return React.useMemo(()=>{
3107
+ const result = spec.type;
3108
+ invariant(result != null, 'spec.type must be defined');
3109
+ return result;
3110
+ }, [
3111
+ spec
3112
+ ]);
3113
+ }
3114
+
3115
+ function useRegisteredDragSource(spec, monitor, connector) {
3116
+ const manager = useDragDropManager();
3117
+ const handler = useDragSource(spec, monitor, connector);
3118
+ const itemType = useDragType(spec);
3119
+ useIsomorphicLayoutEffect(function registerDragSource() {
3120
+ if (itemType != null) {
3121
+ const [handlerId, unregister] = registerSource(itemType, handler, manager);
3122
+ monitor.receiveHandlerId(handlerId);
3123
+ connector.receiveHandlerId(handlerId);
3124
+ return unregister;
3125
+ }
3126
+ return;
3127
+ }, [
3128
+ manager,
3129
+ monitor,
3130
+ connector,
3131
+ handler,
3132
+ itemType
3133
+ ]);
3134
+ }
3135
+
3136
+ /**
3137
+ * useDragSource hook
3138
+ * @param sourceSpec The drag source specification (object or function, function preferred)
3139
+ * @param deps The memoization deps array to use when evaluating spec changes
3140
+ */ function useDrag(specArg, deps) {
3141
+ const spec = useOptionalFactory(specArg, deps);
3142
+ invariant(!spec.begin, `useDrag::spec.begin was deprecated in v14. Replace spec.begin() with spec.item(). (see more here - https://react-dnd.github.io/react-dnd/docs/api/use-drag)`);
3143
+ const monitor = useDragSourceMonitor();
3144
+ const connector = useDragSourceConnector(spec.options, spec.previewOptions);
3145
+ useRegisteredDragSource(spec, monitor, connector);
3146
+ return [
3147
+ useCollectedProps(spec.collect, monitor, connector),
3148
+ useConnectDragSource(connector),
3149
+ useConnectDragPreview(connector),
3150
+ ];
3151
+ }
3152
+
3153
+ function useConnectDropTarget(connector) {
3154
+ return React.useMemo(()=>connector.hooks.dropTarget()
3155
+ , [
3156
+ connector
3157
+ ]);
3158
+ }
3159
+
3160
+ function useDropTargetConnector(options) {
3161
+ const manager = useDragDropManager();
3162
+ const connector = React.useMemo(()=>new TargetConnector(manager.getBackend())
3163
+ , [
3164
+ manager
3165
+ ]);
3166
+ useIsomorphicLayoutEffect(()=>{
3167
+ connector.dropTargetOptions = options || null;
3168
+ connector.reconnect();
3169
+ return ()=>connector.disconnectDropTarget()
3170
+ ;
3171
+ }, [
3172
+ options
3173
+ ]);
3174
+ return connector;
3175
+ }
3176
+
3177
+ function useDropTargetMonitor() {
3178
+ const manager = useDragDropManager();
3179
+ return React.useMemo(()=>new DropTargetMonitorImpl(manager)
3180
+ , [
3181
+ manager
3182
+ ]);
3183
+ }
3184
+
3185
+ /**
3186
+ * Internal utility hook to get an array-version of spec.accept.
3187
+ * The main utility here is that we aren't creating a new array on every render if a non-array spec.accept is passed in.
3188
+ * @param spec
3189
+ */ function useAccept(spec) {
3190
+ const { accept } = spec;
3191
+ return React.useMemo(()=>{
3192
+ invariant(spec.accept != null, 'accept must be defined');
3193
+ return Array.isArray(accept) ? accept : [
3194
+ accept
3195
+ ];
3196
+ }, [
3197
+ accept
3198
+ ]);
3199
+ }
3200
+
3201
+ class DropTargetImpl {
3202
+ canDrop() {
3203
+ const spec = this.spec;
3204
+ const monitor = this.monitor;
3205
+ return spec.canDrop ? spec.canDrop(monitor.getItem(), monitor) : true;
3206
+ }
3207
+ hover() {
3208
+ const spec = this.spec;
3209
+ const monitor = this.monitor;
3210
+ if (spec.hover) {
3211
+ spec.hover(monitor.getItem(), monitor);
3212
+ }
3213
+ }
3214
+ drop() {
3215
+ const spec = this.spec;
3216
+ const monitor = this.monitor;
3217
+ if (spec.drop) {
3218
+ return spec.drop(monitor.getItem(), monitor);
3219
+ }
3220
+ return;
3221
+ }
3222
+ constructor(spec, monitor){
3223
+ this.spec = spec;
3224
+ this.monitor = monitor;
3225
+ }
3226
+ }
3227
+
3228
+ function useDropTarget(spec, monitor) {
3229
+ const dropTarget = React.useMemo(()=>new DropTargetImpl(spec, monitor)
3230
+ , [
3231
+ monitor
3232
+ ]);
3233
+ React.useEffect(()=>{
3234
+ dropTarget.spec = spec;
3235
+ }, [
3236
+ spec
3237
+ ]);
3238
+ return dropTarget;
3239
+ }
3240
+
3241
+ function useRegisteredDropTarget(spec, monitor, connector) {
3242
+ const manager = useDragDropManager();
3243
+ const dropTarget = useDropTarget(spec, monitor);
3244
+ const accept = useAccept(spec);
3245
+ useIsomorphicLayoutEffect(function registerDropTarget() {
3246
+ const [handlerId, unregister] = registerTarget(accept, dropTarget, manager);
3247
+ monitor.receiveHandlerId(handlerId);
3248
+ connector.receiveHandlerId(handlerId);
3249
+ return unregister;
3250
+ }, [
3251
+ manager,
3252
+ monitor,
3253
+ dropTarget,
3254
+ connector,
3255
+ accept.map((a)=>a.toString()
3256
+ ).join('|'),
3257
+ ]);
3258
+ }
3259
+
3260
+ /**
3261
+ * useDropTarget Hook
3262
+ * @param spec The drop target specification (object or function, function preferred)
3263
+ * @param deps The memoization deps array to use when evaluating spec changes
3264
+ */ function useDrop(specArg, deps) {
3265
+ const spec = useOptionalFactory(specArg, deps);
3266
+ const monitor = useDropTargetMonitor();
3267
+ const connector = useDropTargetConnector(spec.options);
3268
+ useRegisteredDropTarget(spec, monitor, connector);
3269
+ return [
3270
+ useCollectedProps(spec.collect, monitor, connector),
3271
+ useConnectDropTarget(connector),
3272
+ ];
3273
+ }
3274
+
3275
+ var MRT_ColumnPinningButtons = function MRT_ColumnPinningButtons(_ref) {
3276
+ var column = _ref.column,
3277
+ tableInstance = _ref.tableInstance;
3278
+ var _tableInstance$option = tableInstance.options,
3279
+ PushPinIcon = _tableInstance$option.icons.PushPinIcon,
3280
+ localization = _tableInstance$option.localization;
3281
+
3282
+ var handlePinColumn = function handlePinColumn(pinDirection) {
3283
+ column.pin(pinDirection);
3284
+ };
3285
+
3286
+ return React__default.createElement(material.Box, {
3287
+ sx: {
3288
+ mr: '4px'
3289
+ }
3290
+ }, column.getIsPinned() ? React__default.createElement(material.Tooltip, {
3291
+ arrow: true,
3292
+ title: localization.unpin
3293
+ }, React__default.createElement(material.IconButton, {
3294
+ onClick: function onClick() {
3295
+ return handlePinColumn(false);
3296
+ },
3297
+ size: "small"
3298
+ }, React__default.createElement(PushPinIcon, null))) : React__default.createElement(React__default.Fragment, null, React__default.createElement(material.Tooltip, {
3299
+ arrow: true,
3300
+ title: localization.pinToLeft
3301
+ }, React__default.createElement(material.IconButton, {
3302
+ onClick: function onClick() {
3303
+ return handlePinColumn('left');
3304
+ },
3305
+ size: "small"
3306
+ }, React__default.createElement(PushPinIcon, {
3307
+ style: {
3308
+ transform: 'rotate(90deg)'
3309
+ }
3310
+ }))), React__default.createElement(material.Tooltip, {
3311
+ arrow: true,
3312
+ title: localization.pinToRight
3313
+ }, React__default.createElement(material.IconButton, {
3314
+ onClick: function onClick() {
3315
+ return handlePinColumn('right');
3316
+ },
3317
+ size: "small"
3318
+ }, React__default.createElement(PushPinIcon, {
3319
+ style: {
3320
+ transform: 'rotate(-90deg)'
3321
+ }
3322
+ })))));
3323
+ };
3324
+
3325
+ var MRT_GrabHandleButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3326
+ var tableInstance = _ref.tableInstance;
3327
+ var _tableInstance$option = tableInstance.options,
3328
+ DragHandleIcon = _tableInstance$option.icons.DragHandleIcon,
3329
+ localization = _tableInstance$option.localization;
3330
+ return React__default.createElement(material.Tooltip, {
3331
+ arrow: true,
3332
+ enterDelay: 1000,
3333
+ enterNextDelay: 1000,
3334
+ placement: "top",
3335
+ title: localization.grab
3336
+ }, React__default.createElement(material.IconButton, {
3337
+ disableRipple: true,
3338
+ ref: ref,
3339
+ size: "small",
3340
+ sx: {
3341
+ cursor: 'grab',
3342
+ m: 0,
3343
+ opacity: 0.5,
3344
+ p: '2px',
3345
+ transition: 'all 0.2s ease-in-out',
3346
+ '&:hover': {
3347
+ backgroundColor: 'transparent',
3348
+ opacity: 1
3349
+ },
3350
+ '&:active': {
3351
+ cursor: 'grabbing'
3352
+ }
3353
+ }
3354
+ }, React__default.createElement(DragHandleIcon, null)));
3355
+ });
3356
+
3357
+ var MRT_ShowHideColumnsMenuItems = function MRT_ShowHideColumnsMenuItems(_ref) {
3358
+ var _column$columns2;
3359
+
3360
+ var allColumns = _ref.allColumns,
3361
+ column = _ref.column,
3362
+ isSubMenu = _ref.isSubMenu,
3363
+ tableInstance = _ref.tableInstance;
3364
+ var getState = tableInstance.getState,
3365
+ _tableInstance$option = tableInstance.options,
3366
+ enableColumnOrdering = _tableInstance$option.enableColumnOrdering,
3367
+ onToggleColumnVisibility = _tableInstance$option.onToggleColumnVisibility,
3368
+ setColumnOrder = tableInstance.setColumnOrder;
3369
+
3370
+ var _getState = getState(),
3371
+ columnOrder = _getState.columnOrder,
3372
+ columnVisibility = _getState.columnVisibility;
3373
+
3374
+ var columnDef = column.columnDef,
3375
+ columnDefType = column.columnDefType;
3376
+
3377
+ var reorder = function reorder(movingColumn, receivingColumn) {
3378
+ if (movingColumn.getCanPin()) {
3379
+ movingColumn.pin(receivingColumn.getIsPinned());
3380
+ }
3381
+
3382
+ columnOrder.splice(columnOrder.indexOf(receivingColumn.id), 0, columnOrder.splice(columnOrder.indexOf(movingColumn.id), 1)[0]);
3383
+ setColumnOrder([].concat(columnOrder));
3384
+ };
3385
+
3386
+ var _useDrop = useDrop({
3387
+ accept: 'column',
3388
+ drop: function drop(movingColumn) {
3389
+ return reorder(movingColumn, column);
3390
+ }
3391
+ }),
3392
+ dropRef = _useDrop[1];
3393
+
3394
+ var _useDrag = useDrag({
3395
+ collect: function collect(monitor) {
3396
+ return {
3397
+ isDragging: monitor.isDragging()
3398
+ };
3399
+ },
3400
+ item: function item() {
3401
+ return column;
3402
+ },
3403
+ type: 'column'
3404
+ }),
3405
+ dragRef = _useDrag[1],
3406
+ previewRef = _useDrag[2];
3407
+
3408
+ var switchChecked = columnDefType !== 'group' && column.getIsVisible() || columnDefType === 'group' && column.getLeafColumns().some(function (col) {
3409
+ return col.getIsVisible();
3410
+ });
3411
+
3412
+ var handleToggleColumnHidden = function handleToggleColumnHidden(column) {
3413
+ if (columnDefType === 'group') {
3414
+ var _column$columns;
3415
+
3416
+ column == null ? void 0 : (_column$columns = column.columns) == null ? void 0 : _column$columns.forEach == null ? void 0 : _column$columns.forEach(function (childColumn) {
3417
+ childColumn.toggleVisibility(!switchChecked);
3418
+ });
3419
+ } else {
3420
+ column.toggleVisibility();
3421
+ }
3422
+
3423
+ onToggleColumnVisibility == null ? void 0 : onToggleColumnVisibility({
3424
+ column: column,
3425
+ columnVisibility: columnVisibility,
3426
+ tableInstance: tableInstance
3427
+ });
3428
+ };
3429
+
3430
+ return React__default.createElement(React__default.Fragment, null, React__default.createElement(material.MenuItem, {
3431
+ ref: columnDefType === 'data' ? dropRef : undefined,
3432
+ sx: {
3433
+ alignItems: 'center',
3434
+ justifyContent: 'flex-start',
3435
+ my: 0,
3436
+ pl: (column.depth + 0.5) * 2 + "rem",
3437
+ py: '6px'
3438
+ }
3439
+ }, React__default.createElement(material.Box, {
3440
+ ref: previewRef,
3441
+ sx: {
3442
+ display: 'flex',
3443
+ flexWrap: 'nowrap'
3444
+ }
3445
+ }, columnDefType !== 'group' && enableColumnOrdering && columnDef.enableColumnOrdering !== false && !allColumns.some(function (col) {
3446
+ return col.columnDefType === 'group';
3447
+ }) && React__default.createElement(MRT_GrabHandleButton, {
3448
+ ref: dragRef,
3449
+ tableInstance: tableInstance
3450
+ }), !isSubMenu && column.getCanPin() && React__default.createElement(MRT_ColumnPinningButtons, {
3451
+ column: column,
3452
+ tableInstance: tableInstance
3453
+ }), React__default.createElement(material.FormControlLabel, {
3454
+ componentsProps: {
3455
+ typography: {
3456
+ sx: {
3457
+ mb: 0,
3458
+ opacity: columnDefType !== 'display' ? 1 : 0.5
3459
+ }
3460
+ }
3461
+ },
3462
+ checked: switchChecked,
3463
+ control: React__default.createElement(material.Switch, null),
3464
+ disabled: isSubMenu && switchChecked || !column.getCanHide(),
3465
+ label: columnDef.header,
3466
+ onChange: function onChange() {
3467
+ return handleToggleColumnHidden(column);
3468
+ },
3469
+ sx: {
3470
+ ml: '4px'
3471
+ }
3472
+ }))), (_column$columns2 = column.columns) == null ? void 0 : _column$columns2.map(function (c, i) {
3473
+ return React__default.createElement(MRT_ShowHideColumnsMenuItems, {
3474
+ allColumns: allColumns,
3475
+ key: i + "-" + c.id,
3476
+ column: c,
3477
+ isSubMenu: isSubMenu,
3478
+ tableInstance: tableInstance
3479
+ });
3480
+ }));
3481
+ };
3482
+
3483
+ var MRT_ShowHideColumnsMenu = function MRT_ShowHideColumnsMenu(_ref) {
3484
+ var anchorEl = _ref.anchorEl,
3485
+ isSubMenu = _ref.isSubMenu,
3486
+ setAnchorEl = _ref.setAnchorEl,
3487
+ tableInstance = _ref.tableInstance;
3488
+ var getAllColumns = tableInstance.getAllColumns,
3489
+ getAllLeafColumns = tableInstance.getAllLeafColumns,
3490
+ getIsAllColumnsVisible = tableInstance.getIsAllColumnsVisible,
3491
+ getIsSomeColumnsPinned = tableInstance.getIsSomeColumnsPinned,
3492
+ getIsSomeColumnsVisible = tableInstance.getIsSomeColumnsVisible,
3493
+ getState = tableInstance.getState,
3494
+ toggleAllColumnsVisible = tableInstance.toggleAllColumnsVisible,
3495
+ _tableInstance$option = tableInstance.options,
3496
+ localization = _tableInstance$option.localization,
3497
+ enablePinning = _tableInstance$option.enablePinning,
3498
+ enableColumnOrdering = _tableInstance$option.enableColumnOrdering;
3499
+
3500
+ var _getState = getState(),
3501
+ isDensePadding = _getState.isDensePadding,
3502
+ columnOrder = _getState.columnOrder,
3503
+ columnPinning = _getState.columnPinning;
3504
+
3505
+ var hideAllColumns = function hideAllColumns() {
3506
+ getAllLeafColumns().filter(function (col) {
3507
+ return col.columnDef.enableHiding !== false;
3508
+ }).forEach(function (col) {
3509
+ return col.toggleVisibility(false);
3510
+ });
3511
+ };
3512
+
3513
+ var allColumns = React.useMemo(function () {
3514
+ var columns = getAllColumns();
3515
+
3516
+ if (columnOrder.length > 0 && !columns.some(function (col) {
3517
+ return col.columnDefType === 'group';
3518
+ })) {
3519
+ var _columnOrder$map;
3520
+
3521
+ return (_columnOrder$map = columnOrder.map(function (colId) {
3522
+ return columns.find(function (col) {
3523
+ return col.id === colId;
3524
+ });
3525
+ })) != null ? _columnOrder$map : columns;
3526
+ }
3527
+
3528
+ return columns;
3529
+ }, [getAllColumns(), columnOrder, columnPinning]);
3530
+ return React__default.createElement(material.Menu, {
3531
+ anchorEl: anchorEl,
3532
+ open: !!anchorEl,
3533
+ onClose: function onClose() {
3534
+ return setAnchorEl(null);
3535
+ },
3536
+ MenuListProps: {
3537
+ dense: isDensePadding
3538
+ }
3539
+ }, React__default.createElement(material.Box, {
3540
+ sx: {
3541
+ display: 'flex',
3542
+ justifyContent: isSubMenu ? 'center' : 'space-between',
3543
+ p: '0.5rem',
3544
+ pt: 0
3545
+ }
3546
+ }, !isSubMenu && React__default.createElement(material.Button, {
3547
+ disabled: !getIsSomeColumnsVisible(),
3548
+ onClick: hideAllColumns
3549
+ }, localization.hideAll), !isSubMenu && enableColumnOrdering && React__default.createElement(material.Button, {
3550
+ onClick: function onClick() {
3551
+ return tableInstance.resetColumnOrder();
3552
+ }
3553
+ }, localization.resetOrder), !isSubMenu && enablePinning && React__default.createElement(material.Button, {
3554
+ disabled: !getIsSomeColumnsPinned(),
3555
+ onClick: function onClick() {
3556
+ return tableInstance.resetColumnPinning(true);
3557
+ }
3558
+ }, localization.unpinAll), React__default.createElement(material.Button, {
3559
+ disabled: getIsAllColumnsVisible(),
3560
+ onClick: function onClick() {
3561
+ return toggleAllColumnsVisible(true);
3562
+ }
3563
+ }, localization.showAll)), React__default.createElement(material.Divider, null), allColumns.map(function (column, index) {
3564
+ return React__default.createElement(MRT_ShowHideColumnsMenuItems, {
3565
+ allColumns: allColumns,
3566
+ column: column,
3567
+ isSubMenu: isSubMenu,
3568
+ key: index + "-" + column.id,
3569
+ tableInstance: tableInstance
3570
+ });
3571
+ }));
3572
+ };
3573
+
3574
+ var commonMenuItemStyles$1 = {
3575
+ py: '6px',
3576
+ my: 0,
3577
+ justifyContent: 'space-between',
3578
+ alignItems: 'center'
3579
+ };
3580
+ var commonListItemStyles = {
3581
+ display: 'flex',
3582
+ alignItems: 'center'
3583
+ };
3584
+ var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
3585
+ var _localization$sortByC, _localization$sortByC2, _localization$filterB, _localization, _localization$hideCol, _localization$showAll;
3586
+
3587
+ var anchorEl = _ref.anchorEl,
3588
+ header = _ref.header,
3589
+ setAnchorEl = _ref.setAnchorEl,
3590
+ tableInstance = _ref.tableInstance;
3591
+ var getState = tableInstance.getState,
3592
+ toggleAllColumnsVisible = tableInstance.toggleAllColumnsVisible,
3593
+ setColumnOrder = tableInstance.setColumnOrder,
3594
+ _tableInstance$option = tableInstance.options,
3595
+ enableColumnFilters = _tableInstance$option.enableColumnFilters,
3596
+ enableColumnResizing = _tableInstance$option.enableColumnResizing,
3597
+ enableGrouping = _tableInstance$option.enableGrouping,
3598
+ enableHiding = _tableInstance$option.enableHiding,
3599
+ enablePinning = _tableInstance$option.enablePinning,
3600
+ enableSorting = _tableInstance$option.enableSorting,
3601
+ _tableInstance$option2 = _tableInstance$option.icons,
3602
+ ArrowRightIcon = _tableInstance$option2.ArrowRightIcon,
3603
+ ClearAllIcon = _tableInstance$option2.ClearAllIcon,
3604
+ ViewColumnIcon = _tableInstance$option2.ViewColumnIcon,
3605
+ DynamicFeedIcon = _tableInstance$option2.DynamicFeedIcon,
3606
+ FilterListIcon = _tableInstance$option2.FilterListIcon,
3607
+ FilterListOffIcon = _tableInstance$option2.FilterListOffIcon,
3608
+ PushPinIcon = _tableInstance$option2.PushPinIcon,
3609
+ SortIcon = _tableInstance$option2.SortIcon,
3610
+ RestartAltIcon = _tableInstance$option2.RestartAltIcon,
3611
+ VisibilityOffIcon = _tableInstance$option2.VisibilityOffIcon,
3612
+ idPrefix = _tableInstance$option.idPrefix,
3613
+ localization = _tableInstance$option.localization,
3614
+ setShowFilters = tableInstance.setShowFilters;
3615
+ var column = header.column;
3616
+ var columnDef = column.columnDef;
3617
+
3618
+ var _getState = getState(),
3619
+ columnSizing = _getState.columnSizing,
3620
+ columnVisibility = _getState.columnVisibility,
3621
+ isDensePadding = _getState.isDensePadding;
3622
+
3623
+ var _useState = React.useState(null),
3624
+ filterMenuAnchorEl = _useState[0],
3625
+ setFilterMenuAnchorEl = _useState[1];
3626
+
3627
+ var _useState2 = React.useState(null),
3628
+ showHideColumnsMenuAnchorEl = _useState2[0],
3629
+ setShowHideColumnsMenuAnchorEl = _useState2[1];
3630
+
3631
+ var handleClearSort = function handleClearSort() {
3632
+ column.clearSorting();
3633
+ setAnchorEl(null);
3634
+ };
3635
+
3636
+ var handleSortAsc = function handleSortAsc() {
3637
+ column.toggleSorting(false);
3638
+ setAnchorEl(null);
3639
+ };
3640
+
3641
+ var handleSortDesc = function handleSortDesc() {
3642
+ column.toggleSorting(true);
3643
+ setAnchorEl(null);
3644
+ };
3645
+
3646
+ var handleResetColumnSize = function handleResetColumnSize() {
3647
+ column.resetSize();
3648
+ setAnchorEl(null);
3649
+ };
3650
+
3651
+ var handleHideColumn = function handleHideColumn() {
3652
+ column.toggleVisibility(false);
3653
+ setAnchorEl(null);
3654
+ };
3655
+
3656
+ var handlePinColumn = function handlePinColumn(pinDirection) {
3657
+ column.pin(pinDirection);
3658
+ setAnchorEl(null);
3659
+ };
3660
+
3661
+ var handleGroupByColumn = function handleGroupByColumn() {
3662
+ column.toggleGrouping();
3663
+ setColumnOrder(function (old) {
3664
+ return ['mrt-expand'].concat(old);
3665
+ });
3666
+ setAnchorEl(null);
3667
+ };
3668
+
3669
+ var handleClearFilter = function handleClearFilter() {
3670
+ column.setFilterValue('');
3671
+ setAnchorEl(null);
3672
+ };
3673
+
3674
+ var handleFilterByColumn = function handleFilterByColumn() {
3675
+ setShowFilters(true);
3676
+ setTimeout(function () {
3677
+ var _document$getElementB, _header$muiTableHeadC, _header$muiTableHeadC2;
3678
+
3679
+ return (_document$getElementB = document.getElementById( // @ts-ignore
3680
+ (_header$muiTableHeadC = (_header$muiTableHeadC2 = header.muiTableHeadCellFilterTextFieldProps) == null ? void 0 : _header$muiTableHeadC2.id) != null ? _header$muiTableHeadC : "mrt-" + idPrefix + "-" + header.id + "-filter-text-field")) == null ? void 0 : _document$getElementB.focus();
3681
+ }, 200);
3682
+ setAnchorEl(null);
3683
+ };
3684
+
3685
+ var handleShowAllColumns = function handleShowAllColumns() {
3686
+ toggleAllColumnsVisible(true);
3687
+ setAnchorEl(null);
3688
+ };
3689
+
3690
+ var handleOpenFilterModeMenu = function handleOpenFilterModeMenu(event) {
3691
+ event.stopPropagation();
3692
+ setFilterMenuAnchorEl(event.currentTarget);
3693
+ };
3694
+
3695
+ var handleOpenShowHideColumnsMenu = function handleOpenShowHideColumnsMenu(event) {
3696
+ event.stopPropagation();
3697
+ setShowHideColumnsMenuAnchorEl(event.currentTarget);
3698
+ };
3699
+
3700
+ return React__default.createElement(material.Menu, {
3701
+ anchorEl: anchorEl,
3702
+ open: !!anchorEl,
3703
+ onClose: function onClose() {
3704
+ return setAnchorEl(null);
3705
+ },
3706
+ MenuListProps: {
3707
+ dense: isDensePadding
3708
+ }
3709
+ }, enableSorting && column.getCanSort() && [React__default.createElement(material.MenuItem, {
3710
+ disabled: !column.getIsSorted(),
3711
+ key: 0,
3712
+ onClick: handleClearSort,
3713
+ sx: commonMenuItemStyles$1
3714
+ }, React__default.createElement(material.Box, {
3715
+ sx: commonListItemStyles
3716
+ }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(ClearAllIcon, null)), localization.clearSort)), React__default.createElement(material.MenuItem, {
3717
+ disabled: column.getIsSorted() === 'asc',
3718
+ key: 1,
3719
+ onClick: handleSortAsc,
3720
+ sx: commonMenuItemStyles$1
3721
+ }, React__default.createElement(material.Box, {
3722
+ sx: commonListItemStyles
3723
+ }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(SortIcon, null)), (_localization$sortByC = localization.sortByColumnAsc) == null ? void 0 : _localization$sortByC.replace('{column}', String(columnDef.header)))), React__default.createElement(material.MenuItem, {
3724
+ divider: enableColumnFilters || enableGrouping || enableHiding,
3725
+ key: 2,
3726
+ disabled: column.getIsSorted() === 'desc',
3727
+ onClick: handleSortDesc,
3728
+ sx: commonMenuItemStyles$1
3729
+ }, React__default.createElement(material.Box, {
3730
+ sx: commonListItemStyles
3731
+ }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(SortIcon, {
3732
+ style: {
3733
+ transform: 'rotate(180deg) scaleX(-1)'
3734
+ }
3735
+ })), (_localization$sortByC2 = localization.sortByColumnDesc) == null ? void 0 : _localization$sortByC2.replace('{column}', String(columnDef.header))))], enableColumnFilters && column.getCanFilter() && [React__default.createElement(material.MenuItem, {
3736
+ disabled: !column.getFilterValue(),
3737
+ key: 0,
3738
+ onClick: handleClearFilter,
3739
+ sx: commonMenuItemStyles$1
3740
+ }, React__default.createElement(material.Box, {
3741
+ sx: commonListItemStyles
3742
+ }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(FilterListOffIcon, null)), localization.clearFilter)), React__default.createElement(material.MenuItem, {
3743
+ divider: enableGrouping || enableHiding,
3744
+ key: 1,
3745
+ onClick: handleFilterByColumn,
3746
+ sx: commonMenuItemStyles$1
3747
+ }, React__default.createElement(material.Box, {
3748
+ sx: commonListItemStyles
3749
+ }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(FilterListIcon, null)), (_localization$filterB = localization.filterByColumn) == null ? void 0 : _localization$filterB.replace('{column}', String(columnDef.header))), !columnDef.filterSelectOptions && React__default.createElement(material.IconButton, {
3750
+ onClick: handleOpenFilterModeMenu,
3751
+ onMouseEnter: handleOpenFilterModeMenu,
3752
+ size: "small",
3753
+ sx: {
3754
+ p: 0
3755
+ }
3756
+ }, React__default.createElement(ArrowRightIcon, null))), React__default.createElement(MRT_FilterOptionMenu, {
3757
+ anchorEl: filterMenuAnchorEl,
3758
+ header: header,
3759
+ key: 2,
3760
+ onSelect: handleFilterByColumn,
3761
+ setAnchorEl: setFilterMenuAnchorEl,
3762
+ tableInstance: tableInstance
3763
+ })], enableGrouping && column.getCanGroup() && [React__default.createElement(material.MenuItem, {
3764
+ divider: enablePinning,
3765
+ key: 0,
3766
+ onClick: handleGroupByColumn,
3767
+ sx: commonMenuItemStyles$1
3768
+ }, React__default.createElement(material.Box, {
3769
+ sx: commonListItemStyles
3770
+ }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(DynamicFeedIcon, null)), (_localization = localization[column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn']) == null ? void 0 : _localization.replace('{column}', String(columnDef.header))))], enablePinning && column.getCanPin() && [React__default.createElement(material.MenuItem, {
3771
+ disabled: column.getIsPinned() === 'left' || !column.getCanPin(),
3772
+ key: 0,
3773
+ onClick: function onClick() {
3774
+ return handlePinColumn('left');
3775
+ },
3776
+ sx: commonMenuItemStyles$1
3777
+ }, React__default.createElement(material.Box, {
3778
+ sx: commonListItemStyles
3779
+ }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(PushPinIcon, {
3780
+ style: {
3781
+ transform: 'rotate(90deg)'
3782
+ }
3783
+ })), localization.pinToLeft)), React__default.createElement(material.MenuItem, {
3784
+ disabled: column.getIsPinned() === 'right' || !column.getCanPin(),
3785
+ key: 1,
3786
+ onClick: function onClick() {
3787
+ return handlePinColumn('right');
3788
+ },
3789
+ sx: commonMenuItemStyles$1
3790
+ }, React__default.createElement(material.Box, {
3791
+ sx: commonListItemStyles
3792
+ }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(PushPinIcon, {
3793
+ style: {
3794
+ transform: 'rotate(-90deg)'
3795
+ }
3796
+ })), localization.pinToRight)), React__default.createElement(material.MenuItem, {
3797
+ disabled: !column.getIsPinned(),
3798
+ divider: enableHiding,
3799
+ key: 2,
3800
+ onClick: function onClick() {
3801
+ return handlePinColumn(false);
3802
+ },
3803
+ sx: commonMenuItemStyles$1
3804
+ }, React__default.createElement(material.Box, {
3805
+ sx: commonListItemStyles
3806
+ }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(PushPinIcon, null)), localization.unpin))], enableColumnResizing && [React__default.createElement(material.MenuItem, {
3807
+ disabled: !column.getCanResize() || !columnSizing[column.id],
3808
+ key: 0,
3809
+ onClick: handleResetColumnSize,
3810
+ sx: commonMenuItemStyles$1
3811
+ }, React__default.createElement(material.Box, {
3812
+ sx: commonListItemStyles
3813
+ }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(RestartAltIcon, null)), localization.resetColumnSize))], enableHiding && [React__default.createElement(material.MenuItem, {
3814
+ disabled: columnDef.enableHiding === false,
3815
+ key: 0,
3816
+ onClick: handleHideColumn,
3817
+ sx: commonMenuItemStyles$1
3818
+ }, React__default.createElement(material.Box, {
3819
+ sx: commonListItemStyles
3820
+ }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(VisibilityOffIcon, null)), (_localization$hideCol = localization.hideColumn) == null ? void 0 : _localization$hideCol.replace('{column}', String(columnDef.header)))), React__default.createElement(material.MenuItem, {
3821
+ disabled: !Object.values(columnVisibility).filter(function (visible) {
3822
+ return !visible;
3823
+ }).length,
3824
+ key: 1,
3825
+ onClick: handleShowAllColumns,
3826
+ sx: commonMenuItemStyles$1
3827
+ }, React__default.createElement(material.Box, {
3828
+ sx: commonListItemStyles
3829
+ }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(ViewColumnIcon, null)), (_localization$showAll = localization.showAllColumns) == null ? void 0 : _localization$showAll.replace('{column}', String(columnDef.header))), React__default.createElement(material.IconButton, {
3830
+ onClick: handleOpenShowHideColumnsMenu,
3831
+ onMouseEnter: handleOpenShowHideColumnsMenu,
3832
+ size: "small",
3833
+ sx: {
3834
+ p: 0
3835
+ }
3836
+ }, React__default.createElement(ArrowRightIcon, null))), React__default.createElement(MRT_ShowHideColumnsMenu, {
3837
+ anchorEl: showHideColumnsMenuAnchorEl,
3838
+ isSubMenu: true,
3839
+ key: 2,
3840
+ setAnchorEl: setShowHideColumnsMenuAnchorEl,
3841
+ tableInstance: tableInstance
3842
+ })]);
3843
+ };
3718
3844
 
3719
- function useDragSourceConnector(dragSourceOptions, dragPreviewOptions) {
3720
- const manager = useDragDropManager();
3721
- const connector = React.useMemo(()=>new SourceConnector(manager.getBackend())
3722
- , [
3723
- manager
3724
- ]);
3725
- useIsomorphicLayoutEffect(()=>{
3726
- connector.dragSourceOptions = dragSourceOptions || null;
3727
- connector.reconnect();
3728
- return ()=>connector.disconnectDragSource()
3729
- ;
3730
- }, [
3731
- connector,
3732
- dragSourceOptions
3733
- ]);
3734
- useIsomorphicLayoutEffect(()=>{
3735
- connector.dragPreviewOptions = dragPreviewOptions || null;
3736
- connector.reconnect();
3737
- return ()=>connector.disconnectDragPreview()
3738
- ;
3739
- }, [
3740
- connector,
3741
- dragPreviewOptions
3742
- ]);
3743
- return connector;
3744
- }
3845
+ var MRT_RowActionMenu = function MRT_RowActionMenu(_ref) {
3846
+ var anchorEl = _ref.anchorEl,
3847
+ handleEdit = _ref.handleEdit,
3848
+ row = _ref.row,
3849
+ setAnchorEl = _ref.setAnchorEl,
3850
+ tableInstance = _ref.tableInstance;
3851
+ var getState = tableInstance.getState,
3852
+ _tableInstance$option = tableInstance.options,
3853
+ EditIcon = _tableInstance$option.icons.EditIcon,
3854
+ enableEditing = _tableInstance$option.enableEditing,
3855
+ localization = _tableInstance$option.localization,
3856
+ renderRowActionMenuItems = _tableInstance$option.renderRowActionMenuItems;
3745
3857
 
3746
- function useDragSourceMonitor() {
3747
- const manager = useDragDropManager();
3748
- return React.useMemo(()=>new DragSourceMonitorImpl(manager)
3749
- , [
3750
- manager
3751
- ]);
3752
- }
3858
+ var _getState = getState(),
3859
+ isDensePadding = _getState.isDensePadding;
3753
3860
 
3754
- class DragSourceImpl {
3755
- beginDrag() {
3756
- const spec = this.spec;
3757
- const monitor = this.monitor;
3758
- let result = null;
3759
- if (typeof spec.item === 'object') {
3760
- result = spec.item;
3761
- } else if (typeof spec.item === 'function') {
3762
- result = spec.item(monitor);
3763
- } else {
3764
- result = {};
3765
- }
3766
- return result !== null && result !== void 0 ? result : null;
3767
- }
3768
- canDrag() {
3769
- const spec = this.spec;
3770
- const monitor = this.monitor;
3771
- if (typeof spec.canDrag === 'boolean') {
3772
- return spec.canDrag;
3773
- } else if (typeof spec.canDrag === 'function') {
3774
- return spec.canDrag(monitor);
3775
- } else {
3776
- return true;
3777
- }
3778
- }
3779
- isDragging(globalMonitor, target) {
3780
- const spec = this.spec;
3781
- const monitor = this.monitor;
3782
- const { isDragging } = spec;
3783
- return isDragging ? isDragging(monitor) : target === globalMonitor.getSourceId();
3784
- }
3785
- endDrag() {
3786
- const spec = this.spec;
3787
- const monitor = this.monitor;
3788
- const connector = this.connector;
3789
- const { end } = spec;
3790
- if (end) {
3791
- end(monitor.getItem(), monitor);
3792
- }
3793
- connector.reconnect();
3861
+ return React__default.createElement(material.Menu, {
3862
+ anchorEl: anchorEl,
3863
+ open: !!anchorEl,
3864
+ onClose: function onClose() {
3865
+ return setAnchorEl(null);
3866
+ },
3867
+ MenuListProps: {
3868
+ dense: isDensePadding
3794
3869
  }
3795
- constructor(spec, monitor, connector){
3796
- this.spec = spec;
3797
- this.monitor = monitor;
3798
- this.connector = connector;
3870
+ }, enableEditing && React__default.createElement(material.MenuItem, {
3871
+ onClick: handleEdit,
3872
+ sx: commonMenuItemStyles$1
3873
+ }, React__default.createElement(material.Box, {
3874
+ sx: commonListItemStyles
3875
+ }, React__default.createElement(material.ListItemIcon, null, React__default.createElement(EditIcon, null)), localization.edit)), renderRowActionMenuItems == null ? void 0 : renderRowActionMenuItems({
3876
+ row: row,
3877
+ tableInstance: tableInstance,
3878
+ closeMenu: function closeMenu() {
3879
+ return setAnchorEl(null);
3799
3880
  }
3800
- }
3881
+ }));
3882
+ };
3801
3883
 
3802
- function useDragSource(spec, monitor, connector) {
3803
- const handler = React.useMemo(()=>new DragSourceImpl(spec, monitor, connector)
3804
- , [
3805
- monitor,
3806
- connector
3807
- ]);
3808
- React.useEffect(()=>{
3809
- handler.spec = spec;
3810
- }, [
3811
- spec
3812
- ]);
3813
- return handler;
3814
- }
3884
+ var MRT_EditActionButtons = function MRT_EditActionButtons(_ref) {
3885
+ var row = _ref.row,
3886
+ tableInstance = _ref.tableInstance;
3887
+ var getState = tableInstance.getState,
3888
+ _tableInstance$option = tableInstance.options,
3889
+ _tableInstance$option2 = _tableInstance$option.icons,
3890
+ CancelIcon = _tableInstance$option2.CancelIcon,
3891
+ SaveIcon = _tableInstance$option2.SaveIcon,
3892
+ localization = _tableInstance$option.localization,
3893
+ onEditSubmit = _tableInstance$option.onEditSubmit,
3894
+ setCurrentEditingRow = tableInstance.setCurrentEditingRow;
3815
3895
 
3816
- function useDragType(spec) {
3817
- return React.useMemo(()=>{
3818
- const result = spec.type;
3819
- invariant(result != null, 'spec.type must be defined');
3820
- return result;
3821
- }, [
3822
- spec
3823
- ]);
3824
- }
3896
+ var _getState = getState(),
3897
+ currentEditingRow = _getState.currentEditingRow;
3825
3898
 
3826
- function useRegisteredDragSource(spec, monitor, connector) {
3827
- const manager = useDragDropManager();
3828
- const handler = useDragSource(spec, monitor, connector);
3829
- const itemType = useDragType(spec);
3830
- useIsomorphicLayoutEffect(function registerDragSource() {
3831
- if (itemType != null) {
3832
- const [handlerId, unregister] = registerSource(itemType, handler, manager);
3833
- monitor.receiveHandlerId(handlerId);
3834
- connector.receiveHandlerId(handlerId);
3835
- return unregister;
3836
- }
3837
- return;
3838
- }, [
3839
- manager,
3840
- monitor,
3841
- connector,
3842
- handler,
3843
- itemType
3844
- ]);
3845
- }
3899
+ var handleCancel = function handleCancel() {
3900
+ var _row$original;
3846
3901
 
3847
- /**
3848
- * useDragSource hook
3849
- * @param sourceSpec The drag source specification (object or function, function preferred)
3850
- * @param deps The memoization deps array to use when evaluating spec changes
3851
- */ function useDrag(specArg, deps) {
3852
- const spec = useOptionalFactory(specArg, deps);
3853
- invariant(!spec.begin, `useDrag::spec.begin was deprecated in v14. Replace spec.begin() with spec.item(). (see more here - https://react-dnd.github.io/react-dnd/docs/api/use-drag)`);
3854
- const monitor = useDragSourceMonitor();
3855
- const connector = useDragSourceConnector(spec.options, spec.previewOptions);
3856
- useRegisteredDragSource(spec, monitor, connector);
3857
- return [
3858
- useCollectedProps(spec.collect, monitor, connector),
3859
- useConnectDragSource(connector),
3860
- useConnectDragPreview(connector),
3861
- ];
3862
- }
3902
+ row._valuesCache = (_row$original = row.original) != null ? _row$original : {};
3903
+ setCurrentEditingRow(null);
3904
+ };
3905
+
3906
+ var handleSave = function handleSave() {
3907
+ onEditSubmit == null ? void 0 : onEditSubmit({
3908
+ row: currentEditingRow != null ? currentEditingRow : row,
3909
+ tableInstance: tableInstance
3910
+ });
3911
+ setCurrentEditingRow(null);
3912
+ };
3913
+
3914
+ return React__default.createElement(material.Box, {
3915
+ sx: {
3916
+ display: 'flex',
3917
+ gap: '0.75rem'
3918
+ }
3919
+ }, React__default.createElement(material.Tooltip, {
3920
+ arrow: true,
3921
+ title: localization.cancel
3922
+ }, React__default.createElement(material.IconButton, {
3923
+ "aria-label": localization.cancel,
3924
+ onClick: handleCancel
3925
+ }, React__default.createElement(CancelIcon, null))), React__default.createElement(material.Tooltip, {
3926
+ arrow: true,
3927
+ title: localization.save
3928
+ }, React__default.createElement(material.IconButton, {
3929
+ "aria-label": localization.save,
3930
+ color: "info",
3931
+ onClick: handleSave
3932
+ }, React__default.createElement(SaveIcon, null))));
3933
+ };
3934
+
3935
+ var commonIconButtonStyles = {
3936
+ height: '2rem',
3937
+ ml: '10px',
3938
+ opacity: 0.5,
3939
+ transition: 'opacity 0.2s',
3940
+ width: '2rem',
3941
+ '&:hover': {
3942
+ opacity: 1
3943
+ }
3944
+ };
3945
+ var MRT_ToggleRowActionMenuButton = function MRT_ToggleRowActionMenuButton(_ref) {
3946
+ var row = _ref.row,
3947
+ tableInstance = _ref.tableInstance;
3948
+ var getState = tableInstance.getState,
3949
+ _tableInstance$option = tableInstance.options,
3950
+ enableEditing = _tableInstance$option.enableEditing,
3951
+ _tableInstance$option2 = _tableInstance$option.icons,
3952
+ EditIcon = _tableInstance$option2.EditIcon,
3953
+ MoreHorizIcon = _tableInstance$option2.MoreHorizIcon,
3954
+ localization = _tableInstance$option.localization,
3955
+ renderRowActionMenuItems = _tableInstance$option.renderRowActionMenuItems,
3956
+ renderRowActions = _tableInstance$option.renderRowActions,
3957
+ setCurrentEditingRow = tableInstance.setCurrentEditingRow;
3863
3958
 
3864
- function useConnectDropTarget(connector) {
3865
- return React.useMemo(()=>connector.hooks.dropTarget()
3866
- , [
3867
- connector
3868
- ]);
3869
- }
3959
+ var _getState = getState(),
3960
+ currentEditingRow = _getState.currentEditingRow;
3870
3961
 
3871
- function useDropTargetConnector(options) {
3872
- const manager = useDragDropManager();
3873
- const connector = React.useMemo(()=>new TargetConnector(manager.getBackend())
3874
- , [
3875
- manager
3876
- ]);
3877
- useIsomorphicLayoutEffect(()=>{
3878
- connector.dropTargetOptions = options || null;
3879
- connector.reconnect();
3880
- return ()=>connector.disconnectDropTarget()
3881
- ;
3882
- }, [
3883
- options
3884
- ]);
3885
- return connector;
3886
- }
3962
+ var _useState = React.useState(null),
3963
+ anchorEl = _useState[0],
3964
+ setAnchorEl = _useState[1];
3887
3965
 
3888
- function useDropTargetMonitor() {
3889
- const manager = useDragDropManager();
3890
- return React.useMemo(()=>new DropTargetMonitorImpl(manager)
3891
- , [
3892
- manager
3893
- ]);
3894
- }
3966
+ var handleOpenRowActionMenu = function handleOpenRowActionMenu(event) {
3967
+ event.stopPropagation();
3968
+ event.preventDefault();
3969
+ setAnchorEl(event.currentTarget);
3970
+ };
3895
3971
 
3896
- /**
3897
- * Internal utility hook to get an array-version of spec.accept.
3898
- * The main utility here is that we aren't creating a new array on every render if a non-array spec.accept is passed in.
3899
- * @param spec
3900
- */ function useAccept(spec) {
3901
- const { accept } = spec;
3902
- return React.useMemo(()=>{
3903
- invariant(spec.accept != null, 'accept must be defined');
3904
- return Array.isArray(accept) ? accept : [
3905
- accept
3906
- ];
3907
- }, [
3908
- accept
3909
- ]);
3910
- }
3972
+ var handleStartEditMode = function handleStartEditMode() {
3973
+ setCurrentEditingRow(_extends({}, row));
3974
+ setAnchorEl(null);
3975
+ };
3911
3976
 
3912
- class DropTargetImpl {
3913
- canDrop() {
3914
- const spec = this.spec;
3915
- const monitor = this.monitor;
3916
- return spec.canDrop ? spec.canDrop(monitor.getItem(), monitor) : true;
3917
- }
3918
- hover() {
3919
- const spec = this.spec;
3920
- const monitor = this.monitor;
3921
- if (spec.hover) {
3922
- spec.hover(monitor.getItem(), monitor);
3923
- }
3924
- }
3925
- drop() {
3926
- const spec = this.spec;
3927
- const monitor = this.monitor;
3928
- if (spec.drop) {
3929
- return spec.drop(monitor.getItem(), monitor);
3930
- }
3931
- return;
3932
- }
3933
- constructor(spec, monitor){
3934
- this.spec = spec;
3935
- this.monitor = monitor;
3936
- }
3937
- }
3977
+ return React__default.createElement(React__default.Fragment, null, renderRowActions ? React__default.createElement(React__default.Fragment, null, renderRowActions({
3978
+ row: row,
3979
+ tableInstance: tableInstance
3980
+ })) : row.id === (currentEditingRow == null ? void 0 : currentEditingRow.id) ? React__default.createElement(MRT_EditActionButtons, {
3981
+ row: row,
3982
+ tableInstance: tableInstance
3983
+ }) : !renderRowActionMenuItems && enableEditing ? React__default.createElement(material.Tooltip, {
3984
+ placement: "right",
3985
+ arrow: true,
3986
+ title: localization.edit
3987
+ }, React__default.createElement(material.IconButton, {
3988
+ sx: commonIconButtonStyles,
3989
+ onClick: handleStartEditMode
3990
+ }, React__default.createElement(EditIcon, null))) : renderRowActionMenuItems ? React__default.createElement(React__default.Fragment, null, React__default.createElement(material.Tooltip, {
3991
+ arrow: true,
3992
+ enterDelay: 1000,
3993
+ enterNextDelay: 1000,
3994
+ title: localization.rowActions
3995
+ }, React__default.createElement(material.IconButton, {
3996
+ "aria-label": localization.rowActions,
3997
+ onClick: handleOpenRowActionMenu,
3998
+ size: "small",
3999
+ sx: commonIconButtonStyles
4000
+ }, React__default.createElement(MoreHorizIcon, null))), React__default.createElement(MRT_RowActionMenu, {
4001
+ anchorEl: anchorEl,
4002
+ handleEdit: handleStartEditMode,
4003
+ row: row,
4004
+ setAnchorEl: setAnchorEl,
4005
+ tableInstance: tableInstance
4006
+ })) : null);
4007
+ };
3938
4008
 
3939
- function useDropTarget(spec, monitor) {
3940
- const dropTarget = React.useMemo(()=>new DropTargetImpl(spec, monitor)
3941
- , [
3942
- monitor
3943
- ]);
3944
- React.useEffect(()=>{
3945
- dropTarget.spec = spec;
3946
- }, [
3947
- spec
3948
- ]);
3949
- return dropTarget;
3950
- }
4009
+ var MRT_SelectCheckbox = function MRT_SelectCheckbox(_ref) {
4010
+ var row = _ref.row,
4011
+ selectAll = _ref.selectAll,
4012
+ tableInstance = _ref.tableInstance;
4013
+ var getRowModel = tableInstance.getRowModel,
4014
+ getSelectedRowModel = tableInstance.getSelectedRowModel,
4015
+ getState = tableInstance.getState,
4016
+ _tableInstance$option = tableInstance.options,
4017
+ localization = _tableInstance$option.localization,
4018
+ muiSelectCheckboxProps = _tableInstance$option.muiSelectCheckboxProps,
4019
+ onSelectChange = _tableInstance$option.onSelectChange,
4020
+ onSelectAllChange = _tableInstance$option.onSelectAllChange;
3951
4021
 
3952
- function useRegisteredDropTarget(spec, monitor, connector) {
3953
- const manager = useDragDropManager();
3954
- const dropTarget = useDropTarget(spec, monitor);
3955
- const accept = useAccept(spec);
3956
- useIsomorphicLayoutEffect(function registerDropTarget() {
3957
- const [handlerId, unregister] = registerTarget(accept, dropTarget, manager);
3958
- monitor.receiveHandlerId(handlerId);
3959
- connector.receiveHandlerId(handlerId);
3960
- return unregister;
3961
- }, [
3962
- manager,
3963
- monitor,
3964
- dropTarget,
3965
- connector,
3966
- accept.map((a)=>a.toString()
3967
- ).join('|'),
3968
- ]);
3969
- }
4022
+ var _getState = getState(),
4023
+ isDensePadding = _getState.isDensePadding;
3970
4024
 
3971
- /**
3972
- * useDropTarget Hook
3973
- * @param spec The drop target specification (object or function, function preferred)
3974
- * @param deps The memoization deps array to use when evaluating spec changes
3975
- */ function useDrop(specArg, deps) {
3976
- const spec = useOptionalFactory(specArg, deps);
3977
- const monitor = useDropTargetMonitor();
3978
- const connector = useDropTargetConnector(spec.options);
3979
- useRegisteredDropTarget(spec, monitor, connector);
3980
- return [
3981
- useCollectedProps(spec.collect, monitor, connector),
3982
- useConnectDropTarget(connector),
3983
- ];
3984
- }
4025
+ var handleSelectChange = function handleSelectChange(event) {
4026
+ if (selectAll) {
4027
+ tableInstance.getToggleAllRowsSelectedHandler()(event);
4028
+ onSelectAllChange == null ? void 0 : onSelectAllChange({
4029
+ event: event,
4030
+ selectedRows: event.target.checked ? getRowModel().flatRows : [],
4031
+ tableInstance: tableInstance
4032
+ });
4033
+ } else if (row) {
4034
+ row == null ? void 0 : row.getToggleSelectedHandler()(event);
4035
+ onSelectChange == null ? void 0 : onSelectChange({
4036
+ event: event,
4037
+ row: row,
4038
+ selectedRows: event.target.checked ? [].concat(getSelectedRowModel().flatRows, [row]) : getSelectedRowModel().flatRows.filter(function (selectedRow) {
4039
+ return selectedRow.id !== row.id;
4040
+ }),
4041
+ tableInstance: tableInstance
4042
+ });
4043
+ }
4044
+ };
4045
+
4046
+ var checkboxProps = muiSelectCheckboxProps instanceof Function ? muiSelectCheckboxProps({
4047
+ isSelectAll: !!selectAll,
4048
+ row: row,
4049
+ tableInstance: tableInstance
4050
+ }) : muiSelectCheckboxProps;
4051
+ return React__default.createElement(material.Tooltip, {
4052
+ arrow: true,
4053
+ enterDelay: 1000,
4054
+ enterNextDelay: 1000,
4055
+ title: selectAll ? localization.toggleSelectAll : localization.toggleSelectRow
4056
+ }, React__default.createElement(material.Checkbox, Object.assign({
4057
+ checked: selectAll ? tableInstance.getIsAllRowsSelected() : row == null ? void 0 : row.getIsSelected(),
4058
+ indeterminate: selectAll ? tableInstance.getIsSomeRowsSelected() : row == null ? void 0 : row.getIsSomeSelected(),
4059
+ inputProps: {
4060
+ 'aria-label': selectAll ? localization.toggleSelectAll : localization.toggleSelectRow
4061
+ },
4062
+ onChange: handleSelectChange,
4063
+ size: isDensePadding ? 'small' : 'medium'
4064
+ }, checkboxProps, {
4065
+ sx: _extends({
4066
+ height: isDensePadding ? '1.75rem' : '2.25rem',
4067
+ width: isDensePadding ? '1.75rem' : '2.25rem'
4068
+ }, checkboxProps == null ? void 0 : checkboxProps.sx)
4069
+ })));
4070
+ };
3985
4071
 
3986
4072
  // cheap lodash replacements
3987
4073
  function memoize(fn) {
@@ -5827,38 +5913,6 @@ var MRT_TableHeadCellFilterLabel = function MRT_TableHeadCellFilterLabel(_ref) {
5827
5913
  }, showFilters && !column.getFilterValue() ? React__default.createElement(FilterAltOffIcon, null) : React__default.createElement(FilterAltIcon, null)));
5828
5914
  };
5829
5915
 
5830
- var MRT_TableHeadCellGrabHandle = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
5831
- var tableInstance = _ref.tableInstance;
5832
- var _tableInstance$option = tableInstance.options,
5833
- DragHandleIcon = _tableInstance$option.icons.DragHandleIcon,
5834
- localization = _tableInstance$option.localization;
5835
- return React__default.createElement(material.Tooltip, {
5836
- arrow: true,
5837
- enterDelay: 1000,
5838
- enterNextDelay: 1000,
5839
- placement: "top",
5840
- title: localization.grab
5841
- }, React__default.createElement(material.IconButton, {
5842
- disableRipple: true,
5843
- ref: ref,
5844
- size: "small",
5845
- sx: {
5846
- cursor: 'grab',
5847
- m: 0,
5848
- opacity: 0.5,
5849
- p: '2px',
5850
- transition: 'all 0.2s ease-in-out',
5851
- '&:hover': {
5852
- backgroundColor: 'transparent',
5853
- opacity: 1
5854
- },
5855
- '&:active': {
5856
- cursor: 'grabbing'
5857
- }
5858
- }
5859
- }, React__default.createElement(DragHandleIcon, null)));
5860
- });
5861
-
5862
5916
  var MRT_TableHeadCellResizeHandle = function MRT_TableHeadCellResizeHandle(_ref) {
5863
5917
  var header = _ref.header,
5864
5918
  tableInstance = _ref.tableInstance;
@@ -6092,8 +6146,7 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
6092
6146
  sx: {
6093
6147
  whiteSpace: 'nowrap'
6094
6148
  }
6095
- }, columnDefType === 'data' && (enableColumnOrdering && columnDef.enableColumnOrdering !== false || enableGrouping && columnDef.enableGrouping !== false) && React__default.createElement(MRT_TableHeadCellGrabHandle, {
6096
- header: header,
6149
+ }, columnDefType === 'data' && (enableColumnOrdering && columnDef.enableColumnOrdering !== false || enableGrouping && columnDef.enableGrouping !== false) && React__default.createElement(MRT_GrabHandleButton, {
6097
6150
  ref: dragRef,
6098
6151
  tableInstance: tableInstance
6099
6152
  }), (enableColumnActions || columnDef.enableColumnActions) && columnDef.enableColumnActions !== false && columnDefType !== 'group' && React__default.createElement(MRT_ToggleColumnActionMenuButton, {
@@ -6125,8 +6178,7 @@ var MRT_DraggableTableHeadCell = function MRT_DraggableTableHeadCell(_ref) {
6125
6178
  movingHeader.column.pin(receivingHeader.column.getIsPinned());
6126
6179
  }
6127
6180
 
6128
- var currentIndex = movingHeader.index;
6129
- columnOrder.splice(receivingHeader.index, 0, columnOrder.splice(currentIndex, 1)[0]);
6181
+ columnOrder.splice(receivingHeader.index, 0, columnOrder.splice(movingHeader.index, 1)[0]);
6130
6182
  setColumnOrder([].concat(columnOrder));
6131
6183
  };
6132
6184