@loczer/storefront-sdk 0.216.0 → 0.217.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.
@@ -1,13 +1,6 @@
1
1
  import { StoreOpeningHours, StoreOpeningOverride } from '../../lib/booking-period';
2
- import { GroupedBusinessHoursItem } from './businessHoursUtils';
3
- export type SeasonOption = {
4
- id: string;
5
- label: string;
6
- rangeLabel: string;
7
- startDate: string;
8
- endDate: string;
9
- items: GroupedBusinessHoursItem[];
10
- };
2
+ import { BusinessHoursSeasonOption } from './businessHoursUtils';
3
+ export type SeasonOption = BusinessHoursSeasonOption;
11
4
  type BusinessHoursProps = {
12
5
  openingHours: StoreOpeningHours;
13
6
  openingHoursOverrides: StoreOpeningOverride[];
@@ -1 +1 @@
1
- {"version":3,"file":"BusinessHours.d.ts","sourceRoot":"","sources":["../../../src/components/Footer/BusinessHours.tsx"],"names":[],"mappings":"AAIA,OAAO,EAKL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EAE1B,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,sBAAsB,CAAA;AAG7B,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,wBAAwB,EAAE,CAAA;CAClC,CAAA;AAuDD,KAAK,kBAAkB,GAAG;IACxB,YAAY,EAAE,iBAAiB,CAAA;IAC/B,qBAAqB,EAAE,oBAAoB,EAAE,CAAA;CAC9C,CAAA;AAED,wBAAgB,aAAa,CAAC,EAAE,YAAY,EAAE,qBAAqB,EAAE,EAAE,kBAAkB,kDA8IxF"}
1
+ {"version":3,"file":"BusinessHours.d.ts","sourceRoot":"","sources":["../../../src/components/Footer/BusinessHours.tsx"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EAC1B,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,sBAAsB,CAAA;AAG7B,MAAM,MAAM,YAAY,GAAG,yBAAyB,CAAA;AAEpD,KAAK,kBAAkB,GAAG;IACxB,YAAY,EAAE,iBAAiB,CAAA;IAC/B,qBAAqB,EAAE,oBAAoB,EAAE,CAAA;CAC9C,CAAA;AAED,wBAAgB,aAAa,CAAC,EAAE,YAAY,EAAE,qBAAqB,EAAE,EAAE,kBAAkB,kDA+FxF"}
@@ -1,134 +1,91 @@
1
- import { businessDateStringToDate as e, minutesToTimeString as t, normalizeOpeningHours as n, parseTimeToMinutes as r } from "../../lib/booking-period.js";
2
- import { groupBusinessHoursItems as i } from "./businessHoursUtils.js";
3
- import { useEffect as a, useState as o } from "react";
4
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
5
- import { useTranslation as l } from "react-i18next";
6
- import { ChevronDown as u, Clock as d } from "lucide-react";
1
+ import { buildBusinessHoursSeasonSummary as e } from "./businessHoursUtils.js";
2
+ import { useEffect as t, useState as n } from "react";
3
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
4
+ import { useTranslation as a } from "react-i18next";
5
+ import { ChevronDown as o, Clock as s } from "lucide-react";
7
6
  //#region src/components/Footer/BusinessHours.tsx
8
- var f = (e, t) => {
9
- let n = new Date(2024, 0, 8, 12);
10
- n.setDate(n.getDate() + e);
11
- let r = new Intl.DateTimeFormat(t, { weekday: "long" }).format(n);
12
- return r && `${r.charAt(0).toLocaleUpperCase(t)}${r.slice(1)}`;
13
- }, p = (t, n) => {
14
- let r = e(t);
15
- return Number.isNaN(r.getTime()) ? t : new Intl.DateTimeFormat(n, {
16
- year: "numeric",
17
- month: "short",
18
- day: "2-digit"
19
- }).format(r);
20
- }, m = (e, n) => {
21
- let i = e.map((e) => {
22
- let n = r(e.start), i = r(e.end);
23
- return n == null || i == null || i <= n ? null : {
24
- startMinutes: n,
25
- label: `${t(n)} - ${t(i)}`
26
- };
27
- }).filter((e) => !!e).sort((e, t) => e.startMinutes - t.startMinutes).map((e) => e.label);
28
- return i.length ? i.join(" / ") : n;
29
- };
30
- function h({ openingHours: t, openingHoursOverrides: r }) {
31
- let { t: h, i18n: g } = l(), _ = g.language || "en", v = n(t, r, { referenceDate: /* @__PURE__ */ new Date() }), y = (e, t) => h("footer_business_hours_weekday_range", {
32
- start: e,
33
- end: t
34
- }), b = t.map((e, t) => {
35
- let n = /* @__PURE__ */ new Map();
36
- e.openingHours.forEach((e) => {
37
- let t = (Math.trunc(e.day) % 7 + 7) % 7;
38
- n.set(t, e.openingSlots);
39
- });
40
- let r = i(Array.from({ length: 7 }, (e, t) => {
41
- let r = t;
42
- return {
43
- weekday: r,
44
- label: f(r, _),
45
- value: m(n.get(r) ?? [], h("footer_business_hours_closed"))
46
- };
47
- }), y), a = h("footer_business_hours_season_range", {
48
- start: p(e.startDate, _),
49
- end: p(e.endDate, _)
50
- }), o = e.name || a;
51
- return {
52
- id: String(t),
53
- label: o,
54
- rangeLabel: a,
55
- startDate: e.startDate,
56
- endDate: e.endDate,
57
- items: r
58
- };
59
- }), x = /* @__PURE__ */ new Date();
60
- x.setHours(0, 0, 0, 0);
61
- let S = b.filter((t) => {
62
- let n = e(t.endDate);
63
- return Number.isNaN(n.getTime()) ? !0 : (n.setHours(0, 0, 0, 0), n.getTime() >= x.getTime());
64
- }), C = v.season, w = S.length ? S.find((e) => e.startDate === C?.startDate && e.endDate === C?.endDate)?.id ?? S[0].id : null, [T, E] = o(w);
65
- return a(() => {
66
- if (!S.length) {
67
- T !== null && E(null);
7
+ function c({ openingHours: c, openingHoursOverrides: l }) {
8
+ let { t: u, i18n: d } = a(), { seasons: f, defaultSeasonId: p } = e({
9
+ openingHours: c,
10
+ openingHoursOverrides: l,
11
+ language: d.language || "en",
12
+ closedLabel: u("footer_business_hours_closed"),
13
+ formatWeekdayRange: (e, t) => u("footer_business_hours_weekday_range", {
14
+ start: e,
15
+ end: t
16
+ }),
17
+ formatSeasonRange: (e, t) => u("footer_business_hours_season_range", {
18
+ start: e,
19
+ end: t
20
+ })
21
+ }), [m, h] = n(p);
22
+ return t(() => {
23
+ if (!f.length) {
24
+ m !== null && h(null);
68
25
  return;
69
26
  }
70
- T !== null && (S.some((e) => e.id === T) || E(w));
27
+ m !== null && (f.some((e) => e.id === m) || h(p));
71
28
  }, [
72
- S,
73
- w,
74
- T
75
- ]), S.length ? /* @__PURE__ */ s("div", {
29
+ f,
30
+ p,
31
+ m
32
+ ]), f.length ? /* @__PURE__ */ r("div", {
76
33
  "data-testid": "footer-business-hours",
77
- children: /* @__PURE__ */ s("div", {
34
+ children: /* @__PURE__ */ r("div", {
78
35
  className: "space-y-2",
79
- children: S.map((e) => {
80
- let t = T === e.id;
81
- return /* @__PURE__ */ c("section", {
36
+ children: f.map((e) => {
37
+ let t = m === e.id;
38
+ return /* @__PURE__ */ i("section", {
82
39
  "data-testid": `footer-business-hours-season-${e.id}`,
83
- children: [/* @__PURE__ */ s("h3", { children: /* @__PURE__ */ c("button", {
40
+ children: [/* @__PURE__ */ r("h3", { children: /* @__PURE__ */ i("button", {
84
41
  type: "button",
85
42
  className: "flex w-full cursor-pointer items-center justify-between gap-3 py-1 text-left text-slate-500 transition-colors hover:text-slate-700",
86
43
  "data-testid": `footer-business-hours-season-toggle-${e.id}`,
87
44
  "aria-expanded": t,
88
45
  onClick: () => {
89
- E((t) => t === e.id ? null : e.id);
46
+ h((t) => t === e.id ? null : e.id);
90
47
  },
91
- children: [/* @__PURE__ */ c("span", {
48
+ children: [/* @__PURE__ */ i("span", {
92
49
  className: "min-w-0",
93
- children: [/* @__PURE__ */ c("span", {
50
+ children: [/* @__PURE__ */ i("span", {
94
51
  className: "inline-flex items-center gap-2 text-sm text-slate-500 leading-tight",
95
52
  children: [
96
- /* @__PURE__ */ s(d, {
53
+ /* @__PURE__ */ r(s, {
97
54
  className: "h-3.5 w-3.5 text-slate-400",
98
55
  "aria-hidden": "true"
99
56
  }),
100
- /* @__PURE__ */ c("span", {
57
+ /* @__PURE__ */ i("span", {
101
58
  className: "font-medium",
102
- children: [h("footer_business_hours_season_label"), ":"]
59
+ children: [u("footer_business_hours_season_label"), ":"]
103
60
  }),
104
- /* @__PURE__ */ s("span", {
61
+ /* @__PURE__ */ r("span", {
105
62
  className: "truncate font-medium text-slate-500",
106
63
  children: e.label
107
64
  })
108
65
  ]
109
- }), /* @__PURE__ */ s("span", {
66
+ }), /* @__PURE__ */ r("span", {
110
67
  className: "mt-1 block text-sm text-slate-500 leading-tight",
111
68
  children: e.rangeLabel
112
69
  })]
113
- }), /* @__PURE__ */ s(u, {
70
+ }), /* @__PURE__ */ r(o, {
114
71
  className: `h-4 w-4 shrink-0 text-slate-400 transition-transform ${t ? "rotate-180" : ""}`,
115
72
  "aria-hidden": "true"
116
73
  })]
117
- }) }), t ? /* @__PURE__ */ s("ul", {
74
+ }) }), t ? /* @__PURE__ */ r("ul", {
118
75
  "data-testid": `footer-business-hours-season-panel-${e.id}`,
119
76
  className: "mt-2 space-y-2 text-sm text-slate-700",
120
- children: e.items.map((e) => /* @__PURE__ */ c("li", {
77
+ children: e.items.map((e) => /* @__PURE__ */ i("li", {
121
78
  className: "flex items-baseline gap-3",
122
79
  children: [
123
- /* @__PURE__ */ s("span", {
80
+ /* @__PURE__ */ r("span", {
124
81
  className: "shrink-0 text-slate-600 leading-tight",
125
82
  children: e.label
126
83
  }),
127
- /* @__PURE__ */ s("span", {
84
+ /* @__PURE__ */ r("span", {
128
85
  "aria-hidden": "true",
129
86
  className: "mx-1 flex-1 border-b border-dotted border-slate-200"
130
87
  }),
131
- /* @__PURE__ */ s("span", {
88
+ /* @__PURE__ */ r("span", {
132
89
  className: "shrink-0 text-right font-medium text-slate-800 leading-tight",
133
90
  children: e.value
134
91
  })
@@ -141,4 +98,4 @@ function h({ openingHours: t, openingHoursOverrides: r }) {
141
98
  }) : null;
142
99
  }
143
100
  //#endregion
144
- export { h as BusinessHours };
101
+ export { c as BusinessHours };
@@ -0,0 +1,11 @@
1
+ import { BusinessHoursExceptionOption, BusinessHoursSeasonOption } from './businessHoursUtils';
2
+ type BusinessHoursOverviewDialogProps = {
3
+ open: boolean;
4
+ seasons: BusinessHoursSeasonOption[];
5
+ exceptions: BusinessHoursExceptionOption[];
6
+ mapsHref?: string;
7
+ onOpenChange: (open: boolean) => void;
8
+ };
9
+ export declare function BusinessHoursOverviewDialog({ open, seasons, exceptions, mapsHref, onOpenChange, }: BusinessHoursOverviewDialogProps): import("react/jsx-runtime").JSX.Element;
10
+ export {};
11
+ //# sourceMappingURL=BusinessHoursOverviewDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BusinessHoursOverviewDialog.d.ts","sourceRoot":"","sources":["../../../src/components/Footer/BusinessHoursOverviewDialog.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,4BAA4B,EAC5B,yBAAyB,EAC1B,MAAM,sBAAsB,CAAA;AAG7B,KAAK,gCAAgC,GAAG;IACtC,IAAI,EAAE,OAAO,CAAA;IACb,OAAO,EAAE,yBAAyB,EAAE,CAAA;IACpC,UAAU,EAAE,4BAA4B,EAAE,CAAA;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;CACtC,CAAA;AAED,wBAAgB,2BAA2B,CAAC,EAC1C,IAAI,EACJ,OAAO,EACP,UAAU,EACV,QAAQ,EACR,YAAY,GACb,EAAE,gCAAgC,2CAuKlC"}
@@ -0,0 +1,161 @@
1
+ import { Button as e } from "../../ui/button.js";
2
+ import { ResponsiveDialog as t, ResponsiveDialogClose as n, ResponsiveDialogContent as r, ResponsiveDialogDescription as i, ResponsiveDialogFooter as a, ResponsiveDialogHeader as o, ResponsiveDialogTitle as s } from "../../chunks/pkg/ui/dist/ResponsiveDialog-BJ0RG6gh.js";
3
+ import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
4
+ import { useTranslation as d } from "react-i18next";
5
+ import { ChevronDown as f, Clock as p } from "lucide-react";
6
+ //#region src/components/Footer/BusinessHoursOverviewDialog.tsx
7
+ function m({ open: m, seasons: h, exceptions: g, mapsHref: _, onOpenChange: v }) {
8
+ let { t: y } = d();
9
+ return /* @__PURE__ */ l(t, {
10
+ open: m,
11
+ onOpenChange: v,
12
+ children: m && (h.length > 0 || g.length > 0) ? /* @__PURE__ */ l(r, {
13
+ "data-testid": "business-hours-overview-dialog",
14
+ className: "overflow-hidden border-border bg-background p-0 text-foreground",
15
+ desktopClassName: "max-w-xl gap-0",
16
+ mobileClassName: "max-h-[92dvh] gap-0",
17
+ children: /* @__PURE__ */ u("div", {
18
+ className: "flex max-h-[90dvh] w-full min-w-0 flex-col",
19
+ children: [
20
+ /* @__PURE__ */ l(o, {
21
+ className: "shrink-0 border-b border-border px-5 py-4 text-left sm:px-6",
22
+ children: /* @__PURE__ */ u("div", {
23
+ className: "flex items-start gap-3",
24
+ children: [/* @__PURE__ */ l(p, {
25
+ className: "mt-0.5 h-5 w-5 shrink-0 text-muted-foreground",
26
+ "aria-hidden": "true"
27
+ }), /* @__PURE__ */ u("span", {
28
+ className: "min-w-0 space-y-1",
29
+ children: [/* @__PURE__ */ l(s, {
30
+ className: "text-left text-lg font-semibold leading-6 text-foreground",
31
+ children: /* @__PURE__ */ l("span", { children: y("business_hours_modal_title") })
32
+ }), /* @__PURE__ */ l(i, {
33
+ className: "text-left text-sm text-muted-foreground",
34
+ children: _ ? /* @__PURE__ */ l("a", {
35
+ href: _,
36
+ className: "underline-offset-4 transition-colors hover:text-foreground hover:underline",
37
+ target: "_blank",
38
+ rel: "nofollow noopener noreferrer",
39
+ children: y("business_hours_google_maps_note")
40
+ }) : /* @__PURE__ */ l("span", { children: y("business_hours_modal_description") })
41
+ })]
42
+ })]
43
+ })
44
+ }),
45
+ /* @__PURE__ */ l("div", {
46
+ "data-testid": "business-hours-overview-scroll",
47
+ className: "min-h-0 flex-1 overflow-y-auto overscroll-contain px-5 sm:px-6",
48
+ children: /* @__PURE__ */ u("div", {
49
+ className: "divide-y divide-border",
50
+ children: [h.map((e) => {
51
+ let t = /* @__PURE__ */ l("ul", {
52
+ "data-testid": `business-hours-overview-season-panel-${e.id}`,
53
+ className: "mt-4 space-y-3",
54
+ children: e.items.map((e) => /* @__PURE__ */ u("li", {
55
+ className: "flex min-w-0 items-baseline gap-2 sm:gap-3",
56
+ children: [
57
+ /* @__PURE__ */ l("span", {
58
+ className: "shrink-0 text-sm leading-tight text-muted-foreground",
59
+ children: e.label
60
+ }),
61
+ /* @__PURE__ */ l("span", {
62
+ "aria-hidden": "true",
63
+ className: "mx-1 min-w-2 flex-1 border-b border-dotted border-border"
64
+ }),
65
+ /* @__PURE__ */ l("span", {
66
+ className: "min-w-0 max-w-[60%] text-right text-sm font-medium leading-tight text-foreground",
67
+ children: e.value
68
+ })
69
+ ]
70
+ }, e.id))
71
+ });
72
+ return /* @__PURE__ */ l("section", {
73
+ "data-testid": `business-hours-overview-season-${e.id}`,
74
+ className: "py-5",
75
+ children: e.isCurrent ? /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ u("div", {
76
+ className: "flex flex-col gap-0.5 sm:flex-row sm:items-baseline sm:justify-between sm:gap-4",
77
+ children: [/* @__PURE__ */ l("h3", {
78
+ className: "text-base font-semibold leading-6 text-foreground",
79
+ children: e.label
80
+ }), /* @__PURE__ */ l("p", {
81
+ className: "shrink-0 text-sm text-muted-foreground",
82
+ children: e.rangeLabel
83
+ })]
84
+ }), t] }) : /* @__PURE__ */ u("details", {
85
+ "data-testid": `business-hours-overview-season-details-${e.id}`,
86
+ className: "group",
87
+ children: [/* @__PURE__ */ u("summary", {
88
+ "data-testid": `business-hours-overview-season-toggle-${e.id}`,
89
+ className: "flex cursor-pointer list-none items-center gap-3 rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden",
90
+ children: [/* @__PURE__ */ u("span", {
91
+ className: "flex min-w-0 flex-1 flex-col gap-0.5 sm:flex-row sm:items-baseline sm:justify-between sm:gap-4",
92
+ children: [/* @__PURE__ */ l("span", {
93
+ className: "text-base font-semibold leading-6 text-foreground",
94
+ children: e.label
95
+ }), /* @__PURE__ */ l("span", {
96
+ className: "shrink-0 text-sm text-muted-foreground",
97
+ children: e.rangeLabel
98
+ })]
99
+ }), /* @__PURE__ */ l(f, {
100
+ className: "h-4 w-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180",
101
+ "aria-hidden": "true"
102
+ })]
103
+ }), t]
104
+ })
105
+ }, e.id);
106
+ }), g.length > 0 ? /* @__PURE__ */ u("section", {
107
+ "data-testid": "business-hours-overview-exceptions",
108
+ className: "py-5",
109
+ children: [/* @__PURE__ */ u("div", {
110
+ className: "space-y-0.5",
111
+ children: [/* @__PURE__ */ l("h3", {
112
+ className: "text-base font-semibold leading-6 text-foreground",
113
+ children: /* @__PURE__ */ l("span", { children: y("business_hours_exceptions_title") })
114
+ }), /* @__PURE__ */ l("p", {
115
+ className: "text-sm text-muted-foreground",
116
+ children: /* @__PURE__ */ l("span", { children: y("business_hours_exceptions_description") })
117
+ })]
118
+ }), /* @__PURE__ */ l("ul", {
119
+ className: "mt-4 space-y-3",
120
+ children: g.map((e) => /* @__PURE__ */ u("li", {
121
+ "data-testid": `business-hours-overview-exception-${e.date}`,
122
+ className: "flex min-w-0 items-baseline gap-2 sm:gap-3",
123
+ children: [
124
+ /* @__PURE__ */ l("time", {
125
+ dateTime: e.date,
126
+ className: "min-w-0 text-sm leading-tight text-muted-foreground",
127
+ children: /* @__PURE__ */ l("span", { children: e.label })
128
+ }),
129
+ /* @__PURE__ */ l("span", {
130
+ "aria-hidden": "true",
131
+ className: "mx-1 min-w-2 flex-1 border-b border-dotted border-border"
132
+ }),
133
+ /* @__PURE__ */ l("span", {
134
+ className: "min-w-0 max-w-[45%] text-right text-sm font-medium leading-tight text-foreground",
135
+ children: e.value
136
+ })
137
+ ]
138
+ }, e.id))
139
+ })]
140
+ }) : null]
141
+ })
142
+ }),
143
+ /* @__PURE__ */ l(a, {
144
+ className: "shrink-0 border-t border-border px-5 py-4 sm:px-6",
145
+ children: /* @__PURE__ */ l(n, {
146
+ asChild: !0,
147
+ children: /* @__PURE__ */ l(e, {
148
+ type: "button",
149
+ variant: "outline",
150
+ className: "h-11 w-full rounded-xl sm:w-auto",
151
+ children: /* @__PURE__ */ l("span", { children: y("close_modal") })
152
+ })
153
+ })
154
+ })
155
+ ]
156
+ })
157
+ }) : null
158
+ });
159
+ }
160
+ //#endregion
161
+ export { m as BusinessHoursOverviewDialog };
@@ -1,4 +1,5 @@
1
- import { Weekday } from '../../lib/booking-period';
1
+ import { StoreOpeningHours, StoreOpeningOverride, Weekday } from '../../lib/booking-period';
2
+ import { StorefrontConfiguration } from '../../storefrontSchemas';
2
3
  export type BusinessHoursListItem = {
3
4
  weekday: Weekday;
4
5
  label: string;
@@ -10,5 +11,40 @@ export type GroupedBusinessHoursItem = {
10
11
  label: string;
11
12
  value: string;
12
13
  };
14
+ export type BusinessHoursSeasonOption = {
15
+ id: string;
16
+ label: string;
17
+ rangeLabel: string;
18
+ startDate: string;
19
+ endDate: string;
20
+ isCurrent: boolean;
21
+ items: GroupedBusinessHoursItem[];
22
+ };
23
+ export type BusinessHoursExceptionOption = {
24
+ id: string;
25
+ date: string;
26
+ label: string;
27
+ value: string;
28
+ };
29
+ type StorefrontOpeningHours = StorefrontConfiguration["bookingEngine"]["shop"]["openingHours"];
30
+ type StorefrontOpeningHoursOverrides = StorefrontConfiguration["bookingEngine"]["shop"]["openingHoursOverrides"];
31
+ export declare const normalizeStorefrontOpeningHours: (openingHours?: StorefrontOpeningHours) => StoreOpeningHours;
32
+ export declare const normalizeStorefrontOpeningHoursOverrides: (openingHoursOverrides?: StorefrontOpeningHoursOverrides) => StoreOpeningOverride[];
13
33
  export declare const groupBusinessHoursItems: (items: BusinessHoursListItem[], formatRangeLabel: (startLabel: string, endLabel: string) => string) => GroupedBusinessHoursItem[];
34
+ type BuildBusinessHoursSeasonSummaryOptions = {
35
+ openingHours: StoreOpeningHours;
36
+ openingHoursOverrides: StoreOpeningOverride[];
37
+ language: string;
38
+ closedLabel: string;
39
+ formatWeekdayRange: (startLabel: string, endLabel: string) => string;
40
+ formatSeasonRange: (startDate: string, endDate: string) => string;
41
+ includeReferenceDateOverrideInSeason?: boolean;
42
+ referenceDate?: Date;
43
+ };
44
+ export declare const buildBusinessHoursSeasonSummary: ({ openingHours, openingHoursOverrides, language, closedLabel, formatWeekdayRange, formatSeasonRange, includeReferenceDateOverrideInSeason, referenceDate, }: BuildBusinessHoursSeasonSummaryOptions) => {
45
+ seasons: BusinessHoursSeasonOption[];
46
+ exceptions: BusinessHoursExceptionOption[];
47
+ defaultSeasonId: string | null;
48
+ };
49
+ export {};
14
50
  //# sourceMappingURL=businessHoursUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"businessHoursUtils.d.ts","sourceRoot":"","sources":["../../../src/components/Footer/businessHoursUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAGvD,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAOD,eAAO,MAAM,uBAAuB,GAClC,OAAO,qBAAqB,EAAE,EAC9B,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,KACjE,wBAAwB,EA4C1B,CAAA"}
1
+ {"version":3,"file":"businessHoursUtils.d.ts","sourceRoot":"","sources":["../../../src/components/Footer/businessHoursUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,OAAO,EACb,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AAGtE,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,wBAAwB,EAAE,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,4BAA4B,GAAG;IACzC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,KAAK,sBAAsB,GAAG,uBAAuB,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,CAAA;AAC9F,KAAK,+BAA+B,GAAG,uBAAuB,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,uBAAuB,CAAC,CAAA;AAMhH,eAAO,MAAM,+BAA+B,GAC1C,eAAe,sBAAsB,KACpC,iBAiBF,CAAA;AAED,eAAO,MAAM,wCAAwC,GACnD,wBAAwB,+BAA+B,KACtD,oBAAoB,EAYtB,CAAA;AAOD,eAAO,MAAM,uBAAuB,GAClC,OAAO,qBAAqB,EAAE,EAC9B,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,KACjE,wBAAwB,EA4C1B,CAAA;AAiED,KAAK,sCAAsC,GAAG;IAC5C,YAAY,EAAE,iBAAiB,CAAA;IAC/B,qBAAqB,EAAE,oBAAoB,EAAE,CAAA;IAC7C,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,kBAAkB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAA;IACpE,iBAAiB,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,MAAM,CAAA;IACjE,oCAAoC,CAAC,EAAE,OAAO,CAAA;IAC9C,aAAa,CAAC,EAAE,IAAI,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,+BAA+B,GAAI,6JAS7C,sCAAsC,KAAG;IAC1C,OAAO,EAAE,yBAAyB,EAAE,CAAA;IACpC,UAAU,EAAE,4BAA4B,EAAE,CAAA;IAC1C,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;CAuG/B,CAAA"}
@@ -1,24 +1,121 @@
1
+ import { businessDateStringToDate as e, calendarDateToBusinessDateString as t, minutesToTimeString as n, normalizeBusinessDateString as r, normalizeOpeningHours as i, parseTimeToMinutes as a } from "../../lib/booking-period.js";
1
2
  //#region src/components/Footer/businessHoursUtils.ts
2
- var e = (e) => e <= 4, t = (e) => e === 5 || e === 6, n = (n, r) => {
3
- let i = [...n].sort((e, t) => e.weekday - t.weekday), a = i.filter((t) => e(t.weekday)), o = i.filter((e) => t(e.weekday)), s = [], c = 0;
4
- for (; c < a.length;) {
5
- let e = a[c], t = e.value, n = c;
6
- for (; n + 1 < a.length && a[n + 1].value === t;) n += 1;
7
- let i = a.slice(c, n + 1), o = i.length === 1 ? `${e.weekday}` : `${e.weekday}-${i[i.length - 1].weekday}`;
8
- s.push({
9
- id: `weekday-${o}`,
10
- weekdays: i.map((e) => e.weekday),
11
- label: i.length === 1 ? e.label : r(e.label, i[i.length - 1].label),
12
- value: t
13
- }), c = n + 1;
3
+ var o = (e) => (Math.trunc(e) % 7 + 7) % 7, s = (e) => Array.isArray(e) ? e.map((e) => ({
4
+ name: e.name,
5
+ startDate: e.startDate,
6
+ endDate: e.endDate,
7
+ openingHours: e.openingHours.map((e) => ({
8
+ day: o(e.day),
9
+ openingSlots: e.openingSlots.map((e) => ({
10
+ start: e.start,
11
+ end: e.end
12
+ }))
13
+ }))
14
+ })) : [], c = (e) => Array.isArray(e) ? e.map((e) => ({
15
+ date: e.date,
16
+ openingSlots: e.openingSlots.map((e) => ({
17
+ start: e.start,
18
+ end: e.end
19
+ }))
20
+ })) : [], l = (e) => e <= 4, u = (e) => e === 5 || e === 6, d = (e, t) => {
21
+ let n = [...e].sort((e, t) => e.weekday - t.weekday), r = n.filter((e) => l(e.weekday)), i = n.filter((e) => u(e.weekday)), a = [], o = 0;
22
+ for (; o < r.length;) {
23
+ let e = r[o], n = e.value, i = o;
24
+ for (; i + 1 < r.length && r[i + 1].value === n;) i += 1;
25
+ let s = r.slice(o, i + 1), c = s.length === 1 ? `${e.weekday}` : `${e.weekday}-${s[s.length - 1].weekday}`;
26
+ a.push({
27
+ id: `weekday-${c}`,
28
+ weekdays: s.map((e) => e.weekday),
29
+ label: s.length === 1 ? e.label : t(e.label, s[s.length - 1].label),
30
+ value: n
31
+ }), o = i + 1;
14
32
  }
15
- let l = o.map((e) => ({
33
+ let s = i.map((e) => ({
16
34
  id: `weekend-${e.weekday}`,
17
35
  weekdays: [e.weekday],
18
36
  label: e.label,
19
37
  value: e.value
20
38
  }));
21
- return [...s, ...l];
39
+ return [...a, ...s];
40
+ }, f = (e, t) => {
41
+ let n = new Date(2024, 0, 8, 12);
42
+ n.setDate(n.getDate() + e);
43
+ let r = new Intl.DateTimeFormat(t, { weekday: "long" }).format(n);
44
+ return r && `${r.charAt(0).toLocaleUpperCase(t)}${r.slice(1)}`;
45
+ }, p = (t, n) => {
46
+ let r = e(t);
47
+ return Number.isNaN(r.getTime()) ? t : new Intl.DateTimeFormat(n, {
48
+ year: "numeric",
49
+ month: "short",
50
+ day: "2-digit"
51
+ }).format(r);
52
+ }, m = (t, n) => {
53
+ let r = e(t);
54
+ if (Number.isNaN(r.getTime())) return t;
55
+ let i = new Intl.DateTimeFormat(n, {
56
+ weekday: "long",
57
+ year: "numeric",
58
+ month: "long",
59
+ day: "numeric"
60
+ }).format(r);
61
+ return i && `${i.charAt(0).toLocaleUpperCase(n)}${i.slice(1)}`;
62
+ }, h = (e, t) => {
63
+ let r = e.map((e) => {
64
+ let t = a(e.start), r = a(e.end);
65
+ return t == null || r == null || r <= t ? null : {
66
+ startMinutes: t,
67
+ label: `${n(t)} - ${n(r)}`
68
+ };
69
+ }).filter((e) => !!e).sort((e, t) => e.startMinutes - t.startMinutes).map((e) => e.label);
70
+ return r.length > 0 ? r.join(" / ") : t;
71
+ }, g = ({ openingHours: n, openingHoursOverrides: a, language: s, closedLabel: c, formatWeekdayRange: l, formatSeasonRange: u, includeReferenceDateOverrideInSeason: g = !0, referenceDate: _ = /* @__PURE__ */ new Date() }) => {
72
+ let v = i(n, g ? a : [], { referenceDate: _ }), y = v.season, b = v.days.map((e) => ({
73
+ weekday: e.day,
74
+ label: f(e.day, s),
75
+ value: e.summaryLabel ?? c
76
+ })), x = new Date(_);
77
+ x.setHours(0, 0, 0, 0);
78
+ let S = n.map((t, n) => {
79
+ let r = t.startDate === y?.startDate && t.endDate === y?.endDate, i = /* @__PURE__ */ new Map();
80
+ r || t.openingHours.forEach((e) => {
81
+ i.set(o(e.day), e.openingSlots);
82
+ });
83
+ let a = r ? b : Array.from({ length: 7 }, (e, t) => {
84
+ let n = t;
85
+ return {
86
+ weekday: n,
87
+ label: f(n, s),
88
+ value: h(i.get(n) ?? [], c)
89
+ };
90
+ }), m = u(p(t.startDate, s), p(t.endDate, s)), g = e(t.startDate), _ = e(t.endDate);
91
+ g.setHours(0, 0, 0, 0), _.setHours(0, 0, 0, 0);
92
+ let v = !Number.isNaN(g.getTime()) && !Number.isNaN(_.getTime()) && g.getTime() <= x.getTime() && _.getTime() >= x.getTime();
93
+ return {
94
+ id: String(n),
95
+ label: t.name || m,
96
+ rangeLabel: m,
97
+ startDate: t.startDate,
98
+ endDate: t.endDate,
99
+ isCurrent: v,
100
+ items: d(a, l)
101
+ };
102
+ }).filter((t) => {
103
+ let n = e(t.endDate);
104
+ return Number.isNaN(n.getTime()) ? !0 : (n.setHours(0, 0, 0, 0), n.getTime() >= x.getTime());
105
+ }).sort((e, t) => e.startDate.localeCompare(t.startDate)), C = S.length > 0 ? S.find((e) => e.startDate === y?.startDate && e.endDate === y?.endDate)?.id ?? S[0].id : null, w = t(_), T = /* @__PURE__ */ new Map();
106
+ return a.forEach((e) => {
107
+ let t = r(e.date);
108
+ !t || w && t < w || T.set(t, e);
109
+ }), {
110
+ seasons: S,
111
+ exceptions: Array.from(T.entries()).sort(([e], [t]) => e.localeCompare(t)).map(([e, t]) => ({
112
+ id: e,
113
+ date: e,
114
+ label: m(e, s),
115
+ value: h(t.openingSlots, c)
116
+ })),
117
+ defaultSeasonId: C
118
+ };
22
119
  };
23
120
  //#endregion
24
- export { n as groupBusinessHoursItems };
121
+ export { g as buildBusinessHoursSeasonSummary, d as groupBusinessHoursItems, s as normalizeStorefrontOpeningHours, c as normalizeStorefrontOpeningHoursOverrides };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Footer/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAWtF,KAAK,WAAW,GAAG;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,cAAc,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,YAAY,CAAC,EAAE,uBAAuB,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,CAAA;IAC/E,qBAAqB,CAAC,EAAE,uBAAuB,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,uBAAuB,CAAC,CAAA;CAClG,CAAA;AAyCD,wBAAgB,MAAM,CAAC,EACrB,SAAS,EACT,IAAI,EACJ,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,qBAAqB,GACtB,EAAE,WAAW,2CAoJb"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Footer/index.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAetF,KAAK,WAAW,GAAG;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,cAAc,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,YAAY,CAAC,EAAE,uBAAuB,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,CAAA;IAC/E,qBAAqB,CAAC,EAAE,uBAAuB,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,uBAAuB,CAAC,CAAA;CAClG,CAAA;AAED,wBAAgB,MAAM,CAAC,EACrB,SAAS,EACT,IAAI,EACJ,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,qBAAqB,GACtB,EAAE,WAAW,2CAoJb"}