@whop/embedded-components-react-js 0.0.5-beta.3 → 0.0.5-beta.5
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/package.json +2 -2
- package/package.json.temp +1 -1
- package/dist/chunk-NSSMTXJJ.mjs +0 -9
- package/dist/chunk-NSSMTXJJ.mjs.map +0 -1
- package/dist/index.d.ts +0 -18
- package/dist/index.js +0 -21
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -3
- package/dist/index.mjs.map +0 -1
- package/dist/lib/use-element-snapshot.d.ts +0 -5
- package/dist/lib/use-element-snapshot.js +0 -64
- package/dist/lib/use-element-snapshot.js.map +0 -1
- package/dist/lib/use-element-snapshot.mjs +0 -41
- package/dist/lib/use-element-snapshot.mjs.map +0 -1
- package/dist/payouts/elements/balance.d.ts +0 -16
- package/dist/payouts/elements/balance.js +0 -86
- package/dist/payouts/elements/balance.js.map +0 -1
- package/dist/payouts/elements/balance.mjs +0 -56
- package/dist/payouts/elements/balance.mjs.map +0 -1
- package/dist/payouts/elements/bnpl-reserve-balance-breakdown.d.ts +0 -16
- package/dist/payouts/elements/bnpl-reserve-balance-breakdown.js +0 -86
- package/dist/payouts/elements/bnpl-reserve-balance-breakdown.js.map +0 -1
- package/dist/payouts/elements/bnpl-reserve-balance-breakdown.mjs +0 -56
- package/dist/payouts/elements/bnpl-reserve-balance-breakdown.mjs.map +0 -1
- package/dist/payouts/elements/change-account-country.d.ts +0 -16
- package/dist/payouts/elements/change-account-country.js +0 -86
- package/dist/payouts/elements/change-account-country.js.map +0 -1
- package/dist/payouts/elements/change-account-country.mjs +0 -56
- package/dist/payouts/elements/change-account-country.mjs.map +0 -1
- package/dist/payouts/elements/generate-withdrawal-receipt.d.ts +0 -16
- package/dist/payouts/elements/generate-withdrawal-receipt.js +0 -86
- package/dist/payouts/elements/generate-withdrawal-receipt.js.map +0 -1
- package/dist/payouts/elements/generate-withdrawal-receipt.mjs +0 -56
- package/dist/payouts/elements/generate-withdrawal-receipt.mjs.map +0 -1
- package/dist/payouts/elements/index.d.ts +0 -15
- package/dist/payouts/elements/index.js +0 -31
- package/dist/payouts/elements/index.js.map +0 -1
- package/dist/payouts/elements/index.mjs +0 -13
- package/dist/payouts/elements/index.mjs.map +0 -1
- package/dist/payouts/elements/pending-balance-breakdown.d.ts +0 -16
- package/dist/payouts/elements/pending-balance-breakdown.js +0 -86
- package/dist/payouts/elements/pending-balance-breakdown.js.map +0 -1
- package/dist/payouts/elements/pending-balance-breakdown.mjs +0 -56
- package/dist/payouts/elements/pending-balance-breakdown.mjs.map +0 -1
- package/dist/payouts/elements/regular-reserve-balance-breakdown.d.ts +0 -16
- package/dist/payouts/elements/regular-reserve-balance-breakdown.js +0 -86
- package/dist/payouts/elements/regular-reserve-balance-breakdown.js.map +0 -1
- package/dist/payouts/elements/regular-reserve-balance-breakdown.mjs +0 -56
- package/dist/payouts/elements/regular-reserve-balance-breakdown.mjs.map +0 -1
- package/dist/payouts/elements/reset-account.d.ts +0 -16
- package/dist/payouts/elements/reset-account.js +0 -86
- package/dist/payouts/elements/reset-account.js.map +0 -1
- package/dist/payouts/elements/reset-account.mjs +0 -56
- package/dist/payouts/elements/reset-account.mjs.map +0 -1
- package/dist/payouts/elements/status-banner.d.ts +0 -18
- package/dist/payouts/elements/status-banner.js +0 -102
- package/dist/payouts/elements/status-banner.js.map +0 -1
- package/dist/payouts/elements/status-banner.mjs +0 -76
- package/dist/payouts/elements/status-banner.mjs.map +0 -1
- package/dist/payouts/elements/total-balance-breakdown.d.ts +0 -16
- package/dist/payouts/elements/total-balance-breakdown.js +0 -86
- package/dist/payouts/elements/total-balance-breakdown.js.map +0 -1
- package/dist/payouts/elements/total-balance-breakdown.mjs +0 -56
- package/dist/payouts/elements/total-balance-breakdown.mjs.map +0 -1
- package/dist/payouts/elements/verify.d.ts +0 -16
- package/dist/payouts/elements/verify.js +0 -83
- package/dist/payouts/elements/verify.js.map +0 -1
- package/dist/payouts/elements/verify.mjs +0 -56
- package/dist/payouts/elements/verify.mjs.map +0 -1
- package/dist/payouts/elements/withdraw-button.d.ts +0 -16
- package/dist/payouts/elements/withdraw-button.js +0 -86
- package/dist/payouts/elements/withdraw-button.js.map +0 -1
- package/dist/payouts/elements/withdraw-button.mjs +0 -56
- package/dist/payouts/elements/withdraw-button.mjs.map +0 -1
- package/dist/payouts/elements/withdrawal-breakdown.d.ts +0 -16
- package/dist/payouts/elements/withdrawal-breakdown.js +0 -86
- package/dist/payouts/elements/withdrawal-breakdown.js.map +0 -1
- package/dist/payouts/elements/withdrawal-breakdown.mjs +0 -56
- package/dist/payouts/elements/withdrawal-breakdown.mjs.map +0 -1
- package/dist/payouts/elements/withdrawals.d.ts +0 -16
- package/dist/payouts/elements/withdrawals.js +0 -86
- package/dist/payouts/elements/withdrawals.js.map +0 -1
- package/dist/payouts/elements/withdrawals.mjs +0 -56
- package/dist/payouts/elements/withdrawals.mjs.map +0 -1
- package/dist/payouts/index.d.ts +0 -16
- package/dist/payouts/index.js +0 -20
- package/dist/payouts/index.js.map +0 -1
- package/dist/payouts/index.mjs +0 -2
- package/dist/payouts/index.mjs.map +0 -1
- package/dist/payouts/session.d.ts +0 -11
- package/dist/payouts/session.js +0 -84
- package/dist/payouts/session.js.map +0 -1
- package/dist/payouts/session.mjs +0 -55
- package/dist/payouts/session.mjs.map +0 -1
- package/dist/payouts/use-session-ref.d.ts +0 -8
- package/dist/payouts/use-session-ref.js +0 -29
- package/dist/payouts/use-session-ref.js.map +0 -1
- package/dist/payouts/use-session-ref.mjs +0 -7
- package/dist/payouts/use-session-ref.mjs.map +0 -1
- package/dist/provider.d.ts +0 -11
- package/dist/provider.js +0 -116
- package/dist/provider.js.map +0 -1
- package/dist/provider.mjs +0 -87
- package/dist/provider.mjs.map +0 -1
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import "../../chunk-NSSMTXJJ.mjs";
|
|
3
|
-
import React, { useEffect, useLayoutEffect, useMemo, useRef } from "react";
|
|
4
|
-
import { useElementSnapshot } from "../../lib/use-element-snapshot.mjs";
|
|
5
|
-
import { usePayoutsSession } from "../session.mjs";
|
|
6
|
-
function WithdrawalBreakdownElement({ options, className, style, onReady, fallback }) {
|
|
7
|
-
const payoutsSession = usePayoutsSession();
|
|
8
|
-
const ref = useRef(null);
|
|
9
|
-
const element = useMemo(()=>{
|
|
10
|
-
if (!payoutsSession) return null;
|
|
11
|
-
const createdElement = payoutsSession.createElement(WithdrawalBreakdownElement, options);
|
|
12
|
-
return createdElement;
|
|
13
|
-
}, [
|
|
14
|
-
payoutsSession
|
|
15
|
-
]);
|
|
16
|
-
const elementSnapshot = useElementSnapshot(element);
|
|
17
|
-
const isReady = elementSnapshot?.state === "ready";
|
|
18
|
-
useEffect(()=>{
|
|
19
|
-
if (!element) return;
|
|
20
|
-
element.updateOptions(options);
|
|
21
|
-
}, [
|
|
22
|
-
options,
|
|
23
|
-
element
|
|
24
|
-
]);
|
|
25
|
-
useEffect(()=>{
|
|
26
|
-
if (!element || !onReady) return;
|
|
27
|
-
element.on("ready", onReady);
|
|
28
|
-
return ()=>{
|
|
29
|
-
element.off("ready", onReady);
|
|
30
|
-
};
|
|
31
|
-
}, [
|
|
32
|
-
element,
|
|
33
|
-
onReady
|
|
34
|
-
]);
|
|
35
|
-
useLayoutEffect(()=>{
|
|
36
|
-
if (!element || !ref.current) return;
|
|
37
|
-
element.mount(ref.current);
|
|
38
|
-
return ()=>{
|
|
39
|
-
element.unmount();
|
|
40
|
-
};
|
|
41
|
-
}, [
|
|
42
|
-
element,
|
|
43
|
-
ref.current
|
|
44
|
-
]);
|
|
45
|
-
return React.createElement(React.Fragment, null, React.createElement("div", {
|
|
46
|
-
style: {
|
|
47
|
-
...style,
|
|
48
|
-
visibility: isReady ? void 0 : "hidden"
|
|
49
|
-
},
|
|
50
|
-
className,
|
|
51
|
-
ref
|
|
52
|
-
}), !isReady && (fallback ?? null));
|
|
53
|
-
}
|
|
54
|
-
WithdrawalBreakdownElement.displayName = "WithdrawalBreakdownElement";
|
|
55
|
-
WithdrawalBreakdownElement.type = "withdrawal-breakdown-element";
|
|
56
|
-
export { WithdrawalBreakdownElement };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/payouts/elements/withdrawal-breakdown.tsx"],"sourcesContent":["\"use client\";\n\nimport type { WithdrawalBreakdownElementOptions } from \"@whop/embedded-components-vanilla-js/types\";\n\nimport React, { useEffect, useLayoutEffect, useMemo, useRef } from \"react\";\nimport { useElementSnapshot } from \"../../lib/use-element-snapshot\";\nimport { usePayoutsSession } from \"../session\";\n\nexport function WithdrawalBreakdownElement({\n\toptions,\n\tclassName,\n\tstyle,\n\tonReady,\n\tfallback,\n}: {\n\toptions: WithdrawalBreakdownElementOptions;\n\tclassName?: string;\n\tstyle?: React.CSSProperties;\n\tonReady?: () => void;\n\tfallback?: React.ReactNode;\n}) {\n\tconst payoutsSession = usePayoutsSession();\n\tconst ref = useRef<HTMLDivElement>(null);\n\tconst element = useMemo(() => {\n\t\tif (!payoutsSession) return null;\n\t\tconst createdElement = payoutsSession.createElement(\n\t\t\tWithdrawalBreakdownElement,\n\t\t\toptions,\n\t\t);\n\t\treturn createdElement;\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [payoutsSession]);\n\n\tconst elementSnapshot = useElementSnapshot(element);\n\n\tconst isReady = elementSnapshot?.state === \"ready\";\n\n\tuseEffect(() => {\n\t\tif (!element) return;\n\t\telement.updateOptions(options);\n\t}, [options, element]);\n\n\tuseEffect(() => {\n\t\tif (!element || !onReady) return;\n\t\telement.on(\"ready\", onReady);\n\t\treturn () => {\n\t\t\telement.off(\"ready\", onReady);\n\t\t};\n\t}, [element, onReady]);\n\n\tuseLayoutEffect(() => {\n\t\tif (!element || !ref.current) return;\n\t\telement.mount(ref.current);\n\t\treturn () => {\n\t\t\telement.unmount();\n\t\t};\n\t}, [element, ref.current]);\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tstyle={{ ...style, visibility: isReady ? undefined : \"hidden\" }}\n\t\t\t\tclassName={className}\n\t\t\t\tref={ref}\n\t\t\t/>\n\t\t\t{!isReady && (fallback ?? null)}\n\t\t</>\n\t);\n}\n\nWithdrawalBreakdownElement.displayName = \"WithdrawalBreakdownElement\";\nWithdrawalBreakdownElement.type = \"withdrawal-breakdown-element\" as const;\n"],"mappings":";;AAIA,OAAO,SAAS,WAAW,iBAAiB,SAAS,cAAc;AACnE,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAE3B,SAAS,2BAA2B;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAMG;AACF,QAAM,iBAAiB,kBAAkB;AACzC,QAAM,MAAM,OAAuB,IAAI;AACvC,QAAM,UAAU,QAAQ,MAAM;AAC7B,QAAI,CAAC,eAAgB,QAAO;AAC5B,UAAM,iBAAiB,eAAe;AAAA,MACrC;AAAA,MACA;AAAA,IACD;AACA,WAAO;AAAA,EAER,GAAG,CAAC,cAAc,CAAC;AAEnB,QAAM,kBAAkB,mBAAmB,OAAO;AAElD,QAAM,UAAU,iBAAiB,UAAU;AAE3C,YAAU,MAAM;AACf,QAAI,CAAC,QAAS;AACd,YAAQ,cAAc,OAAO;AAAA,EAC9B,GAAG,CAAC,SAAS,OAAO,CAAC;AAErB,YAAU,MAAM;AACf,QAAI,CAAC,WAAW,CAAC,QAAS;AAC1B,YAAQ,GAAG,SAAS,OAAO;AAC3B,WAAO,MAAM;AACZ,cAAQ,IAAI,SAAS,OAAO;AAAA,IAC7B;AAAA,EACD,GAAG,CAAC,SAAS,OAAO,CAAC;AAErB,kBAAgB,MAAM;AACrB,QAAI,CAAC,WAAW,CAAC,IAAI,QAAS;AAC9B,YAAQ,MAAM,IAAI,OAAO;AACzB,WAAO,MAAM;AACZ,cAAQ,QAAQ;AAAA,IACjB;AAAA,EACD,GAAG,CAAC,SAAS,IAAI,OAAO,CAAC;AAEzB,SACC,0DACC;AAAA,IAAC;AAAA;AAAA,MACA,OAAO,EAAE,GAAG,OAAO,YAAY,UAAU,SAAY,SAAS;AAAA,MAC9D;AAAA,MACA;AAAA;AAAA,EACD,GACC,CAAC,YAAY,YAAY,KAC3B;AAEF;AAEA,2BAA2B,cAAc;AACzC,2BAA2B,OAAO;","names":[]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { WithdrawalsElementOptions } from '@whop/embedded-components-vanilla-js/types';
|
|
2
|
-
import React__default from 'react';
|
|
3
|
-
|
|
4
|
-
declare function WithdrawalsElement({ options, className, style, onReady, fallback, }: {
|
|
5
|
-
options?: WithdrawalsElementOptions;
|
|
6
|
-
className?: string;
|
|
7
|
-
style?: React__default.CSSProperties;
|
|
8
|
-
onReady?: () => void;
|
|
9
|
-
fallback?: React__default.ReactNode;
|
|
10
|
-
}): React__default.JSX.Element;
|
|
11
|
-
declare namespace WithdrawalsElement {
|
|
12
|
-
var displayName: string;
|
|
13
|
-
var type: "withdrawals-element";
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { WithdrawalsElement };
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
var withdrawals_exports = {};
|
|
31
|
-
__export(withdrawals_exports, {
|
|
32
|
-
WithdrawalsElement: () => WithdrawalsElement
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(withdrawals_exports);
|
|
35
|
-
var import_react = __toESM(require("react"));
|
|
36
|
-
var import_use_element_snapshot = require("../../lib/use-element-snapshot");
|
|
37
|
-
var import_session = require("../session");
|
|
38
|
-
function WithdrawalsElement({
|
|
39
|
-
options = {},
|
|
40
|
-
className,
|
|
41
|
-
style,
|
|
42
|
-
onReady,
|
|
43
|
-
fallback
|
|
44
|
-
}) {
|
|
45
|
-
const payoutsSession = (0, import_session.usePayoutsSession)();
|
|
46
|
-
const ref = (0, import_react.useRef)(null);
|
|
47
|
-
const element = (0, import_react.useMemo)(() => {
|
|
48
|
-
if (!payoutsSession) return null;
|
|
49
|
-
const createdElement = payoutsSession.createElement(
|
|
50
|
-
WithdrawalsElement,
|
|
51
|
-
options
|
|
52
|
-
);
|
|
53
|
-
return createdElement;
|
|
54
|
-
}, [payoutsSession]);
|
|
55
|
-
const elementSnapshot = (0, import_use_element_snapshot.useElementSnapshot)(element);
|
|
56
|
-
const isReady = elementSnapshot?.state === "ready";
|
|
57
|
-
(0, import_react.useEffect)(() => {
|
|
58
|
-
if (!element) return;
|
|
59
|
-
element.updateOptions(options);
|
|
60
|
-
}, [options, element]);
|
|
61
|
-
(0, import_react.useEffect)(() => {
|
|
62
|
-
if (!element || !onReady) return;
|
|
63
|
-
element.on("ready", onReady);
|
|
64
|
-
return () => {
|
|
65
|
-
element.off("ready", onReady);
|
|
66
|
-
};
|
|
67
|
-
}, [element, onReady]);
|
|
68
|
-
(0, import_react.useLayoutEffect)(() => {
|
|
69
|
-
if (!element || !ref.current) return;
|
|
70
|
-
element.mount(ref.current);
|
|
71
|
-
return () => {
|
|
72
|
-
element.unmount();
|
|
73
|
-
};
|
|
74
|
-
}, [element, ref.current]);
|
|
75
|
-
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
|
|
76
|
-
"div",
|
|
77
|
-
{
|
|
78
|
-
style: { ...style, visibility: isReady ? void 0 : "hidden" },
|
|
79
|
-
className,
|
|
80
|
-
ref
|
|
81
|
-
}
|
|
82
|
-
), !isReady && (fallback ?? null));
|
|
83
|
-
}
|
|
84
|
-
WithdrawalsElement.displayName = "WithdrawalsElement";
|
|
85
|
-
WithdrawalsElement.type = "withdrawals-element";
|
|
86
|
-
//# sourceMappingURL=withdrawals.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/payouts/elements/withdrawals.tsx"],"sourcesContent":["\"use client\";\n\nimport type { WithdrawalsElementOptions } from \"@whop/embedded-components-vanilla-js/types\";\n\nimport React, { useEffect, useLayoutEffect, useMemo, useRef } from \"react\";\nimport { useElementSnapshot } from \"../../lib/use-element-snapshot\";\nimport { usePayoutsSession } from \"../session\";\n\nexport function WithdrawalsElement({\n\toptions = {},\n\tclassName,\n\tstyle,\n\tonReady,\n\tfallback,\n}: {\n\toptions?: WithdrawalsElementOptions;\n\tclassName?: string;\n\tstyle?: React.CSSProperties;\n\tonReady?: () => void;\n\tfallback?: React.ReactNode;\n}) {\n\tconst payoutsSession = usePayoutsSession();\n\tconst ref = useRef<HTMLDivElement>(null);\n\tconst element = useMemo(() => {\n\t\tif (!payoutsSession) return null;\n\t\tconst createdElement = payoutsSession.createElement(\n\t\t\tWithdrawalsElement,\n\t\t\toptions,\n\t\t);\n\t\treturn createdElement;\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [payoutsSession]);\n\n\tconst elementSnapshot = useElementSnapshot(element);\n\n\tconst isReady = elementSnapshot?.state === \"ready\";\n\n\tuseEffect(() => {\n\t\tif (!element) return;\n\t\telement.updateOptions(options);\n\t}, [options, element]);\n\n\tuseEffect(() => {\n\t\tif (!element || !onReady) return;\n\t\telement.on(\"ready\", onReady);\n\t\treturn () => {\n\t\t\telement.off(\"ready\", onReady);\n\t\t};\n\t}, [element, onReady]);\n\n\tuseLayoutEffect(() => {\n\t\tif (!element || !ref.current) return;\n\t\telement.mount(ref.current);\n\t\treturn () => {\n\t\t\telement.unmount();\n\t\t};\n\t}, [element, ref.current]);\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tstyle={{ ...style, visibility: isReady ? undefined : \"hidden\" }}\n\t\t\t\tclassName={className}\n\t\t\t\tref={ref}\n\t\t\t/>\n\t\t\t{!isReady && (fallback ?? null)}\n\t\t</>\n\t);\n}\n\nWithdrawalsElement.displayName = \"WithdrawalsElement\";\nWithdrawalsElement.type = \"withdrawals-element\" as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,mBAAmE;AACnE,kCAAmC;AACnC,qBAAkC;AAE3B,SAAS,mBAAmB;AAAA,EAClC,UAAU,CAAC;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAMG;AACF,QAAM,qBAAiB,kCAAkB;AACzC,QAAM,UAAM,qBAAuB,IAAI;AACvC,QAAM,cAAU,sBAAQ,MAAM;AAC7B,QAAI,CAAC,eAAgB,QAAO;AAC5B,UAAM,iBAAiB,eAAe;AAAA,MACrC;AAAA,MACA;AAAA,IACD;AACA,WAAO;AAAA,EAER,GAAG,CAAC,cAAc,CAAC;AAEnB,QAAM,sBAAkB,gDAAmB,OAAO;AAElD,QAAM,UAAU,iBAAiB,UAAU;AAE3C,8BAAU,MAAM;AACf,QAAI,CAAC,QAAS;AACd,YAAQ,cAAc,OAAO;AAAA,EAC9B,GAAG,CAAC,SAAS,OAAO,CAAC;AAErB,8BAAU,MAAM;AACf,QAAI,CAAC,WAAW,CAAC,QAAS;AAC1B,YAAQ,GAAG,SAAS,OAAO;AAC3B,WAAO,MAAM;AACZ,cAAQ,IAAI,SAAS,OAAO;AAAA,IAC7B;AAAA,EACD,GAAG,CAAC,SAAS,OAAO,CAAC;AAErB,oCAAgB,MAAM;AACrB,QAAI,CAAC,WAAW,CAAC,IAAI,QAAS;AAC9B,YAAQ,MAAM,IAAI,OAAO;AACzB,WAAO,MAAM;AACZ,cAAQ,QAAQ;AAAA,IACjB;AAAA,EACD,GAAG,CAAC,SAAS,IAAI,OAAO,CAAC;AAEzB,SACC,6BAAAA,QAAA,2BAAAA,QAAA,gBACC,6BAAAA,QAAA;AAAA,IAAC;AAAA;AAAA,MACA,OAAO,EAAE,GAAG,OAAO,YAAY,UAAU,SAAY,SAAS;AAAA,MAC9D;AAAA,MACA;AAAA;AAAA,EACD,GACC,CAAC,YAAY,YAAY,KAC3B;AAEF;AAEA,mBAAmB,cAAc;AACjC,mBAAmB,OAAO;","names":["React"]}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import "../../chunk-NSSMTXJJ.mjs";
|
|
3
|
-
import React, { useEffect, useLayoutEffect, useMemo, useRef } from "react";
|
|
4
|
-
import { useElementSnapshot } from "../../lib/use-element-snapshot.mjs";
|
|
5
|
-
import { usePayoutsSession } from "../session.mjs";
|
|
6
|
-
function WithdrawalsElement({ options = {}, className, style, onReady, fallback }) {
|
|
7
|
-
const payoutsSession = usePayoutsSession();
|
|
8
|
-
const ref = useRef(null);
|
|
9
|
-
const element = useMemo(()=>{
|
|
10
|
-
if (!payoutsSession) return null;
|
|
11
|
-
const createdElement = payoutsSession.createElement(WithdrawalsElement, options);
|
|
12
|
-
return createdElement;
|
|
13
|
-
}, [
|
|
14
|
-
payoutsSession
|
|
15
|
-
]);
|
|
16
|
-
const elementSnapshot = useElementSnapshot(element);
|
|
17
|
-
const isReady = elementSnapshot?.state === "ready";
|
|
18
|
-
useEffect(()=>{
|
|
19
|
-
if (!element) return;
|
|
20
|
-
element.updateOptions(options);
|
|
21
|
-
}, [
|
|
22
|
-
options,
|
|
23
|
-
element
|
|
24
|
-
]);
|
|
25
|
-
useEffect(()=>{
|
|
26
|
-
if (!element || !onReady) return;
|
|
27
|
-
element.on("ready", onReady);
|
|
28
|
-
return ()=>{
|
|
29
|
-
element.off("ready", onReady);
|
|
30
|
-
};
|
|
31
|
-
}, [
|
|
32
|
-
element,
|
|
33
|
-
onReady
|
|
34
|
-
]);
|
|
35
|
-
useLayoutEffect(()=>{
|
|
36
|
-
if (!element || !ref.current) return;
|
|
37
|
-
element.mount(ref.current);
|
|
38
|
-
return ()=>{
|
|
39
|
-
element.unmount();
|
|
40
|
-
};
|
|
41
|
-
}, [
|
|
42
|
-
element,
|
|
43
|
-
ref.current
|
|
44
|
-
]);
|
|
45
|
-
return React.createElement(React.Fragment, null, React.createElement("div", {
|
|
46
|
-
style: {
|
|
47
|
-
...style,
|
|
48
|
-
visibility: isReady ? void 0 : "hidden"
|
|
49
|
-
},
|
|
50
|
-
className,
|
|
51
|
-
ref
|
|
52
|
-
}), !isReady && (fallback ?? null));
|
|
53
|
-
}
|
|
54
|
-
WithdrawalsElement.displayName = "WithdrawalsElement";
|
|
55
|
-
WithdrawalsElement.type = "withdrawals-element";
|
|
56
|
-
export { WithdrawalsElement };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/payouts/elements/withdrawals.tsx"],"sourcesContent":["\"use client\";\n\nimport type { WithdrawalsElementOptions } from \"@whop/embedded-components-vanilla-js/types\";\n\nimport React, { useEffect, useLayoutEffect, useMemo, useRef } from \"react\";\nimport { useElementSnapshot } from \"../../lib/use-element-snapshot\";\nimport { usePayoutsSession } from \"../session\";\n\nexport function WithdrawalsElement({\n\toptions = {},\n\tclassName,\n\tstyle,\n\tonReady,\n\tfallback,\n}: {\n\toptions?: WithdrawalsElementOptions;\n\tclassName?: string;\n\tstyle?: React.CSSProperties;\n\tonReady?: () => void;\n\tfallback?: React.ReactNode;\n}) {\n\tconst payoutsSession = usePayoutsSession();\n\tconst ref = useRef<HTMLDivElement>(null);\n\tconst element = useMemo(() => {\n\t\tif (!payoutsSession) return null;\n\t\tconst createdElement = payoutsSession.createElement(\n\t\t\tWithdrawalsElement,\n\t\t\toptions,\n\t\t);\n\t\treturn createdElement;\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [payoutsSession]);\n\n\tconst elementSnapshot = useElementSnapshot(element);\n\n\tconst isReady = elementSnapshot?.state === \"ready\";\n\n\tuseEffect(() => {\n\t\tif (!element) return;\n\t\telement.updateOptions(options);\n\t}, [options, element]);\n\n\tuseEffect(() => {\n\t\tif (!element || !onReady) return;\n\t\telement.on(\"ready\", onReady);\n\t\treturn () => {\n\t\t\telement.off(\"ready\", onReady);\n\t\t};\n\t}, [element, onReady]);\n\n\tuseLayoutEffect(() => {\n\t\tif (!element || !ref.current) return;\n\t\telement.mount(ref.current);\n\t\treturn () => {\n\t\t\telement.unmount();\n\t\t};\n\t}, [element, ref.current]);\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tstyle={{ ...style, visibility: isReady ? undefined : \"hidden\" }}\n\t\t\t\tclassName={className}\n\t\t\t\tref={ref}\n\t\t\t/>\n\t\t\t{!isReady && (fallback ?? null)}\n\t\t</>\n\t);\n}\n\nWithdrawalsElement.displayName = \"WithdrawalsElement\";\nWithdrawalsElement.type = \"withdrawals-element\" as const;\n"],"mappings":";;AAIA,OAAO,SAAS,WAAW,iBAAiB,SAAS,cAAc;AACnE,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAE3B,SAAS,mBAAmB;AAAA,EAClC,UAAU,CAAC;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAMG;AACF,QAAM,iBAAiB,kBAAkB;AACzC,QAAM,MAAM,OAAuB,IAAI;AACvC,QAAM,UAAU,QAAQ,MAAM;AAC7B,QAAI,CAAC,eAAgB,QAAO;AAC5B,UAAM,iBAAiB,eAAe;AAAA,MACrC;AAAA,MACA;AAAA,IACD;AACA,WAAO;AAAA,EAER,GAAG,CAAC,cAAc,CAAC;AAEnB,QAAM,kBAAkB,mBAAmB,OAAO;AAElD,QAAM,UAAU,iBAAiB,UAAU;AAE3C,YAAU,MAAM;AACf,QAAI,CAAC,QAAS;AACd,YAAQ,cAAc,OAAO;AAAA,EAC9B,GAAG,CAAC,SAAS,OAAO,CAAC;AAErB,YAAU,MAAM;AACf,QAAI,CAAC,WAAW,CAAC,QAAS;AAC1B,YAAQ,GAAG,SAAS,OAAO;AAC3B,WAAO,MAAM;AACZ,cAAQ,IAAI,SAAS,OAAO;AAAA,IAC7B;AAAA,EACD,GAAG,CAAC,SAAS,OAAO,CAAC;AAErB,kBAAgB,MAAM;AACrB,QAAI,CAAC,WAAW,CAAC,IAAI,QAAS;AAC9B,YAAQ,MAAM,IAAI,OAAO;AACzB,WAAO,MAAM;AACZ,cAAQ,QAAQ;AAAA,IACjB;AAAA,EACD,GAAG,CAAC,SAAS,IAAI,OAAO,CAAC;AAEzB,SACC,0DACC;AAAA,IAAC;AAAA;AAAA,MACA,OAAO,EAAE,GAAG,OAAO,YAAY,UAAU,SAAY,SAAS;AAAA,MAC9D;AAAA,MACA;AAAA;AAAA,EACD,GACC,CAAC,YAAY,YAAY,KAC3B;AAEF;AAEA,mBAAmB,cAAc;AACjC,mBAAmB,OAAO;","names":[]}
|
package/dist/payouts/index.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export { PayoutsSession, usePayoutsSession } from './session.js';
|
|
2
|
-
export { BalanceElement } from './elements/balance.js';
|
|
3
|
-
export { ChangeAccountCountryElement } from './elements/change-account-country.js';
|
|
4
|
-
export { ResetAccountElement } from './elements/reset-account.js';
|
|
5
|
-
export { VerifyElement } from './elements/verify.js';
|
|
6
|
-
export { WithdrawButtonElement } from './elements/withdraw-button.js';
|
|
7
|
-
export { WithdrawalBreakdownElement } from './elements/withdrawal-breakdown.js';
|
|
8
|
-
export { WithdrawalsElement } from './elements/withdrawals.js';
|
|
9
|
-
export { TotalBalanceBreakdownElement } from './elements/total-balance-breakdown.js';
|
|
10
|
-
export { PendingBalanceBreakdownElement } from './elements/pending-balance-breakdown.js';
|
|
11
|
-
export { RegularReserveBalanceBreakdownElement } from './elements/regular-reserve-balance-breakdown.js';
|
|
12
|
-
export { BnplReserveBalanceBreakdownElement } from './elements/bnpl-reserve-balance-breakdown.js';
|
|
13
|
-
export { GenerateWithdrawalReceiptElement } from './elements/generate-withdrawal-receipt.js';
|
|
14
|
-
export { StatusBannerElement } from './elements/status-banner.js';
|
|
15
|
-
import '@whop/embedded-components-vanilla-js/types';
|
|
16
|
-
import 'react';
|
package/dist/payouts/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
var payouts_exports = {};
|
|
17
|
-
module.exports = __toCommonJS(payouts_exports);
|
|
18
|
-
__reExport(payouts_exports, require("./session"), module.exports);
|
|
19
|
-
__reExport(payouts_exports, require("./elements"), module.exports);
|
|
20
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/payouts/index.tsx"],"sourcesContent":["export * from \"./session\";\nexport * from \"./elements\";\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,4BAAc,sBAAd;AACA,4BAAc,uBADd;","names":[]}
|
package/dist/payouts/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/payouts/index.tsx"],"sourcesContent":["export * from \"./session\";\nexport * from \"./elements\";\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { PayoutsSession as PayoutsSession$1, PayoutsSessionOptions } from '@whop/embedded-components-vanilla-js/types';
|
|
2
|
-
import React__default, { PropsWithChildren } from 'react';
|
|
3
|
-
|
|
4
|
-
declare function usePayoutsSession(): PayoutsSession$1 | null;
|
|
5
|
-
declare function PayoutsSession({ children, currency, companyId, token, redirectUrl, ref, }: PropsWithChildren<PayoutsSessionOptions & {
|
|
6
|
-
ref?: React__default.RefObject<{
|
|
7
|
-
payoutsSession: PayoutsSession$1 | null;
|
|
8
|
-
} | null>;
|
|
9
|
-
}>): React__default.JSX.Element;
|
|
10
|
-
|
|
11
|
-
export { PayoutsSession, usePayoutsSession };
|
package/dist/payouts/session.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
var session_exports = {};
|
|
31
|
-
__export(session_exports, {
|
|
32
|
-
PayoutsSession: () => PayoutsSession,
|
|
33
|
-
usePayoutsSession: () => usePayoutsSession
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(session_exports);
|
|
36
|
-
var import_react = __toESM(require("react"));
|
|
37
|
-
var import_provider = require("../provider");
|
|
38
|
-
const PayoutsSessionContext = (0, import_react.createContext)(null);
|
|
39
|
-
function usePayoutsSession() {
|
|
40
|
-
const ctx = (0, import_react.useContext)(PayoutsSessionContext);
|
|
41
|
-
if (!ctx) {
|
|
42
|
-
throw new Error(
|
|
43
|
-
"usePayoutsSession must be used within a PayoutsSessionProvider"
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
return ctx.payoutsSession;
|
|
47
|
-
}
|
|
48
|
-
function PayoutsSession({
|
|
49
|
-
children,
|
|
50
|
-
currency,
|
|
51
|
-
companyId,
|
|
52
|
-
token,
|
|
53
|
-
redirectUrl,
|
|
54
|
-
ref
|
|
55
|
-
}) {
|
|
56
|
-
const elements = (0, import_provider.useElements)();
|
|
57
|
-
const payoutsSession = (0, import_react.useMemo)(() => {
|
|
58
|
-
if (!elements) return null;
|
|
59
|
-
return elements.createPayoutsSession({
|
|
60
|
-
token,
|
|
61
|
-
currency,
|
|
62
|
-
companyId,
|
|
63
|
-
redirectUrl
|
|
64
|
-
});
|
|
65
|
-
}, [elements]);
|
|
66
|
-
(0, import_react.useEffect)(() => {
|
|
67
|
-
if (!payoutsSession) return;
|
|
68
|
-
payoutsSession.updateOptions({
|
|
69
|
-
token,
|
|
70
|
-
currency,
|
|
71
|
-
companyId,
|
|
72
|
-
redirectUrl
|
|
73
|
-
});
|
|
74
|
-
}, [payoutsSession, currency, token, companyId, redirectUrl]);
|
|
75
|
-
const value = (0, import_react.useMemo)(
|
|
76
|
-
() => ({
|
|
77
|
-
payoutsSession
|
|
78
|
-
}),
|
|
79
|
-
[payoutsSession]
|
|
80
|
-
);
|
|
81
|
-
(0, import_react.useImperativeHandle)(ref, () => ({ payoutsSession }), [payoutsSession]);
|
|
82
|
-
return /* @__PURE__ */ import_react.default.createElement(PayoutsSessionContext.Provider, { value }, children);
|
|
83
|
-
}
|
|
84
|
-
//# sourceMappingURL=session.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/payouts/session.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n\tPayoutsSessionOptions,\n\tPayoutsSession as PayoutsSessionType,\n} from \"@whop/embedded-components-vanilla-js/types\";\nimport type { PropsWithChildren } from \"react\";\n\nimport React, {\n\tcreateContext,\n\tuseContext,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseMemo,\n} from \"react\";\nimport { useElements } from \"../provider\";\n\ninterface ContextState {\n\tpayoutsSession: PayoutsSessionType | null;\n}\n\nconst PayoutsSessionContext = createContext<ContextState | null>(null);\n\nexport function usePayoutsSession() {\n\tconst ctx = useContext(PayoutsSessionContext);\n\tif (!ctx) {\n\t\tthrow new Error(\n\t\t\t\"usePayoutsSession must be used within a PayoutsSessionProvider\",\n\t\t);\n\t}\n\treturn ctx.payoutsSession;\n}\n\nexport function PayoutsSession({\n\tchildren,\n\tcurrency,\n\tcompanyId,\n\ttoken,\n\tredirectUrl,\n\tref,\n}: PropsWithChildren<\n\tPayoutsSessionOptions & {\n\t\tref?: React.RefObject<{\n\t\t\tpayoutsSession: PayoutsSessionType | null;\n\t\t} | null>;\n\t}\n>) {\n\tconst elements = useElements();\n\n\tconst payoutsSession = useMemo(() => {\n\t\tif (!elements) return null;\n\t\treturn elements.createPayoutsSession({\n\t\t\ttoken,\n\t\t\tcurrency,\n\t\t\tcompanyId,\n\t\t\tredirectUrl,\n\t\t});\n\t}, [elements]);\n\n\tuseEffect(() => {\n\t\tif (!payoutsSession) return;\n\n\t\tpayoutsSession.updateOptions({\n\t\t\ttoken,\n\t\t\tcurrency,\n\t\t\tcompanyId,\n\t\t\tredirectUrl,\n\t\t});\n\t}, [payoutsSession, currency, token, companyId, redirectUrl]);\n\n\tconst value: ContextState = useMemo(\n\t\t() => ({\n\t\t\tpayoutsSession,\n\t\t}),\n\t\t[payoutsSession],\n\t);\n\n\tuseImperativeHandle(ref, () => ({ payoutsSession }), [payoutsSession]);\n\n\treturn (\n\t\t<PayoutsSessionContext.Provider value={value}>\n\t\t\t{children}\n\t\t</PayoutsSessionContext.Provider>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,mBAMO;AACP,sBAA4B;AAM5B,MAAM,4BAAwB,4BAAmC,IAAI;AAE9D,SAAS,oBAAoB;AACnC,QAAM,UAAM,yBAAW,qBAAqB;AAC5C,MAAI,CAAC,KAAK;AACT,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AACA,SAAO,IAAI;AACZ;AAEO,SAAS,eAAe;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAMG;AACF,QAAM,eAAW,6BAAY;AAE7B,QAAM,qBAAiB,sBAAQ,MAAM;AACpC,QAAI,CAAC,SAAU,QAAO;AACtB,WAAO,SAAS,qBAAqB;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAC;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AAEb,8BAAU,MAAM;AACf,QAAI,CAAC,eAAgB;AAErB,mBAAe,cAAc;AAAA,MAC5B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAC;AAAA,EACF,GAAG,CAAC,gBAAgB,UAAU,OAAO,WAAW,WAAW,CAAC;AAE5D,QAAM,YAAsB;AAAA,IAC3B,OAAO;AAAA,MACN;AAAA,IACD;AAAA,IACA,CAAC,cAAc;AAAA,EAChB;AAEA,wCAAoB,KAAK,OAAO,EAAE,eAAe,IAAI,CAAC,cAAc,CAAC;AAErE,SACC,6BAAAA,QAAA,cAAC,sBAAsB,UAAtB,EAA+B,SAC9B,QACF;AAEF;","names":["React"]}
|
package/dist/payouts/session.mjs
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import "../chunk-NSSMTXJJ.mjs";
|
|
3
|
-
import React, { createContext, useContext, useEffect, useImperativeHandle, useMemo } from "react";
|
|
4
|
-
import { useElements } from "../provider.mjs";
|
|
5
|
-
const PayoutsSessionContext = createContext(null);
|
|
6
|
-
function usePayoutsSession() {
|
|
7
|
-
const ctx = useContext(PayoutsSessionContext);
|
|
8
|
-
if (!ctx) {
|
|
9
|
-
throw new Error("usePayoutsSession must be used within a PayoutsSessionProvider");
|
|
10
|
-
}
|
|
11
|
-
return ctx.payoutsSession;
|
|
12
|
-
}
|
|
13
|
-
function PayoutsSession({ children, currency, companyId, token, redirectUrl, ref }) {
|
|
14
|
-
const elements = useElements();
|
|
15
|
-
const payoutsSession = useMemo(()=>{
|
|
16
|
-
if (!elements) return null;
|
|
17
|
-
return elements.createPayoutsSession({
|
|
18
|
-
token,
|
|
19
|
-
currency,
|
|
20
|
-
companyId,
|
|
21
|
-
redirectUrl
|
|
22
|
-
});
|
|
23
|
-
}, [
|
|
24
|
-
elements
|
|
25
|
-
]);
|
|
26
|
-
useEffect(()=>{
|
|
27
|
-
if (!payoutsSession) return;
|
|
28
|
-
payoutsSession.updateOptions({
|
|
29
|
-
token,
|
|
30
|
-
currency,
|
|
31
|
-
companyId,
|
|
32
|
-
redirectUrl
|
|
33
|
-
});
|
|
34
|
-
}, [
|
|
35
|
-
payoutsSession,
|
|
36
|
-
currency,
|
|
37
|
-
token,
|
|
38
|
-
companyId,
|
|
39
|
-
redirectUrl
|
|
40
|
-
]);
|
|
41
|
-
const value = useMemo(()=>({
|
|
42
|
-
payoutsSession
|
|
43
|
-
}), [
|
|
44
|
-
payoutsSession
|
|
45
|
-
]);
|
|
46
|
-
useImperativeHandle(ref, ()=>({
|
|
47
|
-
payoutsSession
|
|
48
|
-
}), [
|
|
49
|
-
payoutsSession
|
|
50
|
-
]);
|
|
51
|
-
return React.createElement(PayoutsSessionContext.Provider, {
|
|
52
|
-
value
|
|
53
|
-
}, children);
|
|
54
|
-
}
|
|
55
|
-
export { PayoutsSession, usePayoutsSession };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/payouts/session.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n\tPayoutsSessionOptions,\n\tPayoutsSession as PayoutsSessionType,\n} from \"@whop/embedded-components-vanilla-js/types\";\nimport type { PropsWithChildren } from \"react\";\n\nimport React, {\n\tcreateContext,\n\tuseContext,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseMemo,\n} from \"react\";\nimport { useElements } from \"../provider\";\n\ninterface ContextState {\n\tpayoutsSession: PayoutsSessionType | null;\n}\n\nconst PayoutsSessionContext = createContext<ContextState | null>(null);\n\nexport function usePayoutsSession() {\n\tconst ctx = useContext(PayoutsSessionContext);\n\tif (!ctx) {\n\t\tthrow new Error(\n\t\t\t\"usePayoutsSession must be used within a PayoutsSessionProvider\",\n\t\t);\n\t}\n\treturn ctx.payoutsSession;\n}\n\nexport function PayoutsSession({\n\tchildren,\n\tcurrency,\n\tcompanyId,\n\ttoken,\n\tredirectUrl,\n\tref,\n}: PropsWithChildren<\n\tPayoutsSessionOptions & {\n\t\tref?: React.RefObject<{\n\t\t\tpayoutsSession: PayoutsSessionType | null;\n\t\t} | null>;\n\t}\n>) {\n\tconst elements = useElements();\n\n\tconst payoutsSession = useMemo(() => {\n\t\tif (!elements) return null;\n\t\treturn elements.createPayoutsSession({\n\t\t\ttoken,\n\t\t\tcurrency,\n\t\t\tcompanyId,\n\t\t\tredirectUrl,\n\t\t});\n\t}, [elements]);\n\n\tuseEffect(() => {\n\t\tif (!payoutsSession) return;\n\n\t\tpayoutsSession.updateOptions({\n\t\t\ttoken,\n\t\t\tcurrency,\n\t\t\tcompanyId,\n\t\t\tredirectUrl,\n\t\t});\n\t}, [payoutsSession, currency, token, companyId, redirectUrl]);\n\n\tconst value: ContextState = useMemo(\n\t\t() => ({\n\t\t\tpayoutsSession,\n\t\t}),\n\t\t[payoutsSession],\n\t);\n\n\tuseImperativeHandle(ref, () => ({ payoutsSession }), [payoutsSession]);\n\n\treturn (\n\t\t<PayoutsSessionContext.Provider value={value}>\n\t\t\t{children}\n\t\t</PayoutsSessionContext.Provider>\n\t);\n}\n"],"mappings":";;AAQA,OAAO;AAAA,EACN;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,mBAAmB;AAM5B,MAAM,wBAAwB,cAAmC,IAAI;AAE9D,SAAS,oBAAoB;AACnC,QAAM,MAAM,WAAW,qBAAqB;AAC5C,MAAI,CAAC,KAAK;AACT,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AACA,SAAO,IAAI;AACZ;AAEO,SAAS,eAAe;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAMG;AACF,QAAM,WAAW,YAAY;AAE7B,QAAM,iBAAiB,QAAQ,MAAM;AACpC,QAAI,CAAC,SAAU,QAAO;AACtB,WAAO,SAAS,qBAAqB;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAC;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AAEb,YAAU,MAAM;AACf,QAAI,CAAC,eAAgB;AAErB,mBAAe,cAAc;AAAA,MAC5B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAC;AAAA,EACF,GAAG,CAAC,gBAAgB,UAAU,OAAO,WAAW,WAAW,CAAC;AAE5D,QAAM,QAAsB;AAAA,IAC3B,OAAO;AAAA,MACN;AAAA,IACD;AAAA,IACA,CAAC,cAAc;AAAA,EAChB;AAEA,sBAAoB,KAAK,OAAO,EAAE,eAAe,IAAI,CAAC,cAAc,CAAC;AAErE,SACC,oCAAC,sBAAsB,UAAtB,EAA+B,SAC9B,QACF;AAEF;","names":[]}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var use_session_ref_exports = {};
|
|
20
|
-
__export(use_session_ref_exports, {
|
|
21
|
-
usePayoutsSessionRef: () => usePayoutsSessionRef
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(use_session_ref_exports);
|
|
24
|
-
var import_react = require("react");
|
|
25
|
-
function usePayoutsSessionRef() {
|
|
26
|
-
const ref = (0, import_react.useRef)(null);
|
|
27
|
-
return ref;
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=use-session-ref.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/payouts/use-session-ref.ts"],"sourcesContent":["import type { PayoutsSession as PayoutsSessionType } from \"@whop/embedded-components-vanilla-js/types\";\n\nimport { useRef } from \"react\";\n\nexport function usePayoutsSessionRef() {\n\tconst ref = useRef<{\n\t\tpayoutsSession: PayoutsSessionType | null;\n\t}>(null);\n\treturn ref;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAuB;AAEhB,SAAS,uBAAuB;AACtC,QAAM,UAAM,qBAET,IAAI;AACP,SAAO;AACR;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/payouts/use-session-ref.ts"],"sourcesContent":["import type { PayoutsSession as PayoutsSessionType } from \"@whop/embedded-components-vanilla-js/types\";\n\nimport { useRef } from \"react\";\n\nexport function usePayoutsSessionRef() {\n\tconst ref = useRef<{\n\t\tpayoutsSession: PayoutsSessionType | null;\n\t}>(null);\n\treturn ref;\n}\n"],"mappings":";AAEA,SAAS,cAAc;AAEhB,SAAS,uBAAuB;AACtC,QAAM,MAAM,OAET,IAAI;AACP,SAAO;AACR;","names":[]}
|
package/dist/provider.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { WhopElements, WhopElementsOptions } from '@whop/embedded-components-vanilla-js/types';
|
|
2
|
-
import React__default from 'react';
|
|
3
|
-
|
|
4
|
-
declare function useElements(): WhopElements | null;
|
|
5
|
-
type ElementsProp = PromiseLike<WhopElements | null> | WhopElements | null;
|
|
6
|
-
declare function Elements({ children, elements: elementsProp, appearance, locale, }: {
|
|
7
|
-
children: React__default.ReactNode;
|
|
8
|
-
elements: ElementsProp;
|
|
9
|
-
} & WhopElementsOptions): React__default.JSX.Element;
|
|
10
|
-
|
|
11
|
-
export { Elements, useElements };
|
package/dist/provider.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __export = (target, all) => {
|
|
11
|
-
for (var name in all)
|
|
12
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
-
};
|
|
14
|
-
var __copyProps = (to, from, except, desc) => {
|
|
15
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
-
for (let key of __getOwnPropNames(from))
|
|
17
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
-
mod
|
|
29
|
-
));
|
|
30
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
32
|
-
var provider_exports = {};
|
|
33
|
-
__export(provider_exports, {
|
|
34
|
-
Elements: () => Elements,
|
|
35
|
-
useElements: () => useElements
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(provider_exports);
|
|
38
|
-
var import_react = __toESM(require("react"));
|
|
39
|
-
var import_react2 = require("react");
|
|
40
|
-
const ElementsContext = (0, import_react2.createContext)(null);
|
|
41
|
-
function useElements() {
|
|
42
|
-
const ctx = (0, import_react2.useContext)(ElementsContext);
|
|
43
|
-
if (!ctx) {
|
|
44
|
-
throw new Error("useElements must be used within a ElementsProvider");
|
|
45
|
-
}
|
|
46
|
-
return ctx.elements;
|
|
47
|
-
}
|
|
48
|
-
function normalizeElementsProp(prop) {
|
|
49
|
-
if (prop instanceof Promise) return prop;
|
|
50
|
-
return Promise.resolve(prop);
|
|
51
|
-
}
|
|
52
|
-
class PromiseStore {
|
|
53
|
-
constructor(promise) {
|
|
54
|
-
__publicField(this, "subscribers", /* @__PURE__ */ new Set());
|
|
55
|
-
__publicField(this, "value", { state: "pending" });
|
|
56
|
-
__publicField(this, "subscribe", (listener) => {
|
|
57
|
-
this.subscribers.add(listener);
|
|
58
|
-
return () => {
|
|
59
|
-
this.subscribers.delete(listener);
|
|
60
|
-
};
|
|
61
|
-
});
|
|
62
|
-
promise.then((value) => {
|
|
63
|
-
this.value = { state: "fulfilled", value };
|
|
64
|
-
for (const subscriber of this.subscribers) {
|
|
65
|
-
subscriber();
|
|
66
|
-
}
|
|
67
|
-
}).catch((err) => {
|
|
68
|
-
this.value = { state: "rejected", error: err };
|
|
69
|
-
for (const subscriber of this.subscribers) {
|
|
70
|
-
subscriber();
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
getSnapshot() {
|
|
75
|
-
return this.value;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function useAwaitElements(elements) {
|
|
79
|
-
const store = (0, import_react2.useMemo)(
|
|
80
|
-
() => new PromiseStore(Promise.resolve(elements)),
|
|
81
|
-
[elements]
|
|
82
|
-
);
|
|
83
|
-
const state = (0, import_react.useSyncExternalStore)(
|
|
84
|
-
store.subscribe,
|
|
85
|
-
() => {
|
|
86
|
-
const snapshot = store.getSnapshot();
|
|
87
|
-
if (snapshot.state === "fulfilled") {
|
|
88
|
-
return snapshot.value;
|
|
89
|
-
}
|
|
90
|
-
return null;
|
|
91
|
-
},
|
|
92
|
-
() => null
|
|
93
|
-
);
|
|
94
|
-
return state;
|
|
95
|
-
}
|
|
96
|
-
function Elements({
|
|
97
|
-
children,
|
|
98
|
-
elements: elementsProp,
|
|
99
|
-
appearance,
|
|
100
|
-
locale
|
|
101
|
-
}) {
|
|
102
|
-
const elementsPromise = normalizeElementsProp(elementsProp);
|
|
103
|
-
const elements = useAwaitElements(elementsPromise);
|
|
104
|
-
(0, import_react2.useEffect)(() => {
|
|
105
|
-
if (!elements) return;
|
|
106
|
-
elements.updateOptions({ appearance, locale });
|
|
107
|
-
}, [elements, appearance, locale]);
|
|
108
|
-
const value = (0, import_react2.useMemo)(
|
|
109
|
-
() => ({
|
|
110
|
-
elements
|
|
111
|
-
}),
|
|
112
|
-
[elements]
|
|
113
|
-
);
|
|
114
|
-
return /* @__PURE__ */ import_react.default.createElement(ElementsContext.Provider, { value }, children);
|
|
115
|
-
}
|
|
116
|
-
//# sourceMappingURL=provider.js.map
|