@drawbridge/components 0.1.15 → 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 (32) hide show
  1. package/dist/bridge/lib/url.js +3 -3
  2. package/dist/bridge/lib/url.mjs +3 -3
  3. package/dist/bridge/share-button.js +12 -2
  4. package/dist/bridge/share-button.mjs +12 -2
  5. package/dist/bridge/template-layout.js +1 -1
  6. package/dist/bridge/template-layout.mjs +1 -1
  7. package/dist/dashboard/answer-rows.js +77 -0
  8. package/dist/dashboard/answer-rows.mjs +41 -0
  9. package/dist/dashboard/card-order.js +186 -243
  10. package/dist/dashboard/card-order.mjs +186 -243
  11. package/dist/dashboard/form-organization-campaign-field-list.js +8 -49
  12. package/dist/dashboard/form-organization-campaign-field-list.mjs +8 -49
  13. package/dist/dashboard/form-organization-workflow.js +70 -120
  14. package/dist/dashboard/form-organization-workflow.mjs +68 -120
  15. package/dist/dashboard/item-row.js +92 -0
  16. package/dist/dashboard/item-row.mjs +63 -0
  17. package/dist/dashboard/lib/sms.js +3 -0
  18. package/dist/dashboard/lib/sms.mjs +2 -0
  19. package/dist/dashboard/order-sections.js +220 -0
  20. package/dist/dashboard/order-sections.mjs +185 -0
  21. package/dist/dashboard/preview.js +29 -2
  22. package/dist/dashboard/preview.mjs +28 -2
  23. package/dist/shared/lib/helpers.js +7 -0
  24. package/dist/shared/lib/helpers.mjs +7 -0
  25. package/package.json +19 -4
  26. package/types/bridge/lib/url.d.ts +5 -4
  27. package/types/dashboard/answer-rows.d.ts +30 -0
  28. package/types/dashboard/card-order.d.ts +16 -14
  29. package/types/dashboard/form-organization-workflow.d.ts +2 -0
  30. package/types/dashboard/item-row.d.ts +25 -0
  31. package/types/dashboard/order-sections.d.ts +36 -0
  32. package/types/shared/lib/helpers.d.ts +1 -1
@@ -1,6 +1,8 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { formatCurrency, formatDateString, formatNumber } from "@drawbridge/drawbridge-utils";
3
3
  import CardDataItem from "./card-data-item.mjs";
4
+ import ItemRow from "./item-row.mjs";
5
+ import { answerRows } from "./answer-rows.mjs";
4
6
  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)]";
5
7
  const attributions = {
6
8
  conversion: "A campaign link brought the buyer to checkout, so the conversion fee applies.",
@@ -26,8 +28,129 @@ const Item = ({ label, value }) => /* @__PURE__ */ jsx(
26
28
  }
27
29
  }
28
30
  );
