@elliemae/ds-shared 1.60.0 → 2.0.0-alpha.12
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 +19 -27
- package/cjs/Animations/Grow.js +17 -22
- package/cjs/Animations/GrowRight.js +17 -23
- package/cjs/Animations/GrowVertical.js +3 -2
- package/cjs/CheckableGroup.js +40 -46
- package/cjs/DeferRenderAfterComputation.js +12 -21
- package/cjs/FocusGroup/FocusGrid.js +91 -92
- package/cjs/FocusGroup/FocusGroup.js +225 -262
- package/cjs/FocusGroup/FocusGroupContext.js +1 -2
- package/cjs/FocusGroup/FocusGroupManager.js +88 -126
- package/cjs/FocusGroup/focusGroupManagerHoc.js +28 -27
- package/cjs/FocusGroup/index.js +14 -28
- package/cjs/FocusGroup/useFocusGroupItem.js +27 -24
- package/cjs/FocusGroup/utils/getNextCellPosition.js +14 -15
- package/cjs/GroupContext/Group.js +81 -103
- package/cjs/GroupContext/GroupContext.js +1 -2
- package/cjs/GroupContext/GroupItem.js +12 -10
- package/cjs/GroupContext/index.js +6 -15
- package/cjs/ScrollSync/ScrollSync.js +90 -112
- package/cjs/ScrollSync/ScrollSyncPane.js +58 -90
- package/cjs/ScrollSync/ScrollSyncProvider.js +36 -26
- package/cjs/ScrollSync/index.js +4 -13
- package/cjs/ScrollSync/useScrollSync.js +0 -1
- package/cjs/constants.js +43 -4
- package/cjs/createDataInstance/createInstancePlugin.js +11 -10
- package/cjs/createDataInstance/createInstanceRef.js +41 -42
- package/cjs/createDataInstance/utils.js +56 -58
- package/cjs/defer-render-hoc/index.js +26 -61
- package/cjs/dimsum.config.js +7 -0
- package/cjs/index.js +10 -20
- package/cjs/prop-types.js +59 -0
- package/cjs/react-spring/index.js +3 -6
- package/cjs/react-spring/renderprops.js +3 -6
- package/cjs/toolbar/ToolbarProvider.js +65 -77
- package/cjs/useDataGrid/VolatileRowsListener.js +13 -27
- package/cjs/useDataGrid/index.js +2 -17
- package/cjs/useDataGrid/initColumnDefinition.js +46 -47
- package/cjs/useDataGrid/useDataGrid.js +104 -144
- package/cjs/useDataList/index.js +2 -15
- package/cjs/useDataList/recordIterator.js +9 -10
- package/cjs/useDataList/useDataList.js +51 -59
- package/cjs/utils.js +46 -59
- package/cjs/virtualization/AutoHeightList.js +31 -22
- package/cjs/virtualization/FluidHeightList.js +26 -12
- package/cjs/virtualization/index.js +12 -17
- package/esm/Animations/BaseAnimation.js +18 -26
- package/esm/Animations/Grow.js +15 -20
- package/esm/Animations/GrowRight.js +15 -21
- package/esm/Animations/GrowVertical.js +3 -2
- package/esm/CheckableGroup.js +38 -42
- package/esm/DeferRenderAfterComputation.js +12 -20
- package/esm/FocusGroup/FocusGrid.js +87 -89
- package/esm/FocusGroup/FocusGroup.js +222 -257
- package/esm/FocusGroup/FocusGroupContext.js +0 -1
- package/esm/FocusGroup/FocusGroupManager.js +82 -114
- package/esm/FocusGroup/focusGroupManagerHoc.js +24 -22
- package/esm/FocusGroup/index.js +0 -14
- package/esm/FocusGroup/useFocusGroupItem.js +25 -22
- package/esm/FocusGroup/utils/getNextCellPosition.js +14 -15
- package/esm/GroupContext/Group.js +80 -95
- package/esm/GroupContext/GroupContext.js +1 -2
- package/esm/GroupContext/GroupItem.js +10 -8
- package/esm/GroupContext/index.js +0 -9
- package/esm/ScrollSync/ScrollSync.js +88 -105
- package/esm/ScrollSync/ScrollSyncPane.js +56 -83
- package/esm/ScrollSync/ScrollSyncProvider.js +35 -26
- package/esm/ScrollSync/index.js +0 -9
- package/esm/ScrollSync/useScrollSync.js +0 -1
- package/esm/constants.js +31 -5
- package/esm/createDataInstance/createInstancePlugin.js +10 -8
- package/esm/createDataInstance/createInstanceRef.js +36 -36
- package/esm/createDataInstance/utils.js +55 -57
- package/esm/defer-render-hoc/index.js +25 -55
- package/esm/dimsum.config.js +5 -0
- package/esm/index.js +0 -10
- package/esm/prop-types.js +43 -0
- package/esm/react-spring/index.js +1 -2
- package/esm/react-spring/renderprops.js +1 -2
- package/esm/toolbar/ToolbarProvider.js +60 -71
- package/esm/useDataGrid/VolatileRowsListener.js +14 -23
- package/esm/useDataGrid/index.js +0 -15
- package/esm/useDataGrid/initColumnDefinition.js +43 -43
- package/esm/useDataGrid/useDataGrid.js +90 -127
- package/esm/useDataList/index.js +0 -13
- package/esm/useDataList/recordIterator.js +9 -10
- package/esm/useDataList/useDataList.js +39 -46
- package/esm/utils.js +44 -57
- package/esm/virtualization/AutoHeightList.js +28 -18
- package/esm/virtualization/FluidHeightList.js +24 -10
- package/esm/virtualization/index.js +6 -11
- package/package.json +201 -8
- 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/Animations/BaseAnimation/package.json +0 -10
- package/Animations/Grow/package.json +0 -10
- package/Animations/GrowRight/package.json +0 -10
- package/Animations/GrowVertical/package.json +0 -10
- package/CheckableGroup/package.json +0 -10
- package/DeferRenderAfterComputation/package.json +0 -10
- package/FocusGroup/FocusGrid/package.json +0 -10
- package/FocusGroup/FocusGroup/package.json +0 -10
- package/FocusGroup/FocusGroupContext/package.json +0 -10
- package/FocusGroup/FocusGroupManager/package.json +0 -10
- package/FocusGroup/focusGroupManagerHoc/package.json +0 -10
- package/FocusGroup/package.json +0 -10
- package/FocusGroup/useFocusGroupItem/package.json +0 -10
- package/FocusGroup/utils/getNextCellPosition/package.json +0 -10
- package/GroupContext/Group/package.json +0 -10
- package/GroupContext/GroupContext/package.json +0 -10
- package/GroupContext/GroupItem/package.json +0 -10
- package/GroupContext/package.json +0 -10
- package/ScrollSync/ScrollSync/package.json +0 -10
- package/ScrollSync/ScrollSyncPane/package.json +0 -10
- package/ScrollSync/ScrollSyncProvider/package.json +0 -10
- package/ScrollSync/package.json +0 -10
- package/ScrollSync/useScrollSync/package.json +0 -10
- package/cjs/Animations/BaseAnimation.js.map +0 -1
- package/cjs/Animations/Grow.js.map +0 -1
- package/cjs/Animations/GrowRight.js.map +0 -1
- package/cjs/Animations/GrowVertical.js.map +0 -1
- package/cjs/CheckableGroup.js.map +0 -1
- package/cjs/DeferRenderAfterComputation.js.map +0 -1
- package/cjs/FocusGroup/FocusGrid.js.map +0 -1
- package/cjs/FocusGroup/FocusGroup.js.map +0 -1
- package/cjs/FocusGroup/FocusGroupContext.js.map +0 -1
- package/cjs/FocusGroup/FocusGroupManager.js.map +0 -1
- package/cjs/FocusGroup/focusGroupManagerHoc.js.map +0 -1
- package/cjs/FocusGroup/index.js.map +0 -1
- package/cjs/FocusGroup/useFocusGroupItem.js.map +0 -1
- package/cjs/FocusGroup/utils/getNextCellPosition.js.map +0 -1
- package/cjs/GroupContext/Group.js.map +0 -1
- package/cjs/GroupContext/GroupContext.js.map +0 -1
- package/cjs/GroupContext/GroupItem.js.map +0 -1
- package/cjs/GroupContext/index.js.map +0 -1
- package/cjs/ScrollSync/ScrollSync.js.map +0 -1
- package/cjs/ScrollSync/ScrollSyncPane.js.map +0 -1
- package/cjs/ScrollSync/ScrollSyncProvider.js.map +0 -1
- package/cjs/ScrollSync/index.js.map +0 -1
- package/cjs/ScrollSync/useScrollSync.js.map +0 -1
- package/cjs/constants.js.map +0 -1
- package/cjs/createDataInstance/createInstancePlugin.js.map +0 -1
- package/cjs/createDataInstance/createInstanceRef.js.map +0 -1
- package/cjs/createDataInstance/utils.js.map +0 -1
- package/cjs/defer-render-hoc/index.js.map +0 -1
- package/cjs/index.js.map +0 -1
- package/cjs/react-spring/index.js.map +0 -1
- package/cjs/react-spring/renderprops.js.map +0 -1
- package/cjs/toolbar/ToolbarProvider.js.map +0 -1
- package/cjs/useDataGrid/VolatileRowsListener.js.map +0 -1
- package/cjs/useDataGrid/index.js.map +0 -1
- package/cjs/useDataGrid/initColumnDefinition.js.map +0 -1
- package/cjs/useDataGrid/useDataGrid.js.map +0 -1
- package/cjs/useDataList/index.js.map +0 -1
- package/cjs/useDataList/recordIterator.js.map +0 -1
- package/cjs/useDataList/useDataList.js.map +0 -1
- package/cjs/utils.js.map +0 -1
- package/cjs/virtualization/AutoHeightList.js.map +0 -1
- package/cjs/virtualization/FluidHeightList.js.map +0 -1
- package/cjs/virtualization/index.js.map +0 -1
- package/constants/package.json +0 -10
- package/createDataInstance/createInstancePlugin/package.json +0 -10
- package/createDataInstance/createInstanceRef/package.json +0 -10
- package/createDataInstance/utils/package.json +0 -10
- package/defer-render-hoc/package.json +0 -10
- package/esm/Animations/BaseAnimation.js.map +0 -1
- package/esm/Animations/Grow.js.map +0 -1
- package/esm/Animations/GrowRight.js.map +0 -1
- package/esm/Animations/GrowVertical.js.map +0 -1
- package/esm/CheckableGroup.js.map +0 -1
- package/esm/DeferRenderAfterComputation.js.map +0 -1
- package/esm/FocusGroup/FocusGrid.js.map +0 -1
- package/esm/FocusGroup/FocusGroup.js.map +0 -1
- package/esm/FocusGroup/FocusGroupContext.js.map +0 -1
- package/esm/FocusGroup/FocusGroupManager.js.map +0 -1
- package/esm/FocusGroup/focusGroupManagerHoc.js.map +0 -1
- package/esm/FocusGroup/index.js.map +0 -1
- package/esm/FocusGroup/useFocusGroupItem.js.map +0 -1
- package/esm/FocusGroup/utils/getNextCellPosition.js.map +0 -1
- package/esm/GroupContext/Group.js.map +0 -1
- package/esm/GroupContext/GroupContext.js.map +0 -1
- package/esm/GroupContext/GroupItem.js.map +0 -1
- package/esm/GroupContext/index.js.map +0 -1
- package/esm/ScrollSync/ScrollSync.js.map +0 -1
- package/esm/ScrollSync/ScrollSyncPane.js.map +0 -1
- package/esm/ScrollSync/ScrollSyncProvider.js.map +0 -1
- package/esm/ScrollSync/index.js.map +0 -1
- package/esm/ScrollSync/useScrollSync.js.map +0 -1
- package/esm/constants.js.map +0 -1
- package/esm/createDataInstance/createInstancePlugin.js.map +0 -1
- package/esm/createDataInstance/createInstanceRef.js.map +0 -1
- package/esm/createDataInstance/utils.js.map +0 -1
- package/esm/defer-render-hoc/index.js.map +0 -1
- package/esm/index.js.map +0 -1
- package/esm/react-spring/index.js.map +0 -1
- package/esm/react-spring/renderprops.js.map +0 -1
- package/esm/toolbar/ToolbarProvider.js.map +0 -1
- package/esm/useDataGrid/VolatileRowsListener.js.map +0 -1
- package/esm/useDataGrid/index.js.map +0 -1
- package/esm/useDataGrid/initColumnDefinition.js.map +0 -1
- package/esm/useDataGrid/useDataGrid.js.map +0 -1
- package/esm/useDataList/index.js.map +0 -1
- package/esm/useDataList/recordIterator.js.map +0 -1
- package/esm/useDataList/useDataList.js.map +0 -1
- package/esm/utils.js.map +0 -1
- package/esm/virtualization/AutoHeightList.js.map +0 -1
- package/esm/virtualization/FluidHeightList.js.map +0 -1
- package/esm/virtualization/index.js.map +0 -1
- package/react-spring/package.json +0 -10
- package/react-spring/renderprops/package.json +0 -10
- package/toolbar/ToolbarProvider/package.json +0 -10
- package/useDataGrid/VolatileRowsListener/package.json +0 -10
- package/useDataGrid/initColumnDefinition/package.json +0 -10
- package/useDataGrid/package.json +0 -10
- package/useDataGrid/useDataGrid/package.json +0 -10
- package/useDataList/package.json +0 -10
- package/useDataList/recordIterator/package.json +0 -10
- package/useDataList/useDataList/package.json +0 -10
- package/utils/package.json +0 -10
- package/virtualization/AutoHeightList/package.json +0 -10
- package/virtualization/FluidHeightList/package.json +0 -10
- package/virtualization/package.json +0 -10
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
|
+
import 'react';
|
|
2
4
|
import BaseAnimation from './BaseAnimation.js';
|
|
3
|
-
import 'react-spring/renderprops.cjs';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
children = _ref.children,
|
|
17
|
-
_ref$onRest = _ref.onRest,
|
|
18
|
-
onRest = _ref$onRest === void 0 ? function () {
|
|
19
|
-
return null;
|
|
20
|
-
} : _ref$onRest;
|
|
21
|
-
return /*#__PURE__*/React.createElement(BaseAnimation, {
|
|
6
|
+
const GrowRight = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
keys = undefined,
|
|
9
|
+
items = undefined,
|
|
10
|
+
duration = 200,
|
|
11
|
+
from = 0,
|
|
12
|
+
to = 1,
|
|
13
|
+
children,
|
|
14
|
+
onRest = () => null
|
|
15
|
+
} = _ref;
|
|
16
|
+
return /*#__PURE__*/_jsx(BaseAnimation, {
|
|
22
17
|
duration: duration,
|
|
23
18
|
enter: {
|
|
24
19
|
opacity: "".concat(to),
|
|
@@ -35,8 +30,7 @@ var GrowRight = function GrowRight(_ref) {
|
|
|
35
30
|
transform: 'translateX(100%)'
|
|
36
31
|
},
|
|
37
32
|
onRest: onRest
|
|
38
|
-
}, children);
|
|
33
|
+
}, void 0, children);
|
|
39
34
|
};
|
|
40
35
|
|
|
41
36
|
export { GrowRight as default };
|
|
42
|
-
//# sourceMappingURL=GrowRight.js.map
|
package/esm/CheckableGroup.js
CHANGED
|
@@ -1,68 +1,64 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
-
import
|
|
2
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
5
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
8
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
9
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
3
10
|
import React, { cloneElement } from 'react';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
11
|
import { useDerivedStateFromProps, runAll, addOrRemove } from '@elliemae/ds-utilities';
|
|
6
12
|
|
|
7
13
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
8
14
|
|
|
9
15
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
10
16
|
function useCheckableGroup(_ref) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
let {
|
|
18
|
+
children,
|
|
19
|
+
active: activeProp,
|
|
20
|
+
multi,
|
|
21
|
+
onCheck = () => null
|
|
22
|
+
} = _ref;
|
|
23
|
+
const [active, setActive] = useDerivedStateFromProps(activeProp);
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var nextActive = multi ? addOrRemove(prevActive, value) : value;
|
|
25
|
+
const handleCheck = (_ref2, item) => {
|
|
26
|
+
let {
|
|
27
|
+
target: {
|
|
28
|
+
value
|
|
29
|
+
}
|
|
30
|
+
} = _ref2;
|
|
31
|
+
setActive(prevActive => {
|
|
32
|
+
const nextActive = multi ? addOrRemove(prevActive, value) : value;
|
|
28
33
|
onCheck(nextActive, item);
|
|
29
34
|
return nextActive;
|
|
30
35
|
});
|
|
31
36
|
};
|
|
32
37
|
|
|
33
|
-
return React.Children.map(children,
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
return React.Children.map(children, child => {
|
|
39
|
+
const {
|
|
40
|
+
props
|
|
41
|
+
} = child;
|
|
42
|
+
const checked = Array.isArray(active) ? active.indexOf(props.name) !== -1 : active === props.name;
|
|
36
43
|
return /*#__PURE__*/cloneElement(child, _objectSpread(_objectSpread({}, props), {}, {
|
|
37
|
-
checked
|
|
44
|
+
checked,
|
|
38
45
|
onClick: runAll(handleCheck, props.onClick)
|
|
39
46
|
}));
|
|
40
47
|
});
|
|
41
48
|
}
|
|
42
49
|
|
|
43
50
|
function CheckableGroup(_ref3) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
let {
|
|
52
|
+
active = [],
|
|
53
|
+
multi = false,
|
|
54
|
+
// checkbox or radio
|
|
55
|
+
children
|
|
56
|
+
} = _ref3;
|
|
49
57
|
return useCheckableGroup({
|
|
50
|
-
active
|
|
51
|
-
multi
|
|
52
|
-
children
|
|
58
|
+
active,
|
|
59
|
+
multi,
|
|
60
|
+
children
|
|
53
61
|
});
|
|
54
62
|
}
|
|
55
63
|
|
|
56
|
-
CheckableGroup.propTypes = {
|
|
57
|
-
/* The item (if multi false) or items (if multi true) selected */
|
|
58
|
-
active: PropTypes.arrayOf(PropTypes.string),
|
|
59
|
-
|
|
60
|
-
/* Whether is multi select or not */
|
|
61
|
-
multi: PropTypes.bool,
|
|
62
|
-
|
|
63
|
-
/* Handler when a user checks an item */
|
|
64
|
-
onCheck: PropTypes.func
|
|
65
|
-
};
|
|
66
|
-
|
|
67
64
|
export { CheckableGroup as default, useCheckableGroup };
|
|
68
|
-
//# sourceMappingURL=CheckableGroup.js.map
|
|
@@ -1,30 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
2
|
import { useState, useEffect } from 'react';
|
|
3
3
|
import raf from 'raf';
|
|
4
4
|
|
|
5
5
|
function DeferRenderAfterComputation(_ref) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
setShouldRender = _useState2[1];
|
|
15
|
-
|
|
16
|
-
useEffect(function () {
|
|
6
|
+
let {
|
|
7
|
+
children,
|
|
8
|
+
resolve,
|
|
9
|
+
fallback,
|
|
10
|
+
timeout = 2000
|
|
11
|
+
} = _ref;
|
|
12
|
+
const [shouldRender, setShouldRender] = useState(false);
|
|
13
|
+
useEffect(() => {
|
|
17
14
|
// eslint-disable-next-line max-nested-callbacks
|
|
18
|
-
raf(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
setShouldRender(true);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
});
|
|
15
|
+
raf(() => raf(() => resolve().then(() => {
|
|
16
|
+
setShouldRender(true);
|
|
17
|
+
})));
|
|
25
18
|
}, []);
|
|
26
19
|
return shouldRender ? children : fallback;
|
|
27
20
|
}
|
|
28
21
|
|
|
29
22
|
export { DeferRenderAfterComputation as default };
|
|
30
|
-
//# sourceMappingURL=DeferRenderAfterComputation.js.map
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
1
2
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
3
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
2
8
|
import React, { useRef, useEffect, useMemo, createContext } from 'react';
|
|
3
9
|
import { mergeRefs, get, runAll, isFunction, useHotkeys } from '@elliemae/ds-utilities';
|
|
4
10
|
import getNextCellPosition from './utils/getNextCellPosition.js';
|
|
@@ -6,62 +12,65 @@ import getNextCellPosition from './utils/getNextCellPosition.js';
|
|
|
6
12
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
7
13
|
|
|
8
14
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
9
|
-
|
|
10
|
-
|
|
15
|
+
const FocusGridContext = /*#__PURE__*/createContext();
|
|
16
|
+
const {
|
|
17
|
+
Provider
|
|
18
|
+
} = FocusGridContext;
|
|
11
19
|
|
|
12
|
-
|
|
13
|
-
return e.preventDefault();
|
|
14
|
-
};
|
|
20
|
+
const preventDefault = e => e.preventDefault();
|
|
15
21
|
|
|
16
22
|
function registerHotKeysHooks(hotKeys, _ref) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
let {
|
|
24
|
+
focusedRow,
|
|
25
|
+
focusedCell
|
|
26
|
+
} = _ref;
|
|
27
|
+
Object.keys(hotKeys).forEach(key => {
|
|
28
|
+
const {
|
|
29
|
+
handler,
|
|
30
|
+
options
|
|
31
|
+
} = hotKeys[key];
|
|
23
32
|
useHotkeys({
|
|
24
33
|
keys: key,
|
|
25
|
-
handler:
|
|
34
|
+
handler: e => {
|
|
26
35
|
e.preventDefault();
|
|
27
|
-
|
|
28
|
-
_handler({
|
|
36
|
+
handler({
|
|
29
37
|
rowIndex: focusedRow.current,
|
|
30
38
|
cellIndex: focusedCell.current
|
|
31
39
|
});
|
|
32
40
|
},
|
|
33
|
-
options
|
|
41
|
+
options
|
|
34
42
|
});
|
|
35
43
|
});
|
|
36
44
|
} // eslint-disable-next-line max-statements
|
|
37
45
|
|
|
38
46
|
|
|
39
47
|
function FocusGridProvider(_ref2) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var decoratedChild = /*#__PURE__*/React.cloneElement(child, {
|
|
48
|
+
let {
|
|
49
|
+
shouldWrapRows = false,
|
|
50
|
+
shouldWrapCells = false,
|
|
51
|
+
shouldRefocus = true,
|
|
52
|
+
children,
|
|
53
|
+
keyBindings,
|
|
54
|
+
hotKeys
|
|
55
|
+
} = _ref2;
|
|
56
|
+
const focusedRow = useRef();
|
|
57
|
+
const focusedCell = useRef();
|
|
58
|
+
const grid = useRef([]);
|
|
59
|
+
const containerRef = useRef(document);
|
|
60
|
+
const child = React.Children.only(children);
|
|
61
|
+
const decoratedChild = /*#__PURE__*/React.cloneElement(child, {
|
|
55
62
|
innerRef: mergeRefs(child.props.innerRef, containerRef)
|
|
56
63
|
});
|
|
57
64
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
const getNode = _ref3 => {
|
|
66
|
+
let {
|
|
67
|
+
rowIndex,
|
|
68
|
+
cellIndex
|
|
69
|
+
} = _ref3;
|
|
61
70
|
return get(grid.current, [rowIndex, cellIndex]);
|
|
62
71
|
};
|
|
63
72
|
|
|
64
|
-
|
|
73
|
+
const register = (node, rowIndex, columnIndex) => {
|
|
65
74
|
if (!node) return;
|
|
66
75
|
|
|
67
76
|
if (!Array.isArray(grid.current[rowIndex])) {
|
|
@@ -74,8 +83,8 @@ function FocusGridProvider(_ref2) {
|
|
|
74
83
|
node.setAttribute('tabindex', -1);
|
|
75
84
|
}
|
|
76
85
|
|
|
77
|
-
node.onfocus =
|
|
78
|
-
|
|
86
|
+
node.onfocus = () => {
|
|
87
|
+
const prevNode = getNode({
|
|
79
88
|
rowIndex: focusedRow.current,
|
|
80
89
|
cellIndex: focusedCell.current
|
|
81
90
|
});
|
|
@@ -88,31 +97,31 @@ function FocusGridProvider(_ref2) {
|
|
|
88
97
|
grid.current[rowIndex][columnIndex] = node;
|
|
89
98
|
};
|
|
90
99
|
|
|
91
|
-
useEffect(
|
|
100
|
+
useEffect(() => {
|
|
92
101
|
if (shouldRefocus) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
102
|
+
const rowIndex = focusedRow.current;
|
|
103
|
+
const cellIndex = focusedCell.current;
|
|
104
|
+
const node = get(grid.current, [rowIndex, cellIndex]);
|
|
96
105
|
if (node) node.focus();
|
|
97
106
|
}
|
|
98
107
|
});
|
|
99
108
|
|
|
100
|
-
|
|
101
|
-
|
|
109
|
+
const focusNextCell = (directionY, directionX, position) => {
|
|
110
|
+
const {
|
|
111
|
+
rowIndex,
|
|
112
|
+
cellIndex
|
|
113
|
+
} = position || getNextCellPosition({
|
|
102
114
|
grid: grid.current,
|
|
103
115
|
currentCell: focusedCell.current,
|
|
104
116
|
currentRow: focusedRow.current,
|
|
105
|
-
directionX
|
|
106
|
-
directionY
|
|
107
|
-
shouldWrapCells
|
|
108
|
-
shouldWrapRows
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
var node = getNode({
|
|
114
|
-
rowIndex: rowIndex,
|
|
115
|
-
cellIndex: cellIndex
|
|
117
|
+
directionX,
|
|
118
|
+
directionY,
|
|
119
|
+
shouldWrapCells,
|
|
120
|
+
shouldWrapRows
|
|
121
|
+
});
|
|
122
|
+
const node = getNode({
|
|
123
|
+
rowIndex,
|
|
124
|
+
cellIndex
|
|
116
125
|
}); // can focus
|
|
117
126
|
|
|
118
127
|
if (node) {
|
|
@@ -123,84 +132,73 @@ function FocusGridProvider(_ref2) {
|
|
|
123
132
|
};
|
|
124
133
|
|
|
125
134
|
registerHotKeysHooks(hotKeys, {
|
|
126
|
-
focusedCell
|
|
127
|
-
focusedRow
|
|
135
|
+
focusedCell,
|
|
136
|
+
focusedRow
|
|
128
137
|
});
|
|
129
138
|
|
|
130
|
-
|
|
131
|
-
ArrowUp: runAll(preventDefault,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
ArrowDown: runAll(preventDefault, function () {
|
|
138
|
-
return focusNextCell(1, 0);
|
|
139
|
-
}),
|
|
140
|
-
ArrowLeft: runAll(preventDefault, function () {
|
|
141
|
-
return focusNextCell(0, -1);
|
|
142
|
-
}),
|
|
143
|
-
Home: runAll(preventDefault, function (e) {
|
|
144
|
-
var rowIndex = focusedRow.current;
|
|
139
|
+
const defaultKeyBindings = _objectSpread({
|
|
140
|
+
ArrowUp: runAll(preventDefault, () => focusNextCell(-1, 0)),
|
|
141
|
+
ArrowRight: runAll(preventDefault, () => focusNextCell(0, 1)),
|
|
142
|
+
ArrowDown: runAll(preventDefault, () => focusNextCell(1, 0)),
|
|
143
|
+
ArrowLeft: runAll(preventDefault, () => focusNextCell(0, -1)),
|
|
144
|
+
Home: runAll(preventDefault, e => {
|
|
145
|
+
let rowIndex = focusedRow.current;
|
|
145
146
|
|
|
146
147
|
if (e.ctrlKey) {
|
|
147
148
|
rowIndex = 0;
|
|
148
149
|
}
|
|
149
150
|
|
|
150
151
|
focusNextCell(0, 0, {
|
|
151
|
-
rowIndex
|
|
152
|
+
rowIndex,
|
|
152
153
|
cellIndex: 0
|
|
153
154
|
});
|
|
154
155
|
}),
|
|
155
|
-
End: runAll(preventDefault,
|
|
156
|
-
|
|
156
|
+
End: runAll(preventDefault, e => {
|
|
157
|
+
let rowIndex = focusedRow.current;
|
|
157
158
|
|
|
158
159
|
if (e.ctrlKey) {
|
|
159
160
|
rowIndex = grid.current.length - 1;
|
|
160
161
|
}
|
|
161
162
|
|
|
162
163
|
focusNextCell(0, 0, {
|
|
163
|
-
rowIndex
|
|
164
|
+
rowIndex,
|
|
164
165
|
cellIndex: grid.current[0].length - 1
|
|
165
166
|
});
|
|
166
167
|
})
|
|
167
168
|
}, keyBindings);
|
|
168
169
|
|
|
169
|
-
|
|
170
|
+
const nextKeyBindings = isFunction(keyBindings) ? keyBindings({
|
|
170
171
|
defaultBindings: defaultKeyBindings,
|
|
171
172
|
rowIndex: focusedRow.current,
|
|
172
173
|
cellIndex: focusedCell.current
|
|
173
174
|
}) : _objectSpread(_objectSpread({}, defaultKeyBindings), keyBindings);
|
|
174
175
|
|
|
175
|
-
|
|
176
|
+
const onKeyDown = e => {
|
|
176
177
|
if (e.target.tagName.toLowerCase() === 'input') return;
|
|
177
|
-
|
|
178
|
+
const action = nextKeyBindings[e.key];
|
|
178
179
|
if (isFunction(action)) action(e);
|
|
179
180
|
};
|
|
180
181
|
|
|
181
|
-
|
|
182
|
+
const activate = container => {
|
|
182
183
|
container.addEventListener('keydown', onKeyDown, true);
|
|
183
184
|
};
|
|
184
185
|
|
|
185
|
-
|
|
186
|
+
const deactivate = container => {
|
|
186
187
|
container.removeEventListener('keydown', onKeyDown, true);
|
|
187
188
|
};
|
|
188
189
|
|
|
189
|
-
useEffect(
|
|
190
|
+
useEffect(() => {
|
|
190
191
|
activate(containerRef.current);
|
|
191
|
-
return
|
|
192
|
+
return () => {
|
|
192
193
|
deactivate(containerRef.current);
|
|
193
194
|
};
|
|
194
195
|
}, []);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}, []);
|
|
200
|
-
return /*#__PURE__*/React.createElement(Provider, {
|
|
196
|
+
const valueProvider = useMemo(() => ({
|
|
197
|
+
register
|
|
198
|
+
}), []);
|
|
199
|
+
return /*#__PURE__*/_jsx(Provider, {
|
|
201
200
|
value: valueProvider
|
|
202
|
-
}, decoratedChild);
|
|
201
|
+
}, void 0, decoratedChild);
|
|
203
202
|
}
|
|
204
203
|
|
|
205
204
|
export { FocusGridContext, FocusGridProvider as default };
|
|
206
|
-
//# sourceMappingURL=FocusGrid.js.map
|