dayjs
This commit is contained in:
parent
1b22991cca
commit
5e53f43d74
8 changed files with 106 additions and 9 deletions
|
|
@ -18,10 +18,11 @@ var __copyProps = (to, from, except, desc) => {
|
|||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var dayjs26_exports = {};
|
||||
__export(dayjs26_exports, {
|
||||
defineDayjsBr: () => defineDayjsBr
|
||||
defineDayjsBr: () => defineDayjsBr,
|
||||
iniciarDayjsBr: () => iniciarDayjsBr
|
||||
});
|
||||
module.exports = __toCommonJS(dayjs26_exports);
|
||||
const defineDayjsBr = ({
|
||||
const iniciarDayjsBr = ({
|
||||
dayjs,
|
||||
duration,
|
||||
isSameOrAfter,
|
||||
|
|
@ -43,7 +44,9 @@ const defineDayjsBr = ({
|
|||
dayjs.locale("pt-br");
|
||||
return dayjs;
|
||||
};
|
||||
const defineDayjsBr = iniciarDayjsBr;
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
defineDayjsBr
|
||||
defineDayjsBr,
|
||||
iniciarDayjsBr
|
||||
});
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ __reExport(index_exports, require("./auditoria"), module.exports);
|
|||
__reExport(index_exports, require("./cacheMemoria"), module.exports);
|
||||
__reExport(index_exports, require("./constantes"), module.exports);
|
||||
__reExport(index_exports, require("./consulta"), module.exports);
|
||||
__reExport(index_exports, require("./dayjs26"), module.exports);
|
||||
__reExport(index_exports, require("./ecosistema"), module.exports);
|
||||
__reExport(index_exports, require("./extensoes"), module.exports);
|
||||
__reExport(index_exports, require("./extensoes"), module.exports);
|
||||
|
|
@ -43,6 +44,7 @@ __reExport(index_exports, require("./zDocumento"), module.exports);
|
|||
...require("./cacheMemoria"),
|
||||
...require("./constantes"),
|
||||
...require("./consulta"),
|
||||
...require("./dayjs26"),
|
||||
...require("./ecosistema"),
|
||||
...require("./extensoes"),
|
||||
...require("./extensoes"),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,14 @@
|
|||
import z from 'zod';
|
||||
import _dayjs from 'dayjs';
|
||||
export { Dayjs, ManipulateType } from 'dayjs';
|
||||
import _duration from 'dayjs/plugin/duration';
|
||||
import _isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
|
||||
import _isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
|
||||
import _minMax from 'dayjs/plugin/minMax';
|
||||
import _relativeTime from 'dayjs/plugin/relativeTime';
|
||||
import _timezone from 'dayjs/plugin/timezone';
|
||||
import _utc from 'dayjs/plugin/utc';
|
||||
import _weekOfYear from 'dayjs/plugin/weekOfYear';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
declare const aleatorio: (tamanho?: number) => string;
|
||||
|
|
@ -114,6 +124,84 @@ declare const zFiltro: z.ZodObject<{
|
|||
ou: z.ZodOptional<z.ZodBoolean>;
|
||||
}, z.core.$strip>;
|
||||
|
||||
/**
|
||||
* Utilitário de configuração do Dayjs focado em compatibilidade com SSR.
|
||||
*
|
||||
* PROBLEMA:
|
||||
* A importação direta do `dayjs` e seus plugins frequentemente causa conflitos em ambientes
|
||||
* de Renderização do Lado do Servidor (SSR), como Nuxt ou Next.js, devido a discrepâncias
|
||||
* na resolução de módulos (ESM vs CJS) e instabilidades de importação.
|
||||
*
|
||||
* SOLUÇÃO:
|
||||
* Este módulo utiliza o padrão de Injeção de Dependência. Ele expõe apenas tipagens e
|
||||
* uma função de configuração (`defineDayjsBr`). A responsabilidade de importar as
|
||||
* bibliotecas "vivas" é delegada à aplicação consumidora (o cliente da função).
|
||||
*
|
||||
* Isso permite que o bundler da aplicação principal (Vite, Webpack, etc.) gerencie as
|
||||
* instâncias, garantindo consistência e evitando erros de "module not found" ou
|
||||
* instâncias duplicadas/não inicializadas adequadamente.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Inicializa e configura o Dayjs com o locale 'pt-br' e plugins essenciais.
|
||||
*
|
||||
* MODO DE USO:
|
||||
* Importe os pacotes reais na sua aplicação e passe-os para esta função.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // Em seu arquivo de configuração (ex: plugins/dayjs.ts):
|
||||
* import dayjs from "dayjs"
|
||||
* import duration from "dayjs/plugin/duration"
|
||||
* import isSameOrAfter from "dayjs/plugin/isSameOrAfter"
|
||||
* import isSameOrBefore from "dayjs/plugin/isSameOrBefore"
|
||||
* import minMax from "dayjs/plugin/minMax"
|
||||
* import relativeTime from "dayjs/plugin/relativeTime"
|
||||
* import timezone from "dayjs/plugin/timezone"
|
||||
* import utc from "dayjs/plugin/utc"
|
||||
* import weekOfYear from "dayjs/plugin/weekOfYear"
|
||||
* import { defineDayjsBr } from "p-comuns"
|
||||
* import "dayjs/locale/pt-br" // Importante: importar o locale!
|
||||
|
||||
* export const dayjsbr = defineDayjsBr({
|
||||
* dayjs,
|
||||
* duration,
|
||||
* isSameOrAfter,
|
||||
* isSameOrBefore,
|
||||
* minMax,
|
||||
* relativeTime,
|
||||
* timezone,
|
||||
* utc,
|
||||
* weekOfYear,
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
declare const iniciarDayjsBr: ({ dayjs, duration, isSameOrAfter, isSameOrBefore, minMax, relativeTime, timezone, utc, weekOfYear, }: {
|
||||
dayjs: typeof _dayjs;
|
||||
duration: typeof _duration;
|
||||
isSameOrAfter: typeof _isSameOrAfter;
|
||||
isSameOrBefore: typeof _isSameOrBefore;
|
||||
minMax: typeof _minMax;
|
||||
relativeTime: typeof _relativeTime;
|
||||
timezone: typeof _timezone;
|
||||
utc: typeof _utc;
|
||||
weekOfYear: typeof _weekOfYear;
|
||||
}) => typeof _dayjs;
|
||||
/**
|
||||
* @deprecated Use iniciarDayjsBr em vez de definirDayjsBr. O método defineDayjsBr está obsoleto e será removido em futuras versões.
|
||||
*/
|
||||
declare const defineDayjsBr: ({ dayjs, duration, isSameOrAfter, isSameOrBefore, minMax, relativeTime, timezone, utc, weekOfYear, }: {
|
||||
dayjs: typeof _dayjs;
|
||||
duration: typeof _duration;
|
||||
isSameOrAfter: typeof _isSameOrAfter;
|
||||
isSameOrBefore: typeof _isSameOrBefore;
|
||||
minMax: typeof _minMax;
|
||||
relativeTime: typeof _relativeTime;
|
||||
timezone: typeof _timezone;
|
||||
utc: typeof _utc;
|
||||
weekOfYear: typeof _weekOfYear;
|
||||
}) => typeof _dayjs;
|
||||
|
||||
declare const link_paiol = "https://paiol.idz.one";
|
||||
|
||||
type tiposArquivo = "imagem" | "documento" | "vídeo" | "outros";
|
||||
|
|
@ -478,4 +566,4 @@ declare const zDocCnpj: z.ZodString;
|
|||
declare const zDocCpf: z.ZodString;
|
||||
declare const zDocumento: z.ZodUnion<[z.ZodString, z.ZodString]>;
|
||||
|
||||
export { Produtos, TipagemRotas, type TipoPayloadAuditoria, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, erUuid, esperar, extensoes, iniciarFiltroDelta, type interfaceConsulta, link_paiol, localValor, nomeVariavel, objetoPg, operadorFiltroDeltaDetalhes, operadores, paraObjetoRegistroPg, pgObjeto, siglas_unidades_medida, texto_busca, tipoArquivo, type tipoColunaFiltroDelta, type tipoCondicaoFiltroDelta, type tipoFiltro, type tipoFiltroDelta, type tipoFiltroDeltaColunaTipada, type tipoOperadorFiltroDelta, tipoUsuarioResiduos, tiposSituacoesElicencie, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zColunaFiltroDelta, zCondicaoFiltroDelta, zDocCnpj, zDocCpf, zDocumento, zFiltro, zFiltroDelta, zOperadorFiltroDelta, zOperadores };
|
||||
export { Produtos, TipagemRotas, type TipoPayloadAuditoria, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, defineDayjsBr, erUuid, esperar, extensoes, iniciarDayjsBr, iniciarFiltroDelta, type interfaceConsulta, link_paiol, localValor, nomeVariavel, objetoPg, operadorFiltroDeltaDetalhes, operadores, paraObjetoRegistroPg, pgObjeto, siglas_unidades_medida, texto_busca, tipoArquivo, type tipoColunaFiltroDelta, type tipoCondicaoFiltroDelta, type tipoFiltro, type tipoFiltroDelta, type tipoFiltroDeltaColunaTipada, type tipoOperadorFiltroDelta, tipoUsuarioResiduos, tiposSituacoesElicencie, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zColunaFiltroDelta, zCondicaoFiltroDelta, zDocCnpj, zDocCpf, zDocumento, zFiltro, zFiltroDelta, zOperadorFiltroDelta, zOperadores };
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "p-comuns",
|
||||
"version": "0.343.0",
|
||||
"version": "0.344.0",
|
||||
"description": "",
|
||||
"main": "./dist-front/index.mjs",
|
||||
"module": "./dist-front/index.mjs",
|
||||
|
|
|
|||
BIN
pacote.tgz
BIN
pacote.tgz
Binary file not shown.
|
|
@ -65,7 +65,7 @@ import type _weekOfYear from "dayjs/plugin/weekOfYear"
|
|||
* })
|
||||
* ```
|
||||
*/
|
||||
const defineDayjsBr = ({
|
||||
const iniciarDayjsBr = ({
|
||||
dayjs,
|
||||
duration,
|
||||
isSameOrAfter,
|
||||
|
|
@ -101,6 +101,10 @@ const defineDayjsBr = ({
|
|||
|
||||
return dayjs
|
||||
}
|
||||
/**
|
||||
* @deprecated Use iniciarDayjsBr em vez de definirDayjsBr. O método defineDayjsBr está obsoleto e será removido em futuras versões.
|
||||
*/
|
||||
const defineDayjsBr = iniciarDayjsBr
|
||||
|
||||
export type { Dayjs }
|
||||
export { defineDayjsBr }
|
||||
export { defineDayjsBr, iniciarDayjsBr }
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ export * from "./auditoria"
|
|||
export * from "./cacheMemoria"
|
||||
export * from "./constantes"
|
||||
export * from "./consulta"
|
||||
export * from "./dayjs26"
|
||||
export * from "./ecosistema"
|
||||
export * from "./extensoes"
|
||||
export * from "./extensoes"
|
||||
|
|
@ -15,7 +16,6 @@ export * from "./testes-de-variaveis"
|
|||
export * from "./texto_busca"
|
||||
export * from "./tipagemRotas"
|
||||
export * from "./tipagemRotas"
|
||||
|
||||
export * from "./unidades_medida"
|
||||
export * from "./uuid"
|
||||
export * from "./variaveisComuns"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue