@aws/address-form-sdk-js 1.4.1 → 1.6.0

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.
Files changed (36) hide show
  1. package/README.md +18 -19
  2. package/dist/lib/address-form-sdk-js.css +1 -1
  3. package/dist/lib/address-form-sdk.cjs.js +1 -1
  4. package/dist/lib/components/AddressForm/index.d.ts +7 -4
  5. package/dist/lib/components/AddressFormReact/AddressForm.d.ts +5 -2
  6. package/dist/lib/components/AddressFormReact/AddressFormAddressField.d.ts +1 -1
  7. package/dist/lib/components/AddressFormReact/AddressFormContext.d.ts +4 -1
  8. package/dist/lib/components/AddressFormReact/AddressFormCountryField.d.ts +1 -1
  9. package/dist/lib/components/AddressFormReact/AddressFormProvider.d.ts +3 -1
  10. package/dist/lib/components/AddressFormReact/AddressFormTextField.d.ts +1 -1
  11. package/dist/lib/components/AddressFormReact/SubmitButton.d.ts +2 -0
  12. package/dist/lib/components/AddressFormReact/render.d.ts +2 -0
  13. package/dist/lib/components/{MapMarker/AdjustButton → AdjustButton}/index.d.ts +1 -1
  14. package/dist/lib/components/AmazonLocationProvider/index.d.ts +2 -2
  15. package/dist/lib/components/Button/index.d.ts +1 -1
  16. package/dist/lib/components/CountrySelect/index.d.ts +1 -1
  17. package/dist/lib/components/Flex/index.d.ts +1 -1
  18. package/dist/lib/components/FormField/index.d.ts +1 -1
  19. package/dist/lib/components/Input/index.d.ts +1 -1
  20. package/dist/lib/components/LocateButton/index.d.ts +3 -1
  21. package/dist/lib/components/Map/index.d.ts +6 -1
  22. package/dist/lib/components/MapMarker/index.d.ts +4 -2
  23. package/dist/lib/components/Tooltip/index.d.ts +7 -0
  24. package/dist/lib/components/Typeahead/index.d.ts +3 -1
  25. package/dist/lib/components/Typeahead/use-typeahead-query.d.ts +1 -1
  26. package/dist/lib/context/amazon-location-context.d.ts +1 -1
  27. package/dist/lib/hooks/use-amazon-location-context.d.ts +1 -1
  28. package/dist/lib/icons/Locate.d.ts +1 -1
  29. package/dist/lib/icons/Logo.d.ts +1 -1
  30. package/dist/lib/stores/notificationStore.d.ts +1 -1
  31. package/dist/lib/test/utils.d.ts +2 -1
  32. package/dist/lib/utils/bounds.d.ts +3 -0
  33. package/dist/lib/utils/position.d.ts +1 -0
  34. package/dist/standalone/address-form-sdk.css +1 -1
  35. package/dist/standalone/address-form-sdk.umd.js +107 -115
  36. package/package.json +15 -19
@@ -1,7 +1,6 @@
1
1
  import { AutocompleteFilterPlaceType, Address } from '@aws-sdk/client-geo-places';
2
2
  import { Config } from '../../types/config.ts';
3
3
  import { MapProps, MapStyle } from '../Map';
4
- import { MapMarkerProps } from '../MapMarker/index.tsx';
5
4
  import { TypeaheadProps } from '../Typeahead';
6
5
  import { TypeaheadAPIName } from '../Typeahead/use-typeahead-query.ts';
7
6
  import { FormFieldID } from './form-field.ts';
@@ -44,6 +43,10 @@ export interface AddressFormProps {
44
43
  language?: string;
45
44
  politicalView?: string;
46
45
  }
47
- export declare function AddressForm({ fields, typeahead, map, politicalView, language, className, onSubmit, }: AddressFormProps): import("react/jsx-runtime").JSX.Element;
48
- export type AddressFormMapProps = MapProps & MapMarkerProps;
49
- export declare const AddressFormMap: ({ adjustablePosition, markerPosition, onSaveMarkerPosition, ...mapProps }: AddressFormMapProps) => import("react/jsx-runtime").JSX.Element;
46
+ export declare function AddressForm({ fields, typeahead, map, politicalView, language, className, onSubmit, }: AddressFormProps): import("react").JSX.Element;
47
+ export interface AddressFormMapProps extends MapProps {
48
+ adjustablePosition?: boolean;
49
+ markerPosition?: [number, number];
50
+ onSaveMarkerPosition?: (position: [number, number]) => void;
51
+ }
52
+ export declare const AddressFormMap: ({ adjustablePosition, markerPosition, onSaveMarkerPosition, onMove, ...mapProps }: AddressFormMapProps) => import("react").JSX.Element;
@@ -1,9 +1,10 @@
1
- import { Address, AutocompleteFilterPlaceType, GetPlaceIntendedUse } from '@aws-sdk/client-geo-places';
1
+ import { Address, AutocompleteFilterPlaceType, GeoPlacesClient, GetPlaceIntendedUse } from '@aws-sdk/client-geo-places';
2
2
  import { ComponentProps, FunctionComponent, ReactNode } from 'react';
