@elliemae/ds-shared 2.3.0-alpha.8 → 2.3.0-next.10
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 +36 -0
- package/cjs/Animations/Grow.js +42 -0
- package/cjs/Animations/GrowRight.js +42 -0
- package/cjs/Animations/GrowVertical.js +7 -0
- package/cjs/CheckableGroup.js +74 -0
- package/cjs/DeferRenderAfterComputation.js +28 -0
- package/cjs/FocusGroup/FocusGrid.js +215 -0
- package/cjs/FocusGroup/FocusGroup.js +308 -0
- package/cjs/FocusGroup/FocusGroupContext.js +11 -0
- package/cjs/FocusGroup/FocusGroupManager.js +117 -0
- package/cjs/FocusGroup/focusGroupManagerHoc.js +44 -0
- package/cjs/FocusGroup/index.js +21 -0
- package/cjs/FocusGroup/useFocusGroupItem.js +59 -0
- package/cjs/FocusGroup/utils/getNextCellPosition.js +60 -0
- package/cjs/GroupContext/Group.js +124 -0
- package/cjs/GroupContext/GroupContext.js +13 -0
- package/cjs/GroupContext/GroupItem.js +22 -0
- package/cjs/GroupContext/index.js +13 -0
- package/cjs/ScrollSync/ScrollSync.js +153 -0
- package/cjs/ScrollSync/ScrollSyncPane.js +81 -0
- package/cjs/ScrollSync/ScrollSyncProvider.js +67 -0
- package/cjs/ScrollSync/index.js +11 -0
- package/cjs/ScrollSync/useScrollSync.js +10 -0
- package/cjs/constants.js +51 -0
- package/cjs/createDataInstance/createInstancePlugin.js +36 -0
- package/cjs/createDataInstance/createInstanceRef.js +97 -0
- package/cjs/createDataInstance/utils.js +123 -0
- package/cjs/defer-render-hoc/index.js +49 -0
- package/cjs/dimsum.config.js +7 -0
- package/cjs/index.js +17 -0
- package/cjs/prop-types.js +59 -0
- package/cjs/react-spring/index.js +14 -0
- package/cjs/react-spring/renderprops.js +14 -0
- package/cjs/toolbar/ToolbarProvider.js +123 -0
- package/cjs/useDataGrid/VolatileRowsListener.js +24 -0
- package/cjs/useDataGrid/index.js +7 -0
- package/cjs/useDataGrid/initColumnDefinition.js +146 -0
- package/cjs/useDataGrid/useDataGrid.js +220 -0
- package/cjs/useDataList/index.js +7 -0
- package/cjs/useDataList/recordIterator.js +31 -0
- package/cjs/useDataList/useDataList.js +102 -0
- package/cjs/utils.js +116 -0
- package/cjs/virtualization/AutoHeightList.js +61 -0
- package/cjs/virtualization/FluidHeightList.js +49 -0
- package/cjs/virtualization/index.js +22 -0
- package/esm/Animations/BaseAnimation.js +30 -0
- package/esm/Animations/Grow.js +36 -0
- package/esm/Animations/GrowRight.js +36 -0
- package/esm/Animations/GrowVertical.js +4 -0
- package/esm/CheckableGroup.js +64 -0
- package/esm/DeferRenderAfterComputation.js +22 -0
- package/esm/FocusGroup/FocusGrid.js +204 -0
- package/{dist/esm → esm}/FocusGroup/FocusGroup.js +137 -56
- package/esm/FocusGroup/FocusGroupContext.js +5 -0
- package/{dist/esm → esm}/FocusGroup/FocusGroupManager.js +38 -24
- package/esm/FocusGroup/focusGroupManagerHoc.js +37 -0
- package/esm/FocusGroup/index.js +6 -0
- package/esm/FocusGroup/useFocusGroupItem.js +50 -0
- package/{dist/esm → esm}/FocusGroup/utils/getNextCellPosition.js +25 -18
- package/esm/GroupContext/Group.js +118 -0
- package/esm/GroupContext/GroupContext.js +5 -0
- package/esm/GroupContext/GroupItem.js +16 -0
- package/esm/GroupContext/index.js +3 -0
- package/{dist/esm → esm}/ScrollSync/ScrollSync.js +64 -30
- package/esm/ScrollSync/ScrollSyncPane.js +74 -0
- package/esm/ScrollSync/ScrollSyncProvider.js +59 -0
- package/esm/ScrollSync/index.js +2 -0
- package/esm/ScrollSync/useScrollSync.js +8 -0
- package/esm/constants.js +32 -0
- package/esm/createDataInstance/createInstancePlugin.js +30 -0
- package/esm/createDataInstance/createInstanceRef.js +90 -0
- package/esm/createDataInstance/utils.js +107 -0
- package/esm/defer-render-hoc/index.js +41 -0
- package/esm/dimsum.config.js +5 -0
- package/esm/index.js +5 -0
- package/esm/prop-types.js +43 -0
- package/esm/react-spring/index.js +1 -0
- package/esm/react-spring/renderprops.js +1 -0
- package/esm/toolbar/ToolbarProvider.js +111 -0
- package/esm/useDataGrid/VolatileRowsListener.js +22 -0
- package/esm/useDataGrid/index.js +1 -0
- package/esm/useDataGrid/initColumnDefinition.js +134 -0
- package/esm/useDataGrid/useDataGrid.js +194 -0
- package/esm/useDataList/index.js +1 -0
- package/esm/useDataList/recordIterator.js +27 -0
- package/esm/useDataList/useDataList.js +90 -0
- package/esm/utils.js +95 -0
- package/esm/virtualization/AutoHeightList.js +52 -0
- package/esm/virtualization/FluidHeightList.js +38 -0
- package/esm/virtualization/index.js +18 -0
- package/package.json +108 -110
- package/types/Animations/BaseAnimation.d.ts +12 -0
- package/types/Animations/Grow.d.ts +11 -0
- package/types/Animations/GrowRight.d.ts +11 -0
- package/types/Animations/GrowVertical.d.ts +1 -0
- package/types/CheckableGroup.d.ts +20 -0
- package/types/DeferRenderAfterComputation.d.ts +6 -0
- package/types/FocusGroup/FocusGrid.d.ts +10 -0
- package/types/FocusGroup/FocusGroup.d.ts +36 -0
- package/types/FocusGroup/FocusGroupContext.d.ts +3 -0
- package/types/FocusGroup/FocusGroupManager.d.ts +24 -0
- package/types/FocusGroup/focusGroupManagerHoc.d.ts +7 -0
- package/types/FocusGroup/index.d.ts +6 -0
- package/types/FocusGroup/useFocusGroupItem.d.ts +2 -0
- package/types/FocusGroup/utils/getNextCellPosition.d.ts +12 -0
- package/types/GroupContext/Group.d.ts +14 -0
- package/types/GroupContext/GroupContext.d.ts +2 -0
- package/types/GroupContext/GroupItem.d.ts +5 -0
- package/types/GroupContext/index.d.ts +3 -0
- package/types/ScrollSync/ScrollSync.d.ts +21 -0
- package/types/ScrollSync/ScrollSyncPane.d.ts +3 -0
- package/types/ScrollSync/ScrollSyncProvider.d.ts +12 -0
- package/types/ScrollSync/index.d.ts +2 -0
- package/types/ScrollSync/useScrollSync.d.ts +6 -0
- package/types/constants.d.ts +30 -0
- package/types/createDataInstance/createInstancePlugin.d.ts +1 -0
- package/types/createDataInstance/createInstanceRef.d.ts +12 -0
- package/types/createDataInstance/tests/createInstanceRef.test.d.ts +0 -0
- package/types/createDataInstance/utils.d.ts +9 -0
- package/types/dimsum.config.d.ts +4 -0
- package/types/index.d.ts +2 -0
- package/types/prop-types.d.ts +41 -0
- package/types/react-spring/index.d.ts +1 -0
- package/types/react-spring/renderprops.d.ts +1 -0
- package/types/toolbar/ToolbarProvider.d.ts +10 -0
- package/types/useDataGrid/VolatileRowsListener.d.ts +5 -0
- package/types/useDataGrid/index.d.ts +1 -0
- package/types/useDataGrid/initColumnDefinition.d.ts +5 -0
- package/types/useDataGrid/useDataGrid.d.ts +8 -0
- package/types/useDataList/index.d.ts +1 -0
- package/types/useDataList/recordIterator.d.ts +1 -0
- package/types/useDataList/useDataList.d.ts +13 -0
- package/types/utils.d.ts +22 -0
- package/types/virtualization/AutoHeightList.d.ts +2 -0
- package/types/virtualization/FluidHeightList.d.ts +2 -0
- package/types/virtualization/index.d.ts +9 -0
- package/dist/cjs/Animations/BaseAnimation.js +0 -56
- package/dist/cjs/Animations/BaseAnimation.js.map +0 -7
- package/dist/cjs/Animations/Grow.js +0 -55
- package/dist/cjs/Animations/Grow.js.map +0 -7
- package/dist/cjs/Animations/GrowRight.js +0 -64
- package/dist/cjs/Animations/GrowRight.js.map +0 -7
- package/dist/cjs/Animations/GrowVertical.js +0 -47
- package/dist/cjs/Animations/GrowVertical.js.map +0 -7
- package/dist/cjs/CheckableGroup.js +0 -76
- package/dist/cjs/CheckableGroup.js.map +0 -7
- package/dist/cjs/DeferRenderAfterComputation.js +0 -52
- package/dist/cjs/DeferRenderAfterComputation.js.map +0 -7
- package/dist/cjs/FocusGroup/FocusGrid.js +0 -180
- package/dist/cjs/FocusGroup/FocusGrid.js.map +0 -7
- package/dist/cjs/FocusGroup/FocusGroup.js +0 -249
- package/dist/cjs/FocusGroup/FocusGroup.js.map +0 -7
- package/dist/cjs/FocusGroup/FocusGroupContext.js +0 -38
- package/dist/cjs/FocusGroup/FocusGroupContext.js.map +0 -7
- package/dist/cjs/FocusGroup/FocusGroupManager.js +0 -126
- package/dist/cjs/FocusGroup/FocusGroupManager.js.map +0 -7
- package/dist/cjs/FocusGroup/focusGroupManagerHoc.js +0 -54
- package/dist/cjs/FocusGroup/focusGroupManagerHoc.js.map +0 -7
- package/dist/cjs/FocusGroup/index.js +0 -47
- package/dist/cjs/FocusGroup/index.js.map +0 -7
- package/dist/cjs/FocusGroup/useFocusGroupItem.js +0 -67
- package/dist/cjs/FocusGroup/useFocusGroupItem.js.map +0 -7
- package/dist/cjs/FocusGroup/utils/getNextCellPosition.js +0 -80
- package/dist/cjs/FocusGroup/utils/getNextCellPosition.js.map +0 -7
- package/dist/cjs/GroupContext/Group.js +0 -115
- package/dist/cjs/GroupContext/Group.js.map +0 -7
- package/dist/cjs/GroupContext/GroupContext.js +0 -36
- package/dist/cjs/GroupContext/GroupContext.js.map +0 -7
- package/dist/cjs/GroupContext/GroupItem.js +0 -40
- package/dist/cjs/GroupContext/GroupItem.js.map +0 -7
- package/dist/cjs/GroupContext/index.js +0 -39
- package/dist/cjs/GroupContext/index.js.map +0 -7
- package/dist/cjs/ScrollSync/ScrollSync.js +0 -138
- package/dist/cjs/ScrollSync/ScrollSync.js.map +0 -7
- package/dist/cjs/ScrollSync/ScrollSyncPane.js +0 -73
- package/dist/cjs/ScrollSync/ScrollSyncPane.js.map +0 -7
- package/dist/cjs/ScrollSync/ScrollSyncProvider.js +0 -120
- package/dist/cjs/ScrollSync/ScrollSyncProvider.js.map +0 -7
- package/dist/cjs/ScrollSync/index.js +0 -37
- package/dist/cjs/ScrollSync/index.js.map +0 -7
- package/dist/cjs/ScrollSync/useScrollSync.js +0 -41
- package/dist/cjs/ScrollSync/useScrollSync.js.map +0 -7
- package/dist/cjs/constants.js +0 -70
- package/dist/cjs/constants.js.map +0 -7
- package/dist/cjs/createDataInstance/createInstancePlugin.js +0 -48
- package/dist/cjs/createDataInstance/createInstancePlugin.js.map +0 -7
- package/dist/cjs/createDataInstance/createInstanceRef.js +0 -92
- package/dist/cjs/createDataInstance/createInstanceRef.js.map +0 -7
- package/dist/cjs/createDataInstance/utils.js +0 -99
- package/dist/cjs/createDataInstance/utils.js.map +0 -7
- package/dist/cjs/defer-render-hoc/index.js +0 -56
- package/dist/cjs/defer-render-hoc/index.js.map +0 -7
- package/dist/cjs/dimsum.config.js +0 -39
- package/dist/cjs/dimsum.config.js.map +0 -7
- package/dist/cjs/index.js +0 -40
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/prop-types.js +0 -116
- package/dist/cjs/prop-types.js.map +0 -7
- package/dist/cjs/react-spring/index.js +0 -28
- package/dist/cjs/react-spring/index.js.map +0 -7
- package/dist/cjs/react-spring/renderprops.js +0 -28
- package/dist/cjs/react-spring/renderprops.js.map +0 -7
- package/dist/cjs/toolbar/ToolbarProvider.js +0 -111
- package/dist/cjs/toolbar/ToolbarProvider.js.map +0 -7
- package/dist/cjs/useDataGrid/VolatileRowsListener.js +0 -49
- package/dist/cjs/useDataGrid/VolatileRowsListener.js.map +0 -7
- package/dist/cjs/useDataGrid/index.js +0 -36
- package/dist/cjs/useDataGrid/index.js.map +0 -7
- package/dist/cjs/useDataGrid/initColumnDefinition.js +0 -141
- package/dist/cjs/useDataGrid/initColumnDefinition.js.map +0 -7
- package/dist/cjs/useDataGrid/useDataGrid.js +0 -194
- package/dist/cjs/useDataGrid/useDataGrid.js.map +0 -7
- package/dist/cjs/useDataList/index.js +0 -36
- package/dist/cjs/useDataList/index.js.map +0 -7
- package/dist/cjs/useDataList/recordIterator.js +0 -55
- package/dist/cjs/useDataList/recordIterator.js.map +0 -7
- package/dist/cjs/useDataList/useDataList.js +0 -93
- package/dist/cjs/useDataList/useDataList.js.map +0 -7
- package/dist/cjs/utils.js +0 -107
- package/dist/cjs/utils.js.map +0 -7
- package/dist/cjs/virtualization/AutoHeightList.js +0 -69
- package/dist/cjs/virtualization/AutoHeightList.js.map +0 -7
- package/dist/cjs/virtualization/FluidHeightList.js +0 -43
- package/dist/cjs/virtualization/FluidHeightList.js.map +0 -7
- package/dist/cjs/virtualization/index.js +0 -50
- package/dist/cjs/virtualization/index.js.map +0 -7
- package/dist/esm/Animations/BaseAnimation.js +0 -27
- package/dist/esm/Animations/BaseAnimation.js.map +0 -7
- package/dist/esm/Animations/Grow.js +0 -26
- package/dist/esm/Animations/Grow.js.map +0 -7
- package/dist/esm/Animations/GrowRight.js +0 -35
- package/dist/esm/Animations/GrowRight.js.map +0 -7
- package/dist/esm/Animations/GrowVertical.js +0 -29
- package/dist/esm/Animations/GrowVertical.js.map +0 -7
- package/dist/esm/CheckableGroup.js +0 -47
- package/dist/esm/CheckableGroup.js.map +0 -7
- package/dist/esm/DeferRenderAfterComputation.js +0 -23
- package/dist/esm/DeferRenderAfterComputation.js.map +0 -7
- package/dist/esm/FocusGroup/FocusGrid.js +0 -151
- package/dist/esm/FocusGroup/FocusGrid.js.map +0 -7
- package/dist/esm/FocusGroup/FocusGroup.js.map +0 -7
- package/dist/esm/FocusGroup/FocusGroupContext.js +0 -9
- package/dist/esm/FocusGroup/FocusGroupContext.js.map +0 -7
- package/dist/esm/FocusGroup/FocusGroupManager.js.map +0 -7
- package/dist/esm/FocusGroup/focusGroupManagerHoc.js +0 -25
- package/dist/esm/FocusGroup/focusGroupManagerHoc.js.map +0 -7
- package/dist/esm/FocusGroup/index.js +0 -18
- package/dist/esm/FocusGroup/index.js.map +0 -7
- package/dist/esm/FocusGroup/useFocusGroupItem.js +0 -38
- package/dist/esm/FocusGroup/useFocusGroupItem.js.map +0 -7
- package/dist/esm/FocusGroup/utils/getNextCellPosition.js.map +0 -7
- package/dist/esm/GroupContext/Group.js +0 -86
- package/dist/esm/GroupContext/Group.js.map +0 -7
- package/dist/esm/GroupContext/GroupContext.js +0 -7
- package/dist/esm/GroupContext/GroupContext.js.map +0 -7
- package/dist/esm/GroupContext/GroupItem.js +0 -11
- package/dist/esm/GroupContext/GroupItem.js.map +0 -7
- package/dist/esm/GroupContext/index.js +0 -10
- package/dist/esm/GroupContext/index.js.map +0 -7
- package/dist/esm/ScrollSync/ScrollSync.js.map +0 -7
- package/dist/esm/ScrollSync/ScrollSyncPane.js +0 -44
- package/dist/esm/ScrollSync/ScrollSyncPane.js.map +0 -7
- package/dist/esm/ScrollSync/ScrollSyncProvider.js +0 -91
- package/dist/esm/ScrollSync/ScrollSyncProvider.js.map +0 -7
- package/dist/esm/ScrollSync/index.js +0 -8
- package/dist/esm/ScrollSync/index.js.map +0 -7
- package/dist/esm/ScrollSync/useScrollSync.js +0 -12
- package/dist/esm/ScrollSync/useScrollSync.js.map +0 -7
- package/dist/esm/constants.js +0 -41
- package/dist/esm/constants.js.map +0 -7
- package/dist/esm/createDataInstance/createInstancePlugin.js +0 -19
- package/dist/esm/createDataInstance/createInstancePlugin.js.map +0 -7
- package/dist/esm/createDataInstance/createInstanceRef.js +0 -67
- package/dist/esm/createDataInstance/createInstanceRef.js.map +0 -7
- package/dist/esm/createDataInstance/utils.js +0 -70
- package/dist/esm/createDataInstance/utils.js.map +0 -7
- package/dist/esm/defer-render-hoc/index.js +0 -27
- package/dist/esm/defer-render-hoc/index.js.map +0 -7
- package/dist/esm/dimsum.config.js +0 -10
- package/dist/esm/dimsum.config.js.map +0 -7
- package/dist/esm/index.js +0 -11
- package/dist/esm/index.js.map +0 -7
- package/dist/esm/prop-types.js +0 -87
- package/dist/esm/prop-types.js.map +0 -7
- package/dist/esm/react-spring/index.js +0 -3
- package/dist/esm/react-spring/index.js.map +0 -7
- package/dist/esm/react-spring/renderprops.js +0 -3
- package/dist/esm/react-spring/renderprops.js.map +0 -7
- package/dist/esm/toolbar/ToolbarProvider.js +0 -82
- package/dist/esm/toolbar/ToolbarProvider.js.map +0 -7
- package/dist/esm/useDataGrid/VolatileRowsListener.js +0 -20
- package/dist/esm/useDataGrid/VolatileRowsListener.js.map +0 -7
- package/dist/esm/useDataGrid/index.js +0 -7
- package/dist/esm/useDataGrid/index.js.map +0 -7
- package/dist/esm/useDataGrid/initColumnDefinition.js +0 -118
- package/dist/esm/useDataGrid/initColumnDefinition.js.map +0 -7
- package/dist/esm/useDataGrid/useDataGrid.js +0 -177
- package/dist/esm/useDataGrid/useDataGrid.js.map +0 -7
- package/dist/esm/useDataList/index.js +0 -7
- package/dist/esm/useDataList/index.js.map +0 -7
- package/dist/esm/useDataList/recordIterator.js +0 -26
- package/dist/esm/useDataList/recordIterator.js.map +0 -7
- package/dist/esm/useDataList/useDataList.js +0 -67
- package/dist/esm/useDataList/useDataList.js.map +0 -7
- package/dist/esm/utils.js +0 -78
- package/dist/esm/utils.js.map +0 -7
- package/dist/esm/virtualization/AutoHeightList.js +0 -40
- package/dist/esm/virtualization/AutoHeightList.js.map +0 -7
- package/dist/esm/virtualization/FluidHeightList.js +0 -14
- package/dist/esm/virtualization/FluidHeightList.js.map +0 -7
- package/dist/esm/virtualization/index.js +0 -21
- package/dist/esm/virtualization/index.js.map +0 -7
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
4
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var GroupContext = require('./GroupContext.js');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
11
|
+
|
|
12
|
+
const getValueItem = e => {
|
|
13
|
+
const {
|
|
14
|
+
target,
|
|
15
|
+
currentTarget
|
|
16
|
+
} = e;
|
|
17
|
+
|
|
18
|
+
if (target) {
|
|
19
|
+
const {
|
|
20
|
+
value
|
|
21
|
+
} = target;
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (currentTarget) {
|
|
26
|
+
const {
|
|
27
|
+
value
|
|
28
|
+
} = currentTarget;
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return e;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const toggleItemValue = (array, e) => {
|
|
36
|
+
const newvalue = getValueItem(e);
|
|
37
|
+
const res = array;
|
|
38
|
+
const index = array.indexOf(newvalue);
|
|
39
|
+
|
|
40
|
+
if (index === -1) {
|
|
41
|
+
res.push(newvalue);
|
|
42
|
+
} else {
|
|
43
|
+
res.splice(index, 1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return res;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const {
|
|
50
|
+
Provider
|
|
51
|
+
} = GroupContext.GroupContext;
|
|
52
|
+
/** deprecated use CheckableGroup instead */
|
|
53
|
+
|
|
54
|
+
class Group extends React.Component {
|
|
55
|
+
constructor(props) {
|
|
56
|
+
super(props);
|
|
57
|
+
const {
|
|
58
|
+
activeValue,
|
|
59
|
+
disabled
|
|
60
|
+
} = props;
|
|
61
|
+
this.state = {
|
|
62
|
+
activeValue,
|
|
63
|
+
disabled,
|
|
64
|
+
prevValue: null,
|
|
65
|
+
onChange: this.handleChange.bind(this)
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static getDerivedStateFromProps(nextProps, _ref) {
|
|
70
|
+
let {
|
|
71
|
+
prevValue
|
|
72
|
+
} = _ref;
|
|
73
|
+
if (nextProps.activeValue === prevValue) return null;
|
|
74
|
+
return {
|
|
75
|
+
activeValue: nextProps.activeValue,
|
|
76
|
+
prevValue: nextProps.activeValue
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
handleChange(e) {
|
|
81
|
+
const {
|
|
82
|
+
multiple,
|
|
83
|
+
onChange
|
|
84
|
+
} = this.props;
|
|
85
|
+
const {
|
|
86
|
+
activeValue
|
|
87
|
+
} = this.state;
|
|
88
|
+
const value = getValueItem(e);
|
|
89
|
+
let newValue;
|
|
90
|
+
|
|
91
|
+
if (multiple) {
|
|
92
|
+
newValue = toggleItemValue(activeValue || [], value);
|
|
93
|
+
} else if (activeValue !== value) {
|
|
94
|
+
// default behaviour it will be toggle the active value
|
|
95
|
+
newValue = value;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
this.setState({
|
|
99
|
+
activeValue: newValue
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
103
|
+
rest[_key - 1] = arguments[_key];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (onChange) onChange(newValue, ...rest);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
render() {
|
|
110
|
+
const {
|
|
111
|
+
children
|
|
112
|
+
} = this.props;
|
|
113
|
+
return /*#__PURE__*/_jsx__default["default"](Provider, {
|
|
114
|
+
value: this.state
|
|
115
|
+
}, void 0, children);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
Group.defaultProps = {
|
|
121
|
+
multiple: false
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
module.exports = Group;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
|
+
|
|
11
|
+
const GroupContext = /*#__PURE__*/React__default["default"].createContext();
|
|
12
|
+
|
|
13
|
+
exports.GroupContext = GroupContext;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
4
|
+
require('react');
|
|
5
|
+
var GroupContext = require('./GroupContext.js');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
10
|
+
|
|
11
|
+
const {
|
|
12
|
+
Consumer
|
|
13
|
+
} = GroupContext.GroupContext;
|
|
14
|
+
|
|
15
|
+
const GroupItem = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
render
|
|
18
|
+
} = _ref;
|
|
19
|
+
return /*#__PURE__*/_jsx__default["default"](Consumer, {}, void 0, context => render(context));
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
module.exports = GroupItem;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var Group = require('./Group.js');
|
|
6
|
+
var GroupContext = require('./GroupContext.js');
|
|
7
|
+
var GroupItem = require('./GroupItem.js');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.Group = Group;
|
|
12
|
+
exports.GroupContext = GroupContext.GroupContext;
|
|
13
|
+
exports.GroupItem = GroupItem;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
9
|
+
require('core-js/modules/esnext.async-iterator.find.js');
|
|
10
|
+
require('core-js/modules/esnext.iterator.find.js');
|
|
11
|
+
var React = require('react');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
+
|
|
15
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
16
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
17
|
+
|
|
18
|
+
const ScrollSyncContext = /*#__PURE__*/React__default["default"].createContext();
|
|
19
|
+
const {
|
|
20
|
+
Provider
|
|
21
|
+
} = ScrollSyncContext;
|
|
22
|
+
class ScrollSync extends React.Component {
|
|
23
|
+
constructor(props) {
|
|
24
|
+
super(props);
|
|
25
|
+
this.panes = {};
|
|
26
|
+
|
|
27
|
+
this.registerPane = (node, groups) => {
|
|
28
|
+
groups.forEach(group => {
|
|
29
|
+
if (!this.panes[group]) {
|
|
30
|
+
this.panes[group] = [];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (this.panes[group].length > 0) {
|
|
34
|
+
this.syncScrollPosition(this.panes[group][0], node);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
this.panes[group].push(node);
|
|
38
|
+
});
|
|
39
|
+
this.addEvents(node, groups);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
this.unregisterPane = (node, groups) => {
|
|
43
|
+
groups.forEach(group => {
|
|
44
|
+
if (this.findPane(node, group)) {
|
|
45
|
+
this.removeEvents(node);
|
|
46
|
+
this.panes[group].splice(this.panes[group].indexOf(node), 1);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
this.addEvents = (node, groups) => {
|
|
52
|
+
/* For some reason element.addEventListener doesnt work with document.body */
|
|
53
|
+
node.onscroll = this.handlePaneScroll.bind(this, node, groups); // eslint-disable-line
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
this.removeEvents = node => {
|
|
57
|
+
/* For some reason element.removeEventListener doesnt work with document.body */
|
|
58
|
+
node.onscroll = null; // eslint-disable-line
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
this.findPane = (node, group) => {
|
|
62
|
+
if (!this.panes[group]) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return this.panes[group].find(pane => pane === node);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
this.handlePaneScroll = (node, groups, e) => {
|
|
70
|
+
const {
|
|
71
|
+
enabled
|
|
72
|
+
} = this.props;
|
|
73
|
+
if (this.props.onScroll) this.props.onScroll(e);
|
|
74
|
+
if (!enabled) return;
|
|
75
|
+
window.requestAnimationFrame(() => {
|
|
76
|
+
this.syncScrollPositions(node, groups);
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
this.syncScrollPositions = (scrolledPane, groups) => {
|
|
81
|
+
groups.forEach(group => {
|
|
82
|
+
this.panes[group].forEach(pane => {
|
|
83
|
+
/* For all panes beside the currently scrolling one */
|
|
84
|
+
if (scrolledPane !== pane) {
|
|
85
|
+
/* Remove event listeners from the node that we'll manipulate */
|
|
86
|
+
this.removeEvents(pane, group);
|
|
87
|
+
this.syncScrollPosition(scrolledPane, pane);
|
|
88
|
+
/* Re-attach event listeners after we're done scrolling */
|
|
89
|
+
|
|
90
|
+
window.requestAnimationFrame(() => {
|
|
91
|
+
this.addEvents(pane, groups);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
this.syncContext = {
|
|
99
|
+
registerPane: this.registerPane,
|
|
100
|
+
unregisterPane: this.unregisterPane
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
syncScrollPosition(scrolledPane, pane) {
|
|
105
|
+
const {
|
|
106
|
+
scrollTop,
|
|
107
|
+
scrollHeight,
|
|
108
|
+
clientHeight,
|
|
109
|
+
scrollLeft,
|
|
110
|
+
scrollWidth,
|
|
111
|
+
clientWidth
|
|
112
|
+
} = scrolledPane;
|
|
113
|
+
const scrollTopOffset = scrollHeight - clientHeight;
|
|
114
|
+
const scrollLeftOffset = scrollWidth - clientWidth;
|
|
115
|
+
const {
|
|
116
|
+
proportional,
|
|
117
|
+
vertical,
|
|
118
|
+
horizontal
|
|
119
|
+
} = this.props;
|
|
120
|
+
/* Calculate the actual pane height */
|
|
121
|
+
|
|
122
|
+
const paneHeight = pane.scrollHeight - clientHeight;
|
|
123
|
+
const paneWidth = pane.scrollWidth - clientWidth;
|
|
124
|
+
/* Adjust the scrollTop position of it accordingly */
|
|
125
|
+
|
|
126
|
+
if (vertical && scrollTopOffset > 0) {
|
|
127
|
+
pane.scrollTop = proportional ? paneHeight * scrollTop / scrollTopOffset : scrollTop; // eslint-disable-line
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (horizontal && scrollLeftOffset > 0) {
|
|
131
|
+
pane.scrollLeft = proportional ? paneWidth * scrollLeft / scrollLeftOffset : scrollLeft; // eslint-disable-line
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
render() {
|
|
136
|
+
const {
|
|
137
|
+
children
|
|
138
|
+
} = this.props;
|
|
139
|
+
return /*#__PURE__*/_jsx__default["default"](Provider, {
|
|
140
|
+
value: this.syncContext
|
|
141
|
+
}, void 0, React__default["default"].Children.only(children));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
ScrollSync.defaultProps = {
|
|
146
|
+
proportional: true,
|
|
147
|
+
vertical: true,
|
|
148
|
+
horizontal: true,
|
|
149
|
+
enabled: true
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
exports.ScrollSyncContext = ScrollSyncContext;
|
|
153
|
+
exports["default"] = ScrollSync;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
4
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
5
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
|
+
require('core-js/modules/esnext.async-iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.async-iterator.to-array.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.to-array.js');
|
|
10
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
11
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
12
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
13
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
14
|
+
var React = require('react');
|
|
15
|
+
var ScrollSync = require('./ScrollSync.js');
|
|
16
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
17
|
+
|
|
18
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
|
+
|
|
20
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
21
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
22
|
+
|
|
23
|
+
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; }
|
|
24
|
+
|
|
25
|
+
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__default["default"](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; }
|
|
26
|
+
|
|
27
|
+
class ScrollSyncPane extends React.Component {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
|
|
31
|
+
this.toArray = groups => [].concat(groups);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
componentWillUnmount() {
|
|
35
|
+
const {
|
|
36
|
+
enabled,
|
|
37
|
+
group,
|
|
38
|
+
syncContext
|
|
39
|
+
} = this.props;
|
|
40
|
+
const {
|
|
41
|
+
unregisterPane
|
|
42
|
+
} = syncContext;
|
|
43
|
+
if (enabled) unregisterPane(this.node, this.toArray(group));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
render() {
|
|
47
|
+
const {
|
|
48
|
+
children,
|
|
49
|
+
group,
|
|
50
|
+
syncContext,
|
|
51
|
+
notPaginated
|
|
52
|
+
} = this.props;
|
|
53
|
+
const {
|
|
54
|
+
registerPane
|
|
55
|
+
} = syncContext;
|
|
56
|
+
return children({
|
|
57
|
+
registerPane: node => {
|
|
58
|
+
if (notPaginated) {
|
|
59
|
+
const virtualizedBody = node.querySelector('.virtualized-body-wrapper');
|
|
60
|
+
|
|
61
|
+
if (virtualizedBody) {
|
|
62
|
+
registerPane(virtualizedBody, this.toArray(group));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return registerPane(node, this.toArray(group));
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
ScrollSyncPane.defaultProps = {
|
|
74
|
+
group: 'default',
|
|
75
|
+
enabled: true
|
|
76
|
+
};
|
|
77
|
+
var ScrollSyncPane$1 = (props => /*#__PURE__*/_jsx__default["default"](ScrollSync.ScrollSyncContext.Consumer, {}, void 0, context => /*#__PURE__*/jsxRuntime.jsx(ScrollSyncPane, _objectSpread(_objectSpread({}, props), {}, {
|
|
78
|
+
syncContext: context
|
|
79
|
+
}))));
|
|
80
|
+
|
|
81
|
+
module.exports = ScrollSyncPane$1;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
4
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
5
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
7
|
+
require('core-js/modules/esnext.async-iterator.find.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.find.js');
|
|
9
|
+
var React = require('react');
|
|
10
|
+
var raf = require('raf');
|
|
11
|
+
|
|
12
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
+
|
|
14
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
15
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
16
|
+
var raf__default = /*#__PURE__*/_interopDefaultLegacy(raf);
|
|
17
|
+
|
|
18
|
+
const ScrollSyncContext = /*#__PURE__*/React__default["default"].createContext();
|
|
19
|
+
const {
|
|
20
|
+
Provider
|
|
21
|
+
} = ScrollSyncContext;
|
|
22
|
+
|
|
23
|
+
function ScrollSyncProvider(_ref) {
|
|
24
|
+
let {
|
|
25
|
+
enabled,
|
|
26
|
+
horizontal,
|
|
27
|
+
vertical,
|
|
28
|
+
children
|
|
29
|
+
} = _ref;
|
|
30
|
+
useRef();
|
|
31
|
+
|
|
32
|
+
raf__default["default"]((scrolledPane, pane) => {
|
|
33
|
+
const {
|
|
34
|
+
scrollTop,
|
|
35
|
+
scrollHeight,
|
|
36
|
+
clientHeight,
|
|
37
|
+
scrollLeft,
|
|
38
|
+
scrollWidth,
|
|
39
|
+
clientWidth
|
|
40
|
+
} = scrolledPane;
|
|
41
|
+
const scrollTopOffset = scrollHeight - clientHeight;
|
|
42
|
+
const scrollLeftOffset = scrollWidth - clientWidth;
|
|
43
|
+
const {
|
|
44
|
+
proportional,
|
|
45
|
+
vertical,
|
|
46
|
+
horizontal
|
|
47
|
+
} = this.props;
|
|
48
|
+
/* Calculate the actual pane height */
|
|
49
|
+
|
|
50
|
+
const paneHeight = pane.scrollHeight - clientHeight;
|
|
51
|
+
const paneWidth = pane.scrollWidth - clientWidth;
|
|
52
|
+
/* Adjust the scrollTop position of it accordingly */
|
|
53
|
+
|
|
54
|
+
if (vertical && scrollTopOffset > 0) {
|
|
55
|
+
pane.scrollTop = proportional ? paneHeight * scrollTop / scrollTopOffset : scrollTop; // eslint-disable-line
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (horizontal && scrollLeftOffset > 0) {
|
|
59
|
+
pane.scrollLeft = proportional ? paneWidth * scrollLeft / scrollLeftOffset : scrollLeft; // eslint-disable-line
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return /*#__PURE__*/_jsx__default["default"](Provider, {}, void 0, children);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
ScrollSyncProvider.defaultProps = {};
|
|
66
|
+
|
|
67
|
+
module.exports = ScrollSyncProvider;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var ScrollSync = require('./ScrollSync.js');
|
|
6
|
+
var ScrollSyncPane = require('./ScrollSyncPane.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.ScrollSync = ScrollSync["default"];
|
|
11
|
+
exports.ScrollSyncPane = ScrollSyncPane;
|
package/cjs/constants.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const DEFAULT_DELAY_OPEN = 200;
|
|
6
|
+
const DEFAULT_DELAY_CLOSE = 300;
|
|
7
|
+
const sizeOptions = ['small', 'medium', 'large', 'x-large'];
|
|
8
|
+
const AM = 'am';
|
|
9
|
+
const PM = 'pm';
|
|
10
|
+
const ARROW_UP = 'ArrowUp';
|
|
11
|
+
const ARROW_DOWN = 'ArrowDown';
|
|
12
|
+
const BACKSPACE = 'Backspace';
|
|
13
|
+
const ESCAPE = 'Escape';
|
|
14
|
+
const HOME = 'Home';
|
|
15
|
+
const SHIFT = 'Shift';
|
|
16
|
+
const END = 'End';
|
|
17
|
+
const HOUR_RANGE_12 = {
|
|
18
|
+
min: 0,
|
|
19
|
+
max: 12
|
|
20
|
+
};
|
|
21
|
+
const HOUR_RANGE_24 = {
|
|
22
|
+
min: 0,
|
|
23
|
+
max: 24
|
|
24
|
+
};
|
|
25
|
+
const GENERAL_TIME_RANGE = {
|
|
26
|
+
min: 0,
|
|
27
|
+
max: 59
|
|
28
|
+
};
|
|
29
|
+
const PLACEHOLDER_TIME = {
|
|
30
|
+
hour: 'hour',
|
|
31
|
+
minutes: 'minutes',
|
|
32
|
+
seconds: 'seconds',
|
|
33
|
+
meridiem: 'meridiem'
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.AM = AM;
|
|
37
|
+
exports.ARROW_DOWN = ARROW_DOWN;
|
|
38
|
+
exports.ARROW_UP = ARROW_UP;
|
|
39
|
+
exports.BACKSPACE = BACKSPACE;
|
|
40
|
+
exports.DEFAULT_DELAY_CLOSE = DEFAULT_DELAY_CLOSE;
|
|
41
|
+
exports.DEFAULT_DELAY_OPEN = DEFAULT_DELAY_OPEN;
|
|
42
|
+
exports.END = END;
|
|
43
|
+
exports.ESCAPE = ESCAPE;
|
|
44
|
+
exports.GENERAL_TIME_RANGE = GENERAL_TIME_RANGE;
|
|
45
|
+
exports.HOME = HOME;
|
|
46
|
+
exports.HOUR_RANGE_12 = HOUR_RANGE_12;
|
|
47
|
+
exports.HOUR_RANGE_24 = HOUR_RANGE_24;
|
|
48
|
+
exports.PLACEHOLDER_TIME = PLACEHOLDER_TIME;
|
|
49
|
+
exports.PM = PM;
|
|
50
|
+
exports.SHIFT = SHIFT;
|
|
51
|
+
exports.sizeOptions = sizeOptions;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
5
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
7
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
10
|
+
|
|
11
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
+
|
|
13
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
14
|
+
|
|
15
|
+
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; }
|
|
16
|
+
|
|
17
|
+
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__default["default"](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; }
|
|
18
|
+
|
|
19
|
+
function getDecoratorsFromHooks(hooks, decorators) {
|
|
20
|
+
const nextDecorators = _objectSpread({}, decorators);
|
|
21
|
+
|
|
22
|
+
Object.keys(hooks).forEach(decorator => {
|
|
23
|
+
if (Array.isArray(decorators[decorator])) {
|
|
24
|
+
nextDecorators[decorator] = [...decorators[decorator], hooks[decorator]];
|
|
25
|
+
} else {
|
|
26
|
+
nextDecorators[decorator] = hooks[decorator];
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return nextDecorators;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function createInstancePlugin(name, hooks) {
|
|
33
|
+
return decorators => getDecoratorsFromHooks(hooks, decorators);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = createInstancePlugin;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
+
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
5
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
9
|
+
require('core-js/modules/esnext.async-iterator.reduce.js');
|
|
10
|
+
require('core-js/modules/esnext.iterator.reduce.js');
|
|
11
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
12
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
13
|
+
var uuid = require('uuid');
|
|
14
|
+
var React = require('react');
|
|
15
|
+
var lodash = require('lodash');
|
|
16
|
+
var utils = require('./utils.js');
|
|
17
|
+
|
|
18
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
|
+
|
|
20
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
21
|
+
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
22
|
+
|
|
23
|
+
const _excluded = ["uuid", "data", "renderers", "plugins", "customDecorators"];
|
|
24
|
+
|
|
25
|
+
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; }
|
|
26
|
+
|
|
27
|
+
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__default["default"](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; }
|
|
28
|
+
const defaultDecorators = {
|
|
29
|
+
instance: [],
|
|
30
|
+
state: [],
|
|
31
|
+
hotKeys: [],
|
|
32
|
+
renderers: [],
|
|
33
|
+
composeData: []
|
|
34
|
+
};
|
|
35
|
+
function createDataInstanceRef(_ref) {
|
|
36
|
+
let {
|
|
37
|
+
uuid: uuidProp,
|
|
38
|
+
data,
|
|
39
|
+
renderers,
|
|
40
|
+
plugins,
|
|
41
|
+
customDecorators
|
|
42
|
+
} = _ref,
|
|
43
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded);
|
|
44
|
+
|
|
45
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
46
|
+
const instance = React.useRef(); // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
47
|
+
|
|
48
|
+
const [uuid$1] = React.useState(uuidProp || (() => uuid.v4()));
|
|
49
|
+
instance.current = {
|
|
50
|
+
uuid: uuid$1,
|
|
51
|
+
state: {},
|
|
52
|
+
actions: {},
|
|
53
|
+
hotKeys: {},
|
|
54
|
+
// keyboard hotkeys to run specific actions
|
|
55
|
+
originalData: data,
|
|
56
|
+
records: [],
|
|
57
|
+
// item abstraction with meta data for originalData
|
|
58
|
+
renderers,
|
|
59
|
+
|
|
60
|
+
ref(key) {
|
|
61
|
+
// eslint-disable-next-line no-return-assign
|
|
62
|
+
return node => instance.current.refs[key] = node;
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
getInstance() {
|
|
66
|
+
return instance.current;
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
props
|
|
70
|
+
}; // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
71
|
+
|
|
72
|
+
const decorators = React.useMemo(() => {
|
|
73
|
+
let nextDecorators = _objectSpread(_objectSpread({}, defaultDecorators), customDecorators);
|
|
74
|
+
|
|
75
|
+
plugins.forEach(plugin => {
|
|
76
|
+
if (!plugin) return;
|
|
77
|
+
nextDecorators = plugin(nextDecorators);
|
|
78
|
+
});
|
|
79
|
+
Object.keys(nextDecorators).forEach(key => {
|
|
80
|
+
if (Array.isArray(nextDecorators[key])) nextDecorators[key] = lodash.orderBy(nextDecorators[key], item => item.order);
|
|
81
|
+
});
|
|
82
|
+
return nextDecorators;
|
|
83
|
+
}, []); // the plugins are defined on creation, but not changed at runtime
|
|
84
|
+
// todo: test if getting the hooks without registering them
|
|
85
|
+
// here would be beneficial to memoize instance and squeeze performance
|
|
86
|
+
|
|
87
|
+
instance.current = decorators.instance.reduce(utils.mergeInstance, instance.current);
|
|
88
|
+
instance.current = decorators.state.reduce(utils.registerStateHookToInstance, instance.current);
|
|
89
|
+
instance.current = decorators.hotKeys.reduce(utils.registerHotKeysHookToInstance, instance.current);
|
|
90
|
+
instance.current.renderers = decorators.renderers.reduce((result, decorator) => decorator(result, instance.current), renderers);
|
|
91
|
+
return {
|
|
92
|
+
instance,
|
|
93
|
+
decorators
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
module.exports = createDataInstanceRef;
|