@kaizen/components 1.67.2 → 1.67.3
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/dist/cjs/Filter/FilterBar/context/FilterBarContext.cjs +17 -2
- package/dist/cjs/Filter/FilterBar/context/reducer/filterBarStateReducer.cjs +4 -0
- package/dist/cjs/Filter/FilterBar/context/reducer/setupFilterBarState.cjs +2 -1
- package/dist/cjs/Filter/FilterBar/subcomponents/AddFiltersMenu/AddFiltersMenu.cjs +12 -1
- package/dist/cjs/Filter/FilterBar/subcomponents/FilterBarButton/FilterBarButton.cjs +12 -1
- package/dist/cjs/Filter/FilterBar/subcomponents/FilterBarMultiSelect/FilterBarMultiSelect.cjs +13 -2
- package/dist/cjs/Filter/FilterMultiSelect/FilterMultiSelect.cjs +4 -2
- package/dist/cjs/Filter/FilterMultiSelect/context/MenuTriggerProvider/MenuTriggerProvider.cjs +4 -2
- package/dist/esm/Filter/FilterBar/context/FilterBarContext.mjs +17 -2
- package/dist/esm/Filter/FilterBar/context/reducer/filterBarStateReducer.mjs +4 -0
- package/dist/esm/Filter/FilterBar/context/reducer/setupFilterBarState.mjs +2 -1
- package/dist/esm/Filter/FilterBar/subcomponents/AddFiltersMenu/AddFiltersMenu.mjs +13 -2
- package/dist/esm/Filter/FilterBar/subcomponents/FilterBarButton/FilterBarButton.mjs +13 -2
- package/dist/esm/Filter/FilterBar/subcomponents/FilterBarMultiSelect/FilterBarMultiSelect.mjs +14 -3
- package/dist/esm/Filter/FilterMultiSelect/FilterMultiSelect.mjs +4 -2
- package/dist/esm/Filter/FilterMultiSelect/context/MenuTriggerProvider/MenuTriggerProvider.mjs +4 -2
- package/dist/styles.css +34 -34
- package/dist/types/Filter/FilterBar/context/FilterBarContext.d.ts +2 -0
- package/dist/types/Filter/FilterBar/context/reducer/filterBarStateReducer.d.ts +3 -0
- package/dist/types/Filter/FilterBar/context/types.d.ts +1 -0
- package/dist/types/Filter/FilterMultiSelect/FilterMultiSelect.d.ts +2 -1
- package/dist/types/Filter/FilterMultiSelect/context/MenuTriggerProvider/MenuTriggerProvider.d.ts +2 -1
- package/package.json +1 -1
- package/src/Filter/FilterBar/FilterBar.spec.tsx +87 -0
- package/src/Filter/FilterBar/context/FilterBarContext.tsx +11 -2
- package/src/Filter/FilterBar/context/reducer/filterBarStateReducer.ts +7 -0
- package/src/Filter/FilterBar/context/reducer/setupFilterBarState.ts +1 -0
- package/src/Filter/FilterBar/context/types.ts +1 -0
- package/src/Filter/FilterBar/subcomponents/AddFiltersMenu/AddFiltersMenu.tsx +12 -2
- package/src/Filter/FilterBar/subcomponents/FilterBarButton/FilterBarButton.tsx +10 -2
- package/src/Filter/FilterBar/subcomponents/FilterBarMultiSelect/FilterBarMultiSelect.tsx +18 -3
- package/src/Filter/FilterMultiSelect/FilterMultiSelect.tsx +3 -1
- package/src/Filter/FilterMultiSelect/context/MenuTriggerProvider/MenuTriggerProvider.tsx +4 -1
|
@@ -80,16 +80,24 @@ var FilterBarProvider = function (_a) {
|
|
|
80
80
|
});
|
|
81
81
|
},
|
|
82
82
|
showFilter: function (id) {
|
|
83
|
-
|
|
83
|
+
dispatch({
|
|
84
84
|
type: "activate_filter",
|
|
85
85
|
id: id
|
|
86
86
|
});
|
|
87
|
+
dispatch({
|
|
88
|
+
type: "set_focus",
|
|
89
|
+
id: id
|
|
90
|
+
});
|
|
87
91
|
},
|
|
88
92
|
hideFilter: function (id) {
|
|
89
93
|
dispatch({
|
|
90
94
|
type: "deactivate_filter",
|
|
91
95
|
id: id
|
|
92
96
|
});
|
|
97
|
+
dispatch({
|
|
98
|
+
type: "set_focus",
|
|
99
|
+
id: "add_filter"
|
|
100
|
+
});
|
|
93
101
|
},
|
|
94
102
|
getInactiveFilters: function () {
|
|
95
103
|
return getInactiveFilters.getInactiveFilters(state);
|
|
@@ -105,7 +113,14 @@ var FilterBarProvider = function (_a) {
|
|
|
105
113
|
type: "update_values",
|
|
106
114
|
values: {}
|
|
107
115
|
});
|
|
108
|
-
}
|
|
116
|
+
},
|
|
117
|
+
setFocus: function (id) {
|
|
118
|
+
dispatch({
|
|
119
|
+
type: "set_focus",
|
|
120
|
+
id: id
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
focusId: state.focusId
|
|
109
124
|
};
|
|
110
125
|
React.useEffect(function () {
|
|
111
126
|
var shouldUpdate = checkShouldUpdateValues.checkShouldUpdateValues(state, values);
|
|
@@ -6,6 +6,10 @@ var updateSingleFilter = require('./updateSingleFilter.cjs');
|
|
|
6
6
|
var updateValues = require('./updateValues.cjs');
|
|
7
7
|
var filterBarStateReducer = function (state, action) {
|
|
8
8
|
switch (action.type) {
|
|
9
|
+
case "set_focus":
|
|
10
|
+
return tslib.__assign(tslib.__assign({}, state), {
|
|
11
|
+
focusId: action.id
|
|
12
|
+
});
|
|
9
13
|
case "update_values":
|
|
10
14
|
return tslib.__assign({}, updateValues.updateValues(state, action.values));
|
|
11
15
|
case "complete_update_values":
|
|
@@ -28,7 +28,8 @@ var setupFilterBarState = function (filters, values) {
|
|
|
28
28
|
activeFilterIds: new Set(),
|
|
29
29
|
values: values,
|
|
30
30
|
dependentFilterIds: new Set(),
|
|
31
|
-
hasUpdatedValues: false
|
|
31
|
+
hasUpdatedValues: false,
|
|
32
|
+
focusId: undefined
|
|
32
33
|
});
|
|
33
34
|
return updateDependentFilters.updateDependentFilters(state);
|
|
34
35
|
};
|
|
@@ -16,6 +16,7 @@ function _interopDefault(e) {
|
|
|
16
16
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
17
17
|
var AddFiltersMenu = function () {
|
|
18
18
|
var formatMessage = i18nReactIntl.useIntl().formatMessage;
|
|
19
|
+
var buttonRef = React.useRef(null);
|
|
19
20
|
var menuButtonLabel = formatMessage({
|
|
20
21
|
id: "filterBar.addFiltersMenu.buttonLabel",
|
|
21
22
|
defaultMessage: "Add Filters",
|
|
@@ -23,10 +24,20 @@ var AddFiltersMenu = function () {
|
|
|
23
24
|
});
|
|
24
25
|
var _a = FilterBarContext.useFilterBarContext(),
|
|
25
26
|
getInactiveFilters = _a.getInactiveFilters,
|
|
26
|
-
showFilter = _a.showFilter
|
|
27
|
+
showFilter = _a.showFilter,
|
|
28
|
+
focusId = _a.focusId,
|
|
29
|
+
setFocus = _a.setFocus;
|
|
27
30
|
var inactiveFilters = getInactiveFilters();
|
|
31
|
+
React.useEffect(function () {
|
|
32
|
+
var _a;
|
|
33
|
+
if (focusId === "add_filter") {
|
|
34
|
+
(_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
35
|
+
setFocus(undefined);
|
|
36
|
+
}
|
|
37
|
+
}, [focusId]);
|
|
28
38
|
return React__default.default.createElement(Menu.Menu, {
|
|
29
39
|
button: React__default.default.createElement(Button.Button, {
|
|
40
|
+
ref: buttonRef,
|
|
30
41
|
label: menuButtonLabel,
|
|
31
42
|
secondary: true,
|
|
32
43
|
disabled: inactiveFilters.length === 0,
|
|
@@ -5,6 +5,7 @@ var React = require('react');
|
|
|
5
5
|
var FilterBarContext = require('../../context/FilterBarContext.cjs');
|
|
6
6
|
var FilterButton = require('../../../FilterButton/FilterButton/FilterButton.cjs');
|
|
7
7
|
var FilterButtonRemovable = require('../../../FilterButton/FilterButtonRemovable/FilterButtonRemovable.cjs');
|
|
8
|
+
var isRefObject = require('../../../../utils/isRefObject.cjs');
|
|
8
9
|
function _interopDefault(e) {
|
|
9
10
|
return e && e.__esModule ? e : {
|
|
10
11
|
default: e
|
|
@@ -16,7 +17,17 @@ var FilterBarButton = React.forwardRef(function (_a, ref) {
|
|
|
16
17
|
_b = _a.isRemovable,
|
|
17
18
|
isRemovable = _b === void 0 ? false : _b,
|
|
18
19
|
props = tslib.__rest(_a, ["filterId", "isRemovable"]);
|
|
19
|
-
var
|
|
20
|
+
var _c = FilterBarContext.useFilterBarContext(),
|
|
21
|
+
hideFilter = _c.hideFilter,
|
|
22
|
+
focusId = _c.focusId,
|
|
23
|
+
setFocus = _c.setFocus;
|
|
24
|
+
React.useEffect(function () {
|
|
25
|
+
var _a, _b, _c;
|
|
26
|
+
if (focusId === filterId && isRefObject.isRefObject(ref)) {
|
|
27
|
+
(_c = (_b = (_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.triggerRef) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c.focus();
|
|
28
|
+
setFocus(undefined);
|
|
29
|
+
}
|
|
30
|
+
}, [focusId]);
|
|
20
31
|
return isRemovable ? React__default.default.createElement(FilterButtonRemovable.FilterButtonRemovable, {
|
|
21
32
|
ref: ref,
|
|
22
33
|
triggerButtonProps: props,
|
package/dist/cjs/Filter/FilterBar/subcomponents/FilterBarMultiSelect/FilterBarMultiSelect.cjs
CHANGED
|
@@ -32,10 +32,13 @@ var FilterBarMultiSelect = function (_a) {
|
|
|
32
32
|
getFilterState = _b.getFilterState,
|
|
33
33
|
setFilterOpenState = _b.setFilterOpenState,
|
|
34
34
|
updateValue = _b.updateValue,
|
|
35
|
-
hideFilter = _b.hideFilter
|
|
35
|
+
hideFilter = _b.hideFilter,
|
|
36
|
+
focusId = _b.focusId,
|
|
37
|
+
setFocus = _b.setFocus;
|
|
36
38
|
var _c = React.useState(propsItems),
|
|
37
39
|
items = _c[0],
|
|
38
40
|
setItems = _c[1];
|
|
41
|
+
var buttonRef = React.useRef(null);
|
|
39
42
|
if (!id) throw Error("Missing `id` prop in FilterBarMultiSelect");
|
|
40
43
|
var filterState = getFilterState(id);
|
|
41
44
|
React.useEffect(function () {
|
|
@@ -57,6 +60,13 @@ var FilterBarMultiSelect = function (_a) {
|
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
62
|
}, [items]);
|
|
63
|
+
React.useEffect(function () {
|
|
64
|
+
var _a;
|
|
65
|
+
if (focusId === id) {
|
|
66
|
+
(_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
67
|
+
setFocus(undefined);
|
|
68
|
+
}
|
|
69
|
+
}, [focusId]);
|
|
60
70
|
return React__default.default.createElement(FilterMultiSelect.FilterMultiSelect, tslib.__assign({
|
|
61
71
|
label: filterState.name,
|
|
62
72
|
// Convert the incoming FilterBar state to a Set (internal FilterMultiSelect state)
|
|
@@ -81,7 +91,8 @@ var FilterBarMultiSelect = function (_a) {
|
|
|
81
91
|
return hideFilter(id);
|
|
82
92
|
}
|
|
83
93
|
})) : React__default.default.createElement(FilterMultiSelect.FilterMultiSelect.TriggerButton, tslib.__assign({}, triggerProps));
|
|
84
|
-
}
|
|
94
|
+
},
|
|
95
|
+
triggerRef: buttonRef
|
|
85
96
|
}, props), children);
|
|
86
97
|
};
|
|
87
98
|
FilterBarMultiSelect.displayName = "FilterBar.MultiSelect";
|
|
@@ -39,11 +39,13 @@ var FilterMultiSelect = function (_a) {
|
|
|
39
39
|
onSelectionChange = _a.onSelectionChange,
|
|
40
40
|
_b = _a.selectionMode,
|
|
41
41
|
selectionMode = _b === void 0 ? "multiple" : _b,
|
|
42
|
-
onSearchInputChange = _a.onSearchInputChange
|
|
42
|
+
onSearchInputChange = _a.onSearchInputChange,
|
|
43
|
+
triggerRef = _a.triggerRef;
|
|
43
44
|
var menuTriggerProps = {
|
|
44
45
|
isOpen: isOpen,
|
|
45
46
|
defaultOpen: defaultOpen,
|
|
46
|
-
onOpenChange: onOpenChange
|
|
47
|
+
onOpenChange: onOpenChange,
|
|
48
|
+
triggerRef: triggerRef
|
|
47
49
|
};
|
|
48
50
|
var menuPopupProps = {
|
|
49
51
|
isLoading: isLoading,
|
package/dist/cjs/Filter/FilterMultiSelect/context/MenuTriggerProvider/MenuTriggerProvider.cjs
CHANGED
|
@@ -15,7 +15,8 @@ function MenuTriggerProvider(_a) {
|
|
|
15
15
|
var isOpen = _a.isOpen,
|
|
16
16
|
defaultOpen = _a.defaultOpen,
|
|
17
17
|
onOpenChange = _a.onOpenChange,
|
|
18
|
-
children = _a.children
|
|
18
|
+
children = _a.children,
|
|
19
|
+
triggerRef = _a.triggerRef;
|
|
19
20
|
// Create state based on the incoming props to manage the open/close
|
|
20
21
|
var state = menu.useMenuTriggerState({
|
|
21
22
|
isOpen: isOpen,
|
|
@@ -23,7 +24,8 @@ function MenuTriggerProvider(_a) {
|
|
|
23
24
|
onOpenChange: onOpenChange
|
|
24
25
|
});
|
|
25
26
|
// Get A11y attributes and events for the menu trigger and menu elements
|
|
26
|
-
var
|
|
27
|
+
var fallbackRef = React.useRef(null);
|
|
28
|
+
var ref = triggerRef || fallbackRef;
|
|
27
29
|
var _b = menu$1.useMenuTrigger({}, state, ref),
|
|
28
30
|
menuTriggerProps = _b.menuTriggerProps,
|
|
29
31
|
menuProps = _b.menuProps;
|
|
@@ -72,16 +72,24 @@ var FilterBarProvider = function (_a) {
|
|
|
72
72
|
});
|
|
73
73
|
},
|
|
74
74
|
showFilter: function (id) {
|
|
75
|
-
|
|
75
|
+
dispatch({
|
|
76
76
|
type: "activate_filter",
|
|
77
77
|
id: id
|
|
78
78
|
});
|
|
79
|
+
dispatch({
|
|
80
|
+
type: "set_focus",
|
|
81
|
+
id: id
|
|
82
|
+
});
|
|
79
83
|
},
|
|
80
84
|
hideFilter: function (id) {
|
|
81
85
|
dispatch({
|
|
82
86
|
type: "deactivate_filter",
|
|
83
87
|
id: id
|
|
84
88
|
});
|
|
89
|
+
dispatch({
|
|
90
|
+
type: "set_focus",
|
|
91
|
+
id: "add_filter"
|
|
92
|
+
});
|
|
85
93
|
},
|
|
86
94
|
getInactiveFilters: function () {
|
|
87
95
|
return getInactiveFilters(state);
|
|
@@ -97,7 +105,14 @@ var FilterBarProvider = function (_a) {
|
|
|
97
105
|
type: "update_values",
|
|
98
106
|
values: {}
|
|
99
107
|
});
|
|
100
|
-
}
|
|
108
|
+
},
|
|
109
|
+
setFocus: function (id) {
|
|
110
|
+
dispatch({
|
|
111
|
+
type: "set_focus",
|
|
112
|
+
id: id
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
focusId: state.focusId
|
|
101
116
|
};
|
|
102
117
|
useEffect(function () {
|
|
103
118
|
var shouldUpdate = checkShouldUpdateValues(state, values);
|
|
@@ -4,6 +4,10 @@ import { updateSingleFilter } from './updateSingleFilter.mjs';
|
|
|
4
4
|
import { updateValues } from './updateValues.mjs';
|
|
5
5
|
var filterBarStateReducer = function (state, action) {
|
|
6
6
|
switch (action.type) {
|
|
7
|
+
case "set_focus":
|
|
8
|
+
return __assign(__assign({}, state), {
|
|
9
|
+
focusId: action.id
|
|
10
|
+
});
|
|
7
11
|
case "update_values":
|
|
8
12
|
return __assign({}, updateValues(state, action.values));
|
|
9
13
|
case "complete_update_values":
|
|
@@ -26,7 +26,8 @@ var setupFilterBarState = function (filters, values) {
|
|
|
26
26
|
activeFilterIds: new Set(),
|
|
27
27
|
values: values,
|
|
28
28
|
dependentFilterIds: new Set(),
|
|
29
|
-
hasUpdatedValues: false
|
|
29
|
+
hasUpdatedValues: false,
|
|
30
|
+
focusId: undefined
|
|
30
31
|
});
|
|
31
32
|
return updateDependentFilters(state);
|
|
32
33
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
2
|
import { useIntl } from '@cultureamp/i18n-react-intl';
|
|
3
3
|
import { Icon } from '../../../../__future__/Icon/Icon.mjs';
|
|
4
4
|
import { useFilterBarContext } from '../../context/FilterBarContext.mjs';
|
|
@@ -9,6 +9,7 @@ import { Button } from '../../../../__actions__/Button/v1/Button/Button.mjs';
|
|
|
9
9
|
const AddFiltersMenu = /*#__PURE__*/function () {
|
|
10
10
|
const AddFiltersMenu = function () {
|
|
11
11
|
var formatMessage = useIntl().formatMessage;
|
|
12
|
+
var buttonRef = useRef(null);
|
|
12
13
|
var menuButtonLabel = formatMessage({
|
|
13
14
|
id: "filterBar.addFiltersMenu.buttonLabel",
|
|
14
15
|
defaultMessage: "Add Filters",
|
|
@@ -16,10 +17,20 @@ const AddFiltersMenu = /*#__PURE__*/function () {
|
|
|
16
17
|
});
|
|
17
18
|
var _a = useFilterBarContext(),
|
|
18
19
|
getInactiveFilters = _a.getInactiveFilters,
|
|
19
|
-
showFilter = _a.showFilter
|
|
20
|
+
showFilter = _a.showFilter,
|
|
21
|
+
focusId = _a.focusId,
|
|
22
|
+
setFocus = _a.setFocus;
|
|
20
23
|
var inactiveFilters = getInactiveFilters();
|
|
24
|
+
useEffect(function () {
|
|
25
|
+
var _a;
|
|
26
|
+
if (focusId === "add_filter") {
|
|
27
|
+
(_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
28
|
+
setFocus(undefined);
|
|
29
|
+
}
|
|
30
|
+
}, [focusId]);
|
|
21
31
|
return /*#__PURE__*/React.createElement(Menu, {
|
|
22
32
|
button: /*#__PURE__*/React.createElement(Button, {
|
|
33
|
+
ref: buttonRef,
|
|
23
34
|
label: menuButtonLabel,
|
|
24
35
|
secondary: true,
|
|
25
36
|
disabled: inactiveFilters.length === 0,
|
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
import { __rest, __assign } from 'tslib';
|
|
2
|
-
import React, { forwardRef } from 'react';
|
|
2
|
+
import React, { forwardRef, useEffect } from 'react';
|
|
3
3
|
import { useFilterBarContext } from '../../context/FilterBarContext.mjs';
|
|
4
4
|
import { FilterButton } from '../../../FilterButton/FilterButton/FilterButton.mjs';
|
|
5
5
|
import { FilterButtonRemovable } from '../../../FilterButton/FilterButtonRemovable/FilterButtonRemovable.mjs';
|
|
6
|
+
import { isRefObject } from '../../../../utils/isRefObject.mjs';
|
|
6
7
|
const FilterBarButton = /*#__PURE__*/function () {
|
|
7
8
|
const FilterBarButton = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
8
9
|
var filterId = _a.filterId,
|
|
9
10
|
_b = _a.isRemovable,
|
|
10
11
|
isRemovable = _b === void 0 ? false : _b,
|
|
11
12
|
props = __rest(_a, ["filterId", "isRemovable"]);
|
|
12
|
-
var
|
|
13
|
+
var _c = useFilterBarContext(),
|
|
14
|
+
hideFilter = _c.hideFilter,
|
|
15
|
+
focusId = _c.focusId,
|
|
16
|
+
setFocus = _c.setFocus;
|
|
17
|
+
useEffect(function () {
|
|
18
|
+
var _a, _b, _c;
|
|
19
|
+
if (focusId === filterId && isRefObject(ref)) {
|
|
20
|
+
(_c = (_b = (_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.triggerRef) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c.focus();
|
|
21
|
+
setFocus(undefined);
|
|
22
|
+
}
|
|
23
|
+
}, [focusId]);
|
|
13
24
|
return isRemovable ? ( /*#__PURE__*/React.createElement(FilterButtonRemovable, {
|
|
14
25
|
ref: ref,
|
|
15
26
|
triggerButtonProps: props,
|
package/dist/esm/Filter/FilterBar/subcomponents/FilterBarMultiSelect/FilterBarMultiSelect.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __rest, __assign } from 'tslib';
|
|
2
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
3
3
|
import { FilterMultiSelect } from '../../../FilterMultiSelect/FilterMultiSelect.mjs';
|
|
4
4
|
import '../../../FilterMultiSelect/context/MenuTriggerProvider/MenuTriggerProvider.mjs';
|
|
5
5
|
import '../../../FilterMultiSelect/context/SelectionProvider/SelectionProvider.mjs';
|
|
@@ -25,10 +25,13 @@ const FilterBarMultiSelect = /*#__PURE__*/function () {
|
|
|
25
25
|
getFilterState = _b.getFilterState,
|
|
26
26
|
setFilterOpenState = _b.setFilterOpenState,
|
|
27
27
|
updateValue = _b.updateValue,
|
|
28
|
-
hideFilter = _b.hideFilter
|
|
28
|
+
hideFilter = _b.hideFilter,
|
|
29
|
+
focusId = _b.focusId,
|
|
30
|
+
setFocus = _b.setFocus;
|
|
29
31
|
var _c = useState(propsItems),
|
|
30
32
|
items = _c[0],
|
|
31
33
|
setItems = _c[1];
|
|
34
|
+
var buttonRef = useRef(null);
|
|
32
35
|
if (!id) throw Error("Missing `id` prop in FilterBarMultiSelect");
|
|
33
36
|
var filterState = getFilterState(id);
|
|
34
37
|
useEffect(function () {
|
|
@@ -50,6 +53,13 @@ const FilterBarMultiSelect = /*#__PURE__*/function () {
|
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
}, [items]);
|
|
56
|
+
useEffect(function () {
|
|
57
|
+
var _a;
|
|
58
|
+
if (focusId === id) {
|
|
59
|
+
(_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
60
|
+
setFocus(undefined);
|
|
61
|
+
}
|
|
62
|
+
}, [focusId]);
|
|
53
63
|
return /*#__PURE__*/React.createElement(FilterMultiSelect, __assign({
|
|
54
64
|
label: filterState.name,
|
|
55
65
|
// Convert the incoming FilterBar state to a Set (internal FilterMultiSelect state)
|
|
@@ -74,7 +84,8 @@ const FilterBarMultiSelect = /*#__PURE__*/function () {
|
|
|
74
84
|
return hideFilter(id);
|
|
75
85
|
}
|
|
76
86
|
}))) : ( /*#__PURE__*/React.createElement(FilterMultiSelect.TriggerButton, __assign({}, triggerProps)));
|
|
77
|
-
}
|
|
87
|
+
},
|
|
88
|
+
triggerRef: buttonRef
|
|
78
89
|
}, props), children);
|
|
79
90
|
};
|
|
80
91
|
FilterBarMultiSelect.displayName = "FilterBar.MultiSelect";
|
|
@@ -32,11 +32,13 @@ const FilterMultiSelect = /*#__PURE__*/function () {
|
|
|
32
32
|
onSelectionChange = _a.onSelectionChange,
|
|
33
33
|
_b = _a.selectionMode,
|
|
34
34
|
selectionMode = _b === void 0 ? "multiple" : _b,
|
|
35
|
-
onSearchInputChange = _a.onSearchInputChange
|
|
35
|
+
onSearchInputChange = _a.onSearchInputChange,
|
|
36
|
+
triggerRef = _a.triggerRef;
|
|
36
37
|
var menuTriggerProps = {
|
|
37
38
|
isOpen: isOpen,
|
|
38
39
|
defaultOpen: defaultOpen,
|
|
39
|
-
onOpenChange: onOpenChange
|
|
40
|
+
onOpenChange: onOpenChange,
|
|
41
|
+
triggerRef: triggerRef
|
|
40
42
|
};
|
|
41
43
|
var menuPopupProps = {
|
|
42
44
|
isLoading: isLoading,
|
package/dist/esm/Filter/FilterMultiSelect/context/MenuTriggerProvider/MenuTriggerProvider.mjs
CHANGED
|
@@ -7,7 +7,8 @@ function MenuTriggerProvider(_a) {
|
|
|
7
7
|
var isOpen = _a.isOpen,
|
|
8
8
|
defaultOpen = _a.defaultOpen,
|
|
9
9
|
onOpenChange = _a.onOpenChange,
|
|
10
|
-
children = _a.children
|
|
10
|
+
children = _a.children,
|
|
11
|
+
triggerRef = _a.triggerRef;
|
|
11
12
|
// Create state based on the incoming props to manage the open/close
|
|
12
13
|
var state = useMenuTriggerState({
|
|
13
14
|
isOpen: isOpen,
|
|
@@ -15,7 +16,8 @@ function MenuTriggerProvider(_a) {
|
|
|
15
16
|
onOpenChange: onOpenChange
|
|
16
17
|
});
|
|
17
18
|
// Get A11y attributes and events for the menu trigger and menu elements
|
|
18
|
-
var
|
|
19
|
+
var fallbackRef = useRef(null);
|
|
20
|
+
var ref = triggerRef || fallbackRef;
|
|
19
21
|
var _b = useMenuTrigger({}, state, ref),
|
|
20
22
|
menuTriggerProps = _b.menuTriggerProps,
|
|
21
23
|
menuProps = _b.menuProps;
|
package/dist/styles.css
CHANGED
|
@@ -1,38 +1,4 @@
|
|
|
1
1
|
@layer tokens, normalize, reset;@layer tokens{:root{--theme-key:heart;--animation-easing-function-ease-in-out:cubic-bezier(0.455,0.03,0.515,0.955);--animation-easing-function-ease-in:cubic-bezier(0.55,0.085,0.68,0.53);--animation-easing-function-ease-out:cubic-bezier(0.25,0.46,0.45,0.94);--animation-easing-function-linear:linear;--animation-easing-function-bounce-in:cubic-bezier(0.485,0.155,0.24,1.245);--animation-easing-function-bounce-out:cubic-bezier(0.485,0.155,0.515,0.845);--animation-easing-function-bounce-in-out:cubic-bezier(0.76,-0.245,0.24,1.245);--animation-duration-instant:0ms;--animation-duration-immediate:100ms;--animation-duration-rapid:200ms;--animation-duration-fast:300ms;--animation-duration-slow:400ms;--animation-duration-deliberate:700ms;--border-solid-border-width:2px;--border-solid-border-radius:7px;--border-solid-border-style:solid;--border-solid-border-color:#e1e2ea;--border-solid-border-color-rgb:225,226,234;--border-dashed-border-width:2px;--border-dashed-border-radius:7px;--border-dashed-border-style:dashed;--border-borderless-border-width:2px;--border-borderless-border-radius:7px;--border-borderless-border-style:solid;--border-borderless-border-color:transparent;--border-borderless-border-color-rgb:0,0,0;--border-focus-ring-border-width:2px;--border-focus-ring-border-radius:10px;--border-focus-ring-border-style:solid;--border-width-1:1px;--color-purple-100:#f4edf8;--color-purple-100-rgb:244,237,248;--color-purple-200:#dfc9ea;--color-purple-200-rgb:223,201,234;--color-purple-300:#c9a5dd;--color-purple-300-rgb:201,165,221;--color-purple-400:#ae67b1;--color-purple-400-rgb:174,103,177;--color-purple-500:#844587;--color-purple-500-rgb:132,69,135;--color-purple-600:#5f3361;--color-purple-600-rgb:95,51,97;--color-purple-700:#4a234d;--color-purple-700-rgb:74,35,77;--color-purple-800:#2f2438;--color-purple-800-rgb:47,36,56;--color-blue-100:#e6f6ff;--color-blue-100-rgb:230,246,255;--color-blue-200:#bde2f5;--color-blue-200-rgb:189,226,245;--color-blue-300:#73c0e8;--color-blue-300-rgb:115,192,232;--color-blue-400:#008bd6;--color-blue-400-rgb:0,139,214;--color-blue-500:#0168b3;--color-blue-500-rgb:1,104,179;--color-blue-600:#004970;--color-blue-600-rgb:0,73,112;--color-blue-700:#003157;--color-blue-700-rgb:0,49,87;--color-green-100:#e8f8f4;--color-green-100-rgb:232,248,244;--color-green-200:#c4ede2;--color-green-200-rgb:196,237,226;--color-green-300:#8fdbc7;--color-green-300-rgb:143,219,199;--color-green-400:#5dcaad;--color-green-400-rgb:93,202,173;--color-green-500:#3f9a86;--color-green-500-rgb:63,154,134;--color-green-600:#2c7d67;--color-green-600-rgb:44,125,103;--color-green-700:#22594a;--color-green-700-rgb:34,89,74;--color-yellow-100:#fff9e4;--color-yellow-100-rgb:255,249,228;--color-yellow-200:#ffeeb3;--color-yellow-200-rgb:255,238,179;--color-yellow-300:#ffe36e;--color-yellow-300-rgb:255,227,110;--color-yellow-400:#ffca4d;--color-yellow-400-rgb:255,202,77;--color-yellow-500:#ffb600;--color-yellow-500-rgb:255,182,0;--color-yellow-600:#c68600;--color-yellow-600-rgb:198,134,0;--color-yellow-700:#876400;--color-yellow-700-rgb:135,100,0;--color-red-100:#fdeaee;--color-red-100-rgb:253,234,238;--color-red-200:#f9c2cb;--color-red-200-rgb:249,194,203;--color-red-300:#f597a8;--color-red-300-rgb:245,151,168;--color-red-400:#e0707d;--color-red-400-rgb:224,112,125;--color-red-500:#c93b55;--color-red-500-rgb:201,59,85;--color-red-600:#a82433;--color-red-600-rgb:168,36,51;--color-red-700:#6c1e20;--color-red-700-rgb:108,30,32;--color-orange-100:#fff0e8;--color-orange-100-rgb:255,240,232;--color-orange-200:#ffd1b9;--color-orange-200-rgb:255,209,185;--color-orange-300:#ffb08a;--color-orange-300-rgb:255,176,138;--color-orange-400:#ff9461;--color-orange-400-rgb:255,148,97;--color-orange-500:#e96c2f;--color-orange-500-rgb:233,108,47;--color-orange-600:#b74302;--color-orange-600-rgb:183,67,2;--color-orange-700:#903c00;--color-orange-700-rgb:144,60,0;--color-gray-100:#f9f9f9;--color-gray-100-rgb:249,249,249;--color-gray-200:#f4f4f5;--color-gray-200-rgb:244,244,245;--color-gray-300:#eaeaec;--color-gray-300-rgb:234,234,236;--color-gray-400:#cdcdd0;--color-gray-400-rgb:205,205,208;--color-gray-500:#878792;--color-gray-500-rgb:135,135,146;--color-gray-600:#524e56;--color-gray-600-rgb:82,78,86;--color-white:#fff;--color-white-rgb:255,255,255;--color-black:#000;--color-black-rgb:0,0,0;--data-viz-favorable:#7dd5bd;--data-viz-favorable-rgb:125,213,189;--data-viz-unfavorable:#e68d97;--data-viz-unfavorable-rgb:230,141,151;--layout-content-max-width:1392px;--layout-content-max-width-with-sidebar:1080px;--layout-content-side-margin:72px;--layout-mobile-actions-drawer-height:60px;--layout-navigation-bar-height:72px;--layout-breakpoints-medium:768px;--layout-breakpoints-large:1080px;--shadow-small-box-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 3px 16px 0 rgba(0,0,0,.06);--shadow-large-box-shadow:0 3px 9px 0 rgba(0,0,0,.1),0 8px 40px 0 rgba(0,0,0,.08);--spacing-0:0;--spacing-1:.0625rem;--spacing-2:.125rem;--spacing-4:.25rem;--spacing-6:.375rem;--spacing-8:.5rem;--spacing-12:.75rem;--spacing-16:1rem;--spacing-20:1.25rem;--spacing-24:1.5rem;--spacing-32:2rem;--spacing-40:2.5rem;--spacing-48:3rem;--spacing-56:3.5rem;--spacing-64:4rem;--spacing-72:4.5rem;--spacing-80:5rem;--spacing-96:6rem;--spacing-112:7rem;--spacing-128:8rem;--spacing-160:10rem;--spacing-200:12.5rem;--spacing-240:15rem;--spacing-280:17.5rem;--spacing-320:20rem;--spacing-xs:0.375rem;--spacing-sm:0.75rem;--spacing-md:1.5rem;--spacing-lg:2.25rem;--spacing-xl:3rem;--spacing-xxl:3.75rem;--spacing-xxxl:4.5rem;--spacing-xxxxl:5.25rem;--spacing-xxxxxl:6rem;--typography-data-large-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-data-large-font-weight:700;--typography-data-large-font-size:5.25rem;--typography-data-large-line-height:5.25rem;--typography-data-large-letter-spacing:normal;--typography-data-large-units-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-data-large-units-font-weight:700;--typography-data-large-units-font-size:2.625rem;--typography-data-large-units-line-height:5.25rem;--typography-data-large-units-letter-spacing:normal;--typography-data-medium-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-data-medium-font-weight:700;--typography-data-medium-font-size:3rem;--typography-data-medium-line-height:5rem;--typography-data-medium-letter-spacing:normal;--typography-data-medium-units-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-data-medium-units-font-weight:700;--typography-data-medium-units-font-size:1.5rem;--typography-data-medium-units-line-height:5rem;--typography-data-medium-units-letter-spacing:normal;--typography-data-small-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-data-small-font-weight:700;--typography-data-small-font-size:1.5rem;--typography-data-small-line-height:1.5rem;--typography-data-small-letter-spacing:normal;--typography-data-small-units-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-data-small-units-font-weight:700;--typography-data-small-units-font-size:1.125rem;--typography-data-small-units-line-height:1.5rem;--typography-data-small-units-letter-spacing:normal;--typography-display-0-font-family:"Tiempos Headline",Georgia,serif;--typography-display-0-font-weight:800;--typography-display-0-font-size:4.5rem;--typography-display-0-line-height:5.25rem;--typography-display-0-letter-spacing:0em;--typography-heading-1-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-heading-1-font-weight:500;--typography-heading-1-font-size:2.125rem;--typography-heading-1-line-height:2.625rem;--typography-heading-1-letter-spacing:normal;--typography-heading-2-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-heading-2-font-weight:600;--typography-heading-2-font-size:1.75rem;--typography-heading-2-line-height:2.25rem;--typography-heading-2-letter-spacing:normal;--typography-heading-3-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-heading-3-font-weight:600;--typography-heading-3-font-size:1.375rem;--typography-heading-3-line-height:1.875rem;--typography-heading-3-letter-spacing:normal;--typography-heading-4-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-heading-4-font-weight:600;--typography-heading-4-font-size:1.125rem;--typography-heading-4-line-height:1.5rem;--typography-heading-4-letter-spacing:normal;--typography-heading-5-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-heading-5-font-weight:600;--typography-heading-5-font-size:1rem;--typography-heading-5-line-height:1.5rem;--typography-heading-5-letter-spacing:normal;--typography-heading-6-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-heading-6-font-weight:600;--typography-heading-6-font-size:0.875rem;--typography-heading-6-line-height:1.5rem;--typography-heading-6-letter-spacing:normal;--typography-paragraph-intro-lede-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-paragraph-intro-lede-font-weight:400;--typography-paragraph-intro-lede-font-size:1.25rem;--typography-paragraph-intro-lede-line-height:1.875rem;--typography-paragraph-intro-lede-letter-spacing:0;--typography-paragraph-intro-lede-max-width:975px;--typography-paragraph-body-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-paragraph-body-font-weight:400;--typography-paragraph-body-font-size:1rem;--typography-paragraph-body-line-height:1.5rem;--typography-paragraph-body-letter-spacing:normal;--typography-paragraph-body-max-width:780px;--typography-paragraph-small-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-paragraph-small-font-weight:400;--typography-paragraph-small-font-size:0.875rem;--typography-paragraph-small-line-height:1.125rem;--typography-paragraph-small-letter-spacing:normal;--typography-paragraph-small-max-width:680px;--typography-paragraph-extra-small-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-paragraph-extra-small-font-weight:400;--typography-paragraph-extra-small-font-size:0.75rem;--typography-paragraph-extra-small-line-height:1.125rem;--typography-paragraph-extra-small-letter-spacing:normal;--typography-paragraph-extra-small-max-width:600px;--typography-paragraph-bold-font-weight:600;--typography-button-primary-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-button-primary-font-weight:500;--typography-button-primary-font-size:1.125rem;--typography-button-primary-line-height:1.5rem;--typography-button-primary-letter-spacing:normal;--typography-button-secondary-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-button-secondary-font-weight:500;--typography-button-secondary-font-size:1rem;--typography-button-secondary-line-height:1.5rem;--typography-button-secondary-letter-spacing:normal}}@layer normalize{html{text-size-adjust:100%;line-height:1.15}body{margin:0}main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:.35em .75em .625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{appearance:none}::-webkit-file-upload-button{appearance:button;font:inherit}details{display:block}summary{display:list-item}[hidden],template{display:none}}@layer reset{@font-face{font-family:Tiempos Headline;font-weight:800;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/tiempos/tiempos-headline-bold.woff2),url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/tiempos/tiempos-headline-bold.woff)}@font-face{font-family:Tiempos Headline;font-weight:500;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/tiempos/tiempos-headline-medium.woff2),url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/tiempos/tiempos-headline-medium.woff)}@font-face{font-family:Greycliff CF;font-weight:300;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/greycliff/greycliff-cf-light.woff) format("woff")}@font-face{font-family:Greycliff CF;font-weight:400;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/greycliff/greycliff-cf-regular.woff) format("woff")}@font-face{font-family:Greycliff CF;font-weight:500;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/greycliff/greycliff-cf-medium.woff) format("woff")}@font-face{font-family:Greycliff CF;font-weight:600;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/greycliff/greycliff-cf-demi-bold.woff) format("woff")}@font-face{font-family:Greycliff CF;font-weight:700;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/greycliff/greycliff-cf-bold.woff) format("woff")}@font-face{font-family:Greycliff CF;font-weight:800;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/greycliff/greycliff-cf-extra-bold.woff) format("woff")}@font-face{font-family:Inter;font-weight:300;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-light.woff2),url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-light.woff)}@font-face{font-family:Inter;font-weight:400;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-regular.woff2),url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-regular.woff)}@font-face{font-family:Inter;font-weight:500;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-medium.woff2),url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-medium.woff)}@font-face{font-family:Inter;font-weight:600;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-demi-bold.woff2),url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-demi-bold.woff)}@font-face{font-family:Inter;font-weight:700;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-bold.woff2),url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-bold.woff)}@font-face{font-family:Inter;font-weight:800;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-extra-bold.woff2),url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-extra-bold.woff)}@font-face{font-family:IBM Plex Mono;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/ibm-plex-mono/ibm-plex-mono-regular.woff2),url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/ibm-plex-mono/ibm-plex-mono-regular.woff)}}@layer reset{*,:after,:before{border-color:var(--border-solid-border-color,"currentColor");border-style:solid;border-width:0}}
|
|
2
|
-
.MenuItem-module_item__DPerF {
|
|
3
|
-
font-family: var(--typography-paragraph-body-font-family);
|
|
4
|
-
font-size: var(--typography-paragraph-body-font-size);
|
|
5
|
-
letter-spacing: var(--typography-paragraph-body-letter-spacing);
|
|
6
|
-
font-weight: var(--typography-paragraph-body-font-weight);
|
|
7
|
-
line-height: var(--typography-paragraph-body-line-height);
|
|
8
|
-
color: rgba(var(--color-purple-800-rgb), 0.7);
|
|
9
|
-
padding: var(--spacing-6) var(--spacing-8);
|
|
10
|
-
border: var(--border-focus-ring-border-width) var(--border-focus-ring-border-style) transparent;
|
|
11
|
-
border-radius: 4px;
|
|
12
|
-
display: flex;
|
|
13
|
-
gap: 0 var(--spacing-8);
|
|
14
|
-
align-items: center;
|
|
15
|
-
margin-inline: var(--spacing-6);
|
|
16
|
-
text-decoration: none;
|
|
17
|
-
cursor: pointer;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.MenuItem-module_iconWrapper__bRdQN {
|
|
21
|
-
flex-shrink: 0;
|
|
22
|
-
display: flex;
|
|
23
|
-
align-items: center;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.MenuItem-module_item__DPerF[data-focused] {
|
|
27
|
-
background-color: var(--color-blue-100);
|
|
28
|
-
color: var(--color-blue-500);
|
|
29
|
-
outline: none;
|
|
30
|
-
border-color: var(--color-blue-500);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.MenuItem-module_item__DPerF[data-disabled] {
|
|
34
|
-
opacity: 0.3;
|
|
35
|
-
}
|
|
36
2
|
.Menu-module_menu__iHYqh {
|
|
37
3
|
background-color: var(--color-white);
|
|
38
4
|
color: var(--color-purple-800);
|
|
@@ -151,6 +117,40 @@
|
|
|
151
117
|
--button-icon-size: var(--spacing-16);
|
|
152
118
|
gap: var(--spacing-8);
|
|
153
119
|
}
|
|
120
|
+
.MenuItem-module_item__DPerF {
|
|
121
|
+
font-family: var(--typography-paragraph-body-font-family);
|
|
122
|
+
font-size: var(--typography-paragraph-body-font-size);
|
|
123
|
+
letter-spacing: var(--typography-paragraph-body-letter-spacing);
|
|
124
|
+
font-weight: var(--typography-paragraph-body-font-weight);
|
|
125
|
+
line-height: var(--typography-paragraph-body-line-height);
|
|
126
|
+
color: rgba(var(--color-purple-800-rgb), 0.7);
|
|
127
|
+
padding: var(--spacing-6) var(--spacing-8);
|
|
128
|
+
border: var(--border-focus-ring-border-width) var(--border-focus-ring-border-style) transparent;
|
|
129
|
+
border-radius: 4px;
|
|
130
|
+
display: flex;
|
|
131
|
+
gap: 0 var(--spacing-8);
|
|
132
|
+
align-items: center;
|
|
133
|
+
margin-inline: var(--spacing-6);
|
|
134
|
+
text-decoration: none;
|
|
135
|
+
cursor: pointer;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.MenuItem-module_iconWrapper__bRdQN {
|
|
139
|
+
flex-shrink: 0;
|
|
140
|
+
display: flex;
|
|
141
|
+
align-items: center;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.MenuItem-module_item__DPerF[data-focused] {
|
|
145
|
+
background-color: var(--color-blue-100);
|
|
146
|
+
color: var(--color-blue-500);
|
|
147
|
+
outline: none;
|
|
148
|
+
border-color: var(--color-blue-500);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.MenuItem-module_item__DPerF[data-disabled] {
|
|
152
|
+
opacity: 0.3;
|
|
153
|
+
}
|
|
154
154
|
.Focusable-module_focusableWrapper__NfuIi {
|
|
155
155
|
display: inline-flex;
|
|
156
156
|
}
|
|
@@ -14,6 +14,8 @@ export type FilterBarContextValue<Value, ValuesMap extends FiltersValues = Recor
|
|
|
14
14
|
hideFilter: <Id extends keyof ValuesMap>(id: Id) => void;
|
|
15
15
|
getInactiveFilters: () => Array<FilterAttributes<ValuesMap>>;
|
|
16
16
|
clearAllFilters: () => void;
|
|
17
|
+
setFocus: <Id extends keyof ValuesMap>(id: Id | undefined) => void;
|
|
18
|
+
focusId?: keyof ValuesMap;
|
|
17
19
|
};
|
|
18
20
|
export declare const useFilterBarContext: <Value, Values extends FiltersValues = Record<string, Value>>() => FilterBarContextValue<Value, Values>;
|
|
19
21
|
export type FilterBarProviderProps<ValuesMap extends FiltersValues> = {
|
|
@@ -18,6 +18,9 @@ type Actions<ValuesMap extends FiltersValues> = {
|
|
|
18
18
|
} | {
|
|
19
19
|
type: "update_filter_labels";
|
|
20
20
|
data: Filters<ValuesMap>;
|
|
21
|
+
} | {
|
|
22
|
+
type: "set_focus";
|
|
23
|
+
id: keyof ValuesMap | undefined;
|
|
21
24
|
};
|
|
22
25
|
export declare const filterBarStateReducer: <ValuesMap extends FiltersValues>(state: FilterBarState<ValuesMap>, action: Actions<ValuesMap>) => FilterBarState<ValuesMap>;
|
|
23
26
|
export {};
|
|
@@ -24,5 +24,6 @@ export type FilterBarState<ValuesMap extends FiltersValues> = {
|
|
|
24
24
|
activeFilterIds: Set<keyof ValuesMap>;
|
|
25
25
|
values: Partial<ValuesMap>;
|
|
26
26
|
dependentFilterIds: Set<keyof ValuesMap>;
|
|
27
|
+
focusId?: keyof ValuesMap;
|
|
27
28
|
};
|
|
28
29
|
export type ActiveFiltersArray<ValuesMap extends FiltersValues> = Array<FilterAttributes<ValuesMap>>;
|
|
@@ -15,9 +15,10 @@ type SelectionProps = {
|
|
|
15
15
|
export type FilterMultiSelectProps = {
|
|
16
16
|
trigger: (value?: MenuTriggerProviderContextType) => React.ReactNode;
|
|
17
17
|
children: (value?: SelectionProviderContextType) => React.ReactNode;
|
|
18
|
+
triggerRef?: React.RefObject<HTMLButtonElement>;
|
|
18
19
|
} & Omit<MenuPopupProps, "children"> & Omit<MenuTriggerProviderProps, "children"> & SelectionProps;
|
|
19
20
|
export declare const FilterMultiSelect: {
|
|
20
|
-
({ trigger, children, isOpen, defaultOpen, onOpenChange, isLoading, loadingSkeleton, label, items, selectedKeys, defaultSelectedKeys, onSelectionChange, selectionMode, onSearchInputChange, }: FilterMultiSelectProps): JSX.Element;
|
|
21
|
+
({ trigger, children, isOpen, defaultOpen, onOpenChange, isLoading, loadingSkeleton, label, items, selectedKeys, defaultSelectedKeys, onSelectionChange, selectionMode, onSearchInputChange, triggerRef, }: FilterMultiSelectProps): JSX.Element;
|
|
21
22
|
displayName: string;
|
|
22
23
|
TriggerButton: {
|
|
23
24
|
({ selectedOptionLabels, label, classNameOverride, labelCharacterLimitBeforeTruncate, }: import("./subcomponents/Trigger").FilterTriggerButtonProps): JSX.Element;
|
package/dist/types/Filter/FilterMultiSelect/context/MenuTriggerProvider/MenuTriggerProvider.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type MenuTriggerProviderProps = {
|
|
|
7
7
|
defaultOpen?: boolean;
|
|
8
8
|
onOpenChange?: (isOpen: boolean) => void;
|
|
9
9
|
children: React.ReactNode;
|
|
10
|
+
triggerRef?: React.RefObject<HTMLButtonElement>;
|
|
10
11
|
};
|
|
11
12
|
export type MenuTriggerProviderContextType = {
|
|
12
13
|
menuTriggerProps: HTMLAttributes<HTMLElement>;
|
|
@@ -15,6 +16,6 @@ export type MenuTriggerProviderContextType = {
|
|
|
15
16
|
menuTriggerState: MenuTriggerState;
|
|
16
17
|
buttonRef: React.RefObject<HTMLButtonElement>;
|
|
17
18
|
};
|
|
18
|
-
export declare function MenuTriggerProvider({ isOpen, defaultOpen, onOpenChange, children, }: MenuTriggerProviderProps): JSX.Element;
|
|
19
|
+
export declare function MenuTriggerProvider({ isOpen, defaultOpen, onOpenChange, children, triggerRef, }: MenuTriggerProviderProps): JSX.Element;
|
|
19
20
|
export declare const useMenuTriggerContext: () => MenuTriggerProviderContextType;
|
|
20
21
|
export declare const MenuTriggerConsumer: ({ children, }: React.ConsumerProps<MenuTriggerProviderContextType>) => JSX.Element;
|
package/package.json
CHANGED
|
@@ -65,6 +65,7 @@ const simpleFilters = [
|
|
|
65
65
|
type ValuesRemovable = {
|
|
66
66
|
flavour: string
|
|
67
67
|
topping: string
|
|
68
|
+
others: string
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
const filtersRemovable = [
|
|
@@ -86,6 +87,37 @@ const filtersRemovable = [
|
|
|
86
87
|
),
|
|
87
88
|
isRemovable: true,
|
|
88
89
|
},
|
|
90
|
+
{
|
|
91
|
+
id: "others",
|
|
92
|
+
name: "Others",
|
|
93
|
+
Component: (
|
|
94
|
+
<FilterBar.MultiSelect
|
|
95
|
+
items={[
|
|
96
|
+
{ value: "gluten-free", label: "Gluten Free" },
|
|
97
|
+
{ value: "no-sugar", label: "No Sugar" },
|
|
98
|
+
{ value: "dairy-free", label: "Dairy Free" },
|
|
99
|
+
]}
|
|
100
|
+
>
|
|
101
|
+
{(): JSX.Element => (
|
|
102
|
+
<>
|
|
103
|
+
<FilterMultiSelect.SearchInput />
|
|
104
|
+
<FilterMultiSelect.ListBox>
|
|
105
|
+
{({ allItems }): JSX.Element | JSX.Element[] =>
|
|
106
|
+
allItems.map(item => (
|
|
107
|
+
<FilterMultiSelect.Option key={item.key} item={item} />
|
|
108
|
+
))
|
|
109
|
+
}
|
|
110
|
+
</FilterMultiSelect.ListBox>
|
|
111
|
+
<FilterMultiSelect.MenuFooter>
|
|
112
|
+
<FilterMultiSelect.SelectAllButton />
|
|
113
|
+
<FilterMultiSelect.ClearButton />
|
|
114
|
+
</FilterMultiSelect.MenuFooter>
|
|
115
|
+
</>
|
|
116
|
+
)}
|
|
117
|
+
</FilterBar.MultiSelect>
|
|
118
|
+
),
|
|
119
|
+
isRemovable: true,
|
|
120
|
+
},
|
|
89
121
|
] satisfies Filters<ValuesRemovable>
|
|
90
122
|
|
|
91
123
|
type ValuesDependent = {
|
|
@@ -288,6 +320,61 @@ describe("<FilterBar />", () => {
|
|
|
288
320
|
expect(filters[1]).toHaveTextContent("Flavour")
|
|
289
321
|
expect(filters[2]).toHaveTextContent("Sugar Level")
|
|
290
322
|
})
|
|
323
|
+
|
|
324
|
+
it("moves focus to recently added filter button", async () => {
|
|
325
|
+
const { getByRole } = render(
|
|
326
|
+
<FilterBarWrapper<ValuesSimple>
|
|
327
|
+
filters={simpleFilters.map(filter => ({
|
|
328
|
+
...filter,
|
|
329
|
+
isRemovable: true,
|
|
330
|
+
}))}
|
|
331
|
+
/>
|
|
332
|
+
)
|
|
333
|
+
await waitForI18nContent()
|
|
334
|
+
|
|
335
|
+
const addFiltersButton = getByRole("button", { name: "Add Filters" })
|
|
336
|
+
await user.click(addFiltersButton)
|
|
337
|
+
|
|
338
|
+
const menuOptionIceLevel = getByRole("button", { name: "Ice Level" })
|
|
339
|
+
await user.click(menuOptionIceLevel)
|
|
340
|
+
|
|
341
|
+
expect(getByRole("button", { name: "Ice Level" })).toHaveFocus()
|
|
342
|
+
})
|
|
343
|
+
|
|
344
|
+
it("moves focus to recently added filter button in the FilterMultiSelect case", async () => {
|
|
345
|
+
const { getByRole } = render(
|
|
346
|
+
<FilterBarWrapper<ValuesRemovable> filters={filtersRemovable} />
|
|
347
|
+
)
|
|
348
|
+
await waitForI18nContent()
|
|
349
|
+
|
|
350
|
+
const addFiltersButton = getByRole("button", { name: "Add Filters" })
|
|
351
|
+
await user.click(addFiltersButton)
|
|
352
|
+
|
|
353
|
+
const menuOptionOthers = getByRole("button", { name: "Others" })
|
|
354
|
+
await user.click(menuOptionOthers)
|
|
355
|
+
|
|
356
|
+
expect(getByRole("button", { name: "Others" })).toHaveFocus()
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
it("restores focus to the add filter button after remove", async () => {
|
|
360
|
+
const { getByRole } = render(
|
|
361
|
+
<FilterBarWrapper<ValuesRemovable>
|
|
362
|
+
filters={filtersRemovable}
|
|
363
|
+
defaultValues={{ topping: "pearls" }}
|
|
364
|
+
/>
|
|
365
|
+
)
|
|
366
|
+
await waitForI18nContent()
|
|
367
|
+
|
|
368
|
+
const filterButton = getByRole("button", { name: "Topping : Pearls" })
|
|
369
|
+
expect(filterButton).toBeVisible()
|
|
370
|
+
|
|
371
|
+
await user.click(getByRole("button", { name: "Remove filter - Topping" }))
|
|
372
|
+
await waitFor(() => {
|
|
373
|
+
expect(filterButton).not.toBeInTheDocument()
|
|
374
|
+
})
|
|
375
|
+
|
|
376
|
+
expect(getByRole("button", { name: "Add Filters" })).toHaveFocus()
|
|
377
|
+
})
|
|
291
378
|
})
|
|
292
379
|
|
|
293
380
|
describe("Dependent filters", () => {
|
|
@@ -43,6 +43,8 @@ export type FilterBarContextValue<
|
|
|
43
43
|
hideFilter: <Id extends keyof ValuesMap>(id: Id) => void
|
|
44
44
|
getInactiveFilters: () => Array<FilterAttributes<ValuesMap>>
|
|
45
45
|
clearAllFilters: () => void
|
|
46
|
+
setFocus: <Id extends keyof ValuesMap>(id: Id | undefined) => void
|
|
47
|
+
focusId?: keyof ValuesMap
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
const FilterBarContext = React.createContext<FilterBarContextValue<any> | null>(
|
|
@@ -119,10 +121,13 @@ export const FilterBarProvider = <ValuesMap extends FiltersValues>({
|
|
|
119
121
|
values: { ...values, [id]: getValidValue(newValue) },
|
|
120
122
|
})
|
|
121
123
|
},
|
|
122
|
-
showFilter: <Id extends keyof ValuesMap>(id: Id): void =>
|
|
123
|
-
dispatch({ type: "activate_filter", id })
|
|
124
|
+
showFilter: <Id extends keyof ValuesMap>(id: Id): void => {
|
|
125
|
+
dispatch({ type: "activate_filter", id })
|
|
126
|
+
dispatch({ type: "set_focus", id })
|
|
127
|
+
},
|
|
124
128
|
hideFilter: <Id extends keyof ValuesMap>(id: Id): void => {
|
|
125
129
|
dispatch({ type: "deactivate_filter", id })
|
|
130
|
+
dispatch({ type: "set_focus", id: "add_filter" })
|
|
126
131
|
},
|
|
127
132
|
getInactiveFilters: () => getInactiveFilters<ValuesMap>(state),
|
|
128
133
|
clearAllFilters: () => {
|
|
@@ -132,6 +137,10 @@ export const FilterBarProvider = <ValuesMap extends FiltersValues>({
|
|
|
132
137
|
})
|
|
133
138
|
dispatch({ type: "update_values", values: {} })
|
|
134
139
|
},
|
|
140
|
+
setFocus: <Id extends keyof ValuesMap>(id: Id | undefined) => {
|
|
141
|
+
dispatch({ type: "set_focus", id })
|
|
142
|
+
},
|
|
143
|
+
focusId: state.focusId,
|
|
135
144
|
} satisfies FilterBarContextValue<any, ValuesMap>
|
|
136
145
|
|
|
137
146
|
useEffect(() => {
|
|
@@ -15,12 +15,19 @@ type Actions<ValuesMap extends FiltersValues> =
|
|
|
15
15
|
| { type: "activate_filter"; id: keyof ValuesMap }
|
|
16
16
|
| { type: "deactivate_filter"; id: keyof ValuesMap }
|
|
17
17
|
| { type: "update_filter_labels"; data: Filters<ValuesMap> }
|
|
18
|
+
| { type: "set_focus"; id: keyof ValuesMap | undefined }
|
|
18
19
|
|
|
19
20
|
export const filterBarStateReducer = <ValuesMap extends FiltersValues>(
|
|
20
21
|
state: FilterBarState<ValuesMap>,
|
|
21
22
|
action: Actions<ValuesMap>
|
|
22
23
|
): FilterBarState<ValuesMap> => {
|
|
23
24
|
switch (action.type) {
|
|
25
|
+
case "set_focus":
|
|
26
|
+
return {
|
|
27
|
+
...state,
|
|
28
|
+
focusId: action.id,
|
|
29
|
+
}
|
|
30
|
+
|
|
24
31
|
case "update_values":
|
|
25
32
|
return { ...updateValues(state, action.values) }
|
|
26
33
|
|
|
@@ -32,6 +32,7 @@ export type FilterBarState<ValuesMap extends FiltersValues> = {
|
|
|
32
32
|
activeFilterIds: Set<keyof ValuesMap>
|
|
33
33
|
values: Partial<ValuesMap>
|
|
34
34
|
dependentFilterIds: Set<keyof ValuesMap>
|
|
35
|
+
focusId?: keyof ValuesMap
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
export type ActiveFiltersArray<ValuesMap extends FiltersValues> = Array<
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react"
|
|
1
|
+
import React, { useEffect, useRef } from "react"
|
|
2
2
|
import { useIntl } from "@cultureamp/i18n-react-intl"
|
|
3
3
|
import { Menu, MenuList, MenuItem, Button } from "~components/__actions__/v2"
|
|
4
4
|
import { Icon } from "~components/__future__/Icon"
|
|
@@ -6,6 +6,7 @@ import { useFilterBarContext } from "../../context/FilterBarContext"
|
|
|
6
6
|
|
|
7
7
|
export const AddFiltersMenu = (): JSX.Element => {
|
|
8
8
|
const { formatMessage } = useIntl()
|
|
9
|
+
const buttonRef = useRef<HTMLButtonElement>(null)
|
|
9
10
|
|
|
10
11
|
const menuButtonLabel = formatMessage({
|
|
11
12
|
id: "filterBar.addFiltersMenu.buttonLabel",
|
|
@@ -14,13 +15,22 @@ export const AddFiltersMenu = (): JSX.Element => {
|
|
|
14
15
|
"Menu button label to show additional available filter options",
|
|
15
16
|
})
|
|
16
17
|
|
|
17
|
-
const { getInactiveFilters, showFilter } =
|
|
18
|
+
const { getInactiveFilters, showFilter, focusId, setFocus } =
|
|
19
|
+
useFilterBarContext()
|
|
18
20
|
const inactiveFilters = getInactiveFilters()
|
|
19
21
|
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (focusId === "add_filter") {
|
|
24
|
+
buttonRef.current?.focus()
|
|
25
|
+
setFocus(undefined)
|
|
26
|
+
}
|
|
27
|
+
}, [focusId])
|
|
28
|
+
|
|
20
29
|
return (
|
|
21
30
|
<Menu
|
|
22
31
|
button={
|
|
23
32
|
<Button
|
|
33
|
+
ref={buttonRef}
|
|
24
34
|
label={menuButtonLabel}
|
|
25
35
|
secondary
|
|
26
36
|
disabled={inactiveFilters.length === 0}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef } from "react"
|
|
1
|
+
import React, { forwardRef, useEffect } from "react"
|
|
2
2
|
import { FilterTriggerRef } from "~components/Filter/Filter"
|
|
3
3
|
import { useFilterBarContext } from "~components/Filter/FilterBar/context/FilterBarContext"
|
|
4
4
|
import {
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
FilterButtonProps,
|
|
7
7
|
FilterButtonRemovable,
|
|
8
8
|
} from "~components/Filter/FilterButton"
|
|
9
|
+
import { isRefObject } from "~components/utils/isRefObject"
|
|
9
10
|
|
|
10
11
|
export type FilterBarButtonProps = FilterButtonProps & {
|
|
11
12
|
filterId: string
|
|
@@ -16,7 +17,14 @@ export const FilterBarButton = forwardRef<
|
|
|
16
17
|
FilterTriggerRef,
|
|
17
18
|
FilterBarButtonProps
|
|
18
19
|
>(({ filterId, isRemovable = false, ...props }, ref): JSX.Element => {
|
|
19
|
-
const { hideFilter } = useFilterBarContext()
|
|
20
|
+
const { hideFilter, focusId, setFocus } = useFilterBarContext()
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (focusId === filterId && isRefObject(ref)) {
|
|
24
|
+
ref?.current?.triggerRef?.current?.focus()
|
|
25
|
+
setFocus(undefined)
|
|
26
|
+
}
|
|
27
|
+
}, [focusId])
|
|
20
28
|
|
|
21
29
|
return isRemovable ? (
|
|
22
30
|
<FilterButtonRemovable
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react"
|
|
1
|
+
import React, { useEffect, useRef, useState } from "react"
|
|
2
2
|
import { Selection, Key } from "@react-types/shared"
|
|
3
3
|
import {
|
|
4
4
|
FilterMultiSelect,
|
|
@@ -43,9 +43,16 @@ export const FilterBarMultiSelect = ({
|
|
|
43
43
|
onSelectionChange,
|
|
44
44
|
...props
|
|
45
45
|
}: FilterBarMultiSelectProps): JSX.Element | null => {
|
|
46
|
-
const {
|
|
47
|
-
|
|
46
|
+
const {
|
|
47
|
+
getFilterState,
|
|
48
|
+
setFilterOpenState,
|
|
49
|
+
updateValue,
|
|
50
|
+
hideFilter,
|
|
51
|
+
focusId,
|
|
52
|
+
setFocus,
|
|
53
|
+
} = useFilterBarContext<ConsumableSelection>()
|
|
48
54
|
const [items, setItems] = useState<ItemType[]>(propsItems)
|
|
55
|
+
const buttonRef = useRef<HTMLButtonElement>(null)
|
|
49
56
|
|
|
50
57
|
if (!id) throw Error("Missing `id` prop in FilterBarMultiSelect")
|
|
51
58
|
|
|
@@ -70,6 +77,13 @@ export const FilterBarMultiSelect = ({
|
|
|
70
77
|
}
|
|
71
78
|
}, [items])
|
|
72
79
|
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (focusId === id) {
|
|
82
|
+
buttonRef.current?.focus()
|
|
83
|
+
setFocus(undefined)
|
|
84
|
+
}
|
|
85
|
+
}, [focusId])
|
|
86
|
+
|
|
73
87
|
return (
|
|
74
88
|
<FilterMultiSelect
|
|
75
89
|
label={filterState.name}
|
|
@@ -103,6 +117,7 @@ export const FilterBarMultiSelect = ({
|
|
|
103
117
|
<FilterMultiSelect.TriggerButton {...triggerProps} />
|
|
104
118
|
)
|
|
105
119
|
}}
|
|
120
|
+
triggerRef={buttonRef}
|
|
106
121
|
{...props}
|
|
107
122
|
>
|
|
108
123
|
{children}
|
|
@@ -41,6 +41,7 @@ type SelectionProps = {
|
|
|
41
41
|
export type FilterMultiSelectProps = {
|
|
42
42
|
trigger: (value?: MenuTriggerProviderContextType) => React.ReactNode
|
|
43
43
|
children: (value?: SelectionProviderContextType) => React.ReactNode // the content of the menu
|
|
44
|
+
triggerRef?: React.RefObject<HTMLButtonElement>
|
|
44
45
|
} & Omit<MenuPopupProps, "children"> &
|
|
45
46
|
Omit<MenuTriggerProviderProps, "children"> &
|
|
46
47
|
SelectionProps
|
|
@@ -60,8 +61,9 @@ export const FilterMultiSelect = ({
|
|
|
60
61
|
onSelectionChange,
|
|
61
62
|
selectionMode = "multiple",
|
|
62
63
|
onSearchInputChange,
|
|
64
|
+
triggerRef,
|
|
63
65
|
}: FilterMultiSelectProps): JSX.Element => {
|
|
64
|
-
const menuTriggerProps = { isOpen, defaultOpen, onOpenChange }
|
|
66
|
+
const menuTriggerProps = { isOpen, defaultOpen, onOpenChange, triggerRef }
|
|
65
67
|
const menuPopupProps = { isLoading, loadingSkeleton }
|
|
66
68
|
const disabledKeys: Selection = new Set(
|
|
67
69
|
items
|
|
@@ -14,6 +14,7 @@ export type MenuTriggerProviderProps = {
|
|
|
14
14
|
defaultOpen?: boolean
|
|
15
15
|
onOpenChange?: (isOpen: boolean) => void
|
|
16
16
|
children: React.ReactNode
|
|
17
|
+
triggerRef?: React.RefObject<HTMLButtonElement>
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export type MenuTriggerProviderContextType = {
|
|
@@ -32,12 +33,14 @@ export function MenuTriggerProvider({
|
|
|
32
33
|
defaultOpen,
|
|
33
34
|
onOpenChange,
|
|
34
35
|
children,
|
|
36
|
+
triggerRef,
|
|
35
37
|
}: MenuTriggerProviderProps): JSX.Element {
|
|
36
38
|
// Create state based on the incoming props to manage the open/close
|
|
37
39
|
const state = useMenuTriggerState({ isOpen, defaultOpen, onOpenChange })
|
|
38
40
|
|
|
39
41
|
// Get A11y attributes and events for the menu trigger and menu elements
|
|
40
|
-
const
|
|
42
|
+
const fallbackRef = useRef<HTMLButtonElement>(null)
|
|
43
|
+
const ref = triggerRef || fallbackRef
|
|
41
44
|
const { menuTriggerProps, menuProps } = useMenuTrigger<ItemType>(
|
|
42
45
|
{},
|
|
43
46
|
state,
|