@drawbridge/components 0.1.48 → 0.1.49

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.
Files changed (125) hide show
  1. package/dist/bridge/fields.js +0 -278
  2. package/dist/bridge/fields.mjs +1 -276
  3. package/dist/bridge/form-subdomain-shop-modal.js +274 -234
  4. package/dist/bridge/form-subdomain-shop-modal.mjs +275 -233
  5. package/dist/bridge/form-subdomain.js +0 -7
  6. package/dist/bridge/form-subdomain.mjs +2 -9
  7. package/dist/bridge/lib/age-gate.js +0 -12
  8. package/dist/bridge/lib/age-gate.mjs +0 -11
  9. package/dist/bridge/lib/checkout-kit.js +32 -2
  10. package/dist/bridge/lib/checkout-kit.mjs +32 -2
  11. package/dist/bridge/lib/entry.js +0 -3
  12. package/dist/bridge/lib/entry.mjs +0 -2
  13. package/dist/bridge/product-tile.js +6 -9
  14. package/dist/bridge/product-tile.mjs +6 -9
  15. package/dist/bridge/template-layout.js +122 -237
  16. package/dist/bridge/template-layout.mjs +122 -237
  17. package/dist/bridge/template-modal.js +73 -28
  18. package/dist/bridge/template-modal.mjs +74 -29
  19. package/dist/dashboard/buttons-subscription.js +1 -1
  20. package/dist/dashboard/buttons-subscription.mjs +1 -1
  21. package/dist/dashboard/campaign-form.js +2 -7
  22. package/dist/dashboard/campaign-form.mjs +2 -7
  23. package/dist/dashboard/card-order.js +4 -22
  24. package/dist/dashboard/card-order.mjs +4 -22
  25. package/dist/dashboard/document-blocks.js +17 -4
  26. package/dist/dashboard/document-blocks.mjs +17 -4
  27. package/dist/dashboard/form-admin-provider.js +17 -71
  28. package/dist/dashboard/form-admin-provider.mjs +17 -71
  29. package/dist/dashboard/form-file-upload.js +2 -3
  30. package/dist/dashboard/form-file-upload.mjs +3 -4
  31. package/dist/dashboard/form-organization-campaign-advertisements.js +6 -47
  32. package/dist/dashboard/form-organization-campaign-advertisements.mjs +6 -47
  33. package/dist/dashboard/form-organization-campaign-agreement.js +121 -83
  34. package/dist/dashboard/form-organization-campaign-agreement.mjs +121 -83
  35. package/dist/dashboard/form-organization-campaign.js +0 -82
  36. package/dist/dashboard/form-organization-campaign.mjs +0 -81
  37. package/dist/dashboard/form-organization-connection.js +6 -48
  38. package/dist/dashboard/form-organization-connection.mjs +7 -48
  39. package/dist/dashboard/form-organization-workflow.js +1 -72
  40. package/dist/dashboard/form-organization-workflow.mjs +1 -69
  41. package/dist/dashboard/form-otc.js +5 -4
  42. package/dist/dashboard/form-otc.mjs +5 -4
  43. package/dist/dashboard/form-stripe.js +5 -12
  44. package/dist/dashboard/form-stripe.mjs +5 -12
  45. package/dist/dashboard/input-fields.js +158 -11
  46. package/dist/dashboard/input-fields.mjs +158 -11
  47. package/dist/dashboard/input-file.js +4 -21
  48. package/dist/dashboard/input-file.mjs +4 -21
  49. package/dist/dashboard/lib/connection-controls.js +2 -5
  50. package/dist/dashboard/lib/connection-controls.mjs +1 -3
  51. package/dist/dashboard/lib/form-page.js +1 -1
  52. package/dist/dashboard/lib/form-page.mjs +1 -1
  53. package/dist/dashboard/lib/uppy.js +1 -10
  54. package/dist/dashboard/lib/uppy.mjs +2 -11
  55. package/dist/dashboard/order-sections.js +6 -456
  56. package/dist/dashboard/order-sections.mjs +7 -453
  57. package/dist/dashboard/provider-ui.js +7 -9
  58. package/dist/dashboard/provider-ui.mjs +7 -9
  59. package/dist/dashboard/template-ui.js +12 -4
  60. package/dist/dashboard/template-ui.mjs +12 -4
  61. package/dist/input-checkbox.js +10 -28
  62. package/dist/input-checkbox.mjs +10 -28
  63. package/dist/product.js +24 -96
  64. package/dist/product.mjs +25 -97
  65. package/dist/shared/lib/helpers.js +6 -54
  66. package/dist/shared/lib/helpers.mjs +8 -53
  67. package/package.json +4 -74
  68. package/types/bridge/fields.d.ts +2 -14
  69. package/types/bridge/form-subdomain-shop-modal.d.ts +3 -27
  70. package/types/bridge/lib/age-gate.d.ts +0 -5
  71. package/types/bridge/lib/checkout-kit.d.ts +10 -2
  72. package/types/bridge/lib/entry.d.ts +0 -3
  73. package/types/dashboard/card-order.d.ts +0 -6
  74. package/types/dashboard/document-blocks.d.ts +3 -2
  75. package/types/dashboard/form-admin-provider.d.ts +2 -9
  76. package/types/dashboard/form-file-upload.d.ts +1 -2
  77. package/types/dashboard/form-organization-campaign-advertisements.d.ts +0 -3
  78. package/types/dashboard/form-organization-campaign-agreement.d.ts +5 -2
  79. package/types/dashboard/form-organization-campaign.d.ts +0 -3
  80. package/types/dashboard/form-organization-connection.d.ts +0 -11
  81. package/types/dashboard/form-otc.d.ts +1 -5
  82. package/types/dashboard/form-stripe.d.ts +2 -3
  83. package/types/dashboard/input-file.d.ts +0 -2
  84. package/types/dashboard/order-sections.d.ts +1 -24
  85. package/types/input-checkbox.d.ts +0 -2
  86. package/types/shared/lib/helpers.d.ts +0 -4
  87. package/dist/bridge/cart-drawer.js +0 -152
  88. package/dist/bridge/cart-drawer.mjs +0 -123
  89. package/dist/bridge/form-subdomain-checkout.js +0 -687
  90. package/dist/bridge/form-subdomain-checkout.mjs +0 -665
  91. package/dist/bridge/lib/cart.js +0 -79
  92. package/dist/bridge/lib/cart.mjs +0 -48
  93. package/dist/dashboard/embed-stripe.js +0 -145
  94. package/dist/dashboard/embed-stripe.mjs +0 -116
  95. package/dist/dashboard/form-organization-campaign-field-birthday.js +0 -193
  96. package/dist/dashboard/form-organization-campaign-field-birthday.mjs +0 -164
  97. package/dist/dashboard/form-organization-campaign-field-rating.js +0 -246
  98. package/dist/dashboard/form-organization-campaign-field-rating.mjs +0 -217
  99. package/dist/dashboard/form-organization-product.js +0 -1461
  100. package/dist/dashboard/form-organization-product.mjs +0 -1425
  101. package/dist/dashboard/input-gallery.js +0 -201
  102. package/dist/dashboard/input-gallery.mjs +0 -172
  103. package/dist/dashboard/lib/products.js +0 -169
  104. package/dist/dashboard/lib/products.mjs +0 -135
  105. package/dist/dashboard/lib/settings-paths.js +0 -35
  106. package/dist/dashboard/lib/settings-paths.mjs +0 -11
  107. package/dist/dashboard/shipping-rates.js +0 -404
  108. package/dist/dashboard/shipping-rates.mjs +0 -371
  109. package/dist/dashboard/template-buyer.js +0 -301
  110. package/dist/dashboard/template-buyer.mjs +0 -267
  111. package/dist/shared/order-summary.js +0 -139
  112. package/dist/shared/order-summary.mjs +0 -110
  113. package/types/bridge/cart-drawer.d.ts +0 -31
  114. package/types/bridge/form-subdomain-checkout.d.ts +0 -20
  115. package/types/bridge/lib/cart.d.ts +0 -44
  116. package/types/dashboard/embed-stripe.d.ts +0 -25
  117. package/types/dashboard/form-organization-campaign-field-birthday.d.ts +0 -31
  118. package/types/dashboard/form-organization-campaign-field-rating.d.ts +0 -33
  119. package/types/dashboard/form-organization-product.d.ts +0 -24
  120. package/types/dashboard/input-gallery.d.ts +0 -14
  121. package/types/dashboard/lib/products.d.ts +0 -14
  122. package/types/dashboard/lib/settings-paths.d.ts +0 -5
  123. package/types/dashboard/shipping-rates.d.ts +0 -26
  124. package/types/dashboard/template-buyer.d.ts +0 -50
  125. package/types/shared/order-summary.d.ts +0 -19
