material-react-table 0.8.11 → 0.8.14
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 +7 -5
- package/dist/buttons/MRT_GrabHandleButton.d.ts +8 -0
- package/dist/localization.d.ts +1 -0
- package/dist/material-react-table.cjs.development.js +2087 -2033
- 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 +233 -179
- 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 +12 -12
- package/src/MaterialReactTable.tsx +8 -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/inputs/MRT_SelectCheckbox.tsx +6 -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 +49 -41
- 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,1784 +496,1074 @@ 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
|
}
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
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
|
+
}
|
|
1377
1087
|
}
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
* Reads the state tree managed by the store.
|
|
1381
|
-
*
|
|
1382
|
-
* @returns {any} The current state tree of your application.
|
|
1383
|
-
*/
|
|
1384
|
-
|
|
1088
|
+
return sourceId;
|
|
1089
|
+
}
|
|
1385
1090
|
|
|
1386
|
-
|
|
1387
|
-
if (
|
|
1388
|
-
|
|
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;
|
|
1389
1101
|
}
|
|
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
|
+
});
|
|
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
|
-
*/
|
|
1250
|
+
}
|
|
1471
1251
|
|
|
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
|
+
}
|
|
1472
1261
|
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1262
|
+
class DragDropManagerImpl {
|
|
1263
|
+
receiveBackend(backend) {
|
|
1264
|
+
this.backend = backend;
|
|
1476
1265
|
}
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
throw new Error( 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
|
|
1266
|
+
getMonitor() {
|
|
1267
|
+
return this.monitor;
|
|
1480
1268
|
}
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
throw new Error( 'Reducers may not dispatch actions.');
|
|
1269
|
+
getBackend() {
|
|
1270
|
+
return this.backend;
|
|
1484
1271
|
}
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
isDispatching = true;
|
|
1488
|
-
currentState = currentReducer(currentState, action);
|
|
1489
|
-
} finally {
|
|
1490
|
-
isDispatching = false;
|
|
1272
|
+
getRegistry() {
|
|
1273
|
+
return this.monitor.registry;
|
|
1491
1274
|
}
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
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
|
+
};
|
|
1285
|
+
}
|
|
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
|
+
}, {});
|
|
1498
1292
|
}
|
|
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));
|
|
1293
|
+
dispatch(action) {
|
|
1294
|
+
this.store.dispatch(action);
|
|
1517
1295
|
}
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
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
|
-
}
|
|
1558
|
-
}
|
|
1559
|
-
|
|
1560
|
-
observeState();
|
|
1561
|
-
var unsubscribe = outerSubscribe(observeState);
|
|
1562
|
-
return {
|
|
1563
|
-
unsubscribe: unsubscribe
|
|
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
|
}
|
|
1348
|
+
return subtract(add(clientOffset, initialSourceClientOffset), initialClientOffset);
|
|
1649
1349
|
}
|
|
1650
|
-
|
|
1651
|
-
|
|
1350
|
+
/**
|
|
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);
|
|
1652
1360
|
}
|
|
1653
1361
|
|
|
1654
|
-
|
|
1362
|
+
const NONE = [];
|
|
1363
|
+
const ALL = [];
|
|
1364
|
+
NONE.__IS_NONE__ = true;
|
|
1365
|
+
ALL.__IS_ALL__ = true;
|
|
1655
1366
|
/**
|
|
1656
|
-
*
|
|
1657
|
-
*
|
|
1658
|
-
* @param
|
|
1659
|
-
* @param
|
|
1660
|
-
*/ function
|
|
1661
|
-
|
|
1662
|
-
|
|
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;
|
|
1663
1380
|
}
|
|
1664
|
-
/**
|
|
1665
|
-
* drop-in replacement for _.without
|
|
1666
|
-
*/ function without(items, item) {
|
|
1667
|
-
return items.filter((i)=>i !== item
|
|
1668
|
-
);
|
|
1669
|
-
}
|
|
1670
|
-
/**
|
|
1671
|
-
* drop-in replacement for _.isString
|
|
1672
|
-
* @param input
|
|
1673
|
-
*/ function isObject(input) {
|
|
1674
|
-
return typeof input === 'object';
|
|
1675
|
-
}
|
|
1676
|
-
/**
|
|
1677
|
-
* replacement for _.xor
|
|
1678
|
-
* @param itemsA
|
|
1679
|
-
* @param itemsB
|
|
1680
|
-
*/ function xor(itemsA, itemsB) {
|
|
1681
|
-
const map = new Map();
|
|
1682
|
-
const insertItem = (item)=>{
|
|
1683
|
-
map.set(item, map.has(item) ? map.get(item) + 1 : 1);
|
|
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
|
-
);
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
|
-
const INIT_COORDS = 'dnd-core/INIT_COORDS';
|
|
1705
|
-
const BEGIN_DRAG = 'dnd-core/BEGIN_DRAG';
|
|
1706
|
-
const PUBLISH_DRAG_SOURCE = 'dnd-core/PUBLISH_DRAG_SOURCE';
|
|
1707
|
-
const HOVER = 'dnd-core/HOVER';
|
|
1708
|
-
const DROP = 'dnd-core/DROP';
|
|
1709
|
-
const END_DRAG = 'dnd-core/END_DRAG';
|
|
1710
1381
|
|
|
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
|
-
|
|
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
|
+
}
|
|
2033
1553
|
};
|
|
2034
1554
|
}
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
};
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
* at the time when the current drag operation has started, and the movement difference.
|
|
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
|
-
}
|
|
2262
|
-
};
|
|
2263
|
-
}
|
|
2264
|
-
// To request a high priority event, we induce a mutation observer by toggling
|
|
2265
|
-
// the text of a text node between "1" and "-1".
|
|
2266
|
-
function makeRequestCallFromMutationObserver(callback) {
|
|
2267
|
-
let toggle = 1;
|
|
2268
|
-
const observer = new BrowserMutationObserver(callback);
|
|
2269
|
-
const node = document.createTextNode('');
|
|
2270
|
-
observer.observe(node, {
|
|
2271
|
-
characterData: true
|
|
2272
|
-
});
|
|
2273
|
-
return function requestCall() {
|
|
2274
|
-
toggle = -toggle;
|
|
2275
|
-
node.data = toggle;
|
|
1555
|
+
// To request a high priority event, we induce a mutation observer by toggling
|
|
1556
|
+
// the text of a text node between "1" and "-1".
|
|
1557
|
+
function makeRequestCallFromMutationObserver(callback) {
|
|
1558
|
+
let toggle = 1;
|
|
1559
|
+
const observer = new BrowserMutationObserver(callback);
|
|
1560
|
+
const node = document.createTextNode('');
|
|
1561
|
+
observer.observe(node, {
|
|
1562
|
+
characterData: true
|
|
1563
|
+
});
|
|
1564
|
+
return function requestCall() {
|
|
1565
|
+
toggle = -toggle;
|
|
1566
|
+
node.data = toggle;
|
|
2276
1567
|
};
|
|
2277
1568
|
}
|
|
2278
1569
|
const makeRequestCall = typeof BrowserMutationObserver === 'function' ? // reliably everywhere they are implemented.
|
|
@@ -3704,282 +2995,1085 @@ class TargetConnector {
|
|
|
3704
2995
|
this.lastConnectedDropTargetOptions = null;
|
|
3705
2996
|
this.backend = backend;
|
|
3706
2997
|
}
|
|
3707
|
-
}
|
|
2998
|
+
}
|
|
2999
|
+
|
|
3000
|
+
/**
|
|
3001
|
+
* A hook to retrieve the DragDropManager from Context
|
|
3002
|
+
*/ function useDragDropManager() {
|
|
3003
|
+
const { dragDropManager } = React.useContext(DndContext);
|
|
3004
|
+
invariant(dragDropManager != null, 'Expected drag drop context');
|
|
3005
|
+
return dragDropManager;
|
|
3006
|
+
}
|
|
3007
|
+
|
|
3008
|
+
function useDragSourceConnector(dragSourceOptions, dragPreviewOptions) {
|
|
3009
|
+
const manager = useDragDropManager();
|
|
3010
|
+
const connector = React.useMemo(()=>new SourceConnector(manager.getBackend())
|
|
3011
|
+
, [
|
|
3012
|
+
manager
|
|
3013
|
+
]);
|
|
3014
|
+
useIsomorphicLayoutEffect(()=>{
|
|
3015
|
+
connector.dragSourceOptions = dragSourceOptions || null;
|
|
3016
|
+
connector.reconnect();
|
|
3017
|
+
return ()=>connector.disconnectDragSource()
|
|
3018
|
+
;
|
|
3019
|
+
}, [
|
|
3020
|
+
connector,
|
|
3021
|
+
dragSourceOptions
|
|
3022
|
+
]);
|
|
3023
|
+
useIsomorphicLayoutEffect(()=>{
|
|
3024
|
+
connector.dragPreviewOptions = dragPreviewOptions || null;
|
|
3025
|
+
connector.reconnect();
|
|
3026
|
+
return ()=>connector.disconnectDragPreview()
|
|
3027
|
+
;
|
|
3028
|
+
}, [
|
|
3029
|
+
connector,
|
|
3030
|
+
dragPreviewOptions
|
|
3031
|
+
]);
|
|
3032
|
+
return connector;
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
function useDragSourceMonitor() {
|
|
3036
|
+
const manager = useDragDropManager();
|
|
3037
|
+
return React.useMemo(()=>new DragSourceMonitorImpl(manager)
|
|
3038
|
+
, [
|
|
3039
|
+
manager
|
|
3040
|
+
]);
|
|
3041
|
+
}
|
|
3042
|
+
|
|
3043
|
+
class DragSourceImpl {
|
|
3044
|
+
beginDrag() {
|
|
3045
|
+
const spec = this.spec;
|
|
3046
|
+
const monitor = this.monitor;
|
|
3047
|
+
let result = null;
|
|
3048
|
+
if (typeof spec.item === 'object') {
|
|
3049
|
+
result = spec.item;
|
|
3050
|
+
} else if (typeof spec.item === 'function') {
|
|
3051
|
+
result = spec.item(monitor);
|
|
3052
|
+
} else {
|
|
3053
|
+
result = {};
|
|
3054
|
+
}
|
|
3055
|
+
return result !== null && result !== void 0 ? result : null;
|
|
3056
|
+
}
|
|
3057
|
+
canDrag() {
|
|
3058
|
+
const spec = this.spec;
|
|
3059
|
+
const monitor = this.monitor;
|
|
3060
|
+
if (typeof spec.canDrag === 'boolean') {
|
|
3061
|
+
return spec.canDrag;
|
|
3062
|
+
} else if (typeof spec.canDrag === 'function') {
|
|
3063
|
+
return spec.canDrag(monitor);
|
|
3064
|
+
} else {
|
|
3065
|
+
return true;
|
|
3066
|
+
}
|
|
3067
|
+
}
|
|
3068
|
+
isDragging(globalMonitor, target) {
|
|
3069
|
+
const spec = this.spec;
|
|
3070
|
+
const monitor = this.monitor;
|
|
3071
|
+
const { isDragging } = spec;
|
|
3072
|
+
return isDragging ? isDragging(monitor) : target === globalMonitor.getSourceId();
|
|
3073
|
+
}
|
|
3074
|
+
endDrag() {
|
|
3075
|
+
const spec = this.spec;
|
|
3076
|
+
const monitor = this.monitor;
|
|
3077
|
+
const connector = this.connector;
|
|
3078
|
+
const { end } = spec;
|
|
3079
|
+
if (end) {
|
|
3080
|
+
end(monitor.getItem(), monitor);
|
|
3081
|
+
}
|
|
3082
|
+
connector.reconnect();
|
|
3083
|
+
}
|
|
3084
|
+
constructor(spec, monitor, connector){
|
|
3085
|
+
this.spec = spec;
|
|
3086
|
+
this.monitor = monitor;
|
|
3087
|
+
this.connector = connector;
|
|
3088
|
+
}
|
|
3089
|
+
}
|
|
3090
|
+
|
|
3091
|
+
function useDragSource(spec, monitor, connector) {
|
|
3092
|
+
const handler = React.useMemo(()=>new DragSourceImpl(spec, monitor, connector)
|
|
3093
|
+
, [
|
|
3094
|
+
monitor,
|
|
3095
|
+
connector
|
|
3096
|
+
]);
|
|
3097
|
+
React.useEffect(()=>{
|
|
3098
|
+
handler.spec = spec;
|
|
3099
|
+
}, [
|
|
3100
|
+
spec
|
|
3101
|
+
]);
|
|
3102
|
+
return handler;
|
|
3103
|
+
}
|
|
3104
|
+
|
|
3105
|
+
function useDragType(spec) {
|
|
3106
|
+
return React.useMemo(()=>{
|
|
3107
|
+
const result = spec.type;
|
|
3108
|
+
invariant(result != null, 'spec.type must be defined');
|
|
3109
|
+
return result;
|
|
3110
|
+
}, [
|
|
3111
|
+
spec
|
|
3112
|
+
]);
|
|
3113
|
+
}
|
|
3114
|
+
|
|
3115
|
+
function useRegisteredDragSource(spec, monitor, connector) {
|
|
3116
|
+
const manager = useDragDropManager();
|
|
3117
|
+
const handler = useDragSource(spec, monitor, connector);
|
|
3118
|
+
const itemType = useDragType(spec);
|
|
3119
|
+
useIsomorphicLayoutEffect(function registerDragSource() {
|
|
3120
|
+
if (itemType != null) {
|
|
3121
|
+
const [handlerId, unregister] = registerSource(itemType, handler, manager);
|
|
3122
|
+
monitor.receiveHandlerId(handlerId);
|
|
3123
|
+
connector.receiveHandlerId(handlerId);
|
|
3124
|
+
return unregister;
|
|
3125
|
+
}
|
|
3126
|
+
return;
|
|
3127
|
+
}, [
|
|
3128
|
+
manager,
|
|
3129
|
+
monitor,
|
|
3130
|
+
connector,
|
|
3131
|
+
handler,
|
|
3132
|
+
itemType
|
|
3133
|
+
]);
|
|
3134
|
+
}
|
|
3135
|
+
|
|
3136
|
+
/**
|
|
3137
|
+
* useDragSource hook
|
|
3138
|
+
* @param sourceSpec The drag source specification (object or function, function preferred)
|
|
3139
|
+
* @param deps The memoization deps array to use when evaluating spec changes
|
|
3140
|
+
*/ function useDrag(specArg, deps) {
|
|
3141
|
+
const spec = useOptionalFactory(specArg, deps);
|
|
3142
|
+
invariant(!spec.begin, `useDrag::spec.begin was deprecated in v14. Replace spec.begin() with spec.item(). (see more here - https://react-dnd.github.io/react-dnd/docs/api/use-drag)`);
|
|
3143
|
+
const monitor = useDragSourceMonitor();
|
|
3144
|
+
const connector = useDragSourceConnector(spec.options, spec.previewOptions);
|
|
3145
|
+
useRegisteredDragSource(spec, monitor, connector);
|
|
3146
|
+
return [
|
|
3147
|
+
useCollectedProps(spec.collect, monitor, connector),
|
|
3148
|
+
useConnectDragSource(connector),
|
|
3149
|
+
useConnectDragPreview(connector),
|
|
3150
|
+
];
|
|
3151
|
+
}
|
|
3152
|
+
|
|
3153
|
+
function useConnectDropTarget(connector) {
|
|
3154
|
+
return React.useMemo(()=>connector.hooks.dropTarget()
|
|
3155
|
+
, [
|
|
3156
|
+
connector
|
|
3157
|
+
]);
|
|
3158
|
+
}
|
|
3159
|
+
|
|
3160
|
+
function useDropTargetConnector(options) {
|
|
3161
|
+
const manager = useDragDropManager();
|
|
3162
|
+
const connector = React.useMemo(()=>new TargetConnector(manager.getBackend())
|
|
3163
|
+
, [
|
|
3164
|
+
manager
|
|
3165
|
+
]);
|
|
3166
|
+
useIsomorphicLayoutEffect(()=>{
|
|
3167
|
+
connector.dropTargetOptions = options || null;
|
|
3168
|
+
connector.reconnect();
|
|
3169
|
+
return ()=>connector.disconnectDropTarget()
|
|
3170
|
+
;
|
|
3171
|
+
}, [
|
|
3172
|
+
options
|
|
3173
|
+
]);
|
|
3174
|
+
return connector;
|
|
3175
|
+
}
|
|
3176
|
+
|
|
3177
|
+
function useDropTargetMonitor() {
|
|
3178
|
+
const manager = useDragDropManager();
|
|
3179
|
+
return React.useMemo(()=>new DropTargetMonitorImpl(manager)
|
|
3180
|
+
, [
|
|
3181
|
+
manager
|
|
3182
|
+
]);
|
|
3183
|
+
}
|
|
3184
|
+
|
|
3185
|
+
/**
|
|
3186
|
+
* Internal utility hook to get an array-version of spec.accept.
|
|
3187
|
+
* The main utility here is that we aren't creating a new array on every render if a non-array spec.accept is passed in.
|
|
3188
|
+
* @param spec
|
|
3189
|
+
*/ function useAccept(spec) {
|
|
3190
|
+
const { accept } = spec;
|
|
3191
|
+
return React.useMemo(()=>{
|
|
3192
|
+
invariant(spec.accept != null, 'accept must be defined');
|
|
3193
|
+
return Array.isArray(accept) ? accept : [
|
|
3194
|
+
accept
|
|
3195
|
+
];
|
|
3196
|
+
}, [
|
|
3197
|
+
accept
|
|
3198
|
+
]);
|
|
3199
|
+
}
|
|
3200
|
+
|
|
3201
|
+
class DropTargetImpl {
|
|
3202
|
+
canDrop() {
|
|
3203
|
+
const spec = this.spec;
|
|
3204
|
+
const monitor = this.monitor;
|
|
3205
|
+
return spec.canDrop ? spec.canDrop(monitor.getItem(), monitor) : true;
|
|
3206
|
+
}
|
|
3207
|
+
hover() {
|
|
3208
|
+
const spec = this.spec;
|
|
3209
|
+
const monitor = this.monitor;
|
|
3210
|
+
if (spec.hover) {
|
|
3211
|
+
spec.hover(monitor.getItem(), monitor);
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
drop() {
|
|
3215
|
+
const spec = this.spec;
|
|
3216
|
+
const monitor = this.monitor;
|
|
3217
|
+
if (spec.drop) {
|
|
3218
|
+
return spec.drop(monitor.getItem(), monitor);
|
|
3219
|
+
}
|
|
3220
|
+
return;
|
|
3221
|
+
}
|
|
3222
|
+
constructor(spec, monitor){
|
|
3223
|
+
this.spec = spec;
|
|
3224
|
+
this.monitor = monitor;
|
|
3225
|
+
}
|
|
3226
|
+
}
|
|
3227
|
+
|
|
3228
|
+
function useDropTarget(spec, monitor) {
|
|
3229
|
+
const dropTarget = React.useMemo(()=>new DropTargetImpl(spec, monitor)
|
|
3230
|
+
, [
|
|
3231
|
+
monitor
|
|
3232
|
+
]);
|
|
3233
|
+
React.useEffect(()=>{
|
|
3234
|
+
dropTarget.spec = spec;
|
|
3235
|
+
}, [
|
|
3236
|
+
spec
|
|
3237
|
+
]);
|
|
3238
|
+
return dropTarget;
|
|
3239
|
+
}
|
|
3240
|
+
|
|
3241
|
+
function useRegisteredDropTarget(spec, monitor, connector) {
|
|
3242
|
+
const manager = useDragDropManager();
|
|
3243
|
+
const dropTarget = useDropTarget(spec, monitor);
|
|
3244
|
+
const accept = useAccept(spec);
|
|
3245
|
+
useIsomorphicLayoutEffect(function registerDropTarget() {
|
|
3246
|
+
const [handlerId, unregister] = registerTarget(accept, dropTarget, manager);
|
|
3247
|
+
monitor.receiveHandlerId(handlerId);
|
|
3248
|
+
connector.receiveHandlerId(handlerId);
|
|
3249
|
+
return unregister;
|
|
3250
|
+
}, [
|
|
3251
|
+
manager,
|
|
3252
|
+
monitor,
|
|
3253
|
+
dropTarget,
|
|
3254
|
+
connector,
|
|
3255
|
+
accept.map((a)=>a.toString()
|
|
3256
|
+
).join('|'),
|
|
3257
|
+
]);
|
|
3258
|
+
}
|
|
3259
|
+
|
|
3260
|
+
/**
|
|
3261
|
+
* useDropTarget Hook
|
|
3262
|
+
* @param spec The drop target specification (object or function, function preferred)
|
|
3263
|
+
* @param deps The memoization deps array to use when evaluating spec changes
|
|
3264
|
+
*/ function useDrop(specArg, deps) {
|
|
3265
|
+
const spec = useOptionalFactory(specArg, deps);
|
|
3266
|
+
const monitor = useDropTargetMonitor();
|
|
3267
|
+
const connector = useDropTargetConnector(spec.options);
|
|
3268
|
+
useRegisteredDropTarget(spec, monitor, connector);
|
|
3269
|
+
return [
|
|
3270
|
+
useCollectedProps(spec.collect, monitor, connector),
|
|
3271
|
+
useConnectDropTarget(connector),
|
|
3272
|
+
];
|
|
3273
|
+
}
|
|
3274
|
+
|
|
3275
|
+
var MRT_ColumnPinningButtons = function MRT_ColumnPinningButtons(_ref) {
|
|
3276
|
+
var column = _ref.column,
|
|
3277
|
+
tableInstance = _ref.tableInstance;
|
|
3278
|
+
var _tableInstance$option = tableInstance.options,
|
|
3279
|
+
PushPinIcon = _tableInstance$option.icons.PushPinIcon,
|
|
3280
|
+
localization = _tableInstance$option.localization;
|
|
3281
|
+
|
|
3282
|
+
var handlePinColumn = function handlePinColumn(pinDirection) {
|
|
3283
|
+
column.pin(pinDirection);
|
|
3284
|
+
};
|
|
3285
|
+
|
|
3286
|
+
return React__default.createElement(material.Box, {
|
|
3287
|
+
sx: {
|
|
3288
|
+
mr: '4px'
|
|
3289
|
+
}
|
|
3290
|
+
}, column.getIsPinned() ? React__default.createElement(material.Tooltip, {
|
|
3291
|
+
arrow: true,
|
|
3292
|
+
title: localization.unpin
|
|
3293
|
+
}, React__default.createElement(material.IconButton, {
|
|
3294
|
+
onClick: function onClick() {
|
|
3295
|
+
return handlePinColumn(false);
|
|
3296
|
+
},
|
|
3297
|
+
size: "small"
|
|
3298
|
+
}, React__default.createElement(PushPinIcon, null))) : React__default.createElement(React__default.Fragment, null, React__default.createElement(material.Tooltip, {
|
|
3299
|
+
arrow: true,
|
|
3300
|
+
title: localization.pinToLeft
|
|
3301
|
+
}, React__default.createElement(material.IconButton, {
|
|
3302
|
+
onClick: function onClick() {
|
|
3303
|
+
return handlePinColumn('left');
|
|
3304
|
+
},
|
|
3305
|
+
size: "small"
|
|
3306
|
+
}, React__default.createElement(PushPinIcon, {
|
|
3307
|
+
style: {
|
|
3308
|
+
transform: 'rotate(90deg)'
|
|
3309
|
+
}
|
|
3310
|
+
}))), React__default.createElement(material.Tooltip, {
|
|
3311
|
+
arrow: true,
|
|
3312
|
+
title: localization.pinToRight
|
|
3313
|
+
}, React__default.createElement(material.IconButton, {
|
|
3314
|
+
onClick: function onClick() {
|
|
3315
|
+
return handlePinColumn('right');
|
|
3316
|
+
},
|
|
3317
|
+
size: "small"
|
|
3318
|
+
}, React__default.createElement(PushPinIcon, {
|
|
3319
|
+
style: {
|
|
3320
|
+
transform: 'rotate(-90deg)'
|
|
3321
|
+
}
|
|
3322
|
+
})))));
|
|
3323
|
+
};
|
|
3324
|
+
|
|
3325
|
+
var MRT_GrabHandleButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
3326
|
+
var tableInstance = _ref.tableInstance;
|
|
3327
|
+
var _tableInstance$option = tableInstance.options,
|
|
3328
|
+
DragHandleIcon = _tableInstance$option.icons.DragHandleIcon,
|
|
3329
|
+
localization = _tableInstance$option.localization;
|
|
3330
|
+
return React__default.createElement(material.Tooltip, {
|
|
3331
|
+
arrow: true,
|
|
3332
|
+
enterDelay: 1000,
|
|
3333
|
+
enterNextDelay: 1000,
|
|
3334
|
+
placement: "top",
|
|
3335
|
+
title: localization.grab
|
|
3336
|
+
}, React__default.createElement(material.IconButton, {
|
|
3337
|
+
disableRipple: true,
|
|
3338
|
+
ref: ref,
|
|
3339
|
+
size: "small",
|
|
3340
|
+
sx: {
|
|
3341
|
+
cursor: 'grab',
|
|
3342
|
+
m: 0,
|
|
3343
|
+
opacity: 0.5,
|
|
3344
|
+
p: '2px',
|
|
3345
|
+
transition: 'all 0.2s ease-in-out',
|
|
3346
|
+
'&:hover': {
|
|
3347
|
+
backgroundColor: 'transparent',
|
|
3348
|
+
opacity: 1
|
|
3349
|
+
},
|
|
3350
|
+
'&:active': {
|
|
3351
|
+
cursor: 'grabbing'
|
|
3352
|
+
}
|
|
3353
|
+
}
|
|
3354
|
+
}, React__default.createElement(DragHandleIcon, null)));
|
|
3355
|
+
});
|
|
3356
|
+
|
|
3357
|
+
var MRT_ShowHideColumnsMenuItems = function MRT_ShowHideColumnsMenuItems(_ref) {
|
|
3358
|
+
var _column$columns2;
|
|
3359
|
+
|
|
3360
|
+
var allColumns = _ref.allColumns,
|
|
3361
|
+
column = _ref.column,
|
|
3362
|
+
isSubMenu = _ref.isSubMenu,
|
|
3363
|
+
tableInstance = _ref.tableInstance;
|
|
3364
|
+
var getState = tableInstance.getState,
|
|
3365
|
+
_tableInstance$option = tableInstance.options,
|
|
3366
|
+
enableColumnOrdering = _tableInstance$option.enableColumnOrdering,
|
|
3367
|
+
onToggleColumnVisibility = _tableInstance$option.onToggleColumnVisibility,
|
|
3368
|
+
setColumnOrder = tableInstance.setColumnOrder;
|
|
3369
|
+
|
|
3370
|
+
var _getState = getState(),
|
|
3371
|
+
columnOrder = _getState.columnOrder,
|
|
3372
|
+
columnVisibility = _getState.columnVisibility;
|
|
3373
|
+
|
|
3374
|
+
var columnDef = column.columnDef,
|
|
3375
|
+
columnDefType = column.columnDefType;
|
|
3376
|
+
|
|
3377
|
+
var reorder = function reorder(movingColumn, receivingColumn) {
|
|
3378
|
+
if (movingColumn.getCanPin()) {
|
|
3379
|
+
movingColumn.pin(receivingColumn.getIsPinned());
|
|
3380
|
+
}
|
|
3381
|
+
|
|
3382
|
+
columnOrder.splice(columnOrder.indexOf(receivingColumn.id), 0, columnOrder.splice(columnOrder.indexOf(movingColumn.id), 1)[0]);
|
|
3383
|
+
setColumnOrder([].concat(columnOrder));
|
|
3384
|
+
};
|
|
3385
|
+
|
|
3386
|
+
var _useDrop = useDrop({
|
|
3387
|
+
accept: 'column',
|
|
3388
|
+
drop: function drop(movingColumn) {
|
|
3389
|
+
return reorder(movingColumn, column);
|
|
3390
|
+
}
|
|
3391
|
+
}),
|
|
3392
|
+
dropRef = _useDrop[1];
|
|
3393
|
+
|
|
3394
|
+
var _useDrag = useDrag({
|
|
3395
|
+
collect: function collect(monitor) {
|
|
3396
|
+
return {
|
|
3397
|
+
isDragging: monitor.isDragging()
|
|
3398
|
+
};
|
|
3399
|
+
},
|
|
3400
|
+
item: function item() {
|
|
3401
|
+
return column;
|
|
3402
|
+
},
|
|
3403
|
+
type: 'column'
|
|
3404
|
+
}),
|
|
3405
|
+
dragRef = _useDrag[1],
|
|
3406
|
+
previewRef = _useDrag[2];
|
|
3407
|
+
|
|
3408
|
+
var switchChecked = columnDefType !== 'group' && column.getIsVisible() || columnDefType === 'group' && column.getLeafColumns().some(function (col) {
|
|
3409
|
+
return col.getIsVisible();
|
|
3410
|
+
});
|
|
3411
|
+
|
|
3412
|
+
var handleToggleColumnHidden = function handleToggleColumnHidden(column) {
|
|
3413
|
+
if (columnDefType === 'group') {
|
|
3414
|
+
var _column$columns;
|
|
3415
|
+
|
|
3416
|
+
column == null ? void 0 : (_column$columns = column.columns) == null ? void 0 : _column$columns.forEach == null ? void 0 : _column$columns.forEach(function (childColumn) {
|
|
3417
|
+
childColumn.toggleVisibility(!switchChecked);
|
|
3418
|
+
});
|
|
3419
|
+
} else {
|
|
3420
|
+
column.toggleVisibility();
|
|
3421
|
+
}
|
|
3422
|
+
|
|
3423
|
+
onToggleColumnVisibility == null ? void 0 : onToggleColumnVisibility({
|
|
3424
|
+
column: column,
|
|
3425
|
+
columnVisibility: columnVisibility,
|
|
3426
|
+
tableInstance: tableInstance
|
|
3427
|
+
});
|
|
3428
|
+
};
|
|
3429
|
+
|
|
3430
|
+
return React__default.createElement(React__default.Fragment, null, React__default.createElement(material.MenuItem, {
|
|
3431
|
+
ref: columnDefType === 'data' ? dropRef : undefined,
|
|
3432
|
+
sx: {
|
|
3433
|
+
alignItems: 'center',
|
|
3434
|
+
justifyContent: 'flex-start',
|
|
3435
|
+
my: 0,
|
|
3436
|
+
pl: (column.depth + 0.5) * 2 + "rem",
|
|
3437
|
+
py: '6px'
|
|
3438
|
+
}
|
|
3439
|
+
}, React__default.createElement(material.Box, {
|
|
3440
|
+
ref: previewRef,
|
|
3441
|
+
sx: {
|
|
3442
|
+
display: 'flex',
|
|
3443
|
+
flexWrap: 'nowrap'
|
|
3444
|
+
}
|
|
3445
|
+
}, columnDefType !== 'group' && enableColumnOrdering && columnDef.enableColumnOrdering !== false && !allColumns.some(function (col) {
|
|
3446
|
+
return col.columnDefType === 'group';
|
|
3447
|
+
}) && React__default.createElement(MRT_GrabHandleButton, {
|
|
3448
|
+
ref: dragRef,
|
|
3449
|
+
tableInstance: tableInstance
|
|
3450
|
+
}), !isSubMenu && column.getCanPin() && React__default.createElement(MRT_ColumnPinningButtons, {
|
|
3451
|
+
column: column,
|
|
3452
|
+
tableInstance: tableInstance
|
|
3453
|
+
}), React__default.createElement(material.FormControlLabel, {
|
|
3454
|
+
componentsProps: {
|
|
3455
|
+
typography: {
|
|
3456
|
+
sx: {
|
|
3457
|
+
mb: 0,
|
|
3458
|
+
opacity: columnDefType !== 'display' ? 1 : 0.5
|
|
3459
|
+
}
|
|
3460
|
+
}
|
|
3461
|
+
},
|
|
3462
|
+
checked: switchChecked,
|
|
3463
|
+
control: React__default.createElement(material.Switch, null),
|
|
3464
|
+
disabled: isSubMenu && switchChecked || !column.getCanHide(),
|
|
3465
|
+
label: columnDef.header,
|
|
3466
|
+
onChange: function onChange() {
|
|
3467
|
+
return handleToggleColumnHidden(column);
|
|
3468
|
+
},
|
|
3469
|
+
sx: {
|
|
3470
|
+
ml: '4px'
|
|
3471
|
+
}
|
|
3472
|
+
}))), (_column$columns2 = column.columns) == null ? void 0 : _column$columns2.map(function (c, i) {
|
|
3473
|
+
return React__default.createElement(MRT_ShowHideColumnsMenuItems, {
|
|
3474
|
+
allColumns: allColumns,
|
|
3475
|
+
key: i + "-" + c.id,
|
|
3476
|
+
column: c,
|
|
3477
|
+
isSubMenu: isSubMenu,
|
|
3478
|
+
tableInstance: tableInstance
|
|
3479
|
+
});
|
|
3480
|
+
}));
|
|
3481
|
+
};
|
|
3482
|
+
|
|
3483
|
+
var MRT_ShowHideColumnsMenu = function MRT_ShowHideColumnsMenu(_ref) {
|
|
3484
|
+
var anchorEl = _ref.anchorEl,
|
|
3485
|
+
isSubMenu = _ref.isSubMenu,
|
|
3486
|
+
setAnchorEl = _ref.setAnchorEl,
|
|
3487
|
+
tableInstance = _ref.tableInstance;
|
|
3488
|
+
var getAllColumns = tableInstance.getAllColumns,
|
|
3489
|
+
getAllLeafColumns = tableInstance.getAllLeafColumns,
|
|
3490
|
+
getIsAllColumnsVisible = tableInstance.getIsAllColumnsVisible,
|
|
3491
|
+
getIsSomeColumnsPinned = tableInstance.getIsSomeColumnsPinned,
|
|
3492
|
+
getIsSomeColumnsVisible = tableInstance.getIsSomeColumnsVisible,
|
|
3493
|
+
getState = tableInstance.getState,
|
|
3494
|
+
toggleAllColumnsVisible = tableInstance.toggleAllColumnsVisible,
|
|
3495
|
+
_tableInstance$option = tableInstance.options,
|
|
3496
|
+
localization = _tableInstance$option.localization,
|
|
3497
|
+
enablePinning = _tableInstance$option.enablePinning,
|
|
3498
|
+
enableColumnOrdering = _tableInstance$option.enableColumnOrdering;
|
|
3499
|
+
|
|
3500
|
+
var _getState = getState(),
|
|
3501
|
+
isDensePadding = _getState.isDensePadding,
|
|
3502
|
+
columnOrder = _getState.columnOrder,
|
|
3503
|
+
columnPinning = _getState.columnPinning;
|
|
3504
|
+
|
|
3505
|
+
var hideAllColumns = function hideAllColumns() {
|
|
3506
|
+
getAllLeafColumns().filter(function (col) {
|
|
3507
|
+
return col.columnDef.enableHiding !== false;
|
|
3508
|
+
}).forEach(function (col) {
|
|
3509
|
+
return col.toggleVisibility(false);
|
|
3510
|
+
});
|
|
3511
|
+
};
|
|
3512
|
+
|
|
3513
|
+
var allColumns = React.useMemo(function () {
|
|
3514
|
+
var columns = getAllColumns();
|
|
3515
|
+
|
|
3516
|
+
if (columnOrder.length > 0 && !columns.some(function (col) {
|
|
3517
|
+
return col.columnDefType === 'group';
|
|
3518
|
+
})) {
|
|
3519
|
+
var _columnOrder$map;
|
|
3520
|
+
|
|
3521
|
+
return (_columnOrder$map = columnOrder.map(function (colId) {
|
|
3522
|
+
return columns.find(function (col) {
|
|
3523
|
+
return col.id === colId;
|
|
3524
|
+
});
|
|
3525
|
+
})) != null ? _columnOrder$map : columns;
|
|
3526
|
+
}
|
|
3527
|
+
|
|
3528
|
+
return columns;
|
|
3529
|
+
}, [getAllColumns(), columnOrder, columnPinning]);
|
|
3530
|
+
return React__default.createElement(material.Menu, {
|
|
3531
|
+
anchorEl: anchorEl,
|
|
3532
|
+
open: !!anchorEl,
|
|
3533
|
+
onClose: function onClose() {
|
|
3534
|
+
return setAnchorEl(null);
|
|
3535
|
+
},
|
|
3536
|
+
MenuListProps: {
|
|
3537
|
+
dense: isDensePadding
|
|
3538
|
+
}
|
|
3539
|
+
}, React__default.createElement(material.Box, {
|
|
3540
|
+
sx: {
|
|
3541
|
+
display: 'flex',
|
|
3542
|
+
justifyContent: isSubMenu ? 'center' : 'space-between',
|
|
3543
|
+
p: '0.5rem',
|
|
3544
|
+
pt: 0
|
|
3545
|
+
}
|
|
3546
|
+
}, !isSubMenu && React__default.createElement(material.Button, {
|
|
3547
|
+
disabled: !getIsSomeColumnsVisible(),
|
|
3548
|
+
onClick: hideAllColumns
|
|
3549
|
+
}, localization.hideAll), !isSubMenu && enableColumnOrdering && React__default.createElement(material.Button, {
|
|
3550
|
+
onClick: function onClick() {
|
|
3551
|
+
return tableInstance.resetColumnOrder();
|
|
3552
|
+
}
|
|
3553
|
+
}, localization.resetOrder), !isSubMenu && enablePinning && React__default.createElement(material.Button, {
|
|
3554
|
+
disabled: !getIsSomeColumnsPinned(),
|
|
3555
|
+
onClick: function onClick() {
|
|
3556
|
+
return tableInstance.resetColumnPinning(true);
|
|
3557
|
+
}
|
|
3558
|
+
}, localization.unpinAll), React__default.createElement(material.Button, {
|
|
3559
|
+
disabled: getIsAllColumnsVisible(),
|
|
3560
|
+
onClick: function onClick() {
|
|
3561
|
+
return toggleAllColumnsVisible(true);
|
|
3562
|
+
}
|
|
3563
|
+
}, localization.showAll)), React__default.createElement(material.Divider, null), allColumns.map(function (column, index) {
|
|
3564
|
+
return React__default.createElement(MRT_ShowHideColumnsMenuItems, {
|
|
3565
|
+
allColumns: allColumns,
|
|
3566
|
+
column: column,
|
|
3567
|
+
isSubMenu: isSubMenu,
|
|
3568
|
+
key: index + "-" + column.id,
|
|
3569
|
+
tableInstance: tableInstance
|
|
3570
|
+
});
|
|
3571
|
+
}));
|
|
3572
|
+
};
|
|
3573
|
+
|
|
3574
|
+
var commonMenuItemStyles$1 = {
|
|
3575
|
+
py: '6px',
|
|
3576
|
+
my: 0,
|
|
3577
|
+
justifyContent: 'space-between',
|
|
3578
|
+
alignItems: 'center'
|
|
3579
|
+
};
|
|
3580
|
+
var commonListItemStyles = {
|
|
3581
|
+
display: 'flex',
|
|
3582
|
+
alignItems: 'center'
|
|
3583
|
+
};
|
|
3584
|
+
var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
3585
|
+
var _localization$sortByC, _localization$sortByC2, _localization$filterB, _localization, _localization$hideCol, _localization$showAll;
|
|
3586
|
+
|
|
3587
|
+
var anchorEl = _ref.anchorEl,
|
|
3588
|
+
header = _ref.header,
|
|
3589
|
+
setAnchorEl = _ref.setAnchorEl,
|
|
3590
|
+
tableInstance = _ref.tableInstance;
|
|
3591
|
+
var getState = tableInstance.getState,
|
|
3592
|
+
toggleAllColumnsVisible = tableInstance.toggleAllColumnsVisible,
|
|
3593
|
+
setColumnOrder = tableInstance.setColumnOrder,
|
|
3594
|
+
_tableInstance$option = tableInstance.options,
|
|
3595
|
+
enableColumnFilters = _tableInstance$option.enableColumnFilters,
|
|
3596
|
+
enableColumnResizing = _tableInstance$option.enableColumnResizing,
|
|
3597
|
+
enableGrouping = _tableInstance$option.enableGrouping,
|
|
3598
|
+
enableHiding = _tableInstance$option.enableHiding,
|
|
3599
|
+
enablePinning = _tableInstance$option.enablePinning,
|
|
3600
|
+
enableSorting = _tableInstance$option.enableSorting,
|
|
3601
|
+
_tableInstance$option2 = _tableInstance$option.icons,
|
|
3602
|
+
ArrowRightIcon = _tableInstance$option2.ArrowRightIcon,
|
|
3603
|
+
ClearAllIcon = _tableInstance$option2.ClearAllIcon,
|
|
3604
|
+
ViewColumnIcon = _tableInstance$option2.ViewColumnIcon,
|
|
3605
|
+
DynamicFeedIcon = _tableInstance$option2.DynamicFeedIcon,
|
|
3606
|
+
FilterListIcon = _tableInstance$option2.FilterListIcon,
|
|
3607
|
+
FilterListOffIcon = _tableInstance$option2.FilterListOffIcon,
|
|
3608
|
+
PushPinIcon = _tableInstance$option2.PushPinIcon,
|
|
3609
|
+
SortIcon = _tableInstance$option2.SortIcon,
|
|
3610
|
+
RestartAltIcon = _tableInstance$option2.RestartAltIcon,
|
|
3611
|
+
VisibilityOffIcon = _tableInstance$option2.VisibilityOffIcon,
|
|
3612
|
+
idPrefix = _tableInstance$option.idPrefix,
|
|
3613
|
+
localization = _tableInstance$option.localization,
|
|
3614
|
+
setShowFilters = tableInstance.setShowFilters;
|
|
3615
|
+
var column = header.column;
|
|
3616
|
+
var columnDef = column.columnDef;
|
|
3617
|
+
|
|
3618
|
+
var _getState = getState(),
|
|
3619
|
+
columnSizing = _getState.columnSizing,
|
|
3620
|
+
columnVisibility = _getState.columnVisibility,
|
|
3621
|
+
isDensePadding = _getState.isDensePadding;
|
|
3622
|
+
|
|
3623
|
+
var _useState = React.useState(null),
|
|
3624
|
+
filterMenuAnchorEl = _useState[0],
|
|
3625
|
+
setFilterMenuAnchorEl = _useState[1];
|
|
3626
|
+
|
|
3627
|
+
var _useState2 = React.useState(null),
|
|
3628
|
+
showHideColumnsMenuAnchorEl = _useState2[0],
|
|
3629
|
+
setShowHideColumnsMenuAnchorEl = _useState2[1];
|
|
3630
|
+
|
|
3631
|
+
var handleClearSort = function handleClearSort() {
|
|
3632
|
+
column.clearSorting();
|
|
3633
|
+
setAnchorEl(null);
|
|
3634
|
+
};
|
|
3635
|
+
|
|
3636
|
+
var handleSortAsc = function handleSortAsc() {
|
|
3637
|
+
column.toggleSorting(false);
|
|
3638
|
+
setAnchorEl(null);
|
|
3639
|
+
};
|
|
3640
|
+
|
|
3641
|
+
var handleSortDesc = function handleSortDesc() {
|
|
3642
|
+
column.toggleSorting(true);
|
|
3643
|
+
setAnchorEl(null);
|
|
3644
|
+
};
|
|
3645
|
+
|
|
3646
|
+
var handleResetColumnSize = function handleResetColumnSize() {
|
|
3647
|
+
column.resetSize();
|
|
3648
|
+
setAnchorEl(null);
|
|
3649
|
+
};
|
|
3650
|
+
|
|
3651
|
+
var handleHideColumn = function handleHideColumn() {
|
|
3652
|
+
column.toggleVisibility(false);
|
|
3653
|
+
setAnchorEl(null);
|
|
3654
|
+
};
|
|
3655
|
+
|
|
3656
|
+
var handlePinColumn = function handlePinColumn(pinDirection) {
|
|
3657
|
+
column.pin(pinDirection);
|
|
3658
|
+
setAnchorEl(null);
|
|
3659
|
+
};
|
|
3660
|
+
|
|
3661
|
+
var handleGroupByColumn = function handleGroupByColumn() {
|
|
3662
|
+
column.toggleGrouping();
|
|
3663
|
+
setColumnOrder(function (old) {
|
|
3664
|
+
return ['mrt-expand'].concat(old);
|
|
3665
|
+
});
|
|
3666
|
+
setAnchorEl(null);
|
|
3667
|
+
};
|
|
3668
|
+
|
|
3669
|
+
var handleClearFilter = function handleClearFilter() {
|
|
3670
|
+
column.setFilterValue('');
|
|
3671
|
+
setAnchorEl(null);
|
|
3672
|
+
};
|
|
3673
|
+
|
|
3674
|
+
var handleFilterByColumn = function handleFilterByColumn() {
|
|
3675
|
+
setShowFilters(true);
|
|
3676
|
+
setTimeout(function () {
|
|
3677
|
+
var _document$getElementB, _header$muiTableHeadC, _header$muiTableHeadC2;
|
|
3678
|
+
|
|
3679
|
+
return (_document$getElementB = document.getElementById( // @ts-ignore
|
|
3680
|
+
(_header$muiTableHeadC = (_header$muiTableHeadC2 = header.muiTableHeadCellFilterTextFieldProps) == null ? void 0 : _header$muiTableHeadC2.id) != null ? _header$muiTableHeadC : "mrt-" + idPrefix + "-" + header.id + "-filter-text-field")) == null ? void 0 : _document$getElementB.focus();
|
|
3681
|
+
}, 200);
|
|
3682
|
+
setAnchorEl(null);
|
|
3683
|
+
};
|
|
3684
|
+
|
|
3685
|
+
var handleShowAllColumns = function handleShowAllColumns() {
|
|
3686
|
+
toggleAllColumnsVisible(true);
|
|
3687
|
+
setAnchorEl(null);
|
|
3688
|
+
};
|
|
3689
|
+
|
|
3690
|
+
var handleOpenFilterModeMenu = function handleOpenFilterModeMenu(event) {
|
|
3691
|
+
event.stopPropagation();
|
|
3692
|
+
setFilterMenuAnchorEl(event.currentTarget);
|
|
3693
|
+
};
|
|
3694
|
+
|
|
3695
|
+
var handleOpenShowHideColumnsMenu = function handleOpenShowHideColumnsMenu(event) {
|
|
3696
|
+
event.stopPropagation();
|
|
3697
|
+
setShowHideColumnsMenuAnchorEl(event.currentTarget);
|
|
3698
|
+
};
|
|
3699
|
+
|
|
3700
|
+
return React__default.createElement(material.Menu, {
|
|
3701
|
+
anchorEl: anchorEl,
|
|
3702
|
+
open: !!anchorEl,
|
|
3703
|
+
onClose: function onClose() {
|
|
3704
|
+
return setAnchorEl(null);
|
|
3705
|
+
},
|
|
3706
|
+
MenuListProps: {
|
|
3707
|
+
dense: isDensePadding
|
|
3708
|
+
}
|
|
3709
|
+
}, enableSorting && column.getCanSort() && [React__default.createElement(material.MenuItem, {
|
|
3710
|
+
disabled: !column.getIsSorted(),
|
|
3711
|
+
key: 0,
|
|
3712
|
+
onClick: handleClearSort,
|
|
3713
|
+
sx: commonMenuItemStyles$1
|
|
3714
|
+
}, React__default.createElement(material.Box, {
|
|
3715
|
+
sx: commonListItemStyles
|
|
3716
|
+
}, React__default.createElement(material.ListItemIcon, null, React__default.createElement(ClearAllIcon, null)), localization.clearSort)), React__default.createElement(material.MenuItem, {
|
|
3717
|
+
disabled: column.getIsSorted() === 'asc',
|
|
3718
|
+
key: 1,
|
|
3719
|
+
onClick: handleSortAsc,
|
|
3720
|
+
sx: commonMenuItemStyles$1
|
|
3721
|
+
}, React__default.createElement(material.Box, {
|
|
3722
|
+
sx: commonListItemStyles
|
|
3723
|
+
}, React__default.createElement(material.ListItemIcon, null, React__default.createElement(SortIcon, null)), (_localization$sortByC = localization.sortByColumnAsc) == null ? void 0 : _localization$sortByC.replace('{column}', String(columnDef.header)))), React__default.createElement(material.MenuItem, {
|
|
3724
|
+
divider: enableColumnFilters || enableGrouping || enableHiding,
|
|
3725
|
+
key: 2,
|
|
3726
|
+
disabled: column.getIsSorted() === 'desc',
|
|
3727
|
+
onClick: handleSortDesc,
|
|
3728
|
+
sx: commonMenuItemStyles$1
|
|
3729
|
+
}, React__default.createElement(material.Box, {
|
|
3730
|
+
sx: commonListItemStyles
|
|
3731
|
+
}, React__default.createElement(material.ListItemIcon, null, React__default.createElement(SortIcon, {
|
|
3732
|
+
style: {
|
|
3733
|
+
transform: 'rotate(180deg) scaleX(-1)'
|
|
3734
|
+
}
|
|
3735
|
+
})), (_localization$sortByC2 = localization.sortByColumnDesc) == null ? void 0 : _localization$sortByC2.replace('{column}', String(columnDef.header))))], enableColumnFilters && column.getCanFilter() && [React__default.createElement(material.MenuItem, {
|
|
3736
|
+
disabled: !column.getFilterValue(),
|
|
3737
|
+
key: 0,
|
|
3738
|
+
onClick: handleClearFilter,
|
|
3739
|
+
sx: commonMenuItemStyles$1
|
|
3740
|
+
}, React__default.createElement(material.Box, {
|
|
3741
|
+
sx: commonListItemStyles
|
|
3742
|
+
}, React__default.createElement(material.ListItemIcon, null, React__default.createElement(FilterListOffIcon, null)), localization.clearFilter)), React__default.createElement(material.MenuItem, {
|
|
3743
|
+
divider: enableGrouping || enableHiding,
|
|
3744
|
+
key: 1,
|
|
3745
|
+
onClick: handleFilterByColumn,
|
|
3746
|
+
sx: commonMenuItemStyles$1
|
|
3747
|
+
}, React__default.createElement(material.Box, {
|
|
3748
|
+
sx: commonListItemStyles
|
|
3749
|
+
}, React__default.createElement(material.ListItemIcon, null, React__default.createElement(FilterListIcon, null)), (_localization$filterB = localization.filterByColumn) == null ? void 0 : _localization$filterB.replace('{column}', String(columnDef.header))), !columnDef.filterSelectOptions && React__default.createElement(material.IconButton, {
|
|
3750
|
+
onClick: handleOpenFilterModeMenu,
|
|
3751
|
+
onMouseEnter: handleOpenFilterModeMenu,
|
|
3752
|
+
size: "small",
|
|
3753
|
+
sx: {
|
|
3754
|
+
p: 0
|
|
3755
|
+
}
|
|
3756
|
+
}, React__default.createElement(ArrowRightIcon, null))), React__default.createElement(MRT_FilterOptionMenu, {
|
|
3757
|
+
anchorEl: filterMenuAnchorEl,
|
|
3758
|
+
header: header,
|
|
3759
|
+
key: 2,
|
|
3760
|
+
onSelect: handleFilterByColumn,
|
|
3761
|
+
setAnchorEl: setFilterMenuAnchorEl,
|
|
3762
|
+
tableInstance: tableInstance
|
|
3763
|
+
})], enableGrouping && column.getCanGroup() && [React__default.createElement(material.MenuItem, {
|
|
3764
|
+
divider: enablePinning,
|
|
3765
|
+
key: 0,
|
|
3766
|
+
onClick: handleGroupByColumn,
|
|
3767
|
+
sx: commonMenuItemStyles$1
|
|
3768
|
+
}, React__default.createElement(material.Box, {
|
|
3769
|
+
sx: commonListItemStyles
|
|
3770
|
+
}, React__default.createElement(material.ListItemIcon, null, React__default.createElement(DynamicFeedIcon, null)), (_localization = localization[column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn']) == null ? void 0 : _localization.replace('{column}', String(columnDef.header))))], enablePinning && column.getCanPin() && [React__default.createElement(material.MenuItem, {
|
|
3771
|
+
disabled: column.getIsPinned() === 'left' || !column.getCanPin(),
|
|
3772
|
+
key: 0,
|
|
3773
|
+
onClick: function onClick() {
|
|
3774
|
+
return handlePinColumn('left');
|
|
3775
|
+
},
|
|
3776
|
+
sx: commonMenuItemStyles$1
|
|
3777
|
+
}, React__default.createElement(material.Box, {
|
|
3778
|
+
sx: commonListItemStyles
|
|
3779
|
+
}, React__default.createElement(material.ListItemIcon, null, React__default.createElement(PushPinIcon, {
|
|
3780
|
+
style: {
|
|
3781
|
+
transform: 'rotate(90deg)'
|
|
3782
|
+
}
|
|
3783
|
+
})), localization.pinToLeft)), React__default.createElement(material.MenuItem, {
|
|
3784
|
+
disabled: column.getIsPinned() === 'right' || !column.getCanPin(),
|
|
3785
|
+
key: 1,
|
|
3786
|
+
onClick: function onClick() {
|
|
3787
|
+
return handlePinColumn('right');
|
|
3788
|
+
},
|
|
3789
|
+
sx: commonMenuItemStyles$1
|
|
3790
|
+
}, React__default.createElement(material.Box, {
|
|
3791
|
+
sx: commonListItemStyles
|
|
3792
|
+
}, React__default.createElement(material.ListItemIcon, null, React__default.createElement(PushPinIcon, {
|
|
3793
|
+
style: {
|
|
3794
|
+
transform: 'rotate(-90deg)'
|
|
3795
|
+
}
|
|
3796
|
+
})), localization.pinToRight)), React__default.createElement(material.MenuItem, {
|
|
3797
|
+
disabled: !column.getIsPinned(),
|
|
3798
|
+
divider: enableHiding,
|
|
3799
|
+
key: 2,
|
|
3800
|
+
onClick: function onClick() {
|
|
3801
|
+
return handlePinColumn(false);
|
|
3802
|
+
},
|
|
3803
|
+
sx: commonMenuItemStyles$1
|
|
3804
|
+
}, React__default.createElement(material.Box, {
|
|
3805
|
+
sx: commonListItemStyles
|
|
3806
|
+
}, React__default.createElement(material.ListItemIcon, null, React__default.createElement(PushPinIcon, null)), localization.unpin))], enableColumnResizing && [React__default.createElement(material.MenuItem, {
|
|
3807
|
+
disabled: !column.getCanResize() || !columnSizing[column.id],
|
|
3808
|
+
key: 0,
|
|
3809
|
+
onClick: handleResetColumnSize,
|
|
3810
|
+
sx: commonMenuItemStyles$1
|
|
3811
|
+
}, React__default.createElement(material.Box, {
|
|
3812
|
+
sx: commonListItemStyles
|
|
3813
|
+
}, React__default.createElement(material.ListItemIcon, null, React__default.createElement(RestartAltIcon, null)), localization.resetColumnSize))], enableHiding && [React__default.createElement(material.MenuItem, {
|
|
3814
|
+
disabled: columnDef.enableHiding === false,
|
|
3815
|
+
key: 0,
|
|
3816
|
+
onClick: handleHideColumn,
|
|
3817
|
+
sx: commonMenuItemStyles$1
|
|
3818
|
+
}, React__default.createElement(material.Box, {
|
|
3819
|
+
sx: commonListItemStyles
|
|
3820
|
+
}, React__default.createElement(material.ListItemIcon, null, React__default.createElement(VisibilityOffIcon, null)), (_localization$hideCol = localization.hideColumn) == null ? void 0 : _localization$hideCol.replace('{column}', String(columnDef.header)))), React__default.createElement(material.MenuItem, {
|
|
3821
|
+
disabled: !Object.values(columnVisibility).filter(function (visible) {
|
|
3822
|
+
return !visible;
|
|
3823
|
+
}).length,
|
|
3824
|
+
key: 1,
|
|
3825
|
+
onClick: handleShowAllColumns,
|
|
3826
|
+
sx: commonMenuItemStyles$1
|
|
3827
|
+
}, React__default.createElement(material.Box, {
|
|
3828
|
+
sx: commonListItemStyles
|
|
3829
|
+
}, React__default.createElement(material.ListItemIcon, null, React__default.createElement(ViewColumnIcon, null)), (_localization$showAll = localization.showAllColumns) == null ? void 0 : _localization$showAll.replace('{column}', String(columnDef.header))), React__default.createElement(material.IconButton, {
|
|
3830
|
+
onClick: handleOpenShowHideColumnsMenu,
|
|
3831
|
+
onMouseEnter: handleOpenShowHideColumnsMenu,
|
|
3832
|
+
size: "small",
|
|
3833
|
+
sx: {
|
|
3834
|
+
p: 0
|
|
3835
|
+
}
|
|
3836
|
+
}, React__default.createElement(ArrowRightIcon, null))), React__default.createElement(MRT_ShowHideColumnsMenu, {
|
|
3837
|
+
anchorEl: showHideColumnsMenuAnchorEl,
|
|
3838
|
+
isSubMenu: true,
|
|
3839
|
+
key: 2,
|
|
3840
|
+
setAnchorEl: setShowHideColumnsMenuAnchorEl,
|
|
3841
|
+
tableInstance: tableInstance
|
|
3842
|
+
})]);
|
|
3843
|
+
};
|
|
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
|
+
};
|
|
3708
3883
|
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
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;
|
|
3716
3895
|
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
const connector = React.useMemo(()=>new SourceConnector(manager.getBackend())
|
|
3720
|
-
, [
|
|
3721
|
-
manager
|
|
3722
|
-
]);
|
|
3723
|
-
useIsomorphicLayoutEffect(()=>{
|
|
3724
|
-
connector.dragSourceOptions = dragSourceOptions || null;
|
|
3725
|
-
connector.reconnect();
|
|
3726
|
-
return ()=>connector.disconnectDragSource()
|
|
3727
|
-
;
|
|
3728
|
-
}, [
|
|
3729
|
-
connector,
|
|
3730
|
-
dragSourceOptions
|
|
3731
|
-
]);
|
|
3732
|
-
useIsomorphicLayoutEffect(()=>{
|
|
3733
|
-
connector.dragPreviewOptions = dragPreviewOptions || null;
|
|
3734
|
-
connector.reconnect();
|
|
3735
|
-
return ()=>connector.disconnectDragPreview()
|
|
3736
|
-
;
|
|
3737
|
-
}, [
|
|
3738
|
-
connector,
|
|
3739
|
-
dragPreviewOptions
|
|
3740
|
-
]);
|
|
3741
|
-
return connector;
|
|
3742
|
-
}
|
|
3896
|
+
var _getState = getState(),
|
|
3897
|
+
currentEditingRow = _getState.currentEditingRow;
|
|
3743
3898
|
|
|
3744
|
-
function
|
|
3745
|
-
|
|
3746
|
-
return React.useMemo(()=>new DragSourceMonitorImpl(manager)
|
|
3747
|
-
, [
|
|
3748
|
-
manager
|
|
3749
|
-
]);
|
|
3750
|
-
}
|
|
3899
|
+
var handleCancel = function handleCancel() {
|
|
3900
|
+
var _row$original;
|
|
3751
3901
|
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
const monitor = this.monitor;
|
|
3756
|
-
let result = null;
|
|
3757
|
-
if (typeof spec.item === 'object') {
|
|
3758
|
-
result = spec.item;
|
|
3759
|
-
} else if (typeof spec.item === 'function') {
|
|
3760
|
-
result = spec.item(monitor);
|
|
3761
|
-
} else {
|
|
3762
|
-
result = {};
|
|
3763
|
-
}
|
|
3764
|
-
return result !== null && result !== void 0 ? result : null;
|
|
3765
|
-
}
|
|
3766
|
-
canDrag() {
|
|
3767
|
-
const spec = this.spec;
|
|
3768
|
-
const monitor = this.monitor;
|
|
3769
|
-
if (typeof spec.canDrag === 'boolean') {
|
|
3770
|
-
return spec.canDrag;
|
|
3771
|
-
} else if (typeof spec.canDrag === 'function') {
|
|
3772
|
-
return spec.canDrag(monitor);
|
|
3773
|
-
} else {
|
|
3774
|
-
return true;
|
|
3775
|
-
}
|
|
3776
|
-
}
|
|
3777
|
-
isDragging(globalMonitor, target) {
|
|
3778
|
-
const spec = this.spec;
|
|
3779
|
-
const monitor = this.monitor;
|
|
3780
|
-
const { isDragging } = spec;
|
|
3781
|
-
return isDragging ? isDragging(monitor) : target === globalMonitor.getSourceId();
|
|
3782
|
-
}
|
|
3783
|
-
endDrag() {
|
|
3784
|
-
const spec = this.spec;
|
|
3785
|
-
const monitor = this.monitor;
|
|
3786
|
-
const connector = this.connector;
|
|
3787
|
-
const { end } = spec;
|
|
3788
|
-
if (end) {
|
|
3789
|
-
end(monitor.getItem(), monitor);
|
|
3790
|
-
}
|
|
3791
|
-
connector.reconnect();
|
|
3792
|
-
}
|
|
3793
|
-
constructor(spec, monitor, connector){
|
|
3794
|
-
this.spec = spec;
|
|
3795
|
-
this.monitor = monitor;
|
|
3796
|
-
this.connector = connector;
|
|
3797
|
-
}
|
|
3798
|
-
}
|
|
3902
|
+
row._valuesCache = (_row$original = row.original) != null ? _row$original : {};
|
|
3903
|
+
setCurrentEditingRow(null);
|
|
3904
|
+
};
|
|
3799
3905
|
|
|
3800
|
-
function
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
handler.spec = spec;
|
|
3808
|
-
}, [
|
|
3809
|
-
spec
|
|
3810
|
-
]);
|
|
3811
|
-
return handler;
|
|
3812
|
-
}
|
|
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
|
+
};
|
|
3813
3913
|
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
}
|
|
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
|
+
};
|
|
3823
3934
|
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
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;
|
|
3844
3958
|
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
* @param sourceSpec The drag source specification (object or function, function preferred)
|
|
3848
|
-
* @param deps The memoization deps array to use when evaluating spec changes
|
|
3849
|
-
*/ function useDrag(specArg, deps) {
|
|
3850
|
-
const spec = useOptionalFactory(specArg, deps);
|
|
3851
|
-
invariant(!spec.begin, `useDrag::spec.begin was deprecated in v14. Replace spec.begin() with spec.item(). (see more here - https://react-dnd.github.io/react-dnd/docs/api/use-drag)`);
|
|
3852
|
-
const monitor = useDragSourceMonitor();
|
|
3853
|
-
const connector = useDragSourceConnector(spec.options, spec.previewOptions);
|
|
3854
|
-
useRegisteredDragSource(spec, monitor, connector);
|
|
3855
|
-
return [
|
|
3856
|
-
useCollectedProps(spec.collect, monitor, connector),
|
|
3857
|
-
useConnectDragSource(connector),
|
|
3858
|
-
useConnectDragPreview(connector),
|
|
3859
|
-
];
|
|
3860
|
-
}
|
|
3959
|
+
var _getState = getState(),
|
|
3960
|
+
currentEditingRow = _getState.currentEditingRow;
|
|
3861
3961
|
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
connector
|
|
3866
|
-
]);
|
|
3867
|
-
}
|
|
3962
|
+
var _useState = React.useState(null),
|
|
3963
|
+
anchorEl = _useState[0],
|
|
3964
|
+
setAnchorEl = _useState[1];
|
|
3868
3965
|
|
|
3869
|
-
function
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
]);
|
|
3875
|
-
useIsomorphicLayoutEffect(()=>{
|
|
3876
|
-
connector.dropTargetOptions = options || null;
|
|
3877
|
-
connector.reconnect();
|
|
3878
|
-
return ()=>connector.disconnectDropTarget()
|
|
3879
|
-
;
|
|
3880
|
-
}, [
|
|
3881
|
-
options
|
|
3882
|
-
]);
|
|
3883
|
-
return connector;
|
|
3884
|
-
}
|
|
3966
|
+
var handleOpenRowActionMenu = function handleOpenRowActionMenu(event) {
|
|
3967
|
+
event.stopPropagation();
|
|
3968
|
+
event.preventDefault();
|
|
3969
|
+
setAnchorEl(event.currentTarget);
|
|
3970
|
+
};
|
|
3885
3971
|
|
|
3886
|
-
function
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
manager
|
|
3891
|
-
]);
|
|
3892
|
-
}
|
|
3972
|
+
var handleStartEditMode = function handleStartEditMode() {
|
|
3973
|
+
setCurrentEditingRow(_extends({}, row));
|
|
3974
|
+
setAnchorEl(null);
|
|
3975
|
+
};
|
|
3893
3976
|
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
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
|
+
};
|
|
3909
4008
|
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
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
|
-
}
|
|
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,
|
|
4021
|
+
selectAllMode = _tableInstance$option.selectAllMode;
|
|
3936
4022
|
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
, [
|
|
3940
|
-
monitor
|
|
3941
|
-
]);
|
|
3942
|
-
React.useEffect(()=>{
|
|
3943
|
-
dropTarget.spec = spec;
|
|
3944
|
-
}, [
|
|
3945
|
-
spec
|
|
3946
|
-
]);
|
|
3947
|
-
return dropTarget;
|
|
3948
|
-
}
|
|
4023
|
+
var _getState = getState(),
|
|
4024
|
+
isDensePadding = _getState.isDensePadding;
|
|
3949
4025
|
|
|
3950
|
-
function
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
connector.receiveHandlerId(handlerId);
|
|
3958
|
-
return unregister;
|
|
3959
|
-
}, [
|
|
3960
|
-
manager,
|
|
3961
|
-
monitor,
|
|
3962
|
-
dropTarget,
|
|
3963
|
-
connector,
|
|
3964
|
-
accept.map((a)=>a.toString()
|
|
3965
|
-
).join('|'),
|
|
3966
|
-
]);
|
|
3967
|
-
}
|
|
4026
|
+
var handleSelectChange = function handleSelectChange(event) {
|
|
4027
|
+
if (selectAll) {
|
|
4028
|
+
if (selectAllMode === 'all') {
|
|
4029
|
+
tableInstance.getToggleAllRowsSelectedHandler()(event);
|
|
4030
|
+
} else if (selectAllMode === 'page') {
|
|
4031
|
+
tableInstance.getToggleAllPageRowsSelectedHandler()(event);
|
|
4032
|
+
}
|
|
3968
4033
|
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
4034
|
+
onSelectAllChange == null ? void 0 : onSelectAllChange({
|
|
4035
|
+
event: event,
|
|
4036
|
+
selectedRows: event.target.checked ? getRowModel().flatRows : [],
|
|
4037
|
+
tableInstance: tableInstance
|
|
4038
|
+
});
|
|
4039
|
+
} else if (row) {
|
|
4040
|
+
row == null ? void 0 : row.getToggleSelectedHandler()(event);
|
|
4041
|
+
onSelectChange == null ? void 0 : onSelectChange({
|
|
4042
|
+
event: event,
|
|
4043
|
+
row: row,
|
|
4044
|
+
selectedRows: event.target.checked ? [].concat(getSelectedRowModel().flatRows, [row]) : getSelectedRowModel().flatRows.filter(function (selectedRow) {
|
|
4045
|
+
return selectedRow.id !== row.id;
|
|
4046
|
+
}),
|
|
4047
|
+
tableInstance: tableInstance
|
|
4048
|
+
});
|
|
4049
|
+
}
|
|
4050
|
+
};
|
|
4051
|
+
|
|
4052
|
+
var checkboxProps = muiSelectCheckboxProps instanceof Function ? muiSelectCheckboxProps({
|
|
4053
|
+
isSelectAll: !!selectAll,
|
|
4054
|
+
row: row,
|
|
4055
|
+
tableInstance: tableInstance
|
|
4056
|
+
}) : muiSelectCheckboxProps;
|
|
4057
|
+
return React__default.createElement(material.Tooltip, {
|
|
4058
|
+
arrow: true,
|
|
4059
|
+
enterDelay: 1000,
|
|
4060
|
+
enterNextDelay: 1000,
|
|
4061
|
+
title: selectAll ? localization.toggleSelectAll : localization.toggleSelectRow
|
|
4062
|
+
}, React__default.createElement(material.Checkbox, Object.assign({
|
|
4063
|
+
checked: selectAll ? tableInstance.getIsAllRowsSelected() : row == null ? void 0 : row.getIsSelected(),
|
|
4064
|
+
indeterminate: selectAll ? tableInstance.getIsSomeRowsSelected() : row == null ? void 0 : row.getIsSomeSelected(),
|
|
4065
|
+
inputProps: {
|
|
4066
|
+
'aria-label': selectAll ? localization.toggleSelectAll : localization.toggleSelectRow
|
|
4067
|
+
},
|
|
4068
|
+
onChange: handleSelectChange,
|
|
4069
|
+
size: isDensePadding ? 'small' : 'medium'
|
|
4070
|
+
}, checkboxProps, {
|
|
4071
|
+
sx: _extends({
|
|
4072
|
+
height: isDensePadding ? '1.75rem' : '2.25rem',
|
|
4073
|
+
width: isDensePadding ? '1.75rem' : '2.25rem'
|
|
4074
|
+
}, checkboxProps == null ? void 0 : checkboxProps.sx)
|
|
4075
|
+
})));
|
|
4076
|
+
};
|
|
3983
4077
|
|
|
3984
4078
|
// cheap lodash replacements
|
|
3985
4079
|
function memoize(fn) {
|
|
@@ -5620,9 +5714,6 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
5620
5714
|
var filterChipLabel = !(filterFn instanceof Function) && [MRT_FILTER_OPTION.EMPTY, MRT_FILTER_OPTION.NOT_EMPTY].includes(filterFn) ? //@ts-ignore
|
|
5621
5715
|
localization["filter" + (filterFn.charAt(0).toUpperCase() + filterFn.slice(1))] : '';
|
|
5622
5716
|
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
5717
|
return React__default.createElement(React__default.Fragment, null, React__default.createElement(material.TextField, Object.assign({
|
|
5627
5718
|
fullWidth: true,
|
|
5628
5719
|
id: filterId,
|
|
@@ -5800,8 +5891,9 @@ var MRT_TableHeadCellFilterLabel = function MRT_TableHeadCellFilterLabel(_ref) {
|
|
|
5800
5891
|
showFilters = _getState.showFilters;
|
|
5801
5892
|
|
|
5802
5893
|
var column = header.column;
|
|
5894
|
+
var columnDef = column.columnDef;
|
|
5803
5895
|
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(
|
|
5896
|
+
var filterTooltip = !!column.getFilterValue() ? localization.filteringByColumn.replace('{column}', String(columnDef.header)).replace('{filterType}', filterFn instanceof Function ? '' : // @ts-ignore
|
|
5805
5897
|
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
5898
|
return React__default.createElement(material.Tooltip, {
|
|
5807
5899
|
arrow: true,
|
|
@@ -5827,38 +5919,6 @@ var MRT_TableHeadCellFilterLabel = function MRT_TableHeadCellFilterLabel(_ref) {
|
|
|
5827
5919
|
}, showFilters && !column.getFilterValue() ? React__default.createElement(FilterAltOffIcon, null) : React__default.createElement(FilterAltIcon, null)));
|
|
5828
5920
|
};
|
|
5829
5921
|
|
|
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
5922
|
var MRT_TableHeadCellResizeHandle = function MRT_TableHeadCellResizeHandle(_ref) {
|
|
5863
5923
|
var header = _ref.header,
|
|
5864
5924
|
tableInstance = _ref.tableInstance;
|
|
@@ -5868,6 +5928,7 @@ var MRT_TableHeadCellResizeHandle = function MRT_TableHeadCellResizeHandle(_ref)
|
|
|
5868
5928
|
showFilters = _getState.showFilters;
|
|
5869
5929
|
|
|
5870
5930
|
var column = header.column;
|
|
5931
|
+
var columnDefType = column.columnDefType;
|
|
5871
5932
|
return React__default.createElement(material.Divider, {
|
|
5872
5933
|
flexItem: true,
|
|
5873
5934
|
orientation: "vertical",
|
|
@@ -5879,7 +5940,7 @@ var MRT_TableHeadCellResizeHandle = function MRT_TableHeadCellResizeHandle(_ref)
|
|
|
5879
5940
|
borderRadius: '2px',
|
|
5880
5941
|
borderRightWidth: '2px',
|
|
5881
5942
|
cursor: 'col-resize',
|
|
5882
|
-
height: showFilters &&
|
|
5943
|
+
height: showFilters && columnDefType === 'data' ? '4rem' : '2rem',
|
|
5883
5944
|
opacity: 0.8,
|
|
5884
5945
|
position: 'absolute',
|
|
5885
5946
|
right: '1px',
|
|
@@ -5906,7 +5967,8 @@ var MRT_TableHeadCellSortLabel = function MRT_TableHeadCellSortLabel(_ref) {
|
|
|
5906
5967
|
tableInstance = _ref.tableInstance;
|
|
5907
5968
|
var localization = tableInstance.options.localization;
|
|
5908
5969
|
var column = header.column;
|
|
5909
|
-
var
|
|
5970
|
+
var columnDef = column.columnDef;
|
|
5971
|
+
var sortTooltip = !!column.getIsSorted() ? column.getIsSorted() === 'desc' ? localization.sortedByColumnDesc.replace('{column}', columnDef.header) : localization.sortedByColumnAsc.replace('{column}', columnDef.header) : localization.unsorted;
|
|
5910
5972
|
return React__default.createElement(material.Tooltip, {
|
|
5911
5973
|
arrow: true,
|
|
5912
5974
|
placement: "top",
|
|
@@ -5926,6 +5988,7 @@ var MRT_ToggleColumnActionMenuButton = function MRT_ToggleColumnActionMenuButton
|
|
|
5926
5988
|
localization = _tableInstance$option.localization,
|
|
5927
5989
|
muiTableHeadCellColumnActionsButtonProps = _tableInstance$option.muiTableHeadCellColumnActionsButtonProps;
|
|
5928
5990
|
var column = header.column;
|
|
5991
|
+
var columnDef = column.columnDef;
|
|
5929
5992
|
|
|
5930
5993
|
var _useState = React.useState(null),
|
|
5931
5994
|
anchorEl = _useState[0],
|
|
@@ -5941,10 +6004,10 @@ var MRT_ToggleColumnActionMenuButton = function MRT_ToggleColumnActionMenuButton
|
|
|
5941
6004
|
column: column,
|
|
5942
6005
|
tableInstance: tableInstance
|
|
5943
6006
|
}) : muiTableHeadCellColumnActionsButtonProps;
|
|
5944
|
-
var mcTableHeadCellColumnActionsButtonProps =
|
|
6007
|
+
var mcTableHeadCellColumnActionsButtonProps = columnDef.muiTableHeadCellColumnActionsButtonProps instanceof Function ? columnDef.muiTableHeadCellColumnActionsButtonProps({
|
|
5945
6008
|
column: column,
|
|
5946
6009
|
tableInstance: tableInstance
|
|
5947
|
-
}) :
|
|
6010
|
+
}) : columnDef.muiTableHeadCellColumnActionsButtonProps;
|
|
5948
6011
|
|
|
5949
6012
|
var iconButtonProps = _extends({}, mTableHeadCellColumnActionsButtonProps, mcTableHeadCellColumnActionsButtonProps);
|
|
5950
6013
|
|
|
@@ -5979,7 +6042,7 @@ var MRT_ToggleColumnActionMenuButton = function MRT_ToggleColumnActionMenuButton
|
|
|
5979
6042
|
};
|
|
5980
6043
|
|
|
5981
6044
|
var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
5982
|
-
var
|
|
6045
|
+
var _columnDef$Header, _columnDef$minSize, _columnDef$header$len, _columnDef$header;
|
|
5983
6046
|
|
|
5984
6047
|
var dragRef = _ref.dragRef,
|
|
5985
6048
|
dropRef = _ref.dropRef,
|
|
@@ -6013,10 +6076,10 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
|
6013
6076
|
|
|
6014
6077
|
var tableCellProps = _extends({}, mTableHeadCellProps, mcTableHeadCellProps);
|
|
6015
6078
|
|
|
6016
|
-
var headerElement = (
|
|
6079
|
+
var headerElement = (columnDef == null ? void 0 : columnDef.Header) instanceof Function ? columnDef == null ? void 0 : columnDef.Header == null ? void 0 : columnDef.Header({
|
|
6017
6080
|
header: header,
|
|
6018
6081
|
tableInstance: tableInstance
|
|
6019
|
-
}) : (
|
|
6082
|
+
}) : (_columnDef$Header = columnDef == null ? void 0 : columnDef.Header) != null ? _columnDef$Header : header.renderHeader();
|
|
6020
6083
|
|
|
6021
6084
|
var getIsLastLeftPinnedColumn = function getIsLastLeftPinnedColumn() {
|
|
6022
6085
|
return column.getIsPinned() === 'left' && tableInstance.getLeftLeafHeaders().length - 1 === column.getPinnedIndex();
|
|
@@ -6047,7 +6110,7 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
|
6047
6110
|
p: isDensePadding ? columnDefType === 'display' ? '0 0.5rem' : '0.5rem' : columnDefType === 'display' ? '0.5rem 0.75rem' : '1rem',
|
|
6048
6111
|
pb: columnDefType === 'display' ? 0 : undefined,
|
|
6049
6112
|
position: column.getIsPinned() && columnDefType !== 'group' ? 'sticky' : undefined,
|
|
6050
|
-
pt: columnDefType
|
|
6113
|
+
pt: columnDefType !== 'data' ? 0 : isDensePadding ? '0.25' : '.5rem',
|
|
6051
6114
|
right: column.getIsPinned() === 'right' ? getTotalRight() + "px" : undefined,
|
|
6052
6115
|
transition: "all " + (enableColumnResizing ? 0 : '0.2s') + " ease-in-out",
|
|
6053
6116
|
verticalAlign: 'text-top',
|
|
@@ -6089,8 +6152,7 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
|
6089
6152
|
sx: {
|
|
6090
6153
|
whiteSpace: 'nowrap'
|
|
6091
6154
|
}
|
|
6092
|
-
}, columnDefType === 'data' && (enableColumnOrdering && columnDef.enableColumnOrdering !== false || enableGrouping && columnDef.enableGrouping !== false) && React__default.createElement(
|
|
6093
|
-
header: header,
|
|
6155
|
+
}, columnDefType === 'data' && (enableColumnOrdering && columnDef.enableColumnOrdering !== false || enableGrouping && columnDef.enableGrouping !== false) && React__default.createElement(MRT_GrabHandleButton, {
|
|
6094
6156
|
ref: dragRef,
|
|
6095
6157
|
tableInstance: tableInstance
|
|
6096
6158
|
}), (enableColumnActions || columnDef.enableColumnActions) && columnDef.enableColumnActions !== false && columnDefType !== 'group' && React__default.createElement(MRT_ToggleColumnActionMenuButton, {
|
|
@@ -6117,19 +6179,22 @@ var MRT_DraggableTableHeadCell = function MRT_DraggableTableHeadCell(_ref) {
|
|
|
6117
6179
|
var _getState = getState(),
|
|
6118
6180
|
columnOrder = _getState.columnOrder;
|
|
6119
6181
|
|
|
6120
|
-
var reorder = function reorder(
|
|
6121
|
-
|
|
6122
|
-
|
|
6182
|
+
var reorder = function reorder(movingHeader, receivingHeader) {
|
|
6183
|
+
if (movingHeader.column.getCanPin()) {
|
|
6184
|
+
movingHeader.column.pin(receivingHeader.column.getIsPinned());
|
|
6185
|
+
}
|
|
6186
|
+
|
|
6187
|
+
columnOrder.splice(receivingHeader.index, 0, columnOrder.splice(movingHeader.index, 1)[0]);
|
|
6123
6188
|
setColumnOrder([].concat(columnOrder));
|
|
6124
6189
|
};
|
|
6125
6190
|
|
|
6126
6191
|
var _useDrop = useDrop({
|
|
6127
6192
|
accept: 'header',
|
|
6128
|
-
drop: function drop(
|
|
6129
|
-
return reorder(
|
|
6193
|
+
drop: function drop(movingHeader) {
|
|
6194
|
+
return reorder(movingHeader, header);
|
|
6130
6195
|
}
|
|
6131
6196
|
}),
|
|
6132
|
-
|
|
6197
|
+
dropRef = _useDrop[1];
|
|
6133
6198
|
|
|
6134
6199
|
var _useDrag = useDrag({
|
|
6135
6200
|
collect: function collect(monitor) {
|
|
@@ -6143,15 +6208,15 @@ var MRT_DraggableTableHeadCell = function MRT_DraggableTableHeadCell(_ref) {
|
|
|
6143
6208
|
type: 'header'
|
|
6144
6209
|
}),
|
|
6145
6210
|
isDragging = _useDrag[0].isDragging,
|
|
6146
|
-
|
|
6147
|
-
|
|
6211
|
+
dragRef = _useDrag[1],
|
|
6212
|
+
previewRef = _useDrag[2];
|
|
6148
6213
|
|
|
6149
6214
|
return React__default.createElement(MRT_TableHeadCell, {
|
|
6150
|
-
dragRef:
|
|
6151
|
-
dropRef:
|
|
6215
|
+
dragRef: dragRef,
|
|
6216
|
+
dropRef: dropRef,
|
|
6152
6217
|
header: header,
|
|
6153
6218
|
isDragging: isDragging,
|
|
6154
|
-
previewRef:
|
|
6219
|
+
previewRef: previewRef,
|
|
6155
6220
|
tableInstance: tableInstance
|
|
6156
6221
|
});
|
|
6157
6222
|
};
|
|
@@ -6297,6 +6362,8 @@ var MRT_CopyButton = function MRT_CopyButton(_ref) {
|
|
|
6297
6362
|
var _tableInstance$option = tableInstance.options,
|
|
6298
6363
|
localization = _tableInstance$option.localization,
|
|
6299
6364
|
muiTableBodyCellCopyButtonProps = _tableInstance$option.muiTableBodyCellCopyButtonProps;
|
|
6365
|
+
var column = cell.column;
|
|
6366
|
+
var columnDef = column.columnDef;
|
|
6300
6367
|
|
|
6301
6368
|
var _useState = React.useState(false),
|
|
6302
6369
|
copied = _useState[0],
|
|
@@ -6314,10 +6381,10 @@ var MRT_CopyButton = function MRT_CopyButton(_ref) {
|
|
|
6314
6381
|
cell: cell,
|
|
6315
6382
|
tableInstance: tableInstance
|
|
6316
6383
|
}) : muiTableBodyCellCopyButtonProps;
|
|
6317
|
-
var mcTableBodyCellCopyButtonProps =
|
|
6384
|
+
var mcTableBodyCellCopyButtonProps = columnDef.muiTableBodyCellCopyButtonProps instanceof Function ? columnDef.muiTableBodyCellCopyButtonProps({
|
|
6318
6385
|
cell: cell,
|
|
6319
6386
|
tableInstance: tableInstance
|
|
6320
|
-
}) :
|
|
6387
|
+
}) : columnDef.muiTableBodyCellCopyButtonProps;
|
|
6321
6388
|
|
|
6322
6389
|
var buttonProps = _extends({}, mTableBodyCellCopyButtonProps, mcTableBodyCellCopyButtonProps);
|
|
6323
6390
|
|
|
@@ -6353,7 +6420,7 @@ var MRT_CopyButton = function MRT_CopyButton(_ref) {
|
|
|
6353
6420
|
};
|
|
6354
6421
|
|
|
6355
6422
|
var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
|
|
6356
|
-
var _columnDef$minSize,
|
|
6423
|
+
var _columnDef$minSize, _columnDef$Cell, _row$subRows, _columnDef$Cell2, _row$subRows$length, _row$subRows2;
|
|
6357
6424
|
|
|
6358
6425
|
var cell = _ref.cell,
|
|
6359
6426
|
enableHover = _ref.enableHover,
|
|
@@ -6378,7 +6445,8 @@ var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
|
|
|
6378
6445
|
|
|
6379
6446
|
var column = cell.column,
|
|
6380
6447
|
row = cell.row;
|
|
6381
|
-
var columnDef = column.columnDef
|
|
6448
|
+
var columnDef = column.columnDef,
|
|
6449
|
+
columnDefType = column.columnDefType;
|
|
6382
6450
|
var mTableCellBodyProps = muiTableBodyCellProps instanceof Function ? muiTableBodyCellProps({
|
|
6383
6451
|
cell: cell,
|
|
6384
6452
|
tableInstance: tableInstance
|
|
@@ -6391,8 +6459,8 @@ var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
|
|
|
6391
6459
|
var tableCellProps = _extends({}, mTableCellBodyProps, mcTableCellBodyProps);
|
|
6392
6460
|
|
|
6393
6461
|
var skeletonWidth = React.useMemo(function () {
|
|
6394
|
-
return
|
|
6395
|
-
}, [
|
|
6462
|
+
return columnDefType === 'display' ? column.getSize() / 2 : Math.random() * (column.getSize() - column.getSize() / 3) + column.getSize() / 3;
|
|
6463
|
+
}, [columnDefType, column.getSize()]);
|
|
6396
6464
|
var isEditable = (enableEditing || columnDef.enableEditing) && columnDef.enableEditing !== false;
|
|
6397
6465
|
var isEditing = isEditable && (editingMode === 'table' || (currentEditingRow == null ? void 0 : currentEditingRow.id) === row.id || (currentEditingCell == null ? void 0 : currentEditingCell.id) === cell.id);
|
|
6398
6466
|
|
|
@@ -6438,7 +6506,7 @@ var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
|
|
|
6438
6506
|
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
6507
|
cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'text',
|
|
6440
6508
|
left: column.getIsPinned() === 'left' ? column.getStart('left') + "px" : undefined,
|
|
6441
|
-
p: isDensePadding ?
|
|
6509
|
+
p: isDensePadding ? columnDefType === 'display' ? '0 0.5rem' : '0.5rem' : columnDefType === 'display' ? '0.5rem 0.75rem' : '1rem',
|
|
6442
6510
|
pl: column.id === 'mrt-expand' ? row.depth + (isDensePadding ? 0.5 : 0.75) + "rem" : undefined,
|
|
6443
6511
|
position: column.getIsPinned() ? 'sticky' : 'relative',
|
|
6444
6512
|
right: column.getIsPinned() === 'right' ? getTotalRight() + "px" : undefined,
|
|
@@ -6459,7 +6527,7 @@ var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
|
|
|
6459
6527
|
animation: "wave",
|
|
6460
6528
|
height: 20,
|
|
6461
6529
|
width: skeletonWidth
|
|
6462
|
-
}, muiTableBodyCellSkeletonProps)) :
|
|
6530
|
+
}, muiTableBodyCellSkeletonProps)) : columnDefType === 'display' ? columnDef.Cell == null ? void 0 : columnDef.Cell({
|
|
6463
6531
|
cell: cell,
|
|
6464
6532
|
tableInstance: tableInstance
|
|
6465
6533
|
}) : cell.getIsPlaceholder() || row.getIsGrouped() && column.id !== row.groupingColumnId ? null : cell.getIsAggregated() ? cell.renderAggregatedCell() : isEditing ? React__default.createElement(MRT_EditCellTextField, {
|
|
@@ -6468,13 +6536,13 @@ var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
|
|
|
6468
6536
|
}) : (enableClickToCopy || columnDef.enableClickToCopy) && columnDef.enableClickToCopy !== false ? React__default.createElement(React__default.Fragment, null, React__default.createElement(MRT_CopyButton, {
|
|
6469
6537
|
cell: cell,
|
|
6470
6538
|
tableInstance: tableInstance
|
|
6471
|
-
}, React__default.createElement(React__default.Fragment, null, (
|
|
6539
|
+
}, React__default.createElement(React__default.Fragment, null, (_columnDef$Cell = columnDef == null ? void 0 : columnDef.Cell == null ? void 0 : columnDef.Cell({
|
|
6472
6540
|
cell: cell,
|
|
6473
6541
|
tableInstance: tableInstance
|
|
6474
|
-
})) != null ?
|
|
6542
|
+
})) != 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
6543
|
cell: cell,
|
|
6476
6544
|
tableInstance: tableInstance
|
|
6477
|
-
})) != null ?
|
|
6545
|
+
})) != 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
6546
|
};
|
|
6479
6547
|
|
|
6480
6548
|
var MRT_TableDetailPanel = function MRT_TableDetailPanel(_ref) {
|
|
@@ -6596,7 +6664,8 @@ var MRT_TableFooterCell = function MRT_TableFooterCell(_ref) {
|
|
|
6596
6664
|
isDensePadding = _getState.isDensePadding;
|
|
6597
6665
|
|
|
6598
6666
|
var column = footer.column;
|
|
6599
|
-
var columnDef = column.columnDef
|
|
6667
|
+
var columnDef = column.columnDef,
|
|
6668
|
+
columnDefType = column.columnDefType;
|
|
6600
6669
|
var mTableFooterCellProps = muiTableFooterCellProps instanceof Function ? muiTableFooterCellProps({
|
|
6601
6670
|
column: column,
|
|
6602
6671
|
tableInstance: tableInstance
|
|
@@ -6609,7 +6678,7 @@ var MRT_TableFooterCell = function MRT_TableFooterCell(_ref) {
|
|
|
6609
6678
|
var tableCellProps = _extends({}, mTableFooterCellProps, mcTableFooterCellProps);
|
|
6610
6679
|
|
|
6611
6680
|
return React__default.createElement(material.TableCell, Object.assign({
|
|
6612
|
-
align:
|
|
6681
|
+
align: columnDefType === 'group' ? 'center' : 'left',
|
|
6613
6682
|
colSpan: footer.colSpan,
|
|
6614
6683
|
variant: "head"
|
|
6615
6684
|
}, tableCellProps, {
|
|
@@ -6639,8 +6708,8 @@ var MRT_TableFooterRow = function MRT_TableFooterRow(_ref) {
|
|
|
6639
6708
|
tableInstance = _ref.tableInstance;
|
|
6640
6709
|
var muiTableFooterRowProps = tableInstance.options.muiTableFooterRowProps; // if no content in row, skip row
|
|
6641
6710
|
|
|
6642
|
-
if (!((_footerGroup$headers = footerGroup.headers) != null && _footerGroup$headers.some(function (
|
|
6643
|
-
return typeof
|
|
6711
|
+
if (!((_footerGroup$headers = footerGroup.headers) != null && _footerGroup$headers.some(function (header) {
|
|
6712
|
+
return typeof header.column.columnDef.footer === 'string' && !!header.column.columnDef.footer || header.column.columnDef.Footer;
|
|
6644
6713
|
}))) return null;
|
|
6645
6714
|
var tableRowProps = muiTableFooterRowProps instanceof Function ? muiTableFooterRowProps({
|
|
6646
6715
|
footerGroup: footerGroup,
|
|
@@ -6831,7 +6900,7 @@ var createDisplayColumn = function createDisplayColumn(table, column) {
|
|
|
6831
6900
|
};
|
|
6832
6901
|
|
|
6833
6902
|
var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
6834
|
-
var _initialState$current, _initialState$current2, _initialState$isDense, _initialState$isFullS, _initialState$showFil, _initialState$showGlo,
|
|
6903
|
+
var _initialState$current, _initialState$current2, _initialState$isDense, _initialState$isFullS, _initialState$showFil, _initialState$showGlo, _props$globalFilterFn, _props$state3, _props$state4;
|
|
6835
6904
|
|
|
6836
6905
|
var _useState = React.useState(props.idPrefix),
|
|
6837
6906
|
idPrefix = _useState[0],
|
|
@@ -6842,9 +6911,18 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
6842
6911
|
|
|
6843
6912
|
return setIdPrefix((_props$idPrefix = props.idPrefix) != null ? _props$idPrefix : Math.random().toString(36).substring(2, 9));
|
|
6844
6913
|
}, [props.idPrefix]);
|
|
6914
|
+
var showActionColumn = props.enableRowActions || props.enableEditing && props.editingMode === 'row';
|
|
6915
|
+
var showExpandColumn = props.enableExpanding || props.enableGrouping;
|
|
6845
6916
|
var initialState = React.useMemo(function () {
|
|
6917
|
+
var _props$initialState, _initState$columnOrde;
|
|
6918
|
+
|
|
6919
|
+
var initState = (_props$initialState = props.initialState) != null ? _props$initialState : {};
|
|
6920
|
+
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) {
|
|
6921
|
+
return c.id;
|
|
6922
|
+
})).filter(Boolean) : [];
|
|
6923
|
+
|
|
6846
6924
|
if (!props.enablePersistentState || !props.idPrefix) {
|
|
6847
|
-
return
|
|
6925
|
+
return initState;
|
|
6848
6926
|
}
|
|
6849
6927
|
|
|
6850
6928
|
if (typeof window === 'undefined') {
|
|
@@ -6852,7 +6930,7 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
6852
6930
|
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
6931
|
}
|
|
6854
6932
|
|
|
6855
|
-
return
|
|
6933
|
+
return initState;
|
|
6856
6934
|
}
|
|
6857
6935
|
|
|
6858
6936
|
var storedState = props.persistentStateMode === 'localStorage' ? localStorage.getItem("mrt-" + idPrefix + "-table-state") : props.persistentStateMode === 'sessionStorage' ? sessionStorage.getItem("mrt-" + idPrefix + "-table-state") : '{}';
|
|
@@ -6861,11 +6939,11 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
6861
6939
|
var parsedState = JSON.parse(storedState);
|
|
6862
6940
|
|
|
6863
6941
|
if (parsedState) {
|
|
6864
|
-
return _extends({},
|
|
6942
|
+
return _extends({}, initState, parsedState);
|
|
6865
6943
|
}
|
|
6866
6944
|
}
|
|
6867
6945
|
|
|
6868
|
-
return
|
|
6946
|
+
return initState;
|
|
6869
6947
|
}, []);
|
|
6870
6948
|
|
|
6871
6949
|
var _useState2 = React.useState((_initialState$current = initialState == null ? void 0 : initialState.currentEditingCell) != null ? _initialState$current : null),
|
|
@@ -6892,35 +6970,42 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
6892
6970
|
showGlobalFilter = _useState7[0],
|
|
6893
6971
|
setShowGlobalFilter = _useState7[1];
|
|
6894
6972
|
|
|
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 () {
|
|
6973
|
+
var _useState8 = React.useState(function () {
|
|
6904
6974
|
return Object.assign.apply(Object, [{}].concat(getAllLeafColumnDefs(props.columns).map(function (c) {
|
|
6905
6975
|
var _ref, _c$filterFn, _initialState$current3, _c$filterSelectOption, _ref2;
|
|
6906
6976
|
|
|
6907
6977
|
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
6978
|
})));
|
|
6909
6979
|
}),
|
|
6910
|
-
currentFilterFns =
|
|
6911
|
-
setCurrentFilterFns =
|
|
6980
|
+
currentFilterFns = _useState8[0],
|
|
6981
|
+
setCurrentFilterFns = _useState8[1];
|
|
6912
6982
|
|
|
6913
|
-
var
|
|
6914
|
-
currentGlobalFilterFn =
|
|
6915
|
-
setCurrentGlobalFilterFn =
|
|
6983
|
+
var _useState9 = React.useState((_props$globalFilterFn = props.globalFilterFn) != null ? _props$globalFilterFn : MRT_FILTER_OPTION.FUZZY),
|
|
6984
|
+
currentGlobalFilterFn = _useState9[0],
|
|
6985
|
+
setCurrentGlobalFilterFn = _useState9[1];
|
|
6916
6986
|
|
|
6917
6987
|
var table = React.useMemo(function () {
|
|
6918
|
-
return reactTable.createTable()
|
|
6988
|
+
return reactTable.createTable().setOptions({
|
|
6989
|
+
//@ts-ignore
|
|
6990
|
+
filterFns: defaultFilterFNs,
|
|
6991
|
+
getCoreRowModel: reactTable.getCoreRowModel(),
|
|
6992
|
+
getExpandedRowModel: reactTable.getExpandedRowModel(),
|
|
6993
|
+
getFacetedRowModel: reactTable.getFacetedRowModel(),
|
|
6994
|
+
getFilteredRowModel: reactTable.getFilteredRowModel(),
|
|
6995
|
+
getGroupedRowModel: reactTable.getGroupedRowModel(),
|
|
6996
|
+
getPaginationRowModel: reactTable.getPaginationRowModel(),
|
|
6997
|
+
getSortedRowModel: reactTable.getSortedRowModel(),
|
|
6998
|
+
getSubRows: function getSubRows(row) {
|
|
6999
|
+
return row == null ? void 0 : row.subRows;
|
|
7000
|
+
},
|
|
7001
|
+
idPrefix: idPrefix,
|
|
7002
|
+
initialState: initialState
|
|
7003
|
+
});
|
|
6919
7004
|
}, []);
|
|
6920
7005
|
var displayColumns = React.useMemo(function () {
|
|
6921
7006
|
var _props$localization, _props$localization2, _props$localization3, _props$localization5;
|
|
6922
7007
|
|
|
6923
|
-
return [
|
|
7008
|
+
return [showActionColumn && createDisplayColumn(table, {
|
|
6924
7009
|
Cell: function Cell(_ref3) {
|
|
6925
7010
|
var cell = _ref3.cell;
|
|
6926
7011
|
return React__default.createElement(MRT_ToggleRowActionMenuButton, {
|
|
@@ -6931,7 +7016,7 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
6931
7016
|
header: (_props$localization = props.localization) == null ? void 0 : _props$localization.actions,
|
|
6932
7017
|
id: 'mrt-row-actions',
|
|
6933
7018
|
size: 60
|
|
6934
|
-
}),
|
|
7019
|
+
}), showExpandColumn && createDisplayColumn(table, {
|
|
6935
7020
|
Cell: function Cell(_ref4) {
|
|
6936
7021
|
var cell = _ref4.cell;
|
|
6937
7022
|
return React__default.createElement(MRT_ExpandButton, {
|
|
@@ -6994,55 +7079,21 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
6994
7079
|
return _ref7 = {}, _ref7[c.id] = null, _ref7;
|
|
6995
7080
|
})));
|
|
6996
7081
|
}) : 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;
|
|
7082
|
+
}, [props.data, (_props$state3 = props.state) == null ? void 0 : _props$state3.isLoading, (_props$state4 = props.state) == null ? void 0 : _props$state4.showSkeletons]); //@ts-ignore
|
|
7001
7083
|
|
|
7002
|
-
|
|
7003
|
-
return c.id;
|
|
7004
|
-
}) : [];
|
|
7005
|
-
}),
|
|
7006
|
-
columnOrder = _useState11[0],
|
|
7007
|
-
setColumnOrder = _useState11[1]; //@ts-ignore
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
var tableInstance = _extends({}, reactTable.useTableInstance(table, _extends({
|
|
7011
|
-
filterFns: defaultFilterFNs,
|
|
7012
|
-
getCoreRowModel: reactTable.getCoreRowModel(),
|
|
7013
|
-
getExpandedRowModel: reactTable.getExpandedRowModel(),
|
|
7014
|
-
getFacetedRowModel: reactTable.getFacetedRowModel(),
|
|
7015
|
-
getFilteredRowModel: reactTable.getFilteredRowModel(),
|
|
7016
|
-
getGroupedRowModel: reactTable.getGroupedRowModel(),
|
|
7017
|
-
getPaginationRowModel: reactTable.getPaginationRowModel(),
|
|
7018
|
-
getSortedRowModel: reactTable.getSortedRowModel(),
|
|
7019
|
-
getSubRows: function getSubRows(row) {
|
|
7020
|
-
return row == null ? void 0 : row.subRows;
|
|
7021
|
-
},
|
|
7022
|
-
//@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
|
-
}
|
|
7030
|
-
}, props, {
|
|
7084
|
+
var tableInstance = _extends({}, reactTable.useTableInstance(table, _extends({}, props, {
|
|
7031
7085
|
//@ts-ignore
|
|
7032
7086
|
columns: columns,
|
|
7033
7087
|
data: data,
|
|
7034
|
-
|
|
7035
|
-
|
|
7088
|
+
//@ts-ignore
|
|
7089
|
+
globalFilterFn: currentGlobalFilterFn,
|
|
7036
7090
|
state: _extends({
|
|
7037
|
-
columnOrder: columnOrder,
|
|
7038
7091
|
currentEditingCell: currentEditingCell,
|
|
7039
7092
|
currentEditingRow: currentEditingRow,
|
|
7040
7093
|
currentFilterFns: currentFilterFns,
|
|
7041
7094
|
currentGlobalFilterFn: currentGlobalFilterFn,
|
|
7042
7095
|
isDensePadding: isDensePadding,
|
|
7043
7096
|
isFullScreen: isFullScreen,
|
|
7044
|
-
//@ts-ignore
|
|
7045
|
-
pagination: pagination,
|
|
7046
7097
|
showFilters: showFilters,
|
|
7047
7098
|
showGlobalFilter: showGlobalFilter
|
|
7048
7099
|
}, props.state)
|
|
@@ -7097,7 +7148,7 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
7097
7148
|
}));
|
|
7098
7149
|
};
|
|
7099
7150
|
|
|
7100
|
-
var _excluded$5 = ["autoResetExpanded", "columnResizeMode", "defaultColumn", "editingMode", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnResizing", "enableDensePaddingToggle", "enableExpandAll", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enablePagination", "enablePinning", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarBottom", "enableToolbarInternalActions", "enableToolbarTop", "icons", "localization", "persistentStateMode", "positionActionsColumn", "positionPagination", "positionToolbarActions", "positionToolbarAlertBanner"];
|
|
7151
|
+
var _excluded$5 = ["autoResetExpanded", "columnResizeMode", "defaultColumn", "editingMode", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnResizing", "enableDensePaddingToggle", "enableExpandAll", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enablePagination", "enablePinning", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarBottom", "enableToolbarInternalActions", "enableToolbarTop", "icons", "localization", "persistentStateMode", "positionActionsColumn", "positionPagination", "positionToolbarActions", "positionToolbarAlertBanner", "selectAllMode"];
|
|
7101
7152
|
var MaterialReactTable = (function (_ref) {
|
|
7102
7153
|
var _ref$autoResetExpande = _ref.autoResetExpanded,
|
|
7103
7154
|
autoResetExpanded = _ref$autoResetExpande === void 0 ? false : _ref$autoResetExpande,
|
|
@@ -7167,6 +7218,8 @@ var MaterialReactTable = (function (_ref) {
|
|
|
7167
7218
|
positionToolbarActions = _ref$positionToolbarA === void 0 ? 'top' : _ref$positionToolbarA,
|
|
7168
7219
|
_ref$positionToolbarA2 = _ref.positionToolbarAlertBanner,
|
|
7169
7220
|
positionToolbarAlertBanner = _ref$positionToolbarA2 === void 0 ? 'top' : _ref$positionToolbarA2,
|
|
7221
|
+
_ref$selectAllMode = _ref.selectAllMode,
|
|
7222
|
+
selectAllMode = _ref$selectAllMode === void 0 ? 'all' : _ref$selectAllMode,
|
|
7170
7223
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
7171
7224
|
|
|
7172
7225
|
return React__default.createElement(MRT_TableRoot, Object.assign({
|
|
@@ -7202,7 +7255,8 @@ var MaterialReactTable = (function (_ref) {
|
|
|
7202
7255
|
positionActionsColumn: positionActionsColumn,
|
|
7203
7256
|
positionPagination: positionPagination,
|
|
7204
7257
|
positionToolbarActions: positionToolbarActions,
|
|
7205
|
-
positionToolbarAlertBanner: positionToolbarAlertBanner
|
|
7258
|
+
positionToolbarAlertBanner: positionToolbarAlertBanner,
|
|
7259
|
+
selectAllMode: selectAllMode
|
|
7206
7260
|
}, rest));
|
|
7207
7261
|
});
|
|
7208
7262
|
|