@eztrak/shared 0.13.8 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -3
- package/dist/{chunk-DSP67UYZ.mjs → chunk-EIX5CUQF.mjs} +10 -1
- package/dist/chunk-EIX5CUQF.mjs.map +1 -0
- package/dist/{chunk-4SOWLOGR.mjs → chunk-KFBKDGZV.mjs} +337 -27
- package/dist/chunk-KFBKDGZV.mjs.map +1 -0
- package/dist/{chunk-UIDXC5S2.mjs → chunk-WZVYTP6G.mjs} +2 -2
- package/dist/components/index.d.mts +157 -5
- package/dist/components/index.d.ts +157 -5
- package/dist/components/index.js +342 -27
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +18 -4
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +342 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -4
- package/dist/utils/index.d.mts +10 -1
- package/dist/utils/index.d.ts +10 -1
- package/dist/utils/index.js +10 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +4 -2
- package/package.json +1 -1
- package/dist/chunk-4SOWLOGR.mjs.map +0 -1
- package/dist/chunk-DSP67UYZ.mjs.map +0 -1
- /package/dist/{chunk-UIDXC5S2.mjs.map → chunk-WZVYTP6G.mjs.map} +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ActionMenuItem,
|
|
2
3
|
CardSkeleton,
|
|
3
4
|
CustomCellEditor,
|
|
4
5
|
CustomPagination,
|
|
@@ -7,17 +8,24 @@ import {
|
|
|
7
8
|
Loader,
|
|
8
9
|
Modal,
|
|
9
10
|
PopupCellRenderer,
|
|
11
|
+
ROW_ACTION_DEFAULT_ICON_SIZE,
|
|
12
|
+
ROW_ACTION_DEFAULT_MENU_TOOLTIP_STYLE,
|
|
13
|
+
ROW_ACTION_ITEM_HOVER_CLASS,
|
|
14
|
+
ROW_ACTION_PRESETS,
|
|
10
15
|
ResetColumnsButton,
|
|
11
16
|
ResetFiltersButton,
|
|
17
|
+
RowActions,
|
|
12
18
|
SearchInput,
|
|
13
19
|
TableErrorBoundary,
|
|
14
20
|
TableLayoutToolbarControls,
|
|
15
21
|
ToolTip,
|
|
16
22
|
TooltipText,
|
|
17
|
-
dropdownStyles
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
dropdownStyles,
|
|
24
|
+
resolveActions
|
|
25
|
+
} from "../chunk-KFBKDGZV.mjs";
|
|
26
|
+
import "../chunk-EIX5CUQF.mjs";
|
|
20
27
|
export {
|
|
28
|
+
ActionMenuItem,
|
|
21
29
|
CardSkeleton,
|
|
22
30
|
CustomCellEditor,
|
|
23
31
|
CustomPagination,
|
|
@@ -26,13 +34,19 @@ export {
|
|
|
26
34
|
Loader,
|
|
27
35
|
Modal,
|
|
28
36
|
PopupCellRenderer,
|
|
37
|
+
ROW_ACTION_DEFAULT_ICON_SIZE,
|
|
38
|
+
ROW_ACTION_DEFAULT_MENU_TOOLTIP_STYLE,
|
|
39
|
+
ROW_ACTION_ITEM_HOVER_CLASS,
|
|
40
|
+
ROW_ACTION_PRESETS,
|
|
29
41
|
ResetColumnsButton,
|
|
30
42
|
ResetFiltersButton,
|
|
43
|
+
RowActions,
|
|
31
44
|
SearchInput,
|
|
32
45
|
TableErrorBoundary,
|
|
33
46
|
TableLayoutToolbarControls,
|
|
34
47
|
ToolTip,
|
|
35
48
|
TooltipText,
|
|
36
|
-
dropdownStyles
|
|
49
|
+
dropdownStyles,
|
|
50
|
+
resolveActions
|
|
37
51
|
};
|
|
38
52
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { CreateBaseQueryWithRetryOptions, PermissionRecord, TransformedPermissions, USER_STATE_STORAGE_KEY, capitalizeText, checkIfExistsInArray, cn, convertCommaDataToArray, createBaseQueryWithRetry, currencyFormatter, deserializeJson, flattenTableData, formatDate, formatDateTime, formatNumber, get, getApiError, getErrorMessages, getFieldsByCategory, getFieldsByInputType, getFieldsByName, getItem, getItemFromLocalStorage, isEmpty, loadUserState, normalizeApiListItems, parseCurrencyValueToNumber, removeByPropertyValues, removeItem, saveItemLocalStorage, saveUserState, set, setItem, storeItemInLocalStorage, toDateInputValue, toLowerCaseText, transformPermissions, truncateFileName, truncateText } from './utils/index.mjs';
|
|
1
|
+
export { CreateBaseQueryWithRetryOptions, PermissionRecord, TransformedPermissions, USER_STATE_STORAGE_KEY, capitalizeText, checkIfExistsInArray, cn, convertCommaDataToArray, createBaseQueryWithRetry, currencyFormatter, deserializeJson, flattenTableData, formatDate, formatDateTime, formatNumber, get, getApiError, getErrorMessages, getFieldsByCategory, getFieldsByInputType, getFieldsByName, getItem, getItemFromLocalStorage, isEmpty, loadUserState, normalizeApiListItems, parseCurrencyValueToNumber, removeByPropertyValues, removeItem, resetPageParam, saveItemLocalStorage, saveUserState, set, setItem, storeItemInLocalStorage, toDateInputValue, toLowerCaseText, transformPermissions, truncateFileName, truncateText } from './utils/index.mjs';
|
|
2
2
|
export { C as ConfirmationAlertOptions, E as ErrorClassification, a as ErrorSuggestedAction, H as HandleApiErrorOptions, R as RtkQueryError, c as classifyError, b as confirmationAlert, f as formatValidationErrorsHtml, h as handleApiError, i as isRetryableError } from './handleApiError-CwVIJOqO.mjs';
|
|
3
3
|
export { UseGridHeightOptions, useGridHeight, usePaginationUrlSync } from './hooks/index.mjs';
|
|
4
|
-
export { CardSkeleton, CardSkeletonProps, CardSkeletonVariant, CellEditPayload, CellEditorInputType, CustomCellEditor, CustomCellEditorProps, CustomCellEditorRef, CustomPagination, CustomPaginationClassNames, CustomPaginationProps, DropdownFilter, DropdownFilterProps, DropdownOption, EztrakTab, EztrakTabs, EztrakTabsClassNames, EztrakTabsProps, LayoutStatus, Loader, LoaderProps, Modal, ModalProps, PaginationData, PopupActionHandler, PopupCellRenderer, PopupCellRendererParams, PopupCellRendererProps, PopupDropDownContent, ResetColumnsButton, ResetColumnsButtonProps, ResetFiltersButton, ResetFiltersButtonProps, ResetFiltersButtonVariant, SearchInput, SearchInputProps, TableErrorBoundary, TableErrorBoundaryProps, TableLayoutToolbarControls, TableLayoutToolbarControlsProps, ToolTip, ToolTipProps, TooltipText, TooltipTextProps, dropdownStyles } from './components/index.mjs';
|
|
4
|
+
export { ActionMenuItem, ActionMenuItemProps, CardSkeleton, CardSkeletonProps, CardSkeletonVariant, CellEditPayload, CellEditorInputType, CustomCellEditor, CustomCellEditorProps, CustomCellEditorRef, CustomPagination, CustomPaginationClassNames, CustomPaginationProps, DropdownFilter, DropdownFilterProps, DropdownOption, EztrakTab, EztrakTabs, EztrakTabsClassNames, EztrakTabsProps, LayoutStatus, Loader, LoaderProps, Modal, ModalProps, PaginationData, PopupActionHandler, PopupCellRenderer, PopupCellRendererParams, PopupCellRendererProps, PopupDropDownContent, ROW_ACTION_DEFAULT_ICON_SIZE, ROW_ACTION_DEFAULT_MENU_TOOLTIP_STYLE, ROW_ACTION_ITEM_HOVER_CLASS, ROW_ACTION_PRESETS, ResetColumnsButton, ResetColumnsButtonProps, ResetFiltersButton, ResetFiltersButtonProps, ResetFiltersButtonVariant, ResolvedRowAction, RowAction, RowActionConfirmFn, RowActionFlag, RowActionItemRenderContext, RowActionItemType, RowActionPreset, RowActionPresetName, RowActions, RowActionsList, RowActionsMode, RowActionsProps, RowActionsRenderContext, SearchInput, SearchInputProps, TableErrorBoundary, TableErrorBoundaryProps, TableLayoutToolbarControls, TableLayoutToolbarControlsProps, ToolTip, ToolTipProps, TooltipText, TooltipTextProps, dropdownStyles, resolveActions } from './components/index.mjs';
|
|
5
5
|
import 'clsx';
|
|
6
6
|
import '@reduxjs/toolkit/query';
|
|
7
7
|
import 'react-router-dom';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { CreateBaseQueryWithRetryOptions, PermissionRecord, TransformedPermissions, USER_STATE_STORAGE_KEY, capitalizeText, checkIfExistsInArray, cn, convertCommaDataToArray, createBaseQueryWithRetry, currencyFormatter, deserializeJson, flattenTableData, formatDate, formatDateTime, formatNumber, get, getApiError, getErrorMessages, getFieldsByCategory, getFieldsByInputType, getFieldsByName, getItem, getItemFromLocalStorage, isEmpty, loadUserState, normalizeApiListItems, parseCurrencyValueToNumber, removeByPropertyValues, removeItem, saveItemLocalStorage, saveUserState, set, setItem, storeItemInLocalStorage, toDateInputValue, toLowerCaseText, transformPermissions, truncateFileName, truncateText } from './utils/index.js';
|
|
1
|
+
export { CreateBaseQueryWithRetryOptions, PermissionRecord, TransformedPermissions, USER_STATE_STORAGE_KEY, capitalizeText, checkIfExistsInArray, cn, convertCommaDataToArray, createBaseQueryWithRetry, currencyFormatter, deserializeJson, flattenTableData, formatDate, formatDateTime, formatNumber, get, getApiError, getErrorMessages, getFieldsByCategory, getFieldsByInputType, getFieldsByName, getItem, getItemFromLocalStorage, isEmpty, loadUserState, normalizeApiListItems, parseCurrencyValueToNumber, removeByPropertyValues, removeItem, resetPageParam, saveItemLocalStorage, saveUserState, set, setItem, storeItemInLocalStorage, toDateInputValue, toLowerCaseText, transformPermissions, truncateFileName, truncateText } from './utils/index.js';
|
|
2
2
|
export { C as ConfirmationAlertOptions, E as ErrorClassification, a as ErrorSuggestedAction, H as HandleApiErrorOptions, R as RtkQueryError, c as classifyError, b as confirmationAlert, f as formatValidationErrorsHtml, h as handleApiError, i as isRetryableError } from './handleApiError-CwVIJOqO.js';
|
|
3
3
|
export { UseGridHeightOptions, useGridHeight, usePaginationUrlSync } from './hooks/index.js';
|
|
4
|
-
export { CardSkeleton, CardSkeletonProps, CardSkeletonVariant, CellEditPayload, CellEditorInputType, CustomCellEditor, CustomCellEditorProps, CustomCellEditorRef, CustomPagination, CustomPaginationClassNames, CustomPaginationProps, DropdownFilter, DropdownFilterProps, DropdownOption, EztrakTab, EztrakTabs, EztrakTabsClassNames, EztrakTabsProps, LayoutStatus, Loader, LoaderProps, Modal, ModalProps, PaginationData, PopupActionHandler, PopupCellRenderer, PopupCellRendererParams, PopupCellRendererProps, PopupDropDownContent, ResetColumnsButton, ResetColumnsButtonProps, ResetFiltersButton, ResetFiltersButtonProps, ResetFiltersButtonVariant, SearchInput, SearchInputProps, TableErrorBoundary, TableErrorBoundaryProps, TableLayoutToolbarControls, TableLayoutToolbarControlsProps, ToolTip, ToolTipProps, TooltipText, TooltipTextProps, dropdownStyles } from './components/index.js';
|
|
4
|
+
export { ActionMenuItem, ActionMenuItemProps, CardSkeleton, CardSkeletonProps, CardSkeletonVariant, CellEditPayload, CellEditorInputType, CustomCellEditor, CustomCellEditorProps, CustomCellEditorRef, CustomPagination, CustomPaginationClassNames, CustomPaginationProps, DropdownFilter, DropdownFilterProps, DropdownOption, EztrakTab, EztrakTabs, EztrakTabsClassNames, EztrakTabsProps, LayoutStatus, Loader, LoaderProps, Modal, ModalProps, PaginationData, PopupActionHandler, PopupCellRenderer, PopupCellRendererParams, PopupCellRendererProps, PopupDropDownContent, ROW_ACTION_DEFAULT_ICON_SIZE, ROW_ACTION_DEFAULT_MENU_TOOLTIP_STYLE, ROW_ACTION_ITEM_HOVER_CLASS, ROW_ACTION_PRESETS, ResetColumnsButton, ResetColumnsButtonProps, ResetFiltersButton, ResetFiltersButtonProps, ResetFiltersButtonVariant, ResolvedRowAction, RowAction, RowActionConfirmFn, RowActionFlag, RowActionItemRenderContext, RowActionItemType, RowActionPreset, RowActionPresetName, RowActions, RowActionsList, RowActionsMode, RowActionsProps, RowActionsRenderContext, SearchInput, SearchInputProps, TableErrorBoundary, TableErrorBoundaryProps, TableLayoutToolbarControls, TableLayoutToolbarControlsProps, ToolTip, ToolTipProps, TooltipText, TooltipTextProps, dropdownStyles, resolveActions } from './components/index.js';
|
|
5
5
|
import 'clsx';
|
|
6
6
|
import '@reduxjs/toolkit/query';
|
|
7
7
|
import 'react-router-dom';
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
+
ActionMenuItem: () => ActionMenuItem,
|
|
33
34
|
CardSkeleton: () => CardSkeleton,
|
|
34
35
|
CustomCellEditor: () => CustomCellEditor,
|
|
35
36
|
CustomPagination: () => CustomPagination,
|
|
@@ -38,8 +39,13 @@ __export(src_exports, {
|
|
|
38
39
|
Loader: () => Loader,
|
|
39
40
|
Modal: () => Modal,
|
|
40
41
|
PopupCellRenderer: () => PopupCellRenderer,
|
|
42
|
+
ROW_ACTION_DEFAULT_ICON_SIZE: () => ROW_ACTION_DEFAULT_ICON_SIZE,
|
|
43
|
+
ROW_ACTION_DEFAULT_MENU_TOOLTIP_STYLE: () => ROW_ACTION_DEFAULT_MENU_TOOLTIP_STYLE,
|
|
44
|
+
ROW_ACTION_ITEM_HOVER_CLASS: () => ROW_ACTION_ITEM_HOVER_CLASS,
|
|
45
|
+
ROW_ACTION_PRESETS: () => ROW_ACTION_PRESETS,
|
|
41
46
|
ResetColumnsButton: () => ResetColumnsButton,
|
|
42
47
|
ResetFiltersButton: () => ResetFiltersButton,
|
|
48
|
+
RowActions: () => RowActions,
|
|
43
49
|
SearchInput: () => SearchInput,
|
|
44
50
|
TableErrorBoundary: () => TableErrorBoundary,
|
|
45
51
|
TableLayoutToolbarControls: () => TableLayoutToolbarControls,
|
|
@@ -77,6 +83,8 @@ __export(src_exports, {
|
|
|
77
83
|
parseCurrencyValueToNumber: () => parseCurrencyValueToNumber,
|
|
78
84
|
removeByPropertyValues: () => removeByPropertyValues,
|
|
79
85
|
removeItem: () => removeItem,
|
|
86
|
+
resetPageParam: () => resetPageParam,
|
|
87
|
+
resolveActions: () => resolveActions,
|
|
80
88
|
saveItemLocalStorage: () => saveItemLocalStorage,
|
|
81
89
|
saveUserState: () => saveUserState,
|
|
82
90
|
set: () => set,
|
|
@@ -99,6 +107,14 @@ function cn(...inputs) {
|
|
|
99
107
|
return (0, import_tailwind_merge.twMerge)((0, import_clsx.default)(inputs));
|
|
100
108
|
}
|
|
101
109
|
|
|
110
|
+
// src/utils/resetPageParam.ts
|
|
111
|
+
function resetPageParam(params, pageKey = "page", defaultPage = "1") {
|
|
112
|
+
if (params.has(pageKey)) {
|
|
113
|
+
params.set(pageKey, defaultPage);
|
|
114
|
+
}
|
|
115
|
+
return params;
|
|
116
|
+
}
|
|
117
|
+
|
|
102
118
|
// src/utils/helpers.ts
|
|
103
119
|
var truncateText = (text, maxLength = 20) => {
|
|
104
120
|
if (text === null || text === void 0) return "";
|
|
@@ -1254,6 +1270,7 @@ function DropdownFilter({
|
|
|
1254
1270
|
isDisabled = false,
|
|
1255
1271
|
isLoading = false,
|
|
1256
1272
|
saveToLocalStorage = false,
|
|
1273
|
+
pageParam = "page",
|
|
1257
1274
|
...otherProps
|
|
1258
1275
|
}) {
|
|
1259
1276
|
const [searchParams, setSearchParams] = (0, import_react_router_dom2.useSearchParams)();
|
|
@@ -1266,10 +1283,10 @@ function DropdownFilter({
|
|
|
1266
1283
|
if (stored != null && stored !== "") {
|
|
1267
1284
|
setSearchParams((prev) => {
|
|
1268
1285
|
prev.set(name, String(stored));
|
|
1269
|
-
return prev;
|
|
1286
|
+
return resetPageParam(prev, pageParam);
|
|
1270
1287
|
});
|
|
1271
1288
|
}
|
|
1272
|
-
}, [saveToLocalStorage, name, searchParams, setSearchParams]);
|
|
1289
|
+
}, [saveToLocalStorage, name, pageParam, searchParams, setSearchParams]);
|
|
1273
1290
|
const currentValue = searchParams.get(name);
|
|
1274
1291
|
const selectedOption = currentValue ? options?.find(
|
|
1275
1292
|
(option) => option[valueKey]?.toString() === currentValue
|
|
@@ -1277,12 +1294,15 @@ function DropdownFilter({
|
|
|
1277
1294
|
const handleChange = (selected) => {
|
|
1278
1295
|
const selectedValue = selected && selected[valueKey] !== "" ? String(selected[valueKey]) : null;
|
|
1279
1296
|
setSearchParams((prev) => {
|
|
1297
|
+
if ((prev.get(name) ?? "") === (selectedValue ?? "")) {
|
|
1298
|
+
return prev;
|
|
1299
|
+
}
|
|
1280
1300
|
if (!selectedValue) {
|
|
1281
1301
|
prev.delete(name);
|
|
1282
1302
|
} else {
|
|
1283
1303
|
prev.set(name, selectedValue);
|
|
1284
1304
|
}
|
|
1285
|
-
return prev;
|
|
1305
|
+
return resetPageParam(prev, pageParam);
|
|
1286
1306
|
});
|
|
1287
1307
|
if (saveToLocalStorage) {
|
|
1288
1308
|
if (selectedValue) {
|
|
@@ -1399,6 +1419,7 @@ function SearchInput({
|
|
|
1399
1419
|
debounceDelay = 500,
|
|
1400
1420
|
customIcon = null,
|
|
1401
1421
|
defaultValue,
|
|
1422
|
+
pageParam = "page",
|
|
1402
1423
|
...props
|
|
1403
1424
|
}) {
|
|
1404
1425
|
const [searchParams, setSearchParams] = (0, import_react_router_dom4.useSearchParams)();
|
|
@@ -1406,17 +1427,18 @@ function SearchInput({
|
|
|
1406
1427
|
const [inputValue, setInputValue] = (0, import_react5.useState)(queryParam);
|
|
1407
1428
|
const debounceTimerRef = (0, import_react5.useRef)(null);
|
|
1408
1429
|
const updateSearchParams = (searchQuery) => {
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1430
|
+
const nextValue = searchQuery?.trim() ?? "";
|
|
1431
|
+
setSearchParams((prev) => {
|
|
1432
|
+
if ((prev.get(defaultParam) ?? "") === nextValue) {
|
|
1412
1433
|
return prev;
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
|
|
1434
|
+
}
|
|
1435
|
+
if (nextValue) {
|
|
1436
|
+
prev.set(defaultParam, nextValue);
|
|
1437
|
+
} else {
|
|
1416
1438
|
prev.delete(defaultParam);
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
}
|
|
1439
|
+
}
|
|
1440
|
+
return resetPageParam(prev, pageParam);
|
|
1441
|
+
});
|
|
1420
1442
|
};
|
|
1421
1443
|
const handleSearch = (e) => {
|
|
1422
1444
|
e.preventDefault();
|
|
@@ -2134,7 +2156,8 @@ function PopupCellRenderer({
|
|
|
2134
2156
|
params,
|
|
2135
2157
|
onAction,
|
|
2136
2158
|
placement = "bottom-end",
|
|
2137
|
-
tippyProps
|
|
2159
|
+
tippyProps,
|
|
2160
|
+
ariaLabel = "Row actions"
|
|
2138
2161
|
}) {
|
|
2139
2162
|
const [visible, setVisible] = (0, import_react9.useState)(false);
|
|
2140
2163
|
const show = () => setVisible(true);
|
|
@@ -2170,7 +2193,7 @@ function PopupCellRenderer({
|
|
|
2170
2193
|
"flex items-center justify-center gap-2 rounded-full text-gray-500 hover:text-gray-800",
|
|
2171
2194
|
className
|
|
2172
2195
|
),
|
|
2173
|
-
"aria-label":
|
|
2196
|
+
"aria-label": ariaLabel,
|
|
2174
2197
|
children: [
|
|
2175
2198
|
!hideTitle && title,
|
|
2176
2199
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ActionIcon, { "aria-hidden": true })
|
|
@@ -2181,10 +2204,296 @@ function PopupCellRenderer({
|
|
|
2181
2204
|
) });
|
|
2182
2205
|
}
|
|
2183
2206
|
|
|
2207
|
+
// src/components/row-actions/presets.ts
|
|
2208
|
+
var import_fa2 = require("react-icons/fa");
|
|
2209
|
+
var ROW_ACTION_ITEM_HOVER_CLASS = "hover:bg-primary-50 hover:text-primary-150";
|
|
2210
|
+
var ROW_ACTION_DEFAULT_ICON_SIZE = 16;
|
|
2211
|
+
var ROW_ACTION_DEFAULT_MENU_TOOLTIP_STYLE = {
|
|
2212
|
+
zIndex: 1e4
|
|
2213
|
+
};
|
|
2214
|
+
var ROW_ACTION_PRESETS = {
|
|
2215
|
+
edit: { label: "Edit", icon: import_fa2.FaEdit },
|
|
2216
|
+
delete: { label: "Delete", icon: import_fa2.FaTrashAlt, danger: true },
|
|
2217
|
+
view: { label: "View", icon: import_fa2.FaEye },
|
|
2218
|
+
notes: { label: "Notes", icon: import_fa2.FaFileAlt },
|
|
2219
|
+
history: { label: "History", icon: import_fa2.FaHistory },
|
|
2220
|
+
download: { label: "Download", icon: import_fa2.FaDownload },
|
|
2221
|
+
archive: { label: "Archive", icon: import_fa2.FaArchive },
|
|
2222
|
+
resolve: { label: "Resolve", icon: import_fa2.FaCheckCircle }
|
|
2223
|
+
};
|
|
2224
|
+
|
|
2225
|
+
// src/components/row-actions/ActionMenuItem.tsx
|
|
2226
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2227
|
+
function ActionMenuItem({
|
|
2228
|
+
label,
|
|
2229
|
+
icon: Icon,
|
|
2230
|
+
iconSize = ROW_ACTION_DEFAULT_ICON_SIZE,
|
|
2231
|
+
iconClassName,
|
|
2232
|
+
tooltip,
|
|
2233
|
+
tooltipPlacement = "top",
|
|
2234
|
+
tooltipDelayShow,
|
|
2235
|
+
tooltipDelayHide,
|
|
2236
|
+
tooltipClassName,
|
|
2237
|
+
tooltipStyle,
|
|
2238
|
+
disabled = false,
|
|
2239
|
+
danger = false,
|
|
2240
|
+
highlight = false,
|
|
2241
|
+
showLabel = true,
|
|
2242
|
+
className,
|
|
2243
|
+
onClick
|
|
2244
|
+
}) {
|
|
2245
|
+
const tooltipText = tooltip ?? label;
|
|
2246
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2247
|
+
ToolTip,
|
|
2248
|
+
{
|
|
2249
|
+
text: tooltipText,
|
|
2250
|
+
disabled: !tooltipText,
|
|
2251
|
+
placement: tooltipPlacement,
|
|
2252
|
+
delayShow: tooltipDelayShow,
|
|
2253
|
+
delayHide: tooltipDelayHide,
|
|
2254
|
+
tooltipClassName,
|
|
2255
|
+
tooltipStyle: { ...ROW_ACTION_DEFAULT_MENU_TOOLTIP_STYLE, ...tooltipStyle },
|
|
2256
|
+
className: showLabel ? "block w-full" : "inline-flex",
|
|
2257
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2258
|
+
"button",
|
|
2259
|
+
{
|
|
2260
|
+
type: "button",
|
|
2261
|
+
disabled,
|
|
2262
|
+
"aria-label": label,
|
|
2263
|
+
onClick: (event) => {
|
|
2264
|
+
event.stopPropagation();
|
|
2265
|
+
if (disabled) return;
|
|
2266
|
+
onClick();
|
|
2267
|
+
},
|
|
2268
|
+
className: cn(
|
|
2269
|
+
"flex items-center gap-2 text-sm transition-colors duration-150",
|
|
2270
|
+
showLabel ? "w-full rounded-xl px-3 py-2 text-left" : "justify-center rounded-md p-1",
|
|
2271
|
+
disabled ? "cursor-not-allowed opacity-50" : ROW_ACTION_ITEM_HOVER_CLASS,
|
|
2272
|
+
danger && "text-red-500",
|
|
2273
|
+
highlight && !danger && "text-primary-150",
|
|
2274
|
+
className
|
|
2275
|
+
),
|
|
2276
|
+
children: [
|
|
2277
|
+
Icon ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2278
|
+
Icon,
|
|
2279
|
+
{
|
|
2280
|
+
className: cn("shrink-0", iconClassName),
|
|
2281
|
+
"aria-hidden": true,
|
|
2282
|
+
size: iconSize
|
|
2283
|
+
}
|
|
2284
|
+
) : null,
|
|
2285
|
+
showLabel ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: label }) : null
|
|
2286
|
+
]
|
|
2287
|
+
}
|
|
2288
|
+
)
|
|
2289
|
+
}
|
|
2290
|
+
);
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
// src/components/row-actions/resolveActions.ts
|
|
2294
|
+
function evalFlag(flag, data) {
|
|
2295
|
+
if (typeof flag === "function") return Boolean(flag(data));
|
|
2296
|
+
return Boolean(flag);
|
|
2297
|
+
}
|
|
2298
|
+
function mergePreset(name, overrides) {
|
|
2299
|
+
if (!name) return void 0;
|
|
2300
|
+
const base = ROW_ACTION_PRESETS[name];
|
|
2301
|
+
const extra = overrides?.[name];
|
|
2302
|
+
if (!extra) return base;
|
|
2303
|
+
return { ...base, ...extra };
|
|
2304
|
+
}
|
|
2305
|
+
function resolveActions(actions, data, hasPermission, presets) {
|
|
2306
|
+
const list = typeof actions === "function" ? actions(data) : actions;
|
|
2307
|
+
return list.flatMap((action, index) => {
|
|
2308
|
+
const type = action.type ?? "item";
|
|
2309
|
+
const preset = mergePreset(action.preset, presets);
|
|
2310
|
+
const key = action.key ?? action.preset ?? `action-${index}`;
|
|
2311
|
+
const label = action.label ?? preset?.label ?? key;
|
|
2312
|
+
if (action.permission && hasPermission && !hasPermission(action.permission)) {
|
|
2313
|
+
return [];
|
|
2314
|
+
}
|
|
2315
|
+
if (evalFlag(action.hidden, data)) {
|
|
2316
|
+
return [];
|
|
2317
|
+
}
|
|
2318
|
+
const tooltip = action.tooltip === false ? void 0 : action.tooltip ?? (type === "divider" ? void 0 : label);
|
|
2319
|
+
const resolved = {
|
|
2320
|
+
key,
|
|
2321
|
+
type,
|
|
2322
|
+
label,
|
|
2323
|
+
icon: action.icon ?? preset?.icon,
|
|
2324
|
+
iconSize: action.iconSize,
|
|
2325
|
+
content: action.content,
|
|
2326
|
+
onClick: action.onClick,
|
|
2327
|
+
disabled: evalFlag(action.disabled, data),
|
|
2328
|
+
danger: action.danger ?? preset?.danger ?? false,
|
|
2329
|
+
highlight: evalFlag(action.highlight, data),
|
|
2330
|
+
tooltip,
|
|
2331
|
+
tooltipPlacement: action.tooltipPlacement,
|
|
2332
|
+
confirm: action.confirm,
|
|
2333
|
+
closeOnClick: action.closeOnClick !== false,
|
|
2334
|
+
className: action.className
|
|
2335
|
+
};
|
|
2336
|
+
return [resolved];
|
|
2337
|
+
});
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2340
|
+
// src/components/row-actions/RowActions.tsx
|
|
2341
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2342
|
+
function runAction(action, data, hide, confirmFn = confirmationAlert) {
|
|
2343
|
+
if (!action.onClick) {
|
|
2344
|
+
if (action.closeOnClick) hide?.();
|
|
2345
|
+
return;
|
|
2346
|
+
}
|
|
2347
|
+
const execute = () => action.onClick?.(data);
|
|
2348
|
+
if (action.confirm) {
|
|
2349
|
+
confirmFn?.(execute, action.confirm);
|
|
2350
|
+
} else {
|
|
2351
|
+
execute();
|
|
2352
|
+
}
|
|
2353
|
+
if (action.closeOnClick) {
|
|
2354
|
+
hide?.();
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
function RowActions({
|
|
2358
|
+
actions,
|
|
2359
|
+
data,
|
|
2360
|
+
mode = "menu",
|
|
2361
|
+
actionIcon,
|
|
2362
|
+
className,
|
|
2363
|
+
menuClassName,
|
|
2364
|
+
itemClassName,
|
|
2365
|
+
itemIconClassName,
|
|
2366
|
+
iconSize = ROW_ACTION_DEFAULT_ICON_SIZE,
|
|
2367
|
+
triggerTooltip = "Actions",
|
|
2368
|
+
triggerAriaLabel = "Row actions",
|
|
2369
|
+
hasPermission,
|
|
2370
|
+
placement = "bottom-end",
|
|
2371
|
+
tippyProps,
|
|
2372
|
+
presets,
|
|
2373
|
+
confirmFn = confirmationAlert,
|
|
2374
|
+
tooltipPlacement = "top",
|
|
2375
|
+
tooltipDelayShow,
|
|
2376
|
+
tooltipDelayHide,
|
|
2377
|
+
tooltipClassName,
|
|
2378
|
+
tooltipStyle,
|
|
2379
|
+
renderItem,
|
|
2380
|
+
renderMenu,
|
|
2381
|
+
renderTrigger
|
|
2382
|
+
}) {
|
|
2383
|
+
const resolved = resolveActions(actions, data, hasPermission, presets);
|
|
2384
|
+
if (resolved.length === 0) {
|
|
2385
|
+
return null;
|
|
2386
|
+
}
|
|
2387
|
+
const mergedTooltipStyle = {
|
|
2388
|
+
...ROW_ACTION_DEFAULT_MENU_TOOLTIP_STYLE,
|
|
2389
|
+
...tooltipStyle
|
|
2390
|
+
};
|
|
2391
|
+
const renderDefaultItem = (action, hide, showLabel = true) => {
|
|
2392
|
+
if (action.type === "divider") {
|
|
2393
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2394
|
+
"div",
|
|
2395
|
+
{
|
|
2396
|
+
role: "separator",
|
|
2397
|
+
className: cn("my-1 h-px bg-gray-100", action.className)
|
|
2398
|
+
},
|
|
2399
|
+
action.key
|
|
2400
|
+
);
|
|
2401
|
+
}
|
|
2402
|
+
if (action.content) {
|
|
2403
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: action.className, children: action.content }, action.key);
|
|
2404
|
+
}
|
|
2405
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2406
|
+
ActionMenuItem,
|
|
2407
|
+
{
|
|
2408
|
+
label: action.label,
|
|
2409
|
+
icon: action.icon,
|
|
2410
|
+
iconSize: action.iconSize ?? iconSize,
|
|
2411
|
+
iconClassName: itemIconClassName,
|
|
2412
|
+
tooltip: action.tooltip,
|
|
2413
|
+
tooltipPlacement: action.tooltipPlacement ?? tooltipPlacement,
|
|
2414
|
+
tooltipDelayShow,
|
|
2415
|
+
tooltipDelayHide,
|
|
2416
|
+
tooltipClassName,
|
|
2417
|
+
tooltipStyle: mergedTooltipStyle,
|
|
2418
|
+
disabled: action.disabled,
|
|
2419
|
+
danger: action.danger,
|
|
2420
|
+
highlight: action.highlight,
|
|
2421
|
+
showLabel,
|
|
2422
|
+
className: cn(itemClassName, action.className),
|
|
2423
|
+
onClick: () => runAction(action, data, hide, confirmFn)
|
|
2424
|
+
},
|
|
2425
|
+
action.key
|
|
2426
|
+
);
|
|
2427
|
+
};
|
|
2428
|
+
const renderItems = (hide, showLabel = true) => resolved.map((action) => {
|
|
2429
|
+
const defaultItem = renderDefaultItem(action, hide, showLabel);
|
|
2430
|
+
if (!renderItem) return defaultItem;
|
|
2431
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { children: renderItem(action, { data, hide: hide ?? (() => void 0), defaultItem }) }, action.key);
|
|
2432
|
+
});
|
|
2433
|
+
if (mode === "inline") {
|
|
2434
|
+
const inlineItems = renderItems(void 0, false);
|
|
2435
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: cn("flex h-full items-center justify-center gap-1", className), children: inlineItems });
|
|
2436
|
+
}
|
|
2437
|
+
const triggerTooltipText = triggerTooltip === false ? void 0 : triggerTooltip;
|
|
2438
|
+
const buildMenu = (hide) => {
|
|
2439
|
+
const defaultMenu = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2440
|
+
"div",
|
|
2441
|
+
{
|
|
2442
|
+
className: cn(
|
|
2443
|
+
"flex min-w-[180px] flex-col rounded-lg border border-gray-100 bg-white p-2 shadow-lg",
|
|
2444
|
+
menuClassName
|
|
2445
|
+
),
|
|
2446
|
+
children: renderItems(hide, true)
|
|
2447
|
+
}
|
|
2448
|
+
);
|
|
2449
|
+
if (!renderMenu) return defaultMenu;
|
|
2450
|
+
return renderMenu({
|
|
2451
|
+
data,
|
|
2452
|
+
actions: resolved,
|
|
2453
|
+
hide,
|
|
2454
|
+
defaultMenu
|
|
2455
|
+
});
|
|
2456
|
+
};
|
|
2457
|
+
if (renderTrigger) {
|
|
2458
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, { children: renderTrigger({
|
|
2459
|
+
data,
|
|
2460
|
+
actions: resolved,
|
|
2461
|
+
hide: () => void 0,
|
|
2462
|
+
defaultMenu: buildMenu(() => void 0)
|
|
2463
|
+
}) });
|
|
2464
|
+
}
|
|
2465
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2466
|
+
ToolTip,
|
|
2467
|
+
{
|
|
2468
|
+
text: triggerTooltipText,
|
|
2469
|
+
disabled: !triggerTooltipText,
|
|
2470
|
+
placement: tooltipPlacement,
|
|
2471
|
+
delayShow: tooltipDelayShow,
|
|
2472
|
+
delayHide: tooltipDelayHide,
|
|
2473
|
+
tooltipClassName,
|
|
2474
|
+
tooltipStyle,
|
|
2475
|
+
className: "flex h-full items-center justify-center",
|
|
2476
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2477
|
+
PopupCellRenderer,
|
|
2478
|
+
{
|
|
2479
|
+
params: { data },
|
|
2480
|
+
actionIcon,
|
|
2481
|
+
hideTitle: true,
|
|
2482
|
+
className,
|
|
2483
|
+
placement,
|
|
2484
|
+
tippyProps,
|
|
2485
|
+
ariaLabel: triggerAriaLabel,
|
|
2486
|
+
dropDownContent: (handleAction) => buildMenu(() => handleAction("close"))
|
|
2487
|
+
}
|
|
2488
|
+
)
|
|
2489
|
+
}
|
|
2490
|
+
);
|
|
2491
|
+
}
|
|
2492
|
+
|
|
2184
2493
|
// src/components/table-error-boundary/TableErrorBoundary.tsx
|
|
2185
2494
|
var import_react11 = require("react");
|
|
2186
2495
|
var import_fa6 = require("react-icons/fa6");
|
|
2187
|
-
var
|
|
2496
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2188
2497
|
var TableErrorBoundary = ({
|
|
2189
2498
|
isError,
|
|
2190
2499
|
isLoading = false,
|
|
@@ -2201,7 +2510,7 @@ var TableErrorBoundary = ({
|
|
|
2201
2510
|
return "Unable to load table data. Please try again.";
|
|
2202
2511
|
}, [error, errorMessage]);
|
|
2203
2512
|
if (isLoading && !isError) {
|
|
2204
|
-
return /* @__PURE__ */ (0,
|
|
2513
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2205
2514
|
"div",
|
|
2206
2515
|
{
|
|
2207
2516
|
className: cn(
|
|
@@ -2212,12 +2521,12 @@ var TableErrorBoundary = ({
|
|
|
2212
2521
|
role: "status",
|
|
2213
2522
|
"aria-live": "polite",
|
|
2214
2523
|
"aria-busy": "true",
|
|
2215
|
-
children: /* @__PURE__ */ (0,
|
|
2524
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Loader, { size: "40px" })
|
|
2216
2525
|
}
|
|
2217
2526
|
);
|
|
2218
2527
|
}
|
|
2219
2528
|
if (isError) {
|
|
2220
|
-
return /* @__PURE__ */ (0,
|
|
2529
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2221
2530
|
"div",
|
|
2222
2531
|
{
|
|
2223
2532
|
className: cn(
|
|
@@ -2228,7 +2537,7 @@ var TableErrorBoundary = ({
|
|
|
2228
2537
|
role: "alert",
|
|
2229
2538
|
"aria-live": "assertive",
|
|
2230
2539
|
children: [
|
|
2231
|
-
/* @__PURE__ */ (0,
|
|
2540
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2232
2541
|
import_fa6.FaTriangleExclamation,
|
|
2233
2542
|
{
|
|
2234
2543
|
className: "text-red-500",
|
|
@@ -2236,11 +2545,11 @@ var TableErrorBoundary = ({
|
|
|
2236
2545
|
"aria-hidden": true
|
|
2237
2546
|
}
|
|
2238
2547
|
),
|
|
2239
|
-
/* @__PURE__ */ (0,
|
|
2240
|
-
/* @__PURE__ */ (0,
|
|
2241
|
-
/* @__PURE__ */ (0,
|
|
2548
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "max-w-md space-y-1", children: [
|
|
2549
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-base font-semibold text-gray-800", children: "Failed to load data" }),
|
|
2550
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-sm text-gray-600", children: message })
|
|
2242
2551
|
] }),
|
|
2243
|
-
refetch && /* @__PURE__ */ (0,
|
|
2552
|
+
refetch && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2244
2553
|
"button",
|
|
2245
2554
|
{
|
|
2246
2555
|
type: "button",
|
|
@@ -2248,7 +2557,7 @@ var TableErrorBoundary = ({
|
|
|
2248
2557
|
disabled: isLoading,
|
|
2249
2558
|
className: "inline-flex items-center gap-2 rounded-lg bg-primary-150 px-4 py-2 text-sm font-medium text-white transition-colors hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60",
|
|
2250
2559
|
children: [
|
|
2251
|
-
/* @__PURE__ */ (0,
|
|
2560
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_fa6.FaArrowsRotate, { className: cn(isLoading && "animate-spin") }),
|
|
2252
2561
|
isLoading ? "Retrying..." : "Try again"
|
|
2253
2562
|
]
|
|
2254
2563
|
}
|
|
@@ -2257,10 +2566,11 @@ var TableErrorBoundary = ({
|
|
|
2257
2566
|
}
|
|
2258
2567
|
);
|
|
2259
2568
|
}
|
|
2260
|
-
return /* @__PURE__ */ (0,
|
|
2569
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children });
|
|
2261
2570
|
};
|
|
2262
2571
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2263
2572
|
0 && (module.exports = {
|
|
2573
|
+
ActionMenuItem,
|
|
2264
2574
|
CardSkeleton,
|
|
2265
2575
|
CustomCellEditor,
|
|
2266
2576
|
CustomPagination,
|
|
@@ -2269,8 +2579,13 @@ var TableErrorBoundary = ({
|
|
|
2269
2579
|
Loader,
|
|
2270
2580
|
Modal,
|
|
2271
2581
|
PopupCellRenderer,
|
|
2582
|
+
ROW_ACTION_DEFAULT_ICON_SIZE,
|
|
2583
|
+
ROW_ACTION_DEFAULT_MENU_TOOLTIP_STYLE,
|
|
2584
|
+
ROW_ACTION_ITEM_HOVER_CLASS,
|
|
2585
|
+
ROW_ACTION_PRESETS,
|
|
2272
2586
|
ResetColumnsButton,
|
|
2273
2587
|
ResetFiltersButton,
|
|
2588
|
+
RowActions,
|
|
2274
2589
|
SearchInput,
|
|
2275
2590
|
TableErrorBoundary,
|
|
2276
2591
|
TableLayoutToolbarControls,
|
|
@@ -2308,6 +2623,8 @@ var TableErrorBoundary = ({
|
|
|
2308
2623
|
parseCurrencyValueToNumber,
|
|
2309
2624
|
removeByPropertyValues,
|
|
2310
2625
|
removeItem,
|
|
2626
|
+
resetPageParam,
|
|
2627
|
+
resolveActions,
|
|
2311
2628
|
saveItemLocalStorage,
|
|
2312
2629
|
saveUserState,
|
|
2313
2630
|
set,
|