@@ -27,7 +27,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
  var age_gate_exports = {};
29
29
  __export(age_gate_exports, {
30
- ageBirthday: () => ageBirthday,
31
30
  ageFor: () => ageFor,
32
31
  ageGateSchema: () => ageGateSchema
33
32
  });
@@ -49,19 +48,8 @@ const ageGateSchema = (values, currentYear = (/* @__PURE__ */ new Date()).getFul
49
48
  })
50
49
  });
51
50
  };
52
- const ageBirthday = (fields, answers = {}, birthday) => {
53
- const sections = Array.isArray(fields == null ? void 0 : fields.sections) ? fields.sections : [];
54
- const field = sections.flatMap((section) => (section == null ? void 0 : section.fields) || []).find((item) => (item == null ? void 0 : item.slug) === "birthday");
55
- const [month, day, year] = typeof birthday === "string" ? birthday.split("/") : [];
56
- if (!(field == null ? void 0 : field.id) || (answers == null ? void 0 : answers[field.id]) || !(month && day && year)) return answers;
57
- return {
58
- ...answers,
59
- [field.id]: [year, month.padStart(2, "0"), day.padStart(2, "0")].join("-")
60
- };
61
- };
62
51
  // Annotate the CommonJS export names for ESM import in node:
63
52
  0 && (module.exports = {
64
- ageBirthday,
65
53
  ageFor,
66
54
  ageGateSchema
67
55
  });
