@zappie/foundations 0.15.0 → 0.17.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 (163) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +115 -5
  3. package/dist/account/index.js +1 -48
  4. package/dist/account/index.js.map +1 -1
  5. package/dist/account/zappie-account.js +1 -38
  6. package/dist/account/zappie-account.js.map +1 -1
  7. package/dist/attribution/powered-by-zappie.js +1 -28
  8. package/dist/attribution/powered-by-zappie.js.map +1 -1
  9. package/dist/branch-map/colors.js +1 -26
  10. package/dist/branch-map/colors.js.map +1 -1
  11. package/dist/branch-map/delivery-map.js +1 -59
  12. package/dist/branch-map/delivery-map.js.map +1 -1
  13. package/dist/branch-map/delivery-runtime.js +1 -117
  14. package/dist/branch-map/delivery-runtime.js.map +1 -1
  15. package/dist/branch-map/fit.js +1 -107
  16. package/dist/branch-map/fit.js.map +1 -1
  17. package/dist/branch-map/geometry.js +1 -11
  18. package/dist/branch-map/geometry.js.map +1 -1
  19. package/dist/branch-map/index.js +1 -94
  20. package/dist/branch-map/index.js.map +1 -1
  21. package/dist/branch-map/loader.js +1 -38
  22. package/dist/branch-map/loader.js.map +1 -1
  23. package/dist/branch-map/markers.js +1 -182
  24. package/dist/branch-map/markers.js.map +1 -1
  25. package/dist/branch-map/runtime.js +1 -294
  26. package/dist/branch-map/runtime.js.map +1 -1
  27. package/dist/branch-map/use-map-runtime.js +1 -52
  28. package/dist/branch-map/use-map-runtime.js.map +1 -1
  29. package/dist/branch-switch/index.js +1 -125
  30. package/dist/branch-switch/index.js.map +1 -1
  31. package/dist/cart/index.js +1 -170
  32. package/dist/cart/index.js.map +1 -1
  33. package/dist/checkout/attempt.js +1 -48
  34. package/dist/checkout/attempt.js.map +1 -1
  35. package/dist/checkout/contact.js +1 -35
  36. package/dist/checkout/contact.js.map +1 -1
  37. package/dist/checkout/index.js +1 -33
  38. package/dist/checkout/index.js.map +1 -1
  39. package/dist/checkout/markers.js +1 -25
  40. package/dist/checkout/markers.js.map +1 -1
  41. package/dist/checkout/offers.js +1 -12
  42. package/dist/checkout/offers.js.map +1 -1
  43. package/dist/checkout/pay-after-sign-in.js +1 -77
  44. package/dist/checkout/pay-after-sign-in.js.map +1 -1
  45. package/dist/checkout/sign-in.js +1 -25
  46. package/dist/checkout/sign-in.js.map +1 -1
  47. package/dist/checkout/status.js +1 -72
  48. package/dist/checkout/status.js.map +1 -1
  49. package/dist/checkout/timing.js +1 -38
  50. package/dist/checkout/timing.js.map +1 -1
  51. package/dist/checkout/use-checkout-flow.js +1 -598
  52. package/dist/checkout/use-checkout-flow.js.map +1 -1
  53. package/dist/deferred/index.js +1 -141
  54. package/dist/deferred/index.js.map +1 -1
  55. package/dist/deferred/retry.js +2 -0
  56. package/dist/deferred/retry.js.map +6 -0
  57. package/dist/fulfilment/address-picker.js +1 -165
  58. package/dist/fulfilment/address-picker.js.map +1 -1
  59. package/dist/fulfilment/branch-picker.js +1 -53
  60. package/dist/fulfilment/branch-picker.js.map +1 -1
  61. package/dist/fulfilment/schedule.js +1 -126
  62. package/dist/fulfilment/schedule.js.map +1 -1
  63. package/dist/fulfilment/switch.js +1 -53
  64. package/dist/fulfilment/switch.js.map +1 -1
  65. package/dist/fulfilment/window.js +1 -154
  66. package/dist/fulfilment/window.js.map +1 -1
  67. package/dist/{index-B1NMxq0i.d.ts → index-B1mCF3ft.d.ts} +5 -4
  68. package/dist/index.d.ts +40 -111
  69. package/dist/index.js +1 -84
  70. package/dist/index.js.map +1 -1
  71. package/dist/internal/combobox.js +1 -130
  72. package/dist/internal/combobox.js.map +1 -1
  73. package/dist/internal/data-attrs.js +1 -7
  74. package/dist/internal/data-attrs.js.map +1 -1
  75. package/dist/internal/ids.js +1 -9
  76. package/dist/internal/ids.js.map +1 -1
  77. package/dist/internal/slot.js +1 -87
  78. package/dist/internal/slot.js.map +1 -1
  79. package/dist/internal/use-controllable-state.js +1 -28
  80. package/dist/internal/use-controllable-state.js.map +1 -1
  81. package/dist/item-form/index.js +1 -14
  82. package/dist/item-form/index.js.map +1 -1
  83. package/dist/item-form/option-group.js +1 -331
  84. package/dist/item-form/option-group.js.map +1 -1
  85. package/dist/item-form/options.js +1 -64
  86. package/dist/item-form/options.js.map +1 -1
  87. package/dist/item-form/quantity.js +1 -130
  88. package/dist/item-form/quantity.js.map +1 -1
  89. package/dist/item-form/root.js +1 -182
  90. package/dist/item-form/root.js.map +1 -1
  91. package/dist/item-sheet/index.d.ts +137 -0
  92. package/dist/item-sheet/index.js +2 -0
  93. package/dist/item-sheet/index.js.map +6 -0
  94. package/dist/loyalty/index.js +1 -278
  95. package/dist/loyalty/index.js.map +1 -1
  96. package/dist/media/image.js +1 -58
  97. package/dist/media/image.js.map +1 -1
  98. package/dist/money.js +1 -19
  99. package/dist/money.js.map +1 -1
  100. package/dist/next.js +1 -57
  101. package/dist/next.js.map +1 -1
  102. package/dist/order/index.js +1 -575
  103. package/dist/order/index.js.map +1 -1
  104. package/dist/order/model.js +1 -83
  105. package/dist/order/model.js.map +1 -1
  106. package/dist/order/use-customer-order.js +1 -55
  107. package/dist/order/use-customer-order.js.map +1 -1
  108. package/dist/otp/input.js +1 -109
  109. package/dist/otp/input.js.map +1 -1
  110. package/dist/overlay/drag-to-close.js +1 -50
  111. package/dist/overlay/drag-to-close.js.map +1 -1
  112. package/dist/overlay/drag.js +1 -209
  113. package/dist/overlay/drag.js.map +1 -1
  114. package/dist/overlay/engine.js +1 -184
  115. package/dist/overlay/engine.js.map +1 -1
  116. package/dist/overlay/history.js +1 -101
  117. package/dist/overlay/history.js.map +1 -1
  118. package/dist/overlay/load.js +1 -28
  119. package/dist/overlay/load.js.map +1 -1
  120. package/dist/overlay/react.js +1 -481
  121. package/dist/overlay/react.js.map +1 -1
  122. package/dist/payment/methods.js +1 -102
  123. package/dist/payment/methods.js.map +1 -1
  124. package/dist/phone/combobox.js +1 -295
  125. package/dist/phone/combobox.js.map +1 -1
  126. package/dist/phone/core.js +1 -162
  127. package/dist/phone/core.js.map +1 -1
  128. package/dist/phone/countries.js +1 -56
  129. package/dist/phone/countries.js.map +1 -1
  130. package/dist/phone/country-data.js +1 -272
  131. package/dist/phone/country-data.js.map +1 -1
  132. package/dist/phone/index.js +1 -42
  133. package/dist/phone/index.js.map +1 -1
  134. package/dist/phone/load.js +1 -12
  135. package/dist/phone/load.js.map +1 -1
  136. package/dist/phone/picker.js +1 -142
  137. package/dist/phone/picker.js.map +1 -1
  138. package/dist/phone/use-phone-field.js +1 -183
  139. package/dist/phone/use-phone-field.js.map +1 -1
  140. package/dist/react-CFPTPzAO.d.ts +120 -0
  141. package/dist/rich-text/banners.js +1 -8
  142. package/dist/rich-text/banners.js.map +1 -1
  143. package/dist/rich-text/browser.js +1 -23
  144. package/dist/rich-text/browser.js.map +1 -1
  145. package/dist/rich-text/core.js +1 -74
  146. package/dist/rich-text/core.js.map +1 -1
  147. package/dist/rich-text/index.js +1 -3
  148. package/dist/rich-text/index.js.map +1 -1
  149. package/dist/schedule/index.js +1 -36
  150. package/dist/schedule/index.js.map +1 -1
  151. package/dist/search/engine.js +1 -92
  152. package/dist/search/engine.js.map +1 -1
  153. package/dist/search/index.js +1 -174
  154. package/dist/search/index.js.map +1 -1
  155. package/dist/status/contact.js +1 -41
  156. package/dist/status/contact.js.map +1 -1
  157. package/dist/status/hours.js +1 -185
  158. package/dist/status/hours.js.map +1 -1
  159. package/dist/status/open-status.js +1 -47
  160. package/dist/status/open-status.js.map +1 -1
  161. package/dist/version.js +1 -5
  162. package/dist/version.js.map +1 -1
  163. package/package.json +14 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @zappie/foundations
