@drawbridge/components 0.1.46 → 0.1.48
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/bridge/cart-drawer.js +152 -0
- package/dist/bridge/cart-drawer.mjs +123 -0
- package/dist/bridge/fields.js +278 -0
- package/dist/bridge/fields.mjs +276 -1
- package/dist/bridge/form-subdomain-checkout.js +687 -0
- package/dist/bridge/form-subdomain-checkout.mjs +665 -0
- package/dist/bridge/form-subdomain-shop-modal.js +234 -274
- package/dist/bridge/form-subdomain-shop-modal.mjs +233 -275
- package/dist/bridge/form-subdomain-shop.js +4 -1
- package/dist/bridge/form-subdomain-shop.mjs +4 -1
- package/dist/bridge/form-subdomain.js +24 -5
- package/dist/bridge/form-subdomain.mjs +25 -6
- package/dist/bridge/lib/age-gate.js +12 -0
- package/dist/bridge/lib/age-gate.mjs +11 -0
- package/dist/bridge/lib/cart.js +79 -0
- package/dist/bridge/lib/cart.mjs +48 -0
- package/dist/bridge/lib/checkout-kit.js +2 -32
- package/dist/bridge/lib/checkout-kit.mjs +2 -32
- package/dist/bridge/lib/entry.js +41 -0
- package/dist/bridge/lib/entry.mjs +40 -0
- package/dist/bridge/product-tile.js +13 -6
- package/dist/bridge/product-tile.mjs +13 -6
- package/dist/bridge/template-layout.js +263 -129
- package/dist/bridge/template-layout.mjs +264 -130
- package/dist/bridge/template-modal.js +39 -74
- package/dist/bridge/template-modal.mjs +40 -75
- package/dist/dashboard/avatar.js +2 -3
- package/dist/dashboard/avatar.mjs +2 -3
- package/dist/dashboard/buttons-subscription.js +1 -1
- package/dist/dashboard/buttons-subscription.mjs +1 -1
- package/dist/dashboard/campaign-form.js +179 -155
- package/dist/dashboard/campaign-form.mjs +179 -155
- package/dist/dashboard/campaign-share.js +347 -0
- package/dist/dashboard/campaign-share.mjs +314 -0
- package/dist/dashboard/card-affiliate.js +1 -1
- package/dist/dashboard/card-affiliate.mjs +1 -1
- package/dist/dashboard/card-campaign-switch.js +4 -1
- package/dist/dashboard/card-campaign-switch.mjs +4 -1
- package/dist/dashboard/card-order.js +22 -4
- package/dist/dashboard/card-order.mjs +22 -4
- package/dist/dashboard/embed-stripe.js +145 -0
- package/dist/dashboard/embed-stripe.mjs +116 -0
- package/dist/dashboard/form-admin-provider.js +71 -17
- package/dist/dashboard/form-admin-provider.mjs +71 -17
- package/dist/dashboard/form-file-upload.js +3 -2
- package/dist/dashboard/form-file-upload.mjs +4 -3
- package/dist/dashboard/form-organization-campaign-advertisements.js +47 -6
- package/dist/dashboard/form-organization-campaign-advertisements.mjs +47 -6
- package/dist/dashboard/form-organization-campaign-field-birthday.js +193 -0
- package/dist/dashboard/form-organization-campaign-field-birthday.mjs +164 -0
- package/dist/dashboard/form-organization-campaign-field-rating.js +246 -0
- package/dist/dashboard/form-organization-campaign-field-rating.mjs +217 -0
- package/dist/dashboard/form-organization-campaign-page.js +73 -39
- package/dist/dashboard/form-organization-campaign-page.mjs +73 -39
- package/dist/dashboard/form-organization-campaign.js +82 -0
- package/dist/dashboard/form-organization-campaign.mjs +81 -0
- package/dist/dashboard/form-organization-connection.js +48 -6
- package/dist/dashboard/form-organization-connection.mjs +48 -7
- package/dist/dashboard/form-organization-product.js +1461 -0
- package/dist/dashboard/form-organization-product.mjs +1425 -0
- package/dist/dashboard/form-organization-workflow.js +72 -1
- package/dist/dashboard/form-organization-workflow.mjs +69 -1
- package/dist/dashboard/form-otc.js +4 -5
- package/dist/dashboard/form-otc.mjs +4 -5
- package/dist/dashboard/form-stripe.js +12 -5
- package/dist/dashboard/form-stripe.mjs +12 -5
- package/dist/dashboard/input-combobox.js +6 -0
- package/dist/dashboard/input-combobox.mjs +6 -0
- package/dist/dashboard/input-fields.js +37 -161
- package/dist/dashboard/input-fields.mjs +37 -161
- package/dist/dashboard/input-file.js +21 -4
- package/dist/dashboard/input-file.mjs +21 -4
- package/dist/dashboard/input-font.js +2 -0
- package/dist/dashboard/input-font.mjs +2 -0
- package/dist/dashboard/input-gallery.js +201 -0
- package/dist/dashboard/input-gallery.mjs +172 -0
- package/dist/dashboard/input-group-ai.js +15 -3
- package/dist/dashboard/input-group-ai.mjs +15 -3
- package/dist/dashboard/lib/ab-tests.js +2 -2
- package/dist/dashboard/lib/ab-tests.mjs +2 -2
- package/dist/dashboard/lib/connection-controls.js +5 -2
- package/dist/dashboard/lib/connection-controls.mjs +3 -1
- package/dist/dashboard/lib/form-page.js +1 -1
- package/dist/dashboard/lib/form-page.mjs +1 -1
- package/dist/dashboard/lib/menu.js +19 -0
- package/dist/dashboard/lib/menu.mjs +18 -0
- package/dist/dashboard/lib/products.js +169 -0
- package/dist/dashboard/lib/products.mjs +135 -0
- package/dist/dashboard/lib/settings-paths.js +35 -0
- package/dist/dashboard/lib/settings-paths.mjs +11 -0
- package/dist/dashboard/lib/uppy.js +10 -1
- package/dist/dashboard/lib/uppy.mjs +11 -2
- package/dist/dashboard/menu.js +13 -2
- package/dist/dashboard/menu.mjs +13 -2
- package/dist/dashboard/order-sections.js +456 -6
- package/dist/dashboard/order-sections.mjs +453 -7
- package/dist/dashboard/preview.js +119 -52
- package/dist/dashboard/preview.mjs +119 -52
- package/dist/dashboard/provider-ui.js +9 -7
- package/dist/dashboard/provider-ui.mjs +9 -7
- package/dist/dashboard/recharts.js +10 -4
- package/dist/dashboard/recharts.mjs +10 -4
- package/dist/dashboard/shipping-rates.js +404 -0
- package/dist/dashboard/shipping-rates.mjs +371 -0
- package/dist/dashboard/template-buyer.js +301 -0
- package/dist/dashboard/template-buyer.mjs +267 -0
- package/dist/dashboard/template-dashboard.js +11 -1
- package/dist/dashboard/template-dashboard.mjs +11 -1
- package/dist/dashboard/template-design.js +209 -130
- package/dist/dashboard/template-design.mjs +210 -131
- package/dist/dashboard/template-ui.js +157 -55
- package/dist/dashboard/template-ui.mjs +158 -56
- package/dist/icons/flags.js +134 -0
- package/dist/icons/flags.mjs +115 -0
- package/dist/input-checkbox.js +28 -10
- package/dist/input-checkbox.mjs +28 -10
- package/dist/product.js +96 -24
- package/dist/product.mjs +97 -25
- package/dist/shared/carousel.js +14 -5
- package/dist/shared/carousel.mjs +14 -5
- package/dist/shared/lib/helpers.js +54 -6
- package/dist/shared/lib/helpers.mjs +53 -8
- package/dist/shared/order-summary.js +139 -0
- package/dist/shared/order-summary.mjs +110 -0
- package/package.json +84 -4
- package/types/bridge/cart-drawer.d.ts +31 -0
- package/types/bridge/fields.d.ts +14 -2
- package/types/bridge/form-subdomain-checkout.d.ts +20 -0
- package/types/bridge/form-subdomain-shop-modal.d.ts +27 -3
- package/types/bridge/form-subdomain.d.ts +13 -0
- package/types/bridge/lib/age-gate.d.ts +5 -0
- package/types/bridge/lib/cart.d.ts +44 -0
- package/types/bridge/lib/checkout-kit.d.ts +2 -10
- package/types/bridge/lib/entry.d.ts +5 -0
- package/types/bridge/product-tile.d.ts +2 -0
- package/types/dashboard/campaign-share.d.ts +16 -0
- package/types/dashboard/card-order.d.ts +6 -0
- package/types/dashboard/embed-stripe.d.ts +25 -0
- package/types/dashboard/form-admin-provider.d.ts +9 -2
- package/types/dashboard/form-file-upload.d.ts +2 -1
- package/types/dashboard/form-organization-campaign-advertisements.d.ts +3 -0
- package/types/dashboard/form-organization-campaign-field-birthday.d.ts +31 -0
- package/types/dashboard/form-organization-campaign-field-rating.d.ts +33 -0
- package/types/dashboard/form-organization-campaign-page.d.ts +8 -1
- package/types/dashboard/form-organization-campaign.d.ts +3 -0
- package/types/dashboard/form-organization-connection.d.ts +11 -0
- package/types/dashboard/form-organization-product.d.ts +24 -0
- package/types/dashboard/form-otc.d.ts +5 -1
- package/types/dashboard/form-stripe.d.ts +3 -2
- package/types/dashboard/input-combobox.d.ts +2 -0
- package/types/dashboard/input-file.d.ts +2 -0
- package/types/dashboard/input-gallery.d.ts +14 -0
- package/types/dashboard/lib/products.d.ts +14 -0
- package/types/dashboard/lib/settings-paths.d.ts +5 -0
- package/types/dashboard/order-sections.d.ts +24 -1
- package/types/dashboard/preview.d.ts +11 -3
- package/types/dashboard/shipping-rates.d.ts +26 -0
- package/types/dashboard/template-buyer.d.ts +50 -0
- package/types/icons/flags.d.ts +5 -0
- package/types/input-checkbox.d.ts +2 -0
- package/types/shared/lib/helpers.d.ts +4 -0
- package/types/shared/order-summary.d.ts +19 -0
|
@@ -0,0 +1,134 @@
|
|
|
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
|
+
var flags_exports = {};
|
|
19
|
+
__export(flags_exports, {
|
|
20
|
+
default: () => flags_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(flags_exports);
|
|
23
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
24
|
+
var import_react = require("react");
|
|
25
|
+
const POLE = "M3 3v1.5M3 21v-6M3 15V4.5";
|
|
26
|
+
const CLOTH = "M3 15l2.77-.693a9 9 0 0 1 6.208.682l.108.054a9 9 0 0 0 6.086.71l3.114-.732a48.524 48.524 0 0 1-.005-10.499l-3.11.732a9 9 0 0 1-6.085-.711l-.108-.054a9 9 0 0 0-6.208-.682L3 4.5Z";
|
|
27
|
+
const SCALE = 0.78;
|
|
28
|
+
const BACK = "translate(5.3 -1.2) scale(" + SCALE + ")";
|
|
29
|
+
const FRONT = "translate(-0.6 5.2) scale(" + SCALE + ")";
|
|
30
|
+
const Flags = (props) => {
|
|
31
|
+
const mask = (0, import_react.useId)();
|
|
32
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
33
|
+
"svg",
|
|
34
|
+
{
|
|
35
|
+
...{
|
|
36
|
+
fill: "none",
|
|
37
|
+
stroke: "currentColor",
|
|
38
|
+
viewBox: "0 0 24 24",
|
|
39
|
+
...props
|
|
40
|
+
},
|
|
41
|
+
children: [
|
|
42
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
43
|
+
"mask",
|
|
44
|
+
{
|
|
45
|
+
...{
|
|
46
|
+
height: 24,
|
|
47
|
+
id: mask,
|
|
48
|
+
maskUnits: "userSpaceOnUse",
|
|
49
|
+
width: 24,
|
|
50
|
+
x: 0,
|
|
51
|
+
y: 0
|
|
52
|
+
},
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
55
|
+
"rect",
|
|
56
|
+
{
|
|
57
|
+
...{
|
|
58
|
+
fill: "white",
|
|
59
|
+
height: 24,
|
|
60
|
+
width: 24
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
),
|
|
64
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
65
|
+
"g",
|
|
66
|
+
{
|
|
67
|
+
...{
|
|
68
|
+
stroke: "black",
|
|
69
|
+
strokeLinecap: "round",
|
|
70
|
+
strokeLinejoin: "round",
|
|
71
|
+
strokeWidth: 4.5 / SCALE,
|
|
72
|
+
transform: FRONT
|
|
73
|
+
},
|
|
74
|
+
children: [
|
|
75
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
76
|
+
"path",
|
|
77
|
+
{
|
|
78
|
+
...{
|
|
79
|
+
d: CLOTH,
|
|
80
|
+
fill: "black"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
),
|
|
84
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
85
|
+
"path",
|
|
86
|
+
{
|
|
87
|
+
...{
|
|
88
|
+
d: POLE
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
)
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
) }),
|
|
98
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
99
|
+
"g",
|
|
100
|
+
{
|
|
101
|
+
...{
|
|
102
|
+
mask: "url(#" + mask + ")"
|
|
103
|
+
},
|
|
104
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
105
|
+
"path",
|
|
106
|
+
{
|
|
107
|
+
...{
|
|
108
|
+
d: POLE + CLOTH,
|
|
109
|
+
strokeLinecap: "round",
|
|
110
|
+
strokeLinejoin: "round",
|
|
111
|
+
strokeWidth: 1.5 / SCALE,
|
|
112
|
+
transform: BACK
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
119
|
+
"path",
|
|
120
|
+
{
|
|
121
|
+
...{
|
|
122
|
+
d: POLE + CLOTH,
|
|
123
|
+
strokeLinecap: "round",
|
|
124
|
+
strokeLinejoin: "round",
|
|
125
|
+
strokeWidth: 1.5 / SCALE,
|
|
126
|
+
transform: FRONT
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
var flags_default = Flags;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
const POLE = "M3 3v1.5M3 21v-6M3 15V4.5";
|
|
4
|
+
const CLOTH = "M3 15l2.77-.693a9 9 0 0 1 6.208.682l.108.054a9 9 0 0 0 6.086.71l3.114-.732a48.524 48.524 0 0 1-.005-10.499l-3.11.732a9 9 0 0 1-6.085-.711l-.108-.054a9 9 0 0 0-6.208-.682L3 4.5Z";
|
|
5
|
+
const SCALE = 0.78;
|
|
6
|
+
const BACK = "translate(5.3 -1.2) scale(" + SCALE + ")";
|
|
7
|
+
const FRONT = "translate(-0.6 5.2) scale(" + SCALE + ")";
|
|
8
|
+
const Flags = (props) => {
|
|
9
|
+
const mask = useId();
|
|
10
|
+
return /* @__PURE__ */ jsxs(
|
|
11
|
+
"svg",
|
|
12
|
+
{
|
|
13
|
+
...{
|
|
14
|
+
fill: "none",
|
|
15
|
+
stroke: "currentColor",
|
|
16
|
+
viewBox: "0 0 24 24",
|
|
17
|
+
...props
|
|
18
|
+
},
|
|
19
|
+
children: [
|
|
20
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs(
|
|
21
|
+
"mask",
|
|
22
|
+
{
|
|
23
|
+
...{
|
|
24
|
+
height: 24,
|
|
25
|
+
id: mask,
|
|
26
|
+
maskUnits: "userSpaceOnUse",
|
|
27
|
+
width: 24,
|
|
28
|
+
x: 0,
|
|
29
|
+
y: 0
|
|
30
|
+
},
|
|
31
|
+
children: [
|
|
32
|
+
/* @__PURE__ */ jsx(
|
|
33
|
+
"rect",
|
|
34
|
+
{
|
|
35
|
+
...{
|
|
36
|
+
fill: "white",
|
|
37
|
+
height: 24,
|
|
38
|
+
width: 24
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
),
|
|
42
|
+
/* @__PURE__ */ jsxs(
|
|
43
|
+
"g",
|
|
44
|
+
{
|
|
45
|
+
...{
|
|
46
|
+
stroke: "black",
|
|
47
|
+
strokeLinecap: "round",
|
|
48
|
+
strokeLinejoin: "round",
|
|
49
|
+
strokeWidth: 4.5 / SCALE,
|
|
50
|
+
transform: FRONT
|
|
51
|
+
},
|
|
52
|
+
children: [
|
|
53
|
+
/* @__PURE__ */ jsx(
|
|
54
|
+
"path",
|
|
55
|
+
{
|
|
56
|
+
...{
|
|
57
|
+
d: CLOTH,
|
|
58
|
+
fill: "black"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
),
|
|
62
|
+
/* @__PURE__ */ jsx(
|
|
63
|
+
"path",
|
|
64
|
+
{
|
|
65
|
+
...{
|
|
66
|
+
d: POLE
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
) }),
|
|
76
|
+
/* @__PURE__ */ jsx(
|
|
77
|
+
"g",
|
|
78
|
+
{
|
|
79
|
+
...{
|
|
80
|
+
mask: "url(#" + mask + ")"
|
|
81
|
+
},
|
|
82
|
+
children: /* @__PURE__ */ jsx(
|
|
83
|
+
"path",
|
|
84
|
+
{
|
|
85
|
+
...{
|
|
86
|
+
d: POLE + CLOTH,
|
|
87
|
+
strokeLinecap: "round",
|
|
88
|
+
strokeLinejoin: "round",
|
|
89
|
+
strokeWidth: 1.5 / SCALE,
|
|
90
|
+
transform: BACK
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
),
|
|
96
|
+
/* @__PURE__ */ jsx(
|
|
97
|
+
"path",
|
|
98
|
+
{
|
|
99
|
+
...{
|
|
100
|
+
d: POLE + CLOTH,
|
|
101
|
+
strokeLinecap: "round",
|
|
102
|
+
strokeLinejoin: "round",
|
|
103
|
+
strokeWidth: 1.5 / SCALE,
|
|
104
|
+
transform: FRONT
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
var flags_default = Flags;
|
|
113
|
+
export {
|
|
114
|
+
flags_default as default
|
|
115
|
+
};
|
package/dist/input-checkbox.js
CHANGED
|
@@ -41,6 +41,9 @@ const InputCheckbox = ({
|
|
|
41
41
|
label,
|
|
42
42
|
labelId,
|
|
43
43
|
onChange,
|
|
44
|
+
// @story fields/multiple-choice
|
|
45
|
+
// A round button for one choice among several: role radio, a dot for its tick.
|
|
46
|
+
round = false,
|
|
44
47
|
style,
|
|
45
48
|
value,
|
|
46
49
|
...rest
|
|
@@ -69,25 +72,40 @@ const InputCheckbox = ({
|
|
|
69
72
|
id: boxId,
|
|
70
73
|
inline: true,
|
|
71
74
|
onClick: () => onChange(value ? false : true),
|
|
72
|
-
role: "checkbox",
|
|
75
|
+
role: round ? "radio" : "checkbox",
|
|
73
76
|
variant: "link",
|
|
74
77
|
...rest
|
|
75
78
|
},
|
|
76
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.
|
|
79
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
77
80
|
"span",
|
|
78
81
|
{
|
|
79
82
|
...{
|
|
80
83
|
className: "relative flex items-center justify-center w-5 h-5 rounded-xs text-inherit bg-inherit border border-inherit",
|
|
81
|
-
style:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
{
|
|
86
|
-
...{
|
|
87
|
-
className: "absolute top-0 w-3.5 h-full pointer-events-none"
|
|
84
|
+
style: {
|
|
85
|
+
...(0, import_styles.inputCheckboxStyle)(style),
|
|
86
|
+
...round && {
|
|
87
|
+
borderRadius: "9999px"
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
},
|
|
91
|
+
children: [
|
|
92
|
+
Boolean(value) && round && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
93
|
+
"span",
|
|
94
|
+
{
|
|
95
|
+
...{
|
|
96
|
+
className: "w-2.5 h-2.5 rounded-full bg-current pointer-events-none"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
),
|
|
100
|
+
Boolean(value) && !round && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
101
|
+
import_check.default,
|
|
102
|
+
{
|
|
103
|
+
...{
|
|
104
|
+
className: "absolute top-0 w-3.5 h-full pointer-events-none"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
]
|
|
91
109
|
}
|
|
92
110
|
)
|
|
93
111
|
}
|
package/dist/input-checkbox.mjs
CHANGED
|
@@ -9,6 +9,9 @@ const InputCheckbox = ({
|
|
|
9
9
|
label,
|
|
10
10
|
labelId,
|
|
11
11
|
onChange,
|
|
12
|
+
// @story fields/multiple-choice
|
|
13
|
+
// A round button for one choice among several: role radio, a dot for its tick.
|
|
14
|
+
round = false,
|
|
12
15
|
style,
|
|
13
16
|
value,
|
|
14
17
|
...rest
|
|
@@ -37,25 +40,40 @@ const InputCheckbox = ({
|
|
|
37
40
|
id: boxId,
|
|
38
41
|
inline: true,
|
|
39
42
|
onClick: () => onChange(value ? false : true),
|
|
40
|
-
role: "checkbox",
|
|
43
|
+
role: round ? "radio" : "checkbox",
|
|
41
44
|
variant: "link",
|
|
42
45
|
...rest
|
|
43
46
|
},
|
|
44
|
-
children: /* @__PURE__ */
|
|
47
|
+
children: /* @__PURE__ */ jsxs(
|
|
45
48
|
"span",
|
|
46
49
|
{
|
|
47
50
|
...{
|
|
48
51
|
className: "relative flex items-center justify-center w-5 h-5 rounded-xs text-inherit bg-inherit border border-inherit",
|
|
49
|
-
style:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
{
|
|
54
|
-
...{
|
|
55
|
-
className: "absolute top-0 w-3.5 h-full pointer-events-none"
|
|
52
|
+
style: {
|
|
53
|
+
...inputCheckboxStyle(style),
|
|
54
|
+
...round && {
|
|
55
|
+
borderRadius: "9999px"
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
},
|
|
59
|
+
children: [
|
|
60
|
+
Boolean(value) && round && /* @__PURE__ */ jsx(
|
|
61
|
+
"span",
|
|
62
|
+
{
|
|
63
|
+
...{
|
|
64
|
+
className: "w-2.5 h-2.5 rounded-full bg-current pointer-events-none"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
),
|
|
68
|
+
Boolean(value) && !round && /* @__PURE__ */ jsx(
|
|
69
|
+
Check,
|
|
70
|
+
{
|
|
71
|
+
...{
|
|
72
|
+
className: "absolute top-0 w-3.5 h-full pointer-events-none"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
]
|
|
59
77
|
}
|
|
60
78
|
)
|
|
61
79
|
}
|
package/dist/product.js
CHANGED
|
@@ -35,7 +35,7 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
35
35
|
var import_react = require("react");
|
|
36
36
|
var import_embla_carousel_react = __toESM(require("embla-carousel-react"));
|
|
37
37
|
var import_cdn = require("@drawbridge/drawbridge-utils/cdn");
|
|
38
|
-
var
|
|
38
|
+
var import_helpers = require("./shared/lib/helpers");
|
|
39
39
|
var import_input_group = __toESM(require("./input-group"));
|
|
40
40
|
var import_input_select = __toESM(require("./input-select"));
|
|
41
41
|
var import_wrapper_gradient = __toESM(require("./wrapper-gradient"));
|
|
@@ -90,26 +90,43 @@ const Product = ({
|
|
|
90
90
|
);
|
|
91
91
|
const [activeImage, setActiveImage] = (0, import_react.useState)(0);
|
|
92
92
|
const [emblaRef, emblaApi] = (0, import_embla_carousel_react.default)();
|
|
93
|
-
const
|
|
93
|
+
const chosen = available.find((v) => v.id === variant) || null;
|
|
94
|
+
const selectedVariant = chosen || available[0] || null;
|
|
95
|
+
const [picked, setPicked] = (0, import_react.useState)([]);
|
|
94
96
|
const images = (0, import_react.useMemo)(
|
|
95
97
|
() => {
|
|
98
|
+
var _a2;
|
|
96
99
|
const variants = ((product == null ? void 0 : product.variants) || []).filter((v) => v.availableForSale);
|
|
97
100
|
const result = [];
|
|
98
101
|
const seen = /* @__PURE__ */ new Set();
|
|
99
|
-
|
|
102
|
+
const remote = (url, variant2 = null) => ({
|
|
103
|
+
src: (0, import_cdn.cdnShopify)(url, "400x400", product == null ? void 0 : product.updatedAt) || url,
|
|
104
|
+
thumb: (0, import_cdn.cdnShopify)(url, "100x100", product == null ? void 0 : product.updatedAt) || url,
|
|
105
|
+
url,
|
|
106
|
+
variant: variant2
|
|
107
|
+
});
|
|
108
|
+
for (const item of (product == null ? void 0 : product.images) || []) {
|
|
109
|
+
if ((item == null ? void 0 : item.url) && !seen.has(item.url)) {
|
|
110
|
+
seen.add(item.url);
|
|
111
|
+
result.push(remote(item.url));
|
|
112
|
+
} else if ((_a2 = item == null ? void 0 : item.file) == null ? void 0 : _a2.sizes) {
|
|
113
|
+
const src = (0, import_cdn.cdnSrc)(item.file, "400x400", item.file.updatedAt) || (0, import_cdn.cdnSrc)(item.file, "original", item.file.updatedAt);
|
|
114
|
+
if (src) result.push({
|
|
115
|
+
src,
|
|
116
|
+
thumb: (0, import_cdn.cdnSrc)(item.file, "100x100", item.file.updatedAt) || src,
|
|
117
|
+
url: item.file.id,
|
|
118
|
+
variant: null
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (!result.length && (product == null ? void 0 : product.image)) {
|
|
100
123
|
seen.add(product.image);
|
|
101
|
-
result.push(
|
|
102
|
-
src: product.image,
|
|
103
|
-
variant: null
|
|
104
|
-
});
|
|
124
|
+
result.push(remote(product.image));
|
|
105
125
|
}
|
|
106
126
|
for (const v of variants) {
|
|
107
127
|
if (v.image && !seen.has(v.image)) {
|
|
108
128
|
seen.add(v.image);
|
|
109
|
-
result.push(
|
|
110
|
-
src: v.image,
|
|
111
|
-
variant: v
|
|
112
|
-
});
|
|
129
|
+
result.push(remote(v.image, v));
|
|
113
130
|
}
|
|
114
131
|
}
|
|
115
132
|
return result;
|
|
@@ -134,13 +151,25 @@ const Product = ({
|
|
|
134
151
|
onVariantChange(value);
|
|
135
152
|
const v = available.find((x) => x.id === value);
|
|
136
153
|
if (!(v == null ? void 0 : v.image)) return;
|
|
137
|
-
const idx = images.findIndex((img) => img.
|
|
154
|
+
const idx = images.findIndex((img) => img.url === v.image);
|
|
138
155
|
if (idx >= 0) {
|
|
139
156
|
setActiveImage(idx);
|
|
140
157
|
emblaApi == null ? void 0 : emblaApi.scrollTo(idx);
|
|
141
158
|
}
|
|
142
159
|
;
|
|
143
160
|
};
|
|
161
|
+
const options = ((product == null ? void 0 : product.options) || []).filter(() => available.every((v) => (v.selectedOptions || []).length));
|
|
162
|
+
const values = chosen ? (chosen.selectedOptions || []).map((item) => item == null ? void 0 : item.value) : picked;
|
|
163
|
+
const pickOption = (index, value) => {
|
|
164
|
+
const wanted = options.map((item, key) => key === index ? value : values[key]);
|
|
165
|
+
setPicked(wanted);
|
|
166
|
+
if (wanted.some((item) => !item)) return onVariantChange("");
|
|
167
|
+
const match = available.find((v) => (v.selectedOptions || []).every((item, key) => (item == null ? void 0 : item.value) === wanted[key])) || available.find((v) => {
|
|
168
|
+
var _a2, _b2;
|
|
169
|
+
return ((_b2 = (_a2 = v.selectedOptions) == null ? void 0 : _a2[index]) == null ? void 0 : _b2.value) === value;
|
|
170
|
+
});
|
|
171
|
+
if (match) handleVariant(match.id);
|
|
172
|
+
};
|
|
144
173
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
145
174
|
"div",
|
|
146
175
|
{
|
|
@@ -170,7 +199,7 @@ const Product = ({
|
|
|
170
199
|
classNameScroll: "flex flex-col w-12 h-48 space-y-3",
|
|
171
200
|
color: resolved.background.color.rgb
|
|
172
201
|
},
|
|
173
|
-
children: images.map(({
|
|
202
|
+
children: images.map(({ thumb }, key) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
174
203
|
import_button.default,
|
|
175
204
|
{
|
|
176
205
|
...{
|
|
@@ -199,7 +228,7 @@ const Product = ({
|
|
|
199
228
|
className: "object-cover",
|
|
200
229
|
fill: true,
|
|
201
230
|
sizes: "48px",
|
|
202
|
-
src:
|
|
231
|
+
src: thumb,
|
|
203
232
|
// Always set opacity + transition so switching the active
|
|
204
233
|
// thumbnail animates the fade in both directions.
|
|
205
234
|
style: {
|
|
@@ -260,7 +289,7 @@ const Product = ({
|
|
|
260
289
|
className: "object-cover",
|
|
261
290
|
fill: true,
|
|
262
291
|
sizes: "192px",
|
|
263
|
-
src
|
|
292
|
+
src,
|
|
264
293
|
unoptimized: true
|
|
265
294
|
}
|
|
266
295
|
}
|
|
@@ -292,11 +321,24 @@ const Product = ({
|
|
|
292
321
|
children: product == null ? void 0 : product.title
|
|
293
322
|
}
|
|
294
323
|
),
|
|
295
|
-
!available.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Unavailable" }) : (selectedVariant == null ? void 0 : selectedVariant.price) && /* @__PURE__ */ (0, import_jsx_runtime.
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
324
|
+
!available.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Unavailable" }) : (selectedVariant == null ? void 0 : selectedVariant.price) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
|
|
325
|
+
(0, import_helpers.money)({
|
|
326
|
+
code: selectedVariant.currency,
|
|
327
|
+
value: selectedVariant.price
|
|
328
|
+
}),
|
|
329
|
+
selectedVariant.sale > selectedVariant.price && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
330
|
+
"s",
|
|
331
|
+
{
|
|
332
|
+
...{
|
|
333
|
+
className: "ml-2 opacity-60"
|
|
334
|
+
},
|
|
335
|
+
children: (0, import_helpers.money)({
|
|
336
|
+
code: selectedVariant.currency,
|
|
337
|
+
value: selectedVariant.sale
|
|
338
|
+
})
|
|
339
|
+
}
|
|
340
|
+
)
|
|
341
|
+
] }),
|
|
300
342
|
(product == null ? void 0 : product.description) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
301
343
|
import_wrapper_gradient.default,
|
|
302
344
|
{
|
|
@@ -310,7 +352,37 @@ const Product = ({
|
|
|
310
352
|
]
|
|
311
353
|
}
|
|
312
354
|
),
|
|
313
|
-
available.length >
|
|
355
|
+
options.length > 0 && available.length > 0 && options.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
356
|
+
import_input_group.default,
|
|
357
|
+
{
|
|
358
|
+
...{
|
|
359
|
+
error: index === options.length - 1 ? errors == null ? void 0 : errors.variant : null,
|
|
360
|
+
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
361
|
+
import_input_select.default,
|
|
362
|
+
{
|
|
363
|
+
...{
|
|
364
|
+
"aria-label": option.name,
|
|
365
|
+
disabled,
|
|
366
|
+
onChange: (value) => pickOption(index, value),
|
|
367
|
+
options: option.values.filter((value) => available.some((v) => {
|
|
368
|
+
var _a2, _b2;
|
|
369
|
+
return ((_b2 = (_a2 = v.selectedOptions) == null ? void 0 : _a2[index]) == null ? void 0 : _b2.value) === value;
|
|
370
|
+
})).map((value) => ({
|
|
371
|
+
label: value,
|
|
372
|
+
value
|
|
373
|
+
})),
|
|
374
|
+
style: resolved,
|
|
375
|
+
value: values[index] || ""
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
),
|
|
379
|
+
label: option.name,
|
|
380
|
+
style: resolved
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
"option-" + option.name
|
|
384
|
+
)),
|
|
385
|
+
!options.length && available.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
314
386
|
import_input_group.default,
|
|
315
387
|
{
|
|
316
388
|
...{
|
|
@@ -334,7 +406,7 @@ const Product = ({
|
|
|
334
406
|
}
|
|
335
407
|
}
|
|
336
408
|
),
|
|
337
|
-
|
|
409
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
338
410
|
import_input_group.default,
|
|
339
411
|
{
|
|
340
412
|
...{
|
|
@@ -356,7 +428,7 @@ const Product = ({
|
|
|
356
428
|
import_button.default,
|
|
357
429
|
{
|
|
358
430
|
...{
|
|
359
|
-
disabled: disabled || Boolean(action),
|
|
431
|
+
disabled: disabled || Boolean(action) || !available.length,
|
|
360
432
|
onClick: onAdd,
|
|
361
433
|
variant: "link"
|
|
362
434
|
},
|
|
@@ -386,7 +458,7 @@ const Product = ({
|
|
|
386
458
|
import_button.default,
|
|
387
459
|
{
|
|
388
460
|
...{
|
|
389
|
-
disabled: disabled || Boolean(action),
|
|
461
|
+
disabled: disabled || Boolean(action) || !available.length,
|
|
390
462
|
loading: action === "buy",
|
|
391
463
|
onClick: onBuy,
|
|
392
464
|
style: resolved
|