UNPKG

@particle-network/connectkit

Version:
218 lines (211 loc) 7.29 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/apple.tsx var apple_exports = {}; __export(apple_exports, { default: () => apple_default }); module.exports = __toCommonJS(apple_exports); var import_jsx_runtime2, Apple, apple_default; var init_apple = __esm({ "src/assets/social/apple.tsx"() { init_useIconColor(); import_jsx_runtime2 = require("react/jsx-runtime"); Apple = () => { const { background } = useIconColor_default(); return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { width: "24", height: "24", viewBox: "0 0 31 31", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( "path", { d: "M23.2154 16.3638C23.2404 14.2641 24.402 12.3195 26.2756 11.21C25.089 9.58753 23.1654 8.59733 21.092 8.53768C18.9062 8.32293 16.7953 9.77841 15.6837 9.77841C14.572 9.77841 12.8359 8.54961 10.9998 8.5854C8.57664 8.65698 6.36583 9.94543 5.19173 11.9735C2.68116 16.1252 4.55472 22.2334 6.96537 25.5858C8.16445 27.2322 9.57587 29.0694 11.412 28.9978C13.2106 28.9262 13.8851 27.9003 16.0584 27.9003C18.2317 27.9003 18.8438 28.9978 20.7173 28.962C22.6533 28.9262 23.8649 27.3157 25.0265 25.6455C25.8884 24.4763 26.5628 23.1759 27 21.804C24.7018 20.8734 23.2154 18.726 23.2029 16.3519L23.2154 16.3638Z", fill: background } ), /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( "path", { d: "M19.6679 6.33057C20.7171 5.12563 21.2417 3.56278 21.1168 1.99994C19.5055 2.16696 18.0191 2.8947 16.945 4.06385C15.8958 5.20914 15.3587 6.71233 15.4586 8.23939C17.0948 8.25132 18.6437 7.55937 19.6679 6.3425V6.33057Z", fill: background } ) ] }); }; apple_default = Apple; } }); init_apple(); //# sourceMappingURL=apple.cjs.map