@patternfly/react-core 4.192.7 → 4.192.11
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/CHANGELOG.md +41 -0
- package/dist/esm/components/Label/Label.d.ts.map +1 -1
- package/dist/esm/components/Label/Label.js +38 -25
- package/dist/esm/components/Label/Label.js.map +1 -1
- package/dist/esm/components/Select/Select.d.ts +5 -1
- package/dist/esm/components/Select/Select.d.ts.map +1 -1
- package/dist/esm/components/Select/Select.js +171 -28
- package/dist/esm/components/Select/Select.js.map +1 -1
- package/dist/esm/components/Select/SelectMenu.d.ts.map +1 -1
- package/dist/esm/components/Select/SelectMenu.js +2 -1
- package/dist/esm/components/Select/SelectMenu.js.map +1 -1
- package/dist/esm/components/Select/SelectOption.d.ts.map +1 -1
- package/dist/esm/components/Select/SelectOption.js +6 -1
- package/dist/esm/components/Select/SelectOption.js.map +1 -1
- package/dist/esm/components/Select/SelectToggle.d.ts +3 -2
- package/dist/esm/components/Select/SelectToggle.d.ts.map +1 -1
- package/dist/esm/components/Select/SelectToggle.js +26 -16
- package/dist/esm/components/Select/SelectToggle.js.map +1 -1
- package/dist/esm/components/Select/selectConstants.d.ts +1 -0
- package/dist/esm/components/Select/selectConstants.d.ts.map +1 -1
- package/dist/esm/components/Select/selectConstants.js +1 -0
- package/dist/esm/components/Select/selectConstants.js.map +1 -1
- package/dist/esm/components/Tabs/Tabs.d.ts +2 -5
- package/dist/esm/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/esm/components/Tabs/Tabs.js +3 -3
- package/dist/esm/components/Tabs/Tabs.js.map +1 -1
- package/dist/esm/components/TimePicker/TimePicker.d.ts +4 -6
- package/dist/esm/components/TimePicker/TimePicker.d.ts.map +1 -1
- package/dist/esm/components/TimePicker/TimePicker.js +74 -42
- package/dist/esm/components/TimePicker/TimePicker.js.map +1 -1
- package/dist/esm/helpers/util.d.ts +6 -0
- package/dist/esm/helpers/util.d.ts.map +1 -1
- package/dist/esm/helpers/util.js +12 -0
- package/dist/esm/helpers/util.js.map +1 -1
- package/dist/js/components/Label/Label.d.ts.map +1 -1
- package/dist/js/components/Label/Label.js +38 -25
- package/dist/js/components/Label/Label.js.map +1 -1
- package/dist/js/components/Select/Select.d.ts +5 -1
- package/dist/js/components/Select/Select.d.ts.map +1 -1
- package/dist/js/components/Select/Select.js +170 -27
- package/dist/js/components/Select/Select.js.map +1 -1
- package/dist/js/components/Select/SelectMenu.d.ts.map +1 -1
- package/dist/js/components/Select/SelectMenu.js +2 -1
- package/dist/js/components/Select/SelectMenu.js.map +1 -1
- package/dist/js/components/Select/SelectOption.d.ts.map +1 -1
- package/dist/js/components/Select/SelectOption.js +6 -1
- package/dist/js/components/Select/SelectOption.js.map +1 -1
- package/dist/js/components/Select/SelectToggle.d.ts +3 -2
- package/dist/js/components/Select/SelectToggle.d.ts.map +1 -1
- package/dist/js/components/Select/SelectToggle.js +25 -15
- package/dist/js/components/Select/SelectToggle.js.map +1 -1
- package/dist/js/components/Select/selectConstants.d.ts +1 -0
- package/dist/js/components/Select/selectConstants.d.ts.map +1 -1
- package/dist/js/components/Select/selectConstants.js +2 -1
- package/dist/js/components/Select/selectConstants.js.map +1 -1
- package/dist/js/components/Tabs/Tabs.d.ts +2 -5
- package/dist/js/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/js/components/Tabs/Tabs.js +3 -3
- package/dist/js/components/Tabs/Tabs.js.map +1 -1
- package/dist/js/components/TimePicker/TimePicker.d.ts +4 -6
- package/dist/js/components/TimePicker/TimePicker.d.ts.map +1 -1
- package/dist/js/components/TimePicker/TimePicker.js +73 -41
- package/dist/js/components/TimePicker/TimePicker.js.map +1 -1
- package/dist/js/helpers/util.d.ts +6 -0
- package/dist/js/helpers/util.d.ts.map +1 -1
- package/dist/js/helpers/util.js +14 -1
- package/dist/js/helpers/util.js.map +1 -1
- package/dist/umd/react-core.css +64 -110
- package/dist/umd/react-core.js +847 -653
- package/dist/umd/react-core.min.css +64 -110
- package/dist/umd/react-core.min.js +3 -3
- package/package.json +6 -6
- package/src/components/Alert/examples/AlertAsyncLiveRegion.tsx +1 -1
- package/src/components/ApplicationLauncher/examples/ApplicationLauncher.md +11 -577
- package/src/components/ApplicationLauncher/examples/ApplicationLauncherAlignRight.tsx +32 -0
- package/src/components/ApplicationLauncher/examples/ApplicationLauncherAlignTop.tsx +31 -0
- package/src/components/ApplicationLauncher/examples/ApplicationLauncherBasic.tsx +23 -0
- package/src/components/ApplicationLauncher/examples/ApplicationLauncherCustomIcon.tsx +32 -0
- package/src/components/ApplicationLauncher/examples/ApplicationLauncherDisabled.tsx +25 -0
- package/src/components/ApplicationLauncher/examples/ApplicationLauncherDocumentBody.tsx +31 -0
- package/src/components/ApplicationLauncher/examples/ApplicationLauncherFavoritesAndSearch.tsx +105 -0
- package/src/components/ApplicationLauncher/examples/ApplicationLauncherRouterLink.tsx +50 -0
- package/src/components/ApplicationLauncher/examples/ApplicationLauncherSectionsAndIcons.tsx +47 -0
- package/src/components/ApplicationLauncher/examples/ApplicationLauncherTooltip.tsx +35 -0
- package/src/components/Label/Label.tsx +58 -39
- package/src/components/Label/__tests__/Label.test.tsx +19 -1
- package/src/components/Label/__tests__/__snapshots__/Label.test.tsx.snap +109 -0
- package/src/components/Label/examples/Label.md +1 -41
- package/src/components/Label/examples/LabelEditable.tsx +57 -0
- package/src/components/Select/Select.tsx +166 -26
- package/src/components/Select/SelectMenu.tsx +2 -1
- package/src/components/Select/SelectOption.tsx +5 -1
- package/src/components/Select/SelectToggle.tsx +38 -17
- package/src/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +74 -24
- package/src/components/Select/examples/Select.md +5 -1
- package/src/components/Select/selectConstants.tsx +2 -0
- package/src/components/Tabs/Tabs.tsx +6 -9
- package/src/components/TimePicker/TimePicker.tsx +112 -124
- package/src/components/TimePicker/examples/TimePicker.md +16 -10
- package/src/helpers/util.ts +13 -0
|
@@ -6,7 +6,6 @@ const React = tslib_1.__importStar(require("react"));
|
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const label_1 = tslib_1.__importDefault(require("@patternfly/react-styles/css/components/Label/label"));
|
|
8
8
|
const label_group_1 = tslib_1.__importDefault(require("@patternfly/react-styles/css/components/LabelGroup/label-group"));
|
|
9
|
-
const inline_edit_1 = tslib_1.__importDefault(require("@patternfly/react-styles/css/components/InlineEdit/inline-edit"));
|
|
10
9
|
const Button_1 = require("../Button");
|
|
11
10
|
const Tooltip_1 = require("../Tooltip");
|
|
12
11
|
const react_styles_1 = require("@patternfly/react-styles");
|
|
@@ -24,7 +23,9 @@ const colorStyles = {
|
|
|
24
23
|
const Label = (_a) => {
|
|
25
24
|
var { children, className = '', color = 'grey', variant = 'filled', isCompact = false, isEditable = false, editableProps, isTruncated = false, tooltipPosition, icon, onClose, onEditCancel, onEditComplete, closeBtn, closeBtnAriaLabel, closeBtnProps, href, isOverflowLabel, render } = _a, props = tslib_1.__rest(_a, ["children", "className", "color", "variant", "isCompact", "isEditable", "editableProps", "isTruncated", "tooltipPosition", "icon", "onClose", "onEditCancel", "onEditComplete", "closeBtn", "closeBtnAriaLabel", "closeBtnProps", "href", "isOverflowLabel", "render"]);
|
|
26
25
|
const [isEditableActive, setIsEditableActive] = react_1.useState(false);
|
|
27
|
-
const
|
|
26
|
+
const [currValue, setCurrValue] = react_1.useState(children);
|
|
27
|
+
const editableButtonRef = React.useRef();
|
|
28
|
+
const editableInputRef = React.useRef();
|
|
28
29
|
React.useEffect(() => {
|
|
29
30
|
document.addEventListener('click', onDocClick);
|
|
30
31
|
document.addEventListener('keydown', onKeyDown);
|
|
@@ -35,30 +36,41 @@ const Label = (_a) => {
|
|
|
35
36
|
});
|
|
36
37
|
const onDocClick = (event) => {
|
|
37
38
|
if (isEditableActive &&
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
!
|
|
41
|
-
|
|
39
|
+
editableInputRef &&
|
|
40
|
+
editableInputRef.current &&
|
|
41
|
+
!editableInputRef.current.contains(event.target)) {
|
|
42
|
+
if (editableInputRef.current.value) {
|
|
43
|
+
onEditComplete && onEditComplete(editableInputRef.current.value);
|
|
44
|
+
}
|
|
42
45
|
setIsEditableActive(false);
|
|
43
46
|
}
|
|
44
47
|
};
|
|
45
48
|
const onKeyDown = (event) => {
|
|
46
49
|
const key = event.key;
|
|
47
|
-
if (!
|
|
50
|
+
if ((!isEditableActive &&
|
|
51
|
+
(!editableButtonRef ||
|
|
52
|
+
!editableButtonRef.current ||
|
|
53
|
+
!editableButtonRef.current.contains(event.target))) ||
|
|
54
|
+
(isEditableActive &&
|
|
55
|
+
(!editableInputRef || !editableInputRef.current || !editableInputRef.current.contains(event.target)))) {
|
|
48
56
|
return;
|
|
49
57
|
}
|
|
50
58
|
if (isEditableActive && (key === 'Enter' || key === 'Tab')) {
|
|
51
59
|
event.preventDefault();
|
|
52
60
|
event.stopImmediatePropagation();
|
|
53
|
-
|
|
61
|
+
if (editableInputRef.current.value) {
|
|
62
|
+
onEditComplete && onEditComplete(editableInputRef.current.value);
|
|
63
|
+
}
|
|
54
64
|
setIsEditableActive(false);
|
|
55
65
|
}
|
|
56
66
|
if (isEditableActive && key === 'Escape') {
|
|
57
67
|
event.preventDefault();
|
|
58
68
|
event.stopImmediatePropagation();
|
|
59
69
|
// Reset div text to initial children prop - pre-edit
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
if (editableInputRef.current.value) {
|
|
71
|
+
editableInputRef.current.value = children;
|
|
72
|
+
onEditCancel && onEditCancel(children);
|
|
73
|
+
}
|
|
62
74
|
setIsEditableActive(false);
|
|
63
75
|
}
|
|
64
76
|
if (!isEditableActive && key === 'Enter') {
|
|
@@ -90,10 +102,19 @@ const Label = (_a) => {
|
|
|
90
102
|
icon && React.createElement("span", { className: react_styles_1.css(label_1.default.labelIcon) }, icon),
|
|
91
103
|
isTruncated && (React.createElement("span", { ref: textRef, className: react_styles_1.css(label_1.default.labelText) }, children)),
|
|
92
104
|
!isTruncated && children));
|
|
105
|
+
React.useEffect(() => {
|
|
106
|
+
if (isEditableActive && editableInputRef) {
|
|
107
|
+
editableInputRef.current && editableInputRef.current.focus();
|
|
108
|
+
}
|
|
109
|
+
}, [editableInputRef, isEditableActive]);
|
|
110
|
+
const updateVal = () => {
|
|
111
|
+
setCurrValue(editableInputRef.current.value);
|
|
112
|
+
};
|
|
93
113
|
if (isEditable) {
|
|
94
|
-
content = (React.createElement(
|
|
95
|
-
|
|
96
|
-
|
|
114
|
+
content = (React.createElement("button", Object.assign({ ref: editableButtonRef, className: react_styles_1.css(label_1.default.labelEditableText), onClick: e => {
|
|
115
|
+
setIsEditableActive(true);
|
|
116
|
+
e.stopPropagation();
|
|
117
|
+
} }, editableProps), children));
|
|
97
118
|
}
|
|
98
119
|
let labelComponentChild = (React.createElement(Component, Object.assign({ className: react_styles_1.css(label_1.default.labelContent) }, (href && { href })), content));
|
|
99
120
|
if (render) {
|
|
@@ -109,18 +130,10 @@ const Label = (_a) => {
|
|
|
109
130
|
labelComponentChild = (React.createElement(Tooltip_1.Tooltip, { content: children, position: tooltipPosition },
|
|
110
131
|
React.createElement(Component, Object.assign({ className: react_styles_1.css(label_1.default.labelContent) }, (href && { href })), content)));
|
|
111
132
|
}
|
|
112
|
-
return (React.createElement(LabelComponent, Object.assign({}, props, { className: react_styles_1.css(label_1.default.label, colorStyles[color], variant === 'outline' && label_1.default.modifiers.outline, isOverflowLabel && label_1.default.modifiers.overflow, isCompact && label_1.default.modifiers.compact, isEditable && label_group_1.default.modifiers.editable, isEditableActive && label_1.default.modifiers.editableActive, className) },
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
setIsEditableActive(true);
|
|
119
|
-
editableDivRef.current.focus();
|
|
120
|
-
}
|
|
121
|
-
})),
|
|
122
|
-
labelComponentChild,
|
|
123
|
-
onClose && button));
|
|
133
|
+
return (React.createElement(LabelComponent, Object.assign({}, props, { className: react_styles_1.css(label_1.default.label, colorStyles[color], variant === 'outline' && label_1.default.modifiers.outline, isOverflowLabel && label_1.default.modifiers.overflow, isCompact && label_1.default.modifiers.compact, isEditable && label_group_1.default.modifiers.editable, isEditableActive && label_1.default.modifiers.editableActive, className) }),
|
|
134
|
+
!isEditableActive && labelComponentChild,
|
|
135
|
+
!isEditableActive && onClose && button,
|
|
136
|
+
isEditableActive && (React.createElement("input", Object.assign({ className: react_styles_1.css(label_1.default.labelEditableText), type: "text", id: "editable-input", ref: editableInputRef, value: currValue, onChange: updateVal }, editableProps)))));
|
|
124
137
|
};
|
|
125
138
|
exports.Label = Label;
|
|
126
139
|
exports.Label.displayName = 'Label';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Label.js","sourceRoot":"","sources":["../../../../src/components/Label/Label.tsx"],"names":[],"mappings":";;;;AAAA,qDAA+B;AAC/B,iCAAiC;AACjC,wGAAyE;AACzE,yHAA4F;AAC5F,
|
|
1
|
+
{"version":3,"file":"Label.js","sourceRoot":"","sources":["../../../../src/components/Label/Label.tsx"],"names":[],"mappings":";;;;AAAA,qDAA+B;AAC/B,iCAAiC;AACjC,wGAAyE;AACzE,yHAA4F;AAC5F,sCAAmC;AACnC,wCAAqC;AACrC,2DAA+C;AAC/C,0GAA0E;AAC1E,2CAA0D;AAmD1D,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,eAAM,CAAC,SAAS,CAAC,IAAI;IAC3B,IAAI,EAAE,eAAM,CAAC,SAAS,CAAC,IAAI;IAC3B,KAAK,EAAE,eAAM,CAAC,SAAS,CAAC,KAAK;IAC7B,MAAM,EAAE,eAAM,CAAC,SAAS,CAAC,MAAM;IAC/B,MAAM,EAAE,eAAM,CAAC,SAAS,CAAC,MAAM;IAC/B,GAAG,EAAE,eAAM,CAAC,SAAS,CAAC,GAAG;IACzB,IAAI,EAAE,EAAE;CACT,CAAC;AAEK,MAAM,KAAK,GAAwC,CAAC,EAqB9C,EAAE,EAAE;QArB0C,EACzD,QAAQ,EACR,SAAS,GAAG,EAAE,E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AE,kBAAG,CAAC,eAAM,CAAC,iBAAiB,CAAC,EACxC,IAAI,EAAC,MAAM,EACX,EAAE,EAAC,gBAAgB,EACnB,GAAG,EAAE,gBAAgB,EACrB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,SAAS,IACf,aAAa,EACjB,CACH,CACc,CAClB,CAAC;AACJ,CAAC,CAAC;AApNW,QAAA,KAAK,SAoNhB;AACF,aAAK,CAAC,WAAW,GAAG,OAAO,CAAC"}
|
|
@@ -105,6 +105,8 @@ export interface SelectProps extends ToggleMenuBaseProps, Omit<React.HTMLProps<H
|
|
|
105
105
|
customBadgeText?: string | number;
|
|
106
106
|
/** Prefix for the id of the input in the checkbox select variant*/
|
|
107
107
|
inputIdPrefix?: string;
|
|
108
|
+
/** Value for the typeahead and inline filtering input autocomplete attribute */
|
|
109
|
+
inputAutoComplete?: string;
|
|
108
110
|
/** Optional props to pass to the chip group in the typeaheadmulti variant */
|
|
109
111
|
chipGroupProps?: Omit<ChipGroupProps, 'children' | 'ref'>;
|
|
110
112
|
/** Optional props to render custom chip group in the typeaheadmulti variant */
|
|
@@ -153,7 +155,9 @@ export declare class Select extends React.Component<SelectProps & OUIAProps, Sel
|
|
|
153
155
|
sendRef: (optionRef: React.ReactNode, favoriteRef: React.ReactNode, optionContainerRef: React.ReactNode, index: number) => void;
|
|
154
156
|
handleMenuKeys: (index: number, innerIndex: number, position: string) => void;
|
|
155
157
|
moveFocus: (nextIndex: number, updateCurrentIndex?: boolean) => void;
|
|
156
|
-
|
|
158
|
+
switchFocusToFavoriteMenu: () => void;
|
|
159
|
+
moveFocusToLastMenuItem: () => void;
|
|
160
|
+
handleTypeaheadKeys: (position: string, shiftKey?: boolean) => void;
|
|
157
161
|
onClickTypeaheadToggleButton: () => void;
|
|
158
162
|
getDisplay: (value: string | SelectOptionObject, type?: 'node' | 'text') => any;
|
|
159
163
|
findText: (item: React.ReactNode) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../src/components/Select/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B,OAAO,EAAgB,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGlE,OAAO,
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../src/components/Select/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B,OAAO,EAAgB,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGlE,OAAO,EAGL,cAAc,EAIf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAmB,cAAc,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EAIL,SAAS,EAET,YAAY,EAEb,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,mBAAmB,EAAU,MAAM,6BAA6B,CAAC;AAQ1E,MAAM,WAAW,oBAAoB;IACnC,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,WAAW,KAAK,IAAI,CAAC;CAChE;AACD,MAAM,WAAW,WACf,SAAQ,mBAAmB,EACzB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,UAAU,GAAG,KAAK,GAAG,SAAS,GAAG,UAAU,CAAC,EAClF,SAAS;IACX,yFAAyF;IACzF,QAAQ,CAAC,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC;IAChC,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,cAAc,GAAG,OAAO,GAAG,MAAM,CAAC;IAC7C,8DAA8D;IAC9D,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAC1B,yCAAyC;IACzC,MAAM,CAAC,EAAE,OAAO,CAAC;IACj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AAmB,aAEjB;IAEF,wBAAwB,UAAW,GAAG,aACwC;IAE9E,MAAM;CAifP"}
|
|
@@ -20,10 +20,12 @@ const selectConstants_1 = require("./selectConstants");
|
|
|
20
20
|
const ChipGroup_1 = require("../ChipGroup");
|
|
21
21
|
const Spinner_1 = require("../Spinner");
|
|
22
22
|
const helpers_1 = require("../../helpers");
|
|
23
|
+
const util_1 = require("../../helpers/util");
|
|
23
24
|
const Divider_1 = require("../Divider");
|
|
24
25
|
const Popper_1 = require("../../helpers/Popper/Popper");
|
|
25
26
|
const favorites_1 = require("../../helpers/favorites");
|
|
26
27
|
const constants_1 = require("../../helpers/constants");
|
|
28
|
+
const util_2 = require("../../helpers/util");
|
|
27
29
|
// seed for the aria-labelledby ID
|
|
28
30
|
let currentId = 0;
|
|
29
31
|
class Select extends React.Component {
|
|
@@ -275,9 +277,37 @@ class Select extends React.Component {
|
|
|
275
277
|
typeaheadInputValue
|
|
276
278
|
}));
|
|
277
279
|
};
|
|
278
|
-
this.
|
|
280
|
+
this.switchFocusToFavoriteMenu = () => {
|
|
281
|
+
const { typeaheadCurrIndex, typeaheadStoredIndex } = this.state;
|
|
282
|
+
let indexForFocus = 0;
|
|
283
|
+
if (typeaheadCurrIndex !== -1) {
|
|
284
|
+
indexForFocus = typeaheadCurrIndex;
|
|
285
|
+
}
|
|
286
|
+
else if (typeaheadStoredIndex !== -1) {
|
|
287
|
+
indexForFocus = typeaheadStoredIndex;
|
|
288
|
+
}
|
|
289
|
+
if (this.refCollection[indexForFocus] !== null && this.refCollection[indexForFocus][0] !== null) {
|
|
290
|
+
this.refCollection[indexForFocus][0].focus();
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
this.clearRef.current.focus();
|
|
294
|
+
}
|
|
295
|
+
this.setState({
|
|
296
|
+
tabbedIntoFavoritesMenu: true,
|
|
297
|
+
typeaheadCurrIndex: -1
|
|
298
|
+
});
|
|
299
|
+
};
|
|
300
|
+
this.moveFocusToLastMenuItem = () => {
|
|
301
|
+
const refCollectionLen = this.refCollection.length;
|
|
302
|
+
if (refCollectionLen > 0 &&
|
|
303
|
+
this.refCollection[refCollectionLen - 1] !== null &&
|
|
304
|
+
this.refCollection[refCollectionLen - 1][0] !== null) {
|
|
305
|
+
this.refCollection[refCollectionLen - 1][0].focus();
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
this.handleTypeaheadKeys = (position, shiftKey = false) => {
|
|
279
309
|
const { isOpen, onFavorite } = this.props;
|
|
280
|
-
const { typeaheadCurrIndex, tabbedIntoFavoritesMenu
|
|
310
|
+
const { typeaheadCurrIndex, tabbedIntoFavoritesMenu } = this.state;
|
|
281
311
|
const typeaheadActiveChild = this.getTypeaheadActiveChild(typeaheadCurrIndex);
|
|
282
312
|
if (isOpen) {
|
|
283
313
|
if (position === 'enter') {
|
|
@@ -295,32 +325,127 @@ class Select extends React.Component {
|
|
|
295
325
|
}
|
|
296
326
|
else if (position === 'tab') {
|
|
297
327
|
if (onFavorite) {
|
|
328
|
+
// if the input has focus, tab to the first item or the last item that was previously focused.
|
|
298
329
|
if (this.inputRef.current === document.activeElement) {
|
|
299
|
-
|
|
300
|
-
if (
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
this.refCollection[indexForFocus][0].focus();
|
|
330
|
+
// If shift is also clicked and there is a footer, tab to the last item in tabbable footer
|
|
331
|
+
if (this.props.footer && shiftKey) {
|
|
332
|
+
const tabbableItems = util_2.findTabbableElements(this.footerRef, selectConstants_1.SelectFooterTabbableItems);
|
|
333
|
+
if (tabbableItems.length > 0) {
|
|
334
|
+
if (tabbableItems[tabbableItems.length - 1]) {
|
|
335
|
+
tabbableItems[tabbableItems.length - 1].focus();
|
|
336
|
+
}
|
|
337
|
+
}
|
|
308
338
|
}
|
|
309
339
|
else {
|
|
310
|
-
this.
|
|
340
|
+
this.switchFocusToFavoriteMenu();
|
|
311
341
|
}
|
|
312
|
-
this.setState({
|
|
313
|
-
tabbedIntoFavoritesMenu: true,
|
|
314
|
-
typeaheadCurrIndex: -1
|
|
315
|
-
});
|
|
316
342
|
}
|
|
317
343
|
else {
|
|
318
|
-
|
|
319
|
-
this.
|
|
344
|
+
// focus is on menu or footer
|
|
345
|
+
if (this.props.footer) {
|
|
346
|
+
let tabbedIntoMenu = false;
|
|
347
|
+
const tabbableItems = util_2.findTabbableElements(this.footerRef, selectConstants_1.SelectFooterTabbableItems);
|
|
348
|
+
if (tabbableItems.length > 0) {
|
|
349
|
+
// if current element is not in footer, tab to first tabbable element in footer,
|
|
350
|
+
// if shift was clicked, tab to input since focus is on menu
|
|
351
|
+
const currentElementIndex = tabbableItems.findIndex((item) => item === document.activeElement);
|
|
352
|
+
if (currentElementIndex === -1) {
|
|
353
|
+
if (shiftKey) {
|
|
354
|
+
// currently in menu, shift back to input
|
|
355
|
+
this.inputRef.current.focus();
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
// currently in menu, tab to first tabbable item in footer
|
|
359
|
+
tabbableItems[0].focus();
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
// already in footer
|
|
364
|
+
if (shiftKey) {
|
|
365
|
+
// shift to previous item
|
|
366
|
+
if (currentElementIndex === 0) {
|
|
367
|
+
// on first footer item, shift back to menu
|
|
368
|
+
this.switchFocusToFavoriteMenu();
|
|
369
|
+
tabbedIntoMenu = true;
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
// shift to previous footer item
|
|
373
|
+
tabbableItems[currentElementIndex - 1].focus();
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
// tab to next tabbable item in footer or to input.
|
|
378
|
+
if (tabbableItems[currentElementIndex + 1]) {
|
|
379
|
+
tabbableItems[currentElementIndex + 1].focus();
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
this.inputRef.current.focus();
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
// no tabbable items in footer, tab to input
|
|
389
|
+
this.inputRef.current.focus();
|
|
390
|
+
tabbedIntoMenu = false;
|
|
391
|
+
}
|
|
392
|
+
this.setState({ tabbedIntoFavoritesMenu: tabbedIntoMenu });
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
this.inputRef.current.focus();
|
|
396
|
+
this.setState({ tabbedIntoFavoritesMenu: false });
|
|
397
|
+
}
|
|
320
398
|
}
|
|
321
399
|
}
|
|
322
400
|
else {
|
|
323
|
-
|
|
401
|
+
// Close if there is no footer
|
|
402
|
+
if (!this.props.footer) {
|
|
403
|
+
this.onToggle(false);
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
// has footer
|
|
407
|
+
const tabbableItems = util_2.findTabbableElements(this.footerRef, selectConstants_1.SelectFooterTabbableItems);
|
|
408
|
+
const currentElementIndex = tabbableItems.findIndex((item) => item === document.activeElement);
|
|
409
|
+
if (this.inputRef.current === document.activeElement) {
|
|
410
|
+
if (shiftKey) {
|
|
411
|
+
// close toggle if shift key and tab on input
|
|
412
|
+
this.onToggle(false);
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
// tab to first tabbable item in footer
|
|
416
|
+
if (tabbableItems[0]) {
|
|
417
|
+
tabbableItems[0].focus();
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
this.onToggle(false);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
// focus is in footer
|
|
426
|
+
if (shiftKey) {
|
|
427
|
+
if (currentElementIndex === 0) {
|
|
428
|
+
// shift tab back to input
|
|
429
|
+
this.inputRef.current.focus();
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
// shift to previous footer item
|
|
433
|
+
tabbableItems[currentElementIndex - 1].focus();
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
// tab to next footer item or close tab if last item
|
|
438
|
+
if (tabbableItems[currentElementIndex + 1]) {
|
|
439
|
+
tabbableItems[currentElementIndex + 1].focus();
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
// no next item, close toggle
|
|
443
|
+
this.onToggle(false);
|
|
444
|
+
this.inputRef.current.focus();
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
324
449
|
}
|
|
325
450
|
}
|
|
326
451
|
else if (!tabbedIntoFavoritesMenu) {
|
|
@@ -477,13 +602,13 @@ class Select extends React.Component {
|
|
|
477
602
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
478
603
|
onFilter,
|
|
479
604
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
480
|
-
onTypeaheadInputChanged, onCreateOption, isCreatable, onToggle, createText, noResultsFoundText, customBadgeText, inputIdPrefix,
|
|
605
|
+
onTypeaheadInputChanged, onCreateOption, isCreatable, onToggle, createText, noResultsFoundText, customBadgeText, inputIdPrefix, inputAutoComplete,
|
|
481
606
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
482
607
|
isInputValuePersisted, isInputFilterPersisted,
|
|
483
608
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
484
609
|
menuAppendTo, favorites, onFavorite,
|
|
485
610
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
486
|
-
favoritesLabel, footer, loadingVariant, isCreateSelectOptionObject } = _a, props = tslib_1.__rest(_a, ["children", "chipGroupProps", "chipGroupComponent", "className", "customContent", "variant", "direction", "onSelect", "onClear", "toggleId", "isOpen", "isGrouped", "isPlain", "isDisabled", "hasPlaceholderStyle", "validated", "selections", "typeAheadAriaLabel", "clearSelectionsAriaLabel", "toggleAriaLabel", "removeSelectionAriaLabel", 'aria-label', 'aria-labelledby', 'aria-describedby', 'aria-invalid', "placeholderText", "width", "maxHeight", "toggleIcon", "ouiaId", "ouiaSafe", "hasInlineFilter", "isCheckboxSelectionBadgeHidden", "inlineFilterPlaceholderText", "onFilter", "onTypeaheadInputChanged", "onCreateOption", "isCreatable", "onToggle", "createText", "noResultsFoundText", "customBadgeText", "inputIdPrefix", "isInputValuePersisted", "isInputFilterPersisted", "menuAppendTo", "favorites", "onFavorite", "favoritesLabel", "footer", "loadingVariant", "isCreateSelectOptionObject"]);
|
|
611
|
+
favoritesLabel, footer, loadingVariant, isCreateSelectOptionObject } = _a, props = tslib_1.__rest(_a, ["children", "chipGroupProps", "chipGroupComponent", "className", "customContent", "variant", "direction", "onSelect", "onClear", "toggleId", "isOpen", "isGrouped", "isPlain", "isDisabled", "hasPlaceholderStyle", "validated", "selections", "typeAheadAriaLabel", "clearSelectionsAriaLabel", "toggleAriaLabel", "removeSelectionAriaLabel", 'aria-label', 'aria-labelledby', 'aria-describedby', 'aria-invalid', "placeholderText", "width", "maxHeight", "toggleIcon", "ouiaId", "ouiaSafe", "hasInlineFilter", "isCheckboxSelectionBadgeHidden", "inlineFilterPlaceholderText", "onFilter", "onTypeaheadInputChanged", "onCreateOption", "isCreatable", "onToggle", "createText", "noResultsFoundText", "customBadgeText", "inputIdPrefix", "inputAutoComplete", "isInputValuePersisted", "isInputFilterPersisted", "menuAppendTo", "favorites", "onFavorite", "favoritesLabel", "footer", "loadingVariant", "isCreateSelectOptionObject"]);
|
|
487
612
|
const { focusFirstOption: openedOnEnter, typeaheadCurrIndex, typeaheadInputValue, typeaheadFilteredChildren, favoritesGroup } = this.state;
|
|
488
613
|
const selectToggleId = toggleId || `pf-select-toggle-id-${currentId++}`;
|
|
489
614
|
const selections = Array.isArray(selectionsProp) ? selectionsProp : [selectionsProp];
|
|
@@ -521,11 +646,11 @@ class Select extends React.Component {
|
|
|
521
646
|
if (isOpen) {
|
|
522
647
|
if (renderableItems.find(item => { var _a; return ((_a = item) === null || _a === void 0 ? void 0 : _a.key) === 'loading'; }) === undefined) {
|
|
523
648
|
if (loadingVariant === 'spinner') {
|
|
524
|
-
renderableItems.push(React.createElement(SelectOption_1.SelectOption, { isLoading: true, key: "loading", value: "loading"
|
|
649
|
+
renderableItems.push(React.createElement(SelectOption_1.SelectOption, { isLoading: true, key: "loading", value: "loading" },
|
|
525
650
|
React.createElement(Spinner_1.Spinner, { size: "lg" })));
|
|
526
651
|
}
|
|
527
652
|
else if (loadingVariant === null || loadingVariant === void 0 ? void 0 : loadingVariant.text) {
|
|
528
|
-
renderableItems.push(React.createElement(SelectOption_1.SelectOption, { isLoad: true, key: "loading", value: loadingVariant.text,
|
|
653
|
+
renderableItems.push(React.createElement(SelectOption_1.SelectOption, { isLoad: true, key: "loading", value: loadingVariant.text, setViewMoreNextIndex: this.setVieMoreNextIndex, onClick: loadingVariant === null || loadingVariant === void 0 ? void 0 : loadingVariant.onClick }));
|
|
529
654
|
}
|
|
530
655
|
}
|
|
531
656
|
}
|
|
@@ -564,6 +689,23 @@ class Select extends React.Component {
|
|
|
564
689
|
this.handleMenuKeys(0, 0, 'right');
|
|
565
690
|
event.preventDefault();
|
|
566
691
|
}
|
|
692
|
+
else if (event.key === selectConstants_1.KeyTypes.Tab && variant !== selectConstants_1.SelectVariant.checkbox && this.props.footer) {
|
|
693
|
+
// tab to footer or close menu if shift key
|
|
694
|
+
if (event.shiftKey) {
|
|
695
|
+
this.onToggle(false);
|
|
696
|
+
}
|
|
697
|
+
else {
|
|
698
|
+
const tabbableItems = util_2.findTabbableElements(this.footerRef, selectConstants_1.SelectFooterTabbableItems);
|
|
699
|
+
if (tabbableItems.length > 0) {
|
|
700
|
+
tabbableItems[0].focus();
|
|
701
|
+
event.stopPropagation();
|
|
702
|
+
event.preventDefault();
|
|
703
|
+
}
|
|
704
|
+
else {
|
|
705
|
+
this.onToggle(false);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
}
|
|
567
709
|
else if (event.key === selectConstants_1.KeyTypes.Tab && variant === selectConstants_1.SelectVariant.checkbox) {
|
|
568
710
|
// More modal-like experience for checkboxes
|
|
569
711
|
// Let SelectOption handle this
|
|
@@ -576,7 +718,7 @@ class Select extends React.Component {
|
|
|
576
718
|
event.stopPropagation();
|
|
577
719
|
event.preventDefault();
|
|
578
720
|
}
|
|
579
|
-
}, ref: this.filterRef, autoComplete:
|
|
721
|
+
}, ref: this.filterRef, autoComplete: inputAutoComplete })),
|
|
580
722
|
React.createElement(Divider_1.Divider, { key: "inline-filter-divider" })));
|
|
581
723
|
renderableItems = [filterBox, ...typeaheadFilteredChildren].map((option, index) => React.cloneElement(option, { key: index }));
|
|
582
724
|
}
|
|
@@ -638,7 +780,7 @@ class Select extends React.Component {
|
|
|
638
780
|
" ") : innerMenu;
|
|
639
781
|
const popperContainer = (React.createElement("div", Object.assign({ className: react_styles_1.css(select_1.default.select, isOpen && select_1.default.modifiers.expanded, validated === constants_1.ValidatedOptions.success && select_1.default.modifiers.success, validated === constants_1.ValidatedOptions.warning && select_1.default.modifiers.warning, validated === constants_1.ValidatedOptions.error && select_1.default.modifiers.invalid, direction === selectConstants_1.SelectDirection.up && select_1.default.modifiers.top, className) }, (width && { style: { width } }), (validated !== constants_1.ValidatedOptions.default && { 'aria-describedby': ariaDescribedby }), (validated !== constants_1.ValidatedOptions.default && { 'aria-invalid': ariaInvalid })), isOpen && menuContainer));
|
|
640
782
|
const mainContainer = (React.createElement("div", Object.assign({ className: react_styles_1.css(select_1.default.select, isOpen && select_1.default.modifiers.expanded, validated === constants_1.ValidatedOptions.success && select_1.default.modifiers.success, validated === constants_1.ValidatedOptions.warning && select_1.default.modifiers.warning, validated === constants_1.ValidatedOptions.error && select_1.default.modifiers.invalid, direction === selectConstants_1.SelectDirection.up && select_1.default.modifiers.top, className), ref: this.parentRef }, helpers_1.getOUIAProps(Select.displayName, ouiaId !== undefined ? ouiaId : this.state.ouiaStateId, ouiaSafe), (width && { style: { width } }), (validated !== constants_1.ValidatedOptions.default && { 'aria-describedby': ariaDescribedby }), (validated !== constants_1.ValidatedOptions.default && { 'aria-invalid': ariaInvalid })),
|
|
641
|
-
React.createElement(SelectToggle_1.SelectToggle, Object.assign({ id: selectToggleId, parentRef: this.parentRef, menuRef: this.menuComponentRef }, (footer && { footerRef: this.footerRef }), { isOpen: isOpen, isPlain: isPlain, hasPlaceholderStyle: hasPlaceholderStyle && (!selections.length || selections[0] === null || isSelectedPlaceholder), onToggle: this.onToggle, onEnter: this.onEnter, onClose: this.onClose, variant: variant, "aria-labelledby": `${ariaLabelledBy || ''} ${selectToggleId}`, "aria-label": toggleAriaLabel, handleTypeaheadKeys: this.handleTypeaheadKeys, isDisabled: isDisabled, hasClearButton: hasOnClear, hasFooter: footer !== undefined, onClickTypeaheadToggleButton: this.onClickTypeaheadToggleButton }),
|
|
783
|
+
React.createElement(SelectToggle_1.SelectToggle, Object.assign({ id: selectToggleId, parentRef: this.parentRef, menuRef: this.menuComponentRef }, (footer && { footerRef: this.footerRef }), { isOpen: isOpen, isPlain: isPlain, hasPlaceholderStyle: hasPlaceholderStyle && (!selections.length || selections[0] === null || isSelectedPlaceholder), onToggle: this.onToggle, onEnter: this.onEnter, onClose: this.onClose, variant: variant, "aria-labelledby": `${ariaLabelledBy || ''} ${selectToggleId}`, "aria-label": toggleAriaLabel, handleTypeaheadKeys: this.handleTypeaheadKeys, moveFocusToLastMenuItem: this.moveFocusToLastMenuItem, isDisabled: isDisabled, hasClearButton: hasOnClear, hasFooter: footer !== undefined, onClickTypeaheadToggleButton: this.onClickTypeaheadToggleButton }),
|
|
642
784
|
customContent && (React.createElement("div", { className: react_styles_1.css(select_1.default.selectToggleWrapper) },
|
|
643
785
|
toggleIcon && React.createElement("span", { className: react_styles_1.css(select_1.default.selectToggleIcon) }, toggleIcon),
|
|
644
786
|
React.createElement("span", { className: react_styles_1.css(select_1.default.selectToggleText) }, placeholderText))),
|
|
@@ -659,13 +801,13 @@ class Select extends React.Component {
|
|
|
659
801
|
toggleIcon && React.createElement("span", { className: react_styles_1.css(select_1.default.selectToggleIcon) }, toggleIcon),
|
|
660
802
|
React.createElement("input", { className: react_styles_1.css(form_control_1.default.formControl, select_1.default.selectToggleTypeahead), "aria-activedescendant": typeaheadActiveChild && typeaheadActiveChild.id, id: `${selectToggleId}-select-typeahead`, "aria-label": typeAheadAriaLabel, placeholder: placeholderText, value: typeaheadInputValue !== null
|
|
661
803
|
? typeaheadInputValue
|
|
662
|
-
: this.getDisplay(selections[0], 'text') || '', type: "text", onClick: this.onClick, onChange: this.onChange, autoComplete:
|
|
804
|
+
: this.getDisplay(selections[0], 'text') || '', type: "text", onClick: this.onClick, onChange: this.onChange, autoComplete: inputAutoComplete, disabled: isDisabled, ref: this.inputRef })),
|
|
663
805
|
hasOnClear && (selections[0] || typeaheadInputValue) && clearBtn)),
|
|
664
806
|
variant === selectConstants_1.SelectVariant.typeaheadMulti && !customContent && (React.createElement(React.Fragment, null,
|
|
665
807
|
React.createElement("div", { className: react_styles_1.css(select_1.default.selectToggleWrapper) },
|
|
666
808
|
toggleIcon && React.createElement("span", { className: react_styles_1.css(select_1.default.selectToggleIcon) }, toggleIcon),
|
|
667
809
|
selections && Array.isArray(selections) && selections.length > 0 && selectedChips,
|
|
668
|
-
React.createElement("input", { className: react_styles_1.css(form_control_1.default.formControl, select_1.default.selectToggleTypeahead), "aria-activedescendant": typeaheadActiveChild && typeaheadActiveChild.id, id: `${selectToggleId}-select-multi-typeahead-typeahead`, "aria-label": typeAheadAriaLabel, "aria-invalid": validated === constants_1.ValidatedOptions.error, placeholder: placeholderText, value: typeaheadInputValue !== null ? typeaheadInputValue : '', type: "text", onChange: this.onChange, onClick: this.onClick, autoComplete:
|
|
810
|
+
React.createElement("input", { className: react_styles_1.css(form_control_1.default.formControl, select_1.default.selectToggleTypeahead), "aria-activedescendant": typeaheadActiveChild && typeaheadActiveChild.id, id: `${selectToggleId}-select-multi-typeahead-typeahead`, "aria-label": typeAheadAriaLabel, "aria-invalid": validated === constants_1.ValidatedOptions.error, placeholder: placeholderText, value: typeaheadInputValue !== null ? typeaheadInputValue : '', type: "text", onChange: this.onChange, onClick: this.onClick, autoComplete: inputAutoComplete, disabled: isDisabled, ref: this.inputRef })),
|
|
669
811
|
hasOnClear && ((selections && selections.length > 0) || typeaheadInputValue) && clearBtn)),
|
|
670
812
|
validated === constants_1.ValidatedOptions.success && (React.createElement("span", { className: react_styles_1.css(select_1.default.selectToggleStatusIcon) },
|
|
671
813
|
React.createElement(check_circle_icon_1.default, { "aria-hidden": "true" }))),
|
|
@@ -722,6 +864,7 @@ Select.defaultProps = {
|
|
|
722
864
|
inlineFilterPlaceholderText: null,
|
|
723
865
|
customBadgeText: null,
|
|
724
866
|
inputIdPrefix: '',
|
|
867
|
+
inputAutoComplete: navigator.userAgent.match('Chrome') ? util_1.getUniqueId('pf-no-autocomplete') : 'off',
|
|
725
868
|
menuAppendTo: 'inline',
|
|
726
869
|
favorites: [],
|
|
727
870
|
favoritesLabel: 'Favorites',
|