iguazio.dashboard-react-controls 1.9.2 → 2.0.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/dist/components/Backdrop/Backdrop.js +7 -7
- package/dist/components/Button/Button.js +20 -26
- package/dist/components/ConfirmDialog/ConfirmDialog.js +18 -17
- package/dist/components/FormCheckBox/FormCheckBox.js +28 -32
- package/dist/components/FormChipCell/FormChip/FormChip.js +46 -50
- package/dist/components/FormChipCell/FormChipCell.js +122 -142
- package/dist/components/FormChipCell/FormChipCellView.js +44 -47
- package/dist/components/FormChipCell/HiddenChipsBlock/HiddenChipsBlock.js +23 -20
- package/dist/components/FormChipCell/NewChipForm/NewChipForm.js +129 -152
- package/dist/components/FormChipCell/NewChipInput/NewChipInput.js +24 -27
- package/dist/components/FormChipCell/formChipCell.util.js +6 -16
- package/dist/components/FormCombobox/FormCombobox.js +134 -195
- package/dist/components/FormInput/FormInput.js +134 -212
- package/dist/components/FormInput/InputNumberButtons/InputNumberButtons.js +15 -14
- package/dist/components/FormKeyValueTable/FormKeyValueTable.js +72 -72
- package/dist/components/FormRadio/FormRadio.js +21 -25
- package/dist/components/FormSelect/FormSelect.js +98 -126
- package/dist/components/FormSelect/FormSelect.test.js +56 -60
- package/dist/components/FormTextarea/FormTextarea.js +55 -71
- package/dist/components/FormToggle/FormToggle.js +25 -29
- package/dist/components/Modal/Modal.js +17 -18
- package/dist/components/PopUpDialog/PopUpDialog.js +53 -63
- package/dist/components/RoundedIcon/RoundedIcon.js +14 -13
- package/dist/components/Tip/Tip.js +58 -64
- package/dist/components/Tip/Tip.test.js +41 -64
- package/dist/components/Tooltip/Tooltip.js +75 -89
- package/dist/components/TooltipTemplate/ProducerTooltipTemplate.js +6 -5
- package/dist/components/TooltipTemplate/TextTooltipTemplate.js +10 -10
- package/dist/components/Wizard/Wizard.js +73 -107
- package/dist/components/Wizard/WizardSteps/WizardSteps.js +19 -20
- package/dist/components/index.js +18 -18
- package/dist/constants.js +26 -44
- package/dist/elements/FormActionButton/FormActionButton.js +12 -13
- package/dist/elements/FormRowActions/FormRowActions.js +19 -22
- package/dist/elements/OptionsMenu/OptionsMenu.js +10 -8
- package/dist/elements/SelectOption/SelectOption.js +14 -13
- package/dist/elements/SelectOption/SelectOption.test.js +39 -47
- package/dist/elements/ValidationTemplate/ValidationTemplate.js +7 -6
- package/dist/elements/index.js +5 -5
- package/dist/hooks/index.js +5 -5
- package/dist/hooks/useChipCell.hook.js +66 -85
- package/dist/hooks/useDebounce.hook.js +22 -24
- package/dist/hooks/useDetectOutsideClick.hook.js +4 -4
- package/dist/hooks/useFormTable.hook.js +99 -112
- package/dist/hooks/useHiddenChipsBlock.hook.js +40 -55
- package/dist/index.js +2 -3
- package/dist/scss/borders.scss +6 -0
- package/dist/scss/mixins.scss +32 -0
- package/dist/types.js +43 -67
- package/dist/utils/common.util.js +19 -23
- package/dist/utils/form.util.js +33 -39
- package/dist/utils/generateChipsList.util.js +7 -7
- package/dist/utils/getFirstScrollableParent.util.js +4 -10
- package/dist/utils/math.util.js +3 -3
- package/dist/utils/validation.util.js +74 -131
- package/package.json +34 -34
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -24,132 +23,89 @@ var _exclamationMark = require("../../images/exclamation-mark.svg");
|
|
|
24
23
|
require("./formCombobox.scss");
|
|
25
24
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
25
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
-
function _getRequireWildcardCache(
|
|
28
|
-
function _interopRequireWildcard(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
input = _useField.input,
|
|
79
|
-
meta = _useField.meta;
|
|
80
|
-
var _useState = (0, _react.useState)(inputDefaultValue),
|
|
81
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
82
|
-
inputValue = _useState2[0],
|
|
83
|
-
setInputValue = _useState2[1];
|
|
84
|
-
var _useState3 = (0, _react.useState)(selectDefaultValue),
|
|
85
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
86
|
-
selectValue = _useState4[0],
|
|
87
|
-
setSelectValue = _useState4[1];
|
|
88
|
-
var _useState5 = (0, _react.useState)({
|
|
89
|
-
left: '0px'
|
|
90
|
-
}),
|
|
91
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
92
|
-
dropdownStyle = _useState6[0],
|
|
93
|
-
setDropdownStyle = _useState6[1];
|
|
94
|
-
var _useState7 = (0, _react.useState)(false),
|
|
95
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
96
|
-
showSelectDropdown = _useState8[0],
|
|
97
|
-
setShowSelectDropdown = _useState8[1];
|
|
98
|
-
var _useState9 = (0, _react.useState)(false),
|
|
99
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
100
|
-
showSuggestionList = _useState10[0],
|
|
101
|
-
setShowSuggestionList = _useState10[1];
|
|
102
|
-
var _useState11 = (0, _react.useState)(suggestionList),
|
|
103
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
104
|
-
dropdownList = _useState12[0],
|
|
105
|
-
setDropdownList = _useState12[1];
|
|
106
|
-
var _useState13 = (0, _react.useState)(false),
|
|
107
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
|
108
|
-
searchIsFocused = _useState14[0],
|
|
109
|
-
setSearchIsFocused = _useState14[1];
|
|
110
|
-
var _useState15 = (0, _react.useState)(false),
|
|
111
|
-
_useState16 = _slicedToArray(_useState15, 2),
|
|
112
|
-
isInvalid = _useState16[0],
|
|
113
|
-
setIsInvalid = _useState16[1];
|
|
114
|
-
var _useState17 = (0, _react.useState)(rules),
|
|
115
|
-
_useState18 = _slicedToArray(_useState17, 2),
|
|
116
|
-
validationRules = _useState18[0],
|
|
117
|
-
setValidationRules = _useState18[1];
|
|
118
|
-
var _useState19 = (0, _react.useState)(false),
|
|
119
|
-
_useState20 = _slicedToArray(_useState19, 2),
|
|
120
|
-
showValidationRules = _useState20[0],
|
|
121
|
-
setShowValidationRules = _useState20[1];
|
|
122
|
-
var comboboxRef = (0, _react.useRef)();
|
|
123
|
-
var selectRef = (0, _react.useRef)();
|
|
124
|
-
var inputRef = (0, _react.useRef)();
|
|
125
|
-
var suggestionListRef = (0, _react.useRef)();
|
|
126
|
-
(0, _hooks.useDetectOutsideClick)(comboboxRef, function () {
|
|
127
|
-
return setShowValidationRules(false);
|
|
26
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
27
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
28
|
+
/*
|
|
29
|
+
Copyright 2022 Iguazio Systems Ltd.
|
|
30
|
+
Licensed under the Apache License, Version 2.0 (the "License") with
|
|
31
|
+
an addition restriction as set forth herein. You may not use this
|
|
32
|
+
file except in compliance with the License. You may obtain a copy of
|
|
33
|
+
the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
34
|
+
Unless required by applicable law or agreed to in writing, software
|
|
35
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
36
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
37
|
+
implied. See the License for the specific language governing
|
|
38
|
+
permissions and limitations under the License.
|
|
39
|
+
In addition, you may not use the software for any purposes that are
|
|
40
|
+
illegal under applicable law, and the grant of the foregoing license
|
|
41
|
+
under the Apache 2.0 license is conditioned upon your compliance with
|
|
42
|
+
such restriction.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
const FormCombobox = _ref => {
|
|
46
|
+
let {
|
|
47
|
+
comboboxClassName,
|
|
48
|
+
density,
|
|
49
|
+
disabled,
|
|
50
|
+
hideSearchInput,
|
|
51
|
+
inputDefaultValue,
|
|
52
|
+
inputPlaceholder,
|
|
53
|
+
invalidText,
|
|
54
|
+
label,
|
|
55
|
+
maxSuggestedMatches,
|
|
56
|
+
name,
|
|
57
|
+
onBlur,
|
|
58
|
+
onChange,
|
|
59
|
+
onFocus,
|
|
60
|
+
required,
|
|
61
|
+
rules,
|
|
62
|
+
selectDefaultValue,
|
|
63
|
+
selectOptions,
|
|
64
|
+
selectPlaceholder,
|
|
65
|
+
suggestionList,
|
|
66
|
+
validator,
|
|
67
|
+
withoutBorder
|
|
68
|
+
} = _ref;
|
|
69
|
+
const {
|
|
70
|
+
input,
|
|
71
|
+
meta
|
|
72
|
+
} = (0, _reactFinalForm.useField)(name);
|
|
73
|
+
const [inputValue, setInputValue] = (0, _react.useState)(inputDefaultValue);
|
|
74
|
+
const [selectValue, setSelectValue] = (0, _react.useState)(selectDefaultValue);
|
|
75
|
+
const [dropdownStyle, setDropdownStyle] = (0, _react.useState)({
|
|
76
|
+
left: '0px'
|
|
128
77
|
});
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
(0, _react.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
78
|
+
const [showSelectDropdown, setShowSelectDropdown] = (0, _react.useState)(false);
|
|
79
|
+
const [showSuggestionList, setShowSuggestionList] = (0, _react.useState)(false);
|
|
80
|
+
const [dropdownList, setDropdownList] = (0, _react.useState)(suggestionList);
|
|
81
|
+
const [searchIsFocused, setSearchIsFocused] = (0, _react.useState)(false);
|
|
82
|
+
const [isInvalid, setIsInvalid] = (0, _react.useState)(false);
|
|
83
|
+
const [validationRules, setValidationRules] = (0, _react.useState)(rules);
|
|
84
|
+
const [showValidationRules, setShowValidationRules] = (0, _react.useState)(false);
|
|
85
|
+
const comboboxRef = (0, _react.useRef)();
|
|
86
|
+
const selectRef = (0, _react.useRef)();
|
|
87
|
+
const inputRef = (0, _react.useRef)();
|
|
88
|
+
const suggestionListRef = (0, _react.useRef)();
|
|
89
|
+
(0, _hooks.useDetectOutsideClick)(comboboxRef, () => setShowValidationRules(false));
|
|
90
|
+
const labelClassNames = (0, _classnames.default)('form-field__label', disabled && 'form-field__label-disabled');
|
|
91
|
+
const inputClassNames = (0, _classnames.default)('form-field-combobox__input', selectValue.id.length === 0 && 'form-field-combobox__input_hidden');
|
|
92
|
+
(0, _react.useEffect)(() => {
|
|
93
|
+
setValidationRules(prevState => prevState.map(rule => ({
|
|
94
|
+
...rule,
|
|
95
|
+
isValid: !meta.error || !Array.isArray(meta.error) ? true : !meta.error.some(err => err.name === rule.name)
|
|
96
|
+
})));
|
|
141
97
|
}, [meta.error]);
|
|
142
|
-
(0, _react.useEffect)(
|
|
98
|
+
(0, _react.useEffect)(() => {
|
|
143
99
|
if (!searchIsFocused) {
|
|
144
100
|
if (JSON.stringify(dropdownList) !== JSON.stringify(suggestionList)) {
|
|
145
101
|
setDropdownList(suggestionList);
|
|
146
102
|
}
|
|
147
103
|
}
|
|
148
104
|
}, [dropdownList, suggestionList, searchIsFocused]);
|
|
149
|
-
(0, _react.useEffect)(
|
|
105
|
+
(0, _react.useEffect)(() => {
|
|
150
106
|
setIsInvalid(meta.invalid && (meta.validating || meta.modified || meta.submitFailed && meta.touched));
|
|
151
107
|
}, [meta.invalid, meta.modified, meta.submitFailed, meta.touched, meta.validating]);
|
|
152
|
-
|
|
108
|
+
const handleOutsideClick = (0, _react.useCallback)(event => {
|
|
153
109
|
if (comboboxRef.current && !comboboxRef.current.contains(event.target) && suggestionListRef.current && !suggestionListRef.current.contains(event.target)) {
|
|
154
110
|
setSearchIsFocused(false);
|
|
155
111
|
setShowSelectDropdown(false);
|
|
@@ -158,7 +114,7 @@ var FormCombobox = function FormCombobox(_ref) {
|
|
|
158
114
|
onBlur && onBlur(input.value);
|
|
159
115
|
}
|
|
160
116
|
}, [input, onBlur]);
|
|
161
|
-
|
|
117
|
+
const handleScroll = event => {
|
|
162
118
|
if (comboboxRef.current && comboboxRef.current.contains(event.target)) return;
|
|
163
119
|
if (!event.target.closest('.pop-up-dialog') && !event.target.classList.contains('form-field-combobox')) {
|
|
164
120
|
setShowValidationRules(false);
|
|
@@ -167,34 +123,35 @@ var FormCombobox = function FormCombobox(_ref) {
|
|
|
167
123
|
inputRef.current.blur();
|
|
168
124
|
}
|
|
169
125
|
};
|
|
170
|
-
(0, _react.useEffect)(
|
|
126
|
+
(0, _react.useEffect)(() => {
|
|
171
127
|
window.addEventListener('click', handleOutsideClick);
|
|
172
|
-
return
|
|
128
|
+
return () => {
|
|
173
129
|
window.removeEventListener('click', handleOutsideClick);
|
|
174
130
|
};
|
|
175
131
|
}, [handleOutsideClick]);
|
|
176
|
-
(0, _react.useEffect)(
|
|
132
|
+
(0, _react.useEffect)(() => {
|
|
177
133
|
if (showValidationRules || showSelectDropdown || showSuggestionList) {
|
|
178
134
|
window.addEventListener('scroll', handleScroll, true);
|
|
179
135
|
}
|
|
180
|
-
return
|
|
136
|
+
return () => {
|
|
181
137
|
window.removeEventListener('scroll', handleScroll, true);
|
|
182
138
|
};
|
|
183
139
|
}, [showSelectDropdown, showSuggestionList, showValidationRules]);
|
|
184
|
-
|
|
185
|
-
return validationRules.map(
|
|
186
|
-
|
|
187
|
-
isValid =
|
|
188
|
-
label
|
|
189
|
-
name
|
|
140
|
+
const getValidationRules = () => {
|
|
141
|
+
return validationRules.map(_ref2 => {
|
|
142
|
+
let {
|
|
143
|
+
isValid = false,
|
|
144
|
+
label,
|
|
145
|
+
name
|
|
146
|
+
} = _ref2;
|
|
190
147
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_elements.ValidationTemplate, {
|
|
191
148
|
valid: isValid,
|
|
192
149
|
validationMessage: label
|
|
193
150
|
}, name);
|
|
194
151
|
});
|
|
195
152
|
};
|
|
196
|
-
|
|
197
|
-
|
|
153
|
+
const handleInputChange = event => {
|
|
154
|
+
const target = event.target;
|
|
198
155
|
setDropdownStyle({
|
|
199
156
|
left: "".concat(target.selectionStart < 30 ? target.selectionStart : 30, "ch")
|
|
200
157
|
});
|
|
@@ -208,7 +165,7 @@ var FormCombobox = function FormCombobox(_ref) {
|
|
|
208
165
|
setShowSuggestionList(true);
|
|
209
166
|
}
|
|
210
167
|
};
|
|
211
|
-
|
|
168
|
+
const handleSelectOptionClick = (selectedOption, option) => {
|
|
212
169
|
if (selectedOption.id !== selectValue.id) {
|
|
213
170
|
setSelectValue(selectedOption);
|
|
214
171
|
input.onChange(selectedOption.id);
|
|
@@ -219,10 +176,10 @@ var FormCombobox = function FormCombobox(_ref) {
|
|
|
219
176
|
inputRef.current.focus();
|
|
220
177
|
}
|
|
221
178
|
};
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
179
|
+
const handleSuggestionListOptionClick = option => {
|
|
180
|
+
const inputValueItems = inputValue.split('/');
|
|
181
|
+
const valueIndex = inputValueItems.length - 1;
|
|
182
|
+
let formattedValue = option.customDelimiter ? inputValueItems[valueIndex].replace(new RegExp("".concat(option.customDelimiter, ".*")), '') + option.id : option.id;
|
|
226
183
|
if (inputValueItems.length <= maxSuggestedMatches - 1) formattedValue += '/';
|
|
227
184
|
inputValueItems[valueIndex] = formattedValue;
|
|
228
185
|
if (searchIsFocused) {
|
|
@@ -239,7 +196,7 @@ var FormCombobox = function FormCombobox(_ref) {
|
|
|
239
196
|
left: "".concat(inputRef.current.selectionStart < 30 ? inputRef.current.selectionStart : 30, "ch")
|
|
240
197
|
});
|
|
241
198
|
};
|
|
242
|
-
|
|
199
|
+
const inputOnFocus = () => {
|
|
243
200
|
onFocus && onFocus();
|
|
244
201
|
input.onFocus(new Event('focus'));
|
|
245
202
|
if (showSelectDropdown) {
|
|
@@ -247,15 +204,13 @@ var FormCombobox = function FormCombobox(_ref) {
|
|
|
247
204
|
}
|
|
248
205
|
setShowSuggestionList(true);
|
|
249
206
|
};
|
|
250
|
-
|
|
207
|
+
const suggestionListSearchChange = event => {
|
|
251
208
|
event.persist();
|
|
252
|
-
setDropdownList(
|
|
253
|
-
return
|
|
254
|
-
|
|
255
|
-
});
|
|
256
|
-
});
|
|
209
|
+
setDropdownList(() => suggestionList.filter(option => {
|
|
210
|
+
return option.id.startsWith(event.target.value);
|
|
211
|
+
}));
|
|
257
212
|
};
|
|
258
|
-
|
|
213
|
+
const toggleSelect = (0, _react.useCallback)(() => {
|
|
259
214
|
if (showSelectDropdown) {
|
|
260
215
|
setShowSelectDropdown(false);
|
|
261
216
|
input.onBlur(new Event('blur'));
|
|
@@ -271,26 +226,19 @@ var FormCombobox = function FormCombobox(_ref) {
|
|
|
271
226
|
onFocus && onFocus(input.value);
|
|
272
227
|
}
|
|
273
228
|
}, [input, onBlur, onFocus, showSelectDropdown]);
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
229
|
+
const validateField = function () {
|
|
230
|
+
let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
231
|
+
let allValues = arguments.length > 1 ? arguments[1] : undefined;
|
|
232
|
+
const valueToValidate = value.startsWith(selectValue.id) ? value.substring(selectValue.id.length) : value !== null && value !== void 0 ? value : '';
|
|
233
|
+
let validationError = null;
|
|
279
234
|
if (!(0, _lodash.isEmpty)(validationRules)) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
newRules = _checkPatternsValidit2[0],
|
|
283
|
-
isValidField = _checkPatternsValidit2[1];
|
|
284
|
-
var invalidRules = newRules.filter(function (rule) {
|
|
285
|
-
return !rule.isValid;
|
|
286
|
-
});
|
|
235
|
+
const [newRules, isValidField] = (0, _validation.checkPatternsValidity)(rules, valueToValidate);
|
|
236
|
+
const invalidRules = newRules.filter(rule => !rule.isValid);
|
|
287
237
|
if (!isValidField) {
|
|
288
|
-
validationError = invalidRules.map(
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
};
|
|
293
|
-
});
|
|
238
|
+
validationError = invalidRules.map(rule => ({
|
|
239
|
+
name: rule.name,
|
|
240
|
+
label: rule.label
|
|
241
|
+
}));
|
|
294
242
|
}
|
|
295
243
|
}
|
|
296
244
|
if ((0, _lodash.isEmpty)(validationError)) {
|
|
@@ -311,23 +259,23 @@ var FormCombobox = function FormCombobox(_ref) {
|
|
|
311
259
|
}
|
|
312
260
|
return validationError;
|
|
313
261
|
};
|
|
314
|
-
|
|
315
|
-
setShowValidationRules(
|
|
316
|
-
return !state;
|
|
317
|
-
});
|
|
262
|
+
const warningIconClick = () => {
|
|
263
|
+
setShowValidationRules(state => !state);
|
|
318
264
|
setShowSelectDropdown(false);
|
|
319
265
|
};
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
266
|
+
const comboboxClassNames = (0, _classnames.default)(comboboxClassName, 'form-field-combobox', 'form-field', isInvalid && 'form-field-combobox_invalid');
|
|
267
|
+
const iconClassNames = (0, _classnames.default)(showSelectDropdown && 'form-field-combobox__icon_open', 'form-field-combobox__icon');
|
|
268
|
+
const selectValueClassNames = (0, _classnames.default)(selectValue.className);
|
|
269
|
+
const wrapperClassNames = (0, _classnames.default)('form-field__wrapper', "form-field__wrapper-".concat(density), disabled && 'form-field__wrapper-disabled', isInvalid && 'form-field__wrapper-invalid', withoutBorder && 'without-border');
|
|
324
270
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, {
|
|
325
271
|
name: name,
|
|
326
272
|
validate: validateField,
|
|
327
|
-
children:
|
|
273
|
+
children: _ref3 => {
|
|
328
274
|
var _meta$error$label, _meta$error;
|
|
329
|
-
|
|
330
|
-
|
|
275
|
+
let {
|
|
276
|
+
input,
|
|
277
|
+
meta
|
|
278
|
+
} = _ref3;
|
|
331
279
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
332
280
|
className: comboboxClassNames,
|
|
333
281
|
ref: comboboxRef,
|
|
@@ -337,9 +285,7 @@ var FormCombobox = function FormCombobox(_ref) {
|
|
|
337
285
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
|
|
338
286
|
"data-testid": "label",
|
|
339
287
|
htmlFor: input.name,
|
|
340
|
-
children: [label, (required || validationRules.find(
|
|
341
|
-
return rule.name === 'required';
|
|
342
|
-
})) && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
288
|
+
children: [label, (required || validationRules.find(rule => rule.name === 'required')) && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
343
289
|
className: "form-field__label-mandatory",
|
|
344
290
|
children: " *"
|
|
345
291
|
})]
|
|
@@ -376,14 +322,12 @@ var FormCombobox = function FormCombobox(_ref) {
|
|
|
376
322
|
className: "form-field-combobox__dropdown form-field-combobox__dropdown-select",
|
|
377
323
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", {
|
|
378
324
|
className: "form-field-combobox__dropdown-list",
|
|
379
|
-
children: selectOptions.map(
|
|
325
|
+
children: selectOptions.map(option => {
|
|
380
326
|
if (!option.hidden) {
|
|
381
|
-
|
|
327
|
+
const selectOptionClassNames = (0, _classnames.default)('form-field-combobox__dropdown-list-option', option.className);
|
|
382
328
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
383
329
|
className: selectOptionClassNames,
|
|
384
|
-
onClick:
|
|
385
|
-
return handleSelectOptionClick(option);
|
|
386
|
-
},
|
|
330
|
+
onClick: () => handleSelectOptionClick(option),
|
|
387
331
|
children: option.label
|
|
388
332
|
}, option.id);
|
|
389
333
|
}
|
|
@@ -408,7 +352,9 @@ var FormCombobox = function FormCombobox(_ref) {
|
|
|
408
352
|
position: 'bottom-right'
|
|
409
353
|
},
|
|
410
354
|
className: "form-field-combobox__dropdown form-field-combobox__dropdown-suggestions",
|
|
411
|
-
style:
|
|
355
|
+
style: {
|
|
356
|
+
...dropdownStyle
|
|
357
|
+
},
|
|
412
358
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
413
359
|
ref: suggestionListRef,
|
|
414
360
|
children: [!hideSearchInput && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
@@ -417,9 +363,7 @@ var FormCombobox = function FormCombobox(_ref) {
|
|
|
417
363
|
"data-testid": name ? "".concat(name, "-form-combobox-search") : 'form-combobox-search',
|
|
418
364
|
className: "form-field-combobox__search form-field__control",
|
|
419
365
|
onChange: suggestionListSearchChange,
|
|
420
|
-
onFocus:
|
|
421
|
-
return setSearchIsFocused(true);
|
|
422
|
-
},
|
|
366
|
+
onFocus: () => setSearchIsFocused(true),
|
|
423
367
|
placeholder: "Type to search",
|
|
424
368
|
type: "text"
|
|
425
369
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_search.ReactComponent, {})]
|
|
@@ -428,15 +372,11 @@ var FormCombobox = function FormCombobox(_ref) {
|
|
|
428
372
|
children: searchIsFocused && dropdownList.length === 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
429
373
|
className: "form-field-combobox__dropdown-list-option",
|
|
430
374
|
children: "No data"
|
|
431
|
-
}, "no data") : dropdownList.map(
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
},
|
|
437
|
-
children: value.label
|
|
438
|
-
}, value.id);
|
|
439
|
-
})
|
|
375
|
+
}, "no data") : dropdownList.map(value => /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
376
|
+
className: "form-field-combobox__dropdown-list-option",
|
|
377
|
+
onClick: () => handleSuggestionListOptionClick(value),
|
|
378
|
+
children: value.label
|
|
379
|
+
}, value.id))
|
|
440
380
|
})]
|
|
441
381
|
})
|
|
442
382
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
@@ -510,5 +450,4 @@ FormCombobox.propTypes = {
|
|
|
510
450
|
validator: _propTypes.default.func,
|
|
511
451
|
withoutBorder: _propTypes.default.bool
|
|
512
452
|
};
|
|
513
|
-
var _default = FormCombobox;
|
|
514
|
-
exports.default = _default;
|
|
453
|
+
var _default = exports.default = FormCombobox;
|