@zappie/foundations 0.9.1 → 0.9.3
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 +27 -0
- package/README.md +110 -5
- package/dist/account/index.js +3 -3
- package/dist/account/index.js.map +1 -1
- package/dist/account/zappie-account.js +1 -1
- package/dist/account/zappie-account.js.map +1 -1
- package/dist/branch-map/fit.js +3 -18
- package/dist/branch-map/fit.js.map +1 -1
- package/dist/branch-map/geometry.js +6 -8
- package/dist/branch-map/geometry.js.map +1 -1
- package/dist/branch-switch/index.d.ts +168 -0
- package/dist/branch-switch/index.js +126 -0
- package/dist/branch-switch/index.js.map +6 -0
- package/dist/cart/index.js +61 -63
- package/dist/cart/index.js.map +1 -1
- package/dist/fulfilment/address-picker.js +17 -19
- package/dist/fulfilment/address-picker.js.map +1 -1
- package/dist/fulfilment/branch-picker.js +1 -1
- package/dist/fulfilment/branch-picker.js.map +1 -1
- package/dist/fulfilment/schedule.js +1 -1
- package/dist/fulfilment/schedule.js.map +1 -1
- package/dist/fulfilment/switch.js +1 -1
- package/dist/fulfilment/switch.js.map +1 -1
- package/dist/index-B1NMxq0i.d.ts +91 -0
- package/dist/index.d.ts +76 -104
- package/dist/internal/slot.js +1 -1
- package/dist/internal/slot.js.map +1 -1
- package/dist/item-form/index.js +2 -0
- package/dist/item-form/index.js.map +1 -1
- package/dist/item-form/option-group.js +132 -90
- package/dist/item-form/option-group.js.map +1 -1
- package/dist/item-form/options.js +56 -21
- package/dist/item-form/options.js.map +2 -2
- package/dist/item-form/quantity.js +2 -2
- package/dist/item-form/quantity.js.map +1 -1
- package/dist/item-form/root.js +38 -24
- package/dist/item-form/root.js.map +2 -2
- package/dist/money.js +1 -1
- package/dist/money.js.map +1 -1
- package/dist/otp/input.js +1 -1
- package/dist/otp/input.js.map +1 -1
- package/dist/overlay/engine.js +31 -35
- package/dist/overlay/engine.js.map +1 -1
- package/dist/overlay/react.js +120 -117
- package/dist/overlay/react.js.map +1 -1
- package/dist/payment/methods.js +2 -2
- package/dist/payment/methods.js.map +1 -1
- package/dist/search/index.js +4 -4
- package/dist/search/index.js.map +1 -1
- package/dist/status/open-status.js +1 -1
- package/dist/status/open-status.js.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { P as PartOwnedAttributes, a as PartProps } from './engine-D2iRshfW.js';
|
|
2
2
|
import { Presentation, SwipeDirection } from './overlay/engine.js';
|
|
3
3
|
import * as react from 'react';
|
|
4
|
-
import { HTMLAttributes, ReactNode,
|
|
4
|
+
import { HTMLAttributes, ReactNode, KeyboardEvent as KeyboardEvent$1, ImgHTMLAttributes, ChangeEvent, ClipboardEvent } from 'react';
|
|
5
5
|
import { ZappieEnvironment } from '@zappie/sdk/services';
|
|
6
6
|
import * as _zappie_sdk from '@zappie/sdk';
|
|
7
7
|
import { Branch as Branch$1, CartLine, Money as Money$1, CartLineInput, CartIssue, CartFix, Quote, DeliveryAddress, MenuSchedule, CartFulfilment, OptionGroup as OptionGroup$1, Item, Choice as Choice$1, MoneyFormatOptions, PaymentMethodKind, Category, Menu, Store, OpeningTime } from '@zappie/sdk';
|
|
8
|
+
import { Coordinates } from '@zappie/sdk/branches';
|
|
8
9
|
import { useCart } from '@zappie/sdk/react';
|
|
10
|
+
export { D as Deferred, a as DeferredIdleOptions, b as DeferredProps, I as IntentPreloadHandlers, d as deferred, u as useIntentPreload } from './index-B1NMxq0i.js';
|
|
9
11
|
import { C as CloseOptions, O as OverlayQuery } from './history-BlytQinP.js';
|
|
12
|
+
import { SelectionControl } from '@zappie/sdk/options';
|
|
10
13
|
import '@base-ui/react/dialog';
|
|
11
14
|
|
|
12
15
|
/** Account stubs that do not read credentials or host authentication. */
|
|
@@ -106,11 +109,6 @@ declare const ZappieAccountLink: react.ForwardRefExoticComponent<Omit<react.AllH
|
|
|
106
109
|
returnTo?: string;
|
|
107
110
|
} & react.RefAttributes<HTMLElement>>;
|
|
108
111
|
|
|
109
|
-
type Coordinates = {
|
|
110
|
-
lat: number;
|
|
111
|
-
lng: number;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
112
|
/** What a template gets to render when a map fails to load. */
|
|
115
113
|
type MapLoadErrorState = {
|
|
116
114
|
/** Why the map failed to load. */
|
|
@@ -313,93 +311,6 @@ declare const Totals: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttribut
|
|
|
313
311
|
children?: react.ReactNode | ((state: TotalsState) => react.ReactNode);
|
|
314
312
|
} & react.RefAttributes<HTMLElement>>;
|
|
315
313
|
|
|
316
|
-
/** Props for a deferred component: its own props plus `open`, which the helper reads and passes on. */
|
|
317
|
-
type DeferredProps<P> = Omit<P, "open"> & {
|
|
318
|
-
/**
|
|
319
|
-
* Load the code if needed and render the component. Before the first open
|
|
320
|
-
* it renders nothing; after it, the component stays mounted and receives
|
|
321
|
-
* `open`, so it can animate out and return focus when it closes.
|
|
322
|
-
*/
|
|
323
|
-
open: boolean;
|
|
324
|
-
/** Shown while `open` is true and the code is still loading, for inline parts that should hold their place. */
|
|
325
|
-
fallback?: ReactNode;
|
|
326
|
-
/**
|
|
327
|
-
* Shown while `open` is true and the code failed to load. Call `retry` to load it again.
|
|
328
|
-
* A later `preload()`, such as the next tap on the trigger, also retries and renders on success.
|
|
329
|
-
*/
|
|
330
|
-
failed?: (retry: () => void) => ReactNode;
|
|
331
|
-
};
|
|
332
|
-
/** Options for `preloadWhenIdle`. */
|
|
333
|
-
type DeferredIdleOptions = {
|
|
334
|
-
/** Start the load after this many milliseconds even if the browser never goes idle. */
|
|
335
|
-
timeout?: number;
|
|
336
|
-
};
|
|
337
|
-
/**
|
|
338
|
-
* A component whose code loads on demand and renders without suspending.
|
|
339
|
-
* Create it once at module scope with `deferred()`.
|
|
340
|
-
*/
|
|
341
|
-
type Deferred<P> = {
|
|
342
|
-
/**
|
|
343
|
-
* Start loading the code. Repeated calls share one load. A failed load is
|
|
344
|
-
* forgotten, so the next call tries again.
|
|
345
|
-
* @returns The loaded component, or the load error.
|
|
346
|
-
*/
|
|
347
|
-
preload(): Promise<ComponentType<P>>;
|
|
348
|
-
/**
|
|
349
|
-
* Load the code once the browser is idle. Use it only for small chunks.
|
|
350
|
-
* Does nothing on the server.
|
|
351
|
-
* @returns A function that cancels the scheduled load.
|
|
352
|
-
*/
|
|
353
|
-
preloadWhenIdle(options?: DeferredIdleOptions): () => void;
|
|
354
|
-
/**
|
|
355
|
-
* Renders nothing until `open` is first true and the code is in. When
|
|
356
|
-
* `open` turns true it loads the code and renders as soon as it arrives. If
|
|
357
|
-
* the load fails it shows `failed` and renders once a retry or a later
|
|
358
|
-
* `preload()` succeeds. It never suspends. After the first open the component stays mounted and
|
|
359
|
-
* every prop passes through, `open` included, so it can run its own exit.
|
|
360
|
-
*/
|
|
361
|
-
Component: (props: DeferredProps<P>) => ReactElement | null;
|
|
362
|
-
};
|
|
363
|
-
/** Event handlers that start loading a deferred component when a shopper reaches for its trigger. */
|
|
364
|
-
type IntentPreloadHandlers = {
|
|
365
|
-
onPointerEnter: () => void;
|
|
366
|
-
onPointerDown: () => void;
|
|
367
|
-
onFocus: () => void;
|
|
368
|
-
};
|
|
369
|
-
/** What a deferred load resolves to: a component, or a module whose default export is one. */
|
|
370
|
-
type DeferredModule = ComponentType<never> | {
|
|
371
|
-
default: ComponentType<never>;
|
|
372
|
-
};
|
|
373
|
-
/** The props of the component a deferred load resolves to. */
|
|
374
|
-
type DeferredModuleProps<T> = T extends {
|
|
375
|
-
default: ComponentType<infer P>;
|
|
376
|
-
} ? P : T extends ComponentType<infer P> ? P : never;
|
|
377
|
-
/**
|
|
378
|
-
* Load a component's code on demand without `React.lazy` or `<Suspense>`.
|
|
379
|
-
* React holds a suspended boundary's first reveal for about 300 ms, so a
|
|
380
|
-
* lazy overlay opens late. A deferred one renders on the frame its code
|
|
381
|
-
* arrives. Pass a module whose default export is the component, or resolve
|
|
382
|
-
* to the component itself.
|
|
383
|
-
*
|
|
384
|
-
* @example
|
|
385
|
-
* const Bag = deferred(() => import("./bag-sheet"));
|
|
386
|
-
* const Finder = deferred(() => import("./finder").then((m) => m.Finder));
|
|
387
|
-
* <Bag.Component open={open} onClose={close} />
|
|
388
|
-
*/
|
|
389
|
-
declare function deferred<T extends DeferredModule>(load: () => Promise<T>): Deferred<DeferredModuleProps<T>>;
|
|
390
|
-
/**
|
|
391
|
-
* Start loading a deferred component when the shopper points at, presses or
|
|
392
|
-
* focuses its trigger, so the code is usually in by the click. Spread the
|
|
393
|
-
* result on the trigger.
|
|
394
|
-
*
|
|
395
|
-
* @example
|
|
396
|
-
* const intent = useIntentPreload(Bag);
|
|
397
|
-
* <button {...intent} onClick={openBag}>Bag</button>
|
|
398
|
-
*/
|
|
399
|
-
declare function useIntentPreload(target: {
|
|
400
|
-
preload(): Promise<unknown>;
|
|
401
|
-
}): IntentPreloadHandlers;
|
|
402
|
-
|
|
403
314
|
declare function useCombobox<T>(results: readonly T[], onSelect: (item: T) => void): {
|
|
404
315
|
setListId: react.Dispatch<react.SetStateAction<string>>;
|
|
405
316
|
registerOption: (index: number, id: string) => void;
|
|
@@ -640,6 +551,8 @@ type ItemFormContext = {
|
|
|
640
551
|
status: "incomplete" | "valid" | "added";
|
|
641
552
|
value: CartLineInput;
|
|
642
553
|
setValue: (value: CartLineInput) => void;
|
|
554
|
+
/** True while Add asks for a branch instead of adding. See `branchRequired` on ItemForm.Root. */
|
|
555
|
+
branchRequired: boolean;
|
|
643
556
|
};
|
|
644
557
|
/**
|
|
645
558
|
* An option group that failed validation when the shopper tried to add, with its element and issues.
|
|
@@ -672,8 +585,20 @@ type ItemFormProps = Omit<PartProps<ItemFormContext>, "onInvalid"> & {
|
|
|
672
585
|
* when no issue belongs to a group.
|
|
673
586
|
*/
|
|
674
587
|
onInvalid?: (groups: ItemFormInvalidGroup[]) => void;
|
|
588
|
+
/**
|
|
589
|
+
* True when the shopper hasn't chosen a branch yet, for example on a shared
|
|
590
|
+
* product link. Add then adds nothing and calls `onBranchRequired` instead,
|
|
591
|
+
* before checking the options, so the site can open its branch finder.
|
|
592
|
+
*/
|
|
593
|
+
branchRequired?: boolean;
|
|
594
|
+
/**
|
|
595
|
+
* Called when the shopper presses Add while `branchRequired` is true, with
|
|
596
|
+
* the line as chosen so far. Open the branch finder here, and keep the
|
|
597
|
+
* selection to restore it once a branch is chosen.
|
|
598
|
+
*/
|
|
599
|
+
onBranchRequired?: (input: CartLineInput) => void;
|
|
675
600
|
};
|
|
676
|
-
declare function Root$3({ item, value, defaultValue, onValueChange, defaultQuantity, onAdded, onCommit, onInvalid, ...props }: ItemFormProps): react.JSX.Element;
|
|
601
|
+
declare function Root$3({ item, value, defaultValue, onValueChange, defaultQuantity, onAdded, onCommit, onInvalid, branchRequired, onBranchRequired, ...props }: ItemFormProps): react.JSX.Element;
|
|
677
602
|
|
|
678
603
|
type GroupState = {
|
|
679
604
|
group: OptionGroup$1;
|
|
@@ -681,29 +606,49 @@ type GroupState = {
|
|
|
681
606
|
invalid: boolean;
|
|
682
607
|
input: string;
|
|
683
608
|
setInput: (value: string) => void;
|
|
609
|
+
/** Pick or untick a choice. Picking does nothing while the group is at its limit. */
|
|
684
610
|
toggle: (id: string) => void;
|
|
685
611
|
quantities: Readonly<Record<string, number>>;
|
|
686
|
-
/**
|
|
612
|
+
/**
|
|
613
|
+
* Set a choice's quantity, capped by the choice's own bounds and the room
|
|
614
|
+
* left in the group. Zero deselects it. A positive value selects it.
|
|
615
|
+
*/
|
|
687
616
|
setQuantity: (id: string, quantity: number) => void;
|
|
617
|
+
/** Radios for a required group of exactly one, checkboxes otherwise. */
|
|
618
|
+
control: SelectionControl;
|
|
619
|
+
/** The chosen units, each choice counting its quantity. */
|
|
620
|
+
count: number;
|
|
621
|
+
/** How many more units the group takes, or undefined when it has no limit. */
|
|
622
|
+
room: number | undefined;
|
|
623
|
+
/** Whether the group is full, so unchosen choices can't be picked until one is removed. */
|
|
624
|
+
atLimit: boolean;
|
|
625
|
+
/** The hint shown while the group is at its limit, or undefined. */
|
|
626
|
+
limitHint: string | undefined;
|
|
688
627
|
};
|
|
689
628
|
type ChoiceState = {
|
|
690
629
|
choice: Choice$1;
|
|
691
630
|
selected: boolean;
|
|
631
|
+
/** True when the choice is unavailable or held back by the group's limit. */
|
|
692
632
|
disabled: boolean;
|
|
633
|
+
/** True when the group is at its limit and this choice is not chosen. It stays focusable. */
|
|
634
|
+
limitReached: boolean;
|
|
635
|
+
control: SelectionControl;
|
|
693
636
|
toggle: () => void;
|
|
694
|
-
/** Selected quantity (0 when unselected) and the choice's bounds. */
|
|
637
|
+
/** Selected quantity (0 when unselected) and the choice's bounds, capped by the room left in the group. */
|
|
695
638
|
quantity: number;
|
|
696
639
|
min: number;
|
|
697
640
|
max: number;
|
|
698
641
|
setQuantity: (quantity: number) => void;
|
|
699
642
|
};
|
|
700
643
|
/**
|
|
701
|
-
* Render a selectable option within an OptionGroup
|
|
702
|
-
*
|
|
644
|
+
* Render a selectable option within an OptionGroup. A required group of exactly
|
|
645
|
+
* one gives radios, every other group checkboxes. Unavailable choices are
|
|
646
|
+
* disabled. While the group is at its limit, unchosen choices are marked
|
|
647
|
+
* aria-disabled and data-limit-reached but stay focusable.
|
|
703
648
|
*/
|
|
704
649
|
declare const Choice: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
705
650
|
asChild?: boolean;
|
|
706
|
-
children?:
|
|
651
|
+
children?: ReactNode | ((state: ChoiceState) => ReactNode);
|
|
707
652
|
} & {
|
|
708
653
|
choice: Choice$1;
|
|
709
654
|
} & react.RefAttributes<HTMLElement>>;
|
|
@@ -713,7 +658,7 @@ declare const Choice: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttribut
|
|
|
713
658
|
*/
|
|
714
659
|
declare const OptionGroup: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
715
660
|
asChild?: boolean;
|
|
716
|
-
children?:
|
|
661
|
+
children?: ReactNode | ((state: GroupState) => ReactNode);
|
|
717
662
|
} & {
|
|
718
663
|
group: OptionGroup$1;
|
|
719
664
|
/**
|
|
@@ -722,16 +667,43 @@ declare const OptionGroup: react.ForwardRefExoticComponent<Omit<react.AllHTMLAtt
|
|
|
722
667
|
* group's own heading already says so to assistive technology.
|
|
723
668
|
*/
|
|
724
669
|
requiredNote?: string | false;
|
|
670
|
+
/**
|
|
671
|
+
* The visible hint added at the end of the group while it is at its limit.
|
|
672
|
+
* Defaults to "Limit reached. Remove one to choose another." Pass false to
|
|
673
|
+
* render `limitHint` from the render state yourself.
|
|
674
|
+
*/
|
|
675
|
+
limitHint?: string | false;
|
|
725
676
|
} & react.RefAttributes<HTMLElement>> & {
|
|
726
677
|
Input: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
727
678
|
asChild?: boolean;
|
|
728
|
-
children?:
|
|
679
|
+
children?: ReactNode | ((state: GroupState) => ReactNode);
|
|
729
680
|
} & react.RefAttributes<HTMLElement>>;
|
|
730
681
|
};
|
|
731
682
|
|
|
683
|
+
/**
|
|
684
|
+
* The item note as it stands, its limit and a setter, exposed by ItemNote.
|
|
685
|
+
*/
|
|
686
|
+
type NoteState = {
|
|
687
|
+
value: string;
|
|
688
|
+
/** Set the note. Text past the limit is cut. An empty note removes it. */
|
|
689
|
+
setValue: (note: string) => void;
|
|
690
|
+
maxLength: number;
|
|
691
|
+
/** How many characters are left. */
|
|
692
|
+
remaining: number;
|
|
693
|
+
};
|
|
694
|
+
/**
|
|
695
|
+
* A textarea bound to the line's note, limited to `ITEM_NOTE_MAX_LENGTH`
|
|
696
|
+
* characters. Place it inside ItemForm.Root. Use asChild to render your own
|
|
697
|
+
* field. It is separate from ItemForm so a form without a note doesn't load it.
|
|
698
|
+
*/
|
|
699
|
+
declare const ItemNote: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
700
|
+
asChild?: boolean;
|
|
701
|
+
children?: react.ReactNode | ((state: NoteState) => react.ReactNode);
|
|
702
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
703
|
+
|
|
732
704
|
/**
|
|
733
705
|
* Composable item configuration parts for selecting options, validating a line and adding it to the cart.
|
|
734
|
-
* Use ItemForm.Root within your ZappieProvider and place Options and Add inside it.
|
|
706
|
+
* Use ItemForm.Root within your ZappieProvider and place Options and Add inside it. ItemNote edits the line's note.
|
|
735
707
|
*/
|
|
736
708
|
declare const ItemForm: {
|
|
737
709
|
Root: typeof Root$3;
|
|
@@ -1143,5 +1115,5 @@ declare const OpenStatus: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttr
|
|
|
1143
1115
|
/** The installed @zappie/foundations version. */
|
|
1144
1116
|
declare const FOUNDATIONS_VERSION: string;
|
|
1145
1117
|
|
|
1146
|
-
export { Account, AccountNotConfiguredError, Address, Branch, BranchMap, Cart, Choice, DeliveryMap, FOUNDATIONS_VERSION, Fulfilment, Image, ItemForm, Money, OpenStatus, OptionGroup, Otp, Overlay, PartProps, PaymentMethods, Quantity, Schedule, Search, Totals, ZappieAccountLink, canOrderAhead, contactLinks, createSearchIndex,
|
|
1147
|
-
export type { ActiveGroup, AddressState, AddressSuggestion, BranchMapLoadErrorState, BranchMapProps, ContactLink, Customer,
|
|
1118
|
+
export { Account, AccountNotConfiguredError, Address, Branch, BranchMap, Cart, Choice, DeliveryMap, FOUNDATIONS_VERSION, Fulfilment, Image, ItemForm, ItemNote, Money, OpenStatus, OptionGroup, Otp, Overlay, PartProps, PaymentMethods, Quantity, Schedule, Search, Totals, ZappieAccountLink, canOrderAhead, contactLinks, createSearchIndex, formatOpeningHours, formatWallClock, getOpenStatus, parseWallClock, preloadOverlay, scheduleSlots, useControllableState, useOverlay, useZappieAccountUrl, zappieAccountUrl, zappieEnvironment, zappieSupportUrl };
|
|
1119
|
+
export type { ActiveGroup, AddressState, AddressSuggestion, BranchMapLoadErrorState, BranchMapProps, ContactLink, Customer, DeliveryMapProps, ImageProps, ItemFormContext, ItemFormInvalidGroup, ItemFormProps, MapLoadErrorState, NoteState, PaymentMethod, QuantityProps, QuantityState, ScheduleSlot, ScheduleState, ScheduleStatus, SearchResult, SearchSource, SearchState, SignInOptions, TotalsState, ZappieSupportContext };
|
package/dist/internal/slot.js
CHANGED
|
@@ -54,7 +54,7 @@ function part(tag, props, state, defaults = {}, ref) {
|
|
|
54
54
|
const { asChild, children, ...dom } = props;
|
|
55
55
|
const content = typeof children === "function" ? children(state) : children;
|
|
56
56
|
const merged = mergeProps(defaults, dom);
|
|
57
|
-
if (asChild || tag === "input" && typeof children === "function") {
|
|
57
|
+
if (asChild || (tag === "input" || tag === "textarea") && typeof children === "function") {
|
|
58
58
|
const child = Children.only(content);
|
|
59
59
|
if (!isValidElement(child)) {
|
|
60
60
|
throw new Error("asChild requires one React element");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/internal/slot.tsx"],
|
|
4
|
-
"mappings": ";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AAaA,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,SAAS,EAAE,GAAG,MAAM,GAAG,SAAS;AACtC,MACE,OAAO,KAAK,cAAc,YAC1B,OAAO,SAAS,cAAc,UAC9B;AACA,WAAO,YAAY,GAAG,KAAK,SAAS,IAAI,SAAS,SAAS;AAAA,EAC5D;AACA,MACE,KAAK,SACL,SAAS,SACT,OAAO,KAAK,UAAU,YACtB,OAAO,SAAS,UAAU,UAC1B;AACA,WAAO,QAAQ,EAAE,GAAG,KAAK,OAAO,GAAG,SAAS,MAAM;AAAA,EACpD;AACA,aAAW,OAAO,OAAO,KAAK,IAAI,GAAG;AACnC,QACE,WAAW,KAAK,GAAG,KACnB,OAAO,KAAK,GAAG,MAAM,cACrB,OAAO,SAAS,GAAG,MAAM,YACzB;AACA,aAAO,GAAG,IAAI,CAAC,UAA0C;AACvD,QAAC,SAAS,GAAG,EAA+B,KAAK;AACjD,YAAI,CAAC,MAAM,kBAAkB;AAC3B,UAAC,KAAK,GAAG,EAA+B,KAAK;AAAA,QAC/C;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AACO,SAAS,KACd,KACA,OACA,OACA,WAAoC,CAAC,GACrC,KACA;AACA,QAAM,EAAE,SAAS,UAAU,GAAG,IAAI,IAAI;AACtC,QAAM,UAAU,OAAO,aAAa,aAAa,SAAS,KAAK,IAAI;AACnE,QAAM,SAAS,WAAW,UAAU,GAAG;AACvC,
|
|
4
|
+
"mappings": ";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AAaA,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,SAAS,EAAE,GAAG,MAAM,GAAG,SAAS;AACtC,MACE,OAAO,KAAK,cAAc,YAC1B,OAAO,SAAS,cAAc,UAC9B;AACA,WAAO,YAAY,GAAG,KAAK,SAAS,IAAI,SAAS,SAAS;AAAA,EAC5D;AACA,MACE,KAAK,SACL,SAAS,SACT,OAAO,KAAK,UAAU,YACtB,OAAO,SAAS,UAAU,UAC1B;AACA,WAAO,QAAQ,EAAE,GAAG,KAAK,OAAO,GAAG,SAAS,MAAM;AAAA,EACpD;AACA,aAAW,OAAO,OAAO,KAAK,IAAI,GAAG;AACnC,QACE,WAAW,KAAK,GAAG,KACnB,OAAO,KAAK,GAAG,MAAM,cACrB,OAAO,SAAS,GAAG,MAAM,YACzB;AACA,aAAO,GAAG,IAAI,CAAC,UAA0C;AACvD,QAAC,SAAS,GAAG,EAA+B,KAAK;AACjD,YAAI,CAAC,MAAM,kBAAkB;AAC3B,UAAC,KAAK,GAAG,EAA+B,KAAK;AAAA,QAC/C;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AACO,SAAS,KACd,KACA,OACA,OACA,WAAoC,CAAC,GACrC,KACA;AACA,QAAM,EAAE,SAAS,UAAU,GAAG,IAAI,IAAI;AACtC,QAAM,UAAU,OAAO,aAAa,aAAa,SAAS,KAAK,IAAI;AACnE,QAAM,SAAS,WAAW,UAAU,GAAG;AACvC,MACE,YACE,QAAQ,WAAW,QAAQ,eAAe,OAAO,aAAa,YAChE;AACA,UAAM,QAAQ,SAAS,KAAK,OAAO;AACnC,QAAI,CAAC,eAAe,KAAK,GAAG;AAC1B,YAAM,IAAI,MAAM,oCAAoC;AAAA,IACtD;AACA,UAAM,UAAU;AAEhB,UAAM,aAAa,OAAO,yBAAyB,SAAS,KAAK;AACjE,UAAM,WACJ,QAAQ,MAAM,QACb,cAAc,WAAW,aAAa,WAAW,QAAQ;AAC5D,WAAO,aAAa,SAAS;AAAA,MAC3B,GAAG,WAAW,QAAQ,QAAQ,KAAK;AAAA,MACnC,KAAK,YAAY,KAAK,QAA4B;AAAA,IACpD,CAAC;AAAA,EACH;AACA,SAAO,cAAc,KAAK,EAAE,GAAG,QAAQ,IAAI,GAAG,OAAO;AACvD;AAEO,SAAS,OAAO,OAIA;AACrB,MAAI,MAAM,IAAI;AACZ,WAAO,MAAM;AAAA,EACf;AACA,MAAI,MAAM,WAAW,eAAe,MAAM,QAAQ,GAAG;AACnD,UAAM,KAAM,MAAM,SAAS,MAA2B;AACtD,WAAO,OAAO,OAAO,WAAW,KAAK;AAAA,EACvC;AACA,SAAO;AACT;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/item-form/index.js
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
import { Add, Options } from "./options.js";
|
|
3
3
|
import { Root } from "./root.js";
|
|
4
4
|
import { Choice, OptionGroup } from "./option-group.js";
|
|
5
|
+
import { ItemNote } from "./options.js";
|
|
5
6
|
import { Quantity } from "./quantity.js";
|
|
6
7
|
var ItemForm = { Root, Options, Add };
|
|
7
8
|
export {
|
|
8
9
|
Choice,
|
|
9
10
|
ItemForm,
|
|
11
|
+
ItemNote,
|
|
10
12
|
OptionGroup,
|
|
11
13
|
Quantity
|
|
12
14
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/item-form/index.ts"],
|
|
4
|
-
"mappings": ";AAAA,SAAS,KAAK,eAAe;AAC7B,SAAS,YAAY;AAMrB,SAAS,QAAQ,mBAAmB;AACpC,SAAS,gBAAgB;
|
|
4
|
+
"mappings": ";AAAA,SAAS,KAAK,eAAe;AAC7B,SAAS,YAAY;AAMrB,SAAS,QAAQ,mBAAmB;AACpC,SAAS,gBAAgC;AACzC,SAAS,gBAAgB;AAHlB,IAAM,WAAW,EAAE,MAAM,SAAS,IAAI;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
// src/item-form/option-group.tsx
|
|
4
|
+
import {
|
|
5
|
+
canChoose,
|
|
6
|
+
choiceQuantityMax,
|
|
7
|
+
atLimit as groupAtLimit,
|
|
8
|
+
groupRoom,
|
|
9
|
+
LIMIT_REACHED_HINT,
|
|
10
|
+
selectionControl,
|
|
11
|
+
selectionCount
|
|
12
|
+
} from "@zappie/sdk/options";
|
|
4
13
|
import {
|
|
5
14
|
cloneElement,
|
|
6
15
|
createContext,
|
|
7
16
|
forwardRef,
|
|
17
|
+
Fragment,
|
|
8
18
|
isValidElement,
|
|
9
19
|
memo,
|
|
10
20
|
useContext,
|
|
@@ -16,7 +26,7 @@ import { usePartId } from "../internal/ids.js";
|
|
|
16
26
|
import { composeRefs, part } from "../internal/slot.js";
|
|
17
27
|
import { GroupRegistry, useItemForm } from "./root.js";
|
|
18
28
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
19
|
-
var Context = createContext(null);
|
|
29
|
+
var Context = /* @__PURE__ */ createContext(null);
|
|
20
30
|
function useGroup() {
|
|
21
31
|
const value = useContext(Context);
|
|
22
32
|
if (!value) {
|
|
@@ -24,10 +34,12 @@ function useGroup() {
|
|
|
24
34
|
}
|
|
25
35
|
return value;
|
|
26
36
|
}
|
|
27
|
-
var Group = forwardRef(function OptionGroup({
|
|
37
|
+
var Group = /* @__PURE__ */ forwardRef(function OptionGroup({
|
|
28
38
|
group: supplied,
|
|
29
39
|
requiredNote = "Required",
|
|
40
|
+
limitHint: hintText,
|
|
30
41
|
"aria-describedby": describedBy,
|
|
42
|
+
children,
|
|
31
43
|
...props
|
|
32
44
|
}, ref) {
|
|
33
45
|
const ctx = useItemForm();
|
|
@@ -42,67 +54,47 @@ var Group = forwardRef(function OptionGroup({
|
|
|
42
54
|
const input = ctx.value.inputs?.[group.id] ?? "";
|
|
43
55
|
const latest = useRef({ ctx, group });
|
|
44
56
|
latest.current = { ctx, group };
|
|
45
|
-
const actions = useMemo(
|
|
46
|
-
() =>
|
|
57
|
+
const actions = useMemo(() => {
|
|
58
|
+
const write = (id, quantity) => {
|
|
59
|
+
const { ctx: ctx2, group: group2 } = latest.current;
|
|
60
|
+
const previous = ctx2.value.choices ?? [];
|
|
61
|
+
const isThis = (candidate) => candidate.groupId === group2.id && candidate.choiceId === id;
|
|
62
|
+
const choice = group2.choices.find((candidate) => candidate.id === id);
|
|
63
|
+
if (!choice || !Number.isInteger(quantity) || quantity > 0 && !canChoose(group2, previous, id)) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const choices = previous.filter(
|
|
67
|
+
(candidate) => !isThis(candidate) && (quantity <= 0 || candidate.groupId !== group2.id || group2.selection.max !== 1)
|
|
68
|
+
);
|
|
69
|
+
if (quantity > 0) {
|
|
70
|
+
choices.push({
|
|
71
|
+
groupId: group2.id,
|
|
72
|
+
choiceId: id,
|
|
73
|
+
quantity: Math.max(
|
|
74
|
+
choice.quantity?.min ?? 1,
|
|
75
|
+
Math.min(choiceQuantityMax(group2, previous, id), quantity)
|
|
76
|
+
)
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
const inputs = { ...ctx2.value.inputs };
|
|
80
|
+
delete inputs[group2.id];
|
|
81
|
+
ctx2.setValue({ ...ctx2.value, choices, inputs });
|
|
82
|
+
};
|
|
83
|
+
return {
|
|
84
|
+
// A radio stays chosen. A checkbox unticks.
|
|
47
85
|
toggle: (id) => {
|
|
48
86
|
const { ctx: ctx2, group: group2 } = latest.current;
|
|
49
|
-
const
|
|
50
|
-
if (!choice?.isAvailable) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const previous = ctx2.value.choices ?? [];
|
|
54
|
-
const chosen = previous.some(
|
|
87
|
+
const chosen = ctx2.value.choices?.some(
|
|
55
88
|
(candidate) => candidate.groupId === group2.id && candidate.choiceId === id
|
|
56
89
|
);
|
|
57
|
-
|
|
58
|
-
(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
...choices,
|
|
63
|
-
{
|
|
64
|
-
groupId: group2.id,
|
|
65
|
-
choiceId: id,
|
|
66
|
-
quantity: choice.quantity?.min ?? 1
|
|
67
|
-
}
|
|
68
|
-
];
|
|
69
|
-
}
|
|
70
|
-
const inputs = { ...ctx2.value.inputs };
|
|
71
|
-
delete inputs[group2.id];
|
|
72
|
-
ctx2.setValue({ ...ctx2.value, choices, inputs });
|
|
73
|
-
},
|
|
74
|
-
setQuantity: (id, quantity) => {
|
|
75
|
-
const { ctx: ctx2, group: group2 } = latest.current;
|
|
76
|
-
const choice = group2.choices.find((candidate) => candidate.id === id);
|
|
77
|
-
if (!choice?.isAvailable || !Number.isInteger(quantity)) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const others = (ctx2.value.choices ?? []).filter(
|
|
81
|
-
(candidate) => candidate.groupId !== group2.id || group2.selection.max !== 1 && candidate.choiceId !== id
|
|
82
|
-
);
|
|
83
|
-
if (quantity <= 0) {
|
|
84
|
-
ctx2.setValue({
|
|
85
|
-
...ctx2.value,
|
|
86
|
-
choices: (ctx2.value.choices ?? []).filter(
|
|
87
|
-
(candidate) => candidate.groupId !== group2.id || candidate.choiceId !== id
|
|
88
|
-
)
|
|
89
|
-
});
|
|
90
|
-
return;
|
|
90
|
+
if (!chosen || selectionControl(group2) !== "radio") {
|
|
91
|
+
write(
|
|
92
|
+
id,
|
|
93
|
+
chosen ? 0 : group2.choices.find((candidate) => candidate.id === id)?.quantity?.min ?? 1
|
|
94
|
+
);
|
|
91
95
|
}
|
|
92
|
-
const min = choice.quantity?.min ?? 1;
|
|
93
|
-
const max = choice.quantity?.max ?? 99;
|
|
94
|
-
ctx2.setValue({
|
|
95
|
-
...ctx2.value,
|
|
96
|
-
choices: [
|
|
97
|
-
...others,
|
|
98
|
-
{
|
|
99
|
-
groupId: group2.id,
|
|
100
|
-
choiceId: id,
|
|
101
|
-
quantity: Math.min(max, Math.max(min, quantity))
|
|
102
|
-
}
|
|
103
|
-
]
|
|
104
|
-
});
|
|
105
96
|
},
|
|
97
|
+
setQuantity: write,
|
|
106
98
|
setInput: (value) => {
|
|
107
99
|
const { ctx: ctx2, group: group2 } = latest.current;
|
|
108
100
|
ctx2.setValue({
|
|
@@ -116,44 +108,79 @@ var Group = forwardRef(function OptionGroup({
|
|
|
116
108
|
}
|
|
117
109
|
});
|
|
118
110
|
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
);
|
|
111
|
+
};
|
|
112
|
+
}, []);
|
|
122
113
|
const selectionKey = JSON.stringify(quantities);
|
|
114
|
+
const control = selectionControl(group);
|
|
115
|
+
const count = selectionCount(group, mine);
|
|
116
|
+
const full = group.kind === "select" && groupAtLimit(group, mine);
|
|
117
|
+
const heldBack = full && group.choices.some(
|
|
118
|
+
(choice) => choice.isAvailable && !selected.includes(choice.id)
|
|
119
|
+
);
|
|
120
|
+
const text = heldBack && (hintText || LIMIT_REACHED_HINT) || void 0;
|
|
121
|
+
const limitHint = hintText === false ? void 0 : text;
|
|
122
|
+
const hintId = usePartId();
|
|
123
123
|
const state = useMemo(
|
|
124
|
-
() => ({
|
|
125
|
-
|
|
124
|
+
() => ({
|
|
125
|
+
group,
|
|
126
|
+
selected,
|
|
127
|
+
quantities,
|
|
128
|
+
invalid,
|
|
129
|
+
input,
|
|
130
|
+
control,
|
|
131
|
+
count,
|
|
132
|
+
room: groupRoom(group, mine),
|
|
133
|
+
atLimit: full,
|
|
134
|
+
limitHint: text,
|
|
135
|
+
hintId: limitHint && hintId,
|
|
136
|
+
mine,
|
|
137
|
+
...actions
|
|
138
|
+
}),
|
|
139
|
+
[group, selectionKey, invalid, input, hintText, hintId, actions]
|
|
126
140
|
);
|
|
127
|
-
const
|
|
141
|
+
const radio = group.kind === "select" && control === "radio";
|
|
128
142
|
const noteId = usePartId();
|
|
129
|
-
const note = group.required && group.kind === "select" && !
|
|
130
|
-
const
|
|
143
|
+
const note = group.required && group.kind === "select" && !radio && requiredNote;
|
|
144
|
+
const content = typeof children === "function" ? children(state) : children;
|
|
145
|
+
const child = props.asChild && isValidElement(content) ? content : void 0;
|
|
131
146
|
const own = describedBy ?? child?.props["aria-describedby"];
|
|
132
|
-
const description = note
|
|
147
|
+
const description = [note && noteId, limitHint && hintId, own].filter(Boolean).join(" ") || void 0;
|
|
148
|
+
const hint = limitHint ? /* @__PURE__ */ jsx("p", { id: hintId, role: "status", "data-zappie-limit-hint": "", children: limitHint }) : null;
|
|
133
149
|
return /* @__PURE__ */ jsxs(Context.Provider, { value: state, children: [
|
|
134
150
|
note && /* @__PURE__ */ jsx("span", { id: noteId, hidden: true, children: note }),
|
|
135
151
|
part(
|
|
136
152
|
"div",
|
|
137
153
|
child ? {
|
|
138
154
|
...props,
|
|
139
|
-
children: cloneElement(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
155
|
+
children: cloneElement(
|
|
156
|
+
child,
|
|
157
|
+
{ "aria-describedby": description },
|
|
158
|
+
child.props.children,
|
|
159
|
+
hint
|
|
160
|
+
)
|
|
161
|
+
} : {
|
|
162
|
+
...props,
|
|
163
|
+
// One shape with or without the hint, so the choices never remount.
|
|
164
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
165
|
+
content,
|
|
166
|
+
hint
|
|
167
|
+
] })
|
|
168
|
+
},
|
|
143
169
|
state,
|
|
144
170
|
{
|
|
145
|
-
role:
|
|
171
|
+
role: radio ? "radiogroup" : "group",
|
|
146
172
|
tabIndex: -1,
|
|
147
173
|
"aria-label": group.name,
|
|
148
|
-
"aria-required":
|
|
174
|
+
"aria-required": radio ? group.required : void 0,
|
|
149
175
|
"aria-describedby": description,
|
|
150
176
|
"data-zappie-required": group.required ? "true" : void 0,
|
|
151
177
|
"aria-invalid": invalid || void 0,
|
|
152
178
|
"data-invalid": flag(invalid),
|
|
153
179
|
"data-state": invalid ? "invalid" : "valid",
|
|
180
|
+
"data-limit-reached": flag(full),
|
|
154
181
|
"data-zappie-option-group": group.id,
|
|
155
182
|
onKeyDown: (event) => {
|
|
156
|
-
if (!
|
|
183
|
+
if (!radio || ![
|
|
157
184
|
"ArrowDown",
|
|
158
185
|
"ArrowRight",
|
|
159
186
|
"ArrowUp",
|
|
@@ -190,26 +217,32 @@ var Group = forwardRef(function OptionGroup({
|
|
|
190
217
|
)
|
|
191
218
|
] });
|
|
192
219
|
});
|
|
193
|
-
var ChoiceView = memo(
|
|
220
|
+
var ChoiceView = /* @__PURE__ */ memo(
|
|
194
221
|
forwardRef(function ChoiceView2({
|
|
195
222
|
choice,
|
|
196
223
|
selected,
|
|
197
|
-
|
|
224
|
+
control,
|
|
225
|
+
limitReached,
|
|
226
|
+
hintId,
|
|
198
227
|
tabIndex,
|
|
199
228
|
quantity,
|
|
229
|
+
max,
|
|
200
230
|
toggleChoice,
|
|
201
231
|
setChoiceQuantity,
|
|
202
232
|
...props
|
|
203
233
|
}, ref) {
|
|
204
234
|
const toggle = () => toggleChoice(choice.id);
|
|
235
|
+
const unavailable = !choice.isAvailable;
|
|
205
236
|
const state = {
|
|
206
237
|
choice,
|
|
207
238
|
selected,
|
|
208
|
-
disabled:
|
|
239
|
+
disabled: unavailable || limitReached,
|
|
240
|
+
limitReached,
|
|
241
|
+
control,
|
|
209
242
|
toggle,
|
|
210
243
|
quantity,
|
|
211
244
|
min: choice.quantity?.min ?? 1,
|
|
212
|
-
max
|
|
245
|
+
max,
|
|
213
246
|
setQuantity: (next) => setChoiceQuantity(choice.id, next)
|
|
214
247
|
};
|
|
215
248
|
return part(
|
|
@@ -218,14 +251,18 @@ var ChoiceView = memo(
|
|
|
218
251
|
state,
|
|
219
252
|
{
|
|
220
253
|
type: "button",
|
|
221
|
-
role:
|
|
254
|
+
role: control,
|
|
222
255
|
tabIndex,
|
|
223
256
|
"aria-checked": selected,
|
|
224
|
-
|
|
225
|
-
disabled:
|
|
257
|
+
// A choice held back by the limit stays focusable, so it can say why.
|
|
258
|
+
"aria-disabled": unavailable || limitReached,
|
|
259
|
+
"aria-describedby": limitReached ? hintId : void 0,
|
|
260
|
+
disabled: unavailable,
|
|
226
261
|
"data-selected": flag(selected),
|
|
227
|
-
"data-sold-out": flag(
|
|
228
|
-
"data-disabled": flag(
|
|
262
|
+
"data-sold-out": flag(unavailable),
|
|
263
|
+
"data-disabled": flag(unavailable || limitReached),
|
|
264
|
+
"data-limit-reached": flag(limitReached),
|
|
265
|
+
"data-control": control,
|
|
229
266
|
"data-state": selected ? "checked" : "unchecked",
|
|
230
267
|
"data-zappie-option": choice.id,
|
|
231
268
|
onClick: toggle
|
|
@@ -234,27 +271,32 @@ var ChoiceView = memo(
|
|
|
234
271
|
);
|
|
235
272
|
})
|
|
236
273
|
);
|
|
237
|
-
var Choice = forwardRef(function Choice2(props, ref) {
|
|
274
|
+
var Choice = /* @__PURE__ */ forwardRef(function Choice2(props, ref) {
|
|
238
275
|
const ctx = useGroup();
|
|
239
|
-
const
|
|
240
|
-
const
|
|
276
|
+
const id = props.choice.id;
|
|
277
|
+
const radio = ctx.control === "radio";
|
|
278
|
+
const selected = ctx.selected.includes(id);
|
|
279
|
+
const limitReached = props.choice.isAvailable && !canChoose(ctx.group, ctx.mine, id);
|
|
241
280
|
const first = ctx.group.choices.find((choice) => choice.isAvailable);
|
|
242
|
-
const tabIndex = !
|
|
281
|
+
const tabIndex = !radio || selected || !ctx.selected.length && first?.id === id ? 0 : -1;
|
|
243
282
|
return /* @__PURE__ */ jsx(
|
|
244
283
|
ChoiceView,
|
|
245
284
|
{
|
|
246
285
|
...props,
|
|
247
286
|
ref,
|
|
248
287
|
selected,
|
|
249
|
-
|
|
288
|
+
control: ctx.control,
|
|
289
|
+
limitReached,
|
|
290
|
+
hintId: ctx.hintId,
|
|
250
291
|
tabIndex,
|
|
251
|
-
quantity: ctx.quantities[
|
|
292
|
+
quantity: ctx.quantities[id] ?? 0,
|
|
293
|
+
max: choiceQuantityMax(ctx.group, ctx.mine, id),
|
|
252
294
|
toggleChoice: ctx.toggle,
|
|
253
295
|
setChoiceQuantity: ctx.setQuantity
|
|
254
296
|
}
|
|
255
297
|
);
|
|
256
298
|
});
|
|
257
|
-
var Input = forwardRef(
|
|
299
|
+
var Input = /* @__PURE__ */ forwardRef(
|
|
258
300
|
function Input2(props, ref) {
|
|
259
301
|
const ctx = useGroup();
|
|
260
302
|
const id = usePartId(props.id);
|
|
@@ -282,7 +324,7 @@ var Input = forwardRef(
|
|
|
282
324
|
);
|
|
283
325
|
}
|
|
284
326
|
);
|
|
285
|
-
var OptionGroup2 = Object.assign(Group, { Input });
|
|
327
|
+
var OptionGroup2 = /* @__PURE__ */ Object.assign(Group, { Input });
|
|
286
328
|
export {
|
|
287
329
|
Choice,
|
|
288
330
|
OptionGroup2 as OptionGroup
|