@drawbridge/components 0.1.47 → 0.1.48

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 (114) hide show
  1. package/dist/bridge/cart-drawer.js +152 -0
  2. package/dist/bridge/cart-drawer.mjs +123 -0
  3. package/dist/bridge/fields.js +278 -0
  4. package/dist/bridge/fields.mjs +276 -1
  5. package/dist/bridge/form-subdomain-checkout.js +687 -0
  6. package/dist/bridge/form-subdomain-checkout.mjs +665 -0
  7. package/dist/bridge/form-subdomain-shop-modal.js +234 -274
  8. package/dist/bridge/form-subdomain-shop-modal.mjs +233 -275
  9. package/dist/bridge/form-subdomain.js +1 -0
  10. package/dist/bridge/form-subdomain.mjs +2 -1
  11. package/dist/bridge/lib/age-gate.js +12 -0
  12. package/dist/bridge/lib/age-gate.mjs +11 -0
  13. package/dist/bridge/lib/cart.js +79 -0
  14. package/dist/bridge/lib/cart.mjs +48 -0
  15. package/dist/bridge/lib/checkout-kit.js +2 -32
  16. package/dist/bridge/lib/checkout-kit.mjs +2 -32
  17. package/dist/bridge/product-tile.js +9 -6
  18. package/dist/bridge/product-tile.mjs +9 -6
  19. package/dist/bridge/template-layout.js +237 -122
  20. package/dist/bridge/template-layout.mjs +237 -122
  21. package/dist/bridge/template-modal.js +28 -73
  22. package/dist/bridge/template-modal.mjs +29 -74
  23. package/dist/dashboard/buttons-subscription.js +1 -1
  24. package/dist/dashboard/buttons-subscription.mjs +1 -1
  25. package/dist/dashboard/campaign-form.js +7 -2
  26. package/dist/dashboard/campaign-form.mjs +7 -2
  27. package/dist/dashboard/card-order.js +22 -4
  28. package/dist/dashboard/card-order.mjs +22 -4
  29. package/dist/dashboard/embed-stripe.js +145 -0
  30. package/dist/dashboard/embed-stripe.mjs +116 -0
  31. package/dist/dashboard/form-admin-provider.js +71 -17
  32. package/dist/dashboard/form-admin-provider.mjs +71 -17
  33. package/dist/dashboard/form-file-upload.js +3 -2
  34. package/dist/dashboard/form-file-upload.mjs +4 -3
  35. package/dist/dashboard/form-organization-campaign-advertisements.js +47 -6
  36. package/dist/dashboard/form-organization-campaign-advertisements.mjs +47 -6
  37. package/dist/dashboard/form-organization-campaign-field-birthday.js +193 -0
  38. package/dist/dashboard/form-organization-campaign-field-birthday.mjs +164 -0
  39. package/dist/dashboard/form-organization-campaign-field-rating.js +246 -0
  40. package/dist/dashboard/form-organization-campaign-field-rating.mjs +217 -0
  41. package/dist/dashboard/form-organization-campaign.js +82 -0
  42. package/dist/dashboard/form-organization-campaign.mjs +81 -0
  43. package/dist/dashboard/form-organization-connection.js +48 -6
  44. package/dist/dashboard/form-organization-connection.mjs +48 -7
  45. package/dist/dashboard/form-organization-product.js +1461 -0
  46. package/dist/dashboard/form-organization-product.mjs +1425 -0
  47. package/dist/dashboard/form-organization-workflow.js +72 -1
  48. package/dist/dashboard/form-organization-workflow.mjs +69 -1
  49. package/dist/dashboard/form-otc.js +4 -5
  50. package/dist/dashboard/form-otc.mjs +4 -5
  51. package/dist/dashboard/form-stripe.js +12 -5
  52. package/dist/dashboard/form-stripe.mjs +12 -5
  53. package/dist/dashboard/input-fields.js +11 -158
  54. package/dist/dashboard/input-fields.mjs +11 -158
  55. package/dist/dashboard/input-file.js +21 -4
  56. package/dist/dashboard/input-file.mjs +21 -4
  57. package/dist/dashboard/input-gallery.js +201 -0
  58. package/dist/dashboard/input-gallery.mjs +172 -0
  59. package/dist/dashboard/lib/connection-controls.js +5 -2
  60. package/dist/dashboard/lib/connection-controls.mjs +3 -1
  61. package/dist/dashboard/lib/form-page.js +1 -1
  62. package/dist/dashboard/lib/form-page.mjs +1 -1
  63. package/dist/dashboard/lib/products.js +169 -0
  64. package/dist/dashboard/lib/products.mjs +135 -0
  65. package/dist/dashboard/lib/settings-paths.js +35 -0
  66. package/dist/dashboard/lib/settings-paths.mjs +11 -0
  67. package/dist/dashboard/lib/uppy.js +10 -1
  68. package/dist/dashboard/lib/uppy.mjs +11 -2
  69. package/dist/dashboard/order-sections.js +456 -6
  70. package/dist/dashboard/order-sections.mjs +453 -7
  71. package/dist/dashboard/provider-ui.js +9 -7
  72. package/dist/dashboard/provider-ui.mjs +9 -7
  73. package/dist/dashboard/shipping-rates.js +404 -0
  74. package/dist/dashboard/shipping-rates.mjs +371 -0
  75. package/dist/dashboard/template-buyer.js +301 -0
  76. package/dist/dashboard/template-buyer.mjs +267 -0
  77. package/dist/input-checkbox.js +28 -10
  78. package/dist/input-checkbox.mjs +28 -10
  79. package/dist/product.js +96 -24
  80. package/dist/product.mjs +97 -25
  81. package/dist/shared/lib/helpers.js +54 -6
  82. package/dist/shared/lib/helpers.mjs +53 -8
  83. package/dist/shared/order-summary.js +139 -0
  84. package/dist/shared/order-summary.mjs +110 -0
  85. package/package.json +74 -4
  86. package/types/bridge/cart-drawer.d.ts +31 -0
  87. package/types/bridge/fields.d.ts +14 -2
  88. package/types/bridge/form-subdomain-checkout.d.ts +20 -0
  89. package/types/bridge/form-subdomain-shop-modal.d.ts +27 -3
  90. package/types/bridge/lib/age-gate.d.ts +5 -0
  91. package/types/bridge/lib/cart.d.ts +44 -0
  92. package/types/bridge/lib/checkout-kit.d.ts +2 -10
  93. package/types/dashboard/card-order.d.ts +6 -0
  94. package/types/dashboard/embed-stripe.d.ts +25 -0
  95. package/types/dashboard/form-admin-provider.d.ts +9 -2
  96. package/types/dashboard/form-file-upload.d.ts +2 -1
  97. package/types/dashboard/form-organization-campaign-advertisements.d.ts +3 -0
  98. package/types/dashboard/form-organization-campaign-field-birthday.d.ts +31 -0
  99. package/types/dashboard/form-organization-campaign-field-rating.d.ts +33 -0
  100. package/types/dashboard/form-organization-campaign.d.ts +3 -0
  101. package/types/dashboard/form-organization-connection.d.ts +11 -0
  102. package/types/dashboard/form-organization-product.d.ts +24 -0
  103. package/types/dashboard/form-otc.d.ts +5 -1
  104. package/types/dashboard/form-stripe.d.ts +3 -2
  105. package/types/dashboard/input-file.d.ts +2 -0
  106. package/types/dashboard/input-gallery.d.ts +14 -0
  107. package/types/dashboard/lib/products.d.ts +14 -0
  108. package/types/dashboard/lib/settings-paths.d.ts +5 -0
  109. package/types/dashboard/order-sections.d.ts +24 -1
  110. package/types/dashboard/shipping-rates.d.ts +26 -0
  111. package/types/dashboard/template-buyer.d.ts +50 -0
  112. package/types/input-checkbox.d.ts +2 -0
  113. package/types/shared/lib/helpers.d.ts +4 -0
  114. package/types/shared/order-summary.d.ts +19 -0
