@drawbridge/components 0.1.12 → 0.1.14

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 (236) hide show
  1. package/components/styles.css +364 -2
  2. package/dist/advertisement.js +3 -1
  3. package/dist/advertisement.mjs +3 -1
  4. package/dist/bridge/advertisements.js +2 -0
  5. package/dist/bridge/advertisements.mjs +2 -0
  6. package/dist/bridge/countdown.js +2 -1
  7. package/dist/bridge/countdown.mjs +2 -1
  8. package/dist/bridge/form-subdomain-embed.js +18 -20
  9. package/dist/bridge/form-subdomain-embed.mjs +18 -20
  10. package/dist/bridge/form-subdomain-header.js +24 -1
  11. package/dist/bridge/form-subdomain-header.mjs +24 -1
  12. package/dist/bridge/form-subdomain-missions.js +538 -0
  13. package/dist/bridge/form-subdomain-missions.mjs +502 -0
  14. package/dist/bridge/form-subdomain.js +530 -220
  15. package/dist/bridge/form-subdomain.mjs +533 -222
  16. package/dist/bridge/lib/entry.js +59 -0
  17. package/dist/bridge/lib/entry.mjs +29 -0
  18. package/dist/bridge/lib/location.js +38 -0
  19. package/dist/bridge/lib/location.mjs +13 -0
  20. package/dist/bridge/lib/order.js +71 -0
  21. package/dist/bridge/lib/order.mjs +44 -0
  22. package/dist/bridge/lib/url.js +9 -0
  23. package/dist/bridge/lib/url.mjs +7 -0
  24. package/dist/bridge/share-button.js +5 -3
  25. package/dist/bridge/share-button.mjs +5 -3
  26. package/dist/bridge/subdomain-content.js +7 -6
  27. package/dist/bridge/subdomain-content.mjs +7 -6
  28. package/dist/bridge/template-layout.js +59 -21
  29. package/dist/bridge/template-layout.mjs +59 -21
  30. package/dist/bridge/template-modal.js +42 -76
  31. package/dist/bridge/template-modal.mjs +39 -73
  32. package/dist/bridge/template-preview.js +208 -0
  33. package/dist/bridge/template-preview.mjs +173 -0
  34. package/dist/bridge/template-subdomain-gallery.js +6 -2
  35. package/dist/bridge/template-subdomain-gallery.mjs +6 -2
  36. package/dist/bridge/template-subdomain-link.js +6 -1
  37. package/dist/bridge/template-subdomain-link.mjs +6 -1
  38. package/dist/bridge/template-subdomain.js +20 -15
  39. package/dist/bridge/template-subdomain.mjs +20 -15
  40. package/dist/dashboard/accordion.js +74 -39
  41. package/dist/dashboard/accordion.mjs +74 -39
  42. package/dist/dashboard/avatar.js +109 -3
  43. package/dist/dashboard/avatar.mjs +106 -4
  44. package/dist/dashboard/buttons-subscription.js +384 -0
  45. package/dist/dashboard/buttons-subscription.mjs +349 -0
  46. package/dist/dashboard/card-campaign-switch.js +265 -0
  47. package/dist/dashboard/card-campaign-switch.mjs +231 -0
  48. package/dist/dashboard/card-order.js +28 -11
  49. package/dist/dashboard/card-order.mjs +28 -11
  50. package/dist/dashboard/card-section.js +26 -2
  51. package/dist/dashboard/card-section.mjs +26 -2
  52. package/dist/dashboard/card-tile.js +6 -7
  53. package/dist/dashboard/card-tile.mjs +6 -7
  54. package/dist/dashboard/connection-workflows.js +196 -0
  55. package/dist/dashboard/connection-workflows.mjs +162 -0
  56. package/dist/dashboard/device.js +95 -0
  57. package/dist/dashboard/device.mjs +72 -0
  58. package/dist/dashboard/form-admin-campaign.js +19 -50
  59. package/dist/dashboard/form-admin-campaign.mjs +20 -51
  60. package/dist/dashboard/form-ai.js +9 -6
  61. package/dist/dashboard/form-ai.mjs +9 -6
  62. package/dist/dashboard/form-auth.js +35 -25
  63. package/dist/dashboard/form-auth.mjs +36 -26
  64. package/dist/dashboard/form-file.js +10 -1
  65. package/dist/dashboard/form-file.mjs +10 -1
  66. package/dist/dashboard/form-filters-analytics.js +14 -1
  67. package/dist/dashboard/form-filters-analytics.mjs +15 -2
  68. package/dist/dashboard/form-organization-campaign-advertisement.js +15 -1
  69. package/dist/dashboard/form-organization-campaign-advertisement.mjs +16 -2
  70. package/dist/dashboard/form-organization-campaign-agreement.js +215 -164
  71. package/dist/dashboard/form-organization-campaign-agreement.mjs +215 -164
  72. package/dist/dashboard/form-organization-campaign-field-email.js +0 -34
  73. package/dist/dashboard/form-organization-campaign-field-email.mjs +0 -34
  74. package/dist/dashboard/form-organization-campaign-field-list.js +466 -0
  75. package/dist/dashboard/form-organization-campaign-field-list.mjs +437 -0
  76. package/dist/dashboard/form-organization-campaign-field-phone.js +0 -34
  77. package/dist/dashboard/form-organization-campaign-field-phone.mjs +0 -34
  78. package/dist/dashboard/form-organization-campaign-field-remove.js +66 -0
  79. package/dist/dashboard/form-organization-campaign-field-remove.mjs +33 -0
  80. package/dist/dashboard/form-organization-campaign-integration-age.js +6 -12
  81. package/dist/dashboard/form-organization-campaign-integration-age.mjs +6 -12
  82. package/dist/dashboard/form-organization-campaign-integration-enable.js +52 -24
  83. package/dist/dashboard/form-organization-campaign-integration-enable.mjs +54 -26
  84. package/dist/dashboard/form-organization-campaign-integration-geocode.js +6 -12
  85. package/dist/dashboard/form-organization-campaign-integration-geocode.mjs +6 -12
  86. package/dist/dashboard/form-organization-campaign-integration-gtm.js +6 -12
  87. package/dist/dashboard/form-organization-campaign-integration-gtm.mjs +6 -12
  88. package/dist/dashboard/form-organization-campaign-link.js +7 -1
  89. package/dist/dashboard/form-organization-campaign-link.mjs +7 -1
  90. package/dist/dashboard/form-organization-campaign-mission.js +291 -0
  91. package/dist/dashboard/form-organization-campaign-mission.mjs +258 -0
  92. package/dist/dashboard/form-organization-campaign-page-embed.js +13 -2
  93. package/dist/dashboard/form-organization-campaign-page-embed.mjs +12 -1
  94. package/dist/dashboard/form-organization-campaign-page.js +20 -11
  95. package/dist/dashboard/form-organization-campaign-page.mjs +20 -11
  96. package/dist/dashboard/form-organization-campaign-prize-edit.js +12 -1
  97. package/dist/dashboard/form-organization-campaign-prize-edit.mjs +12 -1
  98. package/dist/dashboard/form-organization-campaign-section.js +223 -0
  99. package/dist/dashboard/form-organization-campaign-section.mjs +194 -0
  100. package/dist/dashboard/form-organization-campaign.js +114 -469
  101. package/dist/dashboard/form-organization-campaign.mjs +113 -467
  102. package/dist/dashboard/form-organization-export.js +4 -7
  103. package/dist/dashboard/form-organization-export.mjs +4 -7
  104. package/dist/dashboard/form-organization-identity.js +46 -51
  105. package/dist/dashboard/form-organization-identity.mjs +46 -51
  106. package/dist/dashboard/form-organization-workflow.js +518 -686
  107. package/dist/dashboard/form-organization-workflow.mjs +517 -682
  108. package/dist/dashboard/form-organization.js +82 -110
  109. package/dist/dashboard/form-organization.mjs +81 -109
  110. package/dist/dashboard/form-otc.js +4 -5
  111. package/dist/dashboard/form-otc.mjs +4 -5
  112. package/dist/dashboard/form-payment-methods.js +20 -9
  113. package/dist/dashboard/form-payment-methods.mjs +20 -9
  114. package/dist/dashboard/form-stripe.js +30 -0
  115. package/dist/dashboard/form-stripe.mjs +26 -0
  116. package/dist/dashboard/input-array.js +4 -2
  117. package/dist/dashboard/input-array.mjs +4 -2
  118. package/dist/dashboard/input-combobox.js +7 -3
  119. package/dist/dashboard/input-combobox.mjs +7 -3
  120. package/dist/dashboard/input-date.js +7 -0
  121. package/dist/dashboard/input-date.mjs +7 -0
  122. package/dist/dashboard/input-fields.js +80 -20
  123. package/dist/dashboard/input-fields.mjs +80 -20
  124. package/dist/dashboard/input-file.js +21 -1
  125. package/dist/dashboard/input-file.mjs +21 -1
  126. package/dist/dashboard/input-font.js +10 -1
  127. package/dist/dashboard/input-font.mjs +10 -1
  128. package/dist/dashboard/lib/item-list.js +57 -0
  129. package/dist/dashboard/lib/item-list.mjs +33 -0
  130. package/dist/dashboard/lib/menu.js +50 -0
  131. package/dist/dashboard/lib/menu.mjs +26 -0
  132. package/dist/dashboard/locked.js +82 -0
  133. package/dist/dashboard/locked.mjs +53 -0
  134. package/dist/dashboard/menu.js +72 -19
  135. package/dist/dashboard/menu.mjs +72 -19
  136. package/dist/dashboard/note-ai.js +69 -0
  137. package/dist/dashboard/note-ai.mjs +36 -0
  138. package/dist/dashboard/preview.js +419 -0
  139. package/dist/dashboard/preview.mjs +384 -0
  140. package/dist/dashboard/steps.js +39 -13
  141. package/dist/dashboard/steps.mjs +37 -12
  142. package/dist/dashboard/table-contacts.js +136 -0
  143. package/dist/dashboard/table-contacts.mjs +103 -0
  144. package/dist/dashboard/template-not-found.js +4 -2
  145. package/dist/dashboard/template-not-found.mjs +4 -2
  146. package/dist/dashboard/template-socket.js +51 -7
  147. package/dist/dashboard/template-socket.mjs +51 -7
  148. package/dist/icons/desktop.js +46 -0
  149. package/dist/icons/desktop.mjs +27 -0
  150. package/dist/icons/phone.js +46 -0
  151. package/dist/icons/phone.mjs +27 -0
  152. package/dist/icons/puzzle-piece.js +46 -0
  153. package/dist/icons/puzzle-piece.mjs +27 -0
  154. package/dist/icons/tablet.js +46 -0
  155. package/dist/icons/tablet.mjs +27 -0
  156. package/dist/icons/users.js +46 -0
  157. package/dist/icons/users.mjs +27 -0
  158. package/dist/input-checkbox.js +1 -0
  159. package/dist/input-checkbox.mjs +1 -0
  160. package/dist/input-code.js +101 -0
  161. package/dist/input-code.mjs +78 -0
  162. package/dist/input-text.js +2 -1
  163. package/dist/input-text.mjs +2 -1
  164. package/dist/shared/input-checkbox-list.js +0 -1
  165. package/dist/shared/input-checkbox-list.mjs +0 -1
  166. package/dist/shared/input-switch.js +6 -1
  167. package/dist/shared/input-switch.mjs +6 -1
  168. package/dist/shared/lib/campaign.js +117 -0
  169. package/dist/shared/lib/campaign.mjs +91 -0
  170. package/dist/shared/lib/helpers.js +14 -2
  171. package/dist/shared/lib/helpers.mjs +13 -2
  172. package/package.json +133 -13
  173. package/types/bridge/form-subdomain-header.d.ts +2 -0
  174. package/types/bridge/form-subdomain-missions.d.ts +36 -0
  175. package/types/bridge/form-subdomain.d.ts +23 -1
  176. package/types/bridge/lib/entry.d.ts +26 -0
  177. package/types/bridge/lib/location.d.ts +13 -0
  178. package/types/bridge/lib/order.d.ts +30 -0
  179. package/types/bridge/lib/url.d.ts +19 -0
  180. package/types/bridge/template-modal.d.ts +1 -1
  181. package/types/bridge/template-preview.d.ts +10 -0
  182. package/types/bridge/template-subdomain-link.d.ts +2 -0
  183. package/types/dashboard/accordion.d.ts +2 -0
  184. package/types/dashboard/avatar.d.ts +18 -2
  185. package/types/dashboard/buttons-subscription.d.ts +22 -0
  186. package/types/dashboard/card-campaign-switch.d.ts +32 -0
  187. package/types/dashboard/card-order.d.ts +11 -0
  188. package/types/dashboard/card-section.d.ts +2 -0
  189. package/types/dashboard/connection-workflows.d.ts +33 -0
  190. package/types/dashboard/device.d.ts +12 -0
  191. package/types/dashboard/form-admin-campaign.d.ts +3 -2
  192. package/types/dashboard/form-ai.d.ts +2 -2
  193. package/types/dashboard/form-organization-campaign-agreement.d.ts +18 -12
  194. package/types/dashboard/form-organization-campaign-field-email.d.ts +1 -2
  195. package/types/dashboard/form-organization-campaign-field-list.d.ts +36 -0
  196. package/types/dashboard/form-organization-campaign-field-phone.d.ts +1 -2
  197. package/types/dashboard/form-organization-campaign-field-remove.d.ts +22 -0
  198. package/types/dashboard/form-organization-campaign-field-select.d.ts +2 -1
  199. package/types/dashboard/form-organization-campaign-field-textarea.d.ts +2 -1
  200. package/types/dashboard/form-organization-campaign-integration-age.d.ts +3 -3
  201. package/types/dashboard/form-organization-campaign-integration-enable.d.ts +3 -3
  202. package/types/dashboard/form-organization-campaign-mission.d.ts +40 -0
  203. package/types/dashboard/form-organization-campaign-section.d.ts +27 -0
  204. package/types/dashboard/form-organization-campaign.d.ts +27 -17
  205. package/types/dashboard/form-organization-identity.d.ts +2 -0
  206. package/types/dashboard/form-organization-workflow.d.ts +43 -47
  207. package/types/dashboard/form-organization.d.ts +7 -2
  208. package/types/dashboard/form-stripe.d.ts +3 -0
  209. package/types/dashboard/input-combobox.d.ts +2 -0
  210. package/types/dashboard/input-date.d.ts +2 -0
  211. package/types/dashboard/input-fields.d.ts +3 -2
  212. package/types/dashboard/input-file.d.ts +4 -0
  213. package/types/dashboard/lib/item-list.d.ts +14 -0
  214. package/types/dashboard/lib/menu.d.ts +17 -0
  215. package/types/dashboard/locked.d.ts +10 -0
  216. package/types/dashboard/menu.d.ts +10 -2
  217. package/types/dashboard/note-ai.d.ts +15 -0
  218. package/types/dashboard/preview.d.ts +33 -0
  219. package/types/dashboard/steps.d.ts +19 -4
  220. package/types/dashboard/table-cell-title.d.ts +2 -2
  221. package/types/dashboard/table-contacts.d.ts +2 -0
  222. package/types/icons/desktop.d.ts +5 -0
  223. package/types/icons/phone.d.ts +5 -0
  224. package/types/icons/puzzle-piece.d.ts +5 -0
  225. package/types/icons/tablet.d.ts +5 -0
  226. package/types/icons/users.d.ts +5 -0
  227. package/types/input-code.d.ts +23 -0
  228. package/types/shared/input-switch.d.ts +2 -0
  229. package/types/shared/lib/campaign.d.ts +35 -0
  230. package/types/shared/lib/helpers.d.ts +3 -0
  231. package/dist/dashboard/card-integration.js +0 -187
  232. package/dist/dashboard/card-integration.mjs +0 -158
  233. package/dist/dashboard/iframe.js +0 -159
  234. package/dist/dashboard/iframe.mjs +0 -130
  235. package/types/dashboard/card-integration.d.ts +0 -24
  236. package/types/dashboard/iframe.d.ts +0 -18
