@zappie/foundations 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @zappie/foundations
2
2
 
3
+ ## 0.17.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 1737d6b: A `deferred()` component whose code fails to load shows a retry notice by default, so a shopper who taps never sees nothing. The notice, `OverlayRetry`, is a `role="alert"` saying "This didn't load." with Try again, which loads the code again, and Close. Close and Escape hide it and call the component's `onOpenChange(false)` or `onClose()`. Focus moves to Try again when the shopper opened the component. The notice has no styles of its own.
8
+
9
+ `failed` now also receives `close`, and still replaces the default. Render `OverlayRetry` from it to set the message or a class.
10
+
11
+ The starter's retry notice is now foundations' `OverlayRetry` with the starter's class.
12
+
3
13
  ## 0.16.0
4
14
 
5
15
  ### Minor Changes
package/README.md CHANGED
@@ -92,11 +92,10 @@ function Header() {
92
92
  - Pass `fallback` to hold an inline part's place while its code loads, for
93
93
  example a placeholder label. It shows only while `open` is true and the code
94
94
  is not in yet, and it never suspends.
95
- - Pass `failed` to show something when the code fails to load, such as a
96
- message with a button that calls `retry`. It shows only while `open` is true.
97
- Without it nothing shows, so a shopper who taps and sees nothing never knows
98
- to tap again. A later `preload()`, such as the one the next tap on the
99
- trigger starts, also retries, and the component renders when it succeeds.
95
+ - When the code fails to load, `Component` shows a retry notice while `open`
96
+ is true, so a tap never shows nothing. See [Load failures](#load-failures).
97
+ A later `preload()`, such as the one the next tap on the trigger starts, also
98
+ retries, and the component renders when it succeeds.
100
99
  - `preload()` starts the load and returns its promise. Calls share one load. A
101
100
  failed load is forgotten, so the next `preload()` or the next open tries again.
102
101
  - `preloadWhenIdle({ timeout? })` loads the code when the browser is idle and
@@ -115,6 +114,49 @@ then the panel is hidden from assistive technology and takes no keys, presses or
115
114
  scrolls, apart from Escape and an outside press, which close it. Style the panel
116
115
  and `[data-zappie-backdrop]` as usual: both frames match them.
117
116
 
117
+ ### Load failures
118
+
119
+ A chunk can fail to load on a bad network or while a deploy swaps chunks.
120
+ Without `failed`, `Component` shows `OverlayRetry` in its place:
121
+
122
+ - a `role="alert"` paragraph saying "This didn't load.", which screen readers
123
+ announce;
124
+ - Try again, which loads the code again and renders the component when it
125
+ arrives;
126
+ - Close, and Escape, which hide the notice and call the component's
127
+ `onOpenChange(false)` or `onClose()` when it has one, so the next tap opens
128
+ it again.
129
+
130
+ Focus moves to Try again when the shopper opened the component. A part
131
+ rendered with `open` from the start, such as an inline account button, leaves
132
+ focus where it is. The notice has no styles of its own. It renders in the
133
+ component's place, so give it a class for an overlay that would sit above the
134
+ page.
135
+
136
+ Pass `failed={(retry, close) => ...}` to name what didn't load or to style it.
137
+ `OverlayRetry` takes the same `retry` and `close`, a `message` and a
138
+ `className`:
139
+
140
+ ```tsx
141
+ import { OverlayRetry } from "@zappie/foundations";
142
+
143
+ <BagSheet.Component
144
+ open={open}
145
+ onClose={() => setOpen(false)}
146
+ failed={(retry, close) => (
147
+ <OverlayRetry
148
+ message="Your bag didn't load."
149
+ retry={retry}
150
+ close={close}
151
+ className="retry-notice"
152
+ />
153
+ )}
154
+ />;
155
+ ```
156
+
157
+ The notice is part of the initial entry, not a lazy chunk, because it shows
158
+ when chunks don't load.
159
+
118
160
  ## Drag to close
119
161
 
120
162
  On a phone or touch screen, a drawer or sheet from `Overlay` closes when it is
@@ -1,2 +1,2 @@
1
- "use client";import{Fragment,useEffect,useMemo,useState}from"react";import{jsx}from"react/jsx-runtime";function component(value){if(typeof value==="object"&&value!==null&&"default"in value&&!("$$typeof"in value)){return value.default}return value}var ignore=()=>{};function deferred(load){let loaded;let pending;const waiting=new Set;const preload=()=>{if(loaded){return Promise.resolve(loaded)}if(!pending){const attempt=new Promise(resolve=>resolve(load())).then(component).then(result=>{loaded=result;for(const notify of waiting){notify(result)}return result},error=>{if(pending===attempt){pending=void 0}throw error});attempt.catch(ignore);pending=attempt}return pending};const preloadWhenIdle=(options={})=>{if(typeof window==="undefined"||loaded){return ignore}const start=()=>{preload().catch(ignore)};if(typeof window.requestIdleCallback==="function"){const handle2=window.requestIdleCallback(start,options.timeout===void 0?void 0:{timeout:options.timeout});return()=>window.cancelIdleCallback(handle2)}const handle=window.setTimeout(start,options.timeout??1);return()=>window.clearTimeout(handle)};function DeferredComponent({fallback=null,failed,...props}){const{open}=props;const[ready,setReady]=useState(()=>loaded);const[opened,setOpened]=useState(open);const[failure,setFailure]=useState(false);const[retries,setRetries]=useState(0);if(open&&!opened){setOpened(true)}const Loaded=ready??loaded;useEffect(()=>{if(Loaded){return}const notify=value=>setReady(()=>value);waiting.add(notify);return()=>{waiting.delete(notify)}},[Loaded]);useEffect(()=>{if(!open||Loaded){return}let active=true;setFailure(false);preload().then(value=>{if(active){setReady(()=>value)}},()=>{if(active){setFailure(true)}});return()=>{active=false}},[open,Loaded,retries]);if(!(open||opened)){return null}if(!Loaded){if(!open){return null}return jsx(Fragment,{children:failure&&failed?failed(()=>setRetries(count=>count+1)):fallback})}return jsx(Loaded,{...props})}DeferredComponent.displayName="Deferred";return{preload,preloadWhenIdle,Component:DeferredComponent}}function useIntentPreload(target){return useMemo(()=>{const start=()=>{target.preload().catch(ignore)};return{onPointerEnter:start,onPointerDown:start,onFocus:start}},[target])}export{deferred,useIntentPreload};
1
+ "use client";import{Fragment,useEffect,useMemo,useState}from"react";import{OverlayRetry}from"./retry.js";import{jsx}from"react/jsx-runtime";function component(value){if(typeof value==="object"&&value!==null&&"default"in value&&!("$$typeof"in value)){return value.default}return value}var ignore=()=>{};function deferred(load){let loaded;let pending;const waiting=new Set;const preload=()=>{if(loaded){return Promise.resolve(loaded)}if(!pending){const attempt=new Promise(resolve=>resolve(load())).then(component).then(result=>{loaded=result;for(const notify of waiting){notify(result)}return result},error=>{if(pending===attempt){pending=void 0}throw error});attempt.catch(ignore);pending=attempt}return pending};const preloadWhenIdle=(options={})=>{if(typeof window==="undefined"||loaded){return ignore}const start=()=>{preload().catch(ignore)};if(typeof window.requestIdleCallback==="function"){const handle2=window.requestIdleCallback(start,options.timeout===void 0?void 0:{timeout:options.timeout});return()=>window.cancelIdleCallback(handle2)}const handle=window.setTimeout(start,options.timeout??1);return()=>window.clearTimeout(handle)};function DeferredComponent({fallback=null,failed,...props}){const{open}=props;const[ready,setReady]=useState(()=>loaded);const[opened,setOpened]=useState(open);const[failure,setFailure]=useState(false);const[startedOpen]=useState(open);const[retries,setRetries]=useState(0);if(open&&!opened){setOpened(true)}const Loaded=ready??loaded;useEffect(()=>{if(Loaded){return}const notify=value=>setReady(()=>value);waiting.add(notify);return()=>{waiting.delete(notify)}},[Loaded]);useEffect(()=>{if(!open||Loaded){return}let active=true;setFailure(false);preload().then(value=>{if(active){setReady(()=>value)}},()=>{if(active){setFailure(true)}});return()=>{active=false}},[open,Loaded,retries]);if(!(open||opened)){return null}if(!Loaded){if(!open){return null}if(failure==="closed"){return null}if(!failure){return jsx(Fragment,{children:fallback})}const retry=()=>setRetries(count=>count+1);const close=()=>{setFailure("closed");const{onOpenChange,onClose}=props;if(typeof onOpenChange==="function"){onOpenChange(false)}else if(typeof onClose==="function"){onClose()}};return jsx(Fragment,{children:failed?failed(retry,close):jsx(OverlayRetry,{retry,close,focus:!startedOpen})})}return jsx(Loaded,{...props})}DeferredComponent.displayName="Deferred";return{preload,preloadWhenIdle,Component:DeferredComponent}}function useIntentPreload(target){return useMemo(()=>{const start=()=>{target.preload().catch(ignore)};return{onPointerEnter:start,onPointerDown:start,onFocus:start}},[target])}export{deferred,useIntentPreload};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/deferred/index.tsx"],
4
- "mappings": "aACA,OACE,SACA,UACA,QACA,aAIK,QAwNC,mCA9IR,SAAS,UAAU,MAAqC,CACtD,GACE,OAAO,QAAU,UACjB,QAAU,MACV,YAAa,OACb,EAAE,aAAc,OAChB,CACA,OAAO,MAAM,OACf,CAC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AAO,KAAK,EAEnB,IAAC,cAAa,MAAc,MAAc,MAAO,CAAC,YAAa,EAEnE,CAEJ,CACA,OAAO,IAAC,QAAQ,GAAI,MAAmC,CACzD,CACA,kBAAkB,YAAc,WAEhC,MAAO,CAEL,QACA,gBACA,UAAW,iBACb,CACF,CAWO,SAAS,iBAAiB,OAEP,CACxB,OAAO,QAAQ,IAAM,CACnB,MAAM,MAAQ,IAAM,CAClB,OAAO,QAAQ,EAAE,MAAM,MAAM,CAC/B,EACA,MAAO,CAAE,eAAgB,MAAO,cAAe,MAAO,QAAS,KAAM,CACvE,EAAG,CAAC,MAAM,CAAC,CACb",
5
5
  "names": ["handle"]
6
6
  }
@@ -0,0 +1,2 @@
1
+ "use client";import{useEffect,useRef}from"react";import{jsx,jsxs}from"react/jsx-runtime";function OverlayRetry({message="This didn't load.",retry,close,focus=true,className}){const button=useRef(null);useEffect(()=>{if(focus){button.current?.focus()}},[focus]);const onKeyDown=event=>{if(event.key==="Escape"){close()}};return jsxs("p",{role:"alert",className,"data-zappie-region":"Retry notice",children:[jsx("span",{children:message})," ",jsx("button",{ref:button,type:"button",onClick:retry,onKeyDown,children:"Try again"})," ",jsx("button",{type:"button",onClick:close,onKeyDown,children:"Close"})]})}export{OverlayRetry};
2
+ //# sourceMappingURL=retry.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/deferred/retry.tsx"],
4
+ "mappings": "aACA,OAAS,UAAW,WAAkC,QA6ClD,OACE,IADF,6BAnBG,SAAS,aAAa,CAC3B,QAAU,oBACV,MACA,MACA,MAAQ,KACR,SACF,EAAsB,CACpB,MAAM,OAAS,OAA0B,IAAI,EAC7C,UAAU,IAAM,CACd,GAAI,MAAO,CACT,OAAO,SAAS,MAAM,CACxB,CACF,EAAG,CAAC,KAAK,CAAC,EACV,MAAM,UAAa,OAAyB,CAC1C,GAAI,MAAM,MAAQ,SAAU,CAC1B,MAAM,CACR,CACF,EACA,OACE,KAAC,KAAE,KAAK,QAAQ,UAAsB,qBAAmB,eACvD,cAAC,QAAM,iBAAQ,EAAQ,IACvB,IAAC,UAAO,IAAK,OAAQ,KAAK,SAAS,QAAS,MAAO,UAAsB,qBAEzE,EAAU,IACV,IAAC,UAAO,KAAK,SAAS,QAAS,MAAO,UAAsB,iBAE5D,GACF,CAEJ",
5
+ "names": []
6
+ }
@@ -11,10 +11,11 @@ type DeferredProps<P> = Omit<P, "open"> & {
11
11
  /** Shown while `open` is true and the code is still loading, for inline parts that should hold their place. */
12
12
  fallback?: ReactNode;
13
13
  /**
14
- * Shown while `open` is true and the code failed to load. Call `retry` to load it again.
15
- * A later `preload()`, such as the next tap on the trigger, also retries and renders on success.
14
+ * Shown while `open` is true and the code failed to load. Call `retry` to load it again, and
15
+ * `close` to hide it. A later `preload()`, such as the next tap on the trigger, also retries and
16
+ * renders on success. Defaults to `OverlayRetry`, a notice with Try again and Close.
16
17
  */
17
- failed?: (retry: () => void) => ReactNode;
18
+ failed?: (retry: () => void, close: () => void) => ReactNode;
18
19
  };
