@patternfly/react-core 3.144.1 → 3.146.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/CHANGELOG.md +46 -0
- package/dist/esm/components/DataToolbar/DataToolbarFilter.js +16 -5
- package/dist/esm/components/Drawer/Drawer.js +26 -36
- package/dist/esm/components/Drawer/DrawerActions.js +28 -0
- package/dist/esm/components/Drawer/DrawerCloseButton.js +36 -0
- package/dist/esm/components/Drawer/DrawerContent.js +9 -6
- package/dist/esm/components/Drawer/DrawerContentBody.js +30 -0
- package/dist/esm/components/Drawer/DrawerHead.js +33 -0
- package/dist/esm/components/Drawer/DrawerMain.js +28 -0
- package/dist/esm/components/Drawer/DrawerPanelBody.js +30 -0
- package/dist/esm/components/Drawer/DrawerPanelContent.js +12 -8
- package/dist/esm/components/Drawer/DrawerSection.js +28 -0
- package/dist/esm/components/Drawer/index.js +7 -1
- package/dist/esm/components/Dropdown/Toggle.js +3 -1
- package/dist/esm/components/FileUpload/FileUpload.js +123 -0
- package/dist/esm/components/FileUpload/FileUploadField.js +123 -0
- package/dist/esm/components/FileUpload/index.js +3 -0
- package/dist/esm/components/Modal/ModalBoxDescription.js +30 -0
- package/dist/esm/components/Modal/ModalContent.js +2 -3
- package/dist/esm/components/Select/Select.js +70 -36
- package/dist/esm/components/Select/SelectMenu.js +34 -25
- package/dist/esm/components/Select/SelectOption.js +15 -5
- package/dist/esm/components/Select/SelectToggle.js +6 -3
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/helpers/fileUtils.js +32 -0
- package/dist/esm/helpers/util.js +1 -1
- package/dist/js/components/DataToolbar/DataToolbarFilter.d.ts +8 -2
- package/dist/js/components/DataToolbar/DataToolbarFilter.js +21 -12
- package/dist/js/components/Drawer/Drawer.d.ts +7 -6
- package/dist/js/components/Drawer/Drawer.js +32 -67
- package/dist/js/components/Drawer/DrawerActions.d.ts +8 -0
- package/dist/js/components/Drawer/DrawerActions.js +44 -0
- package/dist/js/components/Drawer/DrawerCloseButton.d.ts +10 -0
- package/dist/js/components/Drawer/DrawerCloseButton.js +58 -0
- package/dist/js/components/Drawer/DrawerContent.d.ts +3 -1
- package/dist/js/components/Drawer/DrawerContent.js +9 -5
- package/dist/js/components/Drawer/DrawerContentBody.d.ts +10 -0
- package/dist/js/components/Drawer/DrawerContentBody.js +47 -0
- package/dist/js/components/Drawer/DrawerHead.d.ts +10 -0
- package/dist/js/components/Drawer/DrawerHead.js +51 -0
- package/dist/js/components/Drawer/DrawerMain.d.ts +8 -0
- package/dist/js/components/Drawer/DrawerMain.js +44 -0
- package/dist/js/components/Drawer/DrawerPanelBody.d.ts +10 -0
- package/dist/js/components/Drawer/DrawerPanelBody.js +47 -0
- package/dist/js/components/Drawer/DrawerPanelContent.d.ts +3 -4
- package/dist/js/components/Drawer/DrawerPanelContent.js +16 -10
- package/dist/js/components/Drawer/DrawerSection.d.ts +8 -0
- package/dist/js/components/Drawer/DrawerSection.js +44 -0
- package/dist/js/components/Drawer/index.d.ts +7 -1
- package/dist/js/components/Drawer/index.js +75 -3
- package/dist/js/components/Dropdown/Toggle.js +2 -1
- package/dist/js/components/FileUpload/FileUpload.d.ts +57 -0
- package/dist/js/components/FileUpload/FileUpload.js +151 -0
- package/dist/js/components/FileUpload/FileUploadField.d.ts +57 -0
- package/dist/js/components/FileUpload/FileUploadField.js +167 -0
- package/dist/js/components/FileUpload/index.d.ts +2 -0
- package/dist/js/components/FileUpload/index.js +30 -0
- package/dist/js/components/Modal/ModalBoxDescription.d.ts +10 -0
- package/dist/js/components/Modal/ModalBoxDescription.js +49 -0
- package/dist/js/components/Modal/ModalContent.js +3 -4
- package/dist/js/components/Select/Select.d.ts +2 -0
- package/dist/js/components/Select/Select.js +79 -35
- package/dist/js/components/Select/SelectMenu.d.ts +3 -1
- package/dist/js/components/Select/SelectMenu.js +30 -14
- package/dist/js/components/Select/SelectOption.d.ts +2 -0
- package/dist/js/components/Select/SelectOption.js +15 -5
- package/dist/js/components/Select/SelectToggle.d.ts +2 -0
- package/dist/js/components/Select/SelectToggle.js +6 -3
- package/dist/js/components/index.d.ts +1 -0
- package/dist/js/components/index.js +12 -0
- package/dist/js/helpers/fileUtils.d.ts +12 -0
- package/dist/js/helpers/fileUtils.js +45 -0
- package/dist/js/helpers/util.js +3 -1
- package/dist/umd/components/DataToolbar/DataToolbarFilter.js +16 -5
- package/dist/umd/components/Drawer/Drawer.js +27 -50
- package/dist/umd/components/Drawer/DrawerActions.js +154 -0
- package/dist/umd/components/Drawer/DrawerCloseButton.js +162 -0
- package/dist/umd/components/Drawer/DrawerContent.js +12 -10
- package/dist/umd/components/Drawer/DrawerContentBody.js +156 -0
- package/dist/umd/components/Drawer/DrawerHead.js +158 -0
- package/dist/umd/components/Drawer/DrawerMain.js +154 -0
- package/dist/umd/components/Drawer/DrawerPanelBody.js +156 -0
- package/dist/umd/components/Drawer/DrawerPanelContent.js +16 -13
- package/dist/umd/components/Drawer/DrawerSection.js +154 -0
- package/dist/umd/components/Drawer/index.js +60 -6
- package/dist/umd/components/Dropdown/Toggle.js +3 -1
- package/dist/umd/components/FileUpload/FileUpload.js +291 -0
- package/dist/umd/components/FileUpload/FileUploadField.js +243 -0
- package/dist/umd/components/FileUpload/index.js +38 -0
- package/dist/umd/components/Modal/ModalBoxDescription.js +156 -0
- package/dist/umd/components/Modal/ModalContent.js +5 -8
- package/dist/umd/components/Select/Select.js +71 -38
- package/dist/umd/components/Select/SelectMenu.js +37 -29
- package/dist/umd/components/Select/SelectOption.js +15 -5
- package/dist/umd/components/Select/SelectToggle.js +6 -3
- package/dist/umd/components/index.js +13 -4
- package/dist/umd/helpers/fileUtils.js +52 -0
- package/dist/umd/helpers/util.js +1 -1
- package/package.json +7 -6
- package/src/components/ApplicationLauncher/__tests__/__snapshots__/ApplicationLauncher.test.tsx.snap +0 -6
- package/src/components/DataToolbar/DataToolbarFilter.tsx +18 -6
- package/src/components/DataToolbar/__tests__/__snapshots__/DataToolbar.test.tsx.snap +16 -0
- package/src/components/Drawer/Drawer.tsx +36 -31
- package/src/components/Drawer/DrawerActions.tsx +21 -0
- package/src/components/Drawer/DrawerCloseButton.tsx +28 -0
- package/src/components/Drawer/DrawerContent.tsx +11 -4
- package/src/components/Drawer/DrawerContentBody.tsx +24 -0
- package/src/components/Drawer/DrawerHead.tsx +27 -0
- package/src/components/Drawer/DrawerMain.tsx +21 -0
- package/src/components/Drawer/DrawerPanelBody.tsx +24 -0
- package/src/components/Drawer/DrawerPanelContent.tsx +19 -8
- package/src/components/Drawer/DrawerSection.tsx +21 -0
- package/src/components/Drawer/__tests__/Drawer.test.tsx +24 -13
- package/src/components/Drawer/__tests__/Generated/__snapshots__/Drawer.test.tsx.snap +13 -5
- package/src/components/Drawer/__tests__/Generated/__snapshots__/DrawerContent.test.tsx.snap +8 -6
- package/src/components/Drawer/__tests__/Generated/__snapshots__/DrawerPanelContent.test.tsx.snap +3 -11
- package/src/components/Drawer/__tests__/__snapshots__/Drawer.test.tsx.snap +764 -69
- package/src/components/Drawer/examples/Drawer.md +434 -11
- package/src/components/Drawer/index.ts +7 -1
- package/src/components/Dropdown/Toggle.tsx +2 -0
- package/src/components/Dropdown/__tests__/__snapshots__/Dropdown.test.tsx.snap +0 -14
- package/src/components/Dropdown/__tests__/__snapshots__/DropdownToggle.test.tsx.snap +0 -5
- package/src/components/Dropdown/__tests__/__snapshots__/Toggle.test.tsx.snap +0 -2
- package/src/components/FileUpload/FileUpload.tsx +150 -0
- package/src/components/FileUpload/FileUploadField.tsx +176 -0
- package/src/components/FileUpload/__tests__/FileUpload.test.tsx +22 -0
- package/src/components/FileUpload/__tests__/FileUploadField.test.tsx +27 -0
- package/src/components/FileUpload/__tests__/__snapshots__/FileUpload.test.tsx.snap +16 -0
- package/src/components/FileUpload/__tests__/__snapshots__/FileUploadField.test.tsx.snap +60 -0
- package/src/components/FileUpload/examples/FileUpload.md +283 -0
- package/src/components/FileUpload/index.ts +2 -0
- package/src/components/Modal/ModalBoxDescription.tsx +23 -0
- package/src/components/Modal/ModalContent.tsx +2 -6
- package/src/components/Modal/__tests__/__snapshots__/ModalContent.test.tsx.snap +2 -3
- package/src/components/OptionsMenu/__tests__/__snapshots__/OptionsMenu.test.tsx.snap +0 -7
- package/src/components/Pagination/__tests__/__snapshots__/Pagination.test.tsx.snap +0 -13
- package/src/components/Select/Select.tsx +74 -33
- package/src/components/Select/SelectMenu.tsx +28 -23
- package/src/components/Select/SelectOption.tsx +28 -3
- package/src/components/Select/SelectToggle.tsx +6 -1
- package/src/components/Select/__tests__/Select.test.tsx +16 -0
- package/src/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +911 -174
- package/src/components/Select/__tests__/__snapshots__/SelectOption.test.tsx.snap +7 -7
- package/src/components/Select/__tests__/__snapshots__/SelectToggle.test.tsx.snap +3 -0
- package/src/components/Select/examples/Select.md +109 -6
- package/src/components/index.ts +1 -0
- package/src/helpers/__tests__/fileUtils.test.ts +17 -0
- package/src/helpers/fileUtils.ts +26 -0
- package/src/helpers/util.ts +1 -1
- package/src/components/Drawer/Drawer.test.tsx +0 -22
- package/src/components/Drawer/__snapshots__/Drawer.test.tsx.snap +0 -121
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import _pt from "prop-types";
|
|
2
|
+
|
|
3
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
+
|
|
5
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
6
|
+
|
|
7
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
8
|
+
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import styles from '@patternfly/react-styles/css/components/FileUpload/file-upload';
|
|
11
|
+
import { css } from '@patternfly/react-styles';
|
|
12
|
+
import { InputGroup } from '../InputGroup';
|
|
13
|
+
import { TextInput } from '../TextInput';
|
|
14
|
+
import { Button, ButtonVariant } from '../Button';
|
|
15
|
+
import { TextArea, TextAreResizeOrientation } from '../TextArea';
|
|
16
|
+
import { Spinner, spinnerSize } from '../Spinner';
|
|
17
|
+
import { fileReaderType } from '../../helpers/fileUtils';
|
|
18
|
+
export const FileUploadField = (_ref) => {
|
|
19
|
+
let {
|
|
20
|
+
id,
|
|
21
|
+
type,
|
|
22
|
+
value = '',
|
|
23
|
+
filename = '',
|
|
24
|
+
onChange = () => {},
|
|
25
|
+
onBrowseButtonClick = () => {},
|
|
26
|
+
onClearButtonClick = () => {},
|
|
27
|
+
className = '',
|
|
28
|
+
isDisabled = false,
|
|
29
|
+
isReadOnly = false,
|
|
30
|
+
isLoading = false,
|
|
31
|
+
spinnerAriaValueText,
|
|
32
|
+
isRequired = false,
|
|
33
|
+
isDragActive = false,
|
|
34
|
+
validated = 'default',
|
|
35
|
+
'aria-label': ariaLabel = 'File upload',
|
|
36
|
+
filenamePlaceholder = 'Drag a file here or browse to upload',
|
|
37
|
+
filenameAriaLabel = filename ? 'Read only filename' : filenamePlaceholder,
|
|
38
|
+
browseButtonText = 'Browse...',
|
|
39
|
+
clearButtonText = 'Clear',
|
|
40
|
+
isClearButtonDisabled = !filename && !value,
|
|
41
|
+
containerRef = null,
|
|
42
|
+
allowEditingUploadedText = false,
|
|
43
|
+
hideDefaultPreview = false,
|
|
44
|
+
children = null
|
|
45
|
+
} = _ref,
|
|
46
|
+
props = _objectWithoutProperties(_ref, ["id", "type", "value", "filename", "onChange", "onBrowseButtonClick", "onClearButtonClick", "className", "isDisabled", "isReadOnly", "isLoading", "spinnerAriaValueText", "isRequired", "isDragActive", "validated", "aria-label", "filenamePlaceholder", "filenameAriaLabel", "browseButtonText", "clearButtonText", "isClearButtonDisabled", "containerRef", "allowEditingUploadedText", "hideDefaultPreview", "children"]);
|
|
47
|
+
|
|
48
|
+
const onTextAreaChange = (newValue, event) => {
|
|
49
|
+
onChange(newValue, filename, event);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return React.createElement("div", _extends({
|
|
53
|
+
className: css(styles.fileUpload, isDragActive && styles.modifiers.dragHover, isLoading && styles.modifiers.loading, className),
|
|
54
|
+
ref: containerRef
|
|
55
|
+
}, props), React.createElement("div", {
|
|
56
|
+
className: styles.fileUploadFileSelect
|
|
57
|
+
}, React.createElement(InputGroup, null, React.createElement(TextInput, {
|
|
58
|
+
isReadOnly: true // Always read-only regardless of isReadOnly prop (which is just for the TextArea)
|
|
59
|
+
,
|
|
60
|
+
isDisabled: isDisabled,
|
|
61
|
+
id: `${id}-filename`,
|
|
62
|
+
name: `${id}-filename`,
|
|
63
|
+
"aria-label": filenameAriaLabel,
|
|
64
|
+
placeholder: filenamePlaceholder,
|
|
65
|
+
"aria-describedby": `${id}-browse-button`,
|
|
66
|
+
value: filename
|
|
67
|
+
}), React.createElement(Button, {
|
|
68
|
+
id: `${id}-browse-button`,
|
|
69
|
+
variant: ButtonVariant.control,
|
|
70
|
+
onClick: onBrowseButtonClick,
|
|
71
|
+
isDisabled: isDisabled
|
|
72
|
+
}, browseButtonText), React.createElement(Button, {
|
|
73
|
+
variant: ButtonVariant.control,
|
|
74
|
+
isDisabled: isDisabled || isClearButtonDisabled,
|
|
75
|
+
onClick: onClearButtonClick
|
|
76
|
+
}, clearButtonText))), React.createElement("div", {
|
|
77
|
+
className: styles.fileUploadFileDetails
|
|
78
|
+
}, !hideDefaultPreview && type === fileReaderType.text && React.createElement(TextArea, {
|
|
79
|
+
readOnly: isReadOnly || !!filename && !allowEditingUploadedText,
|
|
80
|
+
disabled: isDisabled,
|
|
81
|
+
isRequired: isRequired,
|
|
82
|
+
resizeOrientation: TextAreResizeOrientation.vertical,
|
|
83
|
+
validated: validated,
|
|
84
|
+
id: id,
|
|
85
|
+
name: id,
|
|
86
|
+
"aria-label": ariaLabel,
|
|
87
|
+
value: value,
|
|
88
|
+
onChange: onTextAreaChange
|
|
89
|
+
}), isLoading && React.createElement("div", {
|
|
90
|
+
className: styles.fileUploadFileDetailsSpinner
|
|
91
|
+
}, React.createElement(Spinner, {
|
|
92
|
+
size: spinnerSize.lg,
|
|
93
|
+
"aria-valuetext": spinnerAriaValueText
|
|
94
|
+
}))), children);
|
|
95
|
+
};
|
|
96
|
+
FileUploadField.propTypes = {
|
|
97
|
+
id: _pt.string.isRequired,
|
|
98
|
+
type: _pt.oneOf(['text', 'dataURL']),
|
|
99
|
+
value: _pt.oneOfType([_pt.string, _pt.any]),
|
|
100
|
+
filename: _pt.string,
|
|
101
|
+
onChange: _pt.func,
|
|
102
|
+
className: _pt.string,
|
|
103
|
+
isDisabled: _pt.bool,
|
|
104
|
+
isReadOnly: _pt.bool,
|
|
105
|
+
isLoading: _pt.bool,
|
|
106
|
+
spinnerAriaValueText: _pt.string,
|
|
107
|
+
isRequired: _pt.bool,
|
|
108
|
+
validated: _pt.oneOf(['success', 'error', 'default']),
|
|
109
|
+
'aria-label': _pt.string,
|
|
110
|
+
filenamePlaceholder: _pt.string,
|
|
111
|
+
filenameAriaLabel: _pt.string,
|
|
112
|
+
browseButtonText: _pt.string,
|
|
113
|
+
clearButtonText: _pt.string,
|
|
114
|
+
isClearButtonDisabled: _pt.bool,
|
|
115
|
+
hideDefaultPreview: _pt.bool,
|
|
116
|
+
allowEditingUploadedText: _pt.bool,
|
|
117
|
+
children: _pt.node,
|
|
118
|
+
onBrowseButtonClick: _pt.func,
|
|
119
|
+
onClearButtonClick: _pt.func,
|
|
120
|
+
isDragActive: _pt.bool,
|
|
121
|
+
containerRef: _pt.oneOfType([_pt.string, _pt.func, _pt.object])
|
|
122
|
+
};
|
|
123
|
+
//# sourceMappingURL=FileUploadField.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import _pt from "prop-types";
|
|
2
|
+
|
|
3
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
+
|
|
5
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
6
|
+
|
|
7
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
8
|
+
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import { css } from '@patternfly/react-styles';
|
|
11
|
+
import styles from '@patternfly/react-styles/css/components/ModalBox/modal-box';
|
|
12
|
+
export const ModalBoxDescription = (_ref) => {
|
|
13
|
+
let {
|
|
14
|
+
children = null,
|
|
15
|
+
className = '',
|
|
16
|
+
id = ''
|
|
17
|
+
} = _ref,
|
|
18
|
+
props = _objectWithoutProperties(_ref, ["children", "className", "id"]);
|
|
19
|
+
|
|
20
|
+
return React.createElement("div", _extends({}, props, {
|
|
21
|
+
id: id,
|
|
22
|
+
className: css(styles.modalBoxDescription, className)
|
|
23
|
+
}), children);
|
|
24
|
+
};
|
|
25
|
+
ModalBoxDescription.propTypes = {
|
|
26
|
+
children: _pt.node,
|
|
27
|
+
className: _pt.string,
|
|
28
|
+
id: _pt.string
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=ModalBoxDescription.js.map
|
|
@@ -14,7 +14,6 @@ const FocusTrap = require('focus-trap-react');
|
|
|
14
14
|
|
|
15
15
|
import styles from '@patternfly/react-styles/css/layouts/Bullseye/bullseye';
|
|
16
16
|
import titleStyles from '@patternfly/react-styles/css/components/Title/title';
|
|
17
|
-
import modalStyles from '@patternfly/react-styles/css/components/ModalBox/modal-box';
|
|
18
17
|
import { css } from '@patternfly/react-styles';
|
|
19
18
|
import { Backdrop } from '../Backdrop/Backdrop';
|
|
20
19
|
import { ModalBoxBody } from './ModalBoxBody';
|
|
@@ -22,6 +21,7 @@ import { ModalBoxHeader } from './ModalBoxHeader';
|
|
|
22
21
|
import { ModalBoxCloseButton } from './ModalBoxCloseButton';
|
|
23
22
|
import { ModalBox } from './ModalBox';
|
|
24
23
|
import { ModalBoxFooter } from './ModalBoxFooter';
|
|
24
|
+
import { ModalBoxDescription } from './ModalBoxDescription';
|
|
25
25
|
export const ModalContent = (_ref) => {
|
|
26
26
|
let {
|
|
27
27
|
children,
|
|
@@ -71,8 +71,7 @@ export const ModalContent = (_ref) => {
|
|
|
71
71
|
id: ariaDescribedById || id
|
|
72
72
|
}, showClose && React.createElement(ModalBoxCloseButton, {
|
|
73
73
|
onClose: onClose
|
|
74
|
-
}), modalBoxHeader, description && React.createElement(
|
|
75
|
-
className: css(modalStyles.modalBoxDescription),
|
|
74
|
+
}), modalBoxHeader, description && React.createElement(ModalBoxDescription, {
|
|
76
75
|
id: id
|
|
77
76
|
}, description), React.createElement(ModalBoxBody, _extends({}, props, !description && {
|
|
78
77
|
id
|
|
@@ -18,10 +18,11 @@ import TimesCircleIcon from '@patternfly/react-icons/dist/js/icons/times-circle-
|
|
|
18
18
|
import { SelectMenu } from './SelectMenu';
|
|
19
19
|
import { SelectOption } from './SelectOption';
|
|
20
20
|
import { SelectToggle } from './SelectToggle';
|
|
21
|
-
import { SelectContext, SelectVariant, SelectDirection } from './selectConstants';
|
|
21
|
+
import { SelectContext, SelectVariant, SelectDirection, KeyTypes } from './selectConstants';
|
|
22
22
|
import { Chip, ChipGroup } from '../ChipGroup';
|
|
23
23
|
import { keyHandler, getNextIndex } from '../../helpers/util';
|
|
24
|
-
import { withOuiaContext } from '../withOuia';
|
|
24
|
+
import { withOuiaContext } from '../withOuia';
|
|
25
|
+
import { Divider } from '../Divider'; // seed for the aria-labelledby ID
|
|
25
26
|
|
|
26
27
|
let currentId = 0;
|
|
27
28
|
|
|
@@ -31,6 +32,8 @@ class Select extends React.Component {
|
|
|
31
32
|
|
|
32
33
|
_defineProperty(this, "parentRef", React.createRef());
|
|
33
34
|
|
|
35
|
+
_defineProperty(this, "filterRef", React.createRef());
|
|
36
|
+
|
|
34
37
|
_defineProperty(this, "refCollection", []);
|
|
35
38
|
|
|
36
39
|
_defineProperty(this, "state", {
|
|
@@ -43,6 +46,10 @@ class Select extends React.Component {
|
|
|
43
46
|
});
|
|
44
47
|
|
|
45
48
|
_defineProperty(this, "componentDidUpdate", (prevProps, prevState) => {
|
|
49
|
+
if (this.props.hasInlineFilter) {
|
|
50
|
+
this.refCollection[0] = this.filterRef.current;
|
|
51
|
+
}
|
|
52
|
+
|
|
46
53
|
if (!prevState.openedOnEnter && this.state.openedOnEnter) {
|
|
47
54
|
this.refCollection[0].focus();
|
|
48
55
|
}
|
|
@@ -109,7 +116,8 @@ class Select extends React.Component {
|
|
|
109
116
|
!isCreatable && typeaheadFilteredChildren.push(React.createElement(SelectOption, {
|
|
110
117
|
isDisabled: true,
|
|
111
118
|
key: 0,
|
|
112
|
-
value: noResultsFoundText
|
|
119
|
+
value: noResultsFoundText,
|
|
120
|
+
isNoResultsOption: true
|
|
113
121
|
}));
|
|
114
122
|
}
|
|
115
123
|
|
|
@@ -286,16 +294,18 @@ class Select extends React.Component {
|
|
|
286
294
|
ouiaContext,
|
|
287
295
|
ouiaId,
|
|
288
296
|
createText,
|
|
289
|
-
noResultsFoundText
|
|
297
|
+
noResultsFoundText,
|
|
298
|
+
hasInlineFilter
|
|
290
299
|
} = _this$props,
|
|
291
|
-
props = _objectWithoutProperties(_this$props, ["children", "className", "customContent", "variant", "direction", "onToggle", "onSelect", "onClear", "onFilter", "onCreateOption", "toggleId", "isExpanded", "isGrouped", "isPlain", "isDisabled", "isCreatable", "selections", "ariaLabelledBy", "ariaLabelTypeAhead", "ariaLabelClear", "ariaLabelToggle", "ariaLabelRemove", "aria-label", "placeholderText", "width", "maxHeight", "toggleIcon", "ouiaContext", "ouiaId", "createText", "noResultsFoundText"]);
|
|
300
|
+
props = _objectWithoutProperties(_this$props, ["children", "className", "customContent", "variant", "direction", "onToggle", "onSelect", "onClear", "onFilter", "onCreateOption", "toggleId", "isExpanded", "isGrouped", "isPlain", "isDisabled", "isCreatable", "selections", "ariaLabelledBy", "ariaLabelTypeAhead", "ariaLabelClear", "ariaLabelToggle", "ariaLabelRemove", "aria-label", "placeholderText", "width", "maxHeight", "toggleIcon", "ouiaContext", "ouiaId", "createText", "noResultsFoundText", "hasInlineFilter"]);
|
|
292
301
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
293
302
|
|
|
294
303
|
|
|
295
304
|
const {
|
|
296
305
|
openedOnEnter,
|
|
297
306
|
typeaheadInputValue,
|
|
298
|
-
typeaheadActiveChild
|
|
307
|
+
typeaheadActiveChild,
|
|
308
|
+
typeaheadFilteredChildren
|
|
299
309
|
} = this.state;
|
|
300
310
|
const selectToggleId = toggleId || `pf-toggle-id-${currentId++}`;
|
|
301
311
|
let childPlaceholderText = null;
|
|
@@ -307,6 +317,20 @@ class Select extends React.Component {
|
|
|
307
317
|
}
|
|
308
318
|
}
|
|
309
319
|
|
|
320
|
+
const hasOnClear = onClear !== Select.defaultProps.onClear;
|
|
321
|
+
const hasAnySelections = selections && (Array.isArray(selections) ? selections.length > 0 ? true : false : selections !== '');
|
|
322
|
+
const clearBtn = React.createElement("button", {
|
|
323
|
+
className: css(buttonStyles.button, buttonStyles.modifiers.plain, styles.selectToggleClear),
|
|
324
|
+
onClick: e => {
|
|
325
|
+
this.clearSelection(e);
|
|
326
|
+
onClear(e);
|
|
327
|
+
},
|
|
328
|
+
"aria-label": ariaLabelClear,
|
|
329
|
+
type: "button",
|
|
330
|
+
disabled: isDisabled
|
|
331
|
+
}, React.createElement(TimesCircleIcon, {
|
|
332
|
+
"aria-hidden": true
|
|
333
|
+
}));
|
|
310
334
|
let selectedChips = null;
|
|
311
335
|
|
|
312
336
|
if (variant === SelectVariant.typeaheadMulti) {
|
|
@@ -317,6 +341,35 @@ class Select extends React.Component {
|
|
|
317
341
|
}, this.getDisplay(item, 'node'))));
|
|
318
342
|
}
|
|
319
343
|
|
|
344
|
+
let filterWithChildren = children;
|
|
345
|
+
|
|
346
|
+
if (hasInlineFilter) {
|
|
347
|
+
const filterBox = React.createElement(React.Fragment, null, React.createElement("div", {
|
|
348
|
+
key: "inline-filter",
|
|
349
|
+
className: css(styles.selectMenuInput)
|
|
350
|
+
}, React.createElement("input", {
|
|
351
|
+
key: "inline-filter-input",
|
|
352
|
+
type: "search",
|
|
353
|
+
className: css(formStyles.formControl, formStyles.modifiers.search),
|
|
354
|
+
onChange: this.onChange,
|
|
355
|
+
onKeyDown: event => {
|
|
356
|
+
if (event.key === KeyTypes.ArrowUp) {
|
|
357
|
+
this.handleArrowKeys(0, 'up');
|
|
358
|
+
} else if (event.key === KeyTypes.ArrowDown) {
|
|
359
|
+
this.handleArrowKeys(0, 'down');
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
ref: this.filterRef,
|
|
363
|
+
autoComplete: "off"
|
|
364
|
+
})), React.createElement(Divider, {
|
|
365
|
+
key: "inline-filter-divider"
|
|
366
|
+
}));
|
|
367
|
+
this.refCollection[0] = this.filterRef.current;
|
|
368
|
+
filterWithChildren = [filterBox, ...typeaheadFilteredChildren].map((option, index) => React.cloneElement(option, {
|
|
369
|
+
key: index
|
|
370
|
+
}));
|
|
371
|
+
}
|
|
372
|
+
|
|
320
373
|
return React.createElement("div", _extends({
|
|
321
374
|
className: css(styles.select, isExpanded && styles.modifiers.expanded, direction === SelectDirection.up && styles.modifiers.top, className),
|
|
322
375
|
ref: this.parentRef,
|
|
@@ -344,7 +397,8 @@ class Select extends React.Component {
|
|
|
344
397
|
variant: variant,
|
|
345
398
|
ariaLabelToggle: ariaLabelToggle,
|
|
346
399
|
handleTypeaheadKeys: this.handleTypeaheadKeys,
|
|
347
|
-
isDisabled: isDisabled
|
|
400
|
+
isDisabled: isDisabled,
|
|
401
|
+
hasClearButton: hasOnClear
|
|
348
402
|
}, customContent && React.createElement("div", {
|
|
349
403
|
className: css(styles.selectToggleWrapper)
|
|
350
404
|
}, toggleIcon && React.createElement("span", {
|
|
@@ -357,7 +411,7 @@ class Select extends React.Component {
|
|
|
357
411
|
className: css(styles.selectToggleIcon)
|
|
358
412
|
}, toggleIcon), React.createElement("span", {
|
|
359
413
|
className: css(styles.selectToggleText)
|
|
360
|
-
}, this.getDisplay(selections, 'node') || placeholderText || childPlaceholderText)), variant === SelectVariant.checkbox && !customContent && React.createElement(React.Fragment, null, React.createElement("div", {
|
|
414
|
+
}, this.getDisplay(selections, 'node') || placeholderText || childPlaceholderText), hasOnClear && hasAnySelections && clearBtn), variant === SelectVariant.checkbox && !customContent && React.createElement(React.Fragment, null, React.createElement("div", {
|
|
361
415
|
className: css(styles.selectToggleWrapper)
|
|
362
416
|
}, toggleIcon && React.createElement("span", {
|
|
363
417
|
className: css(styles.selectToggleIcon)
|
|
@@ -367,7 +421,7 @@ class Select extends React.Component {
|
|
|
367
421
|
className: css(styles.selectToggleBadge)
|
|
368
422
|
}, React.createElement("span", {
|
|
369
423
|
className: css(badgeStyles.badge, badgeStyles.modifiers.read)
|
|
370
|
-
}, selections.length)))), variant === SelectVariant.typeahead && !customContent && React.createElement(React.Fragment, null, React.createElement("div", {
|
|
424
|
+
}, selections.length))), hasOnClear && hasAnySelections && clearBtn), variant === SelectVariant.typeahead && !customContent && React.createElement(React.Fragment, null, React.createElement("div", {
|
|
371
425
|
className: css(styles.selectToggleWrapper)
|
|
372
426
|
}, toggleIcon && React.createElement("span", {
|
|
373
427
|
className: css(styles.selectToggleIcon)
|
|
@@ -384,18 +438,7 @@ class Select extends React.Component {
|
|
|
384
438
|
onFocus: this.handleFocus,
|
|
385
439
|
autoComplete: "off",
|
|
386
440
|
disabled: isDisabled
|
|
387
|
-
})), (selections || typeaheadInputValue) && React.createElement("
|
|
388
|
-
className: css(buttonStyles.button, buttonStyles.modifiers.plain, styles.selectToggleClear),
|
|
389
|
-
onClick: e => {
|
|
390
|
-
this.clearSelection(e);
|
|
391
|
-
onClear(e);
|
|
392
|
-
},
|
|
393
|
-
"aria-label": ariaLabelClear,
|
|
394
|
-
type: "button",
|
|
395
|
-
disabled: isDisabled
|
|
396
|
-
}, React.createElement(TimesCircleIcon, {
|
|
397
|
-
"aria-hidden": true
|
|
398
|
-
}))), variant === SelectVariant.typeaheadMulti && !customContent && React.createElement(React.Fragment, null, React.createElement("div", {
|
|
441
|
+
})), (selections || typeaheadInputValue) && clearBtn), variant === SelectVariant.typeaheadMulti && !customContent && React.createElement(React.Fragment, null, React.createElement("div", {
|
|
399
442
|
className: css(styles.selectToggleWrapper)
|
|
400
443
|
}, toggleIcon && React.createElement("span", {
|
|
401
444
|
className: css(styles.selectToggleIcon)
|
|
@@ -412,18 +455,7 @@ class Select extends React.Component {
|
|
|
412
455
|
onFocus: this.handleFocus,
|
|
413
456
|
autoComplete: "off",
|
|
414
457
|
disabled: isDisabled
|
|
415
|
-
})), (selections && Array.isArray(selections) && selections.length > 0 || typeaheadInputValue) && React.createElement(
|
|
416
|
-
className: css(buttonStyles.button, buttonStyles.modifiers.plain, styles.selectToggleClear),
|
|
417
|
-
onClick: e => {
|
|
418
|
-
this.clearSelection(e);
|
|
419
|
-
onClear(e);
|
|
420
|
-
},
|
|
421
|
-
"aria-label": ariaLabelClear,
|
|
422
|
-
type: "button",
|
|
423
|
-
disabled: isDisabled
|
|
424
|
-
}, React.createElement(TimesCircleIcon, {
|
|
425
|
-
"aria-hidden": true
|
|
426
|
-
})))), customContent && isExpanded && React.createElement(SelectMenu, _extends({}, props, {
|
|
458
|
+
})), (selections && Array.isArray(selections) && selections.length > 0 || typeaheadInputValue) && clearBtn)), customContent && isExpanded && React.createElement(SelectMenu, _extends({}, props, {
|
|
427
459
|
selected: selections,
|
|
428
460
|
openedOnEnter: openedOnEnter,
|
|
429
461
|
"aria-label": ariaLabel,
|
|
@@ -447,8 +479,9 @@ class Select extends React.Component {
|
|
|
447
479
|
isGrouped: isGrouped,
|
|
448
480
|
sendRef: this.sendRef,
|
|
449
481
|
keyHandler: this.handleArrowKeys,
|
|
450
|
-
maxHeight: maxHeight
|
|
451
|
-
|
|
482
|
+
maxHeight: maxHeight,
|
|
483
|
+
hasInlineFilter: hasInlineFilter
|
|
484
|
+
}), filterWithChildren), (variant === SelectVariant.typeahead || variant === SelectVariant.typeaheadMulti) && isExpanded && !customContent && React.createElement(SelectMenu, _extends({}, props, {
|
|
452
485
|
selected: selections,
|
|
453
486
|
openedOnEnter: openedOnEnter,
|
|
454
487
|
"aria-label": ariaLabel,
|
|
@@ -515,7 +548,8 @@ _defineProperty(Select, "defaultProps", {
|
|
|
515
548
|
onCreateOption: () => undefined,
|
|
516
549
|
toggleIcon: null,
|
|
517
550
|
onFilter: null,
|
|
518
|
-
customContent: null
|
|
551
|
+
customContent: null,
|
|
552
|
+
hasInlineFilter: false
|
|
519
553
|
});
|
|
520
554
|
|
|
521
555
|
const SelectWithOuiaContext = withOuiaContext(Select);
|
|
@@ -12,6 +12,7 @@ import * as React from 'react';
|
|
|
12
12
|
import styles from '@patternfly/react-styles/css/components/Select/select';
|
|
13
13
|
import { default as formStyles } from '@patternfly/react-styles/css/components/Form/form';
|
|
14
14
|
import { css } from '@patternfly/react-styles';
|
|
15
|
+
import { SelectOption } from './SelectOption';
|
|
15
16
|
import { SelectConsumer, SelectVariant } from './selectConstants';
|
|
16
17
|
|
|
17
18
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
@@ -52,38 +53,43 @@ export class SelectMenu extends React.Component {
|
|
|
52
53
|
});
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
extendCheckboxChildren() {
|
|
56
|
+
extendCheckboxChildren(children) {
|
|
56
57
|
const {
|
|
57
|
-
children,
|
|
58
58
|
isGrouped,
|
|
59
59
|
checked,
|
|
60
60
|
sendRef,
|
|
61
|
-
keyHandler
|
|
61
|
+
keyHandler,
|
|
62
|
+
hasInlineFilter
|
|
62
63
|
} = this.props;
|
|
63
|
-
|
|
64
|
+
let index = hasInlineFilter ? 1 : 0;
|
|
64
65
|
|
|
65
66
|
if (isGrouped) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
67
|
+
return React.Children.map(children, group => {
|
|
68
|
+
if (group.type === SelectOption) {
|
|
69
|
+
return group;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return React.cloneElement(group, {
|
|
73
|
+
titleId: group.props.label.replace(/\W/g, '-'),
|
|
74
|
+
children: React.createElement("fieldset", {
|
|
75
|
+
"aria-labelledby": group.props.label.replace(/\W/g, '-'),
|
|
76
|
+
className: css(styles.selectMenuFieldset)
|
|
77
|
+
}, group.props.children.map(option => React.cloneElement(option, {
|
|
78
|
+
isChecked: checked && checked.includes(option.props.value),
|
|
79
|
+
sendRef,
|
|
80
|
+
keyHandler,
|
|
81
|
+
index: index++
|
|
82
|
+
})))
|
|
83
|
+
});
|
|
84
|
+
});
|
|
79
85
|
}
|
|
80
86
|
|
|
81
|
-
return React.
|
|
87
|
+
return React.Children.map(children, child => React.cloneElement(child, {
|
|
82
88
|
isChecked: checked && checked.includes(child.props.value),
|
|
83
89
|
sendRef,
|
|
84
90
|
keyHandler,
|
|
85
|
-
index
|
|
86
|
-
}))
|
|
91
|
+
index: index++
|
|
92
|
+
}));
|
|
87
93
|
}
|
|
88
94
|
|
|
89
95
|
render() {
|
|
@@ -104,9 +110,10 @@ export class SelectMenu extends React.Component {
|
|
|
104
110
|
noResultsFoundText,
|
|
105
111
|
createText,
|
|
106
112
|
'aria-label': ariaLabel,
|
|
107
|
-
'aria-labelledby': ariaLabelledBy
|
|
113
|
+
'aria-labelledby': ariaLabelledBy,
|
|
114
|
+
hasInlineFilter
|
|
108
115
|
} = _this$props,
|
|
109
|
-
props = _objectWithoutProperties(_this$props, ["children", "isCustomContent", "className", "isExpanded", "openedOnEnter", "selected", "checked", "isGrouped", "sendRef", "keyHandler", "maxHeight", "noResultsFoundText", "createText", "aria-label", "aria-labelledby"]);
|
|
116
|
+
props = _objectWithoutProperties(_this$props, ["children", "isCustomContent", "className", "isExpanded", "openedOnEnter", "selected", "checked", "isGrouped", "sendRef", "keyHandler", "maxHeight", "noResultsFoundText", "createText", "aria-label", "aria-labelledby", "hasInlineFilter"]);
|
|
110
117
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
111
118
|
|
|
112
119
|
|
|
@@ -142,7 +149,7 @@ export class SelectMenu extends React.Component {
|
|
|
142
149
|
"aria-label": ariaLabel,
|
|
143
150
|
"aria-labelledby": !ariaLabel && ariaLabelledBy || null,
|
|
144
151
|
className: css(formStyles.formFieldset)
|
|
145
|
-
}), this.extendCheckboxChildren()))), variant === SelectVariant.checkbox && !isCustomContent && React.Children.count(children) === 0 && React.createElement("div", _extends({
|
|
152
|
+
}), hasInlineFilter && [children.shift(), ...this.extendCheckboxChildren(children)], !hasInlineFilter && this.extendCheckboxChildren(children)))), variant === SelectVariant.checkbox && !isCustomContent && React.Children.count(children) === 0 && React.createElement("div", _extends({
|
|
146
153
|
className: css(styles.selectMenu, className)
|
|
147
154
|
}, maxHeight && {
|
|
148
155
|
style: {
|
|
@@ -169,7 +176,8 @@ _defineProperty(SelectMenu, "propTypes", {
|
|
|
169
176
|
noResultsFoundText: _pt.string,
|
|
170
177
|
createText: _pt.string,
|
|
171
178
|
sendRef: _pt.func,
|
|
172
|
-
keyHandler: _pt.func
|
|
179
|
+
keyHandler: _pt.func,
|
|
180
|
+
hasInlineFilter: _pt.bool
|
|
173
181
|
});
|
|
174
182
|
|
|
175
183
|
_defineProperty(SelectMenu, "defaultProps", {
|
|
@@ -181,6 +189,7 @@ _defineProperty(SelectMenu, "defaultProps", {
|
|
|
181
189
|
maxHeight: '',
|
|
182
190
|
sendRef: () => {},
|
|
183
191
|
keyHandler: () => {},
|
|
184
|
-
isCustomContent: false
|
|
192
|
+
isCustomContent: false,
|
|
193
|
+
hasInlineFilter: false
|
|
185
194
|
});
|
|
186
195
|
//# sourceMappingURL=SelectMenu.js.map
|
|
@@ -42,11 +42,11 @@ export class SelectOption extends React.Component {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
componentDidMount() {
|
|
45
|
-
this.props.sendRef(this.ref.current, this.props.index);
|
|
45
|
+
this.props.sendRef(this.props.isDisabled ? null : this.ref.current, this.props.index);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
componentDidUpdate() {
|
|
49
|
-
this.props.sendRef(this.ref.current, this.props.index);
|
|
49
|
+
this.props.sendRef(this.props.isDisabled ? null : this.ref.current, this.props.index);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
render() {
|
|
@@ -59,6 +59,7 @@ export class SelectOption extends React.Component {
|
|
|
59
59
|
onClick,
|
|
60
60
|
isDisabled,
|
|
61
61
|
isPlaceholder,
|
|
62
|
+
isNoResultsOption,
|
|
62
63
|
isSelected,
|
|
63
64
|
isChecked,
|
|
64
65
|
isFocused,
|
|
@@ -67,7 +68,7 @@ export class SelectOption extends React.Component {
|
|
|
67
68
|
index,
|
|
68
69
|
component
|
|
69
70
|
} = _this$props,
|
|
70
|
-
props = _objectWithoutProperties(_this$props, ["children", "className", "value", "onClick", "isDisabled", "isPlaceholder", "isSelected", "isChecked", "isFocused", "sendRef", "keyHandler", "index", "component"]);
|
|
71
|
+
props = _objectWithoutProperties(_this$props, ["children", "className", "value", "onClick", "isDisabled", "isPlaceholder", "isNoResultsOption", "isSelected", "isChecked", "isFocused", "sendRef", "keyHandler", "index", "component"]);
|
|
71
72
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
72
73
|
|
|
73
74
|
|
|
@@ -95,7 +96,7 @@ export class SelectOption extends React.Component {
|
|
|
95
96
|
}), children || value.toString(), isSelected && React.createElement(CheckIcon, {
|
|
96
97
|
className: css(styles.selectMenuItemIcon),
|
|
97
98
|
"aria-hidden": true
|
|
98
|
-
}))), variant === SelectVariant.checkbox && React.createElement("label", _extends({}, props, {
|
|
99
|
+
}))), variant === SelectVariant.checkbox && !isNoResultsOption && React.createElement("label", _extends({}, props, {
|
|
99
100
|
className: css(checkStyles.check, styles.selectMenuItem, isDisabled && styles.modifiers.disabled, className),
|
|
100
101
|
onKeyDown: this.onKeyDown
|
|
101
102
|
}), React.createElement("input", {
|
|
@@ -113,7 +114,14 @@ export class SelectOption extends React.Component {
|
|
|
113
114
|
disabled: isDisabled
|
|
114
115
|
}), React.createElement("span", {
|
|
115
116
|
className: css(checkStyles.checkLabel, isDisabled && styles.modifiers.disabled)
|
|
116
|
-
}, children || value.toString()))
|
|
117
|
+
}, children || value.toString())), variant === SelectVariant.checkbox && isNoResultsOption && React.createElement("div", null, React.createElement(Component, _extends({}, props, {
|
|
118
|
+
className: css(styles.selectMenuItem, isSelected && styles.modifiers.selected, isDisabled && styles.modifiers.disabled, isFocused && styles.modifiers.focus, className),
|
|
119
|
+
role: "option",
|
|
120
|
+
"aria-selected": isSelected || null,
|
|
121
|
+
ref: this.ref,
|
|
122
|
+
onKeyDown: this.onKeyDown,
|
|
123
|
+
type: "button"
|
|
124
|
+
}), children || value.toString()))));
|
|
117
125
|
}
|
|
118
126
|
|
|
119
127
|
}
|
|
@@ -126,6 +134,7 @@ _defineProperty(SelectOption, "propTypes", {
|
|
|
126
134
|
value: _pt.oneOfType([_pt.string, _pt.shape({})]),
|
|
127
135
|
isDisabled: _pt.bool,
|
|
128
136
|
isPlaceholder: _pt.bool,
|
|
137
|
+
isNoResultsOption: _pt.bool,
|
|
129
138
|
isSelected: _pt.bool,
|
|
130
139
|
isChecked: _pt.bool,
|
|
131
140
|
isFocused: _pt.bool,
|
|
@@ -143,6 +152,7 @@ _defineProperty(SelectOption, "defaultProps", {
|
|
|
143
152
|
isSelected: false,
|
|
144
153
|
isChecked: false,
|
|
145
154
|
isFocused: false,
|
|
155
|
+
isNoResultsOption: false,
|
|
146
156
|
component: 'button',
|
|
147
157
|
onClick: () => {},
|
|
148
158
|
sendRef: () => {},
|
|
@@ -130,14 +130,15 @@ export class SelectToggle extends React.Component {
|
|
|
130
130
|
parentRef,
|
|
131
131
|
id,
|
|
132
132
|
type,
|
|
133
|
+
hasClearButton,
|
|
133
134
|
ariaLabelledBy,
|
|
134
135
|
ariaLabelToggle
|
|
135
136
|
} = _this$props,
|
|
136
|
-
props = _objectWithoutProperties(_this$props, ["className", "children", "isExpanded", "isFocused", "isActive", "isHovered", "isPlain", "isDisabled", "variant", "onToggle", "onEnter", "onClose", "handleTypeaheadKeys", "parentRef", "id", "type", "ariaLabelledBy", "ariaLabelToggle"]);
|
|
137
|
+
props = _objectWithoutProperties(_this$props, ["className", "children", "isExpanded", "isFocused", "isActive", "isHovered", "isPlain", "isDisabled", "variant", "onToggle", "onEnter", "onClose", "handleTypeaheadKeys", "parentRef", "id", "type", "hasClearButton", "ariaLabelledBy", "ariaLabelToggle"]);
|
|
137
138
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
138
139
|
|
|
139
140
|
|
|
140
|
-
const isTypeahead = variant === SelectVariant.typeahead || variant === SelectVariant.typeaheadMulti;
|
|
141
|
+
const isTypeahead = variant === SelectVariant.typeahead || variant === SelectVariant.typeaheadMulti || hasClearButton;
|
|
141
142
|
const toggleProps = {
|
|
142
143
|
id,
|
|
143
144
|
'aria-labelledby': ariaLabelledBy,
|
|
@@ -209,7 +210,8 @@ _defineProperty(SelectToggle, "propTypes", {
|
|
|
209
210
|
type: _pt.oneOfType([_pt.oneOf(['reset']), _pt.oneOf(['button']), _pt.oneOf(['submit'])]),
|
|
210
211
|
ariaLabelledBy: _pt.string,
|
|
211
212
|
ariaLabelToggle: _pt.string,
|
|
212
|
-
variant: _pt.oneOf(['single', 'checkbox', 'typeahead', 'typeaheadmulti'])
|
|
213
|
+
variant: _pt.oneOf(['single', 'checkbox', 'typeahead', 'typeaheadmulti']),
|
|
214
|
+
hasClearButton: _pt.bool
|
|
213
215
|
});
|
|
214
216
|
|
|
215
217
|
_defineProperty(SelectToggle, "defaultProps", {
|
|
@@ -220,6 +222,7 @@ _defineProperty(SelectToggle, "defaultProps", {
|
|
|
220
222
|
isActive: false,
|
|
221
223
|
isPlain: false,
|
|
222
224
|
isDisabled: false,
|
|
225
|
+
hasClearButton: false,
|
|
223
226
|
variant: 'single',
|
|
224
227
|
ariaLabelledBy: '',
|
|
225
228
|
ariaLabelToggle: '',
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export let fileReaderType;
|
|
2
|
+
/**
|
|
3
|
+
* Read a file using the FileReader API, either as a plain text string or as a DataURL string.
|
|
4
|
+
* Returns a promise which will resolve with the file contents as a string or reject with a DOMException.
|
|
5
|
+
*
|
|
6
|
+
* @param {File} fileHandle - File object to read
|
|
7
|
+
* @param {fileReaderType} type - How to read it
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
(function (fileReaderType) {
|
|
11
|
+
fileReaderType["text"] = "text";
|
|
12
|
+
fileReaderType["dataURL"] = "dataURL";
|
|
13
|
+
})(fileReaderType || (fileReaderType = {}));
|
|
14
|
+
|
|
15
|
+
export function readFile(fileHandle, type) {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const reader = new FileReader();
|
|
18
|
+
|
|
19
|
+
reader.onload = () => resolve(reader.result);
|
|
20
|
+
|
|
21
|
+
reader.onerror = () => reject(reader.error);
|
|
22
|
+
|
|
23
|
+
if (type === fileReaderType.text) {
|
|
24
|
+
reader.readAsText(fileHandle);
|
|
25
|
+
} else if (type === fileReaderType.dataURL) {
|
|
26
|
+
reader.readAsDataURL(fileHandle);
|
|
27
|
+
} else {
|
|
28
|
+
reject('unknown type');
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=fileUtils.js.map
|