@@ -27,12 +27,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
  var avatar_exports = {};
29
29
  __export(avatar_exports, {
30
+ Avatars: () => Avatars,
30
31
  default: () => avatar_default
31
32
  });
32
33
  module.exports = __toCommonJS(avatar_exports);
33
34
  var import_jsx_runtime = require("react/jsx-runtime");
34
35
  var import_image = __toESM(require("next/image"));
35
36
  var import_cdn = require("@drawbridge/drawbridge-utils/cdn");
37
+ var import_link = __toESM(require("./link"));
38
+ var import_button = __toESM(require("../shared/button"));
39
+ var import_plus = __toESM(require("../icons/plus"));
36
40
  const sizes = {
37
41
  small: { className: "w-6 h-6 text-[10px]", px: 24 },
38
42
  default: { className: "w-10 h-10 text-sm", px: 40 },
@@ -52,12 +56,13 @@ const Avatar = ({
52
56
  }) => {
53
57
  var _a;
54
58
  const { className, px } = sizes[size] || sizes.default;
55
- const src = (0, import_cdn.cdnSrc)(image, px > 50 && ((_a = image == null ? void 0 : image.sizes) == null ? void 0 : _a["200x200"]) ? "200x200" : "100x100", image == null ? void 0 : image.updatedAt);
59
+ const url = typeof image === "string" ? image : null;
60
+ const src = url || (0, import_cdn.cdnSrc)(image, px > 50 && ((_a = image == null ? void 0 : image.sizes) == null ? void 0 : _a["200x200"]) ? "200x200" : "100x100", image == null ? void 0 : image.updatedAt);
56
61
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
57
62
  "span",
58
63
  {
59
64
  ...{
60
- className: ["relative flex items-center justify-center shrink-0 rounded-full overflow-hidden", className, !src && "bg-black text-white"].filter(Boolean).join(" ")
65
+ className: ["relative flex items-center justify-center shrink-0 rounded-full overflow-hidden", className, src ? "bg-white" : "bg-black text-white"].join(" ")
61
66
  },
62
67
  children: src ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
63
68
  import_image.default,
@@ -66,11 +71,112 @@ const Avatar = ({
66
71
  alt: name || title || email || "",
67
72
  fill: true,
68
73
  sizes: px + "px",
69
- src
74
+ src,
75
+ unoptimized: Boolean(url)
70
76
  }
71
77
  }
72
78
  ) : initials({ email, name, title })
73
79
  }
74
80
  );