@@ -15,18 +15,7 @@ const ageGateSchema = (values, currentYear = (/* @__PURE__ */ new Date()).getFul
15
15
  })
16
16
  });
17
17
  };
18
- const ageBirthday = (fields, answers = {}, birthday) => {
19
- const sections = Array.isArray(fields == null ? void 0 : fields.sections) ? fields.sections : [];
20
- const field = sections.flatMap((section) => (section == null ? void 0 : section.fields) || []).find((item) => (item == null ? void 0 : item.slug) === "birthday");
21
- const [month, day, year] = typeof birthday === "string" ? birthday.split("/") : [];
22
- if (!(field == null ? void 0 : field.id) || (answers == null ? void 0 : answers[field.id]) || !(month && day && year)) return answers;
23
- return {
24
- ...answers,
25
- [field.id]: [year, month.padStart(2, "0"), day.padStart(2, "0")].join("-")
26
- };
27
- };
28
18
  export {
29
- ageBirthday,
30
19
  ageFor,
31
20
  ageGateSchema
32
21
  };
@@ -31,6 +31,7 @@ __export(checkout_kit_exports, {
31
31
  ensureCheckoutKit: () => ensureCheckoutKit
32
32
  });
33
33
  module.exports = __toCommonJS(checkout_kit_exports);
34
+ var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
34
35
  var import_inapp_spy = __toESM(require("inapp-spy"));
35
36
  let registration = null;
