@zappie/foundations 0.3.1 → 0.4.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 +15 -0
- package/README.md +1 -0
- package/dist/account/index.js.map +1 -1
- package/dist/account/parts.d.ts +125 -0
- package/dist/account/parts.js +271 -0
- package/dist/account/parts.js.map +6 -0
- package/dist/index.d.ts +3 -3
- package/dist/overlay/engine.d.ts +53 -3
- package/dist/slot-CHfqzPTd.d.ts +13 -0
- package/dist/version.js +1 -1
- package/package.json +6 -2
- package/dist/engine-D2iRshfW.d.ts +0 -61
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @zappie/foundations
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a5bd08f: `@zappie/sdk/account` reads the signed-in shopper's account through the same endpoint and session as `createCustomer`. `createAccount()` returns `wallets()`, `cards()`, `removeCard(id)`, `payments({ limit, cursor })` and `payment(id)`. A call the shopper's sign-in doesn't cover rejects with `ScopeRequiredError`, which names the scope, and a card or payment that isn't theirs rejects with `NotFoundError`. Both are a `CustomerError`. `accountsUrl(path, environment, { returnTo })` builds a link to a page on the Zappie accounts portal, `/account`, `/account/profile`, `/account/payouts`, `/account/withdraw` or `/account/activity`, with the page to come back to. It refuses a path the way `checkoutUrl` does. `@zappie/sdk/testing` adds `mockAccountFetch()` and `accountFixtures`, which answer the account endpoints as the API does, including a removed card and a missing scope.
|
|
8
|
+
|
|
9
|
+
`@zappie/foundations/account` adds headless account parts that load only on account pages: `Wallets`, `Cards`, `RemoveCard` (a confirmation before a card is removed), `Payments`, `Receipt` and `ScopeMissing`, which offers to sign in again. `SignInOptions.scopes` accepts `wallet`, `cards` and `payments:read`.
|
|
10
|
+
|
|
11
|
+
`no-offsite-navigation` trusts the staging accounts portal and `accountsUrl` from `@zappie/sdk/account`, and `no-direct-api` points a written-out accounts address to `accountsUrl`.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [a5bd08f]
|
|
16
|
+
- @zappie/sdk@0.5.0
|
|
17
|
+
|
|
3
18
|
## 0.3.1
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -34,6 +34,7 @@ Want ready-made, styled components instead? Copy them into your project from the
|
|
|
34
34
|
| Import | For |
|
|
35
35
|
| ------------------------------- | --------------------------------------------------------------- |
|
|
36
36
|
| `@zappie/foundations` | Every part |
|
|
37
|
+
| `@zappie/foundations/account` | Wallet, saved card, payment and receipt parts for account pages |
|
|
37
38
|
| `@zappie/foundations/next` | Keeping overlays in step with Back and Forward in a Next.js app |
|
|
38
39
|
| `@zappie/foundations/rich-text` | Sanitising and parsing merchant rich text before you render it |
|
|
39
40
|
|
|
@@ -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;
|
|
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;",
|
|
5
5
|
"names": ["SignIn", "SignOut"]
|
|
6
6
|
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { P as PartOwnedAttributes } from '../slot-CHfqzPTd.js';
|
|
2
|
+
import { PartProps } from '../index.js';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import { SavedCard, AccountClient, CustomerPayment, PaymentReceipt, AccountScope, Wallet } from '@zappie/sdk/account';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Where an account read stands. `scope_required` means the shopper's sign-in doesn't cover it yet,
|
|
8
|
+
* and `not_found` that the card or payment isn't theirs.
|
|
9
|
+
*/
|
|
10
|
+
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. */
|
|
12
|
+
type AccountReadState<T> = {
|
|
13
|
+
status: AccountReadStatus;
|
|
14
|
+
data: T | undefined;
|
|
15
|
+
error: unknown;
|
|
16
|
+
retry: () => void;
|
|
17
|
+
};
|
|
18
|
+
/** The scope a ScopeRequiredError names, or undefined for any other value. */
|
|
19
|
+
declare function missingScope(error: unknown): AccountScope | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Load the shopper's Zappie wallet and expose its balances, one per currency with naira first,
|
|
22
|
+
* to your render function. The element's `data-state` is the read's status.
|
|
23
|
+
*/
|
|
24
|
+
declare const Wallets: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
25
|
+
asChild?: boolean;
|
|
26
|
+
children?: react.ReactNode | ((state: AccountReadState<Wallet[]>) => react.ReactNode);
|
|
27
|
+
} & {
|
|
28
|
+
account: Pick<AccountClient, "wallets">;
|
|
29
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
30
|
+
/** The saved cards read, and a remove that drops a card from the list once the API removes it. */
|
|
31
|
+
type CardsState = AccountReadState<SavedCard[]> & {
|
|
32
|
+
remove: (id: string) => Promise<void>;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Load the shopper's saved cards and expose them to your render function with `remove`.
|
|
36
|
+
* Pair `remove` with RemoveCard so the shopper confirms first.
|
|
37
|
+
*/
|
|
38
|
+
declare const Cards: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
39
|
+
asChild?: boolean;
|
|
40
|
+
children?: react.ReactNode | ((state: CardsState) => react.ReactNode);
|
|
41
|
+
} & {
|
|
42
|
+
account: Pick<AccountClient, "cards" | "removeCard">;
|
|
43
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
44
|
+
/** Whether the confirmation is open, the removal is running, and the error from a failed removal. */
|
|
45
|
+
type RemoveCardState = {
|
|
46
|
+
open: boolean;
|
|
47
|
+
pending: boolean;
|
|
48
|
+
error: unknown;
|
|
49
|
+
};
|
|
50
|
+
declare function RemoveRoot({ onRemove, onRemoved, ...props }: PartProps<RemoveCardState> & {
|
|
51
|
+
/** Removes the card, such as `() => cards.remove(card.id)`. */
|
|
52
|
+
onRemove: () => Promise<void>;
|
|
53
|
+
onRemoved?: () => void;
|
|
54
|
+
}): react.JSX.Element;
|
|
55
|
+
/**
|
|
56
|
+
* A two-step card removal. Trigger opens the confirmation and Confirm takes focus. Confirm and
|
|
57
|
+
* Cancel render only while it is open, and Confirm runs `onRemove` once. A failed removal keeps it
|
|
58
|
+
* open with the error. Cancel returns focus to Trigger.
|
|
59
|
+
*/
|
|
60
|
+
declare const RemoveCard: {
|
|
61
|
+
Root: typeof RemoveRoot;
|
|
62
|
+
Trigger: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
63
|
+
asChild?: boolean;
|
|
64
|
+
children?: react.ReactNode | ((state: RemoveCardState) => react.ReactNode);
|
|
65
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
66
|
+
Confirm: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
67
|
+
asChild?: boolean;
|
|
68
|
+
children?: react.ReactNode | ((state: RemoveCardState) => react.ReactNode);
|
|
69
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
70
|
+
Cancel: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
71
|
+
asChild?: boolean;
|
|
72
|
+
children?: react.ReactNode | ((state: RemoveCardState) => react.ReactNode);
|
|
73
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
74
|
+
};
|
|
75
|
+
/** The payments read so far, newest first, and the next page. */
|
|
76
|
+
type PaymentsState = AccountReadState<CustomerPayment[]> & {
|
|
77
|
+
hasMore: boolean;
|
|
78
|
+
loadingMore: boolean;
|
|
79
|
+
loadMore: () => void;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Load the shopper's payments at this business, newest first, and expose them to your render
|
|
83
|
+
* function. `loadMore` appends the next page while `hasMore` is true.
|
|
84
|
+
*/
|
|
85
|
+
declare const Payments: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
86
|
+
asChild?: boolean;
|
|
87
|
+
children?: react.ReactNode | ((state: PaymentsState) => react.ReactNode);
|
|
88
|
+
} & {
|
|
89
|
+
account: Pick<AccountClient, "payments">;
|
|
90
|
+
/** Payments a page, from 1 to 50. Defaults to the API's 20. */
|
|
91
|
+
limit?: number;
|
|
92
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
93
|
+
/** The receipt read, and print, which opens the browser's print dialog. */
|
|
94
|
+
type ReceiptState = AccountReadState<PaymentReceipt> & {
|
|
95
|
+
print: () => void;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Load one payment's receipt and expose it to your render function with `print`. A payment that
|
|
99
|
+
* isn't the shopper's, or isn't at this business, reads as `not_found`.
|
|
100
|
+
*/
|
|
101
|
+
declare const Receipt: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
102
|
+
asChild?: boolean;
|
|
103
|
+
children?: react.ReactNode | ((state: ReceiptState) => react.ReactNode);
|
|
104
|
+
} & {
|
|
105
|
+
account: Pick<AccountClient, "payment">;
|
|
106
|
+
paymentId: string;
|
|
107
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
108
|
+
/**
|
|
109
|
+
* Offer to sign in again when an account read failed for a scope the shopper's sign-in doesn't
|
|
110
|
+
* cover. It renders nothing for any other error. Its default label is "Sign in again to see this".
|
|
111
|
+
*/
|
|
112
|
+
declare const ScopeMissing: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
113
|
+
asChild?: boolean;
|
|
114
|
+
children?: react.ReactNode | ((state: {
|
|
115
|
+
scope: AccountScope;
|
|
116
|
+
}) => react.ReactNode);
|
|
117
|
+
} & {
|
|
118
|
+
/** The read's error, such as a part's `error` state. */
|
|
119
|
+
error: unknown;
|
|
120
|
+
/** Starts sign-in, such as `() => customer.signIn()`. */
|
|
121
|
+
signIn: () => void;
|
|
122
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
123
|
+
|
|
124
|
+
export { Cards, Payments, Receipt, RemoveCard, ScopeMissing, Wallets, missingScope };
|
|
125
|
+
export type { AccountReadState, AccountReadStatus, CardsState, PaymentsState, ReceiptState, RemoveCardState };
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/account/parts.tsx
|
|
4
|
+
import {
|
|
5
|
+
createContext,
|
|
6
|
+
forwardRef,
|
|
7
|
+
useCallback,
|
|
8
|
+
useContext,
|
|
9
|
+
useEffect,
|
|
10
|
+
useRef,
|
|
11
|
+
useState
|
|
12
|
+
} from "react";
|
|
13
|
+
import { composeRefs, part } from "../internal/slot.js";
|
|
14
|
+
import { jsx } from "react/jsx-runtime";
|
|
15
|
+
function missingScope(error) {
|
|
16
|
+
const value = error;
|
|
17
|
+
return value?.apiCode === "scope_required" ? value.scope : void 0;
|
|
18
|
+
}
|
|
19
|
+
var statusOf = (error) => missingScope(error) ? "scope_required" : error?.status === 404 ? "not_found" : "error";
|
|
20
|
+
function useRead(load, key) {
|
|
21
|
+
const [state, setState] = useState({ status: "loading", data: void 0 });
|
|
22
|
+
const [attempt, setAttempt] = useState(0);
|
|
23
|
+
const latest = useRef(load);
|
|
24
|
+
latest.current = load;
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
let live = true;
|
|
27
|
+
setState((current) => ({ status: "loading", data: current.data }));
|
|
28
|
+
latest.current().then(
|
|
29
|
+
(data) => {
|
|
30
|
+
if (live) {
|
|
31
|
+
setState({ status: "ready", data });
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
(error) => {
|
|
35
|
+
if (live) {
|
|
36
|
+
setState({ status: statusOf(error), data: void 0, error });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
return () => {
|
|
41
|
+
live = false;
|
|
42
|
+
};
|
|
43
|
+
}, [key, attempt]);
|
|
44
|
+
return {
|
|
45
|
+
status: state.status,
|
|
46
|
+
data: state.data,
|
|
47
|
+
error: state.error,
|
|
48
|
+
retry: useCallback(() => setAttempt((value) => value + 1), []),
|
|
49
|
+
set: useCallback((data) => setState({ status: "ready", data }), [])
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
var readAttributes = (status) => ({
|
|
53
|
+
"data-state": status,
|
|
54
|
+
"aria-busy": status === "loading" || void 0
|
|
55
|
+
});
|
|
56
|
+
var Wallets = forwardRef(function Wallets2({ account, ...props }, ref) {
|
|
57
|
+
const { set: _set, ...state } = useRead(() => account.wallets(), account);
|
|
58
|
+
return part("div", props, state, readAttributes(state.status), ref);
|
|
59
|
+
});
|
|
60
|
+
var Cards = forwardRef(function Cards2({ account, ...props }, ref) {
|
|
61
|
+
const { set, ...read } = useRead(() => account.cards(), account);
|
|
62
|
+
const cards = useRef(read.data);
|
|
63
|
+
cards.current = read.data;
|
|
64
|
+
const remove = useCallback(
|
|
65
|
+
async (id) => {
|
|
66
|
+
await account.removeCard(id);
|
|
67
|
+
set((cards.current ?? []).filter((card) => card.id !== id));
|
|
68
|
+
},
|
|
69
|
+
[account, set]
|
|
70
|
+
);
|
|
71
|
+
const state = { ...read, remove };
|
|
72
|
+
return part("div", props, state, readAttributes(state.status), ref);
|
|
73
|
+
});
|
|
74
|
+
var RemoveContext = createContext(null);
|
|
75
|
+
var useRemove = (name) => {
|
|
76
|
+
const context = useContext(RemoveContext);
|
|
77
|
+
if (!context) {
|
|
78
|
+
throw new Error(`RemoveCard.${name} requires RemoveCard.Root`);
|
|
79
|
+
}
|
|
80
|
+
return context;
|
|
81
|
+
};
|
|
82
|
+
function RemoveRoot({
|
|
83
|
+
onRemove,
|
|
84
|
+
onRemoved,
|
|
85
|
+
...props
|
|
86
|
+
}) {
|
|
87
|
+
const [state, setState] = useState({
|
|
88
|
+
open: false,
|
|
89
|
+
pending: false,
|
|
90
|
+
error: void 0
|
|
91
|
+
});
|
|
92
|
+
const live = useRef(true);
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
live.current = true;
|
|
95
|
+
return () => {
|
|
96
|
+
live.current = false;
|
|
97
|
+
};
|
|
98
|
+
}, []);
|
|
99
|
+
const trigger = useRef(null);
|
|
100
|
+
const wasOpen = useRef(false);
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (wasOpen.current && !state.open) {
|
|
103
|
+
trigger.current?.focus();
|
|
104
|
+
}
|
|
105
|
+
wasOpen.current = state.open;
|
|
106
|
+
}, [state.open]);
|
|
107
|
+
const value = {
|
|
108
|
+
state,
|
|
109
|
+
trigger,
|
|
110
|
+
setOpen: (open) => setState(
|
|
111
|
+
(current) => current.pending ? current : { open, pending: false, error: void 0 }
|
|
112
|
+
),
|
|
113
|
+
confirm: () => {
|
|
114
|
+
if (state.pending) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
setState({ open: true, pending: true, error: void 0 });
|
|
118
|
+
onRemove().then(
|
|
119
|
+
() => {
|
|
120
|
+
if (live.current) {
|
|
121
|
+
setState({ open: false, pending: false, error: void 0 });
|
|
122
|
+
}
|
|
123
|
+
onRemoved?.();
|
|
124
|
+
},
|
|
125
|
+
(error) => {
|
|
126
|
+
if (live.current) {
|
|
127
|
+
setState({ open: true, pending: false, error });
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
return /* @__PURE__ */ jsx(RemoveContext.Provider, { value, children: part("div", props, state, {
|
|
134
|
+
role: "group",
|
|
135
|
+
"data-state": state.open ? "open" : "closed"
|
|
136
|
+
}) });
|
|
137
|
+
}
|
|
138
|
+
var RemoveTrigger = forwardRef(
|
|
139
|
+
function RemoveTrigger2(props, ref) {
|
|
140
|
+
const { state, setOpen, trigger } = useRemove("Trigger");
|
|
141
|
+
return part(
|
|
142
|
+
"button",
|
|
143
|
+
props,
|
|
144
|
+
state,
|
|
145
|
+
{
|
|
146
|
+
type: "button",
|
|
147
|
+
"aria-expanded": state.open,
|
|
148
|
+
onClick: () => setOpen(true)
|
|
149
|
+
},
|
|
150
|
+
composeRefs(ref, trigger)
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
var RemoveConfirm = forwardRef(
|
|
155
|
+
function RemoveConfirm2(props, ref) {
|
|
156
|
+
const { state, confirm } = useRemove("Confirm");
|
|
157
|
+
const own = useRef(null);
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
if (state.open) {
|
|
160
|
+
own.current?.focus();
|
|
161
|
+
}
|
|
162
|
+
}, [state.open]);
|
|
163
|
+
if (!state.open) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
return part(
|
|
167
|
+
"button",
|
|
168
|
+
props,
|
|
169
|
+
state,
|
|
170
|
+
{
|
|
171
|
+
type: "button",
|
|
172
|
+
"aria-disabled": state.pending || void 0,
|
|
173
|
+
"aria-busy": state.pending || void 0,
|
|
174
|
+
onClick: confirm
|
|
175
|
+
},
|
|
176
|
+
composeRefs(ref, own)
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
var RemoveCancel = forwardRef(
|
|
181
|
+
function RemoveCancel2(props, ref) {
|
|
182
|
+
const { state, setOpen } = useRemove("Cancel");
|
|
183
|
+
if (!state.open) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
return part(
|
|
187
|
+
"button",
|
|
188
|
+
props,
|
|
189
|
+
state,
|
|
190
|
+
{
|
|
191
|
+
type: "button",
|
|
192
|
+
"aria-disabled": state.pending || void 0,
|
|
193
|
+
onClick: () => setOpen(false)
|
|
194
|
+
},
|
|
195
|
+
ref
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
var RemoveCard = {
|
|
200
|
+
Root: RemoveRoot,
|
|
201
|
+
Trigger: RemoveTrigger,
|
|
202
|
+
Confirm: RemoveConfirm,
|
|
203
|
+
Cancel: RemoveCancel
|
|
204
|
+
};
|
|
205
|
+
var Payments = forwardRef(function Payments2({ account, limit, ...props }, ref) {
|
|
206
|
+
const page = (cursor) => account.payments({
|
|
207
|
+
...limit !== void 0 ? { limit } : {},
|
|
208
|
+
...cursor !== void 0 ? { cursor } : {}
|
|
209
|
+
});
|
|
210
|
+
const [more, setMore] = useState({ payments: [], cursor: null, loading: false });
|
|
211
|
+
const { set: _set, ...read } = useRead(async () => {
|
|
212
|
+
const first = await page();
|
|
213
|
+
setMore({ payments: [], cursor: first.next_cursor, loading: false });
|
|
214
|
+
return first.payments;
|
|
215
|
+
}, account);
|
|
216
|
+
const loadMore = () => {
|
|
217
|
+
const cursor = more.cursor;
|
|
218
|
+
if (cursor === null || more.loading) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
setMore((current) => ({ ...current, loading: true }));
|
|
222
|
+
page(cursor).then(
|
|
223
|
+
(next) => setMore((current) => ({
|
|
224
|
+
payments: [...current.payments, ...next.payments],
|
|
225
|
+
cursor: next.next_cursor,
|
|
226
|
+
loading: false
|
|
227
|
+
})),
|
|
228
|
+
(error) => setMore((current) => ({ ...current, loading: false, error }))
|
|
229
|
+
);
|
|
230
|
+
};
|
|
231
|
+
const state = {
|
|
232
|
+
...read,
|
|
233
|
+
data: read.data && [...read.data, ...more.payments],
|
|
234
|
+
error: read.error ?? more.error,
|
|
235
|
+
hasMore: more.cursor !== null,
|
|
236
|
+
loadingMore: more.loading,
|
|
237
|
+
loadMore
|
|
238
|
+
};
|
|
239
|
+
return part("div", props, state, readAttributes(state.status), ref);
|
|
240
|
+
});
|
|
241
|
+
var Receipt = forwardRef(function Receipt2({ account, paymentId, ...props }, ref) {
|
|
242
|
+
const { set: _set, ...read } = useRead(
|
|
243
|
+
() => account.payment(paymentId),
|
|
244
|
+
`${paymentId}`
|
|
245
|
+
);
|
|
246
|
+
const state = { ...read, print: () => window.print() };
|
|
247
|
+
return part("div", props, state, readAttributes(state.status), ref);
|
|
248
|
+
});
|
|
249
|
+
var ScopeMissing = forwardRef(function ScopeMissing2({ error, signIn, ...props }, ref) {
|
|
250
|
+
const scope = missingScope(error);
|
|
251
|
+
if (!scope) {
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
return part(
|
|
255
|
+
"button",
|
|
256
|
+
{ ...props, children: props.children ?? "Sign in again to see this" },
|
|
257
|
+
{ scope },
|
|
258
|
+
{ type: "button", "data-scope": scope, onClick: signIn },
|
|
259
|
+
ref
|
|
260
|
+
);
|
|
261
|
+
});
|
|
262
|
+
export {
|
|
263
|
+
Cards,
|
|
264
|
+
Payments,
|
|
265
|
+
Receipt,
|
|
266
|
+
RemoveCard,
|
|
267
|
+
ScopeMissing,
|
|
268
|
+
Wallets,
|
|
269
|
+
missingScope
|
|
270
|
+
};
|
|
271
|
+
//# sourceMappingURL=parts.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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;AAAA,MACF;AAAA,MACA,CAAC,UAAmB;AACl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RemoveConfirm", "RemoveCancel", "Payments", "Receipt", "ScopeMissing"]
|
|
6
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { P as PartOwnedAttributes, a as PartProps } from './
|
|
2
|
-
import { Presentation, SwipeDirection } from './overlay/engine.js';
|
|
1
|
+
import { P as PartOwnedAttributes, a as PartProps } from './slot-CHfqzPTd.js';
|
|
3
2
|
import * as react from 'react';
|
|
4
3
|
import { HTMLAttributes, ReactNode, ComponentType, ReactElement, KeyboardEvent as KeyboardEvent$1, ImgHTMLAttributes, ChangeEvent, ClipboardEvent } from 'react';
|
|
5
4
|
import * as _zappie_sdk from '@zappie/sdk';
|
|
6
5
|
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';
|
|
7
6
|
import { useCart } from '@zappie/sdk/react';
|
|
7
|
+
import { Presentation, SwipeDirection } from './overlay/engine.js';
|
|
8
8
|
import { C as CloseOptions, O as OverlayQuery } from './history-BlytQinP.js';
|
|
9
9
|
import '@base-ui/react/dialog';
|
|
10
10
|
|
|
@@ -22,7 +22,7 @@ type SignInOptions = {
|
|
|
22
22
|
returnTo?: string;
|
|
23
23
|
prompt?: "none" | "login";
|
|
24
24
|
display?: "popup" | "redirect" | "auto";
|
|
25
|
-
scopes?: ("openid" | "phone" | "profile" | "addresses" | "orders:read" | "offline_access" | "cart")[];
|
|
25
|
+
scopes?: ("openid" | "phone" | "profile" | "addresses" | "orders:read" | "offline_access" | "cart" | "wallet" | "cards" | "payments:read")[];
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
28
28
|
* An error from Account sign-in and sign-out when authentication is not configured.
|
package/dist/overlay/engine.d.ts
CHANGED
|
@@ -1,3 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
3
|
-
import '
|
|
1
|
+
import { P as PartOwnedAttributes } from '../slot-CHfqzPTd.js';
|
|
2
|
+
import { PartProps } from '../index.js';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import { ReactNode, Ref } from 'react';
|
|
5
|
+
import { Dialog } from '@base-ui/react/dialog';
|
|
6
|
+
|
|
7
|
+
type Presentation = "dialog" | "drawer" | "sheet";
|
|
8
|
+
type SwipeDirection = "up" | "down" | "left" | "right";
|
|
9
|
+
type SurfaceProps = {
|
|
10
|
+
open: boolean;
|
|
11
|
+
presentation: Presentation;
|
|
12
|
+
swipeDirection: SwipeDirection;
|
|
13
|
+
/** Ids the trigger points at; caller-supplied ids win. */
|
|
14
|
+
contentId: string;
|
|
15
|
+
titleId?: string | undefined;
|
|
16
|
+
trigger: {
|
|
17
|
+
current: HTMLElement | null;
|
|
18
|
+
};
|
|
19
|
+
onOpen: () => void;
|
|
20
|
+
onClose: () => void;
|
|
21
|
+
onEscape?: ((event: KeyboardEvent) => void) | undefined;
|
|
22
|
+
onInteractOutside?: ((event: Event) => void) | undefined;
|
|
23
|
+
forceMount?: true | undefined;
|
|
24
|
+
container?: HTMLElement | null | undefined;
|
|
25
|
+
state: unknown;
|
|
26
|
+
contentProps: PartProps<never>;
|
|
27
|
+
contentRef: Ref<HTMLElement>;
|
|
28
|
+
};
|
|
29
|
+
type Parts = {
|
|
30
|
+
Title: typeof Dialog.Title;
|
|
31
|
+
Close: typeof Dialog.Close;
|
|
32
|
+
};
|
|
33
|
+
declare function useEngineParts(): Parts;
|
|
34
|
+
declare function Surface(props: SurfaceProps & {
|
|
35
|
+
children?: ReactNode;
|
|
36
|
+
}): react.JSX.Element;
|
|
37
|
+
declare const EngineTitle: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
38
|
+
asChild?: boolean;
|
|
39
|
+
children?: ReactNode | ((state: unknown) => ReactNode);
|
|
40
|
+
} & {
|
|
41
|
+
id?: string | undefined;
|
|
42
|
+
state: unknown;
|
|
43
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
44
|
+
declare const EngineClose: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
45
|
+
asChild?: boolean;
|
|
46
|
+
children?: ReactNode | ((state: unknown) => ReactNode);
|
|
47
|
+
} & {
|
|
48
|
+
id?: string | undefined;
|
|
49
|
+
state: unknown;
|
|
50
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
51
|
+
|
|
52
|
+
export { EngineClose, EngineTitle, Surface, useEngineParts };
|
|
53
|
+
export type { Presentation, SurfaceProps, SwipeDirection };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AllHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
type PartOwnedAttributes = "children" | "defaultValue" | "value";
|
|
4
|
+
/**
|
|
5
|
+
* HTML attributes shared by foundation parts, with optional render-function children.
|
|
6
|
+
* Set asChild to merge the part props and ref into a single child element.
|
|
7
|
+
*/
|
|
8
|
+
type PartProps<S = Record<string, never>> = Omit<AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
9
|
+
asChild?: boolean;
|
|
10
|
+
children?: ReactNode | ((state: S) => ReactNode);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type { PartOwnedAttributes as P, PartProps as a };
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zappie/foundations",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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,
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
10
|
"import": "./dist/index.js"
|
|
11
11
|
},
|
|
12
|
+
"./account": {
|
|
13
|
+
"types": "./dist/account/parts.d.ts",
|
|
14
|
+
"import": "./dist/account/parts.js"
|
|
15
|
+
},
|
|
12
16
|
"./next": {
|
|
13
17
|
"types": "./dist/next.d.ts",
|
|
14
18
|
"import": "./dist/next.js"
|
|
@@ -33,7 +37,7 @@
|
|
|
33
37
|
"dependencies": {
|
|
34
38
|
"@base-ui/react": "^1.9.0",
|
|
35
39
|
"@googlemaps/markerclusterer": "^2.6.2",
|
|
36
|
-
"@zappie/sdk": "^0.
|
|
40
|
+
"@zappie/sdk": "^0.5.0"
|
|
37
41
|
},
|
|
38
42
|
"peerDependencies": {
|
|
39
43
|
"react": "^18.2.0 || ^19.0.0",
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { AllHTMLAttributes, ReactNode, Ref } from 'react';
|
|
3
|
-
import { Dialog } from '@base-ui/react/dialog';
|
|
4
|
-
|
|
5
|
-
type PartOwnedAttributes = "children" | "defaultValue" | "value";
|
|
6
|
-
/**
|
|
7
|
-
* HTML attributes shared by foundation parts, with optional render-function children.
|
|
8
|
-
* Set asChild to merge the part props and ref into a single child element.
|
|
9
|
-
*/
|
|
10
|
-
type PartProps<S = Record<string, never>> = Omit<AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
11
|
-
asChild?: boolean;
|
|
12
|
-
children?: ReactNode | ((state: S) => ReactNode);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
type Presentation = "dialog" | "drawer" | "sheet";
|
|
16
|
-
type SwipeDirection = "up" | "down" | "left" | "right";
|
|
17
|
-
type SurfaceProps = {
|
|
18
|
-
open: boolean;
|
|
19
|
-
presentation: Presentation;
|
|
20
|
-
swipeDirection: SwipeDirection;
|
|
21
|
-
/** Ids the trigger points at; caller-supplied ids win. */
|
|
22
|
-
contentId: string;
|
|
23
|
-
titleId?: string | undefined;
|
|
24
|
-
trigger: {
|
|
25
|
-
current: HTMLElement | null;
|
|
26
|
-
};
|
|
27
|
-
onOpen: () => void;
|
|
28
|
-
onClose: () => void;
|
|
29
|
-
onEscape?: ((event: KeyboardEvent) => void) | undefined;
|
|
30
|
-
onInteractOutside?: ((event: Event) => void) | undefined;
|
|
31
|
-
forceMount?: true | undefined;
|
|
32
|
-
container?: HTMLElement | null | undefined;
|
|
33
|
-
state: unknown;
|
|
34
|
-
contentProps: PartProps<never>;
|
|
35
|
-
contentRef: Ref<HTMLElement>;
|
|
36
|
-
};
|
|
37
|
-
type Parts = {
|
|
38
|
-
Title: typeof Dialog.Title;
|
|
39
|
-
Close: typeof Dialog.Close;
|
|
40
|
-
};
|
|
41
|
-
declare function useEngineParts(): Parts;
|
|
42
|
-
declare function Surface(props: SurfaceProps & {
|
|
43
|
-
children?: ReactNode;
|
|
44
|
-
}): react.JSX.Element;
|
|
45
|
-
declare const EngineTitle: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
46
|
-
asChild?: boolean;
|
|
47
|
-
children?: ReactNode | ((state: unknown) => ReactNode);
|
|
48
|
-
} & {
|
|
49
|
-
id?: string | undefined;
|
|
50
|
-
state: unknown;
|
|
51
|
-
} & react.RefAttributes<HTMLElement>>;
|
|
52
|
-
declare const EngineClose: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
53
|
-
asChild?: boolean;
|
|
54
|
-
children?: ReactNode | ((state: unknown) => ReactNode);
|
|
55
|
-
} & {
|
|
56
|
-
id?: string | undefined;
|
|
57
|
-
state: unknown;
|
|
58
|
-
} & react.RefAttributes<HTMLElement>>;
|
|
59
|
-
|
|
60
|
-
export { EngineClose as E, EngineTitle as c, Surface as d, useEngineParts as u };
|
|
61
|
-
export type { PartOwnedAttributes as P, SwipeDirection as S, PartProps as a, Presentation as b, SurfaceProps as e };
|