29
- const FormOrder = ({ code, customer, gross, lines, note, pickup, purchasedAt }) => {
31
+ const lineSummary = ({ code, price, quantity = 0, variantTitle }) => [
32
+ variantTitle,
33
+ typeof price === "number" ? formatNumber(quantity) + " \xD7 " + formatCurrency({ code, value: price }) : "Quantity " + formatNumber(quantity)
34
+ ].filter(Boolean).join(" \xB7 ");
35
+ const Lines = ({ code, label, lines, untitled }) => lines.length > 0 && /* @__PURE__ */ jsxs(
36
+ "div",
37
+ {
38
+ ...{
39
+ className: "space-y-2"
40
+ },
41
+ children: [
42
+ /* @__PURE__ */ jsx(
43
+ "p",
44
+ {
45
+ ...{
46
+ className: "text-sm disabled"
47
+ },
48
+ children: label
49
+ }
50
+ ),
51
+ /* @__PURE__ */ jsx(
52
+ "div",
53
+ {
54
+ ...{
55
+ className: "space-y-3"
56
+ },
57
+ children: lines.map((line, key) => /* @__PURE__ */ jsx(
58
+ "div",
59
+ {
60
+ ...{
61
+ className
62
+ },
63
+ children: /* @__PURE__ */ jsx(
64
+ ItemRow,
65
+ {
66
+ ...{
67
+ image: line.image,
68
+ name: line.title || untitled,
69
+ summary: lineSummary({ code, ...line })
70
+ }
71
+ }
72
+ )
73
+ },
74
+ key
75
+ ))
76
+ }
77
+ )
78
+ ]
79
+ }
80
+ );
81
+ const statuses = {
82
+ canceled: "Canceled",
83
+ completed: "Completed",
84
+ open: "Open"
85
+ };
86
+ const StackedRows = ({ rows }) => /* @__PURE__ */ jsx(
87
+ "div",
88
+ {
89
+ ...{
90
+ className: "divide-y divide-gray"
91
+ },
92
+ children: rows.map(({ after, label, value }, index) => /* @__PURE__ */ jsxs(
93
+ "div",
94
+ {
95
+ ...{
96
+ className: "flex items-center gap-4 py-3 first:pt-0 last:pb-0"
97
+ },
98
+ children: [
99
+ /* @__PURE__ */ jsx(
100
+ CardDataItem,
101
+ {
102
+ ...{
103
+ // CardDataItem is `w-full grow-0`: `flex-1` here would lose to
104
+ // that `grow-0` and leave the value no width at all.
105
+ className: "flex flex-col min-w-0",
106
+ classNameSlotLeft: "text-sm disabled",
107
+ classNameSlotRight: "break-words",
108
+ element: "div",
109
+ label,
110
+ value
111
+ }
112
+ }
113
+ ),
114
+ after
115
+ ]
116
+ },
117
+ label + index
118
+ ))
119
+ }
120
+ );
121
+ const Stacked = ({ rows, title }) => rows.length > 0 && /* @__PURE__ */ jsxs(
122
+ "div",
123
+ {
124
+ ...{
125
+ className: "space-y-3"
126
+ },
127
+ children: [
128
+ /* @__PURE__ */ jsx(
129
+ "p",
130
+ {
131
+ ...{
132
+ className: "text-sm text-gray-dark"
133
+ },
134
+ children: title
135
+ }
136
+ ),
137
+ /* @__PURE__ */ jsx(StackedRows, { ...{ rows } })
138
+ ]
139
+ }
140
+ );
141
+ const FormOrder = ({ answers, children, code, cta, fields = [], gross, lines, purchasedAt, status }) => {
30
142
  const priced = lines.some((line) => typeof (line == null ? void 0 : line.price) === "number");
143
+ const rows = answerRows(fields.filter((item) => (item == null ? void 0 : item.slug) !== "list"), answers);
144
+ const details = [
145
+ {
146
+ label: "Date",
147
+ value: date(purchasedAt)
148
+ },
149
+ priced && {
150
+ label: "Estimated total",
151
+ value: formatCurrency({ code, value: gross })
152
+ }
153
+ ].filter(Boolean);
31
154
  return /* @__PURE__ */ jsxs(
32
155
  "div",
33
156
  {
@@ -35,160 +158,57 @@ const FormOrder = ({ code, customer, gross, lines, note, pickup, purchasedAt })
35
158
  className: "space-y-6"
36
159
  },
37
160
  children: [
38
- /* @__PURE__ */ jsx("p", { children: "Placed on your entry form. No payment was taken." }),
39
- /* @__PURE__ */ jsxs(
40
- "div",
161
+ /* @__PURE__ */ jsx(
162
+ StackedRows,
41
163
  {
42
164
  ...{
43
- className: "grid grid-cols-2 gap-6 sm:grid-cols-3"
44
- },
45
- children: [
46
- /* @__PURE__ */ jsx(
47
- Item,
165
+ rows: [
48
166
  {
49
- ...{
50
- label: "Customer",
51
- value: [customer == null ? void 0 : customer.firstName, customer == null ? void 0 : customer.lastName].filter(Boolean).join(" ")
52
- }
53
- }
54
- ),
55
- /* @__PURE__ */ jsx(
56
- Item,
57
- {
58
- ...{
59
- label: "Email",
60
- value: customer == null ? void 0 : customer.email
61
- }
62
- }
63
- ),
64
- /* @__PURE__ */ jsx(
65
- Item,
66
- {
67
- ...{
68
- label: "Phone",
69
- value: customer == null ? void 0 : customer.phone
70
- }
167
+ after: cta || void 0,
168
+ label: "Status",
169
+ value: statuses[status] || statuses.open
71
170
  }
72
- ),
73
- /* @__PURE__ */ jsx(
74
- Item,
75
- {
76
- ...{
77
- label: "Date",
78
- value: date(purchasedAt)
79
- }
80
- }
81
- ),
82
- /* @__PURE__ */ jsx(
83
- Item,
84
- {
85
- ...{
86
- label: "Pickup",
87
- value: pickup
88
- }
89
- }
90
- ),
91
- /* @__PURE__ */ jsx(
92
- Item,
93
- {
94
- ...{
95
- label: "Note",
96
- value: note
97
- }
98
- }
99
- ),
100
- priced && /* @__PURE__ */ jsx(
101
- Item,
102
- {
103
- ...{
104
- label: "Estimated total",
105
- value: formatCurrency({ code, value: gross })
106
- }
107
- }
108
- )
109
- ]
171
+ ]
172
+ }
110
173
  }
111
174
  ),
112
- lines.length > 0 && /* @__PURE__ */ jsxs(
113
- "div",
175
+ children,
176
+ /* @__PURE__ */ jsx(
177
+ Lines,
114
178
  {
115
179
  ...{
116
- className: "space-y-2"
117
- },
118
- children: [
119
- /* @__PURE__ */ jsx(
120
- "p",
121
- {
122
- ...{
123
- className: "text-sm disabled"
124
- },
125
- children: "Items"
126
- }
127
- ),
128
- /* @__PURE__ */ jsx(
129
- "div",
130
- {
131
- ...{
132
- className: "space-y-3"
133
- },
134
- children: lines.map(({ price, quantity = 0, title }, key) => /* @__PURE__ */ jsxs(
135
- "div",
136
- {
137
- ...{
138
- className: ["space-y-3", className].join(" ")
139
- },
140
- children: [
141
- /* @__PURE__ */ jsx("p", { children: title || "Untitled item" }),
142
- /* @__PURE__ */ jsxs(
143
- "div",
144
- {
145
- ...{
146
- className: "grid grid-cols-3 gap-6"
147
- },
148
- children: [
149
- /* @__PURE__ */ jsx(
150
- CardDataItem,
151
- {
152
- ...{
153
- className: "flex flex-col",
154
- classNameSlotLeft: "text-sm disabled",
155
- label: "Quantity",
156
- value: formatNumber(quantity)
157
- }
158
- }
159
- ),
160
- typeof price === "number" && /* @__PURE__ */ jsx(
161
- CardDataItem,
162
- {
163
- ...{
164
- className: "flex flex-col",
165
- classNameSlotLeft: "text-sm disabled",
166
- label: "Price",
167
- value: formatCurrency({ code, value: price })
168
- }
169
- }
170
- ),
171
- typeof price === "number" && /* @__PURE__ */ jsx(
172
- CardDataItem,
173
- {
174
- ...{
175
- className: "flex flex-col",
176
- classNameSlotLeft: "text-sm disabled",
177
- label: "Total",
178
- value: formatCurrency({ code, value: price * quantity })
179
- }
180
- }
181
- )
182
- ]
183
- }
184
- )
185
- ]
186
- },
187
- key
188
- ))
189
- }
190
- )
191
- ]
180
+ code,
181
+ label: "Items",
182
+ lines,
183
+ untitled: "Untitled item"
184
+ }
185
+ }
186
+ ),
187
+ /* @__PURE__ */ jsx(
188
+ Stacked,
189
+ {
190
+ ...{
191
+ rows: [...rows("lead"), ...rows("additional")],
192
+ title: "Answers"
193
+ }
194
+ }
195
+ ),
196
+ /* @__PURE__ */ jsx(
197
+ Stacked,
198
+ {
199
+ ...{
200
+ rows: rows("order"),
201
+ title: "Order"
202
+ }
203
+ }
204
+ ),
205
+ /* @__PURE__ */ jsx(
206
+ Stacked,
207
+ {
208
+ ...{
209
+ rows: details,
210
+ title: "Details"
211
+ }
192
212
  }
193
213
  )
194
214
  ]
@@ -196,17 +216,19 @@ const FormOrder = ({ code, customer, gross, lines, note, pickup, purchasedAt })
196
216
  );
197
217
  };
198
218
  const CardOrder = ({
219
+ answers,
220
+ children,
221
+ cta,
199
222
  currency,
200
- customer,
201
223
  fee = 0,
224
+ fields,
202
225
  gross = 0,
203
226
  lines = [],
204
227
  net = 0,
205
- note,
206
- pickup,
207
228
  provider,
208
229
  purchasedAt,
209
230
  rate,
231
+ status,
210
232
  type
211
233
  }) => {
212
234
  const code = (currency || "usd").toUpperCase();
@@ -214,13 +236,15 @@ const CardOrder = ({
214
236
  FormOrder,
215
237
  {
216
238
  ...{
239
+ answers,
240
+ children,
217
241
  code,
218
- customer,
242
+ cta,
243
+ fields,
219
244
  gross,
220
245
  lines,
221
- note,
222
- pickup,
223
- purchasedAt
246
+ purchasedAt,
247
+ status
224
248
  }
225
249
  }
226
250
  );
@@ -306,97 +330,16 @@ const CardOrder = ({
306
330
  ]
307
331
  }
308
332
  ),
309
- lines.length > 0 && /* @__PURE__ */ jsxs(
310
- "div",
333
+ /* @__PURE__ */ jsx(
334
+ Lines,
311
335
  {
312
336
  ...{
313
- className: "space-y-2"
314
- },
315
- children: [
316
- /* @__PURE__ */ jsx(
317
- "p",
318
- {
319
- ...{
320
- className: "text-sm disabled"
321
- },
322
- children: "Products"
323
- }
324
- ),
325
- /* @__PURE__ */ jsx(
326
- "div",
327
- {
328
- ...{
329
- className: "space-y-3"
330
- },
331
- children: lines.map(({ price = 0, quantity = 0, title, variantTitle }, key) => /* @__PURE__ */ jsxs(
332
- "div",
333
- {
334
- ...{
335
- className: ["space-y-3", className].join(" ")
336
- },
337
- children: [
338
- /* @__PURE__ */ jsxs("div", { children: [
339
- /* @__PURE__ */ jsx("p", { children: title || "Untitled product" }),
340
- variantTitle && /* @__PURE__ */ jsx(
341
- "p",
342
- {
343
- ...{
344
- className: "text-sm text-gray-dark"
345
- },
346
- children: variantTitle
347
- }
348
- )
349
- ] }),
350
- /* @__PURE__ */ jsxs(
351
- "div",
352
- {
353
- ...{
354
- className: "grid grid-cols-3 gap-6"
355
- },
356
- children: [
357
- /* @__PURE__ */ jsx(
358
- CardDataItem,
359
- {
360
- ...{
361
- className: "flex flex-col",
362
- classNameSlotLeft: "text-sm disabled",
363
- label: "Quantity",
364
- value: formatNumber(quantity)
365
- }
366
- }
367
- ),
368
- /* @__PURE__ */ jsx(
369
- CardDataItem,
370
- {
371
- ...{
372
- className: "flex flex-col",
373
- classNameSlotLeft: "text-sm disabled",
374
- label: "Price",
375
- value: formatCurrency({ code, value: price })
376
- }
377
- }
378
- ),
379
- /* @__PURE__ */ jsx(
380
- CardDataItem,
381
- {
382
- ...{
383
- className: "flex flex-col",
384
- classNameSlotLeft: "text-sm disabled",
385
- label: "Total",
386
- value: formatCurrency({ code, value: price * quantity })
387
- }
388
- }
389
- )
390
- ]
391
- }
392
- )
393
- ]
394
- },
395
- key
396
- ))
397
- }
398
- )
399
- ]
337
+ code,
338
+ label: "Products",
339
+ // A store line always has a price.
340
+ lines: lines.map((line) => ({ ...line, price: line.price || 0 })),
341
+ untitled: "Untitled product"
342
+ }
400
343
  }
401
344
  )
402
345
  ]
@@ -44,7 +44,7 @@ var import_input_number = __toESM(require("../input-number"));
44
44
  var import_input_file = __toESM(require("./input-file"));
45
45
  var import_input_array = require("./input-array");
46
46
  var import_dropdown = __toESM(require("./dropdown"));
47
- var import_card_asset = __toESM(require("../shared/card-asset"));
47
+ var import_item_row = __toESM(require("./item-row"));
48
48
  var import_ellipsis = __toESM(require("../icons/ellipsis"));
49
49
  var import_arrow_left = __toESM(require("../icons/arrow-left"));
50
50
  var import_button = __toESM(require("../shared/button"));
@@ -269,58 +269,17 @@ const FormOrganizationCampaignFieldList = ({
269
269
  }
270
270
  },
271
271
  children: ({ handle, index }) => {
272
- var _a2;
273
272
  const row = (items == null ? void 0 : items[index]) || {};
274
- const summary = (0, import_item_list.itemSummary)(row, prices, currency);
275
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
276
- "div",
273
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
274
+ import_item_row.default,
277
275
  {
278
276
  ...{
279
- className: "flex items-center min-w-0 flex-1 gap-3"
280
- },
281
- children: [
277
+ description: row.description,
282
278
  handle,
283
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
284
- import_card_asset.default,
285
- {
286
- ...{
287
- asset: row.image || null,
288
- className: "w-10 h-10",
289
- classNameContainer: "bg-gray-light border border-gray",
290
- sizes: "40px",
291
- title: row.description || ((_a2 = row.image) == null ? void 0 : _a2.filename)
292
- }
293
- }
294
- ),
295
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
296
- "span",
297
- {
298
- ...{
299
- className: "flex flex-col min-w-0"
300
- },
301
- children: [
302
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
303
- "span",
304
- {
305
- ...{
306
- className: "truncate"
307
- },
308
- children: row.name || "Untitled item"
309
- }
310
- ),
311
- summary && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
312
- "span",
313
- {
314
- ...{
315
- className: "text-sm text-gray-dark truncate"
316
- },
317
- children: summary
318
- }
319
- )
320
- ]
321
- }
322
- )
323
- ]
279
+ image: row.image,
280
+ name: row.name || "Untitled item",
281
+ summary: (0, import_item_list.itemSummary)(row, prices, currency)
282
+ }
324
283
  }
