@drawbridge/components 0.1.15 → 0.1.17

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 (49) hide show
  1. package/dist/bridge/form-subdomain-missions.js +43 -34
  2. package/dist/bridge/form-subdomain-missions.mjs +43 -34
  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-order.js +186 -243
  12. package/dist/dashboard/card-order.mjs +186 -243
  13. package/dist/dashboard/form-organization-campaign-agreement.js +2 -2
  14. package/dist/dashboard/form-organization-campaign-agreement.mjs +2 -2
  15. package/dist/dashboard/form-organization-campaign-field-list.js +8 -49
  16. package/dist/dashboard/form-organization-campaign-field-list.mjs +8 -49
  17. package/dist/dashboard/form-organization-workflow.js +588 -157
  18. package/dist/dashboard/form-organization-workflow.mjs +578 -157
  19. package/dist/dashboard/form-otc.js +7 -4
  20. package/dist/dashboard/form-otc.mjs +8 -5
  21. package/dist/dashboard/input-editor.js +46 -10
  22. package/dist/dashboard/input-editor.mjs +44 -9
  23. package/dist/dashboard/item-row.js +92 -0
  24. package/dist/dashboard/item-row.mjs +63 -0
  25. package/dist/dashboard/lib/sms.js +3 -0
  26. package/dist/dashboard/lib/sms.mjs +2 -0
  27. package/dist/dashboard/order-sections.js +231 -0
  28. package/dist/dashboard/order-sections.mjs +196 -0
  29. package/dist/dashboard/preview.js +29 -2
  30. package/dist/dashboard/preview.mjs +28 -2
  31. package/dist/dashboard/steps.js +5 -0
  32. package/dist/dashboard/steps.mjs +5 -0
  33. package/dist/dashboard/template-socket.js +6 -0
  34. package/dist/dashboard/template-socket.mjs +6 -0
  35. package/dist/input-code.js +2 -8
  36. package/dist/input-code.mjs +2 -8
  37. package/dist/shared/lib/helpers.js +7 -0
  38. package/dist/shared/lib/helpers.mjs +7 -0
  39. package/package.json +19 -4
  40. package/types/bridge/lib/url.d.ts +5 -4
  41. package/types/dashboard/answer-rows.d.ts +30 -0
  42. package/types/dashboard/card-order.d.ts +16 -14
  43. package/types/dashboard/form-organization-workflow.d.ts +46 -0
  44. package/types/dashboard/input-editor.d.ts +7 -1
  45. package/types/dashboard/item-row.d.ts +25 -0
  46. package/types/dashboard/order-sections.d.ts +36 -0
  47. package/types/dashboard/steps.d.ts +2 -0
  48. package/types/input-code.d.ts +0 -2
  49. package/types/shared/lib/helpers.d.ts +1 -1
@@ -33,6 +33,8 @@ 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.",
@@ -58,8 +60,129 @@ const Item = ({ label, value }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
58
60
  }
59
61
  }
60
62
  );
61
- const FormOrder = ({ code, customer, gross, lines, note, pickup, purchasedAt }) => {
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 }) => {
62
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);
63
186
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
64
187
  "div",
65
188
  {
@@ -67,160 +190,57 @@ const FormOrder = ({ code, customer, gross, lines, note, pickup, purchasedAt })
67
190
  className: "space-y-6"
68
191
  },
69
192
  children: [
70
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Placed on your entry form. No payment was taken." }),
71
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
72
- "div",
193
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
194
+ StackedRows,
73
195
  {
74
196
  ...{
75
- className: "grid grid-cols-2 gap-6 sm:grid-cols-3"
76
- },
77
- children: [
78
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
79
- Item,
197
+ rows: [
80
198
  {
81
- ...{
82
- label: "Customer",
83
- value: [customer == null ? void 0 : customer.firstName, customer == null ? void 0 : customer.lastName].filter(Boolean).join(" ")
84
- }
85
- }
86
- ),
87
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
88
- Item,
89
- {
90
- ...{
91
- label: "Email",
92
- value: customer == null ? void 0 : customer.email
93
- }
94
- }
95
- ),
96
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
97
- Item,
98
- {
99
- ...{
100
- label: "Phone",
101
- value: customer == null ? void 0 : customer.phone
102
- }
199
+ after: cta || void 0,
200
+ label: "Status",
201
+ value: statuses[status] || statuses.open
103
202
  }
104
- ),
105
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
106
- Item,
107
- {
108
- ...{
109
- label: "Date",
110
- value: date(purchasedAt)
111
- }
112
- }
113
- ),
114
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
115
- Item,
116
- {
117
- ...{
118
- label: "Pickup",
119
- value: pickup
120
- }
121
- }
122
- ),
123
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
124
- Item,
125
- {
126
- ...{
127
- label: "Note",
128
- value: note
129
- }
130
- }
131
- ),
132
- priced && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
133
- Item,
134
- {
135
- ...{
136
- label: "Estimated total",
137
- value: (0, import_drawbridge_utils.formatCurrency)({ code, value: gross })
138
- }
139
- }
140
- )
141
- ]
203
+ ]
204
+ }
142
205
  }
143
206
  ),