19
20
  /** Options for `preloadWhenIdle`. */
20
21
  type DeferredIdleOptions = {
@@ -41,7 +42,7 @@ type Deferred<P> = {
41
42
  /**
42
43
  * Renders nothing until `open` is first true and the code is in. When
43
44
  * `open` turns true it loads the code and renders as soon as it arrives. If
44
- * the load fails it shows `failed` and renders once a retry or a later
45
+ * the load fails it shows `failed`, or `OverlayRetry` without it, and renders once a retry or a later
45
46
  * `preload()` succeeds. It never suspends. After the first open the component stays mounted and
46
47
  * every prop passes through, `open` included, so it can run its own exit.
47
48
  */
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ import * as _zappie_sdk from '@zappie/sdk';
6
6
  import { Branch as Branch$1, CartLine, Money as Money$1, CartLineInput, CartIssue, CartFix, Quote, DeliveryAddress, CartFulfilment, OptionGroup as OptionGroup$1, Item, Choice as Choice$1, MoneyFormatOptions, PaymentMethodKind, Category, Menu, Store, OpeningTime } from '@zappie/sdk';
7
7
  import { Coordinates } from '@zappie/sdk/branches';
8
8
  import { useCart } from '@zappie/sdk/react';
9
- export { D as Deferred, a as DeferredIdleOptions, b as DeferredProps, I as IntentPreloadHandlers, d as deferred, u as useIntentPreload } from './index-B1NMxq0i.js';
9
+ export { D as Deferred, a as DeferredIdleOptions, b as DeferredProps, I as IntentPreloadHandlers, d as deferred, u as useIntentPreload } from './index-B1mCF3ft.js';
10
10
  import { S as ScheduleBlock, a as ScheduleSlot } from './window-BAFAfQnw.js';
11
11
  export { b as ScheduleDay, c as ScheduleMenu, d as ScheduleOptions } from './window-BAFAfQnw.js';
12
12
  export { O as Overlay, u as useOverlay } from './react-CFPTPzAO.js';
@@ -331,6 +331,31 @@ declare const Totals: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttribut
331
331
  children?: react.ReactNode | ((state: TotalsState) => react.ReactNode);
332
332
  } & react.RefAttributes<HTMLElement>>;
333
333
 
334
+ /** Props for `OverlayRetry`. */
335
+ type OverlayRetryProps = {
336
+ /** What didn't load. Defaults to "This didn't load." */
337
+ message?: string;
338
+ /** Loads the code again. */
339
+ retry: () => void;
340
+ /** Hides the notice. Escape on either button calls it too. */
341
+ close: () => void;
342
+ /** Moves focus to Try again when the notice appears. Defaults to `true`. */
343
+ focus?: boolean;
344
+ /** Your class. The notice has no styles of its own. */
345
+ className?: string;
346
+ };
347
+ /**
348
+ * A notice shown in place of a deferred overlay whose code didn't load, with Try again and Close.
349
+ * It is a `role="alert"`, so screen readers announce it, and focus moves to Try again. `deferred()`
350
+ * shows it when you pass no `failed`. Render it from your own `failed` to set the message or class.
351
+ *
352
+ * @example
353
+ * failed={(retry, close) => (
354
+ * <OverlayRetry message="Your bag didn't load." retry={retry} close={close} className="retry" />
355
+ * )}
356
+ */
357
+ declare function OverlayRetry({ message, retry, close, focus, className, }: OverlayRetryProps): react.JSX.Element;
358
+
334
359
  declare function useCombobox<T>(results: readonly T[], onSelect: (item: T) => void): {
335
360
  setListId: react.Dispatch<react.SetStateAction<string>>;
336
361
  registerOption: (index: number, id: string) => void;
@@ -1077,5 +1102,5 @@ declare const OpenStatus: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttr
1077
1102
  /** The installed @zappie/foundations version. */
1078
1103
  declare const FOUNDATIONS_VERSION: string;
1079
1104
 
1080
- export { Account, AccountNotConfiguredError, Address, Branch, BranchMap, Cart, Choice, DeliveryMap, FOUNDATIONS_VERSION, Fulfilment, Image, ItemForm, ItemNote, Money, OpenStatus, OptionGroup, Otp, PartProps, PaymentMethods, PoweredByZappie, Quantity, Schedule, ScheduleBlock, ScheduleSlot, Search, Totals, ZAPPIE_ATTRIBUTION_TEXT, ZAPPIE_ATTRIBUTION_URL, ZappieAccountLink, canOrderAhead, contactLinks, createSearchIndex, formatOpeningHours, formatWallClock, getOpenStatus, parseWallClock, preloadOverlay, useControllableState, useDragToClose, useZappieAccountUrl, zappieAccountUrl, zappieEnvironment, zappieSupportUrl };
1081
- export type { ActiveGroup, AddressState, AddressSuggestion, BranchMapLoadErrorState, BranchMapProps, ContactLink, Customer, DeliveryMapProps, DragDirection, DragToCloseOptions, ImageProps, ItemFormContext, ItemFormInvalidGroup, ItemFormProps, MapLoadErrorState, NoteState, PaymentMethod, PoweredByZappieProps, QuantityProps, QuantityState, ScheduleState, ScheduleStatus, SearchResult, SearchSource, SearchState, SignInOptions, TotalsState, ZappieSupportContext };
1105
+ export { Account, AccountNotConfiguredError, Address, Branch, BranchMap, Cart, Choice, DeliveryMap, FOUNDATIONS_VERSION, Fulfilment, Image, ItemForm, ItemNote, Money, OpenStatus, OptionGroup, Otp, OverlayRetry, PartProps, PaymentMethods, PoweredByZappie, Quantity, Schedule, ScheduleBlock, ScheduleSlot, Search, Totals, ZAPPIE_ATTRIBUTION_TEXT, ZAPPIE_ATTRIBUTION_URL, ZappieAccountLink, canOrderAhead, contactLinks, createSearchIndex, formatOpeningHours, formatWallClock, getOpenStatus, parseWallClock, preloadOverlay, useControllableState, useDragToClose, useZappieAccountUrl, zappieAccountUrl, zappieEnvironment, zappieSupportUrl };
1106
+ export type { ActiveGroup, AddressState, AddressSuggestion, BranchMapLoadErrorState, BranchMapProps, ContactLink, Customer, DeliveryMapProps, DragDirection, DragToCloseOptions, ImageProps, ItemFormContext, ItemFormInvalidGroup, ItemFormProps, MapLoadErrorState, NoteState, OverlayRetryProps, PaymentMethod, PoweredByZappieProps, QuantityProps, QuantityState, ScheduleState, ScheduleStatus, SearchResult, SearchSource, SearchState, SignInOptions, TotalsState, ZappieSupportContext };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use client";import{PACKAGE_VERSION}from"./version.js";import{Account,AccountNotConfiguredError}from"./account/index.js";import{useZappieAccountUrl,ZappieAccountLink,zappieAccountUrl,zappieEnvironment}from"./account/zappie-account.js";import{PoweredByZappie,ZAPPIE_ATTRIBUTION_TEXT,ZAPPIE_ATTRIBUTION_URL}from"./attribution/powered-by-zappie.js";import{BranchMap,DeliveryMap}from"./branch-map/index.js";import{Cart,Totals}from"./cart/index.js";import{deferred,useIntentPreload}from"./deferred/index.js";import{Address}from"./fulfilment/address-picker.js";import{Branch}from"./fulfilment/branch-picker.js";import{Schedule}from"./fulfilment/schedule.js";import{Fulfilment}from"./fulfilment/switch.js";import{useControllableState}from"./internal/use-controllable-state.js";export*from"./item-form/index.js";import{Image}from"./media/image.js";import{Money}from"./money.js";import{Otp}from"./otp/input.js";import{useDragToClose}from"./overlay/drag-to-close.js";import{preloadOverlay}from"./overlay/load.js";import{Overlay,useOverlay}from"./overlay/react.js";import{PaymentMethods}from"./payment/methods.js";import{createSearchIndex,Search}from"./search/index.js";import{contactLinks,zappieSupportUrl}from"./status/contact.js";import{canOrderAhead,formatOpeningHours,formatWallClock,getOpenStatus,parseWallClock}from"./status/hours.js";import{OpenStatus}from"./status/open-status.js";var FOUNDATIONS_VERSION=PACKAGE_VERSION;export{Account,AccountNotConfiguredError,Address,Branch,BranchMap,Cart,DeliveryMap,FOUNDATIONS_VERSION,Fulfilment,Image,Money,OpenStatus,Otp,Overlay,PaymentMethods,PoweredByZappie,Schedule,Search,Totals,ZAPPIE_ATTRIBUTION_TEXT,ZAPPIE_ATTRIBUTION_URL,ZappieAccountLink,canOrderAhead,contactLinks,createSearchIndex,deferred,formatOpeningHours,formatWallClock,getOpenStatus,parseWallClock,preloadOverlay,useControllableState,useDragToClose,useIntentPreload,useOverlay,useZappieAccountUrl,zappieAccountUrl,zappieEnvironment,zappieSupportUrl};
1
+ "use client";import{PACKAGE_VERSION}from"./version.js";import{Account,AccountNotConfiguredError}from"./account/index.js";import{useZappieAccountUrl,ZappieAccountLink,zappieAccountUrl,zappieEnvironment}from"./account/zappie-account.js";import{PoweredByZappie,ZAPPIE_ATTRIBUTION_TEXT,ZAPPIE_ATTRIBUTION_URL}from"./attribution/powered-by-zappie.js";import{BranchMap,DeliveryMap}from"./branch-map/index.js";import{Cart,Totals}from"./cart/index.js";import{deferred,useIntentPreload}from"./deferred/index.js";import{OverlayRetry}from"./deferred/retry.js";import{Address}from"./fulfilment/address-picker.js";import{Branch}from"./fulfilment/branch-picker.js";import{Schedule}from"./fulfilment/schedule.js";import{Fulfilment}from"./fulfilment/switch.js";import{useControllableState}from"./internal/use-controllable-state.js";export*from"./item-form/index.js";import{Image}from"./media/image.js";import{Money}from"./money.js";import{Otp}from"./otp/input.js";import{useDragToClose}from"./overlay/drag-to-close.js";import{preloadOverlay}from"./overlay/load.js";import{Overlay,useOverlay}from"./overlay/react.js";import{PaymentMethods}from"./payment/methods.js";import{createSearchIndex,Search}from"./search/index.js";import{contactLinks,zappieSupportUrl}from"./status/contact.js";import{canOrderAhead,formatOpeningHours,formatWallClock,getOpenStatus,parseWallClock}from"./status/hours.js";import{OpenStatus}from"./status/open-status.js";var FOUNDATIONS_VERSION=PACKAGE_VERSION;export{Account,AccountNotConfiguredError,Address,Branch,BranchMap,Cart,DeliveryMap,FOUNDATIONS_VERSION,Fulfilment,Image,Money,OpenStatus,Otp,Overlay,OverlayRetry,PaymentMethods,PoweredByZappie,Schedule,Search,Totals,ZAPPIE_ATTRIBUTION_TEXT,ZAPPIE_ATTRIBUTION_URL,ZappieAccountLink,canOrderAhead,contactLinks,createSearchIndex,deferred,formatOpeningHours,formatWallClock,getOpenStatus,parseWallClock,preloadOverlay,useControllableState,useDragToClose,useIntentPreload,useOverlay,useZappieAccountUrl,zappieAccountUrl,zappieEnvironment,zappieSupportUrl};
2
2
  //# sourceMappingURL=index.js.map
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,OAAS,oBAAuB,eAIhC,OAAS,QAAS,8BAAiC,qBAEnD,OACE,oBACA,kBACA,iBACA,sBACK,8BACP,OACE,gBACA,wBACA,2BACK,qCAEP,OAAS,UAAW,gBAAmB,wBAOvC,OAAS,KAAM,WAAc,kBAE7B,OAAS,SAAU,qBAAwB,sBAO3C,OAAS,YAAe,iCAKxB,OAAS,WAAc,gCAEvB,OAAS,aAAgB,2BAEzB,OAAS,eAAkB,yBAS3B,OAAS,yBAA4B,uCACrC,WAAc,uBACd,OAAS,UAAa,mBAEtB,OAAS,UAAa,aACtB,OAAS,QAAW,iBACpB,OAAS,mBAAsB,6BAK/B,OAAS,mBAAsB,oBAC/B,OAAS,QAAS,eAAkB,qBACpC,OAAS,mBAAsB,uBAE/B,OAAS,kBAAmB,WAAc,oBAE1C,OAAS,aAAc,qBAAwB,sBAE/C,OACE,cACA,mBACA,gBACA,cACA,mBACK,oBACP,OAAS,eAAkB,0BA3EpB,IAAM,oBAA8B",
4
+ "mappings": "aACA,OAAS,oBAAuB,eAIhC,OAAS,QAAS,8BAAiC,qBAEnD,OACE,oBACA,kBACA,iBACA,sBACK,8BACP,OACE,gBACA,wBACA,2BACK,qCAEP,OAAS,UAAW,gBAAmB,wBAOvC,OAAS,KAAM,WAAc,kBAE7B,OAAS,SAAU,qBAAwB,sBAO3C,OAAS,iBAAoB,sBAE7B,OAAS,YAAe,iCAKxB,OAAS,WAAc,gCAEvB,OAAS,aAAgB,2BAEzB,OAAS,eAAkB,yBAS3B,OAAS,yBAA4B,uCACrC,WAAc,uBACd,OAAS,UAAa,mBAEtB,OAAS,UAAa,aACtB,OAAS,QAAW,iBACpB,OAAS,mBAAsB,6BAK/B,OAAS,mBAAsB,oBAC/B,OAAS,QAAS,eAAkB,qBACpC,OAAS,mBAAsB,uBAE/B,OAAS,kBAAmB,WAAc,oBAE1C,OAAS,aAAc,qBAAwB,sBAE/C,OACE,cACA,mBACA,gBACA,cACA,mBACK,oBACP,OAAS,eAAkB,0BA7EpB,IAAM,oBAA8B",
5
5
  "names": []
6
6
  }
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- var PACKAGE_VERSION=true?"0.16.0":"0.0.0-development";export{PACKAGE_VERSION};
1
+ var PACKAGE_VERSION=true?"0.17.0":"0.0.0-development";export{PACKAGE_VERSION};
2
2
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zappie/foundations",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "UI-less React primitives for Zappie storefronts: behaviour, state and accessibility without styles.",
5
5
  "type": "module",
6
6
  "sideEffects": false,