twico-ui 1.40.0 → 1.41.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/CHANGELOG.md +12 -0
- package/dist/index.cjs +18 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.mjs +18 -2
- package/dist/index.mjs.map +1 -1
- package/llms.txt +2 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1665,6 +1665,11 @@ interface ComboboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>
|
|
|
1665
1665
|
value?: string | null;
|
|
1666
1666
|
/** Uncontrolled initial value. */
|
|
1667
1667
|
defaultValue?: string | null;
|
|
1668
|
+
/** Seed the search *text* with this string each time the menu opens (caret placed at the end), without emitting it as
|
|
1669
|
+
* an `onInputChange`. It is matched against option labels/descriptions like any typed query — not the option
|
|
1670
|
+
* `value` — so to open a cell editor pre-filled on the current selection, pass its **label** (e.g. `"Japan"`),
|
|
1671
|
+
* not its value (`"jp"`). */
|
|
1672
|
+
defaultQuery?: string;
|
|
1668
1673
|
/** Called with the chosen option's value, or `null` when cleared via `clearable`. */
|
|
1669
1674
|
onChange?: (value: string | null) => void;
|
|
1670
1675
|
/** Show a clear (×) affix when a value is selected. */
|
|
@@ -1680,6 +1685,9 @@ interface ComboboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>
|
|
|
1680
1685
|
minWidth?: number;
|
|
1681
1686
|
/** Called with the raw query on every keystroke — drive a debounced remote fetch (with `loading` + `filter={false}`). */
|
|
1682
1687
|
onInputChange?: (query: string) => void;
|
|
1688
|
+
/** Called with `true` when the menu opens and `false` when it closes (including when `close()` silently resets the
|
|
1689
|
+
* typed query) — a host staging that query (e.g. a cell editor) can withdraw it on close. */
|
|
1690
|
+
onOpenChange?: (open: boolean) => void;
|
|
1683
1691
|
/** Client-side filtering: `false` shows options as-is (server-ranked); a function replaces the default label/description match. */
|
|
1684
1692
|
filter?: boolean | ((option: ComboboxOption, query: string) => boolean);
|
|
1685
1693
|
/** Show a loading row instead of the option list / empty state. @default false */
|
package/dist/index.d.ts
CHANGED
|
@@ -1665,6 +1665,11 @@ interface ComboboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>
|
|
|
1665
1665
|
value?: string | null;
|
|
1666
1666
|
/** Uncontrolled initial value. */
|
|
1667
1667
|
defaultValue?: string | null;
|
|
1668
|
+
/** Seed the search *text* with this string each time the menu opens (caret placed at the end), without emitting it as
|
|
1669
|
+
* an `onInputChange`. It is matched against option labels/descriptions like any typed query — not the option
|
|
1670
|
+
* `value` — so to open a cell editor pre-filled on the current selection, pass its **label** (e.g. `"Japan"`),
|
|
1671
|
+
* not its value (`"jp"`). */
|
|
1672
|
+
defaultQuery?: string;
|
|
1668
1673
|
/** Called with the chosen option's value, or `null` when cleared via `clearable`. */
|
|
1669
1674
|
onChange?: (value: string | null) => void;
|
|
1670
1675
|
/** Show a clear (×) affix when a value is selected. */
|
|
@@ -1680,6 +1685,9 @@ interface ComboboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>
|
|
|
1680
1685
|
minWidth?: number;
|
|
1681
1686
|
/** Called with the raw query on every keystroke — drive a debounced remote fetch (with `loading` + `filter={false}`). */
|
|
1682
1687
|
onInputChange?: (query: string) => void;
|
|
1688
|
+
/** Called with `true` when the menu opens and `false` when it closes (including when `close()` silently resets the
|
|
1689
|
+
* typed query) — a host staging that query (e.g. a cell editor) can withdraw it on close. */
|
|
1690
|
+
onOpenChange?: (open: boolean) => void;
|
|
1683
1691
|
/** Client-side filtering: `false` shows options as-is (server-ranked); a function replaces the default label/description match. */
|
|
1684
1692
|
filter?: boolean | ((option: ComboboxOption, query: string) => boolean);
|
|
1685
1693
|
/** Show a loading row instead of the option list / empty state. @default false */
|
package/dist/index.mjs
CHANGED
|
@@ -6328,6 +6328,7 @@ function Combobox({
|
|
|
6328
6328
|
options,
|
|
6329
6329
|
value,
|
|
6330
6330
|
defaultValue = null,
|
|
6331
|
+
defaultQuery,
|
|
6331
6332
|
onChange,
|
|
6332
6333
|
clearable = false,
|
|
6333
6334
|
disabled = false,
|
|
@@ -6335,6 +6336,7 @@ function Combobox({
|
|
|
6335
6336
|
portal = true,
|
|
6336
6337
|
minWidth = 0,
|
|
6337
6338
|
onInputChange,
|
|
6339
|
+
onOpenChange,
|
|
6338
6340
|
filter,
|
|
6339
6341
|
loading = false,
|
|
6340
6342
|
emptyText = "No results found",
|
|
@@ -6451,9 +6453,18 @@ function Combobox({
|
|
|
6451
6453
|
React53__default.useEffect(() => {
|
|
6452
6454
|
setActive(0);
|
|
6453
6455
|
}, [query]);
|
|
6456
|
+
const onOpenChangeRef = React53__default.useRef(onOpenChange);
|
|
6457
|
+
onOpenChangeRef.current = onOpenChange;
|
|
6458
|
+
const prevOpenRef = React53__default.useRef(open);
|
|
6459
|
+
React53__default.useEffect(() => {
|
|
6460
|
+
if (prevOpenRef.current !== open) {
|
|
6461
|
+
prevOpenRef.current = open;
|
|
6462
|
+
onOpenChangeRef.current?.(open);
|
|
6463
|
+
}
|
|
6464
|
+
}, [open]);
|
|
6454
6465
|
React53__default.useEffect(() => {
|
|
6455
6466
|
if (!open) return;
|
|
6456
|
-
const idx =
|
|
6467
|
+
const idx = visible.findIndex((o) => o.value === current);
|
|
6457
6468
|
setActive(idx >= 0 ? idx : 0);
|
|
6458
6469
|
}, [open]);
|
|
6459
6470
|
React53__default.useEffect(() => {
|
|
@@ -6480,8 +6491,13 @@ function Combobox({
|
|
|
6480
6491
|
}, [active, open, virtualized, rows, listH]);
|
|
6481
6492
|
function openMenu() {
|
|
6482
6493
|
if (disabled) return;
|
|
6483
|
-
|
|
6494
|
+
const seed = defaultQuery || "";
|
|
6495
|
+
setQuery(seed);
|
|
6484
6496
|
setOpen(true);
|
|
6497
|
+
if (seed) requestAnimationFrame(() => {
|
|
6498
|
+
const el = inputRef.current;
|
|
6499
|
+
if (el) el.setSelectionRange(seed.length, seed.length);
|
|
6500
|
+
});
|
|
6485
6501
|
}
|
|
6486
6502
|
function close() {
|
|
6487
6503
|
setOpen(false);
|