@zappie/foundations 0.9.2 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,12 +1,13 @@
1
- import { P as PartOwnedAttributes, a as PartProps } from './engine-D2iRshfW.js';
1
+ import { P as PartOwnedAttributes, a as PartProps } from './engine-TxMNPD2g.js';
2
2
  import { Presentation, SwipeDirection } from './overlay/engine.js';
3
3
  import * as react from 'react';
4
- import { HTMLAttributes, ReactNode, ComponentType, ReactElement, KeyboardEvent as KeyboardEvent$1, ImgHTMLAttributes, ChangeEvent, ClipboardEvent } from 'react';
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
8
  import { Coordinates } from '@zappie/sdk/branches';
9
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';
10
11
  import { C as CloseOptions, O as OverlayQuery } from './history-BlytQinP.js';
11
12
  import { SelectionControl } from '@zappie/sdk/options';
12
13
  import '@base-ui/react/dialog';
@@ -310,93 +311,6 @@ declare const Totals: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttribut
310
311
  children?: react.ReactNode | ((state: TotalsState) => react.ReactNode);
311
312
  } & react.RefAttributes<HTMLElement>>;
312
313
 
313
- /** Props for a deferred component: its own props plus `open`, which the helper reads and passes on. */
314
- type DeferredProps<P> = Omit<P, "open"> & {
315
- /**
316
- * Load the code if needed and render the component. Before the first open
317
- * it renders nothing; after it, the component stays mounted and receives
318
- * `open`, so it can animate out and return focus when it closes.
319
- */
320
- open: boolean;
321
- /** Shown while `open` is true and the code is still loading, for inline parts that should hold their place. */
322
- fallback?: ReactNode;
323
- /**
324
- * Shown while `open` is true and the code failed to load. Call `retry` to load it again.
325
- * A later `preload()`, such as the next tap on the trigger, also retries and renders on success.
326
- */
327
- failed?: (retry: () => void) => ReactNode;
328
- };
329
- /** Options for `preloadWhenIdle`. */
330
- type DeferredIdleOptions = {
331
- /** Start the load after this many milliseconds even if the browser never goes idle. */
332
- timeout?: number;
333
- };
334
- /**
335
- * A component whose code loads on demand and renders without suspending.
336
- * Create it once at module scope with `deferred()`.
337
- */
338
- type Deferred<P> = {
339
- /**
340
- * Start loading the code. Repeated calls share one load. A failed load is
341
- * forgotten, so the next call tries again.
342
- * @returns The loaded component, or the load error.
343
- */
344
- preload(): Promise<ComponentType<P>>;
345
- /**
346
- * Load the code once the browser is idle. Use it only for small chunks.
347
- * Does nothing on the server.
348
- * @returns A function that cancels the scheduled load.
349
- */
350
- preloadWhenIdle(options?: DeferredIdleOptions): () => void;
351
- /**
352
- * Renders nothing until `open` is first true and the code is in. When
353
- * `open` turns true it loads the code and renders as soon as it arrives. If
354
- * the load fails it shows `failed` and renders once a retry or a later
355
- * `preload()` succeeds. It never suspends. After the first open the component stays mounted and
356
- * every prop passes through, `open` included, so it can run its own exit.
357
- */
358
- Component: (props: DeferredProps<P>) => ReactElement | null;
359
- };
360
- /** Event handlers that start loading a deferred component when a shopper reaches for its trigger. */
361
- type IntentPreloadHandlers = {
362
- onPointerEnter: () => void;
363
- onPointerDown: () => void;
364
- onFocus: () => void;
365
- };
366
- /** What a deferred load resolves to: a component, or a module whose default export is one. */
367
- type DeferredModule = ComponentType<never> | {
368
- default: ComponentType<never>;
369
- };
370
- /** The props of the component a deferred load resolves to. */
371
- type DeferredModuleProps<T> = T extends {
372
- default: ComponentType<infer P>;
373
- } ? P : T extends ComponentType<infer P> ? P : never;
374
- /**
375
- * Load a component's code on demand without `React.lazy` or `<Suspense>`.
376
- * React holds a suspended boundary's first reveal for about 300 ms, so a
377
- * lazy overlay opens late. A deferred one renders on the frame its code
378
- * arrives. Pass a module whose default export is the component, or resolve
379
- * to the component itself.
380
- *
381
- * @example
382
- * const Bag = deferred(() => import("./bag-sheet"));
383
- * const Finder = deferred(() => import("./finder").then((m) => m.Finder));
384
- * <Bag.Component open={open} onClose={close} />
385
- */
386
- declare function deferred<T extends DeferredModule>(load: () => Promise<T>): Deferred<DeferredModuleProps<T>>;
387
- /**
388
- * Start loading a deferred component when the shopper points at, presses or
389
- * focuses its trigger, so the code is usually in by the click. Spread the
390
- * result on the trigger.
391
- *
392
- * @example
393
- * const intent = useIntentPreload(Bag);
394
- * <button {...intent} onClick={openBag}>Bag</button>
395
- */
396
- declare function useIntentPreload(target: {
397
- preload(): Promise<unknown>;
398
- }): IntentPreloadHandlers;
399
-
400
314
  declare function useCombobox<T>(results: readonly T[], onSelect: (item: T) => void): {
401
315
  setListId: react.Dispatch<react.SetStateAction<string>>;
402
316
  registerOption: (index: number, id: string) => void;
@@ -873,6 +787,45 @@ declare const Otp: {
873
787
  } & react.RefAttributes<HTMLElement>>;
874
788
  };
