@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,133 +1,102 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import _assertThisInitialized from '@babel/runtime/helpers/esm/assertThisInitialized';
|
|
4
|
-
import _inherits from '@babel/runtime/helpers/esm/inherits';
|
|
5
|
-
import _possibleConstructorReturn from '@babel/runtime/helpers/esm/possibleConstructorReturn';
|
|
6
|
-
import _getPrototypeOf from '@babel/runtime/helpers/esm/getPrototypeOf';
|
|
7
|
-
import React, { Component } from 'react';
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import { Component } from 'react';
|
|
8
3
|
import { isFunction } from '@elliemae/ds-utilities';
|
|
9
4
|
import FocusGroup from './FocusGroup.js';
|
|
10
5
|
import FocusGroupContext from './FocusGroupContext.js';
|
|
11
|
-
import '@babel/runtime/helpers/esm/defineProperty';
|
|
12
|
-
import 'hotkeys-js';
|
|
13
6
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
const noop = () => null;
|
|
8
|
+
|
|
9
|
+
class FocusGroupProvider extends Component {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(props);
|
|
12
|
+
this.activated = false;
|
|
13
|
+
this.focusGroup = new FocusGroup(props);
|
|
14
|
+
props.onFocusGroupSet(this);
|
|
15
|
+
this.actions = {
|
|
16
|
+
activate: this.activate.bind(this),
|
|
17
|
+
deactivate: this.deactivate.bind(this),
|
|
18
|
+
register: this.focusGroup.register,
|
|
19
|
+
unregister: this.unregister.bind(this),
|
|
20
|
+
focusFirst: this.focusGroup.focusFirst,
|
|
21
|
+
focusLast: this.focusGroup.focusLast,
|
|
22
|
+
focusItemByIndex: this.focusItemByIndex.bind(this),
|
|
23
|
+
focusItemByNode: this.focusItemByNode.bind(this),
|
|
24
|
+
focus: this.focusGroup.focusCurrent,
|
|
25
|
+
isGroupActive: this.focusGroup.isGroupActive,
|
|
26
|
+
focusNext: this.focusGroup.focusNext,
|
|
27
|
+
focusPrevious: this.focusGroup.focusPrevious
|
|
28
|
+
};
|
|
29
|
+
}
|
|
17
30
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
31
|
+
componentDidMount() {
|
|
32
|
+
const {
|
|
33
|
+
autoFocusOnMount
|
|
34
|
+
} = this.props;
|
|
35
|
+
this.activate();
|
|
21
36
|
|
|
22
|
-
|
|
23
|
-
|
|
37
|
+
if (autoFocusOnMount) {
|
|
38
|
+
setTimeout(() => {
|
|
39
|
+
this.actions.focusFirst();
|
|
40
|
+
}, 0);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
24
43
|
|
|
25
|
-
|
|
44
|
+
componentWillUnmount() {
|
|
45
|
+
this.deactivate();
|
|
46
|
+
}
|
|
26
47
|
|
|
27
|
-
|
|
28
|
-
|
|
48
|
+
activate() {
|
|
49
|
+
const {
|
|
50
|
+
onActivate
|
|
51
|
+
} = this.props;
|
|
52
|
+
this.focusGroup.activate();
|
|
53
|
+
this.activated = true;
|
|
54
|
+
if (isFunction(onActivate)) onActivate();
|
|
55
|
+
}
|
|
29
56
|
|
|
30
|
-
|
|
57
|
+
deactivate() {
|
|
58
|
+
const {
|
|
59
|
+
onExitFocusGroup
|
|
60
|
+
} = this.props;
|
|
61
|
+
this.activated = false;
|
|
62
|
+
this.focusGroup.deactivate();
|
|
31
63
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
props.onFocusGroupSet(_assertThisInitialized(_this));
|
|
36
|
-
_this.actions = {
|
|
37
|
-
activate: _this.activate.bind(_assertThisInitialized(_this)),
|
|
38
|
-
deactivate: _this.deactivate.bind(_assertThisInitialized(_this)),
|
|
39
|
-
register: _this.focusGroup.register,
|
|
40
|
-
unregister: _this.unregister.bind(_assertThisInitialized(_this)),
|
|
41
|
-
focusFirst: _this.focusGroup.focusFirst,
|
|
42
|
-
focusLast: _this.focusGroup.focusLast,
|
|
43
|
-
focusItemByIndex: _this.focusItemByIndex.bind(_assertThisInitialized(_this)),
|
|
44
|
-
focusItemByNode: _this.focusItemByNode.bind(_assertThisInitialized(_this)),
|
|
45
|
-
focus: _this.focusGroup.focusCurrent,
|
|
46
|
-
isGroupActive: _this.focusGroup.isGroupActive,
|
|
47
|
-
focusNext: _this.focusGroup.focusNext,
|
|
48
|
-
focusPrevious: _this.focusGroup.focusPrevious
|
|
49
|
-
};
|
|
50
|
-
return _this;
|
|
64
|
+
if (isFunction(onExitFocusGroup)) {
|
|
65
|
+
onExitFocusGroup();
|
|
66
|
+
}
|
|
51
67
|
}
|
|
52
68
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var _this2 = this;
|
|
57
|
-
|
|
58
|
-
var autoFocusOnMount = this.props.autoFocusOnMount;
|
|
59
|
-
this.activate();
|
|
69
|
+
register(item) {
|
|
70
|
+
this.focusGroup.register(item);
|
|
71
|
+
}
|
|
60
72
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}, 0);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}, {
|
|
68
|
-
key: "componentWillUnmount",
|
|
69
|
-
value: function componentWillUnmount() {
|
|
70
|
-
this.deactivate();
|
|
71
|
-
}
|
|
72
|
-
}, {
|
|
73
|
-
key: "activate",
|
|
74
|
-
value: function activate() {
|
|
75
|
-
var onActivate = this.props.onActivate;
|
|
76
|
-
this.focusGroup.activate();
|
|
77
|
-
this.activated = true;
|
|
78
|
-
if (isFunction(onActivate)) onActivate();
|
|
79
|
-
}
|
|
80
|
-
}, {
|
|
81
|
-
key: "deactivate",
|
|
82
|
-
value: function deactivate() {
|
|
83
|
-
var onExitFocusGroup = this.props.onExitFocusGroup;
|
|
84
|
-
this.activated = false;
|
|
85
|
-
this.focusGroup.deactivate();
|
|
73
|
+
unregister(item) {
|
|
74
|
+
this.focusGroup.unregister(item);
|
|
75
|
+
}
|
|
86
76
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
value: function register(item) {
|
|
94
|
-
this.focusGroup.register(item);
|
|
95
|
-
}
|
|
96
|
-
}, {
|
|
97
|
-
key: "unregister",
|
|
98
|
-
value: function unregister(item) {
|
|
99
|
-
this.focusGroup.unregister(item);
|
|
100
|
-
}
|
|
101
|
-
}, {
|
|
102
|
-
key: "focusItemByIndex",
|
|
103
|
-
value: function focusItemByIndex(index) {
|
|
104
|
-
var _this3 = this;
|
|
77
|
+
focusItemByIndex(index) {
|
|
78
|
+
if (!this.activated) this.activate();
|
|
79
|
+
setTimeout(() => {
|
|
80
|
+
this.focusGroup.focusByIndex(index);
|
|
81
|
+
}, 200);
|
|
82
|
+
}
|
|
105
83
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}, {
|
|
112
|
-
key: "focusItemByNode",
|
|
113
|
-
value: function focusItemByNode(node) {
|
|
114
|
-
if (!this.activated) this.activate();
|
|
115
|
-
var index = this.focusGroup.getItemIndexByNode(node);
|
|
116
|
-
this.focusItemByIndex(index);
|
|
117
|
-
}
|
|
118
|
-
}, {
|
|
119
|
-
key: "render",
|
|
120
|
-
value: function render() {
|
|
121
|
-
var children = this.props.children;
|
|
122
|
-
return /*#__PURE__*/React.createElement(FocusGroupContext.Provider, {
|
|
123
|
-
value: this.actions
|
|
124
|
-
}, children);
|
|
125
|
-
}
|
|
126
|
-
}]);
|
|
84
|
+
focusItemByNode(node) {
|
|
85
|
+
if (!this.activated) this.activate();
|
|
86
|
+
const index = this.focusGroup.getItemIndexByNode(node);
|
|
87
|
+
this.focusItemByIndex(index);
|
|
88
|
+
}
|
|
127
89
|
|
|
128
|
-
|
|
129
|
-
|
|
90
|
+
render() {
|
|
91
|
+
const {
|
|
92
|
+
children
|
|
93
|
+
} = this.props;
|
|
94
|
+
return /*#__PURE__*/_jsx(FocusGroupContext.Provider, {
|
|
95
|
+
value: this.actions
|
|
96
|
+
}, void 0, children);
|
|
97
|
+
}
|
|
130
98
|
|
|
99
|
+
}
|
|
131
100
|
FocusGroupProvider.defaultProps = {
|
|
132
101
|
exitWhenNoPrevious: false,
|
|
133
102
|
exitWhenNoNext: false,
|
|
@@ -140,4 +109,3 @@ FocusGroupProvider.defaultProps = {
|
|
|
140
109
|
};
|
|
141
110
|
|
|
142
111
|
export { FocusGroupProvider as default };
|
|
143
|
-
//# sourceMappingURL=FocusGroupManager.js.map
|
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
7
|
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
3
|
-
import
|
|
8
|
+
import 'react';
|
|
4
9
|
import FocusGroupProvider from './FocusGroupManager.js';
|
|
5
|
-
import '
|
|
6
|
-
import '@babel/runtime/helpers/esm/createClass';
|
|
7
|
-
import '@babel/runtime/helpers/esm/assertThisInitialized';
|
|
8
|
-
import '@babel/runtime/helpers/esm/inherits';
|
|
9
|
-
import '@babel/runtime/helpers/esm/possibleConstructorReturn';
|
|
10
|
-
import '@babel/runtime/helpers/esm/getPrototypeOf';
|
|
11
|
-
import '@elliemae/ds-utilities';
|
|
12
|
-
import './FocusGroup.js';
|
|
13
|
-
import '@babel/runtime/helpers/esm/defineProperty';
|
|
14
|
-
import 'hotkeys-js';
|
|
15
|
-
import './FocusGroupContext.js';
|
|
10
|
+
import { jsx } from 'react/jsx-runtime';
|
|
16
11
|
|
|
17
|
-
|
|
12
|
+
const _excluded = ["onExitFocusGroup", "onFocusPrevGroup", "focusKeyBindings"];
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
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; }
|
|
18
17
|
function FocusGroupHoc(WrappedComponent) {
|
|
19
|
-
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
19
|
+
return _ref => {
|
|
20
|
+
let {
|
|
21
|
+
onExitFocusGroup,
|
|
22
|
+
onFocusPrevGroup,
|
|
23
|
+
focusKeyBindings
|
|
24
|
+
} = _ref,
|
|
24
25
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
25
26
|
|
|
26
|
-
return /*#__PURE__*/
|
|
27
|
+
return /*#__PURE__*/jsx(FocusGroupProvider, _objectSpread(_objectSpread({
|
|
27
28
|
keyBindings: focusKeyBindings,
|
|
28
29
|
onExitFocusGroup: onExitFocusGroup,
|
|
29
30
|
onFocusPrevGroup: onFocusPrevGroup
|
|
30
|
-
}, options),
|
|
31
|
+
}, options), {}, {
|
|
32
|
+
children: /*#__PURE__*/jsx(WrappedComponent, _objectSpread(_objectSpread({}, props), options))
|
|
33
|
+
}));
|
|
31
34
|
};
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
export { FocusGroupHoc as default };
|
|
35
|
-
//# sourceMappingURL=focusGroupManagerHoc.js.map
|
package/esm/FocusGroup/index.js
CHANGED
|
@@ -4,17 +4,3 @@ export { default as FocusGroupManager } from './FocusGroupManager.js';
|
|
|
4
4
|
export { default as useFocusGroupItem, useFocusGroupWithState } from './useFocusGroupItem.js';
|
|
5
5
|
export { default as focusGroupManagerHoc } from './focusGroupManagerHoc.js';
|
|
6
6
|
export { default as FocusGrid, FocusGridContext } from './FocusGrid.js';
|
|
7
|
-
import '@babel/runtime/helpers/esm/classCallCheck';
|
|
8
|
-
import '@babel/runtime/helpers/esm/createClass';
|
|
9
|
-
import '@babel/runtime/helpers/esm/defineProperty';
|
|
10
|
-
import '@elliemae/ds-utilities';
|
|
11
|
-
import 'hotkeys-js';
|
|
12
|
-
import 'react';
|
|
13
|
-
import '@babel/runtime/helpers/esm/assertThisInitialized';
|
|
14
|
-
import '@babel/runtime/helpers/esm/inherits';
|
|
15
|
-
import '@babel/runtime/helpers/esm/possibleConstructorReturn';
|
|
16
|
-
import '@babel/runtime/helpers/esm/getPrototypeOf';
|
|
17
|
-
import '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
18
|
-
import '@babel/runtime/helpers/esm/extends';
|
|
19
|
-
import './utils/getNextCellPosition.js';
|
|
20
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -2,20 +2,22 @@ import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutPr
|
|
|
2
2
|
import { useContext, useEffect } from 'react';
|
|
3
3
|
import FocusGroupContext from './FocusGroupContext.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const _excluded = ["register", "unregister"],
|
|
6
|
+
_excluded2 = ["register", "unregister"];
|
|
7
7
|
function useFocusGroupItem() {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
let ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
9
|
+
let props = arguments.length > 1 ? arguments[1] : undefined;
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const _ref = useContext(FocusGroupContext) || {},
|
|
12
|
+
{
|
|
13
|
+
register,
|
|
14
|
+
unregister
|
|
15
|
+
} = _ref,
|
|
16
|
+
otherActions = _objectWithoutProperties(_ref, _excluded);
|
|
15
17
|
|
|
16
|
-
useEffect(
|
|
18
|
+
useEffect(() => {
|
|
17
19
|
if (ref.current && register) register(ref.current, props);
|
|
18
|
-
return
|
|
20
|
+
return () => {
|
|
19
21
|
if (ref.current && unregister) unregister(ref.current);
|
|
20
22
|
};
|
|
21
23
|
}); // if the focus item is not wrapped with the focus provider then return null
|
|
@@ -23,18 +25,20 @@ function useFocusGroupItem() {
|
|
|
23
25
|
if (!register) return {};
|
|
24
26
|
return otherActions;
|
|
25
27
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
const useFocusGroupWithState = function () {
|
|
29
|
+
let ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
30
|
+
let props = arguments.length > 1 ? arguments[1] : undefined;
|
|
31
|
+
|
|
32
|
+
const _ref2 = useContext(FocusGroupContext) || {},
|
|
33
|
+
{
|
|
34
|
+
register,
|
|
35
|
+
unregister
|
|
36
|
+
} = _ref2,
|
|
37
|
+
otherActions = _objectWithoutProperties(_ref2, _excluded2);
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
36
40
|
if (ref && register) register(ref, props);
|
|
37
|
-
return
|
|
41
|
+
return () => {
|
|
38
42
|
if (ref && unregister) unregister(ref);
|
|
39
43
|
};
|
|
40
44
|
}, [ref]); // if the focus item is not wrapped with the focus provider then return null
|
|
@@ -44,4 +48,3 @@ var useFocusGroupWithState = function useFocusGroupWithState() {
|
|
|
44
48
|
};
|
|
45
49
|
|
|
46
50
|
export { useFocusGroupItem as default, useFocusGroupWithState };
|
|
47
|
-
//# sourceMappingURL=useFocusGroupItem.js.map
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
// eslint-disable-next-line max-statements
|
|
2
2
|
function getNextCellPosition(_ref) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
let {
|
|
4
|
+
grid,
|
|
5
|
+
currentRow = 0,
|
|
6
|
+
currentCell = 0,
|
|
7
|
+
directionY,
|
|
8
|
+
directionX,
|
|
9
|
+
shouldWrapCells,
|
|
10
|
+
shouldWrapRows
|
|
11
|
+
} = _ref;
|
|
12
|
+
let nextRow = currentRow + directionY;
|
|
13
|
+
let nextCell = currentCell + directionX;
|
|
14
|
+
const rowCount = grid.length;
|
|
15
|
+
const isLeftRight = directionX !== 0;
|
|
16
16
|
|
|
17
17
|
if (!rowCount) {
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const cellsLength = grid[0].length; // moving horizontally
|
|
22
22
|
|
|
23
23
|
if (shouldWrapCells && isLeftRight) {
|
|
24
24
|
// to left
|
|
@@ -56,4 +56,3 @@ function getNextCellPosition(_ref) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
export { getNextCellPosition as default };
|
|
59
|
-
//# sourceMappingURL=getNextCellPosition.js.map
|
|
@@ -1,38 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import _inherits from '@babel/runtime/helpers/esm/inherits';
|
|
5
|
-
import _possibleConstructorReturn from '@babel/runtime/helpers/esm/possibleConstructorReturn';
|
|
6
|
-
import _getPrototypeOf from '@babel/runtime/helpers/esm/getPrototypeOf';
|
|
7
|
-
import React, { Component } from 'react';
|
|
8
|
-
import PropTypes from 'prop-types';
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
|
+
import { Component } from 'react';
|
|
9
4
|
import { GroupContext } from './GroupContext.js';
|
|
10
5
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var target = e.target,
|
|
17
|
-
currentTarget = e.currentTarget;
|
|
6
|
+
const getValueItem = e => {
|
|
7
|
+
const {
|
|
8
|
+
target,
|
|
9
|
+
currentTarget
|
|
10
|
+
} = e;
|
|
18
11
|
|
|
19
12
|
if (target) {
|
|
20
|
-
|
|
13
|
+
const {
|
|
14
|
+
value
|
|
15
|
+
} = target;
|
|
21
16
|
return value;
|
|
22
17
|
}
|
|
23
18
|
|
|
24
19
|
if (currentTarget) {
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
const {
|
|
21
|
+
value
|
|
22
|
+
} = currentTarget;
|
|
23
|
+
return value;
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
return e;
|
|
30
27
|
};
|
|
31
28
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
const toggleItemValue = (array, e) => {
|
|
30
|
+
const newvalue = getValueItem(e);
|
|
31
|
+
const res = array;
|
|
32
|
+
const index = array.indexOf(newvalue);
|
|
36
33
|
|
|
37
34
|
if (index === -1) {
|
|
38
35
|
res.push(newvalue);
|
|
@@ -43,91 +40,79 @@ var toggleItemValue = function toggleItemValue(array, e) {
|
|
|
43
40
|
return res;
|
|
44
41
|
};
|
|
45
42
|
|
|
46
|
-
|
|
43
|
+
const {
|
|
44
|
+
Provider
|
|
45
|
+
} = GroupContext;
|
|
47
46
|
/** deprecated use CheckableGroup instead */
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
_this = _super.call(this, props);
|
|
60
|
-
var activeValue = props.activeValue,
|
|
61
|
-
disabled = props.disabled;
|
|
62
|
-
_this.state = {
|
|
63
|
-
activeValue: activeValue,
|
|
64
|
-
disabled: disabled,
|
|
48
|
+
class Group extends Component {
|
|
49
|
+
constructor(props) {
|
|
50
|
+
super(props);
|
|
51
|
+
const {
|
|
52
|
+
activeValue,
|
|
53
|
+
disabled
|
|
54
|
+
} = props;
|
|
55
|
+
this.state = {
|
|
56
|
+
activeValue,
|
|
57
|
+
disabled,
|
|
65
58
|
prevValue: null,
|
|
66
|
-
onChange:
|
|
59
|
+
onChange: this.handleChange.bind(this)
|
|
67
60
|
};
|
|
68
|
-
return _this;
|
|
69
61
|
}
|
|
70
62
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}, {
|
|
99
|
-
key: "render",
|
|
100
|
-
value: function render() {
|
|
101
|
-
var children = this.props.children;
|
|
102
|
-
return /*#__PURE__*/React.createElement(Provider, {
|
|
103
|
-
value: this.state
|
|
104
|
-
}, children);
|
|
63
|
+
static getDerivedStateFromProps(nextProps, _ref) {
|
|
64
|
+
let {
|
|
65
|
+
prevValue
|
|
66
|
+
} = _ref;
|
|
67
|
+
if (nextProps.activeValue === prevValue) return null;
|
|
68
|
+
return {
|
|
69
|
+
activeValue: nextProps.activeValue,
|
|
70
|
+
prevValue: nextProps.activeValue
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
handleChange(e) {
|
|
75
|
+
const {
|
|
76
|
+
multiple,
|
|
77
|
+
onChange
|
|
78
|
+
} = this.props;
|
|
79
|
+
const {
|
|
80
|
+
activeValue
|
|
81
|
+
} = this.state;
|
|
82
|
+
const value = getValueItem(e);
|
|
83
|
+
let newValue;
|
|
84
|
+
|
|
85
|
+
if (multiple) {
|
|
86
|
+
newValue = toggleItemValue(activeValue || [], value);
|
|
87
|
+
} else if (activeValue !== value) {
|
|
88
|
+
// default behaviour it will be toggle the active value
|
|
89
|
+
newValue = value;
|
|
105
90
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
prevValue: nextProps.activeValue
|
|
114
|
-
};
|
|
91
|
+
|
|
92
|
+
this.setState({
|
|
93
|
+
activeValue: newValue
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
97
|
+
rest[_key - 1] = arguments[_key];
|
|
115
98
|
}
|
|
116
|
-
}]);
|
|
117
99
|
|
|
118
|
-
|
|
119
|
-
}
|
|
100
|
+
if (onChange) onChange(newValue, ...rest);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
render() {
|
|
104
|
+
const {
|
|
105
|
+
children
|
|
106
|
+
} = this.props;
|
|
107
|
+
return /*#__PURE__*/_jsx(Provider, {
|
|
108
|
+
value: this.state
|
|
109
|
+
}, void 0, children);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
}
|
|
120
113
|
|
|
121
114
|
Group.defaultProps = {
|
|
122
115
|
multiple: false
|
|
123
116
|
};
|
|
124
|
-
Group.propTypes = {
|
|
125
|
-
children: PropTypes.array,
|
|
126
|
-
multiple: PropTypes.bool,
|
|
127
|
-
onChange: PropTypes.func,
|
|
128
|
-
activeValue: PropTypes.oneOfType([PropTypes.array, PropTypes.number]),
|
|
129
|
-
disabled: PropTypes.bool
|
|
130
|
-
};
|
|
131
117
|
|
|
132
118
|
export { Group as default };
|
|
133
|
-
//# sourceMappingURL=Group.js.map
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'react';
|
|
2
3
|
import { GroupContext } from './GroupContext.js';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
const {
|
|
6
|
+
Consumer
|
|
7
|
+
} = GroupContext;
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
});
|
|
9
|
+
const GroupItem = _ref => {
|
|
10
|
+
let {
|
|
11
|
+
render
|
|
12
|
+
} = _ref;
|
|
13
|
+
return /*#__PURE__*/_jsx(Consumer, {}, void 0, context => render(context));
|
|
11
14
|
};
|
|
12
15
|
|
|
13
16
|
export { GroupItem as default };
|
|
14
|
-
//# sourceMappingURL=GroupItem.js.map
|