3
3
  import { AddressFormAddressFieldProps } from './AddressFormAddressField';
4
4
  import { AddressFormCountryFieldProps } from './AddressFormCountryField';
5
5
  import { AddressFormMapProps } from './AddressFormMap';
6
6
  import { AddressFormTextFieldProps } from './AddressFormTextField';
7
+ import { CenterBounds } from '../../utils/bounds';
7
8
  export interface AddressFormData {
8
9
  placeId?: string;
9
10
  addressLineOne?: string;
@@ -17,8 +18,9 @@ export interface AddressFormData {
17
18
  addressDetails?: Address;
18
19
  }
19
20
  export interface AddressFormProps extends AddressFormContentProps {
20
- apiKey: string;
21
+ apiKey?: string;
21
22
  region: string;
23
+ client?: GeoPlacesClient;
22
24
  language?: string;
23
25
  politicalView?: string;
24
26
  showCurrentCountryResultsOnly?: boolean;
@@ -26,6 +28,7 @@ export interface AddressFormProps extends AddressFormContentProps {
26
28
  placeTypes?: AutocompleteFilterPlaceType[];
27
29
  initialMapCenter?: [number, number];
28
30
  initialMapZoom?: number;
31
+ centerBounds?: CenterBounds;
29
32
  }
30
33
  interface ChildComponents {
31
34
  AddressField: FunctionComponent<AddressFormAddressFieldProps>;
@@ -8,4 +8,4 @@ export interface AddressFormAddressFieldProps {
8
8
  placeholder?: string;
9
9
  className?: string;
10
10
  }
11
- export declare const AddressFormAddressField: import('react').MemoExoticComponent<({ name, label, className, showCurrentLocation, apiName, placeholder }: AddressFormAddressFieldProps) => import("react/jsx-runtime").JSX.Element>;
11
+ export declare const AddressFormAddressField: import('react').MemoExoticComponent<({ name, label, className, showCurrentLocation, apiName, placeholder }: AddressFormAddressFieldProps) => import("react").JSX.Element>;
@@ -1,13 +1,14 @@
1
1
  import { AutocompleteFilterPlaceType } from '@aws-sdk/client-geo-places';
2
2
  import { AddressFormData } from './AddressForm';
3
3
  import { TypeaheadAPIName } from '../Typeahead/use-typeahead-query';
4
+ import { CenterBounds } from '../../utils/bounds';
4
5
  export interface MapViewState {
5
6
  longitude: number;
6
7
  latitude: number;
7
8
  zoom: number;
8
9
  }
9
10
  export interface AddressFormContextType {
10
- apiKey: string;
11
+ apiKey?: string;
11
12
  region: string;
12
13
  data: AddressFormData;
13
14
  setData: (data: AddressFormData) => void;
@@ -19,6 +20,8 @@ export interface AddressFormContextType {
19
20
  showCurrentCountryResultsOnly?: boolean;
20
21
  allowedCountries?: string[];
21
22
  placeTypes?: AutocompleteFilterPlaceType[];
23
+ centerBounds?: CenterBounds;
24
+ isAdjustedPositionOutOfBounds?: boolean;
22
25
  isAutofill: boolean;
23
26
  setIsAutofill: (isAutofill: boolean) => void;
24
27
  typeaheadApiName: TypeaheadAPIName | null;
@@ -5,4 +5,4 @@ export interface AddressFormCountryFieldProps {
5
5
  label: string;
6
6
  placeholder?: string;
7
7
  }
8
- export declare const AddressFormCountryField: import('react').MemoExoticComponent<({ name, className, label, placeholder }: AddressFormCountryFieldProps) => import("react/jsx-runtime").JSX.Element>;
8
+ export declare const AddressFormCountryField: import('react').MemoExoticComponent<({ name, className, label, placeholder }: AddressFormCountryFieldProps) => import("react").JSX.Element>;
@@ -1,7 +1,8 @@
1
1
  import { AutocompleteFilterPlaceType, GeoPlacesClient } from '@aws-sdk/client-geo-places';
2
2
  import { FunctionComponent, PropsWithChildren } from 'react';
3
+ import { CenterBounds } from '../../utils/bounds';
3
4
  export interface AddressFormProps extends PropsWithChildren {
4
- apiKey: string;
5
+ apiKey?: string;
5
6
  region: string;
6
7
  language?: string;
7
8
  politicalView?: string;
@@ -11,5 +12,6 @@ export interface AddressFormProps extends PropsWithChildren {
11
12
  client?: GeoPlacesClient;
12
13
  initialMapCenter?: [number, number];
13
14
  initialMapZoom?: number;
15
+ centerBounds?: CenterBounds;
14
16
  }
15
17
  export declare const AddressFormProvider: FunctionComponent<AddressFormProps>;
@@ -5,4 +5,4 @@ export interface AddressFormTextFieldProps {
5
5
  label: string;
6
6
  placeholder?: string;
7
7
  }
8
- export declare const AddressFormTextField: import('react').MemoExoticComponent<({ name, className, label, placeholder }: AddressFormTextFieldProps) => import("react/jsx-runtime").JSX.Element>;
8
+ export declare const AddressFormTextField: import('react').MemoExoticComponent<({ name, className, label, placeholder }: AddressFormTextFieldProps) => import("react").JSX.Element>;
@@ -0,0 +1,2 @@
1
+ import { ComponentProps, FunctionComponent } from 'react';
2
+ export declare const SubmitButton: FunctionComponent<ComponentProps<"button">>;
@@ -1,5 +1,6 @@
1
1
  import { AutocompleteFilterPlaceType } from '@aws-sdk/client-geo-places';
2
2
  import { SubmitHandler } from './AddressForm';
3
+ import { CenterBounds } from '../../utils/bounds';
3
4
  export interface RenderParams {
4
5
  root: string;
5
6
  apiKey: string;
@@ -12,5 +13,6 @@ export interface RenderParams {
12
13
  onSubmit?: SubmitHandler;
13
14
  initialMapCenter?: [number, number];
14
15
  initialMapZoom?: number;
16
+ centerBounds?: CenterBounds;
15
17
  }
16
18
  export declare const render: ({ root: selector, ...formProps }: RenderParams) => void;
@@ -1,3 +1,3 @@
1
1
  import { FunctionComponent } from 'react';
2
- import { ButtonProps } from '../../Button';
2
+ import { ButtonProps } from '../Button';
3
3
  export declare const AdjustButton: FunctionComponent<Omit<ButtonProps, "variant">>;
@@ -1,9 +1,9 @@
1
1
  import { PropsWithChildren } from 'react';
2
2
  import { GeoPlacesClient } from '@aws-sdk/client-geo-places';
3
3
  type AmazonLocationProviderProps = PropsWithChildren & {
4
- apiKey: string;
4
+ apiKey?: string;
5
5
  region: string;
6
6
  client?: GeoPlacesClient;
7
7
  };
8
- export declare function AmazonLocationProvider({ apiKey, region, children, client }: AmazonLocationProviderProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare function AmazonLocationProvider({ apiKey, region, children, client }: AmazonLocationProviderProps): import("react").JSX.Element;
9
9
  export {};
@@ -4,4 +4,4 @@ export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElemen
4
4
  disabled?: boolean;
5
5
  size?: "small" | "medium" | "large";
6
6
  }
7
- export declare function Button({ children, className, variant, size, disabled, ...restProps }: ButtonProps): import("react/jsx-runtime").JSX.Element;
7
+ export declare function Button({ children, className, variant, size, disabled, ...restProps }: ButtonProps): import("react").JSX.Element;
@@ -14,5 +14,5 @@ interface MultiCountrySelectProps extends BaseCountrySelectProps {
14
14
  onChange: (value: string[]) => void;
15
15
  }
16
16
  export type CountrySelectProps = (SingleCountrySelectProps | MultiCountrySelectProps) & Omit<InputProps, "value" | "onChange" | "id">;
17
- export declare const CountrySelect: ({ id, value, onChange, allowedCountries: defaultAllowedCountries, multiple, ...inputProps }: CountrySelectProps) => import("react/jsx-runtime").JSX.Element;
17
+ export declare const CountrySelect: ({ id, value, onChange, allowedCountries: defaultAllowedCountries, multiple, ...inputProps }: CountrySelectProps) => import("react").JSX.Element;
18
18
  export {};
@@ -4,4 +4,4 @@ export interface FlexProps extends ComponentProps<"div"> {
4
4
  gap?: number | string;
5
5
  flex?: boolean;
6
6
  }
7
- export declare function Flex({ direction, gap, children, className, flex, ...rest }: FlexProps): import("react/jsx-runtime").JSX.Element;
7
+ export declare function Flex({ direction, gap, children, className, flex, ...rest }: FlexProps): import("react").JSX.Element;
@@ -4,4 +4,4 @@ export interface FormFieldProps {
4
4
  children: React.ReactNode;
5
5
  className?: string;
6
6
  }
7
- export declare function FormField({ id, label, children, className }: FormFieldProps): import("react/jsx-runtime").JSX.Element;
7
+ export declare function FormField({ id, label, children, className }: FormFieldProps): import("react").JSX.Element;
@@ -3,4 +3,4 @@ export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement>
3
3
  disabled?: boolean;
4
4
  placeholder?: string;
5
5
  }
6
- export declare function Input({ className, placeholder, disabled, ...restProps }: InputProps): import("react/jsx-runtime").JSX.Element;
6
+ export declare function Input({ className, placeholder, disabled, ...restProps }: InputProps): import("react").JSX.Element;
@@ -1,8 +1,10 @@
1
1
  import { ComponentProps } from 'react';
2
2
  import { TypeaheadOutput } from '../Typeahead/index.tsx';
3
+ import { CenterBounds } from '../../utils/bounds.ts';
3
4
  interface LocateButtonProps extends ComponentProps<"button"> {
4
5
  onLocate: (address: TypeaheadOutput) => void;
5
6
  className?: string;
7
+ queryBounds?: CenterBounds;
6
8
  }
7
- export declare function LocateButton({ onLocate, className, ...restProps }: LocateButtonProps): import("react/jsx-runtime").JSX.Element;
9
+ export declare function LocateButton({ onLocate, className, queryBounds, ...restProps }: LocateButtonProps): import("react").JSX.Element;
8
10
  export {};
@@ -7,5 +7,10 @@ export interface MapProps extends Omit<MapLibreMapProps, "mapStyle"> {
7
7
  mapStyle: ExtendedMapStyle;
8
8
  politicalView?: string;
9
9
  showNavigationControl?: boolean;
10
+ /**
11
+ * Optional base URL for map tile requests. Overrides the default
12
+ * `https://maps.geo.{region}.amazonaws.com`. Used for custom or non-production endpoints.
13
+ */
14
+ mapsEndpointOverride?: string;
10
15
  }
11
- export declare function Map({ mapStyle: extendedMapStyle, politicalView, showNavigationControl, children, ...rest }: MapProps): import("react/jsx-runtime").JSX.Element;
16
+ export declare function Map({ mapStyle: extendedMapStyle, politicalView, showNavigationControl, mapsEndpointOverride, children, ...rest }: MapProps): import("react").JSX.Element;
@@ -2,7 +2,9 @@ import { ColorScheme } from '../Map/index.tsx';
2
2
  export interface MapMarkerProps {
3
3
  adjustablePosition?: boolean;
4
4
  markerPosition?: [number, number];
5
- onSaveMarkerPosition?: (position: [number, number]) => void;
5
+ hasAdjustedPosition?: boolean;
6
+ isOutOfBounds?: boolean;
7
+ onReset?: () => void;
6
8
  colorScheme?: ColorScheme;
7
9
  }
8
- export declare function MapMarker({ adjustablePosition, markerPosition, onSaveMarkerPosition, colorScheme, }: MapMarkerProps): import("react/jsx-runtime").JSX.Element | undefined;
10
+ export declare function MapMarker({ adjustablePosition, markerPosition, hasAdjustedPosition, isOutOfBounds, onReset, colorScheme, }: MapMarkerProps): import("react").JSX.Element | null;
@@ -0,0 +1,7 @@
1
+ import { PropsWithChildren } from 'react';
2
+ interface TooltipProps {
3
+ text: string;
4
+ show?: boolean;
5
+ }
6
+ export declare function Tooltip({ text, show, children }: PropsWithChildren<TooltipProps>): import("react").JSX.Element;
7
+ export {};
@@ -1,5 +1,6 @@
1
1
  import { Address } from '@aws-sdk/client-geo-places';
2
2
  import { TypeaheadAPIInput, TypeaheadAPIName } from './use-typeahead-query.ts';
3
+ import { CenterBounds } from '../../utils/bounds.ts';
3
4
  export interface TypeaheadOutput {
4
5
  placeId?: string;
5
6
  addressLineOneField?: string;
@@ -20,5 +21,6 @@ export interface TypeaheadProps {
20
21
  showCurrentLocation?: boolean;
21
22
  debounce?: number;
22
23
  skipNextQuery?: boolean;
24
+ queryBounds?: CenterBounds;
23
25
  }
24
- export declare const Typeahead: ({ apiName, ...props }: TypeaheadProps) => import("react/jsx-runtime").JSX.Element;
26
+ export declare const Typeahead: ({ apiName, ...props }: TypeaheadProps) => import("react").JSX.Element;
@@ -11,4 +11,4 @@ export interface TypeaheadResultItem {
11
11
  title: string;
12
12
  placeId: string;
13
13
  }
14
- export declare const useTypeaheadQuery: ({ client, apiName, apiInput, enabled }: UseTypeaheadParams) => import('@tanstack/react-query').UseQueryResult<TypeaheadResultItem[], Error>;
14
+ export declare const useTypeaheadQuery: ({ client, apiName, apiInput, enabled }: UseTypeaheadParams) => import('@tanstack/react-query').UseQueryResult<NoInfer<TypeaheadResultItem[]>, Error>;
@@ -1,6 +1,6 @@
1
1
  import { GeoPlacesClient } from '@aws-sdk/client-geo-places';
2
2
  declare const AmazonLocationContext: import('react').Context<{
3
- apiKey: string;
3
+ apiKey?: string;
4
4
  region: string;
5
5
  client: GeoPlacesClient;
6
6
  } | undefined>;
@@ -1,5 +1,5 @@
1
1
  declare function useAmazonLocationContext(): {
2
- apiKey: string;
2
+ apiKey?: string;
3
3
  region: string;
4
4
  client: import('@aws-sdk/client-geo-places').GeoPlacesClient;
5
5
  };
@@ -1 +1 @@
1
- export declare const Locate: () => import("react/jsx-runtime").JSX.Element;
1
+ export declare const Locate: () => import("react").JSX.Element;
@@ -2,5 +2,5 @@ import { ComponentProps } from 'react';
2
2
  interface LogoProps extends ComponentProps<"a"> {
3
3
  mode: "Light" | "Dark";
4
4
  }
5
- export declare const Logo: ({ mode, ...rest }: LogoProps) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const Logo: ({ mode, ...rest }: LogoProps) => import("react").JSX.Element;
6
6
  export {};
@@ -1,4 +1,4 @@
1
- export type NotificationType = "error";
1
+ export type NotificationType = "error" | "warning";
2
2
  export type Notification = {
3
3
  id: string;
4
4
  type: NotificationType;
@@ -1,3 +1,4 @@
1
1
  import { RenderOptions } from '@testing-library/react';
2
2
  import { ReactNode } from 'react';
3
- export declare function renderWithProvider(ui: ReactNode, options?: Omit<RenderOptions, "wrapper">): import('@testing-library/react').RenderResult<typeof import("@testing-library/dom/types/queries"), HTMLElement, HTMLElement>;
3
+ export declare const renderWithProvider: (ui: ReactNode, options?: Omit<RenderOptions, "wrapper">) => import('@testing-library/react').RenderResult<typeof import("@testing-library/dom/types/queries"), HTMLElement, HTMLElement>;
4
+ export declare const renderWithoutApiKey: (ui: ReactNode, options?: Omit<RenderOptions, "wrapper">) => import('@testing-library/react').RenderResult<typeof import("@testing-library/dom/types/queries"), HTMLElement, HTMLElement>;
@@ -0,0 +1,3 @@
1
+ export type CenterBounds = [[number, number], [number, number]];
2
+ export declare const clampCenterToBounds: (center: [number, number], bounds?: CenterBounds) => [number, number];
3
+ export declare const isCenterWithinBounds: (center: [number, number], bounds?: CenterBounds) => boolean;
@@ -1 +1,2 @@
1
1
  export declare const positionToString: ([lng, lat]: number[]) => string;
2
+ export declare const isSamePosition: (a: [number, number] | undefined, b: [number, number] | undefined) => boolean;