@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
@@ -0,0 +1,33 @@
1
+ import { ComponentType } from 'react';
2
+
3
+ // @story fields/rating
4
+ // What the Form page passes: the api's catalog entry (inputs, slug, type) plus
5
+ // the route ids, and the saved field when editing. An input left out of
6
+ // `inputs` renders disabled. A custom section's question only, never a prize's.
7
+ export interface FormOrganizationCampaignFieldRatingValues {
8
+ campaign: string;
9
+ id?: string;
10
+ inputs?: Array<'attributes' | 'label' | 'settings'>;
11
+ organization: string;
12
+ slug?: string;
13
+ type?: 'additional';
14
+ // Scale is attributes.max, 3 to 10, 5 to start; the Required switch, on to start.
15
+ attributes?: { max?: number; required?: boolean };
16
+ label?: string;
17
+ // The words under 1 and under the highest number, up to 50 each.
18
+ settings?: { high?: string | null; low?: string | null };
19
+ // The custom section the question sits in.
20
+ section?: string;
21
+ [ key: string ]: unknown;
22
+ }
23
+
24
+ export interface FormOrganizationCampaignFieldRatingProps {
25
+ disabled?: boolean;
26
+ onError: ( error: Error ) => void;
27
+ onSuccess: ( response: unknown ) => void;
28
+ values: FormOrganizationCampaignFieldRatingValues;
29
+ }
30
+
31
+ declare const FormOrganizationCampaignFieldRating: ComponentType<FormOrganizationCampaignFieldRatingProps>;
32
+
33
+ export default FormOrganizationCampaignFieldRating;
@@ -60,3 +60,6 @@ export declare const FormOrganizationCampaignTitle: ComponentType<FormOrganizati
60
60
  // The Giveaway page's Winner claim window: days, 1 to 365, 7 to start.
61
61
  export declare const FormOrganizationCampaignClaimWindow: ComponentType<FormOrganizationCampaignFormProps>;
62
62
  export declare const FormOrganizationCampaignSettingsShop: ComponentType<FormOrganizationCampaignFormProps>;
63
+
64
+ // The campaign's Checkout dialog: Stripe or Shopify, handed to `onSubmit`.
65
+ export declare const FormOrganizationCampaignCheckout: ComponentType<{ disabled?: boolean; onSubmit: ( checkout: 'shopify' | 'stripe' ) => void; values?: { checkout?: 'shopify' | 'stripe' } }>;
@@ -45,3 +45,14 @@ export interface FormOrganizationConnectionProps {
45
45
  }
46
46
 
47
47
  export declare const FormOrganizationConnection: ComponentType<FormOrganizationConnectionProps>;
48
+
49
+ // One editable field, drawn by its declared kind. A field with a `hook` is a
50
+ // paged, searchable picker over `endpoint` that stores the bare id; `titleFor`
51
+ // names a stored id.
52
+ export declare const Editable: ComponentType<{
53
+ endpoint?: string;
54
+ field: FormOrganizationConnectionField;
55
+ onChange: ( value: unknown ) => void;
56
+ titleFor?: ( id: string ) => string;
57
+ value?: unknown;
58
+ }>;
@@ -0,0 +1,24 @@
1
+ import { ComponentType } from 'react';
2
+
3
+ type Callback = ( response: unknown ) => void;
4
+
5
+ interface Option { name: string; values: string[] }
6
+
7
+ export declare const FormOrganizationProductCreate: ComponentType<{ campaign: string; onError: Callback; onSuccess: Callback; organization: string }>;
8
+
9
+ export declare const FormProductOption: ComponentType<{ disabled?: boolean; onDone: ( option: Option ) => void; others?: Option[]; values?: Option }>;
10
+
11
+ export declare const FormProductVariant: ComponentType<{ disabled?: boolean; onDone: ( values: Record<string, unknown> ) => void; values: Record<string, unknown> }>;
12
+
13
+ // The product page's body. A product whose `editable` is false opens read only.
14
+ export declare const FormOrganizationProduct: ComponentType<{
15
+ campaign?: string;
16
+ disabled?: boolean;
17
+ onDelete?: () => void;
18
+ onError: Callback;
19
+ onSuccess: Callback;
20
+ organization: { id: string; [ key: string ]: unknown };
21
+ product: Record<string, unknown>;
22
+ }>;
23
+
24
+ export default FormOrganizationProduct;
@@ -1,10 +1,14 @@
1
- import { ComponentType } from 'react';
1
+ import { ComponentType, ReactNode } from 'react';
2
2
 
