analytica-frontend-lib 1.1.67 → 1.1.69
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.
- package/dist/DropdownMenu/index.js +110 -75
- package/dist/DropdownMenu/index.js.map +1 -1
- package/dist/DropdownMenu/index.mjs +114 -79
- package/dist/DropdownMenu/index.mjs.map +1 -1
- package/dist/Menu/index.js +1 -1
- package/dist/Menu/index.js.map +1 -1
- package/dist/Menu/index.mjs +1 -1
- package/dist/Menu/index.mjs.map +1 -1
- package/dist/NotificationCard/index.js +112 -77
- package/dist/NotificationCard/index.js.map +1 -1
- package/dist/NotificationCard/index.mjs +123 -88
- package/dist/NotificationCard/index.mjs.map +1 -1
- package/dist/Search/index.js +110 -75
- package/dist/Search/index.js.map +1 -1
- package/dist/Search/index.mjs +119 -84
- package/dist/Search/index.mjs.map +1 -1
- package/dist/ThemeToggle/index.d.mts +3 -1
- package/dist/ThemeToggle/index.d.ts +3 -1
- package/dist/ThemeToggle/index.js +102 -67
- package/dist/ThemeToggle/index.js.map +1 -1
- package/dist/ThemeToggle/index.mjs +105 -70
- package/dist/ThemeToggle/index.mjs.map +1 -1
- package/dist/hooks/useTheme/index.d.mts +6 -2
- package/dist/hooks/useTheme/index.d.ts +6 -2
- package/dist/hooks/useTheme/index.js +102 -67
- package/dist/hooks/useTheme/index.js.map +1 -1
- package/dist/hooks/useTheme/index.mjs +103 -68
- package/dist/hooks/useTheme/index.mjs.map +1 -1
- package/dist/index.css +2 -2
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +133 -96
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +252 -216
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +2 -2
- package/dist/styles.css.map +1 -1
- package/dist/themeStore-P2X64zC-.d.mts +79 -0
- package/dist/themeStore-P2X64zC-.d.ts +79 -0
- package/package.json +1 -1
package/dist/Search/index.js
CHANGED
|
@@ -29,7 +29,7 @@ var import_react6 = require("react");
|
|
|
29
29
|
// src/components/DropdownMenu/DropdownMenu.tsx
|
|
30
30
|
var import_phosphor_react3 = require("phosphor-react");
|
|
31
31
|
var import_react5 = require("react");
|
|
32
|
-
var
|
|
32
|
+
var import_zustand2 = require("zustand");
|
|
33
33
|
|
|
34
34
|
// src/utils/utils.ts
|
|
35
35
|
var import_clsx = require("clsx");
|
|
@@ -431,82 +431,117 @@ var SelectionButton_default = SelectionButton;
|
|
|
431
431
|
|
|
432
432
|
// src/hooks/useTheme.ts
|
|
433
433
|
var import_react3 = require("react");
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
434
|
+
|
|
435
|
+
// src/store/themeStore.ts
|
|
436
|
+
var import_zustand = require("zustand");
|
|
437
|
+
var import_middleware = require("zustand/middleware");
|
|
438
|
+
var applyThemeToDOM = (mode) => {
|
|
439
|
+
const htmlElement = document.documentElement;
|
|
440
|
+
const originalTheme = htmlElement.getAttribute("data-original-theme");
|
|
441
|
+
if (mode === "dark") {
|
|
442
|
+
htmlElement.setAttribute("data-theme", "dark");
|
|
443
|
+
return true;
|
|
444
|
+
} else if (mode === "light") {
|
|
445
|
+
if (originalTheme) {
|
|
446
|
+
htmlElement.setAttribute("data-theme", originalTheme);
|
|
447
|
+
}
|
|
448
|
+
return false;
|
|
449
|
+
} else if (mode === "system") {
|
|
450
|
+
const isSystemDark = window.matchMedia(
|
|
451
|
+
"(prefers-color-scheme: dark)"
|
|
452
|
+
).matches;
|
|
453
|
+
if (isSystemDark) {
|
|
442
454
|
htmlElement.setAttribute("data-theme", "dark");
|
|
443
|
-
|
|
444
|
-
} else if (
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
}
|
|
448
|
-
setIsDark(false);
|
|
449
|
-
} else if (mode === "system") {
|
|
450
|
-
const isSystemDark = window.matchMedia(
|
|
451
|
-
"(prefers-color-scheme: dark)"
|
|
452
|
-
).matches;
|
|
453
|
-
if (isSystemDark) {
|
|
454
|
-
htmlElement.setAttribute("data-theme", "dark");
|
|
455
|
-
setIsDark(true);
|
|
456
|
-
} else if (originalTheme) {
|
|
457
|
-
htmlElement.setAttribute("data-theme", originalTheme);
|
|
458
|
-
setIsDark(false);
|
|
459
|
-
}
|
|
455
|
+
return true;
|
|
456
|
+
} else if (originalTheme) {
|
|
457
|
+
htmlElement.setAttribute("data-theme", originalTheme);
|
|
458
|
+
return false;
|
|
460
459
|
}
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
460
|
+
}
|
|
461
|
+
return false;
|
|
462
|
+
};
|
|
463
|
+
var saveOriginalTheme = () => {
|
|
464
|
+
const htmlElement = document.documentElement;
|
|
465
|
+
const currentTheme = htmlElement.getAttribute("data-theme");
|
|
466
|
+
if (currentTheme && !htmlElement.getAttribute("data-original-theme")) {
|
|
467
|
+
htmlElement.setAttribute("data-original-theme", currentTheme);
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
var useThemeStore = (0, import_zustand.create)()(
|
|
471
|
+
(0, import_middleware.devtools)(
|
|
472
|
+
(0, import_middleware.persist)(
|
|
473
|
+
(set, get) => ({
|
|
474
|
+
// Initial state
|
|
475
|
+
themeMode: "system",
|
|
476
|
+
isDark: false,
|
|
477
|
+
// Actions
|
|
478
|
+
applyTheme: (mode) => {
|
|
479
|
+
const isDark = applyThemeToDOM(mode);
|
|
480
|
+
set({ isDark });
|
|
481
|
+
},
|
|
482
|
+
toggleTheme: () => {
|
|
483
|
+
const { themeMode, applyTheme } = get();
|
|
484
|
+
let newMode;
|
|
485
|
+
if (themeMode === "light") {
|
|
486
|
+
newMode = "dark";
|
|
487
|
+
} else if (themeMode === "dark") {
|
|
488
|
+
newMode = "light";
|
|
489
|
+
} else {
|
|
490
|
+
newMode = "dark";
|
|
491
|
+
}
|
|
492
|
+
set({ themeMode: newMode });
|
|
493
|
+
applyTheme(newMode);
|
|
494
|
+
},
|
|
495
|
+
setTheme: (mode) => {
|
|
496
|
+
const { applyTheme } = get();
|
|
497
|
+
set({ themeMode: mode });
|
|
498
|
+
applyTheme(mode);
|
|
499
|
+
},
|
|
500
|
+
initializeTheme: () => {
|
|
501
|
+
const { themeMode, applyTheme } = get();
|
|
502
|
+
saveOriginalTheme();
|
|
503
|
+
applyTheme(themeMode);
|
|
504
|
+
},
|
|
505
|
+
handleSystemThemeChange: () => {
|
|
506
|
+
const { themeMode, applyTheme } = get();
|
|
507
|
+
if (themeMode === "system") {
|
|
508
|
+
applyTheme("system");
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}),
|
|
512
|
+
{
|
|
513
|
+
name: "theme-store",
|
|
514
|
+
// Nome da chave no localStorage
|
|
515
|
+
partialize: (state) => ({
|
|
516
|
+
themeMode: state.themeMode
|
|
517
|
+
})
|
|
518
|
+
// Só persiste o themeMode, não o isDark
|
|
519
|
+
}
|
|
520
|
+
),
|
|
521
|
+
{
|
|
522
|
+
name: "theme-store"
|
|
470
523
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
const
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
);
|
|
524
|
+
)
|
|
525
|
+
);
|
|
526
|
+
|
|
527
|
+
// src/hooks/useTheme.ts
|
|
528
|
+
var useTheme = () => {
|
|
529
|
+
const {
|
|
530
|
+
themeMode,
|
|
531
|
+
isDark,
|
|
532
|
+
toggleTheme,
|
|
533
|
+
setTheme,
|
|
534
|
+
initializeTheme,
|
|
535
|
+
handleSystemThemeChange
|
|
536
|
+
} = useThemeStore();
|
|
485
537
|
(0, import_react3.useEffect)(() => {
|
|
486
|
-
|
|
487
|
-
const currentTheme = htmlElement.getAttribute("data-theme");
|
|
488
|
-
if (currentTheme && !htmlElement.getAttribute("data-original-theme")) {
|
|
489
|
-
htmlElement.setAttribute("data-original-theme", currentTheme);
|
|
490
|
-
}
|
|
491
|
-
const savedThemeMode = localStorage.getItem("theme-mode");
|
|
492
|
-
const initialMode = savedThemeMode || "system";
|
|
493
|
-
if (!savedThemeMode) {
|
|
494
|
-
localStorage.setItem("theme-mode", "system");
|
|
495
|
-
}
|
|
496
|
-
setThemeMode(initialMode);
|
|
497
|
-
themeModeRef.current = initialMode;
|
|
498
|
-
applyTheme(initialMode);
|
|
538
|
+
initializeTheme();
|
|
499
539
|
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
500
|
-
const handleSystemThemeChange = () => {
|
|
501
|
-
if (themeModeRef.current === "system") {
|
|
502
|
-
applyTheme("system");
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
540
|
mediaQuery.addEventListener("change", handleSystemThemeChange);
|
|
506
541
|
return () => {
|
|
507
542
|
mediaQuery.removeEventListener("change", handleSystemThemeChange);
|
|
508
543
|
};
|
|
509
|
-
}, [
|
|
544
|
+
}, [initializeTheme, handleSystemThemeChange]);
|
|
510
545
|
return {
|
|
511
546
|
themeMode,
|
|
512
547
|
isDark,
|
|
@@ -586,7 +621,7 @@ var ThemeToggle = ({
|
|
|
586
621
|
// src/components/DropdownMenu/DropdownMenu.tsx
|
|
587
622
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
588
623
|
function createDropdownStore() {
|
|
589
|
-
return (0,
|
|
624
|
+
return (0, import_zustand2.create)((set) => ({
|
|
590
625
|
open: false,
|
|
591
626
|
setOpen: (open) => set({ open })
|
|
592
627
|
}));
|
|
@@ -622,7 +657,7 @@ var DropdownMenu = ({
|
|
|
622
657
|
const storeRef = (0, import_react5.useRef)(null);
|
|
623
658
|
storeRef.current ??= createDropdownStore();
|
|
624
659
|
const store = storeRef.current;
|
|
625
|
-
const { open, setOpen: storeSetOpen } = (0,
|
|
660
|
+
const { open, setOpen: storeSetOpen } = (0, import_zustand2.useStore)(store, (s) => s);
|
|
626
661
|
const setOpen = (newOpen) => {
|
|
627
662
|
storeSetOpen(newOpen);
|
|
628
663
|
};
|
|
@@ -689,7 +724,7 @@ var DropdownMenuTrigger = ({
|
|
|
689
724
|
...props
|
|
690
725
|
}) => {
|
|
691
726
|
const store = useDropdownStore(externalStore);
|
|
692
|
-
const open = (0,
|
|
727
|
+
const open = (0, import_zustand2.useStore)(store, (s) => s.open);
|
|
693
728
|
const toggleOpen = () => store.setState({ open: !open });
|
|
694
729
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
695
730
|
"button",
|
|
@@ -749,7 +784,7 @@ var DropdownMenuContent = (0, import_react5.forwardRef)(
|
|
|
749
784
|
...props
|
|
750
785
|
}, ref) => {
|
|
751
786
|
const store = useDropdownStore(externalStore);
|
|
752
|
-
const open = (0,
|
|
787
|
+
const open = (0, import_zustand2.useStore)(store, (s) => s.open);
|
|
753
788
|
const [isVisible, setIsVisible] = (0, import_react5.useState)(open);
|
|
754
789
|
(0, import_react5.useEffect)(() => {
|
|
755
790
|
if (open) {
|
|
@@ -805,7 +840,7 @@ var DropdownMenuItem = (0, import_react5.forwardRef)(
|
|
|
805
840
|
...props
|
|
806
841
|
}, ref) => {
|
|
807
842
|
const store = useDropdownStore(externalStore);
|
|
808
|
-
const setOpen = (0,
|
|
843
|
+
const setOpen = (0, import_zustand2.useStore)(store, (s) => s.setOpen);
|
|
809
844
|
const sizeClasses = ITEM_SIZE_CLASSES[size];
|
|
810
845
|
const handleClick = (e) => {
|
|
811
846
|
if (disabled) {
|
|
@@ -866,7 +901,7 @@ var DropdownMenuSeparator = (0, import_react5.forwardRef)(({ className, store: _
|
|
|
866
901
|
DropdownMenuSeparator.displayName = "DropdownMenuSeparator";
|
|
867
902
|
var ProfileMenuTrigger = (0, import_react5.forwardRef)(({ className, onClick, store: externalStore, ...props }, ref) => {
|
|
868
903
|
const store = useDropdownStore(externalStore);
|
|
869
|
-
const open = (0,
|
|
904
|
+
const open = (0, import_zustand2.useStore)(store, (s) => s.open);
|
|
870
905
|
const toggleOpen = () => store.setState({ open: !open });
|
|
871
906
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
872
907
|
"button",
|
|
@@ -999,7 +1034,7 @@ var ProfileMenuFooter = ({
|
|
|
999
1034
|
...props
|
|
1000
1035
|
}) => {
|
|
1001
1036
|
const store = useDropdownStore(externalStore);
|
|
1002
|
-
const setOpen = (0,
|
|
1037
|
+
const setOpen = (0, import_zustand2.useStore)(store, (s) => s.setOpen);
|
|
1003
1038
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1004
1039
|
Button_default,
|
|
1005
1040
|
{
|