@zappie/foundations 0.4.0 → 0.5.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @zappie/foundations
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 6ea8744: The shopper's Zappie account, with their profile, saved cards, wallet and payments, lives on the Zappie accounts portal. A site keeps its orders, its store contact and one "Your Zappie account" row.
8
+
9
+ `@zappie/foundations` adds that row. `ZappieAccountLink` renders an unstyled link labelled "Your Zappie account" to the portal's `/account`, with a return link to the current page. `useZappieAccountUrl()` gives the same address for your own link, and `zappieAccountUrl(page)` builds it for any page. `zappieEnvironment(host)` picks the portal: `staging` for localhost and the loopback addresses, `*.workers.dev`, `*.zappie-sites.dev` and any host with `.stg.` in it, and `production` for every other host, including `<tag>.zappie.shop` and custom domains. `SignInOptions.scopes` no longer accepts `cards` or `payments:read`.
10
+
11
+ The kit's account page and the starter's account page show the row below "Your orders".
12
+
13
+ `createAccount` and its calls, `ScopeRequiredError`, `NotFoundError` and the account types in `@zappie/sdk/account`, `mockAccountFetch` and `accountFixtures` in `@zappie/sdk/testing`, and the parts in `@zappie/foundations/account` are deprecated and removed in the next minor release. The API is removing the routes they call. `accountsUrl` stays as it is.
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [6ea8744]
18
+ - @zappie/sdk@0.5.2
19
+
3
20
  ## 0.4.0
4
21
 
5
22
  ### Minor Changes
package/README.md CHANGED
@@ -31,12 +31,12 @@ Want ready-made, styled components instead? Copy them into your project from the
31
31
 
32
32
  ## Entry points
33
33
 
34
- | Import | For |
35
- | ------------------------------- | --------------------------------------------------------------- |
36
- | `@zappie/foundations` | Every part |
37
- | `@zappie/foundations/account` | Wallet, saved card, payment and receipt parts for account pages |
38
- | `@zappie/foundations/next` | Keeping overlays in step with Back and Forward in a Next.js app |
39
- | `@zappie/foundations/rich-text` | Sanitising and parsing merchant rich text before you render it |
34
+ | Import | For |
35
+ | ------------------------------- | ------------------------------------------------------------------------------ |
36
+ | `@zappie/foundations` | Every part |
37
+ | `@zappie/foundations/account` | Deprecated, removed in the next minor release. Add `ZappieAccountLink` instead |
38
+ | `@zappie/foundations/next` | Keeping overlays in step with Back and Forward in a Next.js app |
39
+ | `@zappie/foundations/rich-text` | Sanitising and parsing merchant rich text before you render it |
40
40
 
41
41
  ## Docs
42
42
 
@@ -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;AA2B9B,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,SAAS,WAGb,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,UAAU,WAGd,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,eAAe,WAGnB,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,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,SAAS,WAGb,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,UAAU,WAGd,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,eAAe,WAGnB,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;",
5
5
  "names": ["SignIn", "SignOut"]
6
6
  }
