@graphcommerce/address-autocomplete 11.0.0-canary.56 → 11.0.0-canary.57

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @graphcommerce/address-autocomplete
2
2
 
3
+ ## 11.0.0-canary.57
4
+
5
+ ### Major Changes
6
+
7
+ - [#2708](https://github.com/graphcommerce-org/graphcommerce/pull/2708) [`cb36d6c`](https://github.com/graphcommerce-org/graphcommerce/commit/cb36d6c219e067ffe2fb2e847a8ff84e8f87a5e8) - **Breaking change:** GraphCommerce requires Lingui 6 and Node.js 22.19 or later. Lingui 6 has no `@lingui/macro` package: import the JSX macros from `@lingui/react/macro`. The `lingui-next` config excludes `.d.ts` files and `node_modules` outside the working directory too. ([@paales](https://github.com/paales))
8
+
9
+ ### Patch Changes
10
+
11
+ - [#2708](https://github.com/graphcommerce-org/graphcommerce/pull/2708) [`1c97bc6`](https://github.com/graphcommerce-org/graphcommerce/commit/1c97bc6d6d01e80d98fe70e595b06804be2ba905) - Uses `@googlemaps/js-api-loader` 2, `cookie` 2, `fetch-retry` 6, `web-vitals` 6 and `schema-dts` 2. `usePlacesAutocomplete` loads the Places library with `setOptions` and `importLibrary`. ([@paales](https://github.com/paales))
12
+
3
13
  ## 11.0.0-canary.56
4
14
 
5
15
  ## 11.0.0-canary.55
@@ -5,8 +5,8 @@ import type { Root } from 'react-dom/client'
5
5
  import { createRoot } from 'react-dom/client'
6
6
  import { AddressAutocomplete } from './AddressAutocomplete'
7
7
 
8
- const { loaderOptions } = vi.hoisted(() => ({
9
- loaderOptions: [] as unknown[],
8
+ const { mapsOptions } = vi.hoisted(() => ({
9
+ mapsOptions: [] as unknown[],
10
10
  }))
11
11
  const { fetchAutocompleteSuggestions, importLibrary, setValue } = vi.hoisted(() => ({
12
12
  fetchAutocompleteSuggestions: vi.fn(),
@@ -146,13 +146,8 @@ vi.mock('@mui/material', () => ({
146
146
  }))
147
147
 
148
148
  vi.mock('@googlemaps/js-api-loader', () => ({
149
- Loader: class {
150
- constructor(options: unknown) {
151
- loaderOptions.push(options)
152
- }
153
-
154
- importLibrary = importLibrary
155
- },
149
+ importLibrary,
150
+ setOptions: (options: unknown) => mapsOptions.push(options),
156
151
  }))
157
152
 
158
153
  afterEach(() => {
@@ -160,7 +155,6 @@ afterEach(() => {
160
155
  testContainer?.remove()
161
156
  testRoot = undefined
162
157
  testContainer = undefined
163
- loaderOptions.length = 0
164
158
  vi.useRealTimers()
165
159
  vi.clearAllMocks()
166
160
  })
@@ -218,10 +212,7 @@ describe('AddressAutocomplete', () => {
218
212
  expect(streetInput?.getAttribute('autocomplete')).toBe('one-time-code')
219
213
  expect(streetInput?.getAttribute('role')).toBe('combobox')
220
214
  expect(streetInput?.name).toMatch(/^places-search-/)
221
- expect(loaderOptions.at(-1)).toEqual({
222
- apiKey: 'test-key',
223
- version: 'weekly',
224
- })
215
+ expect(mapsOptions).toEqual([{ key: 'test-key', v: 'weekly' }])
225
216
  expect(importLibrary).toHaveBeenCalledWith('places')
226
217
  })
227
218
 
@@ -1,5 +1,5 @@
1
1
  import { googleMapsApiKey } from '@graphcommerce/next-config/config'
2
- import { Loader } from '@googlemaps/js-api-loader'
2
+ import { importLibrary, setOptions } from '@googlemaps/js-api-loader'
3
3
  import { useEventCallback } from '@mui/material'
4
4
  import type { ChangeEvent, KeyboardEvent } from 'react'
5
5
  import { useEffect, useId, useRef, useState } from 'react'
@@ -8,6 +8,7 @@ import { formatAddress } from '../utils/formatAddress'
8
8
 
9
9
  const addressPrimaryTypes = ['street_address', 'premise', 'subpremise', 'route']
10
10
  const requestDelay = 250
11
+ let mapsOptionsSet = false
11
12
 
12
13
  type PlacesAutocompleteLibrary = Pick<
13
14
  google.maps.PlacesLibrary,
@@ -35,9 +36,11 @@ export function usePlacesAutocomplete({ onAddress }: UsePlacesAutocompleteOption
35
36
  if (!googleMapsApiKey) return undefined
36
37
 
37
38
  let active = true
38
- const loader = new Loader({ apiKey: googleMapsApiKey, version: 'weekly' })
39
- void loader
40
- .importLibrary('places')
39
+ if (!mapsOptionsSet) {
40
+ setOptions({ key: googleMapsApiKey, v: 'weekly' })
41
+ mapsOptionsSet = true
42
+ }
43
+ void importLibrary('places')
41
44
  .then((library) => {
42
45
  if (!active) return
43
46
  setPlacesLibrary(library)
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/address-autocomplete",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "11.0.0-canary.56",
5
+ "version": "11.0.0-canary.57",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -16,21 +16,20 @@
16
16
  "./plugins/AddAddressAutocompleteAddressFields": "./plugins/AddAddressAutocompleteAddressFields.tsx"
17
17
  },
18
18
  "dependencies": {
19
- "@googlemaps/js-api-loader": "^1.16.8",
20
- "@types/google.maps": "^3.59.0"
19
+ "@googlemaps/js-api-loader": "^2.1.3",
20
+ "@types/google.maps": "^3.66.9"
21
21
  },
22
22
  "peerDependencies": {
23
- "@graphcommerce/ecommerce-ui": "^11.0.0-canary.56",
24
- "@graphcommerce/eslint-config-pwa": "^11.0.0-canary.56",
25
- "@graphcommerce/graphql": "^11.0.0-canary.56",
26
- "@graphcommerce/magento-customer": "^11.0.0-canary.56",
27
- "@graphcommerce/magento-store": "^11.0.0-canary.56",
28
- "@graphcommerce/next-config": "^11.0.0-canary.56",
29
- "@graphcommerce/prettier-config-pwa": "^11.0.0-canary.56",
30
- "@graphcommerce/typescript-config-pwa": "^11.0.0-canary.56",
31
- "@lingui/core": "^5",
32
- "@lingui/macro": "^5",
33
- "@lingui/react": "^5",
23
+ "@graphcommerce/ecommerce-ui": "^11.0.0-canary.57",
24
+ "@graphcommerce/eslint-config-pwa": "^11.0.0-canary.57",
25
+ "@graphcommerce/graphql": "^11.0.0-canary.57",
26
+ "@graphcommerce/magento-customer": "^11.0.0-canary.57",
27
+ "@graphcommerce/magento-store": "^11.0.0-canary.57",
28
+ "@graphcommerce/next-config": "^11.0.0-canary.57",
29
+ "@graphcommerce/prettier-config-pwa": "^11.0.0-canary.57",
30
+ "@graphcommerce/typescript-config-pwa": "^11.0.0-canary.57",
31
+ "@lingui/core": "^6",
32
+ "@lingui/react": "^6",
34
33
  "@mui/material": "^7.0.0",
35
34
  "react": "^19.2.0",
36
35
  "react-dom": "^19.2.0"