@drawbridge/components 0.1.48 → 0.1.49

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 (125) hide show
  1. package/dist/bridge/fields.js +0 -278
  2. package/dist/bridge/fields.mjs +1 -276
  3. package/dist/bridge/form-subdomain-shop-modal.js +274 -234
  4. package/dist/bridge/form-subdomain-shop-modal.mjs +275 -233
  5. package/dist/bridge/form-subdomain.js +0 -7
  6. package/dist/bridge/form-subdomain.mjs +2 -9
  7. package/dist/bridge/lib/age-gate.js +0 -12
  8. package/dist/bridge/lib/age-gate.mjs +0 -11
  9. package/dist/bridge/lib/checkout-kit.js +32 -2
  10. package/dist/bridge/lib/checkout-kit.mjs +32 -2
  11. package/dist/bridge/lib/entry.js +0 -3
  12. package/dist/bridge/lib/entry.mjs +0 -2
  13. package/dist/bridge/product-tile.js +6 -9
  14. package/dist/bridge/product-tile.mjs +6 -9
  15. package/dist/bridge/template-layout.js +122 -237
  16. package/dist/bridge/template-layout.mjs +122 -237
  17. package/dist/bridge/template-modal.js +73 -28
  18. package/dist/bridge/template-modal.mjs +74 -29
  19. package/dist/dashboard/buttons-subscription.js +1 -1
  20. package/dist/dashboard/buttons-subscription.mjs +1 -1
  21. package/dist/dashboard/campaign-form.js +2 -7
  22. package/dist/dashboard/campaign-form.mjs +2 -7
  23. package/dist/dashboard/card-order.js +4 -22
  24. package/dist/dashboard/card-order.mjs +4 -22
  25. package/dist/dashboard/document-blocks.js +17 -4
  26. package/dist/dashboard/document-blocks.mjs +17 -4
  27. package/dist/dashboard/form-admin-provider.js +17 -71
  28. package/dist/dashboard/form-admin-provider.mjs +17 -71
  29. package/dist/dashboard/form-file-upload.js +2 -3
  30. package/dist/dashboard/form-file-upload.mjs +3 -4
  31. package/dist/dashboard/form-organization-campaign-advertisements.js +6 -47
  32. package/dist/dashboard/form-organization-campaign-advertisements.mjs +6 -47
  33. package/dist/dashboard/form-organization-campaign-agreement.js +121 -83
  34. package/dist/dashboard/form-organization-campaign-agreement.mjs +121 -83
  35. package/dist/dashboard/form-organization-campaign.js +0 -82
  36. package/dist/dashboard/form-organization-campaign.mjs +0 -81
  37. package/dist/dashboard/form-organization-connection.js +6 -48
  38. package/dist/dashboard/form-organization-connection.mjs +7 -48
  39. package/dist/dashboard/form-organization-workflow.js +1 -72
  40. package/dist/dashboard/form-organization-workflow.mjs +1 -69
  41. package/dist/dashboard/form-otc.js +5 -4
  42. package/dist/dashboard/form-otc.mjs +5 -4
  43. package/dist/dashboard/form-stripe.js +5 -12
  44. package/dist/dashboard/form-stripe.mjs +5 -12
  45. package/dist/dashboard/input-fields.js +158 -11
  46. package/dist/dashboard/input-fields.mjs +158 -11
  47. package/dist/dashboard/input-file.js +4 -21
  48. package/dist/dashboard/input-file.mjs +4 -21
  49. package/dist/dashboard/lib/connection-controls.js +2 -5
  50. package/dist/dashboard/lib/connection-controls.mjs +1 -3
  51. package/dist/dashboard/lib/form-page.js +1 -1
  52. package/dist/dashboard/lib/form-page.mjs +1 -1
  53. package/dist/dashboard/lib/uppy.js +1 -10
  54. package/dist/dashboard/lib/uppy.mjs +2 -11
  55. package/dist/dashboard/order-sections.js +6 -456
  56. package/dist/dashboard/order-sections.mjs +7 -453
  57. package/dist/dashboard/provider-ui.js +7 -9
  58. package/dist/dashboard/provider-ui.mjs +7 -9
  59. package/dist/dashboard/template-ui.js +12 -4
  60. package/dist/dashboard/template-ui.mjs +12 -4
  61. package/dist/input-checkbox.js +10 -28
  62. package/dist/input-checkbox.mjs +10 -28
  63. package/dist/product.js +24 -96
  64. package/dist/product.mjs +25 -97
  65. package/dist/shared/lib/helpers.js +6 -54
  66. package/dist/shared/lib/helpers.mjs +8 -53
  67. package/package.json +4 -74
  68. package/types/bridge/fields.d.ts +2 -14
  69. package/types/bridge/form-subdomain-shop-modal.d.ts +3 -27
  70. package/types/bridge/lib/age-gate.d.ts +0 -5
  71. package/types/bridge/lib/checkout-kit.d.ts +10 -2
  72. package/types/bridge/lib/entry.d.ts +0 -3
  73. package/types/dashboard/card-order.d.ts +0 -6
  74. package/types/dashboard/document-blocks.d.ts +3 -2
  75. package/types/dashboard/form-admin-provider.d.ts +2 -9
  76. package/types/dashboard/form-file-upload.d.ts +1 -2
  77. package/types/dashboard/form-organization-campaign-advertisements.d.ts +0 -3
  78. package/types/dashboard/form-organization-campaign-agreement.d.ts +5 -2
  79. package/types/dashboard/form-organization-campaign.d.ts +0 -3
  80. package/types/dashboard/form-organization-connection.d.ts +0 -11
  81. package/types/dashboard/form-otc.d.ts +1 -5
  82. package/types/dashboard/form-stripe.d.ts +2 -3
  83. package/types/dashboard/input-file.d.ts +0 -2
  84. package/types/dashboard/order-sections.d.ts +1 -24
  85. package/types/input-checkbox.d.ts +0 -2
  86. package/types/shared/lib/helpers.d.ts +0 -4
  87. package/dist/bridge/cart-drawer.js +0 -152
  88. package/dist/bridge/cart-drawer.mjs +0 -123
  89. package/dist/bridge/form-subdomain-checkout.js +0 -687
  90. package/dist/bridge/form-subdomain-checkout.mjs +0 -665
  91. package/dist/bridge/lib/cart.js +0 -79
  92. package/dist/bridge/lib/cart.mjs +0 -48
  93. package/dist/dashboard/embed-stripe.js +0 -145
  94. package/dist/dashboard/embed-stripe.mjs +0 -116
  95. package/dist/dashboard/form-organization-campaign-field-birthday.js +0 -193
  96. package/dist/dashboard/form-organization-campaign-field-birthday.mjs +0 -164
  97. package/dist/dashboard/form-organization-campaign-field-rating.js +0 -246
  98. package/dist/dashboard/form-organization-campaign-field-rating.mjs +0 -217
  99. package/dist/dashboard/form-organization-product.js +0 -1461
  100. package/dist/dashboard/form-organization-product.mjs +0 -1425
  101. package/dist/dashboard/input-gallery.js +0 -201
  102. package/dist/dashboard/input-gallery.mjs +0 -172
  103. package/dist/dashboard/lib/products.js +0 -169
  104. package/dist/dashboard/lib/products.mjs +0 -135
  105. package/dist/dashboard/lib/settings-paths.js +0 -35
  106. package/dist/dashboard/lib/settings-paths.mjs +0 -11
  107. package/dist/dashboard/shipping-rates.js +0 -404
  108. package/dist/dashboard/shipping-rates.mjs +0 -371
  109. package/dist/dashboard/template-buyer.js +0 -301
  110. package/dist/dashboard/template-buyer.mjs +0 -267
  111. package/dist/shared/order-summary.js +0 -139
  112. package/dist/shared/order-summary.mjs +0 -110
  113. package/types/bridge/cart-drawer.d.ts +0 -31
  114. package/types/bridge/form-subdomain-checkout.d.ts +0 -20
  115. package/types/bridge/lib/cart.d.ts +0 -44
  116. package/types/dashboard/embed-stripe.d.ts +0 -25
  117. package/types/dashboard/form-organization-campaign-field-birthday.d.ts +0 -31
  118. package/types/dashboard/form-organization-campaign-field-rating.d.ts +0 -33
  119. package/types/dashboard/form-organization-product.d.ts +0 -24
  120. package/types/dashboard/input-gallery.d.ts +0 -14
  121. package/types/dashboard/lib/products.d.ts +0 -14
  122. package/types/dashboard/lib/settings-paths.d.ts +0 -5
  123. package/types/dashboard/shipping-rates.d.ts +0 -26
  124. package/types/dashboard/template-buyer.d.ts +0 -50
  125. package/types/shared/order-summary.d.ts +0 -19