75
81
  };
82
+ const Circle = ({ children, href, title }) => href ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
83
+ import_button.default,
84
+ {
85
+ ...{
86
+ element: import_link.default,
87
+ href,
88
+ inline: true,
89
+ title,
90
+ variant: "link"
91
+ },
92
+ children
93
+ }
94
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
95
+ "span",
96
+ {
97
+ ...{
98
+ className: "flex",
99
+ title
100
+ },
101
+ children
102
+ }
103
+ );
104
+ const Avatars = ({
105
+ href,
106
+ items = [],
107
+ max = 4,
108
+ more,
109
+ plus = false
110
+ }) => {
111
+ const shown = (items || []).slice(0, max);
112
+ const rest = Number(more ?? (items || []).length - shown.length) || 0;
113
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
114
+ "span",
115
+ {
116
+ ...{
117
+ className: "flex items-center -space-x-1.5"
118
+ },
119
+ children: [
120
+ shown.map((item, key) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
121
+ Circle,
122
+ {
123
+ ...{
124
+ href,
125
+ title: (item == null ? void 0 : item.title) || (item == null ? void 0 : item.name) || (item == null ? void 0 : item.email)
126
+ },
127
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
128
+ "span",
129
+ {
130
+ ...{
131
+ className: "rounded-full ring-2 ring-white"
132
+ },
133
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
134
+ Avatar,
135
+ {
136
+ ...{
137
+ ...item,
138
+ size: "small"
139
+ }
140
+ }
141
+ )
142
+ }
143
+ )
144
+ },
145
+ key
146
+ )),
147
+ (rest > 0 || plus) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
148
+ Circle,
149
+ {
150
+ ...{
151
+ href,
152
+ ...rest > 0 && {
153
+ title: rest + " more"
154
+ }
155
+ },
156
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
157
+ "span",
158
+ {
159
+ ...{
160
+ className: ["relative flex items-center justify-center shrink-0 rounded-full bg-black text-white ring-2 ring-white", sizes.small.className].join(" ")
161
+ },
162
+ children: rest > 0 ? "+" + rest : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
163
+ import_plus.default,
164
+ {
165
+ ...{
166
+ className: "w-3 h-3"
167
+ }
168
+ }
169
+ )
170
+ }
171
+ )
172
+ }
173
+ )
174
+ ]
175
+ }
176
+ );
177
+ };
76
178
  var avatar_default = Avatar;
