@zappie/foundations 0.1.9 → 0.1.12
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 +23 -0
- package/dist/account/index.js.map +0 -1
- package/dist/branch-map/colors.js.map +0 -1
- package/dist/branch-map/delivery-map.js.map +0 -1
- package/dist/branch-map/delivery-runtime.js.map +0 -1
- package/dist/branch-map/fit.js.map +0 -1
- package/dist/branch-map/geometry.js.map +0 -1
- package/dist/branch-map/index.js.map +0 -1
- package/dist/branch-map/loader.js.map +0 -1
- package/dist/branch-map/markers.js.map +0 -1
- package/dist/branch-map/runtime.js.map +0 -1
- package/dist/branch-map/use-map-runtime.js.map +0 -1
- package/dist/cart/index.js.map +0 -1
- package/dist/{core-DdojsUzR.d.ts → core-Cd-_zlQx.d.ts} +2 -1
- package/dist/deferred/index.js.map +0 -1
- package/dist/{engine-Bfbv9M0D.d.ts → engine-D2iRshfW.d.ts} +6 -4
- package/dist/fulfilment/address-picker.js.map +0 -1
- package/dist/fulfilment/branch-picker.js.map +0 -1
- package/dist/fulfilment/schedule.js.map +0 -1
- package/dist/fulfilment/switch.js.map +0 -1
- package/dist/{history-Bqu12Vkz.d.ts → history-BlytQinP.d.ts} +2 -1
- package/dist/index.d.ts +38 -36
- package/dist/index.js.map +0 -1
- package/dist/internal/combobox.js.map +0 -1
- package/dist/internal/data-attrs.js.map +0 -1
- package/dist/internal/ids.js.map +0 -1
- package/dist/internal/slot.js.map +1 -2
- package/dist/internal/use-controllable-state.js.map +0 -1
- package/dist/item-form/index.js.map +0 -1
- package/dist/item-form/option-group.js.map +0 -1
- package/dist/item-form/options.js.map +0 -1
- package/dist/item-form/quantity.js.map +0 -1
- package/dist/item-form/root.js.map +0 -1
- package/dist/media/image.js.map +0 -1
- package/dist/money.js.map +0 -1
- package/dist/next.d.ts +1 -1
- package/dist/next.js.map +0 -1
- package/dist/otp/input.js.map +0 -1
- package/dist/overlay/engine.d.ts +1 -1
- package/dist/overlay/engine.js.map +0 -1
- package/dist/overlay/history.js.map +0 -1
- package/dist/overlay/react.js.map +0 -1
- package/dist/payment/methods.js.map +0 -1
- package/dist/rich-text/banners.js.map +0 -1
- package/dist/rich-text/browser.d.ts +1 -1
- package/dist/rich-text/browser.js.map +0 -1
- package/dist/rich-text/core.js.map +0 -1
- package/dist/rich-text/index.d.ts +1 -1
- package/dist/rich-text/index.js.map +0 -1
- package/dist/search/engine.js.map +0 -1
- package/dist/search/index.js.map +0 -1
- package/dist/status/hours.js.map +0 -1
- package/dist/status/open-status.js.map +0 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { P as PartOwnedAttributes, a as PartProps } from './engine-D2iRshfW.js';
|
|
2
|
+
import { Presentation, SwipeDirection } from './overlay/engine.js';
|
|
1
3
|
import * as react from 'react';
|
|
2
4
|
import { HTMLAttributes, ReactNode, ComponentType, ReactElement, KeyboardEvent as KeyboardEvent$1, ImgHTMLAttributes, ChangeEvent, ClipboardEvent } from 'react';
|
|
3
5
|
import * as _zappie_sdk from '@zappie/sdk';
|
|
4
6
|
import { Branch as Branch$1, CartLine, CartLineInput, CartIssue, CartFix, Quote, DeliveryAddress, MenuSchedule, CartFulfilment, OptionGroup as OptionGroup$1, Item, Money as Money$1, Choice as Choice$1, MoneyFormatOptions, PaymentMethodKind, Category, Menu, OpeningTime } from '@zappie/sdk';
|
|
5
7
|
import { useCart } from '@zappie/sdk/react';
|
|
6
|
-
import {
|
|
7
|
-
import { C as CloseOptions, O as OverlayQuery } from './history-Bqu12Vkz.js';
|
|
8
|
+
import { C as CloseOptions, O as OverlayQuery } from './history-BlytQinP.js';
|
|
8
9
|
import '@base-ui/react/dialog';
|
|
9
10
|
|
|
10
11
|
/** Account stubs that do not read credentials or host authentication. */
|
|
@@ -39,21 +40,21 @@ declare function signOut(_options?: {
|
|
|
39
40
|
* SignIn and SignOut reject with AccountNotConfiguredError. They do not authenticate.
|
|
40
41
|
*/
|
|
41
42
|
declare const Account: {
|
|
42
|
-
SignIn: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
43
|
+
SignIn: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
43
44
|
asChild?: boolean;
|
|
44
45
|
children?: react.ReactNode | ((state: {
|
|
45
46
|
signIn: typeof signIn;
|
|
46
47
|
status: "not_configured";
|
|
47
48
|
}) => react.ReactNode);
|
|
48
49
|
} & react.RefAttributes<HTMLElement>>;
|
|
49
|
-
SignOut: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
50
|
+
SignOut: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
50
51
|
asChild?: boolean;
|
|
51
52
|
children?: react.ReactNode | ((state: {
|
|
52
53
|
signOut: typeof signOut;
|
|
53
54
|
status: "not_configured";
|
|
54
55
|
}) => react.ReactNode);
|
|
55
56
|
} & react.RefAttributes<HTMLElement>>;
|
|
56
|
-
Customer: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
57
|
+
Customer: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
57
58
|
asChild?: boolean;
|
|
58
59
|
children?: react.ReactNode | ((state: {
|
|
59
60
|
customer: Customer | null;
|
|
@@ -193,15 +194,15 @@ declare function Root$5({ value, defaultValue, onValueChange, min, max, step, di
|
|
|
193
194
|
*/
|
|
194
195
|
declare const Quantity: {
|
|
195
196
|
Root: typeof Root$5;
|
|
196
|
-
Value: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
197
|
+
Value: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
197
198
|
asChild?: boolean;
|
|
198
199
|
children?: react.ReactNode | ((state: QuantityState) => react.ReactNode);
|
|
199
200
|
} & react.RefAttributes<HTMLElement>>;
|
|
200
|
-
Increment: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
201
|
+
Increment: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
201
202
|
asChild?: boolean;
|
|
202
203
|
children?: react.ReactNode | ((state: QuantityState) => react.ReactNode);
|
|
203
204
|
} & react.RefAttributes<HTMLElement>>;
|
|
204
|
-
Decrement: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
205
|
+
Decrement: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
205
206
|
asChild?: boolean;
|
|
206
207
|
children?: react.ReactNode | ((state: QuantityState) => react.ReactNode);
|
|
207
208
|
} & react.RefAttributes<HTMLElement>>;
|
|
@@ -224,24 +225,24 @@ declare function CartQuantity({ lineId, ...props }: Omit<QuantityProps, "value"
|
|
|
224
225
|
*/
|
|
225
226
|
declare const Cart: {
|
|
226
227
|
Root: typeof Root$4;
|
|
227
|
-
Line: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
228
|
+
Line: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
228
229
|
asChild?: boolean;
|
|
229
230
|
children?: react.ReactNode | ((state: LineContext) => react.ReactNode);
|
|
230
231
|
} & {
|
|
231
232
|
line: CartLine;
|
|
232
233
|
} & react.RefAttributes<HTMLElement>>;
|
|
233
234
|
Quantity: typeof CartQuantity;
|
|
234
|
-
Remove: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
235
|
+
Remove: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
235
236
|
asChild?: boolean;
|
|
236
237
|
children?: react.ReactNode | ((state: Record<string, never>) => react.ReactNode);
|
|
237
238
|
} & {
|
|
238
239
|
lineId: string;
|
|
239
240
|
} & react.RefAttributes<HTMLElement>>;
|
|
240
|
-
Empty: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
241
|
+
Empty: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
241
242
|
asChild?: boolean;
|
|
242
243
|
children?: react.ReactNode | ((state: Record<string, never>) => react.ReactNode);
|
|
243
244
|
} & react.RefAttributes<HTMLElement>>;
|
|
244
|
-
Issues: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
245
|
+
Issues: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
245
246
|
asChild?: boolean;
|
|
246
247
|
children?: react.ReactNode | ((state: {
|
|
247
248
|
issues: readonly CartIssue[];
|
|
@@ -260,7 +261,7 @@ type TotalsState = {
|
|
|
260
261
|
* Expose the cart quote and its freshness or network status to your render function.
|
|
261
262
|
* Subscribes to the cart and quote failures through your ZappieProvider.
|
|
262
263
|
*/
|
|
263
|
-
declare const Totals: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
264
|
+
declare const Totals: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
264
265
|
asChild?: boolean;
|
|
265
266
|
children?: react.ReactNode | ((state: TotalsState) => react.ReactNode);
|
|
266
267
|
} & react.RefAttributes<HTMLElement>>;
|
|
@@ -426,15 +427,15 @@ declare function Picker({ getSuggestions, onSelect, query, defaultQuery, onQuery
|
|
|
426
427
|
*/
|
|
427
428
|
declare const Address: {
|
|
428
429
|
Picker: typeof Picker;
|
|
429
|
-
Input: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
430
|
+
Input: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
430
431
|
asChild?: boolean;
|
|
431
432
|
children?: react.ReactNode | ((state: AddressState) => react.ReactNode);
|
|
432
433
|
} & react.RefAttributes<HTMLElement>>;
|
|
433
|
-
Suggestions: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
434
|
+
Suggestions: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
434
435
|
asChild?: boolean;
|
|
435
436
|
children?: react.ReactNode | ((state: AddressState) => react.ReactNode);
|
|
436
437
|
} & react.RefAttributes<HTMLElement>>;
|
|
437
|
-
Suggestion: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
438
|
+
Suggestion: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
438
439
|
asChild?: boolean;
|
|
439
440
|
children?: react.ReactNode | ((state: AddressState) => react.ReactNode);
|
|
440
441
|
} & {
|
|
@@ -455,7 +456,7 @@ type BranchPickerState = {
|
|
|
455
456
|
* Use Branch.Picker within your ZappieProvider.
|
|
456
457
|
*/
|
|
457
458
|
declare const Branch: {
|
|
458
|
-
Picker: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
459
|
+
Picker: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
459
460
|
asChild?: boolean;
|
|
460
461
|
children?: react.ReactNode | ((state: BranchPickerState) => react.ReactNode);
|
|
461
462
|
} & {
|
|
@@ -507,7 +508,7 @@ declare function scheduleSlots(branch: Branch$1, timezone: string, now: Date, {
|
|
|
507
508
|
* Expose valid fulfilment slots and ASAP eligibility using branch hours and loaded menu metadata.
|
|
508
509
|
* Use null for ASAP. Requires a ZappieProvider and refreshes the available times each minute.
|
|
509
510
|
*/
|
|
510
|
-
declare const Schedule: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
511
|
+
declare const Schedule: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
511
512
|
asChild?: boolean;
|
|
512
513
|
children?: react.ReactNode | ((state: ScheduleState) => react.ReactNode);
|
|
513
514
|
} & {
|
|
@@ -531,7 +532,7 @@ type FulfilmentState = {
|
|
|
531
532
|
* Selections must use an offered mode and the active branch ID.
|
|
532
533
|
*/
|
|
533
534
|
declare const Fulfilment: {
|
|
534
|
-
Switch: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
535
|
+
Switch: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
535
536
|
asChild?: boolean;
|
|
536
537
|
children?: react.ReactNode | ((state: FulfilmentState) => react.ReactNode);
|
|
537
538
|
} & {
|
|
@@ -634,7 +635,7 @@ type ChoiceState = {
|
|
|
634
635
|
* Render a selectable option within an OptionGroup, with radio or checkbox semantics.
|
|
635
636
|
* Exposes selection and quantity controls and disables unavailable choices.
|
|
636
637
|
*/
|
|
637
|
-
declare const Choice: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
638
|
+
declare const Choice: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
638
639
|
asChild?: boolean;
|
|
639
640
|
children?: react.ReactNode | ((state: ChoiceState) => react.ReactNode);
|
|
640
641
|
} & {
|
|
@@ -644,7 +645,7 @@ declare const Choice: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttribut
|
|
|
644
645
|
* Group item options with selection rules, validation state and an Input part for typed responses.
|
|
645
646
|
* Use within ItemForm.Root. Use Choice for options and OptionGroup.Input for typed responses.
|
|
646
647
|
*/
|
|
647
|
-
declare const OptionGroup: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
648
|
+
declare const OptionGroup: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
648
649
|
asChild?: boolean;
|
|
649
650
|
children?: react.ReactNode | ((state: GroupState) => react.ReactNode);
|
|
650
651
|
} & {
|
|
@@ -656,7 +657,7 @@ declare const OptionGroup: react.ForwardRefExoticComponent<Omit<react.AllHTMLAtt
|
|
|
656
657
|
*/
|
|
657
658
|
requiredNote?: string | false;
|
|
658
659
|
} & react.RefAttributes<HTMLElement>> & {
|
|
659
|
-
Input: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
660
|
+
Input: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
660
661
|
asChild?: boolean;
|
|
661
662
|
children?: react.ReactNode | ((state: GroupState) => react.ReactNode);
|
|
662
663
|
} & react.RefAttributes<HTMLElement>>;
|
|
@@ -668,11 +669,11 @@ declare const OptionGroup: react.ForwardRefExoticComponent<Omit<react.AllHTMLAtt
|
|
|
668
669
|
*/
|
|
669
670
|
declare const ItemForm: {
|
|
670
671
|
Root: typeof Root$3;
|
|
671
|
-
Options: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
672
|
+
Options: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
672
673
|
asChild?: boolean;
|
|
673
674
|
children?: react.ReactNode | ((state: ItemFormContext) => react.ReactNode);
|
|
674
675
|
} & react.RefAttributes<HTMLElement>>;
|
|
675
|
-
Add: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
676
|
+
Add: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
676
677
|
asChild?: boolean;
|
|
677
678
|
children?: react.ReactNode | ((state: ItemFormContext) => react.ReactNode);
|
|
678
679
|
} & react.RefAttributes<HTMLElement>>;
|
|
@@ -696,7 +697,7 @@ declare function Image({ src, sizes, priority, quality, mode, resizeHosts, alt,
|
|
|
696
697
|
* Render formatted SDK money in a data element, with the minor-unit amount as its value.
|
|
697
698
|
* You can override the content with children or a render function receiving the formatted string.
|
|
698
699
|
*/
|
|
699
|
-
declare const Money: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
700
|
+
declare const Money: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
700
701
|
asChild?: boolean;
|
|
701
702
|
children?: react.ReactNode | ((state: {
|
|
702
703
|
formatted: string;
|
|
@@ -732,7 +733,7 @@ declare function slotAttributes(index: number, length: number, value: string, di
|
|
|
732
733
|
* You supply code verification.
|
|
733
734
|
*/
|
|
734
735
|
declare const Otp: {
|
|
735
|
-
Input: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
736
|
+
Input: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
736
737
|
asChild?: boolean;
|
|
737
738
|
children?: react.ReactNode | ((state: OtpState) => react.ReactNode);
|
|
738
739
|
} & {
|
|
@@ -790,7 +791,7 @@ declare function Root$2({ param, id, presentation, swipeDirection, fallback, omi
|
|
|
790
791
|
*/
|
|
791
792
|
declare const Overlay: {
|
|
792
793
|
Root: typeof Root$2;
|
|
793
|
-
Trigger: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
794
|
+
Trigger: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
794
795
|
asChild?: boolean;
|
|
795
796
|
children?: react.ReactNode | ((state: {
|
|
796
797
|
isOpen: boolean;
|
|
@@ -798,7 +799,7 @@ declare const Overlay: {
|
|
|
798
799
|
close: () => void;
|
|
799
800
|
}) => react.ReactNode);
|
|
800
801
|
} & react.RefAttributes<HTMLElement>>;
|
|
801
|
-
Content: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
802
|
+
Content: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
802
803
|
asChild?: boolean;
|
|
803
804
|
children?: react.ReactNode | ((state: {
|
|
804
805
|
isOpen: boolean;
|
|
@@ -815,7 +816,7 @@ declare const Overlay: {
|
|
|
815
816
|
/** Where to mount the content. Defaults to `document.body`. */
|
|
816
817
|
container?: HTMLElement | null;
|
|
817
818
|
} & react.RefAttributes<HTMLElement>>;
|
|
818
|
-
Title: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
819
|
+
Title: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
819
820
|
asChild?: boolean;
|
|
820
821
|
children?: react.ReactNode | ((state: {
|
|
821
822
|
isOpen: boolean;
|
|
@@ -823,7 +824,7 @@ declare const Overlay: {
|
|
|
823
824
|
close: () => void;
|
|
824
825
|
}) => react.ReactNode);
|
|
825
826
|
} & react.RefAttributes<HTMLElement>>;
|
|
826
|
-
Close: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
827
|
+
Close: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
827
828
|
asChild?: boolean;
|
|
828
829
|
children?: react.ReactNode | ((state: {
|
|
829
830
|
isOpen: boolean;
|
|
@@ -858,7 +859,7 @@ declare function Root$1({ methods, value, defaultValue, onValueChange, ...props
|
|
|
858
859
|
*/
|
|
859
860
|
declare const PaymentMethods: {
|
|
860
861
|
Root: typeof Root$1;
|
|
861
|
-
Item: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
862
|
+
Item: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
862
863
|
asChild?: boolean;
|
|
863
864
|
children?: react.ReactNode | ((state: PaymentMethod & {
|
|
864
865
|
selected: boolean;
|
|
@@ -926,15 +927,15 @@ declare function Root(props: RootProps): react.JSX.Element;
|
|
|
926
927
|
*/
|
|
927
928
|
declare const Search: {
|
|
928
929
|
Root: typeof Root;
|
|
929
|
-
Input: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
930
|
+
Input: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
930
931
|
asChild?: boolean;
|
|
931
932
|
children?: react.ReactNode | ((state: SearchState) => react.ReactNode);
|
|
932
933
|
} & react.RefAttributes<HTMLElement>>;
|
|
933
|
-
Results: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
934
|
+
Results: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
934
935
|
asChild?: boolean;
|
|
935
936
|
children?: react.ReactNode | ((state: SearchState) => react.ReactNode);
|
|
936
937
|
} & react.RefAttributes<HTMLElement>>;
|
|
937
|
-
Result: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
938
|
+
Result: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
938
939
|
asChild?: boolean;
|
|
939
940
|
children?: react.ReactNode | ((state: SearchState) => react.ReactNode);
|
|
940
941
|
} & {
|
|
@@ -998,7 +999,7 @@ declare function getOpenStatus(branch: Branch$1, timezone: string, now?: Date):
|
|
|
998
999
|
* Expose a branch opening label and open/closed state in a span or your render function.
|
|
999
1000
|
* Uses your time zone override, then the branch, store or UTC, and refreshes at boundaries and window focus.
|
|
1000
1001
|
*/
|
|
1001
|
-
declare const OpenStatus: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>,
|
|
1002
|
+
declare const OpenStatus: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
1002
1003
|
asChild?: boolean;
|
|
1003
1004
|
children?: react.ReactNode | ((state: OpenStatusState) => react.ReactNode);
|
|
1004
1005
|
} & {
|
|
@@ -1009,4 +1010,5 @@ declare const OpenStatus: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttr
|
|
|
1009
1010
|
/** The installed @zappie/foundations version. */
|
|
1010
1011
|
declare const FOUNDATIONS_VERSION: string;
|
|
1011
1012
|
|
|
1012
|
-
export { Account, AccountNotConfiguredError,
|
|
1013
|
+
export { Account, AccountNotConfiguredError, Address, Branch, BranchMap, Cart, Choice, DeliveryMap, FOUNDATIONS_VERSION, Fulfilment, Image, ItemForm, Money, OpenStatus, OptionGroup, Otp, Overlay, PartProps, PaymentMethods, Quantity, Schedule, Search, Totals, createSearchIndex, deferred, formatOpeningHours, formatWallClock, getOpenStatus, parseWallClock, scheduleSlots, useControllableState, useIntentPreload, useOverlay };
|
|
1014
|
+
export type { ActiveGroup, AddressState, AddressSuggestion, BranchMapLoadErrorState, BranchMapProps, Customer, Deferred, DeferredIdleOptions, DeferredProps, DeliveryMapProps, ImageProps, IntentPreloadHandlers, ItemFormContext, ItemFormInvalidGroup, ItemFormProps, MapLoadErrorState, PaymentMethod, QuantityProps, QuantityState, ScheduleSlot, ScheduleState, SearchResult, SearchSource, SearchState, SignInOptions, TotalsState };
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["\"use client\";\nimport { PACKAGE_VERSION } from \"./version\";\n\n/** The installed @zappie/foundations version. */\nexport const FOUNDATIONS_VERSION: string = PACKAGE_VERSION;\nexport { Account, AccountNotConfiguredError } from \"./account\";\nexport type { Customer, SignInOptions } from \"./account\";\nexport { BranchMap, DeliveryMap } from \"./branch-map\";\nexport type {\n BranchMapLoadErrorState,\n BranchMapProps,\n DeliveryMapProps,\n MapLoadErrorState,\n} from \"./branch-map\";\nexport { Cart, Totals } from \"./cart\";\nexport type { TotalsState } from \"./cart\";\nexport { deferred, useIntentPreload } from \"./deferred\";\nexport type {\n Deferred,\n DeferredIdleOptions,\n DeferredProps,\n IntentPreloadHandlers,\n} from \"./deferred\";\nexport { Address } from \"./fulfilment/address-picker\";\nexport type {\n AddressState,\n AddressSuggestion,\n} from \"./fulfilment/address-picker\";\nexport { Branch } from \"./fulfilment/branch-picker\";\nexport { Schedule, scheduleSlots } from \"./fulfilment/schedule\";\nexport type { ScheduleSlot, ScheduleState } from \"./fulfilment/schedule\";\nexport { Fulfilment } from \"./fulfilment/switch\";\nexport type { PartProps } from \"./internal/slot\";\nexport { useControllableState } from \"./internal/use-controllable-state\";\nexport * from \"./item-form\";\nexport { Image } from \"./media/image\";\nexport type { ImageProps } from \"./media/image\";\nexport { Money } from \"./money\";\nexport { Otp } from \"./otp/input\";\nexport { Overlay, useOverlay } from \"./overlay/react\";\nexport { PaymentMethods } from \"./payment/methods\";\nexport type { PaymentMethod } from \"./payment/methods\";\nexport { createSearchIndex, Search } from \"./search\";\nexport type { SearchResult, SearchSource, SearchState } from \"./search\";\nexport {\n formatOpeningHours,\n formatWallClock,\n getOpenStatus,\n parseWallClock,\n} from \"./status/hours\";\nexport { OpenStatus } from \"./status/open-status\";\n"],
|
|
5
4
|
"mappings": ";;;AACA,SAAS,uBAAuB;AAIhC,SAAS,SAAS,iCAAiC;AAEnD,SAAS,WAAW,mBAAmB;AAOvC,SAAS,MAAM,cAAc;AAE7B,SAAS,UAAU,wBAAwB;AAO3C,SAAS,eAAe;AAKxB,SAAS,cAAc;AACvB,SAAS,UAAU,qBAAqB;AAExC,SAAS,kBAAkB;AAE3B,SAAS,4BAA4B;AACrC,cAAc;AACd,SAAS,aAAa;AAEtB,SAAS,aAAa;AACtB,SAAS,WAAW;AACpB,SAAS,SAAS,kBAAkB;AACpC,SAAS,sBAAsB;AAE/B,SAAS,mBAAmB,cAAc;AAE1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AA9CpB,IAAM,sBAA8B;",
|
|
6
5
|
"names": []
|
|
7
6
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/internal/combobox.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n useEffect,\n useState,\n type CSSProperties,\n type KeyboardEvent,\n type ReactNode,\n} from \"react\";\nimport { usePartId } from \"./ids\";\nexport function useCombobox<T>(\n results: readonly T[],\n onSelect: (item: T) => void,\n) {\n const id = usePartId();\n const [activeIndex, setActiveIndex] = useState(-1);\n const [isOpen, setOpen] = useState(false);\n const [listId, setListId] = useState(`${id}-list`);\n const [optionIds, setOptionIds] = useState<Record<number, string>>({});\n // Reset the highlight when the result set changes size; callers reset on a new query.\n // Keying on the array itself would reset on every re-render with an unmemoised array.\n useEffect(() => setActiveIndex(-1), [results.length]);\n const registerOption = (index: number, id: string) =>\n setOptionIds((previous) =>\n previous[index] === id ? previous : { ...previous, [index]: id },\n );\n const active = activeIndex < results.length ? activeIndex : -1;\n const optionId = (index: number) =>\n optionIds[index] ?? `${id}-option-${index}`;\n const activeId = isOpen && active >= 0 ? optionId(active) : undefined;\n // aria-activedescendant doesn't move focus, so keep the highlighted option visible.\n useEffect(() => {\n if (activeId) {\n document.getElementById(activeId)?.scrollIntoView?.({ block: \"nearest\" });\n }\n }, [activeId]);\n const select = (index: number) => {\n const item = results[index];\n if (item !== undefined) {\n onSelect(item);\n setOpen(false);\n setActiveIndex(-1);\n }\n };\n return {\n setListId,\n registerOption,\n activeIndex: active,\n setActiveIndex,\n isOpen,\n setOpen,\n select,\n inputProps: {\n role: \"combobox\",\n \"aria-autocomplete\": \"list\" as const,\n \"aria-expanded\": isOpen,\n \"aria-controls\": listId,\n \"aria-activedescendant\": activeId,\n onKeyDown: (event: KeyboardEvent) => {\n // Keys pressed while an input method composes text belong to the IME, not the list.\n if (event.nativeEvent.isComposing || event.keyCode === 229) {\n return;\n }\n if (event.key === \"Escape\") {\n event.preventDefault();\n setOpen(false);\n setActiveIndex(-1);\n } else if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n setOpen(true);\n setActiveIndex(\n results.length\n ? active < 0\n ? event.key === \"ArrowDown\"\n ? 0\n : results.length - 1\n : (active +\n (event.key === \"ArrowDown\" ? 1 : -1) +\n results.length) %\n results.length\n : -1,\n );\n } else if (event.key === \"Enter\" && isOpen && active >= 0) {\n event.preventDefault();\n select(active);\n }\n },\n onFocus: () => setOpen(true),\n },\n listProps: { id: listId, role: \"listbox\", hidden: !isOpen },\n getOptionProps: (index: number) => ({\n id: optionId(index),\n role: \"option\",\n \"aria-selected\": active === index,\n \"data-selected\": active === index ? \"\" : undefined,\n onMouseDown: (event: { preventDefault: () => void }) =>\n event.preventDefault(),\n // Inside a drawer or sheet, the overlay engine starts a swipe on any\n // press that isn't a button, link or field, then captures the pointer,\n // so the option's click never fires on touch. Options aren't swipe handles.\n onPointerDown: (event: { stopPropagation: () => void }) =>\n event.stopPropagation(),\n onTouchStart: (event: { stopPropagation: () => void }) =>\n event.stopPropagation(),\n onClick: () => select(index),\n }),\n };\n}\n/** Visually hidden but announced; an accessibility mechanism, not a visual default. */\nconst visuallyHidden: CSSProperties = {\n position: \"absolute\",\n width: 1,\n height: 1,\n margin: -1,\n padding: 0,\n border: 0,\n overflow: \"hidden\",\n clip: \"rect(0 0 0 0)\",\n whiteSpace: \"nowrap\",\n};\n/** Default English announcement of how many options a combobox is showing. */\nexport function countAnnouncement(count: number) {\n return count === 0\n ? \"No results\"\n : `${count} result${count === 1 ? \"\" : \"s\"} available`;\n}\n/** A polite status region so screen readers hear how many options are listed. */\nexport function LiveRegion({ message }: { message: string }) {\n return (\n <span\n role=\"status\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n data-zappie-live=\"\"\n style={visuallyHidden}\n >\n {message}\n </span>\n );\n}\n/** Append the live region to a root's children; with `asChild` the caller owns the single child. */\nexport function withLiveRegion<S>(\n props: { asChild?: boolean | undefined; children?: unknown },\n message: string,\n): typeof props {\n if (props.asChild) {\n return props;\n }\n const children = props.children;\n return {\n ...props,\n children: (state: S) => (\n <>\n {typeof children === \"function\"\n ? (children as (state: S) => ReactNode)(state)\n : (children as ReactNode)}\n <LiveRegion message={message} />\n </>\n ),\n };\n}\n"],
|
|
5
4
|
"mappings": ";AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AACP,SAAS,iBAAiB;AAwHtB,SAuBE,UAvBF,KAuBE,YAvBF;AAvHG,SAAS,YACd,SACA,UACA;AACA,QAAM,KAAK,UAAU;AACrB,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,EAAE;AACjD,QAAM,CAAC,QAAQ,OAAO,IAAI,SAAS,KAAK;AACxC,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,GAAG,EAAE,OAAO;AACjD,QAAM,CAAC,WAAW,YAAY,IAAI,SAAiC,CAAC,CAAC;AAGrE,YAAU,MAAM,eAAe,EAAE,GAAG,CAAC,QAAQ,MAAM,CAAC;AACpD,QAAM,iBAAiB,CAAC,OAAeA,QACrC;AAAA,IAAa,CAAC,aACZ,SAAS,KAAK,MAAMA,MAAK,WAAW,EAAE,GAAG,UAAU,CAAC,KAAK,GAAGA,IAAG;AAAA,EACjE;AACF,QAAM,SAAS,cAAc,QAAQ,SAAS,cAAc;AAC5D,QAAM,WAAW,CAAC,UAChB,UAAU,KAAK,KAAK,GAAG,EAAE,WAAW,KAAK;AAC3C,QAAM,WAAW,UAAU,UAAU,IAAI,SAAS,MAAM,IAAI;AAE5D,YAAU,MAAM;AACd,QAAI,UAAU;AACZ,eAAS,eAAe,QAAQ,GAAG,iBAAiB,EAAE,OAAO,UAA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AW,QAAQ,KAAK;AAAA,MACzC,aAAa,CAAC,UACZ,MAAM,eAAe;AAAA;AAAA;AAAA;AAAA,MAIvB,eAAe,CAAC,UACd,MAAM,gBAAgB;AAAA,MACxB,cAAc,CAAC,UACb,MAAM,gBAAgB;AAAA,MACxB,SAAS,MAAM,OAAO,KAAK;AAAA,IAC7B;AAAA,EACF;AACF;AAEA,IAAM,iBAAgC;AAAA,EACpC,UAAU;AAAA,EACV,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,MAAM;AAAA,EACN,YAAY;AACd;AAEO,SAAS,kBAAkB,OAAe;AAC/C,SAAO,UAAU,IACb,eACA,GAAG,KAAK,UAAU,UAAU,IAAI,KAAK,GAAG;AAC9C;AAEO,SAAS,WAAW,EAAE,QAAQ,GAAwB;AAC3D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,aAAU;AAAA,MACV,eAAY;AAAA,MACZ,oBAAiB;AAAA,MACjB,OAAO;AAAA,MAEN;AAAA;AAAA,EACH;AAEJ;AAEO,SAAS,eACd,OACA,SACc;AACd,MAAI,MAAM,SAAS;AACjB,WAAO;AAAA,EACT;AACA,QAAM,WAAW,MAAM;AACvB,SAAO;AAAA,IACL,GAAG;AAAA,IACH,UAAU,CAAC,UACT,iCACG;AAAA,aAAO,aAAa,aAChB,SAAqC,KAAK,IAC1C;AAAA,MACL,oBAAC,cAAW,SAAkB;AAAA,OAChC;AAAA,EAEJ;AACF;",
|
|
6
5
|
"names": ["id"]
|
|
7
6
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/internal/data-attrs.ts"],
|
|
4
|
-
"sourcesContent": ["export function flag(value: unknown): \"\" | undefined {\n return value ? \"\" : undefined;\n}\n"],
|
|
5
4
|
"mappings": ";AAAO,SAAS,KAAK,OAAgC;AACnD,SAAO,QAAQ,KAAK;AACtB;",
|
|
6
5
|
"names": []
|
|
7
6
|
}
|
package/dist/internal/ids.js.map
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/internal/ids.ts"],
|
|
4
|
-
"sourcesContent": ["import { useId } from \"react\";\nexport function usePartId(provided?: string) {\n const id = useId();\n return provided ?? `zappie-${id.replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n}\n"],
|
|
5
4
|
"mappings": ";AAAA,SAAS,aAAa;AACf,SAAS,UAAU,UAAmB;AAC3C,QAAM,KAAK,MAAM;AACjB,SAAO,YAAY,UAAU,GAAG,QAAQ,mBAAmB,EAAE,CAAC;AAChE;",
|
|
6
5
|
"names": []
|
|
7
6
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/internal/slot.tsx"],
|
|
4
|
-
"
|
|
5
|
-
"mappings": ";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AAYA,SAAS,eAAkB,MAAsC;AACtE,MAAI,WAA2B,CAAC;AAChC,SAAO,CAAC,UAAU;AAChB,eAAW,WAAW,UAAU;AAC9B,cAAQ;AAAA,IACV;AACA,eAAW,CAAC;AACZ,QAAI,UAAU,MAAM;AAClB;AAAA,IACF;AACA,eAAW,OAAO,MAAM;AACtB,UAAI,OAAO,QAAQ,YAAY;AAC7B,cAAM,UAAU,IAAI,KAAK;AACzB,iBAAS;AAAA,UACP,OAAO,YAAY,aAAa,UAAU,MAAM,IAAI,IAAI;AAAA,QAC1D;AAAA,MACF,WAAW,KAAK;AACd,YAAI,UAAU;AACd,iBAAS,KAAK,MAAM;AAClB,cAAI,UAAU;AAAA,QAChB,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,WACd,MACA,UACA;AACA,QAAM,S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AACtD,WAAO,OAAO,OAAO,WAAW,KAAK;AAAA,EACvC;AACA,SAAO;AACT;",
|
|
6
5
|
"names": []
|
|
7
6
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/internal/use-controllable-state.ts"],
|
|
4
|
-
"sourcesContent": ["import { useCallback, useRef, useState } from \"react\";\n/**\n * Manage either a supplied value or internal state initialized from defaultValue.\n * The setter accepts a value or updater and calls onChange only when Object.is detects a change.\n *\n * @returns The current value and a stable setter. A defined value keeps state controlled by you.\n */\nexport function useControllableState<T>({\n value,\n defaultValue,\n onChange,\n}: {\n value?: T | undefined;\n defaultValue: T;\n onChange?: ((value: T) => void) | undefined;\n}) {\n const [internal, setInternal] = useState(defaultValue);\n const current = value === undefined ? internal : value;\n const latest = useRef({ current, onChange, controlled: value !== undefined });\n latest.current = { current, onChange, controlled: value !== undefined };\n const set = useCallback((next: T | ((previous: T) => T)) => {\n const snapshot = latest.current;\n const resolved =\n typeof next === \"function\"\n ? (next as (previous: T) => T)(snapshot.current)\n : next;\n if (Object.is(resolved, snapshot.current)) {\n return;\n }\n if (!snapshot.controlled) {\n latest.current.current = resolved;\n setInternal(resolved);\n }\n snapshot.onChange?.(resolved);\n }, []);\n return [current, set] as const;\n}\n"],
|
|
5
4
|
"mappings": ";AAAA,SAAS,aAAa,QAAQ,gBAAgB;AAOvC,SAAS,qBAAwB;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,YAAY;AACrD,QAAM,UAAU,UAAU,SAAY,WAAW;AACjD,QAAM,SAAS,OAAO,EAAE,SAAS,UAAU,YAAY,UAAU,OAAU,CAAC;AAC5E,SAAO,UAAU,EAAE,SAAS,UAAU,YAAY,UAAU,OAAU;AACtE,QAAM,MAAM,YAAY,CAAC,SAAmC;AAC1D,UAAM,WAAW,OAAO;AACxB,UAAM,WACJ,OAAO,SAAS,aACX,KAA4B,SAAS,OAAO,IAC7C;AACN,QAAI,OAAO,GAAG,UAAU,SAAS,OAAO,GAAG;AACzC;AAAA,IACF;AACA,QAAI,CAAC,SAAS,YAAY;AACxB,aAAO,QAAQ,UAAU;AACzB,kBAAY,QAAQ;AAAA,IACtB;AACA,aAAS,WAAW,QAAQ;AAAA,EAC9B,GAAG,CAAC,CAAC;AACL,SAAO,CAAC,SAAS,GAAG;AACtB;",
|
|
6
5
|
"names": []
|
|
7
6
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/item-form/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { Add, Options } from \"./options\";\nimport { Root } from \"./root\";\n/**\n * Composable item configuration parts for selecting options, validating a line and adding it to the cart.\n * Use ItemForm.Root within your ZappieProvider and place Options and Add inside it.\n */\nexport const ItemForm = { Root, Options, Add };\nexport { Choice, OptionGroup } from \"./option-group\";\nexport { Quantity } from \"./quantity\";\nexport type { QuantityProps, QuantityState } from \"./quantity\";\nexport type {\n ActiveGroup,\n ItemFormContext,\n ItemFormInvalidGroup,\n ItemFormProps,\n} from \"./root\";\n"],
|
|
5
4
|
"mappings": ";AAAA,SAAS,KAAK,eAAe;AAC7B,SAAS,YAAY;AAMrB,SAAS,QAAQ,mBAAmB;AACpC,SAAS,gBAAgB;AAFlB,IAAM,WAAW,EAAE,MAAM,SAAS,IAAI;",
|
|
6
5
|
"names": []
|
|
7
6
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/item-form/option-group.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\";\nimport type {\n Choice as ChoiceModel,\n OptionGroup as GroupModel,\n} from \"@zappie/sdk\";\nimport {\n cloneElement,\n createContext,\n forwardRef,\n isValidElement,\n memo,\n useContext,\n useMemo,\n useRef,\n type ChangeEvent,\n type KeyboardEvent,\n} from \"react\";\nimport { flag } from \"../internal/data-attrs\";\nimport { usePartId } from \"../internal/ids\";\nimport { composeRefs, part, type PartProps } from \"../internal/slot\";\nimport { GroupRegistry, useItemForm } from \"./root\";\ntype GroupState = {\n group: GroupModel;\n selected: string[];\n invalid: boolean;\n input: string;\n setInput: (value: string) => void;\n toggle: (id: string) => void;\n quantities: Readonly<Record<string, number>>;\n /** Set a choice's quantity within its bounds. Zero deselects it. A positive value selects it. */\n setQuantity: (id: string, quantity: number) => void;\n};\nconst Context = createContext<GroupState | null>(null);\nfunction useGroup() {\n const value = useContext(Context);\n if (!value) {\n throw new Error(\"Choice and OptionGroup.Input require OptionGroup\");\n }\n return value;\n}\nconst Group = forwardRef<\n HTMLElement,\n PartProps<GroupState> & {\n group: GroupModel;\n /**\n * The hidden text that describes a required multi-select group as required, since\n * role=\"group\" can't take aria-required. Defaults to \"Required\". Pass false when the\n * group's own heading already says so to assistive technology.\n */\n requiredNote?: string | false;\n }\n>(function OptionGroup(\n {\n group: supplied,\n requiredNote = \"Required\",\n \"aria-describedby\": describedBy,\n ...props\n },\n ref,\n) {\n const ctx = useItemForm();\n const registry = useContext(GroupRegistry)!;\n const group =\n ctx.groups.find((candidate) => candidate.id === supplied.id) ?? supplied;\n const mine =\n ctx.value.choices?.filter((choice) => choice.groupId === group.id) ?? [];\n const selected = mine.map((choice) => choice.choiceId);\n const quantities = Object.fromEntries(\n mine.map((choice) => [choice.choiceId, choice.quantity ?? 1]),\n );\n const invalid = ctx.issues.some((issue) => issue.groupId === group.id);\n const input = ctx.value.inputs?.[group.id] ?? \"\";\n const latest = useRef({ ctx, group });\n latest.current = { ctx, group };\n const actions = useMemo(\n () => ({\n toggle: (id: string) => {\n const { ctx, group } = latest.current;\n const choice = group.choices.find((candidate) => candidate.id === id);\n if (!choice?.isAvailable) {\n return;\n }\n const previous = ctx.value.choices ?? [];\n const chosen = previous.some(\n (candidate) =>\n candidate.groupId === group.id && candidate.choiceId === id,\n );\n let choices = previous.filter(\n (candidate) =>\n candidate.groupId !== group.id ||\n (group.selection.max !== 1 && candidate.choiceId !== id),\n );\n if (!chosen || (group.selection.max === 1 && group.required)) {\n choices = [\n ...choices,\n {\n groupId: group.id,\n choiceId: id,\n quantity: choice.quantity?.min ?? 1,\n },\n ];\n }\n const inputs = { ...ctx.value.inputs };\n delete inputs[group.id];\n ctx.setValue({ ...ctx.value, choices, inputs });\n },\n setQuantity: (id: string, quantity: number) => {\n const { ctx, group } = latest.current;\n const choice = group.choices.find((candidate) => candidate.id === id);\n if (!choice?.isAvailable || !Number.isInteger(quantity)) {\n return;\n }\n const others = (ctx.value.choices ?? []).filter(\n (candidate) =>\n candidate.groupId !== group.id ||\n (group.selection.max !== 1 && candidate.choiceId !== id),\n );\n if (quantity <= 0) {\n ctx.setValue({\n ...ctx.value,\n choices: (ctx.value.choices ?? []).filter(\n (candidate) =>\n candidate.groupId !== group.id || candidate.choiceId !== id,\n ),\n });\n return;\n }\n const min = choice.quantity?.min ?? 1;\n const max = choice.quantity?.max ?? 99;\n ctx.setValue({\n ...ctx.value,\n choices: [\n ...others,\n {\n groupId: group.id,\n choiceId: id,\n quantity: Math.min(max, Math.max(min, quantity)),\n },\n ],\n });\n },\n setInput: (value: string) => {\n const { ctx, group } = latest.current;\n ctx.setValue({\n ...ctx.value,\n choices: (ctx.value.choices ?? []).filter(\n (choice) => choice.groupId !== group.id,\n ),\n inputs: {\n ...ctx.value.inputs,\n [group.id]: value.slice(0, group.input?.maxLength ?? 500),\n },\n });\n },\n }),\n [],\n );\n const selectionKey = JSON.stringify(quantities);\n const state = useMemo(\n () => ({ group, selected, quantities, invalid, input, ...actions }),\n [group, selectionKey, invalid, input, actions],\n );\n const single = group.kind === \"select\" && group.selection.max === 1;\n const noteId = usePartId();\n const note =\n group.required && group.kind === \"select\" && !single && requiredNote;\n // An asChild element's own description joins the note, as partId reads its id.\n const child =\n props.asChild &&\n isValidElement<{ \"aria-describedby\"?: string | undefined }>(props.children)\n ? props.children\n : undefined;\n const own = describedBy ?? child?.props[\"aria-describedby\"];\n const description = note ? `${noteId}${own ? ` ${own}` : \"\"}` : own;\n return (\n <Context.Provider value={state}>\n {note && (\n <span id={noteId} hidden>\n {note}\n </span>\n )}\n {part(\n \"div\",\n child\n ? {\n ...props,\n children: cloneElement(child, {\n \"aria-describedby\": description,\n }),\n }\n : props,\n state,\n {\n role: single ? \"radiogroup\" : \"group\",\n tabIndex: -1,\n \"aria-label\": group.name,\n \"aria-required\": single ? group.required : undefined,\n \"aria-describedby\": description,\n \"data-zappie-required\": group.required ? \"true\" : undefined,\n \"aria-invalid\": invalid || undefined,\n \"data-invalid\": flag(invalid),\n \"data-state\": invalid ? \"invalid\" : \"valid\",\n \"data-zappie-option-group\": group.id,\n onKeyDown: (event: KeyboardEvent<HTMLElement>) => {\n if (\n !single ||\n ![\n \"ArrowDown\",\n \"ArrowRight\",\n \"ArrowUp\",\n \"ArrowLeft\",\n \"Home\",\n \"End\",\n ].includes(event.key)\n ) {\n return;\n }\n const choices = Array.from(\n event.currentTarget.querySelectorAll<HTMLElement>(\n '[role=\"radio\"]:not([aria-disabled=\"true\"])',\n ),\n );\n if (!choices.length) {\n return;\n }\n const current = choices.indexOf(\n document.activeElement as HTMLElement,\n );\n const index =\n event.key === \"Home\"\n ? 0\n : event.key === \"End\"\n ? choices.length - 1\n : (current +\n (event.key === \"ArrowUp\" || event.key === \"ArrowLeft\"\n ? -1\n : 1) +\n choices.length) %\n choices.length;\n event.preventDefault();\n choices[index]?.focus();\n choices[index]?.click();\n },\n },\n composeRefs(ref, (node) => {\n if (node) {\n registry.set(group.id, node);\n } else {\n registry.delete(group.id);\n }\n }),\n )}\n </Context.Provider>\n );\n});\ntype ChoiceState = {\n choice: ChoiceModel;\n selected: boolean;\n disabled: boolean;\n toggle: () => void;\n /** Selected quantity (0 when unselected) and the choice's bounds. */\n quantity: number;\n min: number;\n max: number;\n setQuantity: (quantity: number) => void;\n};\nconst ChoiceView = memo(\n forwardRef<\n HTMLElement,\n PartProps<ChoiceState> & {\n choice: ChoiceModel;\n selected: boolean;\n single: boolean;\n tabIndex: number;\n quantity: number;\n toggleChoice: (id: string) => void;\n setChoiceQuantity: (id: string, quantity: number) => void;\n }\n >(function ChoiceView(\n {\n choice,\n selected,\n single,\n tabIndex,\n quantity,\n toggleChoice,\n setChoiceQuantity,\n ...props\n },\n ref,\n ) {\n const toggle = () => toggleChoice(choice.id);\n const state = {\n choice,\n selected,\n disabled: !choice.isAvailable,\n toggle,\n quantity,\n min: choice.quantity?.min ?? 1,\n max: choice.quantity?.max ?? 99,\n setQuantity: (next: number) => setChoiceQuantity(choice.id, next),\n };\n return part(\n \"button\",\n props,\n state,\n {\n type: \"button\",\n role: single ? \"radio\" : \"checkbox\",\n tabIndex,\n \"aria-checked\": selected,\n \"aria-disabled\": !choice.isAvailable,\n disabled: !choice.isAvailable,\n \"data-selected\": flag(selected),\n \"data-sold-out\": flag(!choice.isAvailable),\n \"data-disabled\": flag(!choice.isAvailable),\n \"data-state\": selected ? \"checked\" : \"unchecked\",\n \"data-zappie-option\": choice.id,\n onClick: toggle,\n },\n ref,\n );\n }),\n);\n/**\n * Render a selectable option within an OptionGroup, with radio or checkbox semantics.\n * Exposes selection and quantity controls and disables unavailable choices.\n */\nexport const Choice = forwardRef<\n HTMLElement,\n PartProps<ChoiceState> & { choice: ChoiceModel }\n>(function Choice(props, ref) {\n const ctx = useGroup();\n const single = ctx.group.selection.max === 1;\n const selected = ctx.selected.includes(props.choice.id);\n const first = ctx.group.choices.find((choice) => choice.isAvailable);\n const tabIndex =\n !single ||\n selected ||\n (!ctx.selected.length && first?.id === props.choice.id)\n ? 0\n : -1;\n return (\n <ChoiceView\n {...props}\n ref={ref}\n selected={selected}\n single={single}\n tabIndex={tabIndex}\n quantity={ctx.quantities[props.choice.id] ?? 0}\n toggleChoice={ctx.toggle}\n setChoiceQuantity={ctx.setQuantity}\n />\n );\n});\nconst Input = forwardRef<HTMLElement, PartProps<GroupState>>(\n function Input(props, ref) {\n const ctx = useGroup();\n const id = usePartId(props.id);\n const toggle = ctx.group.kind === \"toggle\";\n return part(\n \"input\",\n props,\n ctx,\n {\n id,\n type: toggle\n ? \"checkbox\"\n : ctx.group.kind === \"select\"\n ? \"text\"\n : ctx.group.kind,\n value: toggle ? undefined : ctx.input,\n checked: toggle ? ctx.input === \"true\" : undefined,\n required: ctx.group.required,\n \"aria-label\": ctx.group.name,\n \"aria-invalid\": ctx.invalid || undefined,\n \"data-invalid\": flag(ctx.invalid),\n maxLength: ctx.group.input?.maxLength ?? 500,\n placeholder: ctx.group.input?.placeholder,\n onChange: (event: ChangeEvent<HTMLInputElement>) =>\n ctx.setInput(\n toggle ? String(event.target.checked) : event.target.value,\n ),\n },\n ref,\n );\n },\n);\n/**\n * Group item options with selection rules, validation state and an Input part for typed responses.\n * Use within ItemForm.Root. Use Choice for options and OptionGroup.Input for typed responses.\n */\nexport const OptionGroup = Object.assign(Group, { Input });\n"],
|
|
5
4
|
"mappings": ";;;AAKA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,aAAa,YAA4B;AAClD,SAAS,eAAe,mBAAmB;AA2JvC,SAEI,KAFJ;AA/IJ,IAAM,UAAU,cAAiC,IAAI;AACrD,SAAS,WAAW;AAClB,QAAM,QAAQ,WAAW,OAAO;AAChC,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM,kDAAkD;AAAA,EACpE;AACA,SAAO;AACT;AACA,IAAM,QAAQ,WAWZ,SAAS,YACT;AAAA,EACE,OAAO;AAAA,EACP,eAAe;AAAA,EACf,oBAAoB;AAAA,EACpB,GAAG;AACL,GACA,KACA;AACA,QAAM,MAAM,YAAY;AACxB,QAAM,WAAW,WAAW,aAAa;AACzC,QAAM,QACJ,IAAI,OAAO,KAAK,CAAC,cAAc,UAAU,OAA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MAAM,SAAS;AACrB,UAAM,KAAK,UAAU,MAAM,EAAE;AAC7B,UAAM,SAAS,IAAI,MAAM,SAAS;AAClC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,QACE;AAAA,QACA,MAAM,SACF,aACA,IAAI,MAAM,SAAS,WACjB,SACA,IAAI,MAAM;AAAA,QAChB,OAAO,SAAS,SAAY,IAAI;AAAA,QAChC,SAAS,SAAS,IAAI,UAAU,SAAS;AAAA,QACzC,UAAU,IAAI,MAAM;AAAA,QACpB,cAAc,IAAI,MAAM;AAAA,QACxB,gBAAgB,IAAI,WAAW;AAAA,QAC/B,gBAAgB,KAAK,IAAI,OAAO;AAAA,QAChC,WAAW,IAAI,MAAM,OAAO,aAAa;AAAA,QACzC,aAAa,IAAI,MAAM,OAAO;AAAA,QAC9B,UAAU,CAAC,UACT,IAAI;AAAA,UACF,SAAS,OAAO,MAAM,OAAO,OAAO,IAAI,MAAM,OAAO;AAAA,QACvD;AAAA,MACJ;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAKO,IAAMC,eAAc,OAAO,OAAO,OAAO,EAAE,MAAM,CAAC;",
|
|
6
5
|
"names": ["ctx", "group", "ChoiceView", "Choice", "Input", "OptionGroup"]
|
|
7
6
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/item-form/options.tsx"],
|
|
4
|
-
"sourcesContent": ["import { forwardRef } from \"react\";\nimport { part, type PartProps } from \"../internal/slot\";\nimport { useItemForm, type ItemFormContext } from \"./root\";\nexport const Options = forwardRef<HTMLElement, PartProps<ItemFormContext>>(\n function Options(props, ref) {\n return part(\"div\", props, useItemForm(), {}, ref);\n },\n);\nexport const Add = forwardRef<HTMLElement, PartProps<ItemFormContext>>(\n function Add(props, ref) {\n const context = useItemForm();\n // Keep invalid configurations actionable so add() can explain and focus errors.\n return part(\n \"button\",\n props,\n context,\n {\n type: \"button\",\n onClick: context.add,\n \"data-zappie-action\": \"add-to-cart\",\n },\n ref,\n );\n },\n);\n"],
|
|
5
4
|
"mappings": ";AAAA,SAAS,kBAAkB;AAC3B,SAAS,YAA4B;AACrC,SAAS,mBAAyC;AAC3C,IAAM,UAAU;AAAA,EACrB,SAASA,SAAQ,OAAO,KAAK;AAC3B,WAAO,KAAK,OAAO,OAAO,YAAY,GAAG,CAAC,GAAG,GAAG;AAAA,EAClD;AACF;AACO,IAAM,MAAM;AAAA,EACjB,SAASC,KAAI,OAAO,KAAK;AACvB,UAAM,UAAU,YAAY;AAE5B,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,SAAS,QAAQ;AAAA,QACjB,sBAAsB;AAAA,MACxB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
5
|
"names": ["Options", "Add"]
|
|
7
6
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/item-form/quantity.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\";\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useMemo,\n type ChangeEvent,\n type KeyboardEvent,\n} from \"react\";\nimport { flag } from \"../internal/data-attrs\";\nimport { part, type PartProps } from \"../internal/slot\";\nimport { useControllableState } from \"../internal/use-controllable-state\";\n/**\n * The current quantity, bounds, step, disabled state and value setter exposed by a quantity control.\n */\nexport type QuantityState = {\n value: number;\n setValue: (value: number) => void;\n min: number;\n max: number;\n step: number;\n disabled: boolean;\n};\nconst Context = createContext<QuantityState | null>(null);\nfunction useQuantity() {\n const context = useContext(Context);\n if (!context) {\n throw new Error(\"Quantity parts require Quantity.Root\");\n }\n return context;\n}\n/**\n * Controlled or default quantity, bounds and change callback for Quantity.Root.\n */\nexport type QuantityProps = PartProps<QuantityState> & {\n value?: number;\n defaultValue?: number;\n onValueChange?: (value: number) => void;\n min?: number;\n max?: number;\n step?: number;\n disabled?: boolean;\n};\nfunction Root({\n value,\n defaultValue,\n onValueChange,\n min = 1,\n max = 99,\n step = 1,\n disabled = false,\n ...props\n}: QuantityProps) {\n if (\n !Number.isFinite(min) ||\n !Number.isFinite(max) ||\n !Number.isFinite(step) ||\n step <= 0 ||\n min > max\n ) {\n throw new RangeError(\n \"Quantity requires finite ordered bounds and a positive step\",\n );\n }\n const [current, set] = useControllableState({\n value,\n defaultValue: defaultValue ?? min,\n onChange: onValueChange,\n });\n const setValue = useCallback(\n (next: number) => {\n if (!disabled && Number.isFinite(next)) {\n const last = min + Math.floor((max - min) / step) * step;\n set(\n Math.max(\n min,\n Math.min(last, min + Math.round((next - min) / step) * step),\n ),\n );\n }\n },\n [min, max, step, disabled, set],\n );\n const state = useMemo(\n () => ({ value: current, setValue, min, max, step, disabled }),\n [current, setValue, min, max, step, disabled],\n );\n return (\n <Context.Provider value={state}>\n {part(\"div\", props, state, { \"data-disabled\": flag(disabled) })}\n </Context.Provider>\n );\n}\nfunction button(direction: -1 | 1) {\n return forwardRef<HTMLElement, PartProps<QuantityState>>(\n function QuantityButton(props, ref) {\n const ctx = useQuantity();\n const disabled =\n ctx.disabled ||\n (direction < 0 ? ctx.value <= ctx.min : ctx.value + ctx.step > ctx.max);\n return part(\n \"button\",\n props,\n ctx,\n {\n type: \"button\",\n disabled,\n \"aria-disabled\": disabled,\n \"data-disabled\": flag(disabled),\n onClick: () => ctx.setValue(ctx.value + direction * ctx.step),\n },\n ref,\n );\n },\n );\n}\nconst Value = forwardRef<HTMLElement, PartProps<QuantityState>>(\n function Value(props, ref) {\n const ctx = useQuantity();\n return part(\n \"input\",\n props,\n ctx,\n {\n type: \"text\",\n inputMode: \"numeric\",\n role: \"spinbutton\",\n value: String(ctx.value),\n disabled: ctx.disabled,\n \"aria-valuenow\": ctx.value,\n \"aria-valuemin\": ctx.min,\n \"aria-valuemax\": ctx.max,\n onChange: (event: ChangeEvent<HTMLInputElement>) => {\n if (event.target.value.trim()) {\n ctx.setValue(Number(event.target.value));\n }\n },\n onKeyDown: (event: KeyboardEvent) => {\n const next = {\n ArrowUp: ctx.value + ctx.step,\n ArrowDown: ctx.value - ctx.step,\n Home: ctx.min,\n End: ctx.max,\n }[event.key];\n if (next !== undefined) {\n event.preventDefault();\n ctx.setValue(next);\n }\n },\n },\n ref,\n );\n },\n);\n/**\n * Composable quantity controls with bounded step changes and keyboard support.\n * Wrap Value, Increment and Decrement in Quantity.Root.\n *\n * @example\n * ```tsx\n * <Quantity.Root min={1} max={10} defaultValue={1}>\n * <Quantity.Decrement>Less</Quantity.Decrement>\n * <Quantity.Value aria-label=\"Quantity\" />\n * <Quantity.Increment>More</Quantity.Increment>\n * </Quantity.Root>\n * ```\n */\nexport const Quantity = {\n Root,\n Value,\n Increment: button(1),\n Decrement: button(-1),\n};\n"],
|
|
5
4
|
"mappings": ";;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,YAAY;AACrB,SAAS,YAA4B;AACrC,SAAS,4BAA4B;AA6EjC;AAjEJ,IAAM,UAAU,cAAoC,IAAI;AACxD,SAAS,cAAc;AACrB,QAAM,UAAU,WAAW,OAAO;AAClC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,sCAAsC;AAAA,EACxD;AACA,SAAO;AACT;AAaA,SAAS,KAAK;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,WAAW;AAAA,EACX,GAAG;AACL,GAAkB;AAChB,MACE,CAAC,OAAO,SAAS,GAAG,KACpB,CAAC,OAAO,SAAS,GAAG,KACpB,CAAC,OAAO,SAAS,IAAI,KACrB,QAAQ,KACR,MAAM,KACN;AACA,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,QAAM,CAAC,SAAS,GAAG,IAAI,qBAAqB;AAAA,IA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AM,MAAM,YAAY;AACxB,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,WAAW;AAAA,QACX,MAAM;AAAA,QACN,OAAO,OAAO,IAAI,KAAK;AAAA,QACvB,UAAU,IAAI;AAAA,QACd,iBAAiB,IAAI;AAAA,QACrB,iBAAiB,IAAI;AAAA,QACrB,iBAAiB,IAAI;AAAA,QACrB,UAAU,CAAC,UAAyC;AAClD,cAAI,MAAM,OAAO,MAAM,KAAK,GAAG;AAC7B,gBAAI,SAAS,OAAO,MAAM,OAAO,KAAK,CAAC;AAAA,UACzC;AAAA,QACF;AAAA,QACA,WAAW,CAAC,UAAyB;AACnC,gBAAM,OAAO;AAAA,YACX,SAAS,IAAI,QAAQ,IAAI;AAAA,YACzB,WAAW,IAAI,QAAQ,IAAI;AAAA,YAC3B,MAAM,IAAI;AAAA,YACV,KAAK,IAAI;AAAA,UACX,EAAE,MAAM,GAAG;AACX,cAAI,SAAS,QAAW;AACtB,kBAAM,eAAe;AACrB,gBAAI,SAAS,IAAI;AAAA,UACnB;AAAA,QACF;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAcO,IAAM,WAAW;AAAA,EACtB;AAAA,EACA;AAAA,EACA,WAAW,OAAO,CAAC;AAAA,EACnB,WAAW,OAAO,EAAE;AACtB;",
|
|
6
5
|
"names": ["Value"]
|
|
7
6
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/item-form/root.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\";\nimport {\n previewItem,\n ZappieCartError,\n type CartIssue,\n type CartLine,\n type CartLineInput,\n type Item,\n type Money,\n type OptionGroup,\n} from \"@zappie/sdk\";\nimport { useCartCatalogue, useZappie } from \"@zappie/sdk/react\";\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { part, type PartProps } from \"../internal/slot\";\nimport { useControllableState } from \"../internal/use-controllable-state\";\n/**\n * An SDK option group with the effective rules exposed by the item preview.\n */\nexport type ActiveGroup = OptionGroup;\n/**\n * The current item selection, preview prices, validation issues and actions supplied to item form parts.\n */\nexport type ItemFormContext = {\n item: Item;\n groups: ActiveGroup[];\n quantity: number;\n setQuantity: (quantity: number) => void;\n unitPrice: Money;\n total: Money;\n issues: CartIssue[];\n canAdd: boolean;\n add: () => CartLine | null;\n status: \"incomplete\" | \"valid\" | \"added\";\n value: CartLineInput;\n setValue: (value: CartLineInput) => void;\n};\nexport const ItemFormStateContext = createContext<ItemFormContext | null>(null);\nexport function useItemForm() {\n const value = useContext(ItemFormStateContext);\n if (!value) {\n throw new Error(\"ItemForm parts require ItemForm.Root\");\n }\n return value;\n}\n/**\n * An option group that failed validation when the shopper tried to add, with its element and issues.\n */\nexport type ItemFormInvalidGroup = {\n groupId: string;\n /** The item's option group, or undefined for a group the template rendered from its own model. */\n group: ActiveGroup | undefined;\n /** The group's rendered element, or undefined when the group is not on screen. */\n element: HTMLElement | undefined;\n issues: CartIssue[];\n};\nexport const GroupRegistry = createContext<Map<string, HTMLElement> | null>(\n null,\n);\n/**\n * Item form configuration with controlled or default selections and cart commit callbacks.\n * Supply onCommit to update an existing line instead of adding a new one.\n */\nexport type ItemFormProps = Omit<PartProps<ItemFormContext>, \"onInvalid\"> & {\n item: Item;\n value?: CartLineInput;\n defaultValue?: Partial<CartLineInput>;\n onValueChange?: (value: CartLineInput) => void;\n defaultQuantity?: number;\n onAdded?: (line: CartLine) => void;\n /** Update an existing line through the same validation and focus workflow. */\n onCommit?: (input: CartLineInput) => CartLine;\n /**\n * Called when an add fails validation, after the first invalid group gets\n * focus without scrolling. Groups are in display order. Scroll to\n * `groups[0].element` yourself, for example smoothly. The list is empty\n * when no issue belongs to a group.\n */\n onInvalid?: (groups: ItemFormInvalidGroup[]) => void;\n};\nexport function Root({\n item,\n value,\n defaultValue,\n onValueChange,\n defaultQuantity,\n onAdded,\n onCommit,\n onInvalid,\n ...props\n}: ItemFormProps) {\n const client = useZappie();\n const menu = useCartCatalogue();\n const [input, setInput] = useControllableState({\n value,\n defaultValue: {\n ...defaultValue,\n itemId: item.id,\n quantity: defaultQuantity ?? defaultValue?.quantity ?? item.quantity.min,\n },\n onChange: onValueChange,\n });\n const registry = useRef(new Map<string, HTMLElement>());\n const [added, setAdded] = useState(false);\n // Errors show only after the shopper tries to add (PRD 05 5.3), then track live validation.\n const [attempted, setAttempted] = useState(false);\n const [failure, setFailure] = useState<CartIssue[] | null>(null);\n const normalized = useMemo(\n () => ({ ...input, itemId: item.id }),\n [input, item.id],\n );\n const preview = useMemo(\n () => previewItem(item, normalized),\n [item, normalized],\n );\n const validation = useMemo(\n () => client.cart.validate(normalized),\n [client, normalized, menu],\n );\n const issues =\n failure ?? (attempted && !validation.ok ? validation.issues : []);\n const setValue = useCallback(\n (next: CartLineInput) => {\n setAdded(false);\n setFailure(null);\n setInput({ ...next, itemId: item.id });\n },\n [setInput, item.id],\n );\n const setQuantity = useCallback(\n (quantity: number) => setValue({ ...normalized, quantity }),\n [setValue, normalized],\n );\n const focusIssue = useCallback(\n (errors: CartIssue[]) => {\n const issuesOf = (groupId: string) =>\n errors.filter((issue) => issue.groupId === groupId);\n const group = (groupId: string) =>\n preview.groups.find((candidate) => candidate.id === groupId);\n // Rendered groups first, in the order they mounted, then any invalid group not on screen.\n const rendered = [...registry.current]\n .filter(([groupId]) => issuesOf(groupId).length > 0)\n .map(([groupId, element]) => ({\n groupId,\n group: group(groupId),\n element: element as HTMLElement | undefined,\n issues: issuesOf(groupId),\n }));\n const offscreen = preview.groups\n .filter(\n (candidate) =>\n !registry.current.has(candidate.id) &&\n issuesOf(candidate.id).length > 0,\n )\n .map((candidate) => ({\n groupId: candidate.id,\n group: candidate,\n element: undefined,\n issues: issuesOf(candidate.id),\n }));\n const invalid = [...rendered, ...offscreen];\n // Focus moves for keyboard and screen reader users; the template decides how to scroll.\n invalid[0]?.element?.focus({ preventScroll: true });\n onInvalid?.(invalid);\n },\n [preview.groups, onInvalid],\n );\n const add = useCallback(() => {\n const result = client.cart.validate(normalized);\n if (!result.ok) {\n setAttempted(true);\n setFailure(result.issues);\n focusIssue(result.issues);\n return null;\n }\n try {\n const line = onCommit\n ? onCommit(normalized)\n : client.cart.add(item, normalized);\n setAttempted(false);\n setAdded(true);\n onAdded?.(line);\n return line;\n } catch (error) {\n if (error instanceof ZappieCartError) {\n setAttempted(true);\n setFailure([...error.issues]);\n focusIssue([...error.issues]);\n return null;\n }\n throw error;\n }\n }, [client, normalized, item, onAdded, onCommit, focusIssue]);\n const context: ItemFormContext = useMemo(\n () => ({\n item,\n ...preview,\n quantity: normalized.quantity ?? item.quantity.min,\n setQuantity,\n issues,\n canAdd: validation.ok && !failure,\n add,\n status: added ? \"added\" : validation.ok ? \"valid\" : \"incomplete\",\n value: normalized,\n setValue,\n }),\n [\n item,\n preview,\n normalized,\n setQuantity,\n issues,\n validation.ok,\n failure,\n add,\n added,\n setValue,\n ],\n );\n return (\n <ItemFormStateContext.Provider value={context}>\n <GroupRegistry.Provider value={registry.current}>\n {part(\"div\", props, context, {\n \"data-zappie-item\": item.id,\n \"data-state\": issues.length ? \"invalid\" : \"valid\",\n \"data-sold-out\": item.isAvailable ? undefined : \"\",\n })}\n </GroupRegistry.Provider>\n </ItemFormStateContext.Provider>\n );\n}\n"],
|
|
5
4
|
"mappings": ";;;AACA;AAAA,EACE;AAAA,EACA;AAAA,OAOK;AACP,SAAS,kBAAkB,iBAAiB;AAC5C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,YAA4B;AACrC,SAAS,4BAA4B;AA8M/B;AAxLC,IAAM,uBAAuB,cAAsC,IAAI;AACvE,SAAS,cAAc;AAC5B,QAAM,QAAQ,WAAW,oBAAoB;AAC7C,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM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|
3
3
|
"sources": ["../../src/media/image.tsx"],
|
|
4
|
-
"sourcesContent": ["import { canResize, resized, srcSet } from \"@zappie/sdk/template\";\nimport { useCallback, useState, type ImgHTMLAttributes } from \"react\";\n\n/** Props for a responsive storefront image. */\nexport type ImageProps = Omit<\n ImgHTMLAttributes<HTMLImageElement>,\n \"src\" | \"srcSet\"\n> & {\n src: string;\n alt: string;\n sizes?: string;\n priority?: boolean;\n quality?: number;\n mode?: \"resize\" | \"direct\";\n /** Lowercase hosts your zone resizes. Defaults to `RESIZE_HOSTS` from `@zappie/sdk/template`. */\n resizeHosts?: readonly string[];\n};\n\n/** Render an image through same-origin resizing, falling back once to `src` if that fails. */\nexport function Image({\n src,\n sizes = \"100vw\",\n priority = false,\n quality,\n mode = \"resize\",\n resizeHosts,\n alt,\n onError,\n ...props\n}: ImageProps) {\n const [failed, setFailed] = useState<string | null>(null);\n const responsive =\n mode === \"resize\" && failed !== src && canResize(src, resizeHosts);\n // Catches an error that fired before hydration.\n const checkLoaded = useCallback(\n (image: HTMLImageElement | null) => {\n if (responsive && image?.complete && image.naturalWidth === 0) {\n setFailed(src);\n }\n },\n [responsive, src],\n );\n return (\n <img\n {...props}\n ref={checkLoaded}\n alt={alt}\n src={responsive ? resized(src, 960, quality, resizeHosts) : src}\n {...(responsive\n ? { srcSet: srcSet(src, quality, resizeHosts), sizes }\n : {})}\n loading={priority ? \"eager\" : \"lazy\"}\n decoding={priority ? \"sync\" : \"async\"}\n {...(priority ? { fetchPriority: \"high\" as const } : {})}\n onError={(event) => {\n if (responsive) {\n setFailed(src);\n }\n onError?.(event);\n }}\n />\n );\n}\n"],
|
|
5
4
|
"mappings": ";AAAA,SAAS,WAAW,SAAS,cAAc;AAC3C,SAAS,aAAa,gBAAwC;AA0C1D;AAxBG,SAAS,MAAM;AAAA,EACpB;AAAA,EACA,QAAQ;AAAA,EACR,WAAW;AAAA,EACX;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAe;AACb,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAwB,IAAI;AACxD,QAAM,aACJ,SAAS,YAAY,WAAW,OAAO,UAAU,KAAK,WAAW;AAEnE,QAAM,cAAc;AAAA,IAClB,CAAC,UAAmC;AAClC,UAAI,cAAc,OAAO,YAAY,MAAM,iBAAiB,GAAG;AAC7D,kBAAU,GAAG;AAAA,MACf;AAAA,IACF;AAAA,IACA,CAAC,YAAY,GAAG;AAAA,EAClB;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,KAAK;AAAA,MACL;AAAA,MACA,KAAK,aAAa,QAAQ,KAAK,KAAK,SAAS,WAAW,IAAI;AAAA,MAC3D,GAAI,aACD,EAAE,QAAQ,OAAO,KAAK,SAAS,WAAW,GAAG,MAAM,IACnD,CAAC;AAAA,MACL,SAAS,WAAW,UAAU;AAAA,MAC9B,UAAU,WAAW,SAAS;AAAA,MAC7B,GAAI,WAAW,EAAE,eAAe,OAAgB,IAAI,CAAC;AAAA,MACtD,SAAS,CAAC,UAAU;AAClB,YAAI,YAAY;AACd,oBAAU,GAAG;AAAA,QACf;AACA,kBAAU,KAAK;AAAA,MACjB;AAAA;AAAA,EACF;AAEJ;",
|
|
6
5
|
"names": []
|
|
7
6
|
}
|
package/dist/money.js.map
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/money.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n format,\n type MoneyFormatOptions,\n type Money as MoneyValue,\n} from \"@zappie/sdk\";\nimport { forwardRef } from \"react\";\nimport { part, type PartProps } from \"./internal/slot\";\n/**\n * Render formatted SDK money in a data element, with the minor-unit amount as its value.\n * You can override the content with children or a render function receiving the formatted string.\n */\nexport const Money = forwardRef<\n HTMLElement,\n PartProps<{ formatted: string }> & {\n value: MoneyValue;\n formatOptions?: MoneyFormatOptions;\n }\n>(function Money({ value, formatOptions, ...props }, ref) {\n const formatted = format.money(value, formatOptions);\n return part(\n \"data\",\n { ...props, children: props.children ?? formatted },\n { formatted },\n { value: String(value.amountMinor) },\n ref,\n );\n});\n"],
|
|
5
4
|
"mappings": ";AAAA;AAAA,EACE;AAAA,OAGK;AACP,SAAS,kBAAkB;AAC3B,SAAS,YAA4B;AAK9B,IAAM,QAAQ,WAMnB,SAASA,OAAM,EAAE,OAAO,eAAe,GAAG,MAAM,GAAG,KAAK;AACxD,QAAM,YAAY,OAAO,MAAM,OAAO,aAAa;AACnD,SAAO;AAAA,IACL;AAAA,IACA,EAAE,GAAG,OAAO,UAAU,MAAM,YAAY,UAAU;AAAA,IAClD,EAAE,UAAU;AAAA,IACZ,EAAE,OAAO,OAAO,MAAM,WAAW,EAAE;AAAA,IACnC;AAAA,EACF;AACF,CAAC;",
|
|
6
5
|
"names": ["Money"]
|
|
7
6
|
}
|
package/dist/next.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { L as OVERLAY_LOCATION_EVENT } from './history-
|
|
1
|
+
export { L as OVERLAY_LOCATION_EVENT } from './history-BlytQinP.js';
|
|
2
2
|
|
|
3
3
|
/** Capture same-page shallow moves before Next attempts a server navigation. */
|
|
4
4
|
declare function installShallowHistory(): () => void;
|
package/dist/next.js.map
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/overlay/next.ts"],
|
|
4
|
-
"sourcesContent": ["\"use client\";\nimport { useEffect } from \"react\";\nimport { LOCATION_EVENT } from \"./history\";\n/**\n * The event overlays re-read the URL on. A host that intercepts `popstate`\n * for its own shallow history (and stops it) must dispatch this too, or open\n * overlays never see Back.\n */\nexport { LOCATION_EVENT as OVERLAY_LOCATION_EVENT };\nlet subscribers = 0;\nlet uninstall: (() => void) | undefined;\n/** Capture same-page shallow moves before Next attempts a server navigation. */\nexport function installShallowHistory() {\n if (typeof window === \"undefined\") {\n return () => {};\n }\n if (subscribers++ === 0) {\n let previous = { base: \"\", pathname: \"\", shallow: false };\n const record = () => {\n previous = {\n base: window.history.state?.__zappieBase ?? window.location.pathname,\n pathname: window.location.pathname,\n shallow: Boolean(window.history.state?.__zappieBase),\n };\n };\n record();\n const onPop = (event: PopStateEvent) => {\n const base = event.state?.__zappieBase ?? window.location.pathname;\n if (\n (Boolean(event.state?.__zappieBase) || previous.shallow) &&\n base === previous.base &&\n window.location.pathname === previous.pathname\n ) {\n event.stopImmediatePropagation();\n record();\n window.dispatchEvent(new Event(LOCATION_EVENT));\n return;\n }\n record();\n };\n window.addEventListener(\"popstate\", onPop, true);\n window.addEventListener(LOCATION_EVENT, record);\n uninstall = () => {\n window.removeEventListener(\"popstate\", onPop, true);\n window.removeEventListener(LOCATION_EVENT, record);\n };\n }\n let released = false;\n return () => {\n if (!released) {\n released = true;\n if (--subscribers === 0) {\n uninstall?.();\n }\n }\n };\n}\n/**\n * Install the shared shallow-history bridge on mount and release it on unmount.\n * Keeps same-page overlay history changes from triggering Next server navigation.\n */\nexport function useNextOverlayBridge() {\n useEffect(installShallowHistory, []);\n}\n"],
|
|
5
4
|
"mappings": ";;;AACA,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAO/B,IAAI,cAAc;AAClB,IAAI;AAEG,SAAS,wBAAwB;AACtC,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO,MAAM;AAAA,IAAC;AAAA,EAChB;AACA,MAAI,kBAAkB,GAAG;AACvB,QAAI,WAAW,EAAE,MAAM,IAAI,UAAU,IAAI,SAAS,MAAM;AACxD,UAAM,SAAS,MAAM;AACnB,iBAAW;AAAA,QACT,MAAM,OAAO,QAAQ,OAAO,gBAAgB,OAAO,SAAS;AAAA,QAC5D,UAAU,OAAO,SAAS;AAAA,QAC1B,SAAS,QAAQ,OAAO,QAAQ,OAAO,YAAY;AAAA,MACrD;AAAA,IACF;AACA,WAAO;AACP,UAAM,QAAQ,CAAC,UAAyB;AACtC,YAAM,OAAO,MAAM,OAAO,gBAAgB,OAAO,SAAS;AAC1D,WACG,QAAQ,MAAM,OAAO,YAAY,KAAK,SAAS,YAChD,SAAS,SAAS,QAClB,OAAO,SAAS,aAAa,SAAS,UACtC;AACA,cAAM,yBAAyB;AAC/B,eAAO;AACP,eAAO,cAAc,IAAI,MAAM,cAAc,CAAC;AAC9C;AAAA,MACF;AACA,aAAO;AAAA,IACT;AACA,WAAO,iBAAiB,YAAY,OAAO,IAAI;AAC/C,WAAO,iBAAiB,gBAAgB,MAAM;AAC9C,gBAAY,MAAM;AAChB,aAAO,oBAAoB,YAAY,OAAO,IAAI;AAClD,aAAO,oBAAoB,gBAAgB,MAAM;AAAA,IACnD;AAAA,EACF;AACA,MAAI,WAAW;AACf,SAAO,MAAM;AACX,QAAI,CAAC,UAAU;AACb,iBAAW;AACX,UAAI,EAAE,gBAAgB,GAAG;AACvB,oBAAY;AAAA,MACd;AAAA,IACF;AAAA,EACF;AACF;AAKO,SAAS,uBAAuB;AACrC,YAAU,uBAAuB,CAAC,CAAC;AACrC;",
|
|
6
5
|
"names": []
|
|
7
6
|
}
|
package/dist/otp/input.js.map
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/otp/input.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\";\nimport {\n forwardRef,\n useEffect,\n useRef,\n type ChangeEvent,\n type ClipboardEvent,\n type KeyboardEvent,\n} from \"react\";\nimport { composeRefs, part, type PartProps } from \"../internal/slot\";\nimport { useControllableState } from \"../internal/use-controllable-state\";\nexport type OtpState = {\n value: string;\n slots: string[];\n getSlotProps: (index: number) => ReturnType<typeof slotAttributes>;\n};\nfunction slotAttributes(\n index: number,\n length: number,\n value: string,\n disabled: boolean,\n update: (index: number, text: string) => void,\n focus: (index: number) => void,\n) {\n return {\n type: \"text\",\n inputMode: \"numeric\" as const,\n autoComplete: index === 0 ? \"one-time-code\" : \"off\",\n \"aria-label\": `Digit ${index + 1} of ${length}`,\n \"data-otp-slot\": index,\n value: value[index] ?? \"\",\n disabled,\n onChange: (event: ChangeEvent<HTMLInputElement>) =>\n update(index, event.target.value),\n onPaste: (event: ClipboardEvent<HTMLInputElement>) => {\n event.preventDefault();\n update(index, event.clipboardData.getData(\"text\"));\n },\n onKeyDown: (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === \"Backspace\") {\n event.preventDefault();\n const target = value[index] ? index : Math.max(0, index - 1);\n update(target, \"\");\n focus(target);\n } else if (event.key === \"ArrowLeft\" || event.key === \"ArrowRight\") {\n event.preventDefault();\n focus(index + (event.key === \"ArrowLeft\" ? -1 : 1));\n }\n },\n onFocus: (event: { currentTarget: HTMLInputElement }) =>\n event.currentTarget.select(),\n };\n}\nconst Input = forwardRef<\n HTMLElement,\n PartProps<OtpState> & {\n length?: number;\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n onComplete?: (value: string) => void;\n disabled?: boolean;\n }\n>(function Input(\n {\n length = 6,\n value,\n defaultValue = \"\",\n onValueChange,\n onComplete,\n disabled = false,\n ...props\n },\n ref,\n) {\n if (!Number.isInteger(length) || length < 1 || length > 12) {\n throw new RangeError(\"OTP length must be 1\u201312\");\n }\n const [current, setValue] = useControllableState({\n value,\n defaultValue,\n onChange: onValueChange,\n });\n const element = useRef<HTMLElement>(null);\n const previous = useRef(\"\");\n const callback = useRef(onComplete);\n callback.current = onComplete;\n useEffect(() => {\n if (\n current.length === length &&\n /^\\d+$/.test(current) &&\n previous.current !== current\n ) {\n callback.current?.(current);\n }\n previous.current = current;\n }, [current, length]);\n const focus = (index: number) =>\n element.current\n ?.querySelector<HTMLInputElement>(\n `[data-otp-slot=\"${Math.max(0, Math.min(length - 1, index))}\"]`,\n )\n ?.focus();\n const update = (index: number, text: string) => {\n if (disabled) {\n return;\n }\n const digits = text.replace(/\\D/g, \"\");\n const start = digits.length >= length ? 0 : index;\n const next = (\n current.slice(0, start) +\n digits +\n current.slice(start + Math.max(1, digits.length))\n ).slice(0, length);\n setValue(next);\n if (digits) {\n focus(start + digits.length);\n }\n };\n // An SMS code can be autofilled (or typed) before hydration: it sits in the\n // DOM with no change event. Adopt it once the component mounts.\n const adopt = useRef(update);\n adopt.current = update;\n useEffect(() => {\n const typed = Array.from(\n element.current?.querySelectorAll<HTMLInputElement>(\"[data-otp-slot]\") ??\n [],\n (input) => input.value,\n ).join(\"\");\n if (typed && typed !== current) {\n adopt.current(0, typed);\n }\n // Mount only: later edits arrive as change events.\n }, []);\n const getSlotProps = (index: number) =>\n slotAttributes(index, length, current, disabled, update, focus);\n const slots = Array.from({ length }, (_, index) => current[index] ?? \"\");\n return part(\n \"div\",\n {\n ...props,\n children:\n props.children ??\n slots.map((_, index) => <input key={index} {...getSlotProps(index)} />),\n },\n { value: current, slots, getSlotProps },\n { role: \"group\", \"data-disabled\": disabled ? \"\" : undefined },\n composeRefs(ref, element),\n );\n});\n/**\n * A numeric one-time-code input with paste, autofill and keyboard focus handling.\n * Otp.Input defaults to six digits and calls onComplete when a new complete code is entered.\n * You supply code verification.\n */\nexport const Otp = { Input };\n"],
|
|
5
4
|
"mappings": ";;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,aAAa,YAA4B;AAClD,SAAS,4BAA4B;AAqIL;AA/HhC,SAAS,eACP,OACA,QACA,OACA,UACA,QACA,OACA;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,WAAW;AAAA,IACX,cAAc,UAAU,IAAI,kBAAkB;AAAA,IAC9C,cAAc,SAAS,QAAQ,CAAC,OAAO,MAAM;AAAA,IAC7C,iBAAiB;AAAA,IACjB,OAAO,MAAM,KAAK,KAAK;AAAA,IACvB;AAAA,IACA,UAAU,CAAC,UACT,OAAO,OAAO,MAAM,OAAO,KAAK;AAAA,IAClC,SAAS,CAAC,UAA4C;AACpD,YAAM,eAAe;AACrB,aAAO,OAAO,MAAM,cAAc,QAAQ,MAAM,CAA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["Input"]
|
|
7
6
|
}
|
package/dist/overlay/engine.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
+
export { E as EngineClose, c as EngineTitle, b as Presentation, d as Surface, e as SurfaceProps, S as SwipeDirection, u as useEngineParts } from '../engine-D2iRshfW.js';
|
|
1
2
|
import 'react';
|
|
2
3
|
import '@base-ui/react/dialog';
|
|
3
|
-
export { E as EngineClose, b as EngineTitle, a as Presentation, c as Surface, d as SurfaceProps, S as SwipeDirection, u as useEngineParts } from '../engine-Bfbv9M0D.js';
|