@drawbridge/components 0.1.14 → 0.1.16

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 (52) hide show
  1. package/dist/bridge/form-subdomain-missions.js +77 -38
  2. package/dist/bridge/form-subdomain-missions.mjs +76 -38
  3. package/dist/bridge/lib/url.js +3 -3
  4. package/dist/bridge/lib/url.mjs +3 -3
  5. package/dist/bridge/share-button.js +12 -2
  6. package/dist/bridge/share-button.mjs +12 -2
  7. package/dist/bridge/template-layout.js +1 -1
  8. package/dist/bridge/template-layout.mjs +1 -1
  9. package/dist/dashboard/answer-rows.js +77 -0
  10. package/dist/dashboard/answer-rows.mjs +41 -0
  11. package/dist/dashboard/card-campaign-switch.js +55 -43
  12. package/dist/dashboard/card-campaign-switch.mjs +56 -44
  13. package/dist/dashboard/card-order.js +248 -120
  14. package/dist/dashboard/card-order.mjs +248 -120
  15. package/dist/dashboard/connection-workflows.js +13 -4
  16. package/dist/dashboard/connection-workflows.mjs +13 -4
  17. package/dist/dashboard/form-organization-campaign-field-list.js +8 -49
  18. package/dist/dashboard/form-organization-campaign-field-list.mjs +8 -49
  19. package/dist/dashboard/form-organization-campaign-field-select.js +51 -5
  20. package/dist/dashboard/form-organization-campaign-field-select.mjs +51 -5
  21. package/dist/dashboard/form-organization-campaign-field-textarea.js +46 -8
  22. package/dist/dashboard/form-organization-campaign-field-textarea.mjs +46 -8
  23. package/dist/dashboard/form-organization-campaign-section.js +24 -4
  24. package/dist/dashboard/form-organization-campaign-section.mjs +24 -4
  25. package/dist/dashboard/form-organization-workflow.js +195 -56
  26. package/dist/dashboard/form-organization-workflow.mjs +191 -57
  27. package/dist/dashboard/item-row.js +92 -0
  28. package/dist/dashboard/item-row.mjs +63 -0
  29. package/dist/dashboard/lib/sms.js +3 -0
  30. package/dist/dashboard/lib/sms.mjs +2 -0
  31. package/dist/dashboard/order-sections.js +220 -0
  32. package/dist/dashboard/order-sections.mjs +185 -0
  33. package/dist/dashboard/preview.js +29 -2
  34. package/dist/dashboard/preview.mjs +28 -2
  35. package/dist/input-code.js +35 -53
  36. package/dist/input-code.mjs +26 -54
  37. package/dist/shared/button.js +1 -1
  38. package/dist/shared/button.mjs +1 -1
  39. package/dist/shared/lib/campaign.js +9 -3
  40. package/dist/shared/lib/campaign.mjs +7 -2
  41. package/dist/shared/lib/helpers.js +7 -0
  42. package/dist/shared/lib/helpers.mjs +7 -0
  43. package/package.json +19 -4
  44. package/types/bridge/form-subdomain-missions.d.ts +3 -1
  45. package/types/bridge/lib/url.d.ts +5 -4
  46. package/types/dashboard/answer-rows.d.ts +30 -0
  47. package/types/dashboard/card-order.d.ts +18 -3
  48. package/types/dashboard/form-organization-campaign-section.d.ts +2 -0
  49. package/types/dashboard/form-organization-workflow.d.ts +15 -0
  50. package/types/dashboard/item-row.d.ts +25 -0
  51. package/types/dashboard/order-sections.d.ts +36 -0
  52. package/types/shared/lib/helpers.d.ts +1 -1
@@ -33,23 +33,253 @@ module.exports = __toCommonJS(card_order_exports);
33
33
  var import_jsx_runtime = require("react/jsx-runtime");
34
34
  var import_drawbridge_utils = require("@drawbridge/drawbridge-utils");
35
35
  var import_card_data_item = __toESM(require("./card-data-item"));
36
+ var import_item_row = __toESM(require("./item-row"));
37
+ var import_answer_rows = require("./answer-rows");
36
38
  const className = "p-3 bg-white rounded shadow-[0_1px_3px_0_rgb(0_0_0/0.1),0_1px_2px_-1px_rgb(0_0_0/0.1)]";