2
2
 
3
+ ## 0.17.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 1737d6b: A `deferred()` component whose code fails to load shows a retry notice by default, so a shopper who taps never sees nothing. The notice, `OverlayRetry`, is a `role="alert"` saying "This didn't load." with Try again, which loads the code again, and Close. Close and Escape hide it and call the component's `onOpenChange(false)` or `onClose()`. Focus moves to Try again when the shopper opened the component. The notice has no styles of its own.
8
+
9
+ `failed` now also receives `close`, and still replaces the default. Render `OverlayRetry` from it to set the message or a class.
10
+
11
+ The starter's retry notice is now foundations' `OverlayRetry` with the starter's class.
12
+
13
+ ## 0.16.0
14
+
15
+ ### Minor Changes
16
+
17
+ - 2ea70d8: `@zappie/foundations/item-sheet` opens a product over the page the shopper tapped it on, in a React Router site. The page stays mounted under the sheet, unchanged, with its own location and loader data. The address is the item's own, `/item/:id`, so it can be shared and Back closes it. Closing goes back to the page with its scroll kept, and focus returns to the card that opened it. A link straight to the item, or a reload, shows it over the item route's own page, such as the menu.
18
+
19
+ `ItemSheet.Root` holds the sheet, `ItemSheet.Page` replaces the layout's `<Outlet />`, `ItemSheet.Content` is the sheet, a foundations `Overlay` with Escape, the focus trap, the scroll lock, drag to close and the exit, and `ItemSheet.Trigger` is each card's link. The sheet paints on the tap, then the address follows. Its code loads when the page is idle and when a shopper points at a card, and a sheet whose code didn't load shows `failed` with a way to try again. The sheet's content stays the site's own. `keptLine`, `restoreLine` and `returnFocusToCard` move in from the sites. The subpath needs React Router 8.4 or later, an optional peer dependency.
20
+
21
+ The starter opens items through it from every page. It adds an About page with the store's items, linked from the footer. The item sheet slides in and out, and stays still under reduced motion.
22
+
23
+ ### Patch Changes
24
+
25
+ - 295d5e1: The published JavaScript carries no whitespace or comments. Identifiers, function names, directives such as `"use client"` and pure annotations stay as written, and each module's source map still points into its source, so a site's own bundle is the same size as before. The packed archives are smaller: the SDK by about 17 KB, foundations by about 9 KB and the base theme by about 7 KB.
26
+ - Updated dependencies [295d5e1]
27
+ - @zappie/sdk@0.18.1
28
+
3
29
  ## 0.15.0
4
30
 
5
31
  ### Minor Changes
package/README.md CHANGED
@@ -39,6 +39,7 @@ Want ready-made, styled components instead? Copy them into your project from the
39
39
  | `@zappie/foundations/checkout` | Checkout behaviour for a bag or a cart page, with no markup |
40
40
  | `@zappie/foundations/loyalty` | The rewards sheet's parts, the bag's rewards row and the claim toast |
41
41
  | `@zappie/foundations/order` | A customer's order details page, as parts or one default layout |
42
+ | `@zappie/foundations/item-sheet` | A product sheet over the current page in a React Router site |
42
43
  | `@zappie/foundations/rich-text` | Sanitising and parsing merchant rich text before you render it |
43
44
 
44
45
  ## Docs