@@ -1,13 +1,16 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
2
3
  import InputGroup from "../input-group.mjs";
3
4
  import InputAnswer from "../input-answer.mjs";
5
+ import InputCheckbox from "../input-checkbox.mjs";
6
+ import Button from "../shared/button.mjs";
4
7
  import InputName from "../input-name.mjs";
5
8
  import InputSelect from "../input-select.mjs";
6
9
  import InputPhone from "../input-phone.mjs";
7
10
  import InputNumber from "../input-number.mjs";
8
11
  import InputText from "../input-text.mjs";
9
12
  import InputTextarea from "../input-textarea.mjs";
10
- import { headerStyle, textStyle } from "../styles.mjs";
13
+ import { buttonStyle, headerStyle, inputCheckboxStyle, textStyle } from "../styles.mjs";
11
14
  const starred = (field) => {
12
15
  var _a;
13
16
  return (field == null ? void 0 : field.label) && ((_a = field == null ? void 0 : field.attributes) == null ? void 0 : _a.required) !== false ? field.label + " *" : field == null ? void 0 : field.label;
@@ -225,6 +228,251 @@ const FieldTextarea = ({
225
228
  }
226
229
  );
227
230
  };
231
+ const birthdayValue = ({ day = "", month = "", year = "" } = {}) => !day && !month && !year ? "" : [year, month && String(month).padStart(2, "0"), day && String(day).padStart(2, "0")].join("-");
232
+ const birthdayInputs = (value) => {
233
+ const [year = "", month = "", day = ""] = typeof value === "string" && value ? value.split("-") : [];
234
+ const typed = (part) => /^\d+$/.test(part) ? String(Number(part)) : part;
235
+ return {
236
+ day: typed(day),
237
+ month: typed(month),
238
+ year
239
+ };
240
+ };
241
+ const FieldBirthday = ({
242
+ error,
243
+ field,
244
+ onChange = () => {
245
+ },
246
+ style,
247
+ value
248
+ }) => {
249
+ const [parts, setParts] = useState(() => birthdayInputs(value));
250
+ const box = (key, label) => /* @__PURE__ */ jsxs(
251
+ "div",
252
+ {
253
+ ...{
254
+ className: "space-y-2 w-full"
255
+ },
256
+ children: [
257
+ /* @__PURE__ */ jsx("p", { children: label }),
258
+ /* @__PURE__ */ jsx(
259
+ InputText,
260
+ {
261
+ ...{
262
+ "aria-label": ((field == null ? void 0 : field.label) ? field.label + ", " : "") + label.toLowerCase(),
263
+ inputMode: "numeric",
264
+ onChange: (text) => {
265
+ const next = {
266
+ ...parts,
267
+ [key]: text
268
+ };
269
+ setParts(next);
270
+ onChange(birthdayValue(next));
271
+ },
272
+ style,
273
+ value: parts[key] || ""
274
+ }
275
+ }
276
+ )
277
+ ]
278
+ },
279
+ key
280
+ );
281
+ return /* @__PURE__ */ jsx(
282
+ InputGroup,
283
+ {
284
+ ...{
285
+ error: error == null ? void 0 : error.message,
286
+ input: /* @__PURE__ */ jsxs(
287
+ "div",
288
+ {
289
+ ...{
290
+ className: "flex items-center space-x-4 w-full"
291
+ },
292
+ children: [
293
+ box("month", "Month"),
294
+ box("day", "Day"),
295
+ box("year", "Year")
296
+ ]
297
+ }
298
+ ),
299
+ label: starred(field),
300
+ style
301
+ }
302
+ }
303
+ );
304
+ };
305
+ const choiceRows = ({ field, picked, pick, round, style }) => {
306
+ var _a;
307
+ return /* @__PURE__ */ jsx(
308
+ "div",
309
+ {
310
+ ...{
311
+ className: "space-y-3",
312
+ role: round ? "radiogroup" : "group",
313
+ "aria-label": field == null ? void 0 : field.label
314
+ },
315
+ children: (((_a = field == null ? void 0 : field.settings) == null ? void 0 : _a.options) || []).map((item, index) => /* @__PURE__ */ jsx(
316
+ InputCheckbox,
317
+ {
318
+ ...{
319
+ label: item == null ? void 0 : item.option,
320
+ labelId: "choice-" + ((field == null ? void 0 : field.id) || "field") + "-" + index,
321
+ onChange: () => pick(item == null ? void 0 : item.option),
322
+ round,
323
+ style,
324
+ value: picked(item == null ? void 0 : item.option)
325
+ }
326
+ },
327
+ (item == null ? void 0 : item.id) || index
328
+ ))
329
+ }
330
+ );
331
+ };
332
+ const FieldRadio = ({
333
+ error,
334
+ field,
335
+ onChange = () => {
336
+ },
337
+ style,
338
+ value
339
+ }) => /* @__PURE__ */ jsx(
340
+ InputGroup,
341
+ {
342
+ ...{
343
+ error: error == null ? void 0 : error.message,
344
+ input: choiceRows({
345
+ field,
346
+ pick: (option) => onChange(option),
347
+ picked: (option) => Boolean(value) && value === option,
348
+ round: true,
349
+ style
350
+ }),
351
+ label: starred(field),
352
+ style
353
+ }
354
+ }
355
+ );
356
+ const tick = (options = [], value, option) => {
357
+ const ticked = Array.isArray(value) ? value : [];
358
+ const next = ticked.includes(option) ? ticked.filter((item) => item !== option) : [...ticked, option];
359
+ return (options || []).map((item) => item == null ? void 0 : item.option).filter((item) => next.includes(item));
360
+ };
361
+ const FieldCheckbox = ({
362
+ error,
363
+ field,
364
+ onChange = () => {
365
+ },
366
+ style,
367
+ value
368
+ }) => /* @__PURE__ */ jsx(
369
+ InputGroup,
370
+ {
371
+ ...{
372
+ error: error == null ? void 0 : error.message,
373
+ input: choiceRows({
374
+ field,
375
+ pick: (option) => {
376
+ var _a;
377
+ return onChange(tick((_a = field == null ? void 0 : field.settings) == null ? void 0 : _a.options, value, option));
378
+ },
379
+ picked: (option) => Array.isArray(value) && value.includes(option),
380
+ round: false,
381
+ style
382
+ }),
383
+ label: starred(field),
384
+ style
385
+ }
386
+ }
387
+ );
388
+ const FieldRating = ({
389
+ error,
390
+ field,
391
+ onChange = () => {
392
+ },
393
+ style,
394
+ value
395
+ }) => {
396
+ var _a, _b, _c;
397
+ const max = Number((_a = field == null ? void 0 : field.attributes) == null ? void 0 : _a.max) || 5;
398
+ const low = (_b = field == null ? void 0 : field.settings) == null ? void 0 : _b.low;
399
+ const high = (_c = field == null ? void 0 : field.settings) == null ? void 0 : _c.high;
400
+ return /* @__PURE__ */ jsx(
401
+ InputGroup,
402
+ {
403
+ ...{
404
+ error: error == null ? void 0 : error.message,
405
+ input: /* @__PURE__ */ jsxs(
406
+ "div",
407
+ {
408
+ ...{
409
+ className: "space-y-2 w-full"
410
+ },
411
+ children: [
412
+ /* @__PURE__ */ jsx(
413
+ "div",
414
+ {
415
+ ...{
416
+ "aria-label": field == null ? void 0 : field.label,
417
+ className: "grid w-full gap-1",
418
+ role: "group",
419
+ style: {
420
+ gridTemplateColumns: "repeat(" + max + ", minmax(0, 1fr))"
421
+ }
422
+ },
423
+ children: Array.from({ length: max }, (_, index) => index + 1).map((number) => /* @__PURE__ */ jsx(
424
+ Button,
425
+ {
426
+ ...{
427
+ "aria-pressed": Number(value) === number,
428
+ onClick: () => onChange(number),
429
+ variant: "link"
430
+ },
431
+ children: /* @__PURE__ */ jsx(
432
+ "span",
433
+ {
434
+ ...{
435
+ className: "flex items-center justify-center w-full h-10 border text-sm tabular-nums",
436
+ style: Number(value) === number ? buttonStyle(style) : inputCheckboxStyle(style)
437
+ },
438
+ children: number
439
+ }
440
+ )
441
+ },
442
+ number
443
+ ))
444
+ }
445
+ ),
446
+ (low || high) && /* @__PURE__ */ jsxs(
447
+ "div",
448
+ {
449
+ ...{
450
+ className: "flex justify-between gap-4 text-xs",
451
+ ...style && { style: textStyle(style) }
452
+ },
453
+ children: [
454
+ /* @__PURE__ */ jsx("span", { children: low }),
455
+ /* @__PURE__ */ jsx(
456
+ "span",
457
+ {
458
+ ...{
459
+ className: "text-right"
460
+ },
461
+ children: high
462
+ }
463
+ )
464
+ ]
465
+ }
466
+ )
467
+ ]
468
+ }
469
+ ),
470
+ label: starred(field),
471
+ style
472
+ }
473
+ }
474
+ );
475
+ };
228
476
  const FieldSection = ({
229
477
  field,
230
478
  style
@@ -289,6 +537,18 @@ const FieldSkill = ({
289
537
  }
290
538
  );
291
539
  const components = {
540
+ birthday: (props) => /* @__PURE__ */ jsx(
541
+ FieldBirthday,
542
+ {
543
+ ...props
544
+ }
545
+ ),
546
+ checkbox: (props) => /* @__PURE__ */ jsx(
547
+ FieldCheckbox,
548
+ {
549
+ ...props
550
+ }
551
+ ),
292
552
  email: (props) => /* @__PURE__ */ jsx(
293
553
  FieldEmail,
294
554
  {
@@ -313,6 +573,18 @@ const components = {
313
573
  ...props
314
574
  }
315
575
  ),
576
+ radio: (props) => /* @__PURE__ */ jsx(
577
+ FieldRadio,
578
+ {
579
+ ...props
580
+ }
581
+ ),
582
+ rating: (props) => /* @__PURE__ */ jsx(
583
+ FieldRating,
584
+ {
585
+ ...props
586
+ }
587
+ ),
316
588
  section: (props) => /* @__PURE__ */ jsx(
317
589
  FieldSection,
318
590
  {
@@ -346,8 +618,11 @@ const components = {
346
618
  };
347
619
  import { errors, validators } from "@drawbridge/drawbridge-utils/fields-validate";
348
620
  export {
621
+ birthdayInputs,
622
+ birthdayValue,
349
623
  components,
350
624
  errors,
351
625
  starred,
626
+ tick,
352
627
  validators as validate
353
628
  };