@lumx/react 4.17.1-alpha.1 → 4.17.1-alpha.2
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 +15 -6
- package/index.js +14 -14
- package/index.js.map +1 -1
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -1862,14 +1862,10 @@ interface ComboboxEventMap {
|
|
|
1862
1862
|
}
|
|
1863
1863
|
/** Callbacks provided by the consumer (React/Vue) to react to combobox state changes. */
|
|
1864
1864
|
interface ComboboxCallbacks {
|
|
1865
|
-
/**
|
|
1866
|
-
* Called when an option is selected (click or keyboard).
|
|
1867
|
-
* Return `false` to skip the default behaviour of updating the input value via `onChange`.
|
|
1868
|
-
* The combobox will still close normally.
|
|
1869
|
-
*/
|
|
1865
|
+
/** Called when an option is selected (click or keyboard). */
|
|
1870
1866
|
onSelect?(option: {
|
|
1871
1867
|
value: string;
|
|
1872
|
-
}):
|
|
1868
|
+
}): void;
|
|
1873
1869
|
}
|
|
1874
1870
|
/**
|
|
1875
1871
|
* Behavioral options for input-mode combobox (autocomplete/filter pattern).
|
|
@@ -1894,6 +1890,19 @@ interface ComboboxInputOptions {
|
|
|
1894
1890
|
* @default false (true when filter is 'off')
|
|
1895
1891
|
*/
|
|
1896
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';
|
|
1897
1906
|
}
|
|
1898
1907
|
|
|
1899
1908
|
/**
|
package/index.js
CHANGED
|
@@ -7404,17 +7404,14 @@ function setupComboboxInput(input, options) {
|
|
|
7404
7404
|
let userHasTyped = false;
|
|
7405
7405
|
|
|
7406
7406
|
/**
|
|
7407
|
-
* Wraps the consumer's onSelect to perform input-mode side effects after selection
|
|
7408
|
-
*
|
|
7409
|
-
*
|
|
7407
|
+
* Wraps the consumer's onSelect to perform input-mode side effects after selection.
|
|
7408
|
+
* Filter and typing state are always reset on selection — selectionMode only controls
|
|
7409
|
+
* whether onChange is called by the framework wrapper, not the internal filter.
|
|
7410
7410
|
*/
|
|
7411
7411
|
const onSelect = option => {
|
|
7412
|
-
|
|
7412
|
+
optionOnSelect?.(option);
|
|
7413
7413
|
userHasTyped = false;
|
|
7414
|
-
if (autoFilter)
|
|
7415
|
-
handle.setFilter('');
|
|
7416
|
-
}
|
|
7417
|
-
return result;
|
|
7414
|
+
if (autoFilter) handle.setFilter('');
|
|
7418
7415
|
};
|
|
7419
7416
|
handle = setupCombobox({
|
|
7420
7417
|
onSelect
|
|
@@ -8161,6 +8158,7 @@ const ComboboxInput = forwardRef((props, ref) => {
|
|
|
8161
8158
|
onSelect,
|
|
8162
8159
|
filter,
|
|
8163
8160
|
openOnFocus,
|
|
8161
|
+
selectionMode,
|
|
8164
8162
|
...otherProps
|
|
8165
8163
|
} = props;
|
|
8166
8164
|
const internalInputRef = useRef(null);
|
|
@@ -8178,11 +8176,12 @@ const ComboboxInput = forwardRef((props, ref) => {
|
|
|
8178
8176
|
if (!input) return undefined;
|
|
8179
8177
|
const handle = setupComboboxInput(input, {
|
|
8180
8178
|
onSelect(option) {
|
|
8181
|
-
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
8179
|
+
onSelectRef.current?.(option);
|
|
8180
|
+
// Drive onChange according to selectionMode.
|
|
8181
|
+
if (selectionMode === 'keep') ; else if (selectionMode === 'clear') {
|
|
8182
|
+
onChangeRef.current?.('');
|
|
8183
|
+
} else {
|
|
8184
|
+
// 'fill' (default): echo the selected value.
|
|
8186
8185
|
onChangeRef.current?.(option.value);
|
|
8187
8186
|
}
|
|
8188
8187
|
},
|
|
@@ -8198,7 +8197,7 @@ const ComboboxInput = forwardRef((props, ref) => {
|
|
|
8198
8197
|
handle.destroy();
|
|
8199
8198
|
setHandle(null);
|
|
8200
8199
|
};
|
|
8201
|
-
}, [filter, openOnFocus, setHandle]);
|
|
8200
|
+
}, [filter, openOnFocus, selectionMode, setHandle]);
|
|
8202
8201
|
const handleToggle = useCallback(() => {
|
|
8203
8202
|
setIsOpen(!isOpen);
|
|
8204
8203
|
internalInputRef.current?.focus();
|
|
@@ -18264,6 +18263,7 @@ const SelectTextField$2 = (props, {
|
|
|
18264
18263
|
children: [/*#__PURE__*/jsx(Combobox.Input, {
|
|
18265
18264
|
label: label,
|
|
18266
18265
|
...inputProps,
|
|
18266
|
+
selectionMode: "keep",
|
|
18267
18267
|
chips: chips
|
|
18268
18268
|
}), /*#__PURE__*/jsxs(Combobox.Popover, {
|
|
18269
18269
|
fitToAnchorWidth: "minWidth",
|