@hitachivantara/uikit-react-core 5.87.2 → 5.88.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/cjs/ActionsGeneric/ActionsGeneric.cjs +1 -1
- package/dist/cjs/Banner/BannerContent/BannerContent.cjs +1 -1
- package/dist/cjs/BaseInput/BaseInput.cjs +44 -83
- package/dist/cjs/BaseInput/BaseInput.styles.cjs +68 -142
- package/dist/cjs/BaseInput/validations.cjs +2 -1
- package/dist/cjs/Calendar/CalendarHeader/CalendarHeader.cjs +0 -6
- package/dist/cjs/Calendar/CalendarHeader/CalendarHeader.styles.cjs +1 -5
- package/dist/cjs/ColorPicker/ColorPicker.cjs +1 -1
- package/dist/cjs/DatePicker/DatePicker.cjs +12 -12
- package/dist/cjs/Dropdown/Dropdown.cjs +8 -10
- package/dist/cjs/FilterGroup/FilterContent/FilterContent.cjs +1 -1
- package/dist/cjs/FormElement/Adornment/Adornment.cjs +15 -36
- package/dist/cjs/FormElement/Adornment/Adornment.styles.cjs +11 -17
- package/dist/cjs/InlineEditor/InlineEditor.cjs +10 -14
- package/dist/cjs/InlineEditor/InlineEditor.styles.cjs +13 -36
- package/dist/cjs/Input/Input.cjs +33 -56
- package/dist/cjs/Input/Input.styles.cjs +6 -19
- package/dist/cjs/List/List.cjs +12 -12
- package/dist/cjs/Pagination/Pagination.styles.cjs +2 -1
- package/dist/cjs/Pagination/Select.cjs +1 -1
- package/dist/cjs/Select/Select.styles.cjs +1 -1
- package/dist/cjs/Table/TableBody/TableBody.cjs +16 -17
- package/dist/cjs/TableSection/TableSection.styles.cjs +10 -10
- package/dist/cjs/Tag/Tag.cjs +1 -1
- package/dist/cjs/TagsInput/TagsInput.cjs +103 -169
- package/dist/cjs/TagsInput/TagsInput.styles.cjs +45 -111
- package/dist/cjs/TextArea/TextArea.cjs +1 -3
- package/dist/cjs/TextArea/TextArea.styles.cjs +1 -1
- package/dist/cjs/TimePicker/TimePicker.cjs +5 -4
- package/dist/cjs/TimePicker/Unit/Unit.cjs +0 -1
- package/dist/cjs/TimePicker/Unit/Unit.styles.cjs +0 -3
- package/dist/cjs/hooks/useFocus.cjs +38 -0
- package/dist/cjs/utils/CounterLabel.cjs +3 -2
- package/dist/cjs/utils/focusUtils.cjs +0 -4
- package/dist/esm/ActionsGeneric/ActionsGeneric.js +1 -1
- package/dist/esm/AvatarGroup/AvatarGroupContext.js +1 -1
- package/dist/esm/Banner/BannerContent/BannerContent.js +1 -1
- package/dist/esm/BaseCheckBox/BaseCheckBox.js +1 -1
- package/dist/esm/BaseDropdown/BaseDropdown.js +3 -3
- package/dist/esm/BaseInput/BaseInput.js +45 -84
- package/dist/esm/BaseInput/BaseInput.js.map +1 -1
- package/dist/esm/BaseInput/BaseInput.styles.js +68 -142
- package/dist/esm/BaseInput/BaseInput.styles.js.map +1 -1
- package/dist/esm/BaseInput/validations.js +2 -1
- package/dist/esm/BaseInput/validations.js.map +1 -1
- package/dist/esm/BaseRadio/BaseRadio.js +1 -1
- package/dist/esm/Button/Button.js +1 -1
- package/dist/esm/Calendar/CalendarHeader/CalendarHeader.js +1 -7
- package/dist/esm/Calendar/CalendarHeader/CalendarHeader.js.map +1 -1
- package/dist/esm/Calendar/CalendarHeader/CalendarHeader.styles.js +1 -5
- package/dist/esm/Calendar/CalendarHeader/CalendarHeader.styles.js.map +1 -1
- package/dist/esm/CheckBoxGroup/CheckBoxGroup.js.map +1 -1
- package/dist/esm/ColorPicker/ColorPicker.js +1 -1
- package/dist/esm/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/esm/ColorPicker/Fields/Fields.js.map +1 -1
- package/dist/esm/DatePicker/DatePicker.js.map +1 -1
- package/dist/esm/DatePicker/utils.js +1 -1
- package/dist/esm/Dialog/context.js +1 -1
- package/dist/esm/DotPagination/DotPagination.js +1 -1
- package/dist/esm/Dropdown/Dropdown.js +8 -10
- package/dist/esm/Dropdown/Dropdown.js.map +1 -1
- package/dist/esm/DropdownButton/DropdownButton.js.map +1 -1
- package/dist/esm/FilterGroup/FilterContent/FilterContent.js +1 -1
- package/dist/esm/FilterGroup/FilterContent/FilterContent.js.map +1 -1
- package/dist/esm/FilterGroup/FilterGroupContext.js +1 -1
- package/dist/esm/FilterGroup/RightPanel/RightPanel.js.map +1 -1
- package/dist/esm/Focus/Focus.js +1 -1
- package/dist/esm/FormElement/Adornment/Adornment.js +15 -36
- package/dist/esm/FormElement/Adornment/Adornment.js.map +1 -1
- package/dist/esm/FormElement/Adornment/Adornment.styles.js +11 -17
- package/dist/esm/FormElement/Adornment/Adornment.styles.js.map +1 -1
- package/dist/esm/Header/Navigation/useSelectionPath.js.map +1 -1
- package/dist/esm/InlineEditor/InlineEditor.js +10 -14
- package/dist/esm/InlineEditor/InlineEditor.js.map +1 -1
- package/dist/esm/InlineEditor/InlineEditor.styles.js +13 -36
- package/dist/esm/InlineEditor/InlineEditor.styles.js.map +1 -1
- package/dist/esm/Input/Input.js +34 -57
- package/dist/esm/Input/Input.js.map +1 -1
- package/dist/esm/Input/Input.styles.js +6 -19
- package/dist/esm/Input/Input.styles.js.map +1 -1
- package/dist/esm/List/List.js +12 -12
- package/dist/esm/List/List.js.map +1 -1
- package/dist/esm/Pagination/Pagination.styles.js +5 -4
- package/dist/esm/Pagination/Pagination.styles.js.map +1 -1
- package/dist/esm/Pagination/Select.js +1 -1
- package/dist/esm/QueryBuilder/Context.js +1 -1
- package/dist/esm/QueryBuilder/QueryBuilder.js +1 -1
- package/dist/esm/QueryBuilder/utils/index.js +1 -1
- package/dist/esm/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/esm/Select/Select.styles.js +1 -1
- package/dist/esm/Select/Select.styles.js.map +1 -1
- package/dist/esm/SelectionList/SelectionList.js.map +1 -1
- package/dist/esm/Slider/Slider.js +1 -1
- package/dist/esm/Slider/Slider.js.map +1 -1
- package/dist/esm/SnackbarProvider/SnackbarProvider.js +2 -2
- package/dist/esm/Table/TableBody/TableBody.js +16 -17
- package/dist/esm/Table/TableBody/TableBody.js.map +1 -1
- package/dist/esm/TableSection/TableSection.styles.js +24 -24
- package/dist/esm/Tag/Tag.js +1 -1
- package/dist/esm/Tag/Tag.js.map +1 -1
- package/dist/esm/TagsInput/TagsInput.js +103 -169
- package/dist/esm/TagsInput/TagsInput.js.map +1 -1
- package/dist/esm/TagsInput/TagsInput.styles.js +45 -111
- package/dist/esm/TagsInput/TagsInput.styles.js.map +1 -1
- package/dist/esm/TextArea/TextArea.js +1 -3
- package/dist/esm/TextArea/TextArea.js.map +1 -1
- package/dist/esm/TextArea/TextArea.styles.js +1 -1
- package/dist/esm/TextArea/TextArea.styles.js.map +1 -1
- package/dist/esm/TimePicker/TimePicker.js +1 -0
- package/dist/esm/TimePicker/TimePicker.js.map +1 -1
- package/dist/esm/TimePicker/Unit/Unit.js +0 -1
- package/dist/esm/TimePicker/Unit/Unit.js.map +1 -1
- package/dist/esm/TimePicker/Unit/Unit.styles.js +0 -3
- package/dist/esm/TimePicker/Unit/Unit.styles.js.map +1 -1
- package/dist/esm/TreeView/internals/TreeViewProvider.js +1 -1
- package/dist/esm/TreeView/internals/hooks/plugins/useTreeViewKeyboardNavigation.js +1 -1
- package/dist/esm/VerticalNavigation/NavigationSlider/NavigationSlider.js.map +1 -1
- package/dist/esm/hooks/useFocus.js +38 -0
- package/dist/esm/hooks/useFocus.js.map +1 -0
- package/dist/esm/hooks/useScrollTo.js.map +1 -1
- package/dist/esm/utils/CounterLabel.js +3 -2
- package/dist/esm/utils/CounterLabel.js.map +1 -1
- package/dist/esm/utils/document.js.map +1 -1
- package/dist/esm/utils/focusUtils.js +0 -4
- package/dist/esm/utils/focusUtils.js.map +1 -1
- package/dist/types/index.d.ts +213 -274
- package/package.json +8 -8
|
@@ -10,7 +10,7 @@ const TableBody_styles = require("./TableBody.styles.cjs");
|
|
|
10
10
|
const Focus = require("../../Focus/Focus.cjs");
|
|
11
11
|
const tableSectionContext = {
|
|
12
12
|
type: "body",
|
|
13
|
-
filterClassName: "
|
|
13
|
+
filterClassName: "_trgrid"
|
|
14
14
|
};
|
|
15
15
|
const defaultComponent = "tbody";
|
|
16
16
|
const HvTableBody = React.forwardRef(
|
|
@@ -36,22 +36,21 @@ const HvTableBody = React.forwardRef(
|
|
|
36
36
|
role: Component === defaultComponent ? null : "rowgroup",
|
|
37
37
|
...others,
|
|
38
38
|
children: withNavigation ? React.Children.map(children, (element) => {
|
|
39
|
-
if (React.isValidElement(element))
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
39
|
+
if (!React.isValidElement(element)) return void 0;
|
|
40
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
41
|
+
Focus.HvFocus,
|
|
42
|
+
{
|
|
43
|
+
id: `my-id-${element.key}`,
|
|
44
|
+
rootRef: bodyRef,
|
|
45
|
+
strategy: "grid",
|
|
46
|
+
filterClass: tableSectionContext.filterClassName,
|
|
47
|
+
navigationJump: 1,
|
|
48
|
+
focusDisabled: false,
|
|
49
|
+
selected: element.props.selected,
|
|
50
|
+
children: element
|
|
51
|
+
},
|
|
52
|
+
`row-${element.key}`
|
|
53
|
+
);
|
|
55
54
|
}) : children
|
|
56
55
|
}
|
|
57
56
|
) });
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const uikitReactUtils = require("@hitachivantara/uikit-react-utils");
|
|
4
4
|
const uikitStyles = require("@hitachivantara/uikit-styles");
|
|
5
|
-
const TableContainer_styles = require("../Table/TableContainer/TableContainer.styles.cjs");
|
|
6
|
-
require("../Table/TableContainer/TableContainer.cjs");
|
|
7
|
-
const TableHeader_styles = require("../Table/TableHeader/TableHeader.styles.cjs");
|
|
8
|
-
require("../Table/TableHeader/TableHeader.cjs");
|
|
9
|
-
const TableRow_styles = require("../Table/TableRow/TableRow.styles.cjs");
|
|
10
|
-
require("../Table/TableRow/TableRow.cjs");
|
|
11
|
-
const TableCell_styles = require("../Table/TableCell/TableCell.styles.cjs");
|
|
12
|
-
require("../Table/TableCell/TableCell.cjs");
|
|
13
|
-
const BulkActions_styles = require("../BulkActions/BulkActions.styles.cjs");
|
|
14
|
-
require("../BulkActions/BulkActions.cjs");
|
|
15
5
|
const Pagination_styles = require("../Pagination/Pagination.styles.cjs");
|
|
16
6
|
require("../Pagination/Pagination.cjs");
|
|
7
|
+
const BulkActions_styles = require("../BulkActions/BulkActions.styles.cjs");
|
|
8
|
+
require("../BulkActions/BulkActions.cjs");
|
|
9
|
+
const TableCell_styles = require("../Table/TableCell/TableCell.styles.cjs");
|
|
10
|
+
require("../Table/TableCell/TableCell.cjs");
|
|
11
|
+
const TableRow_styles = require("../Table/TableRow/TableRow.styles.cjs");
|
|
12
|
+
require("../Table/TableRow/TableRow.cjs");
|
|
13
|
+
const TableHeader_styles = require("../Table/TableHeader/TableHeader.styles.cjs");
|
|
14
|
+
require("../Table/TableHeader/TableHeader.cjs");
|
|
15
|
+
const TableContainer_styles = require("../Table/TableContainer/TableContainer.styles.cjs");
|
|
16
|
+
require("../Table/TableContainer/TableContainer.cjs");
|
|
17
17
|
const { staticClasses, useClasses } = uikitReactUtils.createClasses("HvTableSection", {
|
|
18
18
|
root: {},
|
|
19
19
|
header: {
|
package/dist/cjs/Tag/Tag.cjs
CHANGED
|
@@ -4,10 +4,10 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const utils = require("@mui/material/utils");
|
|
6
6
|
const uikitReactUtils = require("@hitachivantara/uikit-react-utils");
|
|
7
|
-
const uikitStyles = require("@hitachivantara/uikit-styles");
|
|
8
7
|
const validations = require("../BaseInput/validations.cjs");
|
|
9
8
|
const Suggestions = require("../FormElement/Suggestions/Suggestions.cjs");
|
|
10
9
|
const useControlled = require("../hooks/useControlled.cjs");
|
|
10
|
+
const useFocus = require("../hooks/useFocus.cjs");
|
|
11
11
|
const useIsMounted = require("../hooks/useIsMounted.cjs");
|
|
12
12
|
const useUniqueId = require("../hooks/useUniqueId.cjs");
|
|
13
13
|
const keyboardUtils = require("../utils/keyboardUtils.cjs");
|
|
@@ -18,11 +18,7 @@ const utils$1 = require("../FormElement/utils.cjs");
|
|
|
18
18
|
const FormElement = require("../FormElement/FormElement.cjs");
|
|
19
19
|
const Label = require("../FormElement/Label/Label.cjs");
|
|
20
20
|
const InfoMessage = require("../FormElement/InfoMessage/InfoMessage.cjs");
|
|
21
|
-
const ListContainer = require("../ListContainer/ListContainer.cjs");
|
|
22
|
-
const ListItem = require("../ListContainer/ListItem/ListItem.cjs");
|
|
23
21
|
const Tag = require("../Tag/Tag.cjs");
|
|
24
|
-
const BaseInput_styles = require("../BaseInput/BaseInput.styles.cjs");
|
|
25
|
-
const Input = require("../Input/Input.cjs");
|
|
26
22
|
const WarningText = require("../FormElement/WarningText/WarningText.cjs");
|
|
27
23
|
const HvTagsInput = React.forwardRef(
|
|
28
24
|
function HvTagsInput2(props, ref) {
|
|
@@ -47,10 +43,11 @@ const HvTagsInput = React.forwardRef(
|
|
|
47
43
|
onBlur,
|
|
48
44
|
onFocus,
|
|
49
45
|
placeholder,
|
|
46
|
+
endAdornment,
|
|
50
47
|
hideCounter,
|
|
51
48
|
middleCountLabel = "/",
|
|
52
49
|
maxTagsQuantity,
|
|
53
|
-
resizable
|
|
50
|
+
resizable,
|
|
54
51
|
inputProps,
|
|
55
52
|
countCharProps,
|
|
56
53
|
multiline,
|
|
@@ -64,7 +61,7 @@ const HvTagsInput = React.forwardRef(
|
|
|
64
61
|
suggestionsLoose,
|
|
65
62
|
...others
|
|
66
63
|
} = uikitReactUtils.useDefaultProps("HvTagsInput", props);
|
|
67
|
-
const { classes, cx
|
|
64
|
+
const { classes, cx } = TagsInput_styles.useClasses(classesProp);
|
|
68
65
|
const elementId = useUniqueId.useUniqueId(id);
|
|
69
66
|
const hasLabel = textAreaLabel != null;
|
|
70
67
|
const hasDescription = description != null;
|
|
@@ -77,16 +74,13 @@ const HvTagsInput = React.forwardRef(
|
|
|
77
74
|
statusMessage,
|
|
78
75
|
""
|
|
79
76
|
);
|
|
80
|
-
const [tagInput, setTagInput] = React.useState("");
|
|
81
|
-
const [tagCursorPos, setTagCursorPos] = React.useState(value.length);
|
|
82
77
|
const [stateValid, setStateValid] = React.useState(true);
|
|
83
|
-
const inputRef = React.useRef();
|
|
84
|
-
const containerRef = React.useRef();
|
|
78
|
+
const inputRef = React.useRef(null);
|
|
79
|
+
const containerRef = React.useRef(null);
|
|
85
80
|
const skipReset = React.useRef(false);
|
|
86
81
|
const blurTimeout = React.useRef();
|
|
87
|
-
const
|
|
82
|
+
const focusUtils = useFocus.useFocus({ containerRef });
|
|
88
83
|
const forkedContainerRef = utils.useForkRef(ref, containerRef);
|
|
89
|
-
const isTagSelected = tagCursorPos >= 0 && tagCursorPos < value.length;
|
|
90
84
|
const hasCounter = maxTagsQuantity != null && !hideCounter;
|
|
91
85
|
const [suggestionValues, setSuggestionValues] = React.useState(null);
|
|
92
86
|
const isStateInvalid = React.useMemo(() => {
|
|
@@ -118,59 +112,46 @@ const HvTagsInput = React.forwardRef(
|
|
|
118
112
|
]
|
|
119
113
|
);
|
|
120
114
|
const deleteTag = React.useCallback(
|
|
121
|
-
(tagPos, event,
|
|
115
|
+
(tagPos, event, refocus = false) => {
|
|
122
116
|
const newTagsArr = [
|
|
123
117
|
...value.slice(0, tagPos),
|
|
124
118
|
...value.slice(tagPos + 1)
|
|
125
119
|
];
|
|
126
120
|
setValue(newTagsArr);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
inputRef.current?.focus();
|
|
121
|
+
if (refocus) {
|
|
122
|
+
setTimeout(() => focusUtils.focusChild(tagPos), 10);
|
|
123
|
+
}
|
|
131
124
|
performValidation(newTagsArr);
|
|
132
125
|
onDelete?.(event, value[tagPos], tagPos);
|
|
133
126
|
onChange?.(event, newTagsArr);
|
|
134
127
|
skipReset.current = true;
|
|
135
128
|
},
|
|
136
|
-
[onChange, onDelete, performValidation, setValue,
|
|
129
|
+
[focusUtils, onChange, onDelete, performValidation, setValue, value]
|
|
137
130
|
);
|
|
138
131
|
const addTag = React.useCallback(
|
|
139
|
-
(event,
|
|
132
|
+
(event, tagInput) => {
|
|
140
133
|
event.preventDefault();
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
134
|
+
const tag = tagInput ?? inputRef.current?.value ?? "";
|
|
135
|
+
if (tag === "") return;
|
|
136
|
+
const newTag = { label: tag, type: "semantic" };
|
|
137
|
+
const newTagsArr = [...value, newTag];
|
|
138
|
+
setValue(newTagsArr);
|
|
139
|
+
performValidation(newTagsArr);
|
|
140
|
+
onAdd?.(event, newTag, newTagsArr.length - 1);
|
|
141
|
+
onChange?.(event, newTagsArr);
|
|
142
|
+
inputRef.current.value = "";
|
|
149
143
|
},
|
|
150
144
|
[onAdd, onChange, performValidation, setValue, value]
|
|
151
145
|
);
|
|
152
146
|
const canShowError = status !== void 0 && status === "invalid" && statusMessage !== void 0 || !stateValid;
|
|
153
147
|
React.useEffect(() => {
|
|
154
|
-
if (!
|
|
155
|
-
|
|
156
|
-
setTimeout(() => {
|
|
157
|
-
const container = containerRef.current;
|
|
158
|
-
if (container == null) return;
|
|
159
|
-
container.scrollLeft = element ? element.offsetLeft - container.getBoundingClientRect().width / 2 + element.getBoundingClientRect().width / 2 : 0;
|
|
160
|
-
}, 10);
|
|
161
|
-
element?.focus();
|
|
162
|
-
}
|
|
163
|
-
}, [multiline, tagCursorPos]);
|
|
164
|
-
React.useEffect(() => {
|
|
165
|
-
if (!skipReset.current) {
|
|
166
|
-
setTagInput("");
|
|
167
|
-
setTagCursorPos(value.length);
|
|
168
|
-
}
|
|
148
|
+
if (skipReset.current || !inputRef.current) return;
|
|
149
|
+
inputRef.current.value = "";
|
|
169
150
|
skipReset.current = false;
|
|
170
151
|
}, [value]);
|
|
171
152
|
const isMounted = useIsMounted.useIsMounted();
|
|
172
153
|
const focusInput = () => {
|
|
173
|
-
|
|
154
|
+
inputRef.current?.focus();
|
|
174
155
|
};
|
|
175
156
|
const getSuggestions = React.useCallback(
|
|
176
157
|
(li) => {
|
|
@@ -198,8 +179,7 @@ const HvTagsInput = React.forwardRef(
|
|
|
198
179
|
[suggestionClearHandler, suggestionListCallback]
|
|
199
180
|
);
|
|
200
181
|
const suggestionSelectedHandler = (event, item) => {
|
|
201
|
-
addTag(event, item.value || item.label);
|
|
202
|
-
setTagInput(item.value || item.label);
|
|
182
|
+
addTag(event, item.value || String(item.label));
|
|
203
183
|
focusInput();
|
|
204
184
|
suggestionClearHandler();
|
|
205
185
|
};
|
|
@@ -212,10 +192,9 @@ const HvTagsInput = React.forwardRef(
|
|
|
212
192
|
}
|
|
213
193
|
};
|
|
214
194
|
const onChangeHandler = React.useCallback(
|
|
215
|
-
(event
|
|
216
|
-
setTagInput(input);
|
|
195
|
+
(event) => {
|
|
217
196
|
if (canShowSuggestions) {
|
|
218
|
-
suggestionHandler(
|
|
197
|
+
suggestionHandler(event.target.value);
|
|
219
198
|
}
|
|
220
199
|
},
|
|
221
200
|
[canShowSuggestions, suggestionHandler]
|
|
@@ -223,63 +202,63 @@ const HvTagsInput = React.forwardRef(
|
|
|
223
202
|
const onInputKeyDownHandler = React.useCallback(
|
|
224
203
|
(event) => {
|
|
225
204
|
if (!canShowSuggestions && commitTagOn.includes(event.code)) {
|
|
226
|
-
addTag(event
|
|
205
|
+
addTag(event);
|
|
227
206
|
}
|
|
228
207
|
},
|
|
229
|
-
[addTag, canShowSuggestions, commitTagOn
|
|
208
|
+
[addTag, canShowSuggestions, commitTagOn]
|
|
230
209
|
);
|
|
231
210
|
const onKeyDownHandler = React.useCallback(
|
|
232
211
|
(event) => {
|
|
212
|
+
const tagInput = inputRef.current?.value || "";
|
|
233
213
|
if (tagInput === "") {
|
|
234
214
|
switch (event.code) {
|
|
235
215
|
case "ArrowLeft":
|
|
236
|
-
|
|
237
|
-
|
|
216
|
+
focusUtils.focusPrevious();
|
|
217
|
+
return;
|
|
238
218
|
case "ArrowRight":
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
219
|
+
focusUtils.focusNext();
|
|
220
|
+
return;
|
|
221
|
+
case "End":
|
|
222
|
+
focusUtils.focusLast();
|
|
223
|
+
return;
|
|
224
|
+
case "Home":
|
|
225
|
+
focusUtils.focusFirst();
|
|
226
|
+
return;
|
|
243
227
|
case "Backspace":
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
setTagCursorPos(value.length - 1);
|
|
248
|
-
}
|
|
249
|
-
break;
|
|
250
|
-
case "Delete":
|
|
251
|
-
if (isTagSelected) {
|
|
252
|
-
deleteTag(tagCursorPos, event, false);
|
|
228
|
+
case "Delete": {
|
|
229
|
+
if (document.activeElement === inputRef.current) {
|
|
230
|
+
deleteTag(value.length - 1, event);
|
|
253
231
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
case "ArrowDown":
|
|
259
|
-
getSuggestions(0)?.focus();
|
|
260
|
-
break;
|
|
261
|
-
case "Enter":
|
|
262
|
-
if (canShowSuggestions && suggestionsLoose && (suggestionValidation?.(tagInput) || !suggestionValidation)) {
|
|
263
|
-
addTag(event, tagInput);
|
|
264
|
-
setTagInput(tagInput);
|
|
265
|
-
focusInput();
|
|
266
|
-
suggestionClearHandler();
|
|
267
|
-
}
|
|
268
|
-
break;
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
default:
|
|
235
|
+
return;
|
|
269
236
|
}
|
|
270
237
|
}
|
|
238
|
+
switch (event.code) {
|
|
239
|
+
case "ArrowDown":
|
|
240
|
+
getSuggestions(0)?.focus();
|
|
241
|
+
return;
|
|
242
|
+
case "Enter":
|
|
243
|
+
if (canShowSuggestions && suggestionsLoose && (suggestionValidation?.(tagInput) || !suggestionValidation)) {
|
|
244
|
+
addTag(event);
|
|
245
|
+
focusInput();
|
|
246
|
+
suggestionClearHandler();
|
|
247
|
+
}
|
|
248
|
+
return;
|
|
249
|
+
default:
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
271
252
|
},
|
|
272
253
|
[
|
|
273
254
|
addTag,
|
|
274
255
|
canShowSuggestions,
|
|
275
256
|
deleteTag,
|
|
257
|
+
focusUtils,
|
|
276
258
|
getSuggestions,
|
|
277
|
-
isTagSelected,
|
|
278
259
|
suggestionClearHandler,
|
|
279
260
|
suggestionValidation,
|
|
280
261
|
suggestionsLoose,
|
|
281
|
-
tagCursorPos,
|
|
282
|
-
tagInput,
|
|
283
262
|
value.length
|
|
284
263
|
]
|
|
285
264
|
);
|
|
@@ -293,19 +272,18 @@ const HvTagsInput = React.forwardRef(
|
|
|
293
272
|
const onContainerClickHandler = React.useCallback(() => {
|
|
294
273
|
inputRef.current?.focus();
|
|
295
274
|
clearTimeout(blurTimeout.current);
|
|
296
|
-
|
|
297
|
-
}, [value.length]);
|
|
275
|
+
}, []);
|
|
298
276
|
const onBlurHandler = (evt) => {
|
|
299
277
|
blurTimeout.current = setTimeout(() => {
|
|
300
278
|
if (commitOnBlur) {
|
|
301
|
-
addTag(evt
|
|
279
|
+
addTag(evt);
|
|
302
280
|
}
|
|
303
|
-
onBlur?.(evt,
|
|
281
|
+
onBlur?.(evt, inputRef.current?.value || "");
|
|
304
282
|
}, 10);
|
|
305
283
|
};
|
|
306
284
|
const onFocusHandler = (evt) => {
|
|
307
285
|
clearTimeout(blurTimeout.current);
|
|
308
|
-
onFocus?.(evt,
|
|
286
|
+
onFocus?.(evt, inputRef.current?.value || "");
|
|
309
287
|
};
|
|
310
288
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
311
289
|
FormElement.HvFormElement,
|
|
@@ -320,7 +298,10 @@ const HvTagsInput = React.forwardRef(
|
|
|
320
298
|
onFocus: onFocusHandler,
|
|
321
299
|
className: cx(
|
|
322
300
|
classes.root,
|
|
323
|
-
{
|
|
301
|
+
{
|
|
302
|
+
[classes.disabled]: disabled,
|
|
303
|
+
[classes.readOnly]: readOnly
|
|
304
|
+
},
|
|
324
305
|
className
|
|
325
306
|
),
|
|
326
307
|
children: [
|
|
@@ -356,8 +337,9 @@ const HvTagsInput = React.forwardRef(
|
|
|
356
337
|
}
|
|
357
338
|
),
|
|
358
339
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
359
|
-
|
|
340
|
+
"div",
|
|
360
341
|
{
|
|
342
|
+
ref: forkedContainerRef,
|
|
361
343
|
className: cx(classes.tagsList, {
|
|
362
344
|
[classes.error]: canShowError,
|
|
363
345
|
[classes.resizable]: resizable && multiline,
|
|
@@ -366,96 +348,48 @@ const HvTagsInput = React.forwardRef(
|
|
|
366
348
|
}),
|
|
367
349
|
onKeyDown: onKeyDownHandler,
|
|
368
350
|
onClick: onContainerClickHandler,
|
|
369
|
-
ref: forkedContainerRef,
|
|
370
351
|
children: [
|
|
371
352
|
value?.map((t, i) => {
|
|
372
|
-
const tag = typeof t === "string" ? {
|
|
373
|
-
label: t,
|
|
374
|
-
type: "semantic"
|
|
375
|
-
} : t;
|
|
353
|
+
const tag = typeof t === "string" ? { label: t, type: "semantic" } : t;
|
|
376
354
|
const { label, type, ...otherProps } = tag;
|
|
377
355
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
378
|
-
|
|
356
|
+
Tag.HvTag,
|
|
379
357
|
{
|
|
358
|
+
type,
|
|
359
|
+
label,
|
|
360
|
+
disabled,
|
|
380
361
|
tabIndex: -1,
|
|
381
|
-
className: cx(
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
root: classes.listItemRoot
|
|
362
|
+
className: cx(classes.chipRoot, classes.listItemRoot),
|
|
363
|
+
...!(readOnly || disabled || type === "categorical") && {
|
|
364
|
+
onDelete: (event) => onDeleteTagHandler(event, i)
|
|
385
365
|
},
|
|
386
|
-
|
|
387
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
388
|
-
Tag.HvTag,
|
|
389
|
-
{
|
|
390
|
-
label,
|
|
391
|
-
className: cx(classes.chipRoot, {
|
|
392
|
-
[classes.tagSelected]: i === tagCursorPos
|
|
393
|
-
}),
|
|
394
|
-
type,
|
|
395
|
-
...!(readOnly || disabled || type === "categorical") && {
|
|
396
|
-
onDelete: (event) => onDeleteTagHandler(event, i)
|
|
397
|
-
},
|
|
398
|
-
deleteButtonProps: {
|
|
399
|
-
tabIndex: -1
|
|
400
|
-
},
|
|
401
|
-
...otherProps
|
|
402
|
-
}
|
|
403
|
-
)
|
|
366
|
+
...otherProps
|
|
404
367
|
},
|
|
405
|
-
`${
|
|
368
|
+
`${label}-${i}`
|
|
406
369
|
);
|
|
407
370
|
}),
|
|
408
|
-
!
|
|
409
|
-
|
|
371
|
+
!disabled && !readOnly && /* @__PURE__ */ jsxRuntime.jsx(
|
|
372
|
+
"input",
|
|
410
373
|
{
|
|
374
|
+
id: setId.setId(elementId, "input"),
|
|
375
|
+
onChange: onChangeHandler,
|
|
376
|
+
autoComplete: "off",
|
|
377
|
+
onKeyDown: onInputKeyDownHandler,
|
|
378
|
+
placeholder: value.length === 0 ? placeholder : "",
|
|
411
379
|
className: cx(
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
},
|
|
416
|
-
!!isTagSelected && css({
|
|
417
|
-
[`& .${BaseInput_styles.staticClasses.inputRoot}`]: {
|
|
418
|
-
backgroundColor: uikitStyles.theme.colors.atmo1
|
|
419
|
-
}
|
|
420
|
-
})
|
|
380
|
+
classes.tagInputContainerRoot,
|
|
381
|
+
classes.tagInputRoot,
|
|
382
|
+
classes.input
|
|
421
383
|
),
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
Input.HvInput,
|
|
429
|
-
{
|
|
430
|
-
value: tagInput,
|
|
431
|
-
disableClear: true,
|
|
432
|
-
onChange: onChangeHandler,
|
|
433
|
-
onKeyDown: onInputKeyDownHandler,
|
|
434
|
-
placeholder: value.length === 0 ? placeholder : "",
|
|
435
|
-
className: cx({
|
|
436
|
-
[classes.singleLine]: !multiline
|
|
437
|
-
}),
|
|
438
|
-
classes: {
|
|
439
|
-
root: classes.tagInputRoot,
|
|
440
|
-
input: classes.input,
|
|
441
|
-
inputBorderContainer: classes.tagInputBorderContainer,
|
|
442
|
-
inputRootFocused: classes.tagInputRootFocused
|
|
443
|
-
},
|
|
444
|
-
disabled,
|
|
445
|
-
readOnly: readOnly || isTagSelected,
|
|
446
|
-
inputProps: {
|
|
447
|
-
ref: materialInputRef,
|
|
448
|
-
"aria-label": ariaLabel,
|
|
449
|
-
"aria-labelledby": ariaLabelledBy,
|
|
450
|
-
"aria-describedby": ariaDescribedBy != null ? ariaDescribedBy : description && setId.setId(elementId, "description") || void 0,
|
|
451
|
-
...inputProps
|
|
452
|
-
},
|
|
453
|
-
ref: inputRef,
|
|
454
|
-
...others
|
|
455
|
-
}
|
|
456
|
-
)
|
|
384
|
+
ref: inputRef,
|
|
385
|
+
"aria-label": ariaLabel,
|
|
386
|
+
"aria-labelledby": ariaLabelledBy,
|
|
387
|
+
"aria-describedby": ariaDescribedBy ?? (description ? setId.setId(elementId, "description") : void 0),
|
|
388
|
+
...inputProps,
|
|
389
|
+
...others
|
|
457
390
|
}
|
|
458
|
-
)
|
|
391
|
+
),
|
|
392
|
+
!disabled && !readOnly && endAdornment
|
|
459
393
|
]
|
|
460
394
|
}
|
|
461
395
|
),
|
|
@@ -469,8 +403,8 @@ const HvTagsInput = React.forwardRef(
|
|
|
469
403
|
root: classes.suggestionsContainer,
|
|
470
404
|
list: classes.suggestionList
|
|
471
405
|
},
|
|
472
|
-
|
|
473
|
-
anchorEl: containerRef?.current
|
|
406
|
+
open: hasSuggestions,
|
|
407
|
+
anchorEl: containerRef?.current,
|
|
474
408
|
onClose: suggestionClearHandler,
|
|
475
409
|
onKeyDown: onSuggestionKeyDown,
|
|
476
410
|
onSuggestionSelected: suggestionSelectedHandler,
|