teraprox-ui-kit 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +149 -1
- package/dist/index.d.ts +149 -1
- package/dist/index.js +852 -72
- package/dist/index.mjs +853 -68
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -21,9 +21,207 @@ var DeleteButton = ({ title, onDeleteClick }) => {
|
|
|
21
21
|
};
|
|
22
22
|
var DeleteButton_default = DeleteButton;
|
|
23
23
|
|
|
24
|
-
// src/
|
|
25
|
-
import {
|
|
24
|
+
// src/buttons/ActionButtons.tsx
|
|
25
|
+
import { useState as useState2, useRef } from "react";
|
|
26
|
+
import { Button as Button4, Form as Form2, ProgressBar } from "react-bootstrap";
|
|
27
|
+
import { FiSave, FiTrash2, FiRotateCcw, FiCopy, FiChevronLeft } from "react-icons/fi";
|
|
28
|
+
|
|
29
|
+
// src/forms/DeleteConfirm.tsx
|
|
30
|
+
import { useState } from "react";
|
|
31
|
+
import { Button as Button3, Modal, Form } from "react-bootstrap";
|
|
26
32
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
33
|
+
var DeleteConfirm = ({
|
|
34
|
+
show,
|
|
35
|
+
onHide,
|
|
36
|
+
onConfirm,
|
|
37
|
+
title = "Confirma\xE7\xE3o de Exclus\xE3o",
|
|
38
|
+
dialogText,
|
|
39
|
+
payload,
|
|
40
|
+
needExclusionDetails = false
|
|
41
|
+
}) => {
|
|
42
|
+
const [exclusionDetails, setExclusionDetails] = useState("");
|
|
43
|
+
const getDialogContent = () => {
|
|
44
|
+
if (typeof dialogText === "function" && payload) {
|
|
45
|
+
return dialogText(payload);
|
|
46
|
+
}
|
|
47
|
+
return dialogText || "Voc\xEA tem certeza que deseja excluir este item?";
|
|
48
|
+
};
|
|
49
|
+
const isConfirmEnabled = () => {
|
|
50
|
+
if (!needExclusionDetails) return true;
|
|
51
|
+
return exclusionDetails.length >= 8;
|
|
52
|
+
};
|
|
53
|
+
return /* @__PURE__ */ jsxs(Modal, { show, onHide: () => onHide(false), centered: true, children: [
|
|
54
|
+
/* @__PURE__ */ jsx3(Modal.Header, { closeButton: true, children: /* @__PURE__ */ jsx3(Modal.Title, { children: title }) }),
|
|
55
|
+
/* @__PURE__ */ jsx3(Modal.Body, { children: /* @__PURE__ */ jsxs("div", { className: "d-flex flex-column gap-3", children: [
|
|
56
|
+
/* @__PURE__ */ jsx3("div", { children: /* @__PURE__ */ jsx3("strong", { children: getDialogContent() }) }),
|
|
57
|
+
needExclusionDetails && /* @__PURE__ */ jsxs(Form.Group, { children: [
|
|
58
|
+
/* @__PURE__ */ jsx3(Form.Label, { children: "Motivo da Exclus\xE3o (m\xEDn. 8 caracteres)" }),
|
|
59
|
+
/* @__PURE__ */ jsx3(
|
|
60
|
+
Form.Control,
|
|
61
|
+
{
|
|
62
|
+
as: "textarea",
|
|
63
|
+
rows: 3,
|
|
64
|
+
value: exclusionDetails,
|
|
65
|
+
onChange: (e) => setExclusionDetails(e.target.value),
|
|
66
|
+
placeholder: "Descreva o motivo...",
|
|
67
|
+
autoFocus: true
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
] })
|
|
71
|
+
] }) }),
|
|
72
|
+
/* @__PURE__ */ jsxs(Modal.Footer, { children: [
|
|
73
|
+
/* @__PURE__ */ jsx3(Button3, { variant: "secondary", onClick: () => onHide(false), children: "Cancelar" }),
|
|
74
|
+
/* @__PURE__ */ jsx3(
|
|
75
|
+
Button3,
|
|
76
|
+
{
|
|
77
|
+
variant: "danger",
|
|
78
|
+
disabled: !isConfirmEnabled(),
|
|
79
|
+
onClick: () => {
|
|
80
|
+
onConfirm(exclusionDetails);
|
|
81
|
+
onHide(false);
|
|
82
|
+
},
|
|
83
|
+
children: "Confirmar Exclus\xE3o"
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
] })
|
|
87
|
+
] });
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// src/buttons/ActionButtons.tsx
|
|
91
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
92
|
+
var ActionButtons = ({
|
|
93
|
+
onSave,
|
|
94
|
+
saveLabel = "Salvar",
|
|
95
|
+
saveVariant = "primary",
|
|
96
|
+
disabled = false,
|
|
97
|
+
onDelete,
|
|
98
|
+
deleteLabel = "Excluir",
|
|
99
|
+
deleteConfirmMsg,
|
|
100
|
+
needExclusionDetails = false,
|
|
101
|
+
onBack,
|
|
102
|
+
backLabel = "Voltar",
|
|
103
|
+
onCancelEdit,
|
|
104
|
+
cancelEditLabel = "Cancelar",
|
|
105
|
+
onCopy,
|
|
106
|
+
copyLabel = "Copiar Formul\xE1rio",
|
|
107
|
+
isEditing = false,
|
|
108
|
+
useDelayedDelete = false,
|
|
109
|
+
delayedDeleteTimeout = 3e3,
|
|
110
|
+
PermissionWrapper = ({ children }) => /* @__PURE__ */ jsx4(Fragment, { children })
|
|
111
|
+
}) => {
|
|
112
|
+
const [showConfirm, setShowConfirm] = useState2(false);
|
|
113
|
+
const [isHolding, setIsHolding] = useState2(false);
|
|
114
|
+
const [progress, setProgress] = useState2(0);
|
|
115
|
+
const timeoutRef = useRef(null);
|
|
116
|
+
const intervalRef = useRef(null);
|
|
117
|
+
const startHold = () => {
|
|
118
|
+
if (disabled || !onDelete) return;
|
|
119
|
+
setIsHolding(true);
|
|
120
|
+
setProgress(0);
|
|
121
|
+
const step = 2;
|
|
122
|
+
const tickTime = delayedDeleteTimeout / (100 / step);
|
|
123
|
+
intervalRef.current = setInterval(() => {
|
|
124
|
+
setProgress((prev) => prev >= 100 ? 100 : prev + step);
|
|
125
|
+
}, tickTime);
|
|
126
|
+
timeoutRef.current = setTimeout(() => {
|
|
127
|
+
stopHold();
|
|
128
|
+
onDelete();
|
|
129
|
+
}, delayedDeleteTimeout);
|
|
130
|
+
};
|
|
131
|
+
const stopHold = () => {
|
|
132
|
+
setIsHolding(false);
|
|
133
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
134
|
+
if (intervalRef.current) clearInterval(intervalRef.current);
|
|
135
|
+
setProgress(0);
|
|
136
|
+
};
|
|
137
|
+
const renderDeleteButton = () => {
|
|
138
|
+
if (!onDelete || !isEditing) return null;
|
|
139
|
+
if (useDelayedDelete) {
|
|
140
|
+
return /* @__PURE__ */ jsxs2("div", { style: { position: "relative", display: "inline-block", margin: 2 }, children: [
|
|
141
|
+
/* @__PURE__ */ jsxs2(
|
|
142
|
+
Button4,
|
|
143
|
+
{
|
|
144
|
+
variant: "outline-danger",
|
|
145
|
+
onMouseDown: startHold,
|
|
146
|
+
onMouseUp: stopHold,
|
|
147
|
+
onMouseLeave: stopHold,
|
|
148
|
+
onTouchStart: startHold,
|
|
149
|
+
onTouchEnd: stopHold,
|
|
150
|
+
disabled,
|
|
151
|
+
style: { minWidth: "120px" },
|
|
152
|
+
children: [
|
|
153
|
+
/* @__PURE__ */ jsx4(FiTrash2, { className: "me-2" }),
|
|
154
|
+
isHolding ? "Segure..." : deleteLabel
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
),
|
|
158
|
+
isHolding && /* @__PURE__ */ jsx4(
|
|
159
|
+
ProgressBar,
|
|
160
|
+
{
|
|
161
|
+
now: progress,
|
|
162
|
+
style: {
|
|
163
|
+
position: "absolute",
|
|
164
|
+
bottom: 0,
|
|
165
|
+
left: 0,
|
|
166
|
+
right: 0,
|
|
167
|
+
height: "4px",
|
|
168
|
+
borderRadius: "0 0 4px 4px"
|
|
169
|
+
},
|
|
170
|
+
variant: "danger"
|
|
171
|
+
}
|
|
172
|
+
)
|
|
173
|
+
] });
|
|
174
|
+
}
|
|
175
|
+
return /* @__PURE__ */ jsxs2(
|
|
176
|
+
Button4,
|
|
177
|
+
{
|
|
178
|
+
variant: "danger",
|
|
179
|
+
onClick: () => setShowConfirm(true),
|
|
180
|
+
disabled,
|
|
181
|
+
style: { margin: 2 },
|
|
182
|
+
children: [
|
|
183
|
+
/* @__PURE__ */ jsx4(FiTrash2, { className: "me-2" }),
|
|
184
|
+
deleteLabel
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
};
|
|
189
|
+
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
190
|
+
/* @__PURE__ */ jsx4(
|
|
191
|
+
DeleteConfirm,
|
|
192
|
+
{
|
|
193
|
+
show: showConfirm,
|
|
194
|
+
onHide: setShowConfirm,
|
|
195
|
+
onConfirm: (details) => onDelete && onDelete(details),
|
|
196
|
+
dialogText: deleteConfirmMsg,
|
|
197
|
+
needExclusionDetails
|
|
198
|
+
}
|
|
199
|
+
),
|
|
200
|
+
/* @__PURE__ */ jsxs2(Form2.Group, { className: "d-flex flex-wrap align-items-center mt-3 gap-1", children: [
|
|
201
|
+
onBack && /* @__PURE__ */ jsxs2(Button4, { variant: "outline-secondary", onClick: onBack, disabled, style: { margin: 2 }, children: [
|
|
202
|
+
/* @__PURE__ */ jsx4(FiChevronLeft, { className: "me-2" }),
|
|
203
|
+
backLabel
|
|
204
|
+
] }),
|
|
205
|
+
isEditing && onCancelEdit && /* @__PURE__ */ jsxs2(Button4, { variant: "warning", onClick: onCancelEdit, disabled, style: { margin: 2 }, children: [
|
|
206
|
+
/* @__PURE__ */ jsx4(FiRotateCcw, { className: "me-2" }),
|
|
207
|
+
cancelEditLabel
|
|
208
|
+
] }),
|
|
209
|
+
/* @__PURE__ */ jsx4(PermissionWrapper, { children: renderDeleteButton() }),
|
|
210
|
+
onSave && /* @__PURE__ */ jsxs2(Button4, { variant: saveVariant, onClick: onSave, disabled, style: { margin: 2 }, children: [
|
|
211
|
+
/* @__PURE__ */ jsx4(FiSave, { className: "me-2" }),
|
|
212
|
+
saveLabel
|
|
213
|
+
] }),
|
|
214
|
+
isEditing && onCopy && /* @__PURE__ */ jsxs2(Button4, { variant: "outline-primary", onClick: onCopy, disabled, style: { margin: 2 }, children: [
|
|
215
|
+
/* @__PURE__ */ jsx4(FiCopy, { className: "me-2" }),
|
|
216
|
+
copyLabel
|
|
217
|
+
] })
|
|
218
|
+
] })
|
|
219
|
+
] });
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
// src/containers/ResponsiveContainer.tsx
|
|
223
|
+
import { Modal as Modal2, ModalBody } from "react-bootstrap";
|
|
224
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
27
225
|
var ResponsiveContainer = ({
|
|
28
226
|
title,
|
|
29
227
|
show,
|
|
@@ -36,22 +234,22 @@ var ResponsiveContainer = ({
|
|
|
36
234
|
setShow(false);
|
|
37
235
|
if (onClose) onClose();
|
|
38
236
|
};
|
|
39
|
-
return /* @__PURE__ */
|
|
40
|
-
/* @__PURE__ */
|
|
41
|
-
/* @__PURE__ */
|
|
237
|
+
return /* @__PURE__ */ jsxs3(Modal2, { size: "lg", show, onHide: handleClose, scrollable, children: [
|
|
238
|
+
/* @__PURE__ */ jsx5(Modal2.Header, { closeButton: true, onClick: handleClose }),
|
|
239
|
+
/* @__PURE__ */ jsx5(ModalBody, { children })
|
|
42
240
|
] });
|
|
43
241
|
};
|
|
44
242
|
var ResponsiveContainer_default = ResponsiveContainer;
|
|
45
243
|
|
|
46
244
|
// src/displays/UuidPill.tsx
|
|
47
|
-
import { useState, useRef } from "react";
|
|
245
|
+
import { useState as useState3, useRef as useRef2 } from "react";
|
|
48
246
|
import { Badge, Overlay, Tooltip } from "react-bootstrap";
|
|
49
|
-
import { Fragment, jsx as
|
|
247
|
+
import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
50
248
|
var UuidPill = ({ uuid, bg = "light", textColor = "dark", short = 8 }) => {
|
|
51
|
-
const [copied, setCopied] =
|
|
52
|
-
const ref =
|
|
53
|
-
const [showTooltip, setShowTooltip] =
|
|
54
|
-
if (!uuid) return /* @__PURE__ */
|
|
249
|
+
const [copied, setCopied] = useState3(false);
|
|
250
|
+
const ref = useRef2(null);
|
|
251
|
+
const [showTooltip, setShowTooltip] = useState3(false);
|
|
252
|
+
if (!uuid) return /* @__PURE__ */ jsx6("span", { className: "text-muted", children: "\u2014" });
|
|
55
253
|
const shortId = String(uuid).substring(0, short);
|
|
56
254
|
const handleCopy = async (e) => {
|
|
57
255
|
e.stopPropagation();
|
|
@@ -68,8 +266,8 @@ var UuidPill = ({ uuid, bg = "light", textColor = "dark", short = 8 }) => {
|
|
|
68
266
|
setCopied(true);
|
|
69
267
|
setTimeout(() => setCopied(false), 1500);
|
|
70
268
|
};
|
|
71
|
-
return /* @__PURE__ */
|
|
72
|
-
/* @__PURE__ */
|
|
269
|
+
return /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
270
|
+
/* @__PURE__ */ jsxs4(
|
|
73
271
|
Badge,
|
|
74
272
|
{
|
|
75
273
|
ref,
|
|
@@ -90,19 +288,19 @@ var UuidPill = ({ uuid, bg = "light", textColor = "dark", short = 8 }) => {
|
|
|
90
288
|
]
|
|
91
289
|
}
|
|
92
290
|
),
|
|
93
|
-
/* @__PURE__ */
|
|
291
|
+
/* @__PURE__ */ jsx6(Overlay, { target: ref.current, show: showTooltip, placement: "top", children: (props) => /* @__PURE__ */ jsx6(Tooltip, { ...props, children: copied ? /* @__PURE__ */ jsx6("span", { style: { color: "#6f6" }, children: "Copiado!" }) : /* @__PURE__ */ jsxs4("span", { style: { fontFamily: "monospace", fontSize: "0.75rem" }, children: [
|
|
94
292
|
uuid,
|
|
95
|
-
/* @__PURE__ */
|
|
96
|
-
/* @__PURE__ */
|
|
293
|
+
/* @__PURE__ */ jsx6("br", {}),
|
|
294
|
+
/* @__PURE__ */ jsx6("small", { className: "text-muted", children: "Clique para copiar" })
|
|
97
295
|
] }) }) })
|
|
98
296
|
] });
|
|
99
297
|
};
|
|
100
298
|
var UuidPill_default = UuidPill;
|
|
101
299
|
|
|
102
300
|
// src/displays/GenericDisplay.tsx
|
|
103
|
-
import
|
|
301
|
+
import React4, { useState as useState4, useEffect } from "react";
|
|
104
302
|
import { Col, Container, Row } from "react-bootstrap";
|
|
105
|
-
import { Fragment as
|
|
303
|
+
import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
106
304
|
var ConfigObject = class {
|
|
107
305
|
constructor(dotNotation, style, onClick, onBlur, onHideClick, hidden, mapData, additionalComponents) {
|
|
108
306
|
this.dotNotation = dotNotation;
|
|
@@ -152,16 +350,16 @@ var buildData = (obj, propertiesMap, configObjects, opn, innerArray, dispatch, i
|
|
|
152
350
|
const onClick = getOnClick(innerConfigs);
|
|
153
351
|
const extraComponents = getAdditionalComponentes(innerConfigs);
|
|
154
352
|
if (Array.isArray(obj)) {
|
|
155
|
-
return /* @__PURE__ */
|
|
156
|
-
opn && /* @__PURE__ */
|
|
353
|
+
return /* @__PURE__ */ jsxs5(Container, { onClick, style: { ...styles }, children: [
|
|
354
|
+
opn && /* @__PURE__ */ jsx7("div", { style: { textAlign: "center" }, children: /* @__PURE__ */ jsx7("strong", { children: opn }) }),
|
|
157
355
|
obj.map((o, index) => {
|
|
158
356
|
const mapCopy = [...newPropertiesMap, `[${index}]`];
|
|
159
|
-
return /* @__PURE__ */
|
|
357
|
+
return /* @__PURE__ */ jsx7(Row, { style: { padding: 4, ...styles }, children: buildData(o, mapCopy, configObjects, null, true, null, false, editButtonRenderer) }, index);
|
|
160
358
|
})
|
|
161
359
|
] });
|
|
162
360
|
}
|
|
163
361
|
if (typeof obj === "object" && obj != null) {
|
|
164
|
-
return /* @__PURE__ */
|
|
362
|
+
return /* @__PURE__ */ jsxs5(
|
|
165
363
|
Container,
|
|
166
364
|
{
|
|
167
365
|
onClick,
|
|
@@ -174,17 +372,17 @@ var buildData = (obj, propertiesMap, configObjects, opn, innerArray, dispatch, i
|
|
|
174
372
|
...styles
|
|
175
373
|
},
|
|
176
374
|
children: [
|
|
177
|
-
opn && /* @__PURE__ */
|
|
375
|
+
opn && /* @__PURE__ */ jsx7("strong", { children: opn }),
|
|
178
376
|
Object.entries(obj).map(
|
|
179
377
|
([key, value]) => buildData(value, newPropertiesMap, configObjects, key, false, null, false, editButtonRenderer)
|
|
180
378
|
),
|
|
181
|
-
extraComponents.length > 0 ? extraComponents.map((comp, i) => /* @__PURE__ */
|
|
379
|
+
extraComponents.length > 0 ? extraComponents.map((comp, i) => /* @__PURE__ */ jsx7(React4.Fragment, { children: comp() }, i)) : isRoot && editButtonRenderer ? editButtonRenderer(obj, opn) : null
|
|
182
380
|
]
|
|
183
381
|
}
|
|
184
382
|
);
|
|
185
383
|
}
|
|
186
|
-
return /* @__PURE__ */
|
|
187
|
-
/* @__PURE__ */
|
|
384
|
+
return /* @__PURE__ */ jsxs5(Col, { children: [
|
|
385
|
+
/* @__PURE__ */ jsxs5("strong", { children: [
|
|
188
386
|
opn,
|
|
189
387
|
": "
|
|
190
388
|
] }),
|
|
@@ -200,7 +398,7 @@ var GenericDisplay = ({
|
|
|
200
398
|
onRefresh,
|
|
201
399
|
editButtonRenderer
|
|
202
400
|
}) => {
|
|
203
|
-
const [innerOptions, setInnerOptions] =
|
|
401
|
+
const [innerOptions, setInnerOptions] = useState4();
|
|
204
402
|
const refreshFunc = () => {
|
|
205
403
|
if (loadFunc) {
|
|
206
404
|
loadFunc().then((res) => {
|
|
@@ -221,17 +419,600 @@ var GenericDisplay = ({
|
|
|
221
419
|
refreshFunc();
|
|
222
420
|
}
|
|
223
421
|
}, [context]);
|
|
224
|
-
return /* @__PURE__ */
|
|
422
|
+
return /* @__PURE__ */ jsx7(Fragment3, { children: innerOptions && innerOptions.map((cObj, index) => /* @__PURE__ */ jsx7(Container, { style: { padding: 4, border: "solid" }, children: buildData(cObj, [], configObjects, rootName || null, false, null, true, editButtonRenderer) }, index)) });
|
|
225
423
|
};
|
|
226
424
|
var GenericDisplay_default = GenericDisplay;
|
|
227
425
|
|
|
426
|
+
// src/forms/MailSender.tsx
|
|
427
|
+
import { useState as useState5 } from "react";
|
|
428
|
+
import {
|
|
429
|
+
Button as Button5,
|
|
430
|
+
Card,
|
|
431
|
+
Col as Col2,
|
|
432
|
+
Form as Form3,
|
|
433
|
+
Row as Row2,
|
|
434
|
+
Spinner,
|
|
435
|
+
Badge as Badge2,
|
|
436
|
+
InputGroup
|
|
437
|
+
} from "react-bootstrap";
|
|
438
|
+
import { FiMail, FiSearch, FiUser, FiX, FiPlus, FiSend } from "react-icons/fi";
|
|
439
|
+
import { Fragment as Fragment4, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
440
|
+
var MailSender = ({
|
|
441
|
+
htmlContent,
|
|
442
|
+
companyName,
|
|
443
|
+
onFetchEmails,
|
|
444
|
+
onSendEmail,
|
|
445
|
+
hide = false,
|
|
446
|
+
renderTrigger
|
|
447
|
+
}) => {
|
|
448
|
+
const [opened, setOpened] = useState5(false);
|
|
449
|
+
const [addingEmail, setAddingEmail] = useState5(false);
|
|
450
|
+
const [selectedEmails, setSelectedEmails] = useState5([]);
|
|
451
|
+
const [emails, setEmails] = useState5([]);
|
|
452
|
+
const [loading, setLoading] = useState5(false);
|
|
453
|
+
const [postLoading, setPostLoading] = useState5(false);
|
|
454
|
+
const [customEmail, setCustomEmail] = useState5("");
|
|
455
|
+
const [emailError, setEmailError] = useState5("");
|
|
456
|
+
const [searchFilter, setSearchFilter] = useState5("");
|
|
457
|
+
const handleOpen = async () => {
|
|
458
|
+
setLoading(true);
|
|
459
|
+
try {
|
|
460
|
+
const data = await onFetchEmails();
|
|
461
|
+
setEmails(data || []);
|
|
462
|
+
setOpened(true);
|
|
463
|
+
} catch (err) {
|
|
464
|
+
console.error("Erro ao buscar e-mails:", err);
|
|
465
|
+
} finally {
|
|
466
|
+
setLoading(false);
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
const mailListLinter = () => {
|
|
470
|
+
const result = [];
|
|
471
|
+
const seen = /* @__PURE__ */ new Set();
|
|
472
|
+
if (emails) {
|
|
473
|
+
for (const item of emails) {
|
|
474
|
+
if (item.email && !seen.has(item.email)) {
|
|
475
|
+
seen.add(item.email);
|
|
476
|
+
result.push({ email: item.email });
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
return result;
|
|
481
|
+
};
|
|
482
|
+
const filteredEmails = emails ? mailListLinter().filter(
|
|
483
|
+
(email) => email.email.toLowerCase().includes(searchFilter.toLowerCase()) && !selectedEmails.some((selected) => (selected.email || selected) === email.email)
|
|
484
|
+
) : [];
|
|
485
|
+
const sendEmail = async () => {
|
|
486
|
+
const emailString = selectedEmails.map((email) => email.email ? email.email : email).join(", ");
|
|
487
|
+
const emailData = {
|
|
488
|
+
to: emailString,
|
|
489
|
+
subject: `Relat\xF3rio - ${companyName}`,
|
|
490
|
+
text: `Relat\xF3rio de processo da empresa ${companyName}`,
|
|
491
|
+
html: htmlContent
|
|
492
|
+
};
|
|
493
|
+
setPostLoading(true);
|
|
494
|
+
try {
|
|
495
|
+
await onSendEmail(emailData);
|
|
496
|
+
setSelectedEmails([]);
|
|
497
|
+
setCustomEmail("");
|
|
498
|
+
setOpened(false);
|
|
499
|
+
} catch (err) {
|
|
500
|
+
console.error("Erro ao enviar e-mail:", err);
|
|
501
|
+
} finally {
|
|
502
|
+
setPostLoading(false);
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
const validateEmail = (email) => {
|
|
506
|
+
const re = /\S+@\S+\.\S+/;
|
|
507
|
+
return re.test(email);
|
|
508
|
+
};
|
|
509
|
+
const handleEmailAdd = () => {
|
|
510
|
+
if (!customEmail.trim()) {
|
|
511
|
+
setEmailError("Por favor, digite um e-mail");
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
if (!validateEmail(customEmail)) {
|
|
515
|
+
setEmailError("Formato de e-mail inv\xE1lido");
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
if (selectedEmails.some((email) => (email.email || email) === customEmail)) {
|
|
519
|
+
setEmailError("Este e-mail j\xE1 foi selecionado");
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
setSelectedEmails([...selectedEmails, customEmail]);
|
|
523
|
+
setCustomEmail("");
|
|
524
|
+
setEmailError("");
|
|
525
|
+
setAddingEmail(false);
|
|
526
|
+
};
|
|
527
|
+
const handleEmailRemove = (emailToRemove) => {
|
|
528
|
+
setSelectedEmails(
|
|
529
|
+
selectedEmails.filter(
|
|
530
|
+
(email) => (email.email || email) !== (emailToRemove.email || emailToRemove)
|
|
531
|
+
)
|
|
532
|
+
);
|
|
533
|
+
};
|
|
534
|
+
if (hide) return null;
|
|
535
|
+
if (!opened) {
|
|
536
|
+
if (renderTrigger) {
|
|
537
|
+
return renderTrigger({ onClick: handleOpen, loading });
|
|
538
|
+
}
|
|
539
|
+
return /* @__PURE__ */ jsx8(Button5, { disabled: loading, className: "w-100", onClick: handleOpen, children: loading ? "Carregando..." : "Enviar por E-mail" });
|
|
540
|
+
}
|
|
541
|
+
return /* @__PURE__ */ jsxs6(
|
|
542
|
+
"div",
|
|
543
|
+
{
|
|
544
|
+
style: {
|
|
545
|
+
backgroundColor: "#f8f9fa",
|
|
546
|
+
borderRadius: "12px",
|
|
547
|
+
overflow: "hidden",
|
|
548
|
+
border: "1px solid #dee2e6",
|
|
549
|
+
boxShadow: "0 4px 6px rgba(0, 0, 0, 0.1)"
|
|
550
|
+
},
|
|
551
|
+
children: [
|
|
552
|
+
/* @__PURE__ */ jsx8(
|
|
553
|
+
"div",
|
|
554
|
+
{
|
|
555
|
+
style: {
|
|
556
|
+
background: "linear-gradient(135deg, #28a745 0%, #20c997 100%)",
|
|
557
|
+
color: "white",
|
|
558
|
+
padding: "25px"
|
|
559
|
+
},
|
|
560
|
+
children: /* @__PURE__ */ jsxs6("div", { className: "d-flex justify-content-between align-items-center", children: [
|
|
561
|
+
/* @__PURE__ */ jsxs6("div", { children: [
|
|
562
|
+
/* @__PURE__ */ jsxs6("h4", { className: "mb-1", style: { fontWeight: "600", fontSize: "22px" }, children: [
|
|
563
|
+
/* @__PURE__ */ jsx8(FiMail, { className: "me-2", size: 20 }),
|
|
564
|
+
"Enviar Relat\xF3rio por E-mail"
|
|
565
|
+
] }),
|
|
566
|
+
/* @__PURE__ */ jsxs6("small", { style: { opacity: "0.9", fontSize: "14px" }, children: [
|
|
567
|
+
"Selecione os destinat\xE1rios para envio do relat\xF3rio de ",
|
|
568
|
+
companyName
|
|
569
|
+
] })
|
|
570
|
+
] }),
|
|
571
|
+
/* @__PURE__ */ jsxs6("div", { className: "d-flex gap-2", children: [
|
|
572
|
+
/* @__PURE__ */ jsx8(
|
|
573
|
+
Button5,
|
|
574
|
+
{
|
|
575
|
+
variant: "light",
|
|
576
|
+
onClick: sendEmail,
|
|
577
|
+
disabled: selectedEmails.length === 0 || postLoading,
|
|
578
|
+
style: {
|
|
579
|
+
borderRadius: "8px",
|
|
580
|
+
fontWeight: "600",
|
|
581
|
+
minWidth: "130px",
|
|
582
|
+
height: "40px"
|
|
583
|
+
},
|
|
584
|
+
children: postLoading ? /* @__PURE__ */ jsxs6(Fragment4, { children: [
|
|
585
|
+
/* @__PURE__ */ jsx8(Spinner, { size: "sm", className: "me-2" }),
|
|
586
|
+
"Enviando..."
|
|
587
|
+
] }) : /* @__PURE__ */ jsxs6(Fragment4, { children: [
|
|
588
|
+
/* @__PURE__ */ jsx8(FiSend, { className: "me-2", size: 14 }),
|
|
589
|
+
"Enviar E-mail"
|
|
590
|
+
] })
|
|
591
|
+
}
|
|
592
|
+
),
|
|
593
|
+
/* @__PURE__ */ jsx8(
|
|
594
|
+
Button5,
|
|
595
|
+
{
|
|
596
|
+
variant: "outline-light",
|
|
597
|
+
onClick: () => setOpened(false),
|
|
598
|
+
disabled: postLoading,
|
|
599
|
+
style: { borderRadius: "8px", width: "40px", height: "40px" },
|
|
600
|
+
children: /* @__PURE__ */ jsx8(FiX, { size: 16 })
|
|
601
|
+
}
|
|
602
|
+
)
|
|
603
|
+
] })
|
|
604
|
+
] })
|
|
605
|
+
}
|
|
606
|
+
),
|
|
607
|
+
/* @__PURE__ */ jsxs6("div", { style: { padding: "25px" }, children: [
|
|
608
|
+
/* @__PURE__ */ jsx8(Card, { className: "mb-4", style: { border: "none", boxShadow: "0 2px 8px rgba(0,0,0,0.05)" }, children: /* @__PURE__ */ jsxs6(Card.Body, { style: { padding: "20px" }, children: [
|
|
609
|
+
/* @__PURE__ */ jsxs6(Row2, { className: "align-items-center", children: [
|
|
610
|
+
/* @__PURE__ */ jsxs6(Col2, { md: 6, children: [
|
|
611
|
+
/* @__PURE__ */ jsx8("h6", { className: "mb-2", style: { color: "#495057", fontWeight: "600" }, children: "\u{1F527} Filtros e A\xE7\xF5es" }),
|
|
612
|
+
/* @__PURE__ */ jsxs6(InputGroup, { style: { maxWidth: "300px" }, children: [
|
|
613
|
+
/* @__PURE__ */ jsx8(InputGroup.Text, { style: { backgroundColor: "#f8f9fa", border: "1px solid #dee2e6" }, children: /* @__PURE__ */ jsx8(FiSearch, { size: 14, color: "#6c757d" }) }),
|
|
614
|
+
/* @__PURE__ */ jsx8(
|
|
615
|
+
Form3.Control,
|
|
616
|
+
{
|
|
617
|
+
type: "text",
|
|
618
|
+
placeholder: "Buscar e-mails...",
|
|
619
|
+
value: searchFilter,
|
|
620
|
+
onChange: (e) => setSearchFilter(e.target.value),
|
|
621
|
+
style: { border: "1px solid #dee2e6" }
|
|
622
|
+
}
|
|
623
|
+
)
|
|
624
|
+
] })
|
|
625
|
+
] }),
|
|
626
|
+
/* @__PURE__ */ jsx8(Col2, { md: 6, className: "text-end", children: /* @__PURE__ */ jsx8(
|
|
627
|
+
Button5,
|
|
628
|
+
{
|
|
629
|
+
variant: addingEmail ? "outline-secondary" : "outline-primary",
|
|
630
|
+
size: "sm",
|
|
631
|
+
onClick: () => setAddingEmail(!addingEmail),
|
|
632
|
+
disabled: postLoading,
|
|
633
|
+
style: { borderRadius: "8px" },
|
|
634
|
+
children: addingEmail ? /* @__PURE__ */ jsxs6(Fragment4, { children: [
|
|
635
|
+
/* @__PURE__ */ jsx8(FiX, { className: "me-1", size: 14 }),
|
|
636
|
+
"Cancelar"
|
|
637
|
+
] }) : /* @__PURE__ */ jsxs6(Fragment4, { children: [
|
|
638
|
+
/* @__PURE__ */ jsx8(FiPlus, { className: "me-1", size: 14 }),
|
|
639
|
+
"E-mail Personalizado"
|
|
640
|
+
] })
|
|
641
|
+
}
|
|
642
|
+
) })
|
|
643
|
+
] }),
|
|
644
|
+
addingEmail && /* @__PURE__ */ jsxs6(
|
|
645
|
+
"div",
|
|
646
|
+
{
|
|
647
|
+
style: {
|
|
648
|
+
marginTop: "20px",
|
|
649
|
+
padding: "20px",
|
|
650
|
+
backgroundColor: "#f8f9ff",
|
|
651
|
+
borderRadius: "8px",
|
|
652
|
+
border: "1px solid #e3f2fd"
|
|
653
|
+
},
|
|
654
|
+
children: [
|
|
655
|
+
/* @__PURE__ */ jsx8("h6", { className: "mb-3", style: { color: "#1976d2", fontWeight: "600" }, children: "\u2709\uFE0F Adicionar E-mail Personalizado" }),
|
|
656
|
+
/* @__PURE__ */ jsxs6(Row2, { className: "align-items-end", children: [
|
|
657
|
+
/* @__PURE__ */ jsxs6(Col2, { md: 8, children: [
|
|
658
|
+
/* @__PURE__ */ jsx8(Form3.Label, { style: { fontSize: "13px", color: "#6c757d", fontWeight: "500" }, children: "Endere\xE7o de E-mail" }),
|
|
659
|
+
/* @__PURE__ */ jsx8(
|
|
660
|
+
Form3.Control,
|
|
661
|
+
{
|
|
662
|
+
type: "email",
|
|
663
|
+
placeholder: "exemplo@empresa.com",
|
|
664
|
+
value: customEmail,
|
|
665
|
+
onChange: (e) => {
|
|
666
|
+
setCustomEmail(e.target.value);
|
|
667
|
+
if (emailError) setEmailError("");
|
|
668
|
+
},
|
|
669
|
+
isInvalid: !!emailError,
|
|
670
|
+
disabled: postLoading,
|
|
671
|
+
style: { borderRadius: "8px" },
|
|
672
|
+
onKeyPress: (e) => e.key === "Enter" && handleEmailAdd()
|
|
673
|
+
}
|
|
674
|
+
),
|
|
675
|
+
/* @__PURE__ */ jsx8(Form3.Control.Feedback, { type: "invalid", children: emailError })
|
|
676
|
+
] }),
|
|
677
|
+
/* @__PURE__ */ jsx8(Col2, { md: 4, children: /* @__PURE__ */ jsxs6(
|
|
678
|
+
Button5,
|
|
679
|
+
{
|
|
680
|
+
variant: "success",
|
|
681
|
+
onClick: handleEmailAdd,
|
|
682
|
+
disabled: postLoading,
|
|
683
|
+
style: { borderRadius: "8px", width: "100%" },
|
|
684
|
+
children: [
|
|
685
|
+
/* @__PURE__ */ jsx8(FiPlus, { className: "me-1", size: 14 }),
|
|
686
|
+
"Adicionar"
|
|
687
|
+
]
|
|
688
|
+
}
|
|
689
|
+
) })
|
|
690
|
+
] })
|
|
691
|
+
]
|
|
692
|
+
}
|
|
693
|
+
)
|
|
694
|
+
] }) }),
|
|
695
|
+
selectedEmails.length > 0 && /* @__PURE__ */ jsx8(Card, { className: "mb-4", style: { border: "none", boxShadow: "0 2px 8px rgba(0,0,0,0.05)" }, children: /* @__PURE__ */ jsxs6(Card.Body, { style: { padding: "20px" }, children: [
|
|
696
|
+
/* @__PURE__ */ jsxs6("div", { className: "d-flex justify-content-between align-items-center mb-3", children: [
|
|
697
|
+
/* @__PURE__ */ jsx8("h6", { className: "mb-0", style: { color: "#495057", fontWeight: "600" }, children: "\u{1F4CB} Destinat\xE1rios Selecionados" }),
|
|
698
|
+
/* @__PURE__ */ jsxs6(Badge2, { bg: "primary", style: { fontSize: "12px", padding: "6px 12px" }, children: [
|
|
699
|
+
selectedEmails.length,
|
|
700
|
+
" selecionado",
|
|
701
|
+
selectedEmails.length > 1 ? "s" : ""
|
|
702
|
+
] })
|
|
703
|
+
] }),
|
|
704
|
+
/* @__PURE__ */ jsx8("div", { className: "d-flex flex-wrap gap-2", children: selectedEmails.map((email, index) => /* @__PURE__ */ jsxs6(
|
|
705
|
+
"div",
|
|
706
|
+
{
|
|
707
|
+
style: {
|
|
708
|
+
background: "linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%)",
|
|
709
|
+
border: "1px solid #bbdefb",
|
|
710
|
+
borderRadius: "20px",
|
|
711
|
+
padding: "8px 15px",
|
|
712
|
+
display: "flex",
|
|
713
|
+
alignItems: "center",
|
|
714
|
+
fontSize: "14px",
|
|
715
|
+
fontWeight: "500"
|
|
716
|
+
},
|
|
717
|
+
children: [
|
|
718
|
+
/* @__PURE__ */ jsx8(FiUser, { size: 12, className: "me-2", color: "#1976d2" }),
|
|
719
|
+
/* @__PURE__ */ jsx8("span", { children: email.email || email }),
|
|
720
|
+
/* @__PURE__ */ jsx8(
|
|
721
|
+
Button5,
|
|
722
|
+
{
|
|
723
|
+
variant: "link",
|
|
724
|
+
size: "sm",
|
|
725
|
+
onClick: () => handleEmailRemove(email),
|
|
726
|
+
disabled: postLoading,
|
|
727
|
+
style: {
|
|
728
|
+
padding: "0 0 0 8px",
|
|
729
|
+
color: "#dc3545",
|
|
730
|
+
textDecoration: "none",
|
|
731
|
+
fontSize: "16px"
|
|
732
|
+
},
|
|
733
|
+
children: /* @__PURE__ */ jsx8(FiX, { size: 14 })
|
|
734
|
+
}
|
|
735
|
+
)
|
|
736
|
+
]
|
|
737
|
+
},
|
|
738
|
+
index
|
|
739
|
+
)) })
|
|
740
|
+
] }) }),
|
|
741
|
+
/* @__PURE__ */ jsx8(Card, { style: { border: "none", boxShadow: "0 2px 8px rgba(0,0,0,0.05)" }, children: /* @__PURE__ */ jsxs6(Card.Body, { style: { padding: "20px" }, children: [
|
|
742
|
+
/* @__PURE__ */ jsxs6("h6", { className: "mb-3", style: { color: "#495057", fontWeight: "600" }, children: [
|
|
743
|
+
/* @__PURE__ */ jsx8(FiUser, { className: "me-2", size: 16 }),
|
|
744
|
+
"E-mails de ",
|
|
745
|
+
companyName
|
|
746
|
+
] }),
|
|
747
|
+
loading ? /* @__PURE__ */ jsxs6("div", { className: "text-center py-4", children: [
|
|
748
|
+
/* @__PURE__ */ jsx8(Spinner, {}),
|
|
749
|
+
/* @__PURE__ */ jsx8("p", { className: "mt-2 text-muted", children: "Carregando e-mails..." })
|
|
750
|
+
] }) : filteredEmails.length === 0 ? /* @__PURE__ */ jsx8("div", { className: "text-center py-4", children: /* @__PURE__ */ jsx8("p", { className: "text-muted mb-0", children: searchFilter ? "Nenhum e-mail encontrado com esse filtro" : "Nenhum e-mail dispon\xEDvel" }) }) : /* @__PURE__ */ jsx8(Row2, { children: filteredEmails.map((email) => /* @__PURE__ */ jsx8(Col2, { xs: 12, sm: 6, lg: 4, className: "mb-3", children: /* @__PURE__ */ jsx8(
|
|
751
|
+
Card,
|
|
752
|
+
{
|
|
753
|
+
onClick: () => setSelectedEmails([...selectedEmails, email]),
|
|
754
|
+
style: {
|
|
755
|
+
cursor: "pointer",
|
|
756
|
+
border: "1px solid #e9ecef",
|
|
757
|
+
borderRadius: "10px",
|
|
758
|
+
transition: "all 0.2s ease",
|
|
759
|
+
backgroundColor: "#fff"
|
|
760
|
+
},
|
|
761
|
+
onMouseEnter: (e) => {
|
|
762
|
+
e.currentTarget.style.transform = "translateY(-2px)";
|
|
763
|
+
e.currentTarget.style.boxShadow = "0 4px 12px rgba(0,0,0,0.1)";
|
|
764
|
+
e.currentTarget.style.borderColor = "#007bff";
|
|
765
|
+
},
|
|
766
|
+
onMouseLeave: (e) => {
|
|
767
|
+
e.currentTarget.style.transform = "translateY(0)";
|
|
768
|
+
e.currentTarget.style.boxShadow = "none";
|
|
769
|
+
e.currentTarget.style.borderColor = "#e9ecef";
|
|
770
|
+
},
|
|
771
|
+
children: /* @__PURE__ */ jsxs6(Card.Body, { style: { padding: "15px", textAlign: "center" }, children: [
|
|
772
|
+
/* @__PURE__ */ jsx8(FiMail, { size: 20, color: "#007bff", className: "mb-2" }),
|
|
773
|
+
/* @__PURE__ */ jsx8(
|
|
774
|
+
"div",
|
|
775
|
+
{
|
|
776
|
+
style: {
|
|
777
|
+
fontSize: "14px",
|
|
778
|
+
fontWeight: "500",
|
|
779
|
+
color: "#2c3e50",
|
|
780
|
+
wordBreak: "break-word"
|
|
781
|
+
},
|
|
782
|
+
children: email.email
|
|
783
|
+
}
|
|
784
|
+
)
|
|
785
|
+
] })
|
|
786
|
+
}
|
|
787
|
+
) }, email.email)) })
|
|
788
|
+
] }) })
|
|
789
|
+
] })
|
|
790
|
+
]
|
|
791
|
+
}
|
|
792
|
+
);
|
|
793
|
+
};
|
|
794
|
+
|
|
795
|
+
// src/forms/AutoComplete.tsx
|
|
796
|
+
import { useEffect as useEffect2, useMemo, useState as useState6 } from "react";
|
|
797
|
+
import { FloatingLabel, Form as Form4, InputGroup as InputGroup2, ListGroup, Spinner as Spinner2 } from "react-bootstrap";
|
|
798
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
799
|
+
var AutoComplete = ({
|
|
800
|
+
className,
|
|
801
|
+
ops = [],
|
|
802
|
+
sortKey,
|
|
803
|
+
displayKey,
|
|
804
|
+
displayKeys,
|
|
805
|
+
onValueChanged,
|
|
806
|
+
onSelectedClick,
|
|
807
|
+
value,
|
|
808
|
+
actionButton,
|
|
809
|
+
actionButton2,
|
|
810
|
+
placeH,
|
|
811
|
+
title,
|
|
812
|
+
filter,
|
|
813
|
+
filterField,
|
|
814
|
+
loadFunc,
|
|
815
|
+
loadCondition,
|
|
816
|
+
onBlurEvent,
|
|
817
|
+
formatationFunc,
|
|
818
|
+
onEscKeyDown,
|
|
819
|
+
onEnterKeyDown,
|
|
820
|
+
margT,
|
|
821
|
+
margB,
|
|
822
|
+
hideComponent,
|
|
823
|
+
disableComponent = false,
|
|
824
|
+
disableSelect = false,
|
|
825
|
+
autoFocusConfig,
|
|
826
|
+
onLoad,
|
|
827
|
+
cacheKey,
|
|
828
|
+
minChars = 0,
|
|
829
|
+
maxItems,
|
|
830
|
+
showListOnFocus = true,
|
|
831
|
+
lazyLoad = false
|
|
832
|
+
}) => {
|
|
833
|
+
const [liItem, setListItem] = useState6([]);
|
|
834
|
+
const [options, setOptions] = useState6([]);
|
|
835
|
+
const [input, setInput] = useState6("");
|
|
836
|
+
const [hide, setHide] = useState6(true);
|
|
837
|
+
const [onLoaded, setOnLoaded] = useState6(false);
|
|
838
|
+
const [loading, setLoading] = useState6(false);
|
|
839
|
+
const cacheStore = useMemo(() => {
|
|
840
|
+
const win = window;
|
|
841
|
+
if (!win.__AUTO_COMPLETE_CACHE__) {
|
|
842
|
+
win.__AUTO_COMPLETE_CACHE__ = /* @__PURE__ */ new Map();
|
|
843
|
+
}
|
|
844
|
+
return win.__AUTO_COMPLETE_CACHE__;
|
|
845
|
+
}, []);
|
|
846
|
+
const sortOptions = (data, key) => {
|
|
847
|
+
if (!key || !Array.isArray(data)) return data;
|
|
848
|
+
return [...data].sort((a, b) => String(a[key]).localeCompare(String(b[key])));
|
|
849
|
+
};
|
|
850
|
+
useEffect2(() => {
|
|
851
|
+
setInput(value || "");
|
|
852
|
+
}, [value]);
|
|
853
|
+
useEffect2(() => {
|
|
854
|
+
const sortedOptions = sortOptions(ops, sortKey);
|
|
855
|
+
setListItem(sortedOptions);
|
|
856
|
+
setOptions(sortedOptions);
|
|
857
|
+
}, [ops, sortKey]);
|
|
858
|
+
useEffect2(() => {
|
|
859
|
+
const loadData = async () => {
|
|
860
|
+
if (!(loadCondition && loadFunc)) return;
|
|
861
|
+
if (lazyLoad && minChars > 0 && !showListOnFocus && (!value || String(value).length < minChars)) {
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
864
|
+
const key = cacheKey ? `${cacheKey}${filter ? `:${filterField}:${filter}` : ""}` : null;
|
|
865
|
+
if (key && cacheStore.has(key)) {
|
|
866
|
+
const cacheEntry = cacheStore.get(key);
|
|
867
|
+
const data = cacheEntry.promise ? await cacheEntry.promise : cacheEntry.data || cacheEntry;
|
|
868
|
+
setListItem(data);
|
|
869
|
+
setOptions(data);
|
|
870
|
+
triggerOnLoad(data);
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
873
|
+
setLoading(true);
|
|
874
|
+
try {
|
|
875
|
+
const requestPromise = loadFunc().then((res) => {
|
|
876
|
+
let newOps = (res == null ? void 0 : res.content) || res;
|
|
877
|
+
newOps = Array.isArray(newOps) ? newOps.filter((op) => op != null) : [];
|
|
878
|
+
if (filter && filterField) {
|
|
879
|
+
newOps = newOps.filter((op) => op[filterField] === filter);
|
|
880
|
+
}
|
|
881
|
+
return sortOptions(newOps, sortKey);
|
|
882
|
+
});
|
|
883
|
+
if (key) cacheStore.set(key, { promise: requestPromise });
|
|
884
|
+
const sortedOptions = await requestPromise;
|
|
885
|
+
setListItem(sortedOptions);
|
|
886
|
+
setOptions(sortedOptions);
|
|
887
|
+
if (key) cacheStore.set(key, { data: sortedOptions });
|
|
888
|
+
triggerOnLoad(sortedOptions);
|
|
889
|
+
} catch (error) {
|
|
890
|
+
if (key) cacheStore.delete(key);
|
|
891
|
+
setListItem([]);
|
|
892
|
+
} finally {
|
|
893
|
+
setLoading(false);
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
loadData();
|
|
897
|
+
}, [loadCondition, filter, filterField, sortKey, cacheKey, lazyLoad, minChars, showListOnFocus]);
|
|
898
|
+
const triggerOnLoad = (data) => {
|
|
899
|
+
if (onLoad && !onLoaded) {
|
|
900
|
+
setOnLoaded(true);
|
|
901
|
+
onLoad(data);
|
|
902
|
+
}
|
|
903
|
+
};
|
|
904
|
+
const keysJoinner = (li) => {
|
|
905
|
+
if (!displayKeys || !Array.isArray(displayKeys)) return "";
|
|
906
|
+
return displayKeys.map((key) => `${li[key]} `).join("").trim();
|
|
907
|
+
};
|
|
908
|
+
const getDisplayText = (item) => {
|
|
909
|
+
if (formatationFunc) return formatationFunc(item);
|
|
910
|
+
if (displayKey) return item[displayKey];
|
|
911
|
+
if (displayKeys) return keysJoinner(item);
|
|
912
|
+
return String(item);
|
|
913
|
+
};
|
|
914
|
+
const onFieldUpdate = (val) => {
|
|
915
|
+
const search = val.toLowerCase();
|
|
916
|
+
const canSearch = search.length >= minChars;
|
|
917
|
+
if (canSearch && Array.isArray(options)) {
|
|
918
|
+
const filtered = options.filter((item) => {
|
|
919
|
+
const text = getDisplayText(item);
|
|
920
|
+
return String(text).toLowerCase().includes(search);
|
|
921
|
+
});
|
|
922
|
+
setListItem(filtered);
|
|
923
|
+
} else {
|
|
924
|
+
setListItem(options || []);
|
|
925
|
+
}
|
|
926
|
+
onValueChanged == null ? void 0 : onValueChanged(val);
|
|
927
|
+
setInput(val);
|
|
928
|
+
setHide(!canSearch && options.length === 0);
|
|
929
|
+
};
|
|
930
|
+
return /* @__PURE__ */ jsxs7(
|
|
931
|
+
"div",
|
|
932
|
+
{
|
|
933
|
+
className,
|
|
934
|
+
style: { marginTop: margT != null ? margT : 4, marginBottom: margB != null ? margB : 4, position: "relative" },
|
|
935
|
+
onBlur: (e) => {
|
|
936
|
+
setTimeout(() => {
|
|
937
|
+
onBlurEvent == null ? void 0 : onBlurEvent(e, input);
|
|
938
|
+
setHide(true);
|
|
939
|
+
}, 200);
|
|
940
|
+
},
|
|
941
|
+
onKeyDown: (e) => {
|
|
942
|
+
if (e.key === "Escape") {
|
|
943
|
+
setHide(true);
|
|
944
|
+
onEscKeyDown == null ? void 0 : onEscKeyDown();
|
|
945
|
+
}
|
|
946
|
+
if (e.key === "Enter" && onEnterKeyDown) {
|
|
947
|
+
onEnterKeyDown(input);
|
|
948
|
+
}
|
|
949
|
+
},
|
|
950
|
+
onMouseLeave: () => setHide(true),
|
|
951
|
+
children: [
|
|
952
|
+
!hideComponent && /* @__PURE__ */ jsxs7(InputGroup2, { children: [
|
|
953
|
+
/* @__PURE__ */ jsx9(FloatingLabel, { controlId: "floatingInput", label: title, style: { zIndex: 0, flex: 1 }, children: /* @__PURE__ */ jsx9(
|
|
954
|
+
Form4.Control,
|
|
955
|
+
{
|
|
956
|
+
autoFocus: autoFocusConfig,
|
|
957
|
+
disabled: disableComponent || disableSelect,
|
|
958
|
+
placeholder: placeH,
|
|
959
|
+
autoComplete: "off",
|
|
960
|
+
value: input,
|
|
961
|
+
onClickCapture: () => {
|
|
962
|
+
const canOpen = showListOnFocus && input.length >= minChars;
|
|
963
|
+
setHide(!canOpen);
|
|
964
|
+
},
|
|
965
|
+
onChange: (e) => onFieldUpdate(e.currentTarget.value),
|
|
966
|
+
type: "text"
|
|
967
|
+
}
|
|
968
|
+
) }),
|
|
969
|
+
loading && /* @__PURE__ */ jsx9(InputGroup2.Text, { children: /* @__PURE__ */ jsx9(Spinner2, { animation: "border", size: "sm" }) }),
|
|
970
|
+
!disableComponent && (actionButton == null ? void 0 : actionButton(() => setInput(""))),
|
|
971
|
+
!disableComponent && (actionButton2 == null ? void 0 : actionButton2(input))
|
|
972
|
+
] }),
|
|
973
|
+
/* @__PURE__ */ jsx9(
|
|
974
|
+
ListGroup,
|
|
975
|
+
{
|
|
976
|
+
className: "listgroup-autocomplete shadow-sm",
|
|
977
|
+
hidden: hide || liItem.length === 0,
|
|
978
|
+
style: {
|
|
979
|
+
position: "absolute",
|
|
980
|
+
top: "100%",
|
|
981
|
+
left: 0,
|
|
982
|
+
width: "100%",
|
|
983
|
+
maxHeight: "250px",
|
|
984
|
+
overflowY: "auto",
|
|
985
|
+
zIndex: 1050,
|
|
986
|
+
backgroundColor: "#fff"
|
|
987
|
+
},
|
|
988
|
+
children: (maxItems ? liItem.slice(0, maxItems) : liItem).map((li, index) => /* @__PURE__ */ jsx9(
|
|
989
|
+
ListGroup.Item,
|
|
990
|
+
{
|
|
991
|
+
action: true,
|
|
992
|
+
onClick: () => {
|
|
993
|
+
const text = getDisplayText(li);
|
|
994
|
+
setInput(text);
|
|
995
|
+
onSelectedClick(li, index, liItem);
|
|
996
|
+
setHide(true);
|
|
997
|
+
},
|
|
998
|
+
children: getDisplayText(li)
|
|
999
|
+
},
|
|
1000
|
+
index
|
|
1001
|
+
))
|
|
1002
|
+
}
|
|
1003
|
+
)
|
|
1004
|
+
]
|
|
1005
|
+
}
|
|
1006
|
+
);
|
|
1007
|
+
};
|
|
1008
|
+
|
|
228
1009
|
// src/forms/GenericForm.tsx
|
|
229
|
-
import { useState as
|
|
230
|
-
import { Button as
|
|
231
|
-
import { jsx as
|
|
1010
|
+
import { useState as useState7 } from "react";
|
|
1011
|
+
import { Button as Button6, Form as Form5 } from "react-bootstrap";
|
|
1012
|
+
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
232
1013
|
var GenericForm = ({ fields, onSubmit, renderCustomSelect }) => {
|
|
233
|
-
const [formValues, setFormValues] =
|
|
234
|
-
const [errors, setErrors] =
|
|
1014
|
+
const [formValues, setFormValues] = useState7({});
|
|
1015
|
+
const [errors, setErrors] = useState7({});
|
|
235
1016
|
const handleChange = (key, value) => {
|
|
236
1017
|
setFormValues({
|
|
237
1018
|
...formValues,
|
|
@@ -260,10 +1041,10 @@ var GenericForm = ({ fields, onSubmit, renderCustomSelect }) => {
|
|
|
260
1041
|
switch (type) {
|
|
261
1042
|
case "text":
|
|
262
1043
|
case "number":
|
|
263
|
-
return /* @__PURE__ */
|
|
264
|
-
/* @__PURE__ */
|
|
265
|
-
/* @__PURE__ */
|
|
266
|
-
|
|
1044
|
+
return /* @__PURE__ */ jsxs8(Form5.Group, { className: "mb-3", children: [
|
|
1045
|
+
/* @__PURE__ */ jsx10(Form5.Label, { children: label }),
|
|
1046
|
+
/* @__PURE__ */ jsx10(
|
|
1047
|
+
Form5.Control,
|
|
267
1048
|
{
|
|
268
1049
|
type,
|
|
269
1050
|
placeholder,
|
|
@@ -272,30 +1053,30 @@ var GenericForm = ({ fields, onSubmit, renderCustomSelect }) => {
|
|
|
272
1053
|
isInvalid: !!errors[key]
|
|
273
1054
|
}
|
|
274
1055
|
),
|
|
275
|
-
/* @__PURE__ */
|
|
1056
|
+
/* @__PURE__ */ jsx10(Form5.Control.Feedback, { type: "invalid", children: errors[key] })
|
|
276
1057
|
] }, key);
|
|
277
1058
|
case "select": {
|
|
278
1059
|
const orderedOptions = (options || []).filter((opt) => opt && opt.value !== void 0 && opt.label !== void 0).sort((a, b) => a.label.localeCompare(b.label));
|
|
279
|
-
return /* @__PURE__ */
|
|
280
|
-
/* @__PURE__ */
|
|
281
|
-
/* @__PURE__ */
|
|
282
|
-
|
|
1060
|
+
return /* @__PURE__ */ jsxs8(Form5.Group, { className: "mb-3", children: [
|
|
1061
|
+
/* @__PURE__ */ jsx10(Form5.Label, { children: label }),
|
|
1062
|
+
/* @__PURE__ */ jsxs8(
|
|
1063
|
+
Form5.Select,
|
|
283
1064
|
{
|
|
284
1065
|
value,
|
|
285
1066
|
onChange: (e) => handleChange(key, e.target.value),
|
|
286
1067
|
isInvalid: !!errors[key],
|
|
287
1068
|
children: [
|
|
288
|
-
/* @__PURE__ */
|
|
289
|
-
orderedOptions.map((option) => /* @__PURE__ */
|
|
1069
|
+
/* @__PURE__ */ jsx10("option", { value: "", children: "Selecione..." }),
|
|
1070
|
+
orderedOptions.map((option) => /* @__PURE__ */ jsx10("option", { value: option.value, children: option.label }, String(option.value)))
|
|
290
1071
|
]
|
|
291
1072
|
}
|
|
292
1073
|
),
|
|
293
|
-
/* @__PURE__ */
|
|
1074
|
+
/* @__PURE__ */ jsx10(Form5.Control.Feedback, { type: "invalid", children: errors[key] })
|
|
294
1075
|
] }, key);
|
|
295
1076
|
}
|
|
296
1077
|
case "custom-select":
|
|
297
1078
|
if (renderCustomSelect) {
|
|
298
|
-
return /* @__PURE__ */
|
|
1079
|
+
return /* @__PURE__ */ jsxs8("div", { children: [
|
|
299
1080
|
renderCustomSelect({
|
|
300
1081
|
label,
|
|
301
1082
|
value,
|
|
@@ -303,15 +1084,15 @@ var GenericForm = ({ fields, onSubmit, renderCustomSelect }) => {
|
|
|
303
1084
|
onChange: (v) => handleChange(key, v),
|
|
304
1085
|
placeholder
|
|
305
1086
|
}),
|
|
306
|
-
errors[key] && /* @__PURE__ */
|
|
1087
|
+
errors[key] && /* @__PURE__ */ jsx10("div", { className: "invalid-feedback d-block", children: errors[key] })
|
|
307
1088
|
] }, key);
|
|
308
1089
|
}
|
|
309
1090
|
return null;
|
|
310
1091
|
case "date":
|
|
311
|
-
return /* @__PURE__ */
|
|
312
|
-
/* @__PURE__ */
|
|
313
|
-
/* @__PURE__ */
|
|
314
|
-
|
|
1092
|
+
return /* @__PURE__ */ jsxs8(Form5.Group, { className: "mb-3", children: [
|
|
1093
|
+
/* @__PURE__ */ jsx10(Form5.Label, { children: label }),
|
|
1094
|
+
/* @__PURE__ */ jsx10(
|
|
1095
|
+
Form5.Control,
|
|
315
1096
|
{
|
|
316
1097
|
type: "date",
|
|
317
1098
|
value,
|
|
@@ -319,23 +1100,23 @@ var GenericForm = ({ fields, onSubmit, renderCustomSelect }) => {
|
|
|
319
1100
|
isInvalid: !!errors[key]
|
|
320
1101
|
}
|
|
321
1102
|
),
|
|
322
|
-
/* @__PURE__ */
|
|
1103
|
+
/* @__PURE__ */ jsx10(Form5.Control.Feedback, { type: "invalid", children: errors[key] })
|
|
323
1104
|
] }, key);
|
|
324
1105
|
default:
|
|
325
1106
|
return null;
|
|
326
1107
|
}
|
|
327
1108
|
};
|
|
328
|
-
return /* @__PURE__ */
|
|
1109
|
+
return /* @__PURE__ */ jsxs8(Form5, { onSubmit: handleSubmit, children: [
|
|
329
1110
|
fields.map((field) => renderField(field)),
|
|
330
|
-
/* @__PURE__ */
|
|
1111
|
+
/* @__PURE__ */ jsx10("div", { className: "d-grid", children: /* @__PURE__ */ jsx10(Button6, { variant: "primary", type: "submit", children: "Salvar" }) })
|
|
331
1112
|
] });
|
|
332
1113
|
};
|
|
333
1114
|
var GenericForm_default = GenericForm;
|
|
334
1115
|
|
|
335
1116
|
// src/forms/GenericSelect.tsx
|
|
336
|
-
import { useEffect as
|
|
337
|
-
import { Form as
|
|
338
|
-
import { Fragment as
|
|
1117
|
+
import { useEffect as useEffect3, useState as useState8 } from "react";
|
|
1118
|
+
import { Form as Form6, InputGroup as InputGroup3 } from "react-bootstrap";
|
|
1119
|
+
import { Fragment as Fragment5, jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
339
1120
|
var GenericSelectOps = class {
|
|
340
1121
|
constructor(noLabel, title, onChange, ops, selection, returnType, displayType, filter, filterField, valueType, loadFunc, loadCondition, actionClick, locked) {
|
|
341
1122
|
this.noLabel = noLabel;
|
|
@@ -372,8 +1153,8 @@ var GenericSelect = ({
|
|
|
372
1153
|
isBold,
|
|
373
1154
|
...restProps
|
|
374
1155
|
}) => {
|
|
375
|
-
const [options, setOptions] =
|
|
376
|
-
|
|
1156
|
+
const [options, setOptions] = useState8(ops || []);
|
|
1157
|
+
useEffect3(() => {
|
|
377
1158
|
const loadFunction = async () => {
|
|
378
1159
|
if (loadCondition && loadFunc) {
|
|
379
1160
|
loadFunc().then((res) => {
|
|
@@ -398,15 +1179,15 @@ var GenericSelect = ({
|
|
|
398
1179
|
}
|
|
399
1180
|
};
|
|
400
1181
|
const defaultPlaceholder = (restProps == null ? void 0 : restProps.default) || "Seleciona uma Op\xE7\xE3o";
|
|
401
|
-
const selectContent = /* @__PURE__ */
|
|
402
|
-
|
|
1182
|
+
const selectContent = /* @__PURE__ */ jsxs9(
|
|
1183
|
+
Form6.Control,
|
|
403
1184
|
{
|
|
404
1185
|
disabled: locked,
|
|
405
1186
|
as: "select",
|
|
406
1187
|
value: selection,
|
|
407
1188
|
onChange: (event) => getTrueValue(event.target.selectedIndex),
|
|
408
1189
|
children: [
|
|
409
|
-
/* @__PURE__ */
|
|
1190
|
+
/* @__PURE__ */ jsxs9("option", { value: void 0, children: [
|
|
410
1191
|
"-- ",
|
|
411
1192
|
defaultPlaceholder,
|
|
412
1193
|
" --"
|
|
@@ -415,34 +1196,38 @@ var GenericSelect = ({
|
|
|
415
1196
|
const val = valueType && op[valueType] || op.id || op;
|
|
416
1197
|
let fill = displayType && op[displayType] || op;
|
|
417
1198
|
if (typeof fill == "object") fill = "";
|
|
418
|
-
return /* @__PURE__ */
|
|
1199
|
+
return /* @__PURE__ */ jsx11("option", { value: val, children: fill }, op.id || index);
|
|
419
1200
|
})
|
|
420
1201
|
]
|
|
421
1202
|
}
|
|
422
1203
|
);
|
|
423
1204
|
if (actionClick) {
|
|
424
|
-
return /* @__PURE__ */
|
|
425
|
-
/* @__PURE__ */
|
|
426
|
-
/* @__PURE__ */
|
|
1205
|
+
return /* @__PURE__ */ jsxs9(Fragment5, { children: [
|
|
1206
|
+
/* @__PURE__ */ jsx11(Form6.Label, { style: { fontWeight: isBold ? "bold" : void 0 }, hidden: noLabel, children: title }),
|
|
1207
|
+
/* @__PURE__ */ jsxs9(InputGroup3, { children: [
|
|
427
1208
|
selectContent,
|
|
428
1209
|
actionClick()
|
|
429
1210
|
] })
|
|
430
1211
|
] });
|
|
431
1212
|
}
|
|
432
|
-
return /* @__PURE__ */
|
|
433
|
-
/* @__PURE__ */
|
|
1213
|
+
return /* @__PURE__ */ jsxs9(Fragment5, { children: [
|
|
1214
|
+
/* @__PURE__ */ jsx11(Form6.Label, { style: { fontWeight: isBold ? "bold" : void 0 }, hidden: noLabel, children: title }),
|
|
434
1215
|
selectContent
|
|
435
1216
|
] });
|
|
436
1217
|
};
|
|
437
1218
|
var GenericSelect_default = GenericSelect;
|
|
438
1219
|
export {
|
|
1220
|
+
ActionButtons,
|
|
439
1221
|
AddButton_default as AddButton,
|
|
1222
|
+
AutoComplete,
|
|
440
1223
|
ConfigObject,
|
|
441
1224
|
DeleteButton_default as DeleteButton,
|
|
1225
|
+
DeleteConfirm,
|
|
442
1226
|
GenericDisplay_default as GenericDisplay,
|
|
443
1227
|
GenericForm_default as GenericForm,
|
|
444
1228
|
GenericSelect_default as GenericSelect,
|
|
445
1229
|
GenericSelectOps,
|
|
1230
|
+
MailSender,
|
|
446
1231
|
ResponsiveContainer_default as ResponsiveContainer,
|
|
447
1232
|
UuidPill_default as UuidPill
|
|
448
1233
|
};
|