@zappie/foundations 0.26.0 → 0.27.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,11 @@
1
1
  # @zappie/foundations
2
2
 
3
+ ## 0.27.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 34ea474: A menu that needs a day's notice and takes orders one day ahead can be scheduled. `scheduleSlots`, `scheduleDays`, `scheduleBlocker` and `Schedule` count the days ahead as the API does: from the first day with a time past the notice, skipping days with none, and only days every menu in the bag is served. Before, they counted 24-hour spans from now, so a pre-order menu with 24 hours' notice and 1 day ahead had no time at all and every quote said `schedule_invalid`. `maxDays` is the most days with a time to offer.
8
+
3
9
  ## 0.26.0
4
10
 
5
11
  ### Minor Changes
@@ -1,2 +1,2 @@
1
- import{canOrderAhead,getOpenStatus,localParts,openingIntervals}from"../status/hours.js";var labels=new Map;function grid(branch,timezone,now,menus,step,days,earliest){const latest=now.getTime()+days*864e5;const menuIntervals=menus.flatMap(({schedule})=>schedule?.openingTimes.length?[openingIntervals({...branch,openingTimes:schedule.openingTimes,specialHours:[]},timezone,now,days+1)]:[]);let label=labels.get(timezone);if(!label){label=new Intl.DateTimeFormat("en",{timeZone:timezone,hour:"numeric",minute:"2-digit",timeZoneName:"shortOffset"});labels.set(timezone,label)}const slots=[];for(const{start,end}of openingIntervals(branch,timezone,now,days+1)){for(let instant=start+Math.max(0,Math.ceil((earliest-start)/step))*step;instant<end&&instant<=latest;instant+=step){if(menuIntervals.every(intervals=>intervals.some(interval=>interval.start<=instant&&interval.end>instant))){const date=new Date(instant);slots.push({value:date.toISOString(),date:localParts(date,timezone).date,label:label.format(date)})}}}return slots}function explain(branch,timezone,now,menus,{intervalMinutes=30,maxDays=90,noticeMinutes=0}={},span=0){if(!Number.isInteger(intervalMinutes)||intervalMinutes<1||!Number.isInteger(maxDays)||maxDays<1||maxDays>90||!(noticeMinutes>=0&&noticeMinutes<Infinity)||!Number.isInteger(span)||span<0||span>90){throw new RangeError("Schedule requires a positive interval, 1\u201390 days and a non-negative notice")}const preorders=menus.filter(menu=>menu.schedule?.preorder);const ahead=branch.orderAheadDays;let days=Math.min(maxDays,ahead>0||!preorders.some(menu=>menu.schedule.preorderMaxDays>0)?ahead??14:90);let notice=noticeMinutes;let daysMenu;let noticeMenu;for(const{id,schedule}of preorders){const limit=schedule.preorderMaxDays;if(limit>0&&limit<days){days=limit;daysMenu=id}if(schedule.preorderNoticeHours*60>notice){notice=schedule.preorderNoticeHours*60;noticeMenu=id}}const step=intervalMinutes*6e4;const scheduling=branch.fulfilment.scheduling&&(preorders.length>0||canOrderAhead(branch));const slots=scheduling?grid(branch,timezone,now,menus,step,days,now.getTime()+notice*6e4):[];let why;return{slots,why(date){if(!scheduling){return{reason:"no-scheduling"}}if(!why){const open=list=>grid(branch,timezone,now,list,step,Math.max(span,days,7),-Infinity);const branchOpen=open([]);const menusOpen=menus.map((_,index)=>open(menus.slice(0,index+1)));why=on=>{const at=list=>list.filter(slot=>on?slot.date===on:Date.parse(slot.value)>=now.getTime());const index=menusOpen.findIndex(list=>!at(list).length);return at(slots).length?void 0:!at(branchOpen).length?{reason:"closed"}:index>=0?{reason:"menu-closed",menuId:menus[index].id}:at(menusOpen.at(-1)??branchOpen).every(slot=>Date.parse(slot.value)>now.getTime()+days*864e5)?{reason:"too-far",maxDays:days,menuId:daysMenu}:{reason:"too-soon",noticeHours:notice/60,menuId:noticeMenu}}}return why(date)}}}function bagWindow(branch,timezone,now,menu,ids,options){const sections=menu?.menus?.filter(section=>ids.split(" ").includes(section.id));const menus=sections?.length?sections:menu?.schedule?[menu]:[];return{...explain(branch,timezone,now,menus,options),canAsap:branch.isOpen!==false&&getOpenStatus(branch,timezone,now).isOpen&&menus.every(({schedule})=>!schedule?.preorder&&(!schedule?.openingTimes.length||getOpenStatus({...branch,...schedule},timezone,now).isOpen))}}export{bagWindow,explain};
1
+ import{canOrderAhead,getOpenStatus,localParts,openingIntervals}from"../status/hours.js";var labels=new Map;function grid(branch,timezone,now,menus,step,days,earliest,bookableDays=Infinity){const menuIntervals=menus.flatMap(({schedule})=>schedule?.openingTimes.length?[openingIntervals({...branch,openingTimes:schedule.openingTimes,specialHours:[]},timezone,now,days+1)]:[]);let label=labels.get(timezone);if(!label){label=new Intl.DateTimeFormat("en",{timeZone:timezone,hour:"numeric",minute:"2-digit",timeZoneName:"shortOffset"});labels.set(timezone,label)}const slots=[];const dates=new Set;for(const{start,end}of openingIntervals(branch,timezone,now,days+1)){for(let instant=start+Math.max(0,Math.ceil((earliest-start)/step))*step;instant<end;instant+=step){if(menuIntervals.every(intervals=>intervals.some(interval=>interval.start<=instant&&interval.end>instant))){const at=new Date(instant);const date=localParts(at,timezone).date;if(dates.add(date).size>bookableDays){return slots}slots.push({value:at.toISOString(),date,label:label.format(at)})}}}return slots}function explain(branch,timezone,now,menus,{intervalMinutes=30,maxDays=90,noticeMinutes=0}={},span=0){if(!Number.isInteger(intervalMinutes)||intervalMinutes<1||!Number.isInteger(maxDays)||maxDays<1||maxDays>90||!(noticeMinutes>=0&&noticeMinutes<Infinity)||!Number.isInteger(span)||span<0||span>90){throw new RangeError("Schedule requires a positive interval, 1\u201390 days and a non-negative notice")}const preorders=menus.filter(menu=>menu.schedule?.preorder);const ahead=branch.orderAheadDays;let days=Math.min(maxDays,ahead>0||!preorders.some(menu=>menu.schedule.preorderMaxDays>0)?ahead??14:90);let notice=noticeMinutes;let daysMenu;let noticeMenu;for(const{id,schedule}of preorders){const limit=schedule.preorderMaxDays;if(limit>0&&limit<days){days=limit;daysMenu=id}if(schedule.preorderNoticeHours*60>notice){notice=schedule.preorderNoticeHours*60;noticeMenu=id}}const step=intervalMinutes*6e4;const scheduling=branch.fulfilment.scheduling&&(preorders.length>0||canOrderAhead(branch));const earliest=now.getTime()+notice*6e4;const lead=Math.ceil(notice/1440);const slots=scheduling?grid(branch,timezone,now,menus,step,lead+Math.min(days*7+7,366),earliest,days):[];let why;return{slots,why(date){if(!scheduling){return{reason:"no-scheduling"}}if(!why){const open=list=>grid(branch,timezone,now,list,step,Math.max(span,lead+days,7),-Infinity);const branchOpen=open([]);const menusOpen=menus.map((_,index)=>open(menus.slice(0,index+1)));why=on=>{const at=list=>list.filter(slot=>on?slot.date===on:Date.parse(slot.value)>=now.getTime());const index=menusOpen.findIndex(list=>!at(list).length);return at(slots).length?void 0:!at(branchOpen).length?{reason:"closed"}:index>=0?{reason:"menu-closed",menuId:menus[index].id}:at(menusOpen.at(-1)??branchOpen).every(slot=>slot.value>(slots.at(-1)?.value??"~"))?{reason:"too-far",maxDays:days,menuId:daysMenu}:{reason:"too-soon",noticeHours:notice/60,menuId:noticeMenu}}}return why(date)}}}function bagWindow(branch,timezone,now,menu,ids,options){const sections=menu?.menus?.filter(section=>ids.split(" ").includes(section.id));const menus=sections?.length?sections:menu?.schedule?[menu]:[];return{...explain(branch,timezone,now,menus,options),canAsap:branch.isOpen!==false&&getOpenStatus(branch,timezone,now).isOpen&&menus.every(({schedule})=>!schedule?.preorder&&(!schedule?.openingTimes.length||getOpenStatus({...branch,...schedule},timezone,now).isOpen))}}export{bagWindow,explain};
2
2
  //# sourceMappingURL=window.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/fulfilment/window.ts"],
