jclib-ui 1.0.293 → 1.0.294

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.
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import React__default, { createContext, useContext, useState, useCallback, useEffect, useRef, useLayoutEffect, useImperativeHandle, useMemo } from "react";
2
+ import React__default, { useEffect, createContext, useContext, useState, useCallback, useRef, useLayoutEffect, useImperativeHandle, useMemo } from "react";
3
3
  import { isDarkMode, random, isMobile, formatData, formatDataHora, formatValor, isDesktop, getDateTimeStr, getHash, validarCNPJ, validarCPF } from "jcinfo-utils";
4
4
  import { useDragControls, motion } from "framer-motion";
5
5
  import styled from "styled-components";
@@ -3895,6 +3895,25 @@ if (process.env.NODE_ENV === "production") {
3895
3895
  jsxRuntime.exports = requireReactJsxRuntime_development();
3896
3896
  }
3897
3897
  var jsxRuntimeExports = jsxRuntime.exports;
3898
+ const MARCADOR_LOCALHOST = " 🔴 ";
3899
+ const MARCADOR_TESTE = " 🟢 ";
3900
+ function useLocalhostBadge() {
3901
+ useEffect(() => {
3902
+ const inLocalhost = window.location.hostname == "localhost" || window.location.hostname == "127.0.0.1" || window.location.hostname == "[::1]" || window.location.hostname.startsWith("192.168.");
3903
+ if (inLocalhost && !document.title.includes(MARCADOR_LOCALHOST)) {
3904
+ document.title = `${MARCADOR_LOCALHOST}${document.title}`;
3905
+ }
3906
+ }, []);
3907
+ }
3908
+ function useTestDomainBadge(testDomain) {
3909
+ useEffect(() => {
3910
+ const domains = testDomain ? [].concat(testDomain) : ["test.", "test-"];
3911
+ const inTestServer = domains.some((domain) => window.location.hostname.includes(domain));
3912
+ if (inTestServer && !document.title.includes(MARCADOR_TESTE)) {
3913
+ document.title = `${MARCADOR_TESTE}${document.title}`;
3914
+ }
3915
+ }, [testDomain]);
3916
+ }
3898
3917
  const LibContext = createContext({
3899
3918
  modalList: [],
3900
3919
  theme: "light",
@@ -3919,7 +3938,7 @@ const LibContext = createContext({
3919
3938
  }
3920
3939
  });
3921
3940
  const cTheme = "sys/theme";
3922
- const LibProvider = ({ apiConfig, children, versionApp, useTheme }) => {
3941
+ const LibProvider = ({ apiConfig, children, versionApp, useTheme, testDomain }) => {
3923
3942
  const canChangeTheme = typeof useTheme == "boolean" ? useTheme : false;
3924
3943
  const [theme, setTheme] = useState(() => {
3925
3944
  let result = "";
@@ -3972,18 +3991,8 @@ const LibProvider = ({ apiConfig, children, versionApp, useTheme }) => {
3972
3991
  },
3973
3992
  [modalList]
3974
3993
  );
3975
- useEffect(() => {
3976
- const MARCADOR = " 🔴 ";
3977
- const inLocalhost = window.location.hostname == "localhost" || window.location.hostname == "127.0.0.1" || window.location.hostname == "[::1]" || window.location.hostname.startsWith("192.168.");
3978
- if (inLocalhost && !document.title.includes(MARCADOR)) {
3979
- document.title = `${MARCADOR}${document.title}`;
3980
- }
3981
- const MARCADOR2 = " 🟢 ";
3982
- const inServerTest = window.location.hostname.includes("test.") || window.location.hostname.includes("test-");
3983
- if (inServerTest && !document.title.includes(MARCADOR2)) {
3984
- document.title = `${MARCADOR2}${document.title}`;
3985
- }
3986
- }, []);
3994
+ useLocalhostBadge();
3995
+ useTestDomainBadge(testDomain);
3987
3996
  useEffect(() => {
3988
3997
  if (canChangeTheme) {
3989
3998
  localStorage.setItem(cTheme, theme);
@@ -25802,8 +25811,10 @@ export {
25802
25811
  useLibContext,
25803
25812
  useLocalForage,
25804
25813
  useLocalStorage,
25814
+ useLocalhostBadge,
25805
25815
  useParamId,
25806
25816
  useQuery,
25807
- useSessionStorage
25817
+ useSessionStorage,
25818
+ useTestDomainBadge
25808
25819
  };
25809
25820
  //# sourceMappingURL=jclib-ui.es.js.map