@orangesix/react 1.0.7 → 1.0.10

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.
Files changed (43) hide show
  1. package/api/index.cjs.js +1 -1
  2. package/api/index.cjs.js.map +1 -1
  3. package/api/index.d.ts +140 -2
  4. package/api/index.esm.js +1 -1
  5. package/api/index.esm.js.map +1 -1
  6. package/api/theme.css +1 -1
  7. package/box/_box.scss +1 -1
  8. package/box/index.cjs.js +1 -1
  9. package/box/index.cjs.js.map +1 -1
  10. package/box/index.d.ts +6 -3
  11. package/box/index.esm.js +1 -1
  12. package/box/index.esm.js.map +1 -1
  13. package/editor/_editor.scss +98 -35
  14. package/editor/index.cjs.js +1 -1
  15. package/editor/index.cjs.js.map +1 -1
  16. package/editor/index.d.ts +25 -11
  17. package/editor/index.esm.js +1 -1
  18. package/editor/index.esm.js.map +1 -1
  19. package/inputfilter/_inputfilter.scss +64 -0
  20. package/inputfilter/index.cjs.js +2 -0
  21. package/inputfilter/index.cjs.js.map +1 -0
  22. package/inputfilter/index.d.ts +161 -0
  23. package/inputfilter/index.esm.js +2 -0
  24. package/inputfilter/index.esm.js.map +1 -0
  25. package/inputfilter/package.json +5 -0
  26. package/package.json +13 -4
  27. package/table/index.cjs.js +1 -1
  28. package/table/index.cjs.js.map +1 -1
  29. package/table/index.d.ts +56 -52
  30. package/table/index.esm.js +1 -1
  31. package/table/index.esm.js.map +1 -1
  32. package/tablepivot/_tablepivot.scss +101 -0
  33. package/tablepivot/index.cjs.js +2 -0
  34. package/tablepivot/index.cjs.js.map +1 -0
  35. package/tablepivot/index.d.ts +256 -0
  36. package/tablepivot/index.esm.js +2 -0
  37. package/tablepivot/index.esm.js.map +1 -0
  38. package/tablepivot/package.json +5 -0
  39. package/utils/index.cjs.js +1 -1
  40. package/utils/index.cjs.js.map +1 -1
  41. package/utils/index.d.ts +25 -1
  42. package/utils/index.esm.js +1 -1
  43. package/utils/index.esm.js.map +1 -1
package/editor/index.d.ts CHANGED
@@ -5,6 +5,11 @@ import React, { CSSProperties } from 'react';
5
5
  */
