bolesa-apitables 0.1.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.js ADDED
@@ -0,0 +1,2308 @@
1
+ import React4, { createContext, useMemo, useEffect, useId, useState, useContext, useCallback } from 'react';
2
+ import { clsx } from 'clsx';
3
+ import { twMerge } from 'tailwind-merge';
4
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
5
+ import { useDispatch, useSelector, Provider } from 'react-redux';
6
+ import { useForm, Controller } from 'react-hook-form';
7
+ import { createSlice, configureStore, nanoid } from '@reduxjs/toolkit';
8
+ import { IoMdExpand } from 'react-icons/io';
9
+ import { PhotoProvider, PhotoView } from 'react-photo-view';
10
+ import 'react-photo-view/dist/react-photo-view.css';
11
+ import { PiDotsThreeOutlineVerticalBold, PiGearFill } from 'react-icons/pi';
12
+ import { IoCopy } from 'react-icons/io5';
13
+ import { MdInsertLink, MdFilterListAlt } from 'react-icons/md';
14
+ import { ImSpinner6 } from 'react-icons/im';
15
+ import { toast } from 'sonner';
16
+ import { X } from 'lucide-react';
17
+ import { isValid, format } from 'date-fns';
18
+ import DataTable from 'react-data-table-component';
19
+ import { HiChevronUpDown } from 'react-icons/hi2';
20
+ import { FaCircle } from 'react-icons/fa';
21
+ import { FiChevronDown } from 'react-icons/fi';
22
+ import { RiEyeCloseFill } from 'react-icons/ri';
23
+ import parse from 'html-react-parser';
24
+ import axios from 'axios';
25
+
26
+ var ApiTablesConfigContext = createContext(null);
27
+ var runtimeConfig = null;
28
+ function getApiTablesRuntimeConfig() {
29
+ return runtimeConfig;
30
+ }
31
+ function ApiTablesHostProvider({ config, children }) {
32
+ const merged = {
33
+ cn: (...classes) => twMerge(clsx(classes)),
34
+ storage: {
35
+ get: (key) => {
36
+ try {
37
+ const raw = localStorage.getItem(key);
38
+ return raw ? JSON.parse(raw) : null;
39
+ } catch {
40
+ return null;
41
+ }
42
+ },
43
+ set: (key, value) => localStorage.setItem(key, JSON.stringify(value))
44
+ },
45
+ ...config,
46
+ components: config.components
47
+ };
48
+ runtimeConfig = merged;
49
+ return /* @__PURE__ */ jsx(ApiTablesConfigContext.Provider, { value: merged, children });
50
+ }
51
+ function useApiTablesConfig() {
52
+ const config = useContext(ApiTablesConfigContext);
53
+ if (!config) {
54
+ throw new Error("useApiTablesConfig must be used within <ApiTablesHostProvider>");
55
+ }
56
+ return config;
57
+ }
58
+ function useApiTablesComponent(name) {
59
+ const { components } = useApiTablesConfig();
60
+ const component = components[name];
61
+ if (!component) {
62
+ throw new Error(
63
+ `ApiTablesConfig.components.${String(name)} is required but was not provided`
64
+ );
65
+ }
66
+ return component;
67
+ }
68
+ var initialState = {
69
+ tableColumns: [],
70
+ visibleColumns: [],
71
+ selectedRows: [],
72
+ selectedIds: [],
73
+ toggledClearRows: false,
74
+ rowSelectedModal: null
75
+ };
76
+ var tableColumnsSlice = createSlice({
77
+ name: "tableColumns",
78
+ initialState,
79
+ reducers: {
80
+ _setSelectedRows: (state, action) => {
81
+ state.selectedRows = action?.payload;
82
+ state.selectedIds = action?.payload?.length > 0 ? action?.payload?.map((row) => row?.id) : [];
83
+ },
84
+ _setToggledClearRow: (state, action) => {
85
+ state.toggledClearRows = action?.payload;
86
+ },
87
+ _setVisibleColumns: (state, action) => {
88
+ state.visibleColumns = action?.payload;
89
+ state.tableColumns = state.tableColumns?.map((col) => ({
90
+ ...col,
91
+ omit: action?.payload?.indexOf(col?.data_src) === -1
92
+ }));
93
+ },
94
+ _setRowSelectedModal: (state, action) => {
95
+ state.rowSelectedModal = action?.payload;
96
+ },
97
+ _setTableColumns: (state, action) => {
98
+ state.tableColumns = action?.payload?.update ? action?.payload?.cols : formatTableColumns(action?.payload?.cols, action?.payload?.tbData);
99
+ },
100
+ _resetTableColumns: (state) => {
101
+ state.tableColumns = [];
102
+ state.visibleColumns = [];
103
+ state.selectedRows = [];
104
+ state.selectedIds = [];
105
+ state.toggledClearRows = false;
106
+ state.rowSelectedModal = null;
107
+ }
108
+ }
109
+ });
110
+ var { _setSelectedRows, _setToggledClearRow, _setVisibleColumns, _setRowSelectedModal, _setTableColumns, _resetTableColumns } = tableColumnsSlice.actions;
111
+ var tableColumnsSlice_default = tableColumnsSlice.reducer;
112
+
113
+ // src/shims/next-intl.ts
114
+ function useTranslations(namespace) {
115
+ const translate = getApiTablesRuntimeConfig()?.useTranslations?.(namespace);
116
+ return translate ?? ((key) => key);
117
+ }
118
+ function Link(props) {
119
+ const { Link: HostLink } = useApiTablesConfig();
120
+ if (!HostLink) {
121
+ throw new Error("ApiTablesConfig.Link is required for redirect row actions");
122
+ }
123
+ const Comp = HostLink;
124
+ return /* @__PURE__ */ jsx(Comp, { ...props });
125
+ }
126
+ function createHostComponent(name) {
127
+ const HostComponent = (props) => {
128
+ const { components } = useApiTablesConfig();
129
+ const Comp = components[name];
130
+ if (!Comp) {
131
+ throw new Error(`ApiTablesConfig.components.${name} is required`);
132
+ }
133
+ return /* @__PURE__ */ jsx(Comp, { ...props });
134
+ };
135
+ HostComponent.displayName = `ApiTablesHost(${name})`;
136
+ return HostComponent;
137
+ }
138
+
139
+ // src/shims/components.ts
140
+ var Button = createHostComponent("Button");
141
+ var Badge = createHostComponent("Badge");
142
+ createHostComponent("Card");
143
+ var Skeleton = createHostComponent("Skeleton");
144
+ var Switch = createHostComponent("Switch");
145
+ var Label = createHostComponent("Label");
146
+ var Input = createHostComponent("Input");
147
+ createHostComponent("InputWrapper");
148
+ var Checkbox = createHostComponent("Checkbox");
149
+ var Popover = createHostComponent("Popover");
150
+ var PopoverContent = createHostComponent("PopoverContent");
151
+ var PopoverTrigger = createHostComponent("PopoverTrigger");
152
+ var Select = createHostComponent("Select");
153
+ var SelectContent = createHostComponent("SelectContent");
154
+ var SelectGroup = createHostComponent("SelectGroup");
155
+ var SelectItem = createHostComponent("SelectItem");
156
+ var SelectTrigger = createHostComponent("SelectTrigger");
157
+ var SelectValue = createHostComponent("SelectValue");
158
+ var Tooltip = createHostComponent("Tooltip");
159
+ var TooltipContent = createHostComponent("TooltipContent");
160
+ var TooltipTrigger = createHostComponent("TooltipTrigger");
161
+ var Sheet = createHostComponent("Sheet");
162
+ var SheetContent = createHostComponent("SheetContent");
163
+ createHostComponent("SheetDescription");
164
+ var SheetHeader = createHostComponent("SheetHeader");
165
+ var SheetTitle = createHostComponent("SheetTitle");
166
+ var SheetTrigger = createHostComponent("SheetTrigger");
167
+ var DropdownMenu = createHostComponent("DropdownMenu");
168
+ var DropdownMenuContent = createHostComponent("DropdownMenuContent");
169
+ var DropdownMenuItem = createHostComponent("DropdownMenuItem");
170
+ var DropdownMenuTrigger = createHostComponent("DropdownMenuTrigger");
171
+ var Table = createHostComponent("Table");
172
+ var TableBody = createHostComponent("TableBody");
173
+ var TableCell = createHostComponent("TableCell");
174
+ createHostComponent("TableFooter");
175
+ var TableHead = createHostComponent("TableHead");
176
+ var TableHeader = createHostComponent("TableHeader");
177
+ var TableRow = createHostComponent("TableRow");
178
+ var MultiSelect = createHostComponent("MultiSelect");
179
+ var MultiSelectContent = createHostComponent("MultiSelectContent");
180
+ createHostComponent("MultiSelectGroup");
181
+ var MultiSelectItem = createHostComponent("MultiSelectItem");
182
+ var MultiSelectTrigger = createHostComponent("MultiSelectTrigger");
183
+ var MultiSelectValue = createHostComponent("MultiSelectValue");
184
+ var LoadingButton = createHostComponent("LoadingButton");
185
+ var AppCurrency = createHostComponent("AppCurrency");
186
+ var DatePicker = createHostComponent("DatePicker");
187
+ var TagsInput = createHostComponent("TagsInput");
188
+ var CustomPagination = createHostComponent("CustomPagination");
189
+ var Popup = createHostComponent("Popup");
190
+ createHostComponent("FullPageTableLoader");
191
+ function TextCell({ col, row }) {
192
+ return col?.values_formating && Object.keys(col?.values_formating)?.filter((key) => row[col?.data_src] === col?.values_formating[key]["showValue"])?.length > 0 ? Object.keys(col?.values_formating)?.filter((key) => row[col?.data_src] === col?.values_formating[key]["showValue"])?.map((key, index) => /* @__PURE__ */ jsx(
193
+ "span",
194
+ {
195
+ className: `status text-capitalize ${col?.values_formating[key]["style"] === "success" ? "active" : col?.values_formating[key]["style"] === "danger" ? "in-active" : col?.values_formating[key]["style"] === "info" && "info"}`,
196
+ children: row[col?.data_src]
197
+ },
198
+ index
199
+ )) : row[col?.data_src] === "CR" || row[col?.data_src] === "approved" ? /* @__PURE__ */ jsx("span", { className: "status active", children: row[col?.data_src] }) : row[col?.data_src] === "DR" || row[col?.data_src] === "pending" ? /* @__PURE__ */ jsx("span", { className: "status in-active", children: row[col?.data_src] }) : /* @__PURE__ */ jsx("p", { className: "mb-0 text-wrap", children: row[col?.data_src] });
200
+ }
201
+ function LinkCell({ col, row }) {
202
+ const tApiTables = useTranslations("ApiTables");
203
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
204
+ col?.linkStyle === "text" ? /* @__PURE__ */ jsx(Button, { asChild: true, variant: "outline", size: "sm", className: "text-[12px]", children: /* @__PURE__ */ jsx(
205
+ Link,
206
+ {
207
+ href: row[col?.data_src]?.value || row[col?.data_src],
208
+ className: `text-${col?.linkColor} ${row[col?.data_src] === "!#" || row[col?.data_src]?.value === "!#" || !row[col?.data_src] ? "disabled pointer-events-none" : ""}`,
209
+ target: "_blank",
210
+ children: row[col?.data_src]?.label || col?.linkText
211
+ }
212
+ ) }) : col?.linkStyle === "button" && /* @__PURE__ */ jsx(Button, { asChild: true, variant: "outline", size: "sm", className: "text-[12px]", children: /* @__PURE__ */ jsx(Link, { color: "primary", href: row[col?.data_src]?.value || row[col?.data_src], target: "_blank", children: col?.linkText }) }),
213
+ col?.showCopyBtn && /* @__PURE__ */ jsx(Button, { variant: "outline", type: "button", size: "sm", className: "text-[12px]", onClick: () => copyToClipboard(row[col?.data_src]), children: tApiTables("copy_link") })
214
+ ] });
215
+ }
216
+ function BooleanCell({ row, col }) {
217
+ if (row[col?.data_src] === true) {
218
+ return /* @__PURE__ */ jsxs(
219
+ Badge,
220
+ {
221
+ variant: "outline",
222
+ className: "inline-flex items-center border-green-500/5 px-3 py-[2px] text-green-800 dark:border-green-300/40 dark:text-green-100 bg-green-400/5 gap-1",
223
+ children: [
224
+ /* @__PURE__ */ jsx("div", { className: "w-2 h-2 rounded-full bg-green-400" }),
225
+ col?.values_formating?.trueLabel
226
+ ]
227
+ }
228
+ );
229
+ }
230
+ return /* @__PURE__ */ jsxs(
231
+ Badge,
232
+ {
233
+ variant: "outline",
234
+ className: "inline-flex items-center border-red-500/5 dark:border-red-300/40 px-3 py-[2px] text-red-800 dark:text-red-50 bg-red-400/5 gap-1",
235
+ children: [
236
+ /* @__PURE__ */ jsx("div", { className: "w-2 h-2 rounded-full bg-red-400" }),
237
+ col?.values_formating?.falseLabel
238
+ ]
239
+ }
240
+ );
241
+ }
242
+ function HTMLCell({ col, row }) {
243
+ const dispatch = useDispatch();
244
+ const tApiTables = useTranslations("ApiTables");
245
+ return /* @__PURE__ */ jsx(
246
+ Button,
247
+ {
248
+ size: "sm",
249
+ variant: "outline",
250
+ onClick: () => {
251
+ dispatch(
252
+ _setRowSelectedModal({
253
+ label: col?.label,
254
+ value: row[col?.data_src]
255
+ })
256
+ );
257
+ },
258
+ children: tApiTables("show")
259
+ }
260
+ );
261
+ }
262
+ function DataListCell({ col, row }) {
263
+ const dispatch = useDispatch();
264
+ return /* @__PURE__ */ jsxs(
265
+ Button,
266
+ {
267
+ variant: "outline",
268
+ size: "sm",
269
+ onClick: () => {
270
+ dispatch(
271
+ _setRowSelectedModal({
272
+ label: col?.label,
273
+ value: row[col?.data_src]
274
+ })
275
+ );
276
+ },
277
+ children: [
278
+ /* @__PURE__ */ jsx(IoMdExpand, {}),
279
+ col?.linkText
280
+ ]
281
+ }
282
+ );
283
+ }
284
+ function BarcodeCell({ col, row }) {
285
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(PhotoProvider, { children: /* @__PURE__ */ jsx(PhotoView, { src: `data:image/png;base64,${row[col?.data_src]}`, children: /* @__PURE__ */ jsx("img", { src: `data:image/png;base64,${row[col?.data_src]}`, alt: "Barcode", className: "w-auto max-w-[50px] cursor-pointer" }) }) }) });
286
+ }
287
+
288
+ // src/table-utils/errorHandling.ts
289
+ function getToast() {
290
+ return getApiTablesRuntimeConfig()?.toast ?? null;
291
+ }
292
+ function handleResponseErrors(response, message, successCallback, errorCallback) {
293
+ const toast2 = getToast();
294
+ if (response?.data?.success) {
295
+ successCallback?.();
296
+ if (message && toast2) toast2.success(message);
297
+ }
298
+ if (!response?.data?.success && !response?.data?.errors && response?.data?.message) {
299
+ toast2?.error(response.data.message);
300
+ }
301
+ if (!response?.data?.success && response?.data?.errors) {
302
+ const errors = response.data.errors;
303
+ if (Array.isArray(errors) && errors.length > 0) {
304
+ errors.forEach((item) => toast2?.error(item));
305
+ } else if (typeof errors === "string" && errors.length > 0) {
306
+ toast2?.error(errors);
307
+ } else if (errors && typeof errors === "object") {
308
+ Object.keys(errors).forEach((key) => {
309
+ const value = errors[key];
310
+ if (Array.isArray(value)) toast2?.error(value.join(","));
311
+ });
312
+ }
313
+ } else if (!response?.data?.success && !response?.data?.errors) ;
314
+ }
315
+ async function handleNetworkErrors(err) {
316
+ console.log(err);
317
+ const config = getApiTablesRuntimeConfig();
318
+ const toast2 = config?.toast ?? null;
319
+ if (err?.response?.status === 401) {
320
+ try {
321
+ if (config?.onUnauthorized) {
322
+ await config.onUnauthorized();
323
+ } else if (config?.axiosAuth) {
324
+ const res = await config.axiosAuth.delete("/api/delete-auth");
325
+ if (res?.data?.success) {
326
+ window.location.href = "/login";
327
+ localStorage.removeItem("FCM_ERRIM");
328
+ }
329
+ }
330
+ } catch (error2) {
331
+ console.log(error2);
332
+ }
333
+ }
334
+ if (err?.code === "ERR_CANCELED") return;
335
+ const error = err?.response?.data?.error;
336
+ if (error && typeof error === "string" && error.length > 0) {
337
+ toast2?.error(error);
338
+ } else if (error && Array.isArray(error) && error.length > 0) {
339
+ toast2?.error(error.join(","));
340
+ } else {
341
+ toast2?.error(err?.message || "Something went wrong!");
342
+ }
343
+ }
344
+ var initialState2 = {
345
+ tableName: null,
346
+ structureColumns: null,
347
+ structureFilters: null,
348
+ customElement: null,
349
+ appliedFilters: [],
350
+ renderedFilters: [],
351
+ tableSorting: {},
352
+ tableData: [],
353
+ tableBindings: null,
354
+ currentPage: 1,
355
+ pageSize: 25,
356
+ tablePagination: null,
357
+ tableFetchingLoading: false,
358
+ tableRefresher: 0
359
+ };
360
+ var tableCoreSlice = createSlice({
361
+ name: "tableCore",
362
+ initialState: initialState2,
363
+ reducers: {
364
+ _getTableComponents: (state, action) => {
365
+ state.tableName = action?.payload?.tableName;
366
+ state.structureColumns = action?.payload?.columns;
367
+ state.structureFilters = action?.payload?.filters;
368
+ state.customElement = action?.payload?.customElement ?? null;
369
+ },
370
+ _setAppliedFilters: (state, action) => {
371
+ state.appliedFilters = action?.payload?.reduce((acc, curr) => {
372
+ acc[curr.key] = curr;
373
+ return acc;
374
+ }, {});
375
+ },
376
+ _setRenderedFilters: (state, action) => {
377
+ state.renderedFilters = action?.payload;
378
+ },
379
+ _getTableData: (state, action) => {
380
+ state.tableData = action?.payload;
381
+ },
382
+ _getTablePagination: (state, action) => {
383
+ state.tablePagination = action?.payload;
384
+ },
385
+ _getTableBindings: (state, action) => {
386
+ state.tableBindings = action?.payload;
387
+ },
388
+ _setTableLoading: (state, action) => {
389
+ state.tableFetchingLoading = action?.payload;
390
+ },
391
+ _setCurrentPage: (state, action) => {
392
+ state.currentPage = action?.payload;
393
+ },
394
+ _setTableSorting: (state, action) => {
395
+ state.tableSorting = action?.payload;
396
+ },
397
+ _changePageSize: (state, action) => {
398
+ state.pageSize = action?.payload;
399
+ },
400
+ _triggerTableReload: (state) => {
401
+ state.tableRefresher = state.tableRefresher + 1;
402
+ },
403
+ _resetTableCore: (state) => {
404
+ state.tableName = null;
405
+ state.structureColumns = null;
406
+ state.structureFilters = null;
407
+ state.customElement = null;
408
+ state.appliedFilters = [];
409
+ state.renderedFilters = [];
410
+ state.tableSorting = {};
411
+ state.tableData = [];
412
+ state.tableBindings = null;
413
+ state.currentPage = 1;
414
+ state.pageSize = 25;
415
+ state.tablePagination = null;
416
+ state.tableFetchingLoading = false;
417
+ state.tableRefresher = 0;
418
+ }
419
+ }
420
+ });
421
+ var {
422
+ _getTableComponents,
423
+ _setAppliedFilters,
424
+ _setRenderedFilters,
425
+ _getTableData,
426
+ _getTablePagination,
427
+ _getTableBindings,
428
+ _setTableLoading,
429
+ _setCurrentPage,
430
+ _setTableSorting,
431
+ _changePageSize,
432
+ _triggerTableReload,
433
+ _resetTableCore
434
+ } = tableCoreSlice.actions;
435
+ var tableCoreSlice_default = tableCoreSlice.reducer;
436
+ var initialState3 = {
437
+ bulkActions: [],
438
+ selectedBulkAction: null,
439
+ bulkActionPostLoading: false,
440
+ bulkActionPostResponse: null
441
+ };
442
+ var bulkActionsSlice = createSlice({
443
+ name: "bulkActions",
444
+ initialState: initialState3,
445
+ reducers: {
446
+ _getStructureBulkActions: (state, action) => {
447
+ state.bulkActions = objectToArrayValue(action?.payload);
448
+ },
449
+ _getSelectedBulkAction: (state, action) => {
450
+ state.selectedBulkAction = action?.payload;
451
+ },
452
+ _bulkActionPostLoading: (state, action) => {
453
+ state.bulkActionPostLoading = action?.payload;
454
+ },
455
+ _bulkActionPostResponse: (state, action) => {
456
+ state.bulkActionPostResponse = action?.payload;
457
+ },
458
+ _resetTableBulkActions: (state) => {
459
+ state.bulkActions = [];
460
+ state.selectedBulkAction = null;
461
+ state.bulkActionPostLoading = false;
462
+ state.bulkActionPostResponse = null;
463
+ }
464
+ }
465
+ });
466
+ var { _getStructureBulkActions, _getSelectedBulkAction, _bulkActionPostLoading, _bulkActionPostResponse, _resetTableBulkActions } = bulkActionsSlice.actions;
467
+ var bulkActionsSlice_default = bulkActionsSlice.reducer;
468
+ var initialState4 = {
469
+ structureRowActions: [],
470
+ selectedRowActions: [],
471
+ clickedRowAction: null,
472
+ rowActionPostLoading: false,
473
+ clickedRowActionResponse: null,
474
+ customControlAction: null,
475
+ actionsInRegularCells: false,
476
+ clickedRowActionId: null
477
+ };
478
+ var rowActionsSlice = createSlice({
479
+ name: "rowActions",
480
+ initialState: initialState4,
481
+ reducers: {
482
+ _getStructureRowActions: (state, action) => {
483
+ state.structureRowActions = objectToArrayValue(action?.payload);
484
+ },
485
+ _checkActionsInRegularCells: (state, action) => {
486
+ state.actionsInRegularCells = action.payload;
487
+ },
488
+ _getSelectedRowActions: (state, action) => {
489
+ state.selectedRowActions = objectToArrayValue(action?.payload)?.filter((action2) => action2?.applicableAsBulkAction);
490
+ },
491
+ _setRowActionPostLoading: (state, action) => {
492
+ state.rowActionPostLoading = action?.payload;
493
+ },
494
+ _getClickedRowAction: (state, action) => {
495
+ state.clickedRowAction = action?.payload;
496
+ },
497
+ _getClickedRowActionId: (state, action) => {
498
+ state.clickedRowActionId = action?.payload;
499
+ },
500
+ _getClickedRowActionResponse: (state, action) => {
501
+ state.clickedRowActionResponse = action?.payload;
502
+ },
503
+ _getCustomControlRequest: (state, action) => {
504
+ state.customControlAction = action?.payload;
505
+ },
506
+ _resetTableRowActions: (state) => {
507
+ state.structureRowActions = [];
508
+ state.selectedRowActions = [];
509
+ state.clickedRowAction = null;
510
+ state.rowActionPostLoading = false;
511
+ state.clickedRowActionResponse = null;
512
+ state.customControlAction = null;
513
+ state.actionsInRegularCells = false;
514
+ state.clickedRowActionId = null;
515
+ }
516
+ }
517
+ });
518
+ var {
519
+ _getStructureRowActions,
520
+ _checkActionsInRegularCells,
521
+ _getSelectedRowActions,
522
+ _setRowActionPostLoading,
523
+ _getClickedRowAction,
524
+ _getClickedRowActionId,
525
+ _getClickedRowActionResponse,
526
+ _getCustomControlRequest,
527
+ _resetTableRowActions
528
+ } = rowActionsSlice.actions;
529
+ var rowActionsSlice_default = rowActionsSlice.reducer;
530
+
531
+ // src/table-providers/useUtilsProvider.tsx
532
+ function useUtilsProvider() {
533
+ const dispatch = useDispatch();
534
+ const config = useApiTablesConfig();
535
+ const { axiosTable, usePathname, getExternalStore, onBulkActionSuccess, setMainLoader } = config;
536
+ const { downloadBlob, downloadPDF, generatePDF } = config;
537
+ const { tableData } = useSelector((state) => state.tableCore);
538
+ const { toggledClearRows } = useSelector((state) => state.tableColumns);
539
+ const pathname = usePathname?.() ?? "";
540
+ const externalStore = getExternalStore?.();
541
+ function triggerTableReload() {
542
+ dispatch(_triggerTableReload());
543
+ }
544
+ function handleBulkActionReponse(action, response, payload) {
545
+ onBulkActionSuccess?.(action, response, payload);
546
+ if (action?.onSuccess === "deleteRow" || action.onSuccess === "reload") {
547
+ triggerTableReload();
548
+ dispatch(_getSelectedBulkAction(null));
549
+ }
550
+ }
551
+ async function bulkActionsPostHandler(method, url, payload, loaderInfo, action) {
552
+ dispatch(_bulkActionPostLoading(true));
553
+ if (loaderInfo && setMainLoader) {
554
+ setMainLoader({ status: true, msg: loaderInfo?.msg, icon: loaderInfo?.icon ?? null });
555
+ }
556
+ try {
557
+ const response = await axiosTable({
558
+ method,
559
+ url,
560
+ data: { ...payload },
561
+ ...action?.action_key === "export-excel-blob" && { responseType: "blob" }
562
+ });
563
+ if (action?.action_key === "export-excel-blob") {
564
+ downloadBlob?.(response?.data);
565
+ dispatch(_getSelectedBulkAction(null));
566
+ } else {
567
+ handleResponseErrors(
568
+ response,
569
+ response?.data?.message,
570
+ () => {
571
+ dispatch(_bulkActionPostResponse(response?.data));
572
+ handleBulkActionReponse(action, response?.data, payload);
573
+ },
574
+ void 0
575
+ );
576
+ }
577
+ } catch (err) {
578
+ console.log(err);
579
+ } finally {
580
+ dispatch(_bulkActionPostLoading(false));
581
+ dispatch(_getSelectedBulkAction(null));
582
+ if (setMainLoader) setMainLoader({ status: false, msg: "", icon: null });
583
+ }
584
+ }
585
+ function resetClickedRowAction() {
586
+ dispatch(_getClickedRowAction(null));
587
+ dispatch(_getClickedRowActionResponse(null));
588
+ dispatch(_getCustomControlRequest(null));
589
+ dispatch(_setToggledClearRow(!toggledClearRows));
590
+ dispatch(_setSelectedRows([]));
591
+ }
592
+ function handleCommonCases(type, response) {
593
+ if (pathname === "/packing/materials" && type === "reload" && externalStore) {
594
+ onBulkActionSuccess?.(
595
+ { onSuccess: "reload" },
596
+ response,
597
+ void 0
598
+ );
599
+ }
600
+ if (type === "deleteRow" || type === "reload") {
601
+ triggerTableReload();
602
+ resetClickedRowAction();
603
+ } else if (type === "refetchData") {
604
+ dispatch(
605
+ _getTableData(
606
+ tableData?.map((item) => {
607
+ const matchingItem = response?.items?.find(
608
+ (entry) => entry.id === item?.id
609
+ );
610
+ return matchingItem ?? item;
611
+ })
612
+ )
613
+ );
614
+ resetClickedRowAction();
615
+ } else if (type === "refetchRow") {
616
+ dispatch(
617
+ _getTableData(
618
+ tableData?.map((item) => {
619
+ if (item?.id !== response?.data?.row?.id) return item;
620
+ return response?.data?.row;
621
+ })
622
+ )
623
+ );
624
+ resetClickedRowAction();
625
+ } else if (type === "downloadData") {
626
+ downloadURL(response?.data?.url ?? "", response?.data?.filename ?? "");
627
+ resetClickedRowAction();
628
+ } else if (type === "download_pdf") {
629
+ void downloadPDF?.(response?.data?.url ?? "", response?.data?.filename ?? "");
630
+ resetClickedRowAction();
631
+ } else if (type === "generatePdf" || type === "downloadPdf") {
632
+ void generatePDF?.(
633
+ response?.data ?? {},
634
+ "Invoice",
635
+ response?.data?.invoice_number ?? "invoice.pdf"
636
+ );
637
+ resetClickedRowAction();
638
+ }
639
+ }
640
+ function handleRowActionRepsonse(action, response) {
641
+ if (action?.isBulk) {
642
+ handleCommonCases(action?.onBulkSuccess || "", response);
643
+ } else {
644
+ handleCommonCases(action?.onSuccess || "", response);
645
+ }
646
+ }
647
+ async function rowActionsPostHandler(method, url, payload, action, customHeader) {
648
+ dispatch(_setRowActionPostLoading(true));
649
+ dispatch(_getClickedRowAction(action));
650
+ try {
651
+ const response = await axiosTable({
652
+ method,
653
+ url,
654
+ data: payload instanceof FormData ? payload : { ...payload },
655
+ ...customHeader && { headers: { ...customHeader } },
656
+ ...(action?.action_key === "export-excel-blob" || action?.action_key === "export_failed_excel") && {
657
+ responseType: "blob"
658
+ }
659
+ });
660
+ if (action?.action_key === "export-excel-blob" || action?.action_key === "export_failed_excel") {
661
+ downloadBlob?.(response?.data);
662
+ resetClickedRowAction();
663
+ } else {
664
+ handleResponseErrors(
665
+ response,
666
+ response?.data?.message,
667
+ () => {
668
+ if (action?.onSuccess !== "OpenModalForm") {
669
+ dispatch(_getClickedRowActionResponse(response?.data));
670
+ } else {
671
+ dispatch(_getCustomControlRequest(response?.data));
672
+ }
673
+ handleRowActionRepsonse(action, response?.data);
674
+ },
675
+ void 0
676
+ );
677
+ }
678
+ } catch (err) {
679
+ console.log(err);
680
+ resetClickedRowAction();
681
+ await handleNetworkErrors(err);
682
+ } finally {
683
+ dispatch(_setRowActionPostLoading(false));
684
+ dispatch(_getClickedRowActionId(null));
685
+ }
686
+ }
687
+ return { triggerTableReload, bulkActionsPostHandler, rowActionsPostHandler, resetClickedRowAction };
688
+ }
689
+
690
+ // src/shims/loading-button.ts
691
+ var loading_button_default = LoadingButton;
692
+ var requireModal = (action) => {
693
+ return action?.need_confirmation || action?.action_type === "custom_control";
694
+ };
695
+ var ToggleRowActionElement = ({ action, isBulk }) => {
696
+ const { rowActionsPostHandler } = useUtilsProvider();
697
+ const dispatch = useDispatch();
698
+ const { selectedIds } = useSelector((state) => state?.tableColumns);
699
+ const id = useId();
700
+ function fireRowAction(action2) {
701
+ if (requireModal(action2)) {
702
+ dispatch(_getClickedRowAction({ ...action2, ...isBulk && { isBulk: false } }));
703
+ } else {
704
+ rowActionsPostHandler(
705
+ action2?.method,
706
+ isBulk ? action2?.action?.api?.replace("/api", "") : action2?.action.api?.replace("/api", ""),
707
+ { selected_ids: selectedIds },
708
+ { ...action2, ...isBulk && { isBulk: true } }
709
+ );
710
+ }
711
+ }
712
+ return /* @__PURE__ */ jsx("div", { className: "flex items-center space-x-2 w-full", children: /* @__PURE__ */ jsxs(
713
+ Label,
714
+ {
715
+ htmlFor: `tableRowSwitch_${id}`,
716
+ className: `cursor-pointer w-full flex items-center gap-2 px-4 py-2 rounded-lg border transition-colors
717
+ ${action?.toggle_current_value ? "border-orange-500 dark:border-orange-700 text-orange-800 dark:text-orange-200 bg-orange-300/10 dark:bg-orange-300/5" : "border-muted-foreground/40"}
718
+ `,
719
+ children: [
720
+ /* @__PURE__ */ jsx(
721
+ Switch,
722
+ {
723
+ defaultChecked: action?.toggle_current_value || false,
724
+ id: `tableRowSwitch_${id}`,
725
+ checked: action?.toggle_current_value,
726
+ onCheckedChange: () => fireRowAction(action),
727
+ className: "cursor-pointer"
728
+ }
729
+ ),
730
+ /* @__PURE__ */ jsx("span", { children: action?.button?.label })
731
+ ]
732
+ }
733
+ ) });
734
+ };
735
+ var RedirectRowActionElement = ({ action }) => {
736
+ const [fired, setFired] = useState(false);
737
+ const handleLinkClick = (e) => {
738
+ if (e.defaultPrevented || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button && e.button !== 0) {
739
+ return;
740
+ }
741
+ setFired(true);
742
+ };
743
+ return /* @__PURE__ */ jsx(Button, { disabled: fired, variant: "outline", className: "w-full p-0!", children: /* @__PURE__ */ jsxs(
744
+ Link,
745
+ {
746
+ className: "flex items-center w-full justify-center gap-1 py-2 px-3!",
747
+ href: action?.redirect_routes?.api?.replace(/^\/api/, ""),
748
+ onClick: handleLinkClick,
749
+ children: [
750
+ fired ? /* @__PURE__ */ jsx(ImSpinner6, { className: "animate-spin" }) : /* @__PURE__ */ jsx(MdInsertLink, {}),
751
+ fired ? "Redirecting..." : action?.button?.label
752
+ ]
753
+ }
754
+ ) });
755
+ };
756
+ var ExternalRedirectRowActionElement = ({ action }) => {
757
+ return /* @__PURE__ */ jsx(Button, { asChild: true, variant: "default", className: "w-full", children: /* @__PURE__ */ jsxs("a", { target: "_blank", className: "inline-flex items-center gap-1 w-full", href: action?.redirect_routes?.api?.replace(/^\/api/, ""), children: [
758
+ /* @__PURE__ */ jsx(MdInsertLink, {}),
759
+ action?.button?.label
760
+ ] }) });
761
+ };
762
+ var CopyTextRowActionElement = ({ action }) => {
763
+ return /* @__PURE__ */ jsxs(
764
+ loading_button_default,
765
+ {
766
+ variant: "outline",
767
+ onClick: () => {
768
+ copyToClipboard(action?.copy_value);
769
+ },
770
+ children: [
771
+ /* @__PURE__ */ jsx(IoCopy, {}),
772
+ action?.button?.label
773
+ ]
774
+ }
775
+ );
776
+ };
777
+ var GeneralRowActionElement = ({ action, isBulk }) => {
778
+ const id = useId();
779
+ const { rowActionsPostHandler } = useUtilsProvider();
780
+ const dispatch = useDispatch();
781
+ const { clickedRowAction, clickedRowActionId, rowActionPostLoading } = useSelector((state) => state?.rowActions);
782
+ const { selectedIds } = useSelector((state) => state?.tableColumns);
783
+ function fireRowAction(action2) {
784
+ dispatch(_getClickedRowActionId(id));
785
+ if (requireModal(action2)) {
786
+ dispatch(_getClickedRowAction({ ...action2, ...isBulk && { isBulk: false } }));
787
+ if (action2?.action_type === "custom_control") {
788
+ rowActionsPostHandler(
789
+ action2?.method,
790
+ isBulk ? action2?.action?.api?.replace(/^\/api/, "") : action2?.action.api?.replace(/^\/api/, ""),
791
+ { selected_ids: selectedIds },
792
+ action2
793
+ );
794
+ }
795
+ } else {
796
+ rowActionsPostHandler(
797
+ action2?.method,
798
+ isBulk ? action2?.action?.api?.replace(/^\/api/, "") : action2?.action.api?.replace(/^\/api/, ""),
799
+ { selected_ids: selectedIds },
800
+ { ...action2, ...isBulk && { isBulk: true } }
801
+ );
802
+ }
803
+ }
804
+ return /* @__PURE__ */ jsx(
805
+ loading_button_default,
806
+ {
807
+ variant: "secondary",
808
+ className: "w-full text-[13px] h-auto py-1.5 border",
809
+ onClick: () => {
810
+ fireRowAction(action);
811
+ },
812
+ isLoading: clickedRowAction?.action_key === action?.action_key && rowActionPostLoading && clickedRowActionId === id,
813
+ children: action?.button?.label
814
+ }
815
+ );
816
+ };
817
+ function TableRowActions({ row, col, isActionCol = false }) {
818
+ const { selectedRows } = useSelector((state) => state?.tableColumns);
819
+ const { actionsInRegularCells } = useSelector((state) => state?.rowActions);
820
+ const dispatch = useDispatch();
821
+ const rowActions = useMemo(() => {
822
+ if (actionsInRegularCells) {
823
+ const filteredColActions = row?.actions[col?.name];
824
+ return objectToArrayValue(filteredColActions);
825
+ } else {
826
+ return objectToArrayValue(row?.actions);
827
+ }
828
+ }, [row, actionsInRegularCells, col]);
829
+ console.log("\u{1F680} actionsInRegularCells \u{1F449}", actionsInRegularCells, "\u2728");
830
+ useEffect(() => {
831
+ if (selectedRows?.length > 0) {
832
+ dispatch(_getSelectedRowActions(objectToArrayValue(getIntersectedRowActions(selectedRows?.map((row2) => row2?.actions)))));
833
+ } else {
834
+ dispatch(_getSelectedRowActions([]));
835
+ }
836
+ }, [selectedRows]);
837
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
838
+ !col?.separated_action && /* @__PURE__ */ jsx(Fragment, { children: rowActions?.filter((action) => action)?.length > 0 ? /* @__PURE__ */ jsxs(Popover, { children: [
839
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "outline", size: "icon", children: /* @__PURE__ */ jsx(PiDotsThreeOutlineVerticalBold, { className: "!w-3 !h-3" }) }) }),
840
+ /* @__PURE__ */ jsx(PopoverContent, { align: "end", className: "inline-flex min-w-[160px] p-2 z-100!", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2 w-full", children: rowActions?.filter((action) => action)?.map((action) => /* @__PURE__ */ jsx("div", { className: "w-full", children: action?.action_type === "toggle" ? /* @__PURE__ */ jsx(ToggleRowActionElement, { action }) : action?.action_type === "redirect" ? /* @__PURE__ */ jsx(RedirectRowActionElement, { action }) : action?.action_type === "external_redirect" ? /* @__PURE__ */ jsx(ExternalRedirectRowActionElement, { action }) : action?.action_type === "copy" ? /* @__PURE__ */ jsx(CopyTextRowActionElement, { action }) : /* @__PURE__ */ jsx(GeneralRowActionElement, { action }) }, action?.action_key)) }) })
841
+ ] }) : /* @__PURE__ */ jsx(Badge, { variant: "secondary", children: "\u063A\u064A\u0631 \u0645\u0641\u0639\u0644" }) }),
842
+ col?.separated_action && /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2 w-full", children: rowActions?.filter((action) => action)?.map((action) => /* @__PURE__ */ jsx("div", { className: "w-full", children: action?.action_type === "toggle" ? /* @__PURE__ */ jsx(ToggleRowActionElement, { action }) : action?.action_type === "redirect" ? /* @__PURE__ */ jsx(RedirectRowActionElement, { action }) : action?.action_type === "external_redirect" ? /* @__PURE__ */ jsx(ExternalRedirectRowActionElement, { action }) : action?.action_type === "copy" ? /* @__PURE__ */ jsx(CopyTextRowActionElement, { action }) : /* @__PURE__ */ jsx(GeneralRowActionElement, { action }) }, action?.action_key)) })
843
+ ] });
844
+ }
845
+ var TableRowActions_default = TableRowActions;
846
+
847
+ // src/host/storage.ts
848
+ function getHostStorage() {
849
+ const config = getApiTablesRuntimeConfig();
850
+ if (config?.useSecureLS) {
851
+ return config.useSecureLS();
852
+ }
853
+ return config?.storage ?? { get: () => null, set: () => void 0 };
854
+ }
855
+ var copyToClipboard = (value, noToast, msg) => {
856
+ navigator.clipboard.writeText(value).then(function() {
857
+ console.log("");
858
+ }).catch(function(err) {
859
+ console.error("Failed to copy text: ", err);
860
+ });
861
+ {
862
+ toast.success("\u062A\u0645 \u0627\u0644\u0646\u0633\u062E");
863
+ }
864
+ };
865
+ function truncateStart(fullStr, strLen, separator) {
866
+ if (fullStr?.length <= strLen) return fullStr;
867
+ separator = separator || "...";
868
+ let charsToShow = strLen, frontChars = Math.ceil(charsToShow);
869
+ return fullStr?.substr(0, frontChars) + separator;
870
+ }
871
+ function formatDateNoTime(timestamp) {
872
+ const date = new Date(timestamp);
873
+ const day = date.getDate().toString().padStart(2, "0");
874
+ const month = (date.getMonth() + 1).toString().padStart(2, "0");
875
+ const year = date.getFullYear();
876
+ return `${day}/${month}/${year}`;
877
+ }
878
+ function objectToArrayValue(obj) {
879
+ return obj ? Object.keys(obj).map((key) => obj[key]) : [];
880
+ }
881
+ function objectToArrayKey(obj) {
882
+ return obj ? Object.keys(obj).map((key) => key) : [];
883
+ }
884
+ function objectToArrayKeyVal(obj) {
885
+ return obj ? Object.keys(obj).map((key) => ({
886
+ key: obj[key],
887
+ value: key
888
+ })) : [];
889
+ }
890
+ function downloadURL(url, name) {
891
+ const link = document.createElement("a");
892
+ link.href = url;
893
+ link.download = `${name}`;
894
+ document.body.appendChild(link);
895
+ link.setAttribute("target", "_blank");
896
+ link.click();
897
+ URL.revokeObjectURL(url);
898
+ document.body.removeChild(link);
899
+ }
900
+ function getIntersectedRowActions(arrayOfObjects) {
901
+ if (arrayOfObjects.length === 0) return {};
902
+ const result = {};
903
+ for (const key in arrayOfObjects[0]) {
904
+ const actionKey = arrayOfObjects[0][key].action_key;
905
+ const isCommon = arrayOfObjects.every((obj) => obj[key] && obj[key].action_key === actionKey);
906
+ if (isCommon) {
907
+ result[key] = arrayOfObjects[0][key];
908
+ }
909
+ }
910
+ return result;
911
+ }
912
+ function restructureSelectedFilters(data, dirtyFields, structureFilters) {
913
+ const submittedData = objectToArrayKey(dirtyFields);
914
+ const filteredObject = Object.fromEntries(
915
+ Object.entries(data)?.filter(([key, value]) => {
916
+ if (typeof value === "string") {
917
+ const typedValue2 = value;
918
+ return submittedData?.includes(key) && typedValue2?.trim() !== "" && typedValue2;
919
+ }
920
+ const typedValue = value;
921
+ return submittedData?.includes(key) && typedValue?.fieldValue !== "" && typedValue?.fieldValue;
922
+ })
923
+ );
924
+ const renderedFilters = Object.keys(filteredObject)?.map((key) => {
925
+ const targetFilter = structureFilters?.find((filter) => filter?.filter_name === key);
926
+ const value = typeof filteredObject[key] === "string" ? filteredObject[key] : filteredObject[key].fieldValue;
927
+ return {
928
+ key,
929
+ value,
930
+ label: targetFilter?.label,
931
+ type: targetFilter?.type,
932
+ valueLable: targetFilter?.props?.select_options ? targetFilter?.props?.select_options[value] : value,
933
+ operator: targetFilter?.type === "date" ? targetFilter?.props?.operators?.[0] : filteredObject[key]?.operator,
934
+ props: targetFilter?.props
935
+ };
936
+ });
937
+ return renderedFilters;
938
+ }
939
+ var calculateMinWidth = (content, title, type) => {
940
+ const charWidth = 8;
941
+ const padding = 34;
942
+ const headPadding = 60;
943
+ const cellContent = content?.length * charWidth + padding;
944
+ const headContent = title?.length * charWidth + headPadding;
945
+ return type === "link" ? "200px" : `${Math.max(cellContent, headContent)}px`;
946
+ };
947
+ var rowWithLongestField = (data, field) => {
948
+ return data?.reduce((longest, current) => {
949
+ return current[field]?.length > longest?.length ? current[field] : longest;
950
+ }, "");
951
+ };
952
+ var calculateColMinWidth = (content, title) => {
953
+ const charWidth = 8;
954
+ const padding = 34;
955
+ const headPadding = 60;
956
+ const cellContent = content?.length * charWidth + padding;
957
+ const headContent = title?.length * charWidth + headPadding;
958
+ return Math.max(cellContent, headContent) <= 500 ? `${Math.max(cellContent, headContent) + 20}px` : "500px";
959
+ };
960
+ var tableRowWithLongestField = (data, field) => {
961
+ return data?.reduce((longest, current) => {
962
+ return current[field]?.length > longest?.length ? current[field] : longest;
963
+ }, "");
964
+ };
965
+ function formatTableColumns(cols, tbData) {
966
+ return cols?.filter((col) => col?.showable)?.map((col) => {
967
+ return {
968
+ name: col?.label,
969
+ sortable: col?.sortable,
970
+ colIdentifier: col?.data_src,
971
+ data_src: col?.data_src,
972
+ type: col?.type,
973
+ minWidth: col?.type !== "link" && col?.type !== "barcode" ? calculateColMinWidth(tableRowWithLongestField(tbData, col?.data_src), col?.label) : "250px",
974
+ selector: (row) => row[col?.data_src],
975
+ cell: (row) => {
976
+ return /* @__PURE__ */ jsx("div", { "data-row": JSON.stringify(row), className: "text-sm tabel-col-cell w-full", children: row[col?.data_src] === null ? /* @__PURE__ */ jsx("p", { className: "mb-0", children: "-" }) : row[col?.data_src] !== null && /* @__PURE__ */ jsx(Fragment, { children: col?.type === "text" ? /* @__PURE__ */ jsx(TextCell, { col, row }) : col?.type === "text_truncate" ? /* @__PURE__ */ jsx("p", { className: "mb-0 text-wrap", children: truncateStart(row[col?.data_src], 20, "...") }) : col?.type === "link" ? /* @__PURE__ */ jsx(LinkCell, { col, row }) : col?.type === "boolean" ? /* @__PURE__ */ jsx(BooleanCell, { col, row }) : col?.type === "html" ? /* @__PURE__ */ jsx(HTMLCell, { col, row }) : col?.type === "datalist" || col?.type === "dataList" ? /* @__PURE__ */ jsx(DataListCell, { col, row }) : col?.type === "barcode" ? /* @__PURE__ */ jsx(BarcodeCell, { col, row }) : col?.type === "actions" && row?.actions && Object.keys(row?.actions)?.length > 0 && /* @__PURE__ */ jsx(TableRowActions_default, { isActionCol: true, row, col }) }) });
977
+ }
978
+ };
979
+ });
980
+ }
981
+ function AppliedFilters({ setValue, resetField }) {
982
+ const t = useTranslations("ApiTables");
983
+ const { renderedFilters } = useSelector((state) => state.tableCore);
984
+ const dispatch = useDispatch();
985
+ function handleClearRenderedFilters(key, props, type) {
986
+ const filteredRenderedFilters = renderedFilters?.filter((filter) => filter?.key !== key);
987
+ if (type !== "date") {
988
+ setValue(`${key}.fieldValue`, "", { shouldDirty: true, shouldValidate: true });
989
+ setValue(`${key}.operator`, props?.operators[0], { shouldDirty: true, shouldValidate: true });
990
+ } else {
991
+ resetField(`${key}.fieldValue`);
992
+ }
993
+ dispatch(_setRenderedFilters(filteredRenderedFilters));
994
+ dispatch(_setAppliedFilters(filteredRenderedFilters));
995
+ dispatch(_setCurrentPage(1));
996
+ }
997
+ return /* @__PURE__ */ jsx(Fragment, { children: renderedFilters?.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3 p-0 mb-1 my-5", children: [
998
+ /* @__PURE__ */ jsx("div", { className: "text-sm font-bold me-2", children: t("filterBy") }),
999
+ renderedFilters?.map((filter) => /* @__PURE__ */ jsx("div", { className: "mb-1", children: /* @__PURE__ */ jsxs(Badge, { variant: "secondary", className: "ps-2 pe-0.5 rounded-full border !border-foreground/30 dark:border-foreground/10", children: [
1000
+ /* @__PURE__ */ jsxs("strong", { className: "me-1", children: [
1001
+ filter?.label,
1002
+ ":"
1003
+ ] }),
1004
+ /* @__PURE__ */ jsx("span", { children: filter?.type !== "date" ? filter?.valueLable : formatDateNoTime(filter?.value) }),
1005
+ /* @__PURE__ */ jsx(
1006
+ Button,
1007
+ {
1008
+ variant: "default",
1009
+ className: "p-0 ms-3 !px-0 h-5 w-5 max-w-5 rounded-full hover:bg-destructive/10 dark:hover:bg-destructive/10 hover:text-destructive bg-foreground dark:bg-foreground/10",
1010
+ onClick: () => handleClearRenderedFilters(filter?.key, filter?.props, filter?.type),
1011
+ children: /* @__PURE__ */ jsx(X, { className: "size-3" })
1012
+ }
1013
+ )
1014
+ ] }) }, nanoid()))
1015
+ ] }) });
1016
+ }
1017
+ var AppliedFilters_default = AppliedFilters;
1018
+
1019
+ // src/table-utils/useUtilTranslator.ts
1020
+ function useUtilTranslator() {
1021
+ const t = useTranslations("General");
1022
+ function getOperatorLabel(operator) {
1023
+ if (operator === "=") {
1024
+ return t("exact");
1025
+ }
1026
+ if (operator === "like") {
1027
+ return t("like");
1028
+ }
1029
+ if (operator === ">=") {
1030
+ return t("greaterOrEqual");
1031
+ }
1032
+ if (operator === "<=") {
1033
+ return t("lessOrEqual");
1034
+ }
1035
+ }
1036
+ return { getOperatorLabel };
1037
+ }
1038
+
1039
+ // src/shims/tags-input.ts
1040
+ var tags_input_default = TagsInput;
1041
+ function TableFilters({ showFilters, setShowFilters }) {
1042
+ const { tableName, structureFilters } = useSelector((state) => state.tableCore);
1043
+ const [expandedFilters, setExpandedFilters] = useState(true);
1044
+ const [isSubmitEnabled, setIsSubmitEnabled] = useState(false);
1045
+ const dispatch = useDispatch();
1046
+ const t = useTranslations("General");
1047
+ const tApiTables = useTranslations("ApiTables");
1048
+ const {
1049
+ handleSubmit,
1050
+ control,
1051
+ setValue,
1052
+ resetField,
1053
+ watch,
1054
+ formState: { dirtyFields }
1055
+ } = useForm();
1056
+ const watchFields = watch();
1057
+ const { getOperatorLabel } = useUtilTranslator();
1058
+ useEffect(() => {
1059
+ const isAnyFieldFilled = Object.values(watchFields).some((field) => {
1060
+ const v = field?.fieldValue;
1061
+ if (typeof v === "string") return v?.trim() !== "";
1062
+ if (v && typeof v === "object" && "from" in v) return !!v.from;
1063
+ if (v instanceof Date) return true;
1064
+ if (Array.isArray(v)) return v.length > 0;
1065
+ return false;
1066
+ });
1067
+ setIsSubmitEnabled(isAnyFieldFilled);
1068
+ }, [watchFields]);
1069
+ const getOperators = (filter) => {
1070
+ return filter?.props?.operators;
1071
+ };
1072
+ const renderOperator = (filter) => {
1073
+ return filter?.props?.operators?.length > 1;
1074
+ };
1075
+ const DATE_FORMAT = "dd-MM-yyyy";
1076
+ function formatSingleDate(date) {
1077
+ if (!date || !isValid(date)) return null;
1078
+ const formatted = format(date, DATE_FORMAT);
1079
+ return { label: formatted, value: formatted };
1080
+ }
1081
+ function formatDateRangeFromCalendar(range) {
1082
+ if (!range?.from || !isValid(range.from)) return null;
1083
+ const fromStr = format(range.from, DATE_FORMAT);
1084
+ const toDate = range.to && isValid(range.to) ? range.to : range.from;
1085
+ const toStr = format(toDate, DATE_FORMAT);
1086
+ const label = `${fromStr} - ${toStr}`;
1087
+ return { label, value: [fromStr, toStr] };
1088
+ }
1089
+ function submitFiltersHandler(data) {
1090
+ const updatedForTags = Object.fromEntries(
1091
+ Object.entries(data).map(([key, value]) => {
1092
+ if (typeof value.fieldValue === "string" && value.operator === "in") {
1093
+ return [key, { ...value, fieldValue: value.fieldValue.split(",")?.filter((el) => el !== "") }];
1094
+ }
1095
+ if (value.fieldValue instanceof Date) {
1096
+ const formatted = formatSingleDate(value.fieldValue);
1097
+ if (formatted) return [key, { ...value, fieldValue: formatted.value }];
1098
+ }
1099
+ if (value.operator === "between" && value.fieldValue && typeof value.fieldValue === "object" && "from" in value.fieldValue) {
1100
+ const formatted = formatDateRangeFromCalendar(value.fieldValue);
1101
+ if (formatted) return [key, { ...value, fieldValue: formatted.value }];
1102
+ }
1103
+ return [key, value];
1104
+ })
1105
+ );
1106
+ const updatedForDate = Object.fromEntries(
1107
+ Object.entries(data).map(([key, value]) => {
1108
+ if (value.fieldValue instanceof Date) {
1109
+ const formatted = formatSingleDate(value.fieldValue);
1110
+ if (formatted) return [key, { ...value, fieldValue: formatted.label }];
1111
+ }
1112
+ if (value.operator === "between" && value.fieldValue && typeof value.fieldValue === "object" && "from" in value.fieldValue) {
1113
+ const formatted = formatDateRangeFromCalendar(value.fieldValue);
1114
+ if (formatted) return [key, { ...value, fieldValue: formatted.label }];
1115
+ }
1116
+ return [key, value];
1117
+ })
1118
+ );
1119
+ dispatch(_setAppliedFilters(restructureSelectedFilters(updatedForTags, dirtyFields, structureFilters)));
1120
+ dispatch(_setRenderedFilters(restructureSelectedFilters(updatedForDate, dirtyFields, structureFilters)));
1121
+ dispatch(_setCurrentPage(1));
1122
+ setShowFilters(false);
1123
+ }
1124
+ return (
1125
+ // <div className="z-[200]">
1126
+ // <div className="flex mb-5 justify-start">
1127
+ // <Button variant="outline" onClick={() => setExpandedFilters((prev) => !prev)}>
1128
+ // {expandedFilters ? <GoChevronUp className="ms-auto" /> : <GoChevronDown className="ms-auto" />}
1129
+ // {expandedFilters ? tApiTables("hide_filters") : tApiTables("show_filters")}
1130
+ // </Button>
1131
+ // </div>
1132
+ // <div className={`${expandedFilters ? "block" : "hidden"}`}>
1133
+ // <form
1134
+ // noValidate
1135
+ // className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3 items-end"
1136
+ // onSubmit={handleSubmit(submitFiltersHandler)}
1137
+ // >
1138
+ // {/* ... Date Type Filters */}
1139
+ // {structureFilters
1140
+ // ?.filter((filter) => filter?.type === "date")
1141
+ // ?.map(
1142
+ // (filter) =>
1143
+ // filter?.pair_with && (
1144
+ // <div className="m-0 w-full" key={filter.filter_name}>
1145
+ // <Controller
1146
+ // name={`${filter?.filter_name}.fieldValue`}
1147
+ // control={control}
1148
+ // defaultValue={undefined}
1149
+ // render={({ field }) => (
1150
+ // <Popover>
1151
+ // <PopoverTrigger asChild>
1152
+ // <Button
1153
+ // id="date"
1154
+ // variant="outline"
1155
+ // className={cn(
1156
+ // "w-[300px] justify-start text-left font-normal bg-background",
1157
+ // !field.value && "text-muted-foreground"
1158
+ // )}
1159
+ // >
1160
+ // <CalendarIcon className="mr-2 h-4 w-4" />
1161
+ // {field.value?.from ? (
1162
+ // field.value.to ? (
1163
+ // <>
1164
+ // {format(field.value.from, "LLL dd, y")} -{" "}
1165
+ // {format(field.value.to, "LLL dd, y")}
1166
+ // </>
1167
+ // ) : (
1168
+ // format(field.value.from, "LLL dd, y")
1169
+ // )
1170
+ // ) : (
1171
+ // <span>Pick a date</span>
1172
+ // )}
1173
+ // </Button>
1174
+ // </PopoverTrigger>
1175
+ // <PopoverContent className="w-auto p-0" align="start">
1176
+ // <Calendar
1177
+ // autoFocus
1178
+ // mode="range"
1179
+ // defaultMonth={field.value?.from}
1180
+ // selected={field.value}
1181
+ // onSelect={(dates) => field.onChange(dates)}
1182
+ // numberOfMonths={1}
1183
+ // />
1184
+ // </PopoverContent>
1185
+ // </Popover>
1186
+ // )}
1187
+ // />
1188
+ // </div>
1189
+ // )
1190
+ // )}
1191
+ // {true &&
1192
+ // structureFilters
1193
+ // ?.filter((filter) => filter?.type !== "range" && filter?.type !== "date")
1194
+ // ?.map((filter) => (
1195
+ // <div className="space-y-2" key={filter?.filter_name}>
1196
+ // <Label>{filter?.label}</Label>
1197
+ // <div className={`${renderOperator(filter) ? "relative" : ""}`}>
1198
+ // <div className={`flex items-stretch`}>
1199
+ // <div className="m-0 w-full">
1200
+ // {filter?.type === "text" && (
1201
+ // <Controller
1202
+ // name={`${filter?.filter_name}.fieldValue`}
1203
+ // control={control}
1204
+ // defaultValue=""
1205
+ // render={({ field }) => (
1206
+ // <Input
1207
+ // className={`!focus-visible:ring-0 !focus-visible:shadow-none bg-background ${
1208
+ // renderOperator(filter) ? "border-ee-0 rounded-e-nonee" : ""
1209
+ // }`}
1210
+ // aria-label={`${filter?.filter_name}`}
1211
+ // {...field}
1212
+ // type={filter?.type}
1213
+ // placeholder={filter?.label}
1214
+ // />
1215
+ // )}
1216
+ // />
1217
+ // )}
1218
+ // {(filter?.type === "select" || filter?.type === "boolean" || filter?.type === "null") && (
1219
+ // <Controller
1220
+ // name={`${filter?.filter_name}.fieldValue`}
1221
+ // control={control}
1222
+ // defaultValue={undefined}
1223
+ // render={({ field }) => (
1224
+ // <Select
1225
+ // {...field}
1226
+ // onValueChange={field.onChange}
1227
+ // defaultValue={field.value}
1228
+ // aria-label={`${filter?.filter_name}`}
1229
+ // >
1230
+ // <SelectTrigger
1231
+ // className={`w-full cursor-pointer bg-background
1232
+ // ${renderOperator(filter) ? "border-ee-0 rounded-e-nonee" : ""} `}
1233
+ // >
1234
+ // <SelectValue placeholder={filter?.label} />
1235
+ // </SelectTrigger>
1236
+ // <SelectContent>
1237
+ // {objectToArrayKeyVal(filter?.props?.select_options || {})
1238
+ // ?.sort((a, b) => (a.value === "" ? -1 : b.value === "" ? 1 : 0))
1239
+ // ?.map((opt) => (
1240
+ // <SelectItem value={opt?.value} key={opt?.value}>
1241
+ // {opt?.key}
1242
+ // </SelectItem>
1243
+ // ))}
1244
+ // </SelectContent>
1245
+ // </Select>
1246
+ // )}
1247
+ // />
1248
+ // )}
1249
+ // {filter?.type === "number" && (
1250
+ // <Controller
1251
+ // name={`${filter?.filter_name}.fieldValue`}
1252
+ // control={control}
1253
+ // defaultValue=""
1254
+ // render={({ field }) => (
1255
+ // <Input
1256
+ // className={`bg-background ${
1257
+ // renderOperator(filter) ? "border-ee-0 rounded-e-nonee" : ""
1258
+ // }`}
1259
+ // {...field}
1260
+ // aria-label={`${filter?.filter_name}`}
1261
+ // type="text"
1262
+ // onKeyDown={(e) => {
1263
+ // // Allow: backspace, delete, tab, escape, enter, decimal point
1264
+ // if (
1265
+ // [46, 8, 9, 27, 13, 190, 110].indexOf(e.keyCode) !== -1 ||
1266
+ // // Allow: Ctrl+A
1267
+ // (e.keyCode === 65 && e.ctrlKey === true) ||
1268
+ // // Allow: home, end, left, right
1269
+ // (e.keyCode >= 35 && e.keyCode <= 39)
1270
+ // ) {
1271
+ // return;
1272
+ // }
1273
+ // // Ensure that it is a number and stop the keypress if not
1274
+ // if (
1275
+ // (e.shiftKey || e.keyCode < 48 || e.keyCode > 57) &&
1276
+ // (e.keyCode < 96 || e.keyCode > 105)
1277
+ // ) {
1278
+ // e.preventDefault();
1279
+ // }
1280
+ // }}
1281
+ // onChange={(e) => {
1282
+ // // Only allow numbers and one decimal point
1283
+ // const value = e.target.value.replace(/[^\d.]/g, "");
1284
+ // // Prevent multiple decimal points
1285
+ // const parts = value.split(".");
1286
+ // if (parts.length > 2) {
1287
+ // return;
1288
+ // }
1289
+ // field.onChange(value);
1290
+ // }}
1291
+ // placeholder={filter?.label}
1292
+ // />
1293
+ // )}
1294
+ // />
1295
+ // )}
1296
+ // {filter?.type === "multi_select" && !filter?.props?.options && <></>}
1297
+ // {filter?.type === "multi_select" && filter?.props?.options && <></>}
1298
+ // </div>
1299
+ // <Controller
1300
+ // name={`${filter.filter_name}.operator`}
1301
+ // control={control}
1302
+ // defaultValue={getOperators(filter)[0]}
1303
+ // render={({ field }) => (
1304
+ // <Select
1305
+ // {...field}
1306
+ // onValueChange={field.onChange}
1307
+ // value={field.value || getOperators(filter)[0]}
1308
+ // aria-label={`${filter?.filter_name}`}
1309
+ // >
1310
+ // <Tooltip>
1311
+ // <TooltipTrigger asChild>
1312
+ // <SelectTrigger
1313
+ // className={`bg-muted-foreground/10 absolute top-[3px] end-[3px] min-w-[80px] max-w-[80px] border-none !h-[32px] !cursor-pointer shadow-none ${
1314
+ // renderOperator(filter) ? "" : "hidden"
1315
+ // }`}
1316
+ // >
1317
+ // <SelectValue />
1318
+ // </SelectTrigger>
1319
+ // </TooltipTrigger>
1320
+ // <TooltipContent className="dark:text-background">
1321
+ // {getOperatorLabel(watch(`${filter.filter_name}.operator`)) ||
1322
+ // getOperatorLabel(getOperators(filter)?.[0])}
1323
+ // </TooltipContent>
1324
+ // </Tooltip>
1325
+ // <SelectContent align={"end"}>
1326
+ // {getOperators(filter)?.map((operator: string) => (
1327
+ // <SelectItem key={operator} value={operator}>
1328
+ // {operator}
1329
+ // </SelectItem>
1330
+ // ))}
1331
+ // </SelectContent>
1332
+ // </Select>
1333
+ // )}
1334
+ // />
1335
+ // </div>
1336
+ // </div>
1337
+ // </div>
1338
+ // ))}
1339
+ // {/* Filters Submission */}
1340
+ // <div className="col">
1341
+ // <Button type="submit" variant="primary-opac" className="px-5" disabled={!isSubmitEnabled}>
1342
+ // {t("apply")}
1343
+ // </Button>
1344
+ // </div>
1345
+ // </form>
1346
+ // </div>
1347
+ // <AppliedFilters setValue={setValue} resetField={resetField} />
1348
+ // </div>
1349
+ /* @__PURE__ */ jsxs(Fragment, { children: [
1350
+ structureFilters?.length > 0 && /* @__PURE__ */ jsxs(Sheet, { open: showFilters, onOpenChange: setShowFilters, children: [
1351
+ /* @__PURE__ */ jsx(SheetTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "outline", className: "hidden" }) }),
1352
+ /* @__PURE__ */ jsxs(SheetContent, { className: "z-[999] rounded-xl overflow-hidden! pb-5", children: [
1353
+ /* @__PURE__ */ jsx(SheetHeader, { children: /* @__PURE__ */ jsx(SheetTitle, { children: tApiTables("filters") }) }),
1354
+ /* @__PURE__ */ jsxs(
1355
+ "form",
1356
+ {
1357
+ noValidate: true,
1358
+ id: "tb_filters_form",
1359
+ className: "flex flex-col h-full overflow-y-auto gap-4 px-4 pb-20 relative",
1360
+ onSubmit: handleSubmit(submitFiltersHandler),
1361
+ children: [
1362
+ structureFilters?.filter((filter) => filter?.type === "date")?.map(
1363
+ (filter) => filter?.pair_with && /* @__PURE__ */ jsxs("div", { className: "m-0 w-full space-y-2", children: [
1364
+ /* @__PURE__ */ jsx(Label, { children: filter?.label }),
1365
+ /* @__PURE__ */ jsx(
1366
+ Controller,
1367
+ {
1368
+ name: `${filter?.filter_name}.fieldValue`,
1369
+ control,
1370
+ defaultValue: void 0,
1371
+ render: ({ field }) => /* @__PURE__ */ jsx(
1372
+ DatePicker,
1373
+ {
1374
+ date: field.value instanceof Date ? field.value : void 0,
1375
+ setDate: field.onChange,
1376
+ placeholder: filter?.label
1377
+ }
1378
+ )
1379
+ }
1380
+ )
1381
+ ] }, filter.filter_name)
1382
+ ),
1383
+ structureFilters?.filter((filter) => filter?.type !== "range" && filter?.type !== "date")?.map((filter) => /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
1384
+ /* @__PURE__ */ jsx(Label, { children: filter?.label }),
1385
+ /* @__PURE__ */ jsx("div", { className: `${renderOperator(filter) ? "relative" : ""}`, children: /* @__PURE__ */ jsxs("div", { className: `flex items-stretch`, children: [
1386
+ /* @__PURE__ */ jsxs("div", { className: "m-0 w-full", children: [
1387
+ filter?.type === "text" && /* @__PURE__ */ jsx(
1388
+ Controller,
1389
+ {
1390
+ name: `${filter?.filter_name}.fieldValue`,
1391
+ control,
1392
+ defaultValue: "",
1393
+ render: ({ field }) => /* @__PURE__ */ jsx(
1394
+ Input,
1395
+ {
1396
+ className: `!focus-visible:ring-0 !focus-visible:shadow-none bg-background ${renderOperator(filter) ? "border-ee-0 rounded-e-nonee" : ""}`,
1397
+ "aria-label": `${filter?.filter_name}`,
1398
+ ...field,
1399
+ type: filter?.type,
1400
+ placeholder: filter?.label
1401
+ }
1402
+ )
1403
+ }
1404
+ ),
1405
+ (filter?.type === "select" || filter?.type === "boolean" || filter?.type === "null") && /* @__PURE__ */ jsx(
1406
+ Controller,
1407
+ {
1408
+ name: `${filter?.filter_name}.fieldValue`,
1409
+ control,
1410
+ defaultValue: void 0,
1411
+ render: ({ field }) => /* @__PURE__ */ jsxs(
1412
+ Select,
1413
+ {
1414
+ ...field,
1415
+ onValueChange: field.onChange,
1416
+ defaultValue: field.value,
1417
+ "aria-label": `${filter?.filter_name}`,
1418
+ children: [
1419
+ /* @__PURE__ */ jsx(
1420
+ SelectTrigger,
1421
+ {
1422
+ className: `w-full cursor-pointer bg-background
1423
+ ${renderOperator(filter) ? "border-ee-0 rounded-e-nonee" : ""} `,
1424
+ children: /* @__PURE__ */ jsx(SelectValue, { placeholder: filter?.label })
1425
+ }
1426
+ ),
1427
+ /* @__PURE__ */ jsx(SelectContent, { children: objectToArrayKeyVal(filter?.props?.select_options || {})?.sort((a, b) => a.value === "" ? -1 : b.value === "" ? 1 : 0)?.map((opt) => /* @__PURE__ */ jsx(SelectItem, { value: opt?.value, children: opt?.key }, opt?.value)) })
1428
+ ]
1429
+ }
1430
+ )
1431
+ }
1432
+ ),
1433
+ filter?.type === "number" && /* @__PURE__ */ jsx(
1434
+ Controller,
1435
+ {
1436
+ name: `${filter?.filter_name}.fieldValue`,
1437
+ control,
1438
+ defaultValue: "",
1439
+ render: ({ field }) => /* @__PURE__ */ jsx(
1440
+ Input,
1441
+ {
1442
+ className: `bg-background ${renderOperator(filter) ? "border-ee-0 rounded-e-nonee" : ""}`,
1443
+ ...field,
1444
+ "aria-label": `${filter?.filter_name}`,
1445
+ type: "text",
1446
+ onKeyDown: (e) => {
1447
+ if ([46, 8, 9, 27, 13, 190, 110].indexOf(e.keyCode) !== -1 || // Allow: Ctrl+A
1448
+ e.keyCode === 65 && e.ctrlKey === true || // Allow: home, end, left, right
1449
+ e.keyCode >= 35 && e.keyCode <= 39) {
1450
+ return;
1451
+ }
1452
+ if ((e.shiftKey || e.keyCode < 48 || e.keyCode > 57) && (e.keyCode < 96 || e.keyCode > 105)) {
1453
+ e.preventDefault();
1454
+ }
1455
+ },
1456
+ onChange: (e) => {
1457
+ const value = e.target.value.replace(/[^\d.]/g, "");
1458
+ const parts = value.split(".");
1459
+ if (parts.length > 2) {
1460
+ return;
1461
+ }
1462
+ field.onChange(value);
1463
+ },
1464
+ placeholder: filter?.label
1465
+ }
1466
+ )
1467
+ }
1468
+ ),
1469
+ filter?.type === "multi_select" && filter?.props?.selectOptions && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
1470
+ Controller,
1471
+ {
1472
+ name: `${filter?.filter_name}.fieldValue`,
1473
+ control,
1474
+ defaultValue: void 0,
1475
+ render: ({ field }) => /* @__PURE__ */ jsxs(
1476
+ MultiSelect,
1477
+ {
1478
+ ...field,
1479
+ onValuesChange: (values) => field.onChange(values),
1480
+ defaultValues: field.value || [],
1481
+ "aria-label": `${filter?.filter_name}`,
1482
+ children: [
1483
+ /* @__PURE__ */ jsx(
1484
+ MultiSelectTrigger,
1485
+ {
1486
+ className: `w-full cursor-pointer bg-background
1487
+ ${renderOperator(filter) ? "border-ee-0 rounded-e-nonee" : ""} `,
1488
+ children: /* @__PURE__ */ jsx(MultiSelectValue, { placeholder: filter?.label })
1489
+ }
1490
+ ),
1491
+ /* @__PURE__ */ jsx(MultiSelectContent, { children: objectToArrayKeyVal(filter?.props?.selectOptions || {})?.sort((a, b) => a.value === "" ? -1 : b.value === "" ? 1 : 0)?.map((opt) => /* @__PURE__ */ jsx(MultiSelectItem, { value: opt?.value, children: opt?.key }, opt?.value)) })
1492
+ ]
1493
+ }
1494
+ )
1495
+ }
1496
+ ) }),
1497
+ filter?.type === "multi_select" && !filter?.props?.selectOptions && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
1498
+ Controller,
1499
+ {
1500
+ name: `${filter?.filter_name}.fieldValue`,
1501
+ control,
1502
+ defaultValue: "",
1503
+ render: ({ field }) => /* @__PURE__ */ jsx(
1504
+ tags_input_default,
1505
+ {
1506
+ value: field.value || [],
1507
+ onChange: (values) => field.onChange(values),
1508
+ placeholder: filter?.label
1509
+ }
1510
+ )
1511
+ }
1512
+ ) })
1513
+ ] }),
1514
+ /* @__PURE__ */ jsx(
1515
+ Controller,
1516
+ {
1517
+ name: `${filter.filter_name}.operator`,
1518
+ control,
1519
+ defaultValue: getOperators(filter)[0],
1520
+ render: ({ field }) => /* @__PURE__ */ jsxs(
1521
+ Select,
1522
+ {
1523
+ ...field,
1524
+ onValueChange: field.onChange,
1525
+ value: field.value || getOperators(filter)[0],
1526
+ "aria-label": `${filter?.filter_name}`,
1527
+ children: [
1528
+ /* @__PURE__ */ jsxs(Tooltip, { children: [
1529
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
1530
+ SelectTrigger,
1531
+ {
1532
+ className: `bg-muted-foreground/10 absolute top-[3px] end-[3px] bottom-[3px] min-w-[80px] max-w-[80px] border-none !h-[30px] !cursor-pointer shadow-none ${renderOperator(filter) ? "" : "hidden"}`,
1533
+ children: /* @__PURE__ */ jsx(SelectValue, {})
1534
+ }
1535
+ ) }),
1536
+ /* @__PURE__ */ jsx(TooltipContent, { className: "dark:text-background", children: getOperatorLabel(watch(`${filter.filter_name}.operator`)) || getOperatorLabel(getOperators(filter)?.[0]) })
1537
+ ] }),
1538
+ /* @__PURE__ */ jsx(SelectContent, { align: "end", children: getOperators(filter)?.map((operator) => /* @__PURE__ */ jsx(SelectItem, { value: operator, children: operator }, operator)) })
1539
+ ]
1540
+ }
1541
+ )
1542
+ }
1543
+ )
1544
+ ] }) })
1545
+ ] }, filter?.filter_name))
1546
+ ]
1547
+ }
1548
+ ),
1549
+ /* @__PURE__ */ jsx("div", { className: "col absolute bottom-0 p-3 bg-background dark:bg-neutral-800 left-0 right-0", children: /* @__PURE__ */ jsx(Button, { form: "tb_filters_form", type: "submit", variant: "primary-opac", className: "px-5 w-full", disabled: !isSubmitEnabled, children: t("apply") }) })
1550
+ ] })
1551
+ ] }),
1552
+ /* @__PURE__ */ jsx(AppliedFilters_default, { setValue, resetField })
1553
+ ] })
1554
+ );
1555
+ }
1556
+ var TableFilters_default = TableFilters;
1557
+ var Checkbox2 = React4.forwardRef(({ onClick, onChange, checked, ...rest }, ref) => {
1558
+ return /* @__PURE__ */ jsx(Checkbox, { ref, onCheckedChange: onClick, checked, ...rest });
1559
+ });
1560
+ function TableLoader({ count }) {
1561
+ return /* @__PURE__ */ jsx("div", { className: "w-full P-4 bg-neutral-100 dark:bg-neutral-700", children: /* @__PURE__ */ jsx("div", { className: "mb-0 flex flex-col gap-1 p-2", children: Array.from({ length: count }, (_, index) => /* @__PURE__ */ jsx(Skeleton, { className: "h-[50px] dark:bg-neutral-800 bg-neutral-200 w-full rounded-md" }, index)) }) });
1562
+ }
1563
+ function ExpandedRow({ data }) {
1564
+ const { tableColumns } = useSelector((state) => state.tableColumns);
1565
+ return /* @__PURE__ */ jsx("div", { className: "bg-neutral-100 dark:bg-neutral-800 dark:text-white", children: /* @__PURE__ */ jsx("div", { style: { maxWidth: "500px" }, className: "w-full", children: /* @__PURE__ */ jsx("div", { className: "grid items-center grid-cols-1 lg:grid-cols-12 gap-3 text-end g-4 py-4", children: tableColumns?.map((col, index) => /* @__PURE__ */ jsx("div", { className: `${col?.type === "actions" ? "lg:col-span-9" : "lg:col-span-6"}`, children: /* @__PURE__ */ jsxs("div", { className: "h-full w-full flex px-3 gap-2 items-start", children: [
1566
+ /* @__PURE__ */ jsx(FaCircle, { size: 4, className: "mt-[5px] text-primary flex-shrink-0" }),
1567
+ /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
1568
+ /* @__PURE__ */ jsx("h6", { className: "text-[12px] text-start font-semibold mb-1", children: col?.name }),
1569
+ /* @__PURE__ */ jsx("div", { className: "text-start", children: col?.cell(data) })
1570
+ ] })
1571
+ ] }) }, index)) }) }) });
1572
+ }
1573
+ var ExpandedRow_default = ExpandedRow;
1574
+
1575
+ // src/shims/useSecureLS.ts
1576
+ function useSecureLS() {
1577
+ return getHostStorage();
1578
+ }
1579
+
1580
+ // src/shims/app-currency.ts
1581
+ var app_currency_default = AppCurrency;
1582
+ function CalculateWithdrawalAmount({ selectedRows }) {
1583
+ const t = useTranslations("ApiTables");
1584
+ useDispatch();
1585
+ const { bulkActions } = useSelector((state) => state.bulkActions ?? { bulkActions: [] });
1586
+ const totalAmountSelected = useMemo(() => {
1587
+ return selectedRows?.reduce((total, row) => total + Number(row?.dues), 0) ?? 0;
1588
+ }, [selectedRows]);
1589
+ useMemo(
1590
+ () => bulkActions?.find((a) => a?.action_key === "create_withdrawal_bulk"),
1591
+ [bulkActions]
1592
+ );
1593
+ return totalAmountSelected > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center justify-center gap-2 mb-3", children: /* @__PURE__ */ jsx("h6", { className: "text-3xl mb-0 lh-1", style: { lineHeight: "1 !important" }, children: /* @__PURE__ */ jsxs("span", { className: "text-sm font-[400] flex items-center gap-1", children: [
1594
+ totalAmountSelected?.toFixed(2),
1595
+ " ",
1596
+ /* @__PURE__ */ jsx(app_currency_default, { t, className: "text-sm font-[400]" })
1597
+ ] }) }) });
1598
+ }
1599
+ function TableBody2() {
1600
+ const { bulkActions } = useSelector((state) => state.bulkActions);
1601
+ const { structureRowActions, actionsInRegularCells } = useSelector((state) => state.rowActions);
1602
+ const { tableColumns, toggledClearRows, selectedRows } = useSelector((state) => state.tableColumns);
1603
+ const { tableData, tableFetchingLoading, pageSize, structureColumns, tableName, customElement } = useSelector((state) => state.tableCore);
1604
+ const dispatch = useDispatch();
1605
+ const tApiTables = useTranslations("ApiTables");
1606
+ const { get } = useSecureLS();
1607
+ function sortingTableHandler(column, sortDirection) {
1608
+ dispatch(_setTableSorting({ label: column?.name, direction: sortDirection, [column?.colIdentifier]: sortDirection }));
1609
+ }
1610
+ useEffect(() => {
1611
+ dispatch(_setTableColumns({ cols: structureColumns?.filter((col) => col?.showable), tbData: tableData }));
1612
+ if (!get(`${tableName}_tb`)) {
1613
+ dispatch(_setVisibleColumns(structureColumns?.map((col) => col?.data_src)));
1614
+ } else {
1615
+ dispatch(_setVisibleColumns(JSON.parse(get(`${tableName}_tb`))));
1616
+ }
1617
+ }, [structureColumns, tableData]);
1618
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1619
+ customElement === "withdrawal_requests" && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(CalculateWithdrawalAmount, { selectedRows: selectedRows ?? [] }) }),
1620
+ /* @__PURE__ */ jsx("div", { className: "rdt-table-holder static", children: /* @__PURE__ */ jsx("div", { className: `table-scrollable-holder text-nowrap static`, children: /* @__PURE__ */ jsx(
1621
+ DataTable,
1622
+ {
1623
+ className: "text-nowrap",
1624
+ columns: tableColumns,
1625
+ data: tableData,
1626
+ expandableRows: true,
1627
+ expandableRowsComponent: ExpandedRow_default,
1628
+ responsive: true,
1629
+ progressPending: tableFetchingLoading,
1630
+ progressComponent: /* @__PURE__ */ jsx(TableLoader, { count: Number(pageSize) }),
1631
+ sortIcon: /* @__PURE__ */ jsx(HiChevronUpDown, { className: "me-1" }),
1632
+ selectableRowsComponent: Checkbox2,
1633
+ sortServer: true,
1634
+ onSort: sortingTableHandler,
1635
+ noDataComponent: /* @__PURE__ */ jsx("div", { className: "py-4 text-foreground bg-neutral-100 dark:bg-neutral-800 px-4 w-full text-start lg:text-center", children: tApiTables("no_results") }),
1636
+ persistTableHead: true,
1637
+ selectableRows: !tableFetchingLoading && (bulkActions.length > 0 || structureRowActions?.filter((action) => action?.applicableAsBulkAction)?.length > 0) ? true : false,
1638
+ onSelectedRowsChange: ({ selectedRows: selectedRows2 }) => dispatch(_setSelectedRows(selectedRows2)),
1639
+ clearSelectedRows: !toggledClearRows
1640
+ }
1641
+ ) }) })
1642
+ ] });
1643
+ }
1644
+ var TableBody_default = TableBody2;
1645
+
1646
+ // src/shims/custom-pagination.ts
1647
+ var custom_pagination_default = CustomPagination;
1648
+ function TablePagination() {
1649
+ const { tablePagination, currentPage } = useSelector((state) => state.tableCore);
1650
+ const dispatch = useDispatch();
1651
+ const tApiTables = useTranslations("ApiTables");
1652
+ function setCurrentPageHandler(link) {
1653
+ dispatch(_setCurrentPage(Number(link)));
1654
+ }
1655
+ const currentPageNumber = tablePagination?.current_page ?? currentPage;
1656
+ return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-4 lg:grid-cols-2 mt-5 text-center lg:text-end", children: [
1657
+ /* @__PURE__ */ jsx("div", { className: "col", children: tablePagination && tablePagination.total > 0 && /* @__PURE__ */ jsx(
1658
+ custom_pagination_default,
1659
+ {
1660
+ currentPage: currentPageNumber,
1661
+ totalPages: tablePagination.last_page,
1662
+ onPageChange: (page) => {
1663
+ setCurrentPageHandler(page);
1664
+ }
1665
+ }
1666
+ ) }),
1667
+ /* @__PURE__ */ jsxs("div", { className: "text-muted-foreground text-center lg:text-end text-sm", children: [
1668
+ /* @__PURE__ */ jsxs("span", { children: [
1669
+ " ",
1670
+ tApiTables("show_results"),
1671
+ " "
1672
+ ] }),
1673
+ /* @__PURE__ */ jsx("strong", { className: "mx-1", children: tablePagination?.from ?? 0 }),
1674
+ /* @__PURE__ */ jsxs("span", { children: [
1675
+ tApiTables("to_results"),
1676
+ " "
1677
+ ] }),
1678
+ /* @__PURE__ */ jsx("strong", { className: "mx-1", children: tablePagination?.to ?? 0 }),
1679
+ /* @__PURE__ */ jsxs("span", { children: [
1680
+ " ",
1681
+ tApiTables("from_results")
1682
+ ] }),
1683
+ /* @__PURE__ */ jsx("strong", { className: "mx-1", children: tablePagination?.total ?? 0 }),
1684
+ /* @__PURE__ */ jsxs("span", { children: [
1685
+ " ",
1686
+ tApiTables("results")
1687
+ ] })
1688
+ ] })
1689
+ ] });
1690
+ }
1691
+ var TablePagination_default = TablePagination;
1692
+ function TableSorting() {
1693
+ const { tableSorting } = useSelector((state) => state?.tableCore);
1694
+ const dispatch = useDispatch();
1695
+ function resetTableSorting() {
1696
+ dispatch(_setTableSorting({}));
1697
+ }
1698
+ return /* @__PURE__ */ jsx(Fragment, { children: Object.keys(tableSorting)?.length > 0 && /* @__PURE__ */ jsx("div", { className: "my-3", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-1 p-0 mb-1 pt-3", children: [
1699
+ /* @__PURE__ */ jsx("div", { className: "text-sm font-bold me-2", children: "Sorted By " }),
1700
+ /* @__PURE__ */ jsxs(Badge, { variant: "secondary", className: "ps-4 pe-0.5 rounded-full border !border-foreground/30 dark:border-foreground/10", children: [
1701
+ tableSorting?.label,
1702
+ ": ",
1703
+ tableSorting?.direction,
1704
+ /* @__PURE__ */ jsx(
1705
+ Button,
1706
+ {
1707
+ variant: "default",
1708
+ className: "p-0 ms-3 h-6 w-6 rounded-full hover:bg-destructive/10 dark:hover:bg-destructive/10 hover:text-destructive bg-foreground dark:bg-foreground/10",
1709
+ onClick: resetTableSorting,
1710
+ children: /* @__PURE__ */ jsx(X, { className: "size-3" })
1711
+ }
1712
+ )
1713
+ ] })
1714
+ ] }) }) });
1715
+ }
1716
+ var TableSorting_default = TableSorting;
1717
+ var API_TABLES_PAGE_SIZE_KEY = "api_tables_page_size";
1718
+ function TablePageSize() {
1719
+ const { pageSize } = useSelector((state) => state.tableCore);
1720
+ const dispatch = useDispatch();
1721
+ const { set: setStored } = useSecureLS();
1722
+ function changePageSize(value) {
1723
+ setStored(API_TABLES_PAGE_SIZE_KEY, String(value));
1724
+ dispatch(_changePageSize(value));
1725
+ dispatch(_setCurrentPage(1));
1726
+ }
1727
+ return /* @__PURE__ */ jsx("div", { className: "w-full sm:w-[90px]", children: /* @__PURE__ */ jsxs(Select, { onValueChange: (value) => changePageSize(Number(value)), value: `${pageSize}`, children: [
1728
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Page Size" }) }),
1729
+ /* @__PURE__ */ jsx(SelectContent, { children: /* @__PURE__ */ jsxs(SelectGroup, { children: [
1730
+ /* @__PURE__ */ jsx(SelectItem, { value: "10", children: "10" }),
1731
+ /* @__PURE__ */ jsx(SelectItem, { value: "25", children: "25" }),
1732
+ /* @__PURE__ */ jsx(SelectItem, { value: "50", children: "50" }),
1733
+ /* @__PURE__ */ jsx(SelectItem, { value: "100", children: "100" })
1734
+ ] }) })
1735
+ ] }) });
1736
+ }
1737
+ var TablePageSize_default = TablePageSize;
1738
+ function ColumnsVisibility() {
1739
+ const { tableName } = useSelector((state) => state.tableCore);
1740
+ const { tableColumns, visibleColumns } = useSelector((state) => state.tableColumns);
1741
+ const dispatch = useDispatch();
1742
+ const tApiTables = useTranslations("ApiTables");
1743
+ const { set } = useSecureLS();
1744
+ function toggleColumnVisibility(value, data_src, tableName2) {
1745
+ let columns = [...visibleColumns];
1746
+ if (value === true) {
1747
+ columns = [...visibleColumns, data_src];
1748
+ } else {
1749
+ columns = columns.filter((col) => col !== data_src);
1750
+ }
1751
+ dispatch(_setVisibleColumns(columns));
1752
+ set(`${tableName2}_tb`, JSON.stringify(columns));
1753
+ }
1754
+ return /* @__PURE__ */ jsxs(Popover, { children: [
1755
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { className: "w-full sm:w-auto", variant: "outline", children: [
1756
+ /* @__PURE__ */ jsx(RiEyeCloseFill, {}),
1757
+ tApiTables("columns"),
1758
+ /* @__PURE__ */ jsx(FiChevronDown, { className: "ms-auto" })
1759
+ ] }) }),
1760
+ /* @__PURE__ */ jsx(PopoverContent, { align: "start", className: "p-4 flex flex-col gap-1 max-h-[min(90vh,400px)] overflow-y-auto w-auto min-w-[--radix-popover-trigger-width]", children: tableColumns?.map((col, index) => {
1761
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
1762
+ /* @__PURE__ */ jsx(
1763
+ Checkbox,
1764
+ {
1765
+ className: "cursor-pointer",
1766
+ checked: visibleColumns?.indexOf(col.data_src) !== -1,
1767
+ onCheckedChange: (checked) => toggleColumnVisibility(checked, col.data_src, tableName),
1768
+ id: col.data_src
1769
+ }
1770
+ ),
1771
+ /* @__PURE__ */ jsx("label", { htmlFor: col.data_src, className: "text-sm cursor-pointer", children: col.name })
1772
+ ] }, index);
1773
+ }) })
1774
+ ] });
1775
+ }
1776
+ var ColumnsVisibility_default = ColumnsVisibility;
1777
+ function ActionsOfSelections() {
1778
+ const { selectedRows, selectedIds } = useSelector((state) => state.tableColumns);
1779
+ const { appliedFilters } = useSelector((state) => state.tableCore);
1780
+ const { bulkActions } = useSelector((state) => state.bulkActions);
1781
+ const { selectedRowActions } = useSelector((state) => state.rowActions);
1782
+ const { bulkActionsPostHandler } = useUtilsProvider();
1783
+ useDispatch();
1784
+ return /* @__PURE__ */ jsx(Fragment, { children: selectedRows?.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center justify-center gap-2 mb-4", children: selectedRowActions?.map((action) => /* @__PURE__ */ jsx("div", { className: "flex flex-grow-1 md:flex-grow-0 items-center", children: action.action_type === "toggle" ? /* @__PURE__ */ jsx(ToggleRowActionElement, { action, isBulk: true }) : action.action_type === "redirect" ? /* @__PURE__ */ jsx(RedirectRowActionElement, { action, isBulk: true }) : action.action_type === "external_redirect" ? /* @__PURE__ */ jsx(ExternalRedirectRowActionElement, { action, isBulk: true }) : /* @__PURE__ */ jsx(GeneralRowActionElement, { action, isBulk: true }) }, action.action_key)) }) });
1785
+ }
1786
+ var ActionsOfSelection_default = ActionsOfSelections;
1787
+
1788
+ // src/shims/popup.ts
1789
+ var popup_default = Popup;
1790
+ function DatalistModal({ closeModal }) {
1791
+ const { rowSelectedModal } = useSelector((state) => state.tableColumns);
1792
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1793
+ /* @__PURE__ */ jsx("div", { className: "text-center mb-4", children: /* @__PURE__ */ jsx("h5", { className: "font-bold", children: rowSelectedModal?.label }) }),
1794
+ /* @__PURE__ */ jsx("ol", { className: "mb-4 overflow-hidden", children: Array.isArray(rowSelectedModal?.value?.value) && rowSelectedModal?.value?.value?.map((item, index) => /* @__PURE__ */ jsx("li", { className: "p-3 text-wrap whitespace-normal bg-neutral-100 dark:bg-neutral-800 text-sm rounded-md mb-2", children: item }, index)) }),
1795
+ /* @__PURE__ */ jsx(Button, { variant: "outline", className: "w-full", onClick: closeModal, children: "Dismiss" })
1796
+ ] });
1797
+ }
1798
+ function DatalistObjModal({ closeModal }) {
1799
+ const { rowSelectedModal } = useSelector((state) => state.tableColumns);
1800
+ const obj = rowSelectedModal?.value?.value;
1801
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1802
+ /* @__PURE__ */ jsx("div", { className: "text-center mb-6", children: /* @__PURE__ */ jsx("h5", { children: rowSelectedModal?.label }) }),
1803
+ /* @__PURE__ */ jsx("ol", { className: "mb-4", children: obj && Object.keys(obj)?.map((key, index) => /* @__PURE__ */ jsxs("li", { className: "flex items-center gap-2 mb-2", children: [
1804
+ /* @__PURE__ */ jsx("strong", { className: "py-2 px-3 bg-neutral-100 dark:bg-neutral-800 w-full rounded-md", children: key }),
1805
+ /* @__PURE__ */ jsx("span", { className: "py-2 px-3 bg-neutral-100 dark:bg-neutral-800 w-full rounded-md", children: obj[key]?.join(" - ") })
1806
+ ] }, index)) }),
1807
+ /* @__PURE__ */ jsx(Button, { variant: "outline", className: "w-full", onClick: closeModal, children: "Dismiss" })
1808
+ ] });
1809
+ }
1810
+ function HTMLParsedModal() {
1811
+ const { rowSelectedModal } = useSelector((state) => state.tableColumns);
1812
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1813
+ /* @__PURE__ */ jsx("div", { className: "text-center mb-4", children: /* @__PURE__ */ jsx("h5", { children: rowSelectedModal?.label }) }),
1814
+ rowSelectedModal?.value?.value && typeof rowSelectedModal?.value?.value === "string" && parse(rowSelectedModal?.value?.value)
1815
+ ] });
1816
+ }
1817
+ function ViewRowData({ data }) {
1818
+ const modalData = useMemo(() => {
1819
+ return data?.data;
1820
+ }, [data]);
1821
+ return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 xl:grid-cols-12 items-stretch gap-1 pt-7", children: [
1822
+ modalData && modalData?.barcode && /* @__PURE__ */ jsxs("div", { className: "xl:col-span-12 flex flex-col items-center justify-center p-4", children: [
1823
+ /* @__PURE__ */ jsx("h6", { className: "mb-2 font-[400] text-md", children: modalData.barcode?.label || "Barcode" }),
1824
+ modalData.barcode && /* @__PURE__ */ jsx(
1825
+ "img",
1826
+ {
1827
+ src: `data:image/png;base64,${modalData.barcode}`,
1828
+ alt: "Barcode",
1829
+ className: "max-w-full h-auto mb-2 border rounded bg-white",
1830
+ style: { maxHeight: "50vh" }
1831
+ }
1832
+ ),
1833
+ modalData.barcode && /* @__PURE__ */ jsxs(Button, { variant: "outline", onClick: () => copyToClipboard(String(modalData.barcodeValue)), className: "mt-2", children: [
1834
+ /* @__PURE__ */ jsx(IoCopy, { size: 17 }),
1835
+ "Copy Barcode"
1836
+ ] })
1837
+ ] }),
1838
+ modalData && Array.isArray(modalData) && /* @__PURE__ */ jsx("div", { className: "xl:col-span-12", children: /* @__PURE__ */ jsxs(Table, { className: "border", children: [
1839
+ /* @__PURE__ */ jsx(TableHeader, { className: "bg-muted", children: /* @__PURE__ */ jsx(TableRow, { children: Object.keys(modalData?.at(0) ?? {}).map((key, idx) => /* @__PURE__ */ jsx(TableHead, { className: "px-3", children: modalData?.at(0)?.[key]?.label }, idx)) }) }),
1840
+ /* @__PURE__ */ jsx(TableBody, { children: modalData?.map((item, index) => /* @__PURE__ */ jsx(TableRow, { className: Object.keys(item)?.length > 2 ? index % 2 === 0 ? "" : "bg-muted/50" : "", children: Object.keys(item)?.map((key, idx) => /* @__PURE__ */ jsx(TableCell, { className: "font-medium px-3", children: /* @__PURE__ */ jsx("p", { children: item[key]?.value }) })) }, index)) })
1841
+ ] }) }),
1842
+ modalData && !modalData?.barcode && !Array.isArray(modalData) && Object.keys(modalData)?.map((key, index) => /* @__PURE__ */ jsx("div", { className: "2xl:col-span-4 xl:col-span-6", children: /* @__PURE__ */ jsxs("div", { className: "bg-neutral-100 dark:bg-neutral-800 h-full p-3 rounded-md", children: [
1843
+ /* @__PURE__ */ jsx("h6", { className: "mb-0 font-[400] text-[13px]", children: modalData[key]?.label }),
1844
+ modalData[key]?.type === "copy_value" ? modalData[key]?.value && modalData[key]?.value !== "#!" && modalData[key]?.value !== "!#" ? /* @__PURE__ */ jsxs(Button, { variant: "outline", onClick: () => copyToClipboard(String(modalData[key]?.value)), children: [
1845
+ /* @__PURE__ */ jsx(IoCopy, { size: 17 }),
1846
+ "Copy Link"
1847
+ ] }) : /* @__PURE__ */ jsx("p", { className: "mb-0 text-muted-foreground text-wrap", children: "No share Link" }) : Array.isArray(modalData[key]?.value) ? /* @__PURE__ */ jsx("ul", { className: "mb-0 mt-3 pe-4 text-[13px]", children: modalData[key]?.value?.map((item, index2) => /* @__PURE__ */ jsx("li", { children: item }, index2)) }) : (typeof modalData[key]?.value === "string" || typeof modalData[key]?.value === "number") && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-wrap mb-0 text-[14px] mt-2", children: modalData[key]?.value || "----" })
1848
+ ] }) }, index))
1849
+ ] });
1850
+ }
1851
+ function ConfirmationModal({ closeModal, confirmationFor }) {
1852
+ const t = useTranslations("ApiTables");
1853
+ const { clickedRowAction, rowActionPostLoading } = useSelector((state) => state.rowActions);
1854
+ const { appliedFilters } = useSelector((state) => state.tableCore);
1855
+ const { bulkActionsPostHandler, selectedBulkAction, bulkActionPostLoading } = useSelector((state) => state.bulkActions);
1856
+ const { selectedIds } = useSelector((state) => state.tableColumns);
1857
+ const { rowActionsPostHandler } = useUtilsProvider();
1858
+ function fireRowAction() {
1859
+ if (confirmationFor === "rowAction")
1860
+ rowActionsPostHandler(
1861
+ clickedRowAction?.method,
1862
+ clickedRowAction?.isBulk ? clickedRowAction?.bulk_actions_url?.api ?? "" : clickedRowAction?.action?.api?.replace(/^\/api/, "") ?? "",
1863
+ { selected_ids: selectedIds },
1864
+ clickedRowAction
1865
+ );
1866
+ if (confirmationFor === "bulkAction") {
1867
+ bulkActionsPostHandler(
1868
+ selectedBulkAction?.method,
1869
+ selectedBulkAction?.action.api,
1870
+ { filters: appliedFilters, selected_ids: selectedIds },
1871
+ null,
1872
+ selectedBulkAction
1873
+ );
1874
+ }
1875
+ }
1876
+ return /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
1877
+ /* @__PURE__ */ jsx("h4", { className: "mb-1 font-bold text-2xl", children: t("confirmActionTitle") }),
1878
+ /* @__PURE__ */ jsx("p", { className: "h6 mb-4 text-sm pb-6", children: t("confirmActionMessage") }),
1879
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 ms-auto max-w-[200px] gap-2", children: [
1880
+ /* @__PURE__ */ jsx("div", { className: "col", children: /* @__PURE__ */ jsx(
1881
+ loading_button_default,
1882
+ {
1883
+ variant: "default",
1884
+ className: "w-full h-9!",
1885
+ onClick: fireRowAction,
1886
+ disabled: rowActionPostLoading || bulkActionPostLoading,
1887
+ isLoading: rowActionPostLoading || bulkActionPostLoading,
1888
+ children: t("confirm")
1889
+ }
1890
+ ) }),
1891
+ /* @__PURE__ */ jsx("div", { className: "col", children: /* @__PURE__ */ jsx(Button, { variant: "outline", className: "w-full", onClick: closeModal, children: t("dismiss") }) })
1892
+ ] })
1893
+ ] });
1894
+ }
1895
+ function matchUrl(customControlAction, match) {
1896
+ const api = customControlAction?.url?.api ?? "";
1897
+ const web = customControlAction?.url?.web ?? "";
1898
+ const haystack = `${api} ${web}`;
1899
+ return typeof match === "string" ? haystack.includes(match) : match.test(haystack);
1900
+ }
1901
+ function ApiTablesModals() {
1902
+ const { selectedBulkAction } = useSelector((state) => state?.bulkActions ?? {});
1903
+ const { rowSelectedModal } = useSelector((state) => state?.tableColumns ?? {});
1904
+ const { clickedRowAction, clickedRowActionResponse, customControlAction } = useSelector(
1905
+ (state) => state?.rowActions ?? {}
1906
+ );
1907
+ const { customControls = [], bulkActionModals = [], rowActionModals = [] } = useApiTablesConfig();
1908
+ const dispatch = useDispatch();
1909
+ function handleCloseModal() {
1910
+ dispatch(_getClickedRowActionResponse(null));
1911
+ dispatch(_getSelectedBulkAction(null));
1912
+ dispatch(_getClickedRowAction(null));
1913
+ dispatch(_getCustomControlRequest(null));
1914
+ }
1915
+ function handleCloseStaticModals() {
1916
+ dispatch(_setRowSelectedModal(null));
1917
+ }
1918
+ const bulkActionKey = selectedBulkAction?.action_key;
1919
+ const bulkModal = bulkActionModals.find((entry) => entry.actionKey === bulkActionKey);
1920
+ const isCustomBulkModal = !!bulkModal;
1921
+ const showConfirmation = !!clickedRowAction?.need_confirmation || !!selectedBulkAction?.need_confirmation && !isCustomBulkModal;
1922
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1923
+ /* @__PURE__ */ jsxs(
1924
+ popup_default,
1925
+ {
1926
+ status: clickedRowActionResponse,
1927
+ closeModal: handleCloseModal,
1928
+ isVisible: !!clickedRowActionResponse,
1929
+ children: [
1930
+ clickedRowAction?.onSuccess === "DisplayOnModal" && /* @__PURE__ */ jsx(ViewRowData, { data: clickedRowActionResponse }),
1931
+ rowActionModals.map(({ match, component: RowModal }) => {
1932
+ const response = clickedRowActionResponse;
1933
+ const api = String(
1934
+ clickedRowAction?.action?.api ?? response?.url?.api ?? ""
1935
+ );
1936
+ const matched = typeof match === "string" ? api.includes(match) : match.test(api);
1937
+ return matched && response ? /* @__PURE__ */ jsx(RowModal, { data: response }, String(match)) : null;
1938
+ })
1939
+ ]
1940
+ }
1941
+ ),
1942
+ /* @__PURE__ */ jsx(
1943
+ popup_default,
1944
+ {
1945
+ status: showConfirmation,
1946
+ closeModal: handleCloseModal,
1947
+ containerClass: "max-w-xl",
1948
+ isVisible: showConfirmation,
1949
+ children: /* @__PURE__ */ jsx(
1950
+ ConfirmationModal,
1951
+ {
1952
+ closeModal: handleCloseModal,
1953
+ confirmationFor: clickedRowAction ? "rowAction" : selectedBulkAction ? "bulkAction" : "rowAction"
1954
+ }
1955
+ )
1956
+ }
1957
+ ),
1958
+ bulkModal && /* @__PURE__ */ jsx(
1959
+ popup_default,
1960
+ {
1961
+ status: bulkActionKey,
1962
+ closeModal: handleCloseModal,
1963
+ isVisible: !!selectedBulkAction,
1964
+ children: /* @__PURE__ */ jsx(bulkModal.component, { closeModal: handleCloseModal, action: selectedBulkAction })
1965
+ }
1966
+ ),
1967
+ /* @__PURE__ */ jsx(
1968
+ popup_default,
1969
+ {
1970
+ status: rowSelectedModal,
1971
+ containerClass: "max-w-lg",
1972
+ closeModal: handleCloseStaticModals,
1973
+ isVisible: !!rowSelectedModal,
1974
+ children: Array.isArray(rowSelectedModal?.value?.value) ? /* @__PURE__ */ jsx(DatalistModal, { closeModal: handleCloseStaticModals }) : rowSelectedModal?.value?.value && Array.isArray(Object.keys(rowSelectedModal.value.value)) ? /* @__PURE__ */ jsx(DatalistObjModal, { closeModal: handleCloseStaticModals }) : /* @__PURE__ */ jsx(HTMLParsedModal, {})
1975
+ }
1976
+ ),
1977
+ /* @__PURE__ */ jsx(
1978
+ popup_default,
1979
+ {
1980
+ status: customControlAction,
1981
+ closeModal: handleCloseModal,
1982
+ containerClass: "lg:min-w-4xl",
1983
+ isVisible: !!customControlAction,
1984
+ children: customControls.map(
1985
+ ({ match, component: Control }) => matchUrl(customControlAction, match) ? /* @__PURE__ */ jsx(
1986
+ Control,
1987
+ {
1988
+ action: customControlAction,
1989
+ closeModal: handleCloseModal
1990
+ },
1991
+ String(match)
1992
+ ) : null
1993
+ )
1994
+ }
1995
+ )
1996
+ ] });
1997
+ }
1998
+ var ApiTablesModals_default = ApiTablesModals;
1999
+ function TableBulkActions() {
2000
+ const { selectedIds } = useSelector((state) => state.tableColumns);
2001
+ const { bulkActions, bulkActionPostResponse } = useSelector((state) => state.bulkActions);
2002
+ const { tableData, tableFetchingLoading, appliedFilters, triggerTableReload } = useSelector((state) => state.tableCore);
2003
+ const { bulkActionsPostHandler } = useUtilsProvider();
2004
+ const dispatch = useDispatch();
2005
+ const tApiTables = useTranslations("ApiTables");
2006
+ const disableBulkActions = useMemo(() => {
2007
+ return !tableData || tableData?.length === 0 || tableFetchingLoading;
2008
+ }, [tableData, tableFetchingLoading]);
2009
+ const requireModal2 = (action) => action?.action_key === "store_with_drawal_bulk" || action?.action_key === "create_withdrawal_bulk";
2010
+ useEffect(() => {
2011
+ if (bulkActionPostResponse?.success && bulkActionPostResponse?.type === "stream") {
2012
+ downloadURL(bulkActionPostResponse?.data?.url, bulkActionPostResponse?.file_name);
2013
+ }
2014
+ if (bulkActionPostResponse?.success && bulkActionPostResponse?.onSuccess === "refetchData") {
2015
+ triggerTableReload();
2016
+ }
2017
+ if (bulkActionPostResponse?.success && bulkActionPostResponse?.onSuccess === "reload") {
2018
+ triggerTableReload();
2019
+ }
2020
+ dispatch(_bulkActionPostResponse(null));
2021
+ }, [bulkActionPostResponse]);
2022
+ function fireBulkAction(action) {
2023
+ if (requireModal2(action)) {
2024
+ dispatch(_getSelectedBulkAction(action));
2025
+ } else {
2026
+ bulkActionsPostHandler(
2027
+ action?.method,
2028
+ action?.action.api?.replace("/api", ""),
2029
+ { filters: appliedFilters, selected_ids: selectedIds, ...action?.payload_keys && { ...action?.payload_keys } },
2030
+ {
2031
+ msg: action?.action_key === "export-excel-blob" ? tApiTables("exporting_excel") : tApiTables("processing_data"),
2032
+ icon: "excel"
2033
+ },
2034
+ action
2035
+ );
2036
+ }
2037
+ }
2038
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(DropdownMenu, { children: [
2039
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { className: "w-full sm:w-auto", variant: "outline", children: [
2040
+ /* @__PURE__ */ jsx(PiGearFill, {}),
2041
+ tApiTables("bulk_actions"),
2042
+ /* @__PURE__ */ jsx(FiChevronDown, { className: "ms-auto" })
2043
+ ] }) }),
2044
+ /* @__PURE__ */ jsx(DropdownMenuContent, { className: "min-w-[var(--radix-dropdown-menu-trigger-width)]", children: bulkActions?.map((action, index) => {
2045
+ return /* @__PURE__ */ jsx(DropdownMenuItem, { disabled: disableBulkActions, asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "ghost", className: "w-full text-[14px] cursor-pointer", onClick: () => fireBulkAction(action), children: action?.label }) }, index);
2046
+ }) })
2047
+ ] }) });
2048
+ }
2049
+ var TableBulkActions_default = TableBulkActions;
2050
+ function FilterTrigger({ showFilters, setShowFilters }) {
2051
+ const tApiTables = useTranslations("ApiTables");
2052
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Button, { variant: "outline", onClick: () => setShowFilters(!showFilters), children: [
2053
+ /* @__PURE__ */ jsx(MdFilterListAlt, {}),
2054
+ tApiTables("show_filters")
2055
+ ] }) });
2056
+ }
2057
+ function ApiTablesComponent({ customElement }) {
2058
+ const { bulkActions } = useSelector((state) => state?.bulkActions);
2059
+ const { structureFilters } = useSelector((state) => state?.tableCore);
2060
+ const { selectedRows } = useSelector((state) => state?.tableColumns);
2061
+ const [showFilters, setShowFilters] = useState(false);
2062
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2063
+ structureFilters && structureFilters?.length > 0 && /* @__PURE__ */ jsx(TableFilters_default, { showFilters, setShowFilters }),
2064
+ /* @__PURE__ */ jsx(TableSorting_default, {}),
2065
+ /* @__PURE__ */ jsx("div", { className: "flex mb-4 items-end justify-center lg:justify-between pt-5", children: /* @__PURE__ */ jsxs("ul", { className: "flex w-full flex-col sm:flex-row sm:justify-between items-center gap-3", children: [
2066
+ /* @__PURE__ */ jsxs("div", { className: "w-full grid grid-cols-1 sm:grid-cols-3 gap-2 sm:w-auto", children: [
2067
+ bulkActions?.length > 0 && /* @__PURE__ */ jsx(TableBulkActions_default, {}),
2068
+ /* @__PURE__ */ jsx(ColumnsVisibility_default, {}),
2069
+ structureFilters?.length > 0 && /* @__PURE__ */ jsx(FilterTrigger, { showFilters, setShowFilters })
2070
+ ] }),
2071
+ /* @__PURE__ */ jsx("li", { className: "w-full sm:w-fit", children: /* @__PURE__ */ jsx(TablePageSize_default, {}) })
2072
+ ] }) }),
2073
+ React4.isValidElement(customElement) && /* @__PURE__ */ jsxs("div", { className: "py-2", children: [
2074
+ " ",
2075
+ customElement,
2076
+ " "
2077
+ ] }),
2078
+ selectedRows.length > 0 && /* @__PURE__ */ jsx("div", { className: "text-center text-sm text-muted mb-1", children: /* @__PURE__ */ jsx("strong", { className: "fw-bold mx-1", children: selectedRows?.length }) }),
2079
+ /* @__PURE__ */ jsx(ActionsOfSelection_default, {}),
2080
+ /* @__PURE__ */ jsx(TableBody_default, {}),
2081
+ /* @__PURE__ */ jsx(TablePagination_default, {}),
2082
+ /* @__PURE__ */ jsx(ApiTablesModals_default, {})
2083
+ ] });
2084
+ }
2085
+ var ApiTablesComponent_default = ApiTablesComponent;
2086
+ var useTableFetcher = () => {
2087
+ const dispatch = useDispatch();
2088
+ const { axiosTable } = useApiTablesConfig();
2089
+ const { tableColumns, toggledClearRows } = useSelector((state) => state.tableColumns);
2090
+ async function tableFetchingHandler({
2091
+ tableName,
2092
+ signal,
2093
+ pageSize,
2094
+ currentPage,
2095
+ appliedFilters,
2096
+ tableSorting,
2097
+ params,
2098
+ tbData
2099
+ }) {
2100
+ dispatch(_setSelectedRows([]));
2101
+ dispatch(_setTableLoading(true));
2102
+ dispatch(_getTableData([]));
2103
+ dispatch(_setToggledClearRow(!toggledClearRows));
2104
+ try {
2105
+ const response = await axiosTable({
2106
+ method: "POST",
2107
+ url: `/api-table/control-tables/query-table/${tableName}`,
2108
+ data: {
2109
+ perPage: pageSize,
2110
+ page: currentPage,
2111
+ filters: appliedFilters,
2112
+ sorts: tableSorting,
2113
+ ...params ? { params } : {}
2114
+ },
2115
+ signal
2116
+ });
2117
+ if (tableColumns) {
2118
+ dispatch(
2119
+ _setTableColumns({
2120
+ update: true,
2121
+ cols: tableColumns?.map((col) => ({
2122
+ ...col,
2123
+ style: {
2124
+ width: calculateMinWidth(
2125
+ rowWithLongestField(response?.data?.items, col?.data_src),
2126
+ col?.name,
2127
+ col?.type
2128
+ )
2129
+ }
2130
+ })),
2131
+ tbData
2132
+ })
2133
+ );
2134
+ }
2135
+ dispatch(_getTableData(response?.data?.items));
2136
+ dispatch(_getTablePagination(response?.data?.pagination));
2137
+ dispatch(_getTableBindings(response?.data?.bindings));
2138
+ dispatch(_setTableLoading(false));
2139
+ } catch (err) {
2140
+ handleNetworkErrors(err);
2141
+ if (axios.isCancel(err)) {
2142
+ dispatch(_setTableLoading(true));
2143
+ } else {
2144
+ dispatch(_setTableLoading(false));
2145
+ }
2146
+ }
2147
+ }
2148
+ return { tableFetchingHandler };
2149
+ };
2150
+ var useTableFetcher_default = useTableFetcher;
2151
+ var createTableStore = () => {
2152
+ return configureStore({
2153
+ reducer: {
2154
+ tableCore: tableCoreSlice_default,
2155
+ bulkActions: bulkActionsSlice_default,
2156
+ rowActions: rowActionsSlice_default,
2157
+ tableColumns: tableColumnsSlice_default
2158
+ },
2159
+ devTools: true,
2160
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware({
2161
+ serializableCheck: false
2162
+ })
2163
+ });
2164
+ };
2165
+ var externalStoreGetter = null;
2166
+ function setExternalStoreGetter(getter) {
2167
+ externalStoreGetter = getter;
2168
+ }
2169
+ var getExternalState = () => {
2170
+ if (!externalStoreGetter) {
2171
+ return {};
2172
+ }
2173
+ return externalStoreGetter().getState();
2174
+ };
2175
+ var API_TABLES_PAGE_SIZE_KEY2 = "api_tables_page_size";
2176
+ var DEFAULT_PAGE_SIZE = 25;
2177
+ var VALID_PAGE_SIZES = [10, 25, 50, 100];
2178
+ function flattenMultiCellsActions(rowActions) {
2179
+ if (rowActions && Object.keys(rowActions)?.filter((key) => key === "general_actions")?.length > 0) {
2180
+ return Object.values(rowActions)?.map((object) => Object.values(object))?.reduce((acc, val) => acc?.concat(val), []);
2181
+ }
2182
+ return rowActions;
2183
+ }
2184
+ function checkActionsInRegularCells(rowActions) {
2185
+ return rowActions && Object.keys(rowActions)?.filter((key) => key === "general_actions")?.length > 0;
2186
+ }
2187
+ function ApiTablesController({
2188
+ table,
2189
+ params,
2190
+ customElement
2191
+ }) {
2192
+ const dispatch = useDispatch();
2193
+ const { get: getStored } = getHostStorage();
2194
+ getExternalState();
2195
+ const { usePathname } = useApiTablesConfig();
2196
+ const pathname = usePathname?.() ?? "";
2197
+ const { appliedFilters, currentPage, tableSorting, pageSize, tableName, tableData, tableRefresher } = useSelector((state) => state?.tableCore);
2198
+ const { tableFetchingHandler } = useTableFetcher_default();
2199
+ useEffect(() => {
2200
+ dispatch(
2201
+ _getTableComponents({
2202
+ ...table,
2203
+ ...typeof customElement === "string" && { customElement }
2204
+ })
2205
+ );
2206
+ dispatch(_getStructureBulkActions(table?.bulkActions));
2207
+ dispatch(_getStructureRowActions(flattenMultiCellsActions(table?.rowActions)));
2208
+ if (checkActionsInRegularCells(table?.rowActions)) {
2209
+ dispatch(_checkActionsInRegularCells(true));
2210
+ }
2211
+ return () => {
2212
+ dispatch(_resetTableBulkActions());
2213
+ dispatch(_resetTableColumns());
2214
+ dispatch(_resetTableCore());
2215
+ dispatch(_resetTableRowActions());
2216
+ };
2217
+ }, [table, customElement, dispatch]);
2218
+ useEffect(() => {
2219
+ const stored = getStored(API_TABLES_PAGE_SIZE_KEY2);
2220
+ const parsed = stored != null ? Number(stored) : NaN;
2221
+ const size = VALID_PAGE_SIZES.includes(parsed) ? parsed : DEFAULT_PAGE_SIZE;
2222
+ dispatch(_changePageSize(size));
2223
+ }, [dispatch, getStored]);
2224
+ useEffect(() => {
2225
+ const controller = new AbortController();
2226
+ if (tableName) {
2227
+ tableFetchingHandler({
2228
+ tableName,
2229
+ currentPage,
2230
+ pageSize,
2231
+ appliedFilters,
2232
+ tableSorting,
2233
+ signal: controller.signal,
2234
+ params,
2235
+ tbData: tableData
2236
+ });
2237
+ }
2238
+ return () => controller.abort();
2239
+ }, [tableName, currentPage, pageSize, appliedFilters, tableSorting, tableRefresher, pathname, params, tableData, tableFetchingHandler]);
2240
+ return /* @__PURE__ */ jsx(ApiTablesComponent_default, { customElement });
2241
+ }
2242
+ var ApiTablesController_default = ApiTablesController;
2243
+ function ApiTablesProvider({ children }) {
2244
+ const { useOutScopeRefresher } = useApiTablesConfig();
2245
+ const refresher = useOutScopeRefresher?.() ?? 0;
2246
+ const tableStore = useMemo(() => createTableStore(), []);
2247
+ return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Provider, { store: tableStore, children }) }, String(refresher));
2248
+ }
2249
+ function ReactApiTable({
2250
+ table,
2251
+ controller,
2252
+ children,
2253
+ params,
2254
+ tableStructureLoading,
2255
+ customElement
2256
+ }) {
2257
+ const { components } = useApiTablesConfig();
2258
+ const Card2 = components.Card;
2259
+ const FullPageTableLoader2 = components.FullPageTableLoader;
2260
+ if (!Card2 || !FullPageTableLoader2) {
2261
+ throw new Error(
2262
+ "ApiTablesConfig.components.Card and FullPageTableLoader are required"
2263
+ );
2264
+ }
2265
+ return /* @__PURE__ */ jsxs(ApiTablesProvider, { children: [
2266
+ children,
2267
+ tableStructureLoading ? /* @__PURE__ */ jsx(Card2, { className: "p-5 dark:bg-none", children: /* @__PURE__ */ jsx(FullPageTableLoader2, { count: 20 }) }) : controller || /* @__PURE__ */ jsx(
2268
+ ApiTablesController_default,
2269
+ {
2270
+ table,
2271
+ params,
2272
+ customElement: customElement ?? null
2273
+ }
2274
+ )
2275
+ ] });
2276
+ }
2277
+ var ReactApiTable_default = ReactApiTable;
2278
+ function useTableStructure() {
2279
+ const [tableStructure, setTableStructure] = useState(null);
2280
+ const [tableStructureLoading, setTableStructureLoading] = useState(true);
2281
+ const { axiosTable, useLocale: useLocale2 } = useApiTablesConfig();
2282
+ const locale = useLocale2?.();
2283
+ const dispatch = useDispatch();
2284
+ const getTableStructure = useCallback(
2285
+ async ({ table }) => {
2286
+ setTableStructureLoading(true);
2287
+ dispatch(_getTableData([]));
2288
+ try {
2289
+ const response = await axiosTable.get(table, {
2290
+ headers: {
2291
+ ...locale && { ln: locale }
2292
+ }
2293
+ });
2294
+ setTableStructure(response?.data);
2295
+ } catch (err) {
2296
+ console.log(err);
2297
+ } finally {
2298
+ setTableStructureLoading(false);
2299
+ }
2300
+ },
2301
+ [axiosTable, dispatch, locale]
2302
+ );
2303
+ return { getTableStructure, tableStructure, tableStructureLoading };
2304
+ }
2305
+
2306
+ export { ApiTablesComponent_default as ApiTablesComponent, ApiTablesController_default as ApiTablesController, ApiTablesHostProvider, ApiTablesProvider, ReactApiTable_default as ReactApiTable, _bulkActionPostLoading, _bulkActionPostResponse, _changePageSize, _checkActionsInRegularCells, _getClickedRowAction, _getClickedRowActionId, _getClickedRowActionResponse, _getCustomControlRequest, _getSelectedBulkAction, _getSelectedRowActions, _getStructureBulkActions, _getStructureRowActions, _getTableBindings, _getTableComponents, _getTableData, _getTablePagination, _resetTableBulkActions, _resetTableColumns, _resetTableCore, _resetTableRowActions, _setAppliedFilters, _setCurrentPage, _setRenderedFilters, _setRowActionPostLoading, _setRowSelectedModal, _setSelectedRows, _setTableColumns, _setTableLoading, _setTableSorting, _setToggledClearRow, _setVisibleColumns, _triggerTableReload, createTableStore, getExternalState, setExternalStoreGetter, useApiTablesComponent, useApiTablesConfig, useTableFetcher_default as useTableFetcher, useTableStructure, useUtilsProvider };
2307
+ //# sourceMappingURL=index.js.map
2308
+ //# sourceMappingURL=index.js.map