colbrush 1.0.2 → 1.0.4

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.
Files changed (2) hide show
  1. package/dist/client.js +26 -5
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -84,7 +84,7 @@ var useUpdateLanguage = () => useTheme().updateLanguage;
84
84
  var THEMES = THEME_LABEL;
85
85
 
86
86
  // src/components/ThemeSwitcher.tsx
87
- import { useEffect as useEffect2, useRef, useState as useState2, useMemo as useMemo2 } from "react";
87
+ import { useEffect as useEffect3, useRef, useState as useState3, useMemo as useMemo2 } from "react";
88
88
 
89
89
  // src/icons/Logo.tsx
90
90
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
@@ -491,6 +491,27 @@ var SvgDeuteranopia = (props) => /* @__PURE__ */ jsxs7(
491
491
  );
492
492
  var Deuteranopia_default = SvgDeuteranopia;
493
493
 
494
+ // src/components/ThemeSwitcherPortal.tsx
495
+ import { useEffect as useEffect2, useState as useState2 } from "react";
496
+ import { createPortal } from "react-dom";
497
+ function ThemeSwitcherPortal({
498
+ children
499
+ }) {
500
+ const [container, setContainer] = useState2(null);
501
+ useEffect2(() => {
502
+ if (typeof window === "undefined") return;
503
+ const el = document.createElement("div");
504
+ el.id = "theme-switcher-portal";
505
+ document.body.appendChild(el);
506
+ setContainer(el);
507
+ return () => {
508
+ document.body.removeChild(el);
509
+ };
510
+ }, []);
511
+ if (!container) return null;
512
+ return createPortal(children, container);
513
+ }
514
+
494
515
  // src/components/ThemeSwitcher.tsx
495
516
  import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
496
517
  var THEME_ICON = {
@@ -505,9 +526,9 @@ function ThemeSwitcher({ options, className }) {
505
526
  () => options?.length ? options : getThemeOptions(language),
506
527
  [options, language]
507
528
  );
508
- const [isOpen, setIsOpen] = useState2(false);
529
+ const [isOpen, setIsOpen] = useState3(false);
509
530
  const wrapperRef = useRef(null);
510
- useEffect2(() => {
531
+ useEffect3(() => {
511
532
  const handleClickOutside = (event) => {
512
533
  if (wrapperRef.current && !wrapperRef.current.contains(event.target)) {
513
534
  setIsOpen(false);
@@ -520,7 +541,7 @@ function ThemeSwitcher({ options, className }) {
520
541
  e.stopPropagation();
521
542
  setIsOpen((prev) => !prev);
522
543
  };
523
- return /* @__PURE__ */ jsxs8(
544
+ return /* @__PURE__ */ jsx9(ThemeSwitcherPortal, { children: /* @__PURE__ */ jsxs8(
524
545
  "div",
525
546
  {
526
547
  ref: wrapperRef,
@@ -632,7 +653,7 @@ function ThemeSwitcher({ options, className }) {
632
653
  )
633
654
  ]
634
655
  }
635
- );
656
+ ) });
636
657
  }
637
658
  export {
638
659
  THEMES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "colbrush",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/client.cjs",