@betterstore/react 0.5.12 → 0.5.14

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/compounds/form/address-input/index.tsx"],"names":[],"mappings":"AA+BA,UAAU,iBAAiB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAED,wBAAgB,YAAY,CAAC,EAC3B,SAAc,EACd,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,wBAAwB,GACzB,EAAE,iBAAiB,2CAsOnB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/compounds/form/address-input/index.tsx"],"names":[],"mappings":"AA+BA,UAAU,iBAAiB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAED,wBAAgB,YAAY,CAAC,EAC3B,SAAc,EACd,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,wBAAwB,GACzB,EAAE,iBAAiB,2CAqOnB"}
package/dist/index.cjs.js CHANGED
@@ -7409,14 +7409,9 @@ var Client = class {
7409
7409
  */
7410
7410
  async getAutosuggestAddressResults(clientSecret, params) {
7411
7411
  const apiClient = createApiClient(clientSecret, this.proxy);
7412
- const { data, ...rest } = await apiClient.get(
7413
- "/helpers/autosuggest-address",
7414
- {
7415
- params
7416
- }
7417
- );
7418
- console.log("autosuggest data", data);
7419
- console.log("autosuggest rest", rest);
7412
+ const { data } = await apiClient.get("/helpers/autosuggest-address", {
7413
+ params
7414
+ });
7420
7415
  return data;
7421
7416
  }
7422
7417
  /**
@@ -7424,11 +7419,14 @@ var Client = class {
7424
7419
  */
7425
7420
  async getGeocodeAddressResults(clientSecret, params) {
7426
7421
  const apiClient = createApiClient(clientSecret, this.proxy);
7427
- const { data, ...rest } = await apiClient.get("/helpers/geocode-address", {
7428
- params
7422
+ const { position, ...rest } = params;
7423
+ const { data } = await apiClient.get("/helpers/geocode-address", {
7424
+ params: {
7425
+ ...rest,
7426
+ lat: position.lat,
7427
+ lng: position.lng
7428
+ }
7429
7429
  });
7430
- console.log("geocode data", data);
7431
- console.log("geocode rest", rest);
7432
7430
  return data;
7433
7431
  }
7434
7432
  };
@@ -34445,17 +34443,16 @@ function AddressInput({ className = "", proxy, clientSecret, latitude, longitude
34445
34443
  // eslint-disable-next-line react-hooks/exhaustive-deps
34446
34444
  }, [showAllInputs, addressInput]);
34447
34445
  const handleSelectAddress = (address) => {
34448
- console.log(address);
34449
34446
  const isLookup = "line1" in address;
34450
34447
  if (!isLookup) {
34451
34448
  setIsLoading(true);
34452
34449
  storeClient
34453
- .getGeocodeAddressResults(clientSecret, {
34454
- selectedStreetId: address.id,
34455
- position: address.position,
34456
- })
34450
+ .getGeocodeAddressResults(clientSecret, address)
34457
34451
  .then((results) => {
34458
34452
  console.log(results);
34453
+ setIsLoading(false);
34454
+ setShowSuggestions(false);
34455
+ setSuggestions(results);
34459
34456
  });
34460
34457
  return;
34461
34458
  }
@@ -34476,7 +34473,7 @@ function AddressInput({ className = "", proxy, clientSecret, latitude, longitude
34476
34473
  React.useEffect(() => {
34477
34474
  setShowAllInputs((cityInput === null || cityInput === void 0 ? void 0 : cityInput.length) > 0);
34478
34475
  }, [cityInput]);
34479
- return (jsxRuntime.jsxs("div", { className: cn("space-y-5", className), children: [jsxRuntime.jsx(CountryInput, { prefix: "address", label: "Country", form: form }), jsxRuntime.jsxs("div", { className: "relative", children: [jsxRuntime.jsx(InputGroup, { name: "address.line1", label: showAllInputs ? "Address" : "Start typing address", required: showAllInputs, icon: jsxRuntime.jsx(Search, { className: "h-4 w-4" }), showIcon: !showAllInputs, onFocus: () => setShowSuggestions(true), onBlur: () => setShowSuggestions(false) }), !showAllInputs && (showSuggestions || isLoading) && (jsxRuntime.jsx("div", { className: "bg-background border-border absolute left-0 right-0 top-full z-50 mt-1 rounded-md border shadow-lg", "data-dropdown": "suggestions", children: isLoading ? (jsxRuntime.jsx("div", { className: "text-muted-foreground border-border border-b p-3 text-sm", children: "Searching for addresses..." })) : suggestions.length > 0 ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "text-muted-foreground border-border border-b p-3 text-sm", children: "Keep typing address to display results" }), jsxRuntime.jsx("div", { className: "max-h-60 overflow-y-auto", children: suggestions.map((address, index) => {
34476
+ return (jsxRuntime.jsxs("div", { className: cn("space-y-5", className), children: [jsxRuntime.jsx(CountryInput, { prefix: "address", label: "Country", form: form }), jsxRuntime.jsxs("div", { className: "relative", children: [jsxRuntime.jsx(InputGroup, { name: "address.line1", label: showAllInputs ? "Address" : "Start typing address", required: showAllInputs, icon: jsxRuntime.jsx(Search, { className: "h-4 w-4" }), showIcon: !showAllInputs, onFocus: () => setShowSuggestions(true), onBlur: () => setTimeout(() => setShowSuggestions(false), 100) }), !showAllInputs && (showSuggestions || isLoading) && (jsxRuntime.jsx("div", { className: "bg-background border-border absolute left-0 right-0 top-full z-50 mt-1 rounded-md border shadow-lg", "data-dropdown": "suggestions", children: isLoading ? (jsxRuntime.jsx("div", { className: "text-muted-foreground border-border border-b p-3 text-sm", children: "Searching for addresses..." })) : suggestions.length > 0 ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "text-muted-foreground border-border border-b p-3 text-sm", children: "Keep typing address to display results" }), jsxRuntime.jsx("div", { className: "max-h-60 overflow-y-auto", children: suggestions.map((address, index) => {
34480
34477
  const isLookup = "line1" in address;
34481
34478
  return (jsxRuntime.jsxs("button", { type: "button", onClick: () => handleSelectAddress(address), className: "hover:bg-accent border-border flex w-full cursor-pointer items-center border-b px-3 py-3 text-left transition-colors last:border-b-0", children: [jsxRuntime.jsx("div", { className: "text-foreground text-sm", children: address.title }), !isLookup && (jsxRuntime.jsx(ChevronRight, { className: "text-muted-foreground ml-auto size-4" }))] }, index));
34482
34479
  }) })] })) : (jsxRuntime.jsx("div", { className: "text-muted-foreground border-border border-b p-3 text-sm", children: "No addresses found" })) }))] }), jsxRuntime.jsx("div", { className: cn(!showAllInputs ? "-mt-2 mb-4 block" : "hidden"), children: jsxRuntime.jsx("button", { type: "button", onClick: handleManualEntry, className: "text-foreground hover:text-muted-foreground cursor-pointer text-[13px] underline", children: "Enter address manually" }) }), jsxRuntime.jsxs("div", { className: cn("space-y-4", !showAllInputs && "-mt-4 h-0 max-h-0 w-0 max-w-0 opacity-0"), children: [jsxRuntime.jsx("div", { className: cn(!showApartmentField ? "block" : "hidden"), children: jsxRuntime.jsxs("button", { type: "button", onClick: () => {
package/dist/index.mjs CHANGED
@@ -7389,14 +7389,9 @@ var Client = class {
7389
7389
  */
7390
7390
  async getAutosuggestAddressResults(clientSecret, params) {
7391
7391
  const apiClient = createApiClient(clientSecret, this.proxy);
7392
- const { data, ...rest } = await apiClient.get(
7393
- "/helpers/autosuggest-address",
7394
- {
7395
- params
7396
- }
7397
- );
7398
- console.log("autosuggest data", data);
7399
- console.log("autosuggest rest", rest);
7392
+ const { data } = await apiClient.get("/helpers/autosuggest-address", {
7393
+ params
7394
+ });
7400
7395
  return data;
7401
7396
  }
7402
7397
  /**
@@ -7404,11 +7399,14 @@ var Client = class {
7404
7399
  */
7405
7400
  async getGeocodeAddressResults(clientSecret, params) {
7406
7401
  const apiClient = createApiClient(clientSecret, this.proxy);
7407
- const { data, ...rest } = await apiClient.get("/helpers/geocode-address", {
7408
- params
7402
+ const { position, ...rest } = params;
7403
+ const { data } = await apiClient.get("/helpers/geocode-address", {
7404
+ params: {
7405
+ ...rest,
7406
+ lat: position.lat,
7407
+ lng: position.lng
7408
+ }
7409
7409
  });
7410
- console.log("geocode data", data);
7411
- console.log("geocode rest", rest);
7412
7410
  return data;
7413
7411
  }
7414
7412
  };
@@ -34425,17 +34423,16 @@ function AddressInput({ className = "", proxy, clientSecret, latitude, longitude
34425
34423
  // eslint-disable-next-line react-hooks/exhaustive-deps
34426
34424
  }, [showAllInputs, addressInput]);
34427
34425
  const handleSelectAddress = (address) => {
34428
- console.log(address);
34429
34426
  const isLookup = "line1" in address;
34430
34427
  if (!isLookup) {
34431
34428
  setIsLoading(true);
34432
34429
  storeClient
34433
- .getGeocodeAddressResults(clientSecret, {
34434
- selectedStreetId: address.id,
34435
- position: address.position,
34436
- })
34430
+ .getGeocodeAddressResults(clientSecret, address)
34437
34431
  .then((results) => {
34438
34432
  console.log(results);
34433
+ setIsLoading(false);
34434
+ setShowSuggestions(false);
34435
+ setSuggestions(results);
34439
34436
  });
34440
34437
  return;
34441
34438
  }
@@ -34456,7 +34453,7 @@ function AddressInput({ className = "", proxy, clientSecret, latitude, longitude
34456
34453
  useEffect(() => {
34457
34454
  setShowAllInputs((cityInput === null || cityInput === void 0 ? void 0 : cityInput.length) > 0);
34458
34455
  }, [cityInput]);
34459
- return (jsxs("div", { className: cn("space-y-5", className), children: [jsx(CountryInput, { prefix: "address", label: "Country", form: form }), jsxs("div", { className: "relative", children: [jsx(InputGroup, { name: "address.line1", label: showAllInputs ? "Address" : "Start typing address", required: showAllInputs, icon: jsx(Search, { className: "h-4 w-4" }), showIcon: !showAllInputs, onFocus: () => setShowSuggestions(true), onBlur: () => setShowSuggestions(false) }), !showAllInputs && (showSuggestions || isLoading) && (jsx("div", { className: "bg-background border-border absolute left-0 right-0 top-full z-50 mt-1 rounded-md border shadow-lg", "data-dropdown": "suggestions", children: isLoading ? (jsx("div", { className: "text-muted-foreground border-border border-b p-3 text-sm", children: "Searching for addresses..." })) : suggestions.length > 0 ? (jsxs(Fragment, { children: [jsx("div", { className: "text-muted-foreground border-border border-b p-3 text-sm", children: "Keep typing address to display results" }), jsx("div", { className: "max-h-60 overflow-y-auto", children: suggestions.map((address, index) => {
34456
+ return (jsxs("div", { className: cn("space-y-5", className), children: [jsx(CountryInput, { prefix: "address", label: "Country", form: form }), jsxs("div", { className: "relative", children: [jsx(InputGroup, { name: "address.line1", label: showAllInputs ? "Address" : "Start typing address", required: showAllInputs, icon: jsx(Search, { className: "h-4 w-4" }), showIcon: !showAllInputs, onFocus: () => setShowSuggestions(true), onBlur: () => setTimeout(() => setShowSuggestions(false), 100) }), !showAllInputs && (showSuggestions || isLoading) && (jsx("div", { className: "bg-background border-border absolute left-0 right-0 top-full z-50 mt-1 rounded-md border shadow-lg", "data-dropdown": "suggestions", children: isLoading ? (jsx("div", { className: "text-muted-foreground border-border border-b p-3 text-sm", children: "Searching for addresses..." })) : suggestions.length > 0 ? (jsxs(Fragment, { children: [jsx("div", { className: "text-muted-foreground border-border border-b p-3 text-sm", children: "Keep typing address to display results" }), jsx("div", { className: "max-h-60 overflow-y-auto", children: suggestions.map((address, index) => {
34460
34457
  const isLookup = "line1" in address;
34461
34458
  return (jsxs("button", { type: "button", onClick: () => handleSelectAddress(address), className: "hover:bg-accent border-border flex w-full cursor-pointer items-center border-b px-3 py-3 text-left transition-colors last:border-b-0", children: [jsx("div", { className: "text-foreground text-sm", children: address.title }), !isLookup && (jsx(ChevronRight, { className: "text-muted-foreground ml-auto size-4" }))] }, index));
34462
34459
  }) })] })) : (jsx("div", { className: "text-muted-foreground border-border border-b p-3 text-sm", children: "No addresses found" })) }))] }), jsx("div", { className: cn(!showAllInputs ? "-mt-2 mb-4 block" : "hidden"), children: jsx("button", { type: "button", onClick: handleManualEntry, className: "text-foreground hover:text-muted-foreground cursor-pointer text-[13px] underline", children: "Enter address manually" }) }), jsxs("div", { className: cn("space-y-4", !showAllInputs && "-mt-4 h-0 max-h-0 w-0 max-w-0 opacity-0"), children: [jsx("div", { className: cn(!showApartmentField ? "block" : "hidden"), children: jsxs("button", { type: "button", onClick: () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterstore/react",
3
- "version": "0.5.12",
3
+ "version": "0.5.14",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -27,8 +27,8 @@
27
27
  "tailwindcss": "^4.1.11",
28
28
  "typescript": "5.8.2",
29
29
  "vite": "^6.3.5",
30
- "@betterstore/eslint-config": "0.0.0",
31
- "@betterstore/typescript-config": "0.0.0"
30
+ "@betterstore/typescript-config": "0.0.0",
31
+ "@betterstore/eslint-config": "0.0.0"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "react": "^18.0.0 || ^19.0.0",
@@ -77,7 +77,7 @@
77
77
  "tailwindcss-animate": "^1.0.7",
78
78
  "zod": "^3.25.30",
79
79
  "zustand": "^5.0.5",
80
- "@betterstore/sdk": "0.5.12"
80
+ "@betterstore/sdk": "0.5.14"
81
81
  },
82
82
  "publishConfig": {
83
83
  "access": "public"