@pro6pp/infer-react 0.0.2-beta.17 → 0.0.2-beta.18

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
@@ -47,6 +47,37 @@ You can customize the appearance of the component via the following props:
47
47
  | `showClearButton` | If `true`, displays a button to empty the input field. Defaults to `true`. |
48
48
  | `loadingText` | The text displayed at the bottom of the list when fetching more results. |
49
49
 
50
+ ## Styling
51
+
52
+ By default, the component auto-injects the necessary CSS. You have several options:
53
+
54
+ ### Option 1: Use auto-injected styles (default)
55
+
56
+ No extra setup needed. The CSS is embedded and injected automatically.
57
+
58
+ ### Option 2: Import CSS separately
59
+
60
+ If you prefer to import the CSS file directly:
61
+
62
+ ```tsx
63
+ import { Pro6PPInfer } from '@pro6pp/infer-react';
64
+ import '@pro6pp/infer-react/styles.css';
65
+
66
+ <Pro6PPInfer
67
+ authKey="..."
68
+ country="NL"
69
+ disableDefaultStyles // disable auto-injection since we imported the CSS
70
+ />;
71
+ ```
72
+
73
+ ### Option 3: Fully custom styles
74
+
75
+ Set `disableDefaultStyles` and provide your own CSS targeting the `.pro6pp-*` classes:
76
+
77
+ ```tsx
78
+ <Pro6PPInfer authKey="..." country="NL" disableDefaultStyles className="my-custom-wrapper" />
79
+ ```
80
+
50
81
  ---
51
82
 
52
83
  Alternatively, you can use the headless `useInfer` hook.
package/dist/index.cjs CHANGED
@@ -301,7 +301,7 @@ var InferCore = class {
301
301
  if (street && street_number && city) {
302
302
  const suffix = addition ? ` ${addition}` : "";
303
303
  const postcodeStr = postcode ? `${postcode}, ` : "";
304
- finalQuery = `${street} ${street_number}${suffix}, ${postcodeStr}${city}`;
304
+ finalQuery = `${street}, ${street_number}${suffix}, ${postcodeStr}${city}`;
305
305
  }
306
306
  }
307
307
  this.finishSelection(finalQuery, valueObj);
