@drawbridge/components 0.0.45 → 0.0.46

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,377 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // components/card-advertisement.js
20
- var card_advertisement_exports = {};
21
- __export(card_advertisement_exports, {
22
- default: () => card_advertisement_default
23
- });
24
- module.exports = __toCommonJS(card_advertisement_exports);
25
- var import_react = require("react");
26
- var import_cdn = require("@drawbridge/shopify/cdn");
27
- var import_cdn2 = require("@drawbridge/drawbridge-utils/cdn");
28
- var import_drawbridge_utils = require("@drawbridge/drawbridge-utils");
29
- var import_jsx_runtime = require("react/jsx-runtime");
30
- var DefaultImage = ({ alt, className, src }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
31
- "img",
32
- {
33
- ...{
34
- alt,
35
- className,
36
- src
37
- }
38
- }
39
- );
40
- var DefaultVideo = ({ className, hls, mp4, poster }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
41
- "video",
42
- {
43
- ...{
44
- className,
45
- poster,
46
- src: mp4 || hls
47
- }
48
- }
49
- );
50
- var CardAdvertisement = ({
51
- advertisement,
52
- affiliate,
53
- asset,
54
- brand = {},
55
- button,
56
- campaign,
57
- fonts,
58
- ImageComponent = DefaultImage,
59
- lead,
60
- onClick = () => {
61
- },
62
- onVariantSelect = () => {
63
- },
64
- organization,
65
- page,
66
- preview = false,
67
- product,
68
- title,
69
- url,
70
- VideoComponent = DefaultVideo
71
- }) => {
72
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N;
73
- const variants = ((product == null ? void 0 : product.variants) || []).filter((v) => v.availableForSale);
74
- const hasVariants = variants.length > 0;
75
- const [selectedVariant, setSelectedVariant] = (0, import_react.useState)(variants[0] || null);
76
- const [keyboard, setKeyboard] = (0, import_react.useState)(false);
77
- (0, import_react.useEffect)(() => {
78
- const down = (e) => {
79
- if (e.key === "Tab") setKeyboard(true);
80
- };
81
- const click = () => setKeyboard(false);
82
- window.addEventListener("keydown", down);
83
- window.addEventListener("mousedown", click);
84
- return () => {
85
- window.removeEventListener("keydown", down);
86
- window.removeEventListener("mousedown", click);
87
- };
88
- }, []);
89
- const style = {
90
- background: {
91
- color: ((_a = brand == null ? void 0 : brand.style) == null ? void 0 : _a.background) ? (_b = brand.style.background) == null ? void 0 : _b.color : {
92
- hex: "#FFFFFF",
93
- rgb: "rgb( 255, 255, 255 )"
94
- }
95
- },
96
- text: {
97
- color: ((_c = brand == null ? void 0 : brand.style) == null ? void 0 : _c.text) ? (_d = brand.style.text) == null ? void 0 : _d.color : {
98
- hex: "#000000",
99
- rgb: "rgb( 0, 0, 0 )"
100
- }
101
- }
102
- };
103
- const classes = {
104
- asset: [
105
- "block relative aspect-square rounded overflow-hidden"
106
- ],
107
- button: [
108
- "card-advertisement-button",
109
- "flex items-center justify-center py-3 px-4 w-full border"
110
- ],
111
- container: [
112
- "card-advertisement",
113
- "block w-full space-y-2 border border-gray rounded p-6"
114
- ],
115
- content: [
116
- "flex flex-col items-center justify-between gap-x-4 text-center text-sm rounded"
117
- ]
118
- };
119
- const productImage = (selectedVariant == null ? void 0 : selectedVariant.image) || (product == null ? void 0 : product.image) || null;
120
- const productImageSrc = (0, import_cdn.cdnShopify)(productImage, "400x400", product == null ? void 0 : product.updatedAt);
121
- if (!(asset == null ? void 0 : asset.sizes) && !productImageSrc) {
122
- classes.asset.push("bg-gray-light");
123
- }
124
- ;
125
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
126
- "div",
127
- {
128
- ...{
129
- className: classes.container.join(" "),
130
- style: {
131
- backgroundColor: (_f = (_e = style == null ? void 0 : style.background) == null ? void 0 : _e.color) == null ? void 0 : _f.hex,
132
- color: (_h = (_g = style == null ? void 0 : style.text) == null ? void 0 : _g.color) == null ? void 0 : _h.hex
133
- }
134
- },
135
- children: [
136
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
137
- "span",
138
- {
139
- ...{
140
- className: classes.asset.join(" ")
141
- },
142
- children: [
143
- (asset == null ? void 0 : asset.sizes) && asset.mimetype.includes("image") && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
144
- ImageComponent,
145
- {
146
- ...{
147
- alt: asset == null ? void 0 : asset.filename,
148
- className: "w-full h-full object-cover",
149
- fill: true,
150
- priority: false,
151
- sizes: "100%",
152
- src: (0, import_cdn2.cdnSrc)(asset, "400x400", asset == null ? void 0 : asset.updatedAt)
153
- }
154
- },
155
- asset == null ? void 0 : asset.id
156
- ),
157
- !(asset == null ? void 0 : asset.sizes) && productImageSrc && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
158
- ImageComponent,
159
- {
160
- ...{
161
- alt: (product == null ? void 0 : product.title) || "Product",
162
- className: "w-full h-full object-cover",
163
- fill: true,
164
- priority: false,
165
- sizes: "100%",
166
- src: productImageSrc,
167
- unoptimized: true
168
- }
169
- },
170
- productImageSrc
171
- ),
172
- (asset == null ? void 0 : asset.sizes) && asset.mimetype.includes("video") && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
173
- "div",
174
- {
175
- ...{
176
- className: "relative h-full w-full aspect-[9/16]"
177
- },
178
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
179
- VideoComponent,
180
- {
181
- ...{
182
- className: "w-full h-full",
183
- hls: (0, import_cdn2.cdnSrc)(asset, "hls", asset == null ? void 0 : asset.updatedAt),
184
- mp4: (0, import_cdn2.cdnSrc)(asset, "original", asset == null ? void 0 : asset.updatedAt),
185
- poster: (0, import_cdn2.cdnSrc)((_i = asset == null ? void 0 : asset.frames) == null ? void 0 : _i[asset == null ? void 0 : asset.poster], "500x500", asset == null ? void 0 : asset.updatedAt) || (0, import_cdn2.cdnSrc)((_j = asset == null ? void 0 : asset.frames) == null ? void 0 : _j[asset == null ? void 0 : asset.poster], "1080x1920", asset == null ? void 0 : asset.updatedAt)
186
- }
187
- }
188
- )
189
- }
190
- )
191
- ]
192
- }
193
- ),
194
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
195
- "span",
196
- {
197
- ...{
198
- className: classes.content.join(" "),
199
- style: {
200
- ...fonts == null ? void 0 : fonts.body,
201
- color: (_l = (_k = style == null ? void 0 : style.text) == null ? void 0 : _k.color) == null ? void 0 : _l.hex,
202
- gap: "10px",
203
- marginTop: "10px"
204
- }
205
- },
206
- children: [
207
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
208
- "div",
209
- {
210
- ...{
211
- className: "flex-1 min-w-0 space-y-2"
212
- },
213
- children: [
214
- title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
215
- "p",
216
- {
217
- ...{
218
- style: {
219
- fontSize: "18px"
220
- }
221
- },
222
- children: title
223
- }
224
- ),
225
- (selectedVariant == null ? void 0 : selectedVariant.price) && (selectedVariant == null ? void 0 : selectedVariant.currency) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
226
- "p",
227
- {
228
- ...{
229
- style: {
230
- fontSize: "14px",
231
- marginBottom: "10px"
232
- }
233
- },
234
- children: [
235
- (selectedVariant == null ? void 0 : selectedVariant.sale) && selectedVariant.sale > selectedVariant.price && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
236
- "span",
237
- {
238
- ...{
239
- style: {
240
- marginRight: "6px",
241
- opacity: 0.5,
242
- textDecoration: "line-through"
243
- }
244
- },
245
- children: (0, import_drawbridge_utils.formatCurrency)({
246
- code: selectedVariant.currency,
247
- display: "parts",
248
- value: selectedVariant.sale
249
- })
250
- }
251
- ),
252
- (0, import_drawbridge_utils.formatCurrency)({
253
- code: selectedVariant.currency,
254
- display: "parts",
255
- value: selectedVariant.price
256
- })
257
- ]
258
- }
259
- ),
260
- variants.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
261
- "div",
262
- {
263
- ...{
264
- className: "relative w-full"
265
- },
266
- children: [
267
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
268
- "select",
269
- {
270
- ...{
271
- className: "input appearance-none " + (keyboard ? "focus-visible:!outline-1 focus-visible:!ring-1 focus-visible:!ring-blue-600" : "focus-visible:!outline-0 focus-visible:!ring-0"),
272
- onChange: (e) => {
273
- const variant = variants.find((v) => v.id === e.target.value);
274
- if (variant) setSelectedVariant(variant);
275
- },
276
- style: {
277
- appearance: "none",
278
- backgroundColor: (_n = (_m = style == null ? void 0 : style.background) == null ? void 0 : _m.color) == null ? void 0 : _n.rgb,
279
- backgroundImage: "none",
280
- borderColor: (_p = (_o = style == null ? void 0 : style.text) == null ? void 0 : _o.color) == null ? void 0 : _p.rgb,
281
- borderRadius: ((_r = (_q = brand == null ? void 0 : brand.style) == null ? void 0 : _q.button) == null ? void 0 : _r.radius) != null ? brand.style.button.radius / 4 + "px" : void 0,
282
- color: (_t = (_s = style == null ? void 0 : style.text) == null ? void 0 : _s.color) == null ? void 0 : _t.rgb,
283
- WebkitAppearance: "none"
284
- },
285
- value: (selectedVariant == null ? void 0 : selectedVariant.id) || ""
286
- },
287
- children: variants.map((variant) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
288
- "option",
289
- {
290
- ...{
291
- value: variant.id
292
- },
293
- children: variant.title
294
- },
295
- variant.id
296
- ))
297
- }
298
- ),
299
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
300
- "div",
301
- {
302
- ...{
303
- "aria-hidden": true,
304
- style: {
305
- alignItems: "center",
306
- bottom: 0,
307
- display: "flex",
308
- paddingRight: "0.625rem",
309
- pointerEvents: "none",
310
- position: "absolute",
311
- right: 0,
312
- top: 0
313
- }
314
- },
315
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
316
- "svg",
317
- {
318
- ...{
319
- style: {
320
- height: "1.25rem",
321
- width: "1.25rem"
322
- },
323
- fill: "none",
324
- stroke: "currentColor",
325
- strokeWidth: 1.5,
326
- viewBox: "0 0 24 24",
327
- xmlns: "http://www.w3.org/2000/svg"
328
- },
329
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
330
- "path",
331
- {
332
- ...{
333
- d: "M19.5 8.25l-7.5 7.5-7.5-7.5",
334
- strokeLinecap: "round",
335
- strokeLinejoin: "round"
336
- }
337
- }
338
- )
339
- }
340
- )
341
- }
342
- )
343
- ]
344
- }
345
- )
346
- ]
347
- }
348
- ),
349
- button && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
350
- "button",
351
- {
352
- ...{
353
- className: classes.button.join(" "),
354
- disabled: !preview && !hasVariants && !url,
355
- onClick: hasVariants ? () => {
356
- if (!preview) onVariantSelect(selectedVariant);
357
- } : preview ? () => {
358
- } : onClick,
359
- style: {
360
- backgroundColor: ((_x = (_w = (_v = (_u = brand == null ? void 0 : brand.style) == null ? void 0 : _u.button) == null ? void 0 : _v.background) == null ? void 0 : _w.color) == null ? void 0 : _x.hex) || ((_z = (_y = style == null ? void 0 : style.text) == null ? void 0 : _y.color) == null ? void 0 : _z.hex),
361
- borderColor: ((_D = (_C = (_B = (_A = brand == null ? void 0 : brand.style) == null ? void 0 : _A.button) == null ? void 0 : _B.background) == null ? void 0 : _C.color) == null ? void 0 : _D.hex) || ((_F = (_E = style == null ? void 0 : style.text) == null ? void 0 : _E.color) == null ? void 0 : _F.hex),
362
- borderRadius: ((_H = (_G = brand == null ? void 0 : brand.style) == null ? void 0 : _G.button) == null ? void 0 : _H.radius) != null ? brand.style.button.radius / 4 + "px" : void 0,
363
- color: ((_L = (_K = (_J = (_I = brand == null ? void 0 : brand.style) == null ? void 0 : _I.button) == null ? void 0 : _J.text) == null ? void 0 : _K.color) == null ? void 0 : _L.hex) || ((_N = (_M = style == null ? void 0 : style.background) == null ? void 0 : _M.color) == null ? void 0 : _N.hex)
364
- },
365
- type: "button"
366
- },
367
- children: button
368
- }
369
- )
370
- ]
371
- }
372
- )
373
- ]
374
- }
375
- );
376
- };
377
- var card_advertisement_default = CardAdvertisement;
@@ -1,6 +0,0 @@
1
- import {
2
- card_advertisement_default
3
- } from "./chunk-TJNIR4PF.mjs";
4
- export {
5
- card_advertisement_default as default
6
- };
@@ -1,93 +0,0 @@
1
- // components/styles.js
2
- var backgroundStyle = (style) => {
3
- var _a, _b, _c, _d;
4
- return {
5
- backgroundColor: (_b = (_a = style == null ? void 0 : style.background) == null ? void 0 : _a.color) == null ? void 0 : _b.rgb,
6
- color: (_d = (_c = style == null ? void 0 : style.text) == null ? void 0 : _c.color) == null ? void 0 : _d.rgb
7
- };
8
- };
9
- var borderStyle = (style) => {
10
- var _a, _b;
11
- return {
12
- borderColor: (_b = (_a = style == null ? void 0 : style.text) == null ? void 0 : _a.color) == null ? void 0 : _b.rgb
13
- };
14
- };
15
- var buttonStyle = (style) => {
16
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
17
- return {
18
- backgroundColor: ((_c = (_b = (_a = style == null ? void 0 : style.button) == null ? void 0 : _a.background) == null ? void 0 : _b.color) == null ? void 0 : _c.rgb) || ((_e = (_d = style == null ? void 0 : style.text) == null ? void 0 : _d.color) == null ? void 0 : _e.rgb),
19
- borderColor: ((_h = (_g = (_f = style == null ? void 0 : style.button) == null ? void 0 : _f.background) == null ? void 0 : _g.color) == null ? void 0 : _h.rgb) || ((_j = (_i = style == null ? void 0 : style.text) == null ? void 0 : _i.color) == null ? void 0 : _j.rgb),
20
- borderRadius: ((_k = style == null ? void 0 : style.button) == null ? void 0 : _k.radius) != null ? style.button.radius / 4 + "px" : void 0,
21
- color: ((_n = (_m = (_l = style == null ? void 0 : style.button) == null ? void 0 : _l.text) == null ? void 0 : _m.color) == null ? void 0 : _n.rgb) || ((_p = (_o = style == null ? void 0 : style.background) == null ? void 0 : _o.color) == null ? void 0 : _p.rgb)
22
- };
23
- };
24
- var closeStyle = (style) => {
25
- var _a, _b, _c, _d;
26
- return {
27
- backgroundColor: (_b = (_a = style == null ? void 0 : style.text) == null ? void 0 : _a.color) == null ? void 0 : _b.rgb,
28
- color: (_d = (_c = style == null ? void 0 : style.background) == null ? void 0 : _c.color) == null ? void 0 : _d.rgb
29
- };
30
- };
31
- var headerStyle = (style) => {
32
- var _a, _b, _c;
33
- return {
34
- fontFamily: (_a = style == null ? void 0 : style.heading) == null ? void 0 : _a.family,
35
- fontWeight: (_b = style == null ? void 0 : style.heading) == null ? void 0 : _b.weight,
36
- textTransform: (_c = style == null ? void 0 : style.heading) == null ? void 0 : _c.transform
37
- };
38
- };
39
- var inputStyle = (style) => {
40
- var _a, _b, _c, _d, _e, _f, _g;
41
- return {
42
- backgroundColor: (_b = (_a = style == null ? void 0 : style.background) == null ? void 0 : _a.color) == null ? void 0 : _b.rgb,
43
- borderColor: (_d = (_c = style == null ? void 0 : style.text) == null ? void 0 : _c.color) == null ? void 0 : _d.rgb,
44
- borderRadius: ((_e = style == null ? void 0 : style.input) == null ? void 0 : _e.radius) != null ? style.input.radius / 4 + "px" : void 0,
45
- color: (_g = (_f = style == null ? void 0 : style.text) == null ? void 0 : _f.color) == null ? void 0 : _g.rgb
46
- };
47
- };
48
- var inputCheckboxStyle = (style) => {
49
- var _a;
50
- return {
51
- ...inputStyle(style),
52
- borderRadius: ((_a = style == null ? void 0 : style.input) == null ? void 0 : _a.radius) != null ? Math.min(style.input.radius / 4, 6) + "px" : void 0
53
- };
54
- };
55
- var inputNameStyle = (style) => inputStyle(style);
56
- var inputPhoneStyle = (style) => inputStyle(style);
57
- var menuStyle = (style) => {
58
- var _a, _b, _c, _d, _e, _f;
59
- return {
60
- backgroundColor: (_b = (_a = style == null ? void 0 : style.background) == null ? void 0 : _a.color) == null ? void 0 : _b.rgb,
61
- borderColor: (_d = (_c = style == null ? void 0 : style.text) == null ? void 0 : _c.color) == null ? void 0 : _d.rgb,
62
- color: (_f = (_e = style == null ? void 0 : style.text) == null ? void 0 : _e.color) == null ? void 0 : _f.rgb
63
- };
64
- };
65
- var selectStyle = (style) => {
66
- var _a, _b, _c, _d, _e, _f;
67
- return {
68
- borderColor: (_c = (_b = (_a = style == null ? void 0 : style.text) == null ? void 0 : _a.color) == null ? void 0 : _b.rgb) == null ? void 0 : _c.replace(")", ", 0.3)"),
69
- borderRadius: ((_d = style == null ? void 0 : style.input) == null ? void 0 : _d.radius) != null ? style.input.radius / 4 + "px" : void 0,
70
- color: (_f = (_e = style == null ? void 0 : style.text) == null ? void 0 : _e.color) == null ? void 0 : _f.rgb
71
- };
72
- };
73
- var textStyle = (style) => {
74
- var _a, _b;
75
- return {
76
- color: (_b = (_a = style == null ? void 0 : style.text) == null ? void 0 : _a.color) == null ? void 0 : _b.rgb
77
- };
78
- };
79
-
80
- export {
81
- backgroundStyle,
82
- borderStyle,
83
- buttonStyle,
84
- closeStyle,
85
- headerStyle,
86
- inputStyle,
87
- inputCheckboxStyle,
88
- inputNameStyle,
89
- inputPhoneStyle,
90
- menuStyle,
91
- selectStyle,
92
- textStyle
93
- };