@pro6pp/infer-react 0.0.2-beta.0 → 0.0.2-beta.10
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/README.md +50 -8
- package/dist/index.cjs +777 -0
- package/dist/index.d.cts +68 -0
- package/dist/index.d.ts +54 -10
- package/dist/index.js +732 -32
- package/package.json +35 -10
- package/dist/index.d.mts +0 -24
- package/dist/index.mjs +0 -25
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InferConfig, InferState, InferCore, InferResult } from '@pro6pp/infer-core';
|
|
3
|
+
export { AddressValue, CountryCode, Fetcher, InferConfig, InferResult, InferState, Stage } from '@pro6pp/infer-core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A headless React hook that provides the logic for address search using the Infer API.
|
|
7
|
+
* @param config The engine configuration (authKey, country, etc.).
|
|
8
|
+
* @returns An object containing the current state, the core instance, and pre-bound input props.
|
|
9
|
+
*/
|
|
10
|
+
declare function useInfer(config: InferConfig): {
|
|
11
|
+
/** The current UI state (suggestions, loading status, query, etc.). */
|
|
12
|
+
state: InferState;
|
|
13
|
+
/** The raw InferCore instance for manual control. */
|
|
14
|
+
core: InferCore;
|
|
15
|
+
/** Pre-configured event handlers to spread onto an <input /> element. */
|
|
16
|
+
inputProps: {
|
|
17
|
+
value: string;
|
|
18
|
+
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
19
|
+
onKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
20
|
+
};
|
|
21
|
+
/** Function to manually select a specific suggestion. */
|
|
22
|
+
selectItem: (item: InferResult | string) => boolean;
|
|
23
|
+
/** Function to load more results. */
|
|
24
|
+
loadMore: () => void;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Props for the Pro6PPInfer component.
|
|
28
|
+
*/
|
|
29
|
+
interface Pro6PPInferProps extends InferConfig {
|
|
30
|
+
/** Optional CSS class for the wrapper div. */
|
|
31
|
+
className?: string;
|
|
32
|
+
/** Optional inline styles for the wrapper div. */
|
|
33
|
+
style?: React.CSSProperties;
|
|
34
|
+
/** Attributes to pass directly to the underlying input element. */
|
|
35
|
+
inputProps?: React.InputHTMLAttributes<HTMLInputElement>;
|
|
36
|
+
/** * Custom placeholder text.
|
|
37
|
+
* @default 'Start typing an address...'
|
|
38
|
+
*/
|
|
39
|
+
placeholder?: string;
|
|
40
|
+
/** A custom render function for individual suggestion items. */
|
|
41
|
+
renderItem?: (item: InferResult, isActive: boolean) => React.ReactNode;
|
|
42
|
+
/** * If true, prevents the default CSS theme from being injected.
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
disableDefaultStyles?: boolean;
|
|
46
|
+
/** * The text to show when no results are found.
|
|
47
|
+
* @default 'No results found'
|
|
48
|
+
*/
|
|
49
|
+
noResultsText?: string;
|
|
50
|
+
/** * The text to show on the load more button.
|
|
51
|
+
* @default 'Show more results...'
|
|
52
|
+
*/
|
|
53
|
+
loadMoreText?: string;
|
|
54
|
+
/** A custom render function for the "no results" state. */
|
|
55
|
+
renderNoResults?: (state: InferState) => React.ReactNode;
|
|
56
|
+
/**
|
|
57
|
+
* If true, shows a clear button when the input is not empty.
|
|
58
|
+
* @default true
|
|
59
|
+
*/
|
|
60
|
+
showClearButton?: boolean;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A styled React component for Pro6PP Infer API.
|
|
64
|
+
* Includes styling, keyboard navigation, and loading states.
|
|
65
|
+
*/
|
|
66
|
+
declare const Pro6PPInfer: React.ForwardRefExoticComponent<Pro6PPInferProps & React.RefAttributes<HTMLInputElement>>;
|
|
67
|
+
|
|
68
|
+
export { Pro6PPInfer, type Pro6PPInferProps, useInfer };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { InferConfig, InferState, InferCore, InferResult } from '@pro6pp/infer-core';
|
|
3
|
+
export { AddressValue, CountryCode, Fetcher, InferConfig, InferResult, InferState, Stage } from '@pro6pp/infer-core';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @param config
|
|
6
|
-
* @returns An object containing the current state,
|
|
7
|
-
* @example
|
|
8
|
-
* const { state, inputProps, selectItem } = useInfer({
|
|
9
|
-
* authKey: 'YOUR_KEY',
|
|
10
|
-
* country: 'NL'
|
|
11
|
-
* });
|
|
6
|
+
* A headless React hook that provides the logic for address search using the Infer API.
|
|
7
|
+
* @param config The engine configuration (authKey, country, etc.).
|
|
8
|
+
* @returns An object containing the current state, the core instance, and pre-bound input props.
|
|
12
9
|
*/
|
|
13
10
|
declare function useInfer(config: InferConfig): {
|
|
11
|
+
/** The current UI state (suggestions, loading status, query, etc.). */
|
|
14
12
|
state: InferState;
|
|
13
|
+
/** The raw InferCore instance for manual control. */
|
|
15
14
|
core: InferCore;
|
|
15
|
+
/** Pre-configured event handlers to spread onto an <input /> element. */
|
|
16
16
|
inputProps: {
|
|
17
17
|
value: string;
|
|
18
18
|
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
19
19
|
onKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
/** Function to manually select a specific suggestion. */
|
|
22
|
+
selectItem: (item: InferResult | string) => boolean;
|
|
23
|
+
/** Function to load more results. */
|
|
24
|
+
loadMore: () => void;
|
|
22
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Props for the Pro6PPInfer component.
|
|
28
|
+
*/
|
|
29
|
+
interface Pro6PPInferProps extends InferConfig {
|
|
30
|
+
/** Optional CSS class for the wrapper div. */
|
|
31
|
+
className?: string;
|
|
32
|
+
/** Optional inline styles for the wrapper div. */
|
|
33
|
+
style?: React.CSSProperties;
|
|
34
|
+
/** Attributes to pass directly to the underlying input element. */
|
|
35
|
+
inputProps?: React.InputHTMLAttributes<HTMLInputElement>;
|
|
36
|
+
/** * Custom placeholder text.
|
|
37
|
+
* @default 'Start typing an address...'
|
|
38
|
+
*/
|
|
39
|
+
placeholder?: string;
|
|
40
|
+
/** A custom render function for individual suggestion items. */
|
|
41
|
+
renderItem?: (item: InferResult, isActive: boolean) => React.ReactNode;
|
|
42
|
+
/** * If true, prevents the default CSS theme from being injected.
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
disableDefaultStyles?: boolean;
|
|
46
|
+
/** * The text to show when no results are found.
|
|
47
|
+
* @default 'No results found'
|
|
48
|
+
*/
|
|
49
|
+
noResultsText?: string;
|
|
50
|
+
/** * The text to show on the load more button.
|
|
51
|
+
* @default 'Show more results...'
|
|
52
|
+
*/
|
|
53
|
+
loadMoreText?: string;
|
|
54
|
+
/** A custom render function for the "no results" state. */
|
|
55
|
+
renderNoResults?: (state: InferState) => React.ReactNode;
|
|
56
|
+
/**
|
|
57
|
+
* If true, shows a clear button when the input is not empty.
|
|
58
|
+
* @default true
|
|
59
|
+
*/
|
|
60
|
+
showClearButton?: boolean;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A styled React component for Pro6PP Infer API.
|
|
64
|
+
* Includes styling, keyboard navigation, and loading states.
|
|
65
|
+
*/
|
|
66
|
+
declare const Pro6PPInfer: React.ForwardRefExoticComponent<Pro6PPInferProps & React.RefAttributes<HTMLInputElement>>;
|
|
23
67
|
|
|
24
|
-
export { useInfer };
|
|
68
|
+
export { Pro6PPInfer, type Pro6PPInferProps, useInfer };
|