@@ -1,21 +1,14 @@
1
1
  import { ComponentType } from 'react';
2
2
 
3
3
  export interface FormAdminProviderField {
4
- // A select with `hook` is a picker over GET /admin/provider/:slug/hook/:hook
5
- // that stores the picked item's bare id; a select with `options` is a list.
6
- hook?: string;
7
- input: 'text' | 'password' | 'email' | 'select' | 'switch' | string;
8
- // A dotted path into the nested settings, e.g. 'plans.default.prices.starter'.
4
+ input: 'text' | 'password' | 'email' | 'switch' | string;
9
5
  key: string;
10
6
  label: string;
11
7
  // A stored secret's recognisable mask, e.g. 'kls••••••••9f3a'.
12
8
  mask?: string | null;
13
9
  message?: string | null;
14
- options?: { label: string; value: string }[];
15
10
  redact?: boolean;
16
11
  required?: boolean;
17
- // false when the vendor cannot search.
18
- search?: boolean;
19
12
  // Whether a value is stored.
20
13
  set?: boolean;
21
14
  }
@@ -27,7 +20,7 @@ export interface FormAdminProviderProps {
27
20
  enabled?: boolean;
28
21
  fields?: FormAdminProviderField[];
29
22
  live?: boolean;
30
- // Nested like the stored object; plain fields only, a secret never comes back.
23
+ // Plain fields only: a secret never comes back.
31
24
  settings?: Record<string, unknown>;
32
25
  slug?: string;
33
26
  title?: string;
@@ -7,8 +7,7 @@ export interface FormFileUploadProps {
7
7
  // Video ceiling in bytes; defaults to the shared cap the api enforces.
8
8
  maximumUploadBytes?: number;
9
9
  onSuccess: ( response: unknown ) => void;
10
- // Which formats are accepted: 'all' | 'media' | 'image' | 'video' | 'application',
11
- // or 'digital': a product variant's private file, always through multipart.
10
+ // Which formats are accepted: 'all' | 'media' | 'image' | 'video' | 'application'.
12
11
  type?: string;
13
12
  }
14
13
 
@@ -1,9 +1,6 @@
1
1
  import { ComponentType } from 'react';
2
2
 
3
3
  export interface FormOrganizationCampaignAdvertisementsProps {
4
- // The campaign's Products and checkout: 'stripe' names the tab Products and
5
- // lists the products made in Drawbridge.
6
- checkout?: 'shopify' | 'stripe' | null;
7
4
  // The organization's commerce connection, for the Store tab.
8
5
  commerce?: { slug?: string; title?: string } | null;
9
6
  disabled?: boolean;
@@ -21,9 +21,12 @@ export interface Agreement {
21
21
  active?: boolean;
22
22
  // The one line under its title.
23
23
  description?: string;
24
- // Our standard document: its name, the pieces Insert lists, its text.
25
- document?: { name: string; pieces: string[]; standard: string };
24
+ // Our standard document: its name, the pieces Insert lists, its text, and the
25
+ // pieces no edit removes ( Opting out while the giveaway is on ).
26
+ document?: { locked?: string[]; name: string; pieces: string[]; standard: string };
26
27
  enforceLink?: boolean;
28
+ // What a linked page must include, as the api lists it: shown in a gray box under Link.
29
+ include?: string[];
27
30
  title: string;
28
31
  // What it may be saved as: Document and Link, or Link alone while documents are switched off.
29
32
  types?: ( 'document' | 'link' )[];
@@ -60,6 +60,3 @@ 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,14 +45,3 @@ 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
- }>;
@@ -1,14 +1,10 @@
1
- import { ComponentType, ReactNode } from 'react';
1
+ import { ComponentType } 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;
6
4
  // Receives the request's error; the page shows it.
7
5
  onError: ( error: unknown ) => void;
8
6
  // Receives the PUT /otc/:id/code response.
9
7
  onSuccess: ( response: unknown ) => void;
10
- // Defaults to 'Authorization'.
11
- title?: ReactNode;
12
8
  values?: {
13
9
  // The one-time-code record the code is sent for.
14
10
  id?: string;
@@ -1,9 +1,8 @@
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 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.
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.
7
6
  export interface FormStripeProps {
8
7
  // The submit button's text (default 'Submit').
9
8
  button?: { text?: ReactNode };
@@ -15,8 +15,6 @@ 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;
20
18
  disabled?: boolean;
21
19
  // With onEdit: a green ring on the thumbnail, the file has been edited ( a gallery crop ).
22
20
  edited?: boolean;
@@ -11,23 +11,13 @@ 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;
16
14
  }
17
15
 
18
16
  export declare const useConfirm: () => ( options: ConfirmOptions ) => void;
19
17
 
20
18
  export interface FulfillmentOrder {
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;
19
+ fulfillment?: { status?: 'fulfilled' | 'unfulfilled' | string } | null;
26
20
  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;
31
21
  status?: 'canceled' | 'completed' | 'open' | string;
32
22
  }
33
23
 
@@ -44,16 +34,3 @@ export interface OrderFulfillmentProps {
44
34
  }
45
35
 
46
36
  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 }>;
@@ -5,8 +5,6 @@ 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;
10
8
  style?: BrandStyle;
11
9
  value?: boolean;
12
10
  }
@@ -140,10 +140,6 @@ 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
-
147
143
  export declare const stripeUrl: ( label: string, id: string, ...more: string[] ) => string;
148
144
 
149
145
  export declare const years: ( props: { current: number | string; length?: number } ) => Array<{ key: number; value: number }>;
@@ -1,152 +0,0 @@
1
- "use client";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var cart_drawer_exports = {};
30
- __export(cart_drawer_exports, {
31
- default: () => cart_drawer_default
32
- });
33
- module.exports = __toCommonJS(cart_drawer_exports);
34
- var import_jsx_runtime = require("react/jsx-runtime");
35
- var import_react = require("react");
36
- var import_dynamic = __toESM(require("next/dynamic"));
37
- var import_form_subdomain_shop_modal = require("./form-subdomain-shop-modal");
38
- var import_overlay = __toESM(require("../shared/overlay"));
39
- var import_styles = require("../styles");
40
- const FormSubdomainCheckout = (0, import_dynamic.default)(() => import("./form-subdomain-checkout"), { ssr: false });
41
- const CartDrawer = ({
42
- button,
43
- cart,
44
- cut,
45
- fonts,
46
- onBack,
47
- onCart,
48
- onCheckout,
49
- onClose,
50
- onLineRemove,
51
- onLineUpdate,
52
- onOpenProduct,
53
- onPaid,
54
- open,
55
- params,
56
- pay,
57
- preview,
58
- style,
59
- tracking
60
- }) => {
61
- const drawer = (0, import_react.useRef)(null);
62
- (0, import_react.useEffect)(() => {
63
- if (drawer.current) drawer.current.inert = !open;
64
- }, [open]);
65
- (0, import_react.useEffect)(() => {
66
- if (!open) return;
67
- const onKey = (event) => {
68
- var _a, _b, _c;
69
- if (event.key !== "Escape") return;
70
- const over = (_b = (_a = document.activeElement) == null ? void 0 : _a.closest) == null ? void 0 : _b.call(_a, '[role="dialog"]');
71
- if (over && !((_c = drawer.current) == null ? void 0 : _c.contains(over))) return;
72
- onClose();
73
- };
74
- window.addEventListener("keydown", onKey);
75
- return () => window.removeEventListener("keydown", onKey);
76
- }, [onClose, open]);
77
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
78
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
79
- import_overlay.default,
80
- {
81
- ...{
82
- className: "z-30 fixed inset-0",
83
- onClick: onClose,
84
- show: open,
85
- style
86
- }
87
- }
88
- ),
89
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
90
- "div",
91
- {
92
- ...{
93
- "aria-hidden": !open,
94
- "aria-label": pay ? "Checkout" : "Cart",
95
- className: "z-40 fixed inset-y-0 right-0 flex flex-col w-full lg:max-w-md bg-white transition-transform duration-300 ease-out " + (open ? "translate-x-0" : "translate-x-full"),
96
- ref: drawer,
97
- role: "dialog",
98
- style: {
99
- ...fonts == null ? void 0 : fonts.body,
100
- ...style && (0, import_styles.backgroundStyle)(style)
101
- }
102
- },
103
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
104
- "div",
105
- {
106
- ...{
107
- className: "p-6 space-y-6 overflow-y-auto hide-scrollbar overflow-x-hidden min-h-0"
108
- },
109
- children: pay ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
110
- FormSubdomainCheckout,
111
- {
112
- ...{
113
- back: onBack,
114
- button,
115
- cart: pay,
116
- onCart,
117
- onPaid,
118
- params,
119
- preview,
120
- style
121
- }
122
- },
123
- pay.id
124
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
125
- import_form_subdomain_shop_modal.FormSubdomainCart,
126
- {
127
- ...{
128
- button,
129
- cart,
130
- cut,
131
- onLineRemove,
132
- onLineUpdate,
133
- onOpenProduct,
134
- onSuccess: ({ result }) => {
135
- tracking == null ? void 0 : tracking.track({
136
- name: "shop-checkout",
137
- data: result
138
- });
139
- onCheckout(result);
140
- },
141
- style,
142
- tracking
143
- }
144
- }
145
- )
146
- }
147
- )
148
- }
149
- )
150
- ] });
151
- };
152
- var cart_drawer_default = CartDrawer;
@@ -1,123 +0,0 @@
1
- "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- import { Fragment, useEffect, useRef } from "react";
4
- import dynamic from "next/dynamic";
5
- import { FormSubdomainCart } from "./form-subdomain-shop-modal.mjs";
6
- import Overlay from "../shared/overlay.mjs";
7
- import { backgroundStyle } from "../styles.mjs";
8
- const FormSubdomainCheckout = dynamic(() => import("./form-subdomain-checkout.mjs"), { ssr: false });
9
- const CartDrawer = ({
10
- button,
11
- cart,
12
- cut,
13
- fonts,
14
- onBack,
15
- onCart,
16
- onCheckout,
17
- onClose,
18
- onLineRemove,
19
- onLineUpdate,
20
- onOpenProduct,
21
- onPaid,
22
- open,
23
- params,
24
- pay,
25
- preview,
26
- style,
27
- tracking
28
- }) => {
29
- const drawer = useRef(null);
30
- useEffect(() => {
31
- if (drawer.current) drawer.current.inert = !open;
32
- }, [open]);
33
- useEffect(() => {
34
- if (!open) return;
35
- const onKey = (event) => {
36
- var _a, _b, _c;
37
- if (event.key !== "Escape") return;
38
- const over = (_b = (_a = document.activeElement) == null ? void 0 : _a.closest) == null ? void 0 : _b.call(_a, '[role="dialog"]');
39
- if (over && !((_c = drawer.current) == null ? void 0 : _c.contains(over))) return;
40
- onClose();
41
- };
42
- window.addEventListener("keydown", onKey);
43
- return () => window.removeEventListener("keydown", onKey);
44
- }, [onClose, open]);
45
- return /* @__PURE__ */ jsxs(Fragment, { children: [
46
- /* @__PURE__ */ jsx(
47
- Overlay,
48
- {
49
- ...{
50
- className: "z-30 fixed inset-0",
51
- onClick: onClose,
52
- show: open,
53
- style
54
- }
55
- }
56
- ),
57
- /* @__PURE__ */ jsx(
58
- "div",
59
- {
60
- ...{
61
- "aria-hidden": !open,
62
- "aria-label": pay ? "Checkout" : "Cart",
63
- className: "z-40 fixed inset-y-0 right-0 flex flex-col w-full lg:max-w-md bg-white transition-transform duration-300 ease-out " + (open ? "translate-x-0" : "translate-x-full"),
64
- ref: drawer,
65
- role: "dialog",
66
- style: {
67
- ...fonts == null ? void 0 : fonts.body,
68
- ...style && backgroundStyle(style)
69
- }
70
- },
71
- children: /* @__PURE__ */ jsx(
72
- "div",
73
- {
74
- ...{
75
- className: "p-6 space-y-6 overflow-y-auto hide-scrollbar overflow-x-hidden min-h-0"
76
- },
77
- children: pay ? /* @__PURE__ */ jsx(
78
- FormSubdomainCheckout,
79
- {
80
- ...{
81
- back: onBack,
82
- button,
83
- cart: pay,
84
- onCart,
85
- onPaid,
86
- params,
87
- preview,
88
- style
89
- }
90
- },
91
- pay.id
92
- ) : /* @__PURE__ */ jsx(
93
- FormSubdomainCart,
94
- {
95
- ...{
96
- button,
97
- cart,
98
- cut,
99
- onLineRemove,
100
- onLineUpdate,
101
- onOpenProduct,
102
- onSuccess: ({ result }) => {
103
- tracking == null ? void 0 : tracking.track({
104
- name: "shop-checkout",
105
- data: result
106
- });
107
- onCheckout(result);
108
- },
109
- style,
110
- tracking
111
- }
112
- }
113
- )
114
- }
115
- )
116
- }
117
- )
118
- ] });
119
- };
120
- var cart_drawer_default = CartDrawer;
121
- export {
122
- cart_drawer_default as default
123
- };