UNPKG

@particle-network/connectkit

Version:
218 lines (211 loc) 7.12 kB
"use client"; "use strict"; 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/email.tsx var email_exports = {}; __export(email_exports, { default: () => email_default }); module.exports = __toCommonJS(email_exports); var import_jsx_runtime2, Email, email_default; var init_email = __esm({ "src/assets/social/email.tsx"() { init_useIconColor(); import_jsx_runtime2 = require("react/jsx-runtime"); Email = () => { const { background } = useIconColor_default(); return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("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: "M20.7094 15.5529V8.0907L16.9219 11.9852L20.7094 15.5517M14.3171 14.6618C13.6995 15.3003 12.8591 15.6583 11.9833 15.6561C11.102 15.6561 10.272 15.3028 9.64837 14.6618L7.61689 12.5723L3.2572 16.6801V17.3682C3.2572 18.2685 3.96895 19.0001 4.84357 19.0001H19.123C19.9976 19.0001 20.7094 18.2685 20.7094 17.3694V16.6584L16.3597 12.562L14.3182 14.6606", fill: background } ), /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( "path", { d: "M19.1554 5H4.87591C4.00241 5 3.29179 5.73168 3.29179 6.63075V6.97137L10.243 14.1193C10.7171 14.6055 11.3474 14.8739 12.0167 14.8739C12.6872 14.8739 13.3175 14.6055 13.7905 14.1193L20.7428 6.97137V6.63075C20.7428 5.73168 20.0289 5 19.1554 5ZM3.2572 8.09059V15.5734L7.05464 11.9954L3.2572 8.09059Z", fill: background } ) ] }); }; email_default = Email; } }); init_email(); //# sourceMappingURL=email.cjs.map