@tech-diefra/fluig-ui 1.2.7 → 1.2.9
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/127996989.jpg +0 -0
- package/dist/Attachment/index.d.ts +11 -0
- package/dist/Carousel/index.d.ts +13 -0
- package/dist/Modal/index.d.ts +12 -0
- package/dist/SideBar/index.d.ts +6 -1
- package/dist/SimpleTable/index.d.ts +8 -1
- package/dist/diefra-logo-green.png +0 -0
- package/dist/diefra-logo-white.png +0 -0
- package/dist/diefra-logo.png +0 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +255 -257
- package/package.json +1 -1
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface AttachmentProps {
|
|
4
|
+
name: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
help?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
forceReadOnly?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare const _default: React.MemoExoticComponent<({ name, label, help, className, forceReadOnly, }: AttachmentProps) => import("react/jsx-runtime").JSX.Element>;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
export interface CarouselItem {
|
|
3
|
+
name: string;
|
|
4
|
+
url: string;
|
|
5
|
+
type?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface CarouselProps {
|
|
8
|
+
items: (CarouselItem | string)[];
|
|
9
|
+
time?: number;
|
|
10
|
+
showNavigation?: boolean;
|
|
11
|
+
progressBar?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function Carousel({ items, time, showNavigation, progressBar, }: CarouselProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface ModalProps {
|
|
4
|
+
title: string;
|
|
5
|
+
isOpen: boolean;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
content: React.ReactNode;
|
|
8
|
+
footer?: React.ReactNode;
|
|
9
|
+
onOpen?: () => void;
|
|
10
|
+
width?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function Modal({ title, isOpen, onOpen, onClose, content, footer, width, }: ModalProps): import("react/jsx-runtime").JSX.Element | null;
|
package/dist/SideBar/index.d.ts
CHANGED
|
@@ -3,18 +3,23 @@ import { default as React } from 'react';
|
|
|
3
3
|
interface ChildOptionsProps {
|
|
4
4
|
label: string;
|
|
5
5
|
action?: () => void;
|
|
6
|
+
id?: string;
|
|
6
7
|
}
|
|
7
8
|
interface ChildProps {
|
|
8
9
|
icon?: string;
|
|
9
10
|
label: string;
|
|
10
11
|
action?: () => void;
|
|
11
12
|
options?: ChildOptionsProps[];
|
|
13
|
+
id?: string;
|
|
12
14
|
}
|
|
13
15
|
interface SideBarProps {
|
|
14
16
|
logo?: string;
|
|
15
17
|
childs?: ChildProps[];
|
|
16
18
|
footer?: React.ReactNode;
|
|
17
19
|
contentExternal: React.ReactNode;
|
|
20
|
+
bg?: string;
|
|
21
|
+
color?: string;
|
|
22
|
+
onSelect?: (id?: string) => void;
|
|
18
23
|
}
|
|
19
|
-
export declare function SideBar({ logo, childs, footer, contentExternal, }: SideBarProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export declare function SideBar({ logo, childs, footer, contentExternal, bg, color, onSelect, }: SideBarProps): import("react/jsx-runtime").JSX.Element;
|
|
20
25
|
export {};
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
|
|
3
|
+
export type SimpleTableRenderProps = {
|
|
4
|
+
row: any;
|
|
5
|
+
index: number;
|
|
6
|
+
updateRow: (key: string, value: any) => void;
|
|
7
|
+
isLocked: boolean;
|
|
8
|
+
isView: boolean;
|
|
9
|
+
};
|
|
3
10
|
type SimpleTableColumn = {
|
|
4
11
|
key: string;
|
|
5
12
|
label: string;
|
|
6
13
|
width?: string | number;
|
|
7
|
-
render?: (
|
|
14
|
+
render?: (rowOrProps: any, index?: number, onChange?: (key: string, value: any) => void, isReadOnly?: boolean, isView?: boolean) => React.ReactNode;
|
|
8
15
|
};
|
|
9
16
|
type TableFilter = {
|
|
10
17
|
field: string;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),u=require("react"),M=require("react-hook-form"),X=require("react-imask"),P=require("@fluig-kit/ecm"),L=require("react-datepicker"),H=require("date-fns"),Y={cpf:"000.000.000-00",cnpj:"00.000.000/0000-00",telefone:"(00) 00000-0000",cep:"00000-000"};function Q({name:e,label:s="",placeholder:n="",type:l="text",mask:o,className:c="",forceReadOnly:i=!1,forceHidden:d=!1}){const{isReadOnly:w,isHidden:h}=P.useSection(),j=i||!!w(e),v=d||!!h(e),{control:C}=M.useFormContext(),{isView:R}=P.useFluigRuntime(),{field:x}=M.useController({name:e,control:C}),{errors:y}=M.useFormState({name:e}),b=y==null?void 0:y[e],k=u.useMemo(()=>o?Y[o]??o:null,[o]),N=u.useCallback(a=>{if(!a)return"";const r=a.replace(/\D/g,"");return(Number(r)/100).toLocaleString("pt-BR",{style:"currency",currency:"BRL"})},[]),f=u.useCallback(a=>l==="monetary"?N(a):a,[l,N]);return R?t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:s}),t.jsx("span",{className:"form-control",children:x.value||"-"})]}):t.jsxs("div",{className:`form-group ${v?"hidden":""}`,children:[t.jsx("label",{children:s}),k?t.jsx(X.IMaskInput,{name:e,mask:k,value:String(x.value??""),unmask:!1,onAccept:a=>x.onChange(f(a)),placeholder:n,readOnly:j,className:`form-control ${b?"border-red":""} ${c}`,inputRef:x.ref,onBlur:x.onBlur}):t.jsx("input",{...x,type:"text",value:x.value??"",onChange:a=>x.onChange(f(a.target.value)),placeholder:n,readOnly:j,className:`form-control ${b?"border-red":""} ${c}`}),b&&t.jsx("p",{className:"text-danger",children:String(b.message)})]})}const J=u.memo(Q);function U({name:e,label:s="",options:n=[],placeholder:l="",labelKey:o="label",valueKey:c="value",enableSearch:i=!1,searchPlaceholder:d="Buscar...",loading:w=!1,onSearchChange:h,debounceTime:j=300,onSelect:v,forceReadOnly:C=!1,forceHidden:R=!1}){const{isReadOnly:x,isHidden:y}=P.useSection(),b=C||!!x(e),k=R||!!y(e),{control:N,clearErrors:f}=M.useFormContext(),{isView:a}=P.useFluigRuntime(),{field:{onChange:r,value:m,ref:O},fieldState:{error:g}}=M.useController({name:e,control:N}),[S,$]=u.useState(!1),[V,E]=u.useState(""),T=u.useRef(null),q=u.useRef(h);u.useEffect(()=>{q.current=h},[h]),u.useEffect(()=>{const p=F=>{T.current&&!T.current.contains(F.target)&&$(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[]),u.useEffect(()=>{S||E("")},[S]),u.useEffect(()=>{if(!i)return;const p=setTimeout(()=>{q.current&&q.current(V)},j);return()=>clearTimeout(p)},[V,i,j]);const B=u.useMemo(()=>i&&!h&&V.trim()?n.filter(p=>String((p==null?void 0:p[o])??"").toLowerCase().includes(V.toLowerCase())):n??[],[n,i,h,V,o]),I=u.useMemo(()=>{if(m==null)return"";if(typeof m=="object")return String(m[c]??"");const p=(n||[]).find(F=>String(F==null?void 0:F[c])===String(m));return String(p?(p==null?void 0:p[o])??"":m)},[m,n,c,o]),z=p=>{b||(r(p[c]),v&&v(p),f(e),$(!1))};return t.jsxs("div",{className:`select-wrapper form-group ${k?"hidden":""}`,ref:T,children:[t.jsx("label",{className:"control-label",children:s}),a?t.jsx("span",{className:"form-control",children:I||"-"}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`select-control ${g?"border-red":""} ${b?"readOnly":""}`,onClick:()=>!b&&$(p=>!p),ref:O,children:[t.jsx("span",{className:`select-display ${b?"readOnly":""}`,children:I||l}),t.jsx("i",{className:"flaticon flaticon-chevron-down select-icon"})]}),S&&!b&&t.jsxs("div",{className:"select-dropdown",children:[i&&t.jsx("div",{className:"select-search",children:t.jsx("input",{type:"text",className:"select-search-input",value:V,onChange:p=>E(p.target.value),placeholder:w?"Carregando...":d,autoFocus:!0,onClick:p=>p.stopPropagation()})}),t.jsx("ul",{className:"select-options",children:w?t.jsx("li",{className:"select-option readOnly",children:"Carregando..."}):B.length>0?B.map(p=>t.jsx("li",{onClick:()=>z(p),className:"select-option handleHover",children:p[o]},p[c])):t.jsx("li",{className:"select-option readOnly",children:"Sem resultados"})})]})]}),t.jsx("input",{type:"hidden",name:e,value:m||""}),g&&t.jsx("p",{className:"text-danger",children:String(g.message)})]})}const G=u.memo(U);function Z({name:e,options:s=[],label:n="",valueKey:l="value",labelKey:o="label",forceReadOnly:c=!1,forceHidden:i=!1}){var m,O;const d=M.useFormContext(),{isView:w,isReadOnly:h}=P.useFluigRuntime(),{isReadOnly:j,isHidden:v}=P.useSection(),C=j?j(e):!1,R=v?v(e):!1,x=c||C,y=i||R,b=x||h||w;if(!d||!e)return console.error("Checkbox requer contexto de formulário e nome."),null;const k=()=>!s||!d?{}:s.reduce((g,S)=>{const $=S[l],V=d.getValues($);return g[$]=V==="on",g},{}),N=d.watch(e),f=u.useMemo(()=>N&&typeof N=="object"?N:k(),[N,s,l]);u.useEffect(()=>{const g=d.getValues(e);(!g||typeof g!="object")&&d.setValue(e,f,{shouldDirty:!1,shouldValidate:!1})},[f,e,d]);const a=(g,S)=>{if(b)return;const $={...f,[g]:S};d.setValue(e,$,{shouldDirty:!0,shouldValidate:!0}),d.setValue(g,S?"on":"",{shouldValidate:!1})},r=(O=(m=d.formState)==null?void 0:m.errors)==null?void 0:O[e];return t.jsxs("div",{className:`form-group ${y?"hidden":""}`,children:[n&&t.jsx("label",{children:n}),t.jsx("div",{className:`checkbox-group-custom ${b?"readOnly":""}`,children:s.map(g=>{const S=String(g[l]),$=f[S]===!0;return t.jsxs("div",{children:[t.jsx("input",{type:"hidden",...d.register(S)}),t.jsxs("label",{className:`custom-checkbox ${$?"checked":""} ${b?"readOnly":""}`,children:[t.jsx("input",{type:"checkbox",checked:$,disabled:b,onChange:V=>a(S,V.target.checked)}),t.jsx("span",{className:"checkmark"}),t.jsx("span",{children:g[o]})]})]},S)})}),r&&t.jsx("p",{className:"text-danger",children:String(r.message)})]})}function K({name:e,label:s="",options:n=[],valueKey:l="value",labelKey:o="label",iconKey:c="icon",forceReadOnly:i=!1,forceHidden:d=!1}){const{isReadOnly:w,isHidden:h}=P.useSection(),j=i||!!w(e),v=d||!!h(e),{control:C}=M.useFormContext(),{isView:R,isReadOnly:x}=P.useFluigRuntime(),{field:y,fieldState:{error:b}}=M.useController({name:e,control:C}),k=j||x||R,N=y.value??"",f=u.useCallback(a=>{k||y.onChange(a)},[k,y]);return t.jsxs("div",{className:`form-group column ${v?"hidden":""}`,children:[s&&t.jsx("label",{className:"control-label",children:s}),t.jsx("div",{className:`btn-group ${k?"view-mode":""}`,"data-field-name":e,children:n.map(a=>{const r=a[l],m=N===r,O=a.color?{"--customColor":a.color}:void 0;return t.jsxs("label",{htmlFor:`${e}_${r}`,style:O,className:`btn fs-ellipsis ${m?"active":""}`,children:[t.jsx("input",{type:"radio",id:`${e}_${r}`,name:e,value:r,checked:m,className:"hidden",onChange:()=>f(r),disabled:k}),a[c]&&t.jsx("i",{className:`${a[c]} icon-sm`})," ",a[o]]},r)})}),b&&t.jsx("p",{className:"text-danger",children:String(b.message)})]})}const ee=u.memo(K),te=({name:e,label:s="",placeholder:n="",className:l="",rows:o=4,maxLength:c,forceReadOnly:i=!1,forceHidden:d=!1})=>{const{isReadOnly:w,isHidden:h}=P.useSection(),j=i||!!w(e),v=d||!!h(e),{control:C}=M.useFormContext(),{isView:R}=P.useFluigRuntime(),{field:x,fieldState:{error:y}}=M.useController({name:e,control:C});return R?t.jsxs("div",{className:`form-group ${v?"hidden":""}`,children:[t.jsx("label",{children:s}),t.jsx("span",{className:"form-control",children:x.value||"-"})]}):t.jsxs("div",{className:`form-group ${v?"hidden":""}`,children:[t.jsx("label",{children:s}),t.jsx("textarea",{...x,rows:o,maxLength:c,value:x.value||"",placeholder:n,readOnly:j,className:`form-control ${y?"border-red":""} ${l}`}),y&&t.jsx("p",{className:"text-danger",children:String(y.message)})]})},ne=u.memo(te);function A(e){return(s={})=>{const n=s.width?String(s.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}function W(e){return(s,n)=>{const l=n!=null&&n.context?String(n.context):"standalone";let o;if(l==="formatting"&&e.formattingValues){const i=e.defaultFormattingWidth||e.defaultWidth,d=n!=null&&n.width?String(n.width):i;o=e.formattingValues[d]||e.formattingValues[i]}else{const i=e.defaultWidth,d=n!=null&&n.width?String(n.width):e.defaultWidth;o=e.values[d]||e.values[i]}const c=e.argumentCallback?e.argumentCallback(s):s;return o[c]}}function D(e){return(s,n={})=>{const l=n.width,o=l&&e.matchPatterns[l]||e.matchPatterns[e.defaultMatchWidth],c=s.match(o);if(!c)return null;const i=c[0],d=l&&e.parsePatterns[l]||e.parsePatterns[e.defaultParseWidth],w=Array.isArray(d)?se(d,v=>v.test(i)):ae(d,v=>v.test(i));let h;h=e.valueCallback?e.valueCallback(w):w,h=n.valueCallback?n.valueCallback(h):h;const j=s.slice(i.length);return{value:h,rest:j}}}function ae(e,s){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&s(e[n]))return n}function se(e,s){for(let n=0;n<e.length;n++)if(s(e[n]))return n}function re(e){return(s,n={})=>{const l=s.match(e.matchPattern);if(!l)return null;const o=l[0],c=s.match(e.parsePattern);if(!c)return null;let i=e.valueCallback?e.valueCallback(c[0]):c[0];i=n.valueCallback?n.valueCallback(i):i;const d=s.slice(o.length);return{value:i,rest:d}}}const oe={lessThanXSeconds:{one:"menos de um segundo",other:"menos de {{count}} segundos"},xSeconds:{one:"1 segundo",other:"{{count}} segundos"},halfAMinute:"meio minuto",lessThanXMinutes:{one:"menos de um minuto",other:"menos de {{count}} minutos"},xMinutes:{one:"1 minuto",other:"{{count}} minutos"},aboutXHours:{one:"cerca de 1 hora",other:"cerca de {{count}} horas"},xHours:{one:"1 hora",other:"{{count}} horas"},xDays:{one:"1 dia",other:"{{count}} dias"},aboutXWeeks:{one:"cerca de 1 semana",other:"cerca de {{count}} semanas"},xWeeks:{one:"1 semana",other:"{{count}} semanas"},aboutXMonths:{one:"cerca de 1 mês",other:"cerca de {{count}} meses"},xMonths:{one:"1 mês",other:"{{count}} meses"},aboutXYears:{one:"cerca de 1 ano",other:"cerca de {{count}} anos"},xYears:{one:"1 ano",other:"{{count}} anos"},overXYears:{one:"mais de 1 ano",other:"mais de {{count}} anos"},almostXYears:{one:"quase 1 ano",other:"quase {{count}} anos"}},ie=(e,s,n)=>{let l;const o=oe[e];return typeof o=="string"?l=o:s===1?l=o.one:l=o.other.replace("{{count}}",String(s)),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"em "+l:"há "+l:l},de={full:"EEEE, d 'de' MMMM 'de' y",long:"d 'de' MMMM 'de' y",medium:"d MMM y",short:"dd/MM/yyyy"},le={full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},ce={full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ue={date:A({formats:de,defaultWidth:"full"}),time:A({formats:le,defaultWidth:"full"}),dateTime:A({formats:ce,defaultWidth:"full"})},me={lastWeek:e=>{const s=e.getDay();return"'"+(s===0||s===6?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},he=(e,s,n,l)=>{const o=me[e];return typeof o=="function"?o(s):o},fe={narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},ge={narrow:["1","2","3","4"],abbreviated:["T1","T2","T3","T4"],wide:["1º trimestre","2º trimestre","3º trimestre","4º trimestre"]},xe={narrow:["j","f","m","a","m","j","j","a","s","o","n","d"],abbreviated:["jan","fev","mar","abr","mai","jun","jul","ago","set","out","nov","dez"],wide:["janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"]},be={narrow:["D","S","T","Q","Q","S","S"],short:["dom","seg","ter","qua","qui","sex","sab"],abbreviated:["domingo","segunda","terça","quarta","quinta","sexta","sábado"],wide:["domingo","segunda-feira","terça-feira","quarta-feira","quinta-feira","sexta-feira","sábado"]},pe={narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"},abbreviated:{am:"AM",pm:"PM",midnight:"meia-noite",noon:"meio-dia",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"},wide:{am:"a.m.",pm:"p.m.",midnight:"meia-noite",noon:"meio-dia",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"}},ye={narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"},abbreviated:{am:"AM",pm:"PM",midnight:"meia-noite",noon:"meio-dia",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"},wide:{am:"a.m.",pm:"p.m.",midnight:"meia-noite",noon:"meio-dia",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"}},je=(e,s)=>{const n=Number(e);return(s==null?void 0:s.unit)==="week"?n+"ª":n+"º"},ve={ordinalNumber:je,era:W({values:fe,defaultWidth:"wide"}),quarter:W({values:ge,defaultWidth:"wide",argumentCallback:e=>e-1}),month:W({values:xe,defaultWidth:"wide"}),day:W({values:be,defaultWidth:"wide"}),dayPeriod:W({values:pe,defaultWidth:"wide",formattingValues:ye,defaultFormattingWidth:"wide"})},we=/^(\d+)[ºªo]?/i,Ce=/\d+/i,ke={narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|d\.?\s?c\.?)/i,wide:/^(antes de cristo|depois de cristo)/i},Ne={any:[/^ac/i,/^dc/i],wide:[/^antes de cristo/i,/^depois de cristo/i]},Se={narrow:/^[1234]/i,abbreviated:/^T[1234]/i,wide:/^[1234](º)? trimestre/i},Re={any:[/1/i,/2/i,/3/i,/4/i]},Pe={narrow:/^[jfmajsond]/i,abbreviated:/^(jan|fev|mar|abr|mai|jun|jul|ago|set|out|nov|dez)/i,wide:/^(janeiro|fevereiro|março|abril|maio|junho|julho|agosto|setembro|outubro|novembro|dezembro)/i},Me={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^fev/i,/^mar/i,/^abr/i,/^mai/i,/^jun/i,/^jul/i,/^ago/i,/^set/i,/^out/i,/^nov/i,/^dez/i]},Oe={narrow:/^(dom|[23456]ª?|s[aá]b)/i,short:/^(dom|[23456]ª?|s[aá]b)/i,abbreviated:/^(dom|seg|ter|qua|qui|sex|s[aá]b)/i,wide:/^(domingo|(segunda|ter[cç]a|quarta|quinta|sexta)([- ]feira)?|s[aá]bado)/i},$e={short:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],narrow:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],any:[/^d/i,/^seg/i,/^t/i,/^qua/i,/^qui/i,/^sex/i,/^s[aá]b/i]},Ve={narrow:/^(a|p|mn|md|(da) (manhã|tarde|noite))/i,any:/^([ap]\.?\s?m\.?|meia[-\s]noite|meio[-\s]dia|(da) (manhã|tarde|noite))/i},Fe={any:{am:/^a/i,pm:/^p/i,midnight:/^mn|^meia[-\s]noite/i,noon:/^md|^meio[-\s]dia/i,morning:/manhã/i,afternoon:/tarde/i,evening:/tarde/i,night:/noite/i}},We={ordinalNumber:re({matchPattern:we,parsePattern:Ce,valueCallback:e=>parseInt(e,10)}),era:D({matchPatterns:ke,defaultMatchWidth:"wide",parsePatterns:Ne,defaultParseWidth:"any"}),quarter:D({matchPatterns:Se,defaultMatchWidth:"wide",parsePatterns:Re,defaultParseWidth:"any",valueCallback:e=>e+1}),month:D({matchPatterns:Pe,defaultMatchWidth:"wide",parsePatterns:Me,defaultParseWidth:"any"}),day:D({matchPatterns:Oe,defaultMatchWidth:"wide",parsePatterns:$e,defaultParseWidth:"any"}),dayPeriod:D({matchPatterns:Ve,defaultMatchWidth:"any",parsePatterns:Fe,defaultParseWidth:"any"})},De={code:"pt-BR",formatDistance:ie,formatLong:ue,formatRelative:he,localize:ve,match:We,options:{weekStartsOn:0,firstWeekContainsDate:1}};L.registerLocale("pt-BR",De);const _="dd/MM/yyyy",Te=e=>{if(!e)return null;const s=H.parse(e,_,new Date);return H.isValid(s)?s:null},qe=e=>e?H.format(e,_):"",Ae=u.forwardRef(({shimRef:e,className:s,name:n,...l},o)=>t.jsx("input",{name:n,...l,className:s,ref:c=>{typeof o=="function"?o(c):o&&(o.current=c),e&&e(c)}})),He=({name:e,label:s="",placeholder:n="dd/mm/aaaa",className:l="",forceReadOnly:o=!1,forceHidden:c=!1})=>{const{control:i}=M.useFormContext(),{isView:d}=P.useFluigRuntime(),{isReadOnly:w,isHidden:h}=P.useSection(),j=o||!!w(e),v=c||!!h(e),{field:{onChange:C,onBlur:R,value:x,ref:y},fieldState:{error:b}}=M.useController({name:e,control:i}),k=u.useMemo(()=>Te(x),[x]),N=u.useCallback(a=>{C(a?qe(a):"")},[C]),f=u.useCallback(a=>{var r,m;if(y(a),a&&((m=(r=i._fields)==null?void 0:r[e])!=null&&m._f)){const O=i._fields[e];O._f.ref={focus:()=>{var g;return(g=a.focus)==null?void 0:g.call(a)},select:()=>{var g;return(g=a.select)==null?void 0:g.call(a)},setCustomValidity:g=>{var S;return(S=a.setCustomValidity)==null?void 0:S.call(a,g)},reportValidity:()=>{var g;return(g=a.reportValidity)==null?void 0:g.call(a)}}}},[y,i,e]);return v?null:d?t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:s}),t.jsx("span",{className:"form-control",children:x||"-"})]}):t.jsxs("div",{className:`form-group fluig-style-guide ${l}`,children:[s&&t.jsx("label",{className:"control-label",htmlFor:e,children:s}),t.jsx("div",{className:`${b?"border-red":""}`,children:t.jsx(L,{id:e,name:e,selected:k,onChange:N,onBlur:R,dateFormat:_,placeholderText:n,disabled:j,readOnly:j,locale:"pt-BR",className:`form-control ${b?"border-red":""}`,wrapperClassName:"w-100",showMonthDropdown:!0,showYearDropdown:!0,dropdownMode:"select",isClearable:!j&&!!x,autoComplete:"off",customInput:t.jsx(Ae,{name:e,shimRef:f})})}),b&&t.jsx("span",{className:"help-block text-danger",children:String(b.message)})]})},_e=u.memo(He);function Ee({mapping:e={},defaultLabel:s="Não reconhecido",className:n="",hidden:l=!1,label:o}){const{activityId:c}=P.useFluigRuntime(),i=u.useMemo(()=>!e||c===null||c===void 0?null:e[c],[c,e]);if(!i)return t.jsxs("div",{className:`form-group ${l?"hidden":""}`,children:[o&&t.jsx("label",{children:o}),t.jsx("div",{className:`status-badge default ${n}`,children:s})]});const d={"--customColor":i.color};return t.jsxs("div",{className:`form-group ${l?"hidden":""}`,children:[o&&t.jsx("label",{children:o}),t.jsxs("div",{className:`status-badge ${n}`,style:d,children:[i.icon&&t.jsx("i",{className:i.icon}),t.jsx("span",{children:i.label})]})]})}const Be=u.memo(Ee);function Ie({name:e,control:s,defaultRowValue:n,isView:l,isReadOnly:o,filters:c=[]}){const{field:i}=M.useController({name:e,control:s}),[d,w]=u.useState([]),[h,j]=u.useState([]),v=()=>Date.now()+Math.random(),C=a=>{try{const r=JSON.parse(a);return Array.isArray(r)?r.map(m=>({...m,_uid:m._uid||v()})):[]}catch(r){return console.error(`Erro ao ler dados da tabela "${e}":`,r),[]}};u.useEffect(()=>{if(!(d.length>0&&!l)&&i.value&&typeof i.value=="string"){const a=JSON.stringify(d);if(i.value===a)return;const r=C(i.value);w(r)}},[i.value,l]),u.useEffect(()=>{if(o)return;const a=JSON.stringify(d);i.value!==a&&i.onChange(a)},[d,i,o]);const R=u.useCallback(()=>{const a={_uid:v(),...n};w(r=>[...r,a])},[n]),x=u.useCallback(()=>{w(a=>a.filter(r=>!h.includes(r._uid))),j([])},[h]),y=u.useCallback((a,r,m)=>{w(O=>O.map(g=>g._uid===a?{...g,[r]:m}:g))},[]),b=u.useCallback(a=>{j(r=>r.includes(a)?r.filter(m=>m!==a):[...r,a])},[]),k=u.useCallback(a=>{j(a?d.map(r=>r._uid):[])},[d]),N=d.length>0&&h.length===d.length,f=u.useMemo(()=>!c||c.length===0?d:d.filter(a=>c.every(r=>{if("custom"in r)return r.custom(a);const m=a[r.field];switch(r.operator){case"===":return m===r.value;case"!==":return m!==r.value;case">":return m>r.value;case"<":return m<r.value;case">=":return m>=r.value;case"<=":return m<=r.value;default:return!0}})),[d,c]);return{field:i,tableRows:d,visibleRows:f,selectedRowIds:h,isAllSelected:N,handle:{addRow:R,removeRows:x,updateCellValue:y,toggleSelection:b,toggleSelectAll:k}}}const Le=({name:e,title:s="Tabela Dinâmica",columns:n,defaultRowValue:l={},forceReadOnly:o=!1,layout:c="fluid",actions:i=!0,filters:d=[]})=>{const{control:w}=M.useFormContext(),{isView:h,isReadOnly:j}=P.useFluigRuntime(),{isReadOnly:v}=P.useSection(),C=o||h||j||v&&v(e),{field:R,visibleRows:x,selectedRowIds:y,isAllSelected:b,handle:k}=Ie({name:e,control:w,defaultRowValue:l,isView:h,isReadOnly:!!C,filters:d}),N=c==="fixed";return t.jsxs("div",{className:`table-wrapper ${N?"table-fixed":"table-fluid"}`,children:[t.jsx("input",{type:"hidden",...R}),i&&t.jsxs("div",{className:"header-handle",children:[t.jsx("h3",{children:s}),!C&&t.jsxs("div",{className:"handle-actions",children:[t.jsxs("button",{type:"button",className:`btn ${y.length>0?"btn-danger":""}`,disabled:y.length===0,onClick:k.removeRows,children:["Remover (",y.length,")"]}),t.jsx("button",{type:"button",className:"btn-add",onClick:k.addRow,children:"Adicionar"})]})]}),t.jsx("div",{className:"table-scroll",children:t.jsxs("table",{className:"table-custom",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[!C&&t.jsx("th",{style:{width:"50px"},children:t.jsx("input",{type:"checkbox",checked:b,onChange:f=>k.toggleSelectAll(f.target.checked)})}),n.map(f=>t.jsx("th",{style:!f.width||x.length===0?{width:"max-content"}:{minWidth:N?f.width:"100%"},children:f.label},f.key))]})}),t.jsx("div",{}),t.jsxs("tbody",{children:[x.map((f,a)=>t.jsxs("tr",{children:[!C&&t.jsx("td",{children:t.jsx("input",{type:"checkbox",checked:y.includes(f._uid),onChange:()=>k.toggleSelection(f._uid)})}),n.map(r=>t.jsx("td",{children:r.render?r.render(f,a,(m,O)=>k.updateCellValue(f._uid,m,O),!!C,!!h):f[r.key]},`${f._uid}-${r.key}`))]},f._uid)),x.length===0&&t.jsx("tr",{className:"empty-row",children:t.jsx("td",{colSpan:100,className:"text-center",children:C?"Nenhum registro encontrado.":"Nenhum registro."})})]})]})})]})};exports.Checkbox=Z;exports.DatePicker=_e;exports.Input=J;exports.RadioBtn=ee;exports.Select=G;exports.SimpleTable=Le;exports.StatusBadge=Be;exports.TextArea=ne;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),u=require("react"),O=require("react-hook-form"),X=require("react-imask"),P=require("@fluig-kit/ecm"),I=require("react-datepicker"),H=require("date-fns"),Y={cpf:"000.000.000-00",cnpj:"00.000.000/0000-00",telefone:"(00) 00000-0000",cep:"00000-000"};function Q({name:e,label:s="",placeholder:n="",type:l="text",mask:o,className:c="",forceReadOnly:i=!1,forceHidden:d=!1}){const{isReadOnly:w,isHidden:f}=P.useSection(),j=i||!!w(e),v=d||!!f(e),{control:C}=O.useFormContext(),{isView:R}=P.useFluigRuntime(),{field:x}=O.useController({name:e,control:C}),{errors:y}=O.useFormState({name:e}),b=y==null?void 0:y[e],k=u.useMemo(()=>o?Y[o]??o:null,[o]),N=u.useCallback(a=>{if(!a)return"";const r=a.replace(/\D/g,"");return(Number(r)/100).toLocaleString("pt-BR",{style:"currency",currency:"BRL"})},[]),h=u.useCallback(a=>l==="monetary"?N(a):a,[l,N]);return R?t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:s}),t.jsx("span",{className:"form-control",children:x.value||"-"})]}):t.jsxs("div",{className:`form-group ${v?"hidden":""}`,children:[t.jsx("label",{children:s}),k?t.jsx(X.IMaskInput,{name:e,mask:k,value:String(x.value??""),unmask:!1,onAccept:a=>x.onChange(h(a)),placeholder:n,readOnly:j,className:`form-control ${b?"border-red":""} ${c}`,inputRef:x.ref,onBlur:x.onBlur}):t.jsx("input",{...x,type:"text",value:x.value??"",onChange:a=>x.onChange(h(a.target.value)),placeholder:n,readOnly:j,className:`form-control ${b?"border-red":""} ${c}`}),b&&t.jsx("p",{className:"text-danger",children:String(b.message)})]})}const J=u.memo(Q);function U({name:e,label:s="",options:n=[],placeholder:l="",labelKey:o="label",valueKey:c="value",enableSearch:i=!1,searchPlaceholder:d="Buscar...",loading:w=!1,onSearchChange:f,debounceTime:j=300,onSelect:v,forceReadOnly:C=!1,forceHidden:R=!1}){const{isReadOnly:x,isHidden:y}=P.useSection(),b=C||!!x(e),k=R||!!y(e),{control:N,clearErrors:h}=O.useFormContext(),{isView:a}=P.useFluigRuntime(),{field:{onChange:r,value:m,ref:M},fieldState:{error:g}}=O.useController({name:e,control:N}),[S,$]=u.useState(!1),[V,E]=u.useState(""),T=u.useRef(null),q=u.useRef(f);u.useEffect(()=>{q.current=f},[f]),u.useEffect(()=>{const p=F=>{T.current&&!T.current.contains(F.target)&&$(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[]),u.useEffect(()=>{S||E("")},[S]),u.useEffect(()=>{if(!i)return;const p=setTimeout(()=>{q.current&&q.current(V)},j);return()=>clearTimeout(p)},[V,i,j]);const L=u.useMemo(()=>i&&!f&&V.trim()?n.filter(p=>String((p==null?void 0:p[o])??"").toLowerCase().includes(V.toLowerCase())):n??[],[n,i,f,V,o]),B=u.useMemo(()=>{if(m==null)return"";if(typeof m=="object")return String(m[c]??"");const p=(n||[]).find(F=>String(F==null?void 0:F[c])===String(m));return String(p?(p==null?void 0:p[o])??"":m)},[m,n,c,o]),z=p=>{b||(r(p[c]),v&&v(p),h(e),$(!1))};return t.jsxs("div",{className:`select-wrapper form-group ${k?"hidden":""}`,ref:T,children:[t.jsx("label",{className:"control-label",children:s}),a?t.jsx("span",{className:"form-control",children:B||"-"}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`select-control ${g?"border-red":""} ${b?"readOnly":""}`,onClick:()=>!b&&$(p=>!p),ref:M,children:[t.jsx("span",{className:`select-display ${b?"readOnly":""}`,children:B||l}),t.jsx("i",{className:"flaticon flaticon-chevron-down select-icon"})]}),S&&!b&&t.jsxs("div",{className:"select-dropdown",children:[i&&t.jsx("div",{className:"select-search",children:t.jsx("input",{type:"text",className:"select-search-input",value:V,onChange:p=>E(p.target.value),placeholder:w?"Carregando...":d,autoFocus:!0,onClick:p=>p.stopPropagation()})}),t.jsx("ul",{className:"select-options",children:w?t.jsx("li",{className:"select-option readOnly",children:"Carregando..."}):L.length>0?L.map(p=>t.jsx("li",{onClick:()=>z(p),className:"select-option handleHover",children:p[o]},p[c])):t.jsx("li",{className:"select-option readOnly",children:"Sem resultados"})})]})]}),t.jsx("input",{type:"hidden",name:e,value:m||""}),g&&t.jsx("p",{className:"text-danger",children:String(g.message)})]})}const G=u.memo(U);function Z({name:e,options:s=[],label:n="",valueKey:l="value",labelKey:o="label",forceReadOnly:c=!1,forceHidden:i=!1}){var m,M;const d=O.useFormContext(),{isView:w,isReadOnly:f}=P.useFluigRuntime(),{isReadOnly:j,isHidden:v}=P.useSection(),C=j?j(e):!1,R=v?v(e):!1,x=c||C,y=i||R,b=x||f||w;if(!d||!e)return console.error("Checkbox requer contexto de formulário e nome."),null;const k=()=>!s||!d?{}:s.reduce((g,S)=>{const $=S[l],V=d.getValues($);return g[$]=V==="on",g},{}),N=d.watch(e),h=u.useMemo(()=>N&&typeof N=="object"?N:k(),[N,s,l]);u.useEffect(()=>{const g=d.getValues(e);(!g||typeof g!="object")&&d.setValue(e,h,{shouldDirty:!1,shouldValidate:!1})},[h,e,d]);const a=(g,S)=>{if(b)return;const $={...h,[g]:S};d.setValue(e,$,{shouldDirty:!0,shouldValidate:!0}),d.setValue(g,S?"on":"",{shouldValidate:!1})},r=(M=(m=d.formState)==null?void 0:m.errors)==null?void 0:M[e];return t.jsxs("div",{className:`form-group ${y?"hidden":""}`,children:[n&&t.jsx("label",{children:n}),t.jsx("div",{className:`checkbox-group-custom ${b?"readOnly":""}`,children:s.map(g=>{const S=String(g[l]),$=h[S]===!0;return t.jsxs("div",{children:[t.jsx("input",{type:"hidden",...d.register(S)}),t.jsxs("label",{className:`custom-checkbox ${$?"checked":""} ${b?"readOnly":""}`,children:[t.jsx("input",{type:"checkbox",checked:$,disabled:b,onChange:V=>a(S,V.target.checked)}),t.jsx("span",{className:"checkmark"}),t.jsx("span",{children:g[o]})]})]},S)})}),r&&t.jsx("p",{className:"text-danger",children:String(r.message)})]})}function K({name:e,label:s="",options:n=[],valueKey:l="value",labelKey:o="label",iconKey:c="icon",forceReadOnly:i=!1,forceHidden:d=!1}){const{isReadOnly:w,isHidden:f}=P.useSection(),j=i||!!w(e),v=d||!!f(e),{control:C}=O.useFormContext(),{isView:R,isReadOnly:x}=P.useFluigRuntime(),{field:y,fieldState:{error:b}}=O.useController({name:e,control:C}),k=j||x||R,N=y.value??"",h=u.useCallback(a=>{k||y.onChange(a)},[k,y]);return t.jsxs("div",{className:`form-group column ${v?"hidden":""}`,children:[s&&t.jsx("label",{className:"control-label",children:s}),t.jsx("div",{className:`btn-group ${k?"view-mode":""}`,"data-field-name":e,children:n.map(a=>{const r=a[l],m=N===r,M=a.color?{"--customColor":a.color}:void 0;return t.jsxs("label",{htmlFor:`${e}_${r}`,style:M,className:`btn fs-ellipsis ${m?"active":""}`,children:[t.jsx("input",{type:"radio",id:`${e}_${r}`,name:e,value:r,checked:m,className:"hidden",onChange:()=>h(r),disabled:k}),a[c]&&t.jsx("i",{className:`${a[c]} icon-sm`})," ",a[o]]},r)})}),b&&t.jsx("p",{className:"text-danger",children:String(b.message)})]})}const ee=u.memo(K),te=({name:e,label:s="",placeholder:n="",className:l="",rows:o=4,maxLength:c,forceReadOnly:i=!1,forceHidden:d=!1})=>{const{isReadOnly:w,isHidden:f}=P.useSection(),j=i||!!w(e),v=d||!!f(e),{control:C}=O.useFormContext(),{isView:R}=P.useFluigRuntime(),{field:x,fieldState:{error:y}}=O.useController({name:e,control:C});return R?t.jsxs("div",{className:`form-group ${v?"hidden":""}`,children:[t.jsx("label",{children:s}),t.jsx("span",{className:"form-control",children:x.value||"-"})]}):t.jsxs("div",{className:`form-group ${v?"hidden":""}`,children:[t.jsx("label",{children:s}),t.jsx("textarea",{...x,rows:o,maxLength:c,value:x.value||"",placeholder:n,readOnly:j,className:`form-control ${y?"border-red":""} ${l}`}),y&&t.jsx("p",{className:"text-danger",children:String(y.message)})]})},ne=u.memo(te);function A(e){return(s={})=>{const n=s.width?String(s.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}function W(e){return(s,n)=>{const l=n!=null&&n.context?String(n.context):"standalone";let o;if(l==="formatting"&&e.formattingValues){const i=e.defaultFormattingWidth||e.defaultWidth,d=n!=null&&n.width?String(n.width):i;o=e.formattingValues[d]||e.formattingValues[i]}else{const i=e.defaultWidth,d=n!=null&&n.width?String(n.width):e.defaultWidth;o=e.values[d]||e.values[i]}const c=e.argumentCallback?e.argumentCallback(s):s;return o[c]}}function D(e){return(s,n={})=>{const l=n.width,o=l&&e.matchPatterns[l]||e.matchPatterns[e.defaultMatchWidth],c=s.match(o);if(!c)return null;const i=c[0],d=l&&e.parsePatterns[l]||e.parsePatterns[e.defaultParseWidth],w=Array.isArray(d)?se(d,v=>v.test(i)):ae(d,v=>v.test(i));let f;f=e.valueCallback?e.valueCallback(w):w,f=n.valueCallback?n.valueCallback(f):f;const j=s.slice(i.length);return{value:f,rest:j}}}function ae(e,s){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&s(e[n]))return n}function se(e,s){for(let n=0;n<e.length;n++)if(s(e[n]))return n}function re(e){return(s,n={})=>{const l=s.match(e.matchPattern);if(!l)return null;const o=l[0],c=s.match(e.parsePattern);if(!c)return null;let i=e.valueCallback?e.valueCallback(c[0]):c[0];i=n.valueCallback?n.valueCallback(i):i;const d=s.slice(o.length);return{value:i,rest:d}}}const oe={lessThanXSeconds:{one:"menos de um segundo",other:"menos de {{count}} segundos"},xSeconds:{one:"1 segundo",other:"{{count}} segundos"},halfAMinute:"meio minuto",lessThanXMinutes:{one:"menos de um minuto",other:"menos de {{count}} minutos"},xMinutes:{one:"1 minuto",other:"{{count}} minutos"},aboutXHours:{one:"cerca de 1 hora",other:"cerca de {{count}} horas"},xHours:{one:"1 hora",other:"{{count}} horas"},xDays:{one:"1 dia",other:"{{count}} dias"},aboutXWeeks:{one:"cerca de 1 semana",other:"cerca de {{count}} semanas"},xWeeks:{one:"1 semana",other:"{{count}} semanas"},aboutXMonths:{one:"cerca de 1 mês",other:"cerca de {{count}} meses"},xMonths:{one:"1 mês",other:"{{count}} meses"},aboutXYears:{one:"cerca de 1 ano",other:"cerca de {{count}} anos"},xYears:{one:"1 ano",other:"{{count}} anos"},overXYears:{one:"mais de 1 ano",other:"mais de {{count}} anos"},almostXYears:{one:"quase 1 ano",other:"quase {{count}} anos"}},ie=(e,s,n)=>{let l;const o=oe[e];return typeof o=="string"?l=o:s===1?l=o.one:l=o.other.replace("{{count}}",String(s)),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"em "+l:"há "+l:l},de={full:"EEEE, d 'de' MMMM 'de' y",long:"d 'de' MMMM 'de' y",medium:"d MMM y",short:"dd/MM/yyyy"},le={full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},ce={full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ue={date:A({formats:de,defaultWidth:"full"}),time:A({formats:le,defaultWidth:"full"}),dateTime:A({formats:ce,defaultWidth:"full"})},me={lastWeek:e=>{const s=e.getDay();return"'"+(s===0||s===6?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},he=(e,s,n,l)=>{const o=me[e];return typeof o=="function"?o(s):o},fe={narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},ge={narrow:["1","2","3","4"],abbreviated:["T1","T2","T3","T4"],wide:["1º trimestre","2º trimestre","3º trimestre","4º trimestre"]},xe={narrow:["j","f","m","a","m","j","j","a","s","o","n","d"],abbreviated:["jan","fev","mar","abr","mai","jun","jul","ago","set","out","nov","dez"],wide:["janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"]},be={narrow:["D","S","T","Q","Q","S","S"],short:["dom","seg","ter","qua","qui","sex","sab"],abbreviated:["domingo","segunda","terça","quarta","quinta","sexta","sábado"],wide:["domingo","segunda-feira","terça-feira","quarta-feira","quinta-feira","sexta-feira","sábado"]},pe={narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"},abbreviated:{am:"AM",pm:"PM",midnight:"meia-noite",noon:"meio-dia",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"},wide:{am:"a.m.",pm:"p.m.",midnight:"meia-noite",noon:"meio-dia",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"}},ye={narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"},abbreviated:{am:"AM",pm:"PM",midnight:"meia-noite",noon:"meio-dia",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"},wide:{am:"a.m.",pm:"p.m.",midnight:"meia-noite",noon:"meio-dia",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"}},je=(e,s)=>{const n=Number(e);return(s==null?void 0:s.unit)==="week"?n+"ª":n+"º"},ve={ordinalNumber:je,era:W({values:fe,defaultWidth:"wide"}),quarter:W({values:ge,defaultWidth:"wide",argumentCallback:e=>e-1}),month:W({values:xe,defaultWidth:"wide"}),day:W({values:be,defaultWidth:"wide"}),dayPeriod:W({values:pe,defaultWidth:"wide",formattingValues:ye,defaultFormattingWidth:"wide"})},we=/^(\d+)[ºªo]?/i,Ce=/\d+/i,ke={narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|d\.?\s?c\.?)/i,wide:/^(antes de cristo|depois de cristo)/i},Ne={any:[/^ac/i,/^dc/i],wide:[/^antes de cristo/i,/^depois de cristo/i]},Se={narrow:/^[1234]/i,abbreviated:/^T[1234]/i,wide:/^[1234](º)? trimestre/i},Re={any:[/1/i,/2/i,/3/i,/4/i]},Pe={narrow:/^[jfmajsond]/i,abbreviated:/^(jan|fev|mar|abr|mai|jun|jul|ago|set|out|nov|dez)/i,wide:/^(janeiro|fevereiro|março|abril|maio|junho|julho|agosto|setembro|outubro|novembro|dezembro)/i},Me={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^fev/i,/^mar/i,/^abr/i,/^mai/i,/^jun/i,/^jul/i,/^ago/i,/^set/i,/^out/i,/^nov/i,/^dez/i]},Oe={narrow:/^(dom|[23456]ª?|s[aá]b)/i,short:/^(dom|[23456]ª?|s[aá]b)/i,abbreviated:/^(dom|seg|ter|qua|qui|sex|s[aá]b)/i,wide:/^(domingo|(segunda|ter[cç]a|quarta|quinta|sexta)([- ]feira)?|s[aá]bado)/i},$e={short:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],narrow:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],any:[/^d/i,/^seg/i,/^t/i,/^qua/i,/^qui/i,/^sex/i,/^s[aá]b/i]},Ve={narrow:/^(a|p|mn|md|(da) (manhã|tarde|noite))/i,any:/^([ap]\.?\s?m\.?|meia[-\s]noite|meio[-\s]dia|(da) (manhã|tarde|noite))/i},Fe={any:{am:/^a/i,pm:/^p/i,midnight:/^mn|^meia[-\s]noite/i,noon:/^md|^meio[-\s]dia/i,morning:/manhã/i,afternoon:/tarde/i,evening:/tarde/i,night:/noite/i}},We={ordinalNumber:re({matchPattern:we,parsePattern:Ce,valueCallback:e=>parseInt(e,10)}),era:D({matchPatterns:ke,defaultMatchWidth:"wide",parsePatterns:Ne,defaultParseWidth:"any"}),quarter:D({matchPatterns:Se,defaultMatchWidth:"wide",parsePatterns:Re,defaultParseWidth:"any",valueCallback:e=>e+1}),month:D({matchPatterns:Pe,defaultMatchWidth:"wide",parsePatterns:Me,defaultParseWidth:"any"}),day:D({matchPatterns:Oe,defaultMatchWidth:"wide",parsePatterns:$e,defaultParseWidth:"any"}),dayPeriod:D({matchPatterns:Ve,defaultMatchWidth:"any",parsePatterns:Fe,defaultParseWidth:"any"})},De={code:"pt-BR",formatDistance:ie,formatLong:ue,formatRelative:he,localize:ve,match:We,options:{weekStartsOn:0,firstWeekContainsDate:1}};I.registerLocale("pt-BR",De);const _="dd/MM/yyyy",Te=e=>{if(!e)return null;const s=H.parse(e,_,new Date);return H.isValid(s)?s:null},qe=e=>e?H.format(e,_):"",Ae=u.forwardRef(({shimRef:e,className:s,name:n,...l},o)=>t.jsx("input",{name:n,...l,className:s,ref:c=>{typeof o=="function"?o(c):o&&(o.current=c),e&&e(c)}})),He=({name:e,label:s="",placeholder:n="dd/mm/aaaa",className:l="",forceReadOnly:o=!1,forceHidden:c=!1})=>{const{control:i}=O.useFormContext(),{isView:d}=P.useFluigRuntime(),{isReadOnly:w,isHidden:f}=P.useSection(),j=o||!!w(e),v=c||!!f(e),{field:{onChange:C,onBlur:R,value:x,ref:y},fieldState:{error:b}}=O.useController({name:e,control:i}),k=u.useMemo(()=>Te(x),[x]),N=u.useCallback(a=>{C(a?qe(a):"")},[C]),h=u.useCallback(a=>{var r,m;if(y(a),a&&((m=(r=i._fields)==null?void 0:r[e])!=null&&m._f)){const M=i._fields[e];M._f.ref={focus:()=>{var g;return(g=a.focus)==null?void 0:g.call(a)},select:()=>{var g;return(g=a.select)==null?void 0:g.call(a)},setCustomValidity:g=>{var S;return(S=a.setCustomValidity)==null?void 0:S.call(a,g)},reportValidity:()=>{var g;return(g=a.reportValidity)==null?void 0:g.call(a)}}}},[y,i,e]);return v?null:d?t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:s}),t.jsx("span",{className:"form-control",children:x||"-"})]}):t.jsxs("div",{className:`form-group fluig-style-guide ${l}`,children:[s&&t.jsx("label",{className:"control-label",htmlFor:e,children:s}),t.jsx("div",{className:`${b?"border-red":""}`,children:t.jsx(I,{id:e,name:e,selected:k,onChange:N,onBlur:R,dateFormat:_,placeholderText:n,disabled:j,readOnly:j,locale:"pt-BR",className:`form-control ${b?"border-red":""}`,wrapperClassName:"w-100",showMonthDropdown:!0,showYearDropdown:!0,dropdownMode:"select",isClearable:!j&&!!x,autoComplete:"off",customInput:t.jsx(Ae,{name:e,shimRef:h})})}),b&&t.jsx("span",{className:"help-block text-danger",children:String(b.message)})]})},_e=u.memo(He);function Ee({mapping:e={},defaultLabel:s="Não reconhecido",className:n="",hidden:l=!1,label:o}){const{activityId:c}=P.useFluigRuntime(),i=u.useMemo(()=>!e||c===null||c===void 0?null:e[c],[c,e]);if(!i)return t.jsxs("div",{className:`form-group ${l?"hidden":""}`,children:[o&&t.jsx("label",{children:o}),t.jsx("div",{className:`status-badge default ${n}`,children:s})]});const d={"--customColor":i.color};return t.jsxs("div",{className:`form-group ${l?"hidden":""}`,children:[o&&t.jsx("label",{children:o}),t.jsxs("div",{className:`status-badge ${n}`,style:d,children:[i.icon&&t.jsx("i",{className:i.icon}),t.jsx("span",{children:i.label})]})]})}const Le=u.memo(Ee);function Be({name:e,control:s,defaultRowValue:n,isView:l,isReadOnly:o,filters:c=[]}){const{field:i}=O.useController({name:e,control:s}),[d,w]=u.useState([]),[f,j]=u.useState([]),v=()=>Date.now()+Math.random(),C=a=>{try{const r=JSON.parse(a);return Array.isArray(r)?r.map(m=>({...m,_uid:m._uid||v()})):[]}catch(r){return console.error(`Erro ao ler dados da tabela "${e}":`,r),[]}};u.useEffect(()=>{if(!(d.length>0&&!l)&&i.value&&typeof i.value=="string"){const a=JSON.stringify(d);if(i.value===a)return;const r=C(i.value);w(r)}},[i.value,l]),u.useEffect(()=>{if(o)return;const a=JSON.stringify(d);i.value!==a&&i.onChange(a)},[d,i,o]);const R=u.useCallback(()=>{const a={_uid:v(),...n};w(r=>[...r,a])},[n]),x=u.useCallback(()=>{w(a=>a.filter(r=>!f.includes(r._uid))),j([])},[f]),y=u.useCallback((a,r,m)=>{w(M=>M.map(g=>g._uid===a?{...g,[r]:m}:g))},[]),b=u.useCallback(a=>{j(r=>r.includes(a)?r.filter(m=>m!==a):[...r,a])},[]),k=u.useCallback(a=>{j(a?d.map(r=>r._uid):[])},[d]),N=d.length>0&&f.length===d.length,h=u.useMemo(()=>!c||c.length===0?d:d.filter(a=>c.every(r=>{if("custom"in r)return r.custom(a);const m=a[r.field];switch(r.operator){case"===":return m===r.value;case"!==":return m!==r.value;case">":return m>r.value;case"<":return m<r.value;case">=":return m>=r.value;case"<=":return m<=r.value;default:return!0}})),[d,c]);return{field:i,tableRows:d,visibleRows:h,selectedRowIds:f,isAllSelected:N,handle:{addRow:R,removeRows:x,updateCellValue:y,toggleSelection:b,toggleSelectAll:k}}}const Ie=({name:e,title:s="Tabela Dinâmica",columns:n,defaultRowValue:l={},forceReadOnly:o=!1,layout:c="fluid",actions:i=!0,filters:d=[]})=>{const{control:w}=O.useFormContext(),{isView:f,isReadOnly:j}=P.useFluigRuntime(),{isReadOnly:v}=P.useSection(),C=o||f||j||v&&v(e),{field:R,visibleRows:x,selectedRowIds:y,isAllSelected:b,handle:k}=Be({name:e,control:w,defaultRowValue:l,isView:f,isReadOnly:!!C,filters:d}),N=c==="fixed";return t.jsxs("div",{className:`table-wrapper ${N?"table-fixed":"table-fluid"}`,children:[t.jsx("input",{type:"hidden",...R}),t.jsxs("div",{className:"header-handle",children:[t.jsx("h3",{children:s}),!C&&i&&t.jsxs("div",{className:"handle-actions",children:[t.jsxs("button",{type:"button",className:`btn ${y.length>0?"btn-danger":""}`,disabled:y.length===0,onClick:k.removeRows,children:["Remover (",y.length,")"]}),t.jsx("button",{type:"button",className:"btn-add",onClick:k.addRow,children:"Adicionar"})]})]}),t.jsx("div",{className:"table-scroll",children:t.jsxs("table",{className:"table-custom",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[!C&&t.jsx("th",{style:{width:"50px"},children:t.jsx("input",{type:"checkbox",checked:b,onChange:h=>k.toggleSelectAll(h.target.checked)})}),n.map(h=>t.jsx("th",{style:h.width?{minWidth:N?h.width:"100%"}:{width:"max-content"},children:h.label},h.key))]})}),t.jsxs("tbody",{children:[x.map((h,a)=>t.jsxs("tr",{children:[!C&&t.jsx("td",{children:t.jsx("input",{type:"checkbox",checked:y.includes(h._uid),onChange:()=>k.toggleSelection(h._uid)})}),n.map(r=>t.jsx("td",{children:r.render?r.render.length<=1?r.render({row:h,index:a,updateRow:(m,M)=>k.updateCellValue(h._uid,m,M),isLocked:!!C,isView:!!f}):r.render(h,a,(m,M)=>k.updateCellValue(h._uid,m,M),!!C,!!f):h[r.key]},`${h._uid}-${r.key}`))]},h._uid)),x.length===0&&t.jsx("tr",{className:"empty-row",children:t.jsx("td",{colSpan:100,className:"text-center",children:C?"Nenhum registro encontrado.":"Nenhum registro."})})]})]})})]})};exports.Checkbox=Z;exports.DatePicker=_e;exports.Input=J;exports.RadioBtn=ee;exports.Select=G;exports.SimpleTable=Ie;exports.StatusBadge=Le;exports.TextArea=ne;
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsxs as y, jsx as a, Fragment as Z } from "react/jsx-runtime";
|
|
2
|
-
import { memo as
|
|
3
|
-
import { useFormContext as T, useController as
|
|
2
|
+
import { memo as _, useMemo as j, useCallback as V, useState as B, useRef as U, useEffect as D, forwardRef as K } from "react";
|
|
3
|
+
import { useFormContext as T, useController as F, useFormState as ee } from "react-hook-form";
|
|
4
4
|
import { IMaskInput as te } from "react-imask";
|
|
5
5
|
import { useSection as A, useFluigRuntime as W } from "@fluig-kit/ecm";
|
|
6
6
|
import ne, { registerLocale as ae } from "react-datepicker";
|
|
7
|
-
import { parse as re, isValid as
|
|
8
|
-
const
|
|
7
|
+
import { parse as re, isValid as ie, format as se } from "date-fns";
|
|
8
|
+
const oe = {
|
|
9
9
|
cpf: "000.000.000-00",
|
|
10
10
|
cnpj: "00.000.000/0000-00",
|
|
11
11
|
telefone: "(00) 00000-0000",
|
|
@@ -16,24 +16,24 @@ function de({
|
|
|
16
16
|
label: r = "",
|
|
17
17
|
placeholder: t = "",
|
|
18
18
|
type: l = "text",
|
|
19
|
-
mask:
|
|
19
|
+
mask: s,
|
|
20
20
|
className: c = "",
|
|
21
|
-
forceReadOnly:
|
|
21
|
+
forceReadOnly: o = !1,
|
|
22
22
|
forceHidden: d = !1
|
|
23
23
|
}) {
|
|
24
|
-
const { isReadOnly: k, isHidden:
|
|
25
|
-
() =>
|
|
26
|
-
[
|
|
27
|
-
),
|
|
24
|
+
const { isReadOnly: k, isHidden: h } = A(), w = o || !!k(e), N = d || !!h(e), { control: C } = T(), { isView: P } = W(), { field: g } = F({ name: e, control: C }), { errors: v } = ee({ name: e }), p = v == null ? void 0 : v[e], x = j(
|
|
25
|
+
() => s ? oe[s] ?? s : null,
|
|
26
|
+
[s]
|
|
27
|
+
), R = V((n) => {
|
|
28
28
|
if (!n) return "";
|
|
29
|
-
const
|
|
30
|
-
return (Number(
|
|
29
|
+
const i = n.replace(/\D/g, "");
|
|
30
|
+
return (Number(i) / 100).toLocaleString("pt-BR", {
|
|
31
31
|
style: "currency",
|
|
32
32
|
currency: "BRL"
|
|
33
33
|
});
|
|
34
|
-
}, []),
|
|
35
|
-
(n) => l === "monetary" ?
|
|
36
|
-
[l,
|
|
34
|
+
}, []), m = V(
|
|
35
|
+
(n) => l === "monetary" ? R(n) : n,
|
|
36
|
+
[l, R]
|
|
37
37
|
);
|
|
38
38
|
return P ? /* @__PURE__ */ y("div", { className: "form-group", children: [
|
|
39
39
|
/* @__PURE__ */ a("label", { children: r }),
|
|
@@ -47,10 +47,10 @@ function de({
|
|
|
47
47
|
mask: x,
|
|
48
48
|
value: String(g.value ?? ""),
|
|
49
49
|
unmask: !1,
|
|
50
|
-
onAccept: (n) => g.onChange(
|
|
50
|
+
onAccept: (n) => g.onChange(m(n)),
|
|
51
51
|
placeholder: t,
|
|
52
52
|
readOnly: w,
|
|
53
|
-
className: `form-control ${
|
|
53
|
+
className: `form-control ${p ? "border-red" : ""} ${c}`,
|
|
54
54
|
inputRef: g.ref,
|
|
55
55
|
onBlur: g.onBlur
|
|
56
56
|
}
|
|
@@ -60,67 +60,67 @@ function de({
|
|
|
60
60
|
...g,
|
|
61
61
|
type: "text",
|
|
62
62
|
value: g.value ?? "",
|
|
63
|
-
onChange: (n) => g.onChange(
|
|
63
|
+
onChange: (n) => g.onChange(m(n.target.value)),
|
|
64
64
|
placeholder: t,
|
|
65
65
|
readOnly: w,
|
|
66
|
-
className: `form-control ${
|
|
66
|
+
className: `form-control ${p ? "border-red" : ""} ${c}`
|
|
67
67
|
}
|
|
68
68
|
),
|
|
69
|
-
|
|
69
|
+
p && /* @__PURE__ */ a("p", { className: "text-danger", children: String(p.message) })
|
|
70
70
|
] });
|
|
71
71
|
}
|
|
72
|
-
const rt =
|
|
72
|
+
const rt = _(de);
|
|
73
73
|
function le({
|
|
74
74
|
name: e,
|
|
75
75
|
label: r = "",
|
|
76
76
|
options: t = [],
|
|
77
77
|
placeholder: l = "",
|
|
78
|
-
labelKey:
|
|
78
|
+
labelKey: s = "label",
|
|
79
79
|
valueKey: c = "value",
|
|
80
|
-
enableSearch:
|
|
80
|
+
enableSearch: o = !1,
|
|
81
81
|
searchPlaceholder: d = "Buscar...",
|
|
82
82
|
loading: k = !1,
|
|
83
|
-
onSearchChange:
|
|
83
|
+
onSearchChange: h,
|
|
84
84
|
debounceTime: w = 300,
|
|
85
85
|
onSelect: N,
|
|
86
86
|
forceReadOnly: C = !1,
|
|
87
87
|
forceHidden: P = !1
|
|
88
88
|
}) {
|
|
89
|
-
const { isReadOnly: g, isHidden: v } = A(),
|
|
90
|
-
field: { onChange:
|
|
89
|
+
const { isReadOnly: g, isHidden: v } = A(), p = C || !!g(e), x = P || !!v(e), { control: R, clearErrors: m } = T(), { isView: n } = W(), {
|
|
90
|
+
field: { onChange: i, value: u, ref: O },
|
|
91
91
|
fieldState: { error: f }
|
|
92
|
-
} =
|
|
92
|
+
} = F({
|
|
93
93
|
name: e,
|
|
94
|
-
control:
|
|
95
|
-
}), [
|
|
94
|
+
control: R
|
|
95
|
+
}), [S, M] = B(!1), [$, Y] = B(""), z = U(null), I = U(h);
|
|
96
96
|
D(() => {
|
|
97
|
-
I.current =
|
|
98
|
-
}, [
|
|
99
|
-
const
|
|
100
|
-
z.current && !z.current.contains(
|
|
97
|
+
I.current = h;
|
|
98
|
+
}, [h]), D(() => {
|
|
99
|
+
const b = (H) => {
|
|
100
|
+
z.current && !z.current.contains(H.target) && M(!1);
|
|
101
101
|
};
|
|
102
|
-
return document.addEventListener("mousedown",
|
|
102
|
+
return document.addEventListener("mousedown", b), () => document.removeEventListener("mousedown", b);
|
|
103
103
|
}, []), D(() => {
|
|
104
|
-
|
|
105
|
-
}, [
|
|
106
|
-
if (!
|
|
107
|
-
const
|
|
104
|
+
S || Y("");
|
|
105
|
+
}, [S]), D(() => {
|
|
106
|
+
if (!o) return;
|
|
107
|
+
const b = setTimeout(() => {
|
|
108
108
|
I.current && I.current($);
|
|
109
109
|
}, w);
|
|
110
|
-
return () => clearTimeout(
|
|
111
|
-
}, [$,
|
|
112
|
-
const Q = j(() =>
|
|
113
|
-
(
|
|
114
|
-
) : t ?? [], [t,
|
|
110
|
+
return () => clearTimeout(b);
|
|
111
|
+
}, [$, o, w]);
|
|
112
|
+
const Q = j(() => o && !h && $.trim() ? t.filter(
|
|
113
|
+
(b) => String((b == null ? void 0 : b[s]) ?? "").toLowerCase().includes($.toLowerCase())
|
|
114
|
+
) : t ?? [], [t, o, h, $, s]), J = j(() => {
|
|
115
115
|
if (u == null) return "";
|
|
116
116
|
if (typeof u == "object")
|
|
117
117
|
return String(u[c] ?? "");
|
|
118
|
-
const
|
|
119
|
-
(
|
|
118
|
+
const b = (t || []).find(
|
|
119
|
+
(H) => String(H == null ? void 0 : H[c]) === String(u)
|
|
120
120
|
);
|
|
121
|
-
return String(
|
|
122
|
-
}, [u, t, c,
|
|
123
|
-
|
|
121
|
+
return String(b ? (b == null ? void 0 : b[s]) ?? "" : u);
|
|
122
|
+
}, [u, t, c, s]), G = (b) => {
|
|
123
|
+
p || (i(b[c]), N && N(b), m(e), M(!1));
|
|
124
124
|
};
|
|
125
125
|
return /* @__PURE__ */ y(
|
|
126
126
|
"div",
|
|
@@ -133,36 +133,36 @@ function le({
|
|
|
133
133
|
/* @__PURE__ */ y(
|
|
134
134
|
"div",
|
|
135
135
|
{
|
|
136
|
-
className: `select-control ${f ? "border-red" : ""} ${
|
|
137
|
-
onClick: () => !
|
|
136
|
+
className: `select-control ${f ? "border-red" : ""} ${p ? "readOnly" : ""}`,
|
|
137
|
+
onClick: () => !p && M((b) => !b),
|
|
138
138
|
ref: O,
|
|
139
139
|
children: [
|
|
140
|
-
/* @__PURE__ */ a("span", { className: `select-display ${
|
|
140
|
+
/* @__PURE__ */ a("span", { className: `select-display ${p ? "readOnly" : ""}`, children: J || l }),
|
|
141
141
|
/* @__PURE__ */ a("i", { className: "flaticon flaticon-chevron-down select-icon" })
|
|
142
142
|
]
|
|
143
143
|
}
|
|
144
144
|
),
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
S && !p && /* @__PURE__ */ y("div", { className: "select-dropdown", children: [
|
|
146
|
+
o && /* @__PURE__ */ a("div", { className: "select-search", children: /* @__PURE__ */ a(
|
|
147
147
|
"input",
|
|
148
148
|
{
|
|
149
149
|
type: "text",
|
|
150
150
|
className: "select-search-input",
|
|
151
151
|
value: $,
|
|
152
|
-
onChange: (
|
|
152
|
+
onChange: (b) => Y(b.target.value),
|
|
153
153
|
placeholder: k ? "Carregando..." : d,
|
|
154
154
|
autoFocus: !0,
|
|
155
|
-
onClick: (
|
|
155
|
+
onClick: (b) => b.stopPropagation()
|
|
156
156
|
}
|
|
157
157
|
) }),
|
|
158
|
-
/* @__PURE__ */ a("ul", { className: "select-options", children: k ? /* @__PURE__ */ a("li", { className: "select-option readOnly", children: "Carregando..." }) : Q.length > 0 ? Q.map((
|
|
158
|
+
/* @__PURE__ */ a("ul", { className: "select-options", children: k ? /* @__PURE__ */ a("li", { className: "select-option readOnly", children: "Carregando..." }) : Q.length > 0 ? Q.map((b) => /* @__PURE__ */ a(
|
|
159
159
|
"li",
|
|
160
160
|
{
|
|
161
|
-
onClick: () => G(
|
|
161
|
+
onClick: () => G(b),
|
|
162
162
|
className: "select-option handleHover",
|
|
163
|
-
children:
|
|
163
|
+
children: b[s]
|
|
164
164
|
},
|
|
165
|
-
|
|
165
|
+
b[c]
|
|
166
166
|
)) : /* @__PURE__ */ a("li", { className: "select-option readOnly", children: "Sem resultados" }) })
|
|
167
167
|
] })
|
|
168
168
|
] }),
|
|
@@ -172,73 +172,73 @@ function le({
|
|
|
172
172
|
}
|
|
173
173
|
);
|
|
174
174
|
}
|
|
175
|
-
const
|
|
176
|
-
function
|
|
175
|
+
const it = _(le);
|
|
176
|
+
function st({
|
|
177
177
|
name: e,
|
|
178
178
|
options: r = [],
|
|
179
179
|
label: t = "",
|
|
180
180
|
valueKey: l = "value",
|
|
181
|
-
labelKey:
|
|
181
|
+
labelKey: s = "label",
|
|
182
182
|
forceReadOnly: c = !1,
|
|
183
|
-
forceHidden:
|
|
183
|
+
forceHidden: o = !1
|
|
184
184
|
}) {
|
|
185
185
|
var u, O;
|
|
186
|
-
const d = T(), { isView: k, isReadOnly:
|
|
186
|
+
const d = T(), { isView: k, isReadOnly: h } = W(), { isReadOnly: w, isHidden: N } = A(), C = w ? w(e) : !1, P = N ? N(e) : !1, g = c || C, v = o || P, p = g || h || k;
|
|
187
187
|
if (!d || !e)
|
|
188
188
|
return console.error("Checkbox requer contexto de formulário e nome."), null;
|
|
189
|
-
const x = () => !r || !d ? {} : r.reduce((f,
|
|
190
|
-
const M =
|
|
189
|
+
const x = () => !r || !d ? {} : r.reduce((f, S) => {
|
|
190
|
+
const M = S[l], $ = d.getValues(M);
|
|
191
191
|
return f[M] = $ === "on", f;
|
|
192
|
-
}, {}),
|
|
192
|
+
}, {}), R = d.watch(e), m = j(() => R && typeof R == "object" ? R : x(), [R, r, l]);
|
|
193
193
|
D(() => {
|
|
194
194
|
const f = d.getValues(e);
|
|
195
|
-
(!f || typeof f != "object") && d.setValue(e,
|
|
195
|
+
(!f || typeof f != "object") && d.setValue(e, m, {
|
|
196
196
|
shouldDirty: !1,
|
|
197
197
|
shouldValidate: !1
|
|
198
198
|
});
|
|
199
|
-
}, [
|
|
200
|
-
const n = (f,
|
|
201
|
-
if (
|
|
202
|
-
const M = { ...
|
|
199
|
+
}, [m, e, d]);
|
|
200
|
+
const n = (f, S) => {
|
|
201
|
+
if (p) return;
|
|
202
|
+
const M = { ...m, [f]: S };
|
|
203
203
|
d.setValue(e, M, {
|
|
204
204
|
shouldDirty: !0,
|
|
205
205
|
shouldValidate: !0
|
|
206
|
-
}), d.setValue(f,
|
|
207
|
-
},
|
|
206
|
+
}), d.setValue(f, S ? "on" : "", { shouldValidate: !1 });
|
|
207
|
+
}, i = (O = (u = d.formState) == null ? void 0 : u.errors) == null ? void 0 : O[e];
|
|
208
208
|
return /* @__PURE__ */ y("div", { className: `form-group ${v ? "hidden" : ""}`, children: [
|
|
209
209
|
t && /* @__PURE__ */ a("label", { children: t }),
|
|
210
210
|
/* @__PURE__ */ a(
|
|
211
211
|
"div",
|
|
212
212
|
{
|
|
213
|
-
className: `checkbox-group-custom ${
|
|
213
|
+
className: `checkbox-group-custom ${p ? "readOnly" : ""}`,
|
|
214
214
|
children: r.map((f) => {
|
|
215
|
-
const
|
|
215
|
+
const S = String(f[l]), M = m[S] === !0;
|
|
216
216
|
return /* @__PURE__ */ y("div", { children: [
|
|
217
|
-
/* @__PURE__ */ a("input", { type: "hidden", ...d.register(
|
|
217
|
+
/* @__PURE__ */ a("input", { type: "hidden", ...d.register(S) }),
|
|
218
218
|
/* @__PURE__ */ y(
|
|
219
219
|
"label",
|
|
220
220
|
{
|
|
221
|
-
className: `custom-checkbox ${M ? "checked" : ""} ${
|
|
221
|
+
className: `custom-checkbox ${M ? "checked" : ""} ${p ? "readOnly" : ""}`,
|
|
222
222
|
children: [
|
|
223
223
|
/* @__PURE__ */ a(
|
|
224
224
|
"input",
|
|
225
225
|
{
|
|
226
226
|
type: "checkbox",
|
|
227
227
|
checked: M,
|
|
228
|
-
disabled:
|
|
229
|
-
onChange: ($) => n(
|
|
228
|
+
disabled: p,
|
|
229
|
+
onChange: ($) => n(S, $.target.checked)
|
|
230
230
|
}
|
|
231
231
|
),
|
|
232
232
|
/* @__PURE__ */ a("span", { className: "checkmark" }),
|
|
233
|
-
/* @__PURE__ */ a("span", { children: f[
|
|
233
|
+
/* @__PURE__ */ a("span", { children: f[s] })
|
|
234
234
|
]
|
|
235
235
|
}
|
|
236
236
|
)
|
|
237
|
-
] },
|
|
237
|
+
] }, S);
|
|
238
238
|
})
|
|
239
239
|
}
|
|
240
240
|
),
|
|
241
|
-
|
|
241
|
+
i && /* @__PURE__ */ a("p", { className: "text-danger", children: String(i.message) })
|
|
242
242
|
] });
|
|
243
243
|
}
|
|
244
244
|
function ce({
|
|
@@ -246,18 +246,18 @@ function ce({
|
|
|
246
246
|
label: r = "",
|
|
247
247
|
options: t = [],
|
|
248
248
|
valueKey: l = "value",
|
|
249
|
-
labelKey:
|
|
249
|
+
labelKey: s = "label",
|
|
250
250
|
iconKey: c = "icon",
|
|
251
|
-
forceReadOnly:
|
|
251
|
+
forceReadOnly: o = !1,
|
|
252
252
|
forceHidden: d = !1
|
|
253
253
|
}) {
|
|
254
|
-
const { isReadOnly: k, isHidden:
|
|
254
|
+
const { isReadOnly: k, isHidden: h } = A(), w = o || !!k(e), N = d || !!h(e), { control: C } = T(), { isView: P, isReadOnly: g } = W(), {
|
|
255
255
|
field: v,
|
|
256
|
-
fieldState: { error:
|
|
257
|
-
} =
|
|
256
|
+
fieldState: { error: p }
|
|
257
|
+
} = F({
|
|
258
258
|
name: e,
|
|
259
259
|
control: C
|
|
260
|
-
}), x = w || g || P,
|
|
260
|
+
}), x = w || g || P, R = v.value ?? "", m = V(
|
|
261
261
|
(n) => {
|
|
262
262
|
x || v.onChange(n);
|
|
263
263
|
},
|
|
@@ -271,11 +271,11 @@ function ce({
|
|
|
271
271
|
className: `btn-group ${x ? "view-mode" : ""}`,
|
|
272
272
|
"data-field-name": e,
|
|
273
273
|
children: t.map((n) => {
|
|
274
|
-
const
|
|
274
|
+
const i = n[l], u = R === i, O = n.color ? { "--customColor": n.color } : void 0;
|
|
275
275
|
return /* @__PURE__ */ y(
|
|
276
276
|
"label",
|
|
277
277
|
{
|
|
278
|
-
htmlFor: `${e}_${
|
|
278
|
+
htmlFor: `${e}_${i}`,
|
|
279
279
|
style: O,
|
|
280
280
|
className: `btn fs-ellipsis ${u ? "active" : ""}`,
|
|
281
281
|
children: [
|
|
@@ -283,42 +283,42 @@ function ce({
|
|
|
283
283
|
"input",
|
|
284
284
|
{
|
|
285
285
|
type: "radio",
|
|
286
|
-
id: `${e}_${
|
|
286
|
+
id: `${e}_${i}`,
|
|
287
287
|
name: e,
|
|
288
|
-
value:
|
|
288
|
+
value: i,
|
|
289
289
|
checked: u,
|
|
290
290
|
className: "hidden",
|
|
291
|
-
onChange: () =>
|
|
291
|
+
onChange: () => m(i),
|
|
292
292
|
disabled: x
|
|
293
293
|
}
|
|
294
294
|
),
|
|
295
295
|
n[c] && /* @__PURE__ */ a("i", { className: `${n[c]} icon-sm` }),
|
|
296
296
|
" ",
|
|
297
|
-
n[
|
|
297
|
+
n[s]
|
|
298
298
|
]
|
|
299
299
|
},
|
|
300
|
-
|
|
300
|
+
i
|
|
301
301
|
);
|
|
302
302
|
})
|
|
303
303
|
}
|
|
304
304
|
),
|
|
305
|
-
|
|
305
|
+
p && /* @__PURE__ */ a("p", { className: "text-danger", children: String(p.message) })
|
|
306
306
|
] });
|
|
307
307
|
}
|
|
308
|
-
const
|
|
308
|
+
const ot = _(ce), ue = ({
|
|
309
309
|
name: e,
|
|
310
310
|
label: r = "",
|
|
311
311
|
placeholder: t = "",
|
|
312
312
|
className: l = "",
|
|
313
|
-
rows:
|
|
313
|
+
rows: s = 4,
|
|
314
314
|
maxLength: c,
|
|
315
|
-
forceReadOnly:
|
|
315
|
+
forceReadOnly: o = !1,
|
|
316
316
|
forceHidden: d = !1
|
|
317
317
|
}) => {
|
|
318
|
-
const { isReadOnly: k, isHidden:
|
|
318
|
+
const { isReadOnly: k, isHidden: h } = A(), w = o || !!k(e), N = d || !!h(e), { control: C } = T(), { isView: P } = W(), {
|
|
319
319
|
field: g,
|
|
320
320
|
fieldState: { error: v }
|
|
321
|
-
} =
|
|
321
|
+
} = F({
|
|
322
322
|
name: e,
|
|
323
323
|
control: C
|
|
324
324
|
});
|
|
@@ -331,7 +331,7 @@ const st = F(ce), ue = ({
|
|
|
331
331
|
"textarea",
|
|
332
332
|
{
|
|
333
333
|
...g,
|
|
334
|
-
rows:
|
|
334
|
+
rows: s,
|
|
335
335
|
maxLength: c,
|
|
336
336
|
value: g.value || "",
|
|
337
337
|
placeholder: t,
|
|
@@ -341,7 +341,7 @@ const st = F(ce), ue = ({
|
|
|
341
341
|
),
|
|
342
342
|
v && /* @__PURE__ */ a("p", { className: "text-danger", children: String(v.message) })
|
|
343
343
|
] });
|
|
344
|
-
}, dt =
|
|
344
|
+
}, dt = _(ue);
|
|
345
345
|
function E(e) {
|
|
346
346
|
return (r = {}) => {
|
|
347
347
|
const t = r.width ? String(r.width) : e.defaultWidth;
|
|
@@ -351,34 +351,34 @@ function E(e) {
|
|
|
351
351
|
function q(e) {
|
|
352
352
|
return (r, t) => {
|
|
353
353
|
const l = t != null && t.context ? String(t.context) : "standalone";
|
|
354
|
-
let
|
|
354
|
+
let s;
|
|
355
355
|
if (l === "formatting" && e.formattingValues) {
|
|
356
|
-
const
|
|
357
|
-
|
|
356
|
+
const o = e.defaultFormattingWidth || e.defaultWidth, d = t != null && t.width ? String(t.width) : o;
|
|
357
|
+
s = e.formattingValues[d] || e.formattingValues[o];
|
|
358
358
|
} else {
|
|
359
|
-
const
|
|
360
|
-
|
|
359
|
+
const o = e.defaultWidth, d = t != null && t.width ? String(t.width) : e.defaultWidth;
|
|
360
|
+
s = e.values[d] || e.values[o];
|
|
361
361
|
}
|
|
362
362
|
const c = e.argumentCallback ? e.argumentCallback(r) : r;
|
|
363
|
-
return
|
|
363
|
+
return s[c];
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
|
-
function
|
|
366
|
+
function L(e) {
|
|
367
367
|
return (r, t = {}) => {
|
|
368
|
-
const l = t.width,
|
|
368
|
+
const l = t.width, s = l && e.matchPatterns[l] || e.matchPatterns[e.defaultMatchWidth], c = r.match(s);
|
|
369
369
|
if (!c)
|
|
370
370
|
return null;
|
|
371
|
-
const
|
|
371
|
+
const o = c[0], d = l && e.parsePatterns[l] || e.parsePatterns[e.defaultParseWidth], k = Array.isArray(d) ? he(d, (N) => N.test(o)) : (
|
|
372
372
|
// [TODO] -- I challenge you to fix the type
|
|
373
|
-
me(d, (N) => N.test(
|
|
373
|
+
me(d, (N) => N.test(o))
|
|
374
374
|
);
|
|
375
|
-
let
|
|
376
|
-
|
|
375
|
+
let h;
|
|
376
|
+
h = e.valueCallback ? e.valueCallback(k) : k, h = t.valueCallback ? (
|
|
377
377
|
// [TODO] -- I challenge you to fix the type
|
|
378
|
-
t.valueCallback(
|
|
379
|
-
) :
|
|
380
|
-
const w = r.slice(
|
|
381
|
-
return { value:
|
|
378
|
+
t.valueCallback(h)
|
|
379
|
+
) : h;
|
|
380
|
+
const w = r.slice(o.length);
|
|
381
|
+
return { value: h, rest: w };
|
|
382
382
|
};
|
|
383
383
|
}
|
|
384
384
|
function me(e, r) {
|
|
@@ -395,12 +395,12 @@ function fe(e) {
|
|
|
395
395
|
return (r, t = {}) => {
|
|
396
396
|
const l = r.match(e.matchPattern);
|
|
397
397
|
if (!l) return null;
|
|
398
|
-
const
|
|
398
|
+
const s = l[0], c = r.match(e.parsePattern);
|
|
399
399
|
if (!c) return null;
|
|
400
|
-
let
|
|
401
|
-
|
|
402
|
-
const d = r.slice(
|
|
403
|
-
return { value:
|
|
400
|
+
let o = e.valueCallback ? e.valueCallback(c[0]) : c[0];
|
|
401
|
+
o = t.valueCallback ? t.valueCallback(o) : o;
|
|
402
|
+
const d = r.slice(s.length);
|
|
403
|
+
return { value: o, rest: d };
|
|
404
404
|
};
|
|
405
405
|
}
|
|
406
406
|
const ge = {
|
|
@@ -465,11 +465,11 @@ const ge = {
|
|
|
465
465
|
one: "quase 1 ano",
|
|
466
466
|
other: "quase {{count}} anos"
|
|
467
467
|
}
|
|
468
|
-
},
|
|
468
|
+
}, pe = (e, r, t) => {
|
|
469
469
|
let l;
|
|
470
|
-
const
|
|
471
|
-
return typeof
|
|
472
|
-
},
|
|
470
|
+
const s = ge[e];
|
|
471
|
+
return typeof s == "string" ? l = s : r === 1 ? l = s.one : l = s.other.replace("{{count}}", String(r)), t != null && t.addSuffix ? t.comparison && t.comparison > 0 ? "em " + l : "há " + l : l;
|
|
472
|
+
}, be = {
|
|
473
473
|
full: "EEEE, d 'de' MMMM 'de' y",
|
|
474
474
|
long: "d 'de' MMMM 'de' y",
|
|
475
475
|
medium: "d MMM y",
|
|
@@ -486,7 +486,7 @@ const ge = {
|
|
|
486
486
|
short: "{{date}}, {{time}}"
|
|
487
487
|
}, we = {
|
|
488
488
|
date: E({
|
|
489
|
-
formats:
|
|
489
|
+
formats: be,
|
|
490
490
|
defaultWidth: "full"
|
|
491
491
|
}),
|
|
492
492
|
time: E({
|
|
@@ -508,8 +508,8 @@ const ge = {
|
|
|
508
508
|
nextWeek: "eeee 'às' p",
|
|
509
509
|
other: "P"
|
|
510
510
|
}, ke = (e, r, t, l) => {
|
|
511
|
-
const
|
|
512
|
-
return typeof
|
|
511
|
+
const s = Ne[e];
|
|
512
|
+
return typeof s == "function" ? s(r) : s;
|
|
513
513
|
}, Ce = {
|
|
514
514
|
narrow: ["AC", "DC"],
|
|
515
515
|
abbreviated: ["AC", "DC"],
|
|
@@ -518,7 +518,7 @@ const ge = {
|
|
|
518
518
|
narrow: ["1", "2", "3", "4"],
|
|
519
519
|
abbreviated: ["T1", "T2", "T3", "T4"],
|
|
520
520
|
wide: ["1º trimestre", "2º trimestre", "3º trimestre", "4º trimestre"]
|
|
521
|
-
},
|
|
521
|
+
}, Re = {
|
|
522
522
|
narrow: ["j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"],
|
|
523
523
|
abbreviated: [
|
|
524
524
|
"jan",
|
|
@@ -548,7 +548,7 @@ const ge = {
|
|
|
548
548
|
"novembro",
|
|
549
549
|
"dezembro"
|
|
550
550
|
]
|
|
551
|
-
},
|
|
551
|
+
}, Se = {
|
|
552
552
|
narrow: ["D", "S", "T", "Q", "Q", "S", "S"],
|
|
553
553
|
short: ["dom", "seg", "ter", "qua", "qui", "sex", "sab"],
|
|
554
554
|
abbreviated: [
|
|
@@ -646,11 +646,11 @@ const ge = {
|
|
|
646
646
|
argumentCallback: (e) => e - 1
|
|
647
647
|
}),
|
|
648
648
|
month: q({
|
|
649
|
-
values:
|
|
649
|
+
values: Re,
|
|
650
650
|
defaultWidth: "wide"
|
|
651
651
|
}),
|
|
652
652
|
day: q({
|
|
653
|
-
values:
|
|
653
|
+
values: Se,
|
|
654
654
|
defaultWidth: "wide"
|
|
655
655
|
}),
|
|
656
656
|
dayPeriod: q({
|
|
@@ -672,11 +672,11 @@ const ge = {
|
|
|
672
672
|
wide: /^[1234](º)? trimestre/i
|
|
673
673
|
}, Ae = {
|
|
674
674
|
any: [/1/i, /2/i, /3/i, /4/i]
|
|
675
|
-
},
|
|
675
|
+
}, _e = {
|
|
676
676
|
narrow: /^[jfmajsond]/i,
|
|
677
677
|
abbreviated: /^(jan|fev|mar|abr|mai|jun|jul|ago|set|out|nov|dez)/i,
|
|
678
678
|
wide: /^(janeiro|fevereiro|março|abril|maio|junho|julho|agosto|setembro|outubro|novembro|dezembro)/i
|
|
679
|
-
},
|
|
679
|
+
}, Fe = {
|
|
680
680
|
narrow: [
|
|
681
681
|
/^j/i,
|
|
682
682
|
/^f/i,
|
|
@@ -705,7 +705,7 @@ const ge = {
|
|
|
705
705
|
/^nov/i,
|
|
706
706
|
/^dez/i
|
|
707
707
|
]
|
|
708
|
-
},
|
|
708
|
+
}, He = {
|
|
709
709
|
narrow: /^(dom|[23456]ª?|s[aá]b)/i,
|
|
710
710
|
short: /^(dom|[23456]ª?|s[aá]b)/i,
|
|
711
711
|
abbreviated: /^(dom|seg|ter|qua|qui|sex|s[aá]b)/i,
|
|
@@ -714,10 +714,10 @@ const ge = {
|
|
|
714
714
|
short: [/^d/i, /^2/i, /^3/i, /^4/i, /^5/i, /^6/i, /^s[aá]/i],
|
|
715
715
|
narrow: [/^d/i, /^2/i, /^3/i, /^4/i, /^5/i, /^6/i, /^s[aá]/i],
|
|
716
716
|
any: [/^d/i, /^seg/i, /^t/i, /^qua/i, /^qui/i, /^sex/i, /^s[aá]b/i]
|
|
717
|
-
},
|
|
717
|
+
}, Le = {
|
|
718
718
|
narrow: /^(a|p|mn|md|(da) (manhã|tarde|noite))/i,
|
|
719
719
|
any: /^([ap]\.?\s?m\.?|meia[-\s]noite|meio[-\s]dia|(da) (manhã|tarde|noite))/i
|
|
720
|
-
},
|
|
720
|
+
}, Be = {
|
|
721
721
|
any: {
|
|
722
722
|
am: /^a/i,
|
|
723
723
|
pm: /^p/i,
|
|
@@ -734,40 +734,40 @@ const ge = {
|
|
|
734
734
|
parsePattern: We,
|
|
735
735
|
valueCallback: (e) => parseInt(e, 10)
|
|
736
736
|
}),
|
|
737
|
-
era:
|
|
737
|
+
era: L({
|
|
738
738
|
matchPatterns: De,
|
|
739
739
|
defaultMatchWidth: "wide",
|
|
740
740
|
parsePatterns: je,
|
|
741
741
|
defaultParseWidth: "any"
|
|
742
742
|
}),
|
|
743
|
-
quarter:
|
|
743
|
+
quarter: L({
|
|
744
744
|
matchPatterns: Te,
|
|
745
745
|
defaultMatchWidth: "wide",
|
|
746
746
|
parsePatterns: Ae,
|
|
747
747
|
defaultParseWidth: "any",
|
|
748
748
|
valueCallback: (e) => e + 1
|
|
749
749
|
}),
|
|
750
|
-
month:
|
|
751
|
-
matchPatterns:
|
|
750
|
+
month: L({
|
|
751
|
+
matchPatterns: _e,
|
|
752
752
|
defaultMatchWidth: "wide",
|
|
753
|
-
parsePatterns:
|
|
753
|
+
parsePatterns: Fe,
|
|
754
754
|
defaultParseWidth: "any"
|
|
755
755
|
}),
|
|
756
|
-
day:
|
|
757
|
-
matchPatterns:
|
|
756
|
+
day: L({
|
|
757
|
+
matchPatterns: He,
|
|
758
758
|
defaultMatchWidth: "wide",
|
|
759
759
|
parsePatterns: qe,
|
|
760
760
|
defaultParseWidth: "any"
|
|
761
761
|
}),
|
|
762
|
-
dayPeriod:
|
|
763
|
-
matchPatterns:
|
|
762
|
+
dayPeriod: L({
|
|
763
|
+
matchPatterns: Le,
|
|
764
764
|
defaultMatchWidth: "any",
|
|
765
|
-
parsePatterns:
|
|
765
|
+
parsePatterns: Be,
|
|
766
766
|
defaultParseWidth: "any"
|
|
767
767
|
})
|
|
768
768
|
}, Ie = {
|
|
769
769
|
code: "pt-BR",
|
|
770
|
-
formatDistance:
|
|
770
|
+
formatDistance: pe,
|
|
771
771
|
formatLong: we,
|
|
772
772
|
formatRelative: ke,
|
|
773
773
|
localize: $e,
|
|
@@ -781,16 +781,16 @@ ae("pt-BR", Ie);
|
|
|
781
781
|
const X = "dd/MM/yyyy", Ee = (e) => {
|
|
782
782
|
if (!e) return null;
|
|
783
783
|
const r = re(e, X, /* @__PURE__ */ new Date());
|
|
784
|
-
return
|
|
785
|
-
}, Xe = (e) => e ?
|
|
786
|
-
({ shimRef: e, className: r, name: t, ...l },
|
|
784
|
+
return ie(r) ? r : null;
|
|
785
|
+
}, Xe = (e) => e ? se(e, X) : "", Ye = K(
|
|
786
|
+
({ shimRef: e, className: r, name: t, ...l }, s) => /* @__PURE__ */ a(
|
|
787
787
|
"input",
|
|
788
788
|
{
|
|
789
789
|
name: t,
|
|
790
790
|
...l,
|
|
791
791
|
className: r,
|
|
792
792
|
ref: (c) => {
|
|
793
|
-
typeof
|
|
793
|
+
typeof s == "function" ? s(c) : s && (s.current = c), e && e(c);
|
|
794
794
|
}
|
|
795
795
|
}
|
|
796
796
|
)
|
|
@@ -799,25 +799,25 @@ const X = "dd/MM/yyyy", Ee = (e) => {
|
|
|
799
799
|
label: r = "",
|
|
800
800
|
placeholder: t = "dd/mm/aaaa",
|
|
801
801
|
className: l = "",
|
|
802
|
-
forceReadOnly:
|
|
802
|
+
forceReadOnly: s = !1,
|
|
803
803
|
forceHidden: c = !1
|
|
804
804
|
}) => {
|
|
805
|
-
const { control:
|
|
805
|
+
const { control: o } = T(), { isView: d } = W(), { isReadOnly: k, isHidden: h } = A(), w = s || !!k(e), N = c || !!h(e), {
|
|
806
806
|
field: { onChange: C, onBlur: P, value: g, ref: v },
|
|
807
|
-
fieldState: { error:
|
|
808
|
-
} =
|
|
807
|
+
fieldState: { error: p }
|
|
808
|
+
} = F({
|
|
809
809
|
name: e,
|
|
810
|
-
control:
|
|
811
|
-
}), x = j(() => Ee(g), [g]),
|
|
810
|
+
control: o
|
|
811
|
+
}), x = j(() => Ee(g), [g]), R = V(
|
|
812
812
|
(n) => {
|
|
813
813
|
C(n ? Xe(n) : "");
|
|
814
814
|
},
|
|
815
815
|
[C]
|
|
816
|
-
),
|
|
816
|
+
), m = V(
|
|
817
817
|
(n) => {
|
|
818
|
-
var
|
|
819
|
-
if (v(n), n && ((u = (
|
|
820
|
-
const O =
|
|
818
|
+
var i, u;
|
|
819
|
+
if (v(n), n && ((u = (i = o._fields) == null ? void 0 : i[e]) != null && u._f)) {
|
|
820
|
+
const O = o._fields[e];
|
|
821
821
|
O._f.ref = {
|
|
822
822
|
focus: () => {
|
|
823
823
|
var f;
|
|
@@ -828,8 +828,8 @@ const X = "dd/MM/yyyy", Ee = (e) => {
|
|
|
828
828
|
return (f = n.select) == null ? void 0 : f.call(n);
|
|
829
829
|
},
|
|
830
830
|
setCustomValidity: (f) => {
|
|
831
|
-
var
|
|
832
|
-
return (
|
|
831
|
+
var S;
|
|
832
|
+
return (S = n.setCustomValidity) == null ? void 0 : S.call(n, f);
|
|
833
833
|
},
|
|
834
834
|
reportValidity: () => {
|
|
835
835
|
var f;
|
|
@@ -838,154 +838,154 @@ const X = "dd/MM/yyyy", Ee = (e) => {
|
|
|
838
838
|
};
|
|
839
839
|
}
|
|
840
840
|
},
|
|
841
|
-
[v,
|
|
841
|
+
[v, o, e]
|
|
842
842
|
);
|
|
843
843
|
return N ? null : d ? /* @__PURE__ */ y("div", { className: "form-group", children: [
|
|
844
844
|
/* @__PURE__ */ a("label", { children: r }),
|
|
845
845
|
/* @__PURE__ */ a("span", { className: "form-control", children: g || "-" })
|
|
846
846
|
] }) : /* @__PURE__ */ y("div", { className: `form-group fluig-style-guide ${l}`, children: [
|
|
847
847
|
r && /* @__PURE__ */ a("label", { className: "control-label", htmlFor: e, children: r }),
|
|
848
|
-
/* @__PURE__ */ a("div", { className: `${
|
|
848
|
+
/* @__PURE__ */ a("div", { className: `${p ? "border-red" : ""}`, children: /* @__PURE__ */ a(
|
|
849
849
|
ne,
|
|
850
850
|
{
|
|
851
851
|
id: e,
|
|
852
852
|
name: e,
|
|
853
853
|
selected: x,
|
|
854
|
-
onChange:
|
|
854
|
+
onChange: R,
|
|
855
855
|
onBlur: P,
|
|
856
856
|
dateFormat: X,
|
|
857
857
|
placeholderText: t,
|
|
858
858
|
disabled: w,
|
|
859
859
|
readOnly: w,
|
|
860
860
|
locale: "pt-BR",
|
|
861
|
-
className: `form-control ${
|
|
861
|
+
className: `form-control ${p ? "border-red" : ""}`,
|
|
862
862
|
wrapperClassName: "w-100",
|
|
863
863
|
showMonthDropdown: !0,
|
|
864
864
|
showYearDropdown: !0,
|
|
865
865
|
dropdownMode: "select",
|
|
866
866
|
isClearable: !w && !!g,
|
|
867
867
|
autoComplete: "off",
|
|
868
|
-
customInput: /* @__PURE__ */ a(Ye, { name: e, shimRef:
|
|
868
|
+
customInput: /* @__PURE__ */ a(Ye, { name: e, shimRef: m })
|
|
869
869
|
}
|
|
870
870
|
) }),
|
|
871
|
-
|
|
871
|
+
p && /* @__PURE__ */ a("span", { className: "help-block text-danger", children: String(p.message) })
|
|
872
872
|
] });
|
|
873
|
-
}, lt =
|
|
873
|
+
}, lt = _(Qe);
|
|
874
874
|
function Je({
|
|
875
875
|
mapping: e = {},
|
|
876
876
|
defaultLabel: r = "Não reconhecido",
|
|
877
877
|
className: t = "",
|
|
878
878
|
hidden: l = !1,
|
|
879
|
-
label:
|
|
879
|
+
label: s
|
|
880
880
|
}) {
|
|
881
|
-
const { activityId: c } = W(),
|
|
882
|
-
if (!
|
|
881
|
+
const { activityId: c } = W(), o = j(() => !e || c === null || c === void 0 ? null : e[c], [c, e]);
|
|
882
|
+
if (!o)
|
|
883
883
|
return /* @__PURE__ */ y("div", { className: `form-group ${l ? "hidden" : ""}`, children: [
|
|
884
|
-
|
|
884
|
+
s && /* @__PURE__ */ a("label", { children: s }),
|
|
885
885
|
/* @__PURE__ */ a("div", { className: `status-badge default ${t}`, children: r })
|
|
886
886
|
] });
|
|
887
887
|
const d = {
|
|
888
|
-
"--customColor":
|
|
888
|
+
"--customColor": o.color
|
|
889
889
|
};
|
|
890
890
|
return /* @__PURE__ */ y("div", { className: `form-group ${l ? "hidden" : ""}`, children: [
|
|
891
|
-
|
|
891
|
+
s && /* @__PURE__ */ a("label", { children: s }),
|
|
892
892
|
/* @__PURE__ */ y("div", { className: `status-badge ${t}`, style: d, children: [
|
|
893
|
-
|
|
894
|
-
/* @__PURE__ */ a("span", { children:
|
|
893
|
+
o.icon && /* @__PURE__ */ a("i", { className: o.icon }),
|
|
894
|
+
/* @__PURE__ */ a("span", { children: o.label })
|
|
895
895
|
] })
|
|
896
896
|
] });
|
|
897
897
|
}
|
|
898
|
-
const ct =
|
|
898
|
+
const ct = _(Je);
|
|
899
899
|
function Ue({
|
|
900
900
|
name: e,
|
|
901
901
|
control: r,
|
|
902
902
|
defaultRowValue: t,
|
|
903
903
|
isView: l,
|
|
904
|
-
isReadOnly:
|
|
904
|
+
isReadOnly: s,
|
|
905
905
|
filters: c = []
|
|
906
906
|
}) {
|
|
907
|
-
const { field:
|
|
907
|
+
const { field: o } = F({ name: e, control: r }), [d, k] = B([]), [h, w] = B([]), N = () => Date.now() + Math.random(), C = (n) => {
|
|
908
908
|
try {
|
|
909
|
-
const
|
|
910
|
-
return Array.isArray(
|
|
909
|
+
const i = JSON.parse(n);
|
|
910
|
+
return Array.isArray(i) ? i.map((u) => ({
|
|
911
911
|
...u,
|
|
912
912
|
_uid: u._uid || N()
|
|
913
913
|
})) : [];
|
|
914
|
-
} catch (
|
|
915
|
-
return console.error(`Erro ao ler dados da tabela "${e}":`,
|
|
914
|
+
} catch (i) {
|
|
915
|
+
return console.error(`Erro ao ler dados da tabela "${e}":`, i), [];
|
|
916
916
|
}
|
|
917
917
|
};
|
|
918
918
|
D(() => {
|
|
919
|
-
if (!(d.length > 0 && !l) &&
|
|
919
|
+
if (!(d.length > 0 && !l) && o.value && typeof o.value == "string") {
|
|
920
920
|
const n = JSON.stringify(d);
|
|
921
|
-
if (
|
|
922
|
-
const
|
|
923
|
-
k(
|
|
921
|
+
if (o.value === n) return;
|
|
922
|
+
const i = C(o.value);
|
|
923
|
+
k(i);
|
|
924
924
|
}
|
|
925
|
-
}, [
|
|
926
|
-
if (
|
|
925
|
+
}, [o.value, l]), D(() => {
|
|
926
|
+
if (s) return;
|
|
927
927
|
const n = JSON.stringify(d);
|
|
928
|
-
|
|
929
|
-
}, [d,
|
|
928
|
+
o.value !== n && o.onChange(n);
|
|
929
|
+
}, [d, o, s]);
|
|
930
930
|
const P = V(() => {
|
|
931
931
|
const n = { _uid: N(), ...t };
|
|
932
|
-
k((
|
|
932
|
+
k((i) => [...i, n]);
|
|
933
933
|
}, [t]), g = V(() => {
|
|
934
934
|
k(
|
|
935
|
-
(n) => n.filter((
|
|
935
|
+
(n) => n.filter((i) => !h.includes(i._uid))
|
|
936
936
|
), w([]);
|
|
937
|
-
}, [
|
|
938
|
-
(n,
|
|
937
|
+
}, [h]), v = V(
|
|
938
|
+
(n, i, u) => {
|
|
939
939
|
k(
|
|
940
940
|
(O) => O.map(
|
|
941
|
-
(f) => f._uid === n ? { ...f, [
|
|
941
|
+
(f) => f._uid === n ? { ...f, [i]: u } : f
|
|
942
942
|
)
|
|
943
943
|
);
|
|
944
944
|
},
|
|
945
945
|
[]
|
|
946
|
-
),
|
|
946
|
+
), p = V((n) => {
|
|
947
947
|
w(
|
|
948
|
-
(
|
|
948
|
+
(i) => i.includes(n) ? i.filter((u) => u !== n) : [...i, n]
|
|
949
949
|
);
|
|
950
950
|
}, []), x = V(
|
|
951
951
|
(n) => {
|
|
952
|
-
w(n ? d.map((
|
|
952
|
+
w(n ? d.map((i) => i._uid) : []);
|
|
953
953
|
},
|
|
954
954
|
[d]
|
|
955
|
-
),
|
|
956
|
-
(n) => c.every((
|
|
957
|
-
if ("custom" in
|
|
958
|
-
return
|
|
959
|
-
const u = n[
|
|
960
|
-
switch (
|
|
955
|
+
), R = d.length > 0 && h.length === d.length, m = j(() => !c || c.length === 0 ? d : d.filter(
|
|
956
|
+
(n) => c.every((i) => {
|
|
957
|
+
if ("custom" in i)
|
|
958
|
+
return i.custom(n);
|
|
959
|
+
const u = n[i.field];
|
|
960
|
+
switch (i.operator) {
|
|
961
961
|
case "===":
|
|
962
|
-
return u ===
|
|
962
|
+
return u === i.value;
|
|
963
963
|
case "!==":
|
|
964
|
-
return u !==
|
|
964
|
+
return u !== i.value;
|
|
965
965
|
case ">":
|
|
966
|
-
return u >
|
|
966
|
+
return u > i.value;
|
|
967
967
|
case "<":
|
|
968
|
-
return u <
|
|
968
|
+
return u < i.value;
|
|
969
969
|
case ">=":
|
|
970
|
-
return u >=
|
|
970
|
+
return u >= i.value;
|
|
971
971
|
case "<=":
|
|
972
|
-
return u <=
|
|
972
|
+
return u <= i.value;
|
|
973
973
|
default:
|
|
974
974
|
return !0;
|
|
975
975
|
}
|
|
976
976
|
})
|
|
977
977
|
), [d, c]);
|
|
978
978
|
return {
|
|
979
|
-
field:
|
|
979
|
+
field: o,
|
|
980
980
|
tableRows: d,
|
|
981
|
-
visibleRows:
|
|
982
|
-
selectedRowIds:
|
|
983
|
-
isAllSelected:
|
|
981
|
+
visibleRows: m,
|
|
982
|
+
selectedRowIds: h,
|
|
983
|
+
isAllSelected: R,
|
|
984
984
|
handle: {
|
|
985
985
|
addRow: P,
|
|
986
986
|
removeRows: g,
|
|
987
987
|
updateCellValue: v,
|
|
988
|
-
toggleSelection:
|
|
988
|
+
toggleSelection: p,
|
|
989
989
|
toggleSelectAll: x
|
|
990
990
|
}
|
|
991
991
|
};
|
|
@@ -995,31 +995,24 @@ const ut = ({
|
|
|
995
995
|
title: r = "Tabela Dinâmica",
|
|
996
996
|
columns: t,
|
|
997
997
|
defaultRowValue: l = {},
|
|
998
|
-
forceReadOnly:
|
|
998
|
+
forceReadOnly: s = !1,
|
|
999
999
|
layout: c = "fluid",
|
|
1000
|
-
actions:
|
|
1000
|
+
actions: o = !0,
|
|
1001
1001
|
filters: d = []
|
|
1002
1002
|
}) => {
|
|
1003
|
-
const { control: k } = T(), { isView:
|
|
1004
|
-
field: P,
|
|
1005
|
-
// tableRows,
|
|
1006
|
-
visibleRows: g,
|
|
1007
|
-
selectedRowIds: v,
|
|
1008
|
-
isAllSelected: b,
|
|
1009
|
-
handle: x
|
|
1010
|
-
} = Ue({
|
|
1003
|
+
const { control: k } = T(), { isView: h, isReadOnly: w } = W(), { isReadOnly: N } = A(), C = s || h || w || N && N(e), { field: P, visibleRows: g, selectedRowIds: v, isAllSelected: p, handle: x } = Ue({
|
|
1011
1004
|
name: e,
|
|
1012
1005
|
control: k,
|
|
1013
1006
|
defaultRowValue: l,
|
|
1014
|
-
isView:
|
|
1007
|
+
isView: h,
|
|
1015
1008
|
isReadOnly: !!C,
|
|
1016
1009
|
filters: d
|
|
1017
|
-
}),
|
|
1018
|
-
return /* @__PURE__ */ y("div", { className: `table-wrapper ${
|
|
1010
|
+
}), R = c === "fixed";
|
|
1011
|
+
return /* @__PURE__ */ y("div", { className: `table-wrapper ${R ? "table-fixed" : "table-fluid"}`, children: [
|
|
1019
1012
|
/* @__PURE__ */ a("input", { type: "hidden", ...P }),
|
|
1020
|
-
|
|
1013
|
+
/* @__PURE__ */ y("div", { className: "header-handle", children: [
|
|
1021
1014
|
/* @__PURE__ */ a("h3", { children: r }),
|
|
1022
|
-
!C && /* @__PURE__ */ y("div", { className: "handle-actions", children: [
|
|
1015
|
+
!C && o && /* @__PURE__ */ y("div", { className: "handle-actions", children: [
|
|
1023
1016
|
/* @__PURE__ */ y(
|
|
1024
1017
|
"button",
|
|
1025
1018
|
{
|
|
@@ -1043,49 +1036,54 @@ const ut = ({
|
|
|
1043
1036
|
"input",
|
|
1044
1037
|
{
|
|
1045
1038
|
type: "checkbox",
|
|
1046
|
-
checked:
|
|
1047
|
-
onChange: (
|
|
1039
|
+
checked: p,
|
|
1040
|
+
onChange: (m) => x.toggleSelectAll(m.target.checked)
|
|
1048
1041
|
}
|
|
1049
1042
|
) }),
|
|
1050
|
-
t.map((
|
|
1043
|
+
t.map((m) => /* @__PURE__ */ a(
|
|
1051
1044
|
"th",
|
|
1052
1045
|
{
|
|
1053
|
-
style:
|
|
1054
|
-
children:
|
|
1046
|
+
style: m.width ? { minWidth: R ? m.width : "100%" } : { width: "max-content" },
|
|
1047
|
+
children: m.label
|
|
1055
1048
|
},
|
|
1056
|
-
|
|
1049
|
+
m.key
|
|
1057
1050
|
))
|
|
1058
1051
|
] }) }),
|
|
1059
|
-
/* @__PURE__ */ a("div", {}),
|
|
1060
1052
|
/* @__PURE__ */ y("tbody", { children: [
|
|
1061
|
-
g.map((
|
|
1053
|
+
g.map((m, n) => /* @__PURE__ */ y("tr", { children: [
|
|
1062
1054
|
!C && /* @__PURE__ */ a("td", { children: /* @__PURE__ */ a(
|
|
1063
1055
|
"input",
|
|
1064
1056
|
{
|
|
1065
1057
|
type: "checkbox",
|
|
1066
|
-
checked: v.includes(
|
|
1067
|
-
onChange: () => x.toggleSelection(
|
|
1058
|
+
checked: v.includes(m._uid),
|
|
1059
|
+
onChange: () => x.toggleSelection(m._uid)
|
|
1068
1060
|
}
|
|
1069
1061
|
) }),
|
|
1070
|
-
t.map((
|
|
1071
|
-
|
|
1062
|
+
t.map((i) => /* @__PURE__ */ a("td", { children: i.render ? i.render.length <= 1 ? i.render({
|
|
1063
|
+
row: m,
|
|
1064
|
+
index: n,
|
|
1065
|
+
updateRow: (u, O) => x.updateCellValue(m._uid, u, O),
|
|
1066
|
+
isLocked: !!C,
|
|
1067
|
+
isView: !!h
|
|
1068
|
+
}) : i.render(
|
|
1069
|
+
m,
|
|
1072
1070
|
n,
|
|
1073
|
-
(u, O) => x.updateCellValue(
|
|
1071
|
+
(u, O) => x.updateCellValue(m._uid, u, O),
|
|
1074
1072
|
!!C,
|
|
1075
|
-
!!
|
|
1076
|
-
) :
|
|
1077
|
-
] },
|
|
1073
|
+
!!h
|
|
1074
|
+
) : m[i.key] }, `${m._uid}-${i.key}`))
|
|
1075
|
+
] }, m._uid)),
|
|
1078
1076
|
g.length === 0 && /* @__PURE__ */ a("tr", { className: "empty-row", children: /* @__PURE__ */ a("td", { colSpan: 100, className: "text-center", children: C ? "Nenhum registro encontrado." : "Nenhum registro." }) })
|
|
1079
1077
|
] })
|
|
1080
1078
|
] }) })
|
|
1081
1079
|
] });
|
|
1082
1080
|
};
|
|
1083
1081
|
export {
|
|
1084
|
-
|
|
1082
|
+
st as Checkbox,
|
|
1085
1083
|
lt as DatePicker,
|
|
1086
1084
|
rt as Input,
|
|
1087
|
-
|
|
1088
|
-
|
|
1085
|
+
ot as RadioBtn,
|
|
1086
|
+
it as Select,
|
|
1089
1087
|
ut as SimpleTable,
|
|
1090
1088
|
ct as StatusBadge,
|
|
1091
1089
|
dt as TextArea
|