@elliemae/ds-shared 2.2.0-alpha.3 → 3.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/Animations/BaseAnimation.js +35 -55
- package/cjs/Animations/Grow.js +41 -54
- package/cjs/Animations/GrowRight.js +41 -63
- package/cjs/Animations/GrowVertical.js +7 -47
- package/cjs/CheckableGroup.js +65 -67
- package/cjs/DeferRenderAfterComputation.js +24 -48
- package/cjs/FocusGroup/FocusGrid.js +143 -108
- package/cjs/FocusGroup/FocusGroup.js +147 -88
- package/cjs/FocusGroup/FocusGroupContext.js +11 -38
- package/cjs/FocusGroup/FocusGroupManager.js +47 -56
- package/cjs/FocusGroup/focusGroupManagerHoc.js +42 -52
- package/cjs/FocusGroup/index.js +21 -47
- package/cjs/FocusGroup/useFocusGroupItem.js +51 -59
- package/cjs/FocusGroup/utils/getNextCellPosition.js +27 -47
- package/cjs/GroupContext/Group.js +73 -64
- package/cjs/GroupContext/GroupContext.js +13 -36
- package/cjs/GroupContext/GroupItem.js +21 -39
- package/cjs/GroupContext/index.js +13 -39
- package/cjs/ScrollSync/ScrollSync.js +75 -60
- package/cjs/ScrollSync/ScrollSyncPane.js +60 -52
- package/cjs/ScrollSync/ScrollSyncProvider.js +50 -103
- package/cjs/ScrollSync/index.js +11 -37
- package/cjs/ScrollSync/useScrollSync.js +7 -38
- package/cjs/constants.js +46 -65
- package/cjs/createDataInstance/createInstancePlugin.js +29 -41
- package/cjs/createDataInstance/createInstanceRef.js +71 -66
- package/cjs/createDataInstance/utils.js +100 -76
- package/cjs/defer-render-hoc/index.js +41 -48
- package/cjs/dimsum.config.js +6 -38
- package/cjs/index.js +17 -40
- package/cjs/prop-types.js +49 -106
- package/cjs/react-spring/index.js +14 -28
- package/cjs/react-spring/renderprops.js +14 -28
- package/cjs/toolbar/ToolbarProvider.js +94 -82
- package/cjs/useDataGrid/VolatileRowsListener.js +13 -38
- package/cjs/useDataGrid/index.js +7 -36
- package/cjs/useDataGrid/initColumnDefinition.js +110 -105
- package/cjs/useDataGrid/useDataGrid.js +148 -122
- package/cjs/useDataList/index.js +7 -36
- package/cjs/useDataList/recordIterator.js +18 -42
- package/cjs/useDataList/useDataList.js +83 -74
- package/cjs/utils.js +80 -71
- package/cjs/virtualization/AutoHeightList.js +54 -62
- package/cjs/virtualization/FluidHeightList.js +48 -42
- package/cjs/virtualization/index.js +20 -48
- package/esm/Animations/BaseAnimation.js +29 -26
- package/esm/Animations/Grow.js +35 -25
- package/esm/Animations/GrowRight.js +35 -34
- package/esm/Animations/GrowVertical.js +4 -29
- package/esm/CheckableGroup.js +52 -35
- package/esm/DeferRenderAfterComputation.js +15 -16
- package/esm/FocusGroup/FocusGrid.js +117 -64
- package/esm/FocusGroup/FocusGroup.js +137 -56
- package/esm/FocusGroup/FocusGroupContext.js +5 -9
- package/esm/FocusGroup/FocusGroupManager.js +38 -24
- package/esm/FocusGroup/focusGroupManagerHoc.js +36 -24
- package/esm/FocusGroup/index.js +6 -18
- package/esm/FocusGroup/useFocusGroupItem.js +40 -28
- package/esm/FocusGroup/utils/getNextCellPosition.js +25 -18
- package/esm/GroupContext/Group.js +66 -34
- package/esm/GroupContext/GroupContext.js +5 -7
- package/esm/GroupContext/GroupItem.js +15 -10
- package/esm/GroupContext/index.js +3 -10
- package/esm/ScrollSync/ScrollSync.js +64 -30
- package/esm/ScrollSync/ScrollSyncPane.js +52 -22
- package/esm/ScrollSync/ScrollSyncProvider.js +42 -74
- package/esm/ScrollSync/index.js +2 -8
- package/esm/ScrollSync/useScrollSync.js +5 -9
- package/esm/constants.js +28 -37
- package/esm/createDataInstance/createInstancePlugin.js +23 -12
- package/esm/createDataInstance/createInstanceRef.js +59 -36
- package/esm/createDataInstance/utils.js +85 -48
- package/esm/defer-render-hoc/index.js +31 -17
- package/esm/dimsum.config.js +4 -9
- package/esm/index.js +5 -11
- package/esm/prop-types.js +31 -75
- package/esm/react-spring/index.js +1 -3
- package/esm/react-spring/renderprops.js +1 -3
- package/esm/toolbar/ToolbarProvider.js +74 -45
- package/esm/useDataGrid/VolatileRowsListener.js +11 -9
- package/esm/useDataGrid/index.js +1 -7
- package/esm/useDataGrid/initColumnDefinition.js +94 -78
- package/esm/useDataGrid/useDataGrid.js +99 -82
- package/esm/useDataList/index.js +1 -7
- package/esm/useDataList/recordIterator.js +14 -13
- package/esm/useDataList/useDataList.js +67 -44
- package/esm/utils.js +59 -42
- package/esm/virtualization/AutoHeightList.js +40 -28
- package/esm/virtualization/FluidHeightList.js +38 -14
- package/esm/virtualization/index.js +16 -19
- package/package.json +3 -3
- package/types/Animations/BaseAnimation.d.ts +0 -1
- package/types/Animations/Grow.d.ts +0 -1
- package/types/Animations/GrowRight.d.ts +0 -1
- package/types/CheckableGroup.d.ts +0 -1
- package/types/DeferRenderAfterComputation.d.ts +2 -3
- package/types/FocusGroup/FocusGrid.d.ts +3 -5
- package/types/FocusGroup/FocusGroup.d.ts +1 -3
- package/types/FocusGroup/FocusGroupContext.d.ts +2 -3
- package/types/FocusGroup/FocusGroupManager.d.ts +1 -3
- package/types/FocusGroup/focusGroupManagerHoc.d.ts +1 -3
- package/types/FocusGroup/index.d.ts +6 -6
- package/types/FocusGroup/useFocusGroupItem.d.ts +1 -3
- package/types/FocusGroup/utils/getNextCellPosition.d.ts +1 -3
- package/types/GroupContext/Group.d.ts +0 -1
- package/types/GroupContext/GroupItem.d.ts +0 -1
- package/types/GroupContext/index.d.ts +3 -3
- package/types/ScrollSync/ScrollSync.d.ts +2 -4
- package/types/ScrollSync/ScrollSyncPane.d.ts +2 -2
- package/types/ScrollSync/index.d.ts +2 -2
- package/types/ScrollSync/useScrollSync.d.ts +5 -6
- package/types/createDataInstance/createInstancePlugin.d.ts +1 -2
- package/types/createDataInstance/createInstanceRef.d.ts +1 -3
- package/types/dimsum.config.d.ts +2 -3
- package/types/index.d.ts +2 -2
- package/types/toolbar/ToolbarProvider.d.ts +8 -3
- package/types/useDataGrid/VolatileRowsListener.d.ts +1 -3
- package/types/useDataGrid/index.d.ts +1 -1
- package/types/useDataGrid/initColumnDefinition.d.ts +1 -2
- package/types/useDataGrid/useDataGrid.d.ts +2 -3
- package/types/useDataList/index.d.ts +1 -1
- package/types/useDataList/useDataList.d.ts +2 -3
- package/cjs/Animations/BaseAnimation.js.map +0 -7
- package/cjs/Animations/Grow.js.map +0 -7
- package/cjs/Animations/GrowRight.js.map +0 -7
- package/cjs/Animations/GrowVertical.js.map +0 -7
- package/cjs/CheckableGroup.js.map +0 -7
- package/cjs/DeferRenderAfterComputation.js.map +0 -7
- package/cjs/FocusGroup/FocusGrid.js.map +0 -7
- package/cjs/FocusGroup/FocusGroup.js.map +0 -7
- package/cjs/FocusGroup/FocusGroupContext.js.map +0 -7
- package/cjs/FocusGroup/FocusGroupManager.js.map +0 -7
- package/cjs/FocusGroup/focusGroupManagerHoc.js.map +0 -7
- package/cjs/FocusGroup/index.js.map +0 -7
- package/cjs/FocusGroup/useFocusGroupItem.js.map +0 -7
- package/cjs/FocusGroup/utils/getNextCellPosition.js.map +0 -7
- package/cjs/GroupContext/Group.js.map +0 -7
- package/cjs/GroupContext/GroupContext.js.map +0 -7
- package/cjs/GroupContext/GroupItem.js.map +0 -7
- package/cjs/GroupContext/index.js.map +0 -7
- package/cjs/ScrollSync/ScrollSync.js.map +0 -7
- package/cjs/ScrollSync/ScrollSyncPane.js.map +0 -7
- package/cjs/ScrollSync/ScrollSyncProvider.js.map +0 -7
- package/cjs/ScrollSync/index.js.map +0 -7
- package/cjs/ScrollSync/useScrollSync.js.map +0 -7
- package/cjs/constants.js.map +0 -7
- package/cjs/createDataInstance/createInstancePlugin.js.map +0 -7
- package/cjs/createDataInstance/createInstanceRef.js.map +0 -7
- package/cjs/createDataInstance/utils.js.map +0 -7
- package/cjs/defer-render-hoc/index.js.map +0 -7
- package/cjs/dimsum.config.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/prop-types.js.map +0 -7
- package/cjs/react-spring/index.js.map +0 -7
- package/cjs/react-spring/renderprops.js.map +0 -7
- package/cjs/toolbar/ToolbarProvider.js.map +0 -7
- package/cjs/useDataGrid/VolatileRowsListener.js.map +0 -7
- package/cjs/useDataGrid/index.js.map +0 -7
- package/cjs/useDataGrid/initColumnDefinition.js.map +0 -7
- package/cjs/useDataGrid/useDataGrid.js.map +0 -7
- package/cjs/useDataList/index.js.map +0 -7
- package/cjs/useDataList/recordIterator.js.map +0 -7
- package/cjs/useDataList/useDataList.js.map +0 -7
- package/cjs/utils.js.map +0 -7
- package/cjs/virtualization/AutoHeightList.js.map +0 -7
- package/cjs/virtualization/FluidHeightList.js.map +0 -7
- package/cjs/virtualization/index.js.map +0 -7
- package/esm/Animations/BaseAnimation.js.map +0 -7
- package/esm/Animations/Grow.js.map +0 -7
- package/esm/Animations/GrowRight.js.map +0 -7
- package/esm/Animations/GrowVertical.js.map +0 -7
- package/esm/CheckableGroup.js.map +0 -7
- package/esm/DeferRenderAfterComputation.js.map +0 -7
- package/esm/FocusGroup/FocusGrid.js.map +0 -7
- package/esm/FocusGroup/FocusGroup.js.map +0 -7
- package/esm/FocusGroup/FocusGroupContext.js.map +0 -7
- package/esm/FocusGroup/FocusGroupManager.js.map +0 -7
- package/esm/FocusGroup/focusGroupManagerHoc.js.map +0 -7
- package/esm/FocusGroup/index.js.map +0 -7
- package/esm/FocusGroup/useFocusGroupItem.js.map +0 -7
- package/esm/FocusGroup/utils/getNextCellPosition.js.map +0 -7
- package/esm/GroupContext/Group.js.map +0 -7
- package/esm/GroupContext/GroupContext.js.map +0 -7
- package/esm/GroupContext/GroupItem.js.map +0 -7
- package/esm/GroupContext/index.js.map +0 -7
- package/esm/ScrollSync/ScrollSync.js.map +0 -7
- package/esm/ScrollSync/ScrollSyncPane.js.map +0 -7
- package/esm/ScrollSync/ScrollSyncProvider.js.map +0 -7
- package/esm/ScrollSync/index.js.map +0 -7
- package/esm/ScrollSync/useScrollSync.js.map +0 -7
- package/esm/constants.js.map +0 -7
- package/esm/createDataInstance/createInstancePlugin.js.map +0 -7
- package/esm/createDataInstance/createInstanceRef.js.map +0 -7
- package/esm/createDataInstance/utils.js.map +0 -7
- package/esm/defer-render-hoc/index.js.map +0 -7
- package/esm/dimsum.config.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/prop-types.js.map +0 -7
- package/esm/react-spring/index.js.map +0 -7
- package/esm/react-spring/renderprops.js.map +0 -7
- package/esm/toolbar/ToolbarProvider.js.map +0 -7
- package/esm/useDataGrid/VolatileRowsListener.js.map +0 -7
- package/esm/useDataGrid/index.js.map +0 -7
- package/esm/useDataGrid/initColumnDefinition.js.map +0 -7
- package/esm/useDataGrid/useDataGrid.js.map +0 -7
- package/esm/useDataList/index.js.map +0 -7
- package/esm/useDataList/recordIterator.js.map +0 -7
- package/esm/useDataList/useDataList.js.map +0 -7
- package/esm/utils.js.map +0 -7
- package/esm/virtualization/AutoHeightList.js.map +0 -7
- package/esm/virtualization/FluidHeightList.js.map +0 -7
- package/esm/virtualization/index.js.map +0 -7
|
@@ -1,52 +1,76 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
7
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
8
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
9
|
+
import React, { useRef, useState, useEffect, useMemo } from 'react';
|
|
10
|
+
import DSPopover from '@elliemae/ds-popper';
|
|
11
|
+
import { useOnClickOutside } from '@elliemae/ds-utilities';
|
|
12
|
+
import { jsx } from 'react/jsx-runtime';
|
|
13
|
+
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
+
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
+
const ToolbarContext = /*#__PURE__*/React.createContext();
|
|
18
|
+
const {
|
|
19
|
+
Provider
|
|
20
|
+
} = ToolbarContext;
|
|
21
|
+
|
|
7
22
|
const useScrollListener = (callback, dependencies) => {
|
|
8
23
|
useEffect(() => {
|
|
9
|
-
window.addEventListener(
|
|
24
|
+
window.addEventListener('scroll', callback, true);
|
|
10
25
|
return () => {
|
|
11
|
-
window.removeEventListener(
|
|
26
|
+
window.removeEventListener('scroll', callback, true);
|
|
12
27
|
};
|
|
13
28
|
}, [dependencies]);
|
|
14
29
|
};
|
|
30
|
+
|
|
15
31
|
const noop = () => null;
|
|
16
|
-
|
|
32
|
+
|
|
33
|
+
function ToolbarProvider(_ref) {
|
|
34
|
+
let {
|
|
35
|
+
delay = 200,
|
|
36
|
+
children,
|
|
37
|
+
onHide = noop,
|
|
38
|
+
onShow = noop
|
|
39
|
+
} = _ref;
|
|
17
40
|
const showTimer = useRef();
|
|
18
41
|
const hideTimer = useRef();
|
|
19
42
|
const toolbarRef = useRef();
|
|
20
43
|
const [tooltipState, setTooltipState] = useState({});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
showTimer.current = setTimeout(() => setTooltipState({
|
|
25
|
-
...state,
|
|
44
|
+
|
|
45
|
+
const show = state => {
|
|
46
|
+
if (state.reference === tooltipState.reference) clearTimeout(hideTimer.current);
|
|
47
|
+
showTimer.current = setTimeout(() => setTooltipState(_objectSpread(_objectSpread({}, state), {}, {
|
|
26
48
|
visible: true
|
|
27
|
-
}), delay);
|
|
49
|
+
})), delay);
|
|
28
50
|
onShow();
|
|
29
51
|
};
|
|
52
|
+
|
|
30
53
|
const hide = (e, force) => {
|
|
31
|
-
if (!force)
|
|
32
|
-
|
|
33
|
-
hideTimer.current = setTimeout(() => setTooltipState((prevState) => ({
|
|
34
|
-
...prevState,
|
|
54
|
+
if (!force) clearTimeout(showTimer.current);
|
|
55
|
+
hideTimer.current = setTimeout(() => setTooltipState(prevState => _objectSpread(_objectSpread({}, prevState), {}, {
|
|
35
56
|
visible: false
|
|
36
57
|
})), 100);
|
|
37
58
|
onHide(tooltipState, e);
|
|
38
59
|
};
|
|
39
|
-
|
|
60
|
+
|
|
61
|
+
useScrollListener(e => hide(e, true), tooltipState.visible);
|
|
40
62
|
useOnClickOutside(toolbarRef, () => hide());
|
|
41
|
-
|
|
42
|
-
|
|
63
|
+
|
|
64
|
+
const keyDownHandler = e => {
|
|
65
|
+
if (e.key === 'Escape') {
|
|
43
66
|
hide(e);
|
|
44
67
|
}
|
|
45
68
|
};
|
|
69
|
+
|
|
46
70
|
useEffect(() => {
|
|
47
|
-
window.addEventListener(
|
|
71
|
+
window.addEventListener('keydown', keyDownHandler);
|
|
48
72
|
return () => {
|
|
49
|
-
window.removeEventListener(
|
|
73
|
+
window.removeEventListener('keydown', keyDownHandler);
|
|
50
74
|
};
|
|
51
75
|
});
|
|
52
76
|
const value = useMemo(() => ({
|
|
@@ -54,29 +78,34 @@ const ToolbarProvider = memo(({ delay = 200, children, onHide = noop, onShow = n
|
|
|
54
78
|
show,
|
|
55
79
|
hide
|
|
56
80
|
}), [tooltipState.reference]);
|
|
57
|
-
return
|
|
58
|
-
value
|
|
59
|
-
}, children,
|
|
60
|
-
boundaries: "scrollParent"
|
|
61
|
-
|
|
81
|
+
return /*#__PURE__*/_jsx(Provider, {
|
|
82
|
+
value: value
|
|
83
|
+
}, void 0, children, /*#__PURE__*/jsx(DSPopover, _objectSpread(_objectSpread({
|
|
84
|
+
boundaries: "scrollParent"
|
|
85
|
+
}, tooltipState.options || {}), {}, {
|
|
62
86
|
content: tooltipState.renderer,
|
|
63
87
|
placement: "left",
|
|
64
88
|
referenceEl: tooltipState.reference,
|
|
65
|
-
renderer:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
89
|
+
renderer: _ref2 => {
|
|
90
|
+
let {
|
|
91
|
+
as: Component,
|
|
92
|
+
style,
|
|
93
|
+
children: Content
|
|
94
|
+
} = _ref2;
|
|
95
|
+
return /*#__PURE__*/jsx("div", {
|
|
96
|
+
ref: toolbarRef,
|
|
97
|
+
onMouseEnter: e => show(tooltipState),
|
|
98
|
+
onMouseLeave: hide,
|
|
99
|
+
children: /*#__PURE__*/_jsx(Component, {
|
|
100
|
+
style: style
|
|
101
|
+
}, void 0, Content)
|
|
102
|
+
});
|
|
103
|
+
},
|
|
72
104
|
style: tooltipState.style,
|
|
73
105
|
visible: tooltipState.visible
|
|
74
|
-
}));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
ToolbarProvider_default as default
|
|
81
|
-
};
|
|
82
|
-
//# sourceMappingURL=ToolbarProvider.js.map
|
|
106
|
+
})));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
var ToolbarProvider$1 = /*#__PURE__*/React.memo(ToolbarProvider);
|
|
110
|
+
|
|
111
|
+
export { ToolbarContext, ToolbarProvider$1 as default };
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
|
+
import { safeCall } from '@elliemae/ds-utilities';
|
|
5
|
+
|
|
3
6
|
class VolatileRowsListener {
|
|
4
7
|
constructor() {
|
|
5
8
|
this.observers = [];
|
|
6
9
|
}
|
|
10
|
+
|
|
7
11
|
observe(listener) {
|
|
8
12
|
this.observers.push(listener);
|
|
9
13
|
}
|
|
14
|
+
|
|
10
15
|
notify(nextRows) {
|
|
11
|
-
this.observers.forEach(
|
|
16
|
+
this.observers.forEach(observer => safeCall(observer, nextRows));
|
|
12
17
|
this.observers = [];
|
|
13
18
|
}
|
|
19
|
+
|
|
14
20
|
}
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
VolatileRowsListener,
|
|
18
|
-
VolatileRowsListener_default as default
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=VolatileRowsListener.js.map
|
|
21
|
+
|
|
22
|
+
export { VolatileRowsListener as default };
|
package/esm/useDataGrid/index.js
CHANGED
|
@@ -1,34 +1,41 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
7
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
8
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
9
|
+
import 'core-js/modules/es.string.replace.js';
|
|
10
|
+
import 'react';
|
|
11
|
+
import { v4 } from 'uuid';
|
|
12
|
+
import { curry, get, cloneDeep, set, isFunction } from '@elliemae/ds-utilities';
|
|
13
|
+
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
+
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
+
|
|
18
|
+
const appendHeaderFormatter = curry((formatter, column) => _objectSpread(_objectSpread({}, column), {}, {
|
|
19
|
+
header: _objectSpread(_objectSpread({}, column.header), {}, {
|
|
20
|
+
formatters: [...get(column, 'header.formatters', []), formatter]
|
|
21
|
+
})
|
|
17
22
|
}));
|
|
18
|
-
const appendCellFormatter = curry((formatter, column
|
|
23
|
+
const appendCellFormatter = curry(function (formatter, column) {
|
|
24
|
+
let path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'formatters';
|
|
19
25
|
const nextColumn = cloneDeep(column);
|
|
20
|
-
const formatters = get(nextColumn, [
|
|
21
|
-
const scrollingFormatters = get(nextColumn,
|
|
26
|
+
const formatters = get(nextColumn, ['cell', path], []);
|
|
27
|
+
const scrollingFormatters = get(nextColumn, 'cell.scrollingFormatters', []);
|
|
28
|
+
|
|
22
29
|
if (Array.isArray(formatter)) {
|
|
23
|
-
if (formatter[1])
|
|
24
|
-
scrollingFormatters.push(formatter[1]);
|
|
30
|
+
if (formatter[1]) scrollingFormatters.push(formatter[1]);
|
|
25
31
|
formatters.push(formatter[0]);
|
|
26
32
|
} else {
|
|
27
33
|
formatters.push(formatter);
|
|
28
34
|
scrollingFormatters.push(formatter);
|
|
29
35
|
}
|
|
30
|
-
|
|
31
|
-
set(nextColumn,
|
|
36
|
+
|
|
37
|
+
set(nextColumn, ['cell', path], formatters);
|
|
38
|
+
set(nextColumn, 'cell.scrollingFormatters', scrollingFormatters);
|
|
32
39
|
return nextColumn;
|
|
33
40
|
});
|
|
34
41
|
const defaultColumnDefinitionOptions = {
|
|
@@ -38,81 +45,90 @@ const defaultColumnDefinitionOptions = {
|
|
|
38
45
|
visible: true
|
|
39
46
|
};
|
|
40
47
|
const mergeClassNameToColumnHeader = curry((className, column) => {
|
|
41
|
-
const headerProps = get(column, [
|
|
42
|
-
const headerClassName = headerProps.className ||
|
|
43
|
-
return {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
48
|
+
const headerProps = get(column, ['header', 'props'], {});
|
|
49
|
+
const headerClassName = headerProps.className || '';
|
|
50
|
+
return _objectSpread(_objectSpread({}, column), {}, {
|
|
51
|
+
header: _objectSpread(_objectSpread({}, column.header), {}, {
|
|
52
|
+
props: _objectSpread(_objectSpread({}, headerProps), {}, {
|
|
53
|
+
className: "".concat(headerClassName, " ").concat(className)
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
});
|
|
53
57
|
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
function initColumnDefinition() {
|
|
59
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
60
|
+
// eslint-disable-next-line complexity
|
|
61
|
+
return column => {
|
|
62
|
+
// todo: clean this
|
|
63
|
+
if (column.type === 'number') {
|
|
64
|
+
// eslint-disable-next-line no-param-reassign
|
|
57
65
|
column.cellStyle = {
|
|
58
|
-
textAlign:
|
|
66
|
+
textAlign: 'right'
|
|
59
67
|
};
|
|
60
68
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
|
|
70
|
+
const {
|
|
71
|
+
useTextTruncation = true,
|
|
72
|
+
isUserColumn,
|
|
73
|
+
visible,
|
|
74
|
+
normalize
|
|
75
|
+
} = _objectSpread(_objectSpread({}, defaultColumnDefinitionOptions), options);
|
|
76
|
+
|
|
65
77
|
if (normalize) {
|
|
66
|
-
|
|
67
|
-
column.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
// eslint-disable-next-line no-param-reassign
|
|
79
|
+
column.originalProperty = column.property; // eslint-disable-next-line no-param-reassign
|
|
80
|
+
|
|
81
|
+
column.property = column.property.replace(/\s+/g, '');
|
|
82
|
+
} // eslint-disable-next-line no-param-reassign
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
column.props = _objectSpread(_objectSpread({}, column.props), {}, {
|
|
71
86
|
style: {}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
|
|
87
|
+
}); // eslint-disable-next-line no-param-reassign
|
|
88
|
+
|
|
89
|
+
column.header = _objectSpread(_objectSpread({}, column.header), {}, {
|
|
75
90
|
label: column.label,
|
|
76
|
-
formatters: [...get(column, [
|
|
91
|
+
formatters: [...get(column, ['header', 'formatters'], [])],
|
|
77
92
|
props: {
|
|
78
93
|
style: column.headerStyle || {}
|
|
79
94
|
}
|
|
80
|
-
};
|
|
95
|
+
});
|
|
96
|
+
|
|
81
97
|
if (useTextTruncation && !(isFunction(column.customHeaderRenderer) || column.header.formatters.length)) {
|
|
82
|
-
column.header.formatters.push(
|
|
98
|
+
column.header.formatters.push(value => /*#__PURE__*/_jsx("span", {
|
|
83
99
|
className: "cell-value"
|
|
84
|
-
}, value));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
100
|
+
}, void 0, value));
|
|
101
|
+
} // eslint-disable-next-line no-param-reassign
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
column.cell = _objectSpread(_objectSpread({}, column.cell), {}, {
|
|
88
105
|
transforms: [],
|
|
89
|
-
formatters: [...get(column, [
|
|
90
|
-
scrollingFormatters: [...get(column, [
|
|
106
|
+
formatters: [...get(column, ['cell', 'formatters'], [])],
|
|
107
|
+
scrollingFormatters: [...get(column, ['cell', 'formatters'], [])],
|
|
91
108
|
props: {
|
|
92
109
|
style: column.cellStyle || {}
|
|
93
110
|
}
|
|
94
|
-
};
|
|
111
|
+
});
|
|
112
|
+
|
|
95
113
|
if (useTextTruncation && !(isFunction(column.customRenderer) || column.cell.formatters.length)) {
|
|
96
|
-
column.cell.formatters.push(
|
|
114
|
+
column.cell.formatters.push(value => /*#__PURE__*/_jsx("span", {
|
|
97
115
|
className: "cell-value",
|
|
98
116
|
style: {
|
|
99
|
-
justifyContent: column.type ===
|
|
117
|
+
justifyContent: column.type === 'number' ? 'flex-end' : 'flex-start'
|
|
100
118
|
}
|
|
101
|
-
}, value));
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
column.
|
|
119
|
+
}, void 0, value));
|
|
120
|
+
} // eslint-disable-next-line no-param-reassign
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
column.uuid = column.uuid || v4(); // eslint-disable-next-line no-param-reassign
|
|
124
|
+
|
|
125
|
+
column.visible = column.visible === undefined ? visible : column.visible; // eslint-disable-next-line no-param-reassign, max-lines
|
|
126
|
+
|
|
127
|
+
column.isUserColumn = column.isUserColumn || isUserColumn; // eslint-disable-next-line no-param-reassign
|
|
128
|
+
|
|
106
129
|
column.headerHookEffects = [];
|
|
107
130
|
return column;
|
|
108
131
|
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export {
|
|
112
|
-
appendCellFormatter,
|
|
113
|
-
appendHeaderFormatter,
|
|
114
|
-
initColumnDefinition_default as default,
|
|
115
|
-
initColumnDefinition,
|
|
116
|
-
mergeClassNameToColumnHeader
|
|
117
|
-
};
|
|
118
|
-
//# sourceMappingURL=initColumnDefinition.js.map
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export { appendCellFormatter, appendHeaderFormatter, initColumnDefinition as default, mergeClassNameToColumnHeader };
|
|
@@ -1,49 +1,61 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
3
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
6
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
8
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
9
|
+
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
10
|
+
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
11
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
12
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
13
|
+
import { useDerivedStateFromProps, compose, cloneDeep, usePrevious, isObject, isEqual, setRef } from '@elliemae/ds-utilities';
|
|
14
|
+
import { useRef, useState, useMemo } from 'react';
|
|
15
|
+
import { v4 } from 'uuid';
|
|
16
|
+
import * as resolve from 'table-resolver';
|
|
17
|
+
import initColumnDefinition from './initColumnDefinition.js';
|
|
18
|
+
import { applyDecorators, decorateColumns, reducePropsGetter } from '../createDataInstance/utils.js';
|
|
19
|
+
import VolatileRowsListener from './VolatileRowsListener.js';
|
|
20
|
+
import { isInternetExplorer } from '../utils.js';
|
|
21
|
+
|
|
22
|
+
const _excluded = ["uuid", "plugins", "rows", "columns", "renderers"];
|
|
23
|
+
|
|
24
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
|
+
|
|
26
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
|
+
const IS_INTERNET_EXPLORER = isInternetExplorer(); // TODO: Reuse createDataInstance for the grid the same
|
|
28
|
+
// way as the list does ex: packages/ds-shared/src/useDataList/useDataList.js
|
|
29
|
+
// eslint-disable-next-line max-statements
|
|
30
|
+
|
|
31
|
+
function useDataGrid(_ref) {
|
|
32
|
+
let {
|
|
33
|
+
uuid: uuidProp,
|
|
34
|
+
plugins: pluginsFromProps,
|
|
35
|
+
rows,
|
|
36
|
+
columns,
|
|
37
|
+
renderers = {}
|
|
38
|
+
} = _ref,
|
|
39
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
40
|
+
|
|
31
41
|
const plugins = pluginsFromProps;
|
|
32
42
|
const instance = useRef();
|
|
33
43
|
const tableRef = useRef();
|
|
34
44
|
const headerRef = useRef();
|
|
35
45
|
const bodyRef = useRef();
|
|
36
46
|
const bodyInnerRef = useRef();
|
|
37
|
-
const [uuid] = useState(uuidProp || (() =>
|
|
47
|
+
const [uuid] = useState(uuidProp || (() => v4()));
|
|
38
48
|
const [hasScroll, setHasScroll] = useState(false);
|
|
39
49
|
const [isRowDragging, setIsRowDragging] = useState(false);
|
|
40
50
|
const isScrolling = useRef();
|
|
41
|
-
const shouldRefocus = useRef();
|
|
42
|
-
|
|
51
|
+
const shouldRefocus = useRef(); // todo: we probably need a plugin for focus related stuff
|
|
52
|
+
|
|
53
|
+
const [RowsObserver] = useState(() => new VolatileRowsListener()); // todo move this with rows composition
|
|
54
|
+
|
|
43
55
|
const [originalRows, updateRows] = useDerivedStateFromProps(rows, {
|
|
44
56
|
onUpdate: resolve.resolve({
|
|
45
57
|
columns,
|
|
46
|
-
method:
|
|
58
|
+
method: extra => compose(resolve.byFunction('valueTransformation')(extra), resolve.nested(extra))
|
|
47
59
|
}),
|
|
48
60
|
updateOnStateChange: true
|
|
49
61
|
});
|
|
@@ -73,9 +85,11 @@ const useDataGrid = ({
|
|
|
73
85
|
updateRows
|
|
74
86
|
},
|
|
75
87
|
updateRows,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
88
|
+
// eslint-disable-next-line no-return-assign
|
|
89
|
+
enableEvents: () => document.body.style.pointerEvents = IS_INTERNET_EXPLORER ? '' : null,
|
|
90
|
+
// eslint-disable-next-line no-return-assign
|
|
91
|
+
disableEvents: () => document.body.style.pointerEvents = 'none',
|
|
92
|
+
observeRows: observer => RowsObserver.observe(observer),
|
|
79
93
|
hotKeys: {},
|
|
80
94
|
shouldRefocus,
|
|
81
95
|
isScrolling,
|
|
@@ -84,20 +98,21 @@ const useDataGrid = ({
|
|
|
84
98
|
isRowDragging,
|
|
85
99
|
plugins
|
|
86
100
|
};
|
|
101
|
+
|
|
87
102
|
instance.current.getState = () => instance.current.state;
|
|
103
|
+
|
|
88
104
|
instance.current.getInstance = () => instance.current;
|
|
105
|
+
|
|
89
106
|
const defaultDecorators = {
|
|
90
107
|
decorateGrid: [],
|
|
91
108
|
registerStateHook: [],
|
|
92
109
|
registerHotKeys: [],
|
|
93
110
|
decorateColumn: [],
|
|
94
|
-
decorateColumns: [
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
})(col))
|
|
100
|
-
],
|
|
111
|
+
decorateColumns: [cols => cols.map(col => initColumnDefinition({
|
|
112
|
+
useTextTruncation: col.useTextTruncation,
|
|
113
|
+
wrapText: props.wrapText,
|
|
114
|
+
normalize: props.normalizeDataKeys
|
|
115
|
+
})(col))],
|
|
101
116
|
decorateRenderers: [],
|
|
102
117
|
getRowProps: [],
|
|
103
118
|
getHeaderRowProps: [],
|
|
@@ -107,45 +122,51 @@ const useDataGrid = ({
|
|
|
107
122
|
composeRows: []
|
|
108
123
|
};
|
|
109
124
|
const decorators = useMemo(() => {
|
|
110
|
-
let nextDecorators = defaultDecorators;
|
|
111
|
-
|
|
125
|
+
let nextDecorators = defaultDecorators; // eslint-disable-next-line no-return-assign
|
|
126
|
+
|
|
127
|
+
plugins.forEach(plugin => nextDecorators = plugin(nextDecorators));
|
|
112
128
|
return nextDecorators;
|
|
113
129
|
}, [plugins]);
|
|
114
|
-
instance.current = decorators.decorateGrid.reduce((nextInstance, decorator) => ({
|
|
115
|
-
...nextInstance,
|
|
116
|
-
...decorator(instance.current)
|
|
117
|
-
}), instance.current);
|
|
130
|
+
instance.current = decorators.decorateGrid.reduce((nextInstance, decorator) => _objectSpread(_objectSpread({}, nextInstance), decorator(instance.current)), instance.current);
|
|
118
131
|
instance.current = decorators.registerStateHook.reduce((nextInstance, decorator) => {
|
|
119
|
-
const {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
...nextInstance.actions,
|
|
128
|
-
...actions
|
|
129
|
-
}
|
|
130
|
-
};
|
|
132
|
+
const {
|
|
133
|
+
state,
|
|
134
|
+
actions
|
|
135
|
+
} = decorator(instance.current);
|
|
136
|
+
return _objectSpread(_objectSpread({}, nextInstance), {}, {
|
|
137
|
+
state: _objectSpread(_objectSpread({}, nextInstance.state), state),
|
|
138
|
+
actions: _objectSpread(_objectSpread({}, nextInstance.actions), actions)
|
|
139
|
+
});
|
|
131
140
|
}, instance.current);
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
141
|
+
|
|
142
|
+
const reduceHotKey = (nextInstance, _ref2) => {
|
|
143
|
+
let {
|
|
144
|
+
key,
|
|
145
|
+
handler,
|
|
146
|
+
options
|
|
147
|
+
} = _ref2;
|
|
148
|
+
return _objectSpread(_objectSpread({}, nextInstance), {}, {
|
|
149
|
+
hotKeys: _objectSpread(_objectSpread({}, nextInstance.hotKeys), {}, {
|
|
150
|
+
[key]: {
|
|
151
|
+
handler,
|
|
152
|
+
options
|
|
153
|
+
}
|
|
154
|
+
})
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
|
|
139
158
|
instance.current = decorators.registerHotKeys.reduce((nextInstance, decorator) => {
|
|
140
159
|
const hotKeys = decorator(nextInstance);
|
|
160
|
+
|
|
141
161
|
if (Array.isArray(hotKeys)) {
|
|
142
162
|
return hotKeys.reduce(reduceHotKey, nextInstance);
|
|
143
163
|
}
|
|
164
|
+
|
|
144
165
|
return reduceHotKey(nextInstance, hotKeys);
|
|
145
166
|
}, instance.current);
|
|
146
167
|
instance.current.decoratedRenderers = applyDecorators(instance.current.decoratedRenderers, decorators.decorateRenderers, instance.current);
|
|
147
168
|
instance.current.decoratedColumns = useMemo(() => {
|
|
148
|
-
const visibleColumns = cloneDeep(columns).filter(
|
|
169
|
+
const visibleColumns = cloneDeep(columns).filter(column => typeof column.visible === 'undefined' || column.visible);
|
|
149
170
|
return visibleColumns.length ? decorateColumns(visibleColumns, decorators, instance.current) : [];
|
|
150
171
|
}, [columns]);
|
|
151
172
|
instance.current.getBodyProps = reducePropsGetter(decorators.getBodyProps, instance.current);
|
|
@@ -157,21 +178,17 @@ const useDataGrid = ({
|
|
|
157
178
|
RowsObserver.notify(instance.current.composedRows);
|
|
158
179
|
const currentShouldRefocus = instance.current.shouldRefocus.current;
|
|
159
180
|
const prevState = usePrevious(instance.current.state);
|
|
181
|
+
|
|
160
182
|
if (isObject(currentShouldRefocus) && currentShouldRefocus.forced) {
|
|
161
183
|
instance.current.shouldRefocus.current = currentShouldRefocus.value;
|
|
162
184
|
} else {
|
|
163
185
|
instance.current.shouldRefocus.current = !isEqual(prevState, instance.current.state);
|
|
164
186
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
return {
|
|
168
|
-
...instance.current,
|
|
187
|
+
|
|
188
|
+
if (props.instanceRef) setRef(props.instanceRef, instance.current);
|
|
189
|
+
return _objectSpread(_objectSpread({}, instance.current), {}, {
|
|
169
190
|
decorators
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export {
|
|
174
|
-
useDataGrid_default as default,
|
|
175
|
-
useDataGrid
|
|
176
|
-
};
|
|
177
|
-
//# sourceMappingURL=useDataGrid.js.map
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export { useDataGrid as default };
|