6
6
  interface ApiComponentProps {
7
7
 
8
+ /**
9
+ * Propriedade para identificar o id do elemento
10
+ */
11
+ id?: string
12
+
8
13
  /**
9
14
  * Adiciona no atributo `class` do componente o valor atribuido nessa propriedade
10
15
  */
@@ -26,6 +31,11 @@ interface ApiComponentProps {
26
31
  */
27
32
  interface ApiFieldComponentProps {
28
33
 
34
+ /**
35
+ * Define o id do campo
36
+ */
37
+ id?: string
38
+
29
39
  /**
30
40
  * Define o nome do campo
31
41
  */
@@ -65,28 +75,32 @@ interface ApiFieldComponentProps {
65
75
  interface EditorProps extends ApiComponentProps, ApiFieldComponentProps {
66
76
 
67
77
  /**
68
- * Define o valor de entrada do campo
78
+ * Valor inicial do editor de texto
69
79
  */
70
- value: any
80
+ value: string;
71
81
 
72
82
  /**
73
- * Atualiza state com valor digitado no campo
83
+ * Define quais opção será renderizada no editor de texto
74
84
  */
75
- onChange(value: any): void
85
+ options?: EditorOptions | "basic" | "full"
76
86
 
77
87
  /**
78
- * Define o tipo de editor de texto que será renderizado
88
+ * Define a altura minima do editor
79
89
  */
80
- module?: "basic" | "complete"
90
+ height?: number
91
+
92
+ /**
93
+ * Método responsável por alterar o valor do state inicial
94
+ */
95
+ onChange(value: string): void
81
96
  }
82
97
 
83
98
  /**
84
99
  * Componente - `Editor`
85
100
  *
86
- * Um componente versátil que pode ser utilizado para criar um palco de edição de texto.
101
+ * Um componente versátil que pode ser utilizado para criar container de edição de texto.
102
+ * Permite personalizar o estilo e o conteúdo através de propriedades.
87
103
  */
88
- declare const Editor: ({ iconPrefix, module, ...props }: EditorProps) => React.JSX.Element;
89
-
90
- type IEditorProps = EditorProps;
104
+ declare const Editor: ({ options, iconPrefix, ...props }: EditorProps) => React.JSX.Element | null;
91
105
 
92
- export { Editor, type IEditorProps };
106
+ export { Editor };
@@ -1,2 +1,2 @@
1
- import e from"react";import{classNames as a}from"primereact/utils";import{Editor as t}from"primereact/editor";const i=({children:t,...i})=>{const l={size:`box-size-${i.size??"100"}`,direction:`box-direction-${i.direction??"row"}`,justify:void 0===i.justify?"":Array.isArray(i.justify)?i.justify?.join(" "):i.justify,align:void 0===i.align?"":Array.isArray(i.align)?i.align?.join(" "):i.align},r={className:a(["box",i.className??"",l.size,l.direction,l.justify,l.align]),style:i.css};return e.createElement("div",{...r},t)},l=({iconPrefix:a="bi bi-",module:l="complete",...r})=>e.createElement(i,{className:"p-0",size:r.size??"100"},r.label&&e.createElement("label",{className:"form-label"},r.icon&&e.createElement("i",{className:a+r.icon+" me-1"}),r.label,r.required&&e.createElement("span",{className:"text-danger"},"*")),e.createElement(t,{className:"w-100 "+(r.className??""),headerTemplate:"basic"===l?e.createElement("span",{className:"ql-formats"},e.createElement("button",{className:"ql-bold"}),e.createElement("button",{className:"ql-italic"}),e.createElement("button",{className:"ql-underline"})):void 0,name:r.name,placeholder:r.placeholder??"Digite o texto...",readOnly:r.disabled??!1,required:r.required,style:r.css,value:r.value,onTextChange:e=>r.onChange(e.htmlValue)}));export{l as Editor};
1
+ import e,{useState as t,useEffect as i}from"react";import{classNames as a}from"primereact/utils";import r from"@tiptap/extension-link";import l from"@tiptap/extension-image";import n from"@tiptap/starter-kit";import{Color as c}from"@tiptap/extension-color";import o from"@tiptap/extension-underline";import s from"@tiptap/extension-highlight";import m from"@tiptap/extension-text-style";import{useEditor as d,EditorContent as u}from"@tiptap/react";const v=({children:t,...i})=>{const r={size:`box-size-${i.size??"100"}`,direction:`box-direction-${i.direction??"row"}`,justify:void 0===i.justify?"":Array.isArray(i.justify)?i.justify?.join(" "):i.justify,align:void 0===i.align?"":Array.isArray(i.align)?i.align?.join(" "):i.align},l={className:a(["box",i.className??"",r.size,r.direction,r.justify,r.align]),style:i.css,id:i.id};return e.createElement("div",{...l},t)},g=({editor:t,active:i})=>i&&e.createElement(e.Fragment,null,e.createElement("a",{className:"editor-menu-item"+(t.isActive("heading",{level:1})?" active":""),href:"#",style:{fontSize:".975em"},onClick:e=>{e.preventDefault(),t.chain().focus().toggleHeading({level:1}).run()}},e.createElement("i",{className:"bi bi-type-h1"})),e.createElement("a",{className:"editor-menu-item"+(t.isActive("heading",{level:2})?" active":""),href:"#",style:{fontSize:".975em"},onClick:e=>{e.preventDefault(),t.chain().focus().toggleHeading({level:2}).run()}},e.createElement("i",{className:"bi bi-type-h2"})),e.createElement("a",{className:"editor-menu-item"+(t.isActive("heading",{level:3})?" active":""),href:"#",style:{fontSize:".975em"},onClick:e=>{e.preventDefault(),t.chain().focus().toggleHeading({level:3}).run()}},e.createElement("i",{className:"bi bi-type-h3"}))),f=({editor:a,active:r})=>{const[l,n]=t(!1),[c,o]=t("");return i((()=>{o("")}),[l]),r&&e.createElement(e.Fragment,null,e.createElement("a",{className:"editor-menu-item"+(a.isActive("link")?" active":""),href:"#",onClick:e=>{e.preventDefault(),a.isActive("link")?a.chain().focus().unsetLink().run():n(!l)}},e.createElement("i",{className:"bi bi-link"})),l&&e.createElement("div",{className:"editor-link"},e.createElement("input",{className:"form-control form-control-sm",placeholder:"https://example.com.br",style:{fontSize:".8em",flex:1},type:"text",value:c,onChange:e=>o(e.target.value)}),e.createElement("a",{className:"text-primary ms-2",href:"#",style:{fontSize:".8em"},onClick:e=>{e.preventDefault(),""===c?a.chain().focus().extendMarkRange("link").unsetLink().run():a.chain().focus().extendMarkRange("link").setLink({href:c}).run(),n(!1)}},e.createElement("i",{className:"bi bi-save me-1"}),"Save")))},p=({editor:t,active:i})=>i&&e.createElement("a",{className:"editor-menu-item"+(t.isActive("bold")?" active":""),href:"#",onClick:e=>{e.preventDefault(),t.chain().focus().toggleBold().run()}},e.createElement("i",{className:"bi bi-type-bold"})),h=({editor:t,active:i})=>i&&e.createElement("a",{className:"editor-menu-item"+(t.isActive("code")?" active":""),href:"#",style:{fontSize:".975em"},onClick:e=>{e.preventDefault(),t.chain().focus().toggleCode().run()}},e.createElement("i",{className:"bi bi-code-slash"})),b=({editor:t,active:i})=>i&&e.createElement("input",{style:{width:"22px",height:"20px",borderRadius:"5px",margin:"auto 2.5px",border:"2px solid var(--editor-border-color)"},type:"color",value:t.getAttributes("textStyle").color??"#000000",onChange:e=>t.chain().focus().setColor(e.target.value).run()}),E=({editor:a,active:r})=>{const[l,n]=t(null),c=e=>{const t=(e.clipboardData||e.originalEvent.clipboardData).items;for(const e of t)if(0===e.type.indexOf("image")){const t=e.getAsFile(),i=new FileReader;i.onload=e=>{a.chain().focus().setImage({src:e?.target?.result}).run()},i.readAsDataURL(t)}};return i((()=>(null!==a.view.dom.parentNode&&r&&a.view.dom.parentNode.addEventListener("paste",c),()=>{a.view.dom.parentNode?.removeEventListener("paste",c)})),[]),i((()=>{if(void 0!==l?.name){const e=new FileReader;e.readAsDataURL(l),e.onload=()=>{a.chain().focus().setImage({src:e.result}).run()}}}),[l]),r&&e.createElement("div",{className:"editor-image"},e.createElement("input",{accept:"image/png, image/jpeg",name:"editor-image",type:"file",onChange:e=>n(e.target.files?.[0])}),e.createElement("a",{className:"editor-menu-item"+(a.isActive("link")?" active":""),href:"#",style:{fontSize:".975em"},onClick:e=>{e.preventDefault()}},e.createElement("i",{className:"bi bi-image"})))},N=({editor:t,active:i})=>i&&e.createElement("a",{className:"editor-menu-item"+(t.isActive("italic")?" active":""),href:"#",onClick:e=>{e.preventDefault(),t.chain().focus().toggleItalic().run()}},e.createElement("i",{className:"bi bi-type-italic"})),k=({editor:t,active:i})=>i&&e.createElement("a",{className:"editor-menu-item"+(t.isActive("strike")?" active":""),href:"#",onClick:e=>{e.preventDefault(),t.chain().focus().toggleStrike().run()}},e.createElement("i",{className:"bi bi-type-strikethrough"})),y=({editor:t,active:i})=>i&&e.createElement("a",{className:"editor-menu-item"+(t.isActive("orderedList")?" active":""),href:"#",onClick:e=>{e.preventDefault(),t.chain().focus().toggleOrderedList().run()}},e.createElement("i",{className:"bi bi-list-ol"})),x=({editor:t,active:i})=>i&&e.createElement("a",{className:"editor-menu-item"+(t.isActive("underline")?" active":""),href:"#",onClick:e=>{e.preventDefault(),t.chain().focus().toggleUnderline().run()}},e.createElement("i",{className:"bi bi-type-underline"})),A=({editor:t,active:i})=>i&&e.createElement("a",{className:"editor-menu-item"+(t.isActive("highlight")?" active":""),href:"#",style:{fontSize:".975em"},onClick:e=>{e.preventDefault(),t.chain().focus().toggleHighlight().run()}},e.createElement("i",{className:"bi bi-highlighter"})),C=({editor:t,active:i})=>i&&e.createElement("a",{className:"editor-menu-item"+(t.isActive("bulletList")?" active":""),href:"#",onClick:e=>{e.preventDefault(),t.chain().focus().toggleBulletList().run()}},e.createElement("i",{className:"bi bi-list-task"})),D=({editor:t,options:i})=>e.createElement("div",{className:"editor-menu"},e.createElement("div",{className:"editor-menu-group"},e.createElement(g,{active:i.text,editor:t}),e.createElement(p,{active:i.bold,editor:t}),e.createElement(N,{active:i.italic,editor:t}),e.createElement(b,{active:i.color,editor:t}),e.createElement(k,{active:i.strike,editor:t}),e.createElement(x,{active:i.underline,editor:t}),e.createElement(h,{active:i.code,editor:t}),e.createElement(A,{active:i.highlight,editor:t})),e.createElement("div",{className:"editor-menu-group"},e.createElement(C,{active:i.bulletlist,editor:t}),e.createElement(y,{active:i.orderlist,editor:t}),e.createElement(f,{active:i.link,editor:t}),e.createElement(E,{active:i.image,editor:t}))),z=({iconPrefix:t="bi bi-",...i})=>i.label&&e.createElement("p",{className:"form-label"},i.icon&&e.createElement("i",{className:t+i.icon+" me-1"}),i.label,i.required&&e.createElement("span",{className:"text-danger"},"*")),L={text:!0,bold:!0,italic:!0,color:!0,strike:!1,underline:!1,code:!1,highlight:!1,bulletlist:!1,orderlist:!1,link:!1,image:!1},S={text:!0,bold:!0,italic:!0,color:!0,strike:!0,underline:!0,code:!0,highlight:!0,bulletlist:!0,orderlist:!0,link:!0,image:!0},j=({options:a="basic",iconPrefix:g="bi bi-",...f})=>{const[p,h]=t(!1),b=d({extensions:[n,o,s,c,m,r.configure({validate:e=>/^https?:\/\//.test(e),HTMLAttributes:{rel:""}}),l.configure({allowBase64:!0})],editable:!f.disabled,content:f.value??"",onFocus:()=>h(!0),onBlur:()=>h(!1),onUpdate:({editor:e})=>{f.onChange(e.getHTML())}});return b?(i((()=>{b&&!p&&b?.commands.setContent(f.value)}),[f.value]),e.createElement(v,{className:f.className,css:f.css,size:f.size??"100"},e.createElement(z,{...f}),e.createElement("div",{className:"editor-container"},!f.disabled&&e.createElement(D,{editor:b,options:"basic"===a?L:"full"===a?S:a}),e.createElement(u,{className:"editor",disabled:f.disabled,editor:b,id:f.id,name:f.name,style:{minHeight:(f.height??100)+"px"}})),e.createElement("div",{"data-name":f.name,id:"j_feedback"}))):(console.error("Não foi possível realizar o carregamento do editor de texto."),null)};export{j as Editor};
2
2
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../../src/box/box.tsx","../../src/editor/editor.tsx"],"sourcesContent":["import { BoxProps } from \"./types\";\r\nimport React, { HTMLAttributes } from \"react\";\r\nimport { classNames } from \"primereact/utils\";\r\n\r\n/**\r\n * Componente - `Box`\r\n *\r\n * Um componente versátil que pode ser utilizado para criar seções ou caixas em uma página.\r\n * Permite personalizar o estilo e o conteúdo através de propriedades.\r\n *\r\n * Exemplo de uso:\r\n * ```tsx\r\n * <Box align=\"align-items-center\"\r\n * justify=\"justify-content-end\"\r\n * size=\"25\">\r\n * ...conteúdo HTML\r\n * </Box>\r\n * ```\r\n */\r\nexport const Box = ({ children, ...props }: BoxProps) => {\r\n const css = {\r\n size: `box-size-${(props.size ?? \"100\")}`,\r\n direction: `box-direction-${props.direction ?? \"row\"}`,\r\n justify: props.justify === undefined ? \"\" : Array.isArray(props.justify) ? props.justify?.join(\" \") : props.justify,\r\n align: props.align === undefined ? \"\" : Array.isArray(props.align) ? props.align?.join(\" \") : props.align\r\n };\r\n\r\n const attr: HTMLAttributes<\"div\"> & Omit<BoxProps, \"children\"> = {\r\n className: classNames([\r\n \"box\",\r\n props.className ?? \"\",\r\n css.size,\r\n css.direction,\r\n css.justify,\r\n css.align\r\n ]),\r\n style: props.css\r\n };\r\n\r\n return (\r\n <div {...attr as any}>{children}</div>\r\n );\r\n};","import React from \"react\";\r\nimport { Box } from \"../box\";\r\nimport { EditorProps } from \"./types\";\r\nimport { Editor as PrimeEditor } from \"primereact/editor\";\r\n\r\n/**\r\n * Componente - `Editor`\r\n *\r\n * Um componente versátil que pode ser utilizado para criar um palco de edição de texto.\r\n */\r\nexport const Editor = ({ iconPrefix = \"bi bi-\", module = \"complete\", ...props }: EditorProps) => {\r\n\r\n //Realiza a configuração do módulo básico do editor\r\n const moduleBasic = () => {\r\n return (\r\n <span className=\"ql-formats\">\r\n <button className=\"ql-bold\"></button>\r\n <button className=\"ql-italic\"></button>\r\n <button className=\"ql-underline\"></button>\r\n </span>\r\n );\r\n };\r\n\r\n /*\r\n |------------------------------------------\r\n | render() - Renderização do componente\r\n |------------------------------------------\r\n */\r\n return (\r\n <Box className=\"p-0\"\r\n size={props.size ?? \"100\"}>\r\n {props.label\r\n && <label className=\"form-label\">\r\n {props.icon && <i className={(iconPrefix + props.icon) + \" me-1\"}/>}\r\n {props.label}\r\n {props.required && <span className=\"text-danger\">*</span>}\r\n </label>}\r\n <PrimeEditor className={\"w-100 \" + (props.className ?? \"\")}\r\n headerTemplate={module === \"basic\" ? moduleBasic() : undefined}\r\n name={props.name}\r\n placeholder={props.placeholder ?? \"Digite o texto...\"}\r\n readOnly={props.disabled ?? false}\r\n required={props.required}\r\n style={props.css}\r\n value={props.value}\r\n onTextChange={(e: any) => props.onChange(e.htmlValue)}/>\r\n </Box>\r\n );\r\n};"],"names":["Box","children","props","css","size","direction","justify","undefined","Array","isArray","join","align","attr","className","classNames","style","React","createElement","Editor","iconPrefix","module","label","icon","required","PrimeEditor","headerTemplate","name","placeholder","readOnly","disabled","value","onTextChange","e","onChange","htmlValue"],"mappings":"8GAmBO,MAAMA,EAAM,EAAGC,cAAaC,MAC/B,MAAMC,EAAM,CACRC,KAAM,YAAaF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M+B,SAASD,EAAEE"}
1
+ {"version":3,"file":"index.esm.js","sources":["../../src/box/box.tsx","../../src/editor/core/text.tsx","../../src/editor/core/link.tsx","../../src/editor/core/bold.tsx","../../src/editor/core/code.tsx","../../src/editor/core/color.tsx","../../src/editor/core/image.tsx","../../src/editor/core/italic.tsx","../../src/editor/core/strike.tsx","../../src/editor/core/orderlist.tsx","../../src/editor/core/underline.tsx","../../src/editor/core/highlight.tsx","../../src/editor/core/bulletlist.tsx","../../src/editor/core/index.tsx","../../src/api/input.tsx","../../src/editor/const.ts","../../src/editor/editor.tsx"],"sourcesContent":["import { BoxProps } from \"./types\";\r\nimport React, { HTMLAttributes } from \"react\";\r\nimport { classNames } from \"primereact/utils\";\r\n\r\n/**\r\n * Componente - `Box`\r\n *\r\n * Um componente versátil que pode ser utilizado para criar seções ou caixas em uma página.\r\n * Permite personalizar o estilo e o conteúdo através de propriedades.\r\n *\r\n * Exemplo de uso:\r\n * ```tsx\r\n * <Box align=\"align-items-center\"\r\n * justify=\"justify-content-end\"\r\n * size=\"25\">\r\n * ...conteúdo HTML\r\n * </Box>\r\n * ```\r\n */\r\nexport const Box = ({ children, ...props }: BoxProps) => {\r\n const css = {\r\n size: `box-size-${(props.size ?? \"100\")}`,\r\n direction: `box-direction-${props.direction ?? \"row\"}`,\r\n justify: props.justify === undefined ? \"\" : Array.isArray(props.justify) ? props.justify?.join(\" \") : props.justify,\r\n align: props.align === undefined ? \"\" : Array.isArray(props.align) ? props.align?.join(\" \") : props.align\r\n };\r\n\r\n const attr: HTMLAttributes<\"div\"> & Omit<BoxProps, \"children\"> = {\r\n className: classNames([\r\n \"box\",\r\n props.className ?? \"\",\r\n css.size,\r\n css.direction,\r\n css.justify,\r\n css.align\r\n ]),\r\n style: props.css,\r\n id: props.id\r\n };\r\n\r\n return (\r\n <div {...attr as any}>{children}</div>\r\n );\r\n};","import React from \"react\";\r\nimport { EditorCoreProps } from \"../types\";\r\n\r\n/**\r\n * Core - `Text`\r\n * Extensão para formatar o texto com tamanho específico\r\n */\r\nexport const Text = ({ editor, active }: EditorCoreProps & { active: boolean }) => {\r\n\r\n return active && (\r\n <>\r\n <a className={\"editor-menu-item\" + (editor.isActive(\"heading\", { level: 1 }) ? \" active\" : \"\")}\r\n href=\"#\"\r\n style={{ fontSize: \".975em\" }}\r\n onClick={event => {\r\n event.preventDefault();\r\n editor.chain().focus().toggleHeading({ level: 1 }).run();\r\n }}><i className=\"bi bi-type-h1\"/></a>\r\n <a className={\"editor-menu-item\" + (editor.isActive(\"heading\", { level: 2 }) ? \" active\" : \"\")}\r\n href=\"#\"\r\n style={{ fontSize: \".975em\" }}\r\n onClick={event => {\r\n event.preventDefault();\r\n editor.chain().focus().toggleHeading({ level: 2 }).run();\r\n }}><i className=\"bi bi-type-h2\"/></a>\r\n <a className={\"editor-menu-item\" + (editor.isActive(\"heading\", { level: 3 }) ? \" active\" : \"\")}\r\n href=\"#\"\r\n style={{ fontSize: \".975em\" }}\r\n onClick={event => {\r\n event.preventDefault();\r\n editor.chain().focus().toggleHeading({ level: 3 }).run();\r\n }}><i className=\"bi bi-type-h3\"/></a>\r\n </>\r\n );\r\n};","import { EditorCoreProps } from \"../types\";\r\nimport React, { useEffect, useState } from \"react\";\r\n\r\n/**\r\n * Core - `Link`\r\n * Extensão para formatar adicionar link no documento\r\n */\r\nexport const Link = ({ editor, active }: EditorCoreProps & { active: boolean }) => {\r\n const [open, setOpen] = useState<boolean>(false);\r\n const [link, setLink] = useState<string>(\"\");\r\n\r\n useEffect(() => {\r\n setLink(\"\");\r\n }, [open]);\r\n\r\n function handleLink() {\r\n if (link === \"\") {\r\n editor.chain().focus().extendMarkRange(\"link\").unsetLink().run();\r\n } else {\r\n editor.chain().focus().extendMarkRange(\"link\").setLink({ href: link }).run();\r\n }\r\n setOpen(false);\r\n }\r\n\r\n return active && (\r\n <>\r\n <a className={\"editor-menu-item\" + (editor.isActive(\"link\") ? \" active\" : \"\")}\r\n href=\"#\"\r\n onClick={event => {\r\n event.preventDefault();\r\n if (!editor.isActive(\"link\")) {\r\n setOpen(!open);\r\n } else {\r\n editor.chain().focus().unsetLink().run();\r\n }\r\n }}><i className=\"bi bi-link\"/></a>\r\n {open && <div className=\"editor-link\">\r\n <input className=\"form-control form-control-sm\"\r\n placeholder=\"https://example.com.br\"\r\n style={{ fontSize: \".8em\", flex: 1 }}\r\n type=\"text\"\r\n value={link}\r\n onChange={event => setLink(event.target.value)}/>\r\n <a className=\"text-primary ms-2\"\r\n href=\"#\"\r\n style={{ fontSize: \".8em\" }}\r\n onClick={event => {\r\n event.preventDefault();\r\n handleLink();\r\n }}><i className=\"bi bi-save me-1\"/>Save</a>\r\n </div>}\r\n </>\r\n );\r\n};","import React from \"react\";\r\nimport { EditorCoreProps } from \"../types\";\r\n\r\n/**\r\n * Core - `Bold`\r\n * Extensão para renderizar texto em negrito\r\n */\r\nexport const Bold = ({ editor, active }: EditorCoreProps & { active: boolean }) => {\r\n return active && (\r\n <a className={\"editor-menu-item\" + (editor.isActive(\"bold\") ? \" active\" : \"\")}\r\n href=\"#\"\r\n onClick={event => {\r\n event.preventDefault();\r\n editor.chain().focus().toggleBold().run();\r\n }}><i className=\"bi bi-type-bold\"/></a>\r\n );\r\n};","import React from \"react\";\r\nimport { EditorCoreProps } from \"../types\";\r\n\r\n/**\r\n * Core - `Code`\r\n * Extensão para renderizar texto em formato de código\r\n */\r\nexport const Code = ({ editor, active }: EditorCoreProps & { active: boolean }) => {\r\n return active && (\r\n <a className={\"editor-menu-item\" + (editor.isActive(\"code\") ? \" active\" : \"\")}\r\n href=\"#\"\r\n style={{ fontSize: \".975em\" }}\r\n onClick={event => {\r\n event.preventDefault();\r\n editor.chain().focus().toggleCode().run();\r\n }}><i className=\"bi bi-code-slash\"/></a>\r\n );\r\n};","import React from \"react\";\r\nimport { EditorCoreProps } from \"../types\";\r\n\r\n/**\r\n * Core - `Color`\r\n * Extensão para formatar o texto com cor especifica\r\n */\r\nexport const Color = ({ editor, active }: EditorCoreProps & { active: boolean }) => {\r\n return active && (\r\n <input\r\n style={{\r\n width: \"22px\",\r\n height: \"20px\",\r\n borderRadius: \"5px\",\r\n margin: \"auto 2.5px\",\r\n border: \"2px solid var(--editor-border-color)\",\r\n }}\r\n type=\"color\"\r\n value={editor.getAttributes(\"textStyle\").color ?? \"#000000\"}\r\n onChange={event => editor.chain().focus().setColor(event.target.value).run()}/>\r\n );\r\n};","import { EditorCoreProps } from \"../types\";\r\nimport React, { useEffect, useState } from \"react\";\r\n\r\n/**\r\n * Core - `Image`\r\n * Extensão para adicionar imagem no documento\r\n */\r\nexport const Image = ({ editor, active }: EditorCoreProps & { active: boolean }) => {\r\n const [file, setFile] = useState<any>(null);\r\n\r\n const handlePaste = (event: any) => {\r\n const items = (event.clipboardData || event.originalEvent.clipboardData).items;\r\n for (const item of items) {\r\n if (item.type.indexOf(\"image\") === 0) {\r\n const file = item.getAsFile();\r\n const reader = new FileReader();\r\n reader.onload = (event) => {\r\n editor.chain().focus().setImage({ src: event?.target?.result as string }).run();\r\n };\r\n reader.readAsDataURL(file);\r\n }\r\n }\r\n };\r\n\r\n useEffect(() => {\r\n if (editor.view.dom.parentNode !== null && active) {\r\n editor.view.dom.parentNode.addEventListener(\"paste\", handlePaste);\r\n }\r\n return () => {\r\n editor.view.dom.parentNode?.removeEventListener(\"paste\", handlePaste);\r\n };\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (file?.name !== undefined) {\r\n const reader = new FileReader();\r\n reader.readAsDataURL(file);\r\n reader.onload = () => {\r\n editor.chain().focus().setImage({ src: reader.result as string }).run();\r\n };\r\n }\r\n }, [file]);\r\n\r\n return active && (\r\n <div className=\"editor-image\">\r\n <input accept=\"image/png, image/jpeg\"\r\n name=\"editor-image\"\r\n type=\"file\"\r\n onChange={event => setFile(event.target.files?.[0])}/>\r\n <a className={\"editor-menu-item\" + (editor.isActive(\"link\") ? \" active\" : \"\")}\r\n href=\"#\"\r\n style={{ fontSize: \".975em\" }}\r\n onClick={event => {\r\n event.preventDefault();\r\n }}><i className=\"bi bi-image\"/></a>\r\n </div>\r\n );\r\n};","import React from \"react\";\r\nimport { EditorCoreProps } from \"../types\";\r\n\r\n/**\r\n * Core - `Italic`\r\n * Extensão para renderizar texto em itálico\r\n */\r\nexport const Italic = ({ editor, active }: EditorCoreProps & { active: boolean }) => {\r\n return active && (\r\n <a className={\"editor-menu-item\" + (editor.isActive(\"italic\") ? \" active\" : \"\")}\r\n href=\"#\"\r\n onClick={event => {\r\n event.preventDefault();\r\n editor.chain().focus().toggleItalic().run();\r\n }}><i className=\"bi bi-type-italic\"/></a>\r\n );\r\n};","import React from \"react\";\r\nimport { EditorCoreProps } from \"../types\";\r\n\r\n/**\r\n * Core - `Strike`\r\n * Extensão para renderizar texto em strike text\r\n */\r\nexport const Strike = ({ editor, active }: EditorCoreProps & { active: boolean }) => {\r\n return active && (\r\n <a className={\"editor-menu-item\" + (editor.isActive(\"strike\") ? \" active\" : \"\")}\r\n href=\"#\"\r\n onClick={event => {\r\n event.preventDefault();\r\n editor.chain().focus().toggleStrike().run();\r\n }}><i className=\"bi bi-type-strikethrough\"/></a>\r\n );\r\n};","import React from \"react\";\r\nimport { EditorCoreProps } from \"../types\";\r\n\r\n/**\r\n * Core - `Orderlist`\r\n * Extensão para renderizar texto em lista ordenada\r\n */\r\nexport const Orderlist = ({ editor, active }: EditorCoreProps & { active: boolean }) => {\r\n return active && (\r\n <a className={\"editor-menu-item\" + (editor.isActive(\"orderedList\") ? \" active\" : \"\")}\r\n href=\"#\"\r\n onClick={event => {\r\n event.preventDefault();\r\n editor.chain().focus().toggleOrderedList().run();\r\n }}><i className=\"bi bi-list-ol\"/></a>\r\n );\r\n};","import React from \"react\";\r\nimport { EditorCoreProps } from \"../types\";\r\n\r\n/**\r\n * Core - `Underline`\r\n * Extensão para renderizar texto em underline text\r\n */\r\nexport const Underline = ({ editor, active }: EditorCoreProps & { active: boolean }) => {\r\n return active && (\r\n <a className={\"editor-menu-item\" + (editor.isActive(\"underline\") ? \" active\" : \"\")}\r\n href=\"#\"\r\n onClick={event => {\r\n event.preventDefault();\r\n editor.chain().focus().toggleUnderline().run();\r\n }}><i className=\"bi bi-type-underline\"/></a>\r\n );\r\n};","import React from \"react\";\r\nimport { EditorCoreProps } from \"../types\";\r\n\r\n/**\r\n * Core - `Highlight`\r\n * Extensão para marcar texto no formato de marca texto\r\n */\r\nexport const Highlight = ({ editor, active }: EditorCoreProps & { active: boolean }) => {\r\n return active && (\r\n <a className={\"editor-menu-item\" + (editor.isActive(\"highlight\") ? \" active\" : \"\")}\r\n href=\"#\"\r\n style={{ fontSize: \".975em\" }}\r\n onClick={event => {\r\n event.preventDefault();\r\n editor.chain().focus().toggleHighlight().run();\r\n }}><i className=\"bi bi-highlighter\"/></a>\r\n );\r\n};","import React from \"react\";\r\nimport { EditorCoreProps } from \"../types\";\r\n\r\n/**\r\n * Core - `Bulletlist`\r\n * Extensão para renderizar texto em lista\r\n */\r\nexport const Bulletlist = ({ editor, active }: EditorCoreProps & { active: boolean }) => {\r\n return active && (\r\n <a className={\"editor-menu-item\" + (editor.isActive(\"bulletList\") ? \" active\" : \"\")}\r\n href=\"#\"\r\n onClick={event => {\r\n event.preventDefault();\r\n editor.chain().focus().toggleBulletList().run();\r\n }}><i className=\"bi bi-list-task\"/></a>\r\n );\r\n};","import React from \"react\";\r\nimport { Text } from \"./text\";\r\nimport { Link } from \"./link\";\r\nimport { Bold } from \"./bold\";\r\nimport { Code } from \"./code\";\r\nimport { Color } from \"./color\";\r\nimport { Image } from \"./image\";\r\nimport { Italic } from \"./italic\";\r\nimport { Strike } from \"./strike\";\r\nimport { Orderlist } from \"./orderlist\";\r\nimport { Underline } from \"./underline\";\r\nimport { Highlight } from \"./highlight\";\r\nimport { Bulletlist } from \"./bulletlist\";\r\nimport { EditorCoreProps, EditorOptionsProps } from \"../types\";\r\n\r\n/**\r\n * Core - `Menu`\r\n * Componente que renderiza todas as opções de menu do componente\r\n */\r\nexport const EditorMenu = ({ editor, options }: EditorCoreProps & { options: EditorOptionsProps }) => {\r\n /*\r\n |------------------------------------------\r\n | render() - Renderização do componente\r\n |------------------------------------------\r\n */\r\n return (\r\n <div className=\"editor-menu\">\r\n <div className=\"editor-menu-group\">\r\n <Text active={options.text}\r\n editor={editor}/>\r\n <Bold active={options.bold}\r\n editor={editor}/>\r\n <Italic active={options.italic}\r\n editor={editor}/>\r\n <Color active={options.color}\r\n editor={editor}/>\r\n <Strike active={options.strike}\r\n editor={editor}/>\r\n <Underline active={options.underline}\r\n editor={editor}/>\r\n <Code active={options.code}\r\n editor={editor}/>\r\n <Highlight active={options.highlight}\r\n editor={editor}/>\r\n </div>\r\n <div className=\"editor-menu-group\">\r\n <Bulletlist active={options.bulletlist}\r\n editor={editor}/>\r\n <Orderlist active={options.orderlist}\r\n editor={editor}/>\r\n <Link active={options.link}\r\n editor={editor}/>\r\n <Image active={options.image}\r\n editor={editor}/>\r\n </div>\r\n </div>\r\n );\r\n};","import React from \"react\";\r\nimport { ApiFieldComponentProps } from \"./types\";\r\n\r\n/**\r\n * API - `InputLabel`\r\n *\r\n * Um componente utilizado como label em todos os componente de campo do pacote.\r\n * Permite personalizar o estilo e o conteúdo através de propriedades.\r\n */\r\nexport const InputLabel = ({ iconPrefix = \"bi bi-\", ...props }: ApiFieldComponentProps) => {\r\n /*\r\n |------------------------------------------\r\n | render() - Renderização do componente\r\n |------------------------------------------\r\n */\r\n return props.label\r\n && <p className='form-label'>\r\n {props.icon && <i className={iconPrefix + props.icon + \" me-1\"}/>}\r\n {props.label}\r\n {props.required && <span className=\"text-danger\">*</span>}\r\n </p>;\r\n};","import { EditorOptionsProps } from \"./types\";\r\n\r\nexport const editorBasic: EditorOptionsProps = {\r\n text: true,\r\n bold: true,\r\n italic: true,\r\n color: true,\r\n strike: false,\r\n underline: false,\r\n code: false,\r\n highlight: false,\r\n bulletlist: false,\r\n orderlist: false,\r\n link: false,\r\n image: false\r\n};\r\n\r\nexport const editorFull: EditorOptionsProps = {\r\n text: true,\r\n bold: true,\r\n italic: true,\r\n color: true,\r\n strike: true,\r\n underline: true,\r\n code: true,\r\n highlight: true,\r\n bulletlist: true,\r\n orderlist: true,\r\n link: true,\r\n image: true\r\n};","import { Box } from \"../box\";\r\nimport { EditorMenu } from \"./core\";\r\nimport { InputLabel } from \"../api\";\r\nimport { EditorProps } from \"./types\";\r\nimport Link from \"@tiptap/extension-link\";\r\nimport Image from \"@tiptap/extension-image\";\r\nimport StarterKit from \"@tiptap/starter-kit\";\r\nimport { Color } from \"@tiptap/extension-color\";\r\nimport { editorBasic, editorFull } from \"./const\";\r\nimport React, { useEffect, useState } from \"react\";\r\nimport Underline from \"@tiptap/extension-underline\";\r\nimport Highlight from \"@tiptap/extension-highlight\";\r\nimport TextStyle from \"@tiptap/extension-text-style\";\r\nimport { EditorContent as EditorTipTap, useEditor } from \"@tiptap/react\";\r\n\r\n/**\r\n * Componente - `Editor`\r\n *\r\n * Um componente versátil que pode ser utilizado para criar container de edição de texto.\r\n * Permite personalizar o estilo e o conteúdo através de propriedades.\r\n */\r\nexport const Editor = ({ options = \"basic\", iconPrefix = \"bi bi-\", ...props }: EditorProps) => {\r\n const [edition, setEdition] = useState(false);\r\n const editor = useEditor({\r\n extensions: [\r\n StarterKit,\r\n Underline,\r\n Highlight,\r\n Color,\r\n TextStyle,\r\n Link.configure({\r\n validate: (href) => /^https?:\\/\\//.test(href),\r\n HTMLAttributes: {\r\n rel: \"\"\r\n }\r\n }),\r\n Image.configure({\r\n allowBase64: true\r\n })\r\n ],\r\n editable: !props.disabled,\r\n content: props.value ?? \"\",\r\n onFocus: () => setEdition(true),\r\n onBlur: () => setEdition(false),\r\n onUpdate: ({ editor }) => {\r\n props.onChange(editor.getHTML());\r\n }\r\n });\r\n\r\n if (!editor) {\r\n console.error(\"Não foi possível realizar o carregamento do editor de texto.\");\r\n return null;\r\n }\r\n\r\n useEffect(() => {\r\n if (editor && !edition) {\r\n editor?.commands.setContent(props.value);\r\n }\r\n }, [props.value]);\r\n\r\n /*\r\n |------------------------------------------\r\n | render() - Renderização do componente\r\n |------------------------------------------\r\n */\r\n return (\r\n <Box className={props.className}\r\n css={props.css}\r\n size={props.size ?? \"100\"}>\r\n <InputLabel {...props}/>\r\n <div className=\"editor-container\">\r\n {!props.disabled\r\n && <EditorMenu editor={editor}\r\n options={options === \"basic\" ? editorBasic : options === \"full\" ? editorFull : options}/>}\r\n <EditorTipTap className=\"editor\"\r\n disabled={props.disabled}\r\n editor={editor}\r\n id={props.id}\r\n name={props.name}\r\n style={{ minHeight: (props.height ?? 100) + \"px\" }}/>\r\n </div>\r\n <div data-name={props.name}\r\n id=\"j_feedback\"/>\r\n </Box>\r\n );\r\n};\r\n\r\nexport default Editor;"],"names":["Box","children","props","css","size","direction","justify","undefined","Array","isArray","join","align","attr","className","classNames","style","id","React","createElement","Text","editor","active","Fragment","isActive","level","href","fontSize","onClick","event","preventDefault","chain","focus","toggleHeading","run","Link","open","setOpen","useState","link","setLink","useEffect","unsetLink","placeholder","flex","type","value","onChange","target","extendMarkRange","Bold","toggleBold","Code","toggleCode","Color","width","height","borderRadius","margin","border","getAttributes","color","setColor","Image","file","setFile","handlePaste","items","clipboardData","originalEvent","item","indexOf","getAsFile","reader","FileReader","onload","setImage","src","result","readAsDataURL","view","dom","parentNode","addEventListener","removeEventListener","name","accept","files","Italic","toggleItalic","Strike","toggleStrike","Orderlist","toggleOrderedList","Underline","toggleUnderline","Highlight","toggleHighlight","Bulletlist","toggleBulletList","EditorMenu","options","text","bold","italic","strike","underline","code","highlight","bulletlist","orderlist","image","InputLabel","iconPrefix","label","icon","required","editorBasic","editorFull","Editor","edition","setEdition","useEditor","extensions","StarterKit","TextStyle","configure","validate","test","HTMLAttributes","rel","allowBase64","editable","disabled","content","onFocus","onBlur","onUpdate","getHTML","commands","setContent","EditorTipTap","minHeight","console","error"],"mappings":"gcAmBO,MAAMA,EAAM,EAAGC,cAAaC,MAC/B,MAAMC,EAAM,CACRC,KAAM,YAAaF,EAAME,MAA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AY,CACRC,EACA9B,EACAE,EACA1C,EACAuE,EACA1F,EAAK2F,UAAU,CACXC,SAAWrG,GAAS,eAAesG,KAAKtG,GACxCuG,eAAgB,CACZC,IAAK,MAGbnE,EAAM+D,UAAU,CACZK,aAAa,KAGrBC,UAAWjI,EAAMkI,SACjBC,QAASnI,EAAM2C,OAAS,GACxByF,QAAS,IAAMd,GAAW,GAC1Be,OAAQ,IAAMf,GAAW,GACzBgB,SAAU,EAAGpH,aACTlB,EAAM4C,SAAS1B,EAAOqH,UAAU,IAIxC,OAAKrH,GAKLoB,GAAU,KACFpB,IAAWmG,GACXnG,GAAQsH,SAASC,WAAWzI,EAAM2C,MACrC,GACF,CAAC3C,EAAM2C,QAQN5B,gBAACjB,EAAG,CAACa,UAAWX,EAAMW,UACjBV,IAAKD,EAAMC,IACXC,KAAMF,EAAME,MAAQ,OACrBa,EAACC,cAAA6F,EAAe,IAAA7G,IAChBe,EAAKC,cAAA,MAAA,CAAAL,UAAU,qBACTX,EAAMkI,UACDnH,EAAAC,cAACiF,EAAU,CAAC/E,OAAQA,EACRgF,QAAqB,UAAZA,EAAsBgB,EAA0B,SAAZhB,EAAqBiB,EAAajB,IAClGnF,EAACC,cAAA0H,GAAa/H,UAAU,SACVuH,SAAUlI,EAAMkI,SAChBhH,OAAQA,EACRJ,GAAId,EAAMc,GACVoE,KAAMlF,EAAMkF,KACZrE,MAAO,CAAE8H,WAAY3I,EAAMqD,QAAU,KAAO,SAE9DtC,EAAgBC,cAAA,MAAA,CAAA,YAAAhB,EAAMkF,KACjBpE,GAAG,kBAhCZ8H,QAAQC,MAAM,gEACP,KAiCT"}
@@ -0,0 +1,64 @@
1
+ :root {
2
+ --input-filter-border-color: var(--gray-400, #ccc);
3
+ --input-filter-border-radius: var(--input-border-radius, 5px);
4
+ }
5
+
6
+ .input-filter-container {
7
+ border-radius: var(--input-filter-border-radius);
8
+ border: 1px dashed var(--input-filter-border-color);
9
+ }
10
+
11
+ .input-filter-content {
12
+ width: 100%;
13
+ display: flex;
14
+ align-items: flex-start;
15
+ gap: .5rem;
16
+
17
+ .p-autocomplete-multiple {
18
+ padding: 0;
19
+ }
20
+
21
+ .p-autocomplete-multiple-container {
22
+ width: 100%;
23
+ padding: .2rem .5rem;
24
+
25
+ .form-control {
26
+ border: none;
27
+ padding: .2rem;
28
+ }
29
+
30
+ .p-autocomplete-token {
31
+ padding: .2rem .5rem;
32
+ margin: 0;
33
+ }
34
+ }
35
+
36
+ .p-autocomplete-multiple-container.p-focus {
37
+ box-shadow: none;
38
+ border-color: var(--input-filter-border-color);
39
+ }
40
+ }
41
+
42
+ .input-filter-select {
43
+ width: 40%;
44
+ max-width: 200px;
45
+ min-width: 130px;
46
+ }
47
+
48
+ .input-filter-field {
49
+ width: 100% !important;
50
+ }
51
+
52
+ .input-filter-field-date {
53
+ flex: 1;
54
+ }
55
+
56
+ .input-filter-field-date.year {
57
+ flex: 2;
58
+ }
59
+
60
+ .input-filter-autocomplete-panel {
61
+ .p-autocomplete-items {
62
+ padding-left: 0 !important;
63
+ }
64
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";require("jquery"),require("axios"),require("node-snackbar"),require("sweetalert2");var e=require("react"),t=require("primereact/utils"),l=require("primereact/autocomplete");function n(e){let t=document.getElementById(e),l=null===t?null:t.content.replace(".br/",".br");return null===l?null:"/"===l.substr(-1)?l.slice(0,l.length-1):l}n("auth"),n("react-base"),n("csrf-token");const a=[{id:1,name:"Janeiro"},{id:2,name:"Fevereiro"},{id:3,name:"Março"},{id:4,name:"Abril"},{id:5,name:"Maio"},{id:6,name:"Junho"},{id:7,name:"Julho"},{id:8,name:"Agosto"},{id:9,name:"Setembro"},{id:10,name:"Outubro"},{id:11,name:"Novembro"},{id:12,name:"Dezembro"}];function i(e,t="decimal"){let l=e.replace(/[^0-9.,]/g,"");return"decimal"===t?l.replace(",",".").replace(/(\..*)\./g,"$1"):parseFloat(l.replace(",",".")).toLocaleString("pt-BR",{style:"currency",currency:"BRL"}).replace("."," ")}const r=["=","!=","%","!%"],o=[{options:"=",label:"Igual a"},{options:"!=",label:"Diferente de"},{options:"<",label:"Menor do que"},{options:">",label:"Maior do que"},{options:"<=",label:"Menor ou igual a"},{options:">=",label:"Maior ou igual a"},{options:"{}",label:"Intervalo"},{options:"%",label:"Contém o que"},{options:"!%",label:"Não contém o que"}];function s(e){if(!e)return null;let t=e?.match(/(=|!=|<|>|<=|>=|%|!%|\{\})/),l=e.charAt(e.length-1),n=t?.[0];return t?.[0]!==l&&isNaN(parseInt(l))&&n?.slice(-1)!==l&&(n=t?.[0]+l),o.filter((e=>e.options===n))[0]?.label??null}const u=({children:l,...n})=>{const a={size:`box-size-${n.size??"100"}`,direction:`box-direction-${n.direction??"row"}`,justify:void 0===n.justify?"":Array.isArray(n.justify)?n.justify?.join(" "):n.justify,align:void 0===n.align?"":Array.isArray(n.align)?n.align?.join(" "):n.align},i={className:t.classNames(["box",n.className??"",a.size,a.direction,a.justify,a.align]),style:n.css,id:n.id};return e.createElement("div",{...i},l)};function c(e){const[t,l,n]=e,a=l>=1&&l<=12,i=n>0&&n<99999,r=t>=1&&t<=31;if(i&&!a&&!r)return[0,0,n];if(i&&a&&!r)return[0,l,n];if(i&&a&&r){let a=new Date(n,l,0);return a.getDate()<t?[a.getDate(),l,n]:e}return i||!a||r?!i&&a&&r?[t,l,0]:i||a||!r?i&&!a&&r?[t,0,n]:[0,0,0]:[t,0,0]:[0,l,0]}function d(e,t){let l=e,n=t.slice().reverse().find((e=>l?.endsWith(e)));return n&&void 0!==l?l.slice(0,-n.length):l??null}function p(e,t,l=null){let n=e,a=/(=|!=|<|>|<=|>=|\{\})/,i=e?.match(a),r=i?i[0].trim():t[0],o=[];return(n?.split("{}")??[]).forEach(((e,t)=>{let l=e.replace(a,"").trim();if(l.includes("/"))o[t]=l.split("/").map((e=>parseInt(e)));else{let e=parseInt(l);o[t]=[isNaN(e)?0:e]}for(;o[t].length<3;)o[t].unshift(0)})),o[1]&&"{}"===r?[...c(o[0]),l??r].concat(...c(o[1])):0===o.length?[0,0,0,r]:[...c(o[0]),l??r]}function m(e,t,l){null!==t&&(l[t]=parseInt(e));let n=l[3],a=l.slice(0,3);if(a=c(a),"{}"!==n)return`${a[0]}/${a[1]}/${a[2]}${n}`;let i=isNaN(parseInt(l[l.length-1]))&&null===t?[0,0,0]:l.slice(-3);return i=c(i),`${a[0]}/${a[1]}/${a[2]}${n}${i[0]}/${i[1]}/${i[2]}`}function f(e,t,l){let n=e?.split(";").map((e=>parseInt(e)))??[];return l.filter((e=>n.includes(e.id)))}function g(e,t){let l=e.map((e=>e.id));return 0===l.length?null:l.join(";")+t}function h(e,t){let l=e,n=t.slice().reverse().find((e=>l?.endsWith(e)));return i(n&&void 0!==l?l.slice(0,-n.length):l??"","decimal")}function b(t){return e.createElement("input",{className:"form-control input-filter-field",disabled:t.disabled,id:(t.id??"input-filter")+"-text",name:(t.name??"input-filter")+"-text",placeholder:t.placeholder,value:d(t.value,t.options)??"",onChange:e=>t.onChange(e.target.value+t.select)})}function N(t){let l=p(t.value,t.options,t.select);function n(e){"{}"===t.select&&"0/0/0{}0/0/0"===e?t.onChange(null):0!=l[0]&&!isNaN(l[0])||0!=l[1]&&!isNaN(l[1])||0!=l[2]&&!isNaN(l[2])?t.onChange(e):t.onChange(null)}return e.createElement("div",{className:"d-flex w-100 flex-column"},e.createElement("div",{className:"w-100 d-flex gap-2"},l.map(((a,i)=>{if(i<=2)return e.createElement("input",{className:"form-control input-filter-field-date"+(2==i?" year":""),disabled:t.disabled,id:(t.id??"input-filter")+"-"+i,key:i,name:(t.name??"input-filter")+"-"+i,placeholder:t.placeholder,value:0===a?"":a,onChange:e=>n(m(e.target.value,i,l))})}))),"{}"===t.select&&l.length>4&&e.createElement("div",{className:"w-100 d-flex gap-2 mt-2"},l.map(((a,i)=>{if(i>=4)return e.createElement("input",{className:"form-control input-filter-field-date"+(6==i?" year":""),disabled:t.disabled,id:(t.id??"input-filter")+"-"+i,key:i,name:(t.name??"input-filter")+"-"+i,placeholder:t.placeholder,value:0===a?"":a,onChange:e=>n(m(e.target.value,i,l))})}))))}const v=({iconPrefix:t="bi bi-",...l})=>l.label&&e.createElement("p",{className:"form-label"},l.icon&&e.createElement("i",{className:t+l.icon+" me-1"}),l.label,l.required&&e.createElement("span",{className:"text-danger"},"*"));function y(t){return e.createElement("input",{className:"form-control input-filter-field",disabled:t.disabled,id:(t.id??"input-filter")+"-number",name:(t.name??"input-filter")+"-number",placeholder:t.placeholder,value:h(t.value,t.options??""),onChange:e=>t.onChange(i(e.target.value,"decimal")+t.select)})}function E(t){const n=f(t.value,t.options,t.data);return e.createElement(l.AutoComplete,{multiple:!0,completeMethod:e=>{let l=n.map((e=>e.id));t.onSearch(e.query,l)},appendTo:"self",className:"w-100",disabled:t.disabled,emptyMessage:"Não encontramos dados.",field:"label",id:(t.id??"input-filter")+"-autocomplete",inputClassName:"form-control",name:(t.name??"input-filter")+"-autocomplete",panelClassName:"input-filter-autocomplete-panel",placeholder:t.placeholder,required:t.required,scrollHeight:t.autocompleteScrollHeight,selectionLimit:t.autocompleteSelectLimit,suggestions:t.data,value:n,onChange:e=>t.onChange(g(e.value,t.select))})}exports.InputFilter=function({...l}){const n=(l.options??r).sort(((e,t)=>e.length-t.length)),a=o.filter((e=>n?.includes(e.options))),[i,s]=e.useState(function(e,t){let l=t.filter((t=>e?.includes(t)));return l[l.length-1]??t[0]}(l.value,n));return e.useEffect((()=>{if(l.type&&"text"!==l.type){if("date"===l.type){let e=p(l.value,n,i),t=m("0",null,e);"{}"===i&&"0/0/0{}0/0/0"===t||0==e[0]&&0==e[1]&&0==e[2]?l.onChange(null):l.onChange(t)}else if("autocomplete"===l.type){let e=f(l.value,0,l.data);l.onChange(g(e,i))}else if("number"===l.type){let e=h(l.value,n);""!==e?l.onChange(e+i):l.onChange(null)}}else{let e=d(l.value,n);null!==e?l.onChange(e+i):l.onChange(null)}}),[i]),e.createElement(u,{...l,className:t.classNames([l.className,"input-filter-container"])},e.createElement(v,{...l}),e.createElement("div",{className:"input-filter-content",id:l.id??"input-filter"},e.createElement("select",{className:"form-select input-filter-select",disabled:l.disabled,id:(l.id??"input-filter")+"-select",name:(l.name??"input-filter")+"-select",value:i,onChange:e=>s(e.target.value)},a?.map((t=>e.createElement("option",{key:t.options,value:t.options},t.label)))),(!l.type||"text"===l.type)&&e.createElement(b,{...l,options:n,select:i}),"date"===l.type&&e.createElement(N,{...l,options:n,select:i}),"autocomplete"===l.type&&e.createElement(E,{...l,options:n,select:i}),"number"===l.type&&e.createElement(y,{...l,options:n,select:i})))},exports.filterLegend=s,exports.filterLegendAutocomplete=function(e,t=[],l=30){let n=s(e);if(null===n||0===t.length)return"Não encontramos legenda definida.";let a=e?.split(";").map((e=>parseInt(e)))??[],i=t.filter((e=>a.includes(e.id))).map((e=>e.label)).join(", "),r=i.substring(0,l);return n+": "+r+(r.length!==i.length?"...":"")},exports.filterLegendData=function(e){let t=s(e);if(null===t)return"Não encontramos legenda definida.";let l=e?.split("{}"),n=e?.split("/");const i=e=>{let t=parseInt(e[0]),l=parseInt(e[1],10),n=parseInt(e[2]);return`\n ${t>0?`${0==l?"dia":""} ${t}`:""} \n ${l>0?`${t>0?"de":""} ${a[l-1]?.name}`:""} \n ${n>0?`${t>0||l>0?"de":""} ${n}`:""}\n `.replace(/\s+/g," ").trim()};return t+": "+(void 0===l?.[1]?i(n):i(l[0].split("/"))+" à "+i(l[1].split("/")))},exports.filterLegendText=function(e){let t=s(e);return null===t?"Não encontramos legenda definida.":t+": "+(e?.replace(/(=|!=|<|>|<=|>=|%|!%|\{\})/g,"")??"")};
2
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../../src/utils/helper.ts","../../src/utils/const.ts","../../src/utils/handle.ts","../../src/inputfilter/const.ts","../../src/inputfilter/legend.ts","../../src/box/box.tsx","../../src/inputfilter/function/validate.ts","../../src/inputfilter/function/handle.ts","../../src/inputfilter/core/text.tsx","../../src/inputfilter/core/date.tsx","../../src/api/input.tsx","../../src/inputfilter/core/number.tsx","../../src/inputfilter/core/autocomplete.tsx","../../src/inputfilter/inputfilter.tsx"],"sourcesContent":["import $ from \"jquery\";\r\nimport axios from \"axios\";\r\nimport { message } from \"./message\";\r\nimport { IUtilsHelperResponse } from \"./types\";\r\n\r\n/**\r\n * Realiza a pesquisa do elemento html na DOM<br>\r\n * <meta id=\"???\" name=\"???\" content=\"your-url\">\r\n */\r\nexport function getMetaContent(id: string): string | null {\r\n let element: any = document.getElementById(id);\r\n let url: null | string = element === null ? null : (element.content).replace(\".br/\", \".br\");\r\n return url === null ? null : url.substr(-1) === \"/\" ? url.slice(0, url.length - 1) : url;\r\n}\r\n\r\n/**\r\n * Realiza a pesquisa do CEP na API pública \"https://viacep.com.br/ws/\"\r\n */\r\nexport async function getCep(value: string): Promise<IUtilsHelperResponse[\"gep_cep\"]> {\r\n let cep = value.length === 0 ? \"00000000\" : value.replace(\"-\", \"\");\r\n return await axios.get<IUtilsHelperResponse[\"gep_cep\"]>(\"https://viacep.com.br/ws/\" + cep + \"/json/\")\r\n .then(data => data.data);\r\n}\r\n\r\n/**\r\n * Realiza a pesquisa do elemento na árvore DOM\r\n */\r\nexport function getElementDOM(element?: string, preloadTimeOut?: number): Promise<null | JQuery<HTMLElement>> {\r\n return new Promise((resolve) => {\r\n // @ts-ignore\r\n let body = window.self === window.top ? $(\"body\") : $(window.frameElement).parents(\"body\");\r\n if (!element || element.length === 0) {\r\n resolve(body);\r\n }\r\n\r\n if (element === \"#\" || element === \".\") {\r\n resolve(null);\r\n }\r\n\r\n let elementFound = body.find(element);\r\n if (elementFound.length > 0) {\r\n resolve(elementFound);\r\n } else {\r\n setTimeout(() => {\r\n let iframe = body.find(\"iframe\").contents();\r\n if (iframe.length === 0) {\r\n resolve(null);\r\n }\r\n elementFound = iframe.find(element);\r\n if (elementFound.length > 0) {\r\n resolve(elementFound);\r\n }\r\n resolve(null);\r\n }, preloadTimeOut ?? 300);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Permite à comunicação de origem cruzada entre objetos do Windows.<br>\r\n * Exemplo: Comunicação entre iframe e corpo principal\r\n */\r\nexport function windowMessageEvent(): void {\r\n window.addEventListener(\"message\", function (event: MessageEvent) {\r\n if (event.data?.type === \"message\") {\r\n let data = event.data;\r\n message<any>({ ...data.params });\r\n }\r\n });\r\n}","import { getMetaContent } from \"./helper\";\r\n\r\nexport const USER: string | null = getMetaContent(\"auth\");\r\nexport const BASE: string | null = getMetaContent(\"react-base\");\r\nexport const TOKEN: string | null = getMetaContent(\"csrf-token\");\r\n\r\nexport const MES: Array<{ id: number, name: string }> = [\r\n { id: 1, name: \"Janeiro\" },\r\n { id: 2, name: \"Fevereiro\" },\r\n { id: 3, name: \"Março\" },\r\n { id: 4, name: \"Abril\" },\r\n { id: 5, name: \"Maio\" },\r\n { id: 6, name: \"Junho\" },\r\n { id: 7, name: \"Julho\" },\r\n { id: 8, name: \"Agosto\" },\r\n { id: 9, name: \"Setembro\" },\r\n { id: 10, name: \"Outubro\" },\r\n { id: 11, name: \"Novembro\" },\r\n { id: 12, name: \"Dezembro\" },\r\n];\r\n\r\nexport const ESTADOS: Array<{ id: string, name: string }> = [\r\n { name: \"Acre\", id: \"AC\" },\r\n { name: \"Alagoas\", id: \"AL\" },\r\n { name: \"Amapá\", id: \"AP\" },\r\n { name: \"Amazonas\", id: \"AM\" },\r\n { name: \"Bahia\", id: \"BA\" },\r\n { name: \"Ceará\", id: \"CE\" },\r\n { name: \"Distrito Federal\", id: \"DF\" },\r\n { name: \"Espírito Santo\", id: \"ES\" },\r\n { name: \"Goiás\", id: \"GO\" },\r\n { name: \"Maranhão\", id: \"MA\" },\r\n { name: \"Mato Grosso\", id: \"MT\" },\r\n { name: \"Mato Grosso do Sul\", id: \"MS\" },\r\n { name: \"Minas Gerais\", id: \"MG\" },\r\n { name: \"Pará\", id: \"PA\" },\r\n { name: \"Paraíba\", id: \"PB\" },\r\n { name: \"Paraná\", id: \"PR\" },\r\n { name: \"Pernambuco\", id: \"PE\" },\r\n { name: \"Piauí\", id: \"PI\" },\r\n { name: \"Rio de Janeiro\", id: \"RJ\" },\r\n { name: \"Rio Grande do Norte\", id: \"RN\" },\r\n { name: \"Rio Grande do Sul\", id: \"RS\" },\r\n { name: \"Rondônia\", id: \"RO\" },\r\n { name: \"Roraima\", id: \"RR\" },\r\n { name: \"Santa Catarina\", id: \"SC\" },\r\n { name: \"São Paulo\", id: \"SP\" },\r\n { name: \"Sergipe\", id: \"SE\" },\r\n { name: \"Tocantins\", id: \"TO\" }\r\n];","/**\r\n * Formata um valor numérico para o formato decimal ou monetário.\r\n *\r\n * @param valor - O valor a ser formatado.\r\n * @param format - O formato desejado: \"money\" para monetário ou \"decimal\" para decimal.\r\n * @returns O valor formatado como string.\r\n */\r\nexport function handleNumber(\r\n valor: string,\r\n format: \"money\" | \"decimal\" = \"decimal\"\r\n): string {\r\n let value = valor.replace(/[^0-9.,]/g, \"\");\r\n if (format === \"decimal\") {\r\n return value.replace(\",\", \".\").replace(/(\\..*)\\./g, \"$1\");\r\n }\r\n return parseFloat(value.replace(\",\", \".\")).toLocaleString(\"pt-BR\", {\r\n style: \"currency\",\r\n currency: \"BRL\"\r\n }).replace(\".\", \" \");\r\n}\r\n\r\n/**\r\n * Formata um valor de string para o formato de horas (HH:MM).\r\n *\r\n * @param valor - O valor a ser formatado.\r\n * @returns O valor formatado como string no formato de horas.\r\n */\r\nexport function handleHours(valor: string): string {\r\n let value = valor.replace(/[^\\d.]/g, \"\");\r\n const parts = value.split(\".\");\r\n\r\n if (parts.length > 1) {\r\n parts[1] = parts[1].substring(0, 2);\r\n }\r\n\r\n value = parts.join(\".\");\r\n if (value.length > 2) {\r\n value = value.substring(0, value.length - 2) + \":\" + value.substring(value.length - 2);\r\n }\r\n return value;\r\n}","import { InputFilterOptionsMap, InputFilterOptionsProps } from \"./types\";\r\n\r\nexport const optionsDefault: Array<InputFilterOptionsMap[\"text\"]> = [\"=\", \"!=\", \"%\", \"!%\"];\r\n\r\nexport const optionsLabel: Array<{\r\n options: InputFilterOptionsProps,\r\n label: string\r\n}> = [\r\n { options: \"=\", label: \"Igual a\" },\r\n { options: \"!=\", label: \"Diferente de\" },\r\n { options: \"<\", label: \"Menor do que\" },\r\n { options: \">\", label: \"Maior do que\" },\r\n { options: \"<=\", label: \"Menor ou igual a\" },\r\n { options: \">=\", label: \"Maior ou igual a\" },\r\n { options: \"{}\", label: \"Intervalo\" },\r\n { options: \"%\", label: \"Contém o que\" },\r\n { options: \"!%\", label: \"Não contém o que\" },\r\n];","import { MES } from \"../utils\";\r\nimport { optionsLabel } from \"./const\";\r\n\r\n/**\r\n * Retorna a legenda de acordo com operador na string\r\n * @param value - Valor a ser tratado\r\n */\r\nexport function filterLegend(value: string | undefined): string | null {\r\n if (!value) {\r\n return null;\r\n }\r\n let optsRegex = /(=|!=|<|>|<=|>=|%|!%|\\{\\})/;\r\n let optsMatch = value?.match(optsRegex);\r\n let opts = value.charAt(value.length - 1);\r\n let option = optsMatch?.[0];\r\n\r\n if (optsMatch?.[0] !== opts && isNaN(parseInt(opts)) && option?.slice(-1) !== opts) {\r\n option = optsMatch?.[0] + opts;\r\n }\r\n return optionsLabel.filter(item => item.options === option)[0]?.label ?? null;\r\n}\r\n\r\n/**\r\n * Realiza o tratamento das informações para retorna a legenda do tipo `Date`\r\n * @param value - Valor a ser tratado\r\n */\r\nexport function filterLegendData(value: string | undefined): string {\r\n let legend = filterLegend(value);\r\n if (legend === null) {\r\n return \"Não encontramos legenda definida.\";\r\n }\r\n\r\n let interval = value?.split(\"{}\");\r\n let date = value?.split(\"/\");\r\n\r\n const handleLegend = (date: any): string => {\r\n let dia = parseInt(date[0]);\r\n let mes = parseInt(date[1], 10);\r\n let ano = parseInt(date[2]);\r\n\r\n return `\r\n ${(dia > 0 ? `${mes == 0 ? \"dia\" : \"\"} ${dia}` : \"\")} \r\n ${mes > 0 ? `${dia > 0 ? \"de\" : \"\"} ${MES[mes - 1]?.name}` : \"\"} \r\n ${ano > 0 ? `${dia > 0 || mes > 0 ? \"de\" : \"\"} ${ano}` : \"\"}\r\n `.replace(/\\s+/g, \" \").trim();\r\n };\r\n let result = interval?.[1] === undefined\r\n ? handleLegend(date)\r\n : handleLegend(interval[0].split(\"/\")) + \" à \" + handleLegend(interval[1].split(\"/\"));\r\n return legend + \": \" + result;\r\n}\r\n\r\n/**\r\n * Realiza o tratamento das informações para retorna a legenda do tipo `Text`\r\n * @param value - Valor a ser tratado\r\n */\r\nexport function filterLegendText(value: string | undefined): string {\r\n let legend = filterLegend(value);\r\n if (legend === null) {\r\n return \"Não encontramos legenda definida.\";\r\n }\r\n return legend + \": \" + (value?.replace(/(=|!=|<|>|<=|>=|%|!%|\\{\\})/g, \"\") ?? \"\");\r\n}\r\n\r\n/**\r\n * Realiza o tratamento das informações para retorna a legando do tipo `autocomplete`\r\n * @param value - Valor a ser tratado\r\n * @param dto - Array de objeto para ser pesquisado a legenda\r\n * @param word - Limite de palavras para a legenda\r\n */\r\nexport function filterLegendAutocomplete(value: string | undefined, dto: any[] = [], word: number = 30): string {\r\n let legend = filterLegend(value);\r\n if (legend === null || dto.length === 0) {\r\n return \"Não encontramos legenda definida.\";\r\n }\r\n let ids: any[] = value?.split(\";\").map(item => parseInt(item)) ?? [];\r\n let values = dto\r\n .filter(obj => ids.includes(obj.id))\r\n .map(item => item.label).join(\", \");\r\n let text = values.substring(0, word);\r\n return legend + \": \" + text + (text.length !== values.length ? \"...\" : \"\");\r\n}","import { BoxProps } from \"./types\";\r\nimport React, { HTMLAttributes } from \"react\";\r\nimport { classNames } from \"primereact/utils\";\r\n\r\n/**\r\n * Componente - `Box`\r\n *\r\n * Um componente versátil que pode ser utilizado para criar seções ou caixas em uma página.\r\n * Permite personalizar o estilo e o conteúdo através de propriedades.\r\n *\r\n * Exemplo de uso:\r\n * ```tsx\r\n * <Box align=\"align-items-center\"\r\n * justify=\"justify-content-end\"\r\n * size=\"25\">\r\n * ...conteúdo HTML\r\n * </Box>\r\n * ```\r\n */\r\nexport const Box = ({ children, ...props }: BoxProps) => {\r\n const css = {\r\n size: `box-size-${(props.size ?? \"100\")}`,\r\n direction: `box-direction-${props.direction ?? \"row\"}`,\r\n justify: props.justify === undefined ? \"\" : Array.isArray(props.justify) ? props.justify?.join(\" \") : props.justify,\r\n align: props.align === undefined ? \"\" : Array.isArray(props.align) ? props.align?.join(\" \") : props.align\r\n };\r\n\r\n const attr: HTMLAttributes<\"div\"> & Omit<BoxProps, \"children\"> = {\r\n className: classNames([\r\n \"box\",\r\n props.className ?? \"\",\r\n css.size,\r\n css.direction,\r\n css.justify,\r\n css.align\r\n ]),\r\n style: props.css,\r\n id: props.id\r\n };\r\n\r\n return (\r\n <div {...attr as any}>{children}</div>\r\n );\r\n};","/**\r\n * Valida e ajusta uma data fornecida como um array de números.\r\n *\r\n * @param date - Um array de números representando [dia, mês, ano].\r\n * @returns Um array de números representando a data validada e ajustada.\r\n */\r\nexport function validateDate(date: number[]): number[] {\r\n const [day, month, year] = date;\r\n\r\n const isMonthValid = month >= 1 && month <= 12;\r\n const isYearValid = year > 0 && year < 99999;\r\n const isDayValid = day >= 1 && day <= 31;\r\n\r\n if (isYearValid && !isMonthValid && !isDayValid) {\r\n return [0, 0, year];\r\n }\r\n\r\n if (isYearValid && isMonthValid && !isDayValid) {\r\n return [0, month, year];\r\n }\r\n\r\n if (isYearValid && isMonthValid && isDayValid) {\r\n let currentDate = new Date(year, month, 0);\r\n if (currentDate.getDate() < day) {\r\n return [currentDate.getDate(), month, year];\r\n }\r\n return date;\r\n }\r\n\r\n if (!isYearValid && isMonthValid && !isDayValid) {\r\n return [0, month, 0];\r\n }\r\n\r\n if (!isYearValid && isMonthValid && isDayValid) {\r\n return [day, month, 0];\r\n }\r\n\r\n if (!isYearValid && !isMonthValid && isDayValid) {\r\n return [day, 0, 0];\r\n }\r\n\r\n if (isYearValid && !isMonthValid && isDayValid) {\r\n return [day, 0, year];\r\n }\r\n\r\n return [0, 0, 0];\r\n}","import { validateDate } from \"./validate\";\r\nimport { handleNumber } from \"../../utils\";\r\nimport { InputFilterOptionsMap } from \"../types\";\r\n\r\n/**\r\n * Obtém a opção de filtro correspondente ao valor fornecido.\r\n *\r\n * @param value - O valor para buscar uma opção correspondente.\r\n * @param options - Um array de opções de filtro disponíveis.\r\n * @returns A opção de filtro correspondente ou a primeira opção se nenhuma correspondência for encontrada.\r\n */\r\nexport function handleGetOption<T extends keyof InputFilterOptionsMap>(\r\n value: string | undefined,\r\n options: Array<InputFilterOptionsMap[T]>\r\n): string {\r\n let exists = options.filter(option => value?.includes(option));\r\n return exists[exists.length - 1] ?? options[0];\r\n}\r\n\r\n/**\r\n * Retorna apenas o valor sem os operadores filtro tipo `Text`.\r\n *\r\n * @param value - O valor completo, incluindo a opção de filtro.\r\n * @param options - Um array de opções de filtro disponíveis.\r\n * @returns O valor sem as opções de filtro.\r\n */\r\nexport function handleGetValueText(\r\n value: string | undefined,\r\n options: Array<InputFilterOptionsMap[\"text\"]>\r\n): string | null {\r\n let str = value;\r\n let exists = options\r\n .slice()\r\n .reverse()\r\n .find(item => str?.endsWith(item));\r\n if (exists && str !== undefined) {\r\n return str.slice(0, -exists.length);\r\n }\r\n return str ?? null;\r\n}\r\n\r\n/**\r\n * Retorna apenas o valor sem os operadores filtro tipo `Date`.\r\n *\r\n * @param value - O valor completo, incluindo a opção de filtro.\r\n * @param options - Um array de opções de filtro disponíveis.\r\n * @param select - Seletor do tipo de filtro\r\n * @returns O valor sem as opções de filtro.\r\n */\r\nexport function handleGetValueDate(\r\n value: string | undefined,\r\n options: Array<InputFilterOptionsMap[\"date\"]>,\r\n select: null | string = null\r\n): Array<number | string> {\r\n let str = value;\r\n let optsRegex = /(=|!=|<|>|<=|>=|\\{\\})/;\r\n let optsMatch = value?.match(optsRegex);\r\n let opts = optsMatch ? optsMatch[0].trim() : options[0];\r\n\r\n let parts: any[] = [];\r\n let interval = str?.split(\"{}\") ?? [];\r\n\r\n interval.forEach((value, index) => {\r\n let clean = value.replace(optsRegex, \"\").trim();\r\n\r\n if (clean.includes(\"/\")) {\r\n parts[index] = clean.split(\"/\").map(item => parseInt(item));\r\n } else {\r\n let number = parseInt(clean);\r\n parts[index] = [isNaN(number) ? 0 : number];\r\n }\r\n\r\n while (parts[index].length < 3) {\r\n parts[index].unshift(0);\r\n }\r\n });\r\n\r\n if (parts[1] && opts === \"{}\") {\r\n return [...validateDate(parts[0]), select ?? opts].concat(...validateDate(parts[1]));\r\n }\r\n return parts.length === 0\r\n ? [0, 0, 0, opts]\r\n : [...validateDate(parts[0]), select ?? opts];\r\n}\r\n\r\n/**\r\n * Atualiza um valor de data em uma posição específica e retorna a data formatada.\r\n *\r\n * @param value - O novo valor a ser inserido na data\r\n * @param position - A posição do valor a ser atualizado (0 para dia, 1 para mês, 2 para ano)\r\n * @param date - O array da data atual, incluindo as opções\r\n * @returns A data atualizada e formatada como string\r\n */\r\nexport function handleSetValueDate(\r\n value: string,\r\n position: number | null,\r\n date: (number | string)[]\r\n): string {\r\n if (position !== null) {\r\n date[position] = parseInt(value);\r\n }\r\n\r\n let opts = date[3];\r\n let firstDate = date.slice(0, 3);\r\n firstDate = validateDate(firstDate as number[]);\r\n\r\n if (opts !== \"{}\") {\r\n return `${firstDate[0]}/${firstDate[1]}/${firstDate[2]}${opts}`;\r\n }\r\n\r\n let lastDate = isNaN(parseInt(date[date.length - 1] as string)) && position === null\r\n ? [0, 0, 0]\r\n : date.slice(-3);\r\n lastDate = validateDate(lastDate as number[]);\r\n return `${firstDate[0]}/${firstDate[1]}/${firstDate[2]}${opts}${lastDate[0]}/${lastDate[1]}/${lastDate[2]}`;\r\n}\r\n\r\n/**\r\n * Obtém os valores selecionados do autocomplete a partir da string de valor e dos dados disponíveis.\r\n *\r\n * @param value - String contendo os IDs dos itens selecionados, separados por ponto e vírgula.\r\n * @param options - Array de opções de filtro disponíveis para o autocomplete.\r\n * @param data - Array de objetos contendo os dados disponíveis para seleção.\r\n * @returns Array de objetos correspondentes aos IDs selecionados.\r\n */\r\nexport function handleGetValueAutocomplete(\r\n value: string | undefined,\r\n options: Array<InputFilterOptionsMap[\"autocomplete\"]>,\r\n data: Array<{ id: number, label: string }>\r\n) {\r\n let values: any[] = value?.split(\";\").map(item => parseInt(item)) ?? [];\r\n return data.filter(item => values.includes(item.id));\r\n}\r\n\r\n/**\r\n * Converte os valores selecionados do autocomplete em uma string formatada para o filtro.\r\n *\r\n * @param value - Array de objetos selecionados no autocomplete.\r\n * @param select - String representando a opção de filtro selecionada.\r\n * @returns String formatada com os IDs dos itens selecionados e a opção de filtro.\r\n */\r\nexport function handleSetValueAutocomplete(\r\n value: Array<{ id: number, label: string }>,\r\n select: string,\r\n): string | null {\r\n let ids = value.map(item => item.id);\r\n return ids.length === 0 ? null : ids.join(\";\") + select;\r\n}\r\n\r\n/**\r\n * Retorna apenas o valor sem os operadores filtro tipo `Number`.\r\n *\r\n * @param value - O valor completo, incluindo a opção de filtro.\r\n * @param options - Um array de opções de filtro disponíveis.\r\n * @returns O valor sem as opções de filtro.\r\n */\r\nexport function handleGetValueNumber(\r\n value: string | undefined,\r\n options: Array<InputFilterOptionsMap[\"text\"]>\r\n): string {\r\n let str = value;\r\n let exists = options\r\n .slice()\r\n .reverse()\r\n .find(item => str?.endsWith(item));\r\n if (exists && str !== undefined) {\r\n return handleNumber(str.slice(0, -exists.length), \"decimal\");\r\n }\r\n return handleNumber(str ?? \"\", \"decimal\");\r\n}","import React from \"react\";\r\nimport { handleGetValueText } from \"../function/handle\";\r\nimport { InputFilterCoreProps, InputFilterOptionsMap } from \"../types\";\r\n\r\n/**\r\n * Core - `Text`\r\n * Campo do filtro tipo texto\r\n */\r\nexport function Text<T extends keyof InputFilterOptionsMap>(props: InputFilterCoreProps<T>) {\r\n return (\r\n <input className=\"form-control input-filter-field\"\r\n disabled={props.disabled}\r\n id={(props.id ?? \"input-filter\") + \"-text\"}\r\n name={(props.name ?? \"input-filter\") + \"-text\"}\r\n placeholder={props.placeholder}\r\n value={handleGetValueText(props.value, props.options) ?? \"\"}\r\n onChange={event => props.onChange(event.target.value + props.select)}/>\r\n );\r\n}","import React from \"react\";\r\nimport { InputFilterCoreProps, InputFilterOptionsMap } from \"../types\";\r\nimport { handleGetValueDate, handleSetValueDate } from \"../function/handle\";\r\n\r\n/**\r\n * Core - `Date`\r\n * Campo do filtro tipo data\r\n */\r\nexport function Date<T extends keyof InputFilterOptionsMap>(props: InputFilterCoreProps<T>) {\r\n let date = handleGetValueDate(props.value, props.options, props.select);\r\n\r\n function handleChangeValue(value: string) {\r\n if (props.select === \"{}\" && value === \"0/0/0{}0/0/0\") {\r\n props.onChange(null);\r\n } else {\r\n if ((date[0] == 0 || isNaN(date[0] as number)) &&\r\n (date[1] == 0 || isNaN(date[1] as number)) &&\r\n (date[2] == 0 || isNaN(date[2] as number))) {\r\n props.onChange(null);\r\n } else {\r\n props.onChange(value);\r\n }\r\n }\r\n }\r\n\r\n return (\r\n <div className=\"d-flex w-100 flex-column\">\r\n <div className=\"w-100 d-flex gap-2\">\r\n {date.map((item, index) => {\r\n if (index <= 2) {\r\n return (\r\n <input className={\"form-control input-filter-field-date\" + (index == 2 ? \" year\" : \"\")}\r\n disabled={props.disabled}\r\n id={(props.id ?? \"input-filter\") + \"-\" + index}\r\n key={index}\r\n name={(props.name ?? \"input-filter\") + \"-\" + index}\r\n placeholder={props.placeholder}\r\n value={item === 0 ? \"\" : item}\r\n onChange={event => handleChangeValue(handleSetValueDate(event.target.value, index, date))}/>\r\n );\r\n }\r\n })}\r\n </div>\r\n {props.select === \"{}\" && date.length > 4\r\n && <div className=\"w-100 d-flex gap-2 mt-2\">\r\n {date.map((item, index) => {\r\n if (index >= 4) {\r\n return (\r\n <input className={\"form-control input-filter-field-date\" + (index == 6 ? \" year\" : \"\")}\r\n disabled={props.disabled}\r\n id={(props.id ?? \"input-filter\") + \"-\" + index}\r\n key={index}\r\n name={(props.name ?? \"input-filter\") + \"-\" + index}\r\n placeholder={props.placeholder}\r\n value={item === 0 ? \"\" : item}\r\n onChange={event => handleChangeValue(handleSetValueDate(event.target.value, index, date))}/>\r\n );\r\n }\r\n })}\r\n </div>}\r\n </div>\r\n );\r\n}","import React from \"react\";\r\nimport { ApiFieldComponentProps } from \"./types\";\r\n\r\n/**\r\n * API - `InputLabel`\r\n *\r\n * Um componente utilizado como label em todos os componente de campo do pacote.\r\n * Permite personalizar o estilo e o conteúdo através de propriedades.\r\n */\r\nexport const InputLabel = ({ iconPrefix = \"bi bi-\", ...props }: ApiFieldComponentProps) => {\r\n /*\r\n |------------------------------------------\r\n | render() - Renderização do componente\r\n |------------------------------------------\r\n */\r\n return props.label\r\n && <p className='form-label'>\r\n {props.icon && <i className={iconPrefix + props.icon + \" me-1\"}/>}\r\n {props.label}\r\n {props.required && <span className=\"text-danger\">*</span>}\r\n </p>;\r\n};","import React from \"react\";\r\nimport { handleNumber } from \"../../utils\";\r\nimport { handleGetValueNumber } from \"../function/handle\";\r\nimport { InputFilterCoreProps, InputFilterOptionsMap } from \"../types\";\r\n\r\n/**\r\n * Core - `Number`\r\n * Campo do filtro tipo numero\r\n */\r\nexport function Number<T extends keyof InputFilterOptionsMap>(props: InputFilterCoreProps<T>) {\r\n return (\r\n <input className=\"form-control input-filter-field\"\r\n disabled={props.disabled}\r\n id={(props.id ?? \"input-filter\") + \"-number\"}\r\n name={(props.name ?? \"input-filter\") + \"-number\"}\r\n placeholder={props.placeholder}\r\n value={handleGetValueNumber(props.value, props.options ?? \"\")}\r\n onChange={event => props.onChange(handleNumber(event.target.value, \"decimal\") + props.select)}/>\r\n );\r\n}","import React from \"react\";\r\nimport { InputFilterCoreProps, InputFilterOptionsMap } from \"../types\";\r\nimport { AutoComplete as AutocompletePrimeReact } from \"primereact/autocomplete\";\r\nimport { handleGetValueAutocomplete, handleSetValueAutocomplete } from \"../function/handle\";\r\n\r\n/**\r\n * Core - `Autocomplete`\r\n * Campo do filtro tipo autocomplete\r\n */\r\nexport function Autocomplete<T extends keyof InputFilterOptionsMap>(props: InputFilterCoreProps<\"autocomplete\">) {\r\n const value = handleGetValueAutocomplete(props.value, props.options, props.data);\r\n\r\n return (\r\n <AutocompletePrimeReact multiple\r\n completeMethod={event => {\r\n let ids = value.map(item => item.id);\r\n props.onSearch(event.query, ids);\r\n }}\r\n appendTo=\"self\"\r\n className=\"w-100\"\r\n disabled={props.disabled}\r\n emptyMessage=\"Não encontramos dados.\"\r\n field=\"label\"\r\n id={(props.id ?? \"input-filter\") + \"-\" + \"autocomplete\"}\r\n inputClassName=\"form-control\"\r\n name={(props.name ?? \"input-filter\") + \"-\" + \"autocomplete\"}\r\n panelClassName=\"input-filter-autocomplete-panel\"\r\n placeholder={props.placeholder}\r\n required={props.required}\r\n scrollHeight={props.autocompleteScrollHeight}\r\n selectionLimit={props.autocompleteSelectLimit}\r\n suggestions={props.data}\r\n value={value}\r\n onChange={event => props.onChange(handleSetValueAutocomplete(event.value, props.select))}/>\r\n );\r\n}","import { Box } from \"../box\";\r\nimport { Text } from \"./core/text\";\r\nimport { Date } from \"./core/date\";\r\nimport { InputLabel } from \"../api\";\r\nimport { Number } from \"./core/number\";\r\nimport * as handle from \"./function/handle\";\r\nimport { classNames } from \"primereact/utils\";\r\nimport { Autocomplete } from \"./core/autocomplete\";\r\nimport React, { useState, useEffect } from \"react\";\r\nimport { optionsDefault, optionsLabel } from \"./const\";\r\nimport { InputFilterOptionsMap, InputFilterProps } from \"./types\";\r\n\r\n/**\r\n * Componente - `InputFilter`\r\n *\r\n * Um componente utilizado para montar o objeto de pesquisa de dados.\r\n * Permite alterar o seu tipo através do type: `text`, `date`, `autocomplete`.\r\n */\r\nexport function InputFilter<T extends keyof InputFilterOptionsMap = \"text\">({ ...props }: InputFilterProps<T>) {\r\n\r\n const options: any[] = (props.options ?? optionsDefault).sort((a, b) => a.length - b.length);\r\n const selectOptions = optionsLabel.filter(item => options?.includes(item.options as any));\r\n const [select, setSelect] = useState<string>(handle.handleGetOption<T>(props.value, options));\r\n\r\n useEffect(() => {\r\n if (!props.type || props.type === \"text\") {\r\n let value = handle.handleGetValueText(props.value, options);\r\n if (value !== null) {\r\n props.onChange(value + select);\r\n } else {\r\n props.onChange(null);\r\n }\r\n } else if (props.type === \"date\") {\r\n let date = handle.handleGetValueDate(props.value, options, select);\r\n let setDate = handle.handleSetValueDate(\"0\", null, date);\r\n\r\n if (select === \"{}\" && setDate === \"0/0/0{}0/0/0\") {\r\n props.onChange(null);\r\n } else {\r\n if (date[0] == 0 && date[1] == 0 && date[2] == 0) {\r\n props.onChange(null);\r\n } else {\r\n props.onChange(setDate);\r\n }\r\n }\r\n } else if (props.type === \"autocomplete\") {\r\n let value = handle.handleGetValueAutocomplete(props.value, options, props.data);\r\n props.onChange(handle.handleSetValueAutocomplete(value, select));\r\n } else if (props.type === \"number\") {\r\n let value = handle.handleGetValueNumber(props.value, options);\r\n if (value !== \"\") {\r\n props.onChange(value + select);\r\n } else {\r\n props.onChange(null);\r\n }\r\n }\r\n }, [select]);\r\n\r\n /*\r\n |------------------------------------------\r\n | render() - Renderização do componente\r\n |------------------------------------------\r\n */\r\n return (\r\n <Box {...props}\r\n className={classNames([props.className, \"input-filter-container\"])}>\r\n <InputLabel {...props}/>\r\n <div className=\"input-filter-content\"\r\n id={props.id ?? \"input-filter\"}>\r\n <select className=\"form-select input-filter-select\"\r\n disabled={props.disabled}\r\n id={(props.id ?? \"input-filter\") + \"-select\"}\r\n name={(props.name ?? \"input-filter\") + \"-select\"}\r\n value={select}\r\n onChange={event => setSelect(event.target.value)}>\r\n {selectOptions?.map(item => (\r\n <option key={item.options}\r\n value={item.options}>{item.label}</option>\r\n ))}\r\n </select>\r\n {(!props.type || props.type === \"text\")\r\n && <Text<\"text\"> {...props as InputFilterProps<\"text\">}\r\n options={options}\r\n select={select}/>}\r\n {props.type === \"date\"\r\n && <Date<\"date\"> {...props as InputFilterProps<\"date\">}\r\n options={options}\r\n select={select}/>}\r\n {props.type === \"autocomplete\"\r\n && <Autocomplete<\"autocomplete\"> {...props as InputFilterProps<\"autocomplete\">}\r\n options={options}\r\n select={select}/>}\r\n {props.type === \"number\"\r\n && <Number<\"number\"> {...props}\r\n options={options}\r\n select={select}/>}\r\n </div>\r\n </Box>\r\n );\r\n}"],"names":["getMetaContent","id","element","document","getElementById","url","replace","substr","slice","length","MES","name","handleNumber","valor","format","value","parseFloat","toLocaleString","style","currency","optionsDefault","optionsLabel","options","label","filterLegend","optsMatch","match","opts","charAt","option","isNaN","parseInt","filter","item","Box","children","props","css","size","direction","justify","undefined","Array","isArray","join","align","attr","className","classNames","React","createElement","validateDate","date","day","month","year","isMonthValid","isYearValid","isDayValid","currentDate","Date","getDate","handleGetValueText","str","exists","reverse","find","endsWith","handleGetValueDate","select","optsRegex","trim","parts","split","forEach","index","clean","includes","map","number","unshift","concat","handleSetValueDate","position","firstDate","lastDate","handleGetValueAutocomplete","data","values","handleSetValueAutocomplete","ids","handleGetValueNumber","Text","disabled","placeholder","onChange","event","target","handleChangeValue","key","InputLabel","iconPrefix","icon","required","Number","Autocomplete","AutocompletePrimeReact","AutoComplete","multiple","completeMethod","onSearch","query","appendTo","emptyMessage","field","inputClassName","panelClassName","scrollHeight","autocompleteScrollHeight","selectionLimit","autocompleteSelectLimit","suggestions","sort","a","b","selectOptions","setSelect","useState","handle.handleGetOption","useEffect","type","handle.handleGetValueDate","setDate","handle.handleSetValueDate","handle.handleGetValueAutocomplete","handle.handleSetValueAutocomplete","handle.handleGetValueNumber","handle.handleGetValueText","dto","word","legend","obj","text","substring","interval","handleLegend","dia","mes","ano"],"mappings":"0LASM,SAAUA,EAAeC,GAC3B,IAAIC,EAAeC,SAASC,eAAeH,GACvCI,EAAiC,OAAZH,EAAmB,KAAQA,EAAe,QAAEI,QAAQ,OAAQ,OACrF,OAAe,OAARD,EAAe,KAA0B,MAAnBA,EAAIE,QAAQ,GAAaF,EAAIG,MAAM,EAAGH,EAAII,OAAS,GAAKJ,CACzF,CCXmCL,EAAe,QACfA,EAAe,cACdA,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AASgE,EAAI5I,MAC/B6E,KAAI7C,GAAQA,EAAKV,QAAOqB,KAAK,MAC9BkG,EAAOtD,EAAOuD,UAAU,EAAGJ,GAC/B,OAAOC,EAAS,KAAOE,GAAQA,EAAKrI,SAAW+E,EAAO/E,OAAS,MAAQ,GAC3E,2BAvDM,SAA2BM,GAC7B,IAAI6H,EAASpH,EAAaT,GAC1B,GAAe,OAAX6H,EACA,MAAO,oCAGX,IAAII,EAAWjI,GAAO0D,MAAM,MACxBrB,EAAOrC,GAAO0D,MAAM,KAExB,MAAMwE,EAAgB7F,IAClB,IAAI8F,EAAMnH,SAASqB,EAAK,IACpB+F,EAAMpH,SAASqB,EAAK,GAAI,IACxBgG,EAAMrH,SAASqB,EAAK,IAExB,MAAO,iBACA8F,EAAM,EAAI,GAAU,GAAPC,EAAW,MAAQ,MAAMD,IAAQ,oBAC/CC,EAAM,EAAI,GAAGD,EAAM,EAAI,KAAO,MAAMxI,EAAIyI,EAAM,IAAIxI,OAAS,oBAC3DyI,EAAM,EAAI,GAAGF,EAAM,GAAKC,EAAM,EAAI,KAAO,MAAMC,IAAQ,eAC3D9I,QAAQ,OAAQ,KAAKiE,MAAM,EAKjC,OAAOqE,EAAS,WAHenG,IAAlBuG,IAAW,GAClBC,EAAa7F,GACb6F,EAAaD,EAAS,GAAGvE,MAAM,MAAQ,MAAQwE,EAAaD,EAAS,GAAGvE,MAAM,MAExF,2BAMM,SAA2B1D,GAC7B,IAAI6H,EAASpH,EAAaT,GAC1B,OAAe,OAAX6H,EACO,oCAEJA,EAAS,MAAQ7H,GAAOT,QAAQ,8BAA+B,KAAO,GACjF"}
@@ -0,0 +1,161 @@
1
+ import React, { CSSProperties } from 'react';
2
+
3
+ /**
4
+ * Retorna a legenda de acordo com operador na string
5
+ * @param value - Valor a ser tratado
6
+ */
7
+ declare function filterLegend(value: string | undefined): string | null;
8
+ /**
9
+ * Realiza o tratamento das informações para retorna a legenda do tipo `Date`
10
+ * @param value - Valor a ser tratado
11
+ */
12
+ declare function filterLegendData(value: string | undefined): string;
13
+ /**
14
+ * Realiza o tratamento das informações para retorna a legenda do tipo `Text`
15
+ * @param value - Valor a ser tratado
16
+ */
17
+ declare function filterLegendText(value: string | undefined): string;
18
+ /**
19
+ * Realiza o tratamento das informações para retorna a legando do tipo `autocomplete`
20
+ * @param value - Valor a ser tratado
21
+ * @param dto - Array de objeto para ser pesquisado a legenda
22
+ * @param word - Limite de palavras para a legenda
23
+ */
24
+ declare function filterLegendAutocomplete(value: string | undefined, dto?: any[], word?: number): string;
25
+
26
+ /**
27
+ * Define as tipagens `default` de todos os componentes do pacote
28
+ */
29
+ interface ApiComponentProps {
30
+
31
+ /**
32
+ * Propriedade para identificar o id do elemento
33
+ */
34
+ id?: string
35
+
36
+ /**
37
+ * Adiciona no atributo `class` do componente o valor atribuido nessa propriedade
38
+ */
39
+ className?: string
40
+
41
+ /**
42
+ * Define o tamanho da box do componente de acordo com o valores abaixo
43
+ */
44
+ size?: "5" | "10" | "12-5" | "15" | "17-5" | "20" | "22-5" | "25" | "30" | "33" | "35" | "40" | "45" | "50" | "55" | "60" | "65" | "70" | "75" | "80" | "85" | "90" | "95" | "100"
45
+
46
+ /**
47
+ * Define as propriedades css do component `style`
48
+ */
49
+ css?: CSSProperties
50
+ }
51
+
52
+ /**
53
+ * Define as tipagens ´default´ de tidos os componente de entrada de dados do pacote
54
+ */
55
+ interface ApiFieldComponentProps {
56
+
57
+ /**
58
+ * Define o id do campo
59
+ */
60
+ id?: string
61
+
62
+ /**
63
+ * Define o nome do campo
64
+ */
65
+ name?: string
66
+
67
+ /**
68
+ * Define o rótulo do campo
69
+ */
70
+ label?: string
71
+
72
+ /**
73
+ * Define o espaço reservador do campo
74
+ */
75
+ placeholder?: string
76
+
77
+ /**
78
+ * Define o icone do campo
79
+ */
80
+ icon?: string
81
+
82
+ /**
83
+ * Define o prefixo dos icones do pacote
84
+ */
85
+ iconPrefix?: "bi bi-" | "pi pi-"
86
+
87
+ /**
88
+ * Define se campo é obrigatório
89
+ */
90
+ required?: boolean
91
+
92
+ /**
93
+ * Desabilita a entrada de dados no campo
94
+ */
95
+ disabled?: boolean
96
+ }
97
+
98
+ interface InputFilterBaseProps<T extends keyof InputFilterOptionsMap> extends ApiComponentProps, ApiFieldComponentProps {
99
+ /**
100
+ * Valor inicial do componente
101
+ */
102
+ value?: string
103
+
104
+ /**
105
+ * Retorna o valor modificado pelo componente
106
+ */
107
+ onChange(value: string | null): void
108
+
109
+ /**
110
+ * Define o tipo do filtro
111
+ */
112
+ type?: T;
113
+
114
+ /**
115
+ * Define as opções do filtro
116
+ */
117
+ options?: Array<InputFilterOptionsMap[T]>;
118
+ }
119
+
120
+ interface InputFilterAutocompleteProps {
121
+ /**
122
+ * Sugestões do autocomplete
123
+ */
124
+ data: Array<{ id: number, label: string }>
125
+
126
+ /**
127
+ * Realiza a pesquisa do autocomplete de acordo com query
128
+ */
129
+ onSearch(query: string, selected?: number[]): void
130
+
131
+ /**
132
+ * Define o número de elementos que poser ser selecionado no autocomplete
133
+ */
134
+ autocompleteSelectLimit?: number
135
+
136
+ /**
137
+ * Define a altura da caixa de seleção dos dados
138
+ */
139
+ autocompleteScrollHeight?: string
140
+ }
141
+
142
+ type InputFilterProps<T extends keyof InputFilterOptionsMap> = T extends "autocomplete"
143
+ ? InputFilterBaseProps<"autocomplete"> & InputFilterAutocompleteProps
144
+ : InputFilterBaseProps<T>;
145
+
146
+ type InputFilterOptionsMap = {
147
+ text: "=" | "!=" | "%" | "!%"
148
+ date: "=" | "!=" | "<" | ">" | "<=" | ">=" | "{}"
149
+ autocomplete: "=" | "!=" | "%" | "!%"
150
+ number: "=" | "!=" | "<" | ">" | "<=" | ">="
151
+ }
152
+
153
+ /**
154
+ * Componente - `InputFilter`
155
+ *
156
+ * Um componente utilizado para montar o objeto de pesquisa de dados.
157
+ * Permite alterar o seu tipo através do type: `text`, `date`, `autocomplete`.
158
+ */
159
+ declare function InputFilter<T extends keyof InputFilterOptionsMap = "text">({ ...props }: InputFilterProps<T>): React.JSX.Element;
160
+
161
+ export { InputFilter, filterLegend, filterLegendAutocomplete, filterLegendData, filterLegendText };
@@ -0,0 +1,2 @@
1
+ import"jquery";import"axios";import"node-snackbar";import"sweetalert2";import e,{useState as t,useEffect as n}from"react";import{classNames as l}from"primereact/utils";import{AutoComplete as a}from"primereact/autocomplete";function i(e){let t=document.getElementById(e),n=null===t?null:t.content.replace(".br/",".br");return null===n?null:"/"===n.substr(-1)?n.slice(0,n.length-1):n}i("auth"),i("react-base"),i("csrf-token");const r=[{id:1,name:"Janeiro"},{id:2,name:"Fevereiro"},{id:3,name:"Março"},{id:4,name:"Abril"},{id:5,name:"Maio"},{id:6,name:"Junho"},{id:7,name:"Julho"},{id:8,name:"Agosto"},{id:9,name:"Setembro"},{id:10,name:"Outubro"},{id:11,name:"Novembro"},{id:12,name:"Dezembro"}];function o(e,t="decimal"){let n=e.replace(/[^0-9.,]/g,"");return"decimal"===t?n.replace(",",".").replace(/(\..*)\./g,"$1"):parseFloat(n.replace(",",".")).toLocaleString("pt-BR",{style:"currency",currency:"BRL"}).replace("."," ")}const s=["=","!=","%","!%"],c=[{options:"=",label:"Igual a"},{options:"!=",label:"Diferente de"},{options:"<",label:"Menor do que"},{options:">",label:"Maior do que"},{options:"<=",label:"Menor ou igual a"},{options:">=",label:"Maior ou igual a"},{options:"{}",label:"Intervalo"},{options:"%",label:"Contém o que"},{options:"!%",label:"Não contém o que"}];function u(e){if(!e)return null;let t=e?.match(/(=|!=|<|>|<=|>=|%|!%|\{\})/),n=e.charAt(e.length-1),l=t?.[0];return t?.[0]!==n&&isNaN(parseInt(n))&&l?.slice(-1)!==n&&(l=t?.[0]+n),c.filter((e=>e.options===l))[0]?.label??null}function p(e){let t=u(e);if(null===t)return"Não encontramos legenda definida.";let n=e?.split("{}"),l=e?.split("/");const a=e=>{let t=parseInt(e[0]),n=parseInt(e[1],10),l=parseInt(e[2]);return`\n ${t>0?`${0==n?"dia":""} ${t}`:""} \n ${n>0?`${t>0?"de":""} ${r[n-1]?.name}`:""} \n ${l>0?`${t>0||n>0?"de":""} ${l}`:""}\n `.replace(/\s+/g," ").trim()};return t+": "+(void 0===n?.[1]?a(l):a(n[0].split("/"))+" à "+a(n[1].split("/")))}function d(e){let t=u(e);return null===t?"Não encontramos legenda definida.":t+": "+(e?.replace(/(=|!=|<|>|<=|>=|%|!%|\{\})/g,"")??"")}function m(e,t=[],n=30){let l=u(e);if(null===l||0===t.length)return"Não encontramos legenda definida.";let a=e?.split(";").map((e=>parseInt(e)))??[],i=t.filter((e=>a.includes(e.id))).map((e=>e.label)).join(", "),r=i.substring(0,n);return l+": "+r+(r.length!==i.length?"...":"")}const f=({children:t,...n})=>{const a={size:`box-size-${n.size??"100"}`,direction:`box-direction-${n.direction??"row"}`,justify:void 0===n.justify?"":Array.isArray(n.justify)?n.justify?.join(" "):n.justify,align:void 0===n.align?"":Array.isArray(n.align)?n.align?.join(" "):n.align},i={className:l(["box",n.className??"",a.size,a.direction,a.justify,a.align]),style:n.css,id:n.id};return e.createElement("div",{...i},t)};function g(e){const[t,n,l]=e,a=n>=1&&n<=12,i=l>0&&l<99999,r=t>=1&&t<=31;if(i&&!a&&!r)return[0,0,l];if(i&&a&&!r)return[0,n,l];if(i&&a&&r){let a=new Date(l,n,0);return a.getDate()<t?[a.getDate(),n,l]:e}return i||!a||r?!i&&a&&r?[t,n,0]:i||a||!r?i&&!a&&r?[t,0,l]:[0,0,0]:[t,0,0]:[0,n,0]}function h(e,t){let n=e,l=t.slice().reverse().find((e=>n?.endsWith(e)));return l&&void 0!==n?n.slice(0,-l.length):n??null}function b(e,t,n=null){let l=e,a=/(=|!=|<|>|<=|>=|\{\})/,i=e?.match(a),r=i?i[0].trim():t[0],o=[];return(l?.split("{}")??[]).forEach(((e,t)=>{let n=e.replace(a,"").trim();if(n.includes("/"))o[t]=n.split("/").map((e=>parseInt(e)));else{let e=parseInt(n);o[t]=[isNaN(e)?0:e]}for(;o[t].length<3;)o[t].unshift(0)})),o[1]&&"{}"===r?[...g(o[0]),n??r].concat(...g(o[1])):0===o.length?[0,0,0,r]:[...g(o[0]),n??r]}function v(e,t,n){null!==t&&(n[t]=parseInt(e));let l=n[3],a=n.slice(0,3);if(a=g(a),"{}"!==l)return`${a[0]}/${a[1]}/${a[2]}${l}`;let i=isNaN(parseInt(n[n.length-1]))&&null===t?[0,0,0]:n.slice(-3);return i=g(i),`${a[0]}/${a[1]}/${a[2]}${l}${i[0]}/${i[1]}/${i[2]}`}function N(e,t,n){let l=e?.split(";").map((e=>parseInt(e)))??[];return n.filter((e=>l.includes(e.id)))}function y(e,t){let n=e.map((e=>e.id));return 0===n.length?null:n.join(";")+t}function E(e,t){let n=e,l=t.slice().reverse().find((e=>n?.endsWith(e)));return o(l&&void 0!==n?n.slice(0,-l.length):n??"","decimal")}function $(t){return e.createElement("input",{className:"form-control input-filter-field",disabled:t.disabled,id:(t.id??"input-filter")+"-text",name:(t.name??"input-filter")+"-text",placeholder:t.placeholder,value:h(t.value,t.options)??"",onChange:e=>t.onChange(e.target.value+t.select)})}function C(t){let n=b(t.value,t.options,t.select);function l(e){"{}"===t.select&&"0/0/0{}0/0/0"===e?t.onChange(null):0!=n[0]&&!isNaN(n[0])||0!=n[1]&&!isNaN(n[1])||0!=n[2]&&!isNaN(n[2])?t.onChange(e):t.onChange(null)}return e.createElement("div",{className:"d-flex w-100 flex-column"},e.createElement("div",{className:"w-100 d-flex gap-2"},n.map(((a,i)=>{if(i<=2)return e.createElement("input",{className:"form-control input-filter-field-date"+(2==i?" year":""),disabled:t.disabled,id:(t.id??"input-filter")+"-"+i,key:i,name:(t.name??"input-filter")+"-"+i,placeholder:t.placeholder,value:0===a?"":a,onChange:e=>l(v(e.target.value,i,n))})}))),"{}"===t.select&&n.length>4&&e.createElement("div",{className:"w-100 d-flex gap-2 mt-2"},n.map(((a,i)=>{if(i>=4)return e.createElement("input",{className:"form-control input-filter-field-date"+(6==i?" year":""),disabled:t.disabled,id:(t.id??"input-filter")+"-"+i,key:i,name:(t.name??"input-filter")+"-"+i,placeholder:t.placeholder,value:0===a?"":a,onChange:e=>l(v(e.target.value,i,n))})}))))}const x=({iconPrefix:t="bi bi-",...n})=>n.label&&e.createElement("p",{className:"form-label"},n.icon&&e.createElement("i",{className:t+n.icon+" me-1"}),n.label,n.required&&e.createElement("span",{className:"text-danger"},"*"));function I(t){return e.createElement("input",{className:"form-control input-filter-field",disabled:t.disabled,id:(t.id??"input-filter")+"-number",name:(t.name??"input-filter")+"-number",placeholder:t.placeholder,value:E(t.value,t.options??""),onChange:e=>t.onChange(o(e.target.value,"decimal")+t.select)})}function j(t){const n=N(t.value,t.options,t.data);return e.createElement(a,{multiple:!0,completeMethod:e=>{let l=n.map((e=>e.id));t.onSearch(e.query,l)},appendTo:"self",className:"w-100",disabled:t.disabled,emptyMessage:"Não encontramos dados.",field:"label",id:(t.id??"input-filter")+"-autocomplete",inputClassName:"form-control",name:(t.name??"input-filter")+"-autocomplete",panelClassName:"input-filter-autocomplete-panel",placeholder:t.placeholder,required:t.required,scrollHeight:t.autocompleteScrollHeight,selectionLimit:t.autocompleteSelectLimit,suggestions:t.data,value:n,onChange:e=>t.onChange(y(e.value,t.select))})}function q({...a}){const i=(a.options??s).sort(((e,t)=>e.length-t.length)),r=c.filter((e=>i?.includes(e.options))),[o,u]=t(function(e,t){let n=t.filter((t=>e?.includes(t)));return n[n.length-1]??t[0]}(a.value,i));return n((()=>{if(a.type&&"text"!==a.type){if("date"===a.type){let e=b(a.value,i,o),t=v("0",null,e);"{}"===o&&"0/0/0{}0/0/0"===t||0==e[0]&&0==e[1]&&0==e[2]?a.onChange(null):a.onChange(t)}else if("autocomplete"===a.type){let e=N(a.value,0,a.data);a.onChange(y(e,o))}else if("number"===a.type){let e=E(a.value,i);""!==e?a.onChange(e+o):a.onChange(null)}}else{let e=h(a.value,i);null!==e?a.onChange(e+o):a.onChange(null)}}),[o]),e.createElement(f,{...a,className:l([a.className,"input-filter-container"])},e.createElement(x,{...a}),e.createElement("div",{className:"input-filter-content",id:a.id??"input-filter"},e.createElement("select",{className:"form-select input-filter-select",disabled:a.disabled,id:(a.id??"input-filter")+"-select",name:(a.name??"input-filter")+"-select",value:o,onChange:e=>u(e.target.value)},r?.map((t=>e.createElement("option",{key:t.options,value:t.options},t.label)))),(!a.type||"text"===a.type)&&e.createElement($,{...a,options:i,select:o}),"date"===a.type&&e.createElement(C,{...a,options:i,select:o}),"autocomplete"===a.type&&e.createElement(j,{...a,options:i,select:o}),"number"===a.type&&e.createElement(I,{...a,options:i,select:o})))}export{q as InputFilter,u as filterLegend,m as filterLegendAutocomplete,p as filterLegendData,d as filterLegendText};
2
+ //# sourceMappingURL=index.esm.js.map