@quantaroute/checkout 1.3.0 โ†’ 1.3.1

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
@@ -6,7 +6,7 @@
6
6
 
7
7
  [![Made in India](https://img.shields.io/badge/Made%20in-India%20๐Ÿ‡ฎ๐Ÿ‡ณ-orange)](https://quantaroute.com)
8
8
  [![DigiPin](https://img.shields.io/badge/DigiPin-India%20Post-blue)](https://www.indiapost.gov.in)
9
- [![Map](https://img.shields.io/badge/Map-MapLibre%20%2B%20OpenFreeMap%20%2F%20Carto-green)](https://openfreemap.org)
9
+ [![Map](https://img.shields.io/badge/Map-Carto%20Positron%20(free)-green)](https://carto.com)
10
10
  [![License](https://img.shields.io/badge/License-MIT-lightgrey)](./LICENSE)
11
11
 
12
12
  ---
@@ -32,7 +32,7 @@ Step 1 โ€“ Map Pin Step 2 โ€“ Auto-fill + Details
32
32
  **Key features:**
33
33
 
34
34
  - DigiPin shown **offline** in real-time as the user drags the pin (~4 m ร— 4 m precision)
35
- - **No Google Maps.** Free vector basemap โ€” choose from Carto Positron or OpenFreeMap styles (no API key for either)
35
+ - **No Google Maps.** Free Carto Positron vector basemap
36
36
  - Auto-fills State, District, Locality, Pincode, Delivery status from QuantaRoute API
37
37
  - Manual fields: Flat no., Floor, Building (OSM pre-filled), Street/Area (OSM pre-filled)
38
38
  - Mobile-first (full-screen on phones, card on desktop/tablet)
@@ -297,7 +297,6 @@ npx expo run:android
297
297
  | `theme` | `'light' \| 'dark'` | `'light'` | all |
298
298
  | `mapHeight` | `string \| number` | `'380px'` / `380` | all |
299
299
  | `title` | `string` | `'Add Delivery Address'` | all |
300
- | `mapStyle` | `BuiltInMapStyle \| string` | `'carto-positron'` | all |
301
300
  | `className` | `string` | โ€“ | web only |
302
301
  | `style` | `CSSProperties \| StyleProp<ViewStyle>` | โ€“ | all |
303
302
  | `indiaBoundaryUrl` | `string` | โ€“ | web only |
@@ -378,25 +377,6 @@ function MyCheckout() {
378
377
  }
379
378
  ```
380
379
 
381
- ### Choose a basemap style
382
-
383
- Pass a built-in preset name or any MapLibre-compatible style URL:
384
-
385
- ```tsx
386
- // Built-in presets (no API key required for any of them)
387
- <CheckoutWidget apiKey="..." mapStyle="carto-positron" onComplete={...} /> {/* default */}
388
- <CheckoutWidget apiKey="..." mapStyle="openfreemap-liberty" onComplete={...} /> {/* colorful OSM */}
389
- <CheckoutWidget apiKey="..." mapStyle="openfreemap-positron" onComplete={...} /> {/* clean light */}
390
- <CheckoutWidget apiKey="..." mapStyle="openfreemap-bright" onComplete={...} /> {/* vibrant */}
391
-
392
- // Custom style URL (your own MapLibre server)
393
- <CheckoutWidget apiKey="..." mapStyle="https://my-tiles.example.com/style.json" onComplete={...} />
394
- ```
395
-
396
- Attribution is applied automatically for each built-in preset.
397
-
398
- > OpenFreeMap is a free, open-source tile hosting service. If you use the `openfreemap-*` presets in production, consider [sponsoring the project](https://github.com/sponsors/hyperknot) to keep the public instance running.
399
-
400
380
  ### India boundary overlay (web only)
401
381
 
402
382
  ```tsx
@@ -424,7 +404,6 @@ Attribution is applied automatically for each built-in preset.
424
404
  โ”‚ โ”œโ”€โ”€ core/
425
405
  โ”‚ โ”‚ โ”œโ”€โ”€ digipin.ts โ† offline DigiPin algorithm (shared, no DOM)
426
406
  โ”‚ โ”‚ โ”œโ”€โ”€ api.ts โ† QuantaRoute API client (shared, fetch)
427
- โ”‚ โ”‚ โ”œโ”€โ”€ mapStyles.ts โ† basemap preset registry + resolver (shared)
428
407
  โ”‚ โ”‚ โ””โ”€โ”€ types.ts โ† TypeScript types (shared)
429
408
  โ”‚ โ”œโ”€โ”€ hooks/
430
409
  โ”‚ โ”‚ โ”œโ”€โ”€ useGeolocation.ts โ† web (navigator.geolocation)
@@ -454,16 +433,11 @@ Vite / Webpack / Next.js โ†’ "import" export โ†’ dist/lib/quantaroute-checkout.
454
433
 
455
434
  ## Map tile license
456
435
 
457
- | Preset | Provider | Attribution | API key |
458
- |---|---|---|---|
459
- | `carto-positron` (default) | [Carto](https://carto.com/attributions) | `ยฉ OpenStreetMap contributors ยฉ CARTO` | None |
460
- | `openfreemap-liberty` | [OpenFreeMap](https://openfreemap.org) | `ยฉ OpenStreetMap contributors ยฉ OpenMapTiles ยท OpenFreeMap` | None |
461
- | `openfreemap-positron` | [OpenFreeMap](https://openfreemap.org) | `ยฉ OpenStreetMap contributors ยฉ OpenMapTiles ยท OpenFreeMap` | None |
462
- | `openfreemap-bright` | [OpenFreeMap](https://openfreemap.org) | `ยฉ OpenStreetMap contributors ยฉ OpenMapTiles ยท OpenFreeMap` | None |
463
-
464
- Attribution is injected automatically for all built-in presets. When using a custom style URL you are responsible for correct attribution per your tile provider's terms.
436
+ Uses **Carto Positron** vector tiles (Carto Voyager on native):
465
437
 
466
- OpenFreeMap is fully open-source (MIT). If you use `openfreemap-*` presets in production, please consider [sponsoring their public instance](https://github.com/sponsors/hyperknot).
438
+ - Free for commercial use โ€” attribution required
439
+ - Attribution: `ยฉ OpenStreetMap contributors ยฉ CARTO`
440
+ - No API key required for Carto basemaps
467
441
 
468
442
  ---
469
443
 
@@ -509,17 +483,6 @@ npx expo run:android # requires Android Studio
509
483
 
510
484
  ## Changelog
511
485
 
512
- ### v1.3.0
513
-
514
- - **`mapStyle` prop** โ€” choose a basemap preset or pass any MapLibre-compatible style URL
515
- - `'carto-positron'` (default, unchanged โ€” fully backward-compatible)
516
- - `'openfreemap-liberty'` โ€” colorful OSM-flavored style via [OpenFreeMap](https://openfreemap.org)
517
- - `'openfreemap-positron'` โ€” clean light style via OpenFreeMap
518
- - `'openfreemap-bright'` โ€” vibrant high-contrast style via OpenFreeMap
519
- - Custom URL string โ€” pass any MapLibre style JSON endpoint
520
- - Attribution text is resolved automatically per provider (no manual setup needed)
521
- - New `src/core/mapStyles.ts` โ€” shared preset registry used by both web and native components
522
-
523
486
  ### v1.2.0
524
487
 
525
488
  - **iOS & Android support** via `expo-osm-sdk` (MapLibre GL Native)
@@ -51,21 +51,43 @@ export declare interface AdministrativeInfo {
51
51
  declare type AnyStyle = any;
52
52
 
53
53
  /**
54
- * Built-in basemap style presets.
54
+ * Call QuantaRoute's autocomplete API.
55
+ * Minimum 3 characters required; max 10 suggestions.
55
56
  *
56
- * | Preset | Provider | Character |
57
- * |--------------------------|---------------|----------------------------------|
58
- * | `'carto-positron'` | Carto | Clean, minimal, light (default) |
59
- * | `'openfreemap-liberty'` | OpenFreeMap | Colorful OSM-flavored |
60
- * | `'openfreemap-positron'` | OpenFreeMap | Clean light, open-source |
61
- * | `'openfreemap-bright'` | OpenFreeMap | Vibrant, high contrast |
62
- *
63
- * You can also pass any MapLibre-compatible style URL string directly.
64
- *
65
- * OpenFreeMap is free and open-source with no API key or rate limits.
66
- * See https://openfreemap.org
57
+ * Pass userLat / userLng (the map pin's current position) to unlock:
58
+ * โ€“ Location-biased results (~50 km soft radius around the pin)
59
+ * โ€“ "Near me" / "nearby" keyword support with a tight ~10 km hard radius
67
60
  */
68
- declare type BuiltInMapStyle = 'carto-positron' | 'openfreemap-liberty' | 'openfreemap-positron' | 'openfreemap-bright';
61
+ export declare function autocompleteAddress(query: string, apiKey: string, baseUrl?: string, limit?: number, userLat?: number, userLng?: number): Promise<AutocompleteSuggestion[]>;
62
+
63
+ export declare interface AutocompleteResponse {
64
+ success: boolean;
65
+ data: AutocompleteSuggestion[];
66
+ error?: string;
67
+ message?: string;
68
+ }
69
+
70
+ /** One address suggestion from /v1/digipin/autocomplete */
71
+ export declare interface AutocompleteSuggestion {
72
+ displayName: string;
73
+ address: string;
74
+ coordinates: {
75
+ latitude: number;
76
+ longitude: number;
77
+ };
78
+ confidence: number;
79
+ addressComponents: {
80
+ house_number?: string;
81
+ road?: string;
82
+ neighbourhood?: string;
83
+ suburb?: string;
84
+ city?: string;
85
+ state?: string;
86
+ postcode?: string;
87
+ country?: string;
88
+ [key: string]: string | undefined;
89
+ };
90
+ }
69
91
 
70
92
  /**
71
93
  * QuantaRoute Checkout Widget
@@ -107,13 +129,6 @@ export declare interface CheckoutWidgetProps {
107
129
  mapHeight?: string | number;
108
130
  /** Widget header title. Defaults to 'Add Delivery Address'. */
109
131
  title?: string;
110
- /**
111
- * Basemap style. Pass a preset name or any MapLibre-compatible style URL.
112
- * Defaults to `'carto-positron'`.
113
- * @example mapStyle="openfreemap-liberty"
114
- * @example mapStyle="https://my-server.com/style.json"
115
- */
116
- mapStyle?: BuiltInMapStyle | string;
117
132
  /**
118
133
  * URL to an India boundary GeoJSON file (FeatureCollection).
119
134
  * When provided, a thin grey outline is drawn on the map for legal compliance.
@@ -121,6 +136,13 @@ export declare interface CheckoutWidgetProps {
121
136
  * Example: indiaBoundaryUrl="/geojson/india.geojson"
122
137
  */
123
138
  indiaBoundaryUrl?: string;
139
+ /**
140
+ * Show the smart search bar on the map step (default: true).
141
+ * Supports address search (API) and DigiPin lookup (100% offline).
142
+ * As India Post promotes DigiPin, buyers can just type their 10-char code
143
+ * and the map instantly flies to their ~4m ร— 4m location โ€” zero API cost.
144
+ */
145
+ enableSearch?: boolean;
124
146
  }
125
147
 
126
148
  export declare interface CompleteAddress {
@@ -224,6 +246,12 @@ export declare interface LocationLookupResponse {
224
246
  message?: string;
225
247
  }
226
248
 
249
+ /**
250
+ * Returns true if the trimmed input looks like a complete DigiPin code.
251
+ * Used to skip the API call and resolve offline instead.
252
+ */
253
+ export declare function looksLikeDigiPin(input: string): boolean;
254
+
227
255
  /**
228
256
  * Call QuantaRoute's Location Lookup API.
229
257
  * Converts lat/lng โ†’ full Indian administrative address + DigiPin.
@@ -239,13 +267,6 @@ export declare interface MapPinSelectorProps {
239
267
  /** Map height. String on web ('380px'), number on native (380). */
240
268
  mapHeight?: string | number;
241
269
  theme?: 'light' | 'dark';
242
- /**
243
- * Basemap style. Pass a preset name or any MapLibre-compatible style URL.
244
- * Defaults to `'carto-positron'`.
245
- * @example mapStyle="openfreemap-liberty"
246
- * @example mapStyle="https://my-server.com/style.json"
247
- */
248
- mapStyle?: BuiltInMapStyle | string;
249
270
  /**
250
271
  * URL to an India boundary GeoJSON file (FeatureCollection).
251
272
  * When provided, a thin grey outline of India's border is drawn on the map
@@ -254,6 +275,18 @@ export declare interface MapPinSelectorProps {
254
275
  * Example: indiaBoundaryUrl="/geojson/india.geojson"
255
276
  */
256
277
  indiaBoundaryUrl?: string;
278
+ /**
279
+ * Show the search bar above the map (default: true).
280
+ * Supports two modes automatically:
281
+ * โ€“ Address search โ†’ calls /v1/digipin/autocomplete (debounced 400ms)
282
+ * โ€“ DigiPin input โ†’ decoded offline, zero API call, instant flyTo
283
+ * Pass apiKey to enable address search. DigiPin search always works offline.
284
+ */
285
+ enableSearch?: boolean;
286
+ /** Required when enableSearch is true โ€” used to call the autocomplete API. */
287
+ apiKey?: string;
288
+ /** API base URL for autocomplete. Defaults to https://api.quantaroute.com */
289
+ apiBaseUrl?: string;
257
290
  }
258
291
 
259
292
  /**