@zappie/foundations 0.1.2 → 0.1.3
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 +9 -0
- package/README.md +31 -0
- package/dist/branch-map/geometry.js +40 -0
- package/dist/branch-map/geometry.js.map +7 -0
- package/dist/branch-map/index.js +89 -0
- package/dist/branch-map/index.js.map +7 -0
- package/dist/branch-map/loader.js +39 -0
- package/dist/branch-map/loader.js.map +7 -0
- package/dist/branch-map/runtime.js +90 -0
- package/dist/branch-map/runtime.js.map +7 -0
- package/dist/index.d.ts +24 -4
- package/dist/index.js +2 -0
- package/dist/index.js.map +2 -2
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @zappie/foundations
|
|
2
2
|
|
|
3
|
+
## 0.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4bfb1b2: Add BranchMap with lazy Maps loading, themeable pins, controlled branch selection, shopper location and a fallback for branches without coordinates.
|
|
8
|
+
- Updated dependencies [4bfb1b2]
|
|
9
|
+
- Updated dependencies [666ba1c]
|
|
10
|
+
- @zappie/sdk@0.1.7
|
|
11
|
+
|
|
3
12
|
## 0.1.2
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -49,3 +49,34 @@ Foundations is at `0.x`. Its API can change in a minor release while it settles.
|
|
|
49
49
|
## License
|
|
50
50
|
|
|
51
51
|
MIT
|
|
52
|
+
|
|
53
|
+
## Branch map
|
|
54
|
+
|
|
55
|
+
`BranchMap` accepts SDK `Branch[]` data, `selectedBranchId`, `onSelect(branch)`,
|
|
56
|
+
`browserKey`, and optional `shopperLocation: { lat, lng }`. It also accepts
|
|
57
|
+
standard div attributes such as `className` and `style`.
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { BranchMap } from "@zappie/foundations";
|
|
61
|
+
|
|
62
|
+
<BranchMap
|
|
63
|
+
branches={branches}
|
|
64
|
+
selectedBranchId={selectedBranchId}
|
|
65
|
+
onSelect={(branch) => setSelectedBranchId(branch.id)}
|
|
66
|
+
browserKey={integrations.googleMaps?.browserKey}
|
|
67
|
+
shopperLocation={shopperLocation}
|
|
68
|
+
className="branch-map"
|
|
69
|
+
/>;
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Set a height on `.branch-map`. Theme pins with `--branch-map-pin`,
|
|
73
|
+
`--branch-map-pin-selected`, `--branch-map-pin-border`, and
|
|
74
|
+
`--branch-map-pin-size`. Pins expose `data-selected` and `aria-pressed`.
|
|
75
|
+
The map fits branches with valid coordinates, including across the date line.
|
|
76
|
+
Branches without coordinates remain selectable with “Map location unavailable”.
|
|
77
|
+
|
|
78
|
+
The component renders nothing without a key. It loads its map runtime and the
|
|
79
|
+
Maps JavaScript API after mount, sharing one script across mounted maps.
|
|
80
|
+
Use one browser key per page. Loading failures show “Map location unavailable”.
|
|
81
|
+
The optional location button pans to coordinates supplied by your app. Your app
|
|
82
|
+
requests geolocation permission and supplies those coordinates.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/branch-map/geometry.ts
|
|
2
|
+
function validCoordinates(value) {
|
|
3
|
+
return !!value && Number.isFinite(value.lat) && Number.isFinite(value.lng) && Math.abs(value.lat) <= 90 && Math.abs(value.lng) <= 180;
|
|
4
|
+
}
|
|
5
|
+
function visibleBranches(branches) {
|
|
6
|
+
return branches.filter(
|
|
7
|
+
(branch) => validCoordinates(branch.coordinates)
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
function branchBounds(branches) {
|
|
11
|
+
const points = visibleBranches(branches).map((branch) => branch.coordinates);
|
|
12
|
+
if (!points.length) {
|
|
13
|
+
return void 0;
|
|
14
|
+
}
|
|
15
|
+
const longitudes = points.map((point) => (point.lng + 360) % 360).sort((a, b) => a - b);
|
|
16
|
+
let gap = -1;
|
|
17
|
+
let start = 0;
|
|
18
|
+
for (let index = 0; index < longitudes.length; index++) {
|
|
19
|
+
const next = longitudes[(index + 1) % longitudes.length] + (index === longitudes.length - 1 ? 360 : 0);
|
|
20
|
+
if (next - longitudes[index] > gap) {
|
|
21
|
+
gap = next - longitudes[index];
|
|
22
|
+
start = (index + 1) % longitudes.length;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const normalize = (lng) => lng > 180 ? lng - 360 : lng;
|
|
26
|
+
return {
|
|
27
|
+
north: Math.max(...points.map((point) => point.lat)),
|
|
28
|
+
south: Math.min(...points.map((point) => point.lat)),
|
|
29
|
+
west: normalize(longitudes[start]),
|
|
30
|
+
east: normalize(
|
|
31
|
+
longitudes[(start + longitudes.length - 1) % longitudes.length]
|
|
32
|
+
)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
branchBounds,
|
|
37
|
+
validCoordinates,
|
|
38
|
+
visibleBranches
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=geometry.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/branch-map/geometry.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Branch } from \"@zappie/sdk\";\n\nexport type Coordinates = { lat: number; lng: number };\nexport function validCoordinates(value?: Coordinates): value is Coordinates {\n return (\n !!value &&\n Number.isFinite(value.lat) &&\n Number.isFinite(value.lng) &&\n Math.abs(value.lat) <= 90 &&\n Math.abs(value.lng) <= 180\n );\n}\nexport function visibleBranches(branches: Branch[]) {\n return branches.filter(\n (branch): branch is Branch & { coordinates: Coordinates } =>\n validCoordinates(branch.coordinates),\n );\n}\nexport function branchBounds(branches: Branch[]) {\n const points = visibleBranches(branches).map((branch) => branch.coordinates);\n if (!points.length) {\n return undefined;\n }\n // The largest longitude gap lies outside the bounds, including across the date line.\n const longitudes = points\n .map((point) => (point.lng + 360) % 360)\n .sort((a, b) => a - b);\n let gap = -1;\n let start = 0;\n for (let index = 0; index < longitudes.length; index++) {\n const next =\n longitudes[(index + 1) % longitudes.length]! +\n (index === longitudes.length - 1 ? 360 : 0);\n if (next - longitudes[index]! > gap) {\n gap = next - longitudes[index]!;\n start = (index + 1) % longitudes.length;\n }\n }\n const normalize = (lng: number) => (lng > 180 ? lng - 360 : lng);\n return {\n north: Math.max(...points.map((point) => point.lat)),\n south: Math.min(...points.map((point) => point.lat)),\n west: normalize(longitudes[start]!),\n east: normalize(\n longitudes[(start + longitudes.length - 1) % longitudes.length]!,\n ),\n };\n}\n"],
|
|
5
|
+
"mappings": ";AAGO,SAAS,iBAAiB,OAA2C;AAC1E,SACE,CAAC,CAAC,SACF,OAAO,SAAS,MAAM,GAAG,KACzB,OAAO,SAAS,MAAM,GAAG,KACzB,KAAK,IAAI,MAAM,GAAG,KAAK,MACvB,KAAK,IAAI,MAAM,GAAG,KAAK;AAE3B;AACO,SAAS,gBAAgB,UAAoB;AAClD,SAAO,SAAS;AAAA,IACd,CAAC,WACC,iBAAiB,OAAO,WAAW;AAAA,EACvC;AACF;AACO,SAAS,aAAa,UAAoB;AAC/C,QAAM,SAAS,gBAAgB,QAAQ,EAAE,IAAI,CAAC,WAAW,OAAO,WAAW;AAC3E,MAAI,CAAC,OAAO,QAAQ;AAClB,WAAO;AAAA,EACT;AAEA,QAAM,aAAa,OAChB,IAAI,CAAC,WAAW,MAAM,MAAM,OAAO,GAAG,EACtC,KAAK,CAAC,GAAG,MAAM,IAAI,CAAC;AACvB,MAAI,MAAM;AACV,MAAI,QAAQ;AACZ,WAAS,QAAQ,GAAG,QAAQ,WAAW,QAAQ,SAAS;AACtD,UAAM,OACJ,YAAY,QAAQ,KAAK,WAAW,MAAM,KACzC,UAAU,WAAW,SAAS,IAAI,MAAM;AAC3C,QAAI,OAAO,WAAW,KAAK,IAAK,KAAK;AACnC,YAAM,OAAO,WAAW,KAAK;AAC7B,eAAS,QAAQ,KAAK,WAAW;AAAA,IACnC;AAAA,EACF;AACA,QAAM,YAAY,CAAC,QAAiB,MAAM,MAAM,MAAM,MAAM;AAC5D,SAAO;AAAA,IACL,OAAO,KAAK,IAAI,GAAG,OAAO,IAAI,CAAC,UAAU,MAAM,GAAG,CAAC;AAAA,IACnD,OAAO,KAAK,IAAI,GAAG,OAAO,IAAI,CAAC,UAAU,MAAM,GAAG,CAAC;AAAA,IACnD,MAAM,UAAU,WAAW,KAAK,CAAE;AAAA,IAClC,MAAM;AAAA,MACJ,YAAY,QAAQ,WAAW,SAAS,KAAK,WAAW,MAAM;AAAA,IAChE;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/branch-map/index.tsx
|
|
4
|
+
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
import {
|
|
6
|
+
validCoordinates,
|
|
7
|
+
visibleBranches
|
|
8
|
+
} from "./geometry.js";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
function BranchMap({
|
|
11
|
+
branches,
|
|
12
|
+
selectedBranchId,
|
|
13
|
+
onSelect,
|
|
14
|
+
shopperLocation,
|
|
15
|
+
browserKey,
|
|
16
|
+
...props
|
|
17
|
+
}) {
|
|
18
|
+
const element = useRef(null);
|
|
19
|
+
const [runtime, setRuntime] = useState();
|
|
20
|
+
const [failed, setFailed] = useState(false);
|
|
21
|
+
const hasCoordinates = visibleBranches(branches).length > 0;
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!browserKey || !element.current || !hasCoordinates) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
let disposed = false;
|
|
27
|
+
const controller = new AbortController();
|
|
28
|
+
let instance;
|
|
29
|
+
const target = element.current;
|
|
30
|
+
setFailed(false);
|
|
31
|
+
void import("./runtime.js").then(({ createMap }) => createMap(target, browserKey, controller.signal)).then((map) => {
|
|
32
|
+
instance = map;
|
|
33
|
+
if (disposed) {
|
|
34
|
+
map.destroy();
|
|
35
|
+
} else {
|
|
36
|
+
setRuntime(map);
|
|
37
|
+
}
|
|
38
|
+
}).catch(() => {
|
|
39
|
+
if (!disposed) {
|
|
40
|
+
setFailed(true);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return () => {
|
|
44
|
+
disposed = true;
|
|
45
|
+
controller.abort();
|
|
46
|
+
instance?.destroy();
|
|
47
|
+
setRuntime(void 0);
|
|
48
|
+
};
|
|
49
|
+
}, [browserKey, hasCoordinates]);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
runtime?.update(branches, selectedBranchId, onSelect, shopperLocation);
|
|
52
|
+
}, [runtime, branches, selectedBranchId, onSelect, shopperLocation]);
|
|
53
|
+
if (!browserKey) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const unavailable = branches.filter(
|
|
57
|
+
(branch) => !validCoordinates(branch.coordinates)
|
|
58
|
+
);
|
|
59
|
+
return /* @__PURE__ */ jsxs("div", { ...props, "data-branch-map": "", children: [
|
|
60
|
+
/* @__PURE__ */ jsx(
|
|
61
|
+
"div",
|
|
62
|
+
{
|
|
63
|
+
hidden: failed || !hasCoordinates,
|
|
64
|
+
ref: element,
|
|
65
|
+
"data-branch-map-canvas": "",
|
|
66
|
+
style: { height: "100%" }
|
|
67
|
+
}
|
|
68
|
+
),
|
|
69
|
+
failed || !hasCoordinates ? /* @__PURE__ */ jsx("p", { role: "status", children: "Map location unavailable" }) : null,
|
|
70
|
+
unavailable.map((branch) => /* @__PURE__ */ jsxs(
|
|
71
|
+
"button",
|
|
72
|
+
{
|
|
73
|
+
type: "button",
|
|
74
|
+
"aria-pressed": branch.id === selectedBranchId,
|
|
75
|
+
onClick: () => onSelect(branch),
|
|
76
|
+
children: [
|
|
77
|
+
branch.name,
|
|
78
|
+
": Map location unavailable"
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
branch.id
|
|
82
|
+
)),
|
|
83
|
+
runtime && validCoordinates(shopperLocation) ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => runtime.locate(shopperLocation), children: "Use my current location" }) : null
|
|
84
|
+
] });
|
|
85
|
+
}
|
|
86
|
+
export {
|
|
87
|
+
BranchMap
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/branch-map/index.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\";\nimport type { Branch } from \"@zappie/sdk\";\nimport { useEffect, useRef, useState, type HTMLAttributes } from \"react\";\nimport {\n validCoordinates,\n visibleBranches,\n type Coordinates,\n} from \"./geometry\";\nimport type { createMap } from \"./runtime\";\n\n/** Branches, selection and optional shopper coordinates for BranchMap. */\nexport type BranchMapProps = Omit<\n HTMLAttributes<HTMLDivElement>,\n \"onSelect\"\n> & {\n branches: Branch[];\n selectedBranchId?: string;\n onSelect: (branch: Branch) => void;\n shopperLocation?: Coordinates;\n browserKey?: string;\n};\n\n/**\n * Show branch locations. Maps loads after mount when you supply a browser key.\n * Set the container height with CSS. Style pins with --branch-map-pin,\n * --branch-map-pin-selected, --branch-map-pin-border and --branch-map-pin-size.\n */\nexport function BranchMap({\n branches,\n selectedBranchId,\n onSelect,\n shopperLocation,\n browserKey,\n ...props\n}: BranchMapProps) {\n const element = useRef<HTMLDivElement>(null);\n const [runtime, setRuntime] =\n useState<Awaited<ReturnType<typeof createMap>>>();\n const [failed, setFailed] = useState(false);\n const hasCoordinates = visibleBranches(branches).length > 0;\n useEffect(() => {\n if (!browserKey || !element.current || !hasCoordinates) {\n return;\n }\n let disposed = false;\n const controller = new AbortController();\n let instance: Awaited<ReturnType<typeof createMap>> | undefined;\n const target = element.current;\n setFailed(false);\n void import(\"./runtime\")\n .then(({ createMap }) => createMap(target, browserKey, controller.signal))\n .then((map) => {\n instance = map;\n if (disposed) {\n map.destroy();\n } else {\n setRuntime(map);\n }\n })\n .catch(() => {\n if (!disposed) {\n setFailed(true);\n }\n });\n return () => {\n disposed = true;\n controller.abort();\n instance?.destroy();\n setRuntime(undefined);\n };\n }, [browserKey, hasCoordinates]);\n useEffect(() => {\n runtime?.update(branches, selectedBranchId, onSelect, shopperLocation);\n }, [runtime, branches, selectedBranchId, onSelect, shopperLocation]);\n if (!browserKey) {\n return null;\n }\n const unavailable = branches.filter(\n (branch) => !validCoordinates(branch.coordinates),\n );\n return (\n <div {...props} data-branch-map=\"\">\n <div\n hidden={failed || !hasCoordinates}\n ref={element}\n data-branch-map-canvas=\"\"\n style={{ height: \"100%\" }}\n />\n {failed || !hasCoordinates ? (\n <p role=\"status\">Map location unavailable</p>\n ) : null}\n {unavailable.map((branch) => (\n <button\n key={branch.id}\n type=\"button\"\n aria-pressed={branch.id === selectedBranchId}\n onClick={() => onSelect(branch)}\n >\n {branch.name}: Map location unavailable\n </button>\n ))}\n {runtime && validCoordinates(shopperLocation) ? (\n <button type=\"button\" onClick={() => runtime.locate(shopperLocation)}>\n Use my current location\n </button>\n ) : null}\n </div>\n );\n}\n"],
|
|
5
|
+
"mappings": ";;;AAEA,SAAS,WAAW,QAAQ,gBAAqC;AACjE;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AA2ED,cAUE,YAVF;AAvDC,SAAS,UAAU;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAmB;AACjB,QAAM,UAAU,OAAuB,IAAI;AAC3C,QAAM,CAAC,SAAS,UAAU,IACxB,SAAgD;AAClD,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,KAAK;AAC1C,QAAM,iBAAiB,gBAAgB,QAAQ,EAAE,SAAS;AAC1D,YAAU,MAAM;AACd,QAAI,CAAC,cAAc,CAAC,QAAQ,WAAW,CAAC,gBAAgB;AACtD;AAAA,IACF;AACA,QAAI,WAAW;AACf,UAAM,aAAa,IAAI,gBAAgB;AACvC,QAAI;AACJ,UAAM,SAAS,QAAQ;AACvB,cAAU,KAAK;AACf,SAAK,OAAO,cAAW,EACpB,KAAK,CAAC,EAAE,UAAU,MAAM,UAAU,QAAQ,YAAY,WAAW,MAAM,CAAC,EACxE,KAAK,CAAC,QAAQ;AACb,iBAAW;AACX,UAAI,UAAU;AACZ,YAAI,QAAQ;AAAA,MACd,OAAO;AACL,mBAAW,GAAG;AAAA,MAChB;AAAA,IACF,CAAC,EACA,MAAM,MAAM;AACX,UAAI,CAAC,UAAU;AACb,kBAAU,IAAI;AAAA,MAChB;AAAA,IACF,CAAC;AACH,WAAO,MAAM;AACX,iBAAW;AACX,iBAAW,MAAM;AACjB,gBAAU,QAAQ;AAClB,iBAAW,MAAS;AAAA,IACtB;AAAA,EACF,GAAG,CAAC,YAAY,cAAc,CAAC;AAC/B,YAAU,MAAM;AACd,aAAS,OAAO,UAAU,kBAAkB,UAAU,eAAe;AAAA,EACvE,GAAG,CAAC,SAAS,UAAU,kBAAkB,UAAU,eAAe,CAAC;AACnE,MAAI,CAAC,YAAY;AACf,WAAO;AAAA,EACT;AACA,QAAM,cAAc,SAAS;AAAA,IAC3B,CAAC,WAAW,CAAC,iBAAiB,OAAO,WAAW;AAAA,EAClD;AACA,SACE,qBAAC,SAAK,GAAG,OAAO,mBAAgB,IAC9B;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,QAAQ,UAAU,CAAC;AAAA,QACnB,KAAK;AAAA,QACL,0BAAuB;AAAA,QACvB,OAAO,EAAE,QAAQ,OAAO;AAAA;AAAA,IAC1B;AAAA,IACC,UAAU,CAAC,iBACV,oBAAC,OAAE,MAAK,UAAS,sCAAwB,IACvC;AAAA,IACH,YAAY,IAAI,CAAC,WAChB;AAAA,MAAC;AAAA;AAAA,QAEC,MAAK;AAAA,QACL,gBAAc,OAAO,OAAO;AAAA,QAC5B,SAAS,MAAM,SAAS,MAAM;AAAA,QAE7B;AAAA,iBAAO;AAAA,UAAK;AAAA;AAAA;AAAA,MALR,OAAO;AAAA,IAMd,CACD;AAAA,IACA,WAAW,iBAAiB,eAAe,IAC1C,oBAAC,YAAO,MAAK,UAAS,SAAS,MAAM,QAAQ,OAAO,eAAe,GAAG,qCAEtE,IACE;AAAA,KACN;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// src/branch-map/loader.ts
|
|
2
|
+
var pending;
|
|
3
|
+
function loadMaps(key) {
|
|
4
|
+
if (globalThis.google?.maps?.Map) {
|
|
5
|
+
return Promise.resolve(google.maps);
|
|
6
|
+
}
|
|
7
|
+
if (pending) {
|
|
8
|
+
return pending;
|
|
9
|
+
}
|
|
10
|
+
pending = new Promise((resolve, reject) => {
|
|
11
|
+
const script = document.createElement("script");
|
|
12
|
+
const callback = `__zappieMaps${Date.now()}`;
|
|
13
|
+
const scope = globalThis;
|
|
14
|
+
const cleanup = () => {
|
|
15
|
+
clearTimeout(timeout);
|
|
16
|
+
delete scope[callback];
|
|
17
|
+
};
|
|
18
|
+
const fail = () => {
|
|
19
|
+
cleanup();
|
|
20
|
+
script.remove();
|
|
21
|
+
pending = void 0;
|
|
22
|
+
reject(new Error("Map location unavailable"));
|
|
23
|
+
};
|
|
24
|
+
const timeout = setTimeout(fail, 15e3);
|
|
25
|
+
scope[callback] = () => {
|
|
26
|
+
cleanup();
|
|
27
|
+
resolve(google.maps);
|
|
28
|
+
};
|
|
29
|
+
script.async = true;
|
|
30
|
+
script.src = `https://maps.googleapis.com/maps/api/js?${new URLSearchParams({ key, loading: "async", callback, v: "weekly" })}`;
|
|
31
|
+
script.onerror = fail;
|
|
32
|
+
document.head.appendChild(script);
|
|
33
|
+
});
|
|
34
|
+
return pending;
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
loadMaps
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/branch-map/loader.ts"],
|
|
4
|
+
"sourcesContent": ["/// <reference types=\"google.maps\" />\nlet pending: Promise<typeof google.maps> | undefined;\n\nexport function loadMaps(key: string): Promise<typeof google.maps> {\n if (globalThis.google?.maps?.Map) {\n return Promise.resolve(google.maps);\n }\n if (pending) {\n return pending;\n }\n pending = new Promise((resolve, reject) => {\n const script = document.createElement(\"script\");\n const callback = `__zappieMaps${Date.now()}`;\n const scope = globalThis as unknown as Record<string, unknown>;\n const cleanup = () => {\n clearTimeout(timeout);\n delete scope[callback];\n };\n const fail = () => {\n cleanup();\n script.remove();\n pending = undefined;\n reject(new Error(\"Map location unavailable\"));\n };\n const timeout = setTimeout(fail, 15000);\n scope[callback] = () => {\n cleanup();\n resolve(google.maps);\n };\n script.async = true;\n script.src = `https://maps.googleapis.com/maps/api/js?${new URLSearchParams({ key, loading: \"async\", callback, v: \"weekly\" })}`;\n script.onerror = fail;\n document.head.appendChild(script);\n });\n return pending;\n}\n"],
|
|
5
|
+
"mappings": ";AACA,IAAI;AAEG,SAAS,SAAS,KAA0C;AACjE,MAAI,WAAW,QAAQ,MAAM,KAAK;AAChC,WAAO,QAAQ,QAAQ,OAAO,IAAI;AAAA,EACpC;AACA,MAAI,SAAS;AACX,WAAO;AAAA,EACT;AACA,YAAU,IAAI,QAAQ,CAAC,SAAS,WAAW;AACzC,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,UAAM,WAAW,eAAe,KAAK,IAAI,CAAC;AAC1C,UAAM,QAAQ;AACd,UAAM,UAAU,MAAM;AACpB,mBAAa,OAAO;AACpB,aAAO,MAAM,QAAQ;AAAA,IACvB;AACA,UAAM,OAAO,MAAM;AACjB,cAAQ;AACR,aAAO,OAAO;AACd,gBAAU;AACV,aAAO,IAAI,MAAM,0BAA0B,CAAC;AAAA,IAC9C;AACA,UAAM,UAAU,WAAW,MAAM,IAAK;AACtC,UAAM,QAAQ,IAAI,MAAM;AACtB,cAAQ;AACR,cAAQ,OAAO,IAAI;AAAA,IACrB;AACA,WAAO,QAAQ;AACf,WAAO,MAAM,2CAA2C,IAAI,gBAAgB,EAAE,KAAK,SAAS,SAAS,UAAU,GAAG,SAAS,CAAC,CAAC;AAC7H,WAAO,UAAU;AACjB,aAAS,KAAK,YAAY,MAAM;AAAA,EAClC,CAAC;AACD,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// src/branch-map/runtime.ts
|
|
2
|
+
import {
|
|
3
|
+
branchBounds,
|
|
4
|
+
validCoordinates,
|
|
5
|
+
visibleBranches
|
|
6
|
+
} from "./geometry.js";
|
|
7
|
+
import { loadMaps } from "./loader.js";
|
|
8
|
+
async function createMap(element, key, signal) {
|
|
9
|
+
const maps = await loadMaps(key);
|
|
10
|
+
signal.throwIfAborted();
|
|
11
|
+
const map = new maps.Map(element, {
|
|
12
|
+
center: { lat: 0, lng: 0 },
|
|
13
|
+
zoom: 12,
|
|
14
|
+
maxZoom: 18,
|
|
15
|
+
mapTypeControl: false,
|
|
16
|
+
streetViewControl: false
|
|
17
|
+
});
|
|
18
|
+
let pins = [];
|
|
19
|
+
class Pin extends maps.OverlayView {
|
|
20
|
+
constructor(position, label, selected, onClick) {
|
|
21
|
+
super();
|
|
22
|
+
this.position = position;
|
|
23
|
+
this.button = document.createElement("button");
|
|
24
|
+
this.button.type = "button";
|
|
25
|
+
this.button.setAttribute("aria-label", label);
|
|
26
|
+
this.button.setAttribute("aria-pressed", String(selected));
|
|
27
|
+
this.button.dataset.selected = String(selected);
|
|
28
|
+
this.button.dataset.branchMapPin = "";
|
|
29
|
+
this.button.style.cssText = `position:absolute;transform:translate(-50%,-100%);width:var(--branch-map-pin-size,24px);height:var(--branch-map-pin-size,24px);border-radius:50%;border:2px solid var(--branch-map-pin-border,currentColor);background:var(${selected ? "--branch-map-pin-selected" : "--branch-map-pin"},currentColor);cursor:pointer`;
|
|
30
|
+
this.button.onclick = onClick ?? null;
|
|
31
|
+
}
|
|
32
|
+
onAdd() {
|
|
33
|
+
this.getPanes()?.overlayMouseTarget.appendChild(this.button);
|
|
34
|
+
maps.OverlayView.preventMapHitsAndGesturesFrom(this.button);
|
|
35
|
+
}
|
|
36
|
+
draw() {
|
|
37
|
+
const point = this.getProjection().fromLatLngToDivPixel(
|
|
38
|
+
new maps.LatLng(this.position)
|
|
39
|
+
);
|
|
40
|
+
if (point) {
|
|
41
|
+
this.button.style.left = `${point.x}px`;
|
|
42
|
+
this.button.style.top = `${point.y}px`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
onRemove() {
|
|
46
|
+
this.button.remove();
|
|
47
|
+
this.button.onclick = null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const clear = () => {
|
|
51
|
+
pins.forEach((pin) => pin.setMap(null));
|
|
52
|
+
pins = [];
|
|
53
|
+
};
|
|
54
|
+
return {
|
|
55
|
+
update(branches, selected, onSelect, location) {
|
|
56
|
+
clear();
|
|
57
|
+
for (const branch of visibleBranches(branches)) {
|
|
58
|
+
const pin = new Pin(
|
|
59
|
+
branch.coordinates,
|
|
60
|
+
branch.name,
|
|
61
|
+
branch.id === selected,
|
|
62
|
+
() => onSelect(branch)
|
|
63
|
+
);
|
|
64
|
+
pin.setMap(map);
|
|
65
|
+
pins.push(pin);
|
|
66
|
+
}
|
|
67
|
+
const bounds = branchBounds(branches);
|
|
68
|
+
if (bounds) {
|
|
69
|
+
map.fitBounds(bounds, 32);
|
|
70
|
+
}
|
|
71
|
+
if (validCoordinates(location)) {
|
|
72
|
+
const pin = new Pin(location, "Your location", false);
|
|
73
|
+
pin.setMap(map);
|
|
74
|
+
pins.push(pin);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
locate(location) {
|
|
78
|
+
map.panTo(location);
|
|
79
|
+
},
|
|
80
|
+
destroy() {
|
|
81
|
+
clear();
|
|
82
|
+
maps.event.clearInstanceListeners(map);
|
|
83
|
+
element.replaceChildren();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
createMap
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/branch-map/runtime.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Branch } from \"@zappie/sdk\";\nimport {\n branchBounds,\n validCoordinates,\n visibleBranches,\n type Coordinates,\n} from \"./geometry\";\nimport { loadMaps } from \"./loader\";\n\nexport async function createMap(\n element: HTMLElement,\n key: string,\n signal: AbortSignal,\n) {\n const maps = await loadMaps(key);\n signal.throwIfAborted();\n const map = new maps.Map(element, {\n center: { lat: 0, lng: 0 },\n zoom: 12,\n maxZoom: 18,\n mapTypeControl: false,\n streetViewControl: false,\n });\n let pins: google.maps.OverlayView[] = [];\n class Pin extends maps.OverlayView {\n private button: HTMLButtonElement;\n constructor(\n private position: Coordinates,\n label: string,\n selected: boolean,\n onClick?: () => void,\n ) {\n super();\n this.button = document.createElement(\"button\");\n this.button.type = \"button\";\n this.button.setAttribute(\"aria-label\", label);\n this.button.setAttribute(\"aria-pressed\", String(selected));\n this.button.dataset.selected = String(selected);\n this.button.dataset.branchMapPin = \"\";\n this.button.style.cssText = `position:absolute;transform:translate(-50%,-100%);width:var(--branch-map-pin-size,24px);height:var(--branch-map-pin-size,24px);border-radius:50%;border:2px solid var(--branch-map-pin-border,currentColor);background:var(${selected ? \"--branch-map-pin-selected\" : \"--branch-map-pin\"},currentColor);cursor:pointer`;\n this.button.onclick = onClick ?? null;\n }\n onAdd() {\n this.getPanes()?.overlayMouseTarget.appendChild(this.button);\n maps.OverlayView.preventMapHitsAndGesturesFrom(this.button);\n }\n draw() {\n const point = this.getProjection().fromLatLngToDivPixel(\n new maps.LatLng(this.position),\n );\n if (point) {\n this.button.style.left = `${point.x}px`;\n this.button.style.top = `${point.y}px`;\n }\n }\n onRemove() {\n this.button.remove();\n this.button.onclick = null;\n }\n }\n const clear = () => {\n pins.forEach((pin) => pin.setMap(null));\n pins = [];\n };\n return {\n update(\n branches: Branch[],\n selected: string | undefined,\n onSelect: (branch: Branch) => void,\n location?: Coordinates,\n ) {\n clear();\n for (const branch of visibleBranches(branches)) {\n const pin = new Pin(\n branch.coordinates,\n branch.name,\n branch.id === selected,\n () => onSelect(branch),\n );\n pin.setMap(map);\n pins.push(pin);\n }\n const bounds = branchBounds(branches);\n if (bounds) {\n map.fitBounds(bounds, 32);\n }\n if (validCoordinates(location)) {\n const pin = new Pin(location, \"Your location\", false);\n pin.setMap(map);\n pins.push(pin);\n }\n },\n locate(location: Coordinates) {\n map.panTo(location);\n },\n destroy() {\n clear();\n maps.event.clearInstanceListeners(map);\n element.replaceChildren();\n },\n };\n}\n"],
|
|
5
|
+
"mappings": ";AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,gBAAgB;AAEzB,eAAsB,UACpB,SACA,KACA,QACA;AACA,QAAM,OAAO,MAAM,SAAS,GAAG;AAC/B,SAAO,eAAe;AACtB,QAAM,MAAM,IAAI,KAAK,IAAI,SAAS;AAAA,IAChC,QAAQ,EAAE,KAAK,GAAG,KAAK,EAAE;AAAA,IACzB,MAAM;AAAA,IACN,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,mBAAmB;AAAA,EACrB,CAAC;AACD,MAAI,OAAkC,CAAC;AAAA,EACvC,MAAM,YAAY,KAAK,YAAY;AAAA,IAEjC,YACU,UACR,OACA,UACA,SACA;AACA,YAAM;AALE;AAMR,WAAK,SAAS,SAAS,cAAc,QAAQ;AAC7C,WAAK,OAAO,OAAO;AACnB,WAAK,OAAO,aAAa,cAAc,KAAK;AAC5C,WAAK,OAAO,aAAa,gBAAgB,OAAO,QAAQ,CAAC;AACzD,WAAK,OAAO,QAAQ,WAAW,OAAO,QAAQ;AAC9C,WAAK,OAAO,QAAQ,eAAe;AACnC,WAAK,OAAO,MAAM,UAAU,8NAA8N,WAAW,8BAA8B,kBAAkB;AACrT,WAAK,OAAO,UAAU,WAAW;AAAA,IACnC;AAAA,IACA,QAAQ;AACN,WAAK,SAAS,GAAG,mBAAmB,YAAY,KAAK,MAAM;AAC3D,WAAK,YAAY,8BAA8B,KAAK,MAAM;AAAA,IAC5D;AAAA,IACA,OAAO;AACL,YAAM,QAAQ,KAAK,cAAc,EAAE;AAAA,QACjC,IAAI,KAAK,OAAO,KAAK,QAAQ;AAAA,MAC/B;AACA,UAAI,OAAO;AACT,aAAK,OAAO,MAAM,OAAO,GAAG,MAAM,CAAC;AACnC,aAAK,OAAO,MAAM,MAAM,GAAG,MAAM,CAAC;AAAA,MACpC;AAAA,IACF;AAAA,IACA,WAAW;AACT,WAAK,OAAO,OAAO;AACnB,WAAK,OAAO,UAAU;AAAA,IACxB;AAAA,EACF;AACA,QAAM,QAAQ,MAAM;AAClB,SAAK,QAAQ,CAAC,QAAQ,IAAI,OAAO,IAAI,CAAC;AACtC,WAAO,CAAC;AAAA,EACV;AACA,SAAO;AAAA,IACL,OACE,UACA,UACA,UACA,UACA;AACA,YAAM;AACN,iBAAW,UAAU,gBAAgB,QAAQ,GAAG;AAC9C,cAAM,MAAM,IAAI;AAAA,UACd,OAAO;AAAA,UACP,OAAO;AAAA,UACP,OAAO,OAAO;AAAA,UACd,MAAM,SAAS,MAAM;AAAA,QACvB;AACA,YAAI,OAAO,GAAG;AACd,aAAK,KAAK,GAAG;AAAA,MACf;AACA,YAAM,SAAS,aAAa,QAAQ;AACpC,UAAI,QAAQ;AACV,YAAI,UAAU,QAAQ,EAAE;AAAA,MAC1B;AACA,UAAI,iBAAiB,QAAQ,GAAG;AAC9B,cAAM,MAAM,IAAI,IAAI,UAAU,iBAAiB,KAAK;AACpD,YAAI,OAAO,GAAG;AACd,aAAK,KAAK,GAAG;AAAA,MACf;AAAA,IACF;AAAA,IACA,OAAO,UAAuB;AAC5B,UAAI,MAAM,QAAQ;AAAA,IACpB;AAAA,IACA,UAAU;AACR,YAAM;AACN,WAAK,MAAM,uBAAuB,GAAG;AACrC,cAAQ,gBAAgB;AAAA,IAC1B;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { KeyboardEvent as KeyboardEvent$1, ImgHTMLAttributes, ChangeEvent, ClipboardEvent } from 'react';
|
|
3
|
-
import * as _zappie_sdk from '@zappie/sdk';
|
|
4
|
-
import { CartLine, CartLineInput, CartIssue, CartFix, Quote, DeliveryAddress, Branch as Branch$1, MenuSchedule, CartFulfilment, OptionGroup as OptionGroup$1, Item, Money as Money$1, Choice as Choice$1, MoneyFormatOptions, PaymentMethodKind, Category, Menu, OpeningTime } from '@zappie/sdk';
|
|
2
|
+
import { HTMLAttributes, KeyboardEvent as KeyboardEvent$1, ImgHTMLAttributes, ChangeEvent, ClipboardEvent } from 'react';
|
|
5
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import * as _zappie_sdk from '@zappie/sdk';
|
|
5
|
+
import { Branch as Branch$1, CartLine, CartLineInput, CartIssue, CartFix, Quote, DeliveryAddress, MenuSchedule, CartFulfilment, OptionGroup as OptionGroup$1, Item, Money as Money$1, Choice as Choice$1, MoneyFormatOptions, PaymentMethodKind, Category, Menu, OpeningTime } from '@zappie/sdk';
|
|
6
6
|
import { useCart } from '@zappie/sdk/react';
|
|
7
7
|
import { P as PartProps, a as Presentation, S as SwipeDirection } from './engine-XTsgCwwe.js';
|
|
8
8
|
import { C as CloseOptions, O as OverlayQuery } from './history-Bqu12Vkz.js';
|
|
@@ -63,6 +63,26 @@ declare const Account: {
|
|
|
63
63
|
} & react.RefAttributes<HTMLElement>>;
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
+
type Coordinates = {
|
|
67
|
+
lat: number;
|
|
68
|
+
lng: number;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** Branches, selection and optional shopper coordinates for BranchMap. */
|
|
72
|
+
type BranchMapProps = Omit<HTMLAttributes<HTMLDivElement>, "onSelect"> & {
|
|
73
|
+
branches: Branch$1[];
|
|
74
|
+
selectedBranchId?: string;
|
|
75
|
+
onSelect: (branch: Branch$1) => void;
|
|
76
|
+
shopperLocation?: Coordinates;
|
|
77
|
+
browserKey?: string;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Show branch locations. Maps loads after mount when you supply a browser key.
|
|
81
|
+
* Set the container height with CSS. Style pins with --branch-map-pin,
|
|
82
|
+
* --branch-map-pin-selected, --branch-map-pin-border and --branch-map-pin-size.
|
|
83
|
+
*/
|
|
84
|
+
declare function BranchMap({ branches, selectedBranchId, onSelect, shopperLocation, browserKey, ...props }: BranchMapProps): react_jsx_runtime.JSX.Element | null;
|
|
85
|
+
|
|
66
86
|
/**
|
|
67
87
|
* The current quantity, bounds, step, disabled state and value setter exposed by a quantity control.
|
|
68
88
|
*/
|
|
@@ -805,4 +825,4 @@ declare const OpenStatus: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttr
|
|
|
805
825
|
/** The installed @zappie/foundations version. */
|
|
806
826
|
declare const FOUNDATIONS_VERSION: string;
|
|
807
827
|
|
|
808
|
-
export { Account, AccountNotConfiguredError, type ActiveGroup, Address, type AddressState, type AddressSuggestion, Branch, Cart, Choice, type Customer, FOUNDATIONS_VERSION, Fulfilment, Image, type ImageProps, ItemForm, type ItemFormContext, type ItemFormProps, Money, OpenStatus, OptionGroup, Otp, Overlay, PartProps, type PaymentMethod, PaymentMethods, Quantity, type QuantityProps, type QuantityState, Schedule, type ScheduleSlot, type ScheduleState, Search, type SearchResult, type SearchSource, type SearchState, type SignInOptions, Totals, type TotalsState, createSearchIndex, formatOpeningHours, formatWallClock, getOpenStatus, parseWallClock, scheduleSlots, useControllableState, useOverlay };
|
|
828
|
+
export { Account, AccountNotConfiguredError, type ActiveGroup, Address, type AddressState, type AddressSuggestion, Branch, BranchMap, type BranchMapProps, Cart, Choice, type Customer, FOUNDATIONS_VERSION, Fulfilment, Image, type ImageProps, ItemForm, type ItemFormContext, type ItemFormProps, Money, OpenStatus, OptionGroup, Otp, Overlay, PartProps, type PaymentMethod, PaymentMethods, Quantity, type QuantityProps, type QuantityState, Schedule, type ScheduleSlot, type ScheduleState, Search, type SearchResult, type SearchSource, type SearchState, type SignInOptions, Totals, type TotalsState, createSearchIndex, formatOpeningHours, formatWallClock, getOpenStatus, parseWallClock, scheduleSlots, useControllableState, useOverlay };
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { PACKAGE_VERSION } from "./version.js";
|
|
5
5
|
import { Account, AccountNotConfiguredError } from "./account/index.js";
|
|
6
|
+
import { BranchMap } from "./branch-map/index.js";
|
|
6
7
|
import { Cart, Totals } from "./cart/index.js";
|
|
7
8
|
import { Address } from "./fulfilment/address-picker.js";
|
|
8
9
|
import { Branch } from "./fulfilment/branch-picker.js";
|
|
@@ -29,6 +30,7 @@ export {
|
|
|
29
30
|
AccountNotConfiguredError,
|
|
30
31
|
Address,
|
|
31
32
|
Branch,
|
|
33
|
+
BranchMap,
|
|
32
34
|
Cart,
|
|
33
35
|
FOUNDATIONS_VERSION,
|
|
34
36
|
Fulfilment,
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["\"use client\";\nimport { PACKAGE_VERSION } from \"./version\";\n\n/** The installed @zappie/foundations version. */\nexport const FOUNDATIONS_VERSION: string = PACKAGE_VERSION;\nexport { Account, AccountNotConfiguredError } from \"./account\";\nexport type { Customer, SignInOptions } from \"./account\";\nexport { Cart, Totals } from \"./cart\";\nexport type { TotalsState } from \"./cart\";\nexport { Address } from \"./fulfilment/address-picker\";\nexport type {\n AddressState,\n AddressSuggestion,\n} from \"./fulfilment/address-picker\";\nexport { Branch } from \"./fulfilment/branch-picker\";\nexport { Schedule, scheduleSlots } from \"./fulfilment/schedule\";\nexport type { ScheduleSlot, ScheduleState } from \"./fulfilment/schedule\";\nexport { Fulfilment } from \"./fulfilment/switch\";\nexport type { PartProps } from \"./internal/slot\";\nexport { useControllableState } from \"./internal/use-controllable-state\";\nexport * from \"./item-form\";\nexport { Image } from \"./media/image\";\nexport type { ImageProps } from \"./media/image\";\nexport { Money } from \"./money\";\nexport { Otp } from \"./otp/input\";\nexport { Overlay, useOverlay } from \"./overlay/react\";\nexport { PaymentMethods } from \"./payment/methods\";\nexport type { PaymentMethod } from \"./payment/methods\";\nexport { createSearchIndex, Search } from \"./search\";\nexport type { SearchResult, SearchSource, SearchState } from \"./search\";\nexport {\n formatOpeningHours,\n formatWallClock,\n getOpenStatus,\n parseWallClock,\n} from \"./status/hours\";\nexport { OpenStatus } from \"./status/open-status\";\n"],
|
|
5
|
-
"mappings": ";;;AACA,SAAS,uBAAuB;AAIhC,SAAS,SAAS,iCAAiC;AAEnD,SAAS,MAAM,cAAc;AAE7B,SAAS,eAAe;AAKxB,SAAS,cAAc;AACvB,SAAS,UAAU,qBAAqB;AAExC,SAAS,kBAAkB;AAE3B,SAAS,4BAA4B;AACrC,cAAc;AACd,SAAS,aAAa;AAEtB,SAAS,aAAa;AACtB,SAAS,WAAW;AACpB,SAAS,SAAS,kBAAkB;AACpC,SAAS,sBAAsB;AAE/B,SAAS,mBAAmB,cAAc;AAE1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;
|
|
4
|
+
"sourcesContent": ["\"use client\";\nimport { PACKAGE_VERSION } from \"./version\";\n\n/** The installed @zappie/foundations version. */\nexport const FOUNDATIONS_VERSION: string = PACKAGE_VERSION;\nexport { Account, AccountNotConfiguredError } from \"./account\";\nexport type { Customer, SignInOptions } from \"./account\";\nexport { BranchMap } from \"./branch-map\";\nexport type { BranchMapProps } from \"./branch-map\";\nexport { Cart, Totals } from \"./cart\";\nexport type { TotalsState } from \"./cart\";\nexport { Address } from \"./fulfilment/address-picker\";\nexport type {\n AddressState,\n AddressSuggestion,\n} from \"./fulfilment/address-picker\";\nexport { Branch } from \"./fulfilment/branch-picker\";\nexport { Schedule, scheduleSlots } from \"./fulfilment/schedule\";\nexport type { ScheduleSlot, ScheduleState } from \"./fulfilment/schedule\";\nexport { Fulfilment } from \"./fulfilment/switch\";\nexport type { PartProps } from \"./internal/slot\";\nexport { useControllableState } from \"./internal/use-controllable-state\";\nexport * from \"./item-form\";\nexport { Image } from \"./media/image\";\nexport type { ImageProps } from \"./media/image\";\nexport { Money } from \"./money\";\nexport { Otp } from \"./otp/input\";\nexport { Overlay, useOverlay } from \"./overlay/react\";\nexport { PaymentMethods } from \"./payment/methods\";\nexport type { PaymentMethod } from \"./payment/methods\";\nexport { createSearchIndex, Search } from \"./search\";\nexport type { SearchResult, SearchSource, SearchState } from \"./search\";\nexport {\n formatOpeningHours,\n formatWallClock,\n getOpenStatus,\n parseWallClock,\n} from \"./status/hours\";\nexport { OpenStatus } from \"./status/open-status\";\n"],
|
|
5
|
+
"mappings": ";;;AACA,SAAS,uBAAuB;AAIhC,SAAS,SAAS,iCAAiC;AAEnD,SAAS,iBAAiB;AAE1B,SAAS,MAAM,cAAc;AAE7B,SAAS,eAAe;AAKxB,SAAS,cAAc;AACvB,SAAS,UAAU,qBAAqB;AAExC,SAAS,kBAAkB;AAE3B,SAAS,4BAA4B;AACrC,cAAc;AACd,SAAS,aAAa;AAEtB,SAAS,aAAa;AACtB,SAAS,WAAW;AACpB,SAAS,SAAS,kBAAkB;AACpC,SAAS,sBAAsB;AAE/B,SAAS,mBAAmB,cAAc;AAE1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAlCpB,IAAM,sBAA8B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zappie/foundations",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "UI-less React primitives for Zappie storefronts: behaviour, state and accessibility without styles.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@base-ui/react": "^1.8.0",
|
|
35
|
-
"@zappie/sdk": "^0.1.
|
|
35
|
+
"@zappie/sdk": "^0.1.7"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"react": "^18.2.0 || ^19.0.0",
|