3
3
  export interface FormOtcCodeProps {
4
+ // The copy under the title; defaults to 'A code will be sent to <identifier>'.
5
+ message?: ReactNode;
4
6
  // Receives the request's error; the page shows it.
5
7
  onError: ( error: unknown ) => void;
6
8
  // Receives the PUT /otc/:id/code response.
7
9
  onSuccess: ( response: unknown ) => void;
10
+ // Defaults to 'Authorization'.
11
+ title?: ReactNode;
8
12
  values?: {
9
13
  // The one-time-code record the code is sent for.
10
14
  id?: string;
@@ -1,8 +1,9 @@
1
1
  import { ComponentType, ReactNode } from 'react';
2
2
 
3
3
  // Stripe's Address and Payment Elements for saving a card. Loads Stripe.js
4
- // with NEXT_PUBLIC_STRIPE_API_KEY when the module is imported, confirms the
5
- // setup intent, then POSTs the payment method to /account/method.
4
+ // with the [ 'app' ] query's credentials.stripePublishableKey ( once per key ),
5
+ // confirms the setup intent, then POSTs the payment method to /account/method.
6
+ // Without a key or a client secret it says payment was not initialized.
6
7
  export interface FormStripeProps {
7
8
  // The submit button's text (default 'Submit').
8
9
  button?: { text?: ReactNode };
@@ -15,6 +15,8 @@ export interface InputFileProps {
15
15
  button?: { icon?: ComponentType<SVGProps<SVGSVGElement>>; text?: ReactNode };
16
16
  // This placement's description of the image (its alt text), up to 150 characters.
17
17
  description?: string;
18
+ // A product variant's digital file: the uploader alone, private, no thumbnail.
19
+ digital?: boolean;
18
20
  disabled?: boolean;
19
21
  // With onEdit: a green ring on the thumbnail, the file has been edited ( a gallery crop ).
20
22
  edited?: boolean;
@@ -0,0 +1,14 @@
1
+ import { ComponentType } from 'react';
2
+
3
+ // The gallery editor the page form and the product page share. It reads the
4
+ // surrounding form through useFormContext.
5
+ declare const InputGallery: ComponentType<{
6
+ endpoint: string;
7
+ label?: string | null;
8
+ name?: string;
9
+ onUpdate?: ( values: Record<string, unknown> ) => void;
10
+ organization?: { id: string; [ key: string ]: unknown };
11
+ reposition?: boolean;
12
+ }>;
13
+
14
+ export default InputGallery;
@@ -0,0 +1,14 @@
1
+ // Where a campaign's shop sells, as the Checkout section names it.
2
+ export declare const CHECKOUT_LABELS: Readonly<{ shopify: string; stripe: string }>;
3
+ // The product editor's rules ( drawbridge-utils products underneath ).
4
+ export declare const VARIANT_DEFAULTS: Readonly<Record<string, unknown>>;
5
+ export declare const variantsFor: ( options: unknown[], variants: unknown[] ) => Record<string, unknown>[];
6
+ export declare const moneyOf: ( value: number, currency?: string ) => string;
7
+ export declare const priceText: ( variants?: unknown[] ) => string;
8
+ export declare const variantRows: ( args: { expanded?: string[]; group?: string; options?: unknown[]; variants?: unknown[] } ) => Record<string, unknown>[];
9
+ export declare const totalQuantity: ( variants?: unknown[] ) => number;
10
+ export declare const variantCount: ( options?: unknown[] ) => number;
11
+ export declare const productBody: ( values: Record<string, unknown> ) => Record<string, unknown>;
12
+
13
+ // How many times a digital line was downloaded: '2 downloads', 'Not downloaded yet'.
14
+ export declare const downloadsText: ( count: number ) => string;
@@ -0,0 +1,5 @@
1
+ // The value at a dotted path ('plans.default.product'), or undefined.
2
+ export declare const readPath: ( object: unknown, key: string ) => unknown;
3
+
4
+ // [ [ 'a.b', 1 ], [ 'c', 2 ] ] becomes { a : { b : 1 }, c : 2 }.
5
+ export declare const nestPaths: ( pairs: Array<[ string, unknown ]> ) => Record<string, unknown>;
@@ -11,13 +11,23 @@ export interface ConfirmOptions {
11
11
  onSuccess?: ( response: unknown ) => void;
12
12
  // Why the action is blocked: shown as a warning, the button disabled.
13
13
  task?: string;
14
+ // The dialog's title when it is not the action's own word.
15
+ title?: string;
14
16
  }
15
17
 
16
18
  export declare const useConfirm: () => ( options: ConfirmOptions ) => void;
17
19
 
18
20
  export interface FulfillmentOrder {
19
- fulfillment?: { status?: 'fulfilled' | 'unfulfilled' | string } | null;
21
+ amounts?: { refunded?: number; shipping?: number; subtotal?: number; tax?: number; total?: number } | null;
22
+ currency?: string;
23
+ customer?: { email?: string | null; firstName?: string | null; lastName?: string | null } | null;
24
+ dispute?: { id?: string; status?: string } | null;
25
+ fulfillment?: { status?: 'fulfilled' | 'partially_fulfilled' | 'unfulfilled' | string } | null;
20
26
  id?: string;
27
+ payment?: string | null;
28
+ provider?: { id?: string; name?: string | null; slug?: string } | null;
29
+ shipping?: { address?: Record<string, string | null>; name?: string | null; rate?: { amount?: number; name?: string } | null } | null;
30
+ source?: { domain?: string; id?: string } | null;
21
31
  status?: 'canceled' | 'completed' | 'open' | string;
22
32
  }
23
33
 
@@ -34,3 +44,16 @@ export interface OrderFulfillmentProps {
34
44
  }
35
45
 
36
46
  export declare const OrderFulfillment: ComponentType<OrderFulfillmentProps>;
47
+
48
+ // A paid order's Mark as fulfilled: Carrier, Tracking number, Email the customer.
49
+ export declare const FormFulfill: ComponentType<{ endpoint: string; onError?: ( error: unknown ) => void; onSuccess?: ( response: unknown ) => void }>;
50
+
51
+ // A paid order's Summary: Subtotal, Shipping, Tax and Total.
52
+ export declare const OrderSummarySection: ComponentType<{ order: FulfillmentOrder }>;
53
+
54
+ // A paid order's Customer: Name, Email and Ships to.
55
+ export declare const OrderCustomer: ComponentType<{ order: FulfillmentOrder }>;
56
+
57
+ // A paid order's Payment: Amount, Status and Refund ( Stripe's payment details
58
+ // overlay through `endpoint`, the orders session route ). `onClose` follows the overlay closing.
59
+ export declare const OrderPayment: ComponentType<{ endpoint: string; onClose?: () => void; order: FulfillmentOrder }>;
@@ -0,0 +1,26 @@
1
+ import { ComponentType } from 'react';
2
+
3
+ export interface ShippingRate {
4
+ country: 'CA' | 'US' | string;
5
+ delivery?: { maximum: number; minimum: number } | null;
6
+ free?: number | null;
7
+ id?: string;
8
+ name: string;
9
+ price: number;
10
+ }
11
+
12
+ // New rate and Edit rate. POSTs ( no `values.id` ) or PUTs `endpoint`.
13
+ export declare const FormRate: ComponentType<{ currency?: string; endpoint: string; onError?: ( error: unknown ) => void; onSuccess?: ( response: unknown ) => void; values?: ShippingRate }>;
14
+
15
+ // The Stripe page's Shipping section: /organization/:organization/rates.
16
+ export interface ShippingRatesProps {
17
+ // The Stripe account's currency.
18
+ currency?: string;
19
+ // Manage access to Connections.
20
+ manage?: boolean;
21
+ organization: string;
22
+ }
23
+
24
+ declare const ShippingRates: ComponentType<ShippingRatesProps>;
25
+
26
+ export default ShippingRates;
@@ -0,0 +1,50 @@
1
+ import { ComponentType, ReactNode } from 'react';
2
+
3
+ // @story orders/buyer-order
4
+ export interface BuyerOrderLine {
5
+ digital: boolean;
6
+ index: number;
7
+ price?: number | null;
8
+ quantity?: number;
9
+ title?: string | null;
10
+ variantTitle?: string | null;
11
+ }
12
+
13
+ export interface BuyerOrderView {
14
+ amounts?: { total?: number } | null;
15
+ currency?: string;
16
+ id: string;
17
+ lines: BuyerOrderLine[];
18
+ number?: string | null;
19
+ organization?: string | null;
20
+ payment?: string | null;
21
+ purchasedAt?: string | Date | null;
22
+ }
23
+
24
+ export interface TemplateBuyerProps {
25
+ children?: ReactNode;
26
+ // Where the Drawbridge mark links.
27
+ home?: string;
28
+ isLoading?: boolean;
29
+ }
30
+
31
+ export interface BuyerOrderProps {
32
+ // The line being downloaded, or null.
33
+ downloading?: number | null;
34
+ onDownload: ( index: number ) => void;
35
+ order: BuyerOrderView;
36
+ }
37
+
38
+ export interface BuyerDownloadProps {
39
+ // The buyer's order page, for View my order.
40
+ href?: string;
41
+ onRetry?: () => void;
42
+ status?: 'starting' | 'expired' | 'failed' | 'refunded' | 'unavailable';
43
+ }
44
+
45
+ export declare const BuyerOrder: ComponentType<BuyerOrderProps>;
46
+ export declare const BuyerDownload: ComponentType<BuyerDownloadProps>;
47
+
48
+ declare const TemplateBuyer: ComponentType<TemplateBuyerProps>;
49
+
50
+ export default TemplateBuyer;
@@ -5,6 +5,8 @@ export interface InputCheckboxProps extends Omit<ButtonHTMLAttributes<HTMLButton
5
5
  label?: ReactNode;
6
6
  labelId?: string;
7
7
  onChange: ( value: boolean ) => void;
8
+ // A round button with role radio and a dot, for one choice among several.
9
+ round?: boolean;
8
10
  style?: BrandStyle;
9
11
  value?: boolean;
10
12
  }
@@ -140,6 +140,10 @@ export interface Alert {
140
140
  // Why a record needs attention (Warning, or Lock when locked), or null when nothing is wrong.
141
141
  export declare const alertFor: ( record: { capped?: boolean; error?: string | null; errors?: { message?: string }[]; status?: string | null; tasks?: { message?: string }[]; totals?: { connectionAlerts?: number; workflowAlerts?: number } } | null | undefined ) => Alert | null;
142
142
 
143
+ // Drawbridge's publishable key ( GET /app credentials.stripePublishableKey ),
144
+ // handed over by ProviderUi; a test key makes stripeUrl link to /test.
145
+ export declare const setStripeKey: ( key?: string | null ) => void;
146
+
143
147
  export declare const stripeUrl: ( label: string, id: string, ...more: string[] ) => string;
144
148
 
145
149
  export declare const years: ( props: { current: number | string; length?: number } ) => Array<{ key: number; value: number }>;
@@ -0,0 +1,19 @@
1
+ import type { FC } from 'react';
2
+
3
+ export interface OrderSummaryLine {
4
+ id: string;
5
+ image?: string | null;
6
+ name: string;
7
+ note?: string | null;
8
+ summary?: string | null;
9
+ }
10
+
11
+ export interface OrderSummaryProps {
12
+ lines?: OrderSummaryLine[];
13
+ // [ label, value ]; a null value shows a dash.
14
+ rows?: [ string, string | null ][];
15
+ }
16
+
17
+ declare const OrderSummary: FC<OrderSummaryProps>;
18
+
19
+ export default OrderSummary;