@lumx/react 4.18.0-next.2 → 4.18.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/index.d.ts +13 -0
- package/index.js +23 -13
- package/index.js.map +1 -1
- package/package.json +3 -4
package/index.d.ts
CHANGED
|
@@ -1890,6 +1890,19 @@ interface ComboboxInputOptions {
|
|
|
1890
1890
|
* @default false (true when filter is 'off')
|
|
1891
1891
|
*/
|
|
1892
1892
|
openOnFocus?: boolean;
|
|
1893
|
+
/**
|
|
1894
|
+
* Controls what happens to the input value when an option is selected.
|
|
1895
|
+
*
|
|
1896
|
+
* - `'fill'` (default) — The input is updated with the selected option value via `onChange`.
|
|
1897
|
+
* - `'keep'` — The input value is left unchanged; `onChange` is not called.
|
|
1898
|
+
* Useful when the component manages the displayed value independently (e.g. showing
|
|
1899
|
+
* an option display name rather than the raw option ID). The filter still resets.
|
|
1900
|
+
* - `'clear'` — The input is cleared (empty string) via `onChange` after selection.
|
|
1901
|
+
* Useful for multi-select patterns where typing starts fresh after each pick.
|
|
1902
|
+
*
|
|
1903
|
+
* @default 'fill'
|
|
1904
|
+
*/
|
|
1905
|
+
selectionMode?: 'fill' | 'keep' | 'clear';
|
|
1893
1906
|
}
|
|
1894
1907
|
|
|
1895
1908
|
/**
|
package/index.js
CHANGED
|
@@ -7387,8 +7387,10 @@ function setupComboboxInput(input, options) {
|
|
|
7387
7387
|
let handle;
|
|
7388
7388
|
const {
|
|
7389
7389
|
filter = 'auto',
|
|
7390
|
+
selectionMode = 'fill',
|
|
7390
7391
|
onSelect: optionOnSelect,
|
|
7391
|
-
onInput: onInputCallback
|
|
7392
|
+
onInput: onInputCallback,
|
|
7393
|
+
onChange: onChangeCallback
|
|
7392
7394
|
} = options;
|
|
7393
7395
|
const openOnFocus = options.openOnFocus ?? filter === 'off';
|
|
7394
7396
|
const autoFilter = filter === 'auto';
|
|
@@ -7404,15 +7406,20 @@ function setupComboboxInput(input, options) {
|
|
|
7404
7406
|
let userHasTyped = false;
|
|
7405
7407
|
|
|
7406
7408
|
/**
|
|
7407
|
-
* Wraps the consumer's onSelect to perform input-mode side effects after selection
|
|
7408
|
-
*
|
|
7409
|
+
* Wraps the consumer's onSelect to perform input-mode side effects after selection,
|
|
7410
|
+
* and drive `onChange` according to `selectionMode`.
|
|
7411
|
+
* Filter and typing state are always reset on selection.
|
|
7409
7412
|
*/
|
|
7410
7413
|
const onSelect = option => {
|
|
7411
7414
|
optionOnSelect?.(option);
|
|
7412
7415
|
userHasTyped = false;
|
|
7413
|
-
if (autoFilter)
|
|
7414
|
-
|
|
7416
|
+
if (autoFilter) handle.setFilter('');
|
|
7417
|
+
if (selectionMode === 'fill') {
|
|
7418
|
+
onChangeCallback?.(option.value);
|
|
7419
|
+
} else if (selectionMode === 'clear') {
|
|
7420
|
+
onChangeCallback?.('');
|
|
7415
7421
|
}
|
|
7422
|
+
// 'keep': onChange is not called — input value stays as-is.
|
|
7416
7423
|
};
|
|
7417
7424
|
handle = setupCombobox({
|
|
7418
7425
|
onSelect
|
|
@@ -8149,18 +8156,19 @@ const ComboboxInput = forwardRef((props, ref) => {
|
|
|
8149
8156
|
setHandle
|
|
8150
8157
|
} = useComboboxContext();
|
|
8151
8158
|
const [isOpen, setIsOpen] = useComboboxOpen();
|
|
8152
|
-
const state = useComboboxEvent('optionsChange', {
|
|
8153
|
-
optionsLength: 0
|
|
8154
|
-
});
|
|
8155
|
-
const isLoading = useComboboxEvent('loadingChange', false);
|
|
8156
8159
|
const {
|
|
8157
8160
|
inputRef: externalInputRef,
|
|
8158
8161
|
toggleButtonProps,
|
|
8159
8162
|
onSelect,
|
|
8160
8163
|
filter,
|
|
8161
8164
|
openOnFocus,
|
|
8165
|
+
selectionMode,
|
|
8162
8166
|
...otherProps
|
|
8163
8167
|
} = props;
|
|
8168
|
+
const state = useComboboxEvent('optionsChange', {
|
|
8169
|
+
optionsLength: 0
|
|
8170
|
+
});
|
|
8171
|
+
const isLoading = useComboboxEvent('loadingChange', false);
|
|
8164
8172
|
const internalInputRef = useRef(null);
|
|
8165
8173
|
const mergedInputRef = useMergeRefs(externalInputRef, internalInputRef);
|
|
8166
8174
|
|
|
@@ -8176,14 +8184,15 @@ const ComboboxInput = forwardRef((props, ref) => {
|
|
|
8176
8184
|
if (!input) return undefined;
|
|
8177
8185
|
const handle = setupComboboxInput(input, {
|
|
8178
8186
|
onSelect(option) {
|
|
8179
|
-
// Update controlled value through React's normal onChange flow.
|
|
8180
|
-
onChangeRef.current?.(option.value);
|
|
8181
8187
|
onSelectRef.current?.(option);
|
|
8182
8188
|
},
|
|
8189
|
+
onChange(value) {
|
|
8190
|
+
onChangeRef.current?.(value);
|
|
8191
|
+
},
|
|
8183
8192
|
onInput(value) {
|
|
8184
|
-
// Keep controlled value in sync.
|
|
8185
8193
|
onChangeRef.current?.(value);
|
|
8186
8194
|
},
|
|
8195
|
+
selectionMode,
|
|
8187
8196
|
filter,
|
|
8188
8197
|
openOnFocus
|
|
8189
8198
|
});
|
|
@@ -8192,7 +8201,7 @@ const ComboboxInput = forwardRef((props, ref) => {
|
|
|
8192
8201
|
handle.destroy();
|
|
8193
8202
|
setHandle(null);
|
|
8194
8203
|
};
|
|
8195
|
-
}, [filter, openOnFocus, setHandle]);
|
|
8204
|
+
}, [filter, openOnFocus, selectionMode, setHandle]);
|
|
8196
8205
|
const handleToggle = useCallback(() => {
|
|
8197
8206
|
setIsOpen(!isOpen);
|
|
8198
8207
|
internalInputRef.current?.focus();
|
|
@@ -18258,6 +18267,7 @@ const SelectTextField$2 = (props, {
|
|
|
18258
18267
|
children: [/*#__PURE__*/jsx(Combobox.Input, {
|
|
18259
18268
|
label: label,
|
|
18260
18269
|
...inputProps,
|
|
18270
|
+
selectionMode: "keep",
|
|
18261
18271
|
chips: chips
|
|
18262
18272
|
}), /*#__PURE__*/jsxs(Combobox.Popover, {
|
|
18263
18273
|
fitToAnchorWidth: "minWidth",
|