@@ -794,11 +794,12 @@ var HighlightedText = ({ text, query }) => {
794
794
  function useInfer(config) {
795
795
  const [state, setState] = (0, import_react.useState)(() => {
796
796
  if (config.initialValue) {
797
+ const suffix = config.initialValue.addition ? ` ${config.initialValue.addition}` : "";
797
798
  const postcodeStr = config.initialValue.postcode ? `${config.initialValue.postcode}, ` : "";
798
799
  return {
799
800
  ...INITIAL_STATE,
800
801
  value: config.initialValue,
801
- query: `${config.initialValue.street} ${config.initialValue.street_number}, ${postcodeStr}${config.initialValue.city}`,
802
+ query: `${config.initialValue.street}, ${config.initialValue.street_number}${suffix}, ${postcodeStr}${config.initialValue.city}`,
802
803
  isValid: true,
803
804
  stage: "final"
804
805
  };
@@ -828,8 +829,9 @@ function useInfer(config) {
828
829
  });
829
830
  if (config.initialValue) {
830
831
  const address = config.initialValue;
832
+ const suffix = address.addition ? ` ${address.addition}` : "";
831
833
  const postcodeStr = address.postcode ? `${address.postcode}, ` : "";
832
- const label = `${address.street} ${address.street_number}, ${postcodeStr}${address.city}`;
834
+ const label = `${address.street}, ${address.street_number}${suffix}, ${postcodeStr}${address.city}`;
833
835
  instance.selectItem({ label, value: address });
834
836
  }
835
837
  return instance;
@@ -845,8 +847,9 @@ function useInfer(config) {
845
847
  ]);
846
848
  const setValue = (address) => {
847
849
  if (!address) return;
850
+ const suffix = address.addition ? ` ${address.addition}` : "";
848
851
  const postcodeStr = address.postcode ? `${address.postcode}, ` : "";
849
- const label = `${address.street} ${address.street_number}, ${postcodeStr}${address.city}`;
852
+ const label = `${address.street}, ${address.street_number}${suffix}, ${postcodeStr}${address.city}`;
850
853
  core.selectItem({ label, value: address });
851
854
  };
852
855
  return {
package/dist/index.js CHANGED
@@ -275,7 +275,7 @@ var InferCore = class {
275
275
  if (street && street_number && city) {
276
276
  const suffix = addition ? ` ${addition}` : "";
277
277
  const postcodeStr = postcode ? `${postcode}, ` : "";
278
- finalQuery = `${street} ${street_number}${suffix}, ${postcodeStr}${city}`;
278
+ finalQuery = `${street}, ${street_number}${suffix}, ${postcodeStr}${city}`;
279
279
  }
280
280
  }
281
281
  this.finishSelection(finalQuery, valueObj);
@@ -768,11 +768,12 @@ var HighlightedText = ({ text, query }) => {
768
768
  function useInfer(config) {
769
769
  const [state, setState] = useState(() => {
770
770
  if (config.initialValue) {
771
+ const suffix = config.initialValue.addition ? ` ${config.initialValue.addition}` : "";
771
772
  const postcodeStr = config.initialValue.postcode ? `${config.initialValue.postcode}, ` : "";
772
773
  return {
773
774
  ...INITIAL_STATE,
774
775
  value: config.initialValue,
775
- query: `${config.initialValue.street} ${config.initialValue.street_number}, ${postcodeStr}${config.initialValue.city}`,
776
+ query: `${config.initialValue.street}, ${config.initialValue.street_number}${suffix}, ${postcodeStr}${config.initialValue.city}`,
776
777
  isValid: true,
777
778
  stage: "final"
778
779
  };
@@ -802,8 +803,9 @@ function useInfer(config) {
802
803
  });
803
804
  if (config.initialValue) {
804
805
  const address = config.initialValue;
806
+ const suffix = address.addition ? ` ${address.addition}` : "";
805
807
  const postcodeStr = address.postcode ? `${address.postcode}, ` : "";
806
- const label = `${address.street} ${address.street_number}, ${postcodeStr}${address.city}`;
808
+ const label = `${address.street}, ${address.street_number}${suffix}, ${postcodeStr}${address.city}`;
807
809
  instance.selectItem({ label, value: address });
808
810
  }
809
811
  return instance;
@@ -819,8 +821,9 @@ function useInfer(config) {
819
821
  ]);
820
822
  const setValue = (address) => {
821
823
  if (!address) return;
824
+ const suffix = address.addition ? ` ${address.addition}` : "";
822
825
  const postcodeStr = address.postcode ? `${address.postcode}, ` : "";
823
- const label = `${address.street} ${address.street_number}, ${postcodeStr}${address.city}`;
826
+ const label = `${address.street}, ${address.street_number}${suffix}, ${postcodeStr}${address.city}`;
824
827
  core.selectItem({ label, value: address });
825
828
  };
826
829
  return {
@@ -0,0 +1,203 @@
1
+ /* Pro6PP Infer SDK - Default Styles */
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
+ -webkit-tap-highlight-color: transparent;
8
+ }
9
+ .pro6pp-wrapper * {
10
+ box-sizing: border-box;
11
+ }
12
+ .pro6pp-input {
13
+ width: 100%;
14
+ padding: 12px 14px;
15
+ padding-right: 48px;
16
+ border: 1px solid #e0e0e0;
17
+ border-radius: 8px;
18
+ font-size: 16px;
19
+ line-height: 1.5;
20
+ appearance: none;
21
+ transition: border-color 0.2s, box-shadow 0.2s;
22
+ }
23
+
24
+ .pro6pp-input::placeholder {
25
+ font-size: 16px;
26
+ color: #a3a3a3;
27
+ }
28
+
29
+ .pro6pp-input:focus {
30
+ outline: none;
31
+ border-color: #3b82f6;
32
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
33
+ }
34
+
35
+ .pro6pp-input-addons {
36
+ position: absolute;
37
+ right: 4px;
38
+ top: 0;
39
+ bottom: 0;
40
+ display: flex;
41
+ align-items: center;
42
+ pointer-events: none;
43
+ }
44
+ .pro6pp-input-addons > * {
45
+ pointer-events: auto;
46
+ }
47
+
48
+ .pro6pp-clear-button {
49
+ background: none;
50
+ border: none;
51
+ width: 32px;
52
+ height: 32px;
53
+ cursor: pointer;
54
+ color: #a3a3a3;
55
+ display: flex;
56
+ align-items: center;
57
+ justify-content: center;
58
+ border-radius: 50%;
59
+ transition: color 0.2s, background-color 0.2s;
60
+ touch-action: manipulation;
61
+ }
62
+
63
+ @media (hover: hover) {
64
+ .pro6pp-clear-button:hover {
65
+ color: #1f2937;
66
+ background-color: #f3f4f6;
67
+ }
68
+ }
69
+
70
+ .pro6pp-clear-button:active {
71
+ background-color: #f3f4f6;
72
+ }
73
+
74
+ .pro6pp-dropdown {
75
+ position: absolute;
76
+ top: 100%;
77
+ left: 0;
78
+ right: 0;
79
+ margin-top: 4px;
80
+ background: #ffffff;
81
+ border: 1px solid #e5e7eb;
82
+ border-radius: 6px;
83
+ box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
84
+ z-index: 9999;
85
+ padding: 0;
86
+ max-height: 280px;
87
+ overflow-y: auto;
88
+ display: flex;
89
+ flex-direction: column;
90
+ }
91
+
92
+ @media (max-height: 500px) {
93
+ .pro6pp-dropdown {
94
+ max-height: 180px;
95
+ }
96
+ }
97
+
98
+ .pro6pp-list {
99
+ list-style: none;
100
+ margin: 0;
101
+ padding: 0;
102
+ width: 100%;
103
+ }
104
+
105
+ .pro6pp-item {
106
+ padding: 12px 14px;
107
+ cursor: pointer;
108
+ display: flex;
109
+ align-items: center;
110
+ font-size: 15px;
111
+ line-height: 1.4;
112
+ color: #374151;
113
+ border-bottom: 1px solid #f3f4f6;
114
+ transition: background-color 0.1s;
115
+ flex-shrink: 0;
116
+ }
117
+
118
+ .pro6pp-item:last-child {
119
+ border-bottom: none;
120
+ }
121
+
122
+ @media (hover: hover) {
123
+ .pro6pp-item:hover, .pro6pp-item--active {
124
+ background-color: #f9fafb;
125
+ }
126
+ }
127
+
128
+ .pro6pp-item:active {
129
+ background-color: #f3f4f6;
130
+ }
131
+
132
+ .pro6pp-item__label {
133
+ font-weight: 400;
134
+ flex-shrink: 1;
135
+ overflow: hidden;
136
+ text-overflow: ellipsis;
137
+ white-space: nowrap;
138
+ }
139
+
140
+ .pro6pp-item__label--match {
141
+ font-weight: 520;
142
+ }
143
+
144
+ .pro6pp-item__label--unmatched {
145
+ font-weight: 400;
146
+ color: #4b5563;
147
+ }
148
+
149
+ .pro6pp-item__subtitle {
150
+ color: #6b7280;
151
+ flex-shrink: 0;
152
+ }
153
+
154
+ .pro6pp-item__chevron {
155
+ color: #d1d5db;
156
+ display: flex;
157
+ align-items: center;
158
+ margin-left: auto;
159
+ padding-left: 8px;
160
+ }
161
+
162
+ .pro6pp-no-results {
163
+ padding: 24px 16px;
164
+ color: #6b7280;
165
+ font-size: 15px;
166
+ text-align: center;
167
+ }
168
+
169
+ .pro6pp-loader-item {
170
+ padding: 10px 12px;
171
+ color: #6b7280;
172
+ font-size: 0.875rem;
173
+ display: flex;
174
+ align-items: center;
175
+ justify-content: center;
176
+ gap: 8px;
177
+ background-color: #f9fafb;
178
+ border-top: 1px solid #f3f4f6;
179
+ }
180
+
181
+ .pro6pp-mini-spinner {
182
+ width: 14px;
183
+ height: 14px;
184
+ border: 2px solid #e5e7eb;
185
+ border-top-color: #6b7280;
186
+ border-radius: 50%;
187
+ animation: pro6pp-spin 0.6s linear infinite;
188
+ }
189
+
190
+ @media (max-width: 640px) {
191
+ .pro6pp-input {
192
+ font-size: 16px;
193
+ padding: 10px 12px;
194
+ }
195
+ .pro6pp-item {
196
+ padding: 10px 12px;
197
+ font-size: 14px;
198
+ }
199
+ }
200
+
201
+ @keyframes pro6pp-spin {
202
+ to { transform: rotate(360deg); }
203
+ }
package/package.json CHANGED
@@ -19,8 +19,10 @@
19
19
  "bugs": {
20
20
  "url": "https://github.com/pro6pp/infer-sdk/issues"
21
21
  },
22
- "sideEffects": false,
23
- "version": "0.0.2-beta.17",
22
+ "sideEffects": [
23
+ "*.css"
24
+ ],
25
+ "version": "0.0.2-beta.18",
24
26
  "main": "./dist/index.cjs",
25
27
  "module": "./dist/index.js",
26
28
  "types": "./dist/index.d.ts",
@@ -29,7 +31,8 @@
29
31
  "types": "./dist/index.d.ts",
30
32
  "import": "./dist/index.js",
31
33
  "require": "./dist/index.cjs"
32
- }
34
+ },
35
+ "./styles.css": "./dist/styles.css"
33
36
  },
34
37
  "files": [
35
38
  "dist",
@@ -46,7 +49,7 @@
46
49
  "react": ">=16"
47
50
  },
48
51
  "dependencies": {
49
- "@pro6pp/infer-core": "0.0.2-beta.15"
52
+ "@pro6pp/infer-core": "0.0.2-beta.16"
50
53
  },
51
54
  "devDependencies": {
52
55
  "@testing-library/dom": "^10.4.1",