@pro6pp/infer-react 0.0.2-beta.8 → 0.1.0-beta.19

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/index.d.cts CHANGED
@@ -1,14 +1,23 @@
1
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';
2
+ import { InferConfig, AddressValue, InferState, InferCore, InferResult } from '@pro6pp/infer-core';
3
+ export { AddressValue, CountryCode, Fetcher, InferConfig, InferResult, InferState, LanguageCode, Stage } from '@pro6pp/infer-core';
4
4
 
5
+ /**
6
+ * Extended configuration for the React hook.
7
+ */
8
+ interface UseInferConfig extends InferConfig {
9
+ /**
10
+ * Initial address value to pre-fill the state with.
11
+ */
12
+ initialValue?: AddressValue;
13
+ }
5
14
  /**
6
15
  * A headless React hook that provides the logic for address search using the Infer API.
7
16
  * @param config The engine configuration (authKey, country, etc.).
8
17
  * @returns An object containing the current state, the core instance, and pre-bound input props.
9
18
  */
10
- declare function useInfer(config: InferConfig): {
11
- /** The current UI state (suggestions, loading status, query, etc.). */
19
+ declare function useInfer(config: UseInferConfig): {
20
+ /** The current UI state (suggestions, loading status, query, value, etc.). */
12
21
  state: InferState;
13
22
  /** The raw InferCore instance for manual control. */
14
23
  core: InferCore;
@@ -18,13 +27,17 @@ declare function useInfer(config: InferConfig): {
18
27
  onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
19
28
  onKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void;
20
29
  };
21
- /** Function to manually select a specific suggestion. */
22
- selectItem: (item: InferResult | string) => void;
30
+ /** Manually select a specific suggestion. */
31
+ selectItem: (item: InferResult | string) => boolean;
32
+ /** Programmatically set the address value. */
33
+ setValue: (address: AddressValue) => void;
34
+ /** Load more results. */
35
+ loadMore: () => void;
23
36
  };
24
37
  /**
25
38
  * Props for the Pro6PPInfer component.
26
39
  */
27
- interface Pro6PPInferProps extends InferConfig {
40
+ interface Pro6PPInferProps extends UseInferConfig {
28
41
  /** Optional CSS class for the wrapper div. */
29
42
  className?: string;
30
43
  /** Optional inline styles for the wrapper div. */
@@ -45,13 +58,22 @@ interface Pro6PPInferProps extends InferConfig {
45
58
  * @default 'No results found'
46
59
  */
47
60
  noResultsText?: string;
61
+ /** * The text to show on the bottom loading indicator.
62
+ * @default 'Loading more...'
63
+ */
64
+ loadingText?: string;
48
65
  /** A custom render function for the "no results" state. */
49
66
  renderNoResults?: (state: InferState) => React.ReactNode;
67
+ /**
68
+ * If true, shows a clear button when the input is not empty.
69
+ * @default true
70
+ */
71
+ showClearButton?: boolean;
50
72
  }
51
73
  /**
52
74
  * A styled React component for Pro6PP Infer API.
53
75
  * Includes styling, keyboard navigation, and loading states.
54
76
  */
55
- declare const Pro6PPInfer: React.FC<Pro6PPInferProps>;
77
+ declare const Pro6PPInfer: React.ForwardRefExoticComponent<Pro6PPInferProps & React.RefAttributes<HTMLInputElement>>;
56
78
 
57
- export { Pro6PPInfer, type Pro6PPInferProps, useInfer };
79
+ export { Pro6PPInfer, type Pro6PPInferProps, type UseInferConfig, useInfer };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,23 @@
1
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';
2
+ import { InferConfig, AddressValue, InferState, InferCore, InferResult } from '@pro6pp/infer-core';
3
+ export { AddressValue, CountryCode, Fetcher, InferConfig, InferResult, InferState, LanguageCode, Stage } from '@pro6pp/infer-core';
4
4
 
5
+ /**
6
+ * Extended configuration for the React hook.
7
+ */
8
+ interface UseInferConfig extends InferConfig {
9
+ /**
10
+ * Initial address value to pre-fill the state with.
11
+ */
12
+ initialValue?: AddressValue;
13
+ }
5
14
  /**
6
15
  * A headless React hook that provides the logic for address search using the Infer API.
7
16
  * @param config The engine configuration (authKey, country, etc.).
8
17
  * @returns An object containing the current state, the core instance, and pre-bound input props.
9
18
  */
10
- declare function useInfer(config: InferConfig): {
11
- /** The current UI state (suggestions, loading status, query, etc.). */
19
+ declare function useInfer(config: UseInferConfig): {
20
+ /** The current UI state (suggestions, loading status, query, value, etc.). */
12
21
  state: InferState;
13
22
  /** The raw InferCore instance for manual control. */
14
23
  core: InferCore;
@@ -18,13 +27,17 @@ declare function useInfer(config: InferConfig): {
18
27
  onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
19
28
  onKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void;
20
29
  };
21
- /** Function to manually select a specific suggestion. */
22
- selectItem: (item: InferResult | string) => void;
30
+ /** Manually select a specific suggestion. */
31
+ selectItem: (item: InferResult | string) => boolean;
32
+ /** Programmatically set the address value. */
33
+ setValue: (address: AddressValue) => void;
34
+ /** Load more results. */
35
+ loadMore: () => void;
23
36
  };
24
37
  /**
25
38
  * Props for the Pro6PPInfer component.
26
39
  */
27
- interface Pro6PPInferProps extends InferConfig {
40
+ interface Pro6PPInferProps extends UseInferConfig {
28
41
  /** Optional CSS class for the wrapper div. */
29
42
  className?: string;
30
43
  /** Optional inline styles for the wrapper div. */
@@ -45,13 +58,22 @@ interface Pro6PPInferProps extends InferConfig {
45
58
  * @default 'No results found'
46
59
  */
47
60
  noResultsText?: string;
61
+ /** * The text to show on the bottom loading indicator.
62
+ * @default 'Loading more...'
63
+ */
64
+ loadingText?: string;
48
65
  /** A custom render function for the "no results" state. */
49
66
  renderNoResults?: (state: InferState) => React.ReactNode;
67
+ /**
68
+ * If true, shows a clear button when the input is not empty.
69
+ * @default true
70
+ */
71
+ showClearButton?: boolean;
50
72
  }
51
73
  /**
52
74
  * A styled React component for Pro6PP Infer API.
53
75
  * Includes styling, keyboard navigation, and loading states.
54
76
  */
55
- declare const Pro6PPInfer: React.FC<Pro6PPInferProps>;
77
+ declare const Pro6PPInfer: React.ForwardRefExoticComponent<Pro6PPInferProps & React.RefAttributes<HTMLInputElement>>;
56
78
 
57
- export { Pro6PPInfer, type Pro6PPInferProps, useInfer };
79
+ export { Pro6PPInfer, type Pro6PPInferProps, type UseInferConfig, useInfer };