36
37
  const ensureCheckoutKit = () => {
@@ -83,13 +84,42 @@ const openCheckoutPopup = ({ checkoutUrl, onClose, onComplete }) => {
83
84
  return true;
84
85
  };
85
86
  const checkout = async ({
87
+ advertisement,
88
+ affiliate,
89
+ campaign,
86
90
  checkoutUrl,
91
+ lines,
87
92
  onClose,
88
93
  onComplete,
89
94
  onOpen,
90
- onRedirect
95
+ onRedirect,
96
+ organization,
97
+ page,
98
+ slug,
99
+ subdomain
91
100
  }) => {
92
- const url = checkoutUrl;
101
+ let url = checkoutUrl;
102
+ if (!url && lines) {
103
+ const attributes = [
104
+ ...campaign ? [{ key: "_drwbrdg_ca", value: campaign }] : [],
105
+ ...organization ? [{ key: "_drwbrdg_or", value: organization }] : [],
106
+ ...advertisement ? [{ key: "_drwbrdg_ad", value: advertisement }] : [],
107
+ ...affiliate ? [{ key: "_drwbrdg_af", value: affiliate }] : [],
108
+ ...page ? [{ key: "_drwbrdg_pg", value: page }] : []
109
+ ];
110
+ const { result } = await (0, import_fetch.request)({
111
+ body: {
112
+ lines: lines.map((line) => ({
113
+ ...line,
114
+ attributes
115
+ }))
116
+ },
117
+ endpoint: "/subdomain/" + subdomain + "/page/" + slug + "/cart",
118
+ method: "POST"
119
+ });
120
+ url = result == null ? void 0 : result.checkoutUrl;
121
+ }
122
+ ;
93
123
  if (!url) return null;
94
124
  const opened = openCheckoutPopup({
95
125
  checkoutUrl: url,
@@ -1,3 +1,4 @@
1
+ import { request } from "@drawbridge/drawbridge-utils/fetch";
1
2
  import InAppSpy from "inapp-spy";
2
3
  let registration = null;
3
4
  const ensureCheckoutKit = () => {
@@ -50,13 +51,42 @@ const openCheckoutPopup = ({ checkoutUrl, onClose, onComplete }) => {
50
51
  return true;
51
52
  };
52
53
  const checkout = async ({
54
+ advertisement,
55
+ affiliate,
56
+ campaign,
53
57
  checkoutUrl,
58
+ lines,
54
59
  onClose,
55
60
  onComplete,
56
61
  onOpen,
57
- onRedirect
62
+ onRedirect,
63
+ organization,
64
+ page,
65
+ slug,
66
+ subdomain
58
67
  }) => {
59
- const url = checkoutUrl;
68
+ let url = checkoutUrl;
69
+ if (!url && lines) {
70
+ const attributes = [
71
+ ...campaign ? [{ key: "_drwbrdg_ca", value: campaign }] : [],
72
+ ...organization ? [{ key: "_drwbrdg_or", value: organization }] : [],
73
+ ...advertisement ? [{ key: "_drwbrdg_ad", value: advertisement }] : [],
74
+ ...affiliate ? [{ key: "_drwbrdg_af", value: affiliate }] : [],
75
+ ...page ? [{ key: "_drwbrdg_pg", value: page }] : []
76
+ ];
77
+ const { result } = await request({
78
+ body: {
79
+ lines: lines.map((line) => ({
80
+ ...line,
81
+ attributes
82
+ }))
83
+ },
84
+ endpoint: "/subdomain/" + subdomain + "/page/" + slug + "/cart",
85
+ method: "POST"
86
+ });
87
+ url = result == null ? void 0 : result.checkoutUrl;
88
+ }
89
+ ;
60
90
  if (!url) return null;
61
91
  const opened = openCheckoutPopup({
62
92
  checkoutUrl: url,
@@ -35,7 +35,6 @@ __export(entry_exports, {
35
35
  menuAgreements: () => menuAgreements,
36
36
  panelMissions: () => panelMissions,
37
37
  previewStep: () => previewStep,
38
- termsOptOut: () => termsOptOut,
39
38
  withLocale: () => withLocale
40
39
  });
41
40
  module.exports = __toCommonJS(entry_exports);
@@ -142,7 +141,6 @@ const withLocale = (agreements = {}, locale = {}) => Object.fromEntries(
142
141
  }
143
142
  ])
144
143
  );
145
- const termsOptOut = ({ giveaway, sms } = {}) => giveaway === false ? null : "If you unsubscribe" + (sms !== false ? " or reply STOP" : "") + ", you can't win and won't be told you were selected.";
146
144
  // Annotate the CommonJS export names for ESM import in node:
147
145
  0 && (module.exports = {
148
146
  AFTER,
@@ -163,6 +161,5 @@ const termsOptOut = ({ giveaway, sms } = {}) => giveaway === false ? null : "If
163
161
  menuAgreements,
164
162
  panelMissions,
165
163
  previewStep,
166
- termsOptOut,
167
164
  withLocale
168
165
  });
@@ -101,7 +101,6 @@ const withLocale = (agreements = {}, locale = {}) => Object.fromEntries(
101
101
  }
102
102
  ])
103
103
  );
104
- const termsOptOut = ({ giveaway, sms } = {}) => giveaway === false ? null : "If you unsubscribe" + (sms !== false ? " or reply STOP" : "") + ", you can't win and won't be told you were selected.";
105
104
  export {
106
105
  AFTER,
107
106
  afterOrder,
@@ -121,6 +120,5 @@ export {
121
120
  menuAgreements,
122
121
  panelMissions,
123
122
  previewStep,
124
- termsOptOut,
125
123
  withLocale
126
124
  };
@@ -33,10 +33,9 @@ __export(product_tile_exports, {
33
33
  module.exports = __toCommonJS(product_tile_exports);
34
34
  var import_jsx_runtime = require("react/jsx-runtime");
35
35
  var import_image = __toESM(require("next/image"));
36
- var import_helpers = require("../shared/lib/helpers");
36
+ var import_drawbridge_utils = require("@drawbridge/drawbridge-utils");
37
37
  var import_button = __toESM(require("../shared/button"));
38
38
  var import_styles = require("../styles");
39
- var import_cart = require("./lib/cart");
40
39
  const CardProduct = ({
41
40
  eager,
42
41
  title,
@@ -46,16 +45,13 @@ const CardProduct = ({
46
45
  variants,
47
46
  ...rest
48
47
  }) => {
49
- var _a, _b, _c;
48
+ var _a, _b, _c, _d;
50
49
  const available = (variants || []).filter((variant) => variant.availableForSale);
51
50
  const price = ((_a = available[0]) == null ? void 0 : _a.price) || null;
52
51
  const currency = ((_b = available[0]) == null ? void 0 : _b.currency) || null;
53
- const image = (0, import_cart.productImage)({
54
- ...rest,
55
- variants
56
- }, "400x400");
52
+ const image = ((_c = available[0]) == null ? void 0 : _c.image) || (rest == null ? void 0 : rest.image) || null;
57
53
  const textSize = stacked ? "text-base" : "text-xs sm:text-sm";
58
- const imageRadius = ((_c = style == null ? void 0 : style.image) == null ? void 0 : _c.radius) != null ? style.image.radius + "px" : "12px";
54
+ const imageRadius = ((_d = style == null ? void 0 : style.image) == null ? void 0 : _d.radius) != null ? style.image.radius + "px" : "12px";
59
55
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
60
56
  import_button.default,
61
57
  {
@@ -103,8 +99,9 @@ const CardProduct = ({
103
99
  ...{
104
100
  className: textSize + " font-bold text-center mb-1"
105
101
  },
106
- children: available.length > 0 && price ? (0, import_helpers.money)({
102
+ children: available.length > 0 && price ? (0, import_drawbridge_utils.formatCurrency)({
107
103
  code: currency,
104
+ display: "parts",
108
105
  value: price
109
106
  }) : "Unavailable"
110
107
  }
@@ -1,10 +1,9 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import Image from "next/image";
4
- import { money } from "../shared/lib/helpers.mjs";
4
+ import { formatCurrency } from "@drawbridge/drawbridge-utils";
5
5
  import Button from "../shared/button.mjs";
6
6
  import { headerStyle } from "../styles.mjs";
7
- import { productImage } from "./lib/cart.mjs";
8
7
  const CardProduct = ({
9
8
  eager,
10
9
  title,
@@ -14,16 +13,13 @@ const CardProduct = ({
14
13
  variants,
15
14
  ...rest
16
15
  }) => {
17
- var _a, _b, _c;
16
+ var _a, _b, _c, _d;
18
17
  const available = (variants || []).filter((variant) => variant.availableForSale);
19
18
  const price = ((_a = available[0]) == null ? void 0 : _a.price) || null;
20
19
  const currency = ((_b = available[0]) == null ? void 0 : _b.currency) || null;
21
- const image = productImage({
22
- ...rest,
23
- variants
24
- }, "400x400");
20
+ const image = ((_c = available[0]) == null ? void 0 : _c.image) || (rest == null ? void 0 : rest.image) || null;
25
21
  const textSize = stacked ? "text-base" : "text-xs sm:text-sm";
26
- const imageRadius = ((_c = style == null ? void 0 : style.image) == null ? void 0 : _c.radius) != null ? style.image.radius + "px" : "12px";
22
+ const imageRadius = ((_d = style == null ? void 0 : style.image) == null ? void 0 : _d.radius) != null ? style.image.radius + "px" : "12px";
27
23
  return /* @__PURE__ */ jsx(
28
24
  Button,
29
25
  {
@@ -71,8 +67,9 @@ const CardProduct = ({
71
67
  ...{
72
68
  className: textSize + " font-bold text-center mb-1"
73
69
  },
74
- children: available.length > 0 && price ? money({
70
+ children: available.length > 0 && price ? formatCurrency({
75
71
  code: currency,
72
+ display: "parts",
76
73
  value: price
77
74
  }) : "Unavailable"
78
75
  }