Abstract Class: AbstractPickupWidgetManager
Shared plumbing for every carrier map: loading the script and stylesheet exactly once, skipping cleanly during server rendering, and tearing everything down on unmount.
Subclasses implement only what differs between carriers — how the mount element is created and how the carrier reports the picked point.
Framework-agnostic (DOM APIs only), so the same adapters work in React, Vue, Svelte or a plain script tag.
Extended by
Implements
Constructors
Constructor
new AbstractPickupWidgetManager(
options):AbstractPickupWidgetManager
Parameters
options
Returns
AbstractPickupWidgetManager
Properties
container
protectedcontainer:HTMLElement|null=null
descriptor
protectedreadonlydescriptor:PickupWidgetDescriptor
element
protectedelement:HTMLElement|null=null
onSelect
protectedreadonlyonSelect: (point) =>void
Parameters
point
Returns
void
token
protectedreadonlytoken:string
Methods
afterAssetsLoaded()
protectedafterAssetsLoaded(_assets):void
The carrier's assets are in the document and the mount element is already in place.
Nothing to do by default: a widget that is a custom element is picked up by the browser itself, whenever the script defines it. A carrier that builds its maps in a one-off scan overrides this — and may throw, because a map that cannot be built has to be visible to the storefront as a failure rather than as a silently empty frame.
Parameters
_assets
PickupWidgetAssetsState
Returns
void
applyDescriptorAttributes()
protectedapplyDescriptorAttributes(element):void
Apply the descriptor's attributes to a freshly created element.
Parameters
element
HTMLElement
Returns
void
createElement()
abstractprotectedcreateElement():HTMLElement
Create the element the carrier's script turns into a map, with its attributes already set.
Attributes MUST be in place before the element enters the document: a custom element reads its configuration once, when it is connected, and a token set afterwards is ignored. That failure is invisible on the first open (the script is still loading, so the upgrade happens after the attribute lands) and appears only on the second — which is why it belongs here rather than in every storefront that renders a map.
Returns
HTMLElement
destroy()
destroy():
void
Remove the widget and release everything it registered. Safe to call more than once.
Returns
void
Implementation of
mount()
mount(
container):Promise<void>
Mount the widget: the element enters the document FIRST, the carrier's assets follow.
That order is the whole difference between a map and an empty frame. A carrier whose widget is a plain element scans the document ONCE, when its script finishes loading, and never looks again — so an element inserted after that scan is never turned into a map, and nothing reports a failure. Waiting for the script before inserting made that the normal case; the custom-element carrier survived it only because a browser upgrades elements whenever they are defined, whenever that happens to be. Inserting first is correct for both.
A failure removes the element again. An empty box left in the checkout reads as a map that is still loading, and the storefront needs the rejection to fall back to point search.
Parameters
container
HTMLElement
Returns
Promise<void>
Implementation of
subscribe()
abstractprotectedsubscribe():void
Start listening for the buyer's choice.
Returns
void
unsubscribe()
abstractprotectedunsubscribe():void
Stop listening and release anything registered globally.
Returns
void