@@ -6,20 +6,32 @@ import { SavedCard, AccountClient, CustomerPayment, PaymentReceipt, AccountScope
6
6
  /**
7
7
  * Where an account read stands. `scope_required` means the shopper's sign-in doesn't cover it yet,
8
8
  * and `not_found` that the card or payment isn't theirs.
9
+ *
10
+ * @deprecated The shopper's Zappie account lives on the accounts portal, so this is removed in the next minor release. Link to the portal with accountsUrl, or add ZappieAccountLink from @zappie/foundations.
9
11
  */
10
12
  type AccountReadStatus = "loading" | "ready" | "error" | "scope_required" | "not_found";
11
- /** An account read's status, its data once it has loaded, the error behind a failed read and a retry. */
13
+ /**
14
+ * An account read's status, its data once it has loaded, the error behind a failed read and a retry.
15
+ *
16
+ * @deprecated The shopper's Zappie account lives on the accounts portal, so this is removed in the next minor release. Link to the portal with accountsUrl, or add ZappieAccountLink from @zappie/foundations.
17
+ */
12
18
  type AccountReadState<T> = {
13
19
  status: AccountReadStatus;
14
20
  data: T | undefined;
15
21
  error: unknown;
16
22
  retry: () => void;
17
23
  };
18
- /** The scope a ScopeRequiredError names, or undefined for any other value. */
24
+ /**
25
+ * The scope a ScopeRequiredError names, or undefined for any other value.
26
+ *
27
+ * @deprecated The shopper's Zappie account lives on the accounts portal, so this is removed in the next minor release. Link to the portal with accountsUrl, or add ZappieAccountLink from @zappie/foundations.
28
+ */
19
29
  declare function missingScope(error: unknown): AccountScope | undefined;
20
30
  /**
21
31
  * Load the shopper's Zappie wallet and expose its balances, one per currency with naira first,
22
32
  * to your render function. The element's `data-state` is the read's status.
33
+ *
34
+ * @deprecated The shopper's Zappie account lives on the accounts portal, so this is removed in the next minor release. Link to the portal with accountsUrl, or add ZappieAccountLink from @zappie/foundations.
23
35
  */
24
36
  declare const Wallets: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
25
37
  asChild?: boolean;
@@ -27,13 +39,19 @@ declare const Wallets: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttribu
27
39
  } & {
28
40
  account: Pick<AccountClient, "wallets">;
29
41
  } & react.RefAttributes<HTMLElement>>;
30
- /** The saved cards read, and a remove that drops a card from the list once the API removes it. */
42
+ /**
43
+ * The saved cards read, and a remove that drops a card from the list once the API removes it.
44
+ *
45
+ * @deprecated The shopper's Zappie account lives on the accounts portal, so this is removed in the next minor release. Link to the portal with accountsUrl, or add ZappieAccountLink from @zappie/foundations.
46
+ */
31
47
  type CardsState = AccountReadState<SavedCard[]> & {
32
48
  remove: (id: string) => Promise<void>;
33
49
  };
34
50
  /**
35
51
  * Load the shopper's saved cards and expose them to your render function with `remove`.
36
52
  * Pair `remove` with RemoveCard so the shopper confirms first.
53
+ *
54
+ * @deprecated The shopper's Zappie account lives on the accounts portal, so this is removed in the next minor release. Link to the portal with accountsUrl, or add ZappieAccountLink from @zappie/foundations.
37
55
  */
38
56
  declare const Cards: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
39
57
  asChild?: boolean;
@@ -41,7 +59,11 @@ declare const Cards: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttribute
41
59
  } & {
42
60
  account: Pick<AccountClient, "cards" | "removeCard">;
43
61
  } & react.RefAttributes<HTMLElement>>;
