@hitachivantara/uikit-react-core 5.75.0 → 5.77.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.
Files changed (32) hide show
  1. package/dist/cjs/Dropdown/Dropdown.cjs +271 -276
  2. package/dist/cjs/Forms/Suggestions/Suggestions.cjs +13 -2
  3. package/dist/cjs/Forms/Suggestions/Suggestions.styles.cjs +7 -4
  4. package/dist/cjs/InlineEditor/InlineEditor.cjs +4 -2
  5. package/dist/cjs/Input/Input.cjs +25 -6
  6. package/dist/cjs/QueryBuilder/Rule/Attribute/Attribute.cjs +1 -1
  7. package/dist/cjs/QueryBuilder/Rule/Operator/Operator.cjs +1 -1
  8. package/dist/cjs/QueryBuilder/Rule/Value/BooleanValue/BooleanValue.cjs +1 -1
  9. package/dist/cjs/Table/renderers/DropdownColumnCell/DropdownColumnCell.cjs +3 -17
  10. package/dist/cjs/Table/renderers/renderers.cjs +2 -5
  11. package/dist/esm/Dropdown/Dropdown.js +272 -277
  12. package/dist/esm/Dropdown/Dropdown.js.map +1 -1
  13. package/dist/esm/Forms/Suggestions/Suggestions.js +13 -2
  14. package/dist/esm/Forms/Suggestions/Suggestions.js.map +1 -1
  15. package/dist/esm/Forms/Suggestions/Suggestions.styles.js +7 -4
  16. package/dist/esm/Forms/Suggestions/Suggestions.styles.js.map +1 -1
  17. package/dist/esm/InlineEditor/InlineEditor.js +4 -2
  18. package/dist/esm/InlineEditor/InlineEditor.js.map +1 -1
  19. package/dist/esm/Input/Input.js +25 -6
  20. package/dist/esm/Input/Input.js.map +1 -1
  21. package/dist/esm/QueryBuilder/Rule/Attribute/Attribute.js +1 -1
  22. package/dist/esm/QueryBuilder/Rule/Attribute/Attribute.js.map +1 -1
  23. package/dist/esm/QueryBuilder/Rule/Operator/Operator.js +1 -1
  24. package/dist/esm/QueryBuilder/Rule/Operator/Operator.js.map +1 -1
  25. package/dist/esm/QueryBuilder/Rule/Value/BooleanValue/BooleanValue.js +1 -1
  26. package/dist/esm/QueryBuilder/Rule/Value/BooleanValue/BooleanValue.js.map +1 -1
  27. package/dist/esm/Table/renderers/DropdownColumnCell/DropdownColumnCell.js +3 -17
  28. package/dist/esm/Table/renderers/DropdownColumnCell/DropdownColumnCell.js.map +1 -1
  29. package/dist/esm/Table/renderers/renderers.js +2 -5
  30. package/dist/esm/Table/renderers/renderers.js.map +1 -1
  31. package/dist/types/index.d.ts +39 -21
  32. package/package.json +2 -2
@@ -7,6 +7,7 @@ const uikitReactUtils = require("@hitachivantara/uikit-react-utils");
7
7
  const useControlled = require("../hooks/useControlled.cjs");
8
8
  const useLabels = require("../hooks/useLabels.cjs");
9
9
  const useUniqueId = require("../hooks/useUniqueId.cjs");
10
+ const generic = require("../types/generic.cjs");
10
11
  const setId = require("../utils/setId.cjs");
11
12
  const Dropdown_styles = require("./Dropdown.styles.cjs");
12
13
  const utils = require("./utils.cjs");
@@ -32,297 +33,291 @@ const DEFAULT_LABELS = {
32
33
  /** The label used in search. */
33
34
  multiSelectionConjunction: "/"
34
35
  };