37
39
  const attributions = {
38
40
  conversion: "A campaign link brought the buyer to checkout, so the conversion fee applies.",
39
41
  redemption: "The buyer used one of your discount codes, so no fee applies."
40
42
  };
43
+ const date = (value) => value ? (0, import_drawbridge_utils.formatDateString)({
44
+ date: value,
45
+ options: {
46
+ day: "numeric",
47
+ month: "short",
48
+ year: "numeric"
49
+ }
50
+ }) : "\u2014";
51
+ const Item = ({ label, value }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
52
+ import_card_data_item.default,
53
+ {
54
+ ...{
55
+ className: ["flex flex-col min-w-0", className].join(" "),
56
+ classNameSlotLeft: "text-sm disabled",
57
+ classNameSlotRight: "w-full break-words",
58
+ label,
59
+ value: value || "\u2014"
60
+ }
61
+ }
62
+ );
63
+ const lineSummary = ({ code, price, quantity = 0, variantTitle }) => [
64
+ variantTitle,
65
+ typeof price === "number" ? (0, import_drawbridge_utils.formatNumber)(quantity) + " \xD7 " + (0, import_drawbridge_utils.formatCurrency)({ code, value: price }) : "Quantity " + (0, import_drawbridge_utils.formatNumber)(quantity)
66
+ ].filter(Boolean).join(" \xB7 ");
67
+ const Lines = ({ code, label, lines, untitled }) => lines.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
68
+ "div",
69
+ {
70
+ ...{
71
+ className: "space-y-2"
72
+ },
73
+ children: [
74
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
75
+ "p",
76
+ {
77
+ ...{
78
+ className: "text-sm disabled"
79
+ },
80
+ children: label
81
+ }
82
+ ),
83
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
84
+ "div",
85
+ {
86
+ ...{
87
+ className: "space-y-3"
88
+ },
89
+ children: lines.map((line, key) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
90
+ "div",
91
+ {
92
+ ...{
93
+ className
94
+ },
95
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
96
+ import_item_row.default,
97
+ {
98
+ ...{
99
+ image: line.image,
100
+ name: line.title || untitled,
101
+ summary: lineSummary({ code, ...line })
102
+ }
103
+ }
104
+ )
105
+ },
106
+ key
107
+ ))
108
+ }
109
+ )
110
+ ]
111
+ }
112
+ );
113
+ const statuses = {
114
+ canceled: "Canceled",
115
+ completed: "Completed",
116
+ open: "Open"
117
+ };
118
+ const StackedRows = ({ rows }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
119
+ "div",
120
+ {
121
+ ...{
122
+ className: "divide-y divide-gray"
123
+ },
124
+ children: rows.map(({ after, label, value }, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
125
+ "div",
126
+ {
127
+ ...{
128
+ className: "flex items-center gap-4 py-3 first:pt-0 last:pb-0"
129
+ },
130
+ children: [
131
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
132
+ import_card_data_item.default,
133
+ {
134
+ ...{
135
+ // CardDataItem is `w-full grow-0`: `flex-1` here would lose to
136
+ // that `grow-0` and leave the value no width at all.
137
+ className: "flex flex-col min-w-0",
138
+ classNameSlotLeft: "text-sm disabled",
139
+ classNameSlotRight: "break-words",
140
+ element: "div",
141
+ label,
142
+ value
143
+ }
144
+ }
145
+ ),
146
+ after
147
+ ]
148
+ },
149
+ label + index
150
+ ))
151
+ }
152
+ );
153
+ const Stacked = ({ rows, title }) => rows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
154
+ "div",
155
+ {
156
+ ...{
157
+ className: "space-y-3"
158
+ },
159
+ children: [
160
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
161
+ "p",
162
+ {
163
+ ...{
164
+ className: "text-sm text-gray-dark"
165
+ },
166
+ children: title
167
+ }
168
+ ),
169
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StackedRows, { ...{ rows } })
170
+ ]
171
+ }
172
+ );
173
+ const FormOrder = ({ answers, children, code, cta, fields = [], gross, lines, purchasedAt, status }) => {
174
+ const priced = lines.some((line) => typeof (line == null ? void 0 : line.price) === "number");
175
+ const rows = (0, import_answer_rows.answerRows)(fields.filter((item) => (item == null ? void 0 : item.slug) !== "list"), answers);
176
+ const details = [
177
+ {
178
+ label: "Date",
179
+ value: date(purchasedAt)
180
+ },
181
+ priced && {
182
+ label: "Estimated total",
183
+ value: (0, import_drawbridge_utils.formatCurrency)({ code, value: gross })
184
+ }
185
+ ].filter(Boolean);
186
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
187
+ "div",
188
+ {
189
+ ...{
190
+ className: "space-y-6"
191
+ },
192
+ children: [
193
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
194
+ StackedRows,
195
+ {
196
+ ...{
197
+ rows: [
198
+ {
199
+ after: cta || void 0,
200
+ label: "Status",
201
+ value: statuses[status] || statuses.open
202
+ }
203
+ ]
204
+ }
205
+ }
206
+ ),
207
+ children,
208
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
209
+ Lines,
210
+ {
211
+ ...{
212
+ code,
213
+ label: "Items",
214
+ lines,
215
+ untitled: "Untitled item"
216
+ }
217
+ }
218
+ ),
219
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
220
+ Stacked,
221
+ {
222
+ ...{
223
+ rows: [...rows("lead"), ...rows("additional")],
224
+ title: "Answers"
225
+ }
226
+ }
227
+ ),
228
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
229
+ Stacked,
230
+ {
231
+ ...{
232
+ rows: rows("order"),
233
+ title: "Order"
234
+ }
235
+ }
236
+ ),
237
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
238
+ Stacked,
239
+ {
240
+ ...{
241
+ rows: details,
242
+ title: "Details"
243
+ }
244
+ }
245
+ )
246
+ ]
247
+ }
248
+ );
249
+ };
41
250
  const CardOrder = ({
251
+ answers,
252
+ children,
253
+ cta,
42
254
  currency,
43
255
  fee = 0,
256
+ fields,
44
257
  gross = 0,
45
258
  lines = [],
46
259
  net = 0,
47
260
  provider,
48
261
  purchasedAt,
49
262
  rate,
263
+ status,
50
264
  type
51
265
  }) => {
52
266
  const code = (currency || "usd").toUpperCase();
267
+ if (type === "form") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
268
+ FormOrder,
269
+ {
270
+ ...{
271
+ answers,
272
+ children,
273
+ code,
274
+ cta,
275
+ fields,
276
+ gross,
277
+ lines,
278
+ purchasedAt,
279
+ status
280
+ }
281
+ }
282
+ );
53
283
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
54
284
  "div",
55
285
  {
@@ -66,84 +296,63 @@ const CardOrder = ({
66
296
  },
67
297
  children: [
68
298
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
69
- import_card_data_item.default,
299
+ Item,
70
300
  {
71
301
  ...{
72
- className: ["flex flex-col", className].join(" "),
73
- classNameSlotLeft: "text-sm disabled",
74
302
  label: "Order number",
75
- value: (provider == null ? void 0 : provider.name) || "\u2014"
303
+ value: provider == null ? void 0 : provider.name
76
304
  }
77
305
  }
78
306
  ),
79
307
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
80
- import_card_data_item.default,
308
+ Item,
81
309
  {
82
310
  ...{
83
- className: ["flex flex-col", className].join(" "),
84
- classNameSlotLeft: "text-sm disabled",
85
311
  label: "Order ID",
86
- value: (provider == null ? void 0 : provider.id) || "\u2014"
312
+ value: provider == null ? void 0 : provider.id
87
313
  }
88
314
  }
89
315
  ),
90
316
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
91
- import_card_data_item.default,
317
+ Item,
92
318
  {
93
319
  ...{
94
- className: ["flex flex-col", className].join(" "),
95
- classNameSlotLeft: "text-sm disabled",
96
320
  label: "Date",
97
- value: purchasedAt ? (0, import_drawbridge_utils.formatDateString)({
98
- date: purchasedAt,
99
- options: {
100
- day: "numeric",
101
- month: "short",
102
- year: "numeric"
103
- }
104
- }) : "\u2014"
321
+ value: date(purchasedAt)
105
322
  }
106
323
  }
107
324
  ),