44
- /** Whether the confirmation is open, the removal is running, and the error from a failed removal. */
62
+ /**
63
+ * Whether the confirmation is open, the removal is running, and the error from a failed removal.
64
+ *
65
+ * @deprecated The shopper's Zappie account lives on the accounts portal, so this is removed in the next minor release. Link to the portal with accountsUrl, or add ZappieAccountLink from @zappie/foundations.
66
+ */
45
67
  type RemoveCardState = {
46
68
  open: boolean;
47
69
  pending: boolean;
@@ -56,6 +78,8 @@ declare function RemoveRoot({ onRemove, onRemoved, ...props }: PartProps<RemoveC
56
78
  * A two-step card removal. Trigger opens the confirmation and Confirm takes focus. Confirm and
57
79
  * Cancel render only while it is open, and Confirm runs `onRemove` once. A failed removal keeps it
58
80
  * open with the error. Cancel returns focus to Trigger.
81
+ *
82
+ * @deprecated The shopper's Zappie account lives on the accounts portal, so this is removed in the next minor release. Link to the portal with accountsUrl, or add ZappieAccountLink from @zappie/foundations.
59
83
  */
60
84
  declare const RemoveCard: {
61
85
  Root: typeof RemoveRoot;
@@ -72,7 +96,11 @@ declare const RemoveCard: {
72
96
  children?: react.ReactNode | ((state: RemoveCardState) => react.ReactNode);
73
97
  } & react.RefAttributes<HTMLElement>>;
74
98
  };
75
- /** The payments read so far, newest first, and the next page. */
99
+ /**
100
+ * The payments read so far, newest first, and the next page.
101
+ *
102
+ * @deprecated The shopper's Zappie account lives on the accounts portal, so this is removed in the next minor release. Link to the portal with accountsUrl, or add ZappieAccountLink from @zappie/foundations.
103
+ */
76
104
  type PaymentsState = AccountReadState<CustomerPayment[]> & {
77
105
  hasMore: boolean;
78
106
  loadingMore: boolean;
@@ -81,6 +109,8 @@ type PaymentsState = AccountReadState<CustomerPayment[]> & {
81
109
  /**
82
110
  * Load the shopper's payments at this business, newest first, and expose them to your render
83
111
  * function. `loadMore` appends the next page while `hasMore` is true.
112
+ *
113
+ * @deprecated The shopper's Zappie account lives on the accounts portal, so this is removed in the next minor release. Link to the portal with accountsUrl, or add ZappieAccountLink from @zappie/foundations.
84
114
  */
85
115
  declare const Payments: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
86
116
  asChild?: boolean;
@@ -90,13 +120,19 @@ declare const Payments: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttrib
90
120
  /** Payments a page, from 1 to 50. Defaults to the API's 20. */
91
121
  limit?: number;
92
122
  } & react.RefAttributes<HTMLElement>>;
93
- /** The receipt read, and print, which opens the browser's print dialog. */
123
+ /**
124
+ * The receipt read, and print, which opens the browser's print dialog.
125
+ *
126
+ * @deprecated The shopper's Zappie account lives on the accounts portal, so this is removed in the next minor release. Link to the portal with accountsUrl, or add ZappieAccountLink from @zappie/foundations.
127
+ */
94
128
  type ReceiptState = AccountReadState<PaymentReceipt> & {
95
129
  print: () => void;
96
130
  };
97
131
  /**
98
132
  * Load one payment's receipt and expose it to your render function with `print`. A payment that
99
133
  * isn't the shopper's, or isn't at this business, reads as `not_found`.
134
+ *
135
+ * @deprecated The shopper's Zappie account lives on the accounts portal, so this is removed in the next minor release. Link to the portal with accountsUrl, or add ZappieAccountLink from @zappie/foundations.
100
136
  */
101
137
  declare const Receipt: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
102
138
  asChild?: boolean;
@@ -108,6 +144,8 @@ declare const Receipt: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttribu
108
144
  /**
109
145
  * Offer to sign in again when an account read failed for a scope the shopper's sign-in doesn't
110
146
  * cover. It renders nothing for any other error. Its default label is "Sign in again to see this".
147
+ *
148
+ * @deprecated The shopper's Zappie account lives on the accounts portal, so this is removed in the next minor release. Link to the portal with accountsUrl, or add ZappieAccountLink from @zappie/foundations.
111
149
  */
112
150
  declare const ScopeMissing: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
113
151
  asChild?: boolean;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/account/parts.tsx"],
4
- "mappings": ";;;AASA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa,YAA4B;AAsM9C;AApLG,SAAS,aAAa,OAA0C;AACrE,QAAM,QAAQ;AACd,SAAO,OAAO,YAAY,mBAAmB,MAAM,QAAQ;AAC7D;AAEA,IAAM,WAAW,CAAC,UAChB,aAAa,KAAK,IACd,mBACC,OAAuC,WAAW,MACjD,cACA;AAER,SAAS,QACP,MACA,KACkD;AAClD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAIvB,EAAE,QAAQ,WAAW,MAAM,OAAU,CAAC;AACzC,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,CAAC;AACxC,QAAM,SAAS,OAAO,IAAI;AAC1B,SAAO,UAAU;AACjB,YAAU,MAAM;AACd,QAAI,OAAO;AACX,aAAS,CAAC,aAAa,EAAE,QAAQ,WAAW,MAAM,QAAQ,KAAK,EAAE;AACjE,WAAO,QAAQ,EAAE;AAAA,MACf,CAAC,SAAS;AACR,YAAI,MAAM;AACR,mBAAS,EAAE,QAAQ,SAAS,KAAK,CAAC;AAAA,QACpC;A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MAAM,MAAM,GAAG,GAAG;AACpE,CAAC;AAiBM,IAAM,UAAU,WAMrB,SAASC,SAAQ,EAAE,SAAS,WAAW,GAAG,MAAM,GAAG,KAAK;AACxD,QAAM,EAAE,KAAK,MAAM,GAAG,KAAK,IAAI;AAAA,IAC7B,MAAM,QAAQ,QAAQ,SAAS;AAAA,IAC/B,GAAG,SAAS;AAAA,EACd;AACA,QAAM,QAAQ,EAAE,GAAG,MAAM,OAAO,MAAM,OAAO,MAAM,EAAE;AACrD,SAAO,KAAK,OAAO,OAAO,OAAO,eAAe,MAAM,MAAM,GAAG,GAAG;AACpE,CAAC;AAQM,IAAM,eAAe,WAQ1B,SAASC,cAAa,EAAE,OAAO,QAAQ,GAAG,MAAM,GAAG,KAAK;AACxD,QAAM,QAAQ,aAAa,KAAK;AAChC,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AACA,SAAO;AAAA,IACL;AAAA,IACA,EAAE,GAAG,OAAO,UAAU,MAAM,YAAY,4BAA4B;AAAA,IACpE,EAAE,MAAM;AAAA,IACR,EAAE,MAAM,UAAU,cAAc,OAAO,SAAS,OAAO;AAAA,IACvD;AAAA,EACF;AACF,CAAC;",
5
5
  "names": ["Wallets", "Cards", "RemoveTrigger", "RemoveConfirm", "RemoveCancel", "Payments", "Receipt", "ScopeMissing"]
6
6
  }
@@ -0,0 +1,39 @@
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 = 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
+ };
39
+ //# sourceMappingURL=zappie-account.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 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,oBAAoB,WAM/B,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,EAAE,MAAM,uBAAuB,GAAG;AAAA,IAClC;AAAA,EACF;AACF,CAAC;",
5
+ "names": ["ZappieAccountLink"]
6
+ }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { P as PartOwnedAttributes, a as PartProps } from './slot-CHfqzPTd.js';
2
2
  import * as react from 'react';
