@zappie/foundations 0.23.0 → 0.26.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 +37 -0
- package/dist/checkout/attempt.js +1 -1
- package/dist/checkout/attempt.js.map +1 -1
- package/dist/checkout/contact.js +1 -1
- package/dist/checkout/contact.js.map +1 -1
- package/dist/checkout/index.d.ts +76 -6
- package/dist/checkout/index.js +1 -1
- package/dist/checkout/index.js.map +1 -1
- package/dist/checkout/status.js +1 -1
- package/dist/checkout/status.js.map +1 -1
- package/dist/checkout/use-checkout-flow.js +1 -1
- package/dist/checkout/use-checkout-flow.js.map +1 -1
- package/dist/index.d.ts +16 -6
- package/dist/internal/labelled-control.js +2 -0
- package/dist/internal/labelled-control.js.map +6 -0
- package/dist/item-form/option-group.js +1 -1
- package/dist/item-form/option-group.js.map +1 -1
- package/dist/payment/methods.js +1 -1
- package/dist/payment/methods.js.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @zappie/foundations
|
|
2
2
|
|
|
3
|
+
## 0.26.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7980f3c: A shopper can order a pickup or a delivery for someone else. The order goes out under that person's name and phone, and the signed-in customer still pays for it and owns it.
|
|
8
|
+
|
|
9
|
+
- `@zappie/sdk`: a checkout request takes `contact_name` beside `contact_phone`.
|
|
10
|
+
- `@zappie/foundations`: `flow.contact.recipient` is the "Ordering for someone else?" switch with their name and phone, labelled `Deliver to` or `Collected by`. It's left out for an in-venue order. While it's on, Pay asks for both, with problems keyed `recipient_name` and `recipient_phone`, the shopper's own phone isn't asked, and the checkout sends them as `contact_name` and `contact_phone`. The switch and what's typed are kept for the session, like the contact details. `recipientProblems()` checks a dialog's own draft of them the same way.
|
|
11
|
+
- `@zappie/checkout-fields`: `recipientProblemText()` words those two problems, and `contactProblemTexts()` uses it. `useContactDraft()` asks for no phone of the shopper's own while the switch is on.
|
|
12
|
+
- `@zappie/starter`: the bag's Your details has the switch and the two fields.
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [7980f3c]
|
|
17
|
+
- @zappie/sdk@0.27.0
|
|
18
|
+
|
|
19
|
+
## 0.25.0
|
|
20
|
+
|
|
21
|
+
### Minor Changes
|
|
22
|
+
|
|
23
|
+
- 80af2eb: Checkout asks for exactly the details the business chose in its dashboard, such as a first name or an email.
|
|
24
|
+
|
|
25
|
+
- `@zappie/sdk`: `store.checkoutFields` lists them with where each applies. `cart.setCustomer()` sends what the shopper typed with each quote and the checkout. A quote's new issues, `checkout_field_required` and `checkout_field_invalid`, name the field in `data.field`, and `quote.checkout.fields` names the keys the cart asks for. `customer.profile()` now returns the account's `email`.
|
|
26
|
+
- `@zappie/foundations`: pass `checkoutFields: store.checkoutFields` to `useCheckoutFlow()`. It asks the fields that apply to the branch and the order type, leaves out what the signed-in account already holds (`contact.held`), sends what is typed, and leads Pay to a missing detail rather than to the cart's issues. `businessContactFields()` and `checkoutCustomer()` do the same outside the flow.
|
|
27
|
+
- `@zappie/starter`: Your details renders the store's checkout fields, and shows a detail the account holds with a link to change it there.
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Updated dependencies [80af2eb]
|
|
32
|
+
- @zappie/sdk@0.26.0
|
|
33
|
+
|
|
34
|
+
## 0.24.0
|
|
35
|
+
|
|
36
|
+
### Minor Changes
|
|
37
|
+
|
|
38
|
+
- 6186e4f: Choice and PaymentMethods.Item are real form controls now. Each is a `<label>` around a native `<input type="radio">` or `<input type="checkbox">`, so the browser draws a round radio for a group that takes exactly one and a square checkbox for every other group, and owns the arrows, Tab and Space. The label keeps every data attribute it had as a button (`data-zappie-option`, `data-control`, `data-state`, `data-selected`, `data-disabled`, `data-sold-out`, `data-limit-reached`) and the template's `className`. The input carries `checked`, `disabled` for a sold-out choice or one the template passes `disabled`, `aria-disabled` for a choice held back by the group's limit, and `data-zappie-choice-input` for styling. A template that draws its own mark restyles or hides that input, styles its focus ring with `:has(> [data-zappie-choice-input]:focus-visible)` and its disabled look with `[data-disabled]`. Put quantity steppers beside a Choice, not inside it. The base theme draws its marks on the input. V05 skips sold-out choices by `data-disabled` as well as `aria-disabled`.
|
|
39
|
+
|
|
3
40
|
## 0.23.0
|
|
4
41
|
|
|
5
42
|
### Minor Changes
|
package/dist/checkout/attempt.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{checkoutFulfilment}from"@zappie/sdk/checkout";function fulfilment(payload){const value=checkoutFulfilment(payload.fulfilment);if(value.type==="dine_in"){throw new Error("Checkout sessions don't take in-venue orders yet")}const scheduled=value.scheduled_for!==void 0?{scheduled_for:value.scheduled_for}:{};if(value.type==="pickup"){return{type:"pickup",...scheduled}}return{type:"delivery",...value.address!==void 0?{address:value.address}:{},...value.delivery_region_id!==void 0?{delivery_region_id:value.delivery_region_id}:{},...value.instructions!==void 0?{instructions:value.instructions}:{},...scheduled}}function createCheckoutAttempt(){let current;return input=>{const{payload,attribution}=input;const phone=input.contactPhone.trim().replace(/\s+/g,"");const digest=JSON.stringify({payload,phone});if(current?.digest===digest){return current.attempt}const request={branch_id:input.branchId,menu_version:payload.menu_version,lines:payload.lines,fulfilment:fulfilment(payload),...phone?{contact_phone:phone}:{},...payload.promo_code?{promo_code:payload.promo_code}:{},...payload.perk_redemption_ids?{perk_redemption_ids:payload.perk_redemption_ids}:{},...attribution.source?{source:attribution.source}:{},...attribution.campaign?{campaign:attribution.campaign}:{},return_url:input.returnUrl,cancel_url:input.cancelUrl};current={digest,attempt:{key:crypto.randomUUID(),request}};return current.attempt}}export{createCheckoutAttempt};
|
|
1
|
+
import{checkoutFulfilment}from"@zappie/sdk/checkout";function fulfilment(payload){const value=checkoutFulfilment(payload.fulfilment);if(value.type==="dine_in"){throw new Error("Checkout sessions don't take in-venue orders yet")}const scheduled=value.scheduled_for!==void 0?{scheduled_for:value.scheduled_for}:{};if(value.type==="pickup"){return{type:"pickup",...scheduled}}return{type:"delivery",...value.address!==void 0?{address:value.address}:{},...value.delivery_region_id!==void 0?{delivery_region_id:value.delivery_region_id}:{},...value.instructions!==void 0?{instructions:value.instructions}:{},...scheduled}}function createCheckoutAttempt(){let current;return input=>{const{payload,attribution}=input;const phone=input.contactPhone.trim().replace(/\s+/g,"");const name=input.contactName?.trim()??"";const digest=JSON.stringify({payload,phone,name});if(current?.digest===digest){return current.attempt}const request={branch_id:input.branchId,menu_version:payload.menu_version,lines:payload.lines,fulfilment:fulfilment(payload),...phone?{contact_phone:phone}:{},...name?{contact_name:name}:{},...payload.promo_code?{promo_code:payload.promo_code}:{},...payload.perk_redemption_ids?{perk_redemption_ids:payload.perk_redemption_ids}:{},...attribution.source?{source:attribution.source}:{},...attribution.campaign?{campaign:attribution.campaign}:{},return_url:input.returnUrl,cancel_url:input.cancelUrl};current={digest,attempt:{key:crypto.randomUUID(),request}};return current.attempt}}export{createCheckoutAttempt};
|
|
2
2
|
//# sourceMappingURL=attempt.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/checkout/attempt.ts"],
|
|
4
|
-
"mappings": "AACA,OAAS,uBAAgD,uBAOzD,SAAS,WAAW,QAAiD,CACnE,MAAM,MAAQ,mBAAmB,QAAQ,UAAU,EAEnD,GAAI,MAAM,OAAS,UAAW,CAC5B,MAAM,IAAI,MAAM,kDAAkD,CACpE,CACA,MAAM,UACJ,MAAM,gBAAkB,OACpB,CAAE,cAAe,MAAM,aAAc,EACrC,CAAC,EACP,GAAI,MAAM,OAAS,SAAU,CAC3B,MAAO,CAAE,KAAM,SAAU,GAAG,SAAU,CACxC,CACA,MAAO,CACL,KAAM,WACN,GAAI,MAAM,UAAY,OAAY,CAAE,QAAS,MAAM,OAAQ,EAAI,CAAC,EA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AAM,EAAI,CAAC,EACxC,GAAI,KAAO,CAAE,aAAc,IAAK,EAAI,CAAC,EACrC,GAAI,QAAQ,WAAa,CAAE,WAAY,QAAQ,UAAW,EAAI,CAAC,EAC/D,GAAI,QAAQ,oBACR,CAAE,oBAAqB,QAAQ,mBAAoB,EACnD,CAAC,EACL,GAAI,YAAY,OAAS,CAAE,OAAQ,YAAY,MAAO,EAAI,CAAC,EAC3D,GAAI,YAAY,SAAW,CAAE,SAAU,YAAY,QAAS,EAAI,CAAC,EACjE,WAAY,MAAM,UAClB,WAAY,MAAM,SACpB,EACA,QAAU,CAAE,OAAQ,QAAS,CAAE,IAAK,OAAO,WAAW,EAAG,OAAQ,CAAE,EACnE,OAAO,QAAQ,OACjB,CACF",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/checkout/contact.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{isContactPhoneValid}from"@zappie/sdk/checkout";function fullPhone(typed,dialCode="+234"){const value=typed.trim().replace(/\s+/g,"");if(!value){return""}return value.startsWith("+")?value:`${dialCode}${value.replace(/^0/,"")}`}var emailPattern=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function contactProblems(fields,values,phone,accountPhone,dialCode="+234"){const problems={};if(!phone.trim()){if(!accountPhone){problems.phone="missing"}}else if(!isContactPhoneValid(fullPhone(phone,dialCode))){problems.phone="invalid"}for(const field of fields){const value=values[field.key]?.trim()??"";if(!value){if(field.required){problems[field.key]="missing"}}else if(field.type==="email"&&!emailPattern.test(value)||field.type==="tel"&&!isContactPhoneValid(value)){problems[field.key]="invalid"}}return problems}export{contactProblems,fullPhone};
|
|
1
|
+
import{isContactPhoneValid}from"@zappie/sdk/checkout";function fullPhone(typed,dialCode="+234"){const value=typed.trim().replace(/\s+/g,"");if(!value){return""}return value.startsWith("+")?value:`${dialCode}${value.replace(/^0/,"")}`}var emailPattern=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function contactProblems(fields,values,phone,accountPhone,dialCode="+234"){const problems={};if(!phone.trim()){if(!accountPhone){problems.phone="missing"}}else if(!isContactPhoneValid(fullPhone(phone,dialCode))){problems.phone="invalid"}for(const field of fields){const value=values[field.key]?.trim()??"";if(!value){if(field.required){problems[field.key]="missing"}}else if(field.type==="email"&&!emailPattern.test(value)||field.type==="tel"&&!isContactPhoneValid(value)){problems[field.key]="invalid"}}return problems}function recipientProblems(recipient,dialCode="+234"){const problems={};if(!recipient.on){return problems}const name=recipient.name.trim();if(!name){problems.recipient_name="missing"}else if(name.length>100){problems.recipient_name="invalid"}if(!recipient.phone.trim()){problems.recipient_phone="missing"}else if(!isContactPhoneValid(fullPhone(recipient.phone,dialCode))){problems.recipient_phone="invalid"}return problems}var BUILT_IN=["given_name","family_name","email"];function businessContactFields(fields,branchId,mode){if(mode!=="pickup"&&mode!=="delivery"){return[]}return(fields??[]).flatMap(field=>BUILT_IN.includes(field.key)&&field.appliesTo.fulfilment.includes(mode)&&(field.appliesTo.branchIds.length===0||field.appliesTo.branchIds.includes(branchId))?[{key:field.key,label:field.label,type:field.type==="email"?"email":"text",required:field.required}]:[])}function checkoutCustomer(fields,values){const customer={};for(const field of fields){const value=values[field.key]?.trim();if(value&&BUILT_IN.includes(field.key)){customer[field.key]=value}}return Object.keys(customer).length?customer:null}export{businessContactFields,checkoutCustomer,contactProblems,fullPhone,recipientProblems};
|
|
2
2
|
//# sourceMappingURL=contact.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/checkout/contact.ts"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": "AACA,OAAS,wBAA2B,uBA0B7B,SAAS,UAAU,MAAe,SAAW,OAAgB,CAClE,MAAM,MAAQ,MAAM,KAAK,EAAE,QAAQ,OAAQ,EAAE,EAC7C,GAAI,CAAC,MAAO,CACV,MAAO,EACT,CACA,OAAO,MAAM,WAAW,GAAG,EACvB,MACA,GAAG,QAAQ,GA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,MAAM,GAAG,GAClD,MAAM,UAAU,WAAW,SAAS,IAAI,IACvC,MAAM,UAAU,UAAU,SAAW,GACpC,MAAM,UAAU,UAAU,SAAS,QAAQ,GACzC,CACE,CACE,IAAK,MAAM,IACX,MAAO,MAAM,MACb,KAAM,MAAM,OAAS,QAAU,QAAU,OACzC,SAAU,MAAM,QAClB,CACF,EACA,CAAC,CACP,CACF,CAQO,SAAS,iBACd,OACA,OACyB,CACzB,MAAM,SAAmC,CAAC,EAC1C,UAAW,SAAS,OAAQ,CAC1B,MAAM,MAAQ,OAAO,MAAM,GAAG,GAAG,KAAK,EACtC,GAAI,OAAU,SAA+B,SAAS,MAAM,GAAG,EAAG,CAChE,SAAS,MAAM,GAAG,EAAI,KACxB,CACF,CACA,OAAO,OAAO,KAAK,QAAQ,EAAE,OAAU,SAAgC,IACzE",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/checkout/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CartModule, CartIssue, CartState, Money, Branch, Menu, CartLine, CartFulfilment, DeliveryAddress, Quote, CartFix } from '@zappie/sdk';
|
|
1
|
+
import { CartModule, CheckoutField, CheckoutCustomer as CheckoutCustomer$1, CartIssue, CartState, Money, Branch, Menu, CartLine, CartFulfilment, DeliveryAddress, Quote, CartFix } from '@zappie/sdk';
|
|
2
2
|
import { CheckoutRequest, CheckoutClient } from '@zappie/sdk/checkout';
|
|
3
3
|
import { C as CheckoutMode } from '../offers-fDZ0bZ0i.js';
|
|
4
4
|
export { c as checkoutOffers } from '../offers-fDZ0bZ0i.js';
|
|
@@ -12,7 +12,7 @@ type CheckoutAttempt = {
|
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
14
|
* Builds checkout requests that reuse one idempotency key for retries of the same payload and
|
|
15
|
-
*
|
|
15
|
+
* contact, and take a new key when either changes.
|
|
16
16
|
*
|
|
17
17
|
* @returns A function from the payload and its addresses to the attempt to open.
|
|
18
18
|
*/
|
|
@@ -20,6 +20,8 @@ declare function createCheckoutAttempt(): (input: {
|
|
|
20
20
|
payload: Payload;
|
|
21
21
|
branchId: string;
|
|
22
22
|
contactPhone: string;
|
|
23
|
+
/** The person a pickup or delivery is for, when the shopper orders for someone else. */
|
|
24
|
+
contactName?: string;
|
|
23
25
|
returnUrl: string;
|
|
24
26
|
cancelUrl: string;
|
|
25
27
|
attribution: {
|
|
@@ -62,6 +64,36 @@ declare function fullPhone(typed: string, dialCode?: string): string;
|
|
|
62
64
|
* @param dialCode - The dial code a local number takes.
|
|
63
65
|
*/
|
|
64
66
|
declare function contactProblems(fields: readonly ContactField[], values: ContactValues, phone: string, accountPhone?: string, dialCode?: string): Record<string, ContactProblem>;
|
|
67
|
+
/** What the shopper typed for the person an order is for, when they order for someone else. */
|
|
68
|
+
type RecipientDraft = {
|
|
69
|
+
on: boolean;
|
|
70
|
+
name: string;
|
|
71
|
+
phone: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* What stops Pay for an order placed for someone else: their name, at most 100 characters, and
|
|
75
|
+
* their phone, by `recipient_name` and `recipient_phone`. Empty while the switch is off.
|
|
76
|
+
*
|
|
77
|
+
* @param recipient - What the shopper typed for them.
|
|
78
|
+
* @param dialCode - The dial code a local number takes.
|
|
79
|
+
*/
|
|
80
|
+
declare function recipientProblems(recipient: RecipientDraft, dialCode?: string): Record<string, ContactProblem>;
|
|
81
|
+
/**
|
|
82
|
+
* The store's checkout fields an order asks for beside the phone, at the branch and fulfilled this
|
|
83
|
+
* way: `store.checkoutFields` read by each field's `appliesTo`. An in-venue order asks none.
|
|
84
|
+
*
|
|
85
|
+
* @param fields - `store.checkoutFields`.
|
|
86
|
+
* @param branchId - The cart's branch.
|
|
87
|
+
* @param mode - How the order reaches the shopper.
|
|
88
|
+
*/
|
|
89
|
+
declare function businessContactFields(fields: readonly CheckoutField[] | undefined, branchId: string, mode: string): ContactField[];
|
|
90
|
+
/**
|
|
91
|
+
* What to send for the store's checkout fields: each field's trimmed value, left out when blank.
|
|
92
|
+
*
|
|
93
|
+
* @param fields - The fields the order asks for.
|
|
94
|
+
* @param values - What the shopper typed, by key.
|
|
95
|
+
*/
|
|
96
|
+
declare function checkoutCustomer(fields: readonly ContactField[], values: ContactValues): CheckoutCustomer$1 | null;
|
|
65
97
|
|
|
66
98
|
/** The attributes that mark an issue's element, so a `fix_issues` step can find it. */
|
|
67
99
|
type IssueMarker = {
|
|
@@ -139,6 +171,8 @@ type CheckoutStatusInput = {
|
|
|
139
171
|
declare function payEnabled(status: CheckoutStatus): boolean;
|
|
140
172
|
/** The issue `fix_issues` points at: the first blocking one, else the first the cart raised. */
|
|
141
173
|
declare function firstIssue(state: CartState): CartIssue | undefined;
|
|
174
|
+
/** Whether an issue is a checkout field's, which the contact step answers. */
|
|
175
|
+
declare function isCheckoutFieldIssue(issue: CartIssue): boolean;
|
|
142
176
|
/**
|
|
143
177
|
* The Pay button's status, in the precedence `CheckoutStatus` lists. Sign-in is asked only when
|
|
144
178
|
* the quote, or opening payment, says the business requires a customer. Otherwise a guest pays
|
|
@@ -261,15 +295,21 @@ type CheckoutAccount = {
|
|
|
261
295
|
*/
|
|
262
296
|
type CheckoutFlowError = "quote_failed" | "open_failed" | "sign_in_failed";
|
|
263
297
|
/** The customer client methods the flow reads. */
|
|
264
|
-
type CheckoutCustomer = Pick<CustomerClient, "state" | "customer" | "onChange" | "addresses" | "session">;
|
|
298
|
+
type CheckoutCustomer = Pick<CustomerClient, "state" | "customer" | "onChange" | "addresses" | "session" | "profile">;
|
|
265
299
|
/** Where the checkout flow reads its branch and how it leaves the page. */
|
|
266
300
|
type CheckoutFlowOptions = {
|
|
267
301
|
/** The cart's branch. */
|
|
268
302
|
branch: Branch;
|
|
269
303
|
/** The branch's menu, for pre-order notice on its source menus. */
|
|
270
304
|
menu?: Menu | undefined;
|
|
271
|
-
/** The contact fields the business asks for beside the phone. */
|
|
305
|
+
/** The contact fields the business asks for beside the phone. Left out with `checkoutFields`. */
|
|
272
306
|
contactFields?: readonly ContactField[];
|
|
307
|
+
/**
|
|
308
|
+
* The store's checkout fields, `store.checkoutFields`. The flow asks those that apply to the
|
|
309
|
+
* branch and mode, leaves out what the signed-in customer's account already holds (see
|
|
310
|
+
* `contact.held`), and sends what the shopper typed with each quote and the checkout.
|
|
311
|
+
*/
|
|
312
|
+
checkoutFields?: readonly CheckoutField[];
|
|
273
313
|
/**
|
|
274
314
|
* How the order can reach the shopper, in the order to show them. Defaults to delivery and
|
|
275
315
|
* pickup, where the branch takes them and its menus serve them. A mode the branch doesn't take,
|
|
@@ -320,10 +360,40 @@ type CheckoutContact = {
|
|
|
320
360
|
setField(key: string, value: string): void;
|
|
321
361
|
/** What stops Pay, by key, with `phone` for the phone. */
|
|
322
362
|
problems: Readonly<Record<string, ContactProblem>>;
|
|
363
|
+
/**
|
|
364
|
+
* The store's checkout fields the signed-in customer's account already holds, with its value.
|
|
365
|
+
* Checkout never asks or changes them. Show them read only, with a link to the account page.
|
|
366
|
+
*/
|
|
367
|
+
held?: readonly HeldContact[];
|
|
368
|
+
/** Ordering for someone else, on a pickup or delivery. Left out for an in-venue order. */
|
|
369
|
+
recipient?: CheckoutRecipient | undefined;
|
|
323
370
|
/** The keys whose problem the template shows: blurred fields, and all of them after Pay. */
|
|
324
371
|
shown: ReadonlySet<string>;
|
|
325
372
|
show(key: string): void;
|
|
326
373
|
};
|
|
374
|
+
/** A checkout field the customer's account already holds. */
|
|
375
|
+
type HeldContact = {
|
|
376
|
+
key: string;
|
|
377
|
+
label: string;
|
|
378
|
+
value: string;
|
|
379
|
+
};
|
|
380
|
+
/**
|
|
381
|
+
* The person a pickup or delivery is for when the shopper orders for someone else. While `on`,
|
|
382
|
+
* the order goes out under their name and phone, and the shopper's own phone isn't asked. The
|
|
383
|
+
* signed-in customer still pays, gets the receipt and owns the order.
|
|
384
|
+
*/
|
|
385
|
+
type CheckoutRecipient = {
|
|
386
|
+
/** `Deliver to` on a delivery, `Collected by` on a pickup. */
|
|
387
|
+
label: "Deliver to" | "Collected by";
|
|
388
|
+
on: boolean;
|
|
389
|
+
setOn(on: boolean): void;
|
|
390
|
+
/** Their name as typed. Its problem is keyed `recipient_name`. */
|
|
391
|
+
name: string;
|
|
392
|
+
setName(name: string): void;
|
|
393
|
+
/** Their phone as typed. Its problem is keyed `recipient_phone`. */
|
|
394
|
+
phone: string;
|
|
395
|
+
setPhone(phone: string): void;
|
|
396
|
+
};
|
|
327
397
|
/** The one Pay button: its status, whether it takes a press, and what a press does. */
|
|
328
398
|
type CheckoutPay = {
|
|
329
399
|
status: CheckoutStatus;
|
|
@@ -421,5 +491,5 @@ type CheckoutFlow = {
|
|
|
421
491
|
*/
|
|
422
492
|
declare function useCheckoutFlow(options: CheckoutFlowOptions): CheckoutFlow;
|
|
423
493
|
|
|
424
|
-
export { CheckoutMode, checkoutStatus, checkoutTiming, contactProblems, createCheckoutAttempt, fieldMarker, fieldSelector, firstIssue, fullPhone, issueMarker, issueSelector, mustSchedule, payEnabled, signInOnce, useCheckoutFlow };
|
|
425
|
-
export type { CheckoutAccount, CheckoutAttempt, CheckoutAuth, CheckoutContact, CheckoutCustomer, CheckoutDelivery, CheckoutDeliveryChange, CheckoutFlow, CheckoutFlowError, CheckoutFlowOptions, CheckoutIntent, CheckoutNotice, CheckoutPay, CheckoutStatus, CheckoutStatusInput, CheckoutTiming, ContactField, ContactProblem, ContactValues, FieldMarker, IssueMarker };
|
|
494
|
+
export { CheckoutMode, businessContactFields, checkoutCustomer, checkoutStatus, checkoutTiming, contactProblems, createCheckoutAttempt, fieldMarker, fieldSelector, firstIssue, fullPhone, isCheckoutFieldIssue, issueMarker, issueSelector, mustSchedule, payEnabled, recipientProblems, signInOnce, useCheckoutFlow };
|
|
495
|
+
export type { CheckoutAccount, CheckoutAttempt, CheckoutAuth, CheckoutContact, CheckoutCustomer, CheckoutDelivery, CheckoutDeliveryChange, CheckoutFlow, CheckoutFlowError, CheckoutFlowOptions, CheckoutIntent, CheckoutNotice, CheckoutPay, CheckoutRecipient, CheckoutStatus, CheckoutStatusInput, CheckoutTiming, ContactField, ContactProblem, ContactValues, FieldMarker, HeldContact, IssueMarker, RecipientDraft };
|
package/dist/checkout/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{createCheckoutAttempt}from"./attempt.js";import{contactProblems,fullPhone}from"./contact.js";import{fieldMarker,fieldSelector,issueMarker,issueSelector}from"./markers.js";import{checkoutOffers}from"./offers.js";import{signInOnce}from"./sign-in.js";import{checkoutStatus,firstIssue,payEnabled}from"./status.js";import{checkoutTiming,mustSchedule}from"./timing.js";import{useCheckoutFlow}from"./use-checkout-flow.js";export{checkoutOffers,checkoutStatus,checkoutTiming,contactProblems,createCheckoutAttempt,fieldMarker,fieldSelector,firstIssue,fullPhone,issueMarker,issueSelector,mustSchedule,payEnabled,signInOnce,useCheckoutFlow};
|
|
1
|
+
"use client";import{createCheckoutAttempt}from"./attempt.js";import{businessContactFields,checkoutCustomer,contactProblems,fullPhone,recipientProblems}from"./contact.js";import{fieldMarker,fieldSelector,issueMarker,issueSelector}from"./markers.js";import{checkoutOffers}from"./offers.js";import{signInOnce}from"./sign-in.js";import{checkoutStatus,firstIssue,isCheckoutFieldIssue,payEnabled}from"./status.js";import{checkoutTiming,mustSchedule}from"./timing.js";import{useCheckoutFlow}from"./use-checkout-flow.js";export{businessContactFields,checkoutCustomer,checkoutOffers,checkoutStatus,checkoutTiming,contactProblems,createCheckoutAttempt,fieldMarker,fieldSelector,firstIssue,fullPhone,isCheckoutFieldIssue,issueMarker,issueSelector,mustSchedule,payEnabled,recipientProblems,signInOnce,useCheckoutFlow};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/checkout/index.ts"],
|
|
4
|
-
"mappings": "aAGA,OAAS,0BAA6B,eAEtC,
|
|
4
|
+
"mappings": "aAGA,OAAS,0BAA6B,eAEtC,OACE,sBACA,iBACA,gBACA,UACA,sBACK,eAOP,OACE,YACA,cACA,YACA,kBACK,eAEP,OAAS,mBAAsB,cAE/B,OAAS,eAAkB,eAC3B,OACE,eACA,WACA,qBACA,eACK,cAMP,OAAS,eAAgB,iBAAoB,cAE7C,OAAS,oBAAuB",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/checkout/status.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var ENABLED=new Set(["address","area","time","fix_issues","sign_in","phone","contact","retry","pay"]);function payEnabled(status){return ENABLED.has(status)}function quoteOf(state){return"quote"in state?state.quote:void 0}function firstIssue(state){const issues=state.status==="needs_attention"?state.issues:quoteOf(state)?.issues??[];
|
|
1
|
+
var ENABLED=new Set(["address","area","time","fix_issues","sign_in","phone","contact","retry","pay"]);function payEnabled(status){return ENABLED.has(status)}function quoteOf(state){return"quote"in state?state.quote:void 0}function firstIssue(state){const issues=state.status==="needs_attention"?state.issues:quoteOf(state)?.issues??[];const cart=issues.filter(issue=>!isCheckoutFieldIssue(issue));return cart.find(issue=>issue.severity==="blocking")??cart[0]}function isCheckoutFieldIssue(issue){return issue.code==="checkout_field_required"||issue.code==="checkout_field_invalid"}function checkoutStatus(input){const{state}=input;if(input.busy){return"busy"}if(input.hydrated&&input.lines===0){return"empty"}if(!input.hydrated||input.auth==="unknown"){return"checking"}if(input.closed){return"closed"}if(input.needsAddress){return"address"}const quote=quoteOf(state);const issues=(state.status==="needs_attention"?state.issues:quote?.issues??[]).filter(issue=>!isCheckoutFieldIssue(issue));const fieldsOnly=quote!==void 0&"e.issues.some(isCheckoutFieldIssue);if(issues.some(issue=>issue.code==="delivery_region_required")){return"area"}if(input.needsTime){return"time"}if(issues.some(issue=>issue.severity==="blocking")||state.status==="needs_attention"&&issues.length>0||quote&&!fieldsOnly&&(!quote.canCheckout||quote.checkout.reason==="issues")){return"fix_issues"}if(input.signInRequired||quote?.checkout.reason==="customer_required"){return"sign_in"}if(input.contactField!==void 0){return input.contactField==="phone"?"phone":"contact"}if(state.status==="quoting"){return"quoting"}if(input.quoteFailed||state.status==="needs_attention"&&!quote){return"retry"}if(quote){return"pay"}return"quoting"}export{checkoutStatus,firstIssue,isCheckoutFieldIssue,payEnabled};
|
|
2
2
|
//# sourceMappingURL=status.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/checkout/status.ts"],
|
|
4
|
-
"mappings": "AAuDA,IAAM,QAAuC,IAAI,IAAI,CACnD,UACA,OACA,OACA,aACA,UACA,QACA,UACA,QACA,KACF,CAAC,EAGM,SAAS,WAAW,OAAiC,CAC1D,OAAO,QAAQ,IAAI,MAAM,CAC3B,CAEA,SAAS,QAAQ,MAAqC,CACpD,MAAO,UAAW,MAAQ,MAAM,MAAQ,MAC1C,CAGO,SAAS,WAAW,MAAyC,CAClE,MAAM,OACJ,MAAM,SAAW,kBACb,MAAM,OACL,QAAQ,KAAK,GAAG,QAAU,CAAC,EAClC,OAAO,OAAO,KAAM,OAAU,MAAM,WAAa,UAAU,GAAK,
|
|
4
|
+
"mappings": "AAuDA,IAAM,QAAuC,IAAI,IAAI,CACnD,UACA,OACA,OACA,aACA,UACA,QACA,UACA,QACA,KACF,CAAC,EAGM,SAAS,WAAW,OAAiC,CAC1D,OAAO,QAAQ,IAAI,MAAM,CAC3B,CAEA,SAAS,QAAQ,MAAqC,CACpD,MAAO,UAAW,MAAQ,MAAM,MAAQ,MAC1C,CAGO,SAAS,WAAW,MAAyC,CAClE,MAAM,OACJ,MAAM,SAAW,kBACb,MAAM,OACL,QAAQ,KAAK,GAAG,QAAU,CAAC,EAClC,MAAM,KAAO,OAAO,OAAQ,OAAU,CAAC,qBAAqB,KAAK,CAAC,EAClE,OAAO,KAAK,KAAM,OAAU,MAAM,WAAa,UAAU,GAAK,KAAK,CAAC,CACtE,CAGO,SAAS,qBAAqB,MAA2B,CAC9D,OACE,MAAM,OAA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import{CheckoutError,createCheckout}from"@zappie/sdk/checkout";import{defaultRegion,prefillFulfilment,rememberAddress,rememberedAddress,watchCheckoutDefaults}from"@zappie/sdk/checkout-defaults";import{createCustomer}from"@zappie/sdk/customer";import{holdPerks}from"@zappie/sdk/loyalty";import{usePendingNavigation}from"@zappie/sdk/navigation/react";import{useCart}from"@zappie/sdk/react";import{redirectToCheckout}from"@zappie/sdk/redirect";import{countEvent,currentSource}from"@zappie/sdk/visits";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{createCheckoutAttempt}from"./attempt.js";import{contactProblems,fullPhone}from"./contact.js";import{fieldSelector,issueSelector}from"./markers.js";import{checkoutOffers}from"./offers.js";import{cartIdentity,paymentNotice,payPath,takePaymentIntent}from"./pay-after-sign-in.js";import{signInOnce}from"./sign-in.js";import{checkoutStatus,firstIssue,payEnabled}from"./status.js";import{checkoutTiming}from"./timing.js";function readSession(key){try{return window.sessionStorage.getItem(key)}catch{return null}}function writeSession(key,value){try{window.sessionStorage.setItem(key,value)}catch{}}function removeSession(key){try{window.sessionStorage.removeItem(key)}catch{}}var aborted=failure=>failure instanceof Error&&failure.name==="AbortError";var NO_FIELDS=[];var LISTED_BY_DEFAULT=["delivery","pickup"];var accountOf=person=>person?{name:person.given_name,phone:person.phone_masked}:void 0;function useCheckoutFlow(options){const{branch,menu,contactFields=NO_FIELDS,reviewPath="/checkout",dialCode="+234",storageKey="zappie:checkout"}=options;const cart=useCart();const checkout=useMemo(()=>options.checkout??createCheckout(),[options.checkout]);const customer=useMemo(()=>options.customer??createCustomer(),[options.customer]);const owned=options.customer===void 0;const attempt=useMemo(()=>createCheckoutAttempt(),[]);const leaving=usePendingNavigation();const[auth,setAuth]=useState("unknown");const[who,setWho]=useState();const[account,setAccount]=useState();const[defaults,setDefaults]=useState();const[phone,setPhoneState]=useState("");const[values,setValues]=useState({});const[shown,setShown]=useState(new Set);const[error,setError]=useState();const[signInRequired,setSignInRequired]=useState(false);const[leavingFor,setLeavingFor]=useState();const[failedKey,setFailedKey]=useState();const[notice,setNotice]=useState();const[defaultsFor,setDefaultsFor]=useState();const payKey=`${storageKey}.pay`;const paying=useRef(void 0);const payRead=useRef(false);useEffect(()=>{if(!payRead.current){payRead.current=true;paying.current=takePaymentIntent(payKey)}},[payKey]);const listed=options.offers??LISTED_BY_DEFAULT;const listedKey=listed.join();const offers=useMemo(()=>{const taken=checkoutOffers(branch,menu);return listed.filter(type=>taken.includes(type))},[branch,menu,listedKey]);const branchId=cart.branchId??branch.id;const fulfilment=cart.fulfilment;const[chosen,setChosen]=useState();const initial=options.initialMode&&offers.includes(options.initialMode)?options.initialMode:offers[0]??"pickup";const mode=chosen??(fulfilment&&offers.includes(fulfilment.type)?fulfilment.type:initial);const[pendingAt,setPendingAt]=useState();const delivery=mode==="delivery"&&fulfilment?.type==="delivery"?fulfilment:void 0;const scheduledFor=mode==="dine_in"?void 0:(fulfilment&&fulfilment.type!=="dine_in"&&fulfilment.type===mode?fulfilment.scheduledFor:void 0)??pendingAt;const latest=useRef(delivery);latest.current=delivery;useEffect(()=>{const ownerKey=`${storageKey}.owner`;const owner=readSession(ownerKey);if(owner&&owner!==who){if(who!==void 0){for(const key of[ownerKey,`${storageKey}.phone`,`${storageKey}.contact`]){removeSession(key)}}setPhoneState("");setValues({});return}if(who){writeSession(ownerKey,who)}setPhoneState(readSession(`${storageKey}.phone`)??"");try{setValues(JSON.parse(readSession(`${storageKey}.contact`)??"{}"))}catch{setValues({})}},[storageKey,who]);const read=useRef({branch,fulfilment});read.current={branch,fulfilment};useEffect(()=>{const stopDefaults=watchCheckoutDefaults(customer,()=>read.current,next=>{setDefaults(next);setDefaultsFor(customer.state==="authenticated"?customer.customer?.id:customer.state==="anonymous"?null:void 0)});const stopAuth=customer.onChange((state,person)=>{setAuth(state);setAccount(state==="authenticated"?accountOf(person):void 0);setWho(state==="authenticated"?person?.id??void 0:state==="anonymous"?null:void 0)});void customer.session().then(current=>{setAuth(current?"authenticated":"anonymous");setAccount(accountOf(current));setWho(current?.id??null)},()=>{setAuth("anonymous");setAccount(void 0)});return()=>{stopDefaults();stopAuth();if(owned&&"dispose"in customer){customer.dispose()}}},[customer,owned]);useEffect(()=>{if(!cart.isHydrated||cart.lines.length===0||mode==="delivery"||fulfilment?.type===mode){return}cart.actions.setFulfilment(mode==="dine_in"?{type:"dine_in",branchId}:{type:"pickup",branchId,...pendingAt?{scheduledFor:pendingAt}:{}})},[branchId,cart.actions,cart.isHydrated,cart.lines.length,fulfilment?.type,mode,pendingAt]);const awaiting=useRef(false);const writeDelivery=useCallback((patch,at=scheduledFor)=>{const current=latest.current;const address=patch.address??current?.address;if(!address?.line1){return false}const regionId=defaultRegion(branch,patch.deliveryRegionId??current?.deliveryRegionId);const next={type:"delivery",branchId,address,...regionId?{deliveryRegionId:regionId}:{},...at?{scheduledFor:at}:{}};latest.current=next;awaiting.current=false;setChosen("delivery");cart.actions.setFulfilment(next);return true},[branch,branchId,cart.actions,scheduledFor]);const prefilled=useRef(void 0);useEffect(()=>{if(!cart.isHydrated||cart.lines.length===0){return}const filled=prefillFulfilment(fulfilment,branch);if(filled&&filled!==fulfilment){cart.actions.setFulfilment(filled);return}if(awaiting.current&&who!==void 0&&mode==="delivery"&&fulfilment?.type!=="delivery"){const known=rememberedAddress({customerId:who})??defaults?.address;if(known){writeDelivery({address:known})}return}const address=defaults?.address;if(mode==="delivery"&&!fulfilment&&address&&prefilled.current!==address){prefilled.current=address;writeDelivery({address})}},[branch,cart.actions,cart.isHydrated,cart.lines.length,defaults?.address,fulfilment,mode,who,writeDelivery]);const quoteKey=JSON.stringify([cart.lines,fulfilment,cart.promoCode]);const quoted=useRef("");useEffect(()=>{if(cart.isHydrated&&cart.lines.length>0&&cart.state.status==="ready"&"ed.current!==quoteKey){quoted.current=quoteKey;void cart.actions.quote().then(()=>{setFailedKey(void 0);setError(current=>current==="quote_failed"?void 0:current)},failure=>{if(!aborted(failure)){setFailedKey(quoteKey);setError("quote_failed")}})}},[cart.actions,cart.isHydrated,cart.lines.length,cart.state.status,quoteKey]);const timing=checkoutTiming(branch,menu,cart.lines,scheduledFor);const quote="quote"in cart.state?cart.state.quote:void 0;const heldQuote=isHeldQuote(quote);const unquotedTime=Boolean(scheduledFor)&&!quote?.fulfilment?.scheduledFor;const issues=useMemo(()=>timing.ahead?unquotedTime?cart.issues.filter(issue2=>!holdsForLater(issue2)):cart.issues:cart.issues.map(issue2=>holdsForLater(issue2)?{...issue2,fixes:issue2.fixes.filter(entry=>entry.action!=="schedule")}:issue2),[cart.issues,timing.ahead,unquotedTime]);const accountPhone=defaults?.phone.fromAccount?defaults.phone.display:void 0;const problems=contactProblems(contactFields,values,phone,accountPhone,dialCode);const contactField=Object.keys(problems)[0];const contactPhone=phone.trim()?fullPhone(phone,dialCode):"";const status=checkoutStatus({busy:leaving.pending,hydrated:cart.isHydrated,lines:cart.lines.length,auth,closed:timing.closed,needsAddress:mode==="delivery"&&!delivery?.address.line1,needsTime:mode!=="dine_in"&&timing.needsTime,state:cart.state,quoteFailed:failedKey===quoteKey,signInRequired,contactField});const shopper=()=>customer.state==="authenticated"?customer.customer?.id??void 0:customer.state==="anonymous"?null:void 0;const choose=type=>{setChosen(type);awaiting.current=false;if(type==="delivery"&&fulfilment?.type!=="delivery"){setPendingAt(scheduledFor);const owner=shopper();const known=(owner===void 0?void 0:rememberedAddress({customerId:owner}))??defaults?.address;if(known){writeDelivery({address:known},scheduledFor);return void 0}awaiting.current=true;return{step:"address"}}return void 0};const setDelivery=(change,{remember=true}={})=>{const base=change.address??latest.current?.address;if(!base?.line1){return{step:"address"}}const typed=change.note??change.address?.instructions??latest.current?.address.instructions;const{instructions:_old,...rest}=base;const note=typed?.trim();writeDelivery({address:note?{...rest,instructions:note}:rest,...change.regionId!==void 0?{deliveryRegionId:change.regionId}:{}});const owner=shopper();if(change.address&&remember&&owner!==void 0){rememberAddress(change.address,void 0,owner)}return void 0};const setAddress=(address,options2={})=>{setDelivery({address},options2)};const setRegion=regionId=>latest.current?setDelivery({regionId}):{step:"address"};const setNote=note=>latest.current?setDelivery({note}):{step:"address"};const schedule=at=>{setPendingAt(at??void 0);if(!fulfilment||fulfilment.type==="dine_in"||fulfilment.type!==mode){return}const{scheduledFor:_old,...rest}=fulfilment;cart.actions.setFulfilment(at?{...rest,scheduledFor:at}:rest)};const fix=(issue2,action)=>{setError(void 0);switch(action.action){case"change_address":return{step:"address"};case"choose_region":return{step:"area"};case"schedule":return{step:"time"};case"switch_fulfilment":{const next=action.types.find(type=>type!==mode&&offers.includes(type))??(mode==="delivery"?"pickup":"delivery");return choose(next)}case"choose_option":case"choose_other_option":{const line=cart.lines.find(entry=>entry.id===issue2.lineId);return line?{step:"item",itemId:line.itemId,lineId:line.id}:void 0}default:cart.actions.applyFix(cart.issues.find(entry=>entry.code===issue2.code&&entry.lineId===issue2.lineId&&entry.message===issue2.message)??issue2,action);return void 0}};const signIn=options.signIn??signInOnce;const leaveToSignIn=()=>{setLeavingFor("sign_in");if(quote){writeSession(payKey,JSON.stringify({at:Date.now(),cart:cartIdentity(branchId,cart.lines,cart.promoCode),total:quote.total}))}if(!signIn(payPath(reviewPath))){removeSession(payKey);leaving.end();setError("sign_in_failed")}};const redirect=options.redirect??(url=>redirectToCheckout(url,window.top??window));const attribution=options.attribution??currentSource;const openPayment=async()=>{setLeavingFor("payment");try{const prepared=attempt({payload:cart.actions.toCheckoutPayload(),branchId,contactPhone,returnUrl:`${location.origin}/checkout/return`,cancelUrl:`${location.origin}${reviewPath}`,attribution:attribution()});const session=await checkout.open(prepared.request,prepared.key);holdPerks(prepared.request.perk_redemption_ids,session);redirect(session.url)}catch(failure){if(failure instanceof CheckoutError&&failure.apiCode==="customer_required"){setSignInRequired(true);leaveToSignIn();return}leaving.end();setError("open_failed")}};const retry=async()=>{setFailedKey(void 0);try{await cart.actions.quote({force:true});setError(void 0)}catch(failure){if(!aborted(failure)){setFailedKey(quoteKey);setError("quote_failed")}}};const issue=status==="fix_issues"?firstIssue(cart.state):void 0;const activate=async()=>{setError(void 0);setNotice(void 0);switch(status){case"address":return{step:"address"};case"area":return{step:"area"};case"time":return{step:"time"};case"fix_issues":{const target=issue??issues[0];return target?{step:"issue",issue:target,target:issueSelector(target)}:void 0}case"phone":case"contact":setShown(current=>new Set([...current,...Object.keys(problems)]));return contactField?{step:"contact",field:contactField,target:fieldSelector(contactField)}:void 0;case"retry":await retry();return void 0;case"sign_in":countEvent("checkout");await leaving.start(leaveToSignIn);return void 0;case"pay":countEvent("checkout");await leaving.start(openPayment);return void 0;default:return void 0}};useEffect(()=>{const intent=paying.current;if(!intent||auth==="unknown"){return}if(auth==="authenticated"&&status!=="empty"&&(defaultsFor!==who||cart.state.status==="ready"||status==="checking"||status==="quoting"||status==="busy")){return}paying.current=void 0;if(auth==="anonymous"){return}const found=paymentNotice(intent,{cart:cartIdentity(branchId,cart.lines,cart.promoCode),total:quote?.total,status,issues});if(found){setNotice(found);return}countEvent("checkout");void leaving.start(openPayment)});return{mode,offers,choose,delivery,setDelivery,setAddress,setRegion,setNote,scheduledFor,schedule,timing,contact:{phone,contactPhone,setPhone:value=>{setPhoneState(value);writeSession(`${storageKey}.phone`,value)},accountPhone,fields:contactFields,values,setField:(key,value)=>{setValues(current=>{const next={...current,[key]:value};writeSession(`${storageKey}.contact`,JSON.stringify(next));return next})},problems,shown,show:key=>setShown(current=>current.has(key)?current:new Set([...current,key]))},auth,account,quote,pricing:cart.state.status==="quoting",held:heldQuote?timing.ahead?"time":"opening":void 0,issues,fix,error,clearError:()=>setError(void 0),notice,clearNotice:()=>setNotice(void 0),pay:{status,enabled:payEnabled(status),leavingFor:status==="busy"?leavingFor:void 0,issue,field:status==="phone"||status==="contact"?contactField:void 0,activate}}}export{useCheckoutFlow};
|
|
1
|
+
"use client";import{holdsForLater,isHeldQuote}from"@zappie/sdk";import{CheckoutError,createCheckout}from"@zappie/sdk/checkout";import{defaultRegion,prefillFulfilment,rememberAddress,rememberedAddress,watchCheckoutDefaults}from"@zappie/sdk/checkout-defaults";import{createCustomer}from"@zappie/sdk/customer";import{holdPerks}from"@zappie/sdk/loyalty";import{usePendingNavigation}from"@zappie/sdk/navigation/react";import{useCart}from"@zappie/sdk/react";import{redirectToCheckout}from"@zappie/sdk/redirect";import{countEvent,currentSource}from"@zappie/sdk/visits";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{createCheckoutAttempt}from"./attempt.js";import{businessContactFields,checkoutCustomer,contactProblems,fullPhone,recipientProblems}from"./contact.js";import{fieldSelector,issueSelector}from"./markers.js";import{checkoutOffers}from"./offers.js";import{cartIdentity,paymentNotice,payPath,takePaymentIntent}from"./pay-after-sign-in.js";import{signInOnce}from"./sign-in.js";import{checkoutStatus,firstIssue,isCheckoutFieldIssue,payEnabled}from"./status.js";import{checkoutTiming}from"./timing.js";function readSession(key){try{return window.sessionStorage.getItem(key)}catch{return null}}function writeSession(key,value){try{window.sessionStorage.setItem(key,value)}catch{}}function removeSession(key){try{window.sessionStorage.removeItem(key)}catch{}}var aborted=failure=>failure instanceof Error&&failure.name==="AbortError";var NO_FIELDS=[];var NO_VALUES={};var NO_RECIPIENT={on:false,name:"",phone:""};function profileValues(me){const values={};for(const[key,value]of[["given_name",me.given_name],["family_name",me.family_name],["email",me.email]]){if(value?.trim()){values[key]=value.trim()}}return values}var LISTED_BY_DEFAULT=["delivery","pickup"];var accountOf=person=>person?{name:person.given_name,phone:person.phone_masked}:void 0;function useCheckoutFlow(options){const{branch,menu,contactFields:givenFields=NO_FIELDS,reviewPath="/checkout",dialCode="+234",storageKey="zappie:checkout"}=options;const cart=useCart();const checkout=useMemo(()=>options.checkout??createCheckout(),[options.checkout]);const customer=useMemo(()=>options.customer??createCustomer(),[options.customer]);const owned=options.customer===void 0;const attempt=useMemo(()=>createCheckoutAttempt(),[]);const leaving=usePendingNavigation();const[auth,setAuth]=useState("unknown");const[who,setWho]=useState();const[account,setAccount]=useState();const[profile,setProfile]=useState();const[defaults,setDefaults]=useState();const[phone,setPhoneState]=useState("");const[values,setValues]=useState({});const[recipient,setRecipient]=useState(NO_RECIPIENT);const[shown,setShown]=useState(new Set);const[error,setError]=useState();const[signInRequired,setSignInRequired]=useState(false);const[leavingFor,setLeavingFor]=useState();const[failedKey,setFailedKey]=useState();const[notice,setNotice]=useState();const[defaultsFor,setDefaultsFor]=useState();const payKey=`${storageKey}.pay`;const paying=useRef(void 0);const payRead=useRef(false);useEffect(()=>{if(!payRead.current){payRead.current=true;paying.current=takePaymentIntent(payKey)}},[payKey]);const listed=options.offers??LISTED_BY_DEFAULT;const listedKey=listed.join();const offers=useMemo(()=>{const taken=checkoutOffers(branch,menu);return listed.filter(type=>taken.includes(type))},[branch,menu,listedKey]);const branchId=cart.branchId??branch.id;const fulfilment=cart.fulfilment;const[chosen,setChosen]=useState();const initial=options.initialMode&&offers.includes(options.initialMode)?options.initialMode:offers[0]??"pickup";const mode=chosen??(fulfilment&&offers.includes(fulfilment.type)?fulfilment.type:initial);const asking=options.checkoutFields!==void 0;const storeFieldsKey=asking?JSON.stringify(options.checkoutFields):"";const asked=useMemo(()=>asking?businessContactFields(options.checkoutFields,branchId,mode):givenFields,[asking,storeFieldsKey,branchId,mode,givenFields]);const holds=profile&&profile.of===who?profile.values:NO_VALUES;const held=asked.flatMap(field=>holds[field.key]?[{key:field.key,label:field.label,value:holds[field.key]}]:[]);const heldKey=held.map(entry=>entry.key).join();const contactFields=useMemo(()=>asked.filter(field=>!heldKey.split(",").includes(field.key)),[asked,heldKey]);const[pendingAt,setPendingAt]=useState();const delivery=mode==="delivery"&&fulfilment?.type==="delivery"?fulfilment:void 0;const scheduledFor=mode==="dine_in"?void 0:(fulfilment&&fulfilment.type!=="dine_in"&&fulfilment.type===mode?fulfilment.scheduledFor:void 0)??pendingAt;const latest=useRef(delivery);latest.current=delivery;useEffect(()=>{const ownerKey=`${storageKey}.owner`;const owner=readSession(ownerKey);if(owner&&owner!==who){if(who!==void 0){for(const key of[ownerKey,`${storageKey}.phone`,`${storageKey}.contact`,`${storageKey}.recipient`]){removeSession(key)}}setPhoneState("");setValues({});setRecipient(NO_RECIPIENT);return}if(who){writeSession(ownerKey,who)}setPhoneState(readSession(`${storageKey}.phone`)??"");try{setValues(JSON.parse(readSession(`${storageKey}.contact`)??"{}"))}catch{setValues({})}try{setRecipient({...NO_RECIPIENT,...JSON.parse(readSession(`${storageKey}.recipient`)??"{}")})}catch{setRecipient(NO_RECIPIENT)}},[storageKey,who]);const read=useRef({branch,fulfilment});read.current={branch,fulfilment};useEffect(()=>{const stopDefaults=watchCheckoutDefaults(customer,()=>read.current,next=>{setDefaults(next);setDefaultsFor(customer.state==="authenticated"?customer.customer?.id:customer.state==="anonymous"?null:void 0)});const stopAuth=customer.onChange((state,person)=>{setAuth(state);setAccount(state==="authenticated"?accountOf(person):void 0);setWho(state==="authenticated"?person?.id??void 0:state==="anonymous"?null:void 0)});void customer.session().then(current=>{setAuth(current?"authenticated":"anonymous");setAccount(accountOf(current));setWho(current?.id??null)},()=>{setAuth("anonymous");setAccount(void 0)});return()=>{stopDefaults();stopAuth();if(owned&&"dispose"in customer){customer.dispose()}}},[customer,owned]);const asksAny=asking&&asked.length>0;useEffect(()=>{if(!asksAny||!who){return}let current=true;customer.profile().then(me=>{if(current){setProfile({of:who,values:profileValues(me)})}},()=>void 0);return()=>{current=false}},[asksAny,who,customer]);useEffect(()=>{if(!cart.isHydrated||cart.lines.length===0||mode==="delivery"||fulfilment?.type===mode){return}cart.actions.setFulfilment(mode==="dine_in"?{type:"dine_in",branchId}:{type:"pickup",branchId,...pendingAt?{scheduledFor:pendingAt}:{}})},[branchId,cart.actions,cart.isHydrated,cart.lines.length,fulfilment?.type,mode,pendingAt]);const awaiting=useRef(false);const writeDelivery=useCallback((patch,at=scheduledFor)=>{const current=latest.current;const address=patch.address??current?.address;if(!address?.line1){return false}const regionId=defaultRegion(branch,patch.deliveryRegionId??current?.deliveryRegionId);const next={type:"delivery",branchId,address,...regionId?{deliveryRegionId:regionId}:{},...at?{scheduledFor:at}:{}};latest.current=next;awaiting.current=false;setChosen("delivery");cart.actions.setFulfilment(next);return true},[branch,branchId,cart.actions,scheduledFor]);const prefilled=useRef(void 0);useEffect(()=>{if(!cart.isHydrated||cart.lines.length===0){return}const filled=prefillFulfilment(fulfilment,branch);if(filled&&filled!==fulfilment){cart.actions.setFulfilment(filled);return}if(awaiting.current&&who!==void 0&&mode==="delivery"&&fulfilment?.type!=="delivery"){const known=rememberedAddress({customerId:who})??defaults?.address;if(known){writeDelivery({address:known})}return}const address=defaults?.address;if(mode==="delivery"&&!fulfilment&&address&&prefilled.current!==address){prefilled.current=address;writeDelivery({address})}},[branch,cart.actions,cart.isHydrated,cart.lines.length,defaults?.address,fulfilment,mode,who,writeDelivery]);const quoteKey=JSON.stringify([cart.lines,fulfilment,cart.promoCode]);const quoted=useRef("");useEffect(()=>{if(cart.isHydrated&&cart.lines.length>0&&cart.state.status==="ready"&"ed.current!==quoteKey){quoted.current=quoteKey;void cart.actions.quote().then(()=>{setFailedKey(void 0);setError(current=>current==="quote_failed"?void 0:current)},failure=>{if(!aborted(failure)){setFailedKey(quoteKey);setError("quote_failed")}})}},[cart.actions,cart.isHydrated,cart.lines.length,cart.state.status,quoteKey]);const timing=checkoutTiming(branch,menu,cart.lines,scheduledFor);const quote="quote"in cart.state?cart.state.quote:void 0;const heldQuote=isHeldQuote(quote);const unquotedTime=Boolean(scheduledFor)&&!quote?.fulfilment?.scheduledFor;const issues=useMemo(()=>{const cartIssues=cart.issues.filter(issue2=>!isCheckoutFieldIssue(issue2));return timing.ahead?unquotedTime?cartIssues.filter(issue2=>!holdsForLater(issue2)):cartIssues:cartIssues.map(issue2=>holdsForLater(issue2)?{...issue2,fixes:issue2.fixes.filter(entry=>entry.action!=="schedule")}:issue2)},[cart.issues,timing.ahead,unquotedTime]);const accountPhone=defaults?.phone.fromAccount?defaults.phone.display:void 0;const forOther=mode!=="dine_in"&&recipient.on;const problems=contactProblems(contactFields,values,phone,accountPhone,dialCode);if(forOther){delete problems.phone;Object.assign(problems,recipientProblems(recipient,dialCode))}const quotedField=cart.issues.map(issue2=>isCheckoutFieldIssue(issue2)?issue2.data?.field:void 0).find(field=>typeof field==="string");const contactField=Object.keys(problems)[0]??quotedField;const sending=asking?checkoutCustomer(contactFields,values):null;const sendingKey=JSON.stringify(sending);useEffect(()=>{if(asking){cart.actions.setCustomer(sending)}},[asking,sendingKey,cart.actions]);const contactPhone=forOther?fullPhone(recipient.phone,dialCode):phone.trim()?fullPhone(phone,dialCode):"";const status=checkoutStatus({busy:leaving.pending,hydrated:cart.isHydrated,lines:cart.lines.length,auth,closed:timing.closed,needsAddress:mode==="delivery"&&!delivery?.address.line1,needsTime:mode!=="dine_in"&&timing.needsTime,state:cart.state,quoteFailed:failedKey===quoteKey,signInRequired,contactField});const shopper=()=>customer.state==="authenticated"?customer.customer?.id??void 0:customer.state==="anonymous"?null:void 0;const choose=type=>{setChosen(type);awaiting.current=false;if(type==="delivery"&&fulfilment?.type!=="delivery"){setPendingAt(scheduledFor);const owner=shopper();const known=(owner===void 0?void 0:rememberedAddress({customerId:owner}))??defaults?.address;if(known){writeDelivery({address:known},scheduledFor);return void 0}awaiting.current=true;return{step:"address"}}return void 0};const setDelivery=(change,{remember=true}={})=>{const base=change.address??latest.current?.address;if(!base?.line1){return{step:"address"}}const typed=change.note??change.address?.instructions??latest.current?.address.instructions;const{instructions:_old,...rest}=base;const note=typed?.trim();writeDelivery({address:note?{...rest,instructions:note}:rest,...change.regionId!==void 0?{deliveryRegionId:change.regionId}:{}});const owner=shopper();if(change.address&&remember&&owner!==void 0){rememberAddress(change.address,void 0,owner)}return void 0};const setAddress=(address,options2={})=>{setDelivery({address},options2)};const setRegion=regionId=>latest.current?setDelivery({regionId}):{step:"address"};const setNote=note=>latest.current?setDelivery({note}):{step:"address"};const schedule=at=>{setPendingAt(at??void 0);if(!fulfilment||fulfilment.type==="dine_in"||fulfilment.type!==mode){return}const{scheduledFor:_old,...rest}=fulfilment;cart.actions.setFulfilment(at?{...rest,scheduledFor:at}:rest)};const fix=(issue2,action)=>{setError(void 0);switch(action.action){case"change_address":return{step:"address"};case"choose_region":return{step:"area"};case"schedule":return{step:"time"};case"switch_fulfilment":{const next=action.types.find(type=>type!==mode&&offers.includes(type))??(mode==="delivery"?"pickup":"delivery");return choose(next)}case"choose_option":case"choose_other_option":{const line=cart.lines.find(entry=>entry.id===issue2.lineId);return line?{step:"item",itemId:line.itemId,lineId:line.id}:void 0}default:cart.actions.applyFix(cart.issues.find(entry=>entry.code===issue2.code&&entry.lineId===issue2.lineId&&entry.message===issue2.message)??issue2,action);return void 0}};const signIn=options.signIn??signInOnce;const leaveToSignIn=()=>{setLeavingFor("sign_in");if(quote){writeSession(payKey,JSON.stringify({at:Date.now(),cart:cartIdentity(branchId,cart.lines,cart.promoCode),total:quote.total}))}if(!signIn(payPath(reviewPath))){removeSession(payKey);leaving.end();setError("sign_in_failed")}};const keepRecipient=change=>setRecipient(current=>{const next={...current,...change};writeSession(`${storageKey}.recipient`,JSON.stringify(next));return next});const redirect=options.redirect??(url=>redirectToCheckout(url,window.top??window));const attribution=options.attribution??currentSource;const openPayment=async()=>{setLeavingFor("payment");try{const prepared=attempt({payload:cart.actions.toCheckoutPayload(),branchId,contactPhone,contactName:forOther?recipient.name:"",returnUrl:`${location.origin}/checkout/return`,cancelUrl:`${location.origin}${reviewPath}`,attribution:attribution()});const session=await checkout.open(prepared.request,prepared.key);holdPerks(prepared.request.perk_redemption_ids,session);redirect(session.url)}catch(failure){if(failure instanceof CheckoutError&&failure.apiCode==="customer_required"){setSignInRequired(true);leaveToSignIn();return}leaving.end();if(failure instanceof CheckoutError&&failure.apiCode==="quote_issues"&&failure.param?.startsWith("customer.")){const key=failure.param.slice("customer.".length);setShown(current=>new Set([...current,key]));void cart.actions.quote({force:true}).catch(()=>void 0);return}setError("open_failed")}};const retry=async()=>{setFailedKey(void 0);try{await cart.actions.quote({force:true});setError(void 0)}catch(failure){if(!aborted(failure)){setFailedKey(quoteKey);setError("quote_failed")}}};const issue=status==="fix_issues"?firstIssue(cart.state):void 0;const activate=async()=>{setError(void 0);setNotice(void 0);switch(status){case"address":return{step:"address"};case"area":return{step:"area"};case"time":return{step:"time"};case"fix_issues":{const target=issue??issues[0];return target?{step:"issue",issue:target,target:issueSelector(target)}:void 0}case"phone":case"contact":setShown(current=>new Set([...current,...Object.keys(problems)]));return contactField?{step:"contact",field:contactField,target:fieldSelector(contactField)}:void 0;case"retry":await retry();return void 0;case"sign_in":countEvent("checkout");await leaving.start(leaveToSignIn);return void 0;case"pay":countEvent("checkout");await leaving.start(openPayment);return void 0;default:return void 0}};useEffect(()=>{const intent=paying.current;if(!intent||auth==="unknown"){return}if(auth==="authenticated"&&status!=="empty"&&(defaultsFor!==who||cart.state.status==="ready"||status==="checking"||status==="quoting"||status==="busy")){return}paying.current=void 0;if(auth==="anonymous"){return}const found=paymentNotice(intent,{cart:cartIdentity(branchId,cart.lines,cart.promoCode),total:quote?.total,status,issues});if(found){setNotice(found);return}countEvent("checkout");void leaving.start(openPayment)});return{mode,offers,choose,delivery,setDelivery,setAddress,setRegion,setNote,scheduledFor,schedule,timing,contact:{phone,contactPhone,setPhone:value=>{setPhoneState(value);writeSession(`${storageKey}.phone`,value)},accountPhone,fields:contactFields,held,values,setField:(key,value)=>{setValues(current=>{const next={...current,[key]:value};writeSession(`${storageKey}.contact`,JSON.stringify(next));return next})},recipient:mode==="dine_in"?void 0:{label:mode==="pickup"?"Collected by":"Deliver to",...recipient,setOn:on=>keepRecipient({on}),setName:name=>keepRecipient({name}),setPhone:value=>keepRecipient({phone:value})},problems,shown,show:key=>setShown(current=>current.has(key)?current:new Set([...current,key]))},auth,account,quote,pricing:cart.state.status==="quoting",held:heldQuote?timing.ahead?"time":"opening":void 0,issues,fix,error,clearError:()=>setError(void 0),notice,clearNotice:()=>setNotice(void 0),pay:{status,enabled:payEnabled(status),leavingFor:status==="busy"?leavingFor:void 0,issue,field:status==="phone"||status==="contact"?contactField:void 0,activate}}}export{useCheckoutFlow};
|
|
2
2
|
//# sourceMappingURL=use-checkout-flow.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/checkout/use-checkout-flow.ts"],
|
|
4
|
-
"mappings": "aACA,OACE,cACA,gBAQK,cACP,OACE,cACA,mBAEK,uBACP,OACE,cACA,kBACA,gBACA,kBACA,0BAEK,gCACP,OAAS,mBAA2C,uBACpD,OAAS,cAAiB,sBAC1B,OAAS,yBAA4B,+BACrC,OAAS,YAAe,oBACxB,OAAS,uBAA0B,uBACnC,OAAS,WAAY,kBAAqB,qBAC1C,OAAS,YAAa,UAAW,QAAS,OAAQ,aAAgB,QAClE,OAAS,0BAA6B,eACtC,OACE,gBACA,cAIK,eACP,OAAS,cAAe,kBAAqB,eAC7C,OAAS,mBAAyC,cAClD,OACE,aACA,cACA,QACA,sBAGK,yBACP,OAAS,eAAkB,eAC3B,OACE,eACA,WACA,eAGK,cACP,OAAS,mBAA2C,cAsMpD,SAAS,YAAY,IAAa,CAChC,GAAI,CACF,OAAO,OAAO,eAAe,QAAQ,GAAG,CAC1C,MAAQ,CACN,OAAO,IACT,CACF,CAEA,SAAS,aAAa,IAAa,MAAe,CAChD,GAAI,CACF,OAAO,eAAe,QAAQ,IAAK,KAAK,CAC1C,MAAQ,CAER,CACF,CAEA,SAAS,cAAc,IAAa,CAClC,GAAI,CACF,OAAO,eAAe,WAAW,GAAG,CACtC,MAAQ,CAER,CACF,CAEA,IAAM,QAAW,SACf,mBAAmB,OAAS,QAAQ,OAAS,aAE/C,IAAM,UAAqC,CAAC,EAE5C,IAAM,kBAA6C,CAAC,WAAY,QAAQ,EAExE,IAAM,UACJ,QAEA,OAAS,CAAE,KAAM,OAAO,WAAY,MAAO,OAAO,YAAa,EAAI,OAkB9D,SAAS,gBAAgB,QAA4C,CAC1E,KAAM,CACJ,OACA,KACA,cAAgB,UAChB,WAAa,YACb,SAAW,OACX,WAAa,iBACf,EAAI,QACJ,MAAM,KAA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,CACxD,CACJ,EACA,KACA,QACA,MACA,QAAS,KAAK,MAAM,SAAW,UAC/B,KAAM,UAAa,OAAO,MAAQ,OAAS,UAAa,OACxD,OACA,IACA,MACA,WAAY,IAAM,SAAS,MAAS,EACpC,OACA,YAAa,IAAM,UAAU,MAAS,EACtC,IAAK,CACH,OACA,QAAS,WAAW,MAAM,EAC1B,WAAY,SAAW,OAAS,WAAa,OAC7C,MACA,MACE,SAAW,SAAW,SAAW,UAAY,aAAe,OAC9D,QACF,CACF,CACF",
|
|
5
5
|
"names": ["issue", "options"]
|
|
6
6
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -692,10 +692,15 @@ type ChoiceState = {
|
|
|
692
692
|
setQuantity: (quantity: number) => void;
|
|
693
693
|
};
|
|
694
694
|
/**
|
|
695
|
-
* Render a selectable option within an OptionGroup
|
|
696
|
-
*
|
|
697
|
-
*
|
|
698
|
-
*
|
|
695
|
+
* Render a selectable option within an OptionGroup as a `<label>` around a
|
|
696
|
+
* native `<input>`: radios for a required group of exactly one, checkboxes for
|
|
697
|
+
* every other group. The input comes first, so the browser draws a round radio
|
|
698
|
+
* or a square checkbox unless the template restyles it. Style the label through
|
|
699
|
+
* its data attributes and the input through `[data-zappie-choice-input]`.
|
|
700
|
+
* Unavailable choices are disabled, and so is a choice given `disabled`, which
|
|
701
|
+
* goes to the input. While the group is at its limit, unchosen
|
|
702
|
+
* choices are aria-disabled and data-limit-reached but stay focusable. Put
|
|
703
|
+
* quantity steppers beside the Choice, not inside it.
|
|
699
704
|
*/
|
|
700
705
|
declare const Choice: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
701
706
|
asChild?: boolean;
|
|
@@ -905,6 +910,8 @@ type PaymentState = {
|
|
|
905
910
|
methods: PaymentMethod[];
|
|
906
911
|
value: PaymentMethodKind | null;
|
|
907
912
|
setValue: (value: PaymentMethodKind) => void;
|
|
913
|
+
/** The name the methods' native radios share. */
|
|
914
|
+
name: string;
|
|
908
915
|
};
|
|
909
916
|
declare function Root$1({ methods, value, defaultValue, onValueChange, ...props }: PartProps<PaymentState> & {
|
|
910
917
|
methods: (PaymentMethod | PaymentMethodKind)[];
|
|
@@ -913,8 +920,11 @@ declare function Root$1({ methods, value, defaultValue, onValueChange, ...props
|
|
|
913
920
|
onValueChange?: (value: PaymentMethodKind | null) => void;
|
|
914
921
|
}): react.JSX.Element;
|
|
915
922
|
/**
|
|
916
|
-
* Composable payment-method
|
|
917
|
-
* Root manages the selection. Item renders each method
|
|
923
|
+
* Composable payment-method radios.
|
|
924
|
+
* Root manages the selection and is a radiogroup. Item renders each method as a
|
|
925
|
+
* `<label>` around a native radio, which the browser draws round unless the
|
|
926
|
+
* template restyles it through `[data-zappie-choice-input]`. A disabled method
|
|
927
|
+
* can't be selected.
|
|
918
928
|
*/
|
|
919
929
|
declare const PaymentMethods: {
|
|
920
930
|
Root: typeof Root$1;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Children,cloneElement,Fragment,isValidElement}from"react";import{part}from"./slot.js";import{jsxs}from"react/jsx-runtime";function labelledControl(props,state,defaults,control,ref){const{asChild,children,...dom}=props;const content=typeof children==="function"?children(state):children;if(asChild){const child=Children.only(content);if(!isValidElement(child)){throw new Error("asChild requires one React element")}return part("label",{...dom,asChild:true,children:cloneElement(child,void 0,control,child.props.children)},state,defaults,ref)}return part("label",{...dom,children:jsxs(Fragment,{children:[control,content]})},state,defaults,ref)}export{labelledControl};
|
|
2
|
+
//# sourceMappingURL=labelled-control.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/internal/labelled-control.tsx"],
|
|
4
|
+
"mappings": "AAAA,OACE,SACA,aACA,SACA,mBAIK,QACP,OAAS,SAA4B,YA0C7B,oCApCD,SAAS,gBACd,MACA,MACA,SACA,QACA,IACA,CACA,KAAM,CAAE,QAAS,SAAU,GAAG,GAAI,EAAI,MACtC,MAAM,QAAU,OAAO,WAAa,WAAa,SAAS,KAAK,EAAI,SACnE,GAAI,QAAS,CACX,MAAM,MAAQ,SAAS,KAAK,OAAO,EACnC,GAAI,CAAC,eAAyC,KAAK,EAAG,CACpD,MAAM,IAAI,MAAM,oCAAoC,CACtD,CACA,OAAO,KACL,QACA,CACE,GAAG,IACH,QAAS,KACT,SAAU,aACR,MACA,OACA,QACA,MAAM,MAAM,QACd,CACF,EACA,MACA,SACA,GACF,CACF,CACA,OAAO,KACL,QACA,CACE,GAAG,IACH,SACE,KAAC,UACE,kBACA,SACH,CAEJ,EACA,MACA,SACA,GACF,CACF",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{canChoose,choiceQuantityMax,atLimit as groupAtLimit,groupRoom,LIMIT_REACHED_HINT,selectionControl,selectionCount}from"@zappie/sdk/options";import{cloneElement,createContext,forwardRef,Fragment,isValidElement,memo,useContext,useMemo,useRef}from"react";import{flag}from"../internal/data-attrs.js";import{usePartId}from"../internal/ids.js";import{composeRefs,part}from"../internal/slot.js";import{GroupRegistry,useItemForm}from"./root.js";import{jsx,jsxs}from"react/jsx-runtime";var Context=/*@__PURE__ */createContext(null);function useGroup(){const value=useContext(Context);if(!value){throw new Error("Choice and OptionGroup.Input require OptionGroup")}return value}var Group=/*@__PURE__ */forwardRef(function OptionGroup({group:supplied,requiredNote="Required",limitHint:hintText,"aria-describedby":describedBy,children,...props},ref){const ctx=useItemForm();const registry=useContext(GroupRegistry);const group=ctx.groups.find(candidate=>candidate.id===supplied.id)??supplied;const mine=ctx.value.choices?.filter(choice=>choice.groupId===group.id)??[];const selected=mine.map(choice=>choice.choiceId);const quantities=Object.fromEntries(mine.map(choice=>[choice.choiceId,choice.quantity??1]));const invalid=ctx.issues.some(issue=>issue.groupId===group.id);const input=ctx.value.inputs?.[group.id]??"";const latest=useRef({ctx,group});latest.current={ctx,group};const actions=useMemo(()=>{const write=(id,quantity)=>{const{ctx:ctx2,group:group2}=latest.current;const previous=ctx2.value.choices??[];const isThis=candidate=>candidate.groupId===group2.id&&candidate.choiceId===id;const choice=group2.choices.find(candidate=>candidate.id===id);if(!choice||!Number.isInteger(quantity)||quantity>0&&!canChoose(group2,previous,id)){return}const choices=previous.filter(candidate=>!isThis(candidate)&&(quantity<=0||candidate.groupId!==group2.id||group2.selection.max!==1));if(quantity>0){choices.push({groupId:group2.id,choiceId:id,quantity:Math.max(choice.quantity?.min??1,Math.min(choiceQuantityMax(group2,previous,id),quantity))})}const inputs={...ctx2.value.inputs};delete inputs[group2.id];ctx2.setValue({...ctx2.value,choices,inputs})};return{toggle:id=>{const{ctx:ctx2,group:group2}=latest.current;const chosen=ctx2.value.choices?.some(candidate=>candidate.groupId===group2.id&&candidate.choiceId===id);if(!chosen||selectionControl(group2)!=="radio"){write(id,chosen?0:group2.choices.find(candidate=>candidate.id===id)?.quantity?.min??1)}},setQuantity:write,setInput:value=>{const{ctx:ctx2,group:group2}=latest.current;ctx2.setValue({...ctx2.value,choices:(ctx2.value.choices??[]).filter(choice=>choice.groupId!==group2.id),inputs:{...ctx2.value.inputs,[group2.id]:value.slice(0,group2.input?.maxLength??500)}})}}},[]);const selectionKey=JSON.stringify(quantities);const control=selectionControl(group);const count=selectionCount(group,mine);const full=group.kind==="select"&&groupAtLimit(group,mine);const heldBack=full&&group.choices.some(choice=>choice.isAvailable&&!selected.includes(choice.id));const text=heldBack&&(hintText||LIMIT_REACHED_HINT)||void 0;const limitHint=hintText===false?void 0:text;const hintId=usePartId();const state=useMemo(()=>({group,selected,quantities,invalid,input,control,count,room:groupRoom(group,mine),atLimit:full,limitHint:text,hintId:limitHint&&hintId,mine,...actions}),[group,selectionKey,invalid,input,hintText,hintId,actions]);const radio=group.kind==="select"&&control==="radio";const noteId=usePartId();const note=group.required&&group.kind==="select"&&!radio&&requiredNote;const content=typeof children==="function"?children(state):children;const child=props.asChild&&isValidElement(content)?content:void 0;const own=describedBy??child?.props["aria-describedby"];const description=[note&¬eId,limitHint&&hintId,own].filter(Boolean).join(" ")||void 0;const hint=limitHint?jsx("p",{id:hintId,role:"status","data-zappie-limit-hint":"",children:limitHint}):null;return jsxs(Context.Provider,{value:state,children:[note&&jsx("span",{id:noteId,hidden:true,children:note}),part("div",child?{...props,children:cloneElement(child,{"aria-describedby":description},child.props.children,hint)}:{...props,children:jsxs(Fragment,{children:[content,hint]})},state,{role:radio?"radiogroup":"group",tabIndex:-1,"aria-label":group.name,"aria-required":radio?group.required:void 0,"aria-describedby":description,"data-zappie-required":group.required?"true":void 0,"aria-invalid":invalid||void 0,"data-invalid":flag(invalid),"data-state":invalid?"invalid":"valid","data-limit-reached":flag(full),"data-zappie-option-group":group.id
|
|
1
|
+
"use client";import{canChoose,choiceQuantityMax,atLimit as groupAtLimit,groupRoom,LIMIT_REACHED_HINT,selectionControl,selectionCount}from"@zappie/sdk/options";import{cloneElement,createContext,forwardRef,Fragment,isValidElement,memo,useContext,useMemo,useRef}from"react";import{flag}from"../internal/data-attrs.js";import{usePartId}from"../internal/ids.js";import{labelledControl}from"../internal/labelled-control.js";import{composeRefs,part}from"../internal/slot.js";import{GroupRegistry,useItemForm}from"./root.js";import{jsx,jsxs}from"react/jsx-runtime";var Context=/*@__PURE__ */createContext(null);function useGroup(){const value=useContext(Context);if(!value){throw new Error("Choice and OptionGroup.Input require OptionGroup")}return value}var Group=/*@__PURE__ */forwardRef(function OptionGroup({group:supplied,requiredNote="Required",limitHint:hintText,"aria-describedby":describedBy,children,...props},ref){const ctx=useItemForm();const registry=useContext(GroupRegistry);const group=ctx.groups.find(candidate=>candidate.id===supplied.id)??supplied;const mine=ctx.value.choices?.filter(choice=>choice.groupId===group.id)??[];const selected=mine.map(choice=>choice.choiceId);const quantities=Object.fromEntries(mine.map(choice=>[choice.choiceId,choice.quantity??1]));const invalid=ctx.issues.some(issue=>issue.groupId===group.id);const input=ctx.value.inputs?.[group.id]??"";const latest=useRef({ctx,group});latest.current={ctx,group};const actions=useMemo(()=>{const write=(id,quantity)=>{const{ctx:ctx2,group:group2}=latest.current;const previous=ctx2.value.choices??[];const isThis=candidate=>candidate.groupId===group2.id&&candidate.choiceId===id;const choice=group2.choices.find(candidate=>candidate.id===id);if(!choice||!Number.isInteger(quantity)||quantity>0&&!canChoose(group2,previous,id)){return}const choices=previous.filter(candidate=>!isThis(candidate)&&(quantity<=0||candidate.groupId!==group2.id||group2.selection.max!==1));if(quantity>0){choices.push({groupId:group2.id,choiceId:id,quantity:Math.max(choice.quantity?.min??1,Math.min(choiceQuantityMax(group2,previous,id),quantity))})}const inputs={...ctx2.value.inputs};delete inputs[group2.id];ctx2.setValue({...ctx2.value,choices,inputs})};return{toggle:id=>{const{ctx:ctx2,group:group2}=latest.current;const chosen=ctx2.value.choices?.some(candidate=>candidate.groupId===group2.id&&candidate.choiceId===id);if(!chosen||selectionControl(group2)!=="radio"){write(id,chosen?0:group2.choices.find(candidate=>candidate.id===id)?.quantity?.min??1)}},setQuantity:write,setInput:value=>{const{ctx:ctx2,group:group2}=latest.current;ctx2.setValue({...ctx2.value,choices:(ctx2.value.choices??[]).filter(choice=>choice.groupId!==group2.id),inputs:{...ctx2.value.inputs,[group2.id]:value.slice(0,group2.input?.maxLength??500)}})}}},[]);const selectionKey=JSON.stringify(quantities);const control=selectionControl(group);const count=selectionCount(group,mine);const full=group.kind==="select"&&groupAtLimit(group,mine);const heldBack=full&&group.choices.some(choice=>choice.isAvailable&&!selected.includes(choice.id));const text=heldBack&&(hintText||LIMIT_REACHED_HINT)||void 0;const limitHint=hintText===false?void 0:text;const hintId=usePartId();const name=usePartId();const state=useMemo(()=>({group,selected,quantities,invalid,input,control,count,room:groupRoom(group,mine),atLimit:full,limitHint:text,hintId:limitHint&&hintId,mine,name,...actions}),[group,selectionKey,invalid,input,hintText,hintId,name,actions]);const radio=group.kind==="select"&&control==="radio";const noteId=usePartId();const note=group.required&&group.kind==="select"&&!radio&&requiredNote;const content=typeof children==="function"?children(state):children;const child=props.asChild&&isValidElement(content)?content:void 0;const own=describedBy??child?.props["aria-describedby"];const description=[note&¬eId,limitHint&&hintId,own].filter(Boolean).join(" ")||void 0;const hint=limitHint?jsx("p",{id:hintId,role:"status","data-zappie-limit-hint":"",children:limitHint}):null;return jsxs(Context.Provider,{value:state,children:[note&&jsx("span",{id:noteId,hidden:true,children:note}),part("div",child?{...props,children:cloneElement(child,{"aria-describedby":description},child.props.children,hint)}:{...props,children:jsxs(Fragment,{children:[content,hint]})},state,{role:radio?"radiogroup":"group",tabIndex:-1,"aria-label":group.name,"aria-required":radio?group.required:void 0,"aria-describedby":description,"data-zappie-required":group.required?"true":void 0,"aria-invalid":invalid||void 0,"data-invalid":flag(invalid),"data-state":invalid?"invalid":"valid","data-limit-reached":flag(full),"data-zappie-option-group":group.id},composeRefs(ref,node=>{if(node){registry.set(group.id,node)}else{registry.delete(group.id)}}))]})});var ChoiceView=/*@__PURE__ */memo(forwardRef(function ChoiceView2({choice,selected,control,limitReached,hintId,name,quantity,max,toggleChoice,setChoiceQuantity,disabled:held,...props},ref){const toggle=()=>toggleChoice(choice.id);const unavailable=!choice.isAvailable||Boolean(held);const state={choice,selected,disabled:unavailable||limitReached,limitReached,control,toggle,quantity,min:choice.quantity?.min??1,max,setQuantity:next=>setChoiceQuantity(choice.id,next)};const input=jsx("input",{type:control,name,value:choice.id,checked:selected,disabled:unavailable,"aria-disabled":limitReached||void 0,"aria-describedby":limitReached?hintId:void 0,"data-zappie-choice-input":"",onChange:toggle});return labelledControl(props,state,{"data-selected":flag(selected),"data-sold-out":flag(unavailable),"data-disabled":flag(unavailable||limitReached),"data-limit-reached":flag(limitReached),"data-control":control,"data-state":selected?"checked":"unchecked","data-zappie-option":choice.id},input,ref)}));var Choice=/*@__PURE__ */forwardRef(function Choice2(props,ref){const ctx=useGroup();const id=props.choice.id;const selected=ctx.selected.includes(id);const limitReached=props.choice.isAvailable&&!canChoose(ctx.group,ctx.mine,id);return jsx(ChoiceView,{...props,ref,selected,control:ctx.control,limitReached,hintId:ctx.hintId,name:ctx.name,quantity:ctx.quantities[id]??0,max:choiceQuantityMax(ctx.group,ctx.mine,id),toggleChoice:ctx.toggle,setChoiceQuantity:ctx.setQuantity})});var Input=/*@__PURE__ */forwardRef(function Input2(props,ref){const ctx=useGroup();const id=usePartId(props.id);const toggle=ctx.group.kind==="toggle";return part("input",props,ctx,{id,type:toggle?"checkbox":ctx.group.kind==="select"?"text":ctx.group.kind,value:toggle?void 0:ctx.input,checked:toggle?ctx.input==="true":void 0,required:ctx.group.required,"aria-label":ctx.group.name,"aria-invalid":ctx.invalid||void 0,"data-invalid":flag(ctx.invalid),maxLength:ctx.group.input?.maxLength??500,placeholder:ctx.group.input?.placeholder,onChange:event=>ctx.setInput(toggle?String(event.target.checked):event.target.value)},ref)});var OptionGroup2=/*@__PURE__ */Object.assign(Group,{Input});export{Choice,OptionGroup2 as OptionGroup};
|
|
2
2
|
//# sourceMappingURL=option-group.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/item-form/option-group.tsx"],
|
|
4
|
-
"mappings": "aAKA,OACE,UACA,kBACA,WAAW,aACX,UACA,mBACA,iBACA,mBAGK,sBACP,OACE,aACA,cACA,WACA,SACA,eACA,KACA,WACA,QACA,
|
|
4
|
+
"mappings": "aAKA,OACE,UACA,kBACA,WAAW,aACX,UACA,mBACA,iBACA,mBAGK,sBACP,OACE,aACA,cACA,WACA,SACA,eACA,KACA,WACA,QACA,WAIK,QACP,OAAS,SAAY,4BACrB,OAAS,cAAiB,qBAC1B,OAAS,oBAAuB,kCAChC,OAAS,YAAa,SAA4B,sBAClD,OAAS,cAAe,gBAAmB,YAgNvC,WA2BY,SA3BZ,oBArLJ,IAAM,QAAU,eAAgB,cAQ9B,IAAI,EACN,SAAS,UAAW,CAClB,MAAM,MAAQ,WAAW,OAAO,EAChC,GAAI,CAAC,MAAO,CACV,MAAM,IAAI,MAAM,k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AO,GACxB,MAAM,SAAW,IAAI,SAAS,SAAS,EAAE,EACzC,MAAM,aACJ,MAAM,OAAO,aAAe,CAAC,UAAU,IAAI,MAAO,IAAI,KAAM,EAAE,EAChE,OACE,IAAC,YACE,GAAG,MACJ,IACA,SACA,QAAS,IAAI,QACb,aACA,OAAQ,IAAI,OACZ,KAAM,IAAI,KACV,SAAU,IAAI,WAAW,EAAE,GAAK,EAChC,IAAK,kBAAkB,IAAI,MAAO,IAAI,KAAM,EAAE,EAC9C,aAAc,IAAI,OAClB,kBAAmB,IAAI,YACzB,CAEJ,CAAC,EACD,IAAM,MAAQ,eAAgB,WAC5B,SAASC,OAAM,MAAO,IAAK,CACzB,MAAM,IAAM,SAAS,EACrB,MAAM,GAAK,UAAU,MAAM,EAAE,EAC7B,MAAM,OAAS,IAAI,MAAM,OAAS,SAClC,OAAO,KACL,QACA,MACA,IACA,CACE,GACA,KAAM,OACF,WACA,IAAI,MAAM,OAAS,SACjB,OACA,IAAI,MAAM,KAChB,MAAO,OAAS,OAAY,IAAI,MAChC,QAAS,OAAS,IAAI,QAAU,OAAS,OACzC,SAAU,IAAI,MAAM,SACpB,aAAc,IAAI,MAAM,KACxB,eAAgB,IAAI,SAAW,OAC/B,eAAgB,KAAK,IAAI,OAAO,EAChC,UAAW,IAAI,MAAM,OAAO,WAAa,IACzC,YAAa,IAAI,MAAM,OAAO,YAC9B,SAAW,OACT,IAAI,SACF,OAAS,OAAO,MAAM,OAAO,OAAO,EAAI,MAAM,OAAO,KACvD,CACJ,EACA,GACF,CACF,CACF,EAKO,IAAMC,aAAc,eAAgB,OAAO,OAAO,MAAO,CAAE,KAAM,CAAC",
|
|
5
5
|
"names": ["ctx", "group", "ChoiceView", "Choice", "Input", "OptionGroup"]
|
|
6
6
|
}
|
package/dist/payment/methods.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{createContext,forwardRef,useContext}from"react";import{usePartId}from"../internal/ids.js";import{part}from"../internal/slot.js";import{useControllableState}from"../internal/use-controllable-state.js";import{jsx}from"react/jsx-runtime";var Context=/*@__PURE__ */createContext(null);function Root({methods,value,defaultValue=null,onValueChange,...props}){const[selected,set]=useControllableState({value,defaultValue,onChange:onValueChange});const normalized=methods.map(method=>typeof method==="string"?{value:method}:method);const setValue=next=>{if(normalized.some(method=>method.value===next&&!method.disabled)){set(next)}};const state={methods:normalized,value:selected,setValue};return jsx(Context.Provider,{value:state,children:part("div",props,state,{role:"radiogroup"
|
|
1
|
+
"use client";import{createContext,forwardRef,Fragment,useContext}from"react";import{usePartId}from"../internal/ids.js";import{labelledControl}from"../internal/labelled-control.js";import{part}from"../internal/slot.js";import{useControllableState}from"../internal/use-controllable-state.js";import{jsx,jsxs}from"react/jsx-runtime";var Context=/*@__PURE__ */createContext(null);function Root({methods,value,defaultValue=null,onValueChange,...props}){const[selected,set]=useControllableState({value,defaultValue,onChange:onValueChange});const normalized=methods.map(method=>typeof method==="string"?{value:method}:method);const setValue=next=>{if(normalized.some(method=>method.value===next&&!method.disabled)){set(next)}};const name=usePartId();const state={methods:normalized,value:selected,setValue,name};return jsx(Context.Provider,{value:state,children:part("div",props,state,{role:"radiogroup"})})}var Item=/*@__PURE__ */forwardRef(function Item2({value,...props},ref){const ctx=useContext(Context);const id=usePartId();if(!ctx){throw new Error("PaymentMethods.Item requires PaymentMethods.Root")}const method=ctx.methods.find(method2=>method2.value===value);if(!method){return null}const selected=ctx.value===value;const reasonId=`${id}-reason`;const input=jsxs(Fragment,{children:[jsx("input",{id,type:"radio",name:ctx.name,value,checked:selected,disabled:method.disabled,"aria-describedby":method.reason?reasonId:void 0,"data-zappie-choice-input":"",onChange:()=>ctx.setValue(value)}),method.reason?jsx("span",{id:reasonId,hidden:true,children:method.reason}):null]});return labelledControl(props,{...method,selected},{"data-disabled":method.disabled?"":void 0,"data-selected":selected?"":void 0,"data-state":selected?"checked":"unchecked","data-control":"radio"},input,ref)});var PaymentMethods={Root,Item};export{PaymentMethods};
|
|
2
2
|
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,MAC/B,MAAM,SAAW,GAAG,EAAE,UACtB,MAAM,MACJ,KAAC,UACC,cAAC,SACC,GACA,KAAK,QACL,KAAM,IAAI,KACV,MACA,QAAS,SACT,SAAU,OAAO,SACjB,mBAAkB,OAAO,OAAS,SAAW,OAC7C,2BAAyB,GACzB,SAAU,IAAM,IAAI,SAAS,KAAK,EACpC,EACC,OAAO,OACN,IAAC,QAAK,GAAI,SAAU,OAAM,KACvB,gBAAO,OACV,EACE,MACN,EAEF,OAAO,gBACL,MACA,CAAE,GAAG,OAAQ,QAAS,EACtB,CACE,gBAAiB,OAAO,SAAW,GAAK,OACxC,gBAAiB,SAAW,GAAK,OACjC,aAAc,SAAW,UAAY,YACrC,eAAgB,OAClB,EACA,MACA,GACF,CACF,CAAC,EAQM,IAAM,eAAiB,CAAE,KAAM,IAAK",
|
|
5
5
|
"names": ["Item", "method"]
|
|
6
6
|
}
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var PACKAGE_VERSION=true?"0.
|
|
1
|
+
var PACKAGE_VERSION=true?"0.26.0":"0.0.0-development";export{PACKAGE_VERSION};
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zappie/foundations",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.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,
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"peerDependencies": {
|
|
102
102
|
"react": "^18.2.0 || ^19.0.0",
|
|
103
103
|
"react-dom": "^18.2.0 || ^19.0.0",
|
|
104
|
-
"@zappie/sdk": "^0.
|
|
104
|
+
"@zappie/sdk": "^0.27.0",
|
|
105
105
|
"react-router": "^8.4.0"
|
|
106
106
|
},
|
|
107
107
|
"peerDependenciesMeta": {
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"@types/google.maps": "^3.66.7",
|
|
119
119
|
"esbuild": "^0.28.2",
|
|
120
120
|
"react-router": "8.5.0",
|
|
121
|
-
"@zappie/sdk": "0.
|
|
121
|
+
"@zappie/sdk": "0.27.0"
|
|
122
122
|
},
|
|
123
123
|
"license": "MIT",
|
|
124
124
|
"homepage": "https://github.com/zappie/storefront-packages#readme",
|