875
789
 
790
+ /** The way a sheet leaves the screen when it is dragged. */
791
+ type DragDirection = "down" | "up" | "left" | "right";
792
+
793
+ /** Options for `useDragToClose`. */
794
+ type DragToCloseOptions = {
795
+ /** Closes the sheet. Pass the same close the sheet's close button uses. */
796
+ onClose: () => void;
797
+ /** Set `false` to keep the sheet still under a drag. Pass the sheet's open state here too. Defaults to `true`. */
798
+ enabled?: boolean;
799
+ /** The way the sheet leaves. Defaults to the viewport edge the sheet is attached to. */
800
+ direction?: DragDirection;
801
+ /** Finds the backdrop to fade as the sheet moves. */
802
+ backdrop?: (panel: HTMLElement) => Element | null | undefined;
803
+ };
804
+ /**
805
+ * Drag a bottom or side sheet off the screen to close it, on phones and touch screens.
806
+ * `Overlay.Content` does this for drawers and sheets. Use the hook for a sheet you build yourself.
807
+ *
808
+ * The sheet follows the finger with `translate` and the backdrop fades. On release it closes past
809
+ * a quarter of its size or on a flick, and otherwise springs back. A scroller inside keeps the
810
+ * gesture until its content is back at the top, and a sideways swipe, such as on a carousel, is
811
+ * never taken. A sheet that fills the viewport along the drag, such as a full-height sheet, and a
812
+ * centred dialog never drag. Under reduced motion the sheet stays still until it closes. Add
813
+ * `data-no-drag` to an element to keep drags that start on it.
814
+ *
815
+ * The sheet gets `data-drag-to-close` (its direction) while it can be dragged, so a handle can be
816
+ * shown only then, and `data-swiping` during a drag.
817
+ *
818
+ * @param options - The close action and, optionally, the direction and the backdrop.
819
+ * @returns A ref for the sheet's panel element.
820
+ *
821
+ * @example
822
+ * ```tsx
823
+ * const dragRef = useDragToClose({ onClose: close, enabled: isOpen });
824
+ * return isOpen ? <div ref={dragRef} role="dialog" aria-modal>…</div> : null;
825
+ * ```
826
+ */
827
+ declare function useDragToClose<T extends HTMLElement = HTMLElement>(options: DragToCloseOptions): (node: T | null) => void;
828
+
876
829
  /**
877
830
  * Start downloading the overlay engine now, so the next overlay to open doesn't wait for it.
878
831
  *
@@ -923,9 +876,12 @@ declare function Root$2({ param, id, presentation, swipeDirection, fallback, omi
923
876
  id: string;
924
877
  /** Your URL adapter for overlays whose open state lives in the path. */
925
878
  navigation?: OverlayState;
