@sprinklrjs/spaceweb 14.13.2 → 14.14.0
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/a11y/accessibilityIsolation.d.ts +5 -0
- package/a11y/accessibilityIsolation.js +12 -0
- package/asyncSelect/hooks/useAsyncSelect.d.ts +54 -0
- package/asyncSelect/hooks/useGroupedAsyncSelect.d.ts +54 -0
- package/baseui/modal/modal.d.ts +4 -0
- package/baseui/modal/modal.js +24 -2
- package/baseui/select/default-props.d.ts +1 -0
- package/baseui/select/default-props.js +2 -0
- package/baseui/select/select-component.d.ts +4 -0
- package/baseui/select/select-component.js +14 -3
- package/baseui/select/stateful-select.d.ts +1 -0
- package/baseui/select/types.d.ts +5 -0
- package/esm/a11y/accessibilityIsolation.d.ts +5 -0
- package/esm/a11y/accessibilityIsolation.js +8 -0
- package/esm/asyncSelect/hooks/useAsyncSelect.d.ts +54 -0
- package/esm/asyncSelect/hooks/useGroupedAsyncSelect.d.ts +54 -0
- package/esm/baseui/modal/modal.d.ts +4 -0
- package/esm/baseui/modal/modal.js +24 -2
- package/esm/baseui/select/default-props.d.ts +1 -0
- package/esm/baseui/select/default-props.js +2 -0
- package/esm/baseui/select/select-component.d.ts +4 -0
- package/esm/baseui/select/select-component.js +12 -2
- package/esm/baseui/select/stateful-select.d.ts +1 -0
- package/esm/baseui/select/types.d.ts +5 -0
- package/esm/menu/menu-item.js +2 -2
- package/esm/select/index.d.ts +1 -1
- package/esm/select/index.js +1 -1
- package/esm/select/multi-value.d.ts +1 -0
- package/esm/select/multi-value.js +4 -3
- package/esm/select/selectMenuAdapter/CollapsibleSelectMenu.js +28 -7
- package/esm/select/selectMenuAdapter/SelectMenuItem.d.ts +1 -1
- package/esm/select/selectMenuAdapter/SelectMenuItem.js +13 -6
- package/esm/select/selectMenuAdapter/hooks/useRootSelectAllKeyboardNav.d.ts +22 -0
- package/esm/select/selectMenuAdapter/hooks/useRootSelectAllKeyboardNav.js +113 -0
- package/esm/select/types.d.ts +1 -0
- package/menu/menu-item.js +2 -2
- package/package.json +3 -2
- package/select/index.d.ts +1 -1
- package/select/index.js +2 -1
- package/select/multi-value.d.ts +1 -0
- package/select/multi-value.js +4 -3
- package/select/selectMenuAdapter/CollapsibleSelectMenu.js +27 -6
- package/select/selectMenuAdapter/SelectMenuItem.d.ts +1 -1
- package/select/selectMenuAdapter/SelectMenuItem.js +13 -6
- package/select/selectMenuAdapter/hooks/useRootSelectAllKeyboardNav.d.ts +22 -0
- package/select/selectMenuAdapter/hooks/useRootSelectAllKeyboardNav.js +117 -0
- package/select/types.d.ts +1 -0
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -15,6 +15,7 @@ import { SIZE, ROLE, CLOSE_SOURCE, BASEWEB_NAME, SIZE_WIDTHS } from './constants
|
|
|
15
15
|
import { Root as StyledRoot, Dialog as StyledDialog, DialogContainer as StyledDialogContainer, Hidden, } from './styled-components';
|
|
16
16
|
import { CloseIcon } from './close-icon';
|
|
17
17
|
import { isFocusVisible, forkFocus, forkBlur } from '../utils/focusVisible';
|
|
18
|
+
import { isolateAccessibilityTree } from '../../a11y/accessibilityIsolation';
|
|
18
19
|
var Modal = /** @class */ (function (_super) {
|
|
19
20
|
__extends(Modal, _super);
|
|
20
21
|
function Modal() {
|
|
@@ -61,6 +62,11 @@ var Modal = /** @class */ (function (_super) {
|
|
|
61
62
|
_this.onCloseClick = function () {
|
|
62
63
|
_this.triggerClose(CLOSE_SOURCE.closeButton);
|
|
63
64
|
};
|
|
65
|
+
_this.onLayerMount = function () {
|
|
66
|
+
if (_this.props.isOpen) {
|
|
67
|
+
_this.enableModalAccessibilityIsolation();
|
|
68
|
+
}
|
|
69
|
+
};
|
|
64
70
|
_this.animateOutComplete = function () {
|
|
65
71
|
_this.setState({
|
|
66
72
|
isVisible: false,
|
|
@@ -82,6 +88,7 @@ var Modal = /** @class */ (function (_super) {
|
|
|
82
88
|
}
|
|
83
89
|
};
|
|
84
90
|
Modal.prototype.componentWillUnmount = function () {
|
|
91
|
+
this.disableModalAccessibilityIsolation();
|
|
85
92
|
this.resetMountNodeScroll();
|
|
86
93
|
this.clearTimers();
|
|
87
94
|
this.prevMounted = this.mounted;
|
|
@@ -121,6 +128,19 @@ var Modal = /** @class */ (function (_super) {
|
|
|
121
128
|
this.lastMountNodeOverflowStyle = null;
|
|
122
129
|
}
|
|
123
130
|
};
|
|
131
|
+
Modal.prototype.enableModalAccessibilityIsolation = function () {
|
|
132
|
+
if (this.releaseModalAccessibilityIsolation || !this.rootRef.current) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
this.releaseModalAccessibilityIsolation = isolateAccessibilityTree(this.rootRef.current);
|
|
136
|
+
};
|
|
137
|
+
Modal.prototype.disableModalAccessibilityIsolation = function () {
|
|
138
|
+
if (!this.releaseModalAccessibilityIsolation) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
this.releaseModalAccessibilityIsolation();
|
|
142
|
+
this.releaseModalAccessibilityIsolation = undefined;
|
|
143
|
+
};
|
|
124
144
|
Modal.prototype.clearTimers = function () {
|
|
125
145
|
if (this.animateOutTimer) {
|
|
126
146
|
clearTimeout(this.animateOutTimer);
|
|
@@ -140,6 +160,7 @@ var Modal = /** @class */ (function (_super) {
|
|
|
140
160
|
// Clear any existing timers (like previous animateOutTimer)
|
|
141
161
|
this.clearTimers();
|
|
142
162
|
this.disableMountNodeScroll();
|
|
163
|
+
this.enableModalAccessibilityIsolation();
|
|
143
164
|
if (this.props.animate) {
|
|
144
165
|
this.animateStartTimer = requestAnimationFrame(function () {
|
|
145
166
|
_this.setState({ isVisible: true });
|
|
@@ -150,6 +171,7 @@ var Modal = /** @class */ (function (_super) {
|
|
|
150
171
|
}
|
|
151
172
|
};
|
|
152
173
|
Modal.prototype.didClose = function () {
|
|
174
|
+
this.disableModalAccessibilityIsolation();
|
|
153
175
|
this.resetMountNodeScroll();
|
|
154
176
|
this.animateOutTimer = setTimeout(this.animateOutComplete, 500);
|
|
155
177
|
};
|
|
@@ -206,7 +228,7 @@ var Modal = /** @class */ (function (_super) {
|
|
|
206
228
|
}
|
|
207
229
|
return (_jsx(FocusLock, __assign({ disabled: !focusLock,
|
|
208
230
|
// Allow focus to escape when UI is within an iframe
|
|
209
|
-
crossFrame: false, returnFocus: returnFocus, autoFocus: autoFocus }, { children: _jsx(Root, __assign({ "data-baseweb": BASEWEB_NAME, ref: this.rootRef }, sharedProps, rootProps, { children: _jsx(DialogContainer, __assign({ "data-testid": "spaceweb-modal-dialog-container", ref: this.dialogContainerRef }, sharedProps, dialogContainerProps, { children: _jsxs(Dialog, __assign({ tabIndex: -1,
|
|
231
|
+
crossFrame: false, returnFocus: returnFocus, autoFocus: autoFocus }, { children: _jsx(Root, __assign({ "data-baseweb": BASEWEB_NAME, ref: this.rootRef }, sharedProps, rootProps, { children: _jsx(DialogContainer, __assign({ "data-testid": "spaceweb-modal-dialog-container", ref: this.dialogContainerRef }, sharedProps, dialogContainerProps, { children: _jsxs(Dialog, __assign({ tabIndex: -1, role: role }, sharedProps, dialogProps, { style: [dialogueWidth ? { '--sw-width': dialogueWidth } : {}, dialogProps === null || dialogProps === void 0 ? void 0 : dialogProps.style] }, { children: [renderedContent, closeable ? (_jsx(Close, __assign({ onClick: this.onCloseClick }, sharedProps, closeProps, { onFocus: forkFocus(closeProps, this.handleFocus), onBlur: forkBlur(closeProps, this.handleBlur) }, { children: _jsx(CloseIcon, {}) }))) : null] })) })) })) })));
|
|
210
232
|
};
|
|
211
233
|
Modal.prototype.render = function () {
|
|
212
234
|
// Only render an open and non-renderAll modal on the browser (portals aren't supported server-side)
|
|
@@ -214,7 +236,7 @@ var Modal = /** @class */ (function (_super) {
|
|
|
214
236
|
var renderedContent = mountedAndOpen || this.props.renderAll ? this.getChildren() : null;
|
|
215
237
|
if (renderedContent) {
|
|
216
238
|
if (mountedAndOpen) {
|
|
217
|
-
return (_jsx(Layer, __assign({ onEscape: this.onEscape, onDocumentClick: this.onDocumentClick, mountNode: this.props.mountNode }, { children: this.renderModal(renderedContent) })));
|
|
239
|
+
return (_jsx(Layer, __assign({ onEscape: this.onEscape, onDocumentClick: this.onDocumentClick, onMount: this.onLayerMount, mountNode: this.props.mountNode }, { children: this.renderModal(renderedContent) })));
|
|
218
240
|
}
|
|
219
241
|
return _jsx(Hidden, { children: renderedContent });
|
|
220
242
|
}
|
|
@@ -5,6 +5,8 @@ type GetOptionLabel = NonNullable<SelectProps['getOptionLabel']>;
|
|
|
5
5
|
export declare function getOptionLabel({ option }: Parameters<GetOptionLabel>[0], { selectLocale, labelKey }: SelectProps): ReactNode;
|
|
6
6
|
type GetValueLabel = NonNullable<SelectProps['getValueLabel']>;
|
|
7
7
|
export declare function getValueLabel({ option }: Parameters<GetValueLabel>[0], { labelKey }: SelectProps): ReactNode;
|
|
8
|
+
type GetValueAriaLabel = NonNullable<SelectProps['getValueAriaLabel']>;
|
|
9
|
+
export declare function getValueAriaLabel({ option }: Parameters<GetValueAriaLabel>[0], { labelKey }: SelectProps): string | undefined;
|
|
8
10
|
declare class Select extends Component<SelectProps, SelectState> {
|
|
9
11
|
static defaultProps: {
|
|
10
12
|
'aria-label': null;
|
|
@@ -39,6 +41,7 @@ declare class Select extends Component<SelectProps, SelectState> {
|
|
|
39
41
|
filterOutSelected: boolean;
|
|
40
42
|
getOptionLabel: null;
|
|
41
43
|
getValueLabel: null;
|
|
44
|
+
getValueAriaLabel: null;
|
|
42
45
|
ignoreCase: boolean;
|
|
43
46
|
isLoading: boolean;
|
|
44
47
|
labelKey: string;
|
|
@@ -108,6 +111,7 @@ declare class Select extends Component<SelectProps, SelectState> {
|
|
|
108
111
|
handleKeyDown: (event: KeyboardEvent) => void;
|
|
109
112
|
getOptionLabel: GetOptionLabel;
|
|
110
113
|
getValueLabel: GetValueLabel;
|
|
114
|
+
getValueAriaLabel: GetValueAriaLabel;
|
|
111
115
|
getMemoizedOptionsMap: (options: Options, valueKey: string) => Map<string, Option>;
|
|
112
116
|
/**
|
|
113
117
|
* Extends the value into an array from the given options
|
|
@@ -49,6 +49,12 @@ export function getValueLabel(_a, _b) {
|
|
|
49
49
|
var labelKey = _b.labelKey;
|
|
50
50
|
return labelKey && option[labelKey];
|
|
51
51
|
}
|
|
52
|
+
export function getValueAriaLabel(_a, _b) {
|
|
53
|
+
var option = _a.option;
|
|
54
|
+
var labelKey = _b.labelKey;
|
|
55
|
+
var label = labelKey && option[labelKey];
|
|
56
|
+
return typeof label === 'string' ? label : undefined;
|
|
57
|
+
}
|
|
52
58
|
var Select = /** @class */ (function (_super) {
|
|
53
59
|
__extends(Select, _super);
|
|
54
60
|
function Select() {
|
|
@@ -401,6 +407,8 @@ var Select = /** @class */ (function (_super) {
|
|
|
401
407
|
_this.getOptionLabel = function (optionData, props) { return getOptionLabel(optionData, props); };
|
|
402
408
|
// eslint-disable-next-line class-methods-use-this -- delegates to module-level helper
|
|
403
409
|
_this.getValueLabel = function (optionData, props) { return getValueLabel(optionData, props); };
|
|
410
|
+
// eslint-disable-next-line class-methods-use-this -- delegates to module-level helper
|
|
411
|
+
_this.getValueAriaLabel = function (optionData, props) { return getValueAriaLabel(optionData, props); };
|
|
404
412
|
_this.getMemoizedOptionsMap = memoizeOne(function (options, valueKey) {
|
|
405
413
|
var normalizedOptions = _this.getMemoizedNormalizedOptions(options);
|
|
406
414
|
return new Map(normalizedOptions.map(function (option) { return [String(option[valueKey]), option]; }));
|
|
@@ -768,6 +776,7 @@ var Select = /** @class */ (function (_super) {
|
|
|
768
776
|
var _a = this.props.overrides, overrides = _a === void 0 ? {} : _a;
|
|
769
777
|
var sharedProps = this.getSharedProps();
|
|
770
778
|
var renderLabel = this.props.getValueLabel || this.getValueLabel;
|
|
779
|
+
var renderAriaLabel = this.props.getValueAriaLabel || this.getValueAriaLabel;
|
|
771
780
|
var Value = this.props.valueComponent || Noop;
|
|
772
781
|
var _b = __read(getOverrides(overrides.ExtraTagPopover, StatefulPopover), 2), ExtraTagPopover = _b[0], extraTagPopoverProps = _b[1];
|
|
773
782
|
var _c = __read(getOverrides(overrides.ExtraTagPopoverList, List), 2), ExtraTagPopoverList = _c[0], extraTagPopoverListProps = _c[1];
|
|
@@ -796,7 +805,7 @@ var Select = /** @class */ (function (_super) {
|
|
|
796
805
|
// if not stopped, backspace event will be handled by select as well.
|
|
797
806
|
// which might remove pop last item from select.
|
|
798
807
|
e.stopPropagation();
|
|
799
|
-
}, disabled: disabled, overrides: { Tag: overrides.Tag, MultiValue: overrides.MultiValue }, tabIndex: 0 }, sharedProps, { "$disabled": disabled, ref: i === _this.state.focusedExtraValueTagIdx
|
|
808
|
+
}, disabled: disabled, overrides: { Tag: overrides.Tag, MultiValue: overrides.MultiValue }, tabIndex: 0 }, sharedProps, { "$disabled": disabled, ariaLabel: renderAriaLabel({ option: value, index: i }, _this.props), ref: i === _this.state.focusedExtraValueTagIdx
|
|
800
809
|
? function (valueEl) {
|
|
801
810
|
valueEl === null || valueEl === void 0 ? void 0 : valueEl.focus();
|
|
802
811
|
}
|
|
@@ -813,6 +822,7 @@ var Select = /** @class */ (function (_super) {
|
|
|
813
822
|
var _b = this.props.overrides, overrides = _b === void 0 ? {} : _b;
|
|
814
823
|
var sharedProps = this.getSharedProps();
|
|
815
824
|
var renderLabel = this.props.getValueLabel || this.getValueLabel;
|
|
825
|
+
var renderAriaLabel = this.props.getValueAriaLabel || this.getValueAriaLabel;
|
|
816
826
|
var Value = this.props.valueComponent || Noop;
|
|
817
827
|
if (!valueArray.length) {
|
|
818
828
|
return null;
|
|
@@ -823,7 +833,7 @@ var Select = /** @class */ (function (_super) {
|
|
|
823
833
|
var remainingTagsCount = valueArray.length - _limitTag;
|
|
824
834
|
return (_jsxs(_Fragment, { children: [valueArray.slice(0, _limitTag).map(function (value, i) {
|
|
825
835
|
var disabled = sharedProps.$disabled || value.clearableValue === false;
|
|
826
|
-
return (_jsx(Value, __assign({ value: value, removeValue: function () { return _this.removeValueAndFocus(value); }, disabled: disabled, overrides: { Tag: overrides.Tag, MultiValue: overrides.MultiValue } }, sharedProps, { "$disabled": disabled, noTooltipOnTruncation: _this.props.noTooltipOnTruncation,
|
|
836
|
+
return (_jsx(Value, __assign({ value: value, removeValue: function () { return _this.removeValueAndFocus(value); }, disabled: disabled, overrides: { Tag: overrides.Tag, MultiValue: overrides.MultiValue } }, sharedProps, { "$disabled": disabled, noTooltipOnTruncation: _this.props.noTooltipOnTruncation, ariaLabel: renderAriaLabel({ option: value, index: i }, _this.props),
|
|
827
837
|
//react calls ref function whenever we pass it and not just on mount
|
|
828
838
|
ref: i === _this.state.currentValueTagIdx
|
|
829
839
|
? function (valueEl) {
|
|
@@ -153,6 +153,11 @@ export type SelectProps = {
|
|
|
153
153
|
option: Option;
|
|
154
154
|
index?: number;
|
|
155
155
|
}, props: SelectProps) => React.ReactNode) | null;
|
|
156
|
+
/** A custom method to get an aria-label for a selected option tag. */
|
|
157
|
+
getValueAriaLabel?: ((a: {
|
|
158
|
+
option: Option;
|
|
159
|
+
index?: number;
|
|
160
|
+
}, props: SelectProps) => string | undefined) | null;
|
|
156
161
|
/** Sets the id attribute of the internal input element. Allows for usage with labels. */
|
|
157
162
|
id?: string;
|
|
158
163
|
/** Defines if the comparison for a new creatable value should be case-insensitive. */
|
package/esm/menu/menu-item.js
CHANGED
|
@@ -87,7 +87,7 @@ function MenuActionContainer(_a) {
|
|
|
87
87
|
}
|
|
88
88
|
function buildListItemAriaProps(itemRole, selected, ChildMenu) {
|
|
89
89
|
var props = {};
|
|
90
|
-
if (selected !== undefined) {
|
|
90
|
+
if (selected !== undefined && itemRole !== 'checkbox') {
|
|
91
91
|
props['aria-selected'] = Boolean(selected);
|
|
92
92
|
}
|
|
93
93
|
if (ChildMenu) {
|
|
@@ -140,7 +140,7 @@ var MenuItem = React.forwardRef(function MenuItem(_a, ref) {
|
|
|
140
140
|
var _a, _b;
|
|
141
141
|
setMenuContainerRef((_b = (_a = ownRef.current) === null || _a === void 0 ? void 0 : _a.parentElement) !== null && _b !== void 0 ? _b : null);
|
|
142
142
|
}, [setMenuContainerRef]);
|
|
143
|
-
var isItemHighlighted = highlighted
|
|
143
|
+
var isItemHighlighted = highlighted !== null && highlighted !== void 0 ? highlighted : (highlightedItem !== null && highlightedItem === ownRef.current);
|
|
144
144
|
var resolvedItemActions = useMemo(function () { return resolveMenuActions(getActionsElement, $item); }, [getActionsElement, $item]);
|
|
145
145
|
var shouldRenderActions = ((_b = resolvedItemActions === null || resolvedItemActions === void 0 ? void 0 : resolvedItemActions.length) !== null && _b !== void 0 ? _b : 0) > 0 && !ChildMenu && !hideInlineActions;
|
|
146
146
|
var resolvedEndEnhancer = useResolvedMenuEndEnhancer(resolvedItemActions, shouldRenderActions, endEnhancer, ChildMenu);
|
package/esm/select/index.d.ts
CHANGED
|
@@ -19,4 +19,4 @@ export { CollapsibleSelectMenu } from './selectMenuAdapter/CollapsibleSelectMenu
|
|
|
19
19
|
export { NestedSelect } from './nested-select';
|
|
20
20
|
export { OverridenPopover } from './mobileSelect/overrides';
|
|
21
21
|
export { filterOptions as defaultFilterOptions } from './utils/default-filter-options';
|
|
22
|
-
export { getOptionLabel, getValueLabel } from '../baseui/select/select-component';
|
|
22
|
+
export { getOptionLabel, getValueLabel, getValueAriaLabel } from '../baseui/select/select-component';
|
package/esm/select/index.js
CHANGED
|
@@ -17,4 +17,4 @@ export { NestedSelect } from './nested-select';
|
|
|
17
17
|
export { OverridenPopover } from './mobileSelect/overrides';
|
|
18
18
|
// Utils
|
|
19
19
|
export { filterOptions as defaultFilterOptions } from './utils/default-filter-options';
|
|
20
|
-
export { getOptionLabel, getValueLabel } from '../baseui/select/select-component';
|
|
20
|
+
export { getOptionLabel, getValueLabel, getValueAriaLabel } from '../baseui/select/select-component';
|
|
@@ -18,6 +18,7 @@ declare const MultiValue: React.ForwardRefExoticComponent<Omit<TagProps, "overri
|
|
|
18
18
|
__groupSelectAll?: boolean | undefined;
|
|
19
19
|
}>>;
|
|
20
20
|
$valueKey: string;
|
|
21
|
+
ariaLabel?: string | undefined;
|
|
21
22
|
value: Readonly<{
|
|
22
23
|
[x: string]: any;
|
|
23
24
|
id?: import("./types").Id | undefined;
|
|
@@ -11,7 +11,7 @@ import { CLEARABLE_KEY, LOADING_KEY } from './constants';
|
|
|
11
11
|
import useCombinedRefs from '../hooks/useCombinedRef';
|
|
12
12
|
var MultiValue = React.forwardRef(function (props, ref) {
|
|
13
13
|
var _a, _b, _c;
|
|
14
|
-
var _d = props.overrides, overrides = _d === void 0 ? {} : _d, onActionClick = props.onActionClick, value = props.value, selectSize = props.selectSize, $disabled = props.$disabled, $valueByIdMap = props.$valueByIdMap, $valueKey = props.$valueKey, _$size = props.$size, _$isContainerFocused = props.$isContainerFocused, restProps = __rest(props, ["overrides", "onActionClick", "value", "selectSize", "$disabled", "$valueByIdMap", "$valueKey", "$size", "$isContainerFocused"]);
|
|
14
|
+
var _d = props.overrides, overrides = _d === void 0 ? {} : _d, onActionClick = props.onActionClick, value = props.value, selectSize = props.selectSize, $disabled = props.$disabled, $valueByIdMap = props.$valueByIdMap, $valueKey = props.$valueKey, _$size = props.$size, _$isContainerFocused = props.$isContainerFocused, ariaLabel = props.ariaLabel, children = props.children, restProps = __rest(props, ["overrides", "onActionClick", "value", "selectSize", "$disabled", "$valueByIdMap", "$valueKey", "$size", "$isContainerFocused", "ariaLabel", "children"]);
|
|
15
15
|
var _e = __read(useOverrides(overrides.Tag, Tag), 2), TagComponent = _e[0], tagProps = _e[1];
|
|
16
16
|
var theme = useStyle().theme;
|
|
17
17
|
var tagRef = useRef();
|
|
@@ -49,6 +49,7 @@ var MultiValue = React.forwardRef(function (props, ref) {
|
|
|
49
49
|
break;
|
|
50
50
|
}
|
|
51
51
|
var closeable = (_b = tagProps.closeable) !== null && _b !== void 0 ? _b : !disabled;
|
|
52
|
+
var resolvedAriaLabel = ariaLabel || (typeof children === 'string' ? children : undefined);
|
|
52
53
|
var tagSpacingClasses;
|
|
53
54
|
switch (selectSize) {
|
|
54
55
|
case 'xxxs':
|
|
@@ -64,7 +65,7 @@ var MultiValue = React.forwardRef(function (props, ref) {
|
|
|
64
65
|
tagSpacingClasses = 'mr-1 my-0.5';
|
|
65
66
|
break;
|
|
66
67
|
}
|
|
67
|
-
return (_jsx(TagComponent, __assign({ ref: combinedRef, variant: "light", intent: "default",
|
|
68
|
+
return (_jsx(TagComponent, __assign({ ref: combinedRef, variant: "light", intent: "default" }, (resolvedAriaLabel ? { 'aria-label': resolvedAriaLabel } : {}), { tabIndex: -1, onActionClick: onActionClickHandler, "$item": value, "$disabled": disabled, size: tagSize }, restProps, tagProps, { closeable: closeable, overrides: mergeOverrides({
|
|
68
69
|
Root: {
|
|
69
70
|
className: [
|
|
70
71
|
'box-border max-w-[--sw-max-width]',
|
|
@@ -85,6 +86,6 @@ var MultiValue = React.forwardRef(function (props, ref) {
|
|
|
85
86
|
},
|
|
86
87
|
},
|
|
87
88
|
Action: { props: { tabIndex: -1 } },
|
|
88
|
-
}, tagProps.overrides) }, { children: isLoading ?
|
|
89
|
+
}, tagProps.overrides) }, { children: isLoading ? _jsx(StyledTombstone, { "data-testid": "multi-value-tombstone", className: "w-20 h-4 rounded-8" }) : children })));
|
|
89
90
|
});
|
|
90
91
|
export default MultiValue;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { __assign, __read } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import _isNumber from 'lodash/isNumber';
|
|
4
|
-
import { useEffect, useMemo, useRef
|
|
4
|
+
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
5
5
|
import { useGetExpandedGroup } from './hooks/useGetExpandedGroup';
|
|
6
|
+
import { useRootSelectAllKeyboardNav } from './hooks/useRootSelectAllKeyboardNav';
|
|
6
7
|
import { Box } from '../../box';
|
|
7
8
|
import { Menu } from '../../menu';
|
|
8
9
|
import { Typography } from '../../typography';
|
|
@@ -46,6 +47,7 @@ export var CollapsibleSelectMenu = function (_a) {
|
|
|
46
47
|
var isFirstItemHighlighted = useRef(false);
|
|
47
48
|
var isLastItemHighlighted = useRef(false);
|
|
48
49
|
var menuRef = useRef(null);
|
|
50
|
+
var selectAllItem = shouldDisplaySelectAll ? groupedItems[UNGROUPED_ID][0] : null;
|
|
49
51
|
var ownerDocument = useDocument();
|
|
50
52
|
var _l = useSelectIds(), listboxId = _l.listboxId, menuDescriptionId = _l.menuDescriptionId;
|
|
51
53
|
var selectedValuesSet = useMemo(function () {
|
|
@@ -72,6 +74,17 @@ export var CollapsibleSelectMenu = function (_a) {
|
|
|
72
74
|
var mergedOverrides = useMemo(function () { return mergeOverrides(selectMenuOverrides, overrides); }, [overrides]);
|
|
73
75
|
var _m = __read(useOverrides(mergedOverrides.Menu, Menu), 2), MenuComponent = _m[0], menuProps = _m[1];
|
|
74
76
|
var _o = __read(useOverrides(mergedOverrides.NoResults, NoResults), 2), NoResultsOverriden = _o[0], noResultsProps = _o[1];
|
|
77
|
+
var _p = useRootSelectAllKeyboardNav({
|
|
78
|
+
menuRef: menuRef,
|
|
79
|
+
selectAllItem: selectAllItem,
|
|
80
|
+
ownerDocument: ownerDocument,
|
|
81
|
+
expandedGroupId: expandedGroupId,
|
|
82
|
+
setExpandedGroupId: setExpandedGroupId,
|
|
83
|
+
groupConfig: groupConfig,
|
|
84
|
+
onItemSelect: onItemSelect,
|
|
85
|
+
inputElement: inputElement,
|
|
86
|
+
isFirstItemHighlighted: isFirstItemHighlighted,
|
|
87
|
+
}), selectAllItemRef = _p.selectAllItemRef, isRootSelectAllHighlighted = _p.isRootSelectAllHighlighted, leaveRootSelectAllHighlight = _p.leaveRootSelectAllHighlight;
|
|
75
88
|
var menuItemOverrides = useMemo(function () { return ({
|
|
76
89
|
MenuItem: mergedOverrides.MenuItem,
|
|
77
90
|
ListItemText: mergedOverrides.ListItemText,
|
|
@@ -104,6 +117,9 @@ export var CollapsibleSelectMenu = function (_a) {
|
|
|
104
117
|
}, [expandedGroupId, groupedItems]);
|
|
105
118
|
var handleOnHighlightedItemChange = function (item) {
|
|
106
119
|
var _a;
|
|
120
|
+
if (item) {
|
|
121
|
+
leaveRootSelectAllHighlight();
|
|
122
|
+
}
|
|
107
123
|
var nextHighlightableElement = getNextItemIndexToHighlight(item !== null && item !== void 0 ? item : null, menuRef.current, nextItem);
|
|
108
124
|
var prevHighlightableElement = getNextItemIndexToHighlight(item !== null && item !== void 0 ? item : null, menuRef.current, prevItem);
|
|
109
125
|
isFirstItemHighlighted.current = !!(item && (!item.previousSibling || item === prevHighlightableElement));
|
|
@@ -111,13 +127,18 @@ export var CollapsibleSelectMenu = function (_a) {
|
|
|
111
127
|
(_a = menuProps === null || menuProps === void 0 ? void 0 : menuProps.onHighlightedItemChange) === null || _a === void 0 ? void 0 : _a.call(menuProps, item);
|
|
112
128
|
};
|
|
113
129
|
var handleOnClick = useCallback(function (newGroupId) {
|
|
130
|
+
leaveRootSelectAllHighlight();
|
|
114
131
|
setExpandedGroupId(function (prev) { return (prev === newGroupId ? undefined : newGroupId); });
|
|
115
132
|
inputElement === null || inputElement === void 0 ? void 0 : inputElement.focus();
|
|
116
|
-
}, [inputElement, setExpandedGroupId]);
|
|
117
|
-
var selectAllItem = shouldDisplaySelectAll ? groupedItems[UNGROUPED_ID][0] : null;
|
|
133
|
+
}, [inputElement, setExpandedGroupId, leaveRootSelectAllHighlight]);
|
|
118
134
|
var clearAsOptionItem = !multi && clearAsOption ? groupedItems[UNGROUPED_ID][0] : null;
|
|
119
135
|
var locale = useLocale().select;
|
|
120
|
-
|
|
136
|
+
var isMenuItemHighlighted = isRootSelectAllHighlighted ? false : undefined;
|
|
137
|
+
return (_jsxs(Box, __assign({ className: "rounded-inherit" }, { children: [selectAllItem ? (_jsx(SelectMenuItem, __assign({ ref: selectAllItemRef, overrides: menuItemOverrides, item: selectAllItem, selected: globalSelectAllSelected, highlighted: isRootSelectAllHighlighted, multi: multi, getItemLabel: getItemLabel, labelKey: labelKey, valueKey: valueKey, onItemSelect: onItemSelect, "$item": selectAllItem, "$as": "div", button: true, "data-testid": "universal-select-all" }, baseuiMenuItemProps, {
|
|
138
|
+
// Root Select All sits outside the options listbox, so it must be role="checkbox" (not role="option" )
|
|
139
|
+
// See SAP UI5 MultiComboBox Select All:
|
|
140
|
+
// https://ui5.sap.com/#/entity/sap.m.MultiComboBox/sample/sap.m.sample.MultiComboBoxSelectAll
|
|
141
|
+
role: "checkbox", className: ['m-2', baseuiMenuItemProps === null || baseuiMenuItemProps === void 0 ? void 0 : baseuiMenuItemProps.className] }), "select-all-option")) : null, groupConfig.map(function (_group, index) {
|
|
121
142
|
var _a;
|
|
122
143
|
var _b, _c;
|
|
123
144
|
var groupId = _group.id, groupLabel = _group.label;
|
|
@@ -137,11 +158,11 @@ export var CollapsibleSelectMenu = function (_a) {
|
|
|
137
158
|
_a[GROUP_SELECT_ALL_ID] = true,
|
|
138
159
|
_a.selected = groupSelectAllSelected,
|
|
139
160
|
_a);
|
|
140
|
-
return (_jsxs(Collapsible, __assign({ className: index === 0 && selectAllItem ? 'border-t-1 border-solid spr-border-primary' : '', group: group, expanded: disableWhenSelectAllChecked && globalSelectAllSelected ? false : groupId === expandedGroupId, disabled: disableWhenSelectAllChecked && globalSelectAllSelected, onClick: handleOnClick }, { children: [_jsx(HiddenElement, __assign({ id: menuDescriptionId !== null && menuDescriptionId !== void 0 ? menuDescriptionId : '' }, { children: "".concat(groupLabel, " ").concat(locale.groupExpandedSuffix) })), _isEmpty(itemsInGroup) ? (_jsx(NoResultsOverriden, __assign({ "aria-live": "polite", "aria-atomic": true, msg: noResultsMsg, noResultsConfig: noResultsConfig, "aria-disabled": true, "$groupId": groupId }, noResultsProps))) : (_jsxs(MenuComponent, __assign({ resetMenuHighlightOnMouseLeave: true, focusWhenNavigationEnabled: false, keyboardFocusRestoreTarget: inputElement, tabIndex: -1, selectOnTab: selectOnTab, getActionsElement: getActionsElement }, menuProps, { role: "listbox", id: listboxId, virtual: virtual, className: ['overflow-auto max-h-50 pt-0', menuProps === null || menuProps === void 0 ? void 0 : menuProps.className], onScroll: function (e) {
|
|
161
|
+
return (_jsxs(Collapsible, __assign({ className: index === 0 && selectAllItem ? 'border-t-1 border-solid spr-border-primary' : '', group: group, expanded: disableWhenSelectAllChecked && globalSelectAllSelected ? false : groupId === expandedGroupId, disabled: disableWhenSelectAllChecked && globalSelectAllSelected, onClick: handleOnClick }, { children: [_jsx(HiddenElement, __assign({ id: menuDescriptionId !== null && menuDescriptionId !== void 0 ? menuDescriptionId : '' }, { children: "".concat(groupLabel, " ").concat(locale.groupExpandedSuffix) })), _isEmpty(itemsInGroup) ? (_jsx(NoResultsOverriden, __assign({ "aria-live": "polite", "aria-atomic": true, msg: noResultsMsg, noResultsConfig: noResultsConfig, "aria-disabled": true, "$groupId": groupId }, noResultsProps))) : (_jsxs(MenuComponent, __assign({ resetMenuHighlightOnMouseLeave: true, focusWhenNavigationEnabled: false, disableAutoHighlight: isRootSelectAllHighlighted, keyboardFocusRestoreTarget: inputElement, tabIndex: -1, selectOnTab: selectOnTab, getActionsElement: getActionsElement }, menuProps, { role: "listbox", id: listboxId, virtual: virtual, className: ['overflow-auto max-h-50 pt-0', menuProps === null || menuProps === void 0 ? void 0 : menuProps.className], onScroll: function (e) {
|
|
141
162
|
$onPaginate === null || $onPaginate === void 0 ? void 0 : $onPaginate(e, groupId);
|
|
142
|
-
}, onHighlightedItemChange: handleOnHighlightedItemChange, ref: menuRef }, { children: [shouldDisplayGroupSelectAll ? (_jsx(SelectMenuItem, __assign({ overrides: menuItemOverrides, item: groupSelectAllItem, "data-testid": "".concat(group.label, "-group-select-all"), selected: groupSelectAllSelected, multi: multi, getItemLabel: getItemLabel, labelKey: labelKey, valueKey: valueKey, onItemSelect: onItemSelect, "$item": groupSelectAllItem, button: true, disabled: group.count <= countDisabledOptions }, baseuiMenuItemProps), "select-all-option")) : null, clearAsOptionItem ? (_jsx(SelectMenuItem, __assign({ overrides: menuItemOverrides, item: clearAsOptionItem, selected: false, multi: multi, getItemLabel: getItemLabel, labelKey: labelKey, valueKey: valueKey, onItemSelect: onItemSelect, "$item": clearAsOptionItem, button: true }, baseuiMenuItemProps), "clear-option")) : null, itemsInGroup.map(function (item) {
|
|
163
|
+
}, onHighlightedItemChange: handleOnHighlightedItemChange, ref: menuRef }, { children: [shouldDisplayGroupSelectAll ? (_jsx(SelectMenuItem, __assign({ overrides: menuItemOverrides, item: groupSelectAllItem, "data-testid": "".concat(group.label, "-group-select-all"), selected: groupSelectAllSelected, multi: multi, getItemLabel: getItemLabel, labelKey: labelKey, valueKey: valueKey, onItemSelect: onItemSelect, "$item": groupSelectAllItem, button: true, disabled: group.count <= countDisabledOptions, highlighted: isMenuItemHighlighted }, baseuiMenuItemProps), "select-all-option")) : null, clearAsOptionItem ? (_jsx(SelectMenuItem, __assign({ overrides: menuItemOverrides, item: clearAsOptionItem, selected: false, multi: multi, getItemLabel: getItemLabel, labelKey: labelKey, valueKey: valueKey, onItemSelect: onItemSelect, "$item": clearAsOptionItem, button: true, highlighted: isMenuItemHighlighted }, baseuiMenuItemProps), "clear-option")) : null, itemsInGroup.map(function (item) {
|
|
143
164
|
var selected = selectedValuesSet.has(item[valueKey]);
|
|
144
|
-
return (_jsx(SelectMenuItem, __assign({ overrides: menuItemOverrides, item: item, selected: selected, multi: multi, getItemLabel: getItemLabel, labelKey: labelKey, valueKey: valueKey, onItemSelect: onItemSelect, "$item": item, button: true }, baseuiMenuItemProps), item.isCreatable ? 'creatable-option' : item[valueKey]));
|
|
165
|
+
return (_jsx(SelectMenuItem, __assign({ overrides: menuItemOverrides, item: item, selected: selected, multi: multi, getItemLabel: getItemLabel, labelKey: labelKey, valueKey: valueKey, onItemSelect: onItemSelect, "$item": item, button: true, highlighted: isMenuItemHighlighted }, baseuiMenuItemProps), item.isCreatable ? 'creatable-option' : item[valueKey]));
|
|
145
166
|
})] })))] }), groupId));
|
|
146
167
|
})] })));
|
|
147
168
|
};
|
|
@@ -3,7 +3,7 @@ import { type ListItemTextProps } from '../../list';
|
|
|
3
3
|
import { type Override } from '../../overrides';
|
|
4
4
|
import type { MenuItemProps } from '../../menu';
|
|
5
5
|
import type { SelectProps } from '../types';
|
|
6
|
-
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<Pick<MenuItemProps, "selected"> & Pick<SelectProps, "labelKey" | "multi" | "valueKey"> & {
|
|
6
|
+
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<Pick<MenuItemProps, "selected" | "role"> & Pick<SelectProps, "labelKey" | "multi" | "valueKey"> & {
|
|
7
7
|
item: Record<string, any>;
|
|
8
8
|
getItemLabel: (item: Record<string, any>) => React.ReactNode;
|
|
9
9
|
onItemSelect: (item: Record<string, any>) => void;
|
|
@@ -16,10 +16,11 @@ var shouldHideSelectItemActions = function (item) {
|
|
|
16
16
|
return Boolean(item[SELECT_ALL_ID] || item[GROUP_SELECT_ALL_ID] || item[CLEAR_OPTION_ID] || item.isCreatable);
|
|
17
17
|
};
|
|
18
18
|
var SelectMenuItem = React.forwardRef(function (_a, ref) {
|
|
19
|
-
var item = _a.item, valueKey = _a.valueKey, overrides = _a.overrides, labelKey = _a.labelKey, multi = _a.multi, selected = _a.selected, getItemLabel = _a.getItemLabel, onItemSelect = _a.onItemSelect, restProps = __rest(_a, ["item", "valueKey", "overrides", "labelKey", "multi", "selected", "getItemLabel", "onItemSelect"]);
|
|
20
|
-
var
|
|
21
|
-
var _c = __read(useOverrides(overrides === null || overrides === void 0 ? void 0 : overrides.
|
|
22
|
-
var _d = __read(useOverrides(overrides === null || overrides === void 0 ? void 0 : overrides.
|
|
19
|
+
var item = _a.item, valueKey = _a.valueKey, overrides = _a.overrides, labelKey = _a.labelKey, multi = _a.multi, selected = _a.selected, getItemLabel = _a.getItemLabel, onItemSelect = _a.onItemSelect, _b = _a.role, role = _b === void 0 ? 'option' : _b, restProps = __rest(_a, ["item", "valueKey", "overrides", "labelKey", "multi", "selected", "getItemLabel", "onItemSelect", "role"]);
|
|
20
|
+
var isCheckboxRole = role === 'checkbox';
|
|
21
|
+
var _c = __read(useOverrides(overrides === null || overrides === void 0 ? void 0 : overrides.MenuItem, MenuItem), 2), MenuItemOverriden = _c[0], menuItemProps = _c[1];
|
|
22
|
+
var _d = __read(useOverrides(overrides === null || overrides === void 0 ? void 0 : overrides.Checkbox, Checkbox), 2), CheckboxOverriden = _d[0], checkboxProps = _d[1];
|
|
23
|
+
var _e = __read(useOverrides(overrides === null || overrides === void 0 ? void 0 : overrides.ListItemText, ListItemText), 2), ListItemTextOverriden = _e[0], listItemTextProps = _e[1];
|
|
23
24
|
var handleItemSelect = useCallback(function (event) { return onItemSelect({ item: item, event: event }); }, [item, onItemSelect]);
|
|
24
25
|
var textOverrides = listItemTextProps === null || listItemTextProps === void 0 ? void 0 : listItemTextProps.overrides;
|
|
25
26
|
var listItemTextOverrides = useMemo(function () {
|
|
@@ -32,14 +33,20 @@ var SelectMenuItem = React.forwardRef(function (_a, ref) {
|
|
|
32
33
|
var id = useUniqueId();
|
|
33
34
|
var checkboxPropsOverrides = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.overrides;
|
|
34
35
|
var checkboxOverrides = useMemo(function () {
|
|
35
|
-
return mergeOverrides({
|
|
36
|
+
return mergeOverrides({
|
|
37
|
+
Input: {
|
|
38
|
+
props: { 'aria-labelledby': id, tabIndex: -1 },
|
|
39
|
+
className: 'invisible',
|
|
40
|
+
},
|
|
41
|
+
Label: { className: 'hidden' },
|
|
42
|
+
}, checkboxPropsOverrides);
|
|
36
43
|
}, [id, checkboxPropsOverrides]);
|
|
37
44
|
// Passes intent to override intent from useContextualFormProps,
|
|
38
45
|
// see: https://prod-gitlab.sprinklr.com/sprinklr/frontend/spaceweb/-/issues/282
|
|
39
46
|
var startEnhancer = useMemo(function () {
|
|
40
47
|
return multi && (_jsx(CheckboxOverriden, __assign({ checked: selected, size: "medium", disabled: item.disabled, intent: "default" }, checkboxProps, { overrides: checkboxOverrides })));
|
|
41
48
|
}, [multi, CheckboxOverriden, selected, item.disabled, checkboxProps, checkboxOverrides]);
|
|
42
|
-
var menuItemEl = (_jsx(MenuItemOverriden, __assign({ role:
|
|
49
|
+
var menuItemEl = (_jsx(MenuItemOverriden, __assign({ role: role }, (isCheckboxRole ? { 'aria-checked': selected } : { 'aria-selected': selected }), {
|
|
43
50
|
// for Multi Select variant do not show selected styles
|
|
44
51
|
selected: multi ? false : selected, onClick: handleItemSelect, startEnhancer: startEnhancer, disabled: item.disabled, "$multi": multi, tabIndex: -1, "$item": item, "$valueKey": valueKey, "$labelKey": labelKey, ref: ref, id: id, tooltipContent: item.tooltipContent, hideInlineActions: shouldHideSelectItemActions(item) }, restProps, menuItemProps, { children: _jsx(ListItemTextOverriden, __assign({ "$multi": multi, "$item": item, "$labelKey": labelKey }, listItemTextProps, { overrides: listItemTextOverrides }, { children: getItemLabel(item) })) })));
|
|
45
52
|
return item.disabled && item.disabledTooltipConfig ? (_jsx(ActionableTooltip, __assign({}, item.disabledTooltipConfig, { children: menuItemEl }))) : (menuItemEl);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Dispatch, MutableRefObject, RefObject, SetStateAction } from 'react';
|
|
2
|
+
import type { Item, OnItemSelectFn } from '../../../baseui/menu/types';
|
|
3
|
+
import type { MenuRef } from '../../../menu/types';
|
|
4
|
+
import type { GroupConfig } from '../types';
|
|
5
|
+
type UseRootSelectAllKeyboardNavParams = {
|
|
6
|
+
menuRef: RefObject<MenuRef>;
|
|
7
|
+
selectAllItem: Item | null;
|
|
8
|
+
ownerDocument: Document | undefined;
|
|
9
|
+
expandedGroupId: string | undefined;
|
|
10
|
+
setExpandedGroupId: Dispatch<SetStateAction<string | undefined>>;
|
|
11
|
+
groupConfig: GroupConfig;
|
|
12
|
+
onItemSelect?: OnItemSelectFn;
|
|
13
|
+
inputElement?: HTMLInputElement | null;
|
|
14
|
+
isFirstItemHighlighted: MutableRefObject<boolean>;
|
|
15
|
+
};
|
|
16
|
+
type UseRootSelectAllKeyboardNavReturn = {
|
|
17
|
+
selectAllItemRef: RefObject<HTMLElement | null>;
|
|
18
|
+
isRootSelectAllHighlighted: boolean;
|
|
19
|
+
leaveRootSelectAllHighlight: () => void;
|
|
20
|
+
};
|
|
21
|
+
export declare const useRootSelectAllKeyboardNav: ({ menuRef, selectAllItem, ownerDocument, expandedGroupId, setExpandedGroupId, groupConfig, onItemSelect, inputElement, isFirstItemHighlighted, }: UseRootSelectAllKeyboardNavParams) => UseRootSelectAllKeyboardNavReturn;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { __read } from "tslib";
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { canHighlightItem, getFirstHighlightableElement, getNextItemIndexToHighlight, prevItem, } from '../../../menu/helpers';
|
|
4
|
+
var stopKeyboardEvent = function (event) {
|
|
5
|
+
event.preventDefault();
|
|
6
|
+
event.stopPropagation();
|
|
7
|
+
};
|
|
8
|
+
var isFirstHighlightableInMenu = function (menu, highlightedItem) {
|
|
9
|
+
return getNextItemIndexToHighlight(highlightedItem, menu, prevItem) === highlightedItem;
|
|
10
|
+
};
|
|
11
|
+
var isFirstMenuItemHighlighted = function (menu, isFirstItemHighlighted) {
|
|
12
|
+
var highlightedMenuItem = menu === null || menu === void 0 ? void 0 : menu.querySelector('[data-highlighted="true"]');
|
|
13
|
+
if (menu && highlightedMenuItem && canHighlightItem(highlightedMenuItem)) {
|
|
14
|
+
return isFirstHighlightableInMenu(menu, highlightedMenuItem);
|
|
15
|
+
}
|
|
16
|
+
return isFirstItemHighlighted.current;
|
|
17
|
+
};
|
|
18
|
+
export var useRootSelectAllKeyboardNav = function (_a) {
|
|
19
|
+
var menuRef = _a.menuRef, selectAllItem = _a.selectAllItem, ownerDocument = _a.ownerDocument, expandedGroupId = _a.expandedGroupId, setExpandedGroupId = _a.setExpandedGroupId, groupConfig = _a.groupConfig, onItemSelect = _a.onItemSelect, inputElement = _a.inputElement, isFirstItemHighlighted = _a.isFirstItemHighlighted;
|
|
20
|
+
var selectAllItemRef = useRef(null);
|
|
21
|
+
var _b = __read(useState(!!selectAllItem), 2), isRootSelectAllHighlighted = _b[0], setIsRootSelectAllHighlighted = _b[1];
|
|
22
|
+
var clearMenuHighlight = useCallback(function () {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
var menu = menuRef.current;
|
|
25
|
+
if (!menu)
|
|
26
|
+
return;
|
|
27
|
+
(_a = menu.turnOffKeyboardNavigation) === null || _a === void 0 ? void 0 : _a.call(menu);
|
|
28
|
+
(_b = menu.setHighlightedItem) === null || _b === void 0 ? void 0 : _b.call(menu, null);
|
|
29
|
+
}, [menuRef]);
|
|
30
|
+
var highlightFirstMenuItem = useCallback(function () {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
var menu = menuRef.current;
|
|
33
|
+
if (!menu)
|
|
34
|
+
return;
|
|
35
|
+
(_a = menu.turnOnKeyboardNavigation) === null || _a === void 0 ? void 0 : _a.call(menu);
|
|
36
|
+
var firstHighlightableItem = getFirstHighlightableElement(menu).firstHighlightableItem;
|
|
37
|
+
var itemToHighlight = firstHighlightableItem;
|
|
38
|
+
(_b = menu.setHighlightedItem) === null || _b === void 0 ? void 0 : _b.call(menu, itemToHighlight);
|
|
39
|
+
}, [menuRef]);
|
|
40
|
+
var highlightRootSelectAll = useCallback(function () {
|
|
41
|
+
clearMenuHighlight();
|
|
42
|
+
setIsRootSelectAllHighlighted(true);
|
|
43
|
+
}, [clearMenuHighlight]);
|
|
44
|
+
var leaveRootSelectAllHighlight = useCallback(function () {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
setIsRootSelectAllHighlighted(false);
|
|
47
|
+
(_b = (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.turnOnKeyboardNavigation) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
48
|
+
}, [menuRef]);
|
|
49
|
+
useEffect(function () {
|
|
50
|
+
if (!selectAllItem || !ownerDocument)
|
|
51
|
+
return undefined;
|
|
52
|
+
var captureKeydownHandler = function (event) {
|
|
53
|
+
var _a;
|
|
54
|
+
if (isRootSelectAllHighlighted && event.key === 'ArrowDown' && !event.shiftKey) {
|
|
55
|
+
stopKeyboardEvent(event);
|
|
56
|
+
leaveRootSelectAllHighlight();
|
|
57
|
+
var firstGroupId = (_a = groupConfig[0]) === null || _a === void 0 ? void 0 : _a.id;
|
|
58
|
+
if (firstGroupId && expandedGroupId !== firstGroupId) {
|
|
59
|
+
setExpandedGroupId(firstGroupId);
|
|
60
|
+
}
|
|
61
|
+
highlightFirstMenuItem();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
var expandedGroupIndex = groupConfig.findIndex(function (group) { return group.id === expandedGroupId; });
|
|
65
|
+
if (event.key === 'ArrowUp' &&
|
|
66
|
+
!event.shiftKey &&
|
|
67
|
+
expandedGroupIndex === 0 &&
|
|
68
|
+
isFirstMenuItemHighlighted(menuRef.current, isFirstItemHighlighted)) {
|
|
69
|
+
stopKeyboardEvent(event);
|
|
70
|
+
highlightRootSelectAll();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (isRootSelectAllHighlighted && event.key === 'Enter' && event.keyCode !== 229) {
|
|
74
|
+
stopKeyboardEvent(event);
|
|
75
|
+
onItemSelect === null || onItemSelect === void 0 ? void 0 : onItemSelect({ item: selectAllItem, event: event });
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
ownerDocument.body.addEventListener('keydown', captureKeydownHandler, { capture: true });
|
|
79
|
+
return function () {
|
|
80
|
+
ownerDocument.body.removeEventListener('keydown', captureKeydownHandler, { capture: true });
|
|
81
|
+
};
|
|
82
|
+
}, [
|
|
83
|
+
menuRef,
|
|
84
|
+
ownerDocument,
|
|
85
|
+
selectAllItem,
|
|
86
|
+
expandedGroupId,
|
|
87
|
+
groupConfig,
|
|
88
|
+
isRootSelectAllHighlighted,
|
|
89
|
+
setExpandedGroupId,
|
|
90
|
+
onItemSelect,
|
|
91
|
+
highlightRootSelectAll,
|
|
92
|
+
highlightFirstMenuItem,
|
|
93
|
+
leaveRootSelectAllHighlight,
|
|
94
|
+
isFirstItemHighlighted,
|
|
95
|
+
]);
|
|
96
|
+
useEffect(function () {
|
|
97
|
+
var _a;
|
|
98
|
+
var selectAllItemId = (_a = selectAllItemRef.current) === null || _a === void 0 ? void 0 : _a.id;
|
|
99
|
+
if (!isRootSelectAllHighlighted || !inputElement || !selectAllItemId)
|
|
100
|
+
return undefined;
|
|
101
|
+
inputElement.setAttribute('aria-activedescendant', selectAllItemId);
|
|
102
|
+
return function () {
|
|
103
|
+
if (inputElement.getAttribute('aria-activedescendant') === selectAllItemId) {
|
|
104
|
+
inputElement.removeAttribute('aria-activedescendant');
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}, [isRootSelectAllHighlighted, inputElement]);
|
|
108
|
+
return {
|
|
109
|
+
selectAllItemRef: selectAllItemRef,
|
|
110
|
+
isRootSelectAllHighlighted: isRootSelectAllHighlighted,
|
|
111
|
+
leaveRootSelectAllHighlight: leaveRootSelectAllHighlight,
|
|
112
|
+
};
|
|
113
|
+
};
|
package/esm/select/types.d.ts
CHANGED
|
@@ -130,6 +130,7 @@ export type MultiValueProps = Omit<TagProps, 'overrides'> & SharedProps & {
|
|
|
130
130
|
$isContainerFocused?: boolean;
|
|
131
131
|
$valueByIdMap: Record<string, Option>;
|
|
132
132
|
$valueKey: string;
|
|
133
|
+
ariaLabel?: string;
|
|
133
134
|
value: Option;
|
|
134
135
|
removeValue: RemoveValue;
|
|
135
136
|
selectSize: Size;
|
package/menu/menu-item.js
CHANGED
|
@@ -89,7 +89,7 @@ function MenuActionContainer(_a) {
|
|
|
89
89
|
}
|
|
90
90
|
function buildListItemAriaProps(itemRole, selected, ChildMenu) {
|
|
91
91
|
var props = {};
|
|
92
|
-
if (selected !== undefined) {
|
|
92
|
+
if (selected !== undefined && itemRole !== 'checkbox') {
|
|
93
93
|
props['aria-selected'] = Boolean(selected);
|
|
94
94
|
}
|
|
95
95
|
if (ChildMenu) {
|
|
@@ -142,7 +142,7 @@ var MenuItem = React.forwardRef(function MenuItem(_a, ref) {
|
|
|
142
142
|
var _a, _b;
|
|
143
143
|
setMenuContainerRef((_b = (_a = ownRef.current) === null || _a === void 0 ? void 0 : _a.parentElement) !== null && _b !== void 0 ? _b : null);
|
|
144
144
|
}, [setMenuContainerRef]);
|
|
145
|
-
var isItemHighlighted = highlighted
|
|
145
|
+
var isItemHighlighted = highlighted !== null && highlighted !== void 0 ? highlighted : (highlightedItem !== null && highlightedItem === ownRef.current);
|
|
146
146
|
var resolvedItemActions = (0, react_1.useMemo)(function () { return resolveMenuActions(getActionsElement, $item); }, [getActionsElement, $item]);
|
|
147
147
|
var shouldRenderActions = ((_b = resolvedItemActions === null || resolvedItemActions === void 0 ? void 0 : resolvedItemActions.length) !== null && _b !== void 0 ? _b : 0) > 0 && !ChildMenu && !hideInlineActions;
|
|
148
148
|
var resolvedEndEnhancer = useResolvedMenuEndEnhancer(resolvedItemActions, shouldRenderActions, endEnhancer, ChildMenu);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sprinklrjs/spaceweb",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.14.0",
|
|
4
4
|
"description": "Components for SpaceWeb",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"@types/styletron-engine-atomic": "^1.1.0",
|
|
36
36
|
"@types/styletron-react": "^5.0.2",
|
|
37
37
|
"any-date-parser": "2.2.3",
|
|
38
|
+
"aria-hidden": "^1.2.6",
|
|
38
39
|
"body-scroll-lock": "3.1.5",
|
|
39
40
|
"card-validator": "^6.2.0",
|
|
40
41
|
"class-variance-authority": "^0.7.0",
|
|
@@ -100,7 +101,7 @@
|
|
|
100
101
|
"ts-node": "^10.4.0"
|
|
101
102
|
},
|
|
102
103
|
"peerDependencies": {
|
|
103
|
-
"@sprinklrjs/spaceweb-themes": "14.
|
|
104
|
+
"@sprinklrjs/spaceweb-themes": "14.14.0",
|
|
104
105
|
"react": ">=17.0.2 <19.0.0",
|
|
105
106
|
"react-dom": ">=17.0.2 <19.0.0"
|
|
106
107
|
}
|
package/select/index.d.ts
CHANGED
|
@@ -19,4 +19,4 @@ export { CollapsibleSelectMenu } from './selectMenuAdapter/CollapsibleSelectMenu
|
|
|
19
19
|
export { NestedSelect } from './nested-select';
|
|
20
20
|
export { OverridenPopover } from './mobileSelect/overrides';
|
|
21
21
|
export { filterOptions as defaultFilterOptions } from './utils/default-filter-options';
|
|
22
|
-
export { getOptionLabel, getValueLabel } from '../baseui/select/select-component';
|
|
22
|
+
export { getOptionLabel, getValueLabel, getValueAriaLabel } from '../baseui/select/select-component';
|