@particle-network/connectkit
Version:
209 lines (202 loc) • 7.95 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/social/phone.tsx
var phone_exports = {};
__export(phone_exports, {
default: () => phone_default
});
module.exports = __toCommonJS(phone_exports);
var import_jsx_runtime2, Phone, phone_default;
var init_phone = __esm({
"src/assets/social/phone.tsx"() {
init_useIconColor();
import_jsx_runtime2 = require("react/jsx-runtime");
Phone = () => {
const { background } = useIconColor_default();
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
"path",
{
d: "M19.2575 19.772C19.2575 20.158 19.1785 20.5171 19.0206 20.8492C18.8628 21.1812 18.6458 21.4746 18.3696 21.7294C18.0933 21.9843 17.7697 22.185 17.3987 22.3317C17.0277 22.4785 16.6292 22.5518 16.2029 22.5518H7.79705C7.37086 22.5518 6.97228 22.4785 6.6013 22.3317C6.23035 22.185 5.90674 21.9843 5.6305 21.7294C5.35423 21.4746 5.1372 21.1812 4.97935 20.8492C4.82147 20.5171 4.74255 20.158 4.74255 19.772V4.25124C4.74255 3.86515 4.82147 3.50223 4.97935 3.16248C5.1372 2.82271 5.35423 2.52543 5.6305 2.27061C5.90674 2.01579 6.23035 1.81503 6.6013 1.66831C6.97228 1.5216 7.37086 1.44824 7.79705 1.44824H16.2029C16.6292 1.44824 17.0277 1.5216 17.3987 1.66831C17.7697 1.81503 18.0933 2.01579 18.3696 2.27061C18.6458 2.52543 18.8628 2.82271 19.0206 3.16248C19.1785 3.50223 19.2575 3.86515 19.2575 4.25124V19.772ZM17.3395 5.36317H6.63683V18.6368H17.3395V5.36317ZM11.9882 19.2855C11.6567 19.2855 11.3686 19.4013 11.1239 19.633C10.8792 19.8646 10.7569 20.1504 10.7569 20.4901C10.7569 20.8144 10.8792 21.0963 11.1239 21.3356C11.3686 21.575 11.6567 21.6947 11.9882 21.6947C12.3354 21.6947 12.6275 21.575 12.8643 21.3356C13.101 21.0963 13.2195 20.8144 13.2195 20.4901C13.2195 20.1504 13.101 19.8646 12.8643 19.633C12.6275 19.4013 12.3354 19.2855 11.9882 19.2855ZM13.8824 3.39413C13.8824 3.27058 13.843 3.17406 13.764 3.10455C13.6851 3.03506 13.5983 3.00032 13.5036 3.00032H10.4964C10.4175 3.00032 10.3346 3.03506 10.2478 3.10455C10.161 3.17406 10.1176 3.27058 10.1176 3.39413C10.1176 3.51768 10.157 3.61419 10.236 3.68369C10.3149 3.75318 10.4017 3.78794 10.4964 3.78794H13.5036C13.5983 3.78794 13.6851 3.75318 13.764 3.68369C13.843 3.61419 13.8824 3.51768 13.8824 3.39413Z",
fill: background
}
) });
};
phone_default = Phone;
}
});
init_phone();
//# sourceMappingURL=phone.cjs.map