analytica-frontend-lib 1.1.47 → 1.1.49
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/hooks/useTheme/index.d.mts +8 -0
- package/dist/hooks/useTheme/index.d.ts +8 -0
- package/dist/hooks/useTheme/index.js +52 -0
- package/dist/hooks/useTheme/index.js.map +1 -0
- package/dist/hooks/useTheme/index.mjs +27 -0
- package/dist/hooks/useTheme/index.mjs.map +1 -0
- package/dist/index.d.mts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +180 -153
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook para detectar preferências do sistema e aplicar dark mode automaticamente
|
|
3
|
+
* Este hook aplica o theme baseado nas preferências do sistema (prefers-color-scheme)
|
|
4
|
+
* na inicialização do componente.
|
|
5
|
+
*/
|
|
6
|
+
declare const useTheme: () => void;
|
|
7
|
+
|
|
8
|
+
export { useTheme };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook para detectar preferências do sistema e aplicar dark mode automaticamente
|
|
3
|
+
* Este hook aplica o theme baseado nas preferências do sistema (prefers-color-scheme)
|
|
4
|
+
* na inicialização do componente.
|
|
5
|
+
*/
|
|
6
|
+
declare const useTheme: () => void;
|
|
7
|
+
|
|
8
|
+
export { useTheme };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/hooks/useTheme.ts
|
|
21
|
+
var useTheme_exports = {};
|
|
22
|
+
__export(useTheme_exports, {
|
|
23
|
+
useTheme: () => useTheme
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(useTheme_exports);
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var useTheme = () => {
|
|
28
|
+
(0, import_react.useEffect)(() => {
|
|
29
|
+
const htmlElement = document.documentElement;
|
|
30
|
+
const currentTheme = htmlElement.getAttribute("data-theme");
|
|
31
|
+
if (currentTheme && !htmlElement.getAttribute("data-original-theme")) {
|
|
32
|
+
htmlElement.setAttribute("data-original-theme", currentTheme);
|
|
33
|
+
}
|
|
34
|
+
const applyTheme = () => {
|
|
35
|
+
const isDarkMode = window.matchMedia(
|
|
36
|
+
"(prefers-color-scheme: dark)"
|
|
37
|
+
).matches;
|
|
38
|
+
const originalTheme = htmlElement.getAttribute("data-original-theme");
|
|
39
|
+
if (isDarkMode) {
|
|
40
|
+
htmlElement.setAttribute("data-theme", "dark");
|
|
41
|
+
} else if (originalTheme) {
|
|
42
|
+
htmlElement.setAttribute("data-theme", originalTheme);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
applyTheme();
|
|
46
|
+
}, []);
|
|
47
|
+
};
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
useTheme
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useTheme.ts"],"sourcesContent":["import { useEffect } from 'react';\n\n/**\n * Hook para detectar preferências do sistema e aplicar dark mode automaticamente\n * Este hook aplica o theme baseado nas preferências do sistema (prefers-color-scheme)\n * na inicialização do componente.\n */\nexport const useTheme = () => {\n useEffect(() => {\n const htmlElement = document.documentElement;\n\n // Salva o theme original do white label na primeira execução\n const currentTheme = htmlElement.getAttribute('data-theme');\n if (currentTheme && !htmlElement.getAttribute('data-original-theme')) {\n htmlElement.setAttribute('data-original-theme', currentTheme);\n }\n\n // Função para aplicar o theme baseado nas preferências do sistema\n const applyTheme = () => {\n const isDarkMode = window.matchMedia(\n '(prefers-color-scheme: dark)'\n ).matches;\n const originalTheme = htmlElement.getAttribute('data-original-theme');\n\n if (isDarkMode) {\n // Aplica o theme dark\n htmlElement.setAttribute('data-theme', 'dark');\n } else if (originalTheme) {\n // Restaura o theme light do white label\n htmlElement.setAttribute('data-theme', originalTheme);\n }\n };\n\n // Aplica o theme inicial\n applyTheme();\n }, []);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;AAOnB,IAAM,WAAW,MAAM;AAC5B,8BAAU,MAAM;AACd,UAAM,cAAc,SAAS;AAG7B,UAAM,eAAe,YAAY,aAAa,YAAY;AAC1D,QAAI,gBAAgB,CAAC,YAAY,aAAa,qBAAqB,GAAG;AACpE,kBAAY,aAAa,uBAAuB,YAAY;AAAA,IAC9D;AAGA,UAAM,aAAa,MAAM;AACvB,YAAM,aAAa,OAAO;AAAA,QACxB;AAAA,MACF,EAAE;AACF,YAAM,gBAAgB,YAAY,aAAa,qBAAqB;AAEpE,UAAI,YAAY;AAEd,oBAAY,aAAa,cAAc,MAAM;AAAA,MAC/C,WAAW,eAAe;AAExB,oBAAY,aAAa,cAAc,aAAa;AAAA,MACtD;AAAA,IACF;AAGA,eAAW;AAAA,EACb,GAAG,CAAC,CAAC;AACP;","names":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/hooks/useTheme.ts
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
var useTheme = () => {
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const htmlElement = document.documentElement;
|
|
6
|
+
const currentTheme = htmlElement.getAttribute("data-theme");
|
|
7
|
+
if (currentTheme && !htmlElement.getAttribute("data-original-theme")) {
|
|
8
|
+
htmlElement.setAttribute("data-original-theme", currentTheme);
|
|
9
|
+
}
|
|
10
|
+
const applyTheme = () => {
|
|
11
|
+
const isDarkMode = window.matchMedia(
|
|
12
|
+
"(prefers-color-scheme: dark)"
|
|
13
|
+
).matches;
|
|
14
|
+
const originalTheme = htmlElement.getAttribute("data-original-theme");
|
|
15
|
+
if (isDarkMode) {
|
|
16
|
+
htmlElement.setAttribute("data-theme", "dark");
|
|
17
|
+
} else if (originalTheme) {
|
|
18
|
+
htmlElement.setAttribute("data-theme", originalTheme);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
applyTheme();
|
|
22
|
+
}, []);
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
useTheme
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useTheme.ts"],"sourcesContent":["import { useEffect } from 'react';\n\n/**\n * Hook para detectar preferências do sistema e aplicar dark mode automaticamente\n * Este hook aplica o theme baseado nas preferências do sistema (prefers-color-scheme)\n * na inicialização do componente.\n */\nexport const useTheme = () => {\n useEffect(() => {\n const htmlElement = document.documentElement;\n\n // Salva o theme original do white label na primeira execução\n const currentTheme = htmlElement.getAttribute('data-theme');\n if (currentTheme && !htmlElement.getAttribute('data-original-theme')) {\n htmlElement.setAttribute('data-original-theme', currentTheme);\n }\n\n // Função para aplicar o theme baseado nas preferências do sistema\n const applyTheme = () => {\n const isDarkMode = window.matchMedia(\n '(prefers-color-scheme: dark)'\n ).matches;\n const originalTheme = htmlElement.getAttribute('data-original-theme');\n\n if (isDarkMode) {\n // Aplica o theme dark\n htmlElement.setAttribute('data-theme', 'dark');\n } else if (originalTheme) {\n // Restaura o theme light do white label\n htmlElement.setAttribute('data-theme', originalTheme);\n }\n };\n\n // Aplica o theme inicial\n applyTheme();\n }, []);\n};\n"],"mappings":";AAAA,SAAS,iBAAiB;AAOnB,IAAM,WAAW,MAAM;AAC5B,YAAU,MAAM;AACd,UAAM,cAAc,SAAS;AAG7B,UAAM,eAAe,YAAY,aAAa,YAAY;AAC1D,QAAI,gBAAgB,CAAC,YAAY,aAAa,qBAAqB,GAAG;AACpE,kBAAY,aAAa,uBAAuB,YAAY;AAAA,IAC9D;AAGA,UAAM,aAAa,MAAM;AACvB,YAAM,aAAa,OAAO;AAAA,QACxB;AAAA,MACF,EAAE;AACF,YAAM,gBAAgB,YAAY,aAAa,qBAAqB;AAEpE,UAAI,YAAY;AAEd,oBAAY,aAAa,cAAc,MAAM;AAAA,MAC/C,WAAW,eAAe;AAExB,oBAAY,aAAa,cAAc,aAAa;AAAA,MACtD;AAAA,IACF;AAGA,eAAW;AAAA,EACb,GAAG,CAAC,CAAC;AACP;","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -32,6 +32,7 @@ export { AlertDialog } from './AlertDialog/index.mjs';
|
|
|
32
32
|
export { MultipleChoiceList } from './MultipleChoice/index.mjs';
|
|
33
33
|
export { default as IconRender } from './IconRender/index.mjs';
|
|
34
34
|
export { DeviceType, getDeviceType, useMobile } from './hooks/useMobile/index.mjs';
|
|
35
|
+
export { useTheme } from './hooks/useTheme/index.mjs';
|
|
35
36
|
export { default as DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, MenuLabel, ProfileMenuFooter, ProfileMenuHeader, ProfileMenuSection, ProfileMenuTrigger } from './DropdownMenu/index.mjs';
|
|
36
37
|
export { default as Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './Select/index.mjs';
|
|
37
38
|
export { default as Menu, MenuContent, MenuItem, MenuOverflow } from './Menu/index.mjs';
|
|
@@ -279,9 +280,9 @@ declare const createUseNotifications: (apiClient: NotificationApiClient) => () =
|
|
|
279
280
|
deleteNotification: (id: string) => Promise<void>;
|
|
280
281
|
clearNotifications: () => void;
|
|
281
282
|
resetError: () => void;
|
|
282
|
-
markAsReadAndNavigate: (id: string, entityType?: string, entityId?: string) => Promise<void>;
|
|
283
|
+
markAsReadAndNavigate: (id: string, entityType?: string, entityId?: string, onAfterNavigate?: () => void) => Promise<void>;
|
|
283
284
|
refreshNotifications: () => Promise<void>;
|
|
284
|
-
handleNavigate: (entityType?: string, entityId?: string) => void;
|
|
285
|
+
handleNavigate: (entityType?: string, entityId?: string, onAfterNavigate?: () => void) => void;
|
|
285
286
|
getActionLabel: (entityType?: string) => string | undefined;
|
|
286
287
|
getGroupedNotifications: () => NotificationGroup[];
|
|
287
288
|
getFormattedGroupedNotifications: () => {
|
|
@@ -346,9 +347,9 @@ declare const createNotificationsHook: (apiClient: NotificationApiClient) => ()
|
|
|
346
347
|
deleteNotification: (id: string) => Promise<void>;
|
|
347
348
|
clearNotifications: () => void;
|
|
348
349
|
resetError: () => void;
|
|
349
|
-
markAsReadAndNavigate: (id: string, entityType?: string, entityId?: string) => Promise<void>;
|
|
350
|
+
markAsReadAndNavigate: (id: string, entityType?: string, entityId?: string, onAfterNavigate?: () => void) => Promise<void>;
|
|
350
351
|
refreshNotifications: () => Promise<void>;
|
|
351
|
-
handleNavigate: (entityType?: string, entityId?: string) => void;
|
|
352
|
+
handleNavigate: (entityType?: string, entityId?: string, onAfterNavigate?: () => void) => void;
|
|
352
353
|
getActionLabel: (entityType?: string) => string | undefined;
|
|
353
354
|
getGroupedNotifications: () => NotificationGroup[];
|
|
354
355
|
getFormattedGroupedNotifications: () => {
|
package/dist/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export { AlertDialog } from './AlertDialog/index.js';
|
|
|
32
32
|
export { MultipleChoiceList } from './MultipleChoice/index.js';
|
|
33
33
|
export { default as IconRender } from './IconRender/index.js';
|
|
34
34
|
export { DeviceType, getDeviceType, useMobile } from './hooks/useMobile/index.js';
|
|
35
|
+
export { useTheme } from './hooks/useTheme/index.js';
|
|
35
36
|
export { default as DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, MenuLabel, ProfileMenuFooter, ProfileMenuHeader, ProfileMenuSection, ProfileMenuTrigger } from './DropdownMenu/index.js';
|
|
36
37
|
export { default as Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './Select/index.js';
|
|
37
38
|
export { default as Menu, MenuContent, MenuItem, MenuOverflow } from './Menu/index.js';
|
|
@@ -279,9 +280,9 @@ declare const createUseNotifications: (apiClient: NotificationApiClient) => () =
|
|
|
279
280
|
deleteNotification: (id: string) => Promise<void>;
|
|
280
281
|
clearNotifications: () => void;
|
|
281
282
|
resetError: () => void;
|
|
282
|
-
markAsReadAndNavigate: (id: string, entityType?: string, entityId?: string) => Promise<void>;
|
|
283
|
+
markAsReadAndNavigate: (id: string, entityType?: string, entityId?: string, onAfterNavigate?: () => void) => Promise<void>;
|
|
283
284
|
refreshNotifications: () => Promise<void>;
|
|
284
|
-
handleNavigate: (entityType?: string, entityId?: string) => void;
|
|
285
|
+
handleNavigate: (entityType?: string, entityId?: string, onAfterNavigate?: () => void) => void;
|
|
285
286
|
getActionLabel: (entityType?: string) => string | undefined;
|
|
286
287
|
getGroupedNotifications: () => NotificationGroup[];
|
|
287
288
|
getFormattedGroupedNotifications: () => {
|
|
@@ -346,9 +347,9 @@ declare const createNotificationsHook: (apiClient: NotificationApiClient) => ()
|
|
|
346
347
|
deleteNotification: (id: string) => Promise<void>;
|
|
347
348
|
clearNotifications: () => void;
|
|
348
349
|
resetError: () => void;
|
|
349
|
-
markAsReadAndNavigate: (id: string, entityType?: string, entityId?: string) => Promise<void>;
|
|
350
|
+
markAsReadAndNavigate: (id: string, entityType?: string, entityId?: string, onAfterNavigate?: () => void) => Promise<void>;
|
|
350
351
|
refreshNotifications: () => Promise<void>;
|
|
351
|
-
handleNavigate: (entityType?: string, entityId?: string) => void;
|
|
352
|
+
handleNavigate: (entityType?: string, entityId?: string, onAfterNavigate?: () => void) => void;
|
|
352
353
|
getActionLabel: (entityType?: string) => string | undefined;
|
|
353
354
|
getGroupedNotifications: () => NotificationGroup[];
|
|
354
355
|
getFormattedGroupedNotifications: () => {
|