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