179
+ // Annotate the CommonJS export names for ESM import in node:
180
+ 0 && (module.exports = {
181
+ Avatars
182
+ });
@@ -1,6 +1,9 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import Image from "next/image";
3
3
  import { cdnSrc } from "@drawbridge/drawbridge-utils/cdn";
4
+ import Link from "./link.mjs";
5
+ import Button from "../shared/button.mjs";
6
+ import Plus from "../icons/plus.mjs";
4
7
  const sizes = {
5
8
  small: { className: "w-6 h-6 text-[10px]", px: 24 },
6
9
  default: { className: "w-10 h-10 text-sm", px: 40 },
@@ -20,12 +23,13 @@ const Avatar = ({
20
23
  }) => {
21
24
  var _a;
22
25
  const { className, px } = sizes[size] || sizes.default;
23
- const src = cdnSrc(image, px > 50 && ((_a = image == null ? void 0 : image.sizes) == null ? void 0 : _a["200x200"]) ? "200x200" : "100x100", image == null ? void 0 : image.updatedAt);
26
+ const url = typeof image === "string" ? image : null;
27
+ const src = url || cdnSrc(image, px > 50 && ((_a = image == null ? void 0 : image.sizes) == null ? void 0 : _a["200x200"]) ? "200x200" : "100x100", image == null ? void 0 : image.updatedAt);
24
28
  return /* @__PURE__ */ jsx(
25
29
  "span",
26
30
  {
27
31
  ...{
28
- className: ["relative flex items-center justify-center shrink-0 rounded-full overflow-hidden", className, !src && "bg-black text-white"].filter(Boolean).join(" ")
32
+ className: ["relative flex items-center justify-center shrink-0 rounded-full overflow-hidden", className, src ? "bg-white" : "bg-black text-white"].join(" ")
29
33
  },
30
34
  children: src ? /* @__PURE__ */ jsx(
31
35
  Image,
@@ -34,14 +38,112 @@ const Avatar = ({
34
38
  alt: name || title || email || "",
35
39
  fill: true,
36
40
  sizes: px + "px",
37
- src
41
+ src,
42
+ unoptimized: Boolean(url)
38
43
  }
39
44
  }
40
45
  ) : initials({ email, name, title })
41
46
  }
42
47
  );
43
48
  };
49
+ const Circle = ({ children, href, title }) => href ? /* @__PURE__ */ jsx(
50
+ Button,
51
+ {
52
+ ...{
53
+ element: Link,
54
+ href,
55
+ inline: true,
56
+ title,
57
+ variant: "link"
58
+ },
59
+ children
60
+ }
61
+ ) : /* @__PURE__ */ jsx(
62
+ "span",
63
+ {
64
+ ...{
65
+ className: "flex",
66
+ title
67
+ },
68
+ children
69
+ }
70
+ );
71
+ const Avatars = ({
72
+ href,
73
+ items = [],
74
+ max = 4,
75
+ more,
76
+ plus = false
77
+ }) => {
78
+ const shown = (items || []).slice(0, max);
79
+ const rest = Number(more ?? (items || []).length - shown.length) || 0;
80
+ return /* @__PURE__ */ jsxs(
81
+ "span",
82
+ {
83
+ ...{
84
+ className: "flex items-center -space-x-1.5"
85
+ },
86
+ children: [
87
+ shown.map((item, key) => /* @__PURE__ */ jsx(
88
+ Circle,
89
+ {
90
+ ...{
91
+ href,
92
+ title: (item == null ? void 0 : item.title) || (item == null ? void 0 : item.name) || (item == null ? void 0 : item.email)
93
+ },
94
+ children: /* @__PURE__ */ jsx(
95
+ "span",
96
+ {
97
+ ...{
98
+ className: "rounded-full ring-2 ring-white"
99
+ },
100
+ children: /* @__PURE__ */ jsx(
101
+ Avatar,
102
+ {
103
+ ...{
104
+ ...item,
105
+ size: "small"
106
+ }
107
+ }
108
+ )
109
+ }
110
+ )
111
+ },
112
+ key
113
+ )),
114
+ (rest > 0 || plus) && /* @__PURE__ */ jsx(
115
+ Circle,
116
+ {
117
+ ...{
118
+ href,
119
+ ...rest > 0 && {
120
+ title: rest + " more"
121
+ }
122
+ },
123
+ children: /* @__PURE__ */ jsx(
124
+ "span",
125
+ {
126
+ ...{
127
+ className: ["relative flex items-center justify-center shrink-0 rounded-full bg-black text-white ring-2 ring-white", sizes.small.className].join(" ")
128
+ },
129
+ children: rest > 0 ? "+" + rest : /* @__PURE__ */ jsx(
130
+ Plus,
131
+ {
132
+ ...{
133
+ className: "w-3 h-3"
134
+ }
135
+ }
136
+ )
137
+ }
138
+ )
139
+ }
140
+ )
141
+ ]
142
+ }
143
+ );
144
+ };
44
145
  var avatar_default = Avatar;
45
146
  export {
147
+ Avatars,
46
148
  avatar_default as default
47
149
  };
@@ -0,0 +1,384 @@
1
+ "use client";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var buttons_subscription_exports = {};
30
+ __export(buttons_subscription_exports, {
31
+ SubscriptionBadge: () => SubscriptionBadge,
32
+ SubscriptionButtons: () => SubscriptionButtons,
33
+ default: () => buttons_subscription_default,
34
+ useSubscriptionActions: () => useSubscriptionActions
35
+ });
36
+ module.exports = __toCommonJS(buttons_subscription_exports);
37
+ var import_jsx_runtime = require("react/jsx-runtime");
38
+ var import_react_query = require("@tanstack/react-query");
39
+ var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
40
+ var import_hooks = require("./lib/hooks");
41
+ var import_drawbridge_utils = require("@drawbridge/drawbridge-utils");
42
+ var import_helpers = require("../shared/lib/helpers");
43
+ var import_form_action = __toESM(require("./form-action"));
44
+ var import_form_stripe = require("./form-stripe");
45
+ var import_form_payment_methods = __toESM(require("./form-payment-methods"));
46
+ var import_drawer_subscription = __toESM(require("./drawer-subscription"));
47
+ var import_card_payment_method = __toESM(require("./card-payment-method"));
48
+ var import_badge = __toESM(require("../shared/badge"));
49
+ var import_button = __toESM(require("../shared/button"));
50
+ var import_calendar = __toESM(require("../icons/calendar"));
51
+ var import_card = __toESM(require("../icons/card"));
52
+ var import_rocket = __toESM(require("../icons/rocket"));
53
+ var import_warning = __toESM(require("../icons/warning"));
54
+ const dateOptions = {
55
+ day: "numeric",
56
+ month: "short",
57
+ year: "numeric"
58
+ };
59
+ const SubscriptionBadge = ({
60
+ plan,
61
+ subscription
62
+ }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
63
+ import_badge.default,
64
+ {
65
+ ...((subscription == null ? void 0 : subscription.pending) || (subscription == null ? void 0 : subscription.canceledAt)) && {
66
+ type: "warning"
67
+ },
68
+ children: [
69
+ (0, import_drawbridge_utils.capitalize)(plan == null ? void 0 : plan.title),
70
+ (subscription == null ? void 0 : subscription.pending) && " \u2014 downgrades " + (0, import_drawbridge_utils.formatDateString)({
71
+ date: subscription.pending.effectiveAt,
72
+ options: dateOptions
73
+ }),
74
+ !(subscription == null ? void 0 : subscription.pending) && (subscription == null ? void 0 : subscription.canceledAt) && " \u2014 cancels " + (0, import_drawbridge_utils.formatDateString)({
75
+ date: subscription.canceledAt,
76
+ options: dateOptions
77
+ })
78
+ ]
79
+ }
80
+ );
81
+ const useSubscriptionActions = (params) => {
82
+ var _a, _b;
83
+ const queryClient = (0, import_react_query.useQueryClient)();
84
+ const query = (0, import_react_query.useQuery)({
85
+ enabled: false,
86
+ queryKey: ["organization", params.organization]
87
+ });
88
+ const plan = (_a = query == null ? void 0 : query.data) == null ? void 0 : _a.plan;
89
+ const subscription = (_b = query == null ? void 0 : query.data) == null ? void 0 : _b.subscription;
90
+ const drawer = (0, import_hooks.useDrawer)({
91
+ queryClient
92
+ });
93
+ const modal = (0, import_hooks.useModal)({
94
+ queryClient
95
+ });
96
+ const { onError, onSuccess } = (0, import_hooks.useCallbacks)({
97
+ query,
98
+ queryClient
99
+ });
100
+ const subscriptionQueries = [
101
+ {
102
+ queryKey: ["organization", params.organization]
103
+ },
104
+ {
105
+ queryKey: ["organizations"]
106
+ },
107
+ {
108
+ queryKey: ["organization-dashboard", params]
109
+ },
110
+ {
111
+ queryKey: ["organization-billing-invoices", params.organization]
112
+ },
113
+ {
114
+ queryKey: ["account-methods"]
115
+ },
116
+ {
117
+ queryKey: ["menu", "organization", params.organization]
118
+ },
119
+ {
120
+ queryKey: ["menu", "campaign", params.organization]
121
+ }
122
+ ];
123
+ const actions = {
124
+ // `defaultValues` names the fields the dialog's children hold (FormAction
125
+ // hands them to the callback); they go with the request beside `body`.
126
+ confirm: ({
127
+ body,
128
+ children,
129
+ defaultValues,
130
+ endpoint,
131
+ method = "PUT",
132
+ title
133
+ }) => {
134
+ modal.open({
135
+ message: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
136
+ import_form_action.default,
137
+ {
138
+ ...{
139
+ action: "Confirm",
140
+ callback: (values) => (0, import_fetch.request)({
141
+ body: defaultValues ? { ...body, ...values } : body,
142
+ cache: "no-store",
143
+ endpoint,
144
+ method
145
+ }),
146
+ defaultValues,
147
+ onError,
148
+ onSuccess: (response) => {
149
+ modal.close();
150
+ drawer.close();
151
+ onSuccess(
152
+ response,
153
+ {
154
+ invalidate: [
155
+ {
156
+ queryKey: ["organization", params.organization]
157
+ },
158
+ {
159
+ queryKey: ["organizations"]
160
+ },
161
+ {
162
+ queryKey: ["organization-billing-invoices", params.organization]
163
+ },
164
+ {
165
+ queryKey: ["menu", "organization", params.organization]
166
+ }
167
+ ]
168
+ }
169
+ );
170
+ }
171
+ },
172
+ children
173
+ }
174
+ ),
175
+ title
176
+ });
177
+ },
178
+ method: (callback) => {
179
+ modal.open({
180
+ message: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
181
+ import_form_stripe.FormStripeIntent,
182
+ {
183
+ ...{
184
+ onSuccess: ({ result }) => callback(result)
185
+ }
186
+ }
187
+ ),
188
+ title: "Add payment method"
189
+ });
190
+ },
191
+ cancel: () => actions.confirm({
192
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
193
+ "div",
194
+ {
195
+ ...{
196
+ className: "space-y-3"
197
+ },
198
+ children: [
199
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Your subscription will cancel at the end of your current billing period. You'll keep all paid features until then." }),
200
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "After it cancels, your campaigns, pages, brands and prizes will be drafted, and your workflows will be paused. They won't be deleted, but you'll need to reactivate each one if you re-subscribe." })
201
+ ]
202
+ }
203
+ ),
204
+ endpoint: "/organization/" + params.organization + "/subscription/" + (subscription == null ? void 0 : subscription.id) + "/cancel",
205
+ title: "Cancel subscription"
206
+ }),
207
+ resume: () => actions.confirm({
208
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Your subscription will continue and renew as normal at the end of the current billing period." }),
209
+ endpoint: "/organization/" + params.organization + "/subscription/" + (subscription == null ? void 0 : subscription.id) + "/resume",
210
+ title: "Resume subscription"
211
+ }),
212
+ methods: async (subscription2) => {
213
+ const confirmation = (method) => actions.confirm({
214
+ body: {
215
+ method: method == null ? void 0 : method.id
216
+ },
217
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
218
+ "div",
219
+ {
220
+ ...{
221
+ className: "space-y-3"
222
+ },
223
+ children: [
224
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Are you sure you want to change your payment method?" }),
225
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
226
+ import_card_payment_method.default,
227
+ {
228
+ ...method
229
+ }
230
+ )
231
+ ]
232
+ }
233
+ ),
234
+ endpoint: "/organization/" + params.organization + "/subscription/" + (subscription2 == null ? void 0 : subscription2.id) + "/method",
235
+ title: "Confirm payment method"
236
+ });
237
+ modal.open({
238
+ message: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
239
+ import_form_payment_methods.default,
240
+ {
241
+ ...{
242
+ onChange: confirmation,
243
+ onClickAdd: () => actions.method(confirmation),
244
+ values: {
245
+ method: subscription2 == null ? void 0 : subscription2.method,
246
+ organization: params == null ? void 0 : params.organization
247
+ }
248
+ }
249
+ }
250
+ ),
251
+ title: ((subscription2 == null ? void 0 : subscription2.method) ? "Change" : "Add") + " payment method"
252
+ });
253
+ },
254
+ subscribe: () => drawer.open({
255
+ title: "Subscription",
256
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
257
+ import_drawer_subscription.default,
258
+ {
259
+ ...{
260
+ canceledAt: subscription == null ? void 0 : subscription.canceledAt,
261
+ onCancel: () => actions.cancel(),
262
+ onClickAdd: (callback) => actions.method(callback),
263
+ onError: (error) => {
264
+ drawer.close();
265
+ onError(error);
266
+ subscriptionQueries.forEach((props) => queryClient.invalidateQueries(props));
267
+ query.refetch();
268
+ },
269
+ onResume: () => actions.resume(),
270
+ pending: subscription == null ? void 0 : subscription.pending,
271
+ onSuccess: (response) => {
272
+ drawer.close();
273
+ onSuccess(
274
+ response,
275
+ {
276
+ invalidate: subscriptionQueries
277
+ }
278
+ );
279
+ },
280
+ values: {
281
+ ...params,
282
+ plan,
283
+ subscription
284
+ },
285
+ view: (subscription == null ? void 0 : subscription.id) ? "change" : "start"
286
+ }
287
+ }
288
+ )
289
+ })
290
+ };
291
+ return actions;
292
+ };
293
+ const SubscriptionButtons = ({
294
+ actions,
295
+ organization
296
+ }) => {
297
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
298
+ const subscription = organization == null ? void 0 : organization.subscription;
299
+ const errors = ((organization == null ? void 0 : organization.errors) || []).reduce(
300
+ (accumulator, { reference, message }) => {
301
+ accumulator[reference] = message;
302
+ return accumulator;
303
+ },
304
+ {}
305
+ );
306
+ const methodExpired = (0, import_drawbridge_utils.expiredPaymentMethod)((_a = subscription == null ? void 0 : subscription.method) == null ? void 0 : _a.card);
307
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
308
+ "div",
309
+ {
310
+ ...{
311
+ className: "space-y-2"
312
+ },
313
+ children: [
314
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
315
+ import_button.default,
316
+ {
317
+ ...{
318
+ "data-guide": "button-billing-payment-subscription",
319
+ disabled: Boolean((subscription == null ? void 0 : subscription.id) && !(subscription == null ? void 0 : subscription.method)),
320
+ icon: (subscription == null ? void 0 : subscription.id) ? import_calendar.default : import_rocket.default,
321
+ justify: "between",
322
+ onClick: () => actions.subscribe(),
323
+ variant: (subscription == null ? void 0 : subscription.id) ? "secondary" : "success"
324
+ },
325
+ children: ((subscription == null ? void 0 : subscription.id) ? "Change" : "Start") + " subscription"
326
+ }
327
+ ),
328
+ (subscription == null ? void 0 : subscription.id) && // The label span is w-full, so the row has no free space and the icon sits
329
+ // at the end without justify-between; it stays a child to keep its colour.
330
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
331
+ import_button.default,
332
+ {
333
+ ...{
334
+ "data-guide": "button-billing-payment-method",
335
+ onClick: () => actions.methods(subscription),
336
+ variant: !(subscription == null ? void 0 : subscription.method) || (errors == null ? void 0 : errors[(_b = subscription == null ? void 0 : subscription.method) == null ? void 0 : _b.id]) || methodExpired ? "error" : "secondary"
337
+ },
338
+ children: [
339
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
340
+ "span",
341
+ {
342
+ ...{
343
+ className: "flex flex-col w-full text-left"
344
+ },
345
+ children: [
346
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
347
+ (subscription == null ? void 0 : subscription.method) ? "Manage" : "Missing",
348
+ " payment method"
349
+ ] }),
350
+ (subscription == null ? void 0 : subscription.method) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
351
+ "span",
352
+ {
353
+ ...{
354
+ className: "text-sm"
355
+ },
356
+ children: [
357
+ (0, import_drawbridge_utils.capitalize)((_d = (_c = subscription == null ? void 0 : subscription.method) == null ? void 0 : _c.card) == null ? void 0 : _d.brand),
358
+ " ending in ",
359
+ (0, import_helpers.formatLast4)((_f = (_e = subscription == null ? void 0 : subscription.method) == null ? void 0 : _e.card) == null ? void 0 : _f.last4) + " \u2014 " + ((_h = (_g = subscription == null ? void 0 : subscription.method) == null ? void 0 : _g.card) == null ? void 0 : _h.month),
360
+ "/",
361
+ (_j = (_i = subscription == null ? void 0 : subscription.method) == null ? void 0 : _i.card) == null ? void 0 : _j.year,
362
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
363
+ (errors == null ? void 0 : errors[(_k = subscription == null ? void 0 : subscription.method) == null ? void 0 : _k.id]) || (methodExpired ? "Expired card" : "")
364
+ ]
365
+ }
366
+ )
367
+ ]
368
+ }
369
+ ),
370
+ (subscription == null ? void 0 : subscription.method) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_card.default, { className: "w-5 h-5 text-black" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_warning.default, { className: "w-5 h-5 text-red-dark" })
371
+ ]
372
+ }
373
+ )
374
+ ]
375
+ }
376
+ );
377
+ };
378
+ var buttons_subscription_default = SubscriptionButtons;
379
+ // Annotate the CommonJS export names for ESM import in node:
380
+ 0 && (module.exports = {
381
+ SubscriptionBadge,
382
+ SubscriptionButtons,
383
+ useSubscriptionActions
384
+ });