@loczer/storefront-sdk 0.209.0 → 0.211.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/chunks/pkg/booking-engine/dist/node_modules/@date-fns/tz/date/index-DAbcklF5.js +1 -0
- package/dist/chunks/pkg/booking-engine/dist/node_modules/@date-fns/tz/date/mini-CSEBo1ZP.js +60 -0
- package/dist/chunks/pkg/booking-engine/dist/node_modules/@date-fns/tz/index--u3Qf-qy.js +4 -0
- package/dist/chunks/pkg/booking-engine/dist/node_modules/@date-fns/tz/tz/index-CEcibV-H.js +1 -0
- package/dist/chunks/pkg/booking-engine/dist/node_modules/@date-fns/tz/tzOffset/index-COlDDdap.js +22 -0
- package/dist/chunks/pkg/booking-engine/dist/pricing-BJaynUu_.js +3 -0
- package/dist/chunks/pkg/booking-engine/dist/utils/schedule-ssRov9xe.js +39 -0
- package/dist/chunks/pkg/booking-engine/dist/utils/timezone-B6XIbBPz.js +79 -0
- package/dist/components/AdminFloatingButton/AdminFloatingButton.d.ts +7 -0
- package/dist/components/AdminFloatingButton/AdminFloatingButton.d.ts.map +1 -0
- package/dist/components/AdminFloatingButton/AdminFloatingButton.js +36 -0
- package/dist/components/AdminFloatingButton/index.d.ts +3 -0
- package/dist/components/AdminFloatingButton/index.d.ts.map +1 -0
- package/dist/components/AdminFloatingButton/index.js +2 -0
- package/dist/components/BookingPeriodSelector/useBookingPeriodController.d.ts.map +1 -1
- package/dist/components/BookingPeriodSelector/useBookingPeriodController.js +213 -213
- package/dist/components/ContactSection/index.d.ts.map +1 -1
- package/dist/components/ContactSection/index.js +4 -7
- package/dist/components/Header/index.js +1 -0
- package/dist/components/PlaygroundDevFloatingButton/index.d.ts.map +1 -1
- package/dist/components/PlaygroundDevFloatingButton/index.js +121 -100
- package/dist/components/ProductPriceBadge/index.d.ts.map +1 -1
- package/dist/components/ProductPriceBadge/index.js +86 -80
- package/dist/components/StorefrontCartPanel/index.d.ts +4 -4
- package/dist/components/StorefrontCartPanel/index.d.ts.map +1 -1
- package/dist/components/StorefrontCartPanel/index.js +10 -9
- package/dist/components/WhatsAppFloatingButton/useWhatsAppFloatingButton.d.ts +2 -3
- package/dist/components/WhatsAppFloatingButton/useWhatsAppFloatingButton.d.ts.map +1 -1
- package/dist/components/WhatsAppFloatingButton/useWhatsAppFloatingButton.js +7 -81
- package/dist/i18n/en.d.ts +11 -7
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +13 -9
- package/dist/i18n/fr.d.ts +11 -7
- package/dist/i18n/fr.d.ts.map +1 -1
- package/dist/i18n/fr.js +13 -9
- package/dist/index.d.ts +62 -39
- package/dist/index.js +68 -66
- package/dist/lib/booking.d.ts +0 -6
- package/dist/lib/booking.d.ts.map +1 -1
- package/dist/lib/booking.js +51 -65
- package/dist/lib/cartSummary.d.ts +5 -3
- package/dist/lib/cartSummary.d.ts.map +1 -1
- package/dist/lib/cartSummary.js +7 -7
- package/dist/lib/floatingButtonCollision.d.ts +20 -0
- package/dist/lib/floatingButtonCollision.d.ts.map +1 -0
- package/dist/lib/floatingButtonCollision.js +72 -0
- package/dist/lib/pricing.d.ts +18 -6
- package/dist/lib/pricing.d.ts.map +1 -1
- package/dist/lib/pricing.js +45 -29
- package/dist/lib/useDraggableFloatingButton.d.ts +7 -0
- package/dist/lib/useDraggableFloatingButton.d.ts.map +1 -0
- package/dist/lib/useDraggableFloatingButton.js +107 -0
- package/dist/pages/BookingPage.d.ts.map +1 -1
- package/dist/pages/BookingPage.js +205 -201
- package/dist/pages/CheckoutPage.d.ts.map +1 -1
- package/dist/pages/CheckoutPage.js +195 -191
- package/dist/pages/checkout/components/CheckoutSummaryColumn.d.ts +2 -2
- package/dist/pages/checkout/components/CheckoutSummaryColumn.d.ts.map +1 -1
- package/dist/pages/checkout/components/CheckoutSummaryColumn.js +4 -4
- package/dist/storefront.css +1 -1
- package/dist/ui/day-picker.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@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BAAuB,GAAI,cAAc,eAAe,KAAG,eAcvE,CAAA;AAuBD,eAAO,MAAM,2BAA2B,GAAI,YAAY,MAAM,KAAG,MAOhE,CAAA;AAED,eAAO,MAAM,kCAAkC,GAC7C,SAAS,oBAAoB,EAC7B,YAAY,MAAM,KACjB,eAiBF,CAAA;AAED,eAAO,MAAM,iCAAiC,GAC5C,SAAS,oBAAoB,EAC7B,WAAW,MAAM,GAAG,SAAS,EAC7B,SAAS,OAAO,CAAC,uBAAuB,CAAC,GAAG,eAAe,KAC1D,IAkBF,CAAA;AAED,eAAO,MAAM,yCAAyC,GAAI,YAAY,MAAM,KAAG,eAE9E,CAAA;AAED,eAAO,MAAM,wCAAwC,GACnD,WAAW,MAAM,GAAG,SAAS,EAC7B,SAAS,OAAO,CAAC,uBAAuB,CAAC,GAAG,eAAe,KAC1D,IAEF,CAAA;AAED,eAAO,MAAM,0BAA0B,GACrC,cAAc,eAAe,EAC7B,UAAU;IACR,OAAO,CAAC,EAAE,oBAAoB,CAAA;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,KACA,eAOF,CAAA;AAED,eAAO,MAAM,4CAA4C,GACvD,cAAc,eAAe,EAC7B,YAAY,MAAM,KACjB,eAKF,CAAA"}
|
package/dist/lib/booking.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DEFAULT_BOOKING_DELIVERY_OPTION as e } from "../chunks/pkg/booking-engine/dist/schemas/cart-inputs-D1_Wmkca.js";
|
|
2
2
|
import "../chunks/pkg/booking-engine/dist/schemas-C2PdkXfm.js";
|
|
3
3
|
import { getDefaultBookingPeriod as t, parseTimeToMinutes as n } from "./booking-period.js";
|
|
4
|
-
import {
|
|
4
|
+
import { format as r } from "date-fns";
|
|
5
5
|
//#region src/lib/booking.ts
|
|
6
|
-
var
|
|
6
|
+
var i = [
|
|
7
7
|
"fulfillment",
|
|
8
8
|
"start_date",
|
|
9
9
|
"start_time",
|
|
@@ -11,78 +11,78 @@ var a = [
|
|
|
11
11
|
"end_time",
|
|
12
12
|
"start_address",
|
|
13
13
|
"end_address"
|
|
14
|
-
],
|
|
14
|
+
], a = "loczer_storefront_booking:", o = (e) => r(e, "yyyy-MM-dd"), s = (() => {
|
|
15
15
|
let e = [];
|
|
16
16
|
for (let t = 8; t <= 18; t += 1) for (let n of [0, 30]) t === 18 && n > 0 || e.push(`${String(t).padStart(2, "0")}:${String(n).padStart(2, "0")}`);
|
|
17
17
|
return e;
|
|
18
|
-
})(),
|
|
19
|
-
let n =
|
|
18
|
+
})(), c = (t = /* @__PURE__ */ new Date()) => {
|
|
19
|
+
let n = o(t);
|
|
20
20
|
return {
|
|
21
21
|
fulfillment: e,
|
|
22
22
|
start_date: n,
|
|
23
|
-
start_time:
|
|
23
|
+
start_time: s[3] ?? "09:30",
|
|
24
24
|
end_date: n,
|
|
25
|
-
end_time:
|
|
25
|
+
end_time: s.at(-1) ?? "18:00",
|
|
26
26
|
start_address: "",
|
|
27
27
|
end_address: ""
|
|
28
28
|
};
|
|
29
|
-
},
|
|
29
|
+
}, l = 30, u = 15, d = 10, f = 960, p = (e) => n(e) ?? f, m = (e) => (Math.trunc(e) % 7 + 7) % 7, h = (e) => {
|
|
30
30
|
if (e?.length) return e.map((e) => ({
|
|
31
31
|
minutesAfterClose: e.minutesAfterClose,
|
|
32
32
|
extraAmount: e.extraAmount
|
|
33
33
|
}));
|
|
34
|
-
},
|
|
34
|
+
}, g = (e, t = {}) => ({
|
|
35
35
|
timing: {
|
|
36
|
-
slotIntervalMinutes:
|
|
37
|
-
autoFillCutoffMinutes:
|
|
38
|
-
pastToleranceMinutes:
|
|
39
|
-
minBufferMinutes:
|
|
36
|
+
slotIntervalMinutes: l,
|
|
37
|
+
autoFillCutoffMinutes: p(t.sameDayCutoff),
|
|
38
|
+
pastToleranceMinutes: u,
|
|
39
|
+
minBufferMinutes: d
|
|
40
40
|
},
|
|
41
41
|
openingHours: e.openingHours.map((e) => ({
|
|
42
42
|
...e,
|
|
43
43
|
openingHours: e.openingHours.map((e) => ({
|
|
44
44
|
...e,
|
|
45
|
-
day:
|
|
45
|
+
day: m(e.day)
|
|
46
46
|
}))
|
|
47
47
|
})),
|
|
48
48
|
openingHoursOverrides: e.openingHoursOverrides ?? [],
|
|
49
49
|
timeZone: e.timeZone,
|
|
50
|
-
extraTimeSlots:
|
|
51
|
-
}),
|
|
50
|
+
extraTimeSlots: h(e.extraTimeSlots)
|
|
51
|
+
}), _ = (e, t = {}) => {
|
|
52
52
|
let n = e.checkout.dynamicOptions?.sameDayCutoff;
|
|
53
|
-
return
|
|
54
|
-
},
|
|
53
|
+
return g(e.shop, { sameDayCutoff: t.sameDayCutoff ?? n });
|
|
54
|
+
}, v = (e) => _(e.bookingEngine, { sameDayCutoff: e.settings.sameDayCutoff }), y = (n, r = /* @__PURE__ */ new Date()) => {
|
|
55
55
|
let i = t({
|
|
56
|
-
config:
|
|
56
|
+
config: v(n),
|
|
57
57
|
referenceDate: r
|
|
58
58
|
});
|
|
59
59
|
return {
|
|
60
60
|
fulfillment: e,
|
|
61
|
-
start_date:
|
|
61
|
+
start_date: o(i.startDate),
|
|
62
62
|
start_time: i.startTime,
|
|
63
|
-
end_date:
|
|
63
|
+
end_date: o(i.endDate),
|
|
64
64
|
end_time: i.endTime,
|
|
65
65
|
start_address: "",
|
|
66
66
|
end_address: ""
|
|
67
67
|
};
|
|
68
|
-
},
|
|
68
|
+
}, b = (e, t, n) => {
|
|
69
69
|
let r = e.get(t);
|
|
70
70
|
return r == null || r.trim() === "" ? n : r;
|
|
71
|
-
},
|
|
71
|
+
}, x = (e, t) => {
|
|
72
72
|
let n = {
|
|
73
|
-
...
|
|
73
|
+
...c(),
|
|
74
74
|
...t
|
|
75
75
|
};
|
|
76
76
|
return {
|
|
77
77
|
fulfillment: e.get("fulfillment") === "delivery" ? "delivery" : e.get("fulfillment") === "pickup" ? "pickup" : n.fulfillment,
|
|
78
|
-
start_date:
|
|
79
|
-
start_time:
|
|
80
|
-
end_date:
|
|
81
|
-
end_time:
|
|
82
|
-
start_address:
|
|
83
|
-
end_address:
|
|
78
|
+
start_date: b(e, "start_date", n.start_date),
|
|
79
|
+
start_time: b(e, "start_time", n.start_time),
|
|
80
|
+
end_date: b(e, "end_date", n.end_date),
|
|
81
|
+
end_time: b(e, "end_time", n.end_time),
|
|
82
|
+
start_address: b(e, "start_address", n.start_address),
|
|
83
|
+
end_address: b(e, "end_address", n.end_address)
|
|
84
84
|
};
|
|
85
|
-
},
|
|
85
|
+
}, S = (e, t) => {
|
|
86
86
|
let n = new URLSearchParams(e), r = (e, t) => {
|
|
87
87
|
if (t != null) {
|
|
88
88
|
if (t.trim() === "") {
|
|
@@ -93,38 +93,38 @@ var a = [
|
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
95
|
return r("fulfillment", t.fulfillment), r("start_date", t.start_date), r("start_time", t.start_time), r("end_date", t.end_date), r("end_time", t.end_time), r("start_address", t.start_address), r("end_address", t.end_address), n;
|
|
96
|
-
},
|
|
96
|
+
}, C = (e) => {
|
|
97
97
|
let t = new URLSearchParams();
|
|
98
|
-
for (let n of
|
|
98
|
+
for (let n of i) {
|
|
99
99
|
let r = e.get(n);
|
|
100
100
|
if (r == null) continue;
|
|
101
101
|
let i = r.trim();
|
|
102
102
|
i.length !== 0 && t.set(n, i);
|
|
103
103
|
}
|
|
104
104
|
return t;
|
|
105
|
-
},
|
|
105
|
+
}, w = () => {
|
|
106
106
|
if (typeof window > "u") return null;
|
|
107
107
|
try {
|
|
108
108
|
return window.sessionStorage;
|
|
109
109
|
} catch {
|
|
110
110
|
return null;
|
|
111
111
|
}
|
|
112
|
-
},
|
|
112
|
+
}, T = (e) => e instanceof URLSearchParams ? C(e) : S(new URLSearchParams(), e), E = (e) => {
|
|
113
113
|
let t = e?.trim() ?? "";
|
|
114
|
-
return t ? `${
|
|
115
|
-
},
|
|
116
|
-
let n =
|
|
114
|
+
return t ? `${a}${t}` : "";
|
|
115
|
+
}, D = (e, t) => {
|
|
116
|
+
let n = E(t);
|
|
117
117
|
if (!n || !e) return new URLSearchParams();
|
|
118
118
|
try {
|
|
119
119
|
let t = e.getItem(n);
|
|
120
|
-
return t ?
|
|
120
|
+
return t ? C(new URLSearchParams(t)) : new URLSearchParams();
|
|
121
121
|
} catch {
|
|
122
122
|
return new URLSearchParams();
|
|
123
123
|
}
|
|
124
|
-
},
|
|
125
|
-
let r =
|
|
124
|
+
}, O = (e, t, n) => {
|
|
125
|
+
let r = E(t);
|
|
126
126
|
if (!r || !e) return;
|
|
127
|
-
let i =
|
|
127
|
+
let i = T(n).toString();
|
|
128
128
|
try {
|
|
129
129
|
if (!i) {
|
|
130
130
|
e.removeItem(r);
|
|
@@ -132,28 +132,14 @@ var a = [
|
|
|
132
132
|
}
|
|
133
133
|
e.setItem(r, i);
|
|
134
134
|
} catch {}
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
},
|
|
138
|
-
let n =
|
|
139
|
-
return n.toString() ? n :
|
|
140
|
-
},
|
|
141
|
-
storage:
|
|
135
|
+
}, k = (e) => D(w(), e), A = (e, t) => {
|
|
136
|
+
O(w(), e, t);
|
|
137
|
+
}, j = (e, t) => {
|
|
138
|
+
let n = C(e);
|
|
139
|
+
return n.toString() ? n : D(t?.storage, t?.storeSlug);
|
|
140
|
+
}, M = (e, t) => j(e, {
|
|
141
|
+
storage: w(),
|
|
142
142
|
storeSlug: t
|
|
143
|
-
})
|
|
144
|
-
let t = /* @__PURE__ */ new Date(`${e.start_date}T${e.start_time}:00`), n = /* @__PURE__ */ new Date(`${e.end_date}T${e.end_time}:00`);
|
|
145
|
-
return Number.isNaN(t.getTime()) || Number.isNaN(n.getTime()) ? 0 : Math.max(0, r(n, t));
|
|
146
|
-
}, F = (e) => {
|
|
147
|
-
let t = P(e), n = Math.floor(t / 60), r = t % 60;
|
|
148
|
-
return r === 0 ? {
|
|
149
|
-
hours: n,
|
|
150
|
-
minutes: r,
|
|
151
|
-
label: `${n}h`
|
|
152
|
-
} : {
|
|
153
|
-
hours: n,
|
|
154
|
-
minutes: r,
|
|
155
|
-
label: `${n}h${String(r).padStart(2, "0")}`
|
|
156
|
-
};
|
|
157
|
-
};
|
|
143
|
+
});
|
|
158
144
|
//#endregion
|
|
159
|
-
export {
|
|
145
|
+
export { i as BOOKING_SEARCH_KEYS, s as TIME_OPTIONS, S as applyBookingParamsToSearch, _ as createBookingPeriodConfigFromBookingEngineConfiguration, g as createBookingPeriodConfigFromShopConfiguration, v as createBookingPeriodConfigFromStorefrontConfiguration, x as getBookingParamsFromSearch, E as getBookingSessionStorageKey, c as getDefaultBookingParams, y as getDefaultBookingParamsForStorefrontConfiguration, C as pickBookingSearchParams, k as readBookingSearchParamsFromSessionStorage, D as readBookingSearchParamsFromStorage, j as resolveBookingSearchParams, M as resolveBookingSearchParamsFromSessionStorage, A as writeBookingSearchParamsToSessionStorage, O as writeBookingSearchParamsToStorage };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StorefrontCartItem } from './cart';
|
|
2
2
|
import { StorefrontAvailabilityIssue } from './storefrontAvailability';
|
|
3
3
|
import { StorefrontProductsCollections } from './products';
|
|
4
|
+
import { StorefrontPublicProductPrice } from './storefrontProducts';
|
|
4
5
|
export type StorefrontCartSummaryLine = StorefrontCartItem & {
|
|
5
6
|
checkoutProductId: string;
|
|
6
7
|
productName: string;
|
|
@@ -17,8 +18,8 @@ export type StorefrontCartSummaryLine = StorefrontCartItem & {
|
|
|
17
18
|
};
|
|
18
19
|
export type StorefrontCartSummary = {
|
|
19
20
|
lines: StorefrontCartSummaryLine[];
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
totalPerBaseUnitMinor: number;
|
|
22
|
+
billableUnitCount?: number;
|
|
22
23
|
estimatedTotalMinor?: number;
|
|
23
24
|
};
|
|
24
25
|
export declare const buildStorefrontCartSummary: (params: {
|
|
@@ -26,6 +27,7 @@ export declare const buildStorefrontCartSummary: (params: {
|
|
|
26
27
|
language: string;
|
|
27
28
|
fallbackLanguage?: string;
|
|
28
29
|
products: StorefrontProductsCollections;
|
|
29
|
-
|
|
30
|
+
priceUnit: StorefrontPublicProductPrice["unit"];
|
|
31
|
+
billableUnitCount?: number;
|
|
30
32
|
}) => StorefrontCartSummary;
|
|
31
33
|
//# sourceMappingURL=cartSummary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cartSummary.d.ts","sourceRoot":"","sources":["../../src/lib/cartSummary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAClF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAA;AAE3E,OAAO,EAAkC,KAAK,6BAA6B,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"cartSummary.d.ts","sourceRoot":"","sources":["../../src/lib/cartSummary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAClF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAA;AAE3E,OAAO,EAAkC,KAAK,6BAA6B,EAAE,MAAM,YAAY,CAAA;AAE/F,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAA;AAIxE,MAAM,MAAM,yBAAyB,GAAG,kBAAkB,GAAG;IAC3D,iBAAiB,EAAE,MAAM,CAAA;IACzB,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,yBAAyB,CAAC,EAAE,MAAM,CAAA;IAClC,oBAAoB,EAAE,OAAO,CAAA;IAC7B,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,kBAAkB,CAAC,EAAE,WAAW,GAAG,WAAW,GAAG,cAAc,CAAA;IAC/D,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,iBAAiB,CAAC,EAAE,2BAA2B,CAAA;CAChD,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,yBAAyB,EAAE,CAAA;IAClC,qBAAqB,EAAE,MAAM,CAAA;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,0BAA0B,GAAI,QAAQ;IACjD,KAAK,EAAE,kBAAkB,EAAE,CAAA;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,EAAE,6BAA6B,CAAA;IACvC,SAAS,EAAE,4BAA4B,CAAC,MAAM,CAAC,CAAA;IAC/C,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,KAAG,qBAuEH,CAAA"}
|
package/dist/lib/cartSummary.js
CHANGED
|
@@ -2,15 +2,15 @@ import { getProductVariantAttributeValue as e, getProductVariantDisplay as t } f
|
|
|
2
2
|
import { getLocalizedValue as n } from "../localization.js";
|
|
3
3
|
import { getStorefrontCheckoutProductId as r } from "./products.js";
|
|
4
4
|
import { resolveStorefrontCartItemProduct as i } from "./cart.js";
|
|
5
|
-
import {
|
|
5
|
+
import { calculateRentalPriceForQuantity as a } from "./pricing.js";
|
|
6
6
|
//#region src/lib/cartSummary.ts
|
|
7
7
|
var o = (o) => {
|
|
8
|
-
let s = typeof o.
|
|
8
|
+
let s = typeof o.billableUnitCount == "number" && Number.isFinite(o.billableUnitCount) && o.billableUnitCount > 0 ? o.billableUnitCount : void 0, c = o.items.map((c) => {
|
|
9
9
|
let l = i(c, o.products);
|
|
10
10
|
if (!l) return null;
|
|
11
11
|
let u = c.productVariantId ? l.productVariants?.find((e) => e.id === c.productVariantId) : void 0;
|
|
12
12
|
if (c.productVariantId && !u) return null;
|
|
13
|
-
let d = u ? t(u) : void 0, f = l.prices ?? [], p = a(f, 1) ?? 0, m = n(l.name, o.language, o.fallbackLanguage), h = l.storefrontDisplayMode === "variants_as_products" && d?.label ? `${m} ${d.label}`.trim() : m, g = n(l.warning, o.language, o.fallbackLanguage).trim(), _ = u ? !!e(u, "size") : !1, v = typeof s == "number" ? a(f, s) ?? p * s : void 0, y = typeof v == "number" ? v * c.quantity : void 0;
|
|
13
|
+
let d = u ? t(u) : void 0, f = l.prices ?? [], p = a(f, 1, o.priceUnit) ?? 0, m = n(l.name, o.language, o.fallbackLanguage), h = l.storefrontDisplayMode === "variants_as_products" && d?.label ? `${m} ${d.label}`.trim() : m, g = n(l.warning, o.language, o.fallbackLanguage).trim(), _ = u ? !!e(u, "size") : !1, v = typeof s == "number" ? a(f, s, o.priceUnit) ?? Math.round(p * s) : void 0, y = typeof v == "number" ? v * c.quantity : void 0;
|
|
14
14
|
return {
|
|
15
15
|
...c,
|
|
16
16
|
checkoutProductId: r(l),
|
|
@@ -27,12 +27,12 @@ var o = (o) => {
|
|
|
27
27
|
}).filter((e) => e !== null), l = c.reduce((e, t) => e + t.lineTotalMinor, 0);
|
|
28
28
|
return typeof s == "number" ? {
|
|
29
29
|
lines: c,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
estimatedTotalMinor: c.reduce((e, t) => e + (t.estimatedLineTotalMinor ?? t.lineTotalMinor * s), 0)
|
|
30
|
+
totalPerBaseUnitMinor: l,
|
|
31
|
+
billableUnitCount: s,
|
|
32
|
+
estimatedTotalMinor: c.reduce((e, t) => e + (t.estimatedLineTotalMinor ?? Math.round(t.lineTotalMinor * s)), 0)
|
|
33
33
|
} : {
|
|
34
34
|
lines: c,
|
|
35
|
-
|
|
35
|
+
totalPerBaseUnitMinor: l
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
38
|
//#endregion
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface CollisionVelocity {
|
|
2
|
+
velocityX: number;
|
|
3
|
+
velocityY: number;
|
|
4
|
+
}
|
|
5
|
+
interface MoveResult {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
}
|
|
9
|
+
interface FloatingButtonCollisionParticipant {
|
|
10
|
+
id: string;
|
|
11
|
+
getRect: () => DOMRect | null;
|
|
12
|
+
isDragging: () => boolean;
|
|
13
|
+
moveBy: (dx: number, dy: number) => MoveResult;
|
|
14
|
+
cancelMotion: () => void;
|
|
15
|
+
kick: (velocityX: number, velocityY: number) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare const registerFloatingButtonCollisionParticipant: (participant: FloatingButtonCollisionParticipant) => () => void;
|
|
18
|
+
export declare const resolveFloatingButtonCollisions: (activeId: string, velocity?: Partial<CollisionVelocity>) => void;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=floatingButtonCollision.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"floatingButtonCollision.d.ts","sourceRoot":"","sources":["../../src/lib/floatingButtonCollision.ts"],"names":[],"mappings":"AAAA,UAAU,iBAAiB;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,UAAU,UAAU;IAClB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,UAAU,kCAAkC;IAC1C,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,OAAO,GAAG,IAAI,CAAA;IAC7B,UAAU,EAAE,MAAM,OAAO,CAAA;IACzB,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,UAAU,CAAA;IAC9C,YAAY,EAAE,MAAM,IAAI,CAAA;IACxB,IAAI,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAA;CACrD;AAsHD,eAAO,MAAM,0CAA0C,GACrD,aAAa,kCAAkC,eAWhD,CAAA;AAED,eAAO,MAAM,+BAA+B,GAC1C,UAAU,MAAM,EAChB,WAAW,OAAO,CAAC,iBAAiB,CAAC,SAuDtC,CAAA"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//#region src/lib/floatingButtonCollision.ts
|
|
2
|
+
var e = .45, t = .001, n = globalThis, r = n.__LOCZER_STOREFRONT_FLOATING_BUTTON_COLLISIONS__ ?? {
|
|
3
|
+
participants: /* @__PURE__ */ new Map(),
|
|
4
|
+
activePairs: /* @__PURE__ */ new Set()
|
|
5
|
+
};
|
|
6
|
+
n.__LOCZER_STOREFRONT_FLOATING_BUTTON_COLLISIONS__ = r;
|
|
7
|
+
var { participants: i, activePairs: a } = r, o = (e, t) => [e, t].sort().join("\0"), s = (e, t) => e.split("\0").includes(t), c = (e) => ({
|
|
8
|
+
x: e.left + e.width / 2,
|
|
9
|
+
y: e.top + e.height / 2
|
|
10
|
+
}), l = (e) => Math.min(e.width, e.height) / 2, u = (e) => {
|
|
11
|
+
let t = e?.velocityX, n = e?.velocityY;
|
|
12
|
+
return {
|
|
13
|
+
velocityX: typeof t == "number" && Number.isFinite(t) ? t : 0,
|
|
14
|
+
velocityY: typeof n == "number" && Number.isFinite(n) ? n : 0
|
|
15
|
+
};
|
|
16
|
+
}, d = (e, n, r) => {
|
|
17
|
+
let i = Math.hypot(r.velocityX, r.velocityY);
|
|
18
|
+
if (i > t) return {
|
|
19
|
+
x: r.velocityX / i,
|
|
20
|
+
y: r.velocityY / i
|
|
21
|
+
};
|
|
22
|
+
let a = c(e), o = c(n), s = o.x - a.x, l = o.y - a.y, u = Math.hypot(s, l);
|
|
23
|
+
return u > t ? {
|
|
24
|
+
x: s / u,
|
|
25
|
+
y: l / u
|
|
26
|
+
} : {
|
|
27
|
+
x: 1,
|
|
28
|
+
y: 0
|
|
29
|
+
};
|
|
30
|
+
}, f = (e, n, r) => {
|
|
31
|
+
let i = c(e), a = c(n), o = a.x - i.x, s = a.y - i.y, u = Math.hypot(o, s), f = l(e) + l(n);
|
|
32
|
+
if (u >= f) return null;
|
|
33
|
+
if (u <= t) {
|
|
34
|
+
let t = d(e, n, r);
|
|
35
|
+
o = t.x, s = t.y, u = 1;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
normalX: o / u,
|
|
39
|
+
normalY: s / u,
|
|
40
|
+
overlap: f - u
|
|
41
|
+
};
|
|
42
|
+
}, p = (e) => {
|
|
43
|
+
for (let t of a) s(t, e) && a.delete(t);
|
|
44
|
+
}, m = (e) => (p(e.id), i.set(e.id, e), () => {
|
|
45
|
+
i.get(e.id) === e && (i.delete(e.id), p(e.id));
|
|
46
|
+
}), h = (n, r) => {
|
|
47
|
+
let c = i.get(n), l = c?.getRect();
|
|
48
|
+
if (!c || !l) return;
|
|
49
|
+
let d = u(r), p = /* @__PURE__ */ new Set();
|
|
50
|
+
for (let r of i.values()) {
|
|
51
|
+
if (r.id === n) continue;
|
|
52
|
+
let i = r.getRect();
|
|
53
|
+
if (!i) continue;
|
|
54
|
+
let s = f(l, i, d);
|
|
55
|
+
if (!s) continue;
|
|
56
|
+
let u = o(n, r.id), m = !a.has(u);
|
|
57
|
+
p.add(u), a.add(u), m && !r.isDragging() && r.cancelMotion();
|
|
58
|
+
let h = r.isDragging() ? {
|
|
59
|
+
x: 0,
|
|
60
|
+
y: 0
|
|
61
|
+
} : r.moveBy(s.normalX * s.overlap, s.normalY * s.overlap), g = h.x * s.normalX + h.y * s.normalY, _ = s.overlap - Math.max(g, 0);
|
|
62
|
+
_ > t && c.moveBy(-s.normalX * _, -s.normalY * _);
|
|
63
|
+
let v = Math.hypot(d.velocityX, d.velocityY);
|
|
64
|
+
if (m && v >= 30 && !r.isDragging()) {
|
|
65
|
+
let t = Math.max(v * (1 - e), 80);
|
|
66
|
+
r.kick(d.velocityX * e + s.normalX * t, d.velocityY * e + s.normalY * t);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
for (let e of a) s(e, n) && !p.has(e) && a.delete(e);
|
|
70
|
+
};
|
|
71
|
+
//#endregion
|
|
72
|
+
export { m as registerFloatingButtonCollisionParticipant, h as resolveFloatingButtonCollisions };
|
package/dist/lib/pricing.d.ts
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
import { TFunction } from 'i18next';
|
|
2
|
+
import { StorefrontConfiguration } from '../storefrontSchemas';
|
|
3
|
+
import { StorefrontBookingParams } from './booking';
|
|
2
4
|
import { StorefrontPublicProductPrice } from './storefrontProducts';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
type PriceUnit = StorefrontPublicProductPrice["unit"];
|
|
6
|
+
type PricingConfiguration = StorefrontConfiguration["bookingEngine"]["pricing"];
|
|
7
|
+
export type RentalPriceRow = {
|
|
8
|
+
unitCount: number;
|
|
5
9
|
totalPriceLabel: string;
|
|
6
|
-
|
|
10
|
+
perUnitPriceLabel: string;
|
|
7
11
|
};
|
|
8
12
|
export declare const formatStorefrontPriceMinor: (valueMinor: number, locale: string, { currency }?: {
|
|
9
13
|
currency?: string;
|
|
10
14
|
}) => string;
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
13
|
-
export
|
|
15
|
+
export declare function getPricingUnitLabel(priceUnit: PriceUnit, t: TFunction, count?: number): string;
|
|
16
|
+
export declare function formatRentalUnitQuantity(quantity: number, priceUnit: PriceUnit, locale: string, t: TFunction): string;
|
|
17
|
+
export type BookingRentalUnitSummary = {
|
|
18
|
+
priceUnit: PriceUnit;
|
|
19
|
+
billableUnitCount: number;
|
|
20
|
+
};
|
|
21
|
+
export declare function calculateBookingRentalUnitSummary(booking: StorefrontBookingParams, pricing: PricingConfiguration, timeZone?: string): BookingRentalUnitSummary | null;
|
|
22
|
+
export declare function calculateRentalPriceForQuantity(prices: StorefrontPublicProductPrice[] | undefined, unitCount: number, priceUnit?: PriceUnit): number | null;
|
|
23
|
+
export declare function buildRentalPriceRows(prices: StorefrontPublicProductPrice[] | undefined, locale: string, priceUnit?: PriceUnit): RentalPriceRow[];
|
|
24
|
+
export declare function buildPriceTierLabels(prices: StorefrontPublicProductPrice[] | undefined, locale: string, t: TFunction, priceUnit?: PriceUnit): string[];
|
|
25
|
+
export {};
|
|
14
26
|
//# sourceMappingURL=pricing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../../src/lib/pricing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../../src/lib/pricing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAOxC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AACnE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AACxD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAA;AAQxE,KAAK,SAAS,GAAG,4BAA4B,CAAC,MAAM,CAAC,CAAA;AACrD,KAAK,oBAAoB,GAAG,uBAAuB,CAAC,eAAe,CAAC,CAAC,SAAS,CAAC,CAAA;AAE/E,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,MAAM,CAAA;IACvB,iBAAiB,EAAE,MAAM,CAAA;CAC1B,CAAA;AAoBD,eAAO,MAAM,0BAA0B,GACrC,YAAY,MAAM,EAClB,QAAQ,MAAM,EACd,eAAiC;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,WAKzD,CAAA;AAkBJ,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,SAAS,EACpB,CAAC,EAAE,SAAS,EACZ,KAAK,SAAI,GACR,MAAM,CAER;AAED,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,CAAC,EAAE,SAAS,GACX,MAAM,CAER;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,SAAS,EAAE,SAAS,CAAA;IACpB,iBAAiB,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,oBAAoB,EAC7B,QAAQ,SAAQ,GACf,wBAAwB,GAAG,IAAI,CAcjC;AAED,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,4BAA4B,EAAE,GAAG,SAAS,EAClD,SAAS,EAAE,MAAM,EACjB,SAAS,GAAE,SAA8B,GACxC,MAAM,GAAG,IAAI,CAYf;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,4BAA4B,EAAE,GAAG,SAAS,EAClD,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAA8B,GACxC,cAAc,EAAE,CAiBlB;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,4BAA4B,EAAE,GAAG,SAAS,EAClD,MAAM,EAAE,MAAM,EACd,CAAC,EAAE,SAAS,EACZ,SAAS,GAAE,SAA8B,GACxC,MAAM,EAAE,CAiBV"}
|
package/dist/lib/pricing.js
CHANGED
|
@@ -1,45 +1,61 @@
|
|
|
1
1
|
import { calculatePriceForQuantity as e } from "../chunks/pkg/booking-engine/dist/utils/pricing-CqXJ5fMP.js";
|
|
2
|
-
import {
|
|
2
|
+
import { calculateRentalQuantity as t, combineDateAndTime as n } from "../chunks/pkg/booking-engine/dist/utils/schedule-ssRov9xe.js";
|
|
3
|
+
import "../chunks/pkg/booking-engine/dist/pricing-BJaynUu_.js";
|
|
4
|
+
import { formatPriceMinor as r } from "./utils.js";
|
|
3
5
|
//#region src/lib/pricing.ts
|
|
4
|
-
var
|
|
6
|
+
var i = "EUR", a = "day", o = 8, s = (e) => [...e].sort((e, t) => e.quantity - t.quantity), c = (e) => e.find((e) => e.currency?.trim())?.currency?.trim() || i, l = (e) => Math.abs(e) % 100 == 0 ? {
|
|
5
7
|
minimumFractionDigits: 0,
|
|
6
8
|
maximumFractionDigits: 0
|
|
7
|
-
} : {},
|
|
8
|
-
currency:
|
|
9
|
-
...
|
|
10
|
-
}),
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
} : {}, u = (e, t, { currency: n = i } = {}) => r(e, t, {
|
|
10
|
+
currency: n,
|
|
11
|
+
...l(e)
|
|
12
|
+
}), d = (e, t) => s((e ?? []).filter((e) => e.unit === t && e.quantity > 0)), f = (e, t) => new Intl.NumberFormat(t, { maximumFractionDigits: 3 }).format(e);
|
|
13
|
+
function p(e, t, n = 1) {
|
|
14
|
+
return t(`price_unit_${e}`, { count: n });
|
|
15
|
+
}
|
|
16
|
+
function m(e, t, n, r) {
|
|
17
|
+
return `${f(e, n)} ${p(t, r, e)}`;
|
|
18
|
+
}
|
|
19
|
+
function h(e, r, i = "UTC") {
|
|
20
|
+
try {
|
|
21
|
+
let a = n(e.start_date, e.start_time, i), o = n(e.end_date, e.end_time, i);
|
|
22
|
+
return o.getTime() <= a.getTime() ? null : {
|
|
23
|
+
priceUnit: r.baseUnit,
|
|
24
|
+
billableUnitCount: t(a, o, r, i)
|
|
25
|
+
};
|
|
26
|
+
} catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function g(t, n, r = a) {
|
|
31
|
+
if (!Number.isFinite(n) || n <= 0) return null;
|
|
32
|
+
let i = d(t, r);
|
|
33
|
+
if (i.length === 0) return null;
|
|
18
34
|
try {
|
|
19
|
-
return e(
|
|
35
|
+
return e(i, n, r);
|
|
20
36
|
} catch {
|
|
21
37
|
return null;
|
|
22
38
|
}
|
|
23
39
|
}
|
|
24
|
-
function
|
|
25
|
-
let
|
|
26
|
-
if (
|
|
27
|
-
let i =
|
|
28
|
-
return Array.from({ length:
|
|
29
|
-
let
|
|
40
|
+
function _(e, t, n = a) {
|
|
41
|
+
let r = d(e, n);
|
|
42
|
+
if (r.length === 0) return [];
|
|
43
|
+
let i = c(r);
|
|
44
|
+
return Array.from({ length: o }, (e, a) => {
|
|
45
|
+
let o = a + 1, s = g(r, o, n) ?? 0, c = Math.ceil(s / o / 10) * 10;
|
|
30
46
|
return {
|
|
31
|
-
|
|
32
|
-
totalPriceLabel: s
|
|
33
|
-
|
|
47
|
+
unitCount: o,
|
|
48
|
+
totalPriceLabel: u(s, t, { currency: i }),
|
|
49
|
+
perUnitPriceLabel: u(c, t, { currency: i })
|
|
34
50
|
};
|
|
35
51
|
});
|
|
36
52
|
}
|
|
37
|
-
function
|
|
38
|
-
let
|
|
39
|
-
return
|
|
40
|
-
let
|
|
41
|
-
return d <= 0 || f < 0 ?
|
|
53
|
+
function v(e, t, n, r = a) {
|
|
54
|
+
let i = d(e, r), o = c(i);
|
|
55
|
+
return i.map((e, a) => {
|
|
56
|
+
let s = a > 0 ? i[a - 1] : void 0, c = s?.quantity ?? 0, l = s?.value ?? 0, d = e.quantity - c, f = e.value - l;
|
|
57
|
+
return d <= 0 || f < 0 ? u(e.value, t, { currency: o }) : `${u(f, t, { currency: o })} / ${m(d, r, t, n)}`;
|
|
42
58
|
});
|
|
43
59
|
}
|
|
44
60
|
//#endregion
|
|
45
|
-
export {
|
|
61
|
+
export { v as buildPriceTierLabels, _ as buildRentalPriceRows, h as calculateBookingRentalUnitSummary, g as calculateRentalPriceForQuantity, m as formatRentalUnitQuantity, u as formatStorefrontPriceMinor, p as getPricingUnitLabel };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MouseEventHandler } from 'react';
|
|
2
|
+
export declare function useDraggableFloatingButton(participantId: string): {
|
|
3
|
+
containerRef: import('react').RefObject<HTMLDivElement | null>;
|
|
4
|
+
bubbleRef: import('react').RefObject<HTMLDivElement | null>;
|
|
5
|
+
onLinkClick: MouseEventHandler<HTMLAnchorElement>;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=useDraggableFloatingButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDraggableFloatingButton.d.ts","sourceRoot":"","sources":["../../src/lib/useDraggableFloatingButton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAqBjE,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,MAAM;;;;EA2N/D"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { registerFloatingButtonCollisionParticipant as e, resolveFloatingButtonCollisions as t } from "./floatingButtonCollision.js";
|
|
2
|
+
import { useEffect as n, useRef as r } from "react";
|
|
3
|
+
import i from "interactjs";
|
|
4
|
+
//#region src/lib/useDraggableFloatingButton.ts
|
|
5
|
+
function a(a) {
|
|
6
|
+
let o = r(null), s = r(null), c = r(!1), l = r(!1), u = r(!1), d = r(null), f = r({
|
|
7
|
+
x: 0,
|
|
8
|
+
y: 0
|
|
9
|
+
}), p = r(null), m = r(null);
|
|
10
|
+
return n(() => {
|
|
11
|
+
let n = s.current;
|
|
12
|
+
if (!n || typeof window > "u") return;
|
|
13
|
+
let r = n.getBoundingClientRect();
|
|
14
|
+
p.current = {
|
|
15
|
+
left: r.left,
|
|
16
|
+
top: r.top,
|
|
17
|
+
width: r.width,
|
|
18
|
+
height: r.height
|
|
19
|
+
};
|
|
20
|
+
let o = () => {
|
|
21
|
+
if (!p.current) return f.current;
|
|
22
|
+
let { left: e, top: t, width: n, height: r } = p.current, i = 8 - e, a = 8 - t, o = window.innerWidth - 8 - n - e, s = window.innerHeight - 8 - r - t, c = Math.min(Math.max(f.current.x, i), o), l = Math.min(Math.max(f.current.y, a), s);
|
|
23
|
+
return f.current = {
|
|
24
|
+
x: c,
|
|
25
|
+
y: l
|
|
26
|
+
}, {
|
|
27
|
+
x: c,
|
|
28
|
+
y: l,
|
|
29
|
+
minX: i,
|
|
30
|
+
minY: a,
|
|
31
|
+
maxX: o,
|
|
32
|
+
maxY: s
|
|
33
|
+
};
|
|
34
|
+
}, h = () => {
|
|
35
|
+
let { x: e, y: t } = o();
|
|
36
|
+
n.style.transform = `translate3d(${e}px, ${t}px, 0)`;
|
|
37
|
+
}, g = (e, t) => {
|
|
38
|
+
let n = f.current.x, r = f.current.y;
|
|
39
|
+
return f.current.x += e, f.current.y += t, h(), {
|
|
40
|
+
x: f.current.x - n,
|
|
41
|
+
y: f.current.y - r
|
|
42
|
+
};
|
|
43
|
+
}, _ = () => {
|
|
44
|
+
m.current != null && (cancelAnimationFrame(m.current), m.current = null), l.current = !1;
|
|
45
|
+
}, v = window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches, y = (e = 0, n = 0) => {
|
|
46
|
+
t(a, {
|
|
47
|
+
velocityX: e,
|
|
48
|
+
velocityY: n
|
|
49
|
+
});
|
|
50
|
+
}, b = (e, t) => {
|
|
51
|
+
if (v) {
|
|
52
|
+
h(), y(e, t), l.current = !1;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
let r = performance.now();
|
|
56
|
+
l.current = !0;
|
|
57
|
+
let i = .92, a = .7, s = (c) => {
|
|
58
|
+
let l = (c - r) / 1e3;
|
|
59
|
+
r = c, f.current.x += e * l, f.current.y += t * l;
|
|
60
|
+
let { minX: u, minY: d, maxX: p, maxY: h } = o();
|
|
61
|
+
if (f.current.x <= u + .001 && e < 0 ? (f.current.x = u, e = -e * a) : f.current.x >= p - .001 && e > 0 && (f.current.x = p, e = -e * a), f.current.y <= d + .001 && t < 0 ? (f.current.y = d, t = -t * a) : f.current.y >= h - .001 && t > 0 && (f.current.y = h, t = -t * a), e *= i, t *= i, n.style.transform = `translate3d(${f.current.x}px, ${f.current.y}px, 0)`, y(e, t), Math.hypot(e, t) < 20) {
|
|
62
|
+
_();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
m.current = requestAnimationFrame(s);
|
|
66
|
+
};
|
|
67
|
+
m.current = requestAnimationFrame(s);
|
|
68
|
+
}, x = e({
|
|
69
|
+
id: a,
|
|
70
|
+
getRect: () => n.getBoundingClientRect(),
|
|
71
|
+
isDragging: () => c.current,
|
|
72
|
+
moveBy: g,
|
|
73
|
+
cancelMotion: _,
|
|
74
|
+
kick: b
|
|
75
|
+
}), S = i(n).draggable({ inertia: !1 }).styleCursor(!1).on("dragstart", () => {
|
|
76
|
+
_(), c.current = !0, u.current = !1, d.current != null && (window.clearTimeout(d.current), d.current = null);
|
|
77
|
+
}).on("dragmove", (e) => {
|
|
78
|
+
f.current.x += e.dx, f.current.y += e.dy, u.current = !0, h();
|
|
79
|
+
let t = Number.isFinite(e.velocityX) ? e.velocityX : 0, n = Number.isFinite(e.velocityY) ? e.velocityY : 0;
|
|
80
|
+
y(t, n);
|
|
81
|
+
}).on("dragend", (e) => {
|
|
82
|
+
let t = Number.isFinite(e.velocityX) ? e.velocityX : 0, n = Number.isFinite(e.velocityY) ? e.velocityY : 0;
|
|
83
|
+
c.current = !1, d.current = window.setTimeout(() => {
|
|
84
|
+
u.current = !1, d.current = null;
|
|
85
|
+
}, 0), Math.hypot(t, n) >= 10 ? b(t, n) : (h(), y(t, n));
|
|
86
|
+
}), C = () => {
|
|
87
|
+
let e = n.getBoundingClientRect();
|
|
88
|
+
p.current = {
|
|
89
|
+
left: e.left - f.current.x,
|
|
90
|
+
top: e.top - f.current.y,
|
|
91
|
+
width: e.width,
|
|
92
|
+
height: e.height
|
|
93
|
+
}, h(), y();
|
|
94
|
+
};
|
|
95
|
+
return window.addEventListener("resize", C), h(), y(), () => {
|
|
96
|
+
x(), S.unset(), _(), d.current != null && (window.clearTimeout(d.current), d.current = null), window.removeEventListener("resize", C);
|
|
97
|
+
};
|
|
98
|
+
}, [a]), {
|
|
99
|
+
containerRef: o,
|
|
100
|
+
bubbleRef: s,
|
|
101
|
+
onLinkClick: (e) => {
|
|
102
|
+
(u.current || c.current || l.current) && (e.preventDefault(), e.stopPropagation(), u.current = !1);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
export { a as useDraggableFloatingButton };
|