material-react-table 0.8.10 → 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.
- package/dist/MaterialReactTable.d.ts +5 -4
- package/dist/buttons/MRT_GrabHandleButton.d.ts +8 -0
- package/dist/localization.d.ts +1 -0
- package/dist/material-react-table.cjs.development.js +1879 -1835
- package/dist/material-react-table.cjs.development.js.map +1 -1
- package/dist/material-react-table.cjs.production.min.js +1 -1
- package/dist/material-react-table.cjs.production.min.js.map +1 -1
- package/dist/material-react-table.esm.js +202 -158
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ShowHideColumnsMenu.d.ts +1 -1
- package/dist/menus/MRT_ShowHideColumnsMenuItems.d.ts +1 -0
- package/dist/table/MRT_TableRoot.d.ts +0 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +13 -13
- package/src/MaterialReactTable.tsx +5 -6
- package/src/body/MRT_TableBodyCell.tsx +8 -9
- package/src/buttons/MRT_ColumnPinningButtons.tsx +1 -1
- package/src/buttons/MRT_CopyButton.tsx +7 -3
- package/src/{head/MRT_TableHeadCellGrabHandle.tsx → buttons/MRT_GrabHandleButton.tsx} +2 -3
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +5 -4
- package/src/footer/MRT_TableFooterCell.tsx +2 -2
- package/src/footer/MRT_TableFooterRow.tsx +4 -4
- package/src/head/MRT_DraggableTableHeadCell.tsx +15 -9
- package/src/head/MRT_TableHeadCell.tsx +6 -12
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +3 -1
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +3 -2
- package/src/head/MRT_TableHeadCellSortLabel.tsx +4 -8
- package/src/inputs/MRT_FilterTextField.tsx +1 -1
- package/src/localization.ts +2 -0
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +25 -38
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +74 -21
- package/src/table/MRT_TableRoot.tsx +29 -28
- package/dist/head/MRT_TableHeadCellGrabHandle.d.ts +0 -9
|
@@ -87,6 +87,7 @@ var MRT_DefaultLocalization_EN = {
|
|
|
87
87
|
pinToLeft: 'Pin to left',
|
|
88
88
|
pinToRight: 'Pin to right',
|
|
89
89
|
resetColumnSize: 'Reset column size',
|
|
90
|
+
resetOrder: 'Reset order',
|
|
90
91
|
rowActions: 'Row Actions',
|
|
91
92
|
rowNumber: '#',
|
|
92
93
|
rowNumbers: 'Row Numbers',
|
|
@@ -495,1770 +496,1060 @@ var MRT_FilterOptionMenu = function MRT_FilterOptionMenu(_ref) {
|
|
|
495
496
|
}));
|
|
496
497
|
};
|
|
497
498
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
localization = _tableInstance$option.localization;
|
|
499
|
+
/**
|
|
500
|
+
* Create the React Context
|
|
501
|
+
*/ const DndContext = React.createContext({
|
|
502
|
+
dragDropManager: undefined
|
|
503
|
+
});
|
|
504
504
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
505
|
+
// Inlined version of the `symbol-observable` polyfill
|
|
506
|
+
var $$observable = (function () {
|
|
507
|
+
return typeof Symbol === 'function' && Symbol.observable || '@@observable';
|
|
508
|
+
})();
|
|
508
509
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
onClick: function onClick() {
|
|
518
|
-
return handlePinColumn(false);
|
|
519
|
-
},
|
|
520
|
-
size: "small"
|
|
521
|
-
}, React__default.createElement(PushPinIcon, null))) : React__default.createElement(React__default.Fragment, null, React__default.createElement(material.Tooltip, {
|
|
522
|
-
arrow: true,
|
|
523
|
-
title: localization.pinToLeft
|
|
524
|
-
}, React__default.createElement(material.IconButton, {
|
|
525
|
-
onClick: function onClick() {
|
|
526
|
-
return handlePinColumn('left');
|
|
527
|
-
},
|
|
528
|
-
size: "small"
|
|
529
|
-
}, React__default.createElement(PushPinIcon, {
|
|
530
|
-
style: {
|
|
531
|
-
transform: 'rotate(90deg)'
|
|
532
|
-
}
|
|
533
|
-
}))), React__default.createElement(material.Tooltip, {
|
|
534
|
-
arrow: true,
|
|
535
|
-
title: localization.pinToRight
|
|
536
|
-
}, React__default.createElement(material.IconButton, {
|
|
537
|
-
onClick: function onClick() {
|
|
538
|
-
return handlePinColumn('right');
|
|
539
|
-
},
|
|
540
|
-
size: "small"
|
|
541
|
-
}, React__default.createElement(PushPinIcon, {
|
|
542
|
-
style: {
|
|
543
|
-
transform: 'rotate(-90deg)'
|
|
544
|
-
}
|
|
545
|
-
})))));
|
|
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('.');
|
|
546
518
|
};
|
|
547
519
|
|
|
548
|
-
var
|
|
549
|
-
|
|
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
|
+
};
|
|
550
527
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
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;
|
|
556
535
|
|
|
557
|
-
|
|
558
|
-
|
|
536
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
537
|
+
proto = Object.getPrototypeOf(proto);
|
|
538
|
+
}
|
|
559
539
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
});
|
|
540
|
+
return Object.getPrototypeOf(obj) === proto;
|
|
541
|
+
}
|
|
563
542
|
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
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;
|
|
567
548
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
549
|
+
switch (type) {
|
|
550
|
+
case 'boolean':
|
|
551
|
+
case 'string':
|
|
552
|
+
case 'number':
|
|
553
|
+
case 'symbol':
|
|
554
|
+
case 'function':
|
|
555
|
+
{
|
|
556
|
+
return type;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
574
559
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
});
|
|
580
|
-
};
|
|
560
|
+
if (Array.isArray(val)) return 'array';
|
|
561
|
+
if (isDate(val)) return 'date';
|
|
562
|
+
if (isError(val)) return 'error';
|
|
563
|
+
var constructorName = ctorName(val);
|
|
581
564
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}
|
|
591
|
-
column: column,
|
|
592
|
-
tableInstance: tableInstance
|
|
593
|
-
}), React__default.createElement(material.FormControlLabel, {
|
|
594
|
-
componentsProps: {
|
|
595
|
-
typography: {
|
|
596
|
-
sx: {
|
|
597
|
-
marginBottom: 0
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
},
|
|
601
|
-
checked: switchChecked,
|
|
602
|
-
control: React__default.createElement(material.Switch, null),
|
|
603
|
-
disabled: isSubMenu && switchChecked || !column.getCanHide(),
|
|
604
|
-
label: column.columnDef.header,
|
|
605
|
-
onChange: function onChange() {
|
|
606
|
-
return handleToggleColumnHidden(column);
|
|
607
|
-
}
|
|
608
|
-
})), (_column$columns2 = column.columns) == null ? void 0 : _column$columns2.map(function (c, i) {
|
|
609
|
-
return React__default.createElement(MRT_ShowHideColumnsMenuItems, {
|
|
610
|
-
key: i + "-" + c.id,
|
|
611
|
-
column: c,
|
|
612
|
-
isSubMenu: isSubMenu,
|
|
613
|
-
tableInstance: tableInstance
|
|
614
|
-
});
|
|
615
|
-
}));
|
|
616
|
-
};
|
|
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
|
|
617
574
|
|
|
618
|
-
var MRT_ShowHideColumnsMenu = function MRT_ShowHideColumnsMenu(_ref) {
|
|
619
|
-
var anchorEl = _ref.anchorEl,
|
|
620
|
-
isSubMenu = _ref.isSubMenu,
|
|
621
|
-
setAnchorEl = _ref.setAnchorEl,
|
|
622
|
-
tableInstance = _ref.tableInstance;
|
|
623
|
-
var getAllColumns = tableInstance.getAllColumns,
|
|
624
|
-
getIsAllColumnsVisible = tableInstance.getIsAllColumnsVisible,
|
|
625
|
-
getIsSomeColumnsVisible = tableInstance.getIsSomeColumnsVisible,
|
|
626
|
-
getIsSomeColumnsPinned = tableInstance.getIsSomeColumnsPinned,
|
|
627
|
-
getState = tableInstance.getState,
|
|
628
|
-
toggleAllColumnsVisible = tableInstance.toggleAllColumnsVisible,
|
|
629
|
-
getAllLeafColumns = tableInstance.getAllLeafColumns,
|
|
630
|
-
_tableInstance$option = tableInstance.options,
|
|
631
|
-
localization = _tableInstance$option.localization,
|
|
632
|
-
enablePinning = _tableInstance$option.enablePinning;
|
|
633
575
|
|
|
634
|
-
|
|
635
|
-
|
|
576
|
+
return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
|
|
577
|
+
}
|
|
636
578
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
}).forEach(function (col) {
|
|
641
|
-
return col.toggleVisibility(false);
|
|
642
|
-
});
|
|
643
|
-
};
|
|
579
|
+
function ctorName(val) {
|
|
580
|
+
return typeof val.constructor === 'function' ? val.constructor.name : null;
|
|
581
|
+
}
|
|
644
582
|
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
});
|
|
649
|
-
}, [getAllColumns()]);
|
|
650
|
-
var allDataColumns = React.useMemo(function () {
|
|
651
|
-
var dataColumns = getAllColumns().filter(function (col) {
|
|
652
|
-
return col.columnDefType !== 'display';
|
|
653
|
-
});
|
|
654
|
-
return getIsSomeColumnsPinned() ? [].concat(dataColumns.filter(function (c) {
|
|
655
|
-
return c.getIsPinned() === 'left';
|
|
656
|
-
}), [null], dataColumns.filter(function (c) {
|
|
657
|
-
return c.getIsPinned() === false;
|
|
658
|
-
}), [null], dataColumns.filter(function (c) {
|
|
659
|
-
return c.getIsPinned() === 'right';
|
|
660
|
-
})) : dataColumns;
|
|
661
|
-
}, [getAllColumns(), getState().columnPinning, getIsSomeColumnsPinned()]);
|
|
662
|
-
return React__default.createElement(material.Menu, {
|
|
663
|
-
anchorEl: anchorEl,
|
|
664
|
-
open: !!anchorEl,
|
|
665
|
-
onClose: function onClose() {
|
|
666
|
-
return setAnchorEl(null);
|
|
667
|
-
},
|
|
668
|
-
MenuListProps: {
|
|
669
|
-
dense: isDensePadding
|
|
670
|
-
}
|
|
671
|
-
}, React__default.createElement(material.Box, {
|
|
672
|
-
sx: {
|
|
673
|
-
display: 'flex',
|
|
674
|
-
justifyContent: isSubMenu ? 'center' : 'space-between',
|
|
675
|
-
p: '0.5rem',
|
|
676
|
-
pt: 0
|
|
677
|
-
}
|
|
678
|
-
}, !isSubMenu && React__default.createElement(material.Button, {
|
|
679
|
-
disabled: !getIsSomeColumnsVisible(),
|
|
680
|
-
onClick: hideAllColumns
|
|
681
|
-
}, localization.hideAll), !isSubMenu && enablePinning && React__default.createElement(material.Button, {
|
|
682
|
-
disabled: !getIsSomeColumnsPinned(),
|
|
683
|
-
onClick: function onClick() {
|
|
684
|
-
return tableInstance.resetColumnPinning(true);
|
|
685
|
-
}
|
|
686
|
-
}, localization.unpinAll), React__default.createElement(material.Button, {
|
|
687
|
-
disabled: getIsAllColumnsVisible(),
|
|
688
|
-
onClick: function onClick() {
|
|
689
|
-
return toggleAllColumnsVisible(true);
|
|
690
|
-
}
|
|
691
|
-
}, localization.showAll)), React__default.createElement(material.Divider, null), allDisplayColumns.map(function (column, index) {
|
|
692
|
-
return React__default.createElement(MRT_ShowHideColumnsMenuItems, {
|
|
693
|
-
column: column,
|
|
694
|
-
isSubMenu: isSubMenu,
|
|
695
|
-
key: index + "-" + column.id,
|
|
696
|
-
tableInstance: tableInstance
|
|
697
|
-
});
|
|
698
|
-
}), React__default.createElement(material.Divider, null), allDataColumns.map(function (column, index) {
|
|
699
|
-
return column ? React__default.createElement(MRT_ShowHideColumnsMenuItems, {
|
|
700
|
-
column: column,
|
|
701
|
-
isSubMenu: isSubMenu,
|
|
702
|
-
key: index + "-" + column.id,
|
|
703
|
-
tableInstance: tableInstance
|
|
704
|
-
}) : React__default.createElement(material.Divider, {
|
|
705
|
-
key: index + "-divider"
|
|
706
|
-
});
|
|
707
|
-
}));
|
|
708
|
-
};
|
|
583
|
+
function isError(val) {
|
|
584
|
+
return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
|
|
585
|
+
}
|
|
709
586
|
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
alignItems: 'center'
|
|
715
|
-
};
|
|
716
|
-
var commonListItemStyles = {
|
|
717
|
-
display: 'flex',
|
|
718
|
-
alignItems: 'center'
|
|
719
|
-
};
|
|
720
|
-
var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
721
|
-
var _localization$sortByC, _localization$sortByC2, _localization$filterB, _localization, _localization$hideCol, _localization$showAll;
|
|
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
|
+
}
|
|
722
591
|
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
setAnchorEl = _ref.setAnchorEl,
|
|
726
|
-
tableInstance = _ref.tableInstance;
|
|
727
|
-
var getState = tableInstance.getState,
|
|
728
|
-
toggleAllColumnsVisible = tableInstance.toggleAllColumnsVisible,
|
|
729
|
-
setColumnOrder = tableInstance.setColumnOrder,
|
|
730
|
-
_tableInstance$option = tableInstance.options,
|
|
731
|
-
enableColumnFilters = _tableInstance$option.enableColumnFilters,
|
|
732
|
-
enableColumnResizing = _tableInstance$option.enableColumnResizing,
|
|
733
|
-
enableGrouping = _tableInstance$option.enableGrouping,
|
|
734
|
-
enableHiding = _tableInstance$option.enableHiding,
|
|
735
|
-
enablePinning = _tableInstance$option.enablePinning,
|
|
736
|
-
enableSorting = _tableInstance$option.enableSorting,
|
|
737
|
-
_tableInstance$option2 = _tableInstance$option.icons,
|
|
738
|
-
ArrowRightIcon = _tableInstance$option2.ArrowRightIcon,
|
|
739
|
-
ClearAllIcon = _tableInstance$option2.ClearAllIcon,
|
|
740
|
-
ViewColumnIcon = _tableInstance$option2.ViewColumnIcon,
|
|
741
|
-
DynamicFeedIcon = _tableInstance$option2.DynamicFeedIcon,
|
|
742
|
-
FilterListIcon = _tableInstance$option2.FilterListIcon,
|
|
743
|
-
FilterListOffIcon = _tableInstance$option2.FilterListOffIcon,
|
|
744
|
-
PushPinIcon = _tableInstance$option2.PushPinIcon,
|
|
745
|
-
SortIcon = _tableInstance$option2.SortIcon,
|
|
746
|
-
RestartAltIcon = _tableInstance$option2.RestartAltIcon,
|
|
747
|
-
VisibilityOffIcon = _tableInstance$option2.VisibilityOffIcon,
|
|
748
|
-
idPrefix = _tableInstance$option.idPrefix,
|
|
749
|
-
localization = _tableInstance$option.localization,
|
|
750
|
-
setShowFilters = tableInstance.setShowFilters;
|
|
751
|
-
var column = header.column;
|
|
752
|
-
var columnDef = column.columnDef;
|
|
753
|
-
|
|
754
|
-
var _getState = getState(),
|
|
755
|
-
columnSizing = _getState.columnSizing,
|
|
756
|
-
columnVisibility = _getState.columnVisibility,
|
|
757
|
-
isDensePadding = _getState.isDensePadding;
|
|
592
|
+
function kindOf(val) {
|
|
593
|
+
var typeOfVal = typeof val;
|
|
758
594
|
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
595
|
+
{
|
|
596
|
+
typeOfVal = miniKindOf(val);
|
|
597
|
+
}
|
|
762
598
|
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
setShowHideColumnsMenuAnchorEl = _useState2[1];
|
|
599
|
+
return typeOfVal;
|
|
600
|
+
}
|
|
766
601
|
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
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
|
+
*/
|
|
771
627
|
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
setAnchorEl(null);
|
|
775
|
-
};
|
|
628
|
+
function createStore(reducer, preloadedState, enhancer) {
|
|
629
|
+
var _ref2;
|
|
776
630
|
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
};
|
|
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
|
+
}
|
|
781
634
|
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
}
|
|
635
|
+
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
|
|
636
|
+
enhancer = preloadedState;
|
|
637
|
+
preloadedState = undefined;
|
|
638
|
+
}
|
|
786
639
|
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
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
|
+
}
|
|
791
644
|
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
setAnchorEl(null);
|
|
795
|
-
};
|
|
645
|
+
return enhancer(createStore)(reducer, preloadedState);
|
|
646
|
+
}
|
|
796
647
|
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
return ['mrt-expand'].concat(old);
|
|
801
|
-
});
|
|
802
|
-
setAnchorEl(null);
|
|
803
|
-
};
|
|
648
|
+
if (typeof reducer !== 'function') {
|
|
649
|
+
throw new Error( "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
|
|
650
|
+
}
|
|
804
651
|
|
|
805
|
-
var
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
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
|
+
*/
|
|
809
664
|
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
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
|
+
*/
|
|
814
675
|
|
|
815
|
-
return (_document$getElementB = document.getElementById( // @ts-ignore
|
|
816
|
-
(_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();
|
|
817
|
-
}, 200);
|
|
818
|
-
setAnchorEl(null);
|
|
819
|
-
};
|
|
820
676
|
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
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
|
+
}
|
|
825
681
|
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
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
|
+
*/
|
|
830
707
|
|
|
831
|
-
var handleOpenShowHideColumnsMenu = function handleOpenShowHideColumnsMenu(event) {
|
|
832
|
-
event.stopPropagation();
|
|
833
|
-
setShowHideColumnsMenuAnchorEl(event.currentTarget);
|
|
834
|
-
};
|
|
835
708
|
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
onClose: function onClose() {
|
|
840
|
-
return setAnchorEl(null);
|
|
841
|
-
},
|
|
842
|
-
MenuListProps: {
|
|
843
|
-
dense: isDensePadding
|
|
844
|
-
}
|
|
845
|
-
}, enableSorting && column.getCanSort() && [React__default.createElement(material.MenuItem, {
|
|
846
|
-
disabled: !column.getIsSorted(),
|
|
847
|
-
key: 0,
|
|
848
|
-
onClick: handleClearSort,
|
|
849
|
-
sx: commonMenuItemStyles$1
|
|
850
|
-
}, React__default.createElement(material.Box, {
|
|
851
|
-
sx: commonListItemStyles
|
|
852
|
-
}, React__default.createElement(material.ListItemIcon, null, React__default.createElement(ClearAllIcon, null)), localization.clearSort)), React__default.createElement(material.MenuItem, {
|
|
853
|
-
disabled: column.getIsSorted() === 'asc',
|
|
854
|
-
key: 1,
|
|
855
|
-
onClick: handleSortAsc,
|
|
856
|
-
sx: commonMenuItemStyles$1
|
|
857
|
-
}, React__default.createElement(material.Box, {
|
|
858
|
-
sx: commonListItemStyles
|
|
859
|
-
}, 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, {
|
|
860
|
-
divider: enableColumnFilters || enableGrouping || enableHiding,
|
|
861
|
-
key: 2,
|
|
862
|
-
disabled: column.getIsSorted() === 'desc',
|
|
863
|
-
onClick: handleSortDesc,
|
|
864
|
-
sx: commonMenuItemStyles$1
|
|
865
|
-
}, React__default.createElement(material.Box, {
|
|
866
|
-
sx: commonListItemStyles
|
|
867
|
-
}, React__default.createElement(material.ListItemIcon, null, React__default.createElement(SortIcon, {
|
|
868
|
-
style: {
|
|
869
|
-
transform: 'rotate(180deg) scaleX(-1)'
|
|
709
|
+
function subscribe(listener) {
|
|
710
|
+
if (typeof listener !== 'function') {
|
|
711
|
+
throw new Error( "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
|
|
870
712
|
}
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
onClick: handleClearFilter,
|
|
875
|
-
sx: commonMenuItemStyles$1
|
|
876
|
-
}, React__default.createElement(material.Box, {
|
|
877
|
-
sx: commonListItemStyles
|
|
878
|
-
}, React__default.createElement(material.ListItemIcon, null, React__default.createElement(FilterListOffIcon, null)), localization.clearFilter)), React__default.createElement(material.MenuItem, {
|
|
879
|
-
divider: enableGrouping || enableHiding,
|
|
880
|
-
key: 1,
|
|
881
|
-
onClick: handleFilterByColumn,
|
|
882
|
-
sx: commonMenuItemStyles$1
|
|
883
|
-
}, React__default.createElement(material.Box, {
|
|
884
|
-
sx: commonListItemStyles
|
|
885
|
-
}, 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, {
|
|
886
|
-
onClick: handleOpenFilterModeMenu,
|
|
887
|
-
onMouseEnter: handleOpenFilterModeMenu,
|
|
888
|
-
size: "small",
|
|
889
|
-
sx: {
|
|
890
|
-
p: 0
|
|
713
|
+
|
|
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.');
|
|
891
716
|
}
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
717
|
+
|
|
718
|
+
var isSubscribed = true;
|
|
719
|
+
ensureCanMutateNextListeners();
|
|
720
|
+
nextListeners.push(listener);
|
|
721
|
+
return function unsubscribe() {
|
|
722
|
+
if (!isSubscribed) {
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
|
|
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
|
+
}
|
|
729
|
+
|
|
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.");
|
|
918
767
|
}
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
onClick: function onClick() {
|
|
923
|
-
return handlePinColumn('right');
|
|
924
|
-
},
|
|
925
|
-
sx: commonMenuItemStyles$1
|
|
926
|
-
}, React__default.createElement(material.Box, {
|
|
927
|
-
sx: commonListItemStyles
|
|
928
|
-
}, React__default.createElement(material.ListItemIcon, null, React__default.createElement(PushPinIcon, {
|
|
929
|
-
style: {
|
|
930
|
-
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.');
|
|
931
771
|
}
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
key: 2,
|
|
936
|
-
onClick: function onClick() {
|
|
937
|
-
return handlePinColumn(false);
|
|
938
|
-
},
|
|
939
|
-
sx: commonMenuItemStyles$1
|
|
940
|
-
}, React__default.createElement(material.Box, {
|
|
941
|
-
sx: commonListItemStyles
|
|
942
|
-
}, React__default.createElement(material.ListItemIcon, null, React__default.createElement(PushPinIcon, null)), localization.unpin))], enableColumnResizing && [React__default.createElement(material.MenuItem, {
|
|
943
|
-
disabled: !column.getCanResize() || !columnSizing[column.id],
|
|
944
|
-
key: 0,
|
|
945
|
-
onClick: handleResetColumnSize,
|
|
946
|
-
sx: commonMenuItemStyles$1
|
|
947
|
-
}, React__default.createElement(material.Box, {
|
|
948
|
-
sx: commonListItemStyles
|
|
949
|
-
}, React__default.createElement(material.ListItemIcon, null, React__default.createElement(RestartAltIcon, null)), localization.resetColumnSize))], enableHiding && [React__default.createElement(material.MenuItem, {
|
|
950
|
-
disabled: columnDef.enableHiding === false,
|
|
951
|
-
key: 0,
|
|
952
|
-
onClick: handleHideColumn,
|
|
953
|
-
sx: commonMenuItemStyles$1
|
|
954
|
-
}, React__default.createElement(material.Box, {
|
|
955
|
-
sx: commonListItemStyles
|
|
956
|
-
}, 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, {
|
|
957
|
-
disabled: !Object.values(columnVisibility).filter(function (visible) {
|
|
958
|
-
return !visible;
|
|
959
|
-
}).length,
|
|
960
|
-
key: 1,
|
|
961
|
-
onClick: handleShowAllColumns,
|
|
962
|
-
sx: commonMenuItemStyles$1
|
|
963
|
-
}, React__default.createElement(material.Box, {
|
|
964
|
-
sx: commonListItemStyles
|
|
965
|
-
}, 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, {
|
|
966
|
-
onClick: handleOpenShowHideColumnsMenu,
|
|
967
|
-
onMouseEnter: handleOpenShowHideColumnsMenu,
|
|
968
|
-
size: "small",
|
|
969
|
-
sx: {
|
|
970
|
-
p: 0
|
|
772
|
+
|
|
773
|
+
if (isDispatching) {
|
|
774
|
+
throw new Error( 'Reducers may not dispatch actions.');
|
|
971
775
|
}
|
|
972
|
-
}, React__default.createElement(ArrowRightIcon, null))), React__default.createElement(MRT_ShowHideColumnsMenu, {
|
|
973
|
-
anchorEl: showHideColumnsMenuAnchorEl,
|
|
974
|
-
isSubMenu: true,
|
|
975
|
-
key: 2,
|
|
976
|
-
setAnchorEl: setShowHideColumnsMenuAnchorEl,
|
|
977
|
-
tableInstance: tableInstance
|
|
978
|
-
})]);
|
|
979
|
-
};
|
|
980
776
|
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
var getState = tableInstance.getState,
|
|
988
|
-
_tableInstance$option = tableInstance.options,
|
|
989
|
-
EditIcon = _tableInstance$option.icons.EditIcon,
|
|
990
|
-
enableEditing = _tableInstance$option.enableEditing,
|
|
991
|
-
localization = _tableInstance$option.localization,
|
|
992
|
-
renderRowActionMenuItems = _tableInstance$option.renderRowActionMenuItems;
|
|
777
|
+
try {
|
|
778
|
+
isDispatching = true;
|
|
779
|
+
currentState = currentReducer(currentState, action);
|
|
780
|
+
} finally {
|
|
781
|
+
isDispatching = false;
|
|
782
|
+
}
|
|
993
783
|
|
|
994
|
-
|
|
995
|
-
isDensePadding = _getState.isDensePadding;
|
|
784
|
+
var listeners = currentListeners = nextListeners;
|
|
996
785
|
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
onClose: function onClose() {
|
|
1001
|
-
return setAnchorEl(null);
|
|
1002
|
-
},
|
|
1003
|
-
MenuListProps: {
|
|
1004
|
-
dense: isDensePadding
|
|
1005
|
-
}
|
|
1006
|
-
}, enableEditing && React__default.createElement(material.MenuItem, {
|
|
1007
|
-
onClick: handleEdit,
|
|
1008
|
-
sx: commonMenuItemStyles$1
|
|
1009
|
-
}, React__default.createElement(material.Box, {
|
|
1010
|
-
sx: commonListItemStyles
|
|
1011
|
-
}, React__default.createElement(material.ListItemIcon, null, React__default.createElement(EditIcon, null)), localization.edit)), renderRowActionMenuItems == null ? void 0 : renderRowActionMenuItems({
|
|
1012
|
-
row: row,
|
|
1013
|
-
tableInstance: tableInstance,
|
|
1014
|
-
closeMenu: function closeMenu() {
|
|
1015
|
-
return setAnchorEl(null);
|
|
786
|
+
for (var i = 0; i < listeners.length; i++) {
|
|
787
|
+
var listener = listeners[i];
|
|
788
|
+
listener();
|
|
1016
789
|
}
|
|
1017
|
-
}));
|
|
1018
|
-
};
|
|
1019
790
|
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
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
|
+
*/
|
|
1031
803
|
|
|
1032
|
-
var _getState = getState(),
|
|
1033
|
-
currentEditingRow = _getState.currentEditingRow;
|
|
1034
804
|
|
|
1035
|
-
|
|
1036
|
-
|
|
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
|
+
}
|
|
1037
809
|
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
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.
|
|
1041
814
|
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
row: currentEditingRow != null ? currentEditingRow : row,
|
|
1045
|
-
tableInstance: tableInstance
|
|
815
|
+
dispatch({
|
|
816
|
+
type: ActionTypes.REPLACE
|
|
1046
817
|
});
|
|
1047
|
-
|
|
1048
|
-
|
|
818
|
+
}
|
|
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
|
+
*/
|
|
1049
825
|
|
|
1050
|
-
return React__default.createElement(material.Box, {
|
|
1051
|
-
sx: {
|
|
1052
|
-
display: 'flex',
|
|
1053
|
-
gap: '0.75rem'
|
|
1054
|
-
}
|
|
1055
|
-
}, React__default.createElement(material.Tooltip, {
|
|
1056
|
-
arrow: true,
|
|
1057
|
-
title: localization.cancel
|
|
1058
|
-
}, React__default.createElement(material.IconButton, {
|
|
1059
|
-
"aria-label": localization.cancel,
|
|
1060
|
-
onClick: handleCancel
|
|
1061
|
-
}, React__default.createElement(CancelIcon, null))), React__default.createElement(material.Tooltip, {
|
|
1062
|
-
arrow: true,
|
|
1063
|
-
title: localization.save
|
|
1064
|
-
}, React__default.createElement(material.IconButton, {
|
|
1065
|
-
"aria-label": localization.save,
|
|
1066
|
-
color: "info",
|
|
1067
|
-
onClick: handleSave
|
|
1068
|
-
}, React__default.createElement(SaveIcon, null))));
|
|
1069
|
-
};
|
|
1070
|
-
|
|
1071
|
-
var commonIconButtonStyles = {
|
|
1072
|
-
height: '2rem',
|
|
1073
|
-
ml: '10px',
|
|
1074
|
-
opacity: 0.5,
|
|
1075
|
-
transition: 'opacity 0.2s',
|
|
1076
|
-
width: '2rem',
|
|
1077
|
-
'&:hover': {
|
|
1078
|
-
opacity: 1
|
|
1079
|
-
}
|
|
1080
|
-
};
|
|
1081
|
-
var MRT_ToggleRowActionMenuButton = function MRT_ToggleRowActionMenuButton(_ref) {
|
|
1082
|
-
var row = _ref.row,
|
|
1083
|
-
tableInstance = _ref.tableInstance;
|
|
1084
|
-
var getState = tableInstance.getState,
|
|
1085
|
-
_tableInstance$option = tableInstance.options,
|
|
1086
|
-
enableEditing = _tableInstance$option.enableEditing,
|
|
1087
|
-
_tableInstance$option2 = _tableInstance$option.icons,
|
|
1088
|
-
EditIcon = _tableInstance$option2.EditIcon,
|
|
1089
|
-
MoreHorizIcon = _tableInstance$option2.MoreHorizIcon,
|
|
1090
|
-
localization = _tableInstance$option.localization,
|
|
1091
|
-
renderRowActionMenuItems = _tableInstance$option.renderRowActionMenuItems,
|
|
1092
|
-
renderRowActions = _tableInstance$option.renderRowActions,
|
|
1093
|
-
setCurrentEditingRow = tableInstance.setCurrentEditingRow;
|
|
1094
|
-
|
|
1095
|
-
var _getState = getState(),
|
|
1096
|
-
currentEditingRow = _getState.currentEditingRow;
|
|
1097
|
-
|
|
1098
|
-
var _useState = React.useState(null),
|
|
1099
|
-
anchorEl = _useState[0],
|
|
1100
|
-
setAnchorEl = _useState[1];
|
|
1101
|
-
|
|
1102
|
-
var handleOpenRowActionMenu = function handleOpenRowActionMenu(event) {
|
|
1103
|
-
event.stopPropagation();
|
|
1104
|
-
event.preventDefault();
|
|
1105
|
-
setAnchorEl(event.currentTarget);
|
|
1106
|
-
};
|
|
1107
|
-
|
|
1108
|
-
var handleStartEditMode = function handleStartEditMode() {
|
|
1109
|
-
setCurrentEditingRow(_extends({}, row));
|
|
1110
|
-
setAnchorEl(null);
|
|
1111
|
-
};
|
|
1112
|
-
|
|
1113
|
-
return React__default.createElement(React__default.Fragment, null, renderRowActions ? React__default.createElement(React__default.Fragment, null, renderRowActions({
|
|
1114
|
-
row: row,
|
|
1115
|
-
tableInstance: tableInstance
|
|
1116
|
-
})) : row.id === (currentEditingRow == null ? void 0 : currentEditingRow.id) ? React__default.createElement(MRT_EditActionButtons, {
|
|
1117
|
-
row: row,
|
|
1118
|
-
tableInstance: tableInstance
|
|
1119
|
-
}) : !renderRowActionMenuItems && enableEditing ? React__default.createElement(material.Tooltip, {
|
|
1120
|
-
placement: "right",
|
|
1121
|
-
arrow: true,
|
|
1122
|
-
title: localization.edit
|
|
1123
|
-
}, React__default.createElement(material.IconButton, {
|
|
1124
|
-
sx: commonIconButtonStyles,
|
|
1125
|
-
onClick: handleStartEditMode
|
|
1126
|
-
}, React__default.createElement(EditIcon, null))) : renderRowActionMenuItems ? React__default.createElement(React__default.Fragment, null, React__default.createElement(material.Tooltip, {
|
|
1127
|
-
arrow: true,
|
|
1128
|
-
enterDelay: 1000,
|
|
1129
|
-
enterNextDelay: 1000,
|
|
1130
|
-
title: localization.rowActions
|
|
1131
|
-
}, React__default.createElement(material.IconButton, {
|
|
1132
|
-
"aria-label": localization.rowActions,
|
|
1133
|
-
onClick: handleOpenRowActionMenu,
|
|
1134
|
-
size: "small",
|
|
1135
|
-
sx: commonIconButtonStyles
|
|
1136
|
-
}, React__default.createElement(MoreHorizIcon, null))), React__default.createElement(MRT_RowActionMenu, {
|
|
1137
|
-
anchorEl: anchorEl,
|
|
1138
|
-
handleEdit: handleStartEditMode,
|
|
1139
|
-
row: row,
|
|
1140
|
-
setAnchorEl: setAnchorEl,
|
|
1141
|
-
tableInstance: tableInstance
|
|
1142
|
-
})) : null);
|
|
1143
|
-
};
|
|
1144
826
|
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
selectAll = _ref.selectAll,
|
|
1148
|
-
tableInstance = _ref.tableInstance;
|
|
1149
|
-
var getRowModel = tableInstance.getRowModel,
|
|
1150
|
-
getSelectedRowModel = tableInstance.getSelectedRowModel,
|
|
1151
|
-
getState = tableInstance.getState,
|
|
1152
|
-
_tableInstance$option = tableInstance.options,
|
|
1153
|
-
localization = _tableInstance$option.localization,
|
|
1154
|
-
muiSelectCheckboxProps = _tableInstance$option.muiSelectCheckboxProps,
|
|
1155
|
-
onSelectChange = _tableInstance$option.onSelectChange,
|
|
1156
|
-
onSelectAllChange = _tableInstance$option.onSelectAllChange;
|
|
827
|
+
function observable() {
|
|
828
|
+
var _ref;
|
|
1157
829
|
|
|
1158
|
-
|
|
1159
|
-
|
|
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
|
+
}
|
|
1160
844
|
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
selectedRows: event.target.checked ? getRowModel().flatRows : [],
|
|
1167
|
-
tableInstance: tableInstance
|
|
1168
|
-
});
|
|
1169
|
-
} else if (row) {
|
|
1170
|
-
row == null ? void 0 : row.getToggleSelectedHandler()(event);
|
|
1171
|
-
onSelectChange == null ? void 0 : onSelectChange({
|
|
1172
|
-
event: event,
|
|
1173
|
-
row: row,
|
|
1174
|
-
selectedRows: event.target.checked ? [].concat(getSelectedRowModel().flatRows, [row]) : getSelectedRowModel().flatRows.filter(function (selectedRow) {
|
|
1175
|
-
return selectedRow.id !== row.id;
|
|
1176
|
-
}),
|
|
1177
|
-
tableInstance: tableInstance
|
|
1178
|
-
});
|
|
1179
|
-
}
|
|
1180
|
-
};
|
|
845
|
+
function observeState() {
|
|
846
|
+
if (observer.next) {
|
|
847
|
+
observer.next(getState());
|
|
848
|
+
}
|
|
849
|
+
}
|
|
1181
850
|
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
indeterminate: selectAll ? tableInstance.getIsSomeRowsSelected() : row == null ? void 0 : row.getIsSomeSelected(),
|
|
1195
|
-
inputProps: {
|
|
1196
|
-
'aria-label': selectAll ? localization.toggleSelectAll : localization.toggleSelectRow
|
|
1197
|
-
},
|
|
1198
|
-
onChange: handleSelectChange,
|
|
1199
|
-
size: isDensePadding ? 'small' : 'medium'
|
|
1200
|
-
}, checkboxProps, {
|
|
1201
|
-
sx: _extends({
|
|
1202
|
-
height: isDensePadding ? '1.75rem' : '2.25rem',
|
|
1203
|
-
width: isDensePadding ? '1.75rem' : '2.25rem'
|
|
1204
|
-
}, checkboxProps == null ? void 0 : checkboxProps.sx)
|
|
1205
|
-
})));
|
|
1206
|
-
};
|
|
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.
|
|
1207
863
|
|
|
1208
|
-
/**
|
|
1209
|
-
* Create the React Context
|
|
1210
|
-
*/ const DndContext = React.createContext({
|
|
1211
|
-
dragDropManager: undefined
|
|
1212
|
-
});
|
|
1213
864
|
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
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
|
+
}
|
|
1218
875
|
|
|
1219
876
|
/**
|
|
1220
|
-
*
|
|
1221
|
-
*
|
|
1222
|
-
*
|
|
1223
|
-
*
|
|
877
|
+
* Prints a warning in the console if it exists.
|
|
878
|
+
*
|
|
879
|
+
* @param {String} message The warning message.
|
|
880
|
+
* @returns {void}
|
|
1224
881
|
*/
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
var ActionTypes = {
|
|
1230
|
-
INIT: "@@redux/INIT" + randomString(),
|
|
1231
|
-
REPLACE: "@@redux/REPLACE" + randomString(),
|
|
1232
|
-
PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
|
|
1233
|
-
return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
|
|
882
|
+
function warning(message) {
|
|
883
|
+
/* eslint-disable no-console */
|
|
884
|
+
if (typeof console !== 'undefined' && typeof console.error === 'function') {
|
|
885
|
+
console.error(message);
|
|
1234
886
|
}
|
|
1235
|
-
|
|
887
|
+
/* eslint-enable no-console */
|
|
1236
888
|
|
|
1237
|
-
/**
|
|
1238
|
-
* @param {any} obj The object to inspect.
|
|
1239
|
-
* @returns {boolean} True if the argument appears to be a plain object.
|
|
1240
|
-
*/
|
|
1241
|
-
function isPlainObject(obj) {
|
|
1242
|
-
if (typeof obj !== 'object' || obj === null) return false;
|
|
1243
|
-
var proto = obj;
|
|
1244
889
|
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
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
|
|
1248
896
|
|
|
1249
|
-
return Object.getPrototypeOf(obj) === proto;
|
|
1250
897
|
}
|
|
1251
898
|
|
|
1252
|
-
|
|
1253
|
-
function
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
var type = typeof val;
|
|
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.
|
|
902
|
+
*/
|
|
1257
903
|
|
|
1258
|
-
|
|
1259
|
-
case 'boolean':
|
|
1260
|
-
case 'string':
|
|
1261
|
-
case 'number':
|
|
1262
|
-
case 'symbol':
|
|
1263
|
-
case 'function':
|
|
1264
|
-
{
|
|
1265
|
-
return type;
|
|
1266
|
-
}
|
|
1267
|
-
}
|
|
904
|
+
function isCrushed() {}
|
|
1268
905
|
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
var constructorName = ctorName(val);
|
|
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.');
|
|
908
|
+
}
|
|
1273
909
|
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
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
|
+
}
|
|
1286
940
|
}
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
return typeof val.constructor === 'function' ? val.constructor.name : null;
|
|
941
|
+
function isProduction() {
|
|
942
|
+
return typeof process !== 'undefined' && process.env['NODE_ENV'] === 'production';
|
|
1290
943
|
}
|
|
1291
944
|
|
|
1292
|
-
|
|
1293
|
-
|
|
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);
|
|
1294
954
|
}
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
955
|
+
/**
|
|
956
|
+
* drop-in replacement for _.without
|
|
957
|
+
*/ function without(items, item) {
|
|
958
|
+
return items.filter((i)=>i !== item
|
|
959
|
+
);
|
|
1299
960
|
}
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
typeOfVal = miniKindOf(val);
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
return typeOfVal;
|
|
961
|
+
/**
|
|
962
|
+
* drop-in replacement for _.isString
|
|
963
|
+
* @param input
|
|
964
|
+
*/ function isObject(input) {
|
|
965
|
+
return typeof input === 'object';
|
|
1309
966
|
}
|
|
1310
|
-
|
|
1311
967
|
/**
|
|
1312
|
-
*
|
|
1313
|
-
*
|
|
1314
|
-
*
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
*
|
|
1332
|
-
*
|
|
1333
|
-
*
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
var _ref2;
|
|
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
|
+
}
|
|
1339
994
|
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
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';
|
|
1343
1001
|
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1002
|
+
function setClientOffset(clientOffset, sourceClientOffset) {
|
|
1003
|
+
return {
|
|
1004
|
+
type: INIT_COORDS,
|
|
1005
|
+
payload: {
|
|
1006
|
+
sourceClientOffset: sourceClientOffset || null,
|
|
1007
|
+
clientOffset: clientOffset || null
|
|
1008
|
+
}
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1348
1011
|
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1012
|
+
const ResetCoordinatesAction = {
|
|
1013
|
+
type: INIT_COORDS,
|
|
1014
|
+
payload: {
|
|
1015
|
+
clientOffset: null,
|
|
1016
|
+
sourceClientOffset: null
|
|
1352
1017
|
}
|
|
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
|
+
};
|
|
1066
|
+
};
|
|
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
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
return sourceId;
|
|
1089
|
+
}
|
|
1353
1090
|
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
var nextListeners = currentListeners;
|
|
1365
|
-
var isDispatching = false;
|
|
1366
|
-
/**
|
|
1367
|
-
* This makes a shallow copy of currentListeners so we can use
|
|
1368
|
-
* nextListeners as a temporary list while dispatching.
|
|
1369
|
-
*
|
|
1370
|
-
* This prevents any bugs around consumers calling
|
|
1371
|
-
* subscribe/unsubscribe in the middle of a dispatch.
|
|
1372
|
-
*/
|
|
1373
|
-
|
|
1374
|
-
function ensureCanMutateNextListeners() {
|
|
1375
|
-
if (nextListeners === currentListeners) {
|
|
1376
|
-
nextListeners = currentListeners.slice();
|
|
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;
|
|
1377
1101
|
}
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
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
|
+
});
|
|
1389
1116
|
}
|
|
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();
|
|
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
|
+
}
|
|
1390
1159
|
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
* registered before the `dispatch()` started will be called with the latest
|
|
1411
|
-
* state by the time it exits.
|
|
1412
|
-
*
|
|
1413
|
-
* @param {Function} listener A callback to be invoked on every dispatch.
|
|
1414
|
-
* @returns {Function} A function to remove this change listener.
|
|
1415
|
-
*/
|
|
1416
|
-
|
|
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
|
+
}
|
|
1417
1179
|
|
|
1418
|
-
|
|
1419
|
-
if (
|
|
1420
|
-
|
|
1180
|
+
function matchesType(targetType, draggedItemType) {
|
|
1181
|
+
if (draggedItemType === null) {
|
|
1182
|
+
return targetType === null;
|
|
1421
1183
|
}
|
|
1184
|
+
return Array.isArray(targetType) ? targetType.some((t)=>t === draggedItemType
|
|
1185
|
+
) : targetType === draggedItemType;
|
|
1186
|
+
}
|
|
1422
1187
|
|
|
1423
|
-
|
|
1424
|
-
|
|
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);
|
|
1198
|
+
return {
|
|
1199
|
+
type: HOVER,
|
|
1200
|
+
payload: {
|
|
1201
|
+
targetIds,
|
|
1202
|
+
clientOffset: clientOffset || null
|
|
1203
|
+
}
|
|
1204
|
+
};
|
|
1205
|
+
};
|
|
1206
|
+
}
|
|
1207
|
+
function verifyTargetIdsIsArray(targetIdsArg) {
|
|
1208
|
+
invariant(Array.isArray(targetIdsArg), 'Expected targetIds to be an array.');
|
|
1209
|
+
}
|
|
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.');
|
|
1218
|
+
}
|
|
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);
|
|
1229
|
+
}
|
|
1425
1230
|
}
|
|
1231
|
+
}
|
|
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
|
+
});
|
|
1238
|
+
}
|
|
1426
1239
|
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
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
|
+
};
|
|
1247
|
+
}
|
|
1432
1248
|
return;
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
if (isDispatching) {
|
|
1436
|
-
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.');
|
|
1437
|
-
}
|
|
1438
|
-
|
|
1439
|
-
isSubscribed = false;
|
|
1440
|
-
ensureCanMutateNextListeners();
|
|
1441
|
-
var index = nextListeners.indexOf(listener);
|
|
1442
|
-
nextListeners.splice(index, 1);
|
|
1443
|
-
currentListeners = null;
|
|
1444
1249
|
};
|
|
1445
|
-
|
|
1446
|
-
/**
|
|
1447
|
-
* Dispatches an action. It is the only way to trigger a state change.
|
|
1448
|
-
*
|
|
1449
|
-
* The `reducer` function, used to create the store, will be called with the
|
|
1450
|
-
* current state tree and the given `action`. Its return value will
|
|
1451
|
-
* be considered the **next** state of the tree, and the change listeners
|
|
1452
|
-
* will be notified.
|
|
1453
|
-
*
|
|
1454
|
-
* The base implementation only supports plain object actions. If you want to
|
|
1455
|
-
* dispatch a Promise, an Observable, a thunk, or something else, you need to
|
|
1456
|
-
* wrap your store creating function into the corresponding middleware. For
|
|
1457
|
-
* example, see the documentation for the `redux-thunk` package. Even the
|
|
1458
|
-
* middleware will eventually dispatch plain object actions using this method.
|
|
1459
|
-
*
|
|
1460
|
-
* @param {Object} action A plain object representing “what changed”. It is
|
|
1461
|
-
* a good idea to keep actions serializable so you can record and replay user
|
|
1462
|
-
* sessions, or use the time travelling `redux-devtools`. An action must have
|
|
1463
|
-
* a `type` property which may not be `undefined`. It is a good idea to use
|
|
1464
|
-
* string constants for action types.
|
|
1465
|
-
*
|
|
1466
|
-
* @returns {Object} For convenience, the same action object you dispatched.
|
|
1467
|
-
*
|
|
1468
|
-
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
|
|
1469
|
-
* return something else (for example, a Promise you can await).
|
|
1470
|
-
*/
|
|
1471
|
-
|
|
1250
|
+
}
|
|
1472
1251
|
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1252
|
+
function createDragDropActions(manager) {
|
|
1253
|
+
return {
|
|
1254
|
+
beginDrag: createBeginDrag(manager),
|
|
1255
|
+
publishDragSource: createPublishDragSource(manager),
|
|
1256
|
+
hover: createHover(manager),
|
|
1257
|
+
drop: createDrop(manager),
|
|
1258
|
+
endDrag: createEndDrag(manager)
|
|
1259
|
+
};
|
|
1260
|
+
}
|
|
1477
1261
|
|
|
1478
|
-
|
|
1479
|
-
|
|
1262
|
+
class DragDropManagerImpl {
|
|
1263
|
+
receiveBackend(backend) {
|
|
1264
|
+
this.backend = backend;
|
|
1480
1265
|
}
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
throw new Error( 'Reducers may not dispatch actions.');
|
|
1484
|
-
}
|
|
1485
|
-
|
|
1486
|
-
try {
|
|
1487
|
-
isDispatching = true;
|
|
1488
|
-
currentState = currentReducer(currentState, action);
|
|
1489
|
-
} finally {
|
|
1490
|
-
isDispatching = false;
|
|
1266
|
+
getMonitor() {
|
|
1267
|
+
return this.monitor;
|
|
1491
1268
|
}
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
for (var i = 0; i < listeners.length; i++) {
|
|
1496
|
-
var listener = listeners[i];
|
|
1497
|
-
listener();
|
|
1269
|
+
getBackend() {
|
|
1270
|
+
return this.backend;
|
|
1498
1271
|
}
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
}
|
|
1502
|
-
/**
|
|
1503
|
-
* Replaces the reducer currently used by the store to calculate the state.
|
|
1504
|
-
*
|
|
1505
|
-
* You might need this if your app implements code splitting and you want to
|
|
1506
|
-
* load some of the reducers dynamically. You might also need this if you
|
|
1507
|
-
* implement a hot reloading mechanism for Redux.
|
|
1508
|
-
*
|
|
1509
|
-
* @param {Function} nextReducer The reducer for the store to use instead.
|
|
1510
|
-
* @returns {void}
|
|
1511
|
-
*/
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
function replaceReducer(nextReducer) {
|
|
1515
|
-
if (typeof nextReducer !== 'function') {
|
|
1516
|
-
throw new Error( "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
|
|
1272
|
+
getRegistry() {
|
|
1273
|
+
return this.monitor.registry;
|
|
1517
1274
|
}
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
/**
|
|
1529
|
-
* Interoperability point for observable/reactive libraries.
|
|
1530
|
-
* @returns {observable} A minimal observable of state changes.
|
|
1531
|
-
* For more information, see the observable proposal:
|
|
1532
|
-
* https://github.com/tc39/proposal-observable
|
|
1533
|
-
*/
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
function observable() {
|
|
1537
|
-
var _ref;
|
|
1538
|
-
|
|
1539
|
-
var outerSubscribe = subscribe;
|
|
1540
|
-
return _ref = {
|
|
1541
|
-
/**
|
|
1542
|
-
* The minimal observable subscription method.
|
|
1543
|
-
* @param {Object} observer Any object that can be used as an observer.
|
|
1544
|
-
* The observer object should have a `next` method.
|
|
1545
|
-
* @returns {subscription} An object with an `unsubscribe` method that can
|
|
1546
|
-
* be used to unsubscribe the observable from the store, and prevent further
|
|
1547
|
-
* emission of values from the observable.
|
|
1548
|
-
*/
|
|
1549
|
-
subscribe: function subscribe(observer) {
|
|
1550
|
-
if (typeof observer !== 'object' || observer === null) {
|
|
1551
|
-
throw new Error( "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
|
|
1552
|
-
}
|
|
1553
|
-
|
|
1554
|
-
function observeState() {
|
|
1555
|
-
if (observer.next) {
|
|
1556
|
-
observer.next(getState());
|
|
1557
|
-
}
|
|
1275
|
+
getActions() {
|
|
1276
|
+
/* eslint-disable-next-line @typescript-eslint/no-this-alias */ const manager = this;
|
|
1277
|
+
const { dispatch } = this.store;
|
|
1278
|
+
function bindActionCreator(actionCreator) {
|
|
1279
|
+
return (...args)=>{
|
|
1280
|
+
const action = actionCreator.apply(manager, args);
|
|
1281
|
+
if (typeof action !== 'undefined') {
|
|
1282
|
+
dispatch(action);
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1558
1285
|
}
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1286
|
+
const actions = createDragDropActions(this);
|
|
1287
|
+
return Object.keys(actions).reduce((boundActions, key)=>{
|
|
1288
|
+
const action = actions[key];
|
|
1289
|
+
boundActions[key] = bindActionCreator(action);
|
|
1290
|
+
return boundActions;
|
|
1291
|
+
}, {});
|
|
1292
|
+
}
|
|
1293
|
+
dispatch(action) {
|
|
1294
|
+
this.store.dispatch(action);
|
|
1295
|
+
}
|
|
1296
|
+
constructor(store, monitor){
|
|
1297
|
+
this.isSetUp = false;
|
|
1298
|
+
this.handleRefCountChange = ()=>{
|
|
1299
|
+
const shouldSetUp = this.store.getState().refCount > 0;
|
|
1300
|
+
if (this.backend) {
|
|
1301
|
+
if (shouldSetUp && !this.isSetUp) {
|
|
1302
|
+
this.backend.setup();
|
|
1303
|
+
this.isSetUp = true;
|
|
1304
|
+
} else if (!shouldSetUp && this.isSetUp) {
|
|
1305
|
+
this.backend.teardown();
|
|
1306
|
+
this.isSetUp = false;
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1564
1309
|
};
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
}
|
|
1569
|
-
} // When a store is created, an "INIT" action is dispatched so that every
|
|
1570
|
-
// reducer returns their initial state. This effectively populates
|
|
1571
|
-
// the initial state tree.
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
dispatch({
|
|
1575
|
-
type: ActionTypes.INIT
|
|
1576
|
-
});
|
|
1577
|
-
return _ref2 = {
|
|
1578
|
-
dispatch: dispatch,
|
|
1579
|
-
subscribe: subscribe,
|
|
1580
|
-
getState: getState,
|
|
1581
|
-
replaceReducer: replaceReducer
|
|
1582
|
-
}, _ref2[$$observable] = observable, _ref2;
|
|
1310
|
+
this.store = store;
|
|
1311
|
+
this.monitor = monitor;
|
|
1312
|
+
store.subscribe(this.handleRefCountChange);
|
|
1313
|
+
}
|
|
1583
1314
|
}
|
|
1584
1315
|
|
|
1585
1316
|
/**
|
|
1586
|
-
*
|
|
1587
|
-
*
|
|
1588
|
-
* @param
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
console.error(message);
|
|
1595
|
-
}
|
|
1596
|
-
/* eslint-enable no-console */
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
try {
|
|
1600
|
-
// This error was thrown as a convenience so that if you enable
|
|
1601
|
-
// "break on all exceptions" in your console,
|
|
1602
|
-
// it would pause the execution at this line.
|
|
1603
|
-
throw new Error(message);
|
|
1604
|
-
} catch (e) {} // eslint-disable-line no-empty
|
|
1605
|
-
|
|
1317
|
+
* Coordinate addition
|
|
1318
|
+
* @param a The first coordinate
|
|
1319
|
+
* @param b The second coordinate
|
|
1320
|
+
*/ function add(a, b) {
|
|
1321
|
+
return {
|
|
1322
|
+
x: a.x + b.x,
|
|
1323
|
+
y: a.y + b.y
|
|
1324
|
+
};
|
|
1606
1325
|
}
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
*
|
|
1610
|
-
*
|
|
1611
|
-
*/
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
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.');
|
|
1326
|
+
/**
|
|
1327
|
+
* Coordinate subtraction
|
|
1328
|
+
* @param a The first coordinate
|
|
1329
|
+
* @param b The second coordinate
|
|
1330
|
+
*/ function subtract(a, b) {
|
|
1331
|
+
return {
|
|
1332
|
+
x: a.x - b.x,
|
|
1333
|
+
y: a.y - b.y
|
|
1334
|
+
};
|
|
1617
1335
|
}
|
|
1618
|
-
|
|
1619
1336
|
/**
|
|
1620
|
-
*
|
|
1337
|
+
* Returns the cartesian distance of the drag source component's position, based on its position
|
|
1338
|
+
* at the time when the current drag operation has started, and the movement difference.
|
|
1621
1339
|
*
|
|
1622
|
-
*
|
|
1623
|
-
* to provide information about what broke and what you were
|
|
1624
|
-
* expecting.
|
|
1340
|
+
* Returns null if no item is being dragged.
|
|
1625
1341
|
*
|
|
1626
|
-
*
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
if (
|
|
1630
|
-
|
|
1631
|
-
throw new Error('invariant requires an error message argument');
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
if (!condition) {
|
|
1635
|
-
let error;
|
|
1636
|
-
if (format === undefined) {
|
|
1637
|
-
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
|
1638
|
-
} else {
|
|
1639
|
-
let argIndex = 0;
|
|
1640
|
-
error = new Error(format.replace(/%s/g, function() {
|
|
1641
|
-
return args[argIndex++];
|
|
1642
|
-
}));
|
|
1643
|
-
error.name = 'Invariant Violation';
|
|
1644
|
-
}
|
|
1645
|
-
error.framesToPop = 1 // we don't care about invariant's own frame
|
|
1646
|
-
;
|
|
1647
|
-
throw error;
|
|
1342
|
+
* @param state The offset state to compute from
|
|
1343
|
+
*/ function getSourceClientOffset(state) {
|
|
1344
|
+
const { clientOffset , initialClientOffset , initialSourceClientOffset } = state;
|
|
1345
|
+
if (!clientOffset || !initialClientOffset || !initialSourceClientOffset) {
|
|
1346
|
+
return null;
|
|
1648
1347
|
}
|
|
1649
|
-
|
|
1650
|
-
function isProduction() {
|
|
1651
|
-
return typeof process !== 'undefined' && process.env['NODE_ENV'] === 'production';
|
|
1652
|
-
}
|
|
1653
|
-
|
|
1654
|
-
// cheap lodash replacements
|
|
1655
|
-
/**
|
|
1656
|
-
* drop-in replacement for _.get
|
|
1657
|
-
* @param obj
|
|
1658
|
-
* @param path
|
|
1659
|
-
* @param defaultValue
|
|
1660
|
-
*/ function get(obj, path, defaultValue) {
|
|
1661
|
-
return path.split('.').reduce((a, c)=>a && a[c] ? a[c] : defaultValue || null
|
|
1662
|
-
, obj);
|
|
1348
|
+
return subtract(add(clientOffset, initialSourceClientOffset), initialClientOffset);
|
|
1663
1349
|
}
|
|
1664
1350
|
/**
|
|
1665
|
-
*
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1351
|
+
* Determines the x,y offset between the client offset and the initial client offset
|
|
1352
|
+
*
|
|
1353
|
+
* @param state The offset state to compute from
|
|
1354
|
+
*/ function getDifferenceFromInitialOffset(state) {
|
|
1355
|
+
const { clientOffset , initialClientOffset } = state;
|
|
1356
|
+
if (!clientOffset || !initialClientOffset) {
|
|
1357
|
+
return null;
|
|
1358
|
+
}
|
|
1359
|
+
return subtract(clientOffset, initialClientOffset);
|
|
1669
1360
|
}
|
|
1361
|
+
|
|
1362
|
+
const NONE = [];
|
|
1363
|
+
const ALL = [];
|
|
1364
|
+
NONE.__IS_NONE__ = true;
|
|
1365
|
+
ALL.__IS_ALL__ = true;
|
|
1670
1366
|
/**
|
|
1671
|
-
*
|
|
1672
|
-
*
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
const
|
|
1683
|
-
|
|
1684
|
-
};
|
|
1685
|
-
itemsA.forEach(insertItem);
|
|
1686
|
-
itemsB.forEach(insertItem);
|
|
1687
|
-
const result = [];
|
|
1688
|
-
map.forEach((count, key)=>{
|
|
1689
|
-
if (count === 1) {
|
|
1690
|
-
result.push(key);
|
|
1691
|
-
}
|
|
1692
|
-
});
|
|
1693
|
-
return result;
|
|
1694
|
-
}
|
|
1695
|
-
/**
|
|
1696
|
-
* replacement for _.intersection
|
|
1697
|
-
* @param itemsA
|
|
1698
|
-
* @param itemsB
|
|
1699
|
-
*/ function intersection(itemsA, itemsB) {
|
|
1700
|
-
return itemsA.filter((t)=>itemsB.indexOf(t) > -1
|
|
1701
|
-
);
|
|
1367
|
+
* Determines if the given handler IDs are dirty or not.
|
|
1368
|
+
*
|
|
1369
|
+
* @param dirtyIds The set of dirty handler ids
|
|
1370
|
+
* @param handlerIds The set of handler ids to check
|
|
1371
|
+
*/ function areDirty(dirtyIds, handlerIds) {
|
|
1372
|
+
if (dirtyIds === NONE) {
|
|
1373
|
+
return false;
|
|
1374
|
+
}
|
|
1375
|
+
if (dirtyIds === ALL || typeof handlerIds === 'undefined') {
|
|
1376
|
+
return true;
|
|
1377
|
+
}
|
|
1378
|
+
const commonIds = intersection(handlerIds, dirtyIds);
|
|
1379
|
+
return commonIds.length > 0;
|
|
1702
1380
|
}
|
|
1703
1381
|
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
const
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1382
|
+
class DragDropMonitorImpl {
|
|
1383
|
+
subscribeToStateChange(listener, options = {}) {
|
|
1384
|
+
const { handlerIds } = options;
|
|
1385
|
+
invariant(typeof listener === 'function', 'listener must be a function.');
|
|
1386
|
+
invariant(typeof handlerIds === 'undefined' || Array.isArray(handlerIds), 'handlerIds, when specified, must be an array of strings.');
|
|
1387
|
+
let prevStateId = this.store.getState().stateId;
|
|
1388
|
+
const handleChange = ()=>{
|
|
1389
|
+
const state = this.store.getState();
|
|
1390
|
+
const currentStateId = state.stateId;
|
|
1391
|
+
try {
|
|
1392
|
+
const canSkipListener = currentStateId === prevStateId || currentStateId === prevStateId + 1 && !areDirty(state.dirtyHandlerIds, handlerIds);
|
|
1393
|
+
if (!canSkipListener) {
|
|
1394
|
+
listener();
|
|
1395
|
+
}
|
|
1396
|
+
} finally{
|
|
1397
|
+
prevStateId = currentStateId;
|
|
1398
|
+
}
|
|
1399
|
+
};
|
|
1400
|
+
return this.store.subscribe(handleChange);
|
|
1401
|
+
}
|
|
1402
|
+
subscribeToOffsetChange(listener) {
|
|
1403
|
+
invariant(typeof listener === 'function', 'listener must be a function.');
|
|
1404
|
+
let previousState = this.store.getState().dragOffset;
|
|
1405
|
+
const handleChange = ()=>{
|
|
1406
|
+
const nextState = this.store.getState().dragOffset;
|
|
1407
|
+
if (nextState === previousState) {
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
previousState = nextState;
|
|
1411
|
+
listener();
|
|
1412
|
+
};
|
|
1413
|
+
return this.store.subscribe(handleChange);
|
|
1414
|
+
}
|
|
1415
|
+
canDragSource(sourceId) {
|
|
1416
|
+
if (!sourceId) {
|
|
1417
|
+
return false;
|
|
1717
1418
|
}
|
|
1718
|
-
|
|
1719
|
-
}
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
clientOffset: null,
|
|
1725
|
-
sourceClientOffset: null
|
|
1419
|
+
const source = this.registry.getSource(sourceId);
|
|
1420
|
+
invariant(source, `Expected to find a valid source. sourceId=${sourceId}`);
|
|
1421
|
+
if (this.isDragging()) {
|
|
1422
|
+
return false;
|
|
1423
|
+
}
|
|
1424
|
+
return source.canDrag(this, sourceId);
|
|
1726
1425
|
}
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1426
|
+
canDropOnTarget(targetId) {
|
|
1427
|
+
// undefined on initial render
|
|
1428
|
+
if (!targetId) {
|
|
1429
|
+
return false;
|
|
1430
|
+
}
|
|
1431
|
+
const target = this.registry.getTarget(targetId);
|
|
1432
|
+
invariant(target, `Expected to find a valid target. targetId=${targetId}`);
|
|
1433
|
+
if (!this.isDragging() || this.didDrop()) {
|
|
1434
|
+
return false;
|
|
1435
|
+
}
|
|
1436
|
+
const targetType = this.registry.getTargetType(targetId);
|
|
1437
|
+
const draggedItemType = this.getItemType();
|
|
1438
|
+
return matchesType(targetType, draggedItemType) && target.canDrop(this, targetId);
|
|
1439
|
+
}
|
|
1440
|
+
isDragging() {
|
|
1441
|
+
return Boolean(this.getItemType());
|
|
1442
|
+
}
|
|
1443
|
+
isDraggingSource(sourceId) {
|
|
1444
|
+
// undefined on initial render
|
|
1445
|
+
if (!sourceId) {
|
|
1446
|
+
return false;
|
|
1447
|
+
}
|
|
1448
|
+
const source = this.registry.getSource(sourceId, true);
|
|
1449
|
+
invariant(source, `Expected to find a valid source. sourceId=${sourceId}`);
|
|
1450
|
+
if (!this.isDragging() || !this.isSourcePublic()) {
|
|
1451
|
+
return false;
|
|
1452
|
+
}
|
|
1453
|
+
const sourceType = this.registry.getSourceType(sourceId);
|
|
1454
|
+
const draggedItemType = this.getItemType();
|
|
1455
|
+
if (sourceType !== draggedItemType) {
|
|
1456
|
+
return false;
|
|
1457
|
+
}
|
|
1458
|
+
return source.isDragging(this, sourceId);
|
|
1459
|
+
}
|
|
1460
|
+
isOverTarget(targetId, options = {
|
|
1461
|
+
shallow: false
|
|
1731
1462
|
}) {
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
// Initialize the coordinates using the client offset
|
|
1736
|
-
manager.dispatch(setClientOffset(clientOffset));
|
|
1737
|
-
verifyInvariants(sourceIds, monitor, registry);
|
|
1738
|
-
// Get the draggable source
|
|
1739
|
-
const sourceId = getDraggableSource(sourceIds, monitor);
|
|
1740
|
-
if (sourceId == null) {
|
|
1741
|
-
manager.dispatch(ResetCoordinatesAction);
|
|
1742
|
-
return;
|
|
1463
|
+
// undefined on initial render
|
|
1464
|
+
if (!targetId) {
|
|
1465
|
+
return false;
|
|
1743
1466
|
}
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
if (!getSourceClientOffset) {
|
|
1748
|
-
throw new Error('getSourceClientOffset must be defined');
|
|
1749
|
-
}
|
|
1750
|
-
verifyGetSourceClientOffsetIsFunction(getSourceClientOffset);
|
|
1751
|
-
sourceClientOffset = getSourceClientOffset(sourceId);
|
|
1467
|
+
const { shallow } = options;
|
|
1468
|
+
if (!this.isDragging()) {
|
|
1469
|
+
return false;
|
|
1752
1470
|
}
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
// If source.beginDrag returns null, this is an indicator to cancel the drag
|
|
1758
|
-
if (item == null) {
|
|
1759
|
-
return undefined;
|
|
1471
|
+
const targetType = this.registry.getTargetType(targetId);
|
|
1472
|
+
const draggedItemType = this.getItemType();
|
|
1473
|
+
if (draggedItemType && !matchesType(targetType, draggedItemType)) {
|
|
1474
|
+
return false;
|
|
1760
1475
|
}
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
clientOffset: clientOffset || null,
|
|
1771
|
-
sourceClientOffset: sourceClientOffset || null,
|
|
1772
|
-
isSourcePublic: !!publishSource
|
|
1773
|
-
}
|
|
1774
|
-
};
|
|
1775
|
-
};
|
|
1776
|
-
}
|
|
1777
|
-
function verifyInvariants(sourceIds, monitor, registry) {
|
|
1778
|
-
invariant(!monitor.isDragging(), 'Cannot call beginDrag while dragging.');
|
|
1779
|
-
sourceIds.forEach(function(sourceId) {
|
|
1780
|
-
invariant(registry.getSource(sourceId), 'Expected sourceIds to be registered.');
|
|
1781
|
-
});
|
|
1782
|
-
}
|
|
1783
|
-
function verifyGetSourceClientOffsetIsFunction(getSourceClientOffset) {
|
|
1784
|
-
invariant(typeof getSourceClientOffset === 'function', 'When clientOffset is provided, getSourceClientOffset must be a function.');
|
|
1785
|
-
}
|
|
1786
|
-
function verifyItemIsObject(item) {
|
|
1787
|
-
invariant(isObject(item), 'Item must be an object.');
|
|
1788
|
-
}
|
|
1789
|
-
function getDraggableSource(sourceIds, monitor) {
|
|
1790
|
-
let sourceId = null;
|
|
1791
|
-
for(let i = sourceIds.length - 1; i >= 0; i--){
|
|
1792
|
-
if (monitor.canDragSource(sourceIds[i])) {
|
|
1793
|
-
sourceId = sourceIds[i];
|
|
1794
|
-
break;
|
|
1476
|
+
const targetIds = this.getTargetIds();
|
|
1477
|
+
if (!targetIds.length) {
|
|
1478
|
+
return false;
|
|
1479
|
+
}
|
|
1480
|
+
const index = targetIds.indexOf(targetId);
|
|
1481
|
+
if (shallow) {
|
|
1482
|
+
return index === targetIds.length - 1;
|
|
1483
|
+
} else {
|
|
1484
|
+
return index > -1;
|
|
1795
1485
|
}
|
|
1796
1486
|
}
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
function _defineProperty(obj, key, value) {
|
|
1801
|
-
if (key in obj) {
|
|
1802
|
-
Object.defineProperty(obj, key, {
|
|
1803
|
-
value: value,
|
|
1804
|
-
enumerable: true,
|
|
1805
|
-
configurable: true,
|
|
1806
|
-
writable: true
|
|
1807
|
-
});
|
|
1808
|
-
} else {
|
|
1809
|
-
obj[key] = value;
|
|
1487
|
+
getItemType() {
|
|
1488
|
+
return this.store.getState().dragOperation.itemType;
|
|
1810
1489
|
}
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
function _objectSpread(target) {
|
|
1814
|
-
for(var i = 1; i < arguments.length; i++){
|
|
1815
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
1816
|
-
var ownKeys = Object.keys(source);
|
|
1817
|
-
if (typeof Object.getOwnPropertySymbols === 'function') {
|
|
1818
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
1819
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
1820
|
-
}));
|
|
1821
|
-
}
|
|
1822
|
-
ownKeys.forEach(function(key) {
|
|
1823
|
-
_defineProperty(target, key, source[key]);
|
|
1824
|
-
});
|
|
1490
|
+
getItem() {
|
|
1491
|
+
return this.store.getState().dragOperation.item;
|
|
1825
1492
|
}
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
function createDrop(manager) {
|
|
1829
|
-
return function drop(options = {}) {
|
|
1830
|
-
const monitor = manager.getMonitor();
|
|
1831
|
-
const registry = manager.getRegistry();
|
|
1832
|
-
verifyInvariants$1(monitor);
|
|
1833
|
-
const targetIds = getDroppableTargets(monitor);
|
|
1834
|
-
// Multiple actions are dispatched here, which is why this doesn't return an action
|
|
1835
|
-
targetIds.forEach((targetId, index)=>{
|
|
1836
|
-
const dropResult = determineDropResult(targetId, index, registry, monitor);
|
|
1837
|
-
const action = {
|
|
1838
|
-
type: DROP,
|
|
1839
|
-
payload: {
|
|
1840
|
-
dropResult: _objectSpread({}, options, dropResult)
|
|
1841
|
-
}
|
|
1842
|
-
};
|
|
1843
|
-
manager.dispatch(action);
|
|
1844
|
-
});
|
|
1845
|
-
};
|
|
1846
|
-
}
|
|
1847
|
-
function verifyInvariants$1(monitor) {
|
|
1848
|
-
invariant(monitor.isDragging(), 'Cannot call drop while not dragging.');
|
|
1849
|
-
invariant(!monitor.didDrop(), 'Cannot call drop twice during one drag operation.');
|
|
1850
|
-
}
|
|
1851
|
-
function determineDropResult(targetId, index, registry, monitor) {
|
|
1852
|
-
const target = registry.getTarget(targetId);
|
|
1853
|
-
let dropResult = target ? target.drop(monitor, targetId) : undefined;
|
|
1854
|
-
verifyDropResultType(dropResult);
|
|
1855
|
-
if (typeof dropResult === 'undefined') {
|
|
1856
|
-
dropResult = index === 0 ? {} : monitor.getDropResult();
|
|
1493
|
+
getSourceId() {
|
|
1494
|
+
return this.store.getState().dragOperation.sourceId;
|
|
1857
1495
|
}
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
function verifyDropResultType(dropResult) {
|
|
1861
|
-
invariant(typeof dropResult === 'undefined' || isObject(dropResult), 'Drop result must either be an object or undefined.');
|
|
1862
|
-
}
|
|
1863
|
-
function getDroppableTargets(monitor) {
|
|
1864
|
-
const targetIds = monitor.getTargetIds().filter(monitor.canDropOnTarget, monitor);
|
|
1865
|
-
targetIds.reverse();
|
|
1866
|
-
return targetIds;
|
|
1867
|
-
}
|
|
1868
|
-
|
|
1869
|
-
function createEndDrag(manager) {
|
|
1870
|
-
return function endDrag() {
|
|
1871
|
-
const monitor = manager.getMonitor();
|
|
1872
|
-
const registry = manager.getRegistry();
|
|
1873
|
-
verifyIsDragging(monitor);
|
|
1874
|
-
const sourceId = monitor.getSourceId();
|
|
1875
|
-
if (sourceId != null) {
|
|
1876
|
-
const source = registry.getSource(sourceId, true);
|
|
1877
|
-
source.endDrag(monitor, sourceId);
|
|
1878
|
-
registry.unpinSource();
|
|
1879
|
-
}
|
|
1880
|
-
return {
|
|
1881
|
-
type: END_DRAG
|
|
1882
|
-
};
|
|
1883
|
-
};
|
|
1884
|
-
}
|
|
1885
|
-
function verifyIsDragging(monitor) {
|
|
1886
|
-
invariant(monitor.isDragging(), 'Cannot call endDrag while not dragging.');
|
|
1887
|
-
}
|
|
1888
|
-
|
|
1889
|
-
function matchesType(targetType, draggedItemType) {
|
|
1890
|
-
if (draggedItemType === null) {
|
|
1891
|
-
return targetType === null;
|
|
1496
|
+
getTargetIds() {
|
|
1497
|
+
return this.store.getState().dragOperation.targetIds;
|
|
1892
1498
|
}
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
}
|
|
1896
|
-
|
|
1897
|
-
function createHover(manager) {
|
|
1898
|
-
return function hover(targetIdsArg, { clientOffset } = {}) {
|
|
1899
|
-
verifyTargetIdsIsArray(targetIdsArg);
|
|
1900
|
-
const targetIds = targetIdsArg.slice(0);
|
|
1901
|
-
const monitor = manager.getMonitor();
|
|
1902
|
-
const registry = manager.getRegistry();
|
|
1903
|
-
const draggedItemType = monitor.getItemType();
|
|
1904
|
-
removeNonMatchingTargetIds(targetIds, registry, draggedItemType);
|
|
1905
|
-
checkInvariants(targetIds, monitor, registry);
|
|
1906
|
-
hoverAllTargets(targetIds, monitor, registry);
|
|
1907
|
-
return {
|
|
1908
|
-
type: HOVER,
|
|
1909
|
-
payload: {
|
|
1910
|
-
targetIds,
|
|
1911
|
-
clientOffset: clientOffset || null
|
|
1912
|
-
}
|
|
1913
|
-
};
|
|
1914
|
-
};
|
|
1915
|
-
}
|
|
1916
|
-
function verifyTargetIdsIsArray(targetIdsArg) {
|
|
1917
|
-
invariant(Array.isArray(targetIdsArg), 'Expected targetIds to be an array.');
|
|
1918
|
-
}
|
|
1919
|
-
function checkInvariants(targetIds, monitor, registry) {
|
|
1920
|
-
invariant(monitor.isDragging(), 'Cannot call hover while not dragging.');
|
|
1921
|
-
invariant(!monitor.didDrop(), 'Cannot call hover after drop.');
|
|
1922
|
-
for(let i = 0; i < targetIds.length; i++){
|
|
1923
|
-
const targetId = targetIds[i];
|
|
1924
|
-
invariant(targetIds.lastIndexOf(targetId) === i, 'Expected targetIds to be unique in the passed array.');
|
|
1925
|
-
const target = registry.getTarget(targetId);
|
|
1926
|
-
invariant(target, 'Expected targetIds to be registered.');
|
|
1499
|
+
getDropResult() {
|
|
1500
|
+
return this.store.getState().dragOperation.dropResult;
|
|
1927
1501
|
}
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
// Remove those targetIds that don't match the targetType. This
|
|
1931
|
-
// fixes shallow isOver which would only be non-shallow because of
|
|
1932
|
-
// non-matching targets.
|
|
1933
|
-
for(let i = targetIds.length - 1; i >= 0; i--){
|
|
1934
|
-
const targetId = targetIds[i];
|
|
1935
|
-
const targetType = registry.getTargetType(targetId);
|
|
1936
|
-
if (!matchesType(targetType, draggedItemType)) {
|
|
1937
|
-
targetIds.splice(i, 1);
|
|
1938
|
-
}
|
|
1502
|
+
didDrop() {
|
|
1503
|
+
return this.store.getState().dragOperation.didDrop;
|
|
1939
1504
|
}
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
// Finally call hover on all matching targets.
|
|
1943
|
-
targetIds.forEach(function(targetId) {
|
|
1944
|
-
const target = registry.getTarget(targetId);
|
|
1945
|
-
target.hover(monitor, targetId);
|
|
1946
|
-
});
|
|
1947
|
-
}
|
|
1948
|
-
|
|
1949
|
-
function createPublishDragSource(manager) {
|
|
1950
|
-
return function publishDragSource() {
|
|
1951
|
-
const monitor = manager.getMonitor();
|
|
1952
|
-
if (monitor.isDragging()) {
|
|
1953
|
-
return {
|
|
1954
|
-
type: PUBLISH_DRAG_SOURCE
|
|
1955
|
-
};
|
|
1956
|
-
}
|
|
1957
|
-
return;
|
|
1958
|
-
};
|
|
1959
|
-
}
|
|
1960
|
-
|
|
1961
|
-
function createDragDropActions(manager) {
|
|
1962
|
-
return {
|
|
1963
|
-
beginDrag: createBeginDrag(manager),
|
|
1964
|
-
publishDragSource: createPublishDragSource(manager),
|
|
1965
|
-
hover: createHover(manager),
|
|
1966
|
-
drop: createDrop(manager),
|
|
1967
|
-
endDrag: createEndDrag(manager)
|
|
1968
|
-
};
|
|
1969
|
-
}
|
|
1970
|
-
|
|
1971
|
-
class DragDropManagerImpl {
|
|
1972
|
-
receiveBackend(backend) {
|
|
1973
|
-
this.backend = backend;
|
|
1505
|
+
isSourcePublic() {
|
|
1506
|
+
return Boolean(this.store.getState().dragOperation.isSourcePublic);
|
|
1974
1507
|
}
|
|
1975
|
-
|
|
1976
|
-
return this.
|
|
1508
|
+
getInitialClientOffset() {
|
|
1509
|
+
return this.store.getState().dragOffset.initialClientOffset;
|
|
1977
1510
|
}
|
|
1978
|
-
|
|
1979
|
-
return this.
|
|
1511
|
+
getInitialSourceClientOffset() {
|
|
1512
|
+
return this.store.getState().dragOffset.initialSourceClientOffset;
|
|
1980
1513
|
}
|
|
1981
|
-
|
|
1982
|
-
return this.
|
|
1514
|
+
getClientOffset() {
|
|
1515
|
+
return this.store.getState().dragOffset.clientOffset;
|
|
1983
1516
|
}
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
const { dispatch } = this.store;
|
|
1987
|
-
function bindActionCreator(actionCreator) {
|
|
1988
|
-
return (...args)=>{
|
|
1989
|
-
const action = actionCreator.apply(manager, args);
|
|
1990
|
-
if (typeof action !== 'undefined') {
|
|
1991
|
-
dispatch(action);
|
|
1992
|
-
}
|
|
1993
|
-
};
|
|
1994
|
-
}
|
|
1995
|
-
const actions = createDragDropActions(this);
|
|
1996
|
-
return Object.keys(actions).reduce((boundActions, key)=>{
|
|
1997
|
-
const action = actions[key];
|
|
1998
|
-
boundActions[key] = bindActionCreator(action);
|
|
1999
|
-
return boundActions;
|
|
2000
|
-
}, {});
|
|
1517
|
+
getSourceClientOffset() {
|
|
1518
|
+
return getSourceClientOffset(this.store.getState().dragOffset);
|
|
2001
1519
|
}
|
|
2002
|
-
|
|
2003
|
-
this.store.
|
|
1520
|
+
getDifferenceFromInitialOffset() {
|
|
1521
|
+
return getDifferenceFromInitialOffset(this.store.getState().dragOffset);
|
|
2004
1522
|
}
|
|
2005
|
-
constructor(store,
|
|
2006
|
-
this.isSetUp = false;
|
|
2007
|
-
this.handleRefCountChange = ()=>{
|
|
2008
|
-
const shouldSetUp = this.store.getState().refCount > 0;
|
|
2009
|
-
if (this.backend) {
|
|
2010
|
-
if (shouldSetUp && !this.isSetUp) {
|
|
2011
|
-
this.backend.setup();
|
|
2012
|
-
this.isSetUp = true;
|
|
2013
|
-
} else if (!shouldSetUp && this.isSetUp) {
|
|
2014
|
-
this.backend.teardown();
|
|
2015
|
-
this.isSetUp = false;
|
|
2016
|
-
}
|
|
2017
|
-
}
|
|
2018
|
-
};
|
|
1523
|
+
constructor(store, registry){
|
|
2019
1524
|
this.store = store;
|
|
2020
|
-
this.
|
|
2021
|
-
store.subscribe(this.handleRefCountChange);
|
|
1525
|
+
this.registry = registry;
|
|
2022
1526
|
}
|
|
2023
1527
|
}
|
|
2024
1528
|
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
*/
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
* Returns null if no item is being dragged.
|
|
2050
|
-
*
|
|
2051
|
-
* @param state The offset state to compute from
|
|
2052
|
-
*/ function getSourceClientOffset(state) {
|
|
2053
|
-
const { clientOffset , initialClientOffset , initialSourceClientOffset } = state;
|
|
2054
|
-
if (!clientOffset || !initialClientOffset || !initialSourceClientOffset) {
|
|
2055
|
-
return null;
|
|
2056
|
-
}
|
|
2057
|
-
return subtract(add(clientOffset, initialSourceClientOffset), initialClientOffset);
|
|
2058
|
-
}
|
|
2059
|
-
/**
|
|
2060
|
-
* Determines the x,y offset between the client offset and the initial client offset
|
|
2061
|
-
*
|
|
2062
|
-
* @param state The offset state to compute from
|
|
2063
|
-
*/ function getDifferenceFromInitialOffset(state) {
|
|
2064
|
-
const { clientOffset , initialClientOffset } = state;
|
|
2065
|
-
if (!clientOffset || !initialClientOffset) {
|
|
2066
|
-
return null;
|
|
2067
|
-
}
|
|
2068
|
-
return subtract(clientOffset, initialClientOffset);
|
|
2069
|
-
}
|
|
2070
|
-
|
|
2071
|
-
const NONE = [];
|
|
2072
|
-
const ALL = [];
|
|
2073
|
-
NONE.__IS_NONE__ = true;
|
|
2074
|
-
ALL.__IS_ALL__ = true;
|
|
2075
|
-
/**
|
|
2076
|
-
* Determines if the given handler IDs are dirty or not.
|
|
2077
|
-
*
|
|
2078
|
-
* @param dirtyIds The set of dirty handler ids
|
|
2079
|
-
* @param handlerIds The set of handler ids to check
|
|
2080
|
-
*/ function areDirty(dirtyIds, handlerIds) {
|
|
2081
|
-
if (dirtyIds === NONE) {
|
|
2082
|
-
return false;
|
|
2083
|
-
}
|
|
2084
|
-
if (dirtyIds === ALL || typeof handlerIds === 'undefined') {
|
|
2085
|
-
return true;
|
|
2086
|
-
}
|
|
2087
|
-
const commonIds = intersection(handlerIds, dirtyIds);
|
|
2088
|
-
return commonIds.length > 0;
|
|
2089
|
-
}
|
|
2090
|
-
|
|
2091
|
-
class DragDropMonitorImpl {
|
|
2092
|
-
subscribeToStateChange(listener, options = {}) {
|
|
2093
|
-
const { handlerIds } = options;
|
|
2094
|
-
invariant(typeof listener === 'function', 'listener must be a function.');
|
|
2095
|
-
invariant(typeof handlerIds === 'undefined' || Array.isArray(handlerIds), 'handlerIds, when specified, must be an array of strings.');
|
|
2096
|
-
let prevStateId = this.store.getState().stateId;
|
|
2097
|
-
const handleChange = ()=>{
|
|
2098
|
-
const state = this.store.getState();
|
|
2099
|
-
const currentStateId = state.stateId;
|
|
2100
|
-
try {
|
|
2101
|
-
const canSkipListener = currentStateId === prevStateId || currentStateId === prevStateId + 1 && !areDirty(state.dirtyHandlerIds, handlerIds);
|
|
2102
|
-
if (!canSkipListener) {
|
|
2103
|
-
listener();
|
|
2104
|
-
}
|
|
2105
|
-
} finally{
|
|
2106
|
-
prevStateId = currentStateId;
|
|
2107
|
-
}
|
|
2108
|
-
};
|
|
2109
|
-
return this.store.subscribe(handleChange);
|
|
2110
|
-
}
|
|
2111
|
-
subscribeToOffsetChange(listener) {
|
|
2112
|
-
invariant(typeof listener === 'function', 'listener must be a function.');
|
|
2113
|
-
let previousState = this.store.getState().dragOffset;
|
|
2114
|
-
const handleChange = ()=>{
|
|
2115
|
-
const nextState = this.store.getState().dragOffset;
|
|
2116
|
-
if (nextState === previousState) {
|
|
2117
|
-
return;
|
|
2118
|
-
}
|
|
2119
|
-
previousState = nextState;
|
|
2120
|
-
listener();
|
|
2121
|
-
};
|
|
2122
|
-
return this.store.subscribe(handleChange);
|
|
2123
|
-
}
|
|
2124
|
-
canDragSource(sourceId) {
|
|
2125
|
-
if (!sourceId) {
|
|
2126
|
-
return false;
|
|
2127
|
-
}
|
|
2128
|
-
const source = this.registry.getSource(sourceId);
|
|
2129
|
-
invariant(source, `Expected to find a valid source. sourceId=${sourceId}`);
|
|
2130
|
-
if (this.isDragging()) {
|
|
2131
|
-
return false;
|
|
2132
|
-
}
|
|
2133
|
-
return source.canDrag(this, sourceId);
|
|
2134
|
-
}
|
|
2135
|
-
canDropOnTarget(targetId) {
|
|
2136
|
-
// undefined on initial render
|
|
2137
|
-
if (!targetId) {
|
|
2138
|
-
return false;
|
|
2139
|
-
}
|
|
2140
|
-
const target = this.registry.getTarget(targetId);
|
|
2141
|
-
invariant(target, `Expected to find a valid target. targetId=${targetId}`);
|
|
2142
|
-
if (!this.isDragging() || this.didDrop()) {
|
|
2143
|
-
return false;
|
|
2144
|
-
}
|
|
2145
|
-
const targetType = this.registry.getTargetType(targetId);
|
|
2146
|
-
const draggedItemType = this.getItemType();
|
|
2147
|
-
return matchesType(targetType, draggedItemType) && target.canDrop(this, targetId);
|
|
2148
|
-
}
|
|
2149
|
-
isDragging() {
|
|
2150
|
-
return Boolean(this.getItemType());
|
|
2151
|
-
}
|
|
2152
|
-
isDraggingSource(sourceId) {
|
|
2153
|
-
// undefined on initial render
|
|
2154
|
-
if (!sourceId) {
|
|
2155
|
-
return false;
|
|
2156
|
-
}
|
|
2157
|
-
const source = this.registry.getSource(sourceId, true);
|
|
2158
|
-
invariant(source, `Expected to find a valid source. sourceId=${sourceId}`);
|
|
2159
|
-
if (!this.isDragging() || !this.isSourcePublic()) {
|
|
2160
|
-
return false;
|
|
2161
|
-
}
|
|
2162
|
-
const sourceType = this.registry.getSourceType(sourceId);
|
|
2163
|
-
const draggedItemType = this.getItemType();
|
|
2164
|
-
if (sourceType !== draggedItemType) {
|
|
2165
|
-
return false;
|
|
2166
|
-
}
|
|
2167
|
-
return source.isDragging(this, sourceId);
|
|
2168
|
-
}
|
|
2169
|
-
isOverTarget(targetId, options = {
|
|
2170
|
-
shallow: false
|
|
2171
|
-
}) {
|
|
2172
|
-
// undefined on initial render
|
|
2173
|
-
if (!targetId) {
|
|
2174
|
-
return false;
|
|
2175
|
-
}
|
|
2176
|
-
const { shallow } = options;
|
|
2177
|
-
if (!this.isDragging()) {
|
|
2178
|
-
return false;
|
|
2179
|
-
}
|
|
2180
|
-
const targetType = this.registry.getTargetType(targetId);
|
|
2181
|
-
const draggedItemType = this.getItemType();
|
|
2182
|
-
if (draggedItemType && !matchesType(targetType, draggedItemType)) {
|
|
2183
|
-
return false;
|
|
2184
|
-
}
|
|
2185
|
-
const targetIds = this.getTargetIds();
|
|
2186
|
-
if (!targetIds.length) {
|
|
2187
|
-
return false;
|
|
2188
|
-
}
|
|
2189
|
-
const index = targetIds.indexOf(targetId);
|
|
2190
|
-
if (shallow) {
|
|
2191
|
-
return index === targetIds.length - 1;
|
|
2192
|
-
} else {
|
|
2193
|
-
return index > -1;
|
|
2194
|
-
}
|
|
2195
|
-
}
|
|
2196
|
-
getItemType() {
|
|
2197
|
-
return this.store.getState().dragOperation.itemType;
|
|
2198
|
-
}
|
|
2199
|
-
getItem() {
|
|
2200
|
-
return this.store.getState().dragOperation.item;
|
|
2201
|
-
}
|
|
2202
|
-
getSourceId() {
|
|
2203
|
-
return this.store.getState().dragOperation.sourceId;
|
|
2204
|
-
}
|
|
2205
|
-
getTargetIds() {
|
|
2206
|
-
return this.store.getState().dragOperation.targetIds;
|
|
2207
|
-
}
|
|
2208
|
-
getDropResult() {
|
|
2209
|
-
return this.store.getState().dragOperation.dropResult;
|
|
2210
|
-
}
|
|
2211
|
-
didDrop() {
|
|
2212
|
-
return this.store.getState().dragOperation.didDrop;
|
|
2213
|
-
}
|
|
2214
|
-
isSourcePublic() {
|
|
2215
|
-
return Boolean(this.store.getState().dragOperation.isSourcePublic);
|
|
2216
|
-
}
|
|
2217
|
-
getInitialClientOffset() {
|
|
2218
|
-
return this.store.getState().dragOffset.initialClientOffset;
|
|
2219
|
-
}
|
|
2220
|
-
getInitialSourceClientOffset() {
|
|
2221
|
-
return this.store.getState().dragOffset.initialSourceClientOffset;
|
|
2222
|
-
}
|
|
2223
|
-
getClientOffset() {
|
|
2224
|
-
return this.store.getState().dragOffset.clientOffset;
|
|
2225
|
-
}
|
|
2226
|
-
getSourceClientOffset() {
|
|
2227
|
-
return getSourceClientOffset(this.store.getState().dragOffset);
|
|
2228
|
-
}
|
|
2229
|
-
getDifferenceFromInitialOffset() {
|
|
2230
|
-
return getDifferenceFromInitialOffset(this.store.getState().dragOffset);
|
|
2231
|
-
}
|
|
2232
|
-
constructor(store, registry){
|
|
2233
|
-
this.store = store;
|
|
2234
|
-
this.registry = registry;
|
|
2235
|
-
}
|
|
2236
|
-
}
|
|
2237
|
-
|
|
2238
|
-
// Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that
|
|
2239
|
-
// have WebKitMutationObserver but not un-prefixed MutationObserver.
|
|
2240
|
-
// Must use `global` or `self` instead of `window` to work in both frames and web
|
|
2241
|
-
// workers. `global` is a provision of Browserify, Mr, Mrs, or Mop.
|
|
2242
|
-
/* globals self */ const scope = typeof global !== 'undefined' ? global : self;
|
|
2243
|
-
const BrowserMutationObserver = scope.MutationObserver || scope.WebKitMutationObserver;
|
|
2244
|
-
function makeRequestCallFromTimer(callback) {
|
|
2245
|
-
return function requestCall() {
|
|
2246
|
-
// We dispatch a timeout with a specified delay of 0 for engines that
|
|
2247
|
-
// can reliably accommodate that request. This will usually be snapped
|
|
2248
|
-
// to a 4 milisecond delay, but once we're flushing, there's no delay
|
|
2249
|
-
// between events.
|
|
2250
|
-
const timeoutHandle = setTimeout(handleTimer, 0);
|
|
2251
|
-
// However, since this timer gets frequently dropped in Firefox
|
|
2252
|
-
// workers, we enlist an interval handle that will try to fire
|
|
2253
|
-
// an event 20 times per second until it succeeds.
|
|
2254
|
-
const intervalHandle = setInterval(handleTimer, 50);
|
|
2255
|
-
function handleTimer() {
|
|
2256
|
-
// Whichever timer succeeds will cancel both timers and
|
|
2257
|
-
// execute the callback.
|
|
2258
|
-
clearTimeout(timeoutHandle);
|
|
2259
|
-
clearInterval(intervalHandle);
|
|
2260
|
-
callback();
|
|
2261
|
-
}
|
|
1529
|
+
// Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that
|
|
1530
|
+
// have WebKitMutationObserver but not un-prefixed MutationObserver.
|
|
1531
|
+
// Must use `global` or `self` instead of `window` to work in both frames and web
|
|
1532
|
+
// workers. `global` is a provision of Browserify, Mr, Mrs, or Mop.
|
|
1533
|
+
/* globals self */ const scope = typeof global !== 'undefined' ? global : self;
|
|
1534
|
+
const BrowserMutationObserver = scope.MutationObserver || scope.WebKitMutationObserver;
|
|
1535
|
+
function makeRequestCallFromTimer(callback) {
|
|
1536
|
+
return function requestCall() {
|
|
1537
|
+
// We dispatch a timeout with a specified delay of 0 for engines that
|
|
1538
|
+
// can reliably accommodate that request. This will usually be snapped
|
|
1539
|
+
// to a 4 milisecond delay, but once we're flushing, there's no delay
|
|
1540
|
+
// between events.
|
|
1541
|
+
const timeoutHandle = setTimeout(handleTimer, 0);
|
|
1542
|
+
// However, since this timer gets frequently dropped in Firefox
|
|
1543
|
+
// workers, we enlist an interval handle that will try to fire
|
|
1544
|
+
// an event 20 times per second until it succeeds.
|
|
1545
|
+
const intervalHandle = setInterval(handleTimer, 50);
|
|
1546
|
+
function handleTimer() {
|
|
1547
|
+
// Whichever timer succeeds will cancel both timers and
|
|
1548
|
+
// execute the callback.
|
|
1549
|
+
clearTimeout(timeoutHandle);
|
|
1550
|
+
clearInterval(intervalHandle);
|
|
1551
|
+
callback();
|
|
1552
|
+
}
|
|
2262
1553
|
};
|
|
2263
1554
|
}
|
|
2264
1555
|
// To request a high priority event, we induce a mutation observer by toggling
|
|
@@ -3883,103 +3174,900 @@ function useDropTargetConnector(options) {
|
|
|
3883
3174
|
return connector;
|
|
3884
3175
|
}
|
|
3885
3176
|
|
|
3886
|
-
function useDropTargetMonitor() {
|
|
3887
|
-
const manager = useDragDropManager();
|
|
3888
|
-
return React.useMemo(()=>new DropTargetMonitorImpl(manager)
|
|
3889
|
-
, [
|
|
3890
|
-
manager
|
|
3891
|
-
]);
|
|
3892
|
-
}
|
|
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
|
+
};
|
|
3844
|
+
|
|
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;
|
|
3857
|
+
|
|
3858
|
+
var _getState = getState(),
|
|
3859
|
+
isDensePadding = _getState.isDensePadding;
|
|
3860
|
+
|
|
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
|
|
3869
|
+
}
|
|
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);
|
|
3880
|
+
}
|
|
3881
|
+
}));
|
|
3882
|
+
};
|
|
3883
|
+
|
|
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;
|
|
3895
|
+
|
|
3896
|
+
var _getState = getState(),
|
|
3897
|
+
currentEditingRow = _getState.currentEditingRow;
|
|
3898
|
+
|
|
3899
|
+
var handleCancel = function handleCancel() {
|
|
3900
|
+
var _row$original;
|
|
3901
|
+
|
|
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;
|
|
3958
|
+
|
|
3959
|
+
var _getState = getState(),
|
|
3960
|
+
currentEditingRow = _getState.currentEditingRow;
|
|
3961
|
+
|
|
3962
|
+
var _useState = React.useState(null),
|
|
3963
|
+
anchorEl = _useState[0],
|
|
3964
|
+
setAnchorEl = _useState[1];
|
|
3893
3965
|
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
const { accept } = spec;
|
|
3900
|
-
return React.useMemo(()=>{
|
|
3901
|
-
invariant(spec.accept != null, 'accept must be defined');
|
|
3902
|
-
return Array.isArray(accept) ? accept : [
|
|
3903
|
-
accept
|
|
3904
|
-
];
|
|
3905
|
-
}, [
|
|
3906
|
-
accept
|
|
3907
|
-
]);
|
|
3908
|
-
}
|
|
3966
|
+
var handleOpenRowActionMenu = function handleOpenRowActionMenu(event) {
|
|
3967
|
+
event.stopPropagation();
|
|
3968
|
+
event.preventDefault();
|
|
3969
|
+
setAnchorEl(event.currentTarget);
|
|
3970
|
+
};
|
|
3909
3971
|
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
return spec.canDrop ? spec.canDrop(monitor.getItem(), monitor) : true;
|
|
3915
|
-
}
|
|
3916
|
-
hover() {
|
|
3917
|
-
const spec = this.spec;
|
|
3918
|
-
const monitor = this.monitor;
|
|
3919
|
-
if (spec.hover) {
|
|
3920
|
-
spec.hover(monitor.getItem(), monitor);
|
|
3921
|
-
}
|
|
3922
|
-
}
|
|
3923
|
-
drop() {
|
|
3924
|
-
const spec = this.spec;
|
|
3925
|
-
const monitor = this.monitor;
|
|
3926
|
-
if (spec.drop) {
|
|
3927
|
-
return spec.drop(monitor.getItem(), monitor);
|
|
3928
|
-
}
|
|
3929
|
-
return;
|
|
3930
|
-
}
|
|
3931
|
-
constructor(spec, monitor){
|
|
3932
|
-
this.spec = spec;
|
|
3933
|
-
this.monitor = monitor;
|
|
3934
|
-
}
|
|
3935
|
-
}
|
|
3972
|
+
var handleStartEditMode = function handleStartEditMode() {
|
|
3973
|
+
setCurrentEditingRow(_extends({}, row));
|
|
3974
|
+
setAnchorEl(null);
|
|
3975
|
+
};
|
|
3936
3976
|
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
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
|
+
};
|
|
3949
4008
|
|
|
3950
|
-
function
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
dropTarget,
|
|
3963
|
-
connector,
|
|
3964
|
-
accept.map((a)=>a.toString()
|
|
3965
|
-
).join('|'),
|
|
3966
|
-
]);
|
|
3967
|
-
}
|
|
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;
|
|
3968
4021
|
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
4022
|
+
var _getState = getState(),
|
|
4023
|
+
isDensePadding = _getState.isDensePadding;
|
|
4024
|
+
|
|
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
|
+
};
|
|
3983
4071
|
|
|
3984
4072
|
// cheap lodash replacements
|
|
3985
4073
|
function memoize(fn) {
|
|
@@ -5620,9 +5708,6 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
5620
5708
|
var filterChipLabel = !(filterFn instanceof Function) && [MRT_FILTER_OPTION.EMPTY, MRT_FILTER_OPTION.NOT_EMPTY].includes(filterFn) ? //@ts-ignore
|
|
5621
5709
|
localization["filter" + (filterFn.charAt(0).toUpperCase() + filterFn.slice(1))] : '';
|
|
5622
5710
|
var filterPlaceholder = inputIndex === undefined ? (_localization$filterB = localization.filterByColumn) == null ? void 0 : _localization$filterB.replace('{column}', String(columnDef.header)) : inputIndex === 0 ? localization.min : inputIndex === 1 ? localization.max : '';
|
|
5623
|
-
console.log({
|
|
5624
|
-
textFieldProps: textFieldProps
|
|
5625
|
-
});
|
|
5626
5711
|
return React__default.createElement(React__default.Fragment, null, React__default.createElement(material.TextField, Object.assign({
|
|
5627
5712
|
fullWidth: true,
|
|
5628
5713
|
id: filterId,
|
|
@@ -5800,8 +5885,9 @@ var MRT_TableHeadCellFilterLabel = function MRT_TableHeadCellFilterLabel(_ref) {
|
|
|
5800
5885
|
showFilters = _getState.showFilters;
|
|
5801
5886
|
|
|
5802
5887
|
var column = header.column;
|
|
5888
|
+
var columnDef = column.columnDef;
|
|
5803
5889
|
var filterFn = (_getState2 = getState()) == null ? void 0 : (_getState2$currentFil = _getState2.currentFilterFns) == null ? void 0 : _getState2$currentFil[header.id];
|
|
5804
|
-
var filterTooltip = !!column.getFilterValue() ? localization.filteringByColumn.replace('{column}', String(
|
|
5890
|
+
var filterTooltip = !!column.getFilterValue() ? localization.filteringByColumn.replace('{column}', String(columnDef.header)).replace('{filterType}', filterFn instanceof Function ? '' : // @ts-ignore
|
|
5805
5891
|
localization["filter" + (filterFn.charAt(0).toUpperCase() + filterFn.slice(1))]).replace('{filterValue}', "\"" + (Array.isArray(column.getFilterValue()) ? column.getFilterValue().join("\" " + localization.and + " \"") : column.getFilterValue()) + "\"").replace('" "', '') : localization.showHideFilters;
|
|
5806
5892
|
return React__default.createElement(material.Tooltip, {
|
|
5807
5893
|
arrow: true,
|
|
@@ -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;
|
|
@@ -5868,6 +5922,7 @@ var MRT_TableHeadCellResizeHandle = function MRT_TableHeadCellResizeHandle(_ref)
|
|
|
5868
5922
|
showFilters = _getState.showFilters;
|
|
5869
5923
|
|
|
5870
5924
|
var column = header.column;
|
|
5925
|
+
var columnDefType = column.columnDefType;
|
|
5871
5926
|
return React__default.createElement(material.Divider, {
|
|
5872
5927
|
flexItem: true,
|
|
5873
5928
|
orientation: "vertical",
|
|
@@ -5879,7 +5934,7 @@ var MRT_TableHeadCellResizeHandle = function MRT_TableHeadCellResizeHandle(_ref)
|
|
|
5879
5934
|
borderRadius: '2px',
|
|
5880
5935
|
borderRightWidth: '2px',
|
|
5881
5936
|
cursor: 'col-resize',
|
|
5882
|
-
height: showFilters &&
|
|
5937
|
+
height: showFilters && columnDefType === 'data' ? '4rem' : '2rem',
|
|
5883
5938
|
opacity: 0.8,
|
|
5884
5939
|
position: 'absolute',
|
|
5885
5940
|
right: '1px',
|
|
@@ -5906,7 +5961,8 @@ var MRT_TableHeadCellSortLabel = function MRT_TableHeadCellSortLabel(_ref) {
|
|
|
5906
5961
|
tableInstance = _ref.tableInstance;
|
|
5907
5962
|
var localization = tableInstance.options.localization;
|
|
5908
5963
|
var column = header.column;
|
|
5909
|
-
var
|
|
5964
|
+
var columnDef = column.columnDef;
|
|
5965
|
+
var sortTooltip = !!column.getIsSorted() ? column.getIsSorted() === 'desc' ? localization.sortedByColumnDesc.replace('{column}', columnDef.header) : localization.sortedByColumnAsc.replace('{column}', columnDef.header) : localization.unsorted;
|
|
5910
5966
|
return React__default.createElement(material.Tooltip, {
|
|
5911
5967
|
arrow: true,
|
|
5912
5968
|
placement: "top",
|
|
@@ -5926,6 +5982,7 @@ var MRT_ToggleColumnActionMenuButton = function MRT_ToggleColumnActionMenuButton
|
|
|
5926
5982
|
localization = _tableInstance$option.localization,
|
|
5927
5983
|
muiTableHeadCellColumnActionsButtonProps = _tableInstance$option.muiTableHeadCellColumnActionsButtonProps;
|
|
5928
5984
|
var column = header.column;
|
|
5985
|
+
var columnDef = column.columnDef;
|
|
5929
5986
|
|
|
5930
5987
|
var _useState = React.useState(null),
|
|
5931
5988
|
anchorEl = _useState[0],
|
|
@@ -5941,10 +5998,10 @@ var MRT_ToggleColumnActionMenuButton = function MRT_ToggleColumnActionMenuButton
|
|
|
5941
5998
|
column: column,
|
|
5942
5999
|
tableInstance: tableInstance
|
|
5943
6000
|
}) : muiTableHeadCellColumnActionsButtonProps;
|
|
5944
|
-
var mcTableHeadCellColumnActionsButtonProps =
|
|
6001
|
+
var mcTableHeadCellColumnActionsButtonProps = columnDef.muiTableHeadCellColumnActionsButtonProps instanceof Function ? columnDef.muiTableHeadCellColumnActionsButtonProps({
|
|
5945
6002
|
column: column,
|
|
5946
6003
|
tableInstance: tableInstance
|
|
5947
|
-
}) :
|
|
6004
|
+
}) : columnDef.muiTableHeadCellColumnActionsButtonProps;
|
|
5948
6005
|
|
|
5949
6006
|
var iconButtonProps = _extends({}, mTableHeadCellColumnActionsButtonProps, mcTableHeadCellColumnActionsButtonProps);
|
|
5950
6007
|
|
|
@@ -5979,7 +6036,7 @@ var MRT_ToggleColumnActionMenuButton = function MRT_ToggleColumnActionMenuButton
|
|
|
5979
6036
|
};
|
|
5980
6037
|
|
|
5981
6038
|
var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
5982
|
-
var
|
|
6039
|
+
var _columnDef$Header, _columnDef$minSize, _columnDef$header$len, _columnDef$header;
|
|
5983
6040
|
|
|
5984
6041
|
var dragRef = _ref.dragRef,
|
|
5985
6042
|
dropRef = _ref.dropRef,
|
|
@@ -6013,10 +6070,10 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
|
6013
6070
|
|
|
6014
6071
|
var tableCellProps = _extends({}, mTableHeadCellProps, mcTableHeadCellProps);
|
|
6015
6072
|
|
|
6016
|
-
var headerElement = (
|
|
6073
|
+
var headerElement = (columnDef == null ? void 0 : columnDef.Header) instanceof Function ? columnDef == null ? void 0 : columnDef.Header == null ? void 0 : columnDef.Header({
|
|
6017
6074
|
header: header,
|
|
6018
6075
|
tableInstance: tableInstance
|
|
6019
|
-
}) : (
|
|
6076
|
+
}) : (_columnDef$Header = columnDef == null ? void 0 : columnDef.Header) != null ? _columnDef$Header : header.renderHeader();
|
|
6020
6077
|
|
|
6021
6078
|
var getIsLastLeftPinnedColumn = function getIsLastLeftPinnedColumn() {
|
|
6022
6079
|
return column.getIsPinned() === 'left' && tableInstance.getLeftLeafHeaders().length - 1 === column.getPinnedIndex();
|
|
@@ -6047,7 +6104,7 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
|
6047
6104
|
p: isDensePadding ? columnDefType === 'display' ? '0 0.5rem' : '0.5rem' : columnDefType === 'display' ? '0.5rem 0.75rem' : '1rem',
|
|
6048
6105
|
pb: columnDefType === 'display' ? 0 : undefined,
|
|
6049
6106
|
position: column.getIsPinned() && columnDefType !== 'group' ? 'sticky' : undefined,
|
|
6050
|
-
pt: columnDefType
|
|
6107
|
+
pt: columnDefType !== 'data' ? 0 : isDensePadding ? '0.25' : '.5rem',
|
|
6051
6108
|
right: column.getIsPinned() === 'right' ? getTotalRight() + "px" : undefined,
|
|
6052
6109
|
transition: "all " + (enableColumnResizing ? 0 : '0.2s') + " ease-in-out",
|
|
6053
6110
|
verticalAlign: 'text-top',
|
|
@@ -6089,8 +6146,7 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
|
6089
6146
|
sx: {
|
|
6090
6147
|
whiteSpace: 'nowrap'
|
|
6091
6148
|
}
|
|
6092
|
-
}, columnDefType === 'data' && (enableColumnOrdering && columnDef.enableColumnOrdering !== false || enableGrouping && columnDef.enableGrouping !== false) && React__default.createElement(
|
|
6093
|
-
header: header,
|
|
6149
|
+
}, columnDefType === 'data' && (enableColumnOrdering && columnDef.enableColumnOrdering !== false || enableGrouping && columnDef.enableGrouping !== false) && React__default.createElement(MRT_GrabHandleButton, {
|
|
6094
6150
|
ref: dragRef,
|
|
6095
6151
|
tableInstance: tableInstance
|
|
6096
6152
|
}), (enableColumnActions || columnDef.enableColumnActions) && columnDef.enableColumnActions !== false && columnDefType !== 'group' && React__default.createElement(MRT_ToggleColumnActionMenuButton, {
|
|
@@ -6117,19 +6173,22 @@ var MRT_DraggableTableHeadCell = function MRT_DraggableTableHeadCell(_ref) {
|
|
|
6117
6173
|
var _getState = getState(),
|
|
6118
6174
|
columnOrder = _getState.columnOrder;
|
|
6119
6175
|
|
|
6120
|
-
var reorder = function reorder(
|
|
6121
|
-
|
|
6122
|
-
|
|
6176
|
+
var reorder = function reorder(movingHeader, receivingHeader) {
|
|
6177
|
+
if (movingHeader.column.getCanPin()) {
|
|
6178
|
+
movingHeader.column.pin(receivingHeader.column.getIsPinned());
|
|
6179
|
+
}
|
|
6180
|
+
|
|
6181
|
+
columnOrder.splice(receivingHeader.index, 0, columnOrder.splice(movingHeader.index, 1)[0]);
|
|
6123
6182
|
setColumnOrder([].concat(columnOrder));
|
|
6124
6183
|
};
|
|
6125
6184
|
|
|
6126
6185
|
var _useDrop = useDrop({
|
|
6127
6186
|
accept: 'header',
|
|
6128
|
-
drop: function drop(
|
|
6129
|
-
return reorder(
|
|
6187
|
+
drop: function drop(movingHeader) {
|
|
6188
|
+
return reorder(movingHeader, header);
|
|
6130
6189
|
}
|
|
6131
6190
|
}),
|
|
6132
|
-
|
|
6191
|
+
dropRef = _useDrop[1];
|
|
6133
6192
|
|
|
6134
6193
|
var _useDrag = useDrag({
|
|
6135
6194
|
collect: function collect(monitor) {
|
|
@@ -6143,15 +6202,15 @@ var MRT_DraggableTableHeadCell = function MRT_DraggableTableHeadCell(_ref) {
|
|
|
6143
6202
|
type: 'header'
|
|
6144
6203
|
}),
|
|
6145
6204
|
isDragging = _useDrag[0].isDragging,
|
|
6146
|
-
|
|
6147
|
-
|
|
6205
|
+
dragRef = _useDrag[1],
|
|
6206
|
+
previewRef = _useDrag[2];
|
|
6148
6207
|
|
|
6149
6208
|
return React__default.createElement(MRT_TableHeadCell, {
|
|
6150
|
-
dragRef:
|
|
6151
|
-
dropRef:
|
|
6209
|
+
dragRef: dragRef,
|
|
6210
|
+
dropRef: dropRef,
|
|
6152
6211
|
header: header,
|
|
6153
6212
|
isDragging: isDragging,
|
|
6154
|
-
previewRef:
|
|
6213
|
+
previewRef: previewRef,
|
|
6155
6214
|
tableInstance: tableInstance
|
|
6156
6215
|
});
|
|
6157
6216
|
};
|
|
@@ -6297,6 +6356,8 @@ var MRT_CopyButton = function MRT_CopyButton(_ref) {
|
|
|
6297
6356
|
var _tableInstance$option = tableInstance.options,
|
|
6298
6357
|
localization = _tableInstance$option.localization,
|
|
6299
6358
|
muiTableBodyCellCopyButtonProps = _tableInstance$option.muiTableBodyCellCopyButtonProps;
|
|
6359
|
+
var column = cell.column;
|
|
6360
|
+
var columnDef = column.columnDef;
|
|
6300
6361
|
|
|
6301
6362
|
var _useState = React.useState(false),
|
|
6302
6363
|
copied = _useState[0],
|
|
@@ -6314,10 +6375,10 @@ var MRT_CopyButton = function MRT_CopyButton(_ref) {
|
|
|
6314
6375
|
cell: cell,
|
|
6315
6376
|
tableInstance: tableInstance
|
|
6316
6377
|
}) : muiTableBodyCellCopyButtonProps;
|
|
6317
|
-
var mcTableBodyCellCopyButtonProps =
|
|
6378
|
+
var mcTableBodyCellCopyButtonProps = columnDef.muiTableBodyCellCopyButtonProps instanceof Function ? columnDef.muiTableBodyCellCopyButtonProps({
|
|
6318
6379
|
cell: cell,
|
|
6319
6380
|
tableInstance: tableInstance
|
|
6320
|
-
}) :
|
|
6381
|
+
}) : columnDef.muiTableBodyCellCopyButtonProps;
|
|
6321
6382
|
|
|
6322
6383
|
var buttonProps = _extends({}, mTableBodyCellCopyButtonProps, mcTableBodyCellCopyButtonProps);
|
|
6323
6384
|
|
|
@@ -6353,7 +6414,7 @@ var MRT_CopyButton = function MRT_CopyButton(_ref) {
|
|
|
6353
6414
|
};
|
|
6354
6415
|
|
|
6355
6416
|
var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
|
|
6356
|
-
var _columnDef$minSize,
|
|
6417
|
+
var _columnDef$minSize, _columnDef$Cell, _row$subRows, _columnDef$Cell2, _row$subRows$length, _row$subRows2;
|
|
6357
6418
|
|
|
6358
6419
|
var cell = _ref.cell,
|
|
6359
6420
|
enableHover = _ref.enableHover,
|
|
@@ -6378,7 +6439,8 @@ var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
|
|
|
6378
6439
|
|
|
6379
6440
|
var column = cell.column,
|
|
6380
6441
|
row = cell.row;
|
|
6381
|
-
var columnDef = column.columnDef
|
|
6442
|
+
var columnDef = column.columnDef,
|
|
6443
|
+
columnDefType = column.columnDefType;
|
|
6382
6444
|
var mTableCellBodyProps = muiTableBodyCellProps instanceof Function ? muiTableBodyCellProps({
|
|
6383
6445
|
cell: cell,
|
|
6384
6446
|
tableInstance: tableInstance
|
|
@@ -6391,8 +6453,8 @@ var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
|
|
|
6391
6453
|
var tableCellProps = _extends({}, mTableCellBodyProps, mcTableCellBodyProps);
|
|
6392
6454
|
|
|
6393
6455
|
var skeletonWidth = React.useMemo(function () {
|
|
6394
|
-
return
|
|
6395
|
-
}, [
|
|
6456
|
+
return columnDefType === 'display' ? column.getSize() / 2 : Math.random() * (column.getSize() - column.getSize() / 3) + column.getSize() / 3;
|
|
6457
|
+
}, [columnDefType, column.getSize()]);
|
|
6396
6458
|
var isEditable = (enableEditing || columnDef.enableEditing) && columnDef.enableEditing !== false;
|
|
6397
6459
|
var isEditing = isEditable && (editingMode === 'table' || (currentEditingRow == null ? void 0 : currentEditingRow.id) === row.id || (currentEditingCell == null ? void 0 : currentEditingCell.id) === cell.id);
|
|
6398
6460
|
|
|
@@ -6438,7 +6500,7 @@ var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
|
|
|
6438
6500
|
boxShadow: getIsLastLeftPinnedColumn() ? "4px 0 4px -2px " + material.alpha(theme.palette.common.black, 0.1) : getIsFirstRightPinnedColumn() ? "-4px 0 4px -2px " + material.alpha(theme.palette.common.black, 0.1) : undefined,
|
|
6439
6501
|
cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'text',
|
|
6440
6502
|
left: column.getIsPinned() === 'left' ? column.getStart('left') + "px" : undefined,
|
|
6441
|
-
p: isDensePadding ?
|
|
6503
|
+
p: isDensePadding ? columnDefType === 'display' ? '0 0.5rem' : '0.5rem' : columnDefType === 'display' ? '0.5rem 0.75rem' : '1rem',
|
|
6442
6504
|
pl: column.id === 'mrt-expand' ? row.depth + (isDensePadding ? 0.5 : 0.75) + "rem" : undefined,
|
|
6443
6505
|
position: column.getIsPinned() ? 'sticky' : 'relative',
|
|
6444
6506
|
right: column.getIsPinned() === 'right' ? getTotalRight() + "px" : undefined,
|
|
@@ -6459,7 +6521,7 @@ var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
|
|
|
6459
6521
|
animation: "wave",
|
|
6460
6522
|
height: 20,
|
|
6461
6523
|
width: skeletonWidth
|
|
6462
|
-
}, muiTableBodyCellSkeletonProps)) :
|
|
6524
|
+
}, muiTableBodyCellSkeletonProps)) : columnDefType === 'display' ? columnDef.Cell == null ? void 0 : columnDef.Cell({
|
|
6463
6525
|
cell: cell,
|
|
6464
6526
|
tableInstance: tableInstance
|
|
6465
6527
|
}) : cell.getIsPlaceholder() || row.getIsGrouped() && column.id !== row.groupingColumnId ? null : cell.getIsAggregated() ? cell.renderAggregatedCell() : isEditing ? React__default.createElement(MRT_EditCellTextField, {
|
|
@@ -6468,13 +6530,13 @@ var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
|
|
|
6468
6530
|
}) : (enableClickToCopy || columnDef.enableClickToCopy) && columnDef.enableClickToCopy !== false ? React__default.createElement(React__default.Fragment, null, React__default.createElement(MRT_CopyButton, {
|
|
6469
6531
|
cell: cell,
|
|
6470
6532
|
tableInstance: tableInstance
|
|
6471
|
-
}, React__default.createElement(React__default.Fragment, null, (
|
|
6533
|
+
}, React__default.createElement(React__default.Fragment, null, (_columnDef$Cell = columnDef == null ? void 0 : columnDef.Cell == null ? void 0 : columnDef.Cell({
|
|
6472
6534
|
cell: cell,
|
|
6473
6535
|
tableInstance: tableInstance
|
|
6474
|
-
})) != null ?
|
|
6536
|
+
})) != null ? _columnDef$Cell : cell.renderCell())), row.getIsGrouped() && React__default.createElement(React__default.Fragment, null, " (", (_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length, ")")) : React__default.createElement(React__default.Fragment, null, (_columnDef$Cell2 = columnDef == null ? void 0 : columnDef.Cell == null ? void 0 : columnDef.Cell({
|
|
6475
6537
|
cell: cell,
|
|
6476
6538
|
tableInstance: tableInstance
|
|
6477
|
-
})) != null ?
|
|
6539
|
+
})) != null ? _columnDef$Cell2 : cell.renderCell(), row.getIsGrouped() && React__default.createElement(React__default.Fragment, null, " (", (_row$subRows$length = (_row$subRows2 = row.subRows) == null ? void 0 : _row$subRows2.length) != null ? _row$subRows$length : '', ")"))));
|
|
6478
6540
|
};
|
|
6479
6541
|
|
|
6480
6542
|
var MRT_TableDetailPanel = function MRT_TableDetailPanel(_ref) {
|
|
@@ -6596,7 +6658,8 @@ var MRT_TableFooterCell = function MRT_TableFooterCell(_ref) {
|
|
|
6596
6658
|
isDensePadding = _getState.isDensePadding;
|
|
6597
6659
|
|
|
6598
6660
|
var column = footer.column;
|
|
6599
|
-
var columnDef = column.columnDef
|
|
6661
|
+
var columnDef = column.columnDef,
|
|
6662
|
+
columnDefType = column.columnDefType;
|
|
6600
6663
|
var mTableFooterCellProps = muiTableFooterCellProps instanceof Function ? muiTableFooterCellProps({
|
|
6601
6664
|
column: column,
|
|
6602
6665
|
tableInstance: tableInstance
|
|
@@ -6609,7 +6672,7 @@ var MRT_TableFooterCell = function MRT_TableFooterCell(_ref) {
|
|
|
6609
6672
|
var tableCellProps = _extends({}, mTableFooterCellProps, mcTableFooterCellProps);
|
|
6610
6673
|
|
|
6611
6674
|
return React__default.createElement(material.TableCell, Object.assign({
|
|
6612
|
-
align:
|
|
6675
|
+
align: columnDefType === 'group' ? 'center' : 'left',
|
|
6613
6676
|
colSpan: footer.colSpan,
|
|
6614
6677
|
variant: "head"
|
|
6615
6678
|
}, tableCellProps, {
|
|
@@ -6639,8 +6702,8 @@ var MRT_TableFooterRow = function MRT_TableFooterRow(_ref) {
|
|
|
6639
6702
|
tableInstance = _ref.tableInstance;
|
|
6640
6703
|
var muiTableFooterRowProps = tableInstance.options.muiTableFooterRowProps; // if no content in row, skip row
|
|
6641
6704
|
|
|
6642
|
-
if (!((_footerGroup$headers = footerGroup.headers) != null && _footerGroup$headers.some(function (
|
|
6643
|
-
return typeof
|
|
6705
|
+
if (!((_footerGroup$headers = footerGroup.headers) != null && _footerGroup$headers.some(function (header) {
|
|
6706
|
+
return typeof header.column.columnDef.footer === 'string' && !!header.column.columnDef.footer || header.column.columnDef.Footer;
|
|
6644
6707
|
}))) return null;
|
|
6645
6708
|
var tableRowProps = muiTableFooterRowProps instanceof Function ? muiTableFooterRowProps({
|
|
6646
6709
|
footerGroup: footerGroup,
|
|
@@ -6831,7 +6894,7 @@ var createDisplayColumn = function createDisplayColumn(table, column) {
|
|
|
6831
6894
|
};
|
|
6832
6895
|
|
|
6833
6896
|
var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
6834
|
-
var _initialState$current, _initialState$current2, _initialState$isDense, _initialState$isFullS, _initialState$showFil, _initialState$showGlo,
|
|
6897
|
+
var _initialState$current, _initialState$current2, _initialState$isDense, _initialState$isFullS, _initialState$showFil, _initialState$showGlo, _props$globalFilterFn, _props$state3, _props$state4;
|
|
6835
6898
|
|
|
6836
6899
|
var _useState = React.useState(props.idPrefix),
|
|
6837
6900
|
idPrefix = _useState[0],
|
|
@@ -6842,9 +6905,18 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
6842
6905
|
|
|
6843
6906
|
return setIdPrefix((_props$idPrefix = props.idPrefix) != null ? _props$idPrefix : Math.random().toString(36).substring(2, 9));
|
|
6844
6907
|
}, [props.idPrefix]);
|
|
6908
|
+
var showActionColumn = props.enableRowActions || props.enableEditing && props.editingMode === 'row';
|
|
6909
|
+
var showExpandColumn = props.enableExpanding || props.enableGrouping;
|
|
6845
6910
|
var initialState = React.useMemo(function () {
|
|
6911
|
+
var _props$initialState, _initState$columnOrde;
|
|
6912
|
+
|
|
6913
|
+
var initState = (_props$initialState = props.initialState) != null ? _props$initialState : {};
|
|
6914
|
+
initState.columnOrder = ((_initState$columnOrde = initState == null ? void 0 : initState.columnOrder) != null ? _initState$columnOrde : props.enableColumnOrdering) ? [showActionColumn && 'mrt-row-actions', showExpandColumn && 'mrt-expand', props.enableRowSelection && 'mrt-select', props.enableRowNumbers && 'mrt-row-numbers'].concat(getAllLeafColumnDefs(props.columns).map(function (c) {
|
|
6915
|
+
return c.id;
|
|
6916
|
+
})).filter(Boolean) : [];
|
|
6917
|
+
|
|
6846
6918
|
if (!props.enablePersistentState || !props.idPrefix) {
|
|
6847
|
-
return
|
|
6919
|
+
return initState;
|
|
6848
6920
|
}
|
|
6849
6921
|
|
|
6850
6922
|
if (typeof window === 'undefined') {
|
|
@@ -6852,7 +6924,7 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
6852
6924
|
console.error('The MRT Persistent Table State feature is not supported if using SSR, but you can wrap your <MaterialReactTable /> in a MUI <NoSsr> tags to let it work');
|
|
6853
6925
|
}
|
|
6854
6926
|
|
|
6855
|
-
return
|
|
6927
|
+
return initState;
|
|
6856
6928
|
}
|
|
6857
6929
|
|
|
6858
6930
|
var storedState = props.persistentStateMode === 'localStorage' ? localStorage.getItem("mrt-" + idPrefix + "-table-state") : props.persistentStateMode === 'sessionStorage' ? sessionStorage.getItem("mrt-" + idPrefix + "-table-state") : '{}';
|
|
@@ -6861,11 +6933,11 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
6861
6933
|
var parsedState = JSON.parse(storedState);
|
|
6862
6934
|
|
|
6863
6935
|
if (parsedState) {
|
|
6864
|
-
return _extends({},
|
|
6936
|
+
return _extends({}, initState, parsedState);
|
|
6865
6937
|
}
|
|
6866
6938
|
}
|
|
6867
6939
|
|
|
6868
|
-
return
|
|
6940
|
+
return initState;
|
|
6869
6941
|
}, []);
|
|
6870
6942
|
|
|
6871
6943
|
var _useState2 = React.useState((_initialState$current = initialState == null ? void 0 : initialState.currentEditingCell) != null ? _initialState$current : null),
|
|
@@ -6892,27 +6964,19 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
6892
6964
|
showGlobalFilter = _useState7[0],
|
|
6893
6965
|
setShowGlobalFilter = _useState7[1];
|
|
6894
6966
|
|
|
6895
|
-
var _useState8 = React.useState({
|
|
6896
|
-
pageIndex: (_initialState$paginat = initialState == null ? void 0 : (_initialState$paginat2 = initialState.pagination) == null ? void 0 : _initialState$paginat2.pageIndex) != null ? _initialState$paginat : 0,
|
|
6897
|
-
pageSize: (_initialState$paginat3 = initialState == null ? void 0 : (_initialState$paginat4 = initialState.pagination) == null ? void 0 : _initialState$paginat4.pageSize) != null ? _initialState$paginat3 : 10,
|
|
6898
|
-
pageCount: initialState == null ? void 0 : (_initialState$paginat5 = initialState.pagination) == null ? void 0 : _initialState$paginat5.pageCount
|
|
6899
|
-
}),
|
|
6900
|
-
pagination = _useState8[0],
|
|
6901
|
-
setPagination = _useState8[1];
|
|
6902
|
-
|
|
6903
|
-
var _useState9 = React.useState(function () {
|
|
6967
|
+
var _useState8 = React.useState(function () {
|
|
6904
6968
|
return Object.assign.apply(Object, [{}].concat(getAllLeafColumnDefs(props.columns).map(function (c) {
|
|
6905
6969
|
var _ref, _c$filterFn, _initialState$current3, _c$filterSelectOption, _ref2;
|
|
6906
6970
|
|
|
6907
6971
|
return _ref2 = {}, _ref2[c.id] = (_ref = (_c$filterFn = c.filterFn) != null ? _c$filterFn : initialState == null ? void 0 : (_initialState$current3 = initialState.currentFilterFns) == null ? void 0 : _initialState$current3[c.id]) != null ? _ref : !!((_c$filterSelectOption = c.filterSelectOptions) != null && _c$filterSelectOption.length) ? MRT_FILTER_OPTION.EQUALS : MRT_FILTER_OPTION.FUZZY, _ref2;
|
|
6908
6972
|
})));
|
|
6909
6973
|
}),
|
|
6910
|
-
currentFilterFns =
|
|
6911
|
-
setCurrentFilterFns =
|
|
6974
|
+
currentFilterFns = _useState8[0],
|
|
6975
|
+
setCurrentFilterFns = _useState8[1];
|
|
6912
6976
|
|
|
6913
|
-
var
|
|
6914
|
-
currentGlobalFilterFn =
|
|
6915
|
-
setCurrentGlobalFilterFn =
|
|
6977
|
+
var _useState9 = React.useState((_props$globalFilterFn = props.globalFilterFn) != null ? _props$globalFilterFn : MRT_FILTER_OPTION.FUZZY),
|
|
6978
|
+
currentGlobalFilterFn = _useState9[0],
|
|
6979
|
+
setCurrentGlobalFilterFn = _useState9[1];
|
|
6916
6980
|
|
|
6917
6981
|
var table = React.useMemo(function () {
|
|
6918
6982
|
return reactTable.createTable();
|
|
@@ -6920,7 +6984,7 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
6920
6984
|
var displayColumns = React.useMemo(function () {
|
|
6921
6985
|
var _props$localization, _props$localization2, _props$localization3, _props$localization5;
|
|
6922
6986
|
|
|
6923
|
-
return [
|
|
6987
|
+
return [showActionColumn && createDisplayColumn(table, {
|
|
6924
6988
|
Cell: function Cell(_ref3) {
|
|
6925
6989
|
var cell = _ref3.cell;
|
|
6926
6990
|
return React__default.createElement(MRT_ToggleRowActionMenuButton, {
|
|
@@ -6931,7 +6995,7 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
6931
6995
|
header: (_props$localization = props.localization) == null ? void 0 : _props$localization.actions,
|
|
6932
6996
|
id: 'mrt-row-actions',
|
|
6933
6997
|
size: 60
|
|
6934
|
-
}),
|
|
6998
|
+
}), showExpandColumn && createDisplayColumn(table, {
|
|
6935
6999
|
Cell: function Cell(_ref4) {
|
|
6936
7000
|
var cell = _ref4.cell;
|
|
6937
7001
|
return React__default.createElement(MRT_ExpandButton, {
|
|
@@ -6994,18 +7058,7 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
6994
7058
|
return _ref7 = {}, _ref7[c.id] = null, _ref7;
|
|
6995
7059
|
})));
|
|
6996
7060
|
}) : props.data;
|
|
6997
|
-
}, [props.data, (_props$state3 = props.state) == null ? void 0 : _props$state3.isLoading, (_props$state4 = props.state) == null ? void 0 : _props$state4.showSkeletons]);
|
|
6998
|
-
|
|
6999
|
-
var _useState11 = React.useState(function () {
|
|
7000
|
-
var _initialState$columnO;
|
|
7001
|
-
|
|
7002
|
-
return ((_initialState$columnO = initialState == null ? void 0 : initialState.columnOrder) != null ? _initialState$columnO : props.enableColumnOrdering) ? getAllLeafColumnDefs(columns).map(function (c) {
|
|
7003
|
-
return c.id;
|
|
7004
|
-
}) : [];
|
|
7005
|
-
}),
|
|
7006
|
-
columnOrder = _useState11[0],
|
|
7007
|
-
setColumnOrder = _useState11[1]; //@ts-ignore
|
|
7008
|
-
|
|
7061
|
+
}, [props.data, (_props$state3 = props.state) == null ? void 0 : _props$state3.isLoading, (_props$state4 = props.state) == null ? void 0 : _props$state4.showSkeletons]); //@ts-ignore
|
|
7009
7062
|
|
|
7010
7063
|
var tableInstance = _extends({}, reactTable.useTableInstance(table, _extends({
|
|
7011
7064
|
filterFns: defaultFilterFNs,
|
|
@@ -7020,13 +7073,7 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
7020
7073
|
return row == null ? void 0 : row.subRows;
|
|
7021
7074
|
},
|
|
7022
7075
|
//@ts-ignore
|
|
7023
|
-
globalFilterFn: currentGlobalFilterFn
|
|
7024
|
-
onColumnOrderChange: setColumnOrder,
|
|
7025
|
-
onPaginationChange: function onPaginationChange(updater) {
|
|
7026
|
-
return setPagination(function (old) {
|
|
7027
|
-
return reactTable.functionalUpdate(updater, old);
|
|
7028
|
-
});
|
|
7029
|
-
}
|
|
7076
|
+
globalFilterFn: currentGlobalFilterFn
|
|
7030
7077
|
}, props, {
|
|
7031
7078
|
//@ts-ignore
|
|
7032
7079
|
columns: columns,
|
|
@@ -7034,15 +7081,12 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
7034
7081
|
idPrefix: idPrefix,
|
|
7035
7082
|
initialState: initialState,
|
|
7036
7083
|
state: _extends({
|
|
7037
|
-
columnOrder: columnOrder,
|
|
7038
7084
|
currentEditingCell: currentEditingCell,
|
|
7039
7085
|
currentEditingRow: currentEditingRow,
|
|
7040
7086
|
currentFilterFns: currentFilterFns,
|
|
7041
7087
|
currentGlobalFilterFn: currentGlobalFilterFn,
|
|
7042
7088
|
isDensePadding: isDensePadding,
|
|
7043
7089
|
isFullScreen: isFullScreen,
|
|
7044
|
-
//@ts-ignore
|
|
7045
|
-
pagination: pagination,
|
|
7046
7090
|
showFilters: showFilters,
|
|
7047
7091
|
showGlobalFilter: showGlobalFilter
|
|
7048
7092
|
}, props.state)
|