@charlesgomes/leafcode-shared-lib-react 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/dist/assets/images/seta.svg +3 -0
- package/dist/index.css +462 -0
- package/dist/index.d.mts +89 -0
- package/dist/index.d.ts +89 -0
- package/dist/index.js +995 -0
- package/dist/index.mjs +949 -0
- package/dist/seta-T37FWQKV.svg +3 -0
- package/dist/styles/table.css +548 -0
- package/package.json +59 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,995 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.tsx
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
Botao: () => Botao,
|
|
34
|
+
DataTableAdvancedFilter: () => DataTableAdvancedFilter,
|
|
35
|
+
DateFilterTemplate: () => DateFilterTemplate,
|
|
36
|
+
DateTimeFilterTemplate: () => DateTimeFilterTemplate,
|
|
37
|
+
FilterMatchMode: () => import_api4.FilterMatchMode,
|
|
38
|
+
FilterOperator: () => import_api4.FilterOperator,
|
|
39
|
+
SelectFilterTemplate: () => SelectFilterTemplate,
|
|
40
|
+
ValueFilterTemplate: () => ValueFilterTemplate,
|
|
41
|
+
getDefaultFilterMatchOptionsDate: () => getDefaultFilterMatchOptionsDate,
|
|
42
|
+
getDefaultFilterMatchOptionsString: () => getDefaultFilterMatchOptionsString
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(index_exports);
|
|
45
|
+
|
|
46
|
+
// src/components/Botao/Botao.tsx
|
|
47
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
48
|
+
function Botao({ label, onClick, disabled }) {
|
|
49
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
50
|
+
"button",
|
|
51
|
+
{
|
|
52
|
+
onClick,
|
|
53
|
+
disabled,
|
|
54
|
+
style: {
|
|
55
|
+
backgroundColor: disabled ? "#9ca3af" : "#0070f3",
|
|
56
|
+
color: "#fff",
|
|
57
|
+
padding: "10px 16px",
|
|
58
|
+
borderRadius: 8,
|
|
59
|
+
border: "none",
|
|
60
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
61
|
+
fontWeight: 600
|
|
62
|
+
},
|
|
63
|
+
children: label
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/components/DataTableAdvancedFilter/DataTableAdvancedFilter.tsx
|
|
69
|
+
var import_react6 = require("react");
|
|
70
|
+
|
|
71
|
+
// src/components/DataTableAdvancedFilter/DataTableAdvancedFilterWrapper.tsx
|
|
72
|
+
var import_react4 = require("react");
|
|
73
|
+
var import_react_query = require("@tanstack/react-query");
|
|
74
|
+
|
|
75
|
+
// src/primereact-compat.ts
|
|
76
|
+
var import_datatable = require("primereact/datatable");
|
|
77
|
+
var import_column = require("primereact/column");
|
|
78
|
+
var import_inputtext = require("primereact/inputtext");
|
|
79
|
+
var import_inputnumber = require("primereact/inputnumber");
|
|
80
|
+
var import_calendar = require("primereact/calendar");
|
|
81
|
+
var import_api = require("primereact/api");
|
|
82
|
+
|
|
83
|
+
// src/components/DataTableAdvancedFilter/TableHeader.tsx
|
|
84
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
85
|
+
var TableHeader = ({ globalFilterValue, onGlobalFilterChange }) => {
|
|
86
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
87
|
+
import_inputtext.InputText,
|
|
88
|
+
{
|
|
89
|
+
value: globalFilterValue,
|
|
90
|
+
onChange: onGlobalFilterChange,
|
|
91
|
+
placeholder: "Pesquisar...",
|
|
92
|
+
className: "custom-input"
|
|
93
|
+
}
|
|
94
|
+
) });
|
|
95
|
+
};
|
|
96
|
+
var TableHeader_default = TableHeader;
|
|
97
|
+
|
|
98
|
+
// src/components/DataTableAdvancedFilter/DataTableAdvancedFilterWrapper.tsx
|
|
99
|
+
var import_react5 = require("@phosphor-icons/react");
|
|
100
|
+
|
|
101
|
+
// src/components/DataTableAdvancedFilter/TableActions.tsx
|
|
102
|
+
var import_react = require("@phosphor-icons/react");
|
|
103
|
+
|
|
104
|
+
// src/utils/utils.ts
|
|
105
|
+
var import_clsx = require("clsx");
|
|
106
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
107
|
+
function cn(...inputs) {
|
|
108
|
+
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
109
|
+
}
|
|
110
|
+
function phraseToId(phrase) {
|
|
111
|
+
if (!phrase) return "";
|
|
112
|
+
return phrase.trim().toLowerCase().replace(/[áàâãä]/g, "a").replace(/[éèêë]/g, "e").replace(/[íìîï]/g, "i").replace(/[óòôõö]/g, "o").replace(/[úùûü]/g, "u").replace(/[ç]/g, "c").replace(/[^a-z0-9\-_]+/g, "-").replace(/^-+|-+$/g, "").replace(/-{2,}/g, "-").replace(/^[0-9]/, "_$&");
|
|
113
|
+
}
|
|
114
|
+
function centsToReal(value) {
|
|
115
|
+
if (isNaN(value)) return 0;
|
|
116
|
+
return value / 100;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/components/TooltipCustom.tsx
|
|
120
|
+
var import_react_tooltip = require("react-tooltip");
|
|
121
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
122
|
+
function TooltipCustom({ label, id }) {
|
|
123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
124
|
+
import_react_tooltip.Tooltip,
|
|
125
|
+
{
|
|
126
|
+
className: "tooltip-icone",
|
|
127
|
+
opacity: 1,
|
|
128
|
+
place: "top",
|
|
129
|
+
anchorSelect: `#${id}`,
|
|
130
|
+
style: {
|
|
131
|
+
zIndex: 9999
|
|
132
|
+
},
|
|
133
|
+
positionStrategy: "fixed",
|
|
134
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "tooltip-custom", children: label })
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// src/components/DataTableAdvancedFilter/TableActions.tsx
|
|
140
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
141
|
+
function TableActions({
|
|
142
|
+
onNew,
|
|
143
|
+
onEdit,
|
|
144
|
+
onDelete,
|
|
145
|
+
selectedRows,
|
|
146
|
+
customActions = []
|
|
147
|
+
}) {
|
|
148
|
+
const disableButtonsNotMultiplesSelecteds = selectedRows?.length !== 1 ? true : false;
|
|
149
|
+
const enableButtonsNotMultiplesSelecteds = selectedRows?.length > 0 ? true : false;
|
|
150
|
+
const resolvedCustomActions = typeof customActions === "function" ? customActions(selectedRows) : customActions;
|
|
151
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "box-icones-table-actions", children: [
|
|
152
|
+
onNew && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
153
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
154
|
+
"button",
|
|
155
|
+
{
|
|
156
|
+
id: "add",
|
|
157
|
+
onClick: onNew,
|
|
158
|
+
className: cn(
|
|
159
|
+
"enable-button-table-actions",
|
|
160
|
+
enableButtonsNotMultiplesSelecteds && "disable-button-table-actions"
|
|
161
|
+
),
|
|
162
|
+
disabled: enableButtonsNotMultiplesSelecteds,
|
|
163
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react.Plus, { size: 18 })
|
|
164
|
+
}
|
|
165
|
+
),
|
|
166
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TooltipCustom, { id: "add", label: "Adicionar" })
|
|
167
|
+
] }),
|
|
168
|
+
onEdit && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
169
|
+
"button",
|
|
170
|
+
{
|
|
171
|
+
id: "edit",
|
|
172
|
+
onClick: () => onEdit(selectedRows),
|
|
173
|
+
className: cn(
|
|
174
|
+
"enable-button-table-actions",
|
|
175
|
+
disableButtonsNotMultiplesSelecteds && "disable-button-table-actions"
|
|
176
|
+
),
|
|
177
|
+
disabled: disableButtonsNotMultiplesSelecteds,
|
|
178
|
+
children: [
|
|
179
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react.PencilSimple, { size: 18 }),
|
|
180
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TooltipCustom, { id: "edit", label: "Editar" })
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
) }),
|
|
184
|
+
onDelete && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
185
|
+
"button",
|
|
186
|
+
{
|
|
187
|
+
id: "delete",
|
|
188
|
+
onClick: () => onDelete(selectedRows),
|
|
189
|
+
className: cn(
|
|
190
|
+
"enable-button-table-actions",
|
|
191
|
+
!enableButtonsNotMultiplesSelecteds && "disable-button-table-actions"
|
|
192
|
+
),
|
|
193
|
+
disabled: !enableButtonsNotMultiplesSelecteds,
|
|
194
|
+
children: [
|
|
195
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react.Trash, { size: 18 }),
|
|
196
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TooltipCustom, { id: "delete", label: "Excluir" })
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
) }),
|
|
200
|
+
resolvedCustomActions?.map((action) => {
|
|
201
|
+
const id = `action-table${phraseToId(action.label)}`;
|
|
202
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
203
|
+
"button",
|
|
204
|
+
{
|
|
205
|
+
id,
|
|
206
|
+
onClick: () => action.onClick(selectedRows),
|
|
207
|
+
className: cn("enable-button-table-actions", action.className),
|
|
208
|
+
children: [
|
|
209
|
+
action.icon,
|
|
210
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TooltipCustom, { id, label: action.label })
|
|
211
|
+
]
|
|
212
|
+
},
|
|
213
|
+
id
|
|
214
|
+
);
|
|
215
|
+
})
|
|
216
|
+
] });
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// src/components/DataTableAdvancedFilter/ActionsColumn.tsx
|
|
220
|
+
var import_react2 = require("@phosphor-icons/react");
|
|
221
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
222
|
+
function ActionsColumn({
|
|
223
|
+
row,
|
|
224
|
+
onEdit,
|
|
225
|
+
onDelete,
|
|
226
|
+
customActionsColums
|
|
227
|
+
}) {
|
|
228
|
+
const resolvedCustomActions = typeof customActionsColums === "function" ? customActionsColums(row) : customActionsColums;
|
|
229
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "box-icones-actions-column", children: [
|
|
230
|
+
onEdit && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
231
|
+
"button",
|
|
232
|
+
{
|
|
233
|
+
id: "edit-column",
|
|
234
|
+
className: "btn-icone-actions-column",
|
|
235
|
+
onClick: (e) => {
|
|
236
|
+
onEdit && onEdit([row]);
|
|
237
|
+
},
|
|
238
|
+
children: [
|
|
239
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react2.PencilSimple, { size: 17, weight: "regular" }),
|
|
240
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TooltipCustom, { id: "edit-column", label: "Editar" })
|
|
241
|
+
]
|
|
242
|
+
}
|
|
243
|
+
) }),
|
|
244
|
+
onDelete && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
245
|
+
"button",
|
|
246
|
+
{
|
|
247
|
+
id: "delete-column",
|
|
248
|
+
className: "btn-icone-actions-column",
|
|
249
|
+
onClick: (e) => {
|
|
250
|
+
onDelete && onDelete([row]);
|
|
251
|
+
},
|
|
252
|
+
children: [
|
|
253
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react2.Trash, { size: 17, weight: "regular" }),
|
|
254
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TooltipCustom, { id: "delete-column", label: "Excluir" })
|
|
255
|
+
]
|
|
256
|
+
}
|
|
257
|
+
) }),
|
|
258
|
+
resolvedCustomActions?.map((action) => {
|
|
259
|
+
const id = `action-colunm-${phraseToId(action.label)}`;
|
|
260
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
261
|
+
"button",
|
|
262
|
+
{
|
|
263
|
+
id,
|
|
264
|
+
onClick: () => action.onClick([row]),
|
|
265
|
+
className: cn("btn-icone-actions-column", action.className),
|
|
266
|
+
children: [
|
|
267
|
+
action.icon,
|
|
268
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TooltipCustom, { id, label: action.label })
|
|
269
|
+
]
|
|
270
|
+
},
|
|
271
|
+
id
|
|
272
|
+
);
|
|
273
|
+
})
|
|
274
|
+
] });
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// src/components/DataTableAdvancedFilter/DynamicColumns.tsx
|
|
278
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
279
|
+
function DynamicColumns({
|
|
280
|
+
columns,
|
|
281
|
+
isMultiSelectionMode = true,
|
|
282
|
+
onEdit,
|
|
283
|
+
onDelete,
|
|
284
|
+
customActionsColums = []
|
|
285
|
+
}) {
|
|
286
|
+
const array = [];
|
|
287
|
+
if (isMultiSelectionMode) {
|
|
288
|
+
array.push(
|
|
289
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
290
|
+
import_column.Column,
|
|
291
|
+
{
|
|
292
|
+
selectionMode: "multiple",
|
|
293
|
+
headerStyle: { width: "3rem" },
|
|
294
|
+
exportable: false,
|
|
295
|
+
resizeable: false
|
|
296
|
+
},
|
|
297
|
+
"selection"
|
|
298
|
+
)
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
columns.forEach((col, idx) => {
|
|
302
|
+
const isActionsCol = col.field === "acoes";
|
|
303
|
+
const width = isActionsCol && col?.size ? col.size + "rem" : "6rem";
|
|
304
|
+
array.push(
|
|
305
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
306
|
+
import_column.Column,
|
|
307
|
+
{
|
|
308
|
+
field: isActionsCol ? void 0 : col.field,
|
|
309
|
+
header: col.header,
|
|
310
|
+
filter: !isActionsCol,
|
|
311
|
+
frozen: col.frozen,
|
|
312
|
+
alignFrozen: col.alignFrozen,
|
|
313
|
+
dataType: col.dataType,
|
|
314
|
+
filterElement: col.filterElement ? (options) => col.filterElement?.(options, col.mask) ?? void 0 : void 0,
|
|
315
|
+
filterMatchModeOptions: col.filterMatchModeOptions,
|
|
316
|
+
filterPlaceholder: !isActionsCol ? "Procurar" : void 0,
|
|
317
|
+
...col.field !== "acoes" && {
|
|
318
|
+
resizeable: col.enableResizeable ?? true
|
|
319
|
+
},
|
|
320
|
+
style: isActionsCol ? { width, minWidth: width, position: "relative" } : {},
|
|
321
|
+
body: (rowData) => isActionsCol ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
322
|
+
ActionsColumn,
|
|
323
|
+
{
|
|
324
|
+
row: rowData,
|
|
325
|
+
onEdit,
|
|
326
|
+
onDelete,
|
|
327
|
+
customActionsColums
|
|
328
|
+
}
|
|
329
|
+
) : col.body ? col.body(rowData) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: String(rowData[col.field]) }),
|
|
330
|
+
sortable: !isActionsCol ? col.enableSorting ?? true : false
|
|
331
|
+
},
|
|
332
|
+
`${String(col.field)}-${idx}`
|
|
333
|
+
)
|
|
334
|
+
);
|
|
335
|
+
});
|
|
336
|
+
return array;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// src/utils/DataTableUtils.tsx
|
|
340
|
+
var getUrlParams = (sortFieldInitial, sortOrderInitial) => {
|
|
341
|
+
const params = new URLSearchParams(
|
|
342
|
+
typeof window !== "undefined" ? window.location.search : ""
|
|
343
|
+
);
|
|
344
|
+
return {
|
|
345
|
+
page: Number(params.get("page") ?? 1),
|
|
346
|
+
rows: Number(params.get("rows") ?? 10),
|
|
347
|
+
sortField: params.get("sortField") || sortFieldInitial || "",
|
|
348
|
+
sortOrder: Number(params.get("sortOrder") ?? sortOrderInitial),
|
|
349
|
+
filter: params.get("filter") ?? ""
|
|
350
|
+
};
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
// src/hooks/use-debounce.ts
|
|
354
|
+
var import_react3 = require("react");
|
|
355
|
+
var useDebounce = (value, delay) => {
|
|
356
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react3.useState)(value);
|
|
357
|
+
(0, import_react3.useEffect)(() => {
|
|
358
|
+
const timer = setTimeout(() => {
|
|
359
|
+
setDebouncedValue(value);
|
|
360
|
+
}, delay || 500);
|
|
361
|
+
return () => {
|
|
362
|
+
clearTimeout(timer);
|
|
363
|
+
};
|
|
364
|
+
}, [value, delay]);
|
|
365
|
+
return debouncedValue;
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
// src/components/DataTableAdvancedFilter/DataTableAdvancedFilterWrapper.tsx
|
|
369
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
370
|
+
function DataTableAdvancedFilterWrapper({
|
|
371
|
+
queryKey,
|
|
372
|
+
mutationFn,
|
|
373
|
+
columns,
|
|
374
|
+
initFilters,
|
|
375
|
+
onNew,
|
|
376
|
+
onEdit,
|
|
377
|
+
onDelete,
|
|
378
|
+
customActions = [],
|
|
379
|
+
customActionsColums = [],
|
|
380
|
+
disablePagination = false,
|
|
381
|
+
sortFieldInitial,
|
|
382
|
+
sortOrderInitial = 1,
|
|
383
|
+
isMultiSelectionMode = true
|
|
384
|
+
}) {
|
|
385
|
+
const [isClient, setIsClient] = (0, import_react4.useState)(false);
|
|
386
|
+
(0, import_react4.useEffect)(() => {
|
|
387
|
+
setIsClient(true);
|
|
388
|
+
}, []);
|
|
389
|
+
const {
|
|
390
|
+
page: urlPage,
|
|
391
|
+
rows: urlRows,
|
|
392
|
+
sortField: urlSortField,
|
|
393
|
+
sortOrder: urlSortOrder,
|
|
394
|
+
filter: urlFilter
|
|
395
|
+
} = getUrlParams(sortFieldInitial, sortOrderInitial);
|
|
396
|
+
const [page, setPage] = (0, import_react4.useState)(urlPage);
|
|
397
|
+
const [rows, setRows] = (0, import_react4.useState)(urlRows);
|
|
398
|
+
const [first, setFirst] = (0, import_react4.useState)((urlPage - 1) * urlRows);
|
|
399
|
+
const [sortField, setSortField] = (0, import_react4.useState)(urlSortField);
|
|
400
|
+
const [sortOrder, setSortOrder] = (0, import_react4.useState)(urlSortOrder);
|
|
401
|
+
const [searchText, setSearchText] = (0, import_react4.useState)(urlFilter);
|
|
402
|
+
const [filters, setFilters] = (0, import_react4.useState)({
|
|
403
|
+
...initFilters,
|
|
404
|
+
global: { value: urlFilter, matchMode: "contains" }
|
|
405
|
+
});
|
|
406
|
+
const [selectedRowsData, setSelectedRowsData] = (0, import_react4.useState)([]);
|
|
407
|
+
const debouncedSearch = useDebounce(searchText, 500);
|
|
408
|
+
const debouncedFilters = (0, import_react4.useMemo)(() => {
|
|
409
|
+
const f = { ...filters };
|
|
410
|
+
if (!f.global) f.global = { value: "", matchMode: "contains" };
|
|
411
|
+
f.global.value = debouncedSearch;
|
|
412
|
+
return f;
|
|
413
|
+
}, [filters, debouncedSearch]);
|
|
414
|
+
const filtersKey = JSON.stringify(debouncedFilters);
|
|
415
|
+
const globalFilterFields = (0, import_react4.useMemo)(() => {
|
|
416
|
+
return columns?.filter(
|
|
417
|
+
(col) => col.filterGlobal === true && col.field !== "acoes"
|
|
418
|
+
).map((col) => col.field) ?? [];
|
|
419
|
+
}, [columns]);
|
|
420
|
+
const { data: customers, isLoading } = (0, import_react_query.useQuery)({
|
|
421
|
+
queryKey: [queryKey, { page, rows, sortField, sortOrder, filtersKey }],
|
|
422
|
+
queryFn: () => mutationFn(
|
|
423
|
+
page,
|
|
424
|
+
rows,
|
|
425
|
+
sortField,
|
|
426
|
+
sortOrder,
|
|
427
|
+
debouncedFilters,
|
|
428
|
+
globalFilterFields
|
|
429
|
+
)
|
|
430
|
+
});
|
|
431
|
+
const updateUrlParams = (params) => {
|
|
432
|
+
if (typeof window === "undefined") return;
|
|
433
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
434
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
435
|
+
if (value === void 0 || value === null || value === "") {
|
|
436
|
+
urlParams.delete(key);
|
|
437
|
+
} else {
|
|
438
|
+
urlParams.set(
|
|
439
|
+
key,
|
|
440
|
+
typeof value === "string" ? value : JSON.stringify(value)
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
window.history.replaceState(
|
|
445
|
+
null,
|
|
446
|
+
"",
|
|
447
|
+
`${window.location.pathname}?${urlParams.toString()}`
|
|
448
|
+
);
|
|
449
|
+
};
|
|
450
|
+
const onPage = (event) => {
|
|
451
|
+
setFirst(event.first);
|
|
452
|
+
setRows(event.rows);
|
|
453
|
+
setPage(event.page + 1);
|
|
454
|
+
updateUrlParams({ page: event.page + 1, rows: event.rows });
|
|
455
|
+
};
|
|
456
|
+
const onGlobalFilterChange = (e) => {
|
|
457
|
+
const value = e.target.value;
|
|
458
|
+
const _filters = { ...filters };
|
|
459
|
+
if (!_filters.global)
|
|
460
|
+
_filters.global = { value: "", matchMode: "contains" };
|
|
461
|
+
_filters.global.value = value;
|
|
462
|
+
setFilters(_filters);
|
|
463
|
+
setSearchText(value);
|
|
464
|
+
setPage(1);
|
|
465
|
+
setFirst(0);
|
|
466
|
+
updateUrlParams({ page: 1, filter: value });
|
|
467
|
+
};
|
|
468
|
+
const onSort = (e) => {
|
|
469
|
+
setSortField(e.sortField);
|
|
470
|
+
setSortOrder(e.sortOrder);
|
|
471
|
+
updateUrlParams({ sortField: e.sortField, sortOrder: e.sortOrder });
|
|
472
|
+
};
|
|
473
|
+
(0, import_react4.useEffect)(() => {
|
|
474
|
+
if (customers?.items && selectedRowsData.length > 0) {
|
|
475
|
+
const currentIds = new Set(customers.items.map((item) => item.id));
|
|
476
|
+
const filteredSelection = selectedRowsData.filter(
|
|
477
|
+
(item) => currentIds.has(item.id)
|
|
478
|
+
);
|
|
479
|
+
if (filteredSelection.length !== selectedRowsData.length) {
|
|
480
|
+
setSelectedRowsData(filteredSelection);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}, [customers?.items, selectedRowsData]);
|
|
484
|
+
const TableHeaderAndTableActions = (0, import_react4.useMemo)(
|
|
485
|
+
() => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
486
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
487
|
+
TableHeader_default,
|
|
488
|
+
{
|
|
489
|
+
globalFilterValue: searchText,
|
|
490
|
+
onGlobalFilterChange
|
|
491
|
+
}
|
|
492
|
+
),
|
|
493
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
494
|
+
TableActions,
|
|
495
|
+
{
|
|
496
|
+
selectedRows: selectedRowsData,
|
|
497
|
+
onNew,
|
|
498
|
+
onEdit,
|
|
499
|
+
onDelete,
|
|
500
|
+
customActions
|
|
501
|
+
}
|
|
502
|
+
)
|
|
503
|
+
] }),
|
|
504
|
+
[selectedRowsData, onNew, onEdit, onDelete, customActions]
|
|
505
|
+
);
|
|
506
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: isClient && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
|
|
507
|
+
disablePagination && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "disablePagination", children: globalFilterFields.length > 0 && TableHeaderAndTableActions }),
|
|
508
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
509
|
+
import_datatable.DataTable,
|
|
510
|
+
{
|
|
511
|
+
value: customers?.items ?? [],
|
|
512
|
+
lazy: true,
|
|
513
|
+
first,
|
|
514
|
+
rows,
|
|
515
|
+
paginator: !disablePagination,
|
|
516
|
+
totalRecords: customers?.totalCount ?? 0,
|
|
517
|
+
onPage,
|
|
518
|
+
showGridlines: true,
|
|
519
|
+
loading: isLoading,
|
|
520
|
+
resizableColumns: true,
|
|
521
|
+
scrollable: true,
|
|
522
|
+
scrollHeight: "calc(100vh - 13rem)",
|
|
523
|
+
dataKey: "id",
|
|
524
|
+
size: "small",
|
|
525
|
+
rowClassName: () => "box-row-table",
|
|
526
|
+
filters,
|
|
527
|
+
selection: selectedRowsData,
|
|
528
|
+
onSelectionChange: (e) => setSelectedRowsData(e.value),
|
|
529
|
+
onSort,
|
|
530
|
+
sortField,
|
|
531
|
+
sortOrder,
|
|
532
|
+
paginatorTemplate: {
|
|
533
|
+
layout: "RowsPerPageDropdown PrevPageLink CurrentPageReport NextPageLink",
|
|
534
|
+
RowsPerPageDropdown: (options) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
535
|
+
"select",
|
|
536
|
+
{
|
|
537
|
+
value: options.value,
|
|
538
|
+
onChange: (e) => options.onChange({
|
|
539
|
+
originalEvent: e,
|
|
540
|
+
value: Number(e.target.value)
|
|
541
|
+
}),
|
|
542
|
+
className: "custom-input custom-select",
|
|
543
|
+
children: options.options.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: opt.value, children: opt.label }, opt.value))
|
|
544
|
+
}
|
|
545
|
+
),
|
|
546
|
+
PrevPageLink: (options) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
547
|
+
"button",
|
|
548
|
+
{
|
|
549
|
+
onClick: options.onClick,
|
|
550
|
+
disabled: options.disabled,
|
|
551
|
+
className: `PrevPage ${options.disabled ? "PrevPageDisabled" : "PrevPageEnabled"}`,
|
|
552
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react5.CaretLeft, { size: 18, color: "#fff" })
|
|
553
|
+
}
|
|
554
|
+
),
|
|
555
|
+
CurrentPageReport: (options) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "pageReport", children: [
|
|
556
|
+
"Mostrando ",
|
|
557
|
+
options.first,
|
|
558
|
+
" a ",
|
|
559
|
+
options.last,
|
|
560
|
+
" de",
|
|
561
|
+
" ",
|
|
562
|
+
options.totalRecords
|
|
563
|
+
] }),
|
|
564
|
+
NextPageLink: (options) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
565
|
+
"button",
|
|
566
|
+
{
|
|
567
|
+
onClick: options.onClick,
|
|
568
|
+
disabled: options.disabled,
|
|
569
|
+
className: `NextPage ${options.disabled ? "NextPageDisabled" : "NextPageEnabled"}`,
|
|
570
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react5.CaretRight, { size: 18, color: "#fff" })
|
|
571
|
+
}
|
|
572
|
+
)
|
|
573
|
+
},
|
|
574
|
+
paginatorPosition: "top",
|
|
575
|
+
paginatorLeft: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "paginatorLeft", children: globalFilterFields.length > 0 && TableHeaderAndTableActions }),
|
|
576
|
+
currentPageReportTemplate: "Mostrando {first} a {last} de {totalRecords}",
|
|
577
|
+
emptyMessage: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "mensagem-nenhum-dado", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { children: "Nenhum dado encontrado" }) }),
|
|
578
|
+
onFilter: (e) => setFilters(e.filters),
|
|
579
|
+
rowsPerPageOptions: [10, 25, 50, 100],
|
|
580
|
+
className: "p-datatable-sm",
|
|
581
|
+
paginatorClassName: "paginatorClassName",
|
|
582
|
+
tableClassName: "tableClassName",
|
|
583
|
+
children: [
|
|
584
|
+
...DynamicColumns({
|
|
585
|
+
columns,
|
|
586
|
+
isMultiSelectionMode,
|
|
587
|
+
onEdit,
|
|
588
|
+
onDelete,
|
|
589
|
+
customActionsColums
|
|
590
|
+
})
|
|
591
|
+
]
|
|
592
|
+
}
|
|
593
|
+
)
|
|
594
|
+
] }) });
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
// src/components/DataTableAdvancedFilter/DataTableAdvancedFilter.tsx
|
|
598
|
+
var import_api2 = require("primereact/api");
|
|
599
|
+
|
|
600
|
+
// src/utils/locale.ts
|
|
601
|
+
var localePtBr = {
|
|
602
|
+
accept: "Sim",
|
|
603
|
+
addRule: "Adicionar Regra",
|
|
604
|
+
am: "AM",
|
|
605
|
+
apply: "Aplicar",
|
|
606
|
+
cancel: "Cancelar",
|
|
607
|
+
choose: "Escolher",
|
|
608
|
+
chooseDate: "Escolher Data",
|
|
609
|
+
chooseMonth: "Escolher M\xEAs",
|
|
610
|
+
chooseYear: "Escolher Ano",
|
|
611
|
+
clear: "Limpar",
|
|
612
|
+
contains: "Cont\xE9m",
|
|
613
|
+
custom: "Personalizado",
|
|
614
|
+
dateAfter: "Data depois de",
|
|
615
|
+
dateBefore: "Data antes de",
|
|
616
|
+
dateFormat: "dd/mm/yy",
|
|
617
|
+
dateIs: "Data \xE9",
|
|
618
|
+
dateIsNot: "Data n\xE3o \xE9",
|
|
619
|
+
dayNames: [
|
|
620
|
+
"Domingo",
|
|
621
|
+
"Segunda-feira",
|
|
622
|
+
"Ter\xE7a-feira",
|
|
623
|
+
"Quarta-feira",
|
|
624
|
+
"Quinta-feira",
|
|
625
|
+
"Sexta-feira",
|
|
626
|
+
"S\xE1bado"
|
|
627
|
+
],
|
|
628
|
+
dayNamesMin: ["D", "S", "T", "Q", "Q", "S", "S"],
|
|
629
|
+
dayNamesShort: ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "S\xE1b"],
|
|
630
|
+
emptyFilterMessage: "Nenhum resultado encontrado",
|
|
631
|
+
emptyMessage: "Nenhuma op\xE7\xE3o dispon\xEDvel",
|
|
632
|
+
endsWith: "Termina com",
|
|
633
|
+
equals: "Igual",
|
|
634
|
+
fileSizeTypes: ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
|
|
635
|
+
filter: "Filtro",
|
|
636
|
+
firstDayOfWeek: 0,
|
|
637
|
+
gt: "Maior que",
|
|
638
|
+
gte: "Maior ou igual a",
|
|
639
|
+
lt: "Menor que",
|
|
640
|
+
lte: "Menor ou igual a",
|
|
641
|
+
matchAll: "Corresponder Todos",
|
|
642
|
+
matchAny: "Corresponder Qualquer",
|
|
643
|
+
medium: "M\xE9dio",
|
|
644
|
+
monthNames: [
|
|
645
|
+
"Janeiro",
|
|
646
|
+
"Fevereiro",
|
|
647
|
+
"Mar\xE7o",
|
|
648
|
+
"Abril",
|
|
649
|
+
"Maio",
|
|
650
|
+
"Junho",
|
|
651
|
+
"Julho",
|
|
652
|
+
"Agosto",
|
|
653
|
+
"Setembro",
|
|
654
|
+
"Outubro",
|
|
655
|
+
"Novembro",
|
|
656
|
+
"Dezembro"
|
|
657
|
+
],
|
|
658
|
+
monthNamesShort: [
|
|
659
|
+
"Jan",
|
|
660
|
+
"Fev",
|
|
661
|
+
"Mar",
|
|
662
|
+
"Abr",
|
|
663
|
+
"Mai",
|
|
664
|
+
"Jun",
|
|
665
|
+
"Jul",
|
|
666
|
+
"Ago",
|
|
667
|
+
"Set",
|
|
668
|
+
"Out",
|
|
669
|
+
"Nov",
|
|
670
|
+
"Dez"
|
|
671
|
+
],
|
|
672
|
+
nextDecade: "Pr\xF3xima D\xE9cada",
|
|
673
|
+
nextHour: "Pr\xF3xima Hora",
|
|
674
|
+
nextMinute: "Pr\xF3ximo Minuto",
|
|
675
|
+
nextMonth: "Pr\xF3ximo M\xEAs",
|
|
676
|
+
nextSecond: "Pr\xF3ximo Segundo",
|
|
677
|
+
nextYear: "Pr\xF3ximo Ano",
|
|
678
|
+
noFilter: "Sem Filtro",
|
|
679
|
+
notContains: "N\xE3o cont\xE9m",
|
|
680
|
+
notEquals: "Diferente",
|
|
681
|
+
now: "Agora",
|
|
682
|
+
passwordPrompt: "Digite uma senha",
|
|
683
|
+
pending: "Pendente",
|
|
684
|
+
pm: "PM",
|
|
685
|
+
prevDecade: "D\xE9cada Anterior",
|
|
686
|
+
prevHour: "Hora Anterior",
|
|
687
|
+
prevMinute: "Minuto Anterior",
|
|
688
|
+
prevMonth: "M\xEAs Anterior",
|
|
689
|
+
prevSecond: "Segundo Anterior",
|
|
690
|
+
prevYear: "Ano Anterior",
|
|
691
|
+
reject: "N\xE3o",
|
|
692
|
+
removeRule: "Remover Regra",
|
|
693
|
+
startsWith: "Come\xE7a com",
|
|
694
|
+
strong: "Forte",
|
|
695
|
+
today: "Hoje",
|
|
696
|
+
upload: "Enviar",
|
|
697
|
+
weak: "Fraco",
|
|
698
|
+
weekHeader: "Sem",
|
|
699
|
+
aria: {
|
|
700
|
+
cancelEdit: "Cancelar Edi\xE7\xE3o",
|
|
701
|
+
close: "Fechar",
|
|
702
|
+
collapseRow: "Recolher Linha",
|
|
703
|
+
editRow: "Editar Linha",
|
|
704
|
+
expandRow: "Expandir Linha",
|
|
705
|
+
falseLabel: "Falso",
|
|
706
|
+
filterConstraint: "Restri\xE7\xE3o de Filtro",
|
|
707
|
+
filterOperator: "Operador de Filtro",
|
|
708
|
+
firstPageLabel: "Primeira P\xE1gina",
|
|
709
|
+
gridView: "Visualiza\xE7\xE3o de Grade",
|
|
710
|
+
hideFilterMenu: "Esconder Menu de Filtro",
|
|
711
|
+
jumpToPageDropdownLabel: "Ir para a P\xE1gina",
|
|
712
|
+
jumpToPageInputLabel: "Ir para a P\xE1gina",
|
|
713
|
+
lastPageLabel: "\xDAltima P\xE1gina",
|
|
714
|
+
listLabel: "Lista de op\xE7\xF5es",
|
|
715
|
+
listView: "Visualiza\xE7\xE3o de Lista",
|
|
716
|
+
moveAllToSource: "Mover Todos para a Origem",
|
|
717
|
+
moveAllToTarget: "Mover Todos para o Destino",
|
|
718
|
+
moveBottom: "Mover para o Final",
|
|
719
|
+
moveDown: "Mover para Baixo",
|
|
720
|
+
moveTop: "Mover para o Topo",
|
|
721
|
+
moveToSource: "Mover para a Origem",
|
|
722
|
+
moveToTarget: "Mover para o Destino",
|
|
723
|
+
moveUp: "Mover para Cima",
|
|
724
|
+
navigation: "Navega\xE7\xE3o",
|
|
725
|
+
next: "Pr\xF3ximo",
|
|
726
|
+
nextPageLabel: "Pr\xF3xima P\xE1gina",
|
|
727
|
+
nullLabel: "N\xE3o Selecionado",
|
|
728
|
+
otpLabel: "Insira o caractere da senha de uso \xFAnico {0}",
|
|
729
|
+
pageLabel: "P\xE1gina {page}",
|
|
730
|
+
previous: "Anterior",
|
|
731
|
+
prevPageLabel: "P\xE1gina Anterior",
|
|
732
|
+
rotateLeft: "Rotacionar para a Esquerda",
|
|
733
|
+
rotateRight: "Rotacionar para a Direita",
|
|
734
|
+
rowsPerPageLabel: "Linhas por p\xE1gina",
|
|
735
|
+
saveEdit: "Salvar Edi\xE7\xE3o",
|
|
736
|
+
scrollTop: "Rolar para o Topo",
|
|
737
|
+
selectAll: "Todos os itens selecionados",
|
|
738
|
+
selectRow: "Linha Selecionada",
|
|
739
|
+
showFilterMenu: "Mostrar Menu de Filtro",
|
|
740
|
+
slide: "Deslizar",
|
|
741
|
+
slideNumber: "Slide {slideNumber}",
|
|
742
|
+
star: "1 estrela",
|
|
743
|
+
stars: "{star} estrelas",
|
|
744
|
+
trueLabel: "Verdadeiro",
|
|
745
|
+
unselectAll: "Todos os itens desmarcados",
|
|
746
|
+
unselectRow: "Linha Desmarcada",
|
|
747
|
+
zoomImage: "Ampliar Imagem",
|
|
748
|
+
zoomIn: "Ampliar",
|
|
749
|
+
zoomOut: "Reduzir"
|
|
750
|
+
}
|
|
751
|
+
};
|
|
752
|
+
|
|
753
|
+
// src/components/DataTableAdvancedFilter/DataTableAdvancedFilter.tsx
|
|
754
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
755
|
+
function DataTableAdvancedFilter({
|
|
756
|
+
queryKey,
|
|
757
|
+
mutationFn,
|
|
758
|
+
columns,
|
|
759
|
+
initFilters,
|
|
760
|
+
onNew,
|
|
761
|
+
onEdit,
|
|
762
|
+
onDelete,
|
|
763
|
+
customActions = [],
|
|
764
|
+
customActionsColums = [],
|
|
765
|
+
disablePagination = false,
|
|
766
|
+
sortFieldInitial,
|
|
767
|
+
sortOrderInitial = 1,
|
|
768
|
+
isMultiSelectionMode = true,
|
|
769
|
+
isLanguagePtBr = true
|
|
770
|
+
}) {
|
|
771
|
+
const [isClient, setIsClient] = (0, import_react6.useState)(false);
|
|
772
|
+
(0, import_api2.addLocale)("pt", localePtBr);
|
|
773
|
+
(0, import_api2.locale)("pt");
|
|
774
|
+
(0, import_react6.useEffect)(() => {
|
|
775
|
+
setIsClient(true);
|
|
776
|
+
}, []);
|
|
777
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: isClient && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_api2.PrimeReactProvider, { value: isLanguagePtBr ? { locale: "pt" } : {}, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
778
|
+
DataTableAdvancedFilterWrapper,
|
|
779
|
+
{
|
|
780
|
+
queryKey,
|
|
781
|
+
mutationFn,
|
|
782
|
+
columns,
|
|
783
|
+
initFilters,
|
|
784
|
+
onNew,
|
|
785
|
+
onEdit,
|
|
786
|
+
onDelete,
|
|
787
|
+
customActions,
|
|
788
|
+
customActionsColums,
|
|
789
|
+
disablePagination,
|
|
790
|
+
sortFieldInitial,
|
|
791
|
+
sortOrderInitial,
|
|
792
|
+
isMultiSelectionMode,
|
|
793
|
+
isLanguagePtBr
|
|
794
|
+
}
|
|
795
|
+
) }) });
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
// src/components/DataTableAdvancedFilter/FilterTemplates.tsx
|
|
799
|
+
var import_react_select = __toESM(require("react-select"));
|
|
800
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
801
|
+
var DateFilterTemplate = (options, mask) => {
|
|
802
|
+
const parsedValue = options.value && typeof options.value === "string" ? /* @__PURE__ */ new Date(options.value + "T00:00:00") : options.value;
|
|
803
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
804
|
+
import_calendar.Calendar,
|
|
805
|
+
{
|
|
806
|
+
value: parsedValue,
|
|
807
|
+
onChange: (e) => {
|
|
808
|
+
if (!e.value) {
|
|
809
|
+
options.filterCallback(null, options.index);
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
const date = e.value;
|
|
813
|
+
const valueToFilter = mask ? mask(date) : `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(
|
|
814
|
+
2,
|
|
815
|
+
"0"
|
|
816
|
+
)}-${String(date.getDate()).padStart(2, "0")}`;
|
|
817
|
+
options.filterCallback(valueToFilter, options.index);
|
|
818
|
+
},
|
|
819
|
+
dateFormat: "dd/mm/yy",
|
|
820
|
+
placeholder: "dd/mm/yyyy",
|
|
821
|
+
mask: "99/99/9999",
|
|
822
|
+
inputClassName: "custom-input"
|
|
823
|
+
}
|
|
824
|
+
);
|
|
825
|
+
};
|
|
826
|
+
var DateTimeFilterTemplate = (options, mask) => {
|
|
827
|
+
const parsedValue = options.value && typeof options.value === "string" ? new Date(options.value) : options.value;
|
|
828
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
829
|
+
import_calendar.Calendar,
|
|
830
|
+
{
|
|
831
|
+
value: parsedValue,
|
|
832
|
+
onChange: (e) => {
|
|
833
|
+
if (!e.value) {
|
|
834
|
+
options.filterCallback(null, options.index);
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
const valueToFilter = mask ? mask(e.value) : e.value;
|
|
838
|
+
options.filterCallback(valueToFilter, options.index);
|
|
839
|
+
},
|
|
840
|
+
dateFormat: "dd/mm/yy",
|
|
841
|
+
placeholder: "dd/mm/yyyy",
|
|
842
|
+
mask: "99/99/9999",
|
|
843
|
+
inputClassName: "custom-input"
|
|
844
|
+
}
|
|
845
|
+
);
|
|
846
|
+
};
|
|
847
|
+
var ValueFilterTemplate = (options, mask) => {
|
|
848
|
+
const parsedValue = options.value !== null && options.value !== void 0 ? centsToReal(options.value) : null;
|
|
849
|
+
const handleChange = (e) => {
|
|
850
|
+
const rawValue = e.value;
|
|
851
|
+
if (rawValue === null || rawValue === void 0) {
|
|
852
|
+
options.filterCallback(null, options.index);
|
|
853
|
+
return;
|
|
854
|
+
}
|
|
855
|
+
const valueToFilter = mask ? mask(rawValue) : rawValue;
|
|
856
|
+
options.filterCallback(valueToFilter, options.index);
|
|
857
|
+
};
|
|
858
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
859
|
+
import_inputnumber.InputNumber,
|
|
860
|
+
{
|
|
861
|
+
value: parsedValue,
|
|
862
|
+
onValueChange: handleChange,
|
|
863
|
+
mode: "currency",
|
|
864
|
+
currency: "BRL",
|
|
865
|
+
locale: "pt-BR",
|
|
866
|
+
inputClassName: "custom-input"
|
|
867
|
+
}
|
|
868
|
+
);
|
|
869
|
+
};
|
|
870
|
+
var SelectFilterTemplate = (options, isLanguagePtBr = true) => {
|
|
871
|
+
const selectOptions = [
|
|
872
|
+
{ label: isLanguagePtBr ? "Todos" : "All", value: null },
|
|
873
|
+
{ label: isLanguagePtBr ? "Sim" : "Yes", value: true },
|
|
874
|
+
{ label: isLanguagePtBr ? "N\xE3o" : "No", value: false }
|
|
875
|
+
];
|
|
876
|
+
const currentValue = selectOptions.find((opt) => opt.value === options.value) || selectOptions[0];
|
|
877
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
878
|
+
import_react_select.default,
|
|
879
|
+
{
|
|
880
|
+
options: selectOptions,
|
|
881
|
+
value: currentValue,
|
|
882
|
+
onChange: (selected) => options.filterCallback(selected?.value),
|
|
883
|
+
placeholder: "Todos",
|
|
884
|
+
isClearable: false,
|
|
885
|
+
isSearchable: false,
|
|
886
|
+
className: "custom-select-filtro",
|
|
887
|
+
styles: {
|
|
888
|
+
control: (baseStyles, state) => ({
|
|
889
|
+
...baseStyles,
|
|
890
|
+
"&:hover": {
|
|
891
|
+
borderColor: state.isFocused ? "#094394" : ""
|
|
892
|
+
},
|
|
893
|
+
borderRadius: "6px"
|
|
894
|
+
}),
|
|
895
|
+
menuList: (base) => ({
|
|
896
|
+
...base,
|
|
897
|
+
"::-webkit-scrollbar": {
|
|
898
|
+
width: "6px",
|
|
899
|
+
height: "auto",
|
|
900
|
+
overflowX: "hidden",
|
|
901
|
+
overflowY: "hidden"
|
|
902
|
+
},
|
|
903
|
+
"::-webkit-scrollbar-track": {
|
|
904
|
+
background: "#fff"
|
|
905
|
+
},
|
|
906
|
+
"::-webkit-scrollbar-thumb": {
|
|
907
|
+
background: "#888",
|
|
908
|
+
borderRadius: "2rem"
|
|
909
|
+
},
|
|
910
|
+
"::-webkit-scrollbar-thumb:hover": {
|
|
911
|
+
background: "#555"
|
|
912
|
+
}
|
|
913
|
+
}),
|
|
914
|
+
option: (provided, state) => ({
|
|
915
|
+
...provided,
|
|
916
|
+
backgroundColor: state.isFocused ? "#094394" : "#ffffff",
|
|
917
|
+
color: state.isFocused ? "#ffffff" : "black",
|
|
918
|
+
"&:hover": {
|
|
919
|
+
backgroundColor: "#094394",
|
|
920
|
+
// Cor de fundo quando em hover
|
|
921
|
+
color: "#ffffff"
|
|
922
|
+
// Cor da palavra quando em hover
|
|
923
|
+
}
|
|
924
|
+
})
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
);
|
|
928
|
+
};
|
|
929
|
+
|
|
930
|
+
// src/components/DataTableAdvancedFilter/filterModes.ts
|
|
931
|
+
var import_api3 = require("primereact/api");
|
|
932
|
+
var customMatchModes = {
|
|
933
|
+
notStartsWith: "notStartsWith",
|
|
934
|
+
notEndsWith: "notEndsWith"
|
|
935
|
+
};
|
|
936
|
+
var getDefaultFilterMatchOptionsString = (isLanguagePtBr = true) => [
|
|
937
|
+
{
|
|
938
|
+
label: isLanguagePtBr ? "Cont\xE9m" : "Contains",
|
|
939
|
+
value: import_api3.FilterMatchMode.CONTAINS
|
|
940
|
+
},
|
|
941
|
+
{
|
|
942
|
+
label: isLanguagePtBr ? "N\xE3o cont\xE9m" : "Does not contain",
|
|
943
|
+
value: import_api3.FilterMatchMode.NOT_CONTAINS
|
|
944
|
+
},
|
|
945
|
+
{
|
|
946
|
+
label: isLanguagePtBr ? "Igual" : "Equals",
|
|
947
|
+
value: import_api3.FilterMatchMode.EQUALS
|
|
948
|
+
},
|
|
949
|
+
{
|
|
950
|
+
label: isLanguagePtBr ? "Diferente" : "Not equals",
|
|
951
|
+
value: import_api3.FilterMatchMode.NOT_EQUALS
|
|
952
|
+
},
|
|
953
|
+
{
|
|
954
|
+
label: isLanguagePtBr ? "Come\xE7a com" : "Starts with",
|
|
955
|
+
value: import_api3.FilterMatchMode.STARTS_WITH
|
|
956
|
+
},
|
|
957
|
+
{
|
|
958
|
+
label: isLanguagePtBr ? "N\xE3o come\xE7a com" : "Does not start with",
|
|
959
|
+
value: customMatchModes.notStartsWith
|
|
960
|
+
},
|
|
961
|
+
{
|
|
962
|
+
label: isLanguagePtBr ? "Termina com" : "Ends with",
|
|
963
|
+
value: import_api3.FilterMatchMode.ENDS_WITH
|
|
964
|
+
},
|
|
965
|
+
{
|
|
966
|
+
label: isLanguagePtBr ? "N\xE3o termina com" : "Does not end with",
|
|
967
|
+
value: customMatchModes.notEndsWith
|
|
968
|
+
}
|
|
969
|
+
];
|
|
970
|
+
var getDefaultFilterMatchOptionsDate = (isLanguagePtBr) => [
|
|
971
|
+
{
|
|
972
|
+
label: isLanguagePtBr ? "Data antes de" : "Date before",
|
|
973
|
+
value: import_api3.FilterMatchMode.DATE_BEFORE
|
|
974
|
+
},
|
|
975
|
+
{
|
|
976
|
+
label: isLanguagePtBr ? "Data depois de" : "Date after",
|
|
977
|
+
value: import_api3.FilterMatchMode.DATE_AFTER
|
|
978
|
+
}
|
|
979
|
+
];
|
|
980
|
+
|
|
981
|
+
// src/index.tsx
|
|
982
|
+
var import_api4 = require("primereact/api");
|
|
983
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
984
|
+
0 && (module.exports = {
|
|
985
|
+
Botao,
|
|
986
|
+
DataTableAdvancedFilter,
|
|
987
|
+
DateFilterTemplate,
|
|
988
|
+
DateTimeFilterTemplate,
|
|
989
|
+
FilterMatchMode,
|
|
990
|
+
FilterOperator,
|
|
991
|
+
SelectFilterTemplate,
|
|
992
|
+
ValueFilterTemplate,
|
|
993
|
+
getDefaultFilterMatchOptionsDate,
|
|
994
|
+
getDefaultFilterMatchOptionsString
|
|
995
|
+
});
|