@whop/embedded-components-react-js 0.0.0
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/LICENSE +21 -0
- package/dist/chunk-NSSMTXJJ.mjs +9 -0
- package/dist/chunk-NSSMTXJJ.mjs.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/use-element-snapshot.d.ts +5 -0
- package/dist/lib/use-element-snapshot.js +64 -0
- package/dist/lib/use-element-snapshot.js.map +1 -0
- package/dist/lib/use-element-snapshot.mjs +41 -0
- package/dist/lib/use-element-snapshot.mjs.map +1 -0
- package/dist/payouts/elements/balance.d.ts +16 -0
- package/dist/payouts/elements/balance.js +86 -0
- package/dist/payouts/elements/balance.js.map +1 -0
- package/dist/payouts/elements/balance.mjs +56 -0
- package/dist/payouts/elements/balance.mjs.map +1 -0
- package/dist/payouts/elements/index.d.ts +5 -0
- package/dist/payouts/elements/index.js +21 -0
- package/dist/payouts/elements/index.js.map +1 -0
- package/dist/payouts/elements/index.mjs +3 -0
- package/dist/payouts/elements/index.mjs.map +1 -0
- package/dist/payouts/elements/verify.d.ts +16 -0
- package/dist/payouts/elements/verify.js +83 -0
- package/dist/payouts/elements/verify.js.map +1 -0
- package/dist/payouts/elements/verify.mjs +56 -0
- package/dist/payouts/elements/verify.mjs.map +1 -0
- package/dist/payouts/elements/withdraw-button.d.ts +16 -0
- package/dist/payouts/elements/withdraw-button.js +86 -0
- package/dist/payouts/elements/withdraw-button.js.map +1 -0
- package/dist/payouts/elements/withdraw-button.mjs +56 -0
- package/dist/payouts/elements/withdraw-button.mjs.map +1 -0
- package/dist/payouts/index.d.ts +6 -0
- package/dist/payouts/index.js +20 -0
- package/dist/payouts/index.js.map +1 -0
- package/dist/payouts/index.mjs +2 -0
- package/dist/payouts/index.mjs.map +1 -0
- package/dist/payouts/session.d.ts +7 -0
- package/dist/payouts/session.js +77 -0
- package/dist/payouts/session.js.map +1 -0
- package/dist/payouts/session.mjs +45 -0
- package/dist/payouts/session.mjs.map +1 -0
- package/dist/provider.d.ts +11 -0
- package/dist/provider.js +116 -0
- package/dist/provider.js.map +1 -0
- package/dist/provider.mjs +87 -0
- package/dist/provider.mjs.map +1 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Stripe
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value)=>key in obj ? __defProp(obj, key, {
|
|
3
|
+
enumerable: true,
|
|
4
|
+
configurable: true,
|
|
5
|
+
writable: true,
|
|
6
|
+
value
|
|
7
|
+
}) : obj[key] = value;
|
|
8
|
+
var __publicField = (obj, key, value)=>__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
9
|
+
export { __publicField };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Elements, useElements } from './provider.js';
|
|
2
|
+
export { PayoutsSession, usePayoutsSession } from './payouts/session.js';
|
|
3
|
+
export { VerifyElement } from './payouts/elements/verify.js';
|
|
4
|
+
export { WithdrawButtonElement } from './payouts/elements/withdraw-button.js';
|
|
5
|
+
export { BalanceElement } from './payouts/elements/balance.js';
|
|
6
|
+
import '@whop/embedded-components-vanilla-js/types';
|
|
7
|
+
import 'react';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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 index_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(index_exports);
|
|
18
|
+
__reExport(index_exports, require("./provider"), module.exports);
|
|
19
|
+
__reExport(index_exports, require("./payouts"), module.exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./provider\";\nexport type * from \"./provider\";\n\nexport * from \"./payouts\";\nexport type * from \"./payouts\";\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,uBAAd;AAGA,0BAAc,sBAHd;","names":[]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./provider\";\nexport type * from \"./provider\";\n\nexport * from \"./payouts\";\nexport type * from \"./payouts\";\n"],"mappings":"AAAA,cAAc;AAGd,cAAc;","names":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var use_element_snapshot_exports = {};
|
|
21
|
+
__export(use_element_snapshot_exports, {
|
|
22
|
+
useElementSnapshot: () => useElementSnapshot
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(use_element_snapshot_exports);
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
function useElementSnapshot(source) {
|
|
27
|
+
const callbacks = (0, import_react.useMemo)(() => {
|
|
28
|
+
return /* @__PURE__ */ new Set();
|
|
29
|
+
}, []);
|
|
30
|
+
const state = (0, import_react.useSyncExternalStore)(
|
|
31
|
+
(listener) => {
|
|
32
|
+
const onSnapshot = () => {
|
|
33
|
+
listener();
|
|
34
|
+
};
|
|
35
|
+
callbacks.add(onSnapshot);
|
|
36
|
+
return () => {
|
|
37
|
+
callbacks.delete(onSnapshot);
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
() => {
|
|
41
|
+
const snap = source?.getSnapshot();
|
|
42
|
+
return snap;
|
|
43
|
+
},
|
|
44
|
+
() => {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
(0, import_react.useEffect)(() => {
|
|
49
|
+
if (!source) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const onSnapshot = () => {
|
|
53
|
+
for (const callback of callbacks) {
|
|
54
|
+
callback();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
source.on("snapshot", onSnapshot);
|
|
58
|
+
return () => {
|
|
59
|
+
source.off("snapshot", onSnapshot);
|
|
60
|
+
};
|
|
61
|
+
}, [source, callbacks]);
|
|
62
|
+
return state;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=use-element-snapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/use-element-snapshot.ts"],"sourcesContent":["\"use client\";\n\nimport type { WhopElement } from \"@whop/embedded-components-vanilla-js/types\";\n\nimport { useEffect, useMemo, useSyncExternalStore } from \"react\";\n\nexport function useElementSnapshot<E extends WhopElement<any, any, any>>(\n\tsource: E | undefined | null,\n): ReturnType<E[\"getSnapshot\"]> | null {\n\tconst callbacks = useMemo(() => {\n\t\treturn new Set<() => void>();\n\t}, []);\n\n\tconst state = useSyncExternalStore(\n\t\t(listener) => {\n\t\t\tconst onSnapshot = () => {\n\t\t\t\tlistener();\n\t\t\t};\n\t\t\tcallbacks.add(onSnapshot);\n\t\t\treturn () => {\n\t\t\t\tcallbacks.delete(onSnapshot);\n\t\t\t};\n\t\t},\n\t\t() => {\n\t\t\tconst snap = source?.getSnapshot();\n\t\t\treturn snap;\n\t\t},\n\t\t() => {\n\t\t\treturn null;\n\t\t},\n\t);\n\n\tuseEffect(() => {\n\t\tif (!source) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst onSnapshot = () => {\n\t\t\tfor (const callback of callbacks) {\n\t\t\t\tcallback();\n\t\t\t}\n\t\t};\n\t\tsource.on(\"snapshot\", onSnapshot);\n\t\treturn () => {\n\t\t\tsource.off(\"snapshot\", onSnapshot);\n\t\t};\n\t}, [source, callbacks]);\n\n\treturn state;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,mBAAyD;AAElD,SAAS,mBACf,QACsC;AACtC,QAAM,gBAAY,sBAAQ,MAAM;AAC/B,WAAO,oBAAI,IAAgB;AAAA,EAC5B,GAAG,CAAC,CAAC;AAEL,QAAM,YAAQ;AAAA,IACb,CAAC,aAAa;AACb,YAAM,aAAa,MAAM;AACxB,iBAAS;AAAA,MACV;AACA,gBAAU,IAAI,UAAU;AACxB,aAAO,MAAM;AACZ,kBAAU,OAAO,UAAU;AAAA,MAC5B;AAAA,IACD;AAAA,IACA,MAAM;AACL,YAAM,OAAO,QAAQ,YAAY;AACjC,aAAO;AAAA,IACR;AAAA,IACA,MAAM;AACL,aAAO;AAAA,IACR;AAAA,EACD;AAEA,8BAAU,MAAM;AACf,QAAI,CAAC,QAAQ;AACZ;AAAA,IACD;AAEA,UAAM,aAAa,MAAM;AACxB,iBAAW,YAAY,WAAW;AACjC,iBAAS;AAAA,MACV;AAAA,IACD;AACA,WAAO,GAAG,YAAY,UAAU;AAChC,WAAO,MAAM;AACZ,aAAO,IAAI,YAAY,UAAU;AAAA,IAClC;AAAA,EACD,GAAG,CAAC,QAAQ,SAAS,CAAC;AAEtB,SAAO;AACR;","names":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../chunk-NSSMTXJJ.mjs";
|
|
3
|
+
import { useEffect, useMemo, useSyncExternalStore } from "react";
|
|
4
|
+
function useElementSnapshot(source) {
|
|
5
|
+
const callbacks = useMemo(()=>{
|
|
6
|
+
return new Set();
|
|
7
|
+
}, []);
|
|
8
|
+
const state = useSyncExternalStore((listener)=>{
|
|
9
|
+
const onSnapshot = ()=>{
|
|
10
|
+
listener();
|
|
11
|
+
};
|
|
12
|
+
callbacks.add(onSnapshot);
|
|
13
|
+
return ()=>{
|
|
14
|
+
callbacks.delete(onSnapshot);
|
|
15
|
+
};
|
|
16
|
+
}, ()=>{
|
|
17
|
+
const snap = source?.getSnapshot();
|
|
18
|
+
return snap;
|
|
19
|
+
}, ()=>{
|
|
20
|
+
return null;
|
|
21
|
+
});
|
|
22
|
+
useEffect(()=>{
|
|
23
|
+
if (!source) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const onSnapshot = ()=>{
|
|
27
|
+
for (const callback of callbacks){
|
|
28
|
+
callback();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
source.on("snapshot", onSnapshot);
|
|
32
|
+
return ()=>{
|
|
33
|
+
source.off("snapshot", onSnapshot);
|
|
34
|
+
};
|
|
35
|
+
}, [
|
|
36
|
+
source,
|
|
37
|
+
callbacks
|
|
38
|
+
]);
|
|
39
|
+
return state;
|
|
40
|
+
}
|
|
41
|
+
export { useElementSnapshot };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/use-element-snapshot.ts"],"sourcesContent":["\"use client\";\n\nimport type { WhopElement } from \"@whop/embedded-components-vanilla-js/types\";\n\nimport { useEffect, useMemo, useSyncExternalStore } from \"react\";\n\nexport function useElementSnapshot<E extends WhopElement<any, any, any>>(\n\tsource: E | undefined | null,\n): ReturnType<E[\"getSnapshot\"]> | null {\n\tconst callbacks = useMemo(() => {\n\t\treturn new Set<() => void>();\n\t}, []);\n\n\tconst state = useSyncExternalStore(\n\t\t(listener) => {\n\t\t\tconst onSnapshot = () => {\n\t\t\t\tlistener();\n\t\t\t};\n\t\t\tcallbacks.add(onSnapshot);\n\t\t\treturn () => {\n\t\t\t\tcallbacks.delete(onSnapshot);\n\t\t\t};\n\t\t},\n\t\t() => {\n\t\t\tconst snap = source?.getSnapshot();\n\t\t\treturn snap;\n\t\t},\n\t\t() => {\n\t\t\treturn null;\n\t\t},\n\t);\n\n\tuseEffect(() => {\n\t\tif (!source) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst onSnapshot = () => {\n\t\t\tfor (const callback of callbacks) {\n\t\t\t\tcallback();\n\t\t\t}\n\t\t};\n\t\tsource.on(\"snapshot\", onSnapshot);\n\t\treturn () => {\n\t\t\tsource.off(\"snapshot\", onSnapshot);\n\t\t};\n\t}, [source, callbacks]);\n\n\treturn state;\n}\n"],"mappings":";;AAIA,SAAS,WAAW,SAAS,4BAA4B;AAElD,SAAS,mBACf,QACsC;AACtC,QAAM,YAAY,QAAQ,MAAM;AAC/B,WAAO,oBAAI,IAAgB;AAAA,EAC5B,GAAG,CAAC,CAAC;AAEL,QAAM,QAAQ;AAAA,IACb,CAAC,aAAa;AACb,YAAM,aAAa,MAAM;AACxB,iBAAS;AAAA,MACV;AACA,gBAAU,IAAI,UAAU;AACxB,aAAO,MAAM;AACZ,kBAAU,OAAO,UAAU;AAAA,MAC5B;AAAA,IACD;AAAA,IACA,MAAM;AACL,YAAM,OAAO,QAAQ,YAAY;AACjC,aAAO;AAAA,IACR;AAAA,IACA,MAAM;AACL,aAAO;AAAA,IACR;AAAA,EACD;AAEA,YAAU,MAAM;AACf,QAAI,CAAC,QAAQ;AACZ;AAAA,IACD;AAEA,UAAM,aAAa,MAAM;AACxB,iBAAW,YAAY,WAAW;AACjC,iBAAS;AAAA,MACV;AAAA,IACD;AACA,WAAO,GAAG,YAAY,UAAU;AAChC,WAAO,MAAM;AACZ,aAAO,IAAI,YAAY,UAAU;AAAA,IAClC;AAAA,EACD,GAAG,CAAC,QAAQ,SAAS,CAAC;AAEtB,SAAO;AACR;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BalanceElementOptions } from '@whop/embedded-components-vanilla-js/types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
declare function BalanceElement({ options, className, style, onReady, fallback, }: {
|
|
5
|
+
options?: BalanceElementOptions;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
onReady?: () => void;
|
|
9
|
+
fallback?: React.ReactNode;
|
|
10
|
+
}): React.JSX.Element;
|
|
11
|
+
declare namespace BalanceElement {
|
|
12
|
+
var displayName: string;
|
|
13
|
+
var type: "balance-element";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { BalanceElement };
|
|
@@ -0,0 +1,86 @@
|
|
|
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 balance_exports = {};
|
|
31
|
+
__export(balance_exports, {
|
|
32
|
+
BalanceElement: () => BalanceElement
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(balance_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 BalanceElement({
|
|
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
|
+
BalanceElement,
|
|
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 ? "visible" : "hidden" },
|
|
79
|
+
className,
|
|
80
|
+
ref
|
|
81
|
+
}
|
|
82
|
+
), !isReady && (fallback ?? null));
|
|
83
|
+
}
|
|
84
|
+
BalanceElement.displayName = "BalanceElement";
|
|
85
|
+
BalanceElement.type = "balance-element";
|
|
86
|
+
//# sourceMappingURL=balance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/payouts/elements/balance.tsx"],"sourcesContent":["\"use client\";\n\nimport type { BalanceElementOptions } 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 BalanceElement({\n\toptions = {},\n\tclassName,\n\tstyle,\n\tonReady,\n\tfallback,\n}: {\n\toptions?: BalanceElementOptions;\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\tBalanceElement,\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 ? \"visible\" : \"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\nBalanceElement.displayName = \"BalanceElement\";\nBalanceElement.type = \"balance-element\" as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,mBAAmE;AACnE,kCAAmC;AACnC,qBAAkC;AAE3B,SAAS,eAAe;AAAA,EAC9B,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,YAAY,SAAS;AAAA,MAC9D;AAAA,MACA;AAAA;AAAA,EACD,GACC,CAAC,YAAY,YAAY,KAC3B;AAEF;AAEA,eAAe,cAAc;AAC7B,eAAe,OAAO;","names":["React"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
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 BalanceElement({ 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(BalanceElement, 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 ? "visible" : "hidden"
|
|
49
|
+
},
|
|
50
|
+
className,
|
|
51
|
+
ref
|
|
52
|
+
}), !isReady && (fallback ?? null));
|
|
53
|
+
}
|
|
54
|
+
BalanceElement.displayName = "BalanceElement";
|
|
55
|
+
BalanceElement.type = "balance-element";
|
|
56
|
+
export { BalanceElement };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/payouts/elements/balance.tsx"],"sourcesContent":["\"use client\";\n\nimport type { BalanceElementOptions } 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 BalanceElement({\n\toptions = {},\n\tclassName,\n\tstyle,\n\tonReady,\n\tfallback,\n}: {\n\toptions?: BalanceElementOptions;\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\tBalanceElement,\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 ? \"visible\" : \"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\nBalanceElement.displayName = \"BalanceElement\";\nBalanceElement.type = \"balance-element\" as const;\n"],"mappings":";;AAIA,OAAO,SAAS,WAAW,iBAAiB,SAAS,cAAc;AACnE,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAE3B,SAAS,eAAe;AAAA,EAC9B,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,YAAY,SAAS;AAAA,MAC9D;AAAA,MACA;AAAA;AAAA,EACD,GACC,CAAC,YAAY,YAAY,KAC3B;AAEF;AAEA,eAAe,cAAc;AAC7B,eAAe,OAAO;","names":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
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 elements_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(elements_exports);
|
|
18
|
+
__reExport(elements_exports, require("./verify"), module.exports);
|
|
19
|
+
__reExport(elements_exports, require("./withdraw-button"), module.exports);
|
|
20
|
+
__reExport(elements_exports, require("./balance"), module.exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/payouts/elements/index.tsx"],"sourcesContent":["export * from \"./verify\";\nexport * from \"./withdraw-button\";\nexport * from \"./balance\";\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,6BAAc,qBAAd;AACA,6BAAc,8BADd;AAEA,6BAAc,sBAFd;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/payouts/elements/index.tsx"],"sourcesContent":["export * from \"./verify\";\nexport * from \"./withdraw-button\";\nexport * from \"./balance\";\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { VerifyElementOptions } from '@whop/embedded-components-vanilla-js/types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
declare function VerifyElement({ options, className, style, onReady, fallback, }: {
|
|
5
|
+
options?: VerifyElementOptions;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
onReady?: () => void;
|
|
9
|
+
fallback?: React.ReactNode;
|
|
10
|
+
}): React.JSX.Element;
|
|
11
|
+
declare namespace VerifyElement {
|
|
12
|
+
var displayName: string;
|
|
13
|
+
var type: "verify-element";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { VerifyElement };
|
|
@@ -0,0 +1,83 @@
|
|
|
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 verify_exports = {};
|
|
31
|
+
__export(verify_exports, {
|
|
32
|
+
VerifyElement: () => VerifyElement
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(verify_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 VerifyElement({
|
|
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(VerifyElement, options);
|
|
50
|
+
return createdElement;
|
|
51
|
+
}, [payoutsSession]);
|
|
52
|
+
const elementSnapshot = (0, import_use_element_snapshot.useElementSnapshot)(element);
|
|
53
|
+
const isReady = elementSnapshot?.state === "ready";
|
|
54
|
+
(0, import_react.useEffect)(() => {
|
|
55
|
+
if (!element) return;
|
|
56
|
+
element.updateOptions(options);
|
|
57
|
+
}, [options, element]);
|
|
58
|
+
(0, import_react.useEffect)(() => {
|
|
59
|
+
if (!element || !onReady) return;
|
|
60
|
+
element.on("ready", onReady);
|
|
61
|
+
return () => {
|
|
62
|
+
element.off("ready", onReady);
|
|
63
|
+
};
|
|
64
|
+
}, [element, onReady]);
|
|
65
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
66
|
+
if (!element || !ref.current) return;
|
|
67
|
+
element.mount(ref.current);
|
|
68
|
+
return () => {
|
|
69
|
+
element.unmount();
|
|
70
|
+
};
|
|
71
|
+
}, [element, ref.current]);
|
|
72
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
|
|
73
|
+
"div",
|
|
74
|
+
{
|
|
75
|
+
style: { ...style, visibility: isReady ? "visible" : "hidden" },
|
|
76
|
+
className,
|
|
77
|
+
ref
|
|
78
|
+
}
|
|
79
|
+
), !isReady && (fallback ?? null));
|
|
80
|
+
}
|
|
81
|
+
VerifyElement.displayName = "VerifyElement";
|
|
82
|
+
VerifyElement.type = "verify-element";
|
|
83
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/payouts/elements/verify.tsx"],"sourcesContent":["\"use client\";\n\nimport type { VerifyElementOptions } 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 VerifyElement({\n\toptions = {},\n\tclassName,\n\tstyle,\n\tonReady,\n\tfallback,\n}: {\n\toptions?: VerifyElementOptions;\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(VerifyElement, options);\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 ? \"visible\" : \"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\nVerifyElement.displayName = \"VerifyElement\";\nVerifyElement.type = \"verify-element\" as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,mBAAmE;AACnE,kCAAmC;AACnC,qBAAkC;AAE3B,SAAS,cAAc;AAAA,EAC7B,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,cAAc,eAAe,OAAO;AAC1E,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,YAAY,SAAS;AAAA,MAC9D;AAAA,MACA;AAAA;AAAA,EACD,GACC,CAAC,YAAY,YAAY,KAC3B;AAEF;AAEA,cAAc,cAAc;AAC5B,cAAc,OAAO;","names":["React"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
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 VerifyElement({ 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(VerifyElement, 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 ? "visible" : "hidden"
|
|
49
|
+
},
|
|
50
|
+
className,
|
|
51
|
+
ref
|
|
52
|
+
}), !isReady && (fallback ?? null));
|
|
53
|
+
}
|
|
54
|
+
VerifyElement.displayName = "VerifyElement";
|
|
55
|
+
VerifyElement.type = "verify-element";
|
|
56
|
+
export { VerifyElement };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/payouts/elements/verify.tsx"],"sourcesContent":["\"use client\";\n\nimport type { VerifyElementOptions } 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 VerifyElement({\n\toptions = {},\n\tclassName,\n\tstyle,\n\tonReady,\n\tfallback,\n}: {\n\toptions?: VerifyElementOptions;\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(VerifyElement, options);\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 ? \"visible\" : \"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\nVerifyElement.displayName = \"VerifyElement\";\nVerifyElement.type = \"verify-element\" as const;\n"],"mappings":";;AAIA,OAAO,SAAS,WAAW,iBAAiB,SAAS,cAAc;AACnE,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAE3B,SAAS,cAAc;AAAA,EAC7B,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,cAAc,eAAe,OAAO;AAC1E,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,YAAY,SAAS;AAAA,MAC9D;AAAA,MACA;AAAA;AAAA,EACD,GACC,CAAC,YAAY,YAAY,KAC3B;AAEF;AAEA,cAAc,cAAc;AAC5B,cAAc,OAAO;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WithdrawButtonElementOptions } from '@whop/embedded-components-vanilla-js/types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
declare function WithdrawButtonElement({ options, className, style, onReady, fallback, }: {
|
|
5
|
+
options?: WithdrawButtonElementOptions;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
onReady?: () => void;
|
|
9
|
+
fallback?: React.ReactNode;
|
|
10
|
+
}): React.JSX.Element;
|
|
11
|
+
declare namespace WithdrawButtonElement {
|
|
12
|
+
var displayName: string;
|
|
13
|
+
var type: "withdraw-button-element";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { WithdrawButtonElement };
|