3
3
  import { HTMLAttributes, ReactNode, ComponentType, ReactElement, KeyboardEvent as KeyboardEvent$1, ImgHTMLAttributes, ChangeEvent, ClipboardEvent } from 'react';
4
+ import { ZappieEnvironment } from '@zappie/sdk/services';
4
5
  import * as _zappie_sdk from '@zappie/sdk';
5
6
  import { Branch as Branch$1, CartLine, CartLineInput, CartIssue, CartFix, Quote, DeliveryAddress, MenuSchedule, CartFulfilment, OptionGroup as OptionGroup$1, Item, Money as Money$1, Choice as Choice$1, MoneyFormatOptions, PaymentMethodKind, Category, Menu, Store, OpeningTime } from '@zappie/sdk';
6
7
  import { useCart } from '@zappie/sdk/react';
@@ -22,7 +23,7 @@ type SignInOptions = {
22
23
  returnTo?: string;
23
24
  prompt?: "none" | "login";
24
25
  display?: "popup" | "redirect" | "auto";
25
- scopes?: ("openid" | "phone" | "profile" | "addresses" | "orders:read" | "offline_access" | "cart" | "wallet" | "cards" | "payments:read")[];
26
+ scopes?: ("openid" | "phone" | "profile" | "addresses" | "orders:read" | "offline_access" | "cart" | "wallet")[];
26
27
  };
