@seedgrid/fe-components 2026.11.1 → 2026.11.2
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/ai/seedgrid-components.manifest.json +1180 -0
- package/dist/generated/compiledStyles.d.ts +1 -1
- package/dist/generated/compiledStyles.d.ts.map +1 -1
- package/dist/generated/compiledStyles.js +1 -1
- package/dist/i18n/en-US.d.ts.map +1 -1
- package/dist/i18n/en-US.js +29 -0
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +29 -0
- package/dist/i18n/fr.d.ts.map +1 -1
- package/dist/i18n/fr.js +29 -0
- package/dist/i18n/pt-BR.d.ts.map +1 -1
- package/dist/i18n/pt-BR.js +29 -0
- package/dist/i18n/pt-PT.d.ts.map +1 -1
- package/dist/i18n/pt-PT.js +29 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/inputs/SgCameraCapture.d.ts +25 -0
- package/dist/inputs/SgCameraCapture.d.ts.map +1 -0
- package/dist/inputs/SgCameraCapture.js +114 -0
- package/dist/inputs/SgCameraCapture.meta.d.ts +4 -0
- package/dist/inputs/SgCameraCapture.meta.d.ts.map +1 -0
- package/dist/inputs/SgCameraCapture.meta.js +63 -0
- package/dist/inputs/SgFileUpload.d.ts +69 -0
- package/dist/inputs/SgFileUpload.d.ts.map +1 -0
- package/dist/inputs/SgFileUpload.js +234 -0
- package/dist/inputs/SgFileUpload.meta.d.ts +4 -0
- package/dist/inputs/SgFileUpload.meta.d.ts.map +1 -0
- package/dist/inputs/SgFileUpload.meta.js +71 -0
- package/dist/inputs/SgImageUpload.d.ts +20 -0
- package/dist/inputs/SgImageUpload.d.ts.map +1 -0
- package/dist/inputs/SgImageUpload.js +74 -0
- package/dist/inputs/SgImageUpload.meta.d.ts +4 -0
- package/dist/inputs/SgImageUpload.meta.d.ts.map +1 -0
- package/dist/inputs/SgImageUpload.meta.js +73 -0
- package/dist/inputs/SgInputDateTime.d.ts +29 -0
- package/dist/inputs/SgInputDateTime.d.ts.map +1 -0
- package/dist/inputs/SgInputDateTime.js +130 -0
- package/dist/inputs/SgInputDateTime.meta.d.ts +4 -0
- package/dist/inputs/SgInputDateTime.meta.d.ts.map +1 -0
- package/dist/inputs/SgInputDateTime.meta.js +73 -0
- package/dist/inputs/cameraLogic.d.ts +27 -0
- package/dist/inputs/cameraLogic.d.ts.map +1 -0
- package/dist/inputs/cameraLogic.js +57 -0
- package/dist/inputs/dateTimeLogic.d.ts +22 -0
- package/dist/inputs/dateTimeLogic.d.ts.map +1 -0
- package/dist/inputs/dateTimeLogic.js +140 -0
- package/dist/inputs/fileUploadLogic.d.ts +62 -0
- package/dist/inputs/fileUploadLogic.d.ts.map +1 -0
- package/dist/inputs/fileUploadLogic.js +254 -0
- package/dist/inputs/imageUploadLogic.d.ts +31 -0
- package/dist/inputs/imageUploadLogic.d.ts.map +1 -0
- package/dist/inputs/imageUploadLogic.js +70 -0
- package/dist/menus/SgDockMenu.d.ts.map +1 -1
- package/dist/menus/SgDockMenu.js +2 -0
- package/dist/sandbox.cjs +62 -51
- package/dist/style.css +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export const sgMeta = {
|
|
2
|
+
version: "0.1",
|
|
3
|
+
componentId: "form.input.file-upload",
|
|
4
|
+
package: "@seedgrid/fe-components",
|
|
5
|
+
exportName: "SgFileUpload",
|
|
6
|
+
slug: "sg-file-upload",
|
|
7
|
+
displayName: "SgFileUpload",
|
|
8
|
+
category: "input",
|
|
9
|
+
subcategory: "file",
|
|
10
|
+
description: "Seleciona um ou varios arquivos (clique ou arrastar e soltar), confere o tipo pelo conteudo e valida quantidade e tamanho (por arquivo e total). Mostra a lista com o icone do tipo e permite remover. Nao envia nada ao servidor: entrega os arquivos ao pai.",
|
|
11
|
+
tags: ["form", "file", "upload", "attachment", "document", "pdf", "spreadsheet", "rhf"],
|
|
12
|
+
capabilities: ["rhf", "controlled", "drag-and-drop", "multiple", "validation"],
|
|
13
|
+
fieldSemantics: ["file", "attachment", "document", "upload", "pdf", "spreadsheet"],
|
|
14
|
+
props: [
|
|
15
|
+
{ name: "id", type: "string", required: true, description: "Identificador unico do campo.", semanticRole: "data", bindable: false },
|
|
16
|
+
{ name: "name", type: "string", description: "Nome do campo para formularios.", semanticRole: "data", bindable: true },
|
|
17
|
+
{ name: "label", type: "string", description: "Rotulo exibido acima da area.", semanticRole: "label", bindable: true },
|
|
18
|
+
{ name: "value", type: "SgFileValue[] | null", description: "Arquivos controlados (sempre lista; um arquivo = lista de um). Um arquivo ja salvo entra como { name, url }.", semanticRole: "data", bindable: true },
|
|
19
|
+
{ name: "mediaType", type: "MediaType[]", description: "Tipos aceitos: image, video, audio, pdf, doc, docx, xls, xlsx, ppt, pptx, csv, txt, zip ou all. O tipo e conferido pelo conteudo do arquivo.", semanticRole: "validation", bindable: true },
|
|
20
|
+
{ name: "accept", type: "string", description: "Tipos extras em texto livre (.pdf, image/png, image/*), separados por virgula; soma-se ao mediaType.", semanticRole: "validation", bindable: true },
|
|
21
|
+
{ name: "maxFiles", type: "number", default: 1, description: "Quantos arquivos o campo guarda. Com 1, escolher outro substitui; maior que 1 liga a selecao multipla.", semanticRole: "validation", bindable: true },
|
|
22
|
+
{ name: "maxSizePerFile", type: "SizeLimit", description: "Tamanho maximo de cada arquivo: bytes (numero) ou texto com unidade (\"500KB\", \"1.5MB\", \"1GB\").", semanticRole: "validation", bindable: true },
|
|
23
|
+
{ name: "maxSizeTotal", type: "SizeLimit", description: "Tamanho maximo da soma dos arquivos: bytes (numero) ou texto com unidade.", semanticRole: "validation", bindable: true },
|
|
24
|
+
{ name: "disabled", type: "boolean", default: false, description: "Desabilita a escolha e a remocao.", semanticRole: "appearance", bindable: true },
|
|
25
|
+
{ name: "onChange", type: "(files: SgFileValue[]) => void", description: "Lista de arquivos validos apos escolher ou remover.", semanticRole: "event", bindable: false },
|
|
26
|
+
{ name: "onError", type: "(code: FileErrorCode, message: string, fileName: string) => void", description: "Arquivo recusado (type, size, total, count). Os demais seguem validos.", semanticRole: "event", bindable: false }
|
|
27
|
+
],
|
|
28
|
+
states: ["default", "focused", "loading", "disabled", "readOnly", "error"],
|
|
29
|
+
examples: [
|
|
30
|
+
{
|
|
31
|
+
id: "basic",
|
|
32
|
+
title: "Basico",
|
|
33
|
+
file: "apps/showcase/src/app/components/sg-file-upload/samples/basico.tsx.sample",
|
|
34
|
+
kind: "sample"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: "many",
|
|
38
|
+
title: "Varios arquivos",
|
|
39
|
+
file: "apps/showcase/src/app/components/sg-file-upload/samples/varios.tsx.sample",
|
|
40
|
+
kind: "sample"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: "playground",
|
|
44
|
+
title: "Playground",
|
|
45
|
+
file: "apps/showcase/src/app/components/sg-file-upload/sg-file-upload.tsx.playground",
|
|
46
|
+
kind: "playground"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
showcase: { route: "/components/sg-file-upload", hasPlayground: true, hasPropsTable: true },
|
|
50
|
+
sdui: { rendererType: "field.file", acceptsDataBinding: true, defaultProps: {} }
|
|
51
|
+
};
|
|
52
|
+
export const aiHints = {
|
|
53
|
+
version: "0.1",
|
|
54
|
+
preferredUseCases: [
|
|
55
|
+
"Anexar um ou varios documentos (PDF, planilhas, apresentacoes, zip) a um cadastro ou solicitacao.",
|
|
56
|
+
"Escolher arquivos validando tipo (pelo conteudo), quantidade e tamanho antes de enviar.",
|
|
57
|
+
"Formularios que precisam de arquivos como campo."
|
|
58
|
+
],
|
|
59
|
+
avoidUseCases: [
|
|
60
|
+
"Fotos e imagens com miniatura, dimensao minima ou proporcao; para isso use SgImageUpload.",
|
|
61
|
+
"Capturar pela camera do dispositivo; para isso use SgCameraCapture.",
|
|
62
|
+
"Envio ao servidor ou progresso de upload; nao fazem parte do componente."
|
|
63
|
+
],
|
|
64
|
+
synonyms: ["file upload", "attachment", "anexar arquivo", "upload de arquivo", "documento", "file picker"],
|
|
65
|
+
relatedEntityFields: ["attachment", "document", "file", "contract", "invoice", "receipt"],
|
|
66
|
+
compositionHints: [
|
|
67
|
+
"Envie os arquivos recebidos em onChange pelo servico de arquivos do host; o componente nunca envia sozinho.",
|
|
68
|
+
"Para imagens com miniatura e regras de dimensao, use SgImageUpload (composicao deste componente)."
|
|
69
|
+
],
|
|
70
|
+
rankingSignals: { freeText: 0, structuredChoice: 0.1, date: 0, number: 0, denseLayout: 0.4 }
|
|
71
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type SgFileUploadProps } from "./SgFileUpload";
|
|
2
|
+
/**
|
|
3
|
+
* SgImageUpload (P133, refeito no P141 como COMPOSICAO do SgFileUpload): so imagens (`mediaType: ["image"]`, tipo
|
|
4
|
+
* conferido pelo conteudo), miniaturas no lugar do icone e as regras que so existem para imagem: largura/altura
|
|
5
|
+
* minimas e proporcao. Valor = lista (uma imagem = lista de uma); `maxFiles` maior que 1 mostra a grade.
|
|
6
|
+
*/
|
|
7
|
+
export type SgImageUploadProps = Omit<SgFileUploadProps, "mediaType" | "extraCheck" | "thumbnailBuilder" | "thumbnailSize" | "dropTextKey" | "dropManyTextKey" | "typeNames" | "pickerAccept" | "keyPrefix"> & {
|
|
8
|
+
/** Restringe os formatos de imagem em texto livre (`.png`, `image/jpeg`), separados por virgula. */
|
|
9
|
+
accept?: string;
|
|
10
|
+
/** Largura minima em px. */
|
|
11
|
+
minWidth?: number;
|
|
12
|
+
/** Altura minima em px. */
|
|
13
|
+
minHeight?: number;
|
|
14
|
+
/** Proporcao largura/altura exigida (1 = quadrada, 16 / 9). */
|
|
15
|
+
aspect?: number;
|
|
16
|
+
/** Altura da miniatura em px (padrao 160; na grade, no maximo 120). */
|
|
17
|
+
previewHeight?: number;
|
|
18
|
+
};
|
|
19
|
+
export declare function SgImageUpload(props: SgImageUploadProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
//# sourceMappingURL=SgImageUpload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SgImageUpload.d.ts","sourceRoot":"","sources":["../../src/inputs/SgImageUpload.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAsC,KAAK,iBAAiB,EAAoB,MAAM,gBAAgB,CAAC;AAE9G;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,iBAAiB,EACjB,WAAW,GAAG,YAAY,GAAG,kBAAkB,GAAG,eAAe,GAAG,aAAa,GAAG,iBAAiB,GAAG,WAAW,GAAG,cAAc,GAAG,WAAW,CACnJ,GAAG;IACF,oGAAoG;IACpG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAqDF,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,2CAgDtD"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { ImageOff } from "lucide-react";
|
|
5
|
+
import { t, useComponentsI18n } from "../i18n";
|
|
6
|
+
import { formatAspect, validateImage } from "./imageUploadLogic";
|
|
7
|
+
import { matchesMedia } from "./fileUploadLogic";
|
|
8
|
+
import { SgFileUpload } from "./SgFileUpload";
|
|
9
|
+
function readDimensions(file) {
|
|
10
|
+
return new Promise((resolve) => {
|
|
11
|
+
const url = URL.createObjectURL(file);
|
|
12
|
+
const img = new Image();
|
|
13
|
+
img.onload = () => {
|
|
14
|
+
URL.revokeObjectURL(url);
|
|
15
|
+
resolve({ width: img.naturalWidth, height: img.naturalHeight });
|
|
16
|
+
};
|
|
17
|
+
img.onerror = () => {
|
|
18
|
+
URL.revokeObjectURL(url);
|
|
19
|
+
resolve(null);
|
|
20
|
+
};
|
|
21
|
+
img.src = url;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function Thumbnail(props) {
|
|
25
|
+
const { file, id, side } = props;
|
|
26
|
+
const [url, setUrl] = React.useState(null);
|
|
27
|
+
const [broken, setBroken] = React.useState(false);
|
|
28
|
+
React.useEffect(() => {
|
|
29
|
+
setBroken(false);
|
|
30
|
+
if (typeof File !== "undefined" && file instanceof File) {
|
|
31
|
+
const objectUrl = URL.createObjectURL(file);
|
|
32
|
+
setUrl(objectUrl);
|
|
33
|
+
return () => URL.revokeObjectURL(objectUrl);
|
|
34
|
+
}
|
|
35
|
+
setUrl("url" in file && file.url ? file.url : null);
|
|
36
|
+
return undefined;
|
|
37
|
+
}, [file]);
|
|
38
|
+
if (!url || broken) {
|
|
39
|
+
return (_jsx("span", { className: "flex size-full items-center justify-center bg-muted/40 text-muted-foreground", children: _jsx(ImageOff, { className: "size-5", "aria-hidden": "true" }) }));
|
|
40
|
+
}
|
|
41
|
+
return (
|
|
42
|
+
// eslint-disable-next-line @next/next/no-img-element
|
|
43
|
+
_jsx("img", { src: url, alt: file.name, "data-sg": `sg-image-preview-${id}-${file.name}`, width: side, height: side, onError: () => setBroken(true), className: "size-full object-cover" }));
|
|
44
|
+
}
|
|
45
|
+
export function SgImageUpload(props) {
|
|
46
|
+
const i18n = useComponentsI18n();
|
|
47
|
+
const { accept, minWidth, minHeight, aspect, previewHeight = 160, maxFiles, id, ...rest } = props;
|
|
48
|
+
const multi = (maxFiles ?? 1) > 1;
|
|
49
|
+
const side = multi && previewHeight > 120 ? 120 : previewHeight;
|
|
50
|
+
const check = async (file, info) => {
|
|
51
|
+
if ((accept ?? "").trim() && !matchesMedia(file.name, info.mime, undefined, accept)) {
|
|
52
|
+
return { code: "type", message: t(i18n, "components.inputs.fileupload.type", { types: (accept ?? "").trim() }) };
|
|
53
|
+
}
|
|
54
|
+
const needsDimensions = minWidth !== undefined || minHeight !== undefined || aspect !== undefined;
|
|
55
|
+
if (!needsDimensions)
|
|
56
|
+
return null;
|
|
57
|
+
const dims = await readDimensions(file);
|
|
58
|
+
const code = validateImage({ name: "", type: "", size: file.size, width: dims?.width, height: dims?.height }, { accept: "", minWidth, minHeight, aspect });
|
|
59
|
+
if (code === "dimension") {
|
|
60
|
+
return {
|
|
61
|
+
code,
|
|
62
|
+
message: t(i18n, "components.inputs.imageupload.dimension", {
|
|
63
|
+
minWidth: String(minWidth ?? 0),
|
|
64
|
+
minHeight: String(minHeight ?? 0)
|
|
65
|
+
})
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (code === "aspect") {
|
|
69
|
+
return { code, message: t(i18n, "components.inputs.imageupload.aspect", { aspect: formatAspect(aspect ?? 1) }) };
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
};
|
|
73
|
+
return (_jsx(SgFileUpload, { ...rest, id: id, maxFiles: maxFiles, keyPrefix: "sg-image", mediaType: ["image"], typeNames: (accept ?? "").trim() ? (accept ?? "").trim() : "image", dropTextKey: "components.inputs.imageupload.drop", dropManyTextKey: "components.inputs.imageupload.dropMany", pickerAccept: (accept ?? "").trim() ? (accept ?? "").trim() : "image/*", extraCheck: check, thumbnailBuilder: (file, size) => _jsx(Thumbnail, { file: file, id: id, side: size }), thumbnailSize: side }));
|
|
74
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SgImageUpload.meta.d.ts","sourceRoot":"","sources":["../../src/inputs/SgImageUpload.meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE9D,eAAO,MAAM,MAAM,EAAE,QAqDpB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,WAmBrB,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export const sgMeta = {
|
|
2
|
+
version: "0.1",
|
|
3
|
+
componentId: "form.input.image-upload",
|
|
4
|
+
package: "@seedgrid/fe-components",
|
|
5
|
+
exportName: "SgImageUpload",
|
|
6
|
+
slug: "sg-image-upload",
|
|
7
|
+
displayName: "SgImageUpload",
|
|
8
|
+
category: "input",
|
|
9
|
+
subcategory: "file",
|
|
10
|
+
description: "Seleciona uma ou varias imagens (clique ou arrastar e soltar), valida tipo (pelo conteudo), tamanho, dimensao minima e proporcao, mostra as miniaturas e permite remover. Composicao do SgFileUpload. Nao envia nada ao servidor: entrega os arquivos ao pai.",
|
|
11
|
+
tags: ["form", "image", "upload", "photo", "avatar", "file", "rhf"],
|
|
12
|
+
capabilities: ["rhf", "controlled", "drag-and-drop", "preview", "validation"],
|
|
13
|
+
fieldSemantics: ["image", "photo", "avatar", "logo", "picture", "attachment"],
|
|
14
|
+
props: [
|
|
15
|
+
{ name: "id", type: "string", required: true, description: "Identificador unico do campo.", semanticRole: "data", bindable: false },
|
|
16
|
+
{ name: "name", type: "string", description: "Nome do campo para formularios.", semanticRole: "data", bindable: true },
|
|
17
|
+
{ name: "label", type: "string", description: "Rotulo exibido acima da area.", semanticRole: "label", bindable: true },
|
|
18
|
+
{ name: "value", type: "SgFileValue[] | null", description: "Imagens controladas (sempre lista; uma imagem = lista de uma). Uma imagem ja salva entra como { name, url }.", semanticRole: "data", bindable: true },
|
|
19
|
+
{ name: "accept", type: "string", description: "Restringe os formatos de imagem em texto livre (.png, image/jpeg), separados por virgula.", semanticRole: "validation", bindable: true },
|
|
20
|
+
{ name: "maxFiles", type: "number", default: 1, description: "Quantas imagens o campo guarda. Com 1, escolher outra substitui; maior que 1 liga a selecao multipla e a grade de miniaturas.", semanticRole: "validation", bindable: true },
|
|
21
|
+
{ name: "maxSizePerFile", type: "SizeLimit", description: "Tamanho maximo de cada imagem: bytes (numero) ou texto com unidade (\"500KB\", \"2MB\").", semanticRole: "validation", bindable: true },
|
|
22
|
+
{ name: "maxSizeTotal", type: "SizeLimit", description: "Tamanho maximo da soma das imagens: bytes (numero) ou texto com unidade.", semanticRole: "validation", bindable: true },
|
|
23
|
+
{ name: "minWidth", type: "number", description: "Largura minima em px.", semanticRole: "validation", bindable: true },
|
|
24
|
+
{ name: "minHeight", type: "number", description: "Altura minima em px.", semanticRole: "validation", bindable: true },
|
|
25
|
+
{ name: "aspect", type: "number", description: "Proporcao largura/altura exigida (1 = quadrada).", semanticRole: "validation", bindable: true },
|
|
26
|
+
{ name: "disabled", type: "boolean", default: false, description: "Desabilita a escolha e a remocao.", semanticRole: "appearance", bindable: true },
|
|
27
|
+
{ name: "onChange", type: "(files: SgFileValue[]) => void", description: "Lista de imagens validas apos escolher ou remover.", semanticRole: "event", bindable: false },
|
|
28
|
+
{ name: "onError", type: "(code: FileErrorCode, message: string, fileName: string) => void", description: "Imagem recusada (type, size, total, count, dimension, aspect). As demais seguem validas.", semanticRole: "event", bindable: false }
|
|
29
|
+
],
|
|
30
|
+
states: ["default", "focused", "loading", "disabled", "readOnly", "error"],
|
|
31
|
+
examples: [
|
|
32
|
+
{
|
|
33
|
+
id: "basic",
|
|
34
|
+
title: "Basico",
|
|
35
|
+
file: "apps/showcase/src/app/components/sg-image-upload/samples/basico.tsx.sample",
|
|
36
|
+
kind: "sample"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: "many",
|
|
40
|
+
title: "Varias imagens",
|
|
41
|
+
file: "apps/showcase/src/app/components/sg-image-upload/samples/varias.tsx.sample",
|
|
42
|
+
kind: "sample"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: "playground",
|
|
46
|
+
title: "Playground",
|
|
47
|
+
file: "apps/showcase/src/app/components/sg-image-upload/sg-image-upload.tsx.playground",
|
|
48
|
+
kind: "playground"
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
showcase: { route: "/components/sg-image-upload", hasPlayground: true, hasPropsTable: true },
|
|
52
|
+
sdui: { rendererType: "field.image", acceptsDataBinding: true, defaultProps: {} }
|
|
53
|
+
};
|
|
54
|
+
export const aiHints = {
|
|
55
|
+
version: "0.1",
|
|
56
|
+
preferredUseCases: [
|
|
57
|
+
"Foto de perfil, avatar, logotipo ou foto de documento com pre-visualizacao.",
|
|
58
|
+
"Escolher uma ou varias imagens validando tipo, tamanho e dimensao antes de enviar.",
|
|
59
|
+
"Formularios que precisam de imagens como campo."
|
|
60
|
+
],
|
|
61
|
+
avoidUseCases: [
|
|
62
|
+
"Arquivos que nao sao imagem (PDF, planilhas); nesses casos use SgFileUpload.",
|
|
63
|
+
"Capturar pela camera do dispositivo; para isso use SgCameraCapture.",
|
|
64
|
+
"Recorte ou compressao de imagem; nao fazem parte do componente."
|
|
65
|
+
],
|
|
66
|
+
synonyms: ["image upload", "photo upload", "avatar picker", "enviar foto", "upload de imagem", "logo upload"],
|
|
67
|
+
relatedEntityFields: ["photo", "avatar", "logo", "image", "picture", "documentPhoto"],
|
|
68
|
+
compositionHints: [
|
|
69
|
+
"Envie os arquivos recebidos em onChange pelo servico de arquivos do host; o componente nunca envia sozinho.",
|
|
70
|
+
"Combine com SgPanel e SgInputText em cadastros de pessoa ou produto."
|
|
71
|
+
],
|
|
72
|
+
rankingSignals: { freeText: 0, structuredChoice: 0.1, date: 0, number: 0, denseLayout: 0.4 }
|
|
73
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type SgInputTextProps } from "./SgInputText";
|
|
2
|
+
export type SgInputDateTimeProps = Omit<SgInputTextProps, "type" | "onChange"> & {
|
|
3
|
+
/** Instante controlado: ISO 8601 (com offset ou "Z") ou `Date`. `null`/"" limpa o campo. */
|
|
4
|
+
value?: string | Date | null;
|
|
5
|
+
/** Instante inicial (campo nao controlado). */
|
|
6
|
+
defaultValue?: string | Date | null;
|
|
7
|
+
/**
|
|
8
|
+
* Disparado a cada alteracao com o instante em ISO 8601 UTC (`2026-11-03T17:30:00.000Z`) ou `null` se o
|
|
9
|
+
* campo ficou vazio/incompleto/invalido; `local` e o texto do campo (`2026-11-03T14:30`) no fuso do campo.
|
|
10
|
+
*/
|
|
11
|
+
onChange?: (value: string | null, local: string) => void;
|
|
12
|
+
/** Disparado ao receber foco — padrao seedgrid. */
|
|
13
|
+
onEnter?: () => void;
|
|
14
|
+
/** Disparado ao perder o foco (apos validacao) — padrao seedgrid. */
|
|
15
|
+
onExit?: () => void;
|
|
16
|
+
/** Menor instante permitido (ISO 8601 ou `Date`). */
|
|
17
|
+
minDate?: string | Date;
|
|
18
|
+
/** Maior instante permitido (ISO 8601 ou `Date`). */
|
|
19
|
+
maxDate?: string | Date;
|
|
20
|
+
/** Fuso em que o campo mostra e interpreta a hora: "local" (padrao), "UTC", "+03:00" ou nome IANA. */
|
|
21
|
+
timeZone?: string;
|
|
22
|
+
/** Mostra e aceita segundos. */
|
|
23
|
+
showSeconds?: boolean;
|
|
24
|
+
/** Passo dos minutos (1, 5, 10, 15, 30...). Ignorado com `showSeconds`. */
|
|
25
|
+
minuteStep?: number;
|
|
26
|
+
alwaysFloat?: boolean;
|
|
27
|
+
};
|
|
28
|
+
export declare function SgInputDateTime(props: SgInputDateTimeProps): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
//# sourceMappingURL=SgInputDateTime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SgInputDateTime.d.ts","sourceRoot":"","sources":["../../src/inputs/SgInputDateTime.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAYnE,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,UAAU,CAAC,GAAG;IAC/E,4FAA4F;IAC5F,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IAC7B,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IACpC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzD,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,sGAAsG;IACtG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gCAAgC;IAChC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AASF,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,2CA8J1D"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { SgInputText } from "./SgInputText";
|
|
5
|
+
import { resolveFieldError } from "../rhf";
|
|
6
|
+
import { t, useComponentsI18n } from "../i18n";
|
|
7
|
+
import { useDarkFlag } from "../gadgets/clock/themes/useDarkFlag";
|
|
8
|
+
import { formatWallClock, instantToWallClock, snapMinutes, validateDateTime, wallClockToInstant } from "./dateTimeLogic";
|
|
9
|
+
/** Teto do atributo HTML quando nao ha `maxDate` (o <input> aceitaria ano de 6 digitos). */
|
|
10
|
+
const WIDGET_MAX = "9999-12-31T23:59";
|
|
11
|
+
function localOf(value, timeZone, showSeconds) {
|
|
12
|
+
return instantToWallClock(value ?? undefined, timeZone, showSeconds);
|
|
13
|
+
}
|
|
14
|
+
export function SgInputDateTime(props) {
|
|
15
|
+
const i18n = useComponentsI18n();
|
|
16
|
+
const isDark = useDarkFlag();
|
|
17
|
+
const { value, defaultValue, onChange, minDate, maxDate, timeZone, showSeconds = false, minuteStep, inputProps, alwaysFloat, required, requiredMessage, validateOnBlur, validation, onValidation, error, ...rest } = props;
|
|
18
|
+
const rhfManaged = Boolean(rest.control && rest.name);
|
|
19
|
+
const controlled = value !== undefined;
|
|
20
|
+
const [innerLocal, setInnerLocal] = React.useState(() => localOf(defaultValue, timeZone, showSeconds));
|
|
21
|
+
const local = controlled ? localOf(value, timeZone, showSeconds) : innerLocal;
|
|
22
|
+
const labelText = rest.labelText ?? rest.label ?? "";
|
|
23
|
+
const [internalError, setInternalError] = React.useState(null);
|
|
24
|
+
const hasError = Boolean(error ?? internalError);
|
|
25
|
+
const [hasInteracted, setHasInteracted] = React.useState(false);
|
|
26
|
+
// Segmentos digitados pela metade: o <input type="datetime-local"> entrega "" (validity.badInput). Em modo controlado o
|
|
27
|
+
// React devolveria o `value` antigo e o campo voltaria ao valor anterior; enquanto parcial, o DOM segue sem ser reescrito.
|
|
28
|
+
const [partial, setPartial] = React.useState(false);
|
|
29
|
+
React.useEffect(() => {
|
|
30
|
+
setPartial(false);
|
|
31
|
+
}, [local]);
|
|
32
|
+
const minLocal = minDate ? instantToWallClock(minDate, timeZone, showSeconds) : undefined;
|
|
33
|
+
const maxLocal = maxDate ? instantToWallClock(maxDate, timeZone, showSeconds) : undefined;
|
|
34
|
+
const effectiveStep = showSeconds ? 1 : minuteStep && minuteStep > 1 ? minuteStep * 60 : undefined;
|
|
35
|
+
const runValidation = React.useCallback((text) => {
|
|
36
|
+
const report = (message) => {
|
|
37
|
+
setInternalError(message);
|
|
38
|
+
onValidation?.(message);
|
|
39
|
+
};
|
|
40
|
+
if (!text && required)
|
|
41
|
+
return report(requiredMessage ?? t(i18n, "components.inputs.required"));
|
|
42
|
+
if (!text)
|
|
43
|
+
return report(null);
|
|
44
|
+
const custom = validation?.(text) ?? null;
|
|
45
|
+
if (custom)
|
|
46
|
+
return report(custom);
|
|
47
|
+
const code = validateDateTime(text, { required, min: minDate, max: maxDate, timeZone });
|
|
48
|
+
if (code === "invalid")
|
|
49
|
+
return report(t(i18n, "components.inputs.datetime.invalid"));
|
|
50
|
+
if (code === "min" || code === "max" || code === "range") {
|
|
51
|
+
const min = minLocal ? formatWallClock(minLocal, i18n.locale, showSeconds) : "";
|
|
52
|
+
const max = maxLocal ? formatWallClock(maxLocal, i18n.locale, showSeconds) : "";
|
|
53
|
+
return report(code === "range"
|
|
54
|
+
? t(i18n, "components.inputs.datetime.range", { min, max })
|
|
55
|
+
: code === "min"
|
|
56
|
+
? t(i18n, "components.inputs.datetime.min", { min })
|
|
57
|
+
: t(i18n, "components.inputs.datetime.max", { max }));
|
|
58
|
+
}
|
|
59
|
+
return report(null);
|
|
60
|
+
}, [i18n, maxDate, maxLocal, minDate, minLocal, onValidation, required, requiredMessage, showSeconds, timeZone, validation]);
|
|
61
|
+
const emit = (text) => {
|
|
62
|
+
onChange?.(text ? wallClockToInstant(text, timeZone) : null, text);
|
|
63
|
+
};
|
|
64
|
+
const mergedInputProps = {
|
|
65
|
+
...inputProps,
|
|
66
|
+
placeholder: " ",
|
|
67
|
+
min: minLocal,
|
|
68
|
+
max: maxLocal ?? WIDGET_MAX,
|
|
69
|
+
step: effectiveStep,
|
|
70
|
+
...(rhfManaged ? {} : { value: partial ? "" : local }),
|
|
71
|
+
readOnly: inputProps?.readOnly,
|
|
72
|
+
onChange: (event) => {
|
|
73
|
+
const text = event.currentTarget.value;
|
|
74
|
+
setPartial(text === "" && Boolean(event.currentTarget.validity?.badInput));
|
|
75
|
+
setHasInteracted(true);
|
|
76
|
+
if (!controlled)
|
|
77
|
+
setInnerLocal(text);
|
|
78
|
+
if (validateOnBlur === false || internalError)
|
|
79
|
+
runValidation(text);
|
|
80
|
+
emit(text);
|
|
81
|
+
inputProps?.onChange?.(event);
|
|
82
|
+
},
|
|
83
|
+
onBlur: (event) => {
|
|
84
|
+
let text = event.currentTarget.value;
|
|
85
|
+
const snapped = snapMinutes(text, showSeconds ? undefined : minuteStep);
|
|
86
|
+
if (snapped !== text) {
|
|
87
|
+
text = snapped;
|
|
88
|
+
if (!controlled)
|
|
89
|
+
setInnerLocal(text);
|
|
90
|
+
emit(text);
|
|
91
|
+
}
|
|
92
|
+
if ((validateOnBlur ?? true) || hasInteracted)
|
|
93
|
+
runValidation(text);
|
|
94
|
+
inputProps?.onBlur?.(event);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const inputClassName = (() => {
|
|
98
|
+
if (mergedInputProps.className)
|
|
99
|
+
return mergedInputProps.className;
|
|
100
|
+
const elevationClass = props.elevation === "none" ? "" : props.elevation === "md" ? "shadow-md" : props.elevation === "lg" ? "shadow-lg" : "shadow-sm";
|
|
101
|
+
const baseClass = "peer h-11 w-full rounded-md bg-[var(--sg-input-bg,hsl(var(--background)))] text-[var(--sg-input-fg,hsl(var(--foreground)))] caret-[var(--sg-input-fg,hsl(var(--foreground)))] pl-3 pr-7 py-2.5 text-sm placeholder-transparent focus:outline-none";
|
|
102
|
+
const borderClass = hasError
|
|
103
|
+
? "border border-[hsl(var(--destructive))] focus:border-[hsl(var(--destructive))] focus:ring-2 focus:ring-[hsl(var(--destructive)/0.25)]"
|
|
104
|
+
: "border border-border focus:border-[hsl(var(--primary))] focus:ring-2 focus:ring-[hsl(var(--primary)/0.25)]";
|
|
105
|
+
return [baseClass, borderClass, elevationClass].filter(Boolean).join(" ");
|
|
106
|
+
})();
|
|
107
|
+
const wrapperClassName = ["relative", isDark ? "sg-datetime-dark" : "sg-datetime-light"].join(" ");
|
|
108
|
+
return (_jsxs("div", { className: wrapperClassName, children: [_jsx("style", { children: `
|
|
109
|
+
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
|
|
110
|
+
cursor: pointer;
|
|
111
|
+
}
|
|
112
|
+
.sg-datetime-dark input[type="datetime-local"] {
|
|
113
|
+
color-scheme: dark;
|
|
114
|
+
}
|
|
115
|
+
.sg-datetime-light input[type="datetime-local"] {
|
|
116
|
+
color-scheme: light;
|
|
117
|
+
}
|
|
118
|
+
` }), labelText ? (_jsx("label", { htmlFor: rest.id, className: [
|
|
119
|
+
"pointer-events-none absolute left-3 top-0 z-10 -translate-y-1/2 bg-[var(--sg-input-bg,hsl(var(--background)))] px-1 text-[11px] font-medium leading-none",
|
|
120
|
+
hasError ? "text-[hsl(var(--destructive))]" : "text-foreground/70"
|
|
121
|
+
].join(" "), children: labelText })) : null, _jsx(SgInputText, { ...rest, type: "datetime-local", error: resolveFieldError(error, internalError ?? undefined), inputProps: mergedInputProps, className: inputClassName, labelClassName: "sr-only", onClear: () => {
|
|
122
|
+
setInternalError(null);
|
|
123
|
+
onValidation?.(null);
|
|
124
|
+
setPartial(false);
|
|
125
|
+
if (!controlled)
|
|
126
|
+
setInnerLocal("");
|
|
127
|
+
emit("");
|
|
128
|
+
rest.onClear?.();
|
|
129
|
+
} })] }));
|
|
130
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SgInputDateTime.meta.d.ts","sourceRoot":"","sources":["../../src/inputs/SgInputDateTime.meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE9D,eAAO,MAAM,MAAM,EAAE,QAqDpB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,WAmBrB,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export const sgMeta = {
|
|
2
|
+
version: "0.1",
|
|
3
|
+
componentId: "form.input.datetime",
|
|
4
|
+
package: "@seedgrid/fe-components",
|
|
5
|
+
exportName: "SgInputDateTime",
|
|
6
|
+
slug: "sg-input-date-time",
|
|
7
|
+
displayName: "SgInputDateTime",
|
|
8
|
+
category: "input",
|
|
9
|
+
subcategory: "datetime",
|
|
10
|
+
description: "Campo de data e hora que entrega e recebe instantes ISO 8601 em UTC, exibindo a hora no fuso escolhido, com limites, passo de minutos e validacao.",
|
|
11
|
+
tags: ["form", "date", "time", "datetime", "rhf"],
|
|
12
|
+
capabilities: ["rhf", "controlled", "min-max", "time-zone", "minute-step", "iso-utc"],
|
|
13
|
+
fieldSemantics: ["dateTime", "timestamp", "schedule", "appointment", "deadline"],
|
|
14
|
+
props: [
|
|
15
|
+
{ name: "id", type: "string", required: true, description: "Identificador unico do campo.", semanticRole: "data", bindable: false },
|
|
16
|
+
{ name: "name", type: "string", description: "Nome do campo para formularios.", semanticRole: "data", bindable: true },
|
|
17
|
+
{ name: "label", type: "string", description: "Rotulo principal exibido ao usuario.", semanticRole: "label", bindable: true },
|
|
18
|
+
{ name: "value", type: "string | Date | null", description: "Instante controlado (ISO 8601 ou Date).", semanticRole: "data", bindable: true },
|
|
19
|
+
{ name: "defaultValue", type: "string | Date | null", description: "Instante inicial (nao controlado).", semanticRole: "data", bindable: true },
|
|
20
|
+
{ name: "required", type: "boolean", default: false, description: "Marca o campo como obrigatorio.", semanticRole: "validation", bindable: true },
|
|
21
|
+
{ name: "minDate", type: "string | Date", description: "Menor instante permitido.", semanticRole: "validation", bindable: true },
|
|
22
|
+
{ name: "maxDate", type: "string | Date", description: "Maior instante permitido.", semanticRole: "validation", bindable: true },
|
|
23
|
+
{ name: "timeZone", type: "string", default: "local", description: "Fuso do campo: local, UTC, deslocamento (+03:00) ou nome IANA.", semanticRole: "data", bindable: true },
|
|
24
|
+
{ name: "showSeconds", type: "boolean", default: false, description: "Mostra e aceita segundos.", semanticRole: "appearance", bindable: true },
|
|
25
|
+
{ name: "minuteStep", type: "number", description: "Passo dos minutos (5, 10, 15, 30).", semanticRole: "validation", bindable: true },
|
|
26
|
+
{ name: "onChange", type: "(value: string | null, local: string) => void", description: "Instante ISO UTC (ou null) e texto local do campo.", semanticRole: "event", bindable: false }
|
|
27
|
+
],
|
|
28
|
+
states: ["default", "focused", "disabled", "readOnly", "error"],
|
|
29
|
+
examples: [
|
|
30
|
+
{
|
|
31
|
+
id: "basic",
|
|
32
|
+
title: "Basico",
|
|
33
|
+
file: "apps/showcase/src/app/components/sg-input-date-time/samples/basico.tsx.sample",
|
|
34
|
+
kind: "sample"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: "playground",
|
|
38
|
+
title: "Playground",
|
|
39
|
+
file: "apps/showcase/src/app/components/sg-input-date-time/sg-input-date-time.tsx.playground",
|
|
40
|
+
kind: "playground"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
showcase: {
|
|
44
|
+
route: "/components/sg-input-date-time",
|
|
45
|
+
hasPlayground: true,
|
|
46
|
+
hasPropsTable: true
|
|
47
|
+
},
|
|
48
|
+
sdui: {
|
|
49
|
+
rendererType: "field.datetime",
|
|
50
|
+
acceptsDataBinding: true,
|
|
51
|
+
defaultProps: { labelPosition: "float", clearButton: true }
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
export const aiHints = {
|
|
55
|
+
version: "0.1",
|
|
56
|
+
preferredUseCases: [
|
|
57
|
+
"Agendamentos, compromissos e prazos que exigem data e hora.",
|
|
58
|
+
"Campos de timestamp que precisam trafegar como instante UTC.",
|
|
59
|
+
"Formularios com limites de data e hora e fuso explicito."
|
|
60
|
+
],
|
|
61
|
+
avoidUseCases: [
|
|
62
|
+
"Somente data; prefira SgInputDate.",
|
|
63
|
+
"Somente hora do dia sem data; prefira um campo de hora.",
|
|
64
|
+
"Texto livre; prefira SgInputText."
|
|
65
|
+
],
|
|
66
|
+
synonyms: ["datetime input", "date time picker", "timestamp field", "appointment field"],
|
|
67
|
+
relatedEntityFields: ["createdAt", "scheduledAt", "startsAt", "endsAt", "dueAt", "timestamp"],
|
|
68
|
+
compositionHints: [
|
|
69
|
+
"Combinar dois campos (inicio/fim) com minDate/maxDate para intervalos.",
|
|
70
|
+
"Usar dentro de SgPanel em formularios de agenda."
|
|
71
|
+
],
|
|
72
|
+
rankingSignals: { freeText: 0, structuredChoice: 0.1, date: 0.95, number: 0, denseLayout: 0.7 }
|
|
73
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type CameraFacing = "user" | "environment";
|
|
2
|
+
export type CameraGuide = "none" | "oval" | "rect";
|
|
3
|
+
export type CameraResolution = "low" | "medium" | "high";
|
|
4
|
+
export type CameraErrorCode = "permission" | "noCamera" | "failed";
|
|
5
|
+
export type GuideBox = {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
/** Resolucao pedida ao dispositivo (largura x altura, paisagem). */
|
|
12
|
+
export declare function resolutionSize(resolution: CameraResolution): {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Caixa do guia de enquadramento, centralizada na area de pre-visualizacao `viewW` x `viewH` (px).
|
|
18
|
+
* `oval`: elipse em pe (largura/altura = 3/4), ate 70% da largura e 70% da altura.
|
|
19
|
+
* `rect`: retangulo deitado (largura/altura = 4/3), ate 90% da largura e 70% da altura.
|
|
20
|
+
* `none` => null. Valores arredondados ao pixel.
|
|
21
|
+
*/
|
|
22
|
+
export declare function guideBox(guide: CameraGuide, viewW: number, viewH: number): GuideBox | null;
|
|
23
|
+
/** Nome do erro da plataforma (`NotAllowedError`, `CameraAccessDenied`...) => codigo do componente. */
|
|
24
|
+
export declare function classifyCameraError(name: string): CameraErrorCode;
|
|
25
|
+
/** Alterna entre frontal (`user`) e traseira (`environment`). */
|
|
26
|
+
export declare function nextFacing(facing: CameraFacing): CameraFacing;
|
|
27
|
+
//# sourceMappingURL=cameraLogic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cameraLogic.d.ts","sourceRoot":"","sources":["../../src/inputs/cameraLogic.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,aAAa,CAAC;AAClD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AACnD,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AACzD,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEnE,MAAM,MAAM,QAAQ,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/E,oEAAoE;AACpE,wBAAgB,cAAc,CAAC,UAAU,EAAE,gBAAgB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAS9F;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAa1F;AAYD,uGAAuG;AACvG,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAKjE;AAED,iEAAiE;AACjE,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAE7D"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Logica pura do SgCameraCapture (P134): resolucao, guia de enquadramento, classificacao de erro e troca de camera.
|
|
2
|
+
// Sem DOM: os vetores de paridade com o Flutter (`seedgrid_components/test/widgets/camera_vectors`) sao gerados
|
|
3
|
+
// DESTE modulo. O contrato das props e o mesmo nas duas plataformas.
|
|
4
|
+
/** Resolucao pedida ao dispositivo (largura x altura, paisagem). */
|
|
5
|
+
export function resolutionSize(resolution) {
|
|
6
|
+
switch (resolution) {
|
|
7
|
+
case "low":
|
|
8
|
+
return { width: 640, height: 480 };
|
|
9
|
+
case "high":
|
|
10
|
+
return { width: 1920, height: 1080 };
|
|
11
|
+
default:
|
|
12
|
+
return { width: 1280, height: 720 };
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Caixa do guia de enquadramento, centralizada na area de pre-visualizacao `viewW` x `viewH` (px).
|
|
17
|
+
* `oval`: elipse em pe (largura/altura = 3/4), ate 70% da largura e 70% da altura.
|
|
18
|
+
* `rect`: retangulo deitado (largura/altura = 4/3), ate 90% da largura e 70% da altura.
|
|
19
|
+
* `none` => null. Valores arredondados ao pixel.
|
|
20
|
+
*/
|
|
21
|
+
export function guideBox(guide, viewW, viewH) {
|
|
22
|
+
if (guide === "none" || viewW <= 0 || viewH <= 0)
|
|
23
|
+
return null;
|
|
24
|
+
const ratio = guide === "oval" ? 3 / 4 : 4 / 3;
|
|
25
|
+
const maxW = viewW * (guide === "oval" ? 0.7 : 0.9);
|
|
26
|
+
const maxH = viewH * 0.7;
|
|
27
|
+
const width = Math.min(maxW, maxH * ratio);
|
|
28
|
+
const height = width / ratio;
|
|
29
|
+
return {
|
|
30
|
+
x: Math.round((viewW - width) / 2),
|
|
31
|
+
y: Math.round((viewH - height) / 2),
|
|
32
|
+
width: Math.round(width),
|
|
33
|
+
height: Math.round(height)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const PERMISSION_NAMES = new Set([
|
|
37
|
+
"notallowederror",
|
|
38
|
+
"permissiondeniederror",
|
|
39
|
+
"securityerror",
|
|
40
|
+
"cameraaccessdenied",
|
|
41
|
+
"cameraaccessdeniedwithoutprompt",
|
|
42
|
+
"cameraaccessrestricted"
|
|
43
|
+
]);
|
|
44
|
+
const NO_CAMERA_NAMES = new Set(["notfounderror", "devicesnotfounderror", "nocamera", "notreadableerror_nocamera"]);
|
|
45
|
+
/** Nome do erro da plataforma (`NotAllowedError`, `CameraAccessDenied`...) => codigo do componente. */
|
|
46
|
+
export function classifyCameraError(name) {
|
|
47
|
+
const key = name.trim().toLowerCase();
|
|
48
|
+
if (PERMISSION_NAMES.has(key))
|
|
49
|
+
return "permission";
|
|
50
|
+
if (NO_CAMERA_NAMES.has(key))
|
|
51
|
+
return "noCamera";
|
|
52
|
+
return "failed";
|
|
53
|
+
}
|
|
54
|
+
/** Alterna entre frontal (`user`) e traseira (`environment`). */
|
|
55
|
+
export function nextFacing(facing) {
|
|
56
|
+
return facing === "user" ? "environment" : "user";
|
|
57
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type DateTimeErrorCode = "required" | "invalid" | "min" | "max" | "range";
|
|
2
|
+
/** Deslocamento fixo em minutos ("+03:00" => 180) ou null se nao for um deslocamento. */
|
|
3
|
+
export declare function parseFixedOffset(timeZone: string): number | null;
|
|
4
|
+
/** Minutos a somar ao UTC para obter o relogio de parede de `instantMs` no fuso. */
|
|
5
|
+
export declare function zoneOffsetMinutes(instantMs: number, timeZone?: string): number;
|
|
6
|
+
/** Instante (ISO UTC ou Date) => "YYYY-MM-DDTHH:mm[:ss]" no fuso; "" se invalido/vazio. */
|
|
7
|
+
export declare function instantToWallClock(value: string | Date | undefined | null, timeZone?: string, showSeconds?: boolean): string;
|
|
8
|
+
/** "YYYY-MM-DDTHH:mm[:ss]" no fuso => ISO 8601 UTC ("...Z", ms = 000); null se invalido. */
|
|
9
|
+
export declare function wallClockToInstant(local: string, timeZone?: string): string | null;
|
|
10
|
+
/** Arredonda os minutos ao multiplo de `step` mais proximo (passo invalido ou <= 1 mantem o valor). */
|
|
11
|
+
export declare function snapMinutes(local: string, step?: number): string;
|
|
12
|
+
export type DateTimeValidationInput = {
|
|
13
|
+
required?: boolean;
|
|
14
|
+
min?: string | Date;
|
|
15
|
+
max?: string | Date;
|
|
16
|
+
timeZone?: string;
|
|
17
|
+
};
|
|
18
|
+
/** Codigo do erro (null = valido). `local` e o texto do campo ("" = vazio). min/max sao instantes. */
|
|
19
|
+
export declare function validateDateTime(local: string, input?: DateTimeValidationInput): DateTimeErrorCode | null;
|
|
20
|
+
/** Texto de exibicao de um relogio de parede: dd/mm/aaaa HH:mm (en-US: aaaa-mm-dd HH:mm). */
|
|
21
|
+
export declare function formatWallClock(local: string, locale: string, showSeconds?: boolean): string;
|
|
22
|
+
//# sourceMappingURL=dateTimeLogic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateTimeLogic.d.ts","sourceRoot":"","sources":["../../src/inputs/dateTimeLogic.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,CAAC;AASjF,yFAAyF;AACzF,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMhE;AAMD,oFAAoF;AACpF,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAuB9E;AAQD,2FAA2F;AAC3F,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,EACvC,QAAQ,CAAC,EAAE,MAAM,EACjB,WAAW,UAAQ,GAClB,MAAM,CAMR;AAED,4FAA4F;AAC5F,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAiBlF;AAED,uGAAuG;AACvG,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAkBhE;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,sGAAsG;AACtG,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,uBAA4B,GAAG,iBAAiB,GAAG,IAAI,CAY7G;AAED,6FAA6F;AAC7F,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,UAAQ,GAAG,MAAM,CAM1F"}
|