325
284
  );
326
285
  }
@@ -12,7 +12,7 @@ import InputNumber from "../input-number.mjs";
12
12
  import InputFile from "./input-file.mjs";
13
13
  import { InputArrayButton, InputArraySortable } from "./input-array.mjs";
14
14
  import Dropdown from "./dropdown.mjs";
15
- import CardAsset from "../shared/card-asset.mjs";
15
+ import ItemRow from "./item-row.mjs";
16
16
  import Ellipsis from "../icons/ellipsis.mjs";
17
17
  import ArrowLeft from "../icons/arrow-left.mjs";
18
18
  import Button from "../shared/button.mjs";
@@ -237,58 +237,17 @@ const FormOrganizationCampaignFieldList = ({
237
237
  }
238
238
  },
239
239
  children: ({ handle, index }) => {
240
- var _a2;
241
240
  const row = (items == null ? void 0 : items[index]) || {};
242
- const summary = itemSummary(row, prices, currency);
243
- return /* @__PURE__ */ jsxs(
244
- "div",
241
+ return /* @__PURE__ */ jsx(
242
+ ItemRow,
245
243
  {
246
244
  ...{
247
- className: "flex items-center min-w-0 flex-1 gap-3"
248
- },
249
- children: [
245
+ description: row.description,
250
246
  handle,
251
- /* @__PURE__ */ jsx(
252
- CardAsset,
253
- {
254
- ...{
255
- asset: row.image || null,
256
- className: "w-10 h-10",
257
- classNameContainer: "bg-gray-light border border-gray",
258
- sizes: "40px",
259
- title: row.description || ((_a2 = row.image) == null ? void 0 : _a2.filename)
260
- }
261
- }
262
- ),
263
- /* @__PURE__ */ jsxs(
264
- "span",
265
- {
266
- ...{
267
- className: "flex flex-col min-w-0"
268
- },
269
- children: [
270
- /* @__PURE__ */ jsx(
271
- "span",
272
- {
273
- ...{
274
- className: "truncate"
275
- },
276
- children: row.name || "Untitled item"
277
- }
278
- ),
279
- summary && /* @__PURE__ */ jsx(
280
- "span",
281
- {
282
- ...{
283
- className: "text-sm text-gray-dark truncate"
284
- },
285
- children: summary
286
- }
287
- )
288
- ]
289
- }
290
- )
291
- ]
247
+ image: row.image,
248
+ name: row.name || "Untitled item",
249
+ summary: itemSummary(row, prices, currency)
250
+ }
292
251
  }
293
252
  );
294
253
  }