@drawbridge/components 0.1.13 → 0.1.15

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 (242) 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 +577 -0
  13. package/dist/bridge/form-subdomain-missions.mjs +540 -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 +277 -0
  47. package/dist/dashboard/card-campaign-switch.mjs +243 -0
  48. package/dist/dashboard/card-order.js +231 -29
  49. package/dist/dashboard/card-order.mjs +231 -29
  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 +205 -0
  55. package/dist/dashboard/connection-workflows.mjs +171 -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-field-select.js +51 -5
  81. package/dist/dashboard/form-organization-campaign-field-select.mjs +51 -5
  82. package/dist/dashboard/form-organization-campaign-field-textarea.js +46 -8
  83. package/dist/dashboard/form-organization-campaign-field-textarea.mjs +46 -8
  84. package/dist/dashboard/form-organization-campaign-integration-age.js +6 -12
  85. package/dist/dashboard/form-organization-campaign-integration-age.mjs +6 -12
  86. package/dist/dashboard/form-organization-campaign-integration-enable.js +52 -24
  87. package/dist/dashboard/form-organization-campaign-integration-enable.mjs +54 -26
  88. package/dist/dashboard/form-organization-campaign-integration-geocode.js +6 -12
  89. package/dist/dashboard/form-organization-campaign-integration-geocode.mjs +6 -12
  90. package/dist/dashboard/form-organization-campaign-integration-gtm.js +6 -12
  91. package/dist/dashboard/form-organization-campaign-integration-gtm.mjs +6 -12
  92. package/dist/dashboard/form-organization-campaign-link.js +7 -1
  93. package/dist/dashboard/form-organization-campaign-link.mjs +7 -1
  94. package/dist/dashboard/form-organization-campaign-mission.js +291 -0
  95. package/dist/dashboard/form-organization-campaign-mission.mjs +258 -0
  96. package/dist/dashboard/form-organization-campaign-page-embed.js +13 -2
  97. package/dist/dashboard/form-organization-campaign-page-embed.mjs +12 -1
  98. package/dist/dashboard/form-organization-campaign-page.js +20 -11
  99. package/dist/dashboard/form-organization-campaign-page.mjs +20 -11
  100. package/dist/dashboard/form-organization-campaign-prize-edit.js +12 -1
  101. package/dist/dashboard/form-organization-campaign-prize-edit.mjs +12 -1
  102. package/dist/dashboard/form-organization-campaign-section.js +243 -0
  103. package/dist/dashboard/form-organization-campaign-section.mjs +214 -0
  104. package/dist/dashboard/form-organization-campaign.js +114 -469
  105. package/dist/dashboard/form-organization-campaign.mjs +113 -467
  106. package/dist/dashboard/form-organization-export.js +4 -7
  107. package/dist/dashboard/form-organization-export.mjs +4 -7
  108. package/dist/dashboard/form-organization-identity.js +46 -51
  109. package/dist/dashboard/form-organization-identity.mjs +46 -51
  110. package/dist/dashboard/form-organization-workflow.js +708 -687
  111. package/dist/dashboard/form-organization-workflow.mjs +704 -683
  112. package/dist/dashboard/form-organization.js +82 -110
  113. package/dist/dashboard/form-organization.mjs +81 -109
  114. package/dist/dashboard/form-otc.js +4 -5
  115. package/dist/dashboard/form-otc.mjs +4 -5
  116. package/dist/dashboard/form-payment-methods.js +20 -9
  117. package/dist/dashboard/form-payment-methods.mjs +20 -9
  118. package/dist/dashboard/form-stripe.js +30 -0
  119. package/dist/dashboard/form-stripe.mjs +26 -0
  120. package/dist/dashboard/input-array.js +4 -2
  121. package/dist/dashboard/input-array.mjs +4 -2
  122. package/dist/dashboard/input-combobox.js +7 -3
  123. package/dist/dashboard/input-combobox.mjs +7 -3
  124. package/dist/dashboard/input-date.js +7 -0
  125. package/dist/dashboard/input-date.mjs +7 -0
  126. package/dist/dashboard/input-fields.js +80 -20
  127. package/dist/dashboard/input-fields.mjs +80 -20
  128. package/dist/dashboard/input-file.js +21 -1
  129. package/dist/dashboard/input-file.mjs +21 -1
  130. package/dist/dashboard/input-font.js +10 -1
  131. package/dist/dashboard/input-font.mjs +10 -1
  132. package/dist/dashboard/lib/item-list.js +57 -0
  133. package/dist/dashboard/lib/item-list.mjs +33 -0
  134. package/dist/dashboard/lib/menu.js +50 -0
  135. package/dist/dashboard/lib/menu.mjs +26 -0
  136. package/dist/dashboard/locked.js +82 -0
  137. package/dist/dashboard/locked.mjs +53 -0
  138. package/dist/dashboard/menu.js +72 -19
  139. package/dist/dashboard/menu.mjs +72 -19
  140. package/dist/dashboard/note-ai.js +69 -0
  141. package/dist/dashboard/note-ai.mjs +36 -0
  142. package/dist/dashboard/preview.js +419 -0
  143. package/dist/dashboard/preview.mjs +384 -0
  144. package/dist/dashboard/steps.js +39 -13
  145. package/dist/dashboard/steps.mjs +37 -12
  146. package/dist/dashboard/table-contacts.js +136 -0
  147. package/dist/dashboard/table-contacts.mjs +103 -0
  148. package/dist/dashboard/template-not-found.js +4 -2
  149. package/dist/dashboard/template-not-found.mjs +4 -2
  150. package/dist/dashboard/template-socket.js +20 -7
  151. package/dist/dashboard/template-socket.mjs +20 -7
  152. package/dist/icons/desktop.js +46 -0
  153. package/dist/icons/desktop.mjs +27 -0
  154. package/dist/icons/phone.js +46 -0
  155. package/dist/icons/phone.mjs +27 -0
  156. package/dist/icons/puzzle-piece.js +46 -0
  157. package/dist/icons/puzzle-piece.mjs +27 -0
  158. package/dist/icons/tablet.js +46 -0
  159. package/dist/icons/tablet.mjs +27 -0
  160. package/dist/icons/users.js +46 -0
  161. package/dist/icons/users.mjs +27 -0
  162. package/dist/input-checkbox.js +1 -0
  163. package/dist/input-checkbox.mjs +1 -0
  164. package/dist/input-code.js +83 -0
  165. package/dist/input-code.mjs +50 -0
  166. package/dist/input-text.js +2 -1
  167. package/dist/input-text.mjs +2 -1
  168. package/dist/shared/button.js +1 -1
  169. package/dist/shared/button.mjs +1 -1
  170. package/dist/shared/input-checkbox-list.js +0 -1
  171. package/dist/shared/input-checkbox-list.mjs +0 -1
  172. package/dist/shared/input-switch.js +6 -1
  173. package/dist/shared/input-switch.mjs +6 -1
  174. package/dist/shared/lib/campaign.js +123 -0
  175. package/dist/shared/lib/campaign.mjs +96 -0
  176. package/dist/shared/lib/helpers.js +14 -2
  177. package/dist/shared/lib/helpers.mjs +13 -2
  178. package/package.json +133 -13
  179. package/types/bridge/form-subdomain-header.d.ts +2 -0
  180. package/types/bridge/form-subdomain-missions.d.ts +38 -0
  181. package/types/bridge/form-subdomain.d.ts +23 -1
  182. package/types/bridge/lib/entry.d.ts +26 -0
  183. package/types/bridge/lib/location.d.ts +13 -0
  184. package/types/bridge/lib/order.d.ts +30 -0
  185. package/types/bridge/lib/url.d.ts +19 -0
  186. package/types/bridge/template-modal.d.ts +1 -1
  187. package/types/bridge/template-preview.d.ts +10 -0
  188. package/types/bridge/template-subdomain-link.d.ts +2 -0
  189. package/types/dashboard/accordion.d.ts +2 -0
  190. package/types/dashboard/avatar.d.ts +18 -2
  191. package/types/dashboard/buttons-subscription.d.ts +22 -0
  192. package/types/dashboard/card-campaign-switch.d.ts +32 -0
  193. package/types/dashboard/card-order.d.ts +25 -1
  194. package/types/dashboard/card-section.d.ts +2 -0
  195. package/types/dashboard/connection-workflows.d.ts +33 -0
  196. package/types/dashboard/device.d.ts +12 -0
  197. package/types/dashboard/form-admin-campaign.d.ts +3 -2
  198. package/types/dashboard/form-ai.d.ts +2 -2
  199. package/types/dashboard/form-organization-campaign-agreement.d.ts +18 -12
  200. package/types/dashboard/form-organization-campaign-field-email.d.ts +1 -2
  201. package/types/dashboard/form-organization-campaign-field-list.d.ts +36 -0
  202. package/types/dashboard/form-organization-campaign-field-phone.d.ts +1 -2
  203. package/types/dashboard/form-organization-campaign-field-remove.d.ts +22 -0
  204. package/types/dashboard/form-organization-campaign-field-select.d.ts +2 -1
  205. package/types/dashboard/form-organization-campaign-field-textarea.d.ts +2 -1
  206. package/types/dashboard/form-organization-campaign-integration-age.d.ts +3 -3
  207. package/types/dashboard/form-organization-campaign-integration-enable.d.ts +3 -3
  208. package/types/dashboard/form-organization-campaign-mission.d.ts +40 -0
  209. package/types/dashboard/form-organization-campaign-section.d.ts +29 -0
  210. package/types/dashboard/form-organization-campaign.d.ts +27 -17
  211. package/types/dashboard/form-organization-identity.d.ts +2 -0
  212. package/types/dashboard/form-organization-workflow.d.ts +56 -47
  213. package/types/dashboard/form-organization.d.ts +7 -2
  214. package/types/dashboard/form-stripe.d.ts +3 -0
  215. package/types/dashboard/input-combobox.d.ts +2 -0
  216. package/types/dashboard/input-date.d.ts +2 -0
  217. package/types/dashboard/input-fields.d.ts +3 -2
  218. package/types/dashboard/input-file.d.ts +4 -0
  219. package/types/dashboard/lib/item-list.d.ts +14 -0
  220. package/types/dashboard/lib/menu.d.ts +17 -0
  221. package/types/dashboard/locked.d.ts +10 -0
  222. package/types/dashboard/menu.d.ts +10 -2
  223. package/types/dashboard/note-ai.d.ts +15 -0
  224. package/types/dashboard/preview.d.ts +33 -0
  225. package/types/dashboard/steps.d.ts +19 -4
  226. package/types/dashboard/table-cell-title.d.ts +2 -2
  227. package/types/dashboard/table-contacts.d.ts +2 -0
  228. package/types/icons/desktop.d.ts +5 -0
  229. package/types/icons/phone.d.ts +5 -0
  230. package/types/icons/puzzle-piece.d.ts +5 -0
  231. package/types/icons/tablet.d.ts +5 -0
  232. package/types/icons/users.d.ts +5 -0
  233. package/types/input-code.d.ts +23 -0
  234. package/types/shared/input-switch.d.ts +2 -0
  235. package/types/shared/lib/campaign.d.ts +35 -0
  236. package/types/shared/lib/helpers.d.ts +3 -0
  237. package/dist/dashboard/card-integration.js +0 -187
  238. package/dist/dashboard/card-integration.mjs +0 -158
  239. package/dist/dashboard/iframe.js +0 -159
  240. package/dist/dashboard/iframe.mjs +0 -130
  241. package/types/dashboard/card-integration.d.ts +0 -24
  242. package/types/dashboard/iframe.d.ts +0 -18
