diefra_ecm_ui 1.0.0
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/README.md +138 -0
- package/dist/components/Attachment/index.d.ts +13 -0
- package/dist/components/Attachment/useFluigAttachment.d.ts +4 -0
- package/dist/components/Checkbox/index.d.ts +16 -0
- package/dist/components/DatePicker/index.d.ts +14 -0
- package/dist/components/Input/index.d.ts +17 -0
- package/dist/components/Modal/index.d.ts +12 -0
- package/dist/components/RadioBtn/index.d.ts +24 -0
- package/dist/components/Select/index.d.ts +26 -0
- package/dist/components/SideBar/index.d.ts +26 -0
- package/dist/components/SimpleTable/index.d.ts +34 -0
- package/dist/components/SimpleTable/useSimpleTable.d.ts +36 -0
- package/dist/components/StatusBadge/index.d.ts +17 -0
- package/dist/components/TextArea/index.d.ts +15 -0
- package/dist/components/index.d.ts +11 -0
- 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/fluig-ui.css +1 -0
- package/dist/index.cjs +59 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1540 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +66 -0
package/README.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# @tech-diefra/fluig-ui
|
|
2
|
+
|
|
3
|
+
Biblioteca de componentes React UI desenvolvida para agilizar a criação de formulários em processos BPM no Fluig.
|
|
4
|
+
|
|
5
|
+
Esta biblioteca abstrai a complexidade de integração com o `react-hook-form` e o controle de estado de visualização/edição do Fluig (`fluig-workflow-react`), oferecendo componentes prontos para uso como DatePickers, Selects com busca, Inputs mascarados e Badges de status.
|
|
6
|
+
|
|
7
|
+
## 📦 Instalação
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @tech-diefra/fluig-ui
|
|
11
|
+
# ou
|
|
12
|
+
yarn add @tech-diefra/fluig-ui
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Peer Dependencies
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install react react-dom react-hook-form @fluig-kit/core @fluig-kit/ecm
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## ⚙️ Configuração Inicial
|
|
22
|
+
|
|
23
|
+
### Importar Estilos
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
import "@tech-diefra/fluig-ui/dist/style.css"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Configurar Contextos
|
|
30
|
+
|
|
31
|
+
```jsx
|
|
32
|
+
import { useForm, FormProvider } from "react-hook-form"
|
|
33
|
+
import { FluigRuntimeProvider } from "fluig-workflow-react"
|
|
34
|
+
import { Input } from "@tech-diefra/fluig-ui"
|
|
35
|
+
|
|
36
|
+
function App() {
|
|
37
|
+
const methods = useForm()
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<FluigRuntimeProvider>
|
|
41
|
+
<FormProvider {...methods}>
|
|
42
|
+
<form>
|
|
43
|
+
<Input name="nome_completo" label="Nome" />
|
|
44
|
+
</form>
|
|
45
|
+
</FormProvider>
|
|
46
|
+
</FluigRuntimeProvider>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 📚 Componentes
|
|
52
|
+
|
|
53
|
+
### Input
|
|
54
|
+
|
|
55
|
+
```jsx
|
|
56
|
+
<Input name="email" label="E-mail" type="email" />
|
|
57
|
+
<Input name="cpf_usuario" label="CPF" mask="cpf" />
|
|
58
|
+
<Input name="valor_projeto" label="Valor Estimado" type="monetary" />
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Select
|
|
62
|
+
|
|
63
|
+
```jsx
|
|
64
|
+
const options = [
|
|
65
|
+
{ label: "Sim", value: "SIM" },
|
|
66
|
+
{ label: "Não", value: "NAO" },
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
<Select
|
|
70
|
+
name="fornecedor"
|
|
71
|
+
label="Fornecedor"
|
|
72
|
+
options={options}
|
|
73
|
+
enableSearch
|
|
74
|
+
/>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### DatePicker
|
|
78
|
+
|
|
79
|
+
```jsx
|
|
80
|
+
<DatePicker name="data_inicio" label="Data de Início" />
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### RadioBtn
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
const opcoes = [
|
|
87
|
+
{ label: "Opção 1", value: "op1", icon: "flaticon flaticon-arrow-up", color: "#0f0" },
|
|
88
|
+
{ label: "Opção 2", value: "op2", icon: "flaticon flaticon-cancel", color: "#f00" }
|
|
89
|
+
]
|
|
90
|
+
|
|
91
|
+
<RadioBtn name="decisao" options={opcoes} />
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Checkbox
|
|
95
|
+
|
|
96
|
+
```jsx
|
|
97
|
+
const areas = [
|
|
98
|
+
{ label: "Area 1", value: "area1" },
|
|
99
|
+
{ label: "Area 2", value: "area2" }
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
<Checkbox name="areas" options={areas} />
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### StatusBadge
|
|
106
|
+
|
|
107
|
+
```jsx
|
|
108
|
+
//Mapping activity
|
|
109
|
+
const workflowConfig = {
|
|
110
|
+
5: { label: "Status 1", color: "#006dfc" },
|
|
111
|
+
14: { label: "Status 2", color: "#f0960e" }
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
<StatusBadge mapping={workflowConfig} />
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### TextArea
|
|
118
|
+
|
|
119
|
+
```jsx
|
|
120
|
+
<TextArea name="observacoes" rows={4} />
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## 🎨 Customização (CSS Variables)
|
|
124
|
+
|
|
125
|
+
```css
|
|
126
|
+
:root {
|
|
127
|
+
--colorPrimary: #00916d;
|
|
128
|
+
--dfeErrorColor: #ff5630;
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## 🔒 Controle de Permissões
|
|
133
|
+
|
|
134
|
+
```jsx
|
|
135
|
+
<Input name="campo_sistema" forceReadOnly forceHidden />
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Desenvolvido por Ketson Kersen - Diefra Engenharia.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as React } from '../../../node_modules/react';
|
|
2
|
+
|
|
3
|
+
interface AttachmentProps {
|
|
4
|
+
name: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
help?: string;
|
|
7
|
+
valueManual?: string;
|
|
8
|
+
onChangeManual?: (val: string) => void;
|
|
9
|
+
forceReadOnly?: boolean;
|
|
10
|
+
forceHidden?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const _default: React.MemoExoticComponent<({ name, label, help, valueManual, onChangeManual, forceReadOnly, forceHidden, }: AttachmentProps) => import("react/jsx-runtime").JSX.Element>;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
export interface CheckboxOption {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
}
|
|
5
|
+
export interface CheckboxProps {
|
|
6
|
+
name: string;
|
|
7
|
+
options?: CheckboxOption[];
|
|
8
|
+
label?: string;
|
|
9
|
+
valueKey?: string;
|
|
10
|
+
labelKey?: string;
|
|
11
|
+
forceReadOnly?: boolean;
|
|
12
|
+
forceHidden?: boolean;
|
|
13
|
+
valueManual?: Record<string, boolean>;
|
|
14
|
+
onChangeManual?: (val: Record<string, boolean>) => void;
|
|
15
|
+
}
|
|
16
|
+
export default function Checkbox({ name, options, label, valueKey, labelKey, forceReadOnly, forceHidden, valueManual, onChangeManual, }: CheckboxProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
export interface DatePickerProps {
|
|
3
|
+
name: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
forceReadOnly?: boolean;
|
|
8
|
+
forceHidden?: boolean;
|
|
9
|
+
valueManual?: string;
|
|
10
|
+
onChangeManual?: (value: string) => void;
|
|
11
|
+
errorManual?: string;
|
|
12
|
+
}
|
|
13
|
+
declare const _default: import('../../../node_modules/react').MemoExoticComponent<({ name, label, placeholder, className, forceReadOnly, forceHidden, valueManual, onChangeManual, errorManual, }: DatePickerProps) => import("react/jsx-runtime").JSX.Element | null>;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare const MASKS: Record<string, string>;
|
|
2
|
+
export interface InputProps {
|
|
3
|
+
name: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
type?: "text" | "number" | "email" | "monetary" | string;
|
|
7
|
+
mask?: keyof typeof MASKS | string;
|
|
8
|
+
className?: string;
|
|
9
|
+
forceReadOnly?: boolean;
|
|
10
|
+
forceHidden?: boolean;
|
|
11
|
+
valueManual?: string;
|
|
12
|
+
onChangeManual?: (value: string) => void;
|
|
13
|
+
errorManual?: string;
|
|
14
|
+
}
|
|
15
|
+
declare function InputCustom({ name, label, placeholder, type, mask, className, forceReadOnly, forceHidden, valueManual, onChangeManual, errorManual, }: InputProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
declare const _default: import('../../../node_modules/react').MemoExoticComponent<typeof InputCustom>;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as React } from '../../../node_modules/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 default function Modal({ title, isOpen, onOpen, onClose, content, footer, width, }: ModalProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
export interface RadioOption {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
icon?: string;
|
|
6
|
+
color?: string;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
export interface RadioBtnProps {
|
|
10
|
+
name: string;
|
|
11
|
+
label?: string;
|
|
12
|
+
options?: RadioOption[];
|
|
13
|
+
valueKey?: string;
|
|
14
|
+
labelKey?: string;
|
|
15
|
+
iconKey?: string;
|
|
16
|
+
forceReadOnly?: boolean;
|
|
17
|
+
forceHidden?: boolean;
|
|
18
|
+
valueManual?: string;
|
|
19
|
+
onChangeManual?: (value: string) => void;
|
|
20
|
+
errorManual?: string;
|
|
21
|
+
}
|
|
22
|
+
declare function RadioBtn({ name, label, options, valueKey, labelKey, iconKey, forceReadOnly, forceHidden, valueManual, onChangeManual, errorManual, }: RadioBtnProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
declare const _default: import('../../../node_modules/react').MemoExoticComponent<typeof RadioBtn>;
|
|
24
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
export interface SelectOption {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
}
|
|
5
|
+
export interface SelectProps {
|
|
6
|
+
name: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
options?: SelectOption[];
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
labelKey?: string;
|
|
11
|
+
valueKey?: string;
|
|
12
|
+
enableSearch?: boolean;
|
|
13
|
+
searchPlaceholder?: string;
|
|
14
|
+
loading?: boolean;
|
|
15
|
+
onSearchChange?: (value: string) => void;
|
|
16
|
+
debounceTime?: number;
|
|
17
|
+
onSelect?: (option: SelectOption) => void;
|
|
18
|
+
forceReadOnly?: boolean;
|
|
19
|
+
forceHidden?: boolean;
|
|
20
|
+
valueManual?: any;
|
|
21
|
+
onChangeManual?: (value: any) => void;
|
|
22
|
+
errorManual?: string;
|
|
23
|
+
}
|
|
24
|
+
declare function Select({ name, label, options, placeholder, labelKey, valueKey, enableSearch, searchPlaceholder, loading, onSearchChange, debounceTime, onSelect, forceReadOnly, forceHidden, valueManual, onChangeManual, errorManual, }: SelectProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
declare const _default: import('../../../node_modules/react').MemoExoticComponent<typeof Select>;
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { default as React } from '../../../node_modules/react';
|
|
2
|
+
|
|
3
|
+
interface ChildOptionsProps {
|
|
4
|
+
label: string;
|
|
5
|
+
action?: () => void;
|
|
6
|
+
id?: string;
|
|
7
|
+
}
|
|
8
|
+
interface ChildProps {
|
|
9
|
+
icon?: string;
|
|
10
|
+
label: string;
|
|
11
|
+
action?: () => void;
|
|
12
|
+
options?: ChildOptionsProps[];
|
|
13
|
+
id?: string;
|
|
14
|
+
}
|
|
15
|
+
interface SideBarProps {
|
|
16
|
+
logo?: string;
|
|
17
|
+
childs?: ChildProps[];
|
|
18
|
+
footer?: React.ReactNode;
|
|
19
|
+
contentExternal: React.ReactNode;
|
|
20
|
+
bg?: string;
|
|
21
|
+
color?: string;
|
|
22
|
+
hoverColor?: string;
|
|
23
|
+
onSelect?: (id?: string) => void;
|
|
24
|
+
}
|
|
25
|
+
export default function SideBar({ logo, childs, footer, contentExternal, bg, color, hoverColor, onSelect, }: SideBarProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { default as React, JSX } from '../../../node_modules/react';
|
|
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
|
+
};
|
|
10
|
+
type SimpleTableColumn = {
|
|
11
|
+
key: string;
|
|
12
|
+
label: string;
|
|
13
|
+
width?: string | number;
|
|
14
|
+
render?: (rowOrProps: any, index?: number, onChange?: (key: string, value: any) => void, isReadOnly?: boolean, isView?: boolean) => React.ReactNode;
|
|
15
|
+
};
|
|
16
|
+
type TableFilter = {
|
|
17
|
+
field: string;
|
|
18
|
+
operator: "===" | "!==" | ">" | "<" | ">=" | "<=";
|
|
19
|
+
value: any;
|
|
20
|
+
} | {
|
|
21
|
+
custom: (row: any) => boolean;
|
|
22
|
+
};
|
|
23
|
+
type SimpleTableProps = {
|
|
24
|
+
name: string;
|
|
25
|
+
title?: string;
|
|
26
|
+
columns: SimpleTableColumn[];
|
|
27
|
+
defaultRowValue?: Record<string, any>;
|
|
28
|
+
forceReadOnly?: boolean;
|
|
29
|
+
layout?: "fluid" | "fixed";
|
|
30
|
+
actions?: boolean;
|
|
31
|
+
filters?: TableFilter[];
|
|
32
|
+
};
|
|
33
|
+
declare const SimpleTable: ({ name, title, columns, defaultRowValue, forceReadOnly, layout, actions, filters, }: SimpleTableProps) => JSX.Element;
|
|
34
|
+
export default SimpleTable;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Control } from 'react-hook-form';
|
|
2
|
+
|
|
3
|
+
export interface TableRow {
|
|
4
|
+
_uid: number;
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
7
|
+
type TableFilter = {
|
|
8
|
+
field: string;
|
|
9
|
+
operator: "===" | "!==" | ">" | "<" | ">=" | "<=";
|
|
10
|
+
value: any;
|
|
11
|
+
} | {
|
|
12
|
+
custom: (row: any) => boolean;
|
|
13
|
+
};
|
|
14
|
+
interface UseSimpleTableProps {
|
|
15
|
+
name: string;
|
|
16
|
+
control: Control<any>;
|
|
17
|
+
defaultRowValue: object;
|
|
18
|
+
isView: boolean;
|
|
19
|
+
isReadOnly: boolean;
|
|
20
|
+
filters?: TableFilter[];
|
|
21
|
+
}
|
|
22
|
+
export declare function useSimpleTable({ name, control, defaultRowValue, isView, isReadOnly, filters, }: UseSimpleTableProps): {
|
|
23
|
+
field: import('react-hook-form').ControllerRenderProps<any, string>;
|
|
24
|
+
tableRows: TableRow[];
|
|
25
|
+
visibleRows: TableRow[];
|
|
26
|
+
selectedRowIds: number[];
|
|
27
|
+
isAllSelected: boolean;
|
|
28
|
+
handle: {
|
|
29
|
+
addRow: () => void;
|
|
30
|
+
removeRows: () => void;
|
|
31
|
+
updateCellValue: (uid: number, key: string, value: any) => void;
|
|
32
|
+
toggleSelection: (uid: number) => void;
|
|
33
|
+
toggleSelectAll: (isChecked: boolean) => void;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { default as React } from '../../../node_modules/react';
|
|
2
|
+
|
|
3
|
+
export interface StatusConfig {
|
|
4
|
+
label: string;
|
|
5
|
+
color: string;
|
|
6
|
+
icon?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface StatusBadgeProps {
|
|
9
|
+
mapping?: Record<number, StatusConfig>;
|
|
10
|
+
defaultLabel?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
hidden?: boolean;
|
|
13
|
+
label?: string;
|
|
14
|
+
}
|
|
15
|
+
declare function StatusBadge({ mapping, defaultLabel, className, hidden, label, }: StatusBadgeProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
declare const _default: React.MemoExoticComponent<typeof StatusBadge>;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface TextAreaProps {
|
|
2
|
+
name: string;
|
|
3
|
+
label?: string;
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
rows?: number;
|
|
7
|
+
maxLength?: number;
|
|
8
|
+
forceReadOnly?: boolean;
|
|
9
|
+
forceHidden?: boolean;
|
|
10
|
+
valueManual?: string;
|
|
11
|
+
onChangeManual?: (val: string) => void;
|
|
12
|
+
errorManual?: string;
|
|
13
|
+
}
|
|
14
|
+
declare const _default: import('../../../node_modules/react').MemoExoticComponent<({ name, label, placeholder, className, rows, maxLength, forceReadOnly, forceHidden, valueManual, onChangeManual, errorManual, }: TextAreaProps) => import("react/jsx-runtime").JSX.Element>;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
export { default as Input } from './Input';
|
|
3
|
+
export { default as Select } from './Select';
|
|
4
|
+
export { default as Checkbox } from './Checkbox';
|
|
5
|
+
export { default as RadioBtn } from './RadioBtn';
|
|
6
|
+
export { default as TextArea } from './TextArea';
|
|
7
|
+
export { default as DatePicker } from './DatePicker';
|
|
8
|
+
export { default as StatusBadge } from './StatusBadge';
|
|
9
|
+
export { default as SimpleTable } from './SimpleTable';
|
|
10
|
+
export { default as Attachment } from './Attachment';
|
|
11
|
+
export { default as Modal } from './Modal';
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{--dfe-primary: #00916d;--dfe-primary-hover: #007a5c;--dfe-primary-fg: #ffffff;--dfe-secondary: #c4d600;--dfe-secondary-hover: #b0c000;--dfe-secondary-fg: #1e293b;--dfe-danger: #ef4444;--dfe-danger-hover: #dc2626;--dfe-aux-01: #2898bd;--dfe-aux-02: #206a83;--dfe-aux-03: #cd519d;--dfe-aux-04: #943d73;--dfe-green: #24d456;--dfe-orange: #ff7f30;--dfe-yellow: #edf11d;--dfe-purple: #a230ff;--dfe-blue: #0e81e6;--dfe-bg: #ffffff;--dfe-fg: #626262;--dfe-border: #d6d8db;--dfe-muted: #e8e9ea;--dfe-muted-fg: #6a6a6a;--dfe-overlay-bg: rgba(255, 255, 255, .8);--dfe-radius: 6px;--dfe-radius-sm: 4px;--dfe-radius-full: 100%;--dfe-gap-xs: 4px;--dfe-gap-sm: 8px;--dfe-gap-md: 12px;--dfe-gap-lg: 16px;--dfe-gap-xl: 32px;--dfe-height-control: 36px;--dfe-font: "Inter", sans-serif;--dfe-font-xs: 12px;--dfe-font-sm: 14px;--dfe-font-md: 16px;--dfe-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--dfe-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .1);--z-table-loading: 50;--z-dropdown: 1050;--z-modal: 1060}html.theme-dark{--dfe-bg: #1c1c1c;--dfe-fg: #c7c7c7;--dfe-border: #3b3b3b;--dfe-muted: #202020;--dfe-muted-fg: #a1a1a1;--dfe-overlay-bg: rgba(0, 0, 0, .7);--dfe-shadow: 0 4px 6px -1px rgba(0, 0, 0, .5)}::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:var(--dfe-bg);border-radius:var(--dfe-radius-full)}::-webkit-scrollbar-thumb{background:var(--dfe-border);border-radius:var(--dfe-radius-full);transition:background .2s ease}::-webkit-scrollbar-thumb:hover{background:var(--dfe-muted-fg)}*{scrollbar-width:thin;scrollbar-color:var(--dfe-border) var(--dfe-bg)}.dfe-modal-body::-webkit-scrollbar-thumb,.dfe-table-container::-webkit-scrollbar-thumb{border:1px solid var(--dfe-bg)}#root{display:flex;width:100%;background-color:var(--dfe-bg);color:var(--dfe-fg)}input,textarea,select{background-color:var(--dfe-bg)!important;color:var(--dfe-fg)!important;border:1px solid var(--dfe-border)!important}input,select{height:34px!important}input:focus,textarea:focus,select:focus{border-color:var(--dfe-primary)!important}input.readOnly,textarea.readOnly,select.readOnly{color:var(--dfe-fg)!important;background-color:var(--dfe-muted)!important;border-color:var(--dfe-border)!important;cursor:not-allowed}textarea{resize:none;min-height:34px!important;max-height:60px}.page-header :is(h1,h2,h3,h4,h5,h6){color:var(--dfe-primary-hover)!important;padding:0!important;margin:0!important}.page-header>h3{display:flex;align-items:center;font-size:22px;gap:10px}.form-group>label{font-weight:200!important;color:var(--dfe-primary)!important;font-size:16px}.text-danger{font-size:12px;color:var(--dfe-danger)!important;margin-top:1px!important}.select-view{display:inline-block;width:100%;border:1px solid var(--dfe-border);border-radius:var(--dfe-radius-sm);background-color:var(--dfe-bg)!important;color:var(--dfe-fg)}.select-wrapper{position:relative;width:100%}.select-control{height:34px;display:flex;align-items:center;justify-content:space-between;cursor:pointer;overflow:hidden;width:100%;font-size:14px;font-weight:200;border-radius:var(--dfe-radius-sm);background-color:var(--dfe-bg)!important;color:var(--dfe-fg)!important;border:1px solid var(--dfe-border)!important;padding:10px 14px}.select-display{width:100%;height:34px;white-space:nowrap;text-overflow:ellipsis;display:flex;align-items:center}.select-dropdown{position:absolute;top:66px;left:0;right:0;z-index:var(--z-dropdown);background-color:var(--dfe-bg)!important;border:1px solid var(--dfe-border)!important;border-radius:var(--dfe-radius-sm)!important;box-shadow:var(--dfe-shadow)!important}.select-search{padding:5px 10px;border-bottom:1px solid var(--dfe-border)}.select-search-input{width:100%;font-size:12px;padding:4px 10px;border:1px solid var(--dfe-border);border-radius:var(--dfe-radius-sm)!important;background-color:var(--dfe-bg)!important;color:var(--dfe-fg)!important}.select-options{list-style:none;margin:0;padding:6px;max-height:200px;overflow-y:auto;margin-bottom:0!important}.select-option{padding:8px 16px;font-size:14px;cursor:pointer;border-radius:var(--dfe-radius-sm);white-space:nowrap;overflow:hidden;margin:0!important;color:var(--dfe-fg)!important}.select-option.readOnly{color:var(--dfe-muted-fg)!important;cursor:default}.handleHover:hover{background-color:var(--dfe-primary)!important;color:var(--dfe-primary-fg)!important;font-weight:700}.border-red{border:1px solid var(--dfe-danger)!important}.text-danger{margin-top:4px;color:var(--dfe-danger)!important;margin-bottom:0!important}.select-wrapper>.readOnly{background-color:var(--dfe-muted)!important;color:var(--dfe-muted-fg)!important;cursor:default}.select-display.readOnly{opacity:.5}.checkbox-group-custom{width:100%;display:grid;grid-template-columns:1fr 1fr 1fr;gap:10px 20px}.custom-checkbox{width:30%;position:relative;display:flex;align-items:center;cursor:pointer;font-size:14px;-webkit-user-select:none;user-select:none;padding-left:20px;white-space:noWrap;margin:0!important}.custom-checkbox input{position:absolute;opacity:0;cursor:pointer}.custom-checkbox .checkmark{position:absolute;top:1px;left:0;height:16px;width:16px;background-color:var(--dfe-bg);border:2px solid var(--dfe-border);border-radius:100%;transition:all .2s ease}.custom-checkbox.checked .checkmark,.custom-checkbox:hover .checkmark{border-color:var(--dfe-primary)}.custom-checkbox.checked .checkmark:after{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:8px;height:8px;background-color:var(--dfe-primary);border-color:var(--dfe-primary);border-radius:100%}.custom-checkbox>span{width:50%;color:var(--dfe-fg);font-weight:200;margin:0}.custom-checkbox.readOnly,.checkbox-group-custom.readOnly{pointer-events:none;opacity:.9}.btn-group{display:flex;gap:8px;margin-top:6px;flex-wrap:wrap}.btn-group>label.btn{--btnBase: var(--dfe-border);--btnText: var(--dfe-fg);--bgColor: var(--customColor, var(--btnBase));--hoverColor: color-mix(in srgb, var(--bgColor), transparent 80%);--borderColor: color-mix(in srgb, var(--bgColor), var(--dfe-fg) 20%);min-width:200px;display:flex;align-items:center;justify-content:center;gap:6px;padding:8px 16px;border:1px solid var(--btnBase);border-radius:var(--dfe-radius);cursor:pointer;background-color:var(--dfe-bg);color:var(--btnText);transition:all .2s ease-in-out;font-weight:400}.btn-group>label.btn:hover{background-color:var(--hoverColor);border-color:var(--borderColor);color:var(--borderColor)}.btn-group label.btn:has(input[type=radio]:checked){background-color:var(--bgColor)!important;border-color:var(--borderColor)!important;color:#fff!important;box-shadow:var(--dfe-shadow);font-weight:600;cursor:default}.btn-group label.btn i{font-size:1.1em}.btn-group.view-mode label.btn{opacity:.5;pointer-events:none;filter:grayscale(100%)}.btn-group.view-mode label.btn:has(input[type=radio]:checked){opacity:1;filter:none;background-color:var(--bgColor)!important;border-color:var(--borderColor)!important;color:#fff!important}.column{display:flex!important;flex-direction:column!important}.dfe-datepicker-container{position:relative;width:100%}.dfe-datepicker-trigger{background-color:var(--dfe-bg)!important;border:1px solid var(--dfe-border)!important;border-radius:var(--dfe-radius, 4px);padding:.375rem .75rem;min-height:var(--dfe-height-control, 38px);color:var(--dfe-fg)!important;display:flex;align-items:center;cursor:pointer;transition:border-color .2s}.dfe-datepicker-trigger:hover{border-color:var(--dfe-primary)!important}.dfe-datepicker-trigger.disabled{background-color:var(--dfe-muted)!important;opacity:.7;cursor:not-allowed}.dfe-popover-content{position:absolute;top:100%;left:0;z-index:var(--z-dropdown, 999999)!important;margin-top:5px;padding:15px;background-color:var(--dfe-bg);border:1px solid var(--dfe-border);border-radius:var(--dfe-radius);box-shadow:var(--dfe-shadow-lg);display:block!important;min-width:280px}.dfe-calendar-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:15px;color:var(--dfe-fg)}.dfe-month-label{font-weight:700;text-transform:capitalize;font-size:14px;color:var(--dfe-fg)}.dfe-nav-btn{background:var(--dfe-muted);border:1px solid var(--dfe-border);border-radius:var(--dfe-radius-sm);cursor:pointer;display:flex;align-items:center;justify-content:center;padding:4px;color:var(--dfe-fg)}.dfe-nav-btn:hover{background-color:var(--dfe-border)}.dfe-calendar-grid-header{display:grid;grid-template-columns:repeat(7,1fr);text-align:center;border-bottom:1px solid var(--dfe-border);margin-bottom:8px}.dfe-calendar-grid-header span{font-size:12px;color:var(--dfe-muted-fg);font-weight:600;padding-bottom:5px}.dfe-calendar-grid{display:grid;grid-template-columns:repeat(7,1fr);text-align:center}.dfe-calendar-day{padding:8px 0;font-size:13px;cursor:pointer;border-radius:var(--dfe-radius-sm);color:var(--dfe-fg);transition:background .2s}.dfe-calendar-day:hover:not(.outside){background-color:var(--dfe-muted)}.dfe-calendar-day.outside{color:var(--dfe-muted-fg);opacity:.3;cursor:default}.dfe-calendar-day.today{color:var(--dfe-primary);font-weight:700;background-color:color-mix(in srgb,var(--dfe-primary),transparent 90%)}.dfe-calendar-day.selected{background-color:var(--dfe-primary)!important;color:var(--dfe-primary-fg)!important;font-weight:700}.react-datepicker{background-color:var(--dfe-bg)!important;border-color:var(--dfe-border)!important;color:var(--dfe-fg)!important}.react-datepicker__header{background-color:var(--dfe-muted)!important;border-bottom:1px solid var(--dfe-border)!important}.status-badge{--badgeMainColor: var(--customColor, var(--dfe-muted-fg));background:linear-gradient(45deg,color-mix(in srgb,var(--badgeMainColor),white 20%) 0%,var(--badgeMainColor) 70%,color-mix(in srgb,var(--badgeMainColor),black 15%) 100%);width:100%;height:var(--dfe-height-control, 34px);display:flex;align-items:center;justify-content:center;gap:var(--dfe-gap-sm);border-radius:var(--dfe-radius-sm);color:#fff;font-weight:500;font-size:var(--dfe-font-sm);font-style:italic;box-shadow:var(--dfe-shadow);transition:transform .2s ease,box-shadow .2s ease}.status-badge i{font-size:16px}.status-badge.default{--badgeMainColor: var(--dfe-muted-fg);background:var(--dfe-muted);color:var(--dfe-muted-fg);border:1px solid var(--dfe-border);box-shadow:none}.form-group.hidden{display:none!important}.table-wrapper .header-actions{display:flex;align-items:center;justify-content:space-between;width:100%;margin-bottom:var(--dfe-gap-lg)}.table-wrapper .header-actions>h3{margin:0!important;font-weight:600;color:var(--dfe-fg)}.table-wrapper .header-actions>div{display:flex;gap:var(--dfe-gap-sm)}.table-wrapper .header-handle{display:flex!important;align-items:center!important;justify-content:space-between!important;margin-bottom:var(--dfe-gap-lg)!important}.table-wrapper .handle-actions{display:flex;align-items:center;gap:var(--dfe-gap-lg)}.table-wrapper{width:100%;height:100%;margin-bottom:20px;overflow:hidden;color:var(--dfe-fg)}.table-wrapper h3{margin:0!important;color:var(--dfe-fg)}.table-wrapper .table-fixed .table-scroll{overflow-x:auto}.table-wrapper .table-fluid .table-scroll{overflow-x:hidden}.table-wrapper .table-scroll{width:100%;position:relative;overflow:auto;height:300px}.table-wrapper .table-fixed th,.table-wrapper .table-fixed td{white-space:nowrap}.table-wrapper .table-custom{width:100%;border-collapse:separate;border-spacing:0;border-radius:var(--dfe-radius-sm);border:1px solid var(--dfe-border);background-color:var(--dfe-bg)}.table-wrapper .btn-add{background-color:var(--dfe-primary);border:none;color:var(--dfe-primary-fg)!important;border-radius:var(--dfe-radius-sm);padding:8px 16px;font-size:var(--dfe-font-sm)!important;cursor:pointer;transition:opacity .2s}.table-wrapper .btn-danger{background-color:var(--dfe-danger)!important;color:#fff!important;border:none}.table-wrapper .table-custom thead{background-color:var(--dfe-muted)}.table-wrapper .table-custom thead tr th{position:sticky;top:0;z-index:2;padding:12px 16px;border-bottom:2px solid var(--dfe-border);border-left:1px solid var(--dfe-border);text-align:left;font-weight:700;color:var(--dfe-fg);background-color:var(--dfe-muted)}.table-wrapper .table-custom thead tr th:first-child{border-left:none}.table-wrapper .table-custom tbody tr td{border-left:1px solid var(--dfe-border);padding:12px 16px;vertical-align:middle;background-color:var(--dfe-bg)}.table-wrapper .table-custom tbody tr td:first-child{border-left:none}.table-wrapper .table-custom tbody tr:nth-child(2n) td{background-color:color-mix(in srgb,var(--dfe-muted),transparent 50%)}.table-wrapper .table-custom tbody tr:hover td{background-color:var(--dfe-muted)}.table-wrapper .table-custom th,.table-wrapper .table-custom td{text-overflow:ellipsis}.table-wrapper .table-custom td{flex-wrap:nowrap}.table-wrapper .table-custom .form-control{margin-bottom:0!important;height:34px}.table-wrapper .text-center{text-align:center}.table-wrapper .table-custom tbody tr.empty-row td{height:200px;vertical-align:middle}.fluig-attachment{margin-bottom:var(--dfe-gap-lg)}.fluig-attachment__label{display:block;margin-bottom:var(--dfe-gap-xs);font-weight:700;color:var(--dfe-fg)}.fluig-attachment__box{display:flex;height:var(--dfe-height-control);justify-content:space-between;align-items:center;padding:0 var(--dfe-gap-md);border-radius:var(--dfe-radius);background-color:transparent;transition:all .2s ease-in-out;border:1px dashed var(--dfe-border);cursor:pointer;overflow:hidden;color:var(--dfe-fg)}.fluig-attachment__box--has-file{border:1px solid var(--dfe-primary);background-color:transparent}.fluig-attachment__box--uploading{cursor:wait;background-color:var(--dfe-muted)}.fluig-attachment__content{display:flex;align-items:center;flex:1;min-width:0;margin-right:var(--dfe-gap-md)}.fluig-attachment__icon{flex-shrink:0;margin-right:var(--dfe-gap-sm);color:var(--dfe-primary)}.fluig-attachment__filename{font-size:var(--dfe-font-sm);color:var(--dfe-fg);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block}.fluig-attachment__btn-remove{padding:4px!important;border:none;background:transparent;cursor:pointer;flex-shrink:0;display:flex;align-items:center;color:var(--dfe-danger)}.fluig-attachment__box.readOnly{background-color:var(--dfe-muted);color:var(--dfe-muted-fg);border-color:var(--dfe-border);cursor:not-allowed}.fluig-attachment__box--uploading .fluigicon-loop-test{animation:spin 2s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.modal-overlay{width:100dvw;height:100dvh;background-color:var(--dfe-overlay-bg);position:fixed;top:0;left:0;z-index:var(--z-modal);display:flex;align-items:center;justify-content:center}.modal-container{width:100%;max-width:90%;background-color:var(--dfe-bg);color:var(--dfe-fg);border-radius:var(--dfe-radius);overflow:hidden;box-shadow:var(--dfe-shadow-lg)}.modal-header{display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--dfe-border)!important}.modal-header h3{font-weight:600;font-size:22px;margin:0!important;color:var(--dfe-fg)}.modal-header .btn-close-modal{background-color:var(--dfe-muted);color:var(--dfe-fg);display:flex;align-items:center;justify-content:center;padding:4px;border-radius:var(--dfe-radius-sm);cursor:pointer;border:1px solid var(--dfe-border);transition:opacity .2s ease}.modal-header .btn-close-modal:hover{opacity:.8}.modal-content{background-color:transparent!important;color:var(--dfe-fg)!important;border-radius:0!important;border:none!important;box-shadow:none!important;padding:var(--dfe-gap-lg)!important;max-height:80dvh;overflow-x:hidden;overflow-y:auto}.modal-footer{border:none!important}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),u=require("react"),E=require("react-hook-form"),K=require("react-imask"),W=require("@fluig-kit/ecm"),D=require("date-fns"),M={cpf:"000.000.000-00",cnpj:"00.000.000/0000-00",telefone:"(00) 00000-0000",cep:"00000-000"};function ee({name:e,label:s="",placeholder:n="",type:a="text",mask:r,className:d="",forceReadOnly:l=!1,forceHidden:o=!1,valueManual:g,onChangeManual:i,errorManual:p}){var S,C;const v=g!==void 0&&!!i,{isReadOnly:P,isHidden:F}=W.useSection(),_=l||!!P(e),$=o||!!F(e),{isView:O}=W.useFluigRuntime();let j=null;try{j=E.useFormContext()}catch{}const x=!v&&j?E.useController({name:e,control:j.control}):null,m=!v&&j?E.useFormState({name:e}):null,f=v?g:x==null?void 0:x.field.value,c=v?p:(C=(S=m==null?void 0:m.errors)==null?void 0:S[e])==null?void 0:C.message,h=u.useMemo(()=>r?M[r]??r:null,[r]),y=u.useCallback(b=>{if(!b)return"";const T=b.replace(/\D/g,"");return(Number(T)/100).toLocaleString("pt-BR",{style:"currency",currency:"BRL"})},[]),k=u.useCallback(b=>a==="monetary"?y(b):b,[a,y]),A=b=>{const T=k(b);v?i==null||i(T):x==null||x.field.onChange(T)},N=()=>{v||x==null||x.field.onBlur()};if(O)return t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:s}),t.jsx("span",{className:"form-control",children:f||"-"})]});const w=`form-control ${_?"readOnly":""} ${c?"border-red":""} ${d}`;return t.jsxs("div",{className:`form-group ${$?"hidden":""}`,children:[s&&t.jsx("label",{children:s}),h?t.jsx(K.IMaskInput,{name:e,mask:h,value:String(f??""),unmask:!1,onAccept:b=>A(b),placeholder:n,readOnly:_,className:w,inputRef:v||x==null?void 0:x.field.ref,onBlur:N}):t.jsx("input",{type:"text",name:e,value:f??"",onChange:b=>A(b.target.value),onBlur:N,placeholder:n,readOnly:_,className:w}),c&&t.jsx("p",{className:"text-danger",children:String(c)})]})}const te=u.memo(ee);function se({name:e,label:s="",options:n=[],placeholder:a="",labelKey:r="label",valueKey:d="value",enableSearch:l=!1,searchPlaceholder:o="Buscar...",loading:g=!1,onSearchChange:i,debounceTime:p=300,onSelect:v,forceReadOnly:P=!1,forceHidden:F=!1,valueManual:_,onChangeManual:$,errorManual:O}){var Q;const j=_!==void 0&&!!$,{isReadOnly:x,isHidden:m}=W.useSection(),f=P||!!x(e),c=F||!!m(e),{isView:h}=W.useFluigRuntime();let y="",k=()=>{},A,N=null,w=()=>{};if(j)y=_;else try{const R=E.useFormContext(),V=E.useController({name:e,control:R.control});y=V.field.value,k=V.field.onChange,A=V.field.ref,N=(Q=V.fieldState)==null?void 0:Q.error,w=R.clearErrors}catch{}const[S,C]=u.useState(!1),[b,T]=u.useState(""),H=u.useRef(null),I=u.useRef(i);u.useEffect(()=>{I.current=i},[i]),u.useEffect(()=>{const R=V=>{H.current&&!H.current.contains(V.target)&&C(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[]),u.useEffect(()=>{S||T("")},[S]),u.useEffect(()=>{if(!l)return;const R=setTimeout(()=>{var V;(V=I.current)==null||V.call(I,b)},p);return()=>clearTimeout(R)},[b,l,p]);const X=u.useMemo(()=>l&&!i&&b.trim()?n.filter(R=>String((R==null?void 0:R[r])??"").toLowerCase().includes(b.toLowerCase())):n??[],[n,l,i,b,r]),U=u.useMemo(()=>{if(y==null)return"";if(typeof y=="object")return String(y[d]??"");const R=(n||[]).find(V=>String(V==null?void 0:V[d])===String(y));return String(R?(R==null?void 0:R[r])??"":y)},[y,n,d,r]),Z=R=>{f||(j?$==null||$(R[d]):(k(R[d]),w==null||w(e)),v==null||v(R),C(!1))};return t.jsxs("div",{className:`select-wrapper form-group ${c?"hidden":""}`,ref:H,children:[t.jsx("label",{className:"control-label",children:s}),h?t.jsx("span",{className:"form-control",children:U||"-"}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`select-control ${N?"border-red":""} ${f?"readOnly":""}`,onClick:()=>!f&&C(R=>!R),ref:A,children:[t.jsx("span",{className:`select-display ${f?"readOnly":""}`,children:U||a}),t.jsx("i",{className:"flaticon flaticon-chevron-down select-icon"})]}),S&&!f&&t.jsxs("div",{className:"select-dropdown",children:[l&&t.jsx("div",{className:"select-search",children:t.jsx("input",{type:"text",className:"select-search-input",value:b,onChange:R=>T(R.target.value),placeholder:g?"Carregando...":o,autoFocus:!0,onClick:R=>R.stopPropagation()})}),t.jsx("ul",{className:"select-options",children:g?t.jsx("li",{className:"select-option readOnly",children:"Carregando..."}):X.length>0?X.map(R=>t.jsx("li",{onClick:()=>Z(R),className:"select-option handleHover",children:R[r]},R[d])):t.jsx("li",{className:"select-option readOnly",children:"Sem resultados"})})]})]}),!j&&t.jsx("input",{type:"hidden",name:e,value:y||""}),(N||O)&&t.jsx("p",{className:"text-danger",children:String((N==null?void 0:N.message)??O)})]})}const ne=u.memo(se);function re({name:e,options:s=[],label:n="",valueKey:a="value",labelKey:r="label",forceReadOnly:d=!1,forceHidden:l=!1,valueManual:o,onChangeManual:g}){var A,N;let i=null;try{i=E.useFormContext()}catch{}const p=o!==void 0&&!!g,{isView:v,isReadOnly:P}=W.useFluigRuntime(),{isReadOnly:F,isHidden:_}=W.useSection(),$=F?F(e):!1,O=_?_(e):!1,j=d||$,x=l||O,m=j||P||v,f=()=>s?s.reduce((w,S)=>{const C=String(S[a]);if(p)w[C]=!!(o!=null&&o[C]);else if(i){const b=i.getValues(C);w[C]=b==="on"}else w[C]=!1;return w},{}):{},c=!p&&i?i.watch(e):void 0,h=u.useMemo(()=>p&&o?o:c&&typeof c=="object"?c:f(),[c,o,s]);u.useEffect(()=>{if(p||!i)return;const w=i.getValues(e);(!w||typeof w!="object")&&i.setValue(e,h,{shouldDirty:!1,shouldValidate:!1})},[h,e,i,p]);const y=(w,S)=>{if(m)return;const C={...h,[w]:S};if(p){g&&g(C);return}i&&(i.setValue(e,C,{shouldDirty:!0,shouldValidate:!0}),i.setValue(w,S?"on":"",{shouldValidate:!1}))},k=p?null:(N=(A=i==null?void 0:i.formState)==null?void 0:A.errors)==null?void 0:N[e];return t.jsxs("div",{className:`form-group ${x?"hidden":""}`,children:[n&&t.jsx("label",{children:n}),t.jsx("div",{className:`checkbox-group-custom ${m?"readOnly":""}`,children:s.map(w=>{const S=String(w[a]),C=h[S]===!0;return t.jsxs("div",{children:[!p&&i&&t.jsx("input",{type:"hidden",...i.register(S)}),t.jsxs("label",{className:`custom-checkbox ${C?"checked":""} ${m?"readOnly":""}`,children:[t.jsx("input",{type:"checkbox",checked:C,disabled:m,onChange:b=>y(S,b.target.checked)}),t.jsx("span",{className:"checkmark"}),t.jsx("span",{children:w[r]})]})]},S)})}),k&&t.jsx("p",{className:"text-danger",children:String(k.message)})]})}function ae({name:e,label:s="",options:n=[],valueKey:a="value",labelKey:r="label",iconKey:d="icon",forceReadOnly:l=!1,forceHidden:o=!1,valueManual:g,onChangeManual:i,errorManual:p}){var y;const v=g!==void 0&&!!i,{isReadOnly:P,isHidden:F}=W.useSection(),_=l||!!P(e),$=o||!!F(e),{isView:O,isReadOnly:j}=W.useFluigRuntime();let x=null,m=null;if(!v)try{const{control:k}=E.useFormContext(),A=E.useController({name:e,control:k});x=A.field,m=(y=A.fieldState)==null?void 0:y.error}catch{}const f=_||j||O,c=v?g:(x==null?void 0:x.value)??"",h=u.useCallback(k=>{f||(v?i==null||i(k):x==null||x.onChange(k))},[f,v,i,x]);return t.jsxs("div",{className:`form-group column ${$?"hidden":""}`,children:[s&&t.jsx("label",{className:"control-label",children:s}),t.jsx("div",{className:`btn-group ${f?"view-mode":""}`,"data-field-name":e,children:n.map(k=>{const A=k[a],N=c===A,w=k.color?{"--customColor":k.color}:void 0;return t.jsxs("label",{htmlFor:`${e}_${A}`,style:w,className:`btn fs-ellipsis ${N?"active":""}`,children:[t.jsx("input",{type:"radio",id:`${e}_${A}`,name:e,value:A,checked:N,className:"hidden",onChange:()=>h(A),disabled:f}),k[d]&&t.jsx("i",{className:`${k[d]} icon-sm`})," ",k[r]]},A)})}),(m||p)&&t.jsx("p",{className:"text-danger",children:String((m==null?void 0:m.message)??p)})]})}const ie=u.memo(ae),oe=({name:e,label:s="",placeholder:n="",className:a="",rows:r=4,maxLength:d,forceReadOnly:l=!1,forceHidden:o=!1,valueManual:g,onChangeManual:i,errorManual:p})=>{var h;const v=g!==void 0&&!!i,{isReadOnly:P,isHidden:F}=W.useSection(),_=l||!!P(e),$=o||!!F(e),{isView:O}=W.useFluigRuntime(),j=u.useRef(null);let x={value:g??"",onChange:y=>i==null?void 0:i(y)},m=null;if(!v)try{const{control:y}=E.useFormContext(),k=E.useController({name:e,control:y});x=k.field,m=(h=k.fieldState)==null?void 0:h.error}catch{}const f=()=>{j.current&&(j.current.style.height="auto",j.current.style.height=`${j.current.scrollHeight}px`)};if(u.useEffect(()=>{f()},[x.value]),O)return t.jsxs("div",{className:`form-group ${$?"hidden":""}`,children:[t.jsx("label",{children:s}),t.jsx("span",{className:"form-control",children:x.value||"-"})]});const c=`form-control ${_?"readOnly":""} ${m||p?"border-red":""} ${a}`;return t.jsxs("div",{className:`form-group ${$?"hidden":""}`,children:[s&&t.jsx("label",{children:s}),t.jsx("textarea",{ref:j,rows:r,maxLength:d,value:x.value||"",placeholder:n,readOnly:_,className:c,style:{resize:"none",maxHeight:"400px",overflowY:"auto"},onChange:y=>{v?i==null||i(y.target.value):x.onChange(y)},onInput:f}),(m||p)&&t.jsx("p",{className:"text-danger",children:String((m==null?void 0:m.message)??p)})]})},ce=u.memo(oe);function B(e){return(s={})=>{const n=s.width?String(s.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}function q(e){return(s,n)=>{const a=n!=null&&n.context?String(n.context):"standalone";let r;if(a==="formatting"&&e.formattingValues){const l=e.defaultFormattingWidth||e.defaultWidth,o=n!=null&&n.width?String(n.width):l;r=e.formattingValues[o]||e.formattingValues[l]}else{const l=e.defaultWidth,o=n!=null&&n.width?String(n.width):e.defaultWidth;r=e.values[o]||e.values[l]}const d=e.argumentCallback?e.argumentCallback(s):s;return r[d]}}function L(e){return(s,n={})=>{const a=n.width,r=a&&e.matchPatterns[a]||e.matchPatterns[e.defaultMatchWidth],d=s.match(r);if(!d)return null;const l=d[0],o=a&&e.parsePatterns[a]||e.parsePatterns[e.defaultParseWidth],g=Array.isArray(o)?le(o,v=>v.test(l)):de(o,v=>v.test(l));let i;i=e.valueCallback?e.valueCallback(g):g,i=n.valueCallback?n.valueCallback(i):i;const p=s.slice(l.length);return{value:i,rest:p}}}function de(e,s){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&s(e[n]))return n}function le(e,s){for(let n=0;n<e.length;n++)if(s(e[n]))return n}function ue(e){return(s,n={})=>{const a=s.match(e.matchPattern);if(!a)return null;const r=a[0],d=s.match(e.parsePattern);if(!d)return null;let l=e.valueCallback?e.valueCallback(d[0]):d[0];l=n.valueCallback?n.valueCallback(l):l;const o=s.slice(r.length);return{value:l,rest:o}}}const me={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"}},fe=(e,s,n)=>{let a;const r=me[e];return typeof r=="string"?a=r:s===1?a=r.one:a=r.other.replace("{{count}}",String(s)),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"em "+a:"há "+a:a},he={full:"EEEE, d 'de' MMMM 'de' y",long:"d 'de' MMMM 'de' y",medium:"d MMM y",short:"dd/MM/yyyy"},xe={full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},pe={full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ye={date:B({formats:he,defaultWidth:"full"}),time:B({formats:xe,defaultWidth:"full"}),dateTime:B({formats:pe,defaultWidth:"full"})},ge={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"},ve=(e,s,n,a)=>{const r=ge[e];return typeof r=="function"?r(s):r},be={narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},je={narrow:["1","2","3","4"],abbreviated:["T1","T2","T3","T4"],wide:["1º trimestre","2º trimestre","3º trimestre","4º trimestre"]},we={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"]},ke={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"]},Ne={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"}},Se={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"}},Re=(e,s)=>{const n=Number(e);return(s==null?void 0:s.unit)==="week"?n+"ª":n+"º"},Pe={ordinalNumber:Re,era:q({values:be,defaultWidth:"wide"}),quarter:q({values:je,defaultWidth:"wide",argumentCallback:e=>e-1}),month:q({values:we,defaultWidth:"wide"}),day:q({values:ke,defaultWidth:"wide"}),dayPeriod:q({values:Ne,defaultWidth:"wide",formattingValues:Se,defaultFormattingWidth:"wide"})},$e=/^(\d+)[ºªo]?/i,Ce=/\d+/i,_e={narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|d\.?\s?c\.?)/i,wide:/^(antes de cristo|depois de cristo)/i},Oe={any:[/^ac/i,/^dc/i],wide:[/^antes de cristo/i,/^depois de cristo/i]},Ae={narrow:/^[1234]/i,abbreviated:/^T[1234]/i,wide:/^[1234](º)? trimestre/i},Fe={any:[/1/i,/2/i,/3/i,/4/i]},Ee={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},We={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]},De={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},Te={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},He={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}},Ie={ordinalNumber:ue({matchPattern:$e,parsePattern:Ce,valueCallback:e=>parseInt(e,10)}),era:L({matchPatterns:_e,defaultMatchWidth:"wide",parsePatterns:Oe,defaultParseWidth:"any"}),quarter:L({matchPatterns:Ae,defaultMatchWidth:"wide",parsePatterns:Fe,defaultParseWidth:"any",valueCallback:e=>e+1}),month:L({matchPatterns:Ee,defaultMatchWidth:"wide",parsePatterns:We,defaultParseWidth:"any"}),day:L({matchPatterns:De,defaultMatchWidth:"wide",parsePatterns:Te,defaultParseWidth:"any"}),dayPeriod:L({matchPatterns:Ve,defaultMatchWidth:"any",parsePatterns:He,defaultParseWidth:"any"})},qe={code:"pt-BR",formatDistance:fe,formatLong:ye,formatRelative:ve,localize:Pe,match:Ie,options:{weekStartsOn:0,firstWeekContainsDate:1}};/**
|
|
2
|
+
* @license lucide-react v0.575.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const G=(...e)=>e.filter((s,n,a)=>!!s&&s.trim()!==""&&a.indexOf(s)===n).join(" ").trim();/**
|
|
7
|
+
* @license lucide-react v0.575.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const Le=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
|
|
12
|
+
* @license lucide-react v0.575.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const Be=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(s,n,a)=>a?a.toUpperCase():n.toLowerCase());/**
|
|
17
|
+
* @license lucide-react v0.575.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const Y=e=>{const s=Be(e);return s.charAt(0).toUpperCase()+s.slice(1)};/**
|
|
22
|
+
* @license lucide-react v0.575.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/var ze={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
27
|
+
* @license lucide-react v0.575.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const Xe=e=>{for(const s in e)if(s.startsWith("aria-")||s==="role"||s==="title")return!0;return!1};/**
|
|
32
|
+
* @license lucide-react v0.575.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const Ue=u.forwardRef(({color:e="currentColor",size:s=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:r="",children:d,iconNode:l,...o},g)=>u.createElement("svg",{ref:g,...ze,width:s,height:s,stroke:e,strokeWidth:a?Number(n)*24/Number(s):n,className:G("lucide",r),...!d&&!Xe(o)&&{"aria-hidden":"true"},...o},[...l.map(([i,p])=>u.createElement(i,p)),...Array.isArray(d)?d:[d]]));/**
|
|
37
|
+
* @license lucide-react v0.575.0 - ISC
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the ISC license.
|
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/const z=(e,s)=>{const n=u.forwardRef(({className:a,...r},d)=>u.createElement(Ue,{ref:d,iconNode:s,className:G(`lucide-${Le(Y(e))}`,`lucide-${e}`,a),...r}));return n.displayName=Y(e),n};/**
|
|
42
|
+
* @license lucide-react v0.575.0 - ISC
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the ISC license.
|
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/const Qe=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Ye=z("calendar",Qe);/**
|
|
47
|
+
* @license lucide-react v0.575.0 - ISC
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the ISC license.
|
|
50
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
+
*/const Ge=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Je=z("chevron-left",Ge);/**
|
|
52
|
+
* @license lucide-react v0.575.0 - ISC
|
|
53
|
+
*
|
|
54
|
+
* This source code is licensed under the ISC license.
|
|
55
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
+
*/const Ze=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ke=z("chevron-right",Ze);function Me(e){const s=u.useRef(null);return u.useEffect(()=>{function n(a){s.current&&!s.current.contains(a.target)&&e()}return document.addEventListener("mousedown",n),()=>{document.removeEventListener("mousedown",n)}},[e]),s}const J="dd/MM/yyyy",et=e=>{if(!e)return null;const s=D.parse(e,J,new Date);return D.isValid(s)?s:null},tt=e=>e?D.format(e,J):"",st=({name:e,label:s="",placeholder:n="dd/mm/aaaa",className:a="",forceReadOnly:r=!1,forceHidden:d=!1,valueManual:l,onChangeManual:o,errorManual:g})=>{var w;const[i,p]=u.useState(!1),[v,P]=u.useState(new Date),F=Me(()=>p(!1)),_=l!==void 0&&!!o;let $=null;try{$=E.useFormContext()}catch{}const{isView:O}=W.useFluigRuntime(),{isReadOnly:j,isHidden:x}=W.useSection(),m=r||!!j(e),f=d||!!x(e),c=!_&&$?E.useController({name:e,control:$.control}):null,h=_?l:c==null?void 0:c.field.value,y=_?g:(w=c==null?void 0:c.fieldState.error)==null?void 0:w.message,k=u.useMemo(()=>et(h),[h]),A=S=>{if(m)return;const C=tt(S);_?o==null||o(C):c==null||c.field.onChange(C),p(!1)},N=S=>{const C=D.eachDayOfInterval({start:D.startOfWeek(D.startOfMonth(S)),end:D.endOfWeek(D.endOfMonth(S))});return t.jsxs("div",{className:"dfe-calendar-pane",children:[t.jsxs("div",{className:"dfe-calendar-header",children:[t.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),P(D.subMonths(v,1))},className:"dfe-nav-btn",children:t.jsx(Je,{size:16})}),t.jsx("span",{className:"dfe-month-label",children:D.format(S,"MMMM yyyy",{locale:qe})}),t.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),P(D.addMonths(v,1))},className:"dfe-nav-btn",children:t.jsx(Ke,{size:16})})]}),t.jsx("div",{className:"dfe-calendar-grid-header",children:["D","S","T","Q","Q","S","S"].map((b,T)=>t.jsx("span",{children:b},T))}),t.jsx("div",{className:"dfe-calendar-grid",children:C.map((b,T)=>{const H=!D.isSameMonth(b,S),I=k&&D.isSameDay(b,k);return t.jsx("div",{onClick:()=>!H&&A(b),className:`dfe-calendar-day
|
|
57
|
+
${I?"selected":""}
|
|
58
|
+
${H?"outside":""}
|
|
59
|
+
${D.isToday(b)?"today":""}`,children:D.format(b,"d")},T)})})]})};return f?null:O?t.jsxs("div",{className:`form-group ${a}`,children:[s&&t.jsx("label",{children:s}),t.jsx("span",{className:"form-control readOnly",style:{display:"block",height:"auto"},children:h||"-"})]}):t.jsxs("div",{ref:F,className:`form-group dfe-datepicker-container ${a}`,style:{position:"relative"},children:[s&&t.jsx("label",{children:s}),t.jsxs("div",{className:`form-control dfe-datepicker-trigger ${y?"border-red":""} ${m?"disabled":""}`,onClick:()=>!m&&p(!i),style:{display:"flex",alignItems:"center",cursor:m?"default":"pointer"},children:[t.jsx(Ye,{size:16,className:"dfe-calendar-icon",style:{marginRight:"8px",opacity:.5}}),t.jsx("span",{children:h||n})]}),i&&!m&&t.jsx("div",{className:"dfe-popover-content",children:t.jsx("div",{className:"dfe-calendars-wrapper",children:N(v)})}),y&&t.jsx("p",{className:"text-danger",children:String(y)})]})},nt=u.memo(st);function rt({mapping:e={},defaultLabel:s="Não reconhecido",className:n="",hidden:a=!1,label:r}){const{activityId:d}=W.useFluigRuntime(),l=u.useMemo(()=>!e||d===null||d===void 0?null:e[d],[d,e]);if(!l)return t.jsxs("div",{className:`form-group ${a?"hidden":""}`,children:[r&&t.jsx("label",{children:r}),t.jsx("div",{className:`status-badge default ${n}`,children:s})]});const o={"--customColor":l.color};return t.jsxs("div",{className:`form-group ${a?"hidden":""}`,children:[r&&t.jsx("label",{children:r}),t.jsxs("div",{className:`status-badge ${n}`,style:o,children:[l.icon&&t.jsx("i",{className:l.icon}),t.jsx("span",{children:l.label})]})]})}const at=u.memo(rt);function it({name:e,control:s,defaultRowValue:n,isView:a,isReadOnly:r,filters:d=[]}){const{field:l}=E.useController({name:e,control:s}),[o,g]=u.useState([]),[i,p]=u.useState([]),v=()=>Date.now()+Math.random(),P=f=>{try{const c=JSON.parse(f);return Array.isArray(c)?c.map(h=>({...h,_uid:h._uid||v()})):[]}catch(c){return console.error(`Erro ao ler dados da tabela "${e}":`,c),[]}};u.useEffect(()=>{if(!(o.length>0&&!a)&&l.value&&typeof l.value=="string"){const f=JSON.stringify(o);if(l.value===f)return;const c=P(l.value);g(c)}},[l.value,a]),u.useEffect(()=>{if(r)return;const f=JSON.stringify(o);l.value!==f&&l.onChange(f)},[o,l,r]);const F=u.useCallback(()=>{const f={_uid:v(),...n};g(c=>[...c,f])},[n]),_=u.useCallback(()=>{g(f=>f.filter(c=>!i.includes(c._uid))),p([])},[i]),$=u.useCallback((f,c,h)=>{g(y=>y.map(k=>k._uid===f?{...k,[c]:h}:k))},[]),O=u.useCallback(f=>{p(c=>c.includes(f)?c.filter(h=>h!==f):[...c,f])},[]),j=u.useCallback(f=>{p(f?o.map(c=>c._uid):[])},[o]),x=o.length>0&&i.length===o.length,m=u.useMemo(()=>!d||d.length===0?o:o.filter(f=>d.every(c=>{if("custom"in c)return c.custom(f);const h=f[c.field];switch(c.operator){case"===":return h===c.value;case"!==":return h!==c.value;case">":return h>c.value;case"<":return h<c.value;case">=":return h>=c.value;case"<=":return h<=c.value;default:return!0}})),[o,d]);return{field:l,tableRows:o,visibleRows:m,selectedRowIds:i,isAllSelected:x,handle:{addRow:F,removeRows:_,updateCellValue:$,toggleSelection:O,toggleSelectAll:j}}}const ot=({name:e,title:s="Tabela Dinâmica",columns:n,defaultRowValue:a={},forceReadOnly:r=!1,layout:d="fluid",actions:l=!0,filters:o=[]})=>{const{control:g}=E.useFormContext(),{isView:i,isReadOnly:p}=W.useFluigRuntime(),{isReadOnly:v}=W.useSection(),P=r||i||p||v&&v(e),{field:F,visibleRows:_,selectedRowIds:$,isAllSelected:O,handle:j}=it({name:e,control:g,defaultRowValue:a,isView:i,isReadOnly:!!P,filters:o}),x=d==="fixed";return t.jsxs("div",{className:`table-wrapper ${x?"table-fixed":"table-fluid"}`,children:[t.jsx("input",{type:"hidden",...F}),t.jsxs("div",{className:"header-handle",children:[t.jsx("h3",{children:s}),!P&&l&&t.jsxs("div",{className:"handle-actions",children:[t.jsxs("button",{type:"button",className:`btn ${$.length>0?"btn-danger":"btn-primary"}`,disabled:$.length===0,onClick:j.removeRows,children:["Remover (",$.length,")"]}),t.jsx("button",{type:"button",className:"btn-add",onClick:j.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:[!P&&t.jsx("th",{style:{width:"50px"},children:t.jsx("input",{type:"checkbox",checked:O,onChange:m=>j.toggleSelectAll(m.target.checked)})}),n.map(m=>t.jsx("th",{style:m.width?{minWidth:x?m.width:"100%"}:{width:"max-content"},children:m.label},m.key))]})}),t.jsxs("tbody",{children:[_.map((m,f)=>t.jsxs("tr",{children:[!P&&t.jsx("td",{children:t.jsx("input",{type:"checkbox",checked:$.includes(m._uid),onChange:()=>j.toggleSelection(m._uid)})}),n.map(c=>t.jsx("td",{children:c.render?c.render.length<=1?c.render({row:m,index:f,updateRow:(h,y)=>j.updateCellValue(m._uid,h,y),isLocked:!!P,isView:!!i}):c.render(m,f,(h,y)=>j.updateCellValue(m._uid,h,y),!!P,!!i):m[c.key]},`${m._uid}-${c.key}`))]},m._uid)),_.length===0&&t.jsx("tr",{className:"empty-row",children:t.jsx("td",{colSpan:100,className:"text-center",children:P?"Nenhum registro encontrado.":"Nenhum registro."})})]})]})})]})},ct=(e,s)=>{const[n,a]=u.useState(null);let r=null;try{r=E.useFormContext().watch}catch{}const d=s!==void 0?s:r?r(e):void 0,l=u.useCallback(()=>{try{const g=window.top.__REACT_ATTACHMENT_BRIDGE__;if(g){const i=g.getAttachment(e,d);a(i||(d?{name:d,documentId:0}:null))}else a(d?{name:d,documentId:0}:null)}catch{a(d?{name:d,documentId:0}:null)}},[e,d,s]);return u.useEffect(()=>{l();const o=setInterval(l,2e3);return()=>clearInterval(o)},[l]),{attachment:n,sync:l}},dt=({name:e,label:s,help:n,valueManual:a,onChangeManual:r,forceReadOnly:d=!1,forceHidden:l=!1})=>{const o=a!==void 0&&!!r,{isReadOnly:g,isHidden:i}=W.useSection(),p=d||!!g(e),v=l||!!i(e),{isView:P}=W.useFluigRuntime(),[F,_]=u.useState(!1);let $=null;try{$=E.useFormContext().control}catch{}const O=$&&!o?E.useController({name:e,control:$}).field:{value:a,onChange:N=>r==null?void 0:r(N)},{attachment:j,sync:x}=ct(e,a),m=()=>{var N;try{const w=window.top;return{bridge:w.__REACT_ATTACHMENT_BRIDGE__,toast:(N=w.FLUIGC)==null?void 0:N.toast}}catch{return{bridge:null,toast:null}}},f=u.useCallback(()=>{if(p||P)return;const N=document.createElement("input");N.type="file",N.onchange=w=>{const S=w.target.files[0];if(!S)return;const{bridge:C,toast:b}=m();_(!0),C?C.upload(S,e,T=>{o?r==null||r(T.name):O.onChange(T.name),setTimeout(()=>{_(!1),x()},1e3),b&&b({title:"Sucesso",message:"Arquivo enviado",type:"success"})}):(o?r==null||r(S.name):O.onChange(S.name),_(!1))},N.click()},[e,O,x,r,p,o,P]),c=N=>{if(N.stopPropagation(),p||P)return;const w=(j==null?void 0:j.name)||a||O.value;if(!w)return;const{bridge:S,toast:C}=m();S?S.removeByFileName(w)?(o?r==null||r(""):O.onChange(""),x()):C&&C({title:"Erro",message:"Erro ao remover anexo",type:"danger"}):(o?r==null||r(""):O.onChange(""),x())},h=!!j&&!F,y=(j==null?void 0:j.name)||a||O.value,k=["fluig-attachment__box",h?"fluig-attachment__box--has-file":"",F?"fluig-attachment__box--uploading":"",p?"readOnly":""].join(" "),A=(p||P)&&!h;return P?t.jsxs("div",{className:`form-group fluig-attachment ${v?"hidden":""}`,children:[s&&t.jsx("label",{className:"fluig-attachment__label",children:s}),t.jsx("span",{className:"fluig-attachment__box readOnly",children:y||"-"})]}):t.jsxs("div",{className:`form-group fluig-attachment ${v?"hidden":""}`,children:[s&&t.jsx("label",{className:"fluig-attachment__label",children:s}),t.jsxs("div",{className:k,style:A?{pointerEvents:"none",opacity:.6,cursor:"not-allowed"}:{},onClick:()=>{if(h){const N=m();N.bridge&&y&&N.bridge.view(y)}else f()},children:[t.jsxs("span",{className:"fluig-attachment__content",children:[t.jsx("i",{className:`fluigicon icon-sm ${F?"fluigicon-loop-test":h?"fluigicon-file-pdf":"fluigicon-paperclip"} fluig-attachment__icon`}),t.jsx("span",{className:"fluig-attachment__filename",children:F?" Enviando...":h?y:p?"Nenhum arquivo":n||"Anexar"})]}),h&&!p&&!P&&t.jsx("button",{type:"button",className:"fluig-attachment__btn-remove btn btn-link text-danger",onClick:c,children:t.jsx("i",{className:"flaticon flaticon-trash icon-sm"})})]}),!o&&$&&t.jsx("input",{type:"hidden",name:e,value:O.value||""})]})},lt=u.memo(dt);function ut({title:e,isOpen:s,onOpen:n,onClose:a,content:r,footer:d,width:l}){const o=u.useCallback(g=>{g.key==="Escape"&&a()},[a]);return u.useEffect(()=>(s&&(document.addEventListener("keydown",o),n==null||n(),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",o),document.body.style.overflow="auto"}),[s,o,n]),s?t.jsx("div",{className:"modal-overlay",onClick:a,"aria-modal":"true",role:"dialog",children:t.jsxs("div",{style:{maxWidth:l},className:"modal-container",onClick:g=>g.stopPropagation(),children:[t.jsxs("div",{className:"modal-header",children:[t.jsx("h3",{children:e}),t.jsx("div",{className:"btn-close-modal",onClick:a,role:"button","aria-label":"Fechar modal",children:t.jsx("i",{className:"flaticon flaticon-close icon-md","aria-hidden":"true"})})]}),t.jsx("div",{className:"modal-content",children:r}),d&&t.jsx("div",{className:"modal-footer",children:d})]})}):null}exports.Attachment=lt;exports.Checkbox=re;exports.DatePicker=nt;exports.Input=te;exports.Modal=ut;exports.RadioBtn=ie;exports.Select=ne;exports.SimpleTable=ot;exports.StatusBadge=at;exports.TextArea=ce;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/index'
|