@colabcommerce/elements 0.0.1 → 0.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colabcommerce/elements",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "license": "UNLICENSED",
5
5
  "type": "module",
6
6
  "exports": {
@@ -19,10 +19,11 @@
19
19
  "scripts": {
20
20
  "build": "vite build",
21
21
  "build:dev": "vite build --mode development",
22
+ "build:debug": "DEBUG=vite:* vite build",
22
23
  "dev:storeLocator": "vite ./playground/StoreLocator -c vite.config.js",
23
24
  "dev:retailer": "vite ./playground/Retailer -c vite.config.js",
24
25
  "dev:cartForm": "vite ./playground/CartForm -c vite.config.js",
25
- "dev:productForm": "vite ./playground/ProductForm -c vite.config.js",
26
+ "dev:productForm": "DEBUG=vite:* vite ./playground/ProductForm -c vite.config.js",
26
27
  "test": "vitest",
27
28
  "e2e": "cypress open"
28
29
  },
package/vite.config.js CHANGED
@@ -2,6 +2,9 @@ import { defineConfig, loadEnv } from "vite";
2
2
  import react from "@vitejs/plugin-react";
3
3
  import tailwindcss from "@tailwindcss/vite"
4
4
  import path from "path";
5
+ import crypto from "crypto";
6
+ import stringHash from "string-hash";
7
+ import css from "./src/lib/css";
5
8
 
6
9
  export default defineConfig(({ command, mode }) => {
7
10
 
@@ -1,153 +0,0 @@
1
- import { jsx as s, jsxs as v } from "react/jsx-runtime";
2
- import { createContext as z, useState as d } from "react";
3
- import { h as R, u as Q, d as $, S as V, l as K, b as W, k as X, g as J } from "./index-BComOHrk.js";
4
- import { d as U, a as Y, O as H, c as g, B as ee } from "./globals-D3YPIcjZ.js";
5
- /**
6
- * @license lucide-react v0.542.0 - ISC
7
- *
8
- * This source code is licensed under the ISC license.
9
- * See the LICENSE file in the root directory of this source tree.
10
- */
11
- const te = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]], se = U("check", te);
12
- /**
13
- * @license lucide-react v0.542.0 - ISC
14
- *
15
- * This source code is licensed under the ISC license.
16
- * See the LICENSE file in the root directory of this source tree.
17
- */
18
- const ne = [
19
- ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
20
- ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
21
- ], j = U("x", ne), oe = z(), ke = ({ product: e, children: n }) => {
22
- const [o, i] = d(0), m = {
23
- currentStep: o,
24
- setCurrentStep: i,
25
- product: e
26
- };
27
- return /* @__PURE__ */ s(oe.Provider, { value: m, children: n });
28
- }, ae = z(), we = ({ children: e }) => {
29
- const [n, o] = d(null), [i, m] = d(null), [p, c] = d(null), [_, f] = d(null), [L, S] = d(null), [b, N] = d(null), [h, l] = d(""), [k, a] = d(!1), [r, w] = d(!1), { coords: D, isGeolocationAvailable: x, isGeolocationEnabled: B, getPosition: I } = R({ suppressLocationOnMount: !0, onError: () => w(!1), onSuccess: () => w(!1), positionOptions: { enableHighAccuracy: !1 }, userDecisionTimeout: 5e3 }), F = {
30
- lat: n,
31
- lng: i,
32
- isLoading: k,
33
- setIsLoading: a,
34
- locationName: h,
35
- setLocationName: l,
36
- setLocation: ({ lat: y, lng: C }) => {
37
- o(y), m(C);
38
- },
39
- mapCenter: { lat: p, lng: _ },
40
- setMapCenter: ({ lat: y, lng: C }) => {
41
- c(y), f(C);
42
- },
43
- searchCenter: { lat: L, lng: b },
44
- setSearchCenter: ({ lat: y, lng: C }) => {
45
- S(y), N(C);
46
- },
47
- loadingGeo: r,
48
- geoCoords: D,
49
- isGeolocationAvailable: x,
50
- isGeolocationEnabled: B,
51
- getPosition: I
52
- };
53
- return /* @__PURE__ */ s(ae.Provider, { value: F, children: e });
54
- }, ce = "oHxQR", re = "ggY6v", ie = "B-vL7", de = "xpYRZ", le = "PD0AO", ue = "i1mIs", me = "TOu1q", pe = "BYI6o", he = "_8Athb", ge = "wpcV2", t = {
55
- header: ce,
56
- name: re,
57
- address: ie,
58
- distance: de,
59
- selectBtn: le,
60
- productList: ue,
61
- productHeader: me,
62
- productItem: pe,
63
- inStock: he,
64
- outOfStock: ge
65
- }, be = ({ location: e, showProducts: n = !1 }) => {
66
- var T, A, P;
67
- const { t: o, i18n: i } = Y(), m = i.language, p = K(m), { products: c, searchCenter: _, setSelectedLocationId: f, selectedLocationId: L, setFocusedLocationId: S, setShowMap: b, setShowDetails: N } = Q(), h = $({ lat: (T = e == null ? void 0 : e.address) == null ? void 0 : T.latitude, lng: (A = e.address) == null ? void 0 : A.longitude }, _), l = p === "km" ? h : X(h), k = Math.round(l * 10) / 10, a = e.retailer_location_hours.find((u) => u.day === (/* @__PURE__ */ new Date()).getDay()), r = /* @__PURE__ */ new Date();
68
- let w = /* @__PURE__ */ new Date();
69
- a && (w = new H(r.getUTCFullYear(), r.getMonth(), r.getDate(), a.open_at_hour, a.open_at_minute, 0, 0, a.timezone));
70
- let D = /* @__PURE__ */ new Date();
71
- a && (D = new H(r.getUTCFullYear(), r.getMonth(), r.getDate(), a.close_at_hour, a.close_at_minute, 0, 0, a.timezone));
72
- const x = a && r >= w && r <= D, B = a && !x && r - w > 30 * 6e4 * -1, I = a && x && D - r < 30 * 6e4;
73
- x ? I ? (g(t.hours, t.soon), o("store.closingSoon")) : (g(t.hours, t.open), o("store.openNow")) : B ? (g(t.hours, t.soon), o("store.openingSoon")) : (g(t.hours, t.closed), o("store.closedNow"));
74
- const F = () => {
75
- f(e.id);
76
- }, y = () => {
77
- S(e.id);
78
- }, C = e.id === L ? g(t.wrapper, t.selected) : g(t.wrapper), q = (P = e == null ? void 0 : e.store_type) != null && P.includes("Studio") ? "studio" : "retailer", E = c == null ? void 0 : c.map((u) => {
79
- var G;
80
- const Z = (G = e == null ? void 0 : e.retailer_location_products) == null ? void 0 : G.some((M) => (M.sku === u.sku || M.external_id === u.external_id || M.collection_id === u.collection_id) && M.stocked);
81
- return { ...u, isStocked: Z };
82
- });
83
- return /* @__PURE__ */ v("div", { className: C, onClick: y, children: [
84
- /* @__PURE__ */ v("div", { className: t.header, children: [
85
- /* @__PURE__ */ s("h4", { className: t.name, children: e.retailer_name }),
86
- /* @__PURE__ */ s("div", { className: "text-end", children: /* @__PURE__ */ s(V, { type: q }) })
87
- ] }),
88
- /* @__PURE__ */ v("div", { className: g(t.distance), children: [
89
- k,
90
- " ",
91
- p,
92
- " ",
93
- o("away")
94
- ] }),
95
- /* @__PURE__ */ s("section", { className: `${t.hoursWrapper} d-flex justify-content-between align-items-center pe-3`, children: /* @__PURE__ */ s(W, { hours: e == null ? void 0 : e.retailer_location_hours }) }),
96
- /* @__PURE__ */ s("address", { className: g(t.address), children: /* @__PURE__ */ v("div", { children: [
97
- e.address.street_line_one,
98
- e.address.street_line_two && `, ${e.address.street_line_two}`,
99
- " ",
100
- e.address.city,
101
- ", ",
102
- e.address.province,
103
- " ",
104
- e.address.postal_code
105
- ] }) }),
106
- (c == null ? void 0 : c.length) > 0 && n && /* @__PURE__ */ v("div", { children: [
107
- /* @__PURE__ */ s("div", { className: t.productHeader, children: o("quote.location.product_availability") }),
108
- /* @__PURE__ */ s("div", { className: t.productList, children: E.map((u) => /* @__PURE__ */ v("div", { className: t.productItem, children: [
109
- /* @__PURE__ */ s("div", { className: t.productStatus, children: u.isStocked ? /* @__PURE__ */ s(se, { className: t.inStock, size: 20 }) : /* @__PURE__ */ s(j, { className: t.outOfStock, size: 20 }) }),
110
- /* @__PURE__ */ s("div", { className: t.productName, children: u.name })
111
- ] }, u.name)) })
112
- ] }),
113
- /* @__PURE__ */ s(ee, { variant: "dark", size: "sm", onClick: F, className: `d-flex align-items-center px-3 py-2 ${t.selectBtn}`, children: o("quote.location.select_location") })
114
- ] });
115
- }, _e = "QMwKB", fe = "tlZ-O", Le = "NQEG7", Se = "MGV0F", O = {
116
- wrapper: _e,
117
- message: fe,
118
- dismiss: Le,
119
- cta: Se
120
- }, De = ({ onSelect: e, onDismiss: n }) => {
121
- const { t: o } = Y(), { locations: i, searchCenter: m, setSelectedLocationId: p, isLoading: c } = Q(), { cc_company_retailer_location_id: _ } = J(), [f, L] = d(!1), S = i.length > 0 ? Math.min(...i.map((l) => $({ lat: l.address.latitude, lng: l.address.longitude }, m))) : null, b = !f && (i.length === 0 || S > 100) && !c, N = () => {
122
- p(_);
123
- }, h = () => {
124
- L(!0), n && n();
125
- };
126
- return b ? /* @__PURE__ */ v("div", { className: O.wrapper, children: [
127
- /* @__PURE__ */ s("button", { className: O.dismiss, onClick: h, children: /* @__PURE__ */ s(j, { size: 20 }) }),
128
- /* @__PURE__ */ s("p", { className: O.message, children: o("form_out_of_area.message") }),
129
- /* @__PURE__ */ s("button", { className: O.cta, onClick: N, children: o("form_out_of_area.cta") })
130
- ] }) : null;
131
- };
132
- function xe(e) {
133
- var h;
134
- const n = (l) => {
135
- var k;
136
- return ((k = e.find((a) => a.types.includes(l))) == null ? void 0 : k.long_name) || "";
137
- }, o = n("street_number"), i = n("route"), m = [o, i].filter(Boolean).join(" "), p = n("subpremise"), c = p ? `Unit ${p}` : "", _ = n("locality") || n("postal_town") || n("sublocality") || "", f = n("administrative_area_level_1"), L = n("postal_code"), S = n("country"), N = ((h = e.find((l) => l.types.includes("country"))) == null ? void 0 : h.short_name) || S;
138
- return {
139
- addressLine1: m,
140
- addressLine2: c,
141
- city: _,
142
- province: f,
143
- postalCode: L,
144
- country: N
145
- };
146
- }
147
- export {
148
- De as F,
149
- be as L,
150
- ke as Q,
151
- xe as a,
152
- we as b
153
- };