@ahoo-wang/fetcher-viewer 3.11.10 → 3.12.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/dist/components/RemoteSelect.d.ts +56 -2
- package/dist/components/RemoteSelect.d.ts.map +1 -1
- package/dist/index.es.js +1360 -1342
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/view/hooks/useViewState.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -3,13 +3,67 @@ import { UseDebouncedCallbackOptions } from '@ahoo-wang/fetcher-react';
|
|
|
3
3
|
import { StyleCapable } from '../types';
|
|
4
4
|
import { RefAttributes } from 'react';
|
|
5
5
|
import { BaseOptionType, DefaultOptionType } from 'antd/lib/select';
|
|
6
|
+
/**
|
|
7
|
+
* Props for the RemoteSelect component.
|
|
8
|
+
*
|
|
9
|
+
* @template ValueType - The type of the value(s) selected in the Select
|
|
10
|
+
* @template OptionType - The type of option objects, defaults to antd's DefaultOptionType
|
|
11
|
+
*/
|
|
6
12
|
export interface RemoteSelectProps<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType> extends Omit<SelectProps<ValueType, OptionType>, 'loading' | 'onSearch'>, RefAttributes<RefSelectProps>, StyleCapable {
|
|
13
|
+
/** Debounce options for controlling the search delay */
|
|
7
14
|
debounce?: UseDebouncedCallbackOptions;
|
|
15
|
+
/**
|
|
16
|
+
* Callback function to fetch options from remote API.
|
|
17
|
+
* Called with the current search string when user types.
|
|
18
|
+
*
|
|
19
|
+
* @param search - The current search input value
|
|
20
|
+
* @returns Promise resolving to array of options
|
|
21
|
+
* @throws Error when the remote API request fails
|
|
22
|
+
*/
|
|
8
23
|
search: (search: string) => Promise<OptionType[]>;
|
|
24
|
+
/** Initial options displayed before any search is performed */
|
|
25
|
+
options?: OptionType[];
|
|
26
|
+
/** Custom key field for deduplication, defaults to 'value' */
|
|
27
|
+
uniqueKey?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Additional options that are always appended to the options list.
|
|
30
|
+
* These appear after the remote search results or initial options.
|
|
31
|
+
*/
|
|
32
|
+
additionalOptions?: OptionType[];
|
|
9
33
|
}
|
|
10
34
|
/**
|
|
11
|
-
* A Select component
|
|
12
|
-
* Supports
|
|
35
|
+
* A Select component with built-in remote search functionality.
|
|
36
|
+
* Supports debounced search, loading states, and combining remote results with static options.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* import { RemoteSelect } from '@ahoo-wang/fetcher-viewer';
|
|
41
|
+
*
|
|
42
|
+
* // Basic usage with remote search
|
|
43
|
+
* const UserSelect = () => (
|
|
44
|
+
* <RemoteSelect
|
|
45
|
+
* search={async (keyword) => {
|
|
46
|
+
* const response = await fetch(`/api/users?q=${keyword}`);
|
|
47
|
+
* return response.json();
|
|
48
|
+
* }}
|
|
49
|
+
* placeholder="Search users..."
|
|
50
|
+
* />
|
|
51
|
+
* );
|
|
52
|
+
*
|
|
53
|
+
* // With initial options and additional options
|
|
54
|
+
* const StatusSelect = () => (
|
|
55
|
+
* <RemoteSelect
|
|
56
|
+
* search={async (keyword) => fetchOptions(keyword)}
|
|
57
|
+
* options={[{ label: 'Pending', value: 'pending' }]}
|
|
58
|
+
* additionalOptions={[{ label: 'Unknown', value: 'unknown' }]}
|
|
59
|
+
* />
|
|
60
|
+
* );
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @template ValueType - The type of value(s) selected
|
|
64
|
+
* @template OptionType - The option object type
|
|
65
|
+
* @param props - Component props extending antd SelectProps
|
|
66
|
+
* @returns A Select component with remote search capability
|
|
13
67
|
*/
|
|
14
68
|
export declare function RemoteSelect<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(props: RemoteSelectProps<ValueType, OptionType>): import("react/jsx-runtime").JSX.Element;
|
|
15
69
|
export declare namespace RemoteSelect {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteSelect.d.ts","sourceRoot":"","sources":["../../src/components/RemoteSelect.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAU,WAAW,EAAE,cAAc,EAAqB,MAAM,MAAM,CAAC;AAC9E,OAAO,EACL,2BAA2B,EAE5B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"RemoteSelect.d.ts","sourceRoot":"","sources":["../../src/components/RemoteSelect.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAU,WAAW,EAAE,cAAc,EAAqB,MAAM,MAAM,CAAC;AAC9E,OAAO,EACL,2BAA2B,EAE5B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,aAAa,EAAW,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB,CAChC,SAAS,GAAG,GAAG,EACf,UAAU,SAAS,cAAc,GAAG,iBAAiB,GAAG,iBAAiB,CAEzE,SAAQ,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC,EACtE,aAAa,CAAC,cAAc,CAAC,EAC7B,YAAY;IACd,wDAAwD;IACxD,QAAQ,CAAC,EAAE,2BAA2B,CAAC;IACvC;;;;;;;OAOG;IACH,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IAClD,+DAA+D;IAC/D,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;IACvB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,UAAU,EAAE,CAAC;CAClC;AA2BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,YAAY,CAC1B,SAAS,GAAG,GAAG,EACf,UAAU,SAAS,cAAc,GAAG,iBAAiB,GAAG,iBAAiB,EACzE,KAAK,EAAE,iBAAiB,CAAC,SAAS,EAAE,UAAU,CAAC,2CAoDhD;yBAvDe,YAAY"}
|