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