xertica-ui 1.3.9 → 1.4.1
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/components/ui/alert.tsx +15 -8
- package/components/ui/google-maps-loader.tsx +26 -12
- package/components/ui/index.ts +1 -0
- package/contexts/BrandColorsContext.tsx +5 -5
- package/dist/components/ui/alert.d.ts +4 -1
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/index.es.js +20 -11
- package/dist/index.umd.js +20 -11
- package/package.json +1 -1
package/components/ui/alert.tsx
CHANGED
|
@@ -32,20 +32,27 @@ const alertIcons = {
|
|
|
32
32
|
|
|
33
33
|
type AlertVariantType = keyof typeof alertIcons;
|
|
34
34
|
|
|
35
|
+
export interface AlertProps
|
|
36
|
+
extends React.ComponentProps<"div">,
|
|
37
|
+
VariantProps<typeof alertVariants> {
|
|
38
|
+
icon?: React.ReactNode;
|
|
39
|
+
}
|
|
40
|
+
|
|
35
41
|
function Alert({
|
|
36
42
|
className,
|
|
37
43
|
variant,
|
|
44
|
+
icon,
|
|
38
45
|
children,
|
|
39
46
|
...props
|
|
40
|
-
}:
|
|
47
|
+
}: AlertProps) {
|
|
41
48
|
// Determinar a variante válida com fallback seguro
|
|
42
|
-
const alertVariant: AlertVariantType =
|
|
43
|
-
variant && variant in alertIcons
|
|
44
|
-
? (variant as AlertVariantType)
|
|
49
|
+
const alertVariant: AlertVariantType =
|
|
50
|
+
variant && variant in alertIcons
|
|
51
|
+
? (variant as AlertVariantType)
|
|
45
52
|
: "default";
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
53
|
+
|
|
54
|
+
const DefaultIcon = alertIcons[alertVariant];
|
|
55
|
+
|
|
49
56
|
return (
|
|
50
57
|
<div
|
|
51
58
|
data-slot="alert"
|
|
@@ -53,7 +60,7 @@ function Alert({
|
|
|
53
60
|
className={cn(alertVariants({ variant }), className)}
|
|
54
61
|
{...props}
|
|
55
62
|
>
|
|
56
|
-
<
|
|
63
|
+
{icon !== undefined ? icon : <DefaultIcon className="flex-shrink-0" />}
|
|
57
64
|
<div className="flex-1">{children}</div>
|
|
58
65
|
</div>
|
|
59
66
|
);
|
|
@@ -119,13 +119,14 @@ function loadGoogleMapsScript(apiKey?: string): Promise<void> {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
// Verificar se o script já existe
|
|
122
|
+
// Verificar se o script já existe
|
|
123
123
|
const existing = document.querySelector(`script[src*="maps.googleapis.com/maps/api/js"]`) as HTMLScriptElement;
|
|
124
124
|
if (existing) {
|
|
125
|
-
// Se existe mas com chave diferente,
|
|
125
|
+
// Se existe mas com chave diferente, logar aviso. Não podemos recarregar com SPA se componentes já foram definidos.
|
|
126
126
|
if (!existing.src.includes(`key=${apiKey}`)) {
|
|
127
|
-
console.warn('[GoogleMapsLoader] API key changed, page
|
|
128
|
-
|
|
127
|
+
console.warn('[GoogleMapsLoader] API key changed, but Google Maps cannot be reloaded without a full page refresh because custom elements are already defined.');
|
|
128
|
+
// Don't reject, just resolve to keep the app working with the old key until refresh
|
|
129
|
+
resolve();
|
|
129
130
|
return;
|
|
130
131
|
}
|
|
131
132
|
|
|
@@ -134,7 +135,6 @@ function loadGoogleMapsScript(apiKey?: string): Promise<void> {
|
|
|
134
135
|
resolve();
|
|
135
136
|
} else {
|
|
136
137
|
existing.addEventListener('load', () => {
|
|
137
|
-
// Aguardar um pouco para garantir que todas as bibliotecas foram carregadas
|
|
138
138
|
setTimeout(() => {
|
|
139
139
|
if (isMarkerLibraryLoaded()) {
|
|
140
140
|
resolve();
|
|
@@ -148,6 +148,13 @@ function loadGoogleMapsScript(apiKey?: string): Promise<void> {
|
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
// Prevenir reinjeção se customElements já tem gmp-map (garantia final)
|
|
152
|
+
if (typeof customElements !== 'undefined' && customElements.get('gmp-map')) {
|
|
153
|
+
console.warn('[GoogleMapsLoader] gmp-map is already defined in customElements. Skipping script injection.');
|
|
154
|
+
resolve();
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
151
158
|
// Criar novo script
|
|
152
159
|
const script = document.createElement('script');
|
|
153
160
|
const params = new URLSearchParams({
|
|
@@ -399,16 +406,23 @@ export function reloadGoogleMaps(newApiKey: string): Promise<void> {
|
|
|
399
406
|
}
|
|
400
407
|
|
|
401
408
|
// Verificar se a key atual é a mesma
|
|
402
|
-
const existingScript = document.querySelector(`script[src
|
|
409
|
+
const existingScript = document.querySelector(`script[src*="maps.googleapis.com/maps/api/js"]`) as HTMLScriptElement;
|
|
403
410
|
if (existingScript && existingScript.src.includes(`key=${newApiKey}`)) {
|
|
404
|
-
// Mesma key, apenas resolver
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
411
|
+
// Mesma key, apenas resolver (ou esperar carregar)
|
|
412
|
+
resolve();
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// Se a chave for diferente, NÃO PODEMOS remover o script e adicionar outro
|
|
417
|
+
// se o Google Maps já definiu custom elements. Isso causa o erro:
|
|
418
|
+
// "Element with name 'gmp-...' already defined"
|
|
419
|
+
if (typeof customElements !== 'undefined' && customElements.get('gmp-map')) {
|
|
420
|
+
console.warn('[GoogleMapsLoader] Cannot reload map API dynamically because custom elements (gmp-map) are already registered. A full page reload is required to apply the new API key.');
|
|
421
|
+
resolve(); // Resolver para não quebrar a UI
|
|
422
|
+
return;
|
|
409
423
|
}
|
|
410
424
|
|
|
411
|
-
//
|
|
425
|
+
// Se chegou aqui e não tem custom elements, podemos tentar recarregar
|
|
412
426
|
removeExistingScript();
|
|
413
427
|
|
|
414
428
|
// Atualizar singleton
|
package/components/ui/index.ts
CHANGED
|
@@ -226,6 +226,7 @@ export { RouteMap } from "./route-map";
|
|
|
226
226
|
export type { MapProps } from "./map";
|
|
227
227
|
export type { RouteMapProps } from "./route-map";
|
|
228
228
|
export type { MapLayerType, MapLayersConfig } from "./map-layers";
|
|
229
|
+
export { GoogleMapsLoaderProvider, useGoogleMapsLoader } from "./google-maps-loader";
|
|
229
230
|
|
|
230
231
|
// Xertica Custom Components
|
|
231
232
|
export { XerticaAssistant } from "./xertica-assistant";
|
|
@@ -20,9 +20,9 @@ const BrandColorsContext = createContext<BrandColorsContextType | undefined>(und
|
|
|
20
20
|
|
|
21
21
|
export const BrandColorsProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
|
22
22
|
const [currentTheme, setCurrentTheme] = useState<string>(() => {
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
return
|
|
23
|
+
// Força o tema original / padrão do Xertica UI
|
|
24
|
+
// Ignorando o localStorage para evitar ficar preso em temas antigos sem UI para trocar
|
|
25
|
+
return 'xertica-original';
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
const [radius, setRadius] = useState<number>(0.5);
|
|
@@ -175,8 +175,8 @@ export const BrandColorsProvider: React.FC<{ children: React.ReactNode }> = ({ c
|
|
|
175
175
|
`linear-gradient(135deg, ${gradientStart} 0%, ${gradientEnd} 100%)`
|
|
176
176
|
);
|
|
177
177
|
|
|
178
|
-
//
|
|
179
|
-
localStorage.setItem('xertica-theme-preference', currentTheme);
|
|
178
|
+
// Removido o salvamento de preferência no localStorage para garantir que o tema padrão seja forçado
|
|
179
|
+
// localStorage.setItem('xertica-theme-preference', currentTheme);
|
|
180
180
|
}, [colors, currentTheme, radius]);
|
|
181
181
|
|
|
182
182
|
// Aplicar cores quando elas mudarem
|
|
@@ -3,7 +3,10 @@ import { type VariantProps } from "class-variance-authority";
|
|
|
3
3
|
declare const alertVariants: (props?: ({
|
|
4
4
|
variant?: "default" | "error" | "success" | "warning" | "info" | null | undefined;
|
|
5
5
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
-
|
|
6
|
+
export interface AlertProps extends React.ComponentProps<"div">, VariantProps<typeof alertVariants> {
|
|
7
|
+
icon?: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
declare function Alert({ className, variant, icon, children, ...props }: AlertProps): import("react/jsx-runtime").JSX.Element;
|
|
7
10
|
declare function AlertTitle({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
8
11
|
declare function AlertDescription({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
9
12
|
export { Alert, AlertTitle, AlertDescription };
|
|
@@ -73,6 +73,7 @@ export { RouteMap } from "./route-map";
|
|
|
73
73
|
export type { MapProps } from "./map";
|
|
74
74
|
export type { RouteMapProps } from "./route-map";
|
|
75
75
|
export type { MapLayerType, MapLayersConfig } from "./map-layers";
|
|
76
|
+
export { GoogleMapsLoaderProvider, useGoogleMapsLoader } from "./google-maps-loader";
|
|
76
77
|
export { XerticaAssistant } from "./xertica-assistant";
|
|
77
78
|
export type { MessageType, AttachmentType } from "./xertica-assistant";
|
|
78
79
|
export { PageHeader, PageHeaderDescription, PageHeaderHeading } from "./page-header";
|
package/dist/index.es.js
CHANGED
|
@@ -47804,8 +47804,7 @@ const colorThemes = [
|
|
|
47804
47804
|
const BrandColorsContext = createContext(void 0);
|
|
47805
47805
|
const BrandColorsProvider = ({ children }) => {
|
|
47806
47806
|
const [currentTheme, setCurrentTheme] = useState(() => {
|
|
47807
|
-
|
|
47808
|
-
return saved || "xertica-original";
|
|
47807
|
+
return "xertica-original";
|
|
47809
47808
|
});
|
|
47810
47809
|
const [radius, setRadius] = useState(0.5);
|
|
47811
47810
|
const [colors, setColors] = useState(() => {
|
|
@@ -47896,7 +47895,6 @@ const BrandColorsProvider = ({ children }) => {
|
|
|
47896
47895
|
"--gradient-diagonal",
|
|
47897
47896
|
`linear-gradient(135deg, ${gradientStart} 0%, ${gradientEnd} 100%)`
|
|
47898
47897
|
);
|
|
47899
|
-
localStorage.setItem("xertica-theme-preference", currentTheme);
|
|
47900
47898
|
}, [colors, currentTheme, radius]);
|
|
47901
47899
|
useEffect(() => {
|
|
47902
47900
|
applyColors();
|
|
@@ -47989,8 +47987,8 @@ function loadGoogleMapsScript(apiKey) {
|
|
|
47989
47987
|
const existing = document.querySelector(`script[src*="maps.googleapis.com/maps/api/js"]`);
|
|
47990
47988
|
if (existing) {
|
|
47991
47989
|
if (!existing.src.includes(`key=${apiKey}`)) {
|
|
47992
|
-
console.warn("[GoogleMapsLoader] API key changed, page
|
|
47993
|
-
|
|
47990
|
+
console.warn("[GoogleMapsLoader] API key changed, but Google Maps cannot be reloaded without a full page refresh because custom elements are already defined.");
|
|
47991
|
+
resolve();
|
|
47994
47992
|
return;
|
|
47995
47993
|
}
|
|
47996
47994
|
if (isGoogleMapsAlreadyLoaded() && isMarkerLibraryLoaded()) {
|
|
@@ -48009,6 +48007,11 @@ function loadGoogleMapsScript(apiKey) {
|
|
|
48009
48007
|
}
|
|
48010
48008
|
return;
|
|
48011
48009
|
}
|
|
48010
|
+
if (typeof customElements !== "undefined" && customElements.get("gmp-map")) {
|
|
48011
|
+
console.warn("[GoogleMapsLoader] gmp-map is already defined in customElements. Skipping script injection.");
|
|
48012
|
+
resolve();
|
|
48013
|
+
return;
|
|
48014
|
+
}
|
|
48012
48015
|
const script = document.createElement("script");
|
|
48013
48016
|
const params = new URLSearchParams({
|
|
48014
48017
|
key: apiKey,
|
|
@@ -48175,10 +48178,13 @@ function reloadGoogleMaps(newApiKey) {
|
|
|
48175
48178
|
}
|
|
48176
48179
|
const existingScript = document.querySelector(`script[src*="maps.googleapis.com/maps/api/js"]`);
|
|
48177
48180
|
if (existingScript && existingScript.src.includes(`key=${newApiKey}`)) {
|
|
48178
|
-
|
|
48179
|
-
|
|
48180
|
-
|
|
48181
|
-
|
|
48181
|
+
resolve();
|
|
48182
|
+
return;
|
|
48183
|
+
}
|
|
48184
|
+
if (typeof customElements !== "undefined" && customElements.get("gmp-map")) {
|
|
48185
|
+
console.warn("[GoogleMapsLoader] Cannot reload map API dynamically because custom elements (gmp-map) are already registered. A full page reload is required to apply the new API key.");
|
|
48186
|
+
resolve();
|
|
48187
|
+
return;
|
|
48182
48188
|
}
|
|
48183
48189
|
removeExistingScript();
|
|
48184
48190
|
updateSingleton({ isLoaded: false, loadError: void 0 });
|
|
@@ -51495,11 +51501,12 @@ const alertIcons = {
|
|
|
51495
51501
|
function Alert({
|
|
51496
51502
|
className,
|
|
51497
51503
|
variant,
|
|
51504
|
+
icon,
|
|
51498
51505
|
children,
|
|
51499
51506
|
...props
|
|
51500
51507
|
}) {
|
|
51501
51508
|
const alertVariant = variant && variant in alertIcons ? variant : "default";
|
|
51502
|
-
const
|
|
51509
|
+
const DefaultIcon = alertIcons[alertVariant];
|
|
51503
51510
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
51504
51511
|
"div",
|
|
51505
51512
|
{
|
|
@@ -51508,7 +51515,7 @@ function Alert({
|
|
|
51508
51515
|
className: cn(alertVariants({ variant }), className),
|
|
51509
51516
|
...props,
|
|
51510
51517
|
children: [
|
|
51511
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
51518
|
+
icon !== void 0 ? icon : /* @__PURE__ */ jsxRuntimeExports.jsx(DefaultIcon, { className: "flex-shrink-0" }),
|
|
51512
51519
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children })
|
|
51513
51520
|
]
|
|
51514
51521
|
}
|
|
@@ -98948,6 +98955,7 @@ export {
|
|
|
98948
98955
|
FormLabel,
|
|
98949
98956
|
FormMessage,
|
|
98950
98957
|
FormattedDocument,
|
|
98958
|
+
GoogleMapsLoaderProvider,
|
|
98951
98959
|
Header,
|
|
98952
98960
|
HoverCard,
|
|
98953
98961
|
HoverCardContent,
|
|
@@ -99111,6 +99119,7 @@ export {
|
|
|
99111
99119
|
useAssistente,
|
|
99112
99120
|
useBrandColors,
|
|
99113
99121
|
useFormField,
|
|
99122
|
+
useGoogleMapsLoader,
|
|
99114
99123
|
useIsMobile,
|
|
99115
99124
|
useLanguage,
|
|
99116
99125
|
useLayout,
|
package/dist/index.umd.js
CHANGED
|
@@ -47823,8 +47823,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
47823
47823
|
const BrandColorsContext = React.createContext(void 0);
|
|
47824
47824
|
const BrandColorsProvider = ({ children }) => {
|
|
47825
47825
|
const [currentTheme, setCurrentTheme] = React.useState(() => {
|
|
47826
|
-
|
|
47827
|
-
return saved || "xertica-original";
|
|
47826
|
+
return "xertica-original";
|
|
47828
47827
|
});
|
|
47829
47828
|
const [radius, setRadius] = React.useState(0.5);
|
|
47830
47829
|
const [colors, setColors] = React.useState(() => {
|
|
@@ -47915,7 +47914,6 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
47915
47914
|
"--gradient-diagonal",
|
|
47916
47915
|
`linear-gradient(135deg, ${gradientStart} 0%, ${gradientEnd} 100%)`
|
|
47917
47916
|
);
|
|
47918
|
-
localStorage.setItem("xertica-theme-preference", currentTheme);
|
|
47919
47917
|
}, [colors, currentTheme, radius]);
|
|
47920
47918
|
React.useEffect(() => {
|
|
47921
47919
|
applyColors();
|
|
@@ -48008,8 +48006,8 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
48008
48006
|
const existing = document.querySelector(`script[src*="maps.googleapis.com/maps/api/js"]`);
|
|
48009
48007
|
if (existing) {
|
|
48010
48008
|
if (!existing.src.includes(`key=${apiKey}`)) {
|
|
48011
|
-
console.warn("[GoogleMapsLoader] API key changed, page
|
|
48012
|
-
|
|
48009
|
+
console.warn("[GoogleMapsLoader] API key changed, but Google Maps cannot be reloaded without a full page refresh because custom elements are already defined.");
|
|
48010
|
+
resolve();
|
|
48013
48011
|
return;
|
|
48014
48012
|
}
|
|
48015
48013
|
if (isGoogleMapsAlreadyLoaded() && isMarkerLibraryLoaded()) {
|
|
@@ -48028,6 +48026,11 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
48028
48026
|
}
|
|
48029
48027
|
return;
|
|
48030
48028
|
}
|
|
48029
|
+
if (typeof customElements !== "undefined" && customElements.get("gmp-map")) {
|
|
48030
|
+
console.warn("[GoogleMapsLoader] gmp-map is already defined in customElements. Skipping script injection.");
|
|
48031
|
+
resolve();
|
|
48032
|
+
return;
|
|
48033
|
+
}
|
|
48031
48034
|
const script = document.createElement("script");
|
|
48032
48035
|
const params = new URLSearchParams({
|
|
48033
48036
|
key: apiKey,
|
|
@@ -48194,10 +48197,13 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
48194
48197
|
}
|
|
48195
48198
|
const existingScript = document.querySelector(`script[src*="maps.googleapis.com/maps/api/js"]`);
|
|
48196
48199
|
if (existingScript && existingScript.src.includes(`key=${newApiKey}`)) {
|
|
48197
|
-
|
|
48198
|
-
|
|
48199
|
-
|
|
48200
|
-
|
|
48200
|
+
resolve();
|
|
48201
|
+
return;
|
|
48202
|
+
}
|
|
48203
|
+
if (typeof customElements !== "undefined" && customElements.get("gmp-map")) {
|
|
48204
|
+
console.warn("[GoogleMapsLoader] Cannot reload map API dynamically because custom elements (gmp-map) are already registered. A full page reload is required to apply the new API key.");
|
|
48205
|
+
resolve();
|
|
48206
|
+
return;
|
|
48201
48207
|
}
|
|
48202
48208
|
removeExistingScript();
|
|
48203
48209
|
updateSingleton({ isLoaded: false, loadError: void 0 });
|
|
@@ -51514,11 +51520,12 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
51514
51520
|
function Alert({
|
|
51515
51521
|
className,
|
|
51516
51522
|
variant,
|
|
51523
|
+
icon,
|
|
51517
51524
|
children,
|
|
51518
51525
|
...props
|
|
51519
51526
|
}) {
|
|
51520
51527
|
const alertVariant = variant && variant in alertIcons ? variant : "default";
|
|
51521
|
-
const
|
|
51528
|
+
const DefaultIcon = alertIcons[alertVariant];
|
|
51522
51529
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
51523
51530
|
"div",
|
|
51524
51531
|
{
|
|
@@ -51527,7 +51534,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
51527
51534
|
className: cn(alertVariants({ variant }), className),
|
|
51528
51535
|
...props,
|
|
51529
51536
|
children: [
|
|
51530
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
51537
|
+
icon !== void 0 ? icon : /* @__PURE__ */ jsxRuntimeExports.jsx(DefaultIcon, { className: "flex-shrink-0" }),
|
|
51531
51538
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children })
|
|
51532
51539
|
]
|
|
51533
51540
|
}
|
|
@@ -98966,6 +98973,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert-
|
|
|
98966
98973
|
exports2.FormLabel = FormLabel;
|
|
98967
98974
|
exports2.FormMessage = FormMessage;
|
|
98968
98975
|
exports2.FormattedDocument = FormattedDocument;
|
|
98976
|
+
exports2.GoogleMapsLoaderProvider = GoogleMapsLoaderProvider;
|
|
98969
98977
|
exports2.Header = Header;
|
|
98970
98978
|
exports2.HoverCard = HoverCard;
|
|
98971
98979
|
exports2.HoverCardContent = HoverCardContent;
|
|
@@ -99129,6 +99137,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert-
|
|
|
99129
99137
|
exports2.useAssistente = useAssistente;
|
|
99130
99138
|
exports2.useBrandColors = useBrandColors;
|
|
99131
99139
|
exports2.useFormField = useFormField;
|
|
99140
|
+
exports2.useGoogleMapsLoader = useGoogleMapsLoader;
|
|
99132
99141
|
exports2.useIsMobile = useIsMobile;
|
|
99133
99142
|
exports2.useLanguage = useLanguage;
|
|
99134
99143
|
exports2.useLayout = useLayout;
|