@shopify/hydrogen-react 0.0.0-next-a09da91 → 0.0.0-next-59d697b
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.
- package/dist/dev/CartCheckoutButton.js +29 -0
- package/dist/dev/CartCheckoutButton.js.map +1 -0
- package/dist/dev/CartCheckoutButton.mjs +29 -0
- package/dist/dev/CartCheckoutButton.mjs.map +1 -0
- package/dist/dev/index.js +2 -0
- package/dist/dev/index.js.map +1 -1
- package/dist/dev/index.mjs +2 -0
- package/dist/dev/index.mjs.map +1 -1
- package/dist/prod/CartCheckoutButton.js +29 -0
- package/dist/prod/CartCheckoutButton.js.map +1 -0
- package/dist/prod/CartCheckoutButton.mjs +29 -0
- package/dist/prod/CartCheckoutButton.mjs.map +1 -0
- package/dist/prod/index.js +2 -0
- package/dist/prod/index.js.map +1 -1
- package/dist/prod/index.mjs +2 -0
- package/dist/prod/index.mjs.map +1 -1
- package/dist/types/CartCheckoutButton.d.ts +11 -0
- package/dist/types/index.d.cts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/umd/hydrogen-react.dev.js +40 -11
- package/dist/umd/hydrogen-react.dev.js.map +1 -1
- package/dist/umd/hydrogen-react.prod.js +13 -13
- package/dist/umd/hydrogen-react.prod.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const react = require("react");
|
|
4
|
+
const CartProvider = require("./CartProvider.js");
|
|
5
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
6
|
+
function CartCheckoutButton(props) {
|
|
7
|
+
const [requestedCheckout, setRequestedCheckout] = react.useState(false);
|
|
8
|
+
const {
|
|
9
|
+
status,
|
|
10
|
+
checkoutUrl
|
|
11
|
+
} = CartProvider.useCart();
|
|
12
|
+
const {
|
|
13
|
+
children,
|
|
14
|
+
...passthroughProps
|
|
15
|
+
} = props;
|
|
16
|
+
react.useEffect(() => {
|
|
17
|
+
if (requestedCheckout && checkoutUrl && status === "idle") {
|
|
18
|
+
window.location.href = checkoutUrl;
|
|
19
|
+
}
|
|
20
|
+
}, [requestedCheckout, status, checkoutUrl]);
|
|
21
|
+
return /* @__PURE__ */ jsxRuntime.jsx("button", {
|
|
22
|
+
...passthroughProps,
|
|
23
|
+
disabled: requestedCheckout || passthroughProps.disabled,
|
|
24
|
+
onClick: () => setRequestedCheckout(true),
|
|
25
|
+
children
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
exports.CartCheckoutButton = CartCheckoutButton;
|
|
29
|
+
//# sourceMappingURL=CartCheckoutButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CartCheckoutButton.js","sources":["../../src/CartCheckoutButton.tsx"],"sourcesContent":["import {ReactNode, useEffect, useState} from 'react';\nimport {useCart} from './CartProvider.js';\n\ntype PropsWeControl = 'onClick';\n\n/**\n * The `CartCheckoutButton` component renders a button that redirects to the checkout URL for the cart.\n * It must be a descendent of a `CartProvider` component.\n */\nexport function CartCheckoutButton(\n props: Omit<JSX.IntrinsicElements['button'], PropsWeControl> & {\n /** A `ReactNode` element. */\n children: ReactNode;\n }\n) {\n const [requestedCheckout, setRequestedCheckout] = useState(false);\n const {status, checkoutUrl} = useCart();\n const {children, ...passthroughProps} = props;\n\n useEffect(() => {\n if (requestedCheckout && checkoutUrl && status === 'idle') {\n window.location.href = checkoutUrl;\n }\n }, [requestedCheckout, status, checkoutUrl]);\n\n return (\n <button\n {...passthroughProps}\n disabled={requestedCheckout || passthroughProps.disabled}\n onClick={() => setRequestedCheckout(true)}\n >\n {children}\n </button>\n );\n}\n"],"names":["CartCheckoutButton","props","requestedCheckout","setRequestedCheckout","useState","status","checkoutUrl","useCart","children","passthroughProps","useEffect","window","location","href","disabled"],"mappings":";;;;;AASO,SAASA,mBACdC,OAIA;AACA,QAAM,CAACC,mBAAmBC,oBAApB,IAA4CC,eAAS,KAAD;AACpD,QAAA;AAAA,IAACC;AAAAA,IAAQC;AAAAA,MAAeC,aAA9B,QAAA;AACM,QAAA;AAAA,IAACC;AAAAA,OAAaC;AAAAA,EAAoBR,IAAAA;AAExCS,QAAAA,UAAU,MAAM;AACVR,QAAAA,qBAAqBI,eAAeD,WAAW,QAAQ;AACzDM,aAAOC,SAASC,OAAOP;AAAAA,IACxB;AAAA,EACA,GAAA,CAACJ,mBAAmBG,QAAQC,WAA5B,CAJM;AAMT;OAEQG;AAAAA,IACJ,UAAUP,qBAAqBO,iBAAiBK;AAAAA,IAChD,SAAS,MAAMX,qBAAqB,IAAD;AAAA,IAHrC;AAAA,EAAA,CADF;AASD;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
|
+
import { useCart } from "./CartProvider.mjs";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
function CartCheckoutButton(props) {
|
|
5
|
+
const [requestedCheckout, setRequestedCheckout] = useState(false);
|
|
6
|
+
const {
|
|
7
|
+
status,
|
|
8
|
+
checkoutUrl
|
|
9
|
+
} = useCart();
|
|
10
|
+
const {
|
|
11
|
+
children,
|
|
12
|
+
...passthroughProps
|
|
13
|
+
} = props;
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (requestedCheckout && checkoutUrl && status === "idle") {
|
|
16
|
+
window.location.href = checkoutUrl;
|
|
17
|
+
}
|
|
18
|
+
}, [requestedCheckout, status, checkoutUrl]);
|
|
19
|
+
return /* @__PURE__ */ jsx("button", {
|
|
20
|
+
...passthroughProps,
|
|
21
|
+
disabled: requestedCheckout || passthroughProps.disabled,
|
|
22
|
+
onClick: () => setRequestedCheckout(true),
|
|
23
|
+
children
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
CartCheckoutButton
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=CartCheckoutButton.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CartCheckoutButton.mjs","sources":["../../src/CartCheckoutButton.tsx"],"sourcesContent":["import {ReactNode, useEffect, useState} from 'react';\nimport {useCart} from './CartProvider.js';\n\ntype PropsWeControl = 'onClick';\n\n/**\n * The `CartCheckoutButton` component renders a button that redirects to the checkout URL for the cart.\n * It must be a descendent of a `CartProvider` component.\n */\nexport function CartCheckoutButton(\n props: Omit<JSX.IntrinsicElements['button'], PropsWeControl> & {\n /** A `ReactNode` element. */\n children: ReactNode;\n }\n) {\n const [requestedCheckout, setRequestedCheckout] = useState(false);\n const {status, checkoutUrl} = useCart();\n const {children, ...passthroughProps} = props;\n\n useEffect(() => {\n if (requestedCheckout && checkoutUrl && status === 'idle') {\n window.location.href = checkoutUrl;\n }\n }, [requestedCheckout, status, checkoutUrl]);\n\n return (\n <button\n {...passthroughProps}\n disabled={requestedCheckout || passthroughProps.disabled}\n onClick={() => setRequestedCheckout(true)}\n >\n {children}\n </button>\n );\n}\n"],"names":["CartCheckoutButton","props","requestedCheckout","setRequestedCheckout","useState","status","checkoutUrl","useCart","children","passthroughProps","useEffect","window","location","href","disabled"],"mappings":";;;AASO,SAASA,mBACdC,OAIA;AACA,QAAM,CAACC,mBAAmBC,oBAApB,IAA4CC,SAAS,KAAD;AACpD,QAAA;AAAA,IAACC;AAAAA,IAAQC;AAAAA,MAAeC,QAA9B;AACM,QAAA;AAAA,IAACC;AAAAA,OAAaC;AAAAA,EAAoBR,IAAAA;AAExCS,YAAU,MAAM;AACVR,QAAAA,qBAAqBI,eAAeD,WAAW,QAAQ;AACzDM,aAAOC,SAASC,OAAOP;AAAAA,IACxB;AAAA,EACA,GAAA,CAACJ,mBAAmBG,QAAQC,WAA5B,CAJM;AAMT;OAEQG;AAAAA,IACJ,UAAUP,qBAAqBO,iBAAiBK;AAAAA,IAChD,SAAS,MAAMX,qBAAqB,IAAD;AAAA,IAHrC;AAAA,EAAA,CADF;AASD;"}
|
package/dist/dev/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
3
|
const AddToCartButton = require("./AddToCartButton.js");
|
|
4
|
+
const CartCheckoutButton = require("./CartCheckoutButton.js");
|
|
4
5
|
const CartProvider = require("./CartProvider.js");
|
|
5
6
|
const ExternalVideo = require("./ExternalVideo.js");
|
|
6
7
|
const flattenConnection = require("./flatten-connection.js");
|
|
@@ -18,6 +19,7 @@ const storefrontClient = require("./storefront-client.js");
|
|
|
18
19
|
const useMoney = require("./useMoney.js");
|
|
19
20
|
const Video = require("./Video.js");
|
|
20
21
|
exports.AddToCartButton = AddToCartButton.AddToCartButton;
|
|
22
|
+
exports.CartCheckoutButton = CartCheckoutButton.CartCheckoutButton;
|
|
21
23
|
exports.CartProvider = CartProvider.CartProvider;
|
|
22
24
|
exports.useCart = CartProvider.useCart;
|
|
23
25
|
exports.ExternalVideo = ExternalVideo.ExternalVideo;
|
package/dist/dev/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/dev/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AddToCartButton } from "./AddToCartButton.mjs";
|
|
2
|
+
import { CartCheckoutButton } from "./CartCheckoutButton.mjs";
|
|
2
3
|
import { CartProvider, useCart } from "./CartProvider.mjs";
|
|
3
4
|
import { ExternalVideo } from "./ExternalVideo.mjs";
|
|
4
5
|
import { flattenConnection } from "./flatten-connection.mjs";
|
|
@@ -17,6 +18,7 @@ import { useMoney } from "./useMoney.mjs";
|
|
|
17
18
|
import { Video } from "./Video.mjs";
|
|
18
19
|
export {
|
|
19
20
|
AddToCartButton,
|
|
21
|
+
CartCheckoutButton,
|
|
20
22
|
CartProvider,
|
|
21
23
|
ExternalVideo,
|
|
22
24
|
Image,
|
package/dist/dev/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const react = require("react");
|
|
4
|
+
const CartProvider = require("./CartProvider.js");
|
|
5
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
6
|
+
function CartCheckoutButton(props) {
|
|
7
|
+
const [requestedCheckout, setRequestedCheckout] = react.useState(false);
|
|
8
|
+
const {
|
|
9
|
+
status,
|
|
10
|
+
checkoutUrl
|
|
11
|
+
} = CartProvider.useCart();
|
|
12
|
+
const {
|
|
13
|
+
children,
|
|
14
|
+
...passthroughProps
|
|
15
|
+
} = props;
|
|
16
|
+
react.useEffect(() => {
|
|
17
|
+
if (requestedCheckout && checkoutUrl && status === "idle") {
|
|
18
|
+
window.location.href = checkoutUrl;
|
|
19
|
+
}
|
|
20
|
+
}, [requestedCheckout, status, checkoutUrl]);
|
|
21
|
+
return /* @__PURE__ */ jsxRuntime.jsx("button", {
|
|
22
|
+
...passthroughProps,
|
|
23
|
+
disabled: requestedCheckout || passthroughProps.disabled,
|
|
24
|
+
onClick: () => setRequestedCheckout(true),
|
|
25
|
+
children
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
exports.CartCheckoutButton = CartCheckoutButton;
|
|
29
|
+
//# sourceMappingURL=CartCheckoutButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CartCheckoutButton.js","sources":["../../src/CartCheckoutButton.tsx"],"sourcesContent":["import {ReactNode, useEffect, useState} from 'react';\nimport {useCart} from './CartProvider.js';\n\ntype PropsWeControl = 'onClick';\n\n/**\n * The `CartCheckoutButton` component renders a button that redirects to the checkout URL for the cart.\n * It must be a descendent of a `CartProvider` component.\n */\nexport function CartCheckoutButton(\n props: Omit<JSX.IntrinsicElements['button'], PropsWeControl> & {\n /** A `ReactNode` element. */\n children: ReactNode;\n }\n) {\n const [requestedCheckout, setRequestedCheckout] = useState(false);\n const {status, checkoutUrl} = useCart();\n const {children, ...passthroughProps} = props;\n\n useEffect(() => {\n if (requestedCheckout && checkoutUrl && status === 'idle') {\n window.location.href = checkoutUrl;\n }\n }, [requestedCheckout, status, checkoutUrl]);\n\n return (\n <button\n {...passthroughProps}\n disabled={requestedCheckout || passthroughProps.disabled}\n onClick={() => setRequestedCheckout(true)}\n >\n {children}\n </button>\n );\n}\n"],"names":["CartCheckoutButton","props","requestedCheckout","setRequestedCheckout","useState","status","checkoutUrl","useCart","children","passthroughProps","useEffect","window","location","href","disabled"],"mappings":";;;;;AASO,SAASA,mBACdC,OAIA;AACA,QAAM,CAACC,mBAAmBC,oBAApB,IAA4CC,eAAS,KAAD;AACpD,QAAA;AAAA,IAACC;AAAAA,IAAQC;AAAAA,MAAeC,aAA9B,QAAA;AACM,QAAA;AAAA,IAACC;AAAAA,OAAaC;AAAAA,EAAoBR,IAAAA;AAExCS,QAAAA,UAAU,MAAM;AACVR,QAAAA,qBAAqBI,eAAeD,WAAW,QAAQ;AACzDM,aAAOC,SAASC,OAAOP;AAAAA,IACxB;AAAA,EACA,GAAA,CAACJ,mBAAmBG,QAAQC,WAA5B,CAJM;AAMT;OAEQG;AAAAA,IACJ,UAAUP,qBAAqBO,iBAAiBK;AAAAA,IAChD,SAAS,MAAMX,qBAAqB,IAAD;AAAA,IAHrC;AAAA,EAAA,CADF;AASD;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
|
+
import { useCart } from "./CartProvider.mjs";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
function CartCheckoutButton(props) {
|
|
5
|
+
const [requestedCheckout, setRequestedCheckout] = useState(false);
|
|
6
|
+
const {
|
|
7
|
+
status,
|
|
8
|
+
checkoutUrl
|
|
9
|
+
} = useCart();
|
|
10
|
+
const {
|
|
11
|
+
children,
|
|
12
|
+
...passthroughProps
|
|
13
|
+
} = props;
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (requestedCheckout && checkoutUrl && status === "idle") {
|
|
16
|
+
window.location.href = checkoutUrl;
|
|
17
|
+
}
|
|
18
|
+
}, [requestedCheckout, status, checkoutUrl]);
|
|
19
|
+
return /* @__PURE__ */ jsx("button", {
|
|
20
|
+
...passthroughProps,
|
|
21
|
+
disabled: requestedCheckout || passthroughProps.disabled,
|
|
22
|
+
onClick: () => setRequestedCheckout(true),
|
|
23
|
+
children
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
CartCheckoutButton
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=CartCheckoutButton.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CartCheckoutButton.mjs","sources":["../../src/CartCheckoutButton.tsx"],"sourcesContent":["import {ReactNode, useEffect, useState} from 'react';\nimport {useCart} from './CartProvider.js';\n\ntype PropsWeControl = 'onClick';\n\n/**\n * The `CartCheckoutButton` component renders a button that redirects to the checkout URL for the cart.\n * It must be a descendent of a `CartProvider` component.\n */\nexport function CartCheckoutButton(\n props: Omit<JSX.IntrinsicElements['button'], PropsWeControl> & {\n /** A `ReactNode` element. */\n children: ReactNode;\n }\n) {\n const [requestedCheckout, setRequestedCheckout] = useState(false);\n const {status, checkoutUrl} = useCart();\n const {children, ...passthroughProps} = props;\n\n useEffect(() => {\n if (requestedCheckout && checkoutUrl && status === 'idle') {\n window.location.href = checkoutUrl;\n }\n }, [requestedCheckout, status, checkoutUrl]);\n\n return (\n <button\n {...passthroughProps}\n disabled={requestedCheckout || passthroughProps.disabled}\n onClick={() => setRequestedCheckout(true)}\n >\n {children}\n </button>\n );\n}\n"],"names":["CartCheckoutButton","props","requestedCheckout","setRequestedCheckout","useState","status","checkoutUrl","useCart","children","passthroughProps","useEffect","window","location","href","disabled"],"mappings":";;;AASO,SAASA,mBACdC,OAIA;AACA,QAAM,CAACC,mBAAmBC,oBAApB,IAA4CC,SAAS,KAAD;AACpD,QAAA;AAAA,IAACC;AAAAA,IAAQC;AAAAA,MAAeC,QAA9B;AACM,QAAA;AAAA,IAACC;AAAAA,OAAaC;AAAAA,EAAoBR,IAAAA;AAExCS,YAAU,MAAM;AACVR,QAAAA,qBAAqBI,eAAeD,WAAW,QAAQ;AACzDM,aAAOC,SAASC,OAAOP;AAAAA,IACxB;AAAA,EACA,GAAA,CAACJ,mBAAmBG,QAAQC,WAA5B,CAJM;AAMT;OAEQG;AAAAA,IACJ,UAAUP,qBAAqBO,iBAAiBK;AAAAA,IAChD,SAAS,MAAMX,qBAAqB,IAAD;AAAA,IAHrC;AAAA,EAAA,CADF;AASD;"}
|
package/dist/prod/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
3
|
const AddToCartButton = require("./AddToCartButton.js");
|
|
4
|
+
const CartCheckoutButton = require("./CartCheckoutButton.js");
|
|
4
5
|
const CartProvider = require("./CartProvider.js");
|
|
5
6
|
const ExternalVideo = require("./ExternalVideo.js");
|
|
6
7
|
const flattenConnection = require("./flatten-connection.js");
|
|
@@ -18,6 +19,7 @@ const storefrontClient = require("./storefront-client.js");
|
|
|
18
19
|
const useMoney = require("./useMoney.js");
|
|
19
20
|
const Video = require("./Video.js");
|
|
20
21
|
exports.AddToCartButton = AddToCartButton.AddToCartButton;
|
|
22
|
+
exports.CartCheckoutButton = CartCheckoutButton.CartCheckoutButton;
|
|
21
23
|
exports.CartProvider = CartProvider.CartProvider;
|
|
22
24
|
exports.useCart = CartProvider.useCart;
|
|
23
25
|
exports.ExternalVideo = ExternalVideo.ExternalVideo;
|
package/dist/prod/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/prod/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AddToCartButton } from "./AddToCartButton.mjs";
|
|
2
|
+
import { CartCheckoutButton } from "./CartCheckoutButton.mjs";
|
|
2
3
|
import { CartProvider, useCart } from "./CartProvider.mjs";
|
|
3
4
|
import { ExternalVideo } from "./ExternalVideo.mjs";
|
|
4
5
|
import { flattenConnection } from "./flatten-connection.mjs";
|
|
@@ -17,6 +18,7 @@ import { useMoney } from "./useMoney.mjs";
|
|
|
17
18
|
import { Video } from "./Video.mjs";
|
|
18
19
|
export {
|
|
19
20
|
AddToCartButton,
|
|
21
|
+
CartCheckoutButton,
|
|
20
22
|
CartProvider,
|
|
21
23
|
ExternalVideo,
|
|
22
24
|
Image,
|
package/dist/prod/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
declare type PropsWeControl = 'onClick';
|
|
3
|
+
/**
|
|
4
|
+
* The `CartCheckoutButton` component renders a button that redirects to the checkout URL for the cart.
|
|
5
|
+
* It must be a descendent of a `CartProvider` component.
|
|
6
|
+
*/
|
|
7
|
+
export declare function CartCheckoutButton(props: Omit<JSX.IntrinsicElements['button'], PropsWeControl> & {
|
|
8
|
+
/** A `ReactNode` element. */
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}): JSX.Element;
|
|
11
|
+
export {};
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { AddToCartButton } from './AddToCartButton.js';
|
|
2
2
|
export type { CartState, CartStatus, Cart, CartWithActions, CartAction, } from './cart-types.js';
|
|
3
|
+
export { CartCheckoutButton } from './CartCheckoutButton.js';
|
|
3
4
|
export { CartProvider, useCart } from './CartProvider.js';
|
|
4
5
|
export { ExternalVideo } from './ExternalVideo.js';
|
|
5
6
|
export { flattenConnection } from './flatten-connection.js';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { AddToCartButton } from './AddToCartButton.js';
|
|
2
2
|
export type { CartState, CartStatus, Cart, CartWithActions, CartAction, } from './cart-types.js';
|
|
3
|
+
export { CartCheckoutButton } from './CartCheckoutButton.js';
|
|
3
4
|
export { CartProvider, useCart } from './CartProvider.js';
|
|
4
5
|
export { ExternalVideo } from './ExternalVideo.js';
|
|
5
6
|
export { flattenConnection } from './flatten-connection.js';
|
|
@@ -766,7 +766,7 @@ query CartQuery($id: ID!, $numCartLines: Int = 250, $country: CountryCode = ZZ)
|
|
|
766
766
|
${cartFragment}
|
|
767
767
|
`;
|
|
768
768
|
const SFAPI_VERSION = "2022-10";
|
|
769
|
-
var _jsxFileName$
|
|
769
|
+
var _jsxFileName$e = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ShopifyProvider.tsx";
|
|
770
770
|
const ShopifyContext = React.createContext({
|
|
771
771
|
storeDomain: "test.myshopify.com",
|
|
772
772
|
storefrontToken: "abc123",
|
|
@@ -797,7 +797,7 @@ ${cartFragment}
|
|
|
797
797
|
value: finalConfig,
|
|
798
798
|
__self: this,
|
|
799
799
|
__source: {
|
|
800
|
-
fileName: _jsxFileName$
|
|
800
|
+
fileName: _jsxFileName$e,
|
|
801
801
|
lineNumber: 49,
|
|
802
802
|
columnNumber: 5
|
|
803
803
|
}
|
|
@@ -1312,7 +1312,7 @@ ${cartFragment}
|
|
|
1312
1312
|
function isCartFetchResultEvent(event) {
|
|
1313
1313
|
return event.type === "RESOLVE" || event.type === "ERROR" || event.type === "CART_COMPLETED";
|
|
1314
1314
|
}
|
|
1315
|
-
var _jsxFileName$
|
|
1315
|
+
var _jsxFileName$d = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/CartProvider.tsx";
|
|
1316
1316
|
const CartContext = React.createContext(null);
|
|
1317
1317
|
function useCart() {
|
|
1318
1318
|
const context = React.useContext(CartContext);
|
|
@@ -1625,7 +1625,7 @@ ${cartFragment}
|
|
|
1625
1625
|
value: cartContextValue,
|
|
1626
1626
|
__self: this,
|
|
1627
1627
|
__source: {
|
|
1628
|
-
fileName: _jsxFileName$
|
|
1628
|
+
fileName: _jsxFileName$d,
|
|
1629
1629
|
lineNumber: 425,
|
|
1630
1630
|
columnNumber: 5
|
|
1631
1631
|
}
|
|
@@ -1791,7 +1791,7 @@ fragment ImageFragment on Image {
|
|
|
1791
1791
|
height
|
|
1792
1792
|
}
|
|
1793
1793
|
`;
|
|
1794
|
-
var _jsxFileName$
|
|
1794
|
+
var _jsxFileName$c = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ProductProvider.tsx";
|
|
1795
1795
|
const ProductOptionsContext = React.createContext(null);
|
|
1796
1796
|
function ProductProvider({
|
|
1797
1797
|
children,
|
|
@@ -1877,7 +1877,7 @@ fragment ImageFragment on Image {
|
|
|
1877
1877
|
value,
|
|
1878
1878
|
__self: this,
|
|
1879
1879
|
__source: {
|
|
1880
|
-
fileName: _jsxFileName$
|
|
1880
|
+
fileName: _jsxFileName$c,
|
|
1881
1881
|
lineNumber: 201,
|
|
1882
1882
|
columnNumber: 5
|
|
1883
1883
|
}
|
|
@@ -1950,7 +1950,7 @@ fragment ImageFragment on Image {
|
|
|
1950
1950
|
}
|
|
1951
1951
|
return true;
|
|
1952
1952
|
}
|
|
1953
|
-
var _jsxFileName$
|
|
1953
|
+
var _jsxFileName$b = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/BaseButton.tsx";
|
|
1954
1954
|
function BaseButton(props) {
|
|
1955
1955
|
const {
|
|
1956
1956
|
as,
|
|
@@ -1975,13 +1975,13 @@ fragment ImageFragment on Image {
|
|
|
1975
1975
|
...passthroughProps,
|
|
1976
1976
|
__self: this,
|
|
1977
1977
|
__source: {
|
|
1978
|
-
fileName: _jsxFileName$
|
|
1978
|
+
fileName: _jsxFileName$b,
|
|
1979
1979
|
lineNumber: 59,
|
|
1980
1980
|
columnNumber: 5
|
|
1981
1981
|
}
|
|
1982
1982
|
}, children);
|
|
1983
1983
|
}
|
|
1984
|
-
var _jsxFileName$
|
|
1984
|
+
var _jsxFileName$a = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/AddToCartButton.tsx";
|
|
1985
1985
|
function AddToCartButton(props) {
|
|
1986
1986
|
var _a;
|
|
1987
1987
|
const [addingItem, setAddingItem] = React.useState(false);
|
|
@@ -2025,7 +2025,7 @@ fragment ImageFragment on Image {
|
|
|
2025
2025
|
defaultOnClick: handleAddItem,
|
|
2026
2026
|
__self: this,
|
|
2027
2027
|
__source: {
|
|
2028
|
-
fileName: _jsxFileName$
|
|
2028
|
+
fileName: _jsxFileName$a,
|
|
2029
2029
|
lineNumber: 71,
|
|
2030
2030
|
columnNumber: 7
|
|
2031
2031
|
}
|
|
@@ -2045,12 +2045,40 @@ fragment ImageFragment on Image {
|
|
|
2045
2045
|
"aria-live": "assertive",
|
|
2046
2046
|
__self: this,
|
|
2047
2047
|
__source: {
|
|
2048
|
-
fileName: _jsxFileName$
|
|
2048
|
+
fileName: _jsxFileName$a,
|
|
2049
2049
|
lineNumber: 80,
|
|
2050
2050
|
columnNumber: 9
|
|
2051
2051
|
}
|
|
2052
2052
|
}, addingItem ? accessibleAddingToCartLabel : null) : null);
|
|
2053
2053
|
}
|
|
2054
|
+
var _jsxFileName$9 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/CartCheckoutButton.tsx";
|
|
2055
|
+
function CartCheckoutButton(props) {
|
|
2056
|
+
const [requestedCheckout, setRequestedCheckout] = React.useState(false);
|
|
2057
|
+
const {
|
|
2058
|
+
status,
|
|
2059
|
+
checkoutUrl
|
|
2060
|
+
} = useCart();
|
|
2061
|
+
const {
|
|
2062
|
+
children,
|
|
2063
|
+
...passthroughProps
|
|
2064
|
+
} = props;
|
|
2065
|
+
React.useEffect(() => {
|
|
2066
|
+
if (requestedCheckout && checkoutUrl && status === "idle") {
|
|
2067
|
+
window.location.href = checkoutUrl;
|
|
2068
|
+
}
|
|
2069
|
+
}, [requestedCheckout, status, checkoutUrl]);
|
|
2070
|
+
return /* @__PURE__ */ React__default.default.createElement("button", {
|
|
2071
|
+
...passthroughProps,
|
|
2072
|
+
disabled: requestedCheckout || passthroughProps.disabled,
|
|
2073
|
+
onClick: () => setRequestedCheckout(true),
|
|
2074
|
+
__self: this,
|
|
2075
|
+
__source: {
|
|
2076
|
+
fileName: _jsxFileName$9,
|
|
2077
|
+
lineNumber: 27,
|
|
2078
|
+
columnNumber: 5
|
|
2079
|
+
}
|
|
2080
|
+
}, children);
|
|
2081
|
+
}
|
|
2054
2082
|
var _jsxFileName$8 = "/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ExternalVideo.tsx";
|
|
2055
2083
|
function ExternalVideo(props) {
|
|
2056
2084
|
var _a, _b;
|
|
@@ -3358,6 +3386,7 @@ fragment ImageFragment on Image {
|
|
|
3358
3386
|
};
|
|
3359
3387
|
}
|
|
3360
3388
|
exports2.AddToCartButton = AddToCartButton;
|
|
3389
|
+
exports2.CartCheckoutButton = CartCheckoutButton;
|
|
3361
3390
|
exports2.CartProvider = CartProvider;
|
|
3362
3391
|
exports2.ExternalVideo = ExternalVideo;
|
|
3363
3392
|
exports2.Image = Image;
|