4
- "mappings": "AACA,OACE,cACA,cACA,WACA,qBACK,qBAqCP,IAAM,OAAS,IAAI,IACnB,SAAS,KACP,OACA,SACA,IACA,MACA,KACA,KACA,SACA,CACA,MAAM,OAAS,IAAI,QAAQ,EAAI,KAAO,MACtC,MAAM,cAAgB,MAAM,QAAQ,CAAC,CAAE,QAAS,IAC9C,UAAU,aAAa,OACnB,CACE,iBACE,CACE,GAAG,OACH,aAAc,SAAS,aACvB,aAAc,CAAC,CACjB,EACA,SACA,IACA,KAAO,CACT,CACF,EACA,CAAC,CACP,EACA,IAAI,MAAQ,OAAO,IAAI,QAAQ,EAC/B,GAAI,CAAC,MAAO,CACV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S,KAAM,OAAQ,QAAS,EACrD,CACE,OAAQ,WACR,YAAa,OAAS,GACtB,OAAQ,UACV,CACZ,CACF,CACA,OAAO,IAAI,IAAI,CACjB,CACF,CACF,CAaO,SAAS,UACd,OACA,SACA,IACA,KACA,IACA,QACA,CACA,MAAM,SAAW,MAAM,OAAO,OAAQ,SACpC,IAAI,MAAM,GAAG,EAAE,SAAS,QAAQ,EAAE,CACpC,EACA,MAAM,MAAwB,UAAU,OACpC,SACA,MAAM,SACJ,CAAC,IAAI,EACL,CAAC,EACP,MAAO,CACL,GAAG,QAAQ,OAAQ,SAAU,IAAK,MAAO,OAAO,EAChD,QACE,OAAO,SAAW,OAClB,cAAc,OAAQ,SAAU,GAAG,EAAE,QACrC,MAAM,MACJ,CAAC,CAAE,QAAS,IACV,CAAC,UAAU,WACV,CAAC,UAAU,aAAa,QACvB,cAAc,CAAE,GAAG,OAAQ,GAAG,QAAS,EAAG,SAAU,GAAG,EAAE,OAC/D,CACJ,CACF",
5
5
  "names": []