@@ -0,0 +1,205 @@
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 connection_workflows_exports = {};
30
+ __export(connection_workflows_exports, {
31
+ default: () => connection_workflows_default,
32
+ workflowLine: () => workflowLine,
33
+ workflowsNotRunning: () => workflowsNotRunning
34
+ });
35
+ module.exports = __toCommonJS(connection_workflows_exports);
36
+ var import_jsx_runtime = require("react/jsx-runtime");
37
+ var import_react_query = require("@tanstack/react-query");
38
+ var import_hooks = require("./lib/hooks");
39
+ var import_paged = __toESM(require("./paged"));
40
+ var import_link = __toESM(require("./link"));
41
+ var import_badge = __toESM(require("../shared/badge"));
42
+ var import_button = __toESM(require("../shared/button"));
43
+ var import_empty = __toESM(require("../shared/empty"));
44
+ var import_helpers = require("../shared/lib/helpers");
45
+ const workflowLine = (row) => {
46
+ var _a;
47
+ return [
48
+ (_a = row == null ? void 0 : row.trigger) == null ? void 0 : _a.title,
49
+ ((row == null ? void 0 : row.steps) || []).join(", ")
50
+ ].filter(Boolean).join(" \xB7 ");
51
+ };
52
+ const workflowsNotRunning = (items = []) => {
53
+ const broken = items.filter((row) => (row == null ? void 0 : row.status) === "error");
54
+ if (!broken.length) return null;
55
+ const one = broken.length === 1;
56
+ const names = [...new Set(broken.map((row) => {
57
+ var _a;
58
+ return ((_a = row == null ? void 0 : row.campaign) == null ? void 0 : _a.title) || (row == null ? void 0 : row.title);
59
+ }).filter(Boolean))];
60
+ return {
61
+ message: names.join(", ") + ": a step needs this. Connect below to start " + (one ? "it" : "them") + " again.",
62
+ title: broken.length + (one ? " workflow is" : " workflows are") + " not running"
63
+ };
64
+ };
65
+ const ConnectionWorkflows = ({
66
+ endpoint,
67
+ organization,
68
+ queryKey,
69
+ view = true
70
+ }) => {
71
+ const queryClient = (0, import_react_query.useQueryClient)();
72
+ const drawer = (0, import_hooks.useDrawer)({ queryClient });
73
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
74
+ import_paged.default,
75
+ {
76
+ ...{
77
+ classNamePagination: "pt-6",
78
+ // The drawer is white, so the empty box is the grey one.
79
+ empty: ({ empty, locked }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
80
+ import_empty.default,
81
+ {
82
+ ...{
83
+ variant: "secondary"
84
+ },
85
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: (locked == null ? void 0 : locked.message) || (empty == null ? void 0 : empty.message) || "No workflow uses this connection yet." })
86
+ }
87
+ ),
88
+ endpoint,
89
+ params: {
90
+ limit: 24
91
+ },
92
+ queryKey
93
+ },
94
+ children: ({ items }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
95
+ "div",
96
+ {
97
+ ...{
98
+ className: "divide-y divide-gray"
99
+ },
100
+ children: items.map((row) => {
101
+ var _a, _b, _c, _d;
102
+ const badge = (0, import_helpers.statusBadge)("workflow", row == null ? void 0 : row.status);
103
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
104
+ "div",
105
+ {
106
+ ...{
107
+ className: "flex items-center gap-4 py-4 first:pt-0"
108
+ },
109
+ children: [
110
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
111
+ "div",
112
+ {
113
+ ...{
114
+ className: "flex-1 min-w-0 space-y-1"
115
+ },
116
+ children: [
117
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
118
+ "p",
119
+ {
120
+ ...{
121
+ className: "flex items-center gap-2 min-w-0"
122
+ },
123
+ children: [
124
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
125
+ "span",
126
+ {
127
+ ...{
128
+ className: "truncate"
129
+ },
130
+ children: ((_a = row == null ? void 0 : row.campaign) == null ? void 0 : _a.title) || (row == null ? void 0 : row.title)
131
+ }
132
+ ),
133
+ badge && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
134
+ import_badge.default,
135
+ {
136
+ ...{
137
+ size: "small",
138
+ type: badge.type
139
+ },
140
+ children: badge.text
141
+ }
142
+ )
143
+ ]
144
+ }
145
+ ),
146
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
147
+ "p",
148
+ {
149
+ ...{
150
+ className: "text-sm text-gray-dark"
151
+ },
152
+ children: workflowLine(row)
153
+ }
154
+ ),
155
+ ((_b = row == null ? void 0 : row.issue) == null ? void 0 : _b.message) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
156
+ "p",
157
+ {
158
+ ...{
159
+ className: "text-sm text-red-dark"
160
+ },
161
+ children: row.issue.message
162
+ }
163
+ )
164
+ ]
165
+ }
166
+ ),
167
+ (row == null ? void 0 : row.locked) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
168
+ import_badge.default,
169
+ {
170
+ ...{
171
+ size: "small",
172
+ type: "secondary"
173
+ },
174
+ children: "Locked"
175
+ }
176
+ ) : view && ((_c = row == null ? void 0 : row.campaign) == null ? void 0 : _c.id) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
177
+ import_button.default,
178
+ {
179
+ ...{
180
+ element: import_link.default,
181
+ href: "/organizations/" + organization + "/campaigns/" + row.campaign.id + "/workflows/" + ((_d = row == null ? void 0 : row.trigger) == null ? void 0 : _d.event),
182
+ inline: true,
183
+ onClick: drawer.close,
184
+ size: "small",
185
+ variant: "secondary"
186
+ },
187
+ children: "View"
188
+ }
189
+ )
190
+ ]
191
+ },
192
+ row.id
193
+ );
194
+ })
195
+ }
196
+ )
197
+ }
198
+ );
199
+ };
200
+ var connection_workflows_default = ConnectionWorkflows;
201
+ // Annotate the CommonJS export names for ESM import in node:
202
+ 0 && (module.exports = {
203
+ workflowLine,
204
+ workflowsNotRunning
205
+ });
@@ -0,0 +1,171 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useQueryClient } from "@tanstack/react-query";
4
+ import { useDrawer } from "./lib/hooks.mjs";
5
+ import Paged from "./paged.mjs";
6
+ import Link from "./link.mjs";
7
+ import Badge from "../shared/badge.mjs";
8
+ import Button from "../shared/button.mjs";
9
+ import Empty from "../shared/empty.mjs";
10
+ import { statusBadge } from "../shared/lib/helpers.mjs";
11
+ const workflowLine = (row) => {
12
+ var _a;
13
+ return [
14
+ (_a = row == null ? void 0 : row.trigger) == null ? void 0 : _a.title,
15
+ ((row == null ? void 0 : row.steps) || []).join(", ")
16
+ ].filter(Boolean).join(" \xB7 ");
17
+ };
18
+ const workflowsNotRunning = (items = []) => {
19
+ const broken = items.filter((row) => (row == null ? void 0 : row.status) === "error");
20
+ if (!broken.length) return null;
21
+ const one = broken.length === 1;
22
+ const names = [...new Set(broken.map((row) => {
23
+ var _a;
24
+ return ((_a = row == null ? void 0 : row.campaign) == null ? void 0 : _a.title) || (row == null ? void 0 : row.title);
25
+ }).filter(Boolean))];
26
+ return {
27
+ message: names.join(", ") + ": a step needs this. Connect below to start " + (one ? "it" : "them") + " again.",
28
+ title: broken.length + (one ? " workflow is" : " workflows are") + " not running"
29
+ };
30
+ };
31
+ const ConnectionWorkflows = ({
32
+ endpoint,
33
+ organization,
34
+ queryKey,
35
+ view = true
36
+ }) => {
37
+ const queryClient = useQueryClient();
38
+ const drawer = useDrawer({ queryClient });
39
+ return /* @__PURE__ */ jsx(
40
+ Paged,
41
+ {
42
+ ...{
43
+ classNamePagination: "pt-6",
44
+ // The drawer is white, so the empty box is the grey one.
45
+ empty: ({ empty, locked }) => /* @__PURE__ */ jsx(
46
+ Empty,
47
+ {
48
+ ...{
49
+ variant: "secondary"
50
+ },
51
+ children: /* @__PURE__ */ jsx("p", { children: (locked == null ? void 0 : locked.message) || (empty == null ? void 0 : empty.message) || "No workflow uses this connection yet." })
52
+ }
53
+ ),
54
+ endpoint,
55
+ params: {
56
+ limit: 24
57
+ },
58
+ queryKey
59
+ },
60
+ children: ({ items }) => /* @__PURE__ */ jsx(
61
+ "div",
62
+ {
63
+ ...{
64
+ className: "divide-y divide-gray"
65
+ },
66
+ children: items.map((row) => {
67
+ var _a, _b, _c, _d;
68
+ const badge = statusBadge("workflow", row == null ? void 0 : row.status);
69
+ return /* @__PURE__ */ jsxs(
70
+ "div",
71
+ {
72
+ ...{
73
+ className: "flex items-center gap-4 py-4 first:pt-0"
74
+ },
75
+ children: [
76
+ /* @__PURE__ */ jsxs(
77
+ "div",
78
+ {
79
+ ...{
80
+ className: "flex-1 min-w-0 space-y-1"
81
+ },
82
+ children: [
83
+ /* @__PURE__ */ jsxs(
84
+ "p",
85
+ {
86
+ ...{
87
+ className: "flex items-center gap-2 min-w-0"
88
+ },
89
+ children: [
90
+ /* @__PURE__ */ jsx(
91
+ "span",
92
+ {
93
+ ...{
94
+ className: "truncate"
95
+ },
96
+ children: ((_a = row == null ? void 0 : row.campaign) == null ? void 0 : _a.title) || (row == null ? void 0 : row.title)
97
+ }
98
+ ),
99
+ badge && /* @__PURE__ */ jsx(
100
+ Badge,
101
+ {
102
+ ...{
103
+ size: "small",
104
+ type: badge.type
105
+ },
106
+ children: badge.text
107
+ }
108
+ )
109
+ ]
110
+ }
111
+ ),
112
+ /* @__PURE__ */ jsx(
113
+ "p",
114
+ {
115
+ ...{
116
+ className: "text-sm text-gray-dark"
117
+ },
118
+ children: workflowLine(row)
119
+ }
120
+ ),
121
+ ((_b = row == null ? void 0 : row.issue) == null ? void 0 : _b.message) && /* @__PURE__ */ jsx(
122
+ "p",
123
+ {
124
+ ...{
125
+ className: "text-sm text-red-dark"
126
+ },
127
+ children: row.issue.message
128
+ }
129
+ )
130
+ ]
131
+ }
132
+ ),
133
+ (row == null ? void 0 : row.locked) ? /* @__PURE__ */ jsx(
134
+ Badge,
135
+ {
136
+ ...{
137
+ size: "small",
138
+ type: "secondary"
139
+ },
140
+ children: "Locked"
141
+ }
142
+ ) : view && ((_c = row == null ? void 0 : row.campaign) == null ? void 0 : _c.id) && /* @__PURE__ */ jsx(
143
+ Button,
144
+ {
145
+ ...{
146
+ element: Link,
147
+ href: "/organizations/" + organization + "/campaigns/" + row.campaign.id + "/workflows/" + ((_d = row == null ? void 0 : row.trigger) == null ? void 0 : _d.event),
148
+ inline: true,
149
+ onClick: drawer.close,
150
+ size: "small",
151
+ variant: "secondary"
152
+ },
153
+ children: "View"
154
+ }
155
+ )
156
+ ]
157
+ },
158
+ row.id
159
+ );
160
+ })
161
+ }
162
+ )
163
+ }
164
+ );
165
+ };
166
+ var connection_workflows_default = ConnectionWorkflows;
167
+ export {
168
+ connection_workflows_default as default,
169
+ workflowLine,
170
+ workflowsNotRunning
171
+ };
@@ -0,0 +1,95 @@
1
+ "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var device_exports = {};
20
+ __export(device_exports, {
21
+ DEVICE_TYPES: () => DEVICE_TYPES,
22
+ default: () => device_default
23
+ });
24
+ module.exports = __toCommonJS(device_exports);
25
+ var import_jsx_runtime = require("react/jsx-runtime");
26
+ const DEVICE_TYPES = {
27
+ // The phone's page starts below its status bar and island, as it does in Safari.
28
+ phone: { model: "iphone-14-pro", safe: 50, screen: { height: 830, width: 390 }, viewport: 390 },
29
+ tablet: { model: "ipad-pro", screen: { height: 724, width: 506 }, viewport: 768 },
30
+ desktop: { model: "macbook-pro", screen: { height: 375, width: 600 }, viewport: 1440 }
31
+ };
32
+ const PARTS = ["stripe", "header", "sensors", "btns", "power", "home"];
33
+ const Device = ({
34
+ children,
35
+ type = "phone"
36
+ }) => {
37
+ const { model, safe = 0, screen, viewport } = DEVICE_TYPES[type];
38
+ const scale = screen.width / viewport;
39
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
40
+ "div",
41
+ {
42
+ ...{
43
+ className: "device device-" + model
44
+ },
45
+ children: [
46
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
47
+ "div",
48
+ {
49
+ ...{
50
+ className: "device-frame"
51
+ },
52
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
53
+ "div",
54
+ {
55
+ ...{
56
+ className: "device-screen overflow-hidden bg-white"
57
+ },
58
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
59
+ "div",
60
+ {
61
+ ...{
62
+ // The device's own viewport, scaled into the screen.
63
+ className: "absolute left-0 origin-top-left",
64
+ style: {
65
+ height: (screen.height - safe) / scale,
66
+ top: safe,
67
+ transform: "scale(" + scale + ")",
68
+ width: viewport
69
+ }
70
+ },
71
+ children
72
+ }
73
+ )
74
+ }
75
+ )
76
+ }
77
+ ),
78
+ PARTS.map((part) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
79
+ "div",
80
+ {
81
+ ...{
82
+ className: "device-" + part
83
+ }
84
+ },
85
+ part
86
+ ))
87
+ ]
88
+ }
89
+ );
90
+ };
91
+ var device_default = Device;
92
+ // Annotate the CommonJS export names for ESM import in node:
93
+ 0 && (module.exports = {
94
+ DEVICE_TYPES
95
+ });
@@ -0,0 +1,72 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ const DEVICE_TYPES = {
4
+ // The phone's page starts below its status bar and island, as it does in Safari.
5
+ phone: { model: "iphone-14-pro", safe: 50, screen: { height: 830, width: 390 }, viewport: 390 },
6
+ tablet: { model: "ipad-pro", screen: { height: 724, width: 506 }, viewport: 768 },
7
+ desktop: { model: "macbook-pro", screen: { height: 375, width: 600 }, viewport: 1440 }
8
+ };
9
+ const PARTS = ["stripe", "header", "sensors", "btns", "power", "home"];
10
+ const Device = ({
11
+ children,
12
+ type = "phone"
13
+ }) => {
14
+ const { model, safe = 0, screen, viewport } = DEVICE_TYPES[type];
15
+ const scale = screen.width / viewport;
16
+ return /* @__PURE__ */ jsxs(
17
+ "div",
18
+ {
19
+ ...{
20
+ className: "device device-" + model
21
+ },
22
+ children: [
23
+ /* @__PURE__ */ jsx(
24
+ "div",
25
+ {
26
+ ...{
27
+ className: "device-frame"
28
+ },
29
+ children: /* @__PURE__ */ jsx(
30
+ "div",
31
+ {
32
+ ...{
33
+ className: "device-screen overflow-hidden bg-white"
34
+ },
35
+ children: /* @__PURE__ */ jsx(
36
+ "div",
37
+ {
38
+ ...{
39
+ // The device's own viewport, scaled into the screen.
40
+ className: "absolute left-0 origin-top-left",
41
+ style: {
42
+ height: (screen.height - safe) / scale,
43
+ top: safe,
44
+ transform: "scale(" + scale + ")",
45
+ width: viewport
46
+ }
47
+ },
48
+ children
49
+ }
50
+ )
51
+ }
52
+ )
53
+ }
54
+ ),
55
+ PARTS.map((part) => /* @__PURE__ */ jsx(
56
+ "div",
57
+ {
58
+ ...{
59
+ className: "device-" + part
60
+ }
61
+ },
62
+ part
63
+ ))
64
+ ]
65
+ }
66
+ );
67
+ };
68
+ var device_default = Device;
69
+ export {
70
+ DEVICE_TYPES,
71
+ device_default as default
72
+ };
@@ -35,11 +35,8 @@ var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
35
35
  var import_form = require("../shared/lib/form");