@@ -91,11 +92,10 @@ function Header() {
91
92
  - Pass `fallback` to hold an inline part's place while its code loads, for
92
93
  example a placeholder label. It shows only while `open` is true and the code
93
94
  is not in yet, and it never suspends.
94
- - Pass `failed` to show something when the code fails to load, such as a
95
- message with a button that calls `retry`. It shows only while `open` is true.
96
- Without it nothing shows, so a shopper who taps and sees nothing never knows
97
- to tap again. A later `preload()`, such as the one the next tap on the
98
- trigger starts, also retries, and the component renders when it succeeds.
95
+ - When the code fails to load, `Component` shows a retry notice while `open`
96
+ is true, so a tap never shows nothing. See [Load failures](#load-failures).
97
+ A later `preload()`, such as the one the next tap on the trigger starts, also
98
+ retries, and the component renders when it succeeds.
99
99
  - `preload()` starts the load and returns its promise. Calls share one load. A
100
100
  failed load is forgotten, so the next `preload()` or the next open tries again.
101
101
  - `preloadWhenIdle({ timeout? })` loads the code when the browser is idle and
@@ -114,6 +114,49 @@ then the panel is hidden from assistive technology and takes no keys, presses or
114
114
  scrolls, apart from Escape and an outside press, which close it. Style the panel
115
115
  and `[data-zappie-backdrop]` as usual: both frames match them.
116
116
 
117
+ ### Load failures
118
+
119
+ A chunk can fail to load on a bad network or while a deploy swaps chunks.
120
+ Without `failed`, `Component` shows `OverlayRetry` in its place:
121
+
122
+ - a `role="alert"` paragraph saying "This didn't load.", which screen readers
123
+ announce;
124
+ - Try again, which loads the code again and renders the component when it
125
+ arrives;
126
+ - Close, and Escape, which hide the notice and call the component's
127
+ `onOpenChange(false)` or `onClose()` when it has one, so the next tap opens
128
+ it again.
129
+
130
+ Focus moves to Try again when the shopper opened the component. A part
131
+ rendered with `open` from the start, such as an inline account button, leaves
132
+ focus where it is. The notice has no styles of its own. It renders in the
133
+ component's place, so give it a class for an overlay that would sit above the
134
+ page.
135
+
136
+ Pass `failed={(retry, close) => ...}` to name what didn't load or to style it.
137
+ `OverlayRetry` takes the same `retry` and `close`, a `message` and a
138
+ `className`:
139
+
140
+ ```tsx
141
+ import { OverlayRetry } from "@zappie/foundations";
142
+
143
+ <BagSheet.Component
144
+ open={open}
145
+ onClose={() => setOpen(false)}
146
+ failed={(retry, close) => (
147
+ <OverlayRetry
148
+ message="Your bag didn't load."
149
+ retry={retry}
150
+ close={close}
151
+ className="retry-notice"
152
+ />
153
+ )}
154
+ />;
155
+ ```
156
+
157
+ The notice is part of the initial entry, not a lazy chunk, because it shows
158
+ when chunks don't load.
159
+
117
160
  ## Drag to close
118
161
 
119
162
  On a phone or touch screen, a drawer or sheet from `Overlay` closes when it is
@@ -244,6 +287,73 @@ import { OrderDetails } from "@zappie/foundations/order";
244
287
  />;
245
288
  ```
246
289
 
290
+ ## Item sheet
291
+
292
+ `@zappie/foundations/item-sheet` opens a product over the page the shopper tapped it on, in a React Router site. The page stays mounted under the sheet, unchanged. The address is the item's own, such as `/item/jollof`, so it can be shared and Back closes it. Closing goes back to the page with its scroll kept, and focus returns to the card that opened it. A link straight to the item, or a reload, shows the sheet over the item route's own page, such as the menu.
293
+
294
+ The sheet paints on the tap, and the address catches up a frame later. It is a foundations `Overlay`, so Escape, the focus trap, the scroll lock, drag to close on phones and the exit come with it. Its code loads once the page is idle and when a shopper points at or focuses a card. If it doesn't load, `failed` shows instead, with a way to try again.
295
+
296
+ You write the sheet's content: its photos, choices and Add, built on `ItemForm`, `OptionGroup` and `Choice`. Load it with `deferred()` and pass it as `sheet`.
297
+
298
+ ```tsx
299
+ // app/root.tsx, or the layout that holds the item route
300
+ import { deferred } from "@zappie/foundations";
301
+ import { ItemSheet } from "@zappie/foundations/item-sheet";
302
+
303
+ const sheet = deferred(() => import("./ui/item-sheet-body"));
304
+
305
+ <ItemSheet.Root sheet={sheet} href={(id) => `/item/${id}`} closeTo="/menu">
306
+ <Header />
307
+ <ItemSheet.Page />
308
+ <ItemSheet.Content
309
+ className="item-sheet"
310
+ presentation={{ base: "drawer", lg: "sheet" }}
311
+ failed={(retry, close) => <Retry retry={retry} close={close} />}
312
+ />
313
+ </ItemSheet.Root>;
314
+
315
+ // A card
316
+ <ItemSheet.Trigger itemId={item.id}>{item.name}</ItemSheet.Trigger>;
317
+
318
+ // app/ui/item-sheet-body.tsx
319
+ export default function ItemSheetBody({ itemId, close }: ItemSheetBodyProps) {
320
+ return (
321
+ <>
322
+ <ItemSheet.Title>{name}</ItemSheet.Title>
323
+ <ItemSheet.Close aria-label="Close item">×</ItemSheet.Close>
324
+ <ItemForm.Root item={item} onAdded={close}>
325
+ …
326
+ </ItemForm.Root>
327
+ </>
328
+ );
329
+ }
330
+ ```
331
+
332
+ - `ItemSheet.Root` takes `sheet`, `href` (the item's address), `closeTo` (where closing a sheet opened from a link goes, `/` by default) and `path` (the item route, `/item/:id` by default). Put it in the root or the layout whose `<Outlet />` renders both the pages and the item route.
333
+ - `ItemSheet.Page` goes where that `<Outlet />` was. While the address names an item, it keeps the page the shopper was on, with that page's location and loader data.
334
+ - `ItemSheet.Content` is the sheet. It takes the props of `Overlay.Content`, `presentation` (`drawer` by default), `failed` and, optionally, `fallback` to show while the content loads. Without `fallback`, a sheet tapped before its code is in opens once the code and its styles are, so it never paints unstyled. It marks the dialog with `data-zappie-overlay="item"`.
335
+ - `ItemSheet.Trigger` is an `<a href>` to the item, marked `data-zappie-item-link` and `data-zappie-overlay-trigger="item"`. A click with a modifier key opens the address in a new tab. Use `asChild` for your own anchor.
336
+ - `useItemSheet()` gives the open item and `open`, `close`, `href` and `preload`. `returnFocusToCard(id)` focuses an item's card without scrolling. `keptLine` and `restoreLine` keep the line a shopper chose while they pick a branch, and restore it as that branch sells the item.
337
+
338
+ ### Routes
339
+
340
+ Add `item/:id` beside the pages an item can open over, under the component that renders `ItemSheet.Page`. Its own page is what a link straight to the item shows under the sheet.
341
+
342
+ ```ts
343
+ // Every page: the root holds the sheet.
344
+ route("/", "routes/home.tsx"),
345
+ route("menu", "routes/menu.tsx"),
346
+ route("item/:id", "routes/item.tsx"), // renders the menu
347
+
348
+ // Only the pages under one layout: the layout holds the sheet.
349
+ layout("routes/catalogue.tsx", [
350
+ route("menu", "routes/menu.tsx"),
351
+ route("item/:id", "routes/item.tsx"), // renders the menu
352
+ ]),
353
+ ```
354
+
355
+ An item opened from a page outside the layout replaces that page with the item route's page. The sheet needs React Router 8.4 or later.
356
+
247
357
  ## Branch switch
248
358
 
249
359
  Choosing a branch shows that branch's menu without waiting for the server. A
@@ -1,49 +1,2 @@
1
- // src/account/index.tsx
2
- import { forwardRef } from "react";
3
- import { part } from "../internal/slot.js";
4
- var AccountNotConfiguredError = class extends Error {
5
- constructor() {
6
- super("Account authentication requires SDK auth (Open Storefronts PRD 13)");
7
- this.code = "not_configured";
8
- this.name = "AccountNotConfiguredError";
9
- }
10
- };
11
- async function signIn(_options) {
12
- throw new AccountNotConfiguredError();
13
- }
14
- async function signOut(_options) {
15
- throw new AccountNotConfiguredError();
16
- }
17
- var SignIn = /* @__PURE__ */ forwardRef(function SignIn2(props, ref) {
18
- return part(
19
- "div",
20
- props,
21
- { signIn, status: "not_configured" },
22
- { "data-state": "invalid" },
23
- ref
24
- );
25
- });
26
- var SignOut = /* @__PURE__ */ forwardRef(function SignOut2(props, ref) {
27
- return part(
28
- "div",
29
- props,
30
- { signOut, status: "not_configured" },
31
- { "data-state": "invalid" },
32
- ref
33
- );
34
- });
35
- var CustomerPart = /* @__PURE__ */ forwardRef(function Customer(props, ref) {
36
- return part(
37
- "div",
38
- props,
39
- { customer: null, status: "not_configured" },
40
- { "data-state": "invalid" },
41
- ref
42
- );
43
- });
44
- var Account = { SignIn, SignOut, Customer: CustomerPart };
45
- export {
46
- Account,
47
- AccountNotConfiguredError
48
- };
1
+ import{forwardRef}from"react";import{part}from"../internal/slot.js";var AccountNotConfiguredError=class extends Error{constructor(){super("Account authentication requires SDK auth (Open Storefronts PRD 13)");this.code="not_configured";this.name="AccountNotConfiguredError"}};async function signIn(_options){throw new AccountNotConfiguredError}async function signOut(_options){throw new AccountNotConfiguredError}var SignIn=/*@__PURE__ */forwardRef(function SignIn2(props,ref){return part("div",props,{signIn,status:"not_configured"},{"data-state":"invalid"},ref)});var SignOut=/*@__PURE__ */forwardRef(function SignOut2(props,ref){return part("div",props,{signOut,status:"not_configured"},{"data-state":"invalid"},ref)});var CustomerPart=/*@__PURE__ */forwardRef(function Customer(props,ref){return part("div",props,{customer:null,status:"not_configured"},{"data-state":"invalid"},ref)});var Account={SignIn,SignOut,Customer:CustomerPart};export{Account,AccountNotConfiguredError};
49
2
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/account/index.tsx"],
4
- "mappings": ";AAAA,SAAS,kBAAkB;AAC3B,SAAS,YAA4B;AAyB9B,IAAM,4BAAN,cAAwC,MAAM;AAAA,EAEnD,cAAc;AACZ,UAAM,oEAAoE;AAF5E,SAAS,OAAO;AAGd,SAAK,OAAO;AAAA,EACd;AACF;AACA,eAAe,OAAO,UAAyC;AAC7D,QAAM,IAAI,0BAA0B;AACtC;AACA,eAAe,QAAQ,UAAoD;AACzE,QAAM,IAAI,0BAA0B;AACtC;AACA,IAAM,SAAyB,2BAG7B,SAASA,QAAO,OAAO,KAAK;AAC5B,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,EAAE,QAAQ,QAAQ,iBAAiB;AAAA,IACnC,EAAE,cAAc,UAAU;AAAA,IAC1B;AAAA,EACF;AACF,CAAC;AACD,IAAM,UAA0B,2BAG9B,SAASC,SAAQ,OAAO,KAAK;AAC7B,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,EAAE,SAAS,QAAQ,iBAAiB;AAAA,IACpC,EAAE,cAAc,UAAU;AAAA,IAC1B;AAAA,EACF;AACF,CAAC;AACD,IAAM,eAA+B,2BAGnC,SAAS,SAAS,OAAO,KAAK;AAC9B,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,EAAE,UAAU,MAAM,QAAQ,iBAAiB;AAAA,IAC3C,EAAE,cAAc,UAAU;AAAA,IAC1B;AAAA,EACF;AACF,CAAC;AAKM,IAAM,UAAU,EAAE,QAAQ,SAAS,UAAU,aAAa;",
4
+ "mappings": "AAAA,OAAS,eAAkB,QAC3B,OAAS,SAA4B,sBAyB9B,IAAM,0BAAN,cAAwC,KAAM,CAEnD,aAAc,CACZ,MAAM,oEAAoE,EAF5E,KAAS,KAAO,iBAGd,KAAK,KAAO,2BACd,CACF,EACA,eAAe,OAAO,SAAyC,CAC7D,MAAM,IAAI,yBACZ,CACA,eAAe,QAAQ,SAAoD,CACzE,MAAM,IAAI,yBACZ,CACA,IAAM,OAAS,eAAgB,WAG7B,SAASA,QAAO,MAAO,IAAK,CAC5B,OAAO,KACL,MACA,MACA,CAAE,OAAQ,OAAQ,gBAAiB,EACnC,CAAE,aAAc,SAAU,EAC1B,GACF,CACF,CAAC,EACD,IAAM,QAAU,eAAgB,WAG9B,SAASC,SAAQ,MAAO,IAAK,CAC7B,OAAO,KACL,MACA,MACA,CAAE,QAAS,OAAQ,gBAAiB,EACpC,CAAE,aAAc,SAAU,EAC1B,GACF,CACF,CAAC,EACD,IAAM,aAAe,eAAgB,WAGnC,SAAS,SAAS,MAAO,IAAK,CAC9B,OAAO,KACL,MACA,MACA,CAAE,SAAU,KAAM,OAAQ,gBAAiB,EAC3C,CAAE,aAAc,SAAU,EAC1B,GACF,CACF,CAAC,EAKM,IAAM,QAAU,CAAE,OAAQ,QAAS,SAAU,YAAa",
5
5
  "names": ["SignIn", "SignOut"]
6
6
  }
@@ -1,39 +1,2 @@
1
- // src/account/zappie-account.tsx
2
- import { accountsUrl } from "@zappie/sdk/account";
3
- import { forwardRef, useEffect, useState } from "react";
4
- import { part } from "../internal/slot.js";
5
- var LOOPBACK = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]", "::1"]);
6
- function zappieEnvironment(host) {
7
- const name = host.trim().toLowerCase().replace(/\.$/, "");
8
- return LOOPBACK.has(name) || name.endsWith(".localhost") || name.endsWith(".workers.dev") || name.endsWith(".zappie-sites.dev") || name.includes(".stg.") ? "staging" : "production";
9
- }
10
- function zappieAccountUrl(page) {
11
- const back = new URL(page);
12
- return accountsUrl("/account", zappieEnvironment(back.hostname), {
13
- returnTo: back
14
- });
15
- }
16
- function useZappieAccountUrl(returnTo) {
17
- const [url, setUrl] = useState(() => accountsUrl("/account"));
18
- useEffect(() => {
19
- setUrl(zappieAccountUrl(new URL(returnTo ?? "", window.location.href)));
20
- }, [returnTo]);
21
- return url;
22
- }
23
- var ZappieAccountLink = /* @__PURE__ */ forwardRef(function ZappieAccountLink2({ returnTo, ...props }, ref) {
24
- const href = useZappieAccountUrl(returnTo);
25
- return part(
26
- "a",
27
- { ...props, children: props.children ?? "Your Zappie account" },
28
- { href },
29
- { href, "data-zappie-account": "" },
30
- ref
31
- );
32
- });
33
- export {
34
- ZappieAccountLink,
35
- useZappieAccountUrl,
36
- zappieAccountUrl,
37
- zappieEnvironment
38
- };
1
+ import{accountsUrl}from"@zappie/sdk/account";import{forwardRef,useEffect,useState}from"react";import{part}from"../internal/slot.js";var LOOPBACK=new Set(["localhost","127.0.0.1","[::1]","::1"]);function zappieEnvironment(host){const name=host.trim().toLowerCase().replace(/\.$/,"");return LOOPBACK.has(name)||name.endsWith(".localhost")||name.endsWith(".workers.dev")||name.endsWith(".zappie-sites.dev")||name.includes(".stg.")?"staging":"production"}function zappieAccountUrl(page){const back=new URL(page);return accountsUrl("/account",zappieEnvironment(back.hostname),{returnTo:back})}function useZappieAccountUrl(returnTo){const[url,setUrl]=useState(()=>accountsUrl("/account"));useEffect(()=>{setUrl(zappieAccountUrl(new URL(returnTo??"",window.location.href)))},[returnTo]);return url}var ZappieAccountLink=/*@__PURE__ */forwardRef(function ZappieAccountLink2({returnTo,...props},ref){const href=useZappieAccountUrl(returnTo);return part("a",{...props,children:props.children??"Your Zappie account"},{href},{href,"data-zappie-account":""},ref)});export{ZappieAccountLink,useZappieAccountUrl,zappieAccountUrl,zappieEnvironment};
39
2
  //# sourceMappingURL=zappie-account.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/account/zappie-account.tsx"],
4
- "mappings": ";AAAA,SAAS,mBAAmB;AAE5B,SAAS,YAAY,WAAW,gBAAgB;AAChD,SAAS,YAA4B;AAErC,IAAM,WAAW,oBAAI,IAAI,CAAC,aAAa,aAAa,SAAS,KAAK,CAAC;AAU5D,SAAS,kBAAkB,MAAiC;AACjE,QAAM,OAAO,KAAK,KAAK,EAAE,YAAY,EAAE,QAAQ,OAAO,EAAE;AACxD,SAAO,SAAS,IAAI,IAAI,KACtB,KAAK,SAAS,YAAY,KAC1B,KAAK,SAAS,cAAc,KAC5B,KAAK,SAAS,mBAAmB,KACjC,KAAK,SAAS,OAAO,IACnB,YACA;AACN;AASO,SAAS,iBAAiB,MAA4B;AAC3D,QAAM,OAAO,IAAI,IAAI,IAAI;AACzB,SAAO,YAAY,YAAY,kBAAkB,KAAK,QAAQ,GAAG;AAAA,IAC/D,UAAU;AAAA,EACZ,CAAC;AACH;AAUO,SAAS,oBAAoB,UAA2B;AAG7D,QAAM,CAAC,KAAK,MAAM,IAAI,SAAS,MAAM,YAAY,UAAU,CAAC;AAC5D,YAAU,MAAM;AACd,WAAO,iBAAiB,IAAI,IAAI,YAAY,IAAI,OAAO,SAAS,IAAI,CAAC,CAAC;AAAA,EACxE,GAAG,CAAC,QAAQ,CAAC;AACb,SAAO;AACT;AAQO,IAAM,oBAAoC,2BAM/C,SAASA,mBAAkB,EAAE,UAAU,GAAG,MAAM,GAAG,KAAK;AACxD,QAAM,OAAO,oBAAoB,QAAQ;AACzC,SAAO;AAAA,IACL;AAAA,IACA,EAAE,GAAG,OAAO,UAAU,MAAM,YAAY,sBAAsB;AAAA,IAC9D,EAAE,KAAK;AAAA,IACP,EA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= "https://zappie.ai";
4
- var ZAPPIE_ATTRIBUTION_TEXT = "Powered by Zappie";
5
- function PoweredByZappie({ style, ...props }) {
6
- const size = style?.fontSize ?? "1em";
7
- return /* @__PURE__ */ jsx(
8
- "a",
9
- {
10
- ...props,
11
- style: {
12
- color: "inherit",
13
- ...style,
14
- fontSize: `max(${typeof size == "number" ? size + "px" : size}, var(--z-text-sm, .875rem), 11px)`
15
- },
16
- href: ZAPPIE_ATTRIBUTION_URL,
17
- target: "_blank",
18
- rel: "noopener",
19
- "data-zappie-attribution": "",
20
- children: ZAPPIE_ATTRIBUTION_TEXT
21
- }
22
- );
23
- }
24
- export {
25
- PoweredByZappie,
26
- ZAPPIE_ATTRIBUTION_TEXT,
27
- ZAPPIE_ATTRIBUTION_URL
28
- };
1
+ import{jsx}from"react/jsx-runtime";var ZAPPIE_ATTRIBUTION_URL="https://zappie.ai";var ZAPPIE_ATTRIBUTION_TEXT="Powered by Zappie";function PoweredByZappie({style,...props}){const size=style?.fontSize??"1em";return jsx("a",{...props,style:{color:"inherit",...style,fontSize:`max(${typeof size=="number"?size+"px":size}, var(--z-text-sm, .875rem), 11px)`},href:ZAPPIE_ATTRIBUTION_URL,target:"_blank",rel:"noopener","data-zappie-attribution":"",children:ZAPPIE_ATTRIBUTION_TEXT})}export{PoweredByZappie,ZAPPIE_ATTRIBUTION_TEXT,ZAPPIE_ATTRIBUTION_URL};
29
2
  //# sourceMappingURL=powered-by-zappie.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/attribution/powered-by-zappie.tsx"],
4
- "mappings": ";AAyBI;AAtBG,IAAM,yBAAyB;AAE/B,IAAM,0BAA0B;AAiBhC,SAAS,gBAAgB,EAAE,OAAO,GAAG,MAAM,GAAyB;AACzE,QAAM,OAAO,OAAO,YAAY;AAChC,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO;AAAA,QACL,OAAO;AAAA,QACP,GAAG;AAAA,QACH,UAAU,OAAO,OAAO,QAAQ,WAAW,OAAO,OAAO,IAAI;AAAA,MAC/D;AAAA,MACA,MAAM;AAAA,MACN,QAAO;AAAA,MACP,KAAI;AAAA,MACJ,2BAAwB;AAAA,MAEvB;AAAA;AAAA,EACH;AAEJ;",
4
+ "mappings": "AAyBI,mCAtBG,IAAM,uBAAyB,oBAE/B,IAAM,wBAA0B,oBAiBhC,SAAS,gBAAgB,CAAE,MAAO,GAAG,KAAM,EAAyB,CACzE,MAAM,KAAO,OAAO,UAAY,MAChC,OACE,IAAC,KACE,GAAG,MACJ,MAAO,CACL,MAAO,UACP,GAAG,MACH,SAAU,OAAO,OAAO,MAAQ,SAAW,KAAO,KAAO,IAAI,oCAC/D,EACA,KAAM,uBACN,OAAO,SACP,IAAI,WACJ,0BAAwB,GAEvB,iCACH,CAEJ",
5
5
  "names": []
6
6
  }
@@ -1,27 +1,2 @@
1
- // src/branch-map/colors.ts
2
- var DEFAULT_COLORS = {
3
- accent: "#111111",
4
- accentForeground: "#ffffff"
5
- };
6
- var COLOR_PROBE_STYLE = {
7
- color: "var(--map-accent, currentColor)",
8
- backgroundColor: "var(--map-accent-foreground, #ffffff)",
9
- borderColor: "var(--delivery-map-route, #163300)"
10
- };
11
- function readColors(probe) {
12
- if (!probe || typeof getComputedStyle !== "function") {
13
- return DEFAULT_COLORS;
14
- }
15
- const style = getComputedStyle(probe);
16
- return {
17
- accent: style.color || DEFAULT_COLORS.accent,
18
- accentForeground: style.backgroundColor || DEFAULT_COLORS.accentForeground,
19
- route: style.borderTopColor || void 0
20
- };
21
- }
22
- export {
23
- COLOR_PROBE_STYLE,
24
- DEFAULT_COLORS,
25
- readColors
26
- };
1
+ var DEFAULT_COLORS={accent:"#111111",accentForeground:"#ffffff"};var COLOR_PROBE_STYLE={color:"var(--map-accent, currentColor)",backgroundColor:"var(--map-accent-foreground, #ffffff)",borderColor:"var(--delivery-map-route, #163300)"};function readColors(probe){if(!probe||typeof getComputedStyle!=="function"){return DEFAULT_COLORS}const style=getComputedStyle(probe);return{accent:style.color||DEFAULT_COLORS.accent,accentForeground:style.backgroundColor||DEFAULT_COLORS.accentForeground,route:style.borderTopColor||void 0}}export{COLOR_PROBE_STYLE,DEFAULT_COLORS,readColors};
27
2
  //# sourceMappingURL=colors.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/branch-map/colors.ts"],
4
- "mappings": ";AAQO,IAAM,iBAA4B;AAAA,EACvC,QAAQ;AAAA,EACR,kBAAkB;AACpB;AAGO,IAAM,oBAAoB;AAAA,EAC/B,OAAO;AAAA,EACP,iBAAiB;AAAA,EACjB,aAAa;AACf;AAGO,SAAS,WAAW,OAAsC;AAC/D,MAAI,CAAC,SAAS,OAAO,qBAAqB,YAAY;AACpD,WAAO;AAAA,EACT;AACA,QAAM,QAAQ,iBAAiB,KAAK;AACpC,SAAO;AAAA,IACL,QAAQ,MAAM,SAAS,eAAe;AAAA,IACtC,kBAAkB,MAAM,mBAAmB,eAAe;AAAA,IAC1D,OAAO,MAAM,kBAAkB;AAAA,EACjC;AACF;",
4
+ "mappings": "AAQO,IAAM,eAA4B,CACvC,OAAQ,UACR,iBAAkB,SACpB,EAGO,IAAM,kBAAoB,CAC/B,MAAO,kCACP,gBAAiB,wCACjB,YAAa,oCACf,EAGO,SAAS,WAAW,MAAsC,CAC/D,GAAI,CAAC,OAAS,OAAO,mBAAqB,WAAY,CACpD,OAAO,cACT,CACA,MAAM,MAAQ,iBAAiB,KAAK,EACpC,MAAO,CACL,OAAQ,MAAM,OAAS,eAAe,OACtC,iBAAkB,MAAM,iBAAmB,eAAe,iBAC1D,MAAO,MAAM,gBAAkB,MACjC,CACF",
5
5
  "names": []
6
6
  }
@@ -1,60 +1,2 @@
1
- "use client";
2
-
3
- // src/branch-map/delivery-map.tsx
4
- import { useEffect, useRef } from "react";
5
- import { COLOR_PROBE_STYLE, readColors } from "./colors.js";
6
- import { validCoordinates } from "./geometry.js";
7
- import { useMapRuntime } from "./use-map-runtime.js";
8
- import { jsx, jsxs } from "react/jsx-runtime";
9
- var loadDeliveryMap = (target, key, signal) => import("./delivery-runtime.js").then(
10
- ({ createDeliveryMap }) => createDeliveryMap(target, key, signal)
11
- );
12
- function DeliveryMap({
13
- branch,
14
- shopper,
15
- route,
16
- browserKey,
17
- pinImageUrl,
18
- onLoadError,
19
- renderLoadError,
20
- ...props
21
- }) {
22
- const probe = useRef(null);
23
- const origin = validCoordinates(branch.coordinates) ? branch.coordinates : void 0;
24
- const destination = validCoordinates(shopper) ? shopper : void 0;
25
- const mappable = !!origin && !!destination;
26
- const { element, runtime, failure, retry } = useMapRuntime(browserKey, mappable, loadDeliveryMap, onLoadError);
27
- const failed = failure !== void 0;
28
- const coordinates = branch.coordinates;
29
- useEffect(() => {
30
- if (runtime && validCoordinates(coordinates) && validCoordinates(shopper)) {
31
- runtime.update({
32
- branch: coordinates,
33
- shopper,
34
- route,
35
- pinImageUrl,
36
- colors: readColors(probe.current)
37
- });
38
- }
39
- }, [runtime, coordinates, shopper, route, pinImageUrl]);
40
- if (!browserKey) {
41
- return null;
42
- }
43
- return /* @__PURE__ */ jsxs("div", { ...props, "data-delivery-map": "", children: [
44
- /* @__PURE__ */ jsx("span", { ref: probe, hidden: true, style: COLOR_PROBE_STYLE }),
45
- /* @__PURE__ */ jsx(
46
- "div",
47
- {
48
- hidden: failed || !mappable,
49
- ref: element,
50
- "data-delivery-map-canvas": "",
51
- style: { height: "100%" }
52
- }
53
- ),
54
- failure && renderLoadError ? renderLoadError({ error: failure.error, retry }) : failed || !mappable ? /* @__PURE__ */ jsx("p", { role: "status", children: "Map location unavailable" }) : null
55
- ] });
56
- }
57
- export {
58
- DeliveryMap
59
- };
1
+ "use client";import{useEffect,useRef}from"react";import{COLOR_PROBE_STYLE,readColors}from"./colors.js";import{validCoordinates}from"./geometry.js";import{useMapRuntime}from"./use-map-runtime.js";import{jsx,jsxs}from"react/jsx-runtime";var loadDeliveryMap=(target,key,signal)=>import("./delivery-runtime.js").then(({createDeliveryMap})=>createDeliveryMap(target,key,signal));function DeliveryMap({branch,shopper,route,browserKey,pinImageUrl,onLoadError,renderLoadError,...props}){const probe=useRef(null);const origin=validCoordinates(branch.coordinates)?branch.coordinates:void 0;const destination=validCoordinates(shopper)?shopper:void 0;const mappable=!!origin&&!!destination;const{element,runtime,failure,retry}=useMapRuntime(browserKey,mappable,loadDeliveryMap,onLoadError);const failed=failure!==void 0;const coordinates=branch.coordinates;useEffect(()=>{if(runtime&&validCoordinates(coordinates)&&validCoordinates(shopper)){runtime.update({branch:coordinates,shopper,route,pinImageUrl,colors:readColors(probe.current)})}},[runtime,coordinates,shopper,route,pinImageUrl]);if(!browserKey){return null}return jsxs("div",{...props,"data-delivery-map":"",children:[jsx("span",{ref:probe,hidden:true,style:COLOR_PROBE_STYLE}),jsx("div",{hidden:failed||!mappable,ref:element,"data-delivery-map-canvas":"",style:{height:"100%"}}),failure&&renderLoadError?renderLoadError({error:failure.error,retry}):failed||!mappable?jsx("p",{role:"status",children:"Map location unavailable"}):null]})}export{DeliveryMap};
60
2
  //# sourceMappingURL=delivery-map.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/branch-map/delivery-map.tsx"],
4
- "mappings": ";;;AAEA,SAAS,WAAW,cAAmD;AACvE,SAAS,mBAAmB,kBAAkB;AAE9C,SAAS,wBAA0C;AACnD,SAAS,qBAA6C;AA6ElD,SACE,KADF;AApDJ,IAAM,kBAAkB,CACtB,QACA,KACA,WAEA,OAAO,uBAAoB,EAAE;AAAA,EAAK,CAAC,EAAE,kBAAkB,MACrD,kBAAkB,QAAQ,KAAK,MAAM;AACvC;AASK,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAqB;AACnB,QAAM,QAAQ,OAAwB,IAAI;AAC1C,QAAM,SAAS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AQ,IAAK,MAAM,CACvC,EASK,SAAS,YAAY,CAC1B,OACA,QACA,MACA,WACA,YACA,YACA,gBACA,GAAG,KACL,EAAqB,CACnB,MAAM,MAAQ,OAAwB,IAAI,EAC1C,MAAM,OAAS,iBAAiB,OAAO,WAAW,EAC9C,OAAO,YACP,OACJ,MAAM,YAAc,iBAAiB,OAAO,EAAI,QAAU,OAC1D,MAAM,SAAW,CAAC,CAAC,QAAU,CAAC,CAAC,YAC/B,KAAM,CAAE,QAAS,QAAS,QAAS,KAAM,EAAI,cAE3C,WAAY,SAAU,gBAAiB,WAAW,EACpD,MAAM,OAAS,UAAY,OAC3B,MAAM,YAAc,OAAO,YAC3B,UAAU,IAAM,CACd,GAAI,SAAW,iBAAiB,WAAW,GAAK,iBAAiB,OAAO,EAAG,CACzE,QAAQ,OAAO,CACb,OAAQ,YACR,QACA,MACA,YACA,OAAQ,WAAW,MAAM,OAAO,CAClC,CAAC,CACH,CACF,EAAG,CAAC,QAAS,YAAa,QAAS,MAAO,WAAW,CAAC,EACtD,GAAI,CAAC,WAAY,CACf,OAAO,IACT,CACA,OACE,KAAC,OAAK,GAAG,MAAO,oBAAkB,GAChC,cAAC,QAAK,IAAK,MAAO,OAAM,KAAC,MAAO,kBAAmB,EACnD,IAAC,OACC,OAAQ,QAAU,CAAC,SACnB,IAAK,QACL,2BAAyB,GACzB,MAAO,CAAE,OAAQ,MAAO,EAC1B,EACC,SAAW,gBACV,gBAAgB,CAAE,MAAO,QAAQ,MAAO,KAAM,CAAC,EAC7C,QAAU,CAAC,SACb,IAAC,KAAE,KAAK,SAAS,oCAAwB,EACvC,MACN,CAEJ",
5
5
  "names": []
6
6
  }
@@ -1,118 +1,2 @@
1
- // src/branch-map/delivery-runtime.ts
2
- import { pointBounds } from "./fit.js";
3
- import { loadMaps } from "./loader.js";
4
- import {
5
- DEFAULT_COLORS,
6
- markerOverlayClass,
7
- paintMarker
8
- } from "./markers.js";
9
- var DELIVERY_ROUTE = {
10
- color: "#163300",
11
- opacity: 0.6,
12
- weight: 5
13
- };
14
- var DELIVERY_LOGO_SIZE = 36;
15
- function deliveryPath(update) {
16
- const via = (update.route ?? []).filter(
17
- (point) => Number.isFinite(point.lat) && Number.isFinite(point.lng)
18
- );
19
- return via.length >= 2 ? via : [update.branch, update.shopper];
20
- }
21
- function deliveryBounds(update) {
22
- return pointBounds([update.branch, update.shopper, ...deliveryPath(update)]);
23
- }
24
- async function createDeliveryMap(element, key, signal) {
25
- const maps = await loadMaps(key);
26
- signal.throwIfAborted();
27
- const map = new maps.Map(element, {
28
- center: { lat: 0, lng: 0 },
29
- zoom: 12,
30
- gestureHandling: "none",
31
- disableDefaultUI: true,
32
- keyboardShortcuts: false,
33
- clickableIcons: false
34
- });
35
- const Marker = markerOverlayClass(maps);
36
- let branchPin;
37
- let shopperPin;
38
- let line;
39
- let framed;
40
- let last;
41
- const pin = (key2, position) => {
42
- const node = document.createElement("div");
43
- node.setAttribute("aria-hidden", "true");
44
- node.dataset.deliveryMapPin = key2;
45
- const marker = new Marker(key2, position, node);
46
- marker.setMap(map);
47
- return marker;
48
- };
49
- const frame = (update) => {
50
- map.fitBounds(deliveryBounds(update));
51
- };
52
- const resize = typeof ResizeObserver === "function" ? new ResizeObserver(() => {
53
- if (last) {
54
- frame(last);
55
- }
56
- }) : void 0;
57
- resize?.observe(element);
58
- return {
59
- update(update) {
60
- last = update;
61
- const colors = update.colors ?? DEFAULT_COLORS;
62
- branchPin ?? (branchPin = pin("branch", update.branch));
63
- branchPin.setPosition(update.branch);
64
- if (update.pinImageUrl) {
65
- paintMarker(
66
- branchPin.element,
67
- {
68
- kind: "logo",
69
- size: DELIVERY_LOGO_SIZE,
70
- imageUrl: update.pinImageUrl,
71
- shadow: "sm",
72
- lift: DELIVERY_LOGO_SIZE / 2
73
- },
74
- colors
75
- );
76
- } else {
77
- paintMarker(branchPin.element, { kind: "dot", selected: true }, colors);
78
- }
79
- branchPin.element.style.cursor = "default";
80
- shopperPin ?? (shopperPin = pin("shopper", update.shopper));
81
- shopperPin.setPosition(update.shopper);
82
- paintMarker(
83
- shopperPin.element,
84
- { kind: "house", color: "#ffffff", lift: 16 },
85
- colors
86
- );
87
- line ?? (line = new maps.Polyline({ map }));
88
- line.setOptions({
89
- path: deliveryPath(update),
90
- strokeColor: update.colors?.route ?? DELIVERY_ROUTE.color,
91
- strokeOpacity: DELIVERY_ROUTE.opacity,
92
- strokeWeight: DELIVERY_ROUTE.weight,
93
- clickable: false
94
- });
95
- const key2 = JSON.stringify(deliveryBounds(update));
96
- if (key2 !== framed) {
97
- framed = key2;
98
- frame(update);
99
- }
100
- },
101
- destroy() {
102
- resize?.disconnect();
103
- branchPin?.setMap(null);
104
- shopperPin?.setMap(null);
105
- line?.setMap(null);
106
- maps.event.clearInstanceListeners(map);
107
- element.replaceChildren();
108
- }
109
- };
110
- }
111
- export {
112
- DELIVERY_LOGO_SIZE,
113
- DELIVERY_ROUTE,
114
- createDeliveryMap,
115
- deliveryBounds,
116
- deliveryPath
117
- };
1
+ import{pointBounds}from"./fit.js";import{loadMaps}from"./loader.js";import{DEFAULT_COLORS,markerOverlayClass,paintMarker}from"./markers.js";var DELIVERY_ROUTE={color:"#163300",opacity:.6,weight:5};var DELIVERY_LOGO_SIZE=36;function deliveryPath(update){const via=(update.route??[]).filter(point=>Number.isFinite(point.lat)&&Number.isFinite(point.lng));return via.length>=2?via:[update.branch,update.shopper]}function deliveryBounds(update){return pointBounds([update.branch,update.shopper,...deliveryPath(update)])}async function createDeliveryMap(element,key,signal){const maps=await loadMaps(key);signal.throwIfAborted();const map=new maps.Map(element,{center:{lat:0,lng:0},zoom:12,gestureHandling:"none",disableDefaultUI:true,keyboardShortcuts:false,clickableIcons:false});const Marker=markerOverlayClass(maps);let branchPin;let shopperPin;let line;let framed;let last;const pin=(key2,position)=>{const node=document.createElement("div");node.setAttribute("aria-hidden","true");node.dataset.deliveryMapPin=key2;const marker=new Marker(key2,position,node);marker.setMap(map);return marker};const frame=update=>{map.fitBounds(deliveryBounds(update))};const resize=typeof ResizeObserver==="function"?new ResizeObserver(()=>{if(last){frame(last)}}):void 0;resize?.observe(element);return{update(update){last=update;const colors=update.colors??DEFAULT_COLORS;branchPin??(branchPin=pin("branch",update.branch));branchPin.setPosition(update.branch);if(update.pinImageUrl){paintMarker(branchPin.element,{kind:"logo",size:DELIVERY_LOGO_SIZE,imageUrl:update.pinImageUrl,shadow:"sm",lift:DELIVERY_LOGO_SIZE/2},colors)}else{paintMarker(branchPin.element,{kind:"dot",selected:true},colors)}branchPin.element.style.cursor="default";shopperPin??(shopperPin=pin("shopper",update.shopper));shopperPin.setPosition(update.shopper);paintMarker(shopperPin.element,{kind:"house",color:"#ffffff",lift:16},colors);line??(line=new maps.Polyline({map}));line.setOptions({path:deliveryPath(update),strokeColor:update.colors?.route??DELIVERY_ROUTE.color,strokeOpacity:DELIVERY_ROUTE.opacity,strokeWeight:DELIVERY_ROUTE.weight,clickable:false});const key2=JSON.stringify(deliveryBounds(update));if(key2!==framed){framed=key2;frame(update)}},destroy(){resize?.disconnect();branchPin?.setMap(null);shopperPin?.setMap(null);line?.setMap(null);maps.event.clearInstanceListeners(map);element.replaceChildren()}}}export{DELIVERY_LOGO_SIZE,DELIVERY_ROUTE,createDeliveryMap,deliveryBounds,deliveryPath};
118
2
  //# sourceMappingURL=delivery-runtime.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/branch-map/delivery-runtime.ts"],
4
- "mappings": ";AAAA,SAAS,mBAAmB;AAE5B,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAWA,IAAM,iBAAiB;AAAA,EAC5B,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AACV;AAEO,IAAM,qBAAqB;AAG3B,SAAS,aAAa,QAA2B;AACtD,QAAM,OAAO,OAAO,SAAS,CAAC,GAAG;AAAA,IAC/B,CAAC,UAAU,OAAO,SAAS,MAAM,G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