108
325
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
109
- import_card_data_item.default,
326
+ Item,
110
327
  {
111
328
  ...{
112
- className: ["flex flex-col", className].join(" "),
113
- classNameSlotLeft: "text-sm disabled",
114
329
  label: "Currency",
115
330
  value: code
116
331
  }
117
332
  }
118
333
  ),
119
334
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
120
- import_card_data_item.default,
335
+ Item,
121
336
  {
122
337
  ...{
123
- className: ["flex flex-col", className].join(" "),
124
- classNameSlotLeft: "text-sm disabled",
125
338
  label: "Gross",
126
339
  value: (0, import_drawbridge_utils.formatCurrency)({ code, value: gross })
127
340
  }
128
341
  }
129
342
  ),
130
343
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
131
- import_card_data_item.default,
344
+ Item,
132
345
  {
133
346
  ...{
134
- className: ["flex flex-col", className].join(" "),
135
- classNameSlotLeft: "text-sm disabled",
136
347
  label: "Net",
137
348
  value: (0, import_drawbridge_utils.formatCurrency)({ code, value: net })
138
349
  }
139
350
  }
140
351
  ),
141
352
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
142
- import_card_data_item.default,
353
+ Item,
143
354
  {
144
355
  ...{
145
- className: ["flex flex-col", className].join(" "),
146
- classNameSlotLeft: "text-sm disabled",
147
356
  label: "Fee",
148
357
  // A redemption is charged no fee, so it shows no rate ( rateCell in table.js ).
149
358
  value: (0, import_drawbridge_utils.formatCurrency)({ code, value: fee }) + (type !== "redemption" && (rate || rate === 0) ? " (" + rate + "%)" : "")
@@ -153,97 +362,16 @@ const CardOrder = ({
153
362
  ]
154
363
  }
155
364
  ),
156
- lines.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
157
- "div",
365
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
366
+ Lines,
158
367
  {
159
368
  ...{
160
- className: "space-y-2"
161
- },
162
- children: [
163
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
164
- "p",
165
- {
166
- ...{
167
- className: "text-sm disabled"
168
- },
169
- children: "Products"
170
- }
171
- ),
172
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
173
- "div",
174
- {
175
- ...{
176
- className: "space-y-3"
177
- },
178
- children: lines.map(({ price = 0, quantity = 0, title, variantTitle }, key) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
179
- "div",
180
- {
181
- ...{
182
- className: ["space-y-3", className].join(" ")
183
- },
184
- children: [
185
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
186
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: title || "Untitled product" }),
187
- variantTitle && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
188
- "p",
189
- {
190
- ...{
191
- className: "text-sm text-gray-dark"
192
- },
193
- children: variantTitle
194
- }
195
- )
196
- ] }),
197
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
198
- "div",
199
- {
200
- ...{
201
- className: "grid grid-cols-3 gap-6"
202
- },
203
- children: [
204
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
205
- import_card_data_item.default,
206
- {
207
- ...{
208
- className: "flex flex-col",
209
- classNameSlotLeft: "text-sm disabled",
210
- label: "Quantity",
211
- value: (0, import_drawbridge_utils.formatNumber)(quantity)
212
- }
213
- }
214
- ),
215
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
216
- import_card_data_item.default,
217
- {
218
- ...{
219
- className: "flex flex-col",
220
- classNameSlotLeft: "text-sm disabled",
221
- label: "Price",
222
- value: (0, import_drawbridge_utils.formatCurrency)({ code, value: price })
223
- }
224
- }
225
- ),
226
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
227
- import_card_data_item.default,
228
- {
229
- ...{
230
- className: "flex flex-col",
231
- classNameSlotLeft: "text-sm disabled",
232
- label: "Total",
233
- value: (0, import_drawbridge_utils.formatCurrency)({ code, value: price * quantity })
234
- }
235
- }
236
- )
237
- ]
238
- }
239
- )
240
- ]
241
- },
242
- key
243
- ))
244
- }
245
- )
246
- ]
369
+ code,
370
+ label: "Products",
371
+ // A store line always has a price.
372
+ lines: lines.map((line) => ({ ...line, price: line.price || 0 })),
373
+ untitled: "Untitled product"
374
+ }
247
375
  }
248
376
  )
249
377
  ]