@eztrak/shared 0.14.0 → 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/dist/{chunk-JATUZDLG.mjs → chunk-KFBKDGZV.mjs} +317 -14
- package/dist/chunk-KFBKDGZV.mjs.map +1 -0
- package/dist/components/index.d.mts +145 -3
- package/dist/components/index.d.ts +145 -3
- package/dist/components/index.js +316 -15
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +17 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +314 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -2
- package/package.json +1 -1
- package/dist/chunk-JATUZDLG.mjs.map +0 -1
|
@@ -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
|
-
|
|
23
|
+
dropdownStyles,
|
|
24
|
+
resolveActions
|
|
25
|
+
} from "../chunk-KFBKDGZV.mjs";
|
|
19
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
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
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,
|
|
@@ -78,6 +84,7 @@ __export(src_exports, {
|
|
|
78
84
|
removeByPropertyValues: () => removeByPropertyValues,
|
|
79
85
|
removeItem: () => removeItem,
|
|
80
86
|
resetPageParam: () => resetPageParam,
|
|
87
|
+
resolveActions: () => resolveActions,
|
|
81
88
|
saveItemLocalStorage: () => saveItemLocalStorage,
|
|
82
89
|
saveUserState: () => saveUserState,
|
|
83
90
|
set: () => set,
|
|
@@ -2149,7 +2156,8 @@ function PopupCellRenderer({
|
|
|
2149
2156
|
params,
|
|
2150
2157
|
onAction,
|
|
2151
2158
|
placement = "bottom-end",
|
|
2152
|
-
tippyProps
|
|
2159
|
+
tippyProps,
|
|
2160
|
+
ariaLabel = "Row actions"
|
|
2153
2161
|
}) {
|
|
2154
2162
|
const [visible, setVisible] = (0, import_react9.useState)(false);
|
|
2155
2163
|
const show = () => setVisible(true);
|
|
@@ -2185,7 +2193,7 @@ function PopupCellRenderer({
|
|
|
2185
2193
|
"flex items-center justify-center gap-2 rounded-full text-gray-500 hover:text-gray-800",
|
|
2186
2194
|
className
|
|
2187
2195
|
),
|
|
2188
|
-
"aria-label":
|
|
2196
|
+
"aria-label": ariaLabel,
|
|
2189
2197
|
children: [
|
|
2190
2198
|
!hideTitle && title,
|
|
2191
2199
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ActionIcon, { "aria-hidden": true })
|
|
@@ -2196,10 +2204,296 @@ function PopupCellRenderer({
|
|
|
2196
2204
|
) });
|
|
2197
2205
|
}
|
|
2198
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
|
+
|
|
2199
2493
|
// src/components/table-error-boundary/TableErrorBoundary.tsx
|
|
2200
2494
|
var import_react11 = require("react");
|
|
2201
2495
|
var import_fa6 = require("react-icons/fa6");
|
|
2202
|
-
var
|
|
2496
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2203
2497
|
var TableErrorBoundary = ({
|
|
2204
2498
|
isError,
|
|
2205
2499
|
isLoading = false,
|
|
@@ -2216,7 +2510,7 @@ var TableErrorBoundary = ({
|
|
|
2216
2510
|
return "Unable to load table data. Please try again.";
|
|
2217
2511
|
}, [error, errorMessage]);
|
|
2218
2512
|
if (isLoading && !isError) {
|
|
2219
|
-
return /* @__PURE__ */ (0,
|
|
2513
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2220
2514
|
"div",
|
|
2221
2515
|
{
|
|
2222
2516
|
className: cn(
|
|
@@ -2227,12 +2521,12 @@ var TableErrorBoundary = ({
|
|
|
2227
2521
|
role: "status",
|
|
2228
2522
|
"aria-live": "polite",
|
|
2229
2523
|
"aria-busy": "true",
|
|
2230
|
-
children: /* @__PURE__ */ (0,
|
|
2524
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Loader, { size: "40px" })
|
|
2231
2525
|
}
|
|
2232
2526
|
);
|
|
2233
2527
|
}
|
|
2234
2528
|
if (isError) {
|
|
2235
|
-
return /* @__PURE__ */ (0,
|
|
2529
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2236
2530
|
"div",
|
|
2237
2531
|
{
|
|
2238
2532
|
className: cn(
|
|
@@ -2243,7 +2537,7 @@ var TableErrorBoundary = ({
|
|
|
2243
2537
|
role: "alert",
|
|
2244
2538
|
"aria-live": "assertive",
|
|
2245
2539
|
children: [
|
|
2246
|
-
/* @__PURE__ */ (0,
|
|
2540
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2247
2541
|
import_fa6.FaTriangleExclamation,
|
|
2248
2542
|
{
|
|
2249
2543
|
className: "text-red-500",
|
|
@@ -2251,11 +2545,11 @@ var TableErrorBoundary = ({
|
|
|
2251
2545
|
"aria-hidden": true
|
|
2252
2546
|
}
|
|
2253
2547
|
),
|
|
2254
|
-
/* @__PURE__ */ (0,
|
|
2255
|
-
/* @__PURE__ */ (0,
|
|
2256
|
-
/* @__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 })
|
|
2257
2551
|
] }),
|
|
2258
|
-
refetch && /* @__PURE__ */ (0,
|
|
2552
|
+
refetch && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2259
2553
|
"button",
|
|
2260
2554
|
{
|
|
2261
2555
|
type: "button",
|
|
@@ -2263,7 +2557,7 @@ var TableErrorBoundary = ({
|
|
|
2263
2557
|
disabled: isLoading,
|
|
2264
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",
|
|
2265
2559
|
children: [
|
|
2266
|
-
/* @__PURE__ */ (0,
|
|
2560
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_fa6.FaArrowsRotate, { className: cn(isLoading && "animate-spin") }),
|
|
2267
2561
|
isLoading ? "Retrying..." : "Try again"
|
|
2268
2562
|
]
|
|
2269
2563
|
}
|
|
@@ -2272,10 +2566,11 @@ var TableErrorBoundary = ({
|
|
|
2272
2566
|
}
|
|
2273
2567
|
);
|
|
2274
2568
|
}
|
|
2275
|
-
return /* @__PURE__ */ (0,
|
|
2569
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children });
|
|
2276
2570
|
};
|
|
2277
2571
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2278
2572
|
0 && (module.exports = {
|
|
2573
|
+
ActionMenuItem,
|
|
2279
2574
|
CardSkeleton,
|
|
2280
2575
|
CustomCellEditor,
|
|
2281
2576
|
CustomPagination,
|
|
@@ -2284,8 +2579,13 @@ var TableErrorBoundary = ({
|
|
|
2284
2579
|
Loader,
|
|
2285
2580
|
Modal,
|
|
2286
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,
|
|
2287
2586
|
ResetColumnsButton,
|
|
2288
2587
|
ResetFiltersButton,
|
|
2588
|
+
RowActions,
|
|
2289
2589
|
SearchInput,
|
|
2290
2590
|
TableErrorBoundary,
|
|
2291
2591
|
TableLayoutToolbarControls,
|
|
@@ -2324,6 +2624,7 @@ var TableErrorBoundary = ({
|
|
|
2324
2624
|
removeByPropertyValues,
|
|
2325
2625
|
removeItem,
|
|
2326
2626
|
resetPageParam,
|
|
2627
|
+
resolveActions,
|
|
2327
2628
|
saveItemLocalStorage,
|
|
2328
2629
|
saveUserState,
|
|
2329
2630
|
set,
|