35
- const HvDropdown = React.forwardRef(
36
- (props, ref) => {
37
- const {
38
- classes: classesProp,
39
- className,
40
- id,
41
- name,
42
- required = false,
43
- disabled = false,
44
- readOnly = false,
45
- label,
46
- "aria-label": ariaLabel,
47
- "aria-labelledby": ariaLabelledBy,
48
- description,
49
- "aria-describedby": ariaDescribedBy,
50
- placeholder = "Select...",
51
- onChange,
52
- status,
53
- statusMessage,
54
- "aria-errormessage": ariaErrorMessage,
55
- onCancel,
56
- onToggle,
57
- onClickOutside,
58
- onFocus,
59
- onBlur,
60
- values,
61
- multiSelect = false,
62
- showSearch = false,
63
- expanded,
64
- defaultExpanded = false,
65
- notifyChangesOnFirstRender = false,
66
- labels: labelsProp,
67
- hasTooltips = false,
68
- disablePortal = false,
69
- singleSelectionToggle = true,
70
- placement,
71
- variableWidth = false,
72
- popperProps = {},
73
- height,
74
- maxHeight,
75
- virtualized = false,
76
- baseDropdownProps = {},
77
- listProps = {},
78
- ...others
79
- } = uikitReactUtils.useDefaultProps("HvDropdown", props);
80
- const { classes, cx } = Dropdown_styles.useClasses(classesProp);
81
- const labels = useLabels.useLabels(DEFAULT_LABELS, labelsProp);
82
- const elementId = useUniqueId.useUniqueId(id);
83
- const [validationState, setValidationState] = useControlled.useControlled(
84
- status,
85
- "standBy"
86
- );
87
- const [validationMessage] = useControlled.useControlled(statusMessage, "Required");
88
- const [isOpen, setIsOpen] = useControlled.useControlled(
89
- expanded,
90
- Boolean(defaultExpanded)
91
- );
92
- const [selectionLabel, setSelectionLabel] = React.useState(
36
+ const HvDropdown = generic.fixedForwardRef(function HvDropdown2(props, ref) {
37
+ const {
38
+ classes: classesProp,
39
+ className,
40
+ id,
41
+ name,
42
+ required = false,
43
+ disabled = false,
44
+ readOnly = false,
45
+ label,
46
+ "aria-label": ariaLabel,
47
+ "aria-labelledby": ariaLabelledBy,
48
+ description,
49
+ "aria-describedby": ariaDescribedBy,
50
+ placeholder = "Select...",
51
+ onChange,
52
+ status,
53
+ statusMessage,
54
+ "aria-errormessage": ariaErrorMessage,
55
+ onCancel,
56
+ onToggle,
57
+ onClickOutside,
58
+ onFocus,
59
+ onBlur,
60
+ values,
61
+ multiSelect = false,
62
+ showSearch,
63
+ expanded,
64
+ defaultExpanded,
65
+ notifyChangesOnFirstRender,
66
+ labels: labelsProp,
67
+ hasTooltips,
68
+ disablePortal,
69
+ singleSelectionToggle = true,
70
+ placement,
71
+ variableWidth,
72
+ popperProps = {},
73
+ height,
74
+ maxHeight,
75
+ virtualized,
76
+ baseDropdownProps = {},
77
+ listProps = {},
78
+ ...others
79
+ } = uikitReactUtils.useDefaultProps("HvDropdown", props);
80
+ const { classes, cx } = Dropdown_styles.useClasses(classesProp);
81
+ const labels = useLabels.useLabels(DEFAULT_LABELS, labelsProp);
82
+ const elementId = useUniqueId.useUniqueId(id);
83
+ const [validationState, setValidationState] = useControlled.useControlled(
84
+ status,
85
+ "standBy"
86
+ );
87
+ const [validationMessage] = useControlled.useControlled(statusMessage, "Required");
88
+ const [isOpen, setIsOpen] = useControlled.useControlled(expanded, Boolean(defaultExpanded));
89
+ const [selectionLabel, setSelectionLabel] = React.useState(
90
+ utils.getSelectionLabel(labels, placeholder, multiSelect, values)
91
+ );
92
+ const [internalValues, setInternalValues] = React.useState(values);
93
+ const internalValuesRef = React.useRef(values);
94
+ React.useEffect(() => {
95
+ setInternalValues(values);
96
+ internalValuesRef.current = values;
97
+ }, [values]);
98
+ React.useEffect(() => {
99
+ setSelectionLabel(
93
100
  utils.getSelectionLabel(labels, placeholder, multiSelect, values)
94
101
  );
95
- const [internalValues, setInternalValues] = React.useState(values);
96
- const internalValuesRef = React.useRef(values);
97
- React.useEffect(() => {
98
- setInternalValues(values);
99
- internalValuesRef.current = values;
100
- }, [values]);
101
- React.useEffect(() => {
102
- setSelectionLabel(
103
- utils.getSelectionLabel(labels, placeholder, multiSelect, values)
104
- );
105
- }, [labels, multiSelect, placeholder, values]);
106
- const dropdownHeaderRef = React.useRef();
107
- const {
108
- ref: refProp,
109
- dropdownHeaderRef: dropdownHeaderRefProp,
110
- ...otherBaseDropdownProps
111
- } = baseDropdownProps;
112
- const headerForkedRef = utils$1.useForkRef(
113
- dropdownHeaderRefProp,
114
- dropdownHeaderRef
115
- );
116
- const dropdownForkedRef = utils$1.useForkRef(ref, refProp);
117
- const handleToggle = (event, open) => {
118
- onToggle?.(event, open);
119
- setIsOpen(open);
120
- if (!open) {
121
- setValidationState(() => {
122
- if (required) {
123
- const hasSelection = utils.getSelected(internalValuesRef.current).length > 0;
124
- if (!hasSelection) {
125
- return "invalid";
126
- }
127
- }
128
- return "valid";
129
- });
130
- }
131
- };
132
- const handleSelection = (listValues, commitChanges, toggle, notifyChanges = true) => {
133
- const selected = utils.getSelected(listValues);
134
- if (commitChanges) {
135
- setInternalValues(listValues);
136
- internalValuesRef.current = listValues;
137
- setSelectionLabel(
138
- utils.getSelectionLabel(labels, placeholder, multiSelect, listValues)
139
- );
140
- setValidationState(() => {
141
- if (required && selected.length === 0) {
102
+ }, [labels, multiSelect, placeholder, values]);
103
+ const dropdownHeaderRef = React.useRef();
104
+ const {
105
+ ref: refProp,
106
+ dropdownHeaderRef: dropdownHeaderRefProp,
107
+ ...otherBaseDropdownProps
108
+ } = baseDropdownProps;
109
+ const headerForkedRef = utils$1.useForkRef(dropdownHeaderRefProp, dropdownHeaderRef);
110
+ const dropdownForkedRef = utils$1.useForkRef(ref, refProp);
111
+ const handleToggle = (event, open) => {
112
+ onToggle?.(event, open);
113
+ setIsOpen(open);
114
+ if (!open) {
115
+ setValidationState(() => {
116
+ if (required) {
117
+ const hasSelection = utils.getSelected(internalValuesRef.current).length > 0;
118
+ if (!hasSelection) {
142
119
  return "invalid";
143
120
  }
144
- return "valid";
145
- });
146
- }
147
- if (notifyChanges) onChange?.(multiSelect ? selected : selected[0]);
148
- if (toggle) {
149
- handleToggle(void 0, false);
150
- dropdownHeaderRef.current?.focus({ preventScroll: true });
151
- }
152
- };
153
- const handleCancel = (evt) => {
154
- onCancel?.(evt);
155
- handleToggle(evt, false);
156
- dropdownHeaderRef.current?.focus({ preventScroll: true });
157
- };
158
- const handleClickOutside = (evt) => {
159
- onClickOutside?.(evt);
160
- onCancel?.(evt);
161
- };
162
- const setFocusToContent = (containerRef) => {
163
- const inputs = containerRef?.getElementsByTagName("input");
164
- if (inputs && inputs.length > 0) {
165
- inputs[0].focus();
166
- return;
167
- }
168
- const listItems = containerRef != null ? [...containerRef.getElementsByTagName("li")] : [];
169
- listItems.every((listItem) => {
170
- if (listItem.tabIndex >= 0) {
171
- listItem.focus();
172
- return false;
173
121
  }
174
- return true;
122
+ return "valid";
175
123
  });
176
- };
177
- const buildHeaderLabel = () => {
178
- const hasSelection = utils.getSelected(internalValues).length > 0;
179
- return labels?.select || !multiSelect ? /* @__PURE__ */ jsxRuntime.jsx(
180
- Typography.HvTypography,
181
- {
182
- component: "div",
183
- variant: "body",
184
- className: cx(classes.placeholder, {
185
- [classes.selectionDisabled]: disabled,
186
- [classes.placeholderClosed]: !(isOpen || hasSelection)
187
- }),
188
- children: selectionLabel.selected
189
- }
190
- ) : /* @__PURE__ */ jsxRuntime.jsxs(
191
- Typography.HvTypography,
192
- {
193
- component: "div",
194
- className: cx(classes.placeholder, {
195
- [classes.selectionDisabled]: disabled
196
- }),
197
- variant: "body",
198
- children: [
199
- /* @__PURE__ */ jsxRuntime.jsx("b", { children: selectionLabel.selected }),
200
- ` ${labels?.multiSelectionConjunction} ${selectionLabel.total}`
201
- ]
202
- }
124
+ }
125
+ };
126
+ const handleSelection = (listValues, commitChanges, toggle, notifyChanges = true) => {
127
+ const selected = utils.getSelected(listValues);
128
+ if (commitChanges) {
129
+ setInternalValues(listValues);
130
+ internalValuesRef.current = listValues;
131
+ setSelectionLabel(
132
+ utils.getSelectionLabel(labels, placeholder, multiSelect, listValues)
203
133
  );
204
- };
205
- const hasLabel = label != null;
206
- const hasDescription = description != null;
207
- const canShowError = ariaErrorMessage == null && (status !== void 0 && statusMessage !== void 0 || status === void 0 && required);
208
- const isStateInvalid = validationStates.isInvalid(validationState);
209
- let errorMessageId;
210
- if (isStateInvalid) {
211
- errorMessageId = canShowError ? setId.setId(elementId, "error") : ariaErrorMessage;
134
+ setValidationState(() => {
135
+ if (required && selected.length === 0) {
136
+ return "invalid";
137
+ }
138
+ return "valid";
139
+ });
140
+ }
141
+ if (notifyChanges) {
142
+ onChange?.(multiSelect ? selected : selected[0]);
143
+ }
144
+ if (toggle) {
145
+ handleToggle(void 0, false);
146
+ dropdownHeaderRef.current?.focus({ preventScroll: true });
212
147
  }
213
- return /* @__PURE__ */ jsxRuntime.jsxs(
214
- FormElement.HvFormElement,
148
+ };
149
+ const handleCancel = (evt) => {
150
+ onCancel?.(evt);
151
+ handleToggle(evt, false);
152
+ dropdownHeaderRef.current?.focus({ preventScroll: true });
153
+ };
154
+ const handleClickOutside = (evt) => {
155
+ onClickOutside?.(evt);
156
+ onCancel?.(evt);
157
+ };
158
+ const setFocusToContent = (containerRef) => {
159
+ const inputs = containerRef?.getElementsByTagName("input");
160
+ if (inputs && inputs.length > 0) {
161
+ inputs[0].focus();
162
+ return;
163
+ }
164
+ const listItems = containerRef != null ? [...containerRef.getElementsByTagName("li")] : [];
165
+ listItems.every((listItem) => {
166
+ if (listItem.tabIndex >= 0) {
167
+ listItem.focus();
168
+ return false;
169
+ }
170
+ return true;
171
+ });
172
+ };
173
+ const buildHeaderLabel = () => {
174
+ const hasSelection = utils.getSelected(internalValues).length > 0;
175
+ return labels?.select || !multiSelect ? /* @__PURE__ */ jsxRuntime.jsx(
176
+ Typography.HvTypography,
215
177
  {
216
- id,
217
- name,
218
- status: validationState,
219
- disabled,
220
- readOnly,
221
- required,
222
- className: cx(
223
- classes.root,
224
- {
225
- [classes.disabled]: disabled
226
- },
227
- className
228
- ),
229
- ...others,
178
+ component: "div",
179
+ variant: "body",
180
+ className: cx(classes.placeholder, {
181
+ [classes.selectionDisabled]: disabled,
182
+ [classes.placeholderClosed]: !(isOpen || hasSelection)
183
+ }),
184
+ children: selectionLabel.selected
185
+ }
186
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(
187
+ Typography.HvTypography,
188
+ {
189
+ component: "div",
190
+ className: cx(classes.placeholder, {
191
+ [classes.selectionDisabled]: disabled
192
+ }),
193
+ variant: "body",
230
194
  children: [
231
- (hasLabel || hasDescription) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes.labelContainer, children: [
232
- hasLabel && /* @__PURE__ */ jsxRuntime.jsx(
233
- Label.HvLabel,
234
- {
235
- id: setId.setId(elementId, "label"),
236
- label,
237
- className: classes.label
238
- }
239
- ),
240
- hasDescription && /* @__PURE__ */ jsxRuntime.jsx(
241
- InfoMessage.HvInfoMessage,
242
- {
243
- id: setId.setId(elementId, "description"),
244
- className: classes.description,
245
- children: description
246
- }
247
- )
248
- ] }),
249
- /* @__PURE__ */ jsxRuntime.jsx(
250
- BaseDropdown.HvBaseDropdown,
195
+ /* @__PURE__ */ jsxRuntime.jsx("b", { children: selectionLabel.selected }),
196
+ ` ${labels?.multiSelectionConjunction} ${selectionLabel.total}`
197
+ ]
198
+ }
199
+ );
200
+ };
201
+ const hasLabel = label != null;
202
+ const hasDescription = description != null;
203
+ const canShowError = ariaErrorMessage == null && (status !== void 0 && statusMessage !== void 0 || status === void 0 && required);
204
+ const isStateInvalid = validationStates.isInvalid(validationState);
205
+ let errorMessageId;
206
+ if (isStateInvalid) {
207
+ errorMessageId = canShowError ? setId.setId(elementId, "error") : ariaErrorMessage;
208
+ }
209
+ return /* @__PURE__ */ jsxRuntime.jsxs(
210
+ FormElement.HvFormElement,
211
+ {
212
+ id,
213
+ name,
214
+ status: validationState,
215
+ disabled,
216
+ readOnly,
217
+ required,
218
+ className: cx(
219
+ classes.root,
220
+ {
221
+ [classes.disabled]: disabled
222
+ },
223
+ className
224
+ ),
225
+ ...others,
226
+ children: [
227
+ (hasLabel || hasDescription) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes.labelContainer, children: [
228
+ hasLabel && /* @__PURE__ */ jsxRuntime.jsx(
229
+ Label.HvLabel,
251
230
  {
252
- ref: dropdownForkedRef,
253
- id: setId.setId(id, "dropdown"),
254
- classes: {
255
- root: cx(classes.dropdown, {
256
- [classes.readOnly]: readOnly
257
- }),
258
- arrow: classes.arrow,
259
- header: cx(classes.dropdownHeader, {
260
- [classes.dropdownHeaderInvalid]: isStateInvalid
261
- }),
262
- headerOpen: classes.dropdownHeaderOpen
263
- },
264
- expanded: isOpen,
265
- disabled,
266
- readOnly,
267
- required,
268
- disablePortal,
269
- placement,
270
- popperProps,
271
- placeholder: buildHeaderLabel(),
272
- onToggle: handleToggle,
273
- onClickOutside: handleClickOutside,
274
- onContainerCreation: setFocusToContent,
275
- role: "combobox",
276
- variableWidth,
277
- "aria-label": ariaLabel,
278
- "aria-labelledby": [label && setId.setId(elementId, "label"), ariaLabelledBy].join(" ").trim() || void 0,
279
- "aria-invalid": isStateInvalid ? true : void 0,
280
- "aria-errormessage": errorMessageId,
281
- "aria-describedby": [description && setId.setId(elementId, "description"), ariaDescribedBy].join(" ").trim() || void 0,
282
- onFocus,
283
- onBlur,
284
- dropdownHeaderRef: headerForkedRef,
285
- ...otherBaseDropdownProps,
286
- children: /* @__PURE__ */ jsxRuntime.jsx(
287
- List.HvDropdownList,
288
- {
289
- id: setId.setId(elementId, "values"),
290
- classes: {
291
- rootList: classes.rootList,
292
- dropdownListContainer: classes.dropdownListContainer
293
- },
294
- values: internalValues,
295
- multiSelect,
296
- showSearch,
297
- onChange: handleSelection,
298
- onCancel: handleCancel,
299
- labels,
300
- notifyChangesOnFirstRender,
301
- hasTooltips,
302
- singleSelectionToggle,
303
- "aria-label": ariaLabel,
304
- "aria-labelledby": hasLabel ? setId.setId(elementId, "label") : void 0,
305
- height,
306
- maxHeight,
307
- virtualized,
308
- ...listProps
309
- }
310
- )
231
+ id: setId.setId(elementId, "label"),
232
+ label,
233
+ className: classes.label
311
234
  }
312
235
  ),
313
- canShowError && /* @__PURE__ */ jsxRuntime.jsx(
314
- WarningText.HvWarningText,
236
+ hasDescription && /* @__PURE__ */ jsxRuntime.jsx(
237
+ InfoMessage.HvInfoMessage,
315
238
  {
316
- id: setId.setId(elementId, "error"),
317
- disableBorder: true,
318
- className: classes.error,
319
- children: validationMessage
239
+ id: setId.setId(elementId, "description"),
240
+ className: classes.description,
241
+ children: description
320
242
  }
321
243
  )
322
- ]
323
- }
324
- );
325
- }
326
- );
244
+ ] }),
245
+ /* @__PURE__ */ jsxRuntime.jsx(
246
+ BaseDropdown.HvBaseDropdown,
247
+ {
248
+ ref: dropdownForkedRef,
249
+ id: setId.setId(id, "dropdown"),
250
+ classes: {
251
+ root: cx(classes.dropdown, {
252
+ [classes.readOnly]: readOnly
253
+ }),
254
+ arrow: classes.arrow,
255
+ header: cx(classes.dropdownHeader, {
256
+ [classes.dropdownHeaderInvalid]: isStateInvalid
257
+ }),
258
+ headerOpen: classes.dropdownHeaderOpen
259
+ },
260
+ expanded: isOpen,
261
+ disabled,
262
+ readOnly,
263
+ required,
264
+ disablePortal,
265
+ placement,
266
+ popperProps,
267
+ placeholder: buildHeaderLabel(),
268
+ onToggle: handleToggle,
269
+ onClickOutside: handleClickOutside,
270
+ onContainerCreation: setFocusToContent,
271
+ role: "combobox",
272
+ variableWidth,
273
+ "aria-label": ariaLabel,
274
+ "aria-labelledby": [label && setId.setId(elementId, "label"), ariaLabelledBy].join(" ").trim() || void 0,
275
+ "aria-invalid": isStateInvalid ? true : void 0,
276
+ "aria-errormessage": errorMessageId,
277
+ "aria-describedby": [description && setId.setId(elementId, "description"), ariaDescribedBy].join(" ").trim() || void 0,
278
+ onFocus,
279
+ onBlur,
280
+ dropdownHeaderRef: headerForkedRef,
281
+ ...otherBaseDropdownProps,
282
+ children: /* @__PURE__ */ jsxRuntime.jsx(
283
+ List.HvDropdownList,
284
+ {
285
+ id: setId.setId(elementId, "values"),
286
+ classes: {
287
+ rootList: classes.rootList,
288
+ dropdownListContainer: classes.dropdownListContainer
289
+ },
290
+ values: internalValues,
291
+ multiSelect,
292
+ showSearch,
293
+ onChange: handleSelection,
294
+ onCancel: handleCancel,
295
+ labels,
296
+ notifyChangesOnFirstRender,
297
+ hasTooltips,
298
+ singleSelectionToggle,
299
+ "aria-label": ariaLabel,
300
+ "aria-labelledby": hasLabel ? setId.setId(elementId, "label") : void 0,
301
+ height,
302
+ maxHeight,
303
+ virtualized,
304
+ ...listProps
305
+ }
306
+ )
307
+ }
308
+ ),
309
+ canShowError && /* @__PURE__ */ jsxRuntime.jsx(
310
+ WarningText.HvWarningText,
311
+ {
312
+ id: setId.setId(elementId, "error"),
313
+ disableBorder: true,
314
+ className: classes.error,
315
+ children: validationMessage
316
+ }
317
+ )
318
+ ]
319
+ }
320
+ );
321
+ });
327
322
  exports.dropdownClasses = Dropdown_styles.staticClasses;
328
323
  exports.HvDropdown = HvDropdown;
@@ -5,6 +5,8 @@ const React = require("react");
5
5
  const ClickAwayListener = require("@mui/base/ClickAwayListener");
6
6
  const Popper = require("@mui/base/Popper");
7
7
  const utils = require("@mui/material/utils");
8
+ const uikitReactUtils = require("@hitachivantara/uikit-react-utils");
9
+ const document = require("../../utils/document.cjs");
8
10
  const setId = require("../../utils/setId.cjs");
9
11
  const Suggestions_styles = require("./Suggestions.styles.cjs");
10
12
  const SelectionList = require("../../SelectionList/SelectionList.cjs");
@@ -16,6 +18,7 @@ const HvSuggestions = React.forwardRef((props, extRef) => {
16
18
  className,
17
19
  classes: classesProp,
18
20
  expanded = false,
21
+ enablePortal = false,
19
22
  open: openProp,
20
23
  anchorEl,
21
24
  suggestionValues = [],
@@ -24,6 +27,7 @@ const HvSuggestions = React.forwardRef((props, extRef) => {
24
27
  ...others
25
28
  } = props;
26
29
  const { classes, cx } = Suggestions_styles.useClasses(classesProp);
30
+ const { rootId } = uikitReactUtils.useTheme();
27
31
  const { elementId } = React.useContext(FormElementContext.HvFormElementContext);
28
32
  const localId = id ?? setId.setId(elementId, "suggestions");
29
33
  const ref = React.useRef(null);
@@ -49,10 +53,17 @@ const HvSuggestions = React.forwardRef((props, extRef) => {
49
53
  children: /* @__PURE__ */ jsxRuntime.jsx(
50
54
  Popper.Popper,
51
55
  {
56
+ style: {
57
+ // @ts-ignore
58
+ "--popper-width": enablePortal ? `${anchorEl?.clientWidth}px` : "100%"
59
+ },
52
60
  open: openProp ?? isOpen,
53
- disablePortal: true,
61
+ disablePortal: !enablePortal,
62
+ container: enablePortal ? document.getContainerElement(rootId) : void 0,
54
63
  anchorEl,
55
- className: classes.popper,
64
+ className: cx(classes.popper, {
65
+ [classes.portal]: enablePortal
66
+ }),
56
67
  children: /* @__PURE__ */ jsxRuntime.jsx(
57
68
  SelectionList.HvSelectionList,
58
69
  {
@@ -11,11 +11,14 @@ const { staticClasses, useClasses } = uikitReactUtils.createClasses("HvSuggestio
11
11
  width: "100%"
12
12
  },
13
13
  popper: {
14
- width: "100%",
14
+ width: "var(--popper-width)",
15
15
  position: "absolute",
16
- transform: "translate3d(0, -1px, 0) !important",
17
- zIndex: uikitStyles.theme.zIndices.tooltip
18
- }
16
+ zIndex: uikitStyles.theme.zIndices.tooltip,
17
+ ":not($portal)": {
18
+ transform: "translate3d(0, -1px, 0) !important"
19
+ }
20
+ },
21
+ portal: {}
19
22
  });
20
23
  exports.staticClasses = staticClasses;
21
24
  exports.useClasses = useClasses;
@@ -56,11 +56,13 @@ const HvInlineEditor = generic.fixedForwardRef(function HvInlineEditor2(props, r
56
56
  onBlur?.(event, newValue);
57
57
  };
58
58
  const handleKeyDown = (event) => {
59
+ let newValue = value;
59
60
  if (keyboardUtils.isKey(event, "Esc")) {
61
+ newValue = cachedValue;
60
62
  setEditMode(false);
61
- setValue(cachedValue);
63
+ setValue(newValue);
62
64
  }
63
- onKeyDown?.(event);
65
+ onKeyDown?.(event, newValue);
64
66
  };
65
67
  const handleChange = (event, val) => {
66
68
  setValue(val);