@pro6pp/infer-core 0.0.2-beta.4 → 0.0.2-beta.6

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 CHANGED
@@ -22,17 +22,28 @@ const core = new InferCore({
22
22
  authKey: 'YOUR_AUTH_KEY',
23
23
  country: 'NL',
24
24
  onStateChange: (state) => {
25
- console.log('Current Suggestions:', state.suggestions);
26
- console.log('Is Loading:', state.isLoading);
25
+ // suggestions, isLoading, isValid, selectedSuggestionIndex, etc.
26
+ console.log('Current State:', state);
27
27
  },
28
28
  onSelect: (result) => {
29
29
  console.log('User selected:', result);
30
30
  },
31
31
  });
32
32
 
33
- // feed it input events, e.g. via an <input>
34
- core.handleInput('Amsterdam');
33
+ const input = document.querySelector('#my-input');
35
34
 
36
- // handle selections when user clicks a suggestion in your dropdown
37
- core.selectItem(suggestionObject);
35
+ // pass input events to the core
36
+ input.addEventListener('input', (e) => {
37
+ core.handleInput(e.target.value);
38
+ });
39
+
40
+ // pass keyboard events
41
+ input.addEventListener('keydown', (e) => {
42
+ core.handleKeyDown(e);
43
+ });
44
+
45
+ // handle clicks
46
+ function onSuggestionClick(item) {
47
+ core.selectItem(item);
48
+ }
38
49
  ```
package/dist/index.cjs CHANGED
@@ -1 +1,99 @@
1
- "use strict";var o=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var m=(n,t,e)=>t in n?o(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var I=(n,t)=>{for(var e in t)o(n,e,{get:t[e],enumerable:!0})},y=(n,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of f(t))!S.call(n,r)&&r!==e&&o(n,r,{get:()=>t[r],enumerable:!(s=p(t,r))||s.enumerable});return n};var v=n=>y(o({},"__esModule",{value:!0}),n);var a=(n,t,e)=>m(n,typeof t!="symbol"?t+"":t,e);var x={};I(x,{INITIAL_STATE:()=>h,InferCore:()=>c});module.exports=v(x);var l={API_URL:"https://api.pro6pp.nl/v2",LIMIT:1e3,DEBOUNCE_MS:300},g={DIGITS_1_3:/^[0-9]{1,3}$/},h={query:"",stage:null,cities:[],streets:[],suggestions:[],isValid:!1,isError:!1,isLoading:!1,selectedSuggestionIndex:-1},c=class{constructor(t){a(this,"country");a(this,"authKey");a(this,"apiUrl");a(this,"limit");a(this,"fetcher");a(this,"onStateChange");a(this,"onSelect");a(this,"state");a(this,"abortController",null);a(this,"debouncedFetch");this.country=t.country,this.authKey=t.authKey,this.apiUrl=t.apiUrl||l.API_URL,this.limit=t.limit||l.LIMIT,this.fetcher=t.fetcher||((e,s)=>fetch(e,s)),this.onStateChange=t.onStateChange||(()=>{}),this.onSelect=t.onSelect||(()=>{}),this.state={...h},this.debouncedFetch=this.debounce(e=>this.executeFetch(e),l.DEBOUNCE_MS)}handleInput(t){this.updateState({query:t,isValid:!1,isLoading:!!t.trim(),selectedSuggestionIndex:-1}),this.state.stage==="final"&&this.onSelect(null),this.debouncedFetch(t)}handleKeyDown(t){let e=t.target;if(!e)return;let s=this.state.cities.length+this.state.streets.length+this.state.suggestions.length;if(s>0){if(t.key==="ArrowDown"){t.preventDefault();let i=this.state.selectedSuggestionIndex+1;i>=s&&(i=0),this.updateState({selectedSuggestionIndex:i});return}if(t.key==="ArrowUp"){t.preventDefault();let i=this.state.selectedSuggestionIndex-1;i<0&&(i=s-1),this.updateState({selectedSuggestionIndex:i});return}if(t.key==="Enter"&&this.state.selectedSuggestionIndex>=0){t.preventDefault();let u=[...this.state.cities,...this.state.streets,...this.state.suggestions][this.state.selectedSuggestionIndex];u&&(this.selectItem(u),this.updateState({selectedSuggestionIndex:-1}));return}}let r=e.value;if(t.key===" "&&this.shouldAutoInsertComma(r)){t.preventDefault();let i=`${r.trim()}, `;this.updateQueryAndFetch(i)}}selectItem(t){let e=typeof t=="string"?t:t.label,s=typeof t!="string"?t.value:void 0,r=typeof t!="string"?t.subtitle:null;if(this.state.stage==="final"){this.finishSelection(e,s);return}this.processSelection(e,r)}shouldAutoInsertComma(t){if(!t.includes(",")&&g.DIGITS_1_3.test(t.trim()))return!0;if(this.state.stage==="house_number"){let s=this.getCurrentFragment(t);return g.DIGITS_1_3.test(s)}return!1}finishSelection(t,e){this.updateState({query:t,suggestions:[],cities:[],streets:[],isValid:!0}),this.onSelect(e||t)}processSelection(t,e){let{stage:s,query:r}=this.state,i=r;if(e&&(s==="city"||s==="street"||s==="mixed")){if(s==="city")i=`${e}, ${t}, `;else{let d=this.getQueryPrefix(r);i=d?`${d} ${t}, ${e}, `:`${t}, ${e}, `}this.updateQueryAndFetch(i);return}if(s==="direct"||s==="addition"){this.finishSelection(t);return}!r.includes(",")&&(s==="city"||s==="street"||s==="house_number_first")?i=`${t}, `:(i=this.replaceLastSegment(r,t),s!=="house_number"&&(i+=", ")),this.updateQueryAndFetch(i)}executeFetch(t){let e=(t||"").toString();if(!e.trim()){this.abortController?.abort(),this.resetState();return}this.updateState({isError:!1}),this.abortController&&this.abortController.abort(),this.abortController=new AbortController;let s=new URL(`${this.apiUrl}/infer/${this.country.toLowerCase()}`),r={authKey:this.authKey,query:e,limit:this.limit.toString()};s.search=new URLSearchParams(r).toString(),this.fetcher(s.toString(),{signal:this.abortController.signal}).then(i=>{if(!i.ok)throw new Error("Network error");return i.json()}).then(i=>this.mapResponseToState(i)).catch(i=>{i.name!=="AbortError"&&this.updateState({isError:!0,isLoading:!1})})}mapResponseToState(t){let e={stage:t.stage,isLoading:!1};t.stage==="mixed"?(e.cities=t.cities||[],e.streets=t.streets||[],e.suggestions=[]):(e.suggestions=t.suggestions||[],e.cities=[],e.streets=[]),e.isValid=t.stage==="final",this.updateState(e)}updateQueryAndFetch(t){this.updateState({query:t,suggestions:[],cities:[],streets:[]}),this.handleInput(t)}replaceLastSegment(t,e){let s=t.lastIndexOf(",");return s===-1?e:`${t.slice(0,s+1)} ${e}`.trim()}getQueryPrefix(t){let e=t.lastIndexOf(",");return e===-1?"":t.slice(0,e+1).trimEnd()}getCurrentFragment(t){return(t.split(",").slice(-1)[0]??"").trim()}resetState(){this.updateState({...h,query:this.state.query})}updateState(t){this.state={...this.state,...t},this.onStateChange(this.state)}debounce(t,e){let s;return(...r)=>{s&&clearTimeout(s),s=setTimeout(()=>t.apply(this,r),e)}}};0&&(module.exports={INITIAL_STATE,InferCore});
1
+ "use strict";var c=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var C=(n,e,t)=>e in n?c(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var T=(n,e)=>{for(var t in e)c(n,t,{get:e[t],enumerable:!0})},w=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of v(e))!I.call(n,i)&&i!==t&&c(n,i,{get:()=>e[i],enumerable:!(s=y(e,i))||s.enumerable});return n};var _=n=>w(c({},"__esModule",{value:!0}),n);var o=(n,e,t)=>C(n,typeof e!="symbol"?e+"":e,t);var F={};T(F,{DEFAULT_STYLES:()=>b,INITIAL_STATE:()=>h,InferCore:()=>g});module.exports=_(F);var d={API_URL:"https://api.pro6pp.nl/v2",LIMIT:1e3,DEBOUNCE_MS:150,MIN_DEBOUNCE_MS:50},m={DIGITS_1_3:/^[0-9]{1,3}$/},h={query:"",stage:null,cities:[],streets:[],suggestions:[],isValid:!1,isError:!1,isLoading:!1,selectedSuggestionIndex:-1},g=class{constructor(e){o(this,"country");o(this,"authKey");o(this,"apiUrl");o(this,"limit");o(this,"fetcher");o(this,"onStateChange");o(this,"onSelect");o(this,"state");o(this,"abortController",null);o(this,"debouncedFetch");o(this,"isSelecting",!1);this.country=e.country,this.authKey=e.authKey,this.apiUrl=e.apiUrl||d.API_URL,this.limit=e.limit||d.LIMIT,this.fetcher=e.fetcher||((i,r)=>fetch(i,r)),this.onStateChange=e.onStateChange||(()=>{}),this.onSelect=e.onSelect||(()=>{}),this.state={...h};let t=e.debounceMs!==void 0?e.debounceMs:d.DEBOUNCE_MS,s=Math.max(t,d.MIN_DEBOUNCE_MS);this.debouncedFetch=this.debounce(i=>this.executeFetch(i),s)}handleInput(e){if(this.isSelecting){this.isSelecting=!1;return}let t=this.state.stage==="final"&&e!==this.state.query;this.updateState({query:e,isValid:!1,isLoading:!!e.trim(),selectedSuggestionIndex:-1}),t&&this.onSelect(null),this.debouncedFetch(e)}handleKeyDown(e){let t=e.target;if(!t)return;let s=this.state.cities.length+this.state.streets.length+this.state.suggestions.length;if(s>0){if(e.key==="ArrowDown"){e.preventDefault();let r=this.state.selectedSuggestionIndex+1;r>=s&&(r=0),this.updateState({selectedSuggestionIndex:r});return}if(e.key==="ArrowUp"){e.preventDefault();let r=this.state.selectedSuggestionIndex-1;r<0&&(r=s-1),this.updateState({selectedSuggestionIndex:r});return}if(e.key==="Enter"&&this.state.selectedSuggestionIndex>=0){e.preventDefault();let a=[...this.state.cities,...this.state.streets,...this.state.suggestions][this.state.selectedSuggestionIndex];a&&(this.selectItem(a),this.updateState({selectedSuggestionIndex:-1}));return}}let i=t.value;if(e.key===" "&&this.shouldAutoInsertComma(i)){e.preventDefault();let r=`${i.trim()}, `;this.updateQueryAndFetch(r)}}selectItem(e){this.debouncedFetch.cancel(),this.abortController&&this.abortController.abort();let t=typeof e=="string"?e:e.label,s=t;typeof e!="string"&&typeof e.value=="string"&&(s=e.value);let i=typeof e!="string"&&typeof e.value=="object"?e.value:void 0,r=!!i&&Object.keys(i).length>0;if(this.isSelecting=!0,this.state.stage==="final"||r){let p=t;if(i&&Object.keys(i).length>0){let{street:l,street_number:u,house_number:x,city:f}=i,S=u||x;l&&S&&f&&(p=`${l} ${S}, ${f}`)}this.finishSelection(p,i);return}let a=typeof e!="string"?e.subtitle:null;this.processSelection(s,a)}shouldAutoInsertComma(e){if(!e.includes(",")&&m.DIGITS_1_3.test(e.trim()))return!0;if(this.state.stage==="house_number"){let s=this.getCurrentFragment(e);return m.DIGITS_1_3.test(s)}return!1}finishSelection(e,t){this.updateState({query:e,suggestions:[],cities:[],streets:[],isValid:!0,stage:"final"}),this.onSelect(t||e),setTimeout(()=>{this.isSelecting=!1},0)}processSelection(e,t){let{stage:s,query:i}=this.state,r=i;if(t&&(s==="city"||s==="street"||s==="mixed")){if(s==="city")r=`${t}, ${e}, `;else{let u=this.getQueryPrefix(i);r=u?`${u} ${e}, ${t}, `:`${e}, ${t}, `}this.updateQueryAndFetch(r);return}if(s==="direct"||s==="addition"){this.finishSelection(e);return}!i.includes(",")&&(s==="city"||s==="street"||s==="house_number_first")?r=`${e}, `:(r=this.replaceLastSegment(i,e),s!=="house_number"&&(r+=", ")),this.updateQueryAndFetch(r)}executeFetch(e){let t=(e||"").toString();if(!t.trim()){this.abortController?.abort(),this.resetState();return}this.updateState({isError:!1}),this.abortController&&this.abortController.abort(),this.abortController=new AbortController;let s=new URL(`${this.apiUrl}/infer/${this.country.toLowerCase()}`),i={authKey:this.authKey,query:t,limit:this.limit.toString()};s.search=new URLSearchParams(i).toString(),this.fetcher(s.toString(),{signal:this.abortController.signal}).then(r=>{if(!r.ok)throw new Error("Network error");return r.json()}).then(r=>this.mapResponseToState(r)).catch(r=>{r.name!=="AbortError"&&this.updateState({isError:!0,isLoading:!1})})}mapResponseToState(e){let t={stage:e.stage,isLoading:!1},s=!1,i=null,r=e.suggestions||[],a=[],p=new Set;for(let l of r){let u=`${l.label}|${l.subtitle||""}|${JSON.stringify(l.value||{})}`;p.has(u)||(p.add(u),a.push(l))}if(e.stage==="mixed"?(t.cities=e.cities||[],t.streets=e.streets||[],t.suggestions=[]):(t.suggestions=a,t.cities=[],t.streets=[],e.stage==="final"&&a.length===1&&(s=!0,i=a[0])),t.isValid=e.stage==="final",s&&i){t.query=i.label,t.suggestions=[],t.cities=[],t.streets=[],t.isValid=!0,this.updateState(t);let l=typeof i.value=="object"?i.value:i.label;this.onSelect(l)}else this.updateState(t)}updateQueryAndFetch(e){this.updateState({query:e,suggestions:[],cities:[],streets:[]}),this.updateState({isLoading:!0,isValid:!1}),this.debouncedFetch(e),setTimeout(()=>{this.isSelecting=!1},0)}replaceLastSegment(e,t){let s=e.lastIndexOf(",");return s===-1?t:`${e.slice(0,s+1)} ${t}`.trim()}getQueryPrefix(e){let t=e.lastIndexOf(",");return t===-1?"":e.slice(0,t+1).trimEnd()}getCurrentFragment(e){return(e.split(",").slice(-1)[0]??"").trim()}resetState(){this.updateState({...h,query:this.state.query})}updateState(e){this.state={...this.state,...e},this.onStateChange(this.state)}debounce(e,t){let s,i=(...r)=>{s&&clearTimeout(s),s=setTimeout(()=>e.apply(this,r),t)};return i.cancel=()=>{s&&(clearTimeout(s),s=void 0)},i}};var b=`
2
+ .pro6pp-wrapper {
3
+ position: relative;
4
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
5
+ box-sizing: border-box;
6
+ width: 100%;
7
+ }
8
+ .pro6pp-wrapper * {
9
+ box-sizing: border-box;
10
+ }
11
+ .pro6pp-input {
12
+ width: 100%;
13
+ padding: 10px 12px;
14
+ border: 1px solid #e0e0e0;
15
+ border-radius: 4px;
16
+ font-size: 16px;
17
+ line-height: 1.5;
18
+ transition: border-color 0.2s, box-shadow 0.2s;
19
+ }
20
+ .pro6pp-input:focus {
21
+ outline: none;
22
+ border-color: #3b82f6;
23
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
24
+ }
25
+ .pro6pp-dropdown {
26
+ position: absolute;
27
+ top: 100%;
28
+ left: 0;
29
+ right: 0;
30
+ z-index: 9999;
31
+ margin-top: 4px;
32
+ background: white;
33
+ border: 1px solid #e0e0e0;
34
+ border-radius: 4px;
35
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
36
+ max-height: 300px;
37
+ overflow-y: auto;
38
+ list-style: none !important;
39
+ padding: 0 !important;
40
+ margin: 0 !important;
41
+ }
42
+ .pro6pp-item {
43
+ padding: 10px 16px;
44
+ cursor: pointer;
45
+ display: flex;
46
+ flex-direction: row;
47
+ align-items: center;
48
+ color: #000000;
49
+ font-size: 14px;
50
+ line-height: 1.2;
51
+ white-space: nowrap;
52
+ overflow: hidden;
53
+ }
54
+ .pro6pp-item:hover, .pro6pp-item--active {
55
+ background-color: #f5f5f5;
56
+ }
57
+ .pro6pp-item__label {
58
+ font-weight: 500;
59
+ flex-shrink: 0;
60
+ }
61
+ .pro6pp-item__subtitle {
62
+ font-size: 14px;
63
+ color: #404040;
64
+ overflow: hidden;
65
+ text-overflow: ellipsis;
66
+ flex-shrink: 1;
67
+ }
68
+ .pro6pp-item__chevron {
69
+ margin-left: auto;
70
+ display: flex;
71
+ align-items: center;
72
+ color: #a3a3a3;
73
+ padding-left: 8px;
74
+ }
75
+ .pro6pp-no-results {
76
+ padding: 12px;
77
+ color: #555555;
78
+ font-size: 14px;
79
+ text-align: center;
80
+ user-select: none;
81
+ pointer-events: none;
82
+ }
83
+ .pro6pp-loader {
84
+ position: absolute;
85
+ right: 12px;
86
+ top: 50%;
87
+ transform: translateY(-50%);
88
+ width: 16px;
89
+ height: 16px;
90
+ border: 2px solid #e0e0e0;
91
+ border-top-color: #404040;
92
+ border-radius: 50%;
93
+ animation: pro6pp-spin 0.6s linear infinite;
94
+ pointer-events: none;
95
+ }
96
+ @keyframes pro6pp-spin {
97
+ to { transform: translateY(-50%) rotate(360deg); }
98
+ }
99
+ `;0&&(module.exports={DEFAULT_STYLES,INITIAL_STATE,InferCore});
package/dist/index.d.cts CHANGED
@@ -4,106 +4,139 @@
4
4
  type CountryCode = 'NL' | 'DE';
5
5
  /**
6
6
  * The current step in the address inference process.
7
+ * - `empty`: No input yet.
8
+ * - `mixed`: User is prompted to choose between cities and streets.
9
+ * - `street`: User is selecting a street.
10
+ * - `city`: User is selecting a city.
11
+ * - `postcode`: User is entering a postcode.
12
+ * - `house_number`: User is entering a house number.
13
+ * - `house_number_first`: Specialized mode where number is entered before street.
14
+ * - `addition`: Selecting a house number addition (e.g., 'A', 'III').
15
+ * - `direct`: Direct address hit (often via postcode).
16
+ * - `final`: A complete, valid address has been identified.
7
17
  */
8
18
  type Stage = 'empty' | 'mixed' | 'street' | 'city' | 'postcode' | 'house_number' | 'house_number_first' | 'addition' | 'direct' | 'final';
9
19
  /**
10
- * The standardized address object returned upon selection.
20
+ * The standardized address object returned upon a successful final selection.
11
21
  */
12
22
  interface AddressValue {
23
+ /** The name of the street. */
13
24
  street: string;
25
+ /** The name of the city/locality. */
14
26
  city: string;
27
+ /** The house number (formatted). */
15
28
  street_number?: string | number;
29
+ /** The house number (numeric part). */
16
30
  house_number?: string | number;
31
+ /** The postal code. */
17
32
  postcode?: string;
33
+ /** The full postal code including letters (country-specific). */
18
34
  postcode_full?: string;
35
+ /** The house number addition or suffix. */
19
36
  addition?: string;
20
37
  /** Allow for extra fields if API expands. */
21
38
  [key: string]: unknown;
22
39
  }
23
40
  /**
24
- * A single item in the dropdown list.
41
+ * A single item in the suggestion list.
25
42
  */
26
43
  interface InferResult {
27
- /** The text to display in the UI (e.g. "Amsterdam"). */
44
+ /** The text to display in the UI (e.g. "Main Street"). */
28
45
  label: string;
29
- /** The actual address data. Only present if this result completes an address. */
30
- value?: AddressValue;
31
- /** Helper text. */
46
+ /** The actual address data.
47
+ * Only present if this result completes an address or represents a specific entity.
48
+ */
49
+ value?: AddressValue | string;
50
+ /** Secondary information (e.g., city name when suggesting a street). */
32
51
  subtitle?: string | null;
33
- /** Number of underlying results (optional). */
52
+ /** Number of underlying results found for this suggestion. */
34
53
  count?: number | string;
35
54
  }
36
55
  /**
37
- * The complete state returned by the `useInfer` hook.
56
+ * The complete UI state managed by InferCore.
38
57
  */
39
58
  interface InferState {
40
- /** The current value of the input field. */
59
+ /** The current text value of the search input. */
41
60
  query: string;
42
- /** The current inference stage. */
61
+ /** The current logical stage of the address lookup. */
43
62
  stage: Stage | null;
44
- /** List of cities to display, specific to `mixed` mode. */
63
+ /** List of city suggestions (used in `mixed` stage). */
45
64
  cities: InferResult[];
46
- /** List of streets to display, specific to `mixed` mode. */
65
+ /** List of street suggestions (used in `mixed` stage). */
47
66
  streets: InferResult[];
48
- /** General suggestions to display. */
67
+ /** General list of suggestions for the current stage. */
49
68
  suggestions: InferResult[];
50
- /** True if a full, valid address has been selected. */
69
+ /** Flag indicating if the current selection is a complete, valid address. */
51
70
  isValid: boolean;
52
- /** True if the last network request failed. */
71
+ /** Flag indicating if the last API request failed. */
53
72
  isError: boolean;
54
- /** True if a network request is currently active. */
73
+ /** Flag indicating if a network request is currently in progress. */
55
74
  isLoading: boolean;
56
75
  /**
57
- * The index of the currently highlighted suggestion in the dropdown list.
58
- * - Values `>= 0` indicate an active item (for keyboard navigation).
59
- * - Value `-1` indicates no item is currently highlighted.
76
+ * The index of the currently highlighted suggestion.
77
+ * - `0` to `n`: An item is highlighted via keyboard navigation.
78
+ * - `-1`: No item is highlighted.
60
79
  */
61
80
  selectedSuggestionIndex: number;
62
81
  }
63
82
  /**
64
- * Custom fetch implementation, compatible with `window.fetch`.
65
- * Useful for server-side usage or testing.
83
+ * Custom fetch implementation, compatible with the Web Fetch API.
84
+ * Useful for Node.js environments or proxying requests.
66
85
  */
67
86
  type Fetcher = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
68
87
  /**
69
- * Configuration for Infer Core.
88
+ * Configuration options for the Infer engine.
70
89
  */
71
90
  interface InferConfig {
72
91
  /**
73
- * Pro6PP Authorization Key.
92
+ * Your Pro6PP Authorization Key.
74
93
  */
75
94
  authKey: string;
76
95
  /**
77
- * Country to search addresses in.
96
+ * The country to perform address lookups in.
78
97
  */
79
98
  country: CountryCode;
80
99
  /**
81
100
  * Base URL for the Pro6PP API.
82
- * Useful for proxying requests through your own backend.
83
101
  * @default 'https://api.pro6pp.nl/v2'
84
102
  */
85
103
  apiUrl?: string;
86
104
  /**
87
- * Custom fetch implementation.
88
- * Useful for server-side usage or testing.
105
+ * Custom fetch implementation for network requests.
106
+ * @default window.fetch
89
107
  */
90
108
  fetcher?: Fetcher;
91
109
  /**
92
- * Maximum number of results to return.
110
+ * Maximum number of suggestions to request from the API.
93
111
  * @default 1000
94
112
  */
95
113
  limit?: number;
96
114
  /**
97
- * Callback fired when the internal state changes.
115
+ * The delay in milliseconds before performing the API search.
116
+ * Note: A lower bound of 50ms is enforced to protect API stability.
117
+ * @default 150
118
+ */
119
+ debounceMs?: number;
120
+ /**
121
+ * Callback triggered whenever the internal state (suggestions, loading status, etc.) updates.
98
122
  */
99
123
  onStateChange?: (state: InferState) => void;
100
124
  /**
101
- * Callback fired when a user selects a full valid address.
125
+ * Callback triggered when a user selects an item.
126
+ * If the address is complete, returns an `AddressValue` object.
127
+ * If the selection is partial, returns a `string`.
102
128
  */
103
129
  onSelect?: (selection: AddressValue | string | null) => void;
104
130
  }
105
131
 
132
+ /**
133
+ * The initial state of the address inference engine.
134
+ */
106
135
  declare const INITIAL_STATE: InferState;
136
+ /**
137
+ * The core logic engine for Pro6PP Infer.
138
+ * Manages API communication, state transitions, and keyboard interaction logic.
139
+ */
107
140
  declare class InferCore {
108
141
  private country;
109
142
  private authKey;
@@ -112,16 +145,43 @@ declare class InferCore {
112
145
  private fetcher;
113
146
  private onStateChange;
114
147
  private onSelect;
148
+ /**
149
+ * The current read-only state of the engine.
150
+ * Use `onStateChange` to react to updates.
151
+ */
115
152
  state: InferState;
116
153
  private abortController;
117
154
  private debouncedFetch;
155
+ private isSelecting;
156
+ /**
157
+ * Initializes a new instance of the Infer engine.
158
+ * @param config The configuration object including API keys and callbacks.
159
+ */
118
160
  constructor(config: InferConfig);
161
+ /**
162
+ * Processes new text input from the user.
163
+ * Triggers a debounced API request and updates the internal state.
164
+ * @param value The raw string from the input field.
165
+ */
119
166
  handleInput(value: string): void;
167
+ /**
168
+ * Handles keyboard events for the input field.
169
+ * Supports:
170
+ * - `ArrowUp`/`ArrowDown`: Navigate through the suggestion list.
171
+ * - `Enter`: Select the currently highlighted suggestion.
172
+ * - `Space`: Automatically inserts a comma if a numeric house number is detected.
173
+ * @param event The keyboard event from the input element.
174
+ */
120
175
  handleKeyDown(event: KeyboardEvent | {
121
176
  key: string;
122
177
  target: EventTarget | null;
123
178
  preventDefault: () => void;
124
179
  }): void;
180
+ /**
181
+ * Manually selects a suggestion or a string value.
182
+ * This is typically called when a user clicks a suggestion in the UI.
183
+ * @param item The suggestion object or string to select.
184
+ */
125
185
  selectItem(item: InferResult | string): void;
126
186
  private shouldAutoInsertComma;
127
187
  private finishSelection;
@@ -137,4 +197,6 @@ declare class InferCore {
137
197
  private debounce;
138
198
  }
139
199
 
140
- export { type AddressValue, type CountryCode, type Fetcher, INITIAL_STATE, type InferConfig, InferCore, type InferResult, type InferState, type Stage };
200
+ declare const DEFAULT_STYLES = "\n .pro6pp-wrapper {\n position: relative;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif;\n box-sizing: border-box;\n width: 100%;\n }\n .pro6pp-wrapper * {\n box-sizing: border-box;\n }\n .pro6pp-input {\n width: 100%;\n padding: 10px 12px;\n border: 1px solid #e0e0e0;\n border-radius: 4px;\n font-size: 16px;\n line-height: 1.5;\n transition: border-color 0.2s, box-shadow 0.2s;\n }\n .pro6pp-input:focus {\n outline: none;\n border-color: #3b82f6;\n box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);\n }\n .pro6pp-dropdown {\n position: absolute;\n top: 100%;\n left: 0;\n right: 0;\n z-index: 9999;\n margin-top: 4px;\n background: white;\n border: 1px solid #e0e0e0;\n border-radius: 4px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);\n max-height: 300px;\n overflow-y: auto;\n list-style: none !important;\n padding: 0 !important;\n margin: 0 !important;\n }\n .pro6pp-item {\n padding: 10px 16px;\n cursor: pointer;\n display: flex;\n flex-direction: row;\n align-items: center;\n color: #000000;\n font-size: 14px;\n line-height: 1.2;\n white-space: nowrap;\n overflow: hidden;\n }\n .pro6pp-item:hover, .pro6pp-item--active {\n background-color: #f5f5f5;\n }\n .pro6pp-item__label {\n font-weight: 500;\n flex-shrink: 0;\n }\n .pro6pp-item__subtitle {\n font-size: 14px;\n color: #404040;\n overflow: hidden;\n text-overflow: ellipsis;\n flex-shrink: 1;\n }\n .pro6pp-item__chevron {\n margin-left: auto;\n display: flex;\n align-items: center;\n color: #a3a3a3;\n padding-left: 8px;\n }\n .pro6pp-no-results {\n padding: 12px;\n color: #555555;\n font-size: 14px;\n text-align: center;\n user-select: none;\n pointer-events: none;\n }\n .pro6pp-loader {\n position: absolute;\n right: 12px;\n top: 50%;\n transform: translateY(-50%);\n width: 16px;\n height: 16px;\n border: 2px solid #e0e0e0;\n border-top-color: #404040;\n border-radius: 50%;\n animation: pro6pp-spin 0.6s linear infinite;\n pointer-events: none;\n }\n @keyframes pro6pp-spin {\n to { transform: translateY(-50%) rotate(360deg); }\n }\n";
201
+
202
+ export { type AddressValue, type CountryCode, DEFAULT_STYLES, type Fetcher, INITIAL_STATE, type InferConfig, InferCore, type InferResult, type InferState, type Stage };
package/dist/index.d.ts CHANGED
@@ -4,106 +4,139 @@
4
4
  type CountryCode = 'NL' | 'DE';
5
5
  /**
6
6
  * The current step in the address inference process.
7
+ * - `empty`: No input yet.
8
+ * - `mixed`: User is prompted to choose between cities and streets.
9
+ * - `street`: User is selecting a street.
10
+ * - `city`: User is selecting a city.
11
+ * - `postcode`: User is entering a postcode.
12
+ * - `house_number`: User is entering a house number.
13
+ * - `house_number_first`: Specialized mode where number is entered before street.
14
+ * - `addition`: Selecting a house number addition (e.g., 'A', 'III').
15
+ * - `direct`: Direct address hit (often via postcode).
16
+ * - `final`: A complete, valid address has been identified.
7
17
  */
8
18
  type Stage = 'empty' | 'mixed' | 'street' | 'city' | 'postcode' | 'house_number' | 'house_number_first' | 'addition' | 'direct' | 'final';
9
19
  /**
10
- * The standardized address object returned upon selection.
20
+ * The standardized address object returned upon a successful final selection.
11
21
  */
12
22
  interface AddressValue {
23
+ /** The name of the street. */
13
24
  street: string;
25
+ /** The name of the city/locality. */
14
26
  city: string;
27
+ /** The house number (formatted). */
15
28
  street_number?: string | number;
29
+ /** The house number (numeric part). */
16
30
  house_number?: string | number;
31
+ /** The postal code. */
17
32
  postcode?: string;
33
+ /** The full postal code including letters (country-specific). */
18
34
  postcode_full?: string;
35
+ /** The house number addition or suffix. */
19
36
  addition?: string;
20
37
  /** Allow for extra fields if API expands. */
21
38
  [key: string]: unknown;
22
39
  }
23
40
  /**
24
- * A single item in the dropdown list.
41
+ * A single item in the suggestion list.
25
42
  */
26
43
  interface InferResult {
27
- /** The text to display in the UI (e.g. "Amsterdam"). */
44
+ /** The text to display in the UI (e.g. "Main Street"). */
28
45
  label: string;
29
- /** The actual address data. Only present if this result completes an address. */
30
- value?: AddressValue;
31
- /** Helper text. */
46
+ /** The actual address data.
47
+ * Only present if this result completes an address or represents a specific entity.
48
+ */
49
+ value?: AddressValue | string;
50
+ /** Secondary information (e.g., city name when suggesting a street). */
32
51
  subtitle?: string | null;
33
- /** Number of underlying results (optional). */
52
+ /** Number of underlying results found for this suggestion. */
34
53
  count?: number | string;
35
54
  }
36
55
  /**
37
- * The complete state returned by the `useInfer` hook.
56
+ * The complete UI state managed by InferCore.
38
57
  */
39
58
  interface InferState {
40
- /** The current value of the input field. */
59
+ /** The current text value of the search input. */
41
60
  query: string;
42
- /** The current inference stage. */
61
+ /** The current logical stage of the address lookup. */
43
62
  stage: Stage | null;
44
- /** List of cities to display, specific to `mixed` mode. */
63
+ /** List of city suggestions (used in `mixed` stage). */
45
64
  cities: InferResult[];
46
- /** List of streets to display, specific to `mixed` mode. */
65
+ /** List of street suggestions (used in `mixed` stage). */
47
66
  streets: InferResult[];
48
- /** General suggestions to display. */
67
+ /** General list of suggestions for the current stage. */
49
68
  suggestions: InferResult[];
50
- /** True if a full, valid address has been selected. */
69
+ /** Flag indicating if the current selection is a complete, valid address. */
51
70
  isValid: boolean;
52
- /** True if the last network request failed. */
71
+ /** Flag indicating if the last API request failed. */
53
72
  isError: boolean;
54
- /** True if a network request is currently active. */
73
+ /** Flag indicating if a network request is currently in progress. */
55
74
  isLoading: boolean;
56
75
  /**
57
- * The index of the currently highlighted suggestion in the dropdown list.
58
- * - Values `>= 0` indicate an active item (for keyboard navigation).
59
- * - Value `-1` indicates no item is currently highlighted.
76
+ * The index of the currently highlighted suggestion.
77
+ * - `0` to `n`: An item is highlighted via keyboard navigation.
78
+ * - `-1`: No item is highlighted.
60
79
  */
61
80
  selectedSuggestionIndex: number;
62
81
  }
63
82
  /**
64
- * Custom fetch implementation, compatible with `window.fetch`.
65
- * Useful for server-side usage or testing.
83
+ * Custom fetch implementation, compatible with the Web Fetch API.
84
+ * Useful for Node.js environments or proxying requests.
66
85
  */
67
86
  type Fetcher = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
68
87
  /**
69
- * Configuration for Infer Core.
88
+ * Configuration options for the Infer engine.
70
89
  */
71
90
  interface InferConfig {
72
91
  /**
73
- * Pro6PP Authorization Key.
92
+ * Your Pro6PP Authorization Key.
74
93
  */
75
94
  authKey: string;
76
95
  /**
77
- * Country to search addresses in.
96
+ * The country to perform address lookups in.
78
97
  */
79
98
  country: CountryCode;
80
99
  /**
81
100
  * Base URL for the Pro6PP API.
82
- * Useful for proxying requests through your own backend.
83
101
  * @default 'https://api.pro6pp.nl/v2'
84
102
  */
85
103
  apiUrl?: string;
86
104
  /**
87
- * Custom fetch implementation.
88
- * Useful for server-side usage or testing.
105
+ * Custom fetch implementation for network requests.
106
+ * @default window.fetch
89
107
  */
90
108
  fetcher?: Fetcher;
91
109
  /**
92
- * Maximum number of results to return.
110
+ * Maximum number of suggestions to request from the API.
93
111
  * @default 1000
94
112
  */
95
113
  limit?: number;
96
114
  /**
97
- * Callback fired when the internal state changes.
115
+ * The delay in milliseconds before performing the API search.
116
+ * Note: A lower bound of 50ms is enforced to protect API stability.
117
+ * @default 150
118
+ */
119
+ debounceMs?: number;
120
+ /**
121
+ * Callback triggered whenever the internal state (suggestions, loading status, etc.) updates.
98
122
  */
99
123
  onStateChange?: (state: InferState) => void;
100
124
  /**
101
- * Callback fired when a user selects a full valid address.
125
+ * Callback triggered when a user selects an item.
126
+ * If the address is complete, returns an `AddressValue` object.
127
+ * If the selection is partial, returns a `string`.
102
128
  */
103
129
  onSelect?: (selection: AddressValue | string | null) => void;
104
130
  }
105
131
 
132
+ /**
133
+ * The initial state of the address inference engine.
134
+ */
106
135
  declare const INITIAL_STATE: InferState;
136
+ /**
137
+ * The core logic engine for Pro6PP Infer.
138
+ * Manages API communication, state transitions, and keyboard interaction logic.
139
+ */
107
140
  declare class InferCore {
108
141
  private country;
109
142
  private authKey;
@@ -112,16 +145,43 @@ declare class InferCore {
112
145
  private fetcher;
113
146
  private onStateChange;
114
147
  private onSelect;
148
+ /**
149
+ * The current read-only state of the engine.
150
+ * Use `onStateChange` to react to updates.
151
+ */
115
152
  state: InferState;
116
153
  private abortController;
117
154
  private debouncedFetch;
155
+ private isSelecting;
156
+ /**
157
+ * Initializes a new instance of the Infer engine.
158
+ * @param config The configuration object including API keys and callbacks.
159
+ */
118
160
  constructor(config: InferConfig);
161
+ /**
162
+ * Processes new text input from the user.
163
+ * Triggers a debounced API request and updates the internal state.
164
+ * @param value The raw string from the input field.
165
+ */
119
166
  handleInput(value: string): void;
167
+ /**
168
+ * Handles keyboard events for the input field.
169
+ * Supports:
170
+ * - `ArrowUp`/`ArrowDown`: Navigate through the suggestion list.
171
+ * - `Enter`: Select the currently highlighted suggestion.
172
+ * - `Space`: Automatically inserts a comma if a numeric house number is detected.
173
+ * @param event The keyboard event from the input element.
174
+ */
120
175
  handleKeyDown(event: KeyboardEvent | {
121
176
  key: string;
122
177
  target: EventTarget | null;
123
178
  preventDefault: () => void;
124
179
  }): void;
180
+ /**
181
+ * Manually selects a suggestion or a string value.
182
+ * This is typically called when a user clicks a suggestion in the UI.
183
+ * @param item The suggestion object or string to select.
184
+ */
125
185
  selectItem(item: InferResult | string): void;
126
186
  private shouldAutoInsertComma;
127
187
  private finishSelection;
@@ -137,4 +197,6 @@ declare class InferCore {
137
197
  private debounce;
138
198
  }
139
199
 
140
- export { type AddressValue, type CountryCode, type Fetcher, INITIAL_STATE, type InferConfig, InferCore, type InferResult, type InferState, type Stage };
200
+ declare const DEFAULT_STYLES = "\n .pro6pp-wrapper {\n position: relative;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif;\n box-sizing: border-box;\n width: 100%;\n }\n .pro6pp-wrapper * {\n box-sizing: border-box;\n }\n .pro6pp-input {\n width: 100%;\n padding: 10px 12px;\n border: 1px solid #e0e0e0;\n border-radius: 4px;\n font-size: 16px;\n line-height: 1.5;\n transition: border-color 0.2s, box-shadow 0.2s;\n }\n .pro6pp-input:focus {\n outline: none;\n border-color: #3b82f6;\n box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);\n }\n .pro6pp-dropdown {\n position: absolute;\n top: 100%;\n left: 0;\n right: 0;\n z-index: 9999;\n margin-top: 4px;\n background: white;\n border: 1px solid #e0e0e0;\n border-radius: 4px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);\n max-height: 300px;\n overflow-y: auto;\n list-style: none !important;\n padding: 0 !important;\n margin: 0 !important;\n }\n .pro6pp-item {\n padding: 10px 16px;\n cursor: pointer;\n display: flex;\n flex-direction: row;\n align-items: center;\n color: #000000;\n font-size: 14px;\n line-height: 1.2;\n white-space: nowrap;\n overflow: hidden;\n }\n .pro6pp-item:hover, .pro6pp-item--active {\n background-color: #f5f5f5;\n }\n .pro6pp-item__label {\n font-weight: 500;\n flex-shrink: 0;\n }\n .pro6pp-item__subtitle {\n font-size: 14px;\n color: #404040;\n overflow: hidden;\n text-overflow: ellipsis;\n flex-shrink: 1;\n }\n .pro6pp-item__chevron {\n margin-left: auto;\n display: flex;\n align-items: center;\n color: #a3a3a3;\n padding-left: 8px;\n }\n .pro6pp-no-results {\n padding: 12px;\n color: #555555;\n font-size: 14px;\n text-align: center;\n user-select: none;\n pointer-events: none;\n }\n .pro6pp-loader {\n position: absolute;\n right: 12px;\n top: 50%;\n transform: translateY(-50%);\n width: 16px;\n height: 16px;\n border: 2px solid #e0e0e0;\n border-top-color: #404040;\n border-radius: 50%;\n animation: pro6pp-spin 0.6s linear infinite;\n pointer-events: none;\n }\n @keyframes pro6pp-spin {\n to { transform: translateY(-50%) rotate(360deg); }\n }\n";
201
+
202
+ export { type AddressValue, type CountryCode, DEFAULT_STYLES, type Fetcher, INITIAL_STATE, type InferConfig, InferCore, type InferResult, type InferState, type Stage };
@@ -1 +1,99 @@
1
- "use strict";var Pro6PPCore=(()=>{var o=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var m=(n,t,e)=>t in n?o(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var I=(n,t)=>{for(var e in t)o(n,e,{get:t[e],enumerable:!0})},y=(n,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of f(t))!S.call(n,r)&&r!==e&&o(n,r,{get:()=>t[r],enumerable:!(s=p(t,r))||s.enumerable});return n};var v=n=>y(o({},"__esModule",{value:!0}),n);var a=(n,t,e)=>m(n,typeof t!="symbol"?t+"":t,e);var x={};I(x,{INITIAL_STATE:()=>h,InferCore:()=>c});var l={API_URL:"https://api.pro6pp.nl/v2",LIMIT:1e3,DEBOUNCE_MS:300},g={DIGITS_1_3:/^[0-9]{1,3}$/},h={query:"",stage:null,cities:[],streets:[],suggestions:[],isValid:!1,isError:!1,isLoading:!1,selectedSuggestionIndex:-1},c=class{constructor(t){a(this,"country");a(this,"authKey");a(this,"apiUrl");a(this,"limit");a(this,"fetcher");a(this,"onStateChange");a(this,"onSelect");a(this,"state");a(this,"abortController",null);a(this,"debouncedFetch");this.country=t.country,this.authKey=t.authKey,this.apiUrl=t.apiUrl||l.API_URL,this.limit=t.limit||l.LIMIT,this.fetcher=t.fetcher||((e,s)=>fetch(e,s)),this.onStateChange=t.onStateChange||(()=>{}),this.onSelect=t.onSelect||(()=>{}),this.state={...h},this.debouncedFetch=this.debounce(e=>this.executeFetch(e),l.DEBOUNCE_MS)}handleInput(t){this.updateState({query:t,isValid:!1,isLoading:!!t.trim(),selectedSuggestionIndex:-1}),this.state.stage==="final"&&this.onSelect(null),this.debouncedFetch(t)}handleKeyDown(t){let e=t.target;if(!e)return;let s=this.state.cities.length+this.state.streets.length+this.state.suggestions.length;if(s>0){if(t.key==="ArrowDown"){t.preventDefault();let i=this.state.selectedSuggestionIndex+1;i>=s&&(i=0),this.updateState({selectedSuggestionIndex:i});return}if(t.key==="ArrowUp"){t.preventDefault();let i=this.state.selectedSuggestionIndex-1;i<0&&(i=s-1),this.updateState({selectedSuggestionIndex:i});return}if(t.key==="Enter"&&this.state.selectedSuggestionIndex>=0){t.preventDefault();let u=[...this.state.cities,...this.state.streets,...this.state.suggestions][this.state.selectedSuggestionIndex];u&&(this.selectItem(u),this.updateState({selectedSuggestionIndex:-1}));return}}let r=e.value;if(t.key===" "&&this.shouldAutoInsertComma(r)){t.preventDefault();let i=`${r.trim()}, `;this.updateQueryAndFetch(i)}}selectItem(t){let e=typeof t=="string"?t:t.label,s=typeof t!="string"?t.value:void 0,r=typeof t!="string"?t.subtitle:null;if(this.state.stage==="final"){this.finishSelection(e,s);return}this.processSelection(e,r)}shouldAutoInsertComma(t){if(!t.includes(",")&&g.DIGITS_1_3.test(t.trim()))return!0;if(this.state.stage==="house_number"){let s=this.getCurrentFragment(t);return g.DIGITS_1_3.test(s)}return!1}finishSelection(t,e){this.updateState({query:t,suggestions:[],cities:[],streets:[],isValid:!0}),this.onSelect(e||t)}processSelection(t,e){let{stage:s,query:r}=this.state,i=r;if(e&&(s==="city"||s==="street"||s==="mixed")){if(s==="city")i=`${e}, ${t}, `;else{let d=this.getQueryPrefix(r);i=d?`${d} ${t}, ${e}, `:`${t}, ${e}, `}this.updateQueryAndFetch(i);return}if(s==="direct"||s==="addition"){this.finishSelection(t);return}!r.includes(",")&&(s==="city"||s==="street"||s==="house_number_first")?i=`${t}, `:(i=this.replaceLastSegment(r,t),s!=="house_number"&&(i+=", ")),this.updateQueryAndFetch(i)}executeFetch(t){let e=(t||"").toString();if(!e.trim()){this.abortController?.abort(),this.resetState();return}this.updateState({isError:!1}),this.abortController&&this.abortController.abort(),this.abortController=new AbortController;let s=new URL(`${this.apiUrl}/infer/${this.country.toLowerCase()}`),r={authKey:this.authKey,query:e,limit:this.limit.toString()};s.search=new URLSearchParams(r).toString(),this.fetcher(s.toString(),{signal:this.abortController.signal}).then(i=>{if(!i.ok)throw new Error("Network error");return i.json()}).then(i=>this.mapResponseToState(i)).catch(i=>{i.name!=="AbortError"&&this.updateState({isError:!0,isLoading:!1})})}mapResponseToState(t){let e={stage:t.stage,isLoading:!1};t.stage==="mixed"?(e.cities=t.cities||[],e.streets=t.streets||[],e.suggestions=[]):(e.suggestions=t.suggestions||[],e.cities=[],e.streets=[]),e.isValid=t.stage==="final",this.updateState(e)}updateQueryAndFetch(t){this.updateState({query:t,suggestions:[],cities:[],streets:[]}),this.handleInput(t)}replaceLastSegment(t,e){let s=t.lastIndexOf(",");return s===-1?e:`${t.slice(0,s+1)} ${e}`.trim()}getQueryPrefix(t){let e=t.lastIndexOf(",");return e===-1?"":t.slice(0,e+1).trimEnd()}getCurrentFragment(t){return(t.split(",").slice(-1)[0]??"").trim()}resetState(){this.updateState({...h,query:this.state.query})}updateState(t){this.state={...this.state,...t},this.onStateChange(this.state)}debounce(t,e){let s;return(...r)=>{s&&clearTimeout(s),s=setTimeout(()=>t.apply(this,r),e)}}};return v(x);})();
1
+ "use strict";var Pro6PPCore=(()=>{var c=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var C=(n,e,t)=>e in n?c(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var T=(n,e)=>{for(var t in e)c(n,t,{get:e[t],enumerable:!0})},w=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of v(e))!I.call(n,i)&&i!==t&&c(n,i,{get:()=>e[i],enumerable:!(s=y(e,i))||s.enumerable});return n};var _=n=>w(c({},"__esModule",{value:!0}),n);var o=(n,e,t)=>C(n,typeof e!="symbol"?e+"":e,t);var F={};T(F,{DEFAULT_STYLES:()=>b,INITIAL_STATE:()=>h,InferCore:()=>g});var d={API_URL:"https://api.pro6pp.nl/v2",LIMIT:1e3,DEBOUNCE_MS:150,MIN_DEBOUNCE_MS:50},m={DIGITS_1_3:/^[0-9]{1,3}$/},h={query:"",stage:null,cities:[],streets:[],suggestions:[],isValid:!1,isError:!1,isLoading:!1,selectedSuggestionIndex:-1},g=class{constructor(e){o(this,"country");o(this,"authKey");o(this,"apiUrl");o(this,"limit");o(this,"fetcher");o(this,"onStateChange");o(this,"onSelect");o(this,"state");o(this,"abortController",null);o(this,"debouncedFetch");o(this,"isSelecting",!1);this.country=e.country,this.authKey=e.authKey,this.apiUrl=e.apiUrl||d.API_URL,this.limit=e.limit||d.LIMIT,this.fetcher=e.fetcher||((i,r)=>fetch(i,r)),this.onStateChange=e.onStateChange||(()=>{}),this.onSelect=e.onSelect||(()=>{}),this.state={...h};let t=e.debounceMs!==void 0?e.debounceMs:d.DEBOUNCE_MS,s=Math.max(t,d.MIN_DEBOUNCE_MS);this.debouncedFetch=this.debounce(i=>this.executeFetch(i),s)}handleInput(e){if(this.isSelecting){this.isSelecting=!1;return}let t=this.state.stage==="final"&&e!==this.state.query;this.updateState({query:e,isValid:!1,isLoading:!!e.trim(),selectedSuggestionIndex:-1}),t&&this.onSelect(null),this.debouncedFetch(e)}handleKeyDown(e){let t=e.target;if(!t)return;let s=this.state.cities.length+this.state.streets.length+this.state.suggestions.length;if(s>0){if(e.key==="ArrowDown"){e.preventDefault();let r=this.state.selectedSuggestionIndex+1;r>=s&&(r=0),this.updateState({selectedSuggestionIndex:r});return}if(e.key==="ArrowUp"){e.preventDefault();let r=this.state.selectedSuggestionIndex-1;r<0&&(r=s-1),this.updateState({selectedSuggestionIndex:r});return}if(e.key==="Enter"&&this.state.selectedSuggestionIndex>=0){e.preventDefault();let a=[...this.state.cities,...this.state.streets,...this.state.suggestions][this.state.selectedSuggestionIndex];a&&(this.selectItem(a),this.updateState({selectedSuggestionIndex:-1}));return}}let i=t.value;if(e.key===" "&&this.shouldAutoInsertComma(i)){e.preventDefault();let r=`${i.trim()}, `;this.updateQueryAndFetch(r)}}selectItem(e){this.debouncedFetch.cancel(),this.abortController&&this.abortController.abort();let t=typeof e=="string"?e:e.label,s=t;typeof e!="string"&&typeof e.value=="string"&&(s=e.value);let i=typeof e!="string"&&typeof e.value=="object"?e.value:void 0,r=!!i&&Object.keys(i).length>0;if(this.isSelecting=!0,this.state.stage==="final"||r){let p=t;if(i&&Object.keys(i).length>0){let{street:l,street_number:u,house_number:x,city:f}=i,S=u||x;l&&S&&f&&(p=`${l} ${S}, ${f}`)}this.finishSelection(p,i);return}let a=typeof e!="string"?e.subtitle:null;this.processSelection(s,a)}shouldAutoInsertComma(e){if(!e.includes(",")&&m.DIGITS_1_3.test(e.trim()))return!0;if(this.state.stage==="house_number"){let s=this.getCurrentFragment(e);return m.DIGITS_1_3.test(s)}return!1}finishSelection(e,t){this.updateState({query:e,suggestions:[],cities:[],streets:[],isValid:!0,stage:"final"}),this.onSelect(t||e),setTimeout(()=>{this.isSelecting=!1},0)}processSelection(e,t){let{stage:s,query:i}=this.state,r=i;if(t&&(s==="city"||s==="street"||s==="mixed")){if(s==="city")r=`${t}, ${e}, `;else{let u=this.getQueryPrefix(i);r=u?`${u} ${e}, ${t}, `:`${e}, ${t}, `}this.updateQueryAndFetch(r);return}if(s==="direct"||s==="addition"){this.finishSelection(e);return}!i.includes(",")&&(s==="city"||s==="street"||s==="house_number_first")?r=`${e}, `:(r=this.replaceLastSegment(i,e),s!=="house_number"&&(r+=", ")),this.updateQueryAndFetch(r)}executeFetch(e){let t=(e||"").toString();if(!t.trim()){this.abortController?.abort(),this.resetState();return}this.updateState({isError:!1}),this.abortController&&this.abortController.abort(),this.abortController=new AbortController;let s=new URL(`${this.apiUrl}/infer/${this.country.toLowerCase()}`),i={authKey:this.authKey,query:t,limit:this.limit.toString()};s.search=new URLSearchParams(i).toString(),this.fetcher(s.toString(),{signal:this.abortController.signal}).then(r=>{if(!r.ok)throw new Error("Network error");return r.json()}).then(r=>this.mapResponseToState(r)).catch(r=>{r.name!=="AbortError"&&this.updateState({isError:!0,isLoading:!1})})}mapResponseToState(e){let t={stage:e.stage,isLoading:!1},s=!1,i=null,r=e.suggestions||[],a=[],p=new Set;for(let l of r){let u=`${l.label}|${l.subtitle||""}|${JSON.stringify(l.value||{})}`;p.has(u)||(p.add(u),a.push(l))}if(e.stage==="mixed"?(t.cities=e.cities||[],t.streets=e.streets||[],t.suggestions=[]):(t.suggestions=a,t.cities=[],t.streets=[],e.stage==="final"&&a.length===1&&(s=!0,i=a[0])),t.isValid=e.stage==="final",s&&i){t.query=i.label,t.suggestions=[],t.cities=[],t.streets=[],t.isValid=!0,this.updateState(t);let l=typeof i.value=="object"?i.value:i.label;this.onSelect(l)}else this.updateState(t)}updateQueryAndFetch(e){this.updateState({query:e,suggestions:[],cities:[],streets:[]}),this.updateState({isLoading:!0,isValid:!1}),this.debouncedFetch(e),setTimeout(()=>{this.isSelecting=!1},0)}replaceLastSegment(e,t){let s=e.lastIndexOf(",");return s===-1?t:`${e.slice(0,s+1)} ${t}`.trim()}getQueryPrefix(e){let t=e.lastIndexOf(",");return t===-1?"":e.slice(0,t+1).trimEnd()}getCurrentFragment(e){return(e.split(",").slice(-1)[0]??"").trim()}resetState(){this.updateState({...h,query:this.state.query})}updateState(e){this.state={...this.state,...e},this.onStateChange(this.state)}debounce(e,t){let s,i=(...r)=>{s&&clearTimeout(s),s=setTimeout(()=>e.apply(this,r),t)};return i.cancel=()=>{s&&(clearTimeout(s),s=void 0)},i}};var b=`
2
+ .pro6pp-wrapper {
3
+ position: relative;
4
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
5
+ box-sizing: border-box;
6
+ width: 100%;
7
+ }
8
+ .pro6pp-wrapper * {
9
+ box-sizing: border-box;
10
+ }
11
+ .pro6pp-input {
12
+ width: 100%;
13
+ padding: 10px 12px;
14
+ border: 1px solid #e0e0e0;
15
+ border-radius: 4px;
16
+ font-size: 16px;
17
+ line-height: 1.5;
18
+ transition: border-color 0.2s, box-shadow 0.2s;
19
+ }
20
+ .pro6pp-input:focus {
21
+ outline: none;
22
+ border-color: #3b82f6;
23
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
24
+ }
25
+ .pro6pp-dropdown {
26
+ position: absolute;
27
+ top: 100%;
28
+ left: 0;
29
+ right: 0;
30
+ z-index: 9999;
31
+ margin-top: 4px;
32
+ background: white;
33
+ border: 1px solid #e0e0e0;
34
+ border-radius: 4px;
35
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
36
+ max-height: 300px;
37
+ overflow-y: auto;
38
+ list-style: none !important;
39
+ padding: 0 !important;
40
+ margin: 0 !important;
41
+ }
42
+ .pro6pp-item {
43
+ padding: 10px 16px;
44
+ cursor: pointer;
45
+ display: flex;
46
+ flex-direction: row;
47
+ align-items: center;
48
+ color: #000000;
49
+ font-size: 14px;
50
+ line-height: 1.2;
51
+ white-space: nowrap;
52
+ overflow: hidden;
53
+ }
54
+ .pro6pp-item:hover, .pro6pp-item--active {
55
+ background-color: #f5f5f5;
56
+ }
57
+ .pro6pp-item__label {
58
+ font-weight: 500;
59
+ flex-shrink: 0;
60
+ }
61
+ .pro6pp-item__subtitle {
62
+ font-size: 14px;
63
+ color: #404040;
64
+ overflow: hidden;
65
+ text-overflow: ellipsis;
66
+ flex-shrink: 1;
67
+ }
68
+ .pro6pp-item__chevron {
69
+ margin-left: auto;
70
+ display: flex;
71
+ align-items: center;
72
+ color: #a3a3a3;
73
+ padding-left: 8px;
74
+ }
75
+ .pro6pp-no-results {
76
+ padding: 12px;
77
+ color: #555555;
78
+ font-size: 14px;
79
+ text-align: center;
80
+ user-select: none;
81
+ pointer-events: none;
82
+ }
83
+ .pro6pp-loader {
84
+ position: absolute;
85
+ right: 12px;
86
+ top: 50%;
87
+ transform: translateY(-50%);
88
+ width: 16px;
89
+ height: 16px;
90
+ border: 2px solid #e0e0e0;
91
+ border-top-color: #404040;
92
+ border-radius: 50%;
93
+ animation: pro6pp-spin 0.6s linear infinite;
94
+ pointer-events: none;
95
+ }
96
+ @keyframes pro6pp-spin {
97
+ to { transform: translateY(-50%) rotate(360deg); }
98
+ }
99
+ `;return _(F);})();
package/dist/index.js CHANGED
@@ -1 +1,99 @@
1
- var g=Object.defineProperty;var p=(a,t,e)=>t in a?g(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var n=(a,t,e)=>p(a,typeof t!="symbol"?t+"":t,e);var u={API_URL:"https://api.pro6pp.nl/v2",LIMIT:1e3,DEBOUNCE_MS:300},h={DIGITS_1_3:/^[0-9]{1,3}$/},c={query:"",stage:null,cities:[],streets:[],suggestions:[],isValid:!1,isError:!1,isLoading:!1,selectedSuggestionIndex:-1},d=class{constructor(t){n(this,"country");n(this,"authKey");n(this,"apiUrl");n(this,"limit");n(this,"fetcher");n(this,"onStateChange");n(this,"onSelect");n(this,"state");n(this,"abortController",null);n(this,"debouncedFetch");this.country=t.country,this.authKey=t.authKey,this.apiUrl=t.apiUrl||u.API_URL,this.limit=t.limit||u.LIMIT,this.fetcher=t.fetcher||((e,s)=>fetch(e,s)),this.onStateChange=t.onStateChange||(()=>{}),this.onSelect=t.onSelect||(()=>{}),this.state={...c},this.debouncedFetch=this.debounce(e=>this.executeFetch(e),u.DEBOUNCE_MS)}handleInput(t){this.updateState({query:t,isValid:!1,isLoading:!!t.trim(),selectedSuggestionIndex:-1}),this.state.stage==="final"&&this.onSelect(null),this.debouncedFetch(t)}handleKeyDown(t){let e=t.target;if(!e)return;let s=this.state.cities.length+this.state.streets.length+this.state.suggestions.length;if(s>0){if(t.key==="ArrowDown"){t.preventDefault();let i=this.state.selectedSuggestionIndex+1;i>=s&&(i=0),this.updateState({selectedSuggestionIndex:i});return}if(t.key==="ArrowUp"){t.preventDefault();let i=this.state.selectedSuggestionIndex-1;i<0&&(i=s-1),this.updateState({selectedSuggestionIndex:i});return}if(t.key==="Enter"&&this.state.selectedSuggestionIndex>=0){t.preventDefault();let o=[...this.state.cities,...this.state.streets,...this.state.suggestions][this.state.selectedSuggestionIndex];o&&(this.selectItem(o),this.updateState({selectedSuggestionIndex:-1}));return}}let r=e.value;if(t.key===" "&&this.shouldAutoInsertComma(r)){t.preventDefault();let i=`${r.trim()}, `;this.updateQueryAndFetch(i)}}selectItem(t){let e=typeof t=="string"?t:t.label,s=typeof t!="string"?t.value:void 0,r=typeof t!="string"?t.subtitle:null;if(this.state.stage==="final"){this.finishSelection(e,s);return}this.processSelection(e,r)}shouldAutoInsertComma(t){if(!t.includes(",")&&h.DIGITS_1_3.test(t.trim()))return!0;if(this.state.stage==="house_number"){let s=this.getCurrentFragment(t);return h.DIGITS_1_3.test(s)}return!1}finishSelection(t,e){this.updateState({query:t,suggestions:[],cities:[],streets:[],isValid:!0}),this.onSelect(e||t)}processSelection(t,e){let{stage:s,query:r}=this.state,i=r;if(e&&(s==="city"||s==="street"||s==="mixed")){if(s==="city")i=`${e}, ${t}, `;else{let l=this.getQueryPrefix(r);i=l?`${l} ${t}, ${e}, `:`${t}, ${e}, `}this.updateQueryAndFetch(i);return}if(s==="direct"||s==="addition"){this.finishSelection(t);return}!r.includes(",")&&(s==="city"||s==="street"||s==="house_number_first")?i=`${t}, `:(i=this.replaceLastSegment(r,t),s!=="house_number"&&(i+=", ")),this.updateQueryAndFetch(i)}executeFetch(t){let e=(t||"").toString();if(!e.trim()){this.abortController?.abort(),this.resetState();return}this.updateState({isError:!1}),this.abortController&&this.abortController.abort(),this.abortController=new AbortController;let s=new URL(`${this.apiUrl}/infer/${this.country.toLowerCase()}`),r={authKey:this.authKey,query:e,limit:this.limit.toString()};s.search=new URLSearchParams(r).toString(),this.fetcher(s.toString(),{signal:this.abortController.signal}).then(i=>{if(!i.ok)throw new Error("Network error");return i.json()}).then(i=>this.mapResponseToState(i)).catch(i=>{i.name!=="AbortError"&&this.updateState({isError:!0,isLoading:!1})})}mapResponseToState(t){let e={stage:t.stage,isLoading:!1};t.stage==="mixed"?(e.cities=t.cities||[],e.streets=t.streets||[],e.suggestions=[]):(e.suggestions=t.suggestions||[],e.cities=[],e.streets=[]),e.isValid=t.stage==="final",this.updateState(e)}updateQueryAndFetch(t){this.updateState({query:t,suggestions:[],cities:[],streets:[]}),this.handleInput(t)}replaceLastSegment(t,e){let s=t.lastIndexOf(",");return s===-1?e:`${t.slice(0,s+1)} ${e}`.trim()}getQueryPrefix(t){let e=t.lastIndexOf(",");return e===-1?"":t.slice(0,e+1).trimEnd()}getCurrentFragment(t){return(t.split(",").slice(-1)[0]??"").trim()}resetState(){this.updateState({...c,query:this.state.query})}updateState(t){this.state={...this.state,...t},this.onStateChange(this.state)}debounce(t,e){let s;return(...r)=>{s&&clearTimeout(s),s=setTimeout(()=>t.apply(this,r),e)}}};export{c as INITIAL_STATE,d as InferCore};
1
+ var b=Object.defineProperty;var x=(u,e,t)=>e in u?b(u,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):u[e]=t;var n=(u,e,t)=>x(u,typeof e!="symbol"?e+"":e,t);var c={API_URL:"https://api.pro6pp.nl/v2",LIMIT:1e3,DEBOUNCE_MS:150,MIN_DEBOUNCE_MS:50},g={DIGITS_1_3:/^[0-9]{1,3}$/},f={query:"",stage:null,cities:[],streets:[],suggestions:[],isValid:!1,isError:!1,isLoading:!1,selectedSuggestionIndex:-1},S=class{constructor(e){n(this,"country");n(this,"authKey");n(this,"apiUrl");n(this,"limit");n(this,"fetcher");n(this,"onStateChange");n(this,"onSelect");n(this,"state");n(this,"abortController",null);n(this,"debouncedFetch");n(this,"isSelecting",!1);this.country=e.country,this.authKey=e.authKey,this.apiUrl=e.apiUrl||c.API_URL,this.limit=e.limit||c.LIMIT,this.fetcher=e.fetcher||((r,i)=>fetch(r,i)),this.onStateChange=e.onStateChange||(()=>{}),this.onSelect=e.onSelect||(()=>{}),this.state={...f};let t=e.debounceMs!==void 0?e.debounceMs:c.DEBOUNCE_MS,s=Math.max(t,c.MIN_DEBOUNCE_MS);this.debouncedFetch=this.debounce(r=>this.executeFetch(r),s)}handleInput(e){if(this.isSelecting){this.isSelecting=!1;return}let t=this.state.stage==="final"&&e!==this.state.query;this.updateState({query:e,isValid:!1,isLoading:!!e.trim(),selectedSuggestionIndex:-1}),t&&this.onSelect(null),this.debouncedFetch(e)}handleKeyDown(e){let t=e.target;if(!t)return;let s=this.state.cities.length+this.state.streets.length+this.state.suggestions.length;if(s>0){if(e.key==="ArrowDown"){e.preventDefault();let i=this.state.selectedSuggestionIndex+1;i>=s&&(i=0),this.updateState({selectedSuggestionIndex:i});return}if(e.key==="ArrowUp"){e.preventDefault();let i=this.state.selectedSuggestionIndex-1;i<0&&(i=s-1),this.updateState({selectedSuggestionIndex:i});return}if(e.key==="Enter"&&this.state.selectedSuggestionIndex>=0){e.preventDefault();let o=[...this.state.cities,...this.state.streets,...this.state.suggestions][this.state.selectedSuggestionIndex];o&&(this.selectItem(o),this.updateState({selectedSuggestionIndex:-1}));return}}let r=t.value;if(e.key===" "&&this.shouldAutoInsertComma(r)){e.preventDefault();let i=`${r.trim()}, `;this.updateQueryAndFetch(i)}}selectItem(e){this.debouncedFetch.cancel(),this.abortController&&this.abortController.abort();let t=typeof e=="string"?e:e.label,s=t;typeof e!="string"&&typeof e.value=="string"&&(s=e.value);let r=typeof e!="string"&&typeof e.value=="object"?e.value:void 0,i=!!r&&Object.keys(r).length>0;if(this.isSelecting=!0,this.state.stage==="final"||i){let p=t;if(r&&Object.keys(r).length>0){let{street:a,street_number:l,house_number:m,city:d}=r,h=l||m;a&&h&&d&&(p=`${a} ${h}, ${d}`)}this.finishSelection(p,r);return}let o=typeof e!="string"?e.subtitle:null;this.processSelection(s,o)}shouldAutoInsertComma(e){if(!e.includes(",")&&g.DIGITS_1_3.test(e.trim()))return!0;if(this.state.stage==="house_number"){let s=this.getCurrentFragment(e);return g.DIGITS_1_3.test(s)}return!1}finishSelection(e,t){this.updateState({query:e,suggestions:[],cities:[],streets:[],isValid:!0,stage:"final"}),this.onSelect(t||e),setTimeout(()=>{this.isSelecting=!1},0)}processSelection(e,t){let{stage:s,query:r}=this.state,i=r;if(t&&(s==="city"||s==="street"||s==="mixed")){if(s==="city")i=`${t}, ${e}, `;else{let l=this.getQueryPrefix(r);i=l?`${l} ${e}, ${t}, `:`${e}, ${t}, `}this.updateQueryAndFetch(i);return}if(s==="direct"||s==="addition"){this.finishSelection(e);return}!r.includes(",")&&(s==="city"||s==="street"||s==="house_number_first")?i=`${e}, `:(i=this.replaceLastSegment(r,e),s!=="house_number"&&(i+=", ")),this.updateQueryAndFetch(i)}executeFetch(e){let t=(e||"").toString();if(!t.trim()){this.abortController?.abort(),this.resetState();return}this.updateState({isError:!1}),this.abortController&&this.abortController.abort(),this.abortController=new AbortController;let s=new URL(`${this.apiUrl}/infer/${this.country.toLowerCase()}`),r={authKey:this.authKey,query:t,limit:this.limit.toString()};s.search=new URLSearchParams(r).toString(),this.fetcher(s.toString(),{signal:this.abortController.signal}).then(i=>{if(!i.ok)throw new Error("Network error");return i.json()}).then(i=>this.mapResponseToState(i)).catch(i=>{i.name!=="AbortError"&&this.updateState({isError:!0,isLoading:!1})})}mapResponseToState(e){let t={stage:e.stage,isLoading:!1},s=!1,r=null,i=e.suggestions||[],o=[],p=new Set;for(let a of i){let l=`${a.label}|${a.subtitle||""}|${JSON.stringify(a.value||{})}`;p.has(l)||(p.add(l),o.push(a))}if(e.stage==="mixed"?(t.cities=e.cities||[],t.streets=e.streets||[],t.suggestions=[]):(t.suggestions=o,t.cities=[],t.streets=[],e.stage==="final"&&o.length===1&&(s=!0,r=o[0])),t.isValid=e.stage==="final",s&&r){t.query=r.label,t.suggestions=[],t.cities=[],t.streets=[],t.isValid=!0,this.updateState(t);let a=typeof r.value=="object"?r.value:r.label;this.onSelect(a)}else this.updateState(t)}updateQueryAndFetch(e){this.updateState({query:e,suggestions:[],cities:[],streets:[]}),this.updateState({isLoading:!0,isValid:!1}),this.debouncedFetch(e),setTimeout(()=>{this.isSelecting=!1},0)}replaceLastSegment(e,t){let s=e.lastIndexOf(",");return s===-1?t:`${e.slice(0,s+1)} ${t}`.trim()}getQueryPrefix(e){let t=e.lastIndexOf(",");return t===-1?"":e.slice(0,t+1).trimEnd()}getCurrentFragment(e){return(e.split(",").slice(-1)[0]??"").trim()}resetState(){this.updateState({...f,query:this.state.query})}updateState(e){this.state={...this.state,...e},this.onStateChange(this.state)}debounce(e,t){let s,r=(...i)=>{s&&clearTimeout(s),s=setTimeout(()=>e.apply(this,i),t)};return r.cancel=()=>{s&&(clearTimeout(s),s=void 0)},r}};var y=`
2
+ .pro6pp-wrapper {
3
+ position: relative;
4
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
5
+ box-sizing: border-box;
6
+ width: 100%;
7
+ }
8
+ .pro6pp-wrapper * {
9
+ box-sizing: border-box;
10
+ }
11
+ .pro6pp-input {
12
+ width: 100%;
13
+ padding: 10px 12px;
14
+ border: 1px solid #e0e0e0;
15
+ border-radius: 4px;
16
+ font-size: 16px;
17
+ line-height: 1.5;
18
+ transition: border-color 0.2s, box-shadow 0.2s;
19
+ }
20
+ .pro6pp-input:focus {
21
+ outline: none;
22
+ border-color: #3b82f6;
23
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
24
+ }
25
+ .pro6pp-dropdown {
26
+ position: absolute;
27
+ top: 100%;
28
+ left: 0;
29
+ right: 0;
30
+ z-index: 9999;
31
+ margin-top: 4px;
32
+ background: white;
33
+ border: 1px solid #e0e0e0;
34
+ border-radius: 4px;
35
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
36
+ max-height: 300px;
37
+ overflow-y: auto;
38
+ list-style: none !important;
39
+ padding: 0 !important;
40
+ margin: 0 !important;
41
+ }
42
+ .pro6pp-item {
43
+ padding: 10px 16px;
44
+ cursor: pointer;
45
+ display: flex;
46
+ flex-direction: row;
47
+ align-items: center;
48
+ color: #000000;
49
+ font-size: 14px;
50
+ line-height: 1.2;
51
+ white-space: nowrap;
52
+ overflow: hidden;
53
+ }
54
+ .pro6pp-item:hover, .pro6pp-item--active {
55
+ background-color: #f5f5f5;
56
+ }
57
+ .pro6pp-item__label {
58
+ font-weight: 500;
59
+ flex-shrink: 0;
60
+ }
61
+ .pro6pp-item__subtitle {
62
+ font-size: 14px;
63
+ color: #404040;
64
+ overflow: hidden;
65
+ text-overflow: ellipsis;
66
+ flex-shrink: 1;
67
+ }
68
+ .pro6pp-item__chevron {
69
+ margin-left: auto;
70
+ display: flex;
71
+ align-items: center;
72
+ color: #a3a3a3;
73
+ padding-left: 8px;
74
+ }
75
+ .pro6pp-no-results {
76
+ padding: 12px;
77
+ color: #555555;
78
+ font-size: 14px;
79
+ text-align: center;
80
+ user-select: none;
81
+ pointer-events: none;
82
+ }
83
+ .pro6pp-loader {
84
+ position: absolute;
85
+ right: 12px;
86
+ top: 50%;
87
+ transform: translateY(-50%);
88
+ width: 16px;
89
+ height: 16px;
90
+ border: 2px solid #e0e0e0;
91
+ border-top-color: #404040;
92
+ border-radius: 50%;
93
+ animation: pro6pp-spin 0.6s linear infinite;
94
+ pointer-events: none;
95
+ }
96
+ @keyframes pro6pp-spin {
97
+ to { transform: translateY(-50%) rotate(360deg); }
98
+ }
99
+ `;export{y as DEFAULT_STYLES,f as INITIAL_STATE,S as InferCore};
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "url": "https://github.com/pro6pp/infer-sdk/issues"
23
23
  },
24
24
  "sideEffects": false,
25
- "version": "0.0.2-beta.4",
25
+ "version": "0.0.2-beta.6",
26
26
  "main": "./dist/index.cjs",
27
27
  "module": "./dist/index.js",
28
28
  "types": "./dist/index.d.ts",