36
36
  var import_yup = __toESM(require("../shared/lib/yup"));
37
37
  var import_input_fields = require("./input-fields");
38
- var import_react_query = require("@tanstack/react-query");
39
38
  var import_form2 = __toESM(require("../shared/form"));
40
39
  var import_fieldset = __toESM(require("../shared/fieldset"));
41
- var import_input_group = __toESM(require("../input-group"));
42
- var import_input_combobox = __toESM(require("./input-combobox"));
43
40
  var import_button = __toESM(require("../shared/button"));
44
41
  const FormAdminCampaign = ({
45
42
  disabled,
@@ -47,36 +44,41 @@ const FormAdminCampaign = ({
47
44
  onError,
48
45
  values
49
46
  }) => {
50
- var _a;
51
- const queryClient = (0, import_react_query.useQueryClient)();
52
- const app = queryClient.getQueryData(["app"]);
47
+ var _a, _b;
53
48
  const methods = (0, import_form.useForm)({
54
49
  // Reactive `values` (not `defaultValues`): this form stays mounted on
55
50
  // the admin campaign page, so the save-then-refetch cycle must rebase
56
51
  // the baseline or the unsaved-changes guard would stay armed.
52
+ // @story campaigns/giveaway-module
53
+ // The two switches, read off the campaign; the api applies the rule
54
+ // between them again on the PUT.
57
55
  values: {
58
56
  ...values,
59
- type: (_a = values == null ? void 0 : values.type) == null ? void 0 : _a.value
57
+ form: Boolean((_a = values == null ? void 0 : values.form) == null ? void 0 : _a.enabled),
58
+ giveaway: Boolean((_b = values == null ? void 0 : values.giveaway) == null ? void 0 : _b.enabled)
60
59
  },
61
60
  resolver: (0, import_yup.resolver)(
62
61
  import_yup.default.object({
63
- ...import_input_fields.schemas.campaign({ typeEnum: app.enums.campaign.type.enum }),
64
- status: import_yup.default.string().label("Status").required().oneOf(app.enums.campaign.status.enum)
62
+ ...import_input_fields.schemas.campaign()
65
63
  })
66
64
  )
67
65
  });
68
66
  const { control, handleSubmit, formState } = methods;
69
67
  const onSubmit = async ({
70
- status,
71
- title,
72
- type
68
+ form,
69
+ giveaway,
70
+ title
73
71
  }) => {
74
72
  try {
75
73
  const response = await (0, import_fetch.request)({
76
74
  body: {
77
- status,
78
- title,
79
- type
75
+ form: {
76
+ enabled: form
77
+ },
78
+ giveaway: {
79
+ enabled: giveaway
80
+ },
81
+ title
80
82
  },
81
83
  endpoint: "/admin/organization/" + (values == null ? void 0 : values.organization) + "/campaign/" + (values == null ? void 0 : values.id),
82
84
  method: "PUT"
@@ -94,46 +96,13 @@ const FormAdminCampaign = ({
94
96
  onSubmit: handleSubmit(onSubmit)
95
97
  },
96
98
  children: [
97
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
99
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
98
100
  import_fieldset.default,
99
101
  {
100
102
  ...{
101
103
  disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
102
104
  },
103
- children: [
104
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_input_fields.InputFieldsCampaign, {}),
105
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
106
- import_form.Controller,
107
- {
108
- ...{
109
- control,
110
- name: "status",
111
- render: ({ field: { value, onChange } }) => {
112
- var _a2, _b;
113
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
114
- import_input_group.default,
115
- {
116
- ...{
117
- error: (_b = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.status) == null ? void 0 : _b.message,
118
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
119
- import_input_combobox.default,
120
- {
121
- ...{
122
- onChange,
123
- options: app.enums.campaign.status.options,
124
- value
125
- }
126
- }
127
- ),
128
- label: "Status"
129
- }
130
- }
131
- );
132
- }
133
- }
134
- }
135
- )
136
- ]
105
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_input_fields.InputFieldsCampaign, {})
137
106
  }
138
107
  ),
139
108
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(