27
28
  /**
28
29
  * An error from Account sign-in and sign-out when authentication is not configured.
@@ -63,6 +64,48 @@ declare const Account: {
63
64
  } & react.RefAttributes<HTMLElement>>;
64
65
  };
65
66
 
67
+ /**
68
+ * The Zappie environment a site's page belongs to. A test host is `staging`: localhost and the
69
+ * loopback addresses, `*.workers.dev`, `*.zappie-sites.dev` and any host with `.stg.` in it.
70
+ * Every other host is `production`, including `<tag>.zappie.shop` and custom domains.
71
+ *
72
+ * @param host - The page's host name, such as `location.hostname`.
73
+ * @returns `staging` for a test host, otherwise `production`.
74
+ */
75
+ declare function zappieEnvironment(host: string): ZappieEnvironment;
76
+ /**
77
+ * A link to the shopper's Zappie account on the accounts portal, for the environment of `page`,
78
+ * that brings them back to `page`.
79
+ *
80
+ * @param page - The absolute address of the page to come back to, such as `location.href`.
81
+ * @returns The portal's `/account` address with `page` as its return link.
82
+ */
83
+ declare function zappieAccountUrl(page: string | URL): string;
84
+ /**
85
+ * The address of the shopper's Zappie account for the current page: the accounts portal for this
86
+ * host's environment, with a return link to the page. Before the page mounts it is the production
87
+ * portal with no return link.
88
+ *
89
+ * @param returnTo - The page to come back to. Defaults to the current page.
90
+ * @returns The portal address.
91
+ */
92
+ declare function useZappieAccountUrl(returnTo?: string): string;
93
+ /**
94
+ * The "Your Zappie account" row: a link to the shopper's Zappie account on the accounts portal,
95
+ * where they manage their profile, saved cards, wallet and payments, with a return link to this
96
+ * page. It renders an unstyled `<a>`, so style it like the page's other rows. Its default label
97
+ * is "Your Zappie account".
98
+ */
99
+ declare const ZappieAccountLink: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
100
+ asChild?: boolean;
101
+ children?: react.ReactNode | ((state: {
102
+ href: string;
103
+ }) => react.ReactNode);
104
+ } & {
105
+ /** The page to come back to. Defaults to the current page. */
106
+ returnTo?: string;
107
+ } & react.RefAttributes<HTMLElement>>;
108
+
66
109
  type Coordinates = {
67
110
  lat: number;
68
111
  lng: number;
@@ -1060,5 +1103,5 @@ declare const OpenStatus: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttr
1060
1103
  /** The installed @zappie/foundations version. */
1061
1104
  declare const FOUNDATIONS_VERSION: string;
1062
1105
 
1063
- export { Account, AccountNotConfiguredError, Address, Branch, BranchMap, Cart, Choice, DeliveryMap, FOUNDATIONS_VERSION, Fulfilment, Image, ItemForm, Money, OpenStatus, OptionGroup, Otp, Overlay, PartProps, PaymentMethods, Quantity, Schedule, Search, Totals, canOrderAhead, contactLinks, createSearchIndex, deferred, formatOpeningHours, formatWallClock, getOpenStatus, parseWallClock, scheduleSlots, useControllableState, useIntentPreload, useOverlay, zappieSupportUrl };
1106
+ export { Account, AccountNotConfiguredError, Address, Branch, BranchMap, Cart, Choice, DeliveryMap, FOUNDATIONS_VERSION, Fulfilment, Image, ItemForm, Money, OpenStatus, OptionGroup, Otp, Overlay, PartProps, PaymentMethods, Quantity, Schedule, Search, Totals, ZappieAccountLink, canOrderAhead, contactLinks, createSearchIndex, deferred, formatOpeningHours, formatWallClock, getOpenStatus, parseWallClock, scheduleSlots, useControllableState, useIntentPreload, useOverlay, useZappieAccountUrl, zappieAccountUrl, zappieEnvironment, zappieSupportUrl };
1064
1107
  export type { ActiveGroup, AddressState, AddressSuggestion, BranchMapLoadErrorState, BranchMapProps, ContactLink, Customer, Deferred, DeferredIdleOptions, DeferredProps, DeliveryMapProps, ImageProps, IntentPreloadHandlers, ItemFormContext, ItemFormInvalidGroup, ItemFormProps, MapLoadErrorState, PaymentMethod, QuantityProps, QuantityState, ScheduleSlot, ScheduleState, SearchResult, SearchSource, SearchState, SignInOptions, TotalsState, ZappieSupportContext };
package/dist/index.js CHANGED
@@ -3,6 +3,12 @@
3
3
  // src/index.ts
4
4
  import { PACKAGE_VERSION } from "./version.js";
5
5
  import { Account, AccountNotConfiguredError } from "./account/index.js";
6
+ import {
7
+ useZappieAccountUrl,
8
+ ZappieAccountLink,
9
+ zappieAccountUrl,
10
+ zappieEnvironment
11
+ } from "./account/zappie-account.js";
6
12
  import { BranchMap, DeliveryMap } from "./branch-map/index.js";
7
13
  import { Cart, Totals } from "./cart/index.js";
8
14
  import { deferred, useIntentPreload } from "./deferred/index.js";
@@ -47,6 +53,7 @@ export {
47
53
  Schedule,
48
54
  Search,
49
55
  Totals,
56
+ ZappieAccountLink,
50
57
  canOrderAhead,
51
58
  contactLinks,
52
59
  createSearchIndex,
@@ -59,6 +66,9 @@ export {
59
66
  useControllableState,
60
67
  useIntentPreload,
61
68
  useOverlay,
69
+ useZappieAccountUrl,
70
+ zappieAccountUrl,
71
+ zappieEnvironment,
62
72
  zappieSupportUrl
63
73
  };
64
74
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "mappings": ";;;AACA,SAAS,uBAAuB;AAIhC,SAAS,SAAS,iCAAiC;AAEnD,SAAS,WAAW,mBAAmB;AAOvC,SAAS,MAAM,cAAc;AAE7B,SAAS,UAAU,wBAAwB;AAO3C,SAAS,eAAe;AAKxB,SAAS,cAAc;AACvB,SAAS,UAAU,qBAAqB;AAExC,SAAS,kBAAkB;AAE3B,SAAS,4BAA4B;AACrC,cAAc;AACd,SAAS,aAAa;AAEtB,SAAS,aAAa;AACtB,SAAS,WAAW;AACpB,SAAS,SAAS,kBAAkB;AACpC,SAAS,sBAAsB;AAE/B,SAAS,mBAAmB,cAAc;AAE1C,SAAS,cAAc,wBAAwB;AAE/C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAjDpB,IAAM,sBAA8B;",
4
+ "mappings": ";;;AACA,SAAS,uBAAuB;AAIhC,SAAS,SAAS,iCAAiC;AAEnD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,WAAW,mBAAmB;AAOvC,SAAS,MAAM,cAAc;AAE7B,SAAS,UAAU,wBAAwB;AAO3C,SAAS,eAAe;AAKxB,SAAS,cAAc;AACvB,SAAS,UAAU,qBAAqB;AAExC,SAAS,kBAAkB;AAE3B,SAAS,4BAA4B;AACrC,cAAc;AACd,SAAS,aAAa;AAEtB,SAAS,aAAa;AACtB,SAAS,WAAW;AACpB,SAAS,SAAS,kBAAkB;AACpC,SAAS,sBAAsB;AAE/B,SAAS,mBAAmB,cAAc;AAE1C,SAAS,cAAc,wBAAwB;AAE/C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAvDpB,IAAM,sBAA8B;",
5
5
  "names": []
6
6
  }
package/dist/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var PACKAGE_VERSION = true ? "0.4.0" : "0.0.0-development";
2
+ var PACKAGE_VERSION = true ? "0.5.0" : "0.0.0-development";
3
3
  export {
4
4
  PACKAGE_VERSION
5
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zappie/foundations",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "UI-less React primitives for Zappie storefronts: behaviour, state and accessibility without styles.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -37,7 +37,7 @@
37
37
  "dependencies": {
38
38
  "@base-ui/react": "^1.9.0",
39
39
  "@googlemaps/markerclusterer": "^2.6.2",
40
- "@zappie/sdk": "^0.5.0"
40
+ "@zappie/sdk": "^0.5.2"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "react": "^18.2.0 || ^19.0.0",