144
- lines.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
145
- "div",
207
+ children,
208
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
209
+ Lines,
146
210
  {
147
211
  ...{
148
- className: "space-y-2"
149
- },
150
- children: [
151
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
152
- "p",
153
- {
154
- ...{
155
- className: "text-sm disabled"
156
- },
157
- children: "Items"
158
- }
159
- ),
160
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
161
- "div",
162
- {
163
- ...{
164
- className: "space-y-3"
165
- },
166
- children: lines.map(({ price, quantity = 0, title }, key) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
167
- "div",
168
- {
169
- ...{
170
- className: ["space-y-3", className].join(" ")
171
- },
172
- children: [
173
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: title || "Untitled item" }),
174
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
175
- "div",
176
- {
177
- ...{
178
- className: "grid grid-cols-3 gap-6"
179
- },
180
- children: [
181
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
182
- import_card_data_item.default,
183
- {
184
- ...{
185
- className: "flex flex-col",
186
- classNameSlotLeft: "text-sm disabled",
187
- label: "Quantity",
188
- value: (0, import_drawbridge_utils.formatNumber)(quantity)
189
- }
190
- }
191
- ),
192
- typeof price === "number" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
193
- import_card_data_item.default,
194
- {
195
- ...{
196
- className: "flex flex-col",
197
- classNameSlotLeft: "text-sm disabled",
198
- label: "Price",
199
- value: (0, import_drawbridge_utils.formatCurrency)({ code, value: price })
200
- }
201
- }
202
- ),
203
- typeof price === "number" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
204
- import_card_data_item.default,
205
- {
206
- ...{
207
- className: "flex flex-col",
208
- classNameSlotLeft: "text-sm disabled",
209
- label: "Total",
210
- value: (0, import_drawbridge_utils.formatCurrency)({ code, value: price * quantity })
211
- }
212
- }
213
- )
214
- ]
215
- }
216
- )
217
- ]
218
- },
219
- key
220
- ))
221
- }
222
- )
223
- ]
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
+ }
224
244
  }
225
245
  )
226
246
  ]
@@ -228,17 +248,19 @@ const FormOrder = ({ code, customer, gross, lines, note, pickup, purchasedAt })
228
248
  );
229
249
  };
230
250
  const CardOrder = ({
251
+ answers,
252
+ children,
253
+ cta,
231
254
  currency,
232
- customer,
233
255
  fee = 0,
256
+ fields,
234
257
  gross = 0,
235
258
  lines = [],
236
259
  net = 0,
237
- note,
238
- pickup,
239
260
  provider,
240
261
  purchasedAt,
241
262
  rate,
263
+ status,
242
264
  type
243
265
  }) => {
244
266
  const code = (currency || "usd").toUpperCase();
@@ -246,13 +268,15 @@ const CardOrder = ({
246
268
  FormOrder,
247
269
  {
248
270
  ...{
271
+ answers,
272
+ children,
249
273
  code,
250
- customer,
274
+ cta,
275
+ fields,
251
276
  gross,
252
277
  lines,
253
- note,
254
- pickup,
255
- purchasedAt
278
+ purchasedAt,
279
+ status
256
280
  }
257
281
  }
258
282
  );
@@ -338,97 +362,16 @@ const CardOrder = ({
338
362
  ]
339
363
  }
340
364
  ),
341
- lines.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
342
- "div",
365
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
366
+ Lines,
343
367
  {
344
368
  ...{
345
- className: "space-y-2"
346
- },
347
- children: [
348
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
349
- "p",
350
- {
351
- ...{
352
- className: "text-sm disabled"
353
- },
354
- children: "Products"
355
- }
356
- ),
357
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
358
- "div",
359
- {
360
- ...{
361
- className: "space-y-3"
362
- },
363
- children: lines.map(({ price = 0, quantity = 0, title, variantTitle }, key) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
364
- "div",
365
- {
366
- ...{
367
- className: ["space-y-3", className].join(" ")
368
- },
369
- children: [
370
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
371
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: title || "Untitled product" }),
372
- variantTitle && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
373
- "p",
374
- {
375
- ...{
376
- className: "text-sm text-gray-dark"
377
- },
378
- children: variantTitle
379
- }
380
- )
381
- ] }),
382
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
383
- "div",
384
- {
385
- ...{
386
- className: "grid grid-cols-3 gap-6"
387
- },
388
- children: [
389
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
390
- import_card_data_item.default,
391
- {
392
- ...{
393
- className: "flex flex-col",
394
- classNameSlotLeft: "text-sm disabled",
395
- label: "Quantity",
396
- value: (0, import_drawbridge_utils.formatNumber)(quantity)
397
- }
398
- }
399
- ),
400
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
401
- import_card_data_item.default,
402
- {
403
- ...{
404
- className: "flex flex-col",
405
- classNameSlotLeft: "text-sm disabled",
406
- label: "Price",
407
- value: (0, import_drawbridge_utils.formatCurrency)({ code, value: price })
408
- }
409
- }
410
- ),
411
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
412
- import_card_data_item.default,
413
- {
414
- ...{
415
- className: "flex flex-col",
416
- classNameSlotLeft: "text-sm disabled",
417
- label: "Total",
418
- value: (0, import_drawbridge_utils.formatCurrency)({ code, value: price * quantity })
419
- }
420
- }
421
- )
422
- ]
423
- }
424
- )
425
- ]
426
- },
427
- key
428
- ))
429
- }
430
- )
431
- ]
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
+ }
432
375
  }
433
376
  )
434
377
  ]