6
6
  }
package/dist/index.d.ts CHANGED
@@ -7,8 +7,8 @@ import { Branch as Branch$1, CartLine, Money as Money$1, CartLineInput, CartIssu
7
7
  import { Coordinates } from '@zappie/sdk/branches';
8
8
  import { useCart } from '@zappie/sdk/react';
9
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
- import { S as ScheduleBlock, a as ScheduleSlot } from './window-BAFAfQnw.js';
11
- export { b as ScheduleDay, c as ScheduleMenu, d as ScheduleOptions } from './window-BAFAfQnw.js';
10
+ import { S as ScheduleBlock, a as ScheduleSlot } from './window-BtvnXLww.js';
11
+ export { b as ScheduleDay, c as ScheduleMenu, d as ScheduleOptions } from './window-BtvnXLww.js';
12
12
  export { a as Overlay, u as useOverlay } from './react-C1KQB_W3.js';
13
13
  import { SelectionControl } from '@zappie/sdk/options';
14
14
  import './overlay/engine.js';
@@ -1,15 +1,16 @@
1
1
  import { Branch, MenuSchedule } from '@zappie/sdk';
2
- import { c as ScheduleMenu, d as ScheduleOptions, S as ScheduleBlock, b as ScheduleDay, a as ScheduleSlot } from '../window-BAFAfQnw.js';
2
+ import { c as ScheduleMenu, d as ScheduleOptions, S as ScheduleBlock, b as ScheduleDay, a as ScheduleSlot } from '../window-BtvnXLww.js';
3
3
 
4
4
  /**
5
5
  * Generate scheduling slots within branch hours and the hours and pre-order terms of each menu.
6
6
  * A bag holding items from several menus gets only the times every menu allows: the longest
7
7
  * notice, the shortest days-ahead limit and the hours all the menus share.
8
8
  *
9
- * Slots reach as far as the branch's `orderAheadDays`, or a pre-order menu's shorter limit, and
10
- * never past `maxDays` when you pass it. A pre-order menu at a branch that takes orders only while
11
- * open uses its own limit. A closed branch still gets its later slots. Returns no slots when the
12
- * branch doesn't take orders ahead (`canOrderAhead`), unless a menu is a pre-order menu.
9
+ * Slots reach as many days with a time as the branch's `orderAheadDays`, or a pre-order menu's
10
+ * fewer, and never more than `maxDays`, counted from the first with a time as the API counts. A
11
+ * pre-order menu at a branch that takes orders only while open uses its own limit. A closed branch
12
+ * still gets its later slots. Returns no slots when the branch doesn't take orders ahead
13
+ * (`canOrderAhead`), unless a menu is a pre-order menu.
13
14
  *
14
15
  * @param branch - The branch whose hours and scheduling capability apply.
15
16
  * @param timezone - The time zone used to interpret opening hours and label slots.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/schedule/index.ts"],
4
- "mappings": "AACA,OACE,YAMK,0BACP,OAAS,WAAY,eAAkB,qBAwBhC,SAAS,cACd,OACA,SACA,IACA,CACE,aACA,MAAQ,CAAC,EACT,GAAG,OACL,EAGI,CAAC,EACW,CAChB,OAAO,QACL,OACA,SACA,IACA,aAAe,CAAC,GAAG,MAAO,CAAE,GAAI,GAAI,SAAU,YAAa,CAAC,EAAI,CAAC,GAAG,KAAK,EACzE,OACF,EAAE,KACJ,CAWO,SAAS,gBACd,OACA,SACA,IACA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QAAQ,EAAE,KACxC,OAAO,MAAM,KAAK,CAAE,OAAQ,IAAK,EAAG,CAAC,EAAG,SAAW,CACjD,MAAM,KAAO,WAAW,MAAO,MAAM,EACrC,MAAM,MAAQ,OAAO,MAAM,OAAQ,MAAS,KAAK,OAAS,IAAI,EAC9D,MAAM,QAAU,MAAM,OAAS,OAAY,OAAO,IAAI,IAAI,EAC1D,OAAO,QAAU,CAAE,KAAM,MAAO,OAAQ,EAAI,CAAE,KAAM,KAAM,CAC5D,CAAC,CACH",
5
5
  "names": []
6
6
  }
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- var PACKAGE_VERSION=true?"0.26.0":"0.0.0-development";export{PACKAGE_VERSION};
1
+ var PACKAGE_VERSION=true?"0.27.0":"0.0.0-development";export{PACKAGE_VERSION};
2
2
  //# sourceMappingURL=version.js.map
@@ -14,7 +14,7 @@ type ScheduleMenu = Pick<MenuSection, "id" | "schedule">;
14
14
  type ScheduleOptions = {
15
15
  /** Minutes between slots. Defaults to 30. */
16
16
  intervalMinutes?: number | undefined;
17
- /** The furthest day ahead to offer, 1 to 90. Defaults to 90. */
17
+ /** The most days with a time to offer, 1 to 90. Defaults to 90. */
18
18
  maxDays?: number | undefined;
19
19
  /** Minutes of lead time every order needs. Defaults to 0. */
20
20
  noticeMinutes?: number | undefined;
@@ -25,7 +25,7 @@ type ScheduleOptions = {
25
25
  * - `no-scheduling`: the branch takes no scheduled orders for these menus.
26
26
  * - `closed`: the branch is closed.
27
27
  * - `menu-closed`: the menu named by `menuId` isn't served then, or shares no time with the menus before it.
28
- * - `too-far`: the day is past the `maxDays` limit. `menuId` names the menu that sets it, when one does.
28
+ * - `too-far`: the day is past the `maxDays` days with a time. `menuId` names the menu that sets it, when one does.
29
29
  * - `too-soon`: the remaining times are within the `noticeHours` the order needs. `menuId` names the
30
30
  * menu that asks for that notice, when one does. Zero `noticeHours` means the day's times have passed.
31
31
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zappie/foundations",
3
- "version": "0.26.0",
3
+ "version": "0.27.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,