926
- /** A `dialog`, swipeable `drawer` or `sheet`. Use `{ base, sm, md, lg, xl }` for responsive layouts. */
879
+ /** A `dialog`, or a `drawer` or `sheet` that drags to close on phones. Use `{ base, sm, md, lg, xl }` for responsive layouts. */
927
880
  presentation?: ResponsivePresentation;
928
- /** Swipe direction to dismiss. Defaults to `down` for drawers and `right` for sheets. */
881
+ /**
882
+ * The way a drawer or sheet is dragged to close it on a phone. Defaults to the viewport edge
883
+ * the panel is attached to: down for a bottom sheet, towards its side for a side sheet.
884
+ */
929
885
  swipeDirection?: SwipeDirection;
930
886
  } & CloseOptions): react.JSX.Element;
931
887
  /**
@@ -958,6 +914,12 @@ declare const Overlay: {
958
914
  forceMount?: true;
959
915
  /** Where to mount the content. Defaults to `document.body`. */
960
916
  container?: HTMLElement | null;
917
+ /**
918
+ * Drag a drawer or sheet off the screen to close it, on phones and touch screens. Set `false`
919
+ * to turn it off. A panel that fills the viewport along the drag, and a dialog, never drag.
920
+ * Defaults to `true`.
921
+ */
922
+ dragToClose?: boolean;
961
923
  } & react.RefAttributes<HTMLElement>>;
962
924
  Title: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
963
925
  asChild?: boolean;
@@ -1201,5 +1163,5 @@ declare const OpenStatus: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttr
1201
1163
  /** The installed @zappie/foundations version. */
1202
1164
  declare const FOUNDATIONS_VERSION: string;
1203
1165
 
1204
- 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, deferred, formatOpeningHours, formatWallClock, getOpenStatus, parseWallClock, preloadOverlay, scheduleSlots, useControllableState, useIntentPreload, useOverlay, useZappieAccountUrl, zappieAccountUrl, zappieEnvironment, zappieSupportUrl };
1205
- export type { ActiveGroup, AddressState, AddressSuggestion, BranchMapLoadErrorState, BranchMapProps, ContactLink, Customer, Deferred, DeferredIdleOptions, DeferredProps, DeliveryMapProps, ImageProps, IntentPreloadHandlers, ItemFormContext, ItemFormInvalidGroup, ItemFormProps, MapLoadErrorState, NoteState, PaymentMethod, QuantityProps, QuantityState, ScheduleSlot, ScheduleState, ScheduleStatus, SearchResult, SearchSource, SearchState, SignInOptions, TotalsState, ZappieSupportContext };
1166
+ 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, useDragToClose, useOverlay, useZappieAccountUrl, zappieAccountUrl, zappieEnvironment, zappieSupportUrl };
1167
+ export type { ActiveGroup, AddressState, AddressSuggestion, BranchMapLoadErrorState, BranchMapProps, ContactLink, Customer, DeliveryMapProps, DragDirection, DragToCloseOptions, ImageProps, ItemFormContext, ItemFormInvalidGroup, ItemFormProps, MapLoadErrorState, NoteState, PaymentMethod, QuantityProps, QuantityState, ScheduleSlot, ScheduleState, ScheduleStatus, SearchResult, SearchSource, SearchState, SignInOptions, TotalsState, ZappieSupportContext };
package/dist/index.js CHANGED
@@ -21,6 +21,7 @@ export * from "./item-form/index.js";
21
21
  import { Image } from "./media/image.js";
22
22
  import { Money } from "./money.js";
23
23
  import { Otp } from "./otp/input.js";
24
+ import { useDragToClose } from "./overlay/drag-to-close.js";
24
25
  import { preloadOverlay } from "./overlay/load.js";
25
26
  import { Overlay, useOverlay } from "./overlay/react.js";
26
27
  import { PaymentMethods } from "./payment/methods.js";
@@ -66,6 +67,7 @@ export {
66
67
  preloadOverlay,
67
68
  scheduleSlots,
68
69
  useControllableState,
70
+ useDragToClose,
69
71
  useIntentPreload,
70
72
  useOverlay,
71
73
  useZappieAccountUrl,
package/dist/index.js.map CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "mappings": ";;;AACA,SAAS,uBAAuB;AAIhC,SAAS,SAAS,iCAAiC;AAEnD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,WAAW,mBAAmB;AAOvC,SAAS,MAAM,cAAc;AAE7B,SAAS,UAAU,wBAAwB;AAO3C,SAAS,eAAe;AAKxB,SAAS,cAAc;AACvB,SAAS,UAAU,qBAAqB;AAMxC,SAAS,kBAAkB;AAE3B,SAAS,4BAA4B;AACrC,cAAc;AACd,SAAS,aAAa;AAEtB,SAAS,aAAa;AACtB,SAAS,WAAW;AACpB,SAAS,sBAAsB;AAC/B,SAAS,SAAS,kBAAkB;AACpC,SAAS,sBAAsB;AAE/B,SAAS,mBAAmB,cAAc;AAE1C,SAAS,cAAc,wBAAwB;AAE/C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AA5DpB,IAAM,sBAA8B;",
4
+ "mappings": ";;;AACA,SAAS,uBAAuB;AAIhC,SAAS,SAAS,iCAAiC;AAEnD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,WAAW,mBAAmB;AAOvC,SAAS,MAAM,cAAc;AAE7B,SAAS,UAAU,wBAAwB;AAO3C,SAAS,eAAe;AAKxB,SAAS,cAAc;AACvB,SAAS,UAAU,qBAAqB;AAMxC,SAAS,kBAAkB;AAE3B,SAAS,4BAA4B;AACrC,cAAc;AACd,SAAS,aAAa;AAEtB,SAAS,aAAa;AACtB,SAAS,WAAW;AACpB,SAAS,sBAAsB;AAK/B,SAAS,sBAAsB;AAC/B,SAAS,SAAS,kBAAkB;AACpC,SAAS,sBAAsB;AAE/B,SAAS,mBAAmB,cAAc;AAE1C,SAAS,cAAc,wBAAwB;AAE/C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAjEpB,IAAM,sBAA8B;",
5
5
  "names": []
6
6
  }
@@ -0,0 +1,51 @@
1
+ "use client";
2
+
3
+ // src/overlay/drag-to-close.ts
4
+ import { useEffect, useRef, useState } from "react";
5
+ var attach;
6
+ var gesture;
7
+ var loadGesture = () => gesture ?? (gesture = import("./drag.js").then(
8
+ (module) => attach = module.attachDragToClose,
9
+ (error) => {
10
+ gesture = void 0;
11
+ throw error;
12
+ }
13
+ ));
14
+ function provideGesture(gestureAttach) {
15
+ attach = gestureAttach;
16
+ }
17
+ function useDragToClose(options) {
18
+ const [panel, setPanel] = useState(null);
19
+ const latest = useRef(options);
20
+ latest.current = options;
21
+ const enabled = options.enabled ?? true;
22
+ useEffect(() => {
23
+ if (!enabled || !panel) {
24
+ return void 0;
25
+ }
26
+ const options2 = () => latest.current;
27
+ let detach = attach?.(panel, options2);
28
+ let live = true;
29
+ if (!detach) {
30
+ loadGesture().then(
31
+ (loaded) => {
32
+ if (live) {
33
+ detach = loaded(panel, options2);
34
+ }
35
+ },
36
+ () => {
37
+ }
38
+ );
39
+ }
40
+ return () => {
41
+ live = false;
42
+ detach?.();
43
+ };
44
+ }, [enabled, panel]);
45
+ return setPanel;
46
+ }
47
+ export {
48
+ provideGesture,
49
+ useDragToClose
50
+ };
51
+ //# sourceMappingURL=drag-to-close.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/overlay/drag-to-close.ts"],
4
+ "mappings": ";;;AACA,SAAS,WAAW,QAAQ,gBAAgB;AAkB5C,IAAI;AACJ,IAAI;AAEJ,IAAM,cAAc,MACjB,sBAAY,OAAO,WAAQ,EAAE;AAAA,EAC5B,CAAC,WAAY,SAAS,OAAO;AAAA,EAC7B,CAAC,UAAmB;AAClB,cAAU;AACV,UAAM;AAAA,EACR;AACF;AAEK,SAAS,eAAe,eAA6B;AAC1D,WAAS;AACX;AAyBO,SAAS,eACd,SAC0B;AAC1B,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAmB,IAAI;AACjD,QAAM,SAAS,OAAO,OAAO;AAC7B,SAAO,UAAU;AACjB,QAAM,UAAU,QAAQ,WAAW;AACnC,YAAU,MAAM;AACd,QAAI,CAAC,WAAW,CAAC,OAAO;AACtB,aAAO;AAAA,IACT;AACA,UAAMA,WAAU,MAAM,OAAO;AAC7B,QAAI,SAAS,SAAS,OAAOA,QAAO;AACpC,QAAI,OAAO;AACX,QAAI,CAAC,QAAQ;AACX,kBAAY,EAAE;AAAA,QACZ,CAAC,WAAW;AACV,cAAI,MAAM;AACR,qBAAS,OAAO,OAAOA,QAAO;AAAA,UAChC;AAAA,QACF;AAAA,QACA,MAAM;AAAA,QAAC;AAAA,MACT;AAAA,IACF;AACA,WAAO,MAAM;AACX,aAAO;AACP,eAAS;AAAA,IACX;AAAA,EACF,GAAG,CAAC,SAAS,KAAK,CAAC;AACnB,SAAO;AACT;",
5
+ "names": ["options"]
6
+ }
@@ -0,0 +1,210 @@
1
+ // src/overlay/drag.ts
2
+ var EASE = "cubic-bezier(0.32, 0.72, 0, 1)";
3
+ var SETTLE_MS = 500;
4
+ var CLOSE_FRACTION = 0.25;
5
+ var CLOSE_VELOCITY = 0.4;
6
+ var SLOP = 4;
7
+ var EDGE = 2;
8
+ var NO_DRAG = "input, textarea, select, [contenteditable], [data-no-drag]";
9
+ var PHONE = "(pointer: coarse), (max-width: 639.98px)";
10
+ var STILL = "(prefers-reduced-motion: reduce)";
11
+ var matches = (query) => window.matchMedia(query).matches;
12
+ var vertical = (side) => side === "down" || side === "up";
13
+ function dragDirection(panel, preferred) {
14
+ if (!matches(PHONE)) {
15
+ return void 0;
16
+ }
17
+ const box = panel.getBoundingClientRect();
18
+ const top = box.top <= EDGE;
19
+ const bottom = box.bottom >= window.innerHeight - EDGE;
20
+ const left = box.left <= EDGE;
21
+ const right = box.right >= window.innerWidth - EDGE;
22
+ if (preferred) {
23
+ const spans = vertical(preferred) ? top && bottom : left && right;
24
+ return spans ? void 0 : preferred;
25
+ }
26
+ return bottom && !top ? "down" : right && !left ? "right" : left && !right ? "left" : void 0;
27
+ }
28
+ function scrolls(target, panel, side) {
29
+ for (let node = target; node && node !== panel.parentElement; node = node.parentElement) {
30
+ const style = getComputedStyle(node);
31
+ if (vertical(side)) {
32
+ const room = node.scrollHeight - node.clientHeight;
33
+ if (/(auto|scroll)/.test(style.overflowY) && room > 0 && (side === "down" ? node.scrollTop > 0 : node.scrollTop < room - 1)) {
34
+ return true;
35
+ }
36
+ } else if (/(auto|scroll)/.test(style.overflowX) && node.scrollWidth > node.clientWidth) {
37
+ return true;
38
+ }
39
+ }
40
+ return false;
41
+ }
42
+ function attachDragToClose(panel, options) {
43
+ let side;
44
+ let start;
45
+ let dragging = false;
46
+ let still = false;
47
+ let offset = 0;
48
+ let settle;
49
+ const shade = () => options().backdrop?.(panel);
50
+ const paint = (distance, spring) => {
51
+ const sign = side === "up" || side === "left" ? -1 : 1;
52
+ const transition = spring ? `${SETTLE_MS}ms ${EASE}` : "none";
53
+ panel.style.transition = spring ? `translate ${transition}` : transition;
54
+ panel.style.translate = side && vertical(side) ? `0 ${sign * distance}px` : `${sign * distance}px 0`;
55
+ const backdrop = shade();
56
+ if (backdrop) {
57
+ backdrop.style.transition = spring ? `filter ${transition}` : transition;
58
+ backdrop.style.filter = `opacity(${Math.max(0, 1 - distance / extent())})`;
59
+ }
60
+ };
61
+ const rest = () => {
62
+ window.clearTimeout(settle);
63
+ panel.style.translate = panel.style.transition = "";
64
+ const backdrop = shade();
65
+ if (backdrop) {
66
+ backdrop.style.filter = backdrop.style.transition = "";
67
+ }
68
+ };
69
+ const extent = () => (side && vertical(side) ? panel.offsetHeight : panel.offsetWidth) || 1;
70
+ const mark = () => {
71
+ const direction = dragDirection(panel, options().direction);
72
+ if (direction) {
73
+ panel.setAttribute("data-drag-to-close", direction);
74
+ } else {
75
+ panel.removeAttribute("data-drag-to-close");
76
+ }
77
+ };
78
+ const begin = (x, y, target) => {
79
+ side = dragDirection(panel, options().direction);
80
+ still = matches(STILL);
81
+ dragging = false;
82
+ offset = 0;
83
+ start = side && target instanceof Element && !target.closest(NO_DRAG) ? { x, y, at: performance.now() } : void 0;
84
+ };
85
+ const move = (x, y, target) => {
86
+ if (!start || !side) {
87
+ return false;
88
+ }
89
+ const dx = x - start.x;
90
+ const dy = y - start.y;
91
+ const along = side === "down" ? dy : side === "up" ? -dy : side === "right" ? dx : -dx;
92
+ const across = vertical(side) ? dx : dy;
93
+ if (!dragging) {
94
+ if (Math.abs(along) < SLOP && Math.abs(across) < SLOP) {
95
+ return false;
96
+ }
97
+ if (along <= 0 || Math.abs(across) > Math.abs(along) || target instanceof Element && scrolls(target, panel, side)) {
98
+ start = void 0;
99
+ return false;
100
+ }
101
+ dragging = true;
102
+ window.clearTimeout(settle);
103
+ panel.setAttribute("data-swiping", "");
104
+ }
105
+ offset = Math.max(0, along);
106
+ if (!still) {
107
+ paint(offset, false);
108
+ }
109
+ return true;
110
+ };
111
+ const end = () => {
112
+ const began = start;
113
+ const dragged = dragging;
114
+ start = void 0;
115
+ dragging = false;
116
+ if (!began || !dragged) {
117
+ return false;
118
+ }
119
+ panel.removeAttribute("data-swiping");
120
+ const velocity = offset / Math.max(1, performance.now() - began.at);
121
+ if (offset > extent() * CLOSE_FRACTION || velocity > CLOSE_VELOCITY) {
122
+ options().onClose();
123
+ return true;
124
+ }
125
+ if (!still) {
126
+ paint(0, true);
127
+ settle = window.setTimeout(rest, SETTLE_MS);
128
+ }
129
+ return true;
130
+ };
131
+ const touch = (event) => event.touches.length === 1 ? event.touches[0] : void 0;
132
+ const onTouchStart = (event) => {
133
+ const point = touch(event);
134
+ if (point) {
135
+ begin(point.clientX, point.clientY, event.target);
136
+ } else {
137
+ start = void 0;
138
+ }
139
+ };
140
+ const onTouchMove = (event) => {
141
+ const point = touch(event);
142
+ if (point && move(point.clientX, point.clientY, event.target) && event.cancelable) {
143
+ event.preventDefault();
144
+ }
145
+ };
146
+ const onTouchEnd = () => {
147
+ end();
148
+ };
149
+ const mouse = (event) => event.pointerType === "mouse";
150
+ const onPointerDown = (event) => {
151
+ if (mouse(event) && event.button === 0) {
152
+ begin(event.clientX, event.clientY, event.target);
153
+ }
154
+ };
155
+ const onPointerMove = (event) => {
156
+ if (mouse(event) && move(event.clientX, event.clientY, event.target)) {
157
+ event.preventDefault();
158
+ }
159
+ };
160
+ const swallow = (event) => {
161
+ event.preventDefault();
162
+ event.stopPropagation();
163
+ };
164
+ const onPointerUp = (event) => {
165
+ if (mouse(event) && end()) {
166
+ window.addEventListener("click", swallow, { capture: true, once: true });
167
+ window.setTimeout(
168
+ () => window.removeEventListener("click", swallow, { capture: true })
169
+ );
170
+ }
171
+ };
172
+ const phone = window.matchMedia(PHONE);
173
+ const observer = typeof ResizeObserver === "function" ? new ResizeObserver(mark) : void 0;
174
+ rest();
175
+ mark();
176
+ observer?.observe(panel);
177
+ phone.addEventListener("change", mark);
178
+ window.addEventListener("resize", mark);
179
+ panel.addEventListener("animationend", mark);
180
+ panel.addEventListener("transitionend", mark);
181
+ panel.addEventListener("touchstart", onTouchStart, { passive: true });
182
+ panel.addEventListener("touchmove", onTouchMove, { passive: false });
183
+ panel.addEventListener("touchend", onTouchEnd);
184
+ panel.addEventListener("touchcancel", onTouchEnd);
185
+ panel.addEventListener("pointerdown", onPointerDown);
186
+ window.addEventListener("pointermove", onPointerMove);
187
+ window.addEventListener("pointerup", onPointerUp);
188
+ return () => {
189
+ window.clearTimeout(settle);
190
+ observer?.disconnect();
191
+ phone.removeEventListener("change", mark);
192
+ window.removeEventListener("resize", mark);
193
+ panel.removeEventListener("animationend", mark);
194
+ panel.removeEventListener("transitionend", mark);
195
+ panel.removeEventListener("touchstart", onTouchStart);
196
+ panel.removeEventListener("touchmove", onTouchMove);
197
+ panel.removeEventListener("touchend", onTouchEnd);
198
+ panel.removeEventListener("touchcancel", onTouchEnd);
199
+ panel.removeEventListener("pointerdown", onPointerDown);
200
+ window.removeEventListener("pointermove", onPointerMove);
201
+ window.removeEventListener("pointerup", onPointerUp);
202
+ panel.removeAttribute("data-drag-to-close");
203
+ panel.removeAttribute("data-swiping");
204
+ };
205
+ }
206
+ export {
207
+ attachDragToClose,
208
+ dragDirection
209
+ };
210
+ //# sourceMappingURL=drag.js.map
@@ -0,0 +1,6 @@
1
+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as SurfaceProps, S as SwipeDirection, u as useEngineParts } from '../engine-D2iRshfW.js';
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-TxMNPD2g.js';
2
2
  import 'react';
3
3
  import '@base-ui/react/dialog';
@@ -9,7 +9,10 @@ import {
9
9
  useContext
10
10
  } from "react";
11
11
  import { composeRefs, part, partId } from "../internal/slot.js";
12
+ import { attachDragToClose } from "./drag.js";
13
+ import { provideGesture, useDragToClose } from "./drag-to-close.js";
12
14
  import { jsx, jsxs } from "react/jsx-runtime";
15
+ provideGesture(attachDragToClose);
13
16
  var PartsContext = /* @__PURE__ */ createContext(null);
14
17
  function useEngineParts() {
15
18
  const parts = useContext(PartsContext);
@@ -43,6 +46,12 @@ function Popup({
43
46
  const { contentProps, contentRef, presentation, state } = props;
44
47
  const { id: _ownId, ...rest } = contentProps;
45
48
  const id = partId(contentProps);
49
+ const dragRef = useDragToClose({
50
+ onClose: props.onClose,
51
+ enabled: props.open && props.dragToClose && presentation !== "dialog",
52
+ ...props.dragDirection ? { direction: props.dragDirection } : {},
53
+ backdrop: (panel) => panel.closest("[data-base-ui-portal]")?.querySelector("[data-zappie-backdrop]")
54
+ });
46
55
  return /* @__PURE__ */ jsx(
47
56
  Component,
48
57
  {
@@ -61,7 +70,7 @@ function Popup({
61
70
  "data-presentation": presentation,
62
71
  "data-state": props.open ? "open" : "closed"
63
72
  },
64
- composeRefs(baseRef, contentRef)
73
+ composeRefs(baseRef, contentRef, dragRef)
65
74
  );
66
75
  }
67
76
  }
@@ -121,7 +130,7 @@ function Surface(props) {
121
130
  "data-state": props.open ? "open" : "closed"
122
131
  }
123
132
  ),
124
- /* @__PURE__ */ jsx(Drawer.VirtualKeyboardProvider, { children: /* @__PURE__ */ jsx(Drawer.Viewport, { children: /* @__PURE__ */ jsx(
133
+ /* @__PURE__ */ jsx(Drawer.VirtualKeyboardProvider, { children: /* @__PURE__ */ jsx(Drawer.Viewport, { "data-base-ui-swipe-ignore": "", children: /* @__PURE__ */ jsx(
125
134
  Popup,
126
135
  {
127
136
  props,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/overlay/engine.tsx"],
4
- "mappings": ";;;AAGA,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,aAAa,MAAM,cAA8B;AA0EtD,cAiDM,YAjDN;AA9CJ,IAAM,eAA+B,8BAA4B,IAAI;AAC9D,SAAS,iBAAiB;AAC/B,QAAM,QAAQ,WAAW,YAAY;AACrC,MAAI,CAAC,OAAO;AACV,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEA,SAAS,cAAc,OAAqB;AAC1C,SAAO,CAAC,MAAe,YAA2B;AAChD,QAAI,MAAM;AACR,YAAM,OAAO;AACb;AAAA,IACF;AACA,UAAM,WACJ,QAAQ,WAAW,eACd,MAAM,WACP,QAAQ,WAAW,mBAAmB,QAAQ,WAAW,cACvD,MAAM,oBACN;AACR,eAAW,QAAQ,KAAK;AACxB,QAAI,QAAQ,OAAO,oBAAoB,UAAU;AAC/C,cAAQ,OAAO;AACf;AAAA,IACF;AACA,UAAM,QAAQ;AAAA,EAChB;AACF;AACA,SAAS,MAAM;AAAA,EACb;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,QAAM,EAAE,cAAc,YAAY,cAAc,MAAM,IAAI;AAC1D,QAAM,EAAE,IAAI,QAAQ,GAAG,KAAK,IAAI;AAGhC,QAAM,KAAK,OAAO,YAA4C;AAC9D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,IAAI,MAAM,MAAM;AAAA,MAEhB,cAAc,MACZ,SACG,eAAe,MAAM,MAAM,SAAS,GACnC,cAA2B,kBAAkB,KAAK;AAAA,MAExD,YAAY,MAAM,MAAM,QAAQ,WAAW;AAAA,MAC3C,QAAQ,CAAC,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AA;AAAA,MACC,QAAQ,CAAC,SAAS;AAChB,cAAM,EAAE,KAAK,SAAS,GAAG,KAAK,IAAI;AAMlC,eAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,UACA,EAAE,MAAM,UAAU,GAAG,KAAK;AAAA,UAC1B,YAAY,SAAS,GAAG;AAAA,QAC1B;AAAA,MACF;AAAA;AAAA,EACF;AAEJ,CAAC;",
5
5
  "names": ["EngineTitle", "EngineClose"]
6
6
  }
@@ -139,6 +139,7 @@ function Root({
139
139
  ...overlay,
140
140
  presentation: resolved,
141
141
  swipeDirection: swipeDirection ?? (resolved === "sheet" ? "right" : "down"),
142
+ dragDirection: swipeDirection,
142
143
  contentId,
143
144
  setContentId,
144
145
  trigger
@@ -327,7 +328,14 @@ function Frame({
327
328
  );
328
329
  }
329
330
  var Content = /* @__PURE__ */ forwardRef(
330
- function Content2({ onEscape, onInteractOutside, forceMount, container, ...props }, ref) {
331
+ function Content2({
332
+ onEscape,
333
+ onInteractOutside,
334
+ forceMount,
335
+ container,
336
+ dragToClose = true,
337
+ ...props
338
+ }, ref) {
331
339
  const ctx = useContextValue();
332
340
  const parent = useContext(ContentContext);
333
341
  const [loaded, setEngine] = useState(loadedOverlayEngine);
@@ -417,6 +425,8 @@ var Content = /* @__PURE__ */ forwardRef(
417
425
  open: ctx.isOpen,
418
426
  presentation: ctx.presentation,
419
427
  swipeDirection: ctx.swipeDirection,
428
+ dragToClose,
429
+ dragDirection: ctx.dragDirection,
420
430
  contentId: ctx.contentId,
421
431
  trigger: ctx.trigger,
422
432
  onOpen: () => ctx.open(),