@particle-network/connectkit
Version:
254 lines (247 loc) • 9.28 kB
JavaScript
"use client";
;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/utils/theme.ts
function getSystemMode() {
if (typeof window !== "undefined" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
return "dark";
} else {
return "light";
}
}
var init_theme = __esm({
"src/utils/theme.ts"() {
"use strict";
}
});
// src/utils/deepEqual.ts
function deepEqual(a, b) {
if (a === b)
return true;
if (a && b && typeof a === "object" && typeof b === "object") {
if (a.constructor !== b.constructor)
return false;
let length;
let i;
if (Array.isArray(a) && Array.isArray(b)) {
length = a.length;
if (length !== b.length)
return false;
for (i = length; i-- !== 0; )
if (!deepEqual(a[i], b[i]))
return false;
return true;
}
if (a.valueOf !== Object.prototype.valueOf)
return a.valueOf() === b.valueOf();
if (a.toString !== Object.prototype.toString)
return a.toString() === b.toString();
const keys = Object.keys(a);
length = keys.length;
if (length !== Object.keys(b).length)
return false;
for (i = length; i-- !== 0; )
if (!Object.prototype.hasOwnProperty.call(b, keys[i]))
return false;
for (i = length; i-- !== 0; ) {
const key = keys[i];
if (key && !deepEqual(a[key], b[key]))
return false;
}
return true;
}
return a !== a && b !== b;
}
var init_deepEqual = __esm({
"src/utils/deepEqual.ts"() {
"use strict";
}
});
// src/context/index.tsx
var import_react, import_jsx_runtime, Context, useContext;
var init_context = __esm({
"src/context/index.tsx"() {
"use strict";
import_react = __toESM(require("react"), 1);
import_jsx_runtime = require("react/jsx-runtime");
Context = (0, import_react.createContext)(null);
useContext = () => {
const context = import_react.default.useContext(Context);
if (!context)
throw Error("ConnectKit Hook must be inside a Provider.");
return context;
};
}
});
// src/hooks/useAppearance.ts
function getAppearance(config) {
const appearance = { ...config.appearanceStore.getState() };
if (deepEqual(previousAppearance, appearance))
return previousAppearance;
previousAppearance = appearance;
return appearance;
}
function useAppearance(config) {
if (!config) {
const { config: globalConfig } = useContext();
config = globalConfig;
}
const setAppearance = (0, import_react2.useCallback)(
(value) => {
config.appearanceStore.setState(value || {}, true);
},
[config.appearanceStore]
);
const appearance = (0, import_react2.useSyncExternalStore)(
config.appearanceStore.subscribe,
() => getAppearance(config),
() => getAppearance(config)
);
return {
appearance,
setAppearance
};
}
var import_react2, previousAppearance;
var init_useAppearance = __esm({
"src/hooks/useAppearance.ts"() {
"use strict";
import_react2 = require("react");
init_context();
init_deepEqual();
previousAppearance = {};
}
});
// src/hooks/useIconColor.ts
var import_react3, useIconColor, useIconColor_default;
var init_useIconColor = __esm({
"src/hooks/useIconColor.ts"() {
"use strict";
import_react3 = require("react");
init_theme();
init_useAppearance();
useIconColor = () => {
const [currentMode, setCurrentMode] = (0, import_react3.useState)();
const { appearance } = useAppearance();
(0, import_react3.useEffect)(() => {
if (appearance?.mode && appearance?.mode !== "auto") {
setCurrentMode(appearance?.mode);
} else {
setCurrentMode(getSystemMode());
}
}, [appearance?.mode]);
const foreground = (0, import_react3.useMemo)(() => {
if (currentMode === "dark") {
return "#000000";
} else {
return "#ffffff";
}
}, [currentMode]);
const background = (0, import_react3.useMemo)(() => {
if (currentMode === "dark") {
return "#ffffff";
} else {
return "#000000";
}
}, [currentMode]);
return { foreground, background, currentMode };
};
useIconColor_default = useIconColor;
}
});
// src/assets/wallets/Trust.tsx
var Trust_exports = {};
__export(Trust_exports, {
default: () => Trust_default
});
module.exports = __toCommonJS(Trust_exports);
var import_react4, import_jsx_runtime2, Trust, Trust_default;
var init_Trust = __esm({
"src/assets/wallets/Trust.tsx"() {
import_react4 = require("react");
init_useIconColor();
import_jsx_runtime2 = require("react/jsx-runtime");
Trust = ({ ...props }) => {
const { currentMode } = useIconColor_default();
const id = (0, import_react4.useMemo)(() => {
return Math.random().toString(36).substring(7);
}, []);
const id2 = (0, import_react4.useMemo)(() => {
return Math.random().toString(36).substring(7);
}, []);
return currentMode === "light" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "22", height: "24", viewBox: "0 0 22 24", fill: "none", ...props, children: [
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
"path",
{
d: "M0.286133 3.46686L10.9995 0V24C3.34699 20.7997 0.286133 14.6664 0.286133 11.2003V3.46686Z",
fill: "#0500FF"
}
),
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
"path",
{
d: "M21.7137 3.46686L11.0004 0V24C18.6529 20.7997 21.7137 14.6664 21.7137 11.2003V3.46686Z",
fill: `url(#${id})`
}
),
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("linearGradient", { id, x1: "18.8679", y1: "-1.68063", x2: "10.8399", y2: "23.6925", gradientUnits: "userSpaceOnUse", children: [
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", { offset: "0.02", stopColor: "#0000FF" }),
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", { offset: "0.08", stopColor: "#0094FF" }),
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", { offset: "0.16", stopColor: "#48FF91" }),
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", { offset: "0.42", stopColor: "#0094FF" }),
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", { offset: "0.68", stopColor: "#0038FF" }),
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", { offset: "0.9", stopColor: "#0500FF" })
] }) })
] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "22", height: "24", viewBox: "0 0 22 24", fill: "none", ...props, children: [
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
"path",
{
d: "M0.269531 3.46687L10.9994 0V24C3.33511 20.7997 0.269531 14.6664 0.269531 11.2003V3.46687Z",
fill: "#48FF91"
}
),
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
"path",
{
d: "M21.7305 3.46687L11.0006 0V24C18.6649 20.7997 21.7305 14.6664 21.7305 11.2003V3.46687Z",
fill: `url(#${id2})`
}
),
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("linearGradient", { id: id2, x1: "10.5475", y1: "27.0164", x2: "19.2341", y2: "-4.58841", gradientUnits: "userSpaceOnUse", children: [
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", { offset: "0.26", stopColor: "#48FF91" }),
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", { offset: "0.66", stopColor: "#0094FF" }),
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", { offset: "0.8", stopColor: "#0038FF" }),
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", { offset: "0.89", stopColor: "#0500FF" })
] }) })
] });
};
Trust_default = Trust;
}
});
init_Trust();
//# sourceMappingURL=Trust.cjs.map