@eztrak/shared 0.14.0 → 0.15.1
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-HQPQ6TOE.mjs} +324 -14
- package/dist/chunk-HQPQ6TOE.mjs.map +1 -0
- package/dist/components/index.d.mts +157 -3
- package/dist/components/index.d.ts +157 -3
- package/dist/components/index.js +324 -15
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +19 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +322 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -2
- package/package.json +1 -1
- package/dist/chunk-JATUZDLG.mjs.map +0 -1
|
@@ -4,7 +4,7 @@ import { Props, StylesConfig } from 'react-select';
|
|
|
4
4
|
import { PlacesType } from 'react-tooltip';
|
|
5
5
|
import { IconType } from 'react-icons';
|
|
6
6
|
import { TippyProps } from '@tippyjs/react';
|
|
7
|
-
import { R as RtkQueryError } from '../handleApiError-CwVIJOqO.js';
|
|
7
|
+
import { C as ConfirmationAlertOptions, R as RtkQueryError } from '../handleApiError-CwVIJOqO.js';
|
|
8
8
|
|
|
9
9
|
type EztrakTab = {
|
|
10
10
|
id: string;
|
|
@@ -317,6 +317,8 @@ interface PopupCellRendererProps<TRow = unknown> {
|
|
|
317
317
|
params?: PopupCellRendererParams<TRow>;
|
|
318
318
|
onAction?: (actionType: string, rowData: TRow | undefined, hide: () => void) => void;
|
|
319
319
|
placement?: TippyProps["placement"];
|
|
320
|
+
/** Default `"Row actions"`. */
|
|
321
|
+
ariaLabel?: string;
|
|
320
322
|
tippyProps?: Omit<Partial<TippyProps>, "children" | "content" | "visible" | "placement">;
|
|
321
323
|
}
|
|
322
324
|
|
|
@@ -327,7 +329,159 @@ interface PopupCellRendererProps<TRow = unknown> {
|
|
|
327
329
|
* `import "tippy.js/dist/tippy.css"`
|
|
328
330
|
* `import "tippy.js/themes/light.css"`
|
|
329
331
|
*/
|
|
330
|
-
declare function PopupCellRenderer<TRow = unknown>({ dropDownContent, actionIcon: ActionIcon, title, className, hideTitle, params, onAction, placement, tippyProps, }: PopupCellRendererProps<TRow>): react.JSX.Element;
|
|
332
|
+
declare function PopupCellRenderer<TRow = unknown>({ dropDownContent, actionIcon: ActionIcon, title, className, hideTitle, params, onAction, placement, tippyProps, ariaLabel, }: PopupCellRendererProps<TRow>): react.JSX.Element;
|
|
333
|
+
|
|
334
|
+
type RowActionPresetName = "edit" | "delete" | "view" | "notes" | "history" | "download" | "archive" | "resolve";
|
|
335
|
+
type RowActionsMode = "menu" | "inline";
|
|
336
|
+
type RowActionItemType = "item" | "divider";
|
|
337
|
+
type RowActionFlag<TRow> = boolean | ((row: TRow | undefined) => boolean);
|
|
338
|
+
type RowActionConfirmFn = (onConfirm: () => void | Promise<void>, options?: ConfirmationAlertOptions) => void;
|
|
339
|
+
type RowAction<TRow = unknown> = {
|
|
340
|
+
/** Unique id. Falls back to `preset` when omitted. */
|
|
341
|
+
key?: string;
|
|
342
|
+
/** `"divider"` renders a separator. Default `"item"`. */
|
|
343
|
+
type?: RowActionItemType;
|
|
344
|
+
label?: string;
|
|
345
|
+
icon?: IconType;
|
|
346
|
+
/** Overrides `RowActions` `iconSize` for this item. */
|
|
347
|
+
iconSize?: number;
|
|
348
|
+
preset?: RowActionPresetName;
|
|
349
|
+
onClick?: (row: TRow | undefined) => void;
|
|
350
|
+
/** Fully custom row content (skips the default icon+label button). */
|
|
351
|
+
content?: ReactNode;
|
|
352
|
+
/** If set, the action is hidden unless `hasPermission(permission)` is true. */
|
|
353
|
+
permission?: string;
|
|
354
|
+
hidden?: RowActionFlag<TRow>;
|
|
355
|
+
disabled?: RowActionFlag<TRow>;
|
|
356
|
+
danger?: boolean;
|
|
357
|
+
highlight?: RowActionFlag<TRow>;
|
|
358
|
+
/** Default = resolved label. `false` hides the tooltip. */
|
|
359
|
+
tooltip?: string | false;
|
|
360
|
+
tooltipPlacement?: PlacesType;
|
|
361
|
+
confirm?: ConfirmationAlertOptions;
|
|
362
|
+
/** Default `true`. */
|
|
363
|
+
closeOnClick?: boolean;
|
|
364
|
+
/** Extra classes on this item (merged after defaults; can override hover). */
|
|
365
|
+
className?: string;
|
|
366
|
+
/** Extra classes on this item’s icon (overrides preset, e.g. `"text-red-500"`). */
|
|
367
|
+
iconClassName?: string;
|
|
368
|
+
/** Extra classes on this item’s label. */
|
|
369
|
+
labelClassName?: string;
|
|
370
|
+
};
|
|
371
|
+
type RowActionsList<TRow = unknown> = RowAction<TRow>[] | ((data: TRow | undefined) => RowAction<TRow>[]);
|
|
372
|
+
interface RowActionsRenderContext<TRow = unknown> {
|
|
373
|
+
data: TRow | undefined;
|
|
374
|
+
actions: ResolvedRowAction<TRow>[];
|
|
375
|
+
hide: () => void;
|
|
376
|
+
defaultMenu: ReactNode;
|
|
377
|
+
}
|
|
378
|
+
interface RowActionItemRenderContext<TRow = unknown> {
|
|
379
|
+
data: TRow | undefined;
|
|
380
|
+
hide: () => void;
|
|
381
|
+
defaultItem: ReactNode;
|
|
382
|
+
}
|
|
383
|
+
interface RowActionsProps<TRow = unknown> {
|
|
384
|
+
actions: RowActionsList<TRow>;
|
|
385
|
+
data?: TRow;
|
|
386
|
+
mode?: RowActionsMode;
|
|
387
|
+
/** Override the default vertical 3-dots trigger. */
|
|
388
|
+
actionIcon?: IconType;
|
|
389
|
+
/** Extra classes on the trigger button (merged with defaults). */
|
|
390
|
+
className?: string;
|
|
391
|
+
/** Extra classes on the dropdown panel (merged with defaults). */
|
|
392
|
+
menuClassName?: string;
|
|
393
|
+
/**
|
|
394
|
+
* Extra classes on every menu/inline item (merged after defaults).
|
|
395
|
+
* Override hover here, e.g. `hover:bg-gray-100 hover:text-gray-800`.
|
|
396
|
+
*/
|
|
397
|
+
itemClassName?: string;
|
|
398
|
+
itemIconClassName?: string;
|
|
399
|
+
/** Extra classes on every item label. */
|
|
400
|
+
itemLabelClassName?: string;
|
|
401
|
+
/** Default `16`. */
|
|
402
|
+
iconSize?: number;
|
|
403
|
+
/** Default `"Actions"`. Pass `false` to hide. */
|
|
404
|
+
triggerTooltip?: string | false;
|
|
405
|
+
triggerAriaLabel?: string;
|
|
406
|
+
hasPermission?: (permission: string) => boolean;
|
|
407
|
+
placement?: TippyProps["placement"];
|
|
408
|
+
tippyProps?: PopupCellRendererProps<TRow>["tippyProps"];
|
|
409
|
+
/** Override default `Fa*` preset icons/labels for this instance. */
|
|
410
|
+
presets?: Partial<Record<RowActionPresetName, Partial<RowActionPreset>>>;
|
|
411
|
+
/** Default: shared `confirmationAlert`. */
|
|
412
|
+
confirmFn?: RowActionConfirmFn;
|
|
413
|
+
tooltipPlacement?: PlacesType;
|
|
414
|
+
tooltipDelayShow?: number;
|
|
415
|
+
tooltipDelayHide?: number;
|
|
416
|
+
tooltipClassName?: string;
|
|
417
|
+
tooltipStyle?: CSSProperties;
|
|
418
|
+
/** Replace one item’s markup. */
|
|
419
|
+
renderItem?: (action: ResolvedRowAction<TRow>, ctx: RowActionItemRenderContext<TRow>) => ReactNode;
|
|
420
|
+
/** Replace the dropdown panel. Still opened by the default trigger unless `renderTrigger` is set. */
|
|
421
|
+
renderMenu?: (ctx: RowActionsRenderContext<TRow>) => ReactNode;
|
|
422
|
+
/** Replace trigger + popup engine entirely (e.g. a custom popover). */
|
|
423
|
+
renderTrigger?: (ctx: Omit<RowActionsRenderContext<TRow>, "hide"> & {
|
|
424
|
+
hide: () => void;
|
|
425
|
+
}) => ReactNode;
|
|
426
|
+
}
|
|
427
|
+
interface ActionMenuItemProps {
|
|
428
|
+
label: string;
|
|
429
|
+
icon?: IconType;
|
|
430
|
+
iconSize?: number;
|
|
431
|
+
iconClassName?: string;
|
|
432
|
+
tooltip?: string;
|
|
433
|
+
tooltipPlacement?: PlacesType;
|
|
434
|
+
tooltipDelayShow?: number;
|
|
435
|
+
tooltipDelayHide?: number;
|
|
436
|
+
tooltipClassName?: string;
|
|
437
|
+
tooltipStyle?: CSSProperties;
|
|
438
|
+
disabled?: boolean;
|
|
439
|
+
danger?: boolean;
|
|
440
|
+
highlight?: boolean;
|
|
441
|
+
showLabel?: boolean;
|
|
442
|
+
className?: string;
|
|
443
|
+
labelClassName?: string;
|
|
444
|
+
onClick: () => void;
|
|
445
|
+
}
|
|
446
|
+
interface ResolvedRowAction<TRow = unknown> {
|
|
447
|
+
key: string;
|
|
448
|
+
type: RowActionItemType;
|
|
449
|
+
label: string;
|
|
450
|
+
icon?: IconType;
|
|
451
|
+
iconSize?: number;
|
|
452
|
+
content?: ReactNode;
|
|
453
|
+
onClick?: (row: TRow | undefined) => void;
|
|
454
|
+
disabled: boolean;
|
|
455
|
+
danger: boolean;
|
|
456
|
+
highlight: boolean;
|
|
457
|
+
tooltip?: string;
|
|
458
|
+
tooltipPlacement?: PlacesType;
|
|
459
|
+
confirm?: ConfirmationAlertOptions;
|
|
460
|
+
closeOnClick: boolean;
|
|
461
|
+
className?: string;
|
|
462
|
+
iconClassName?: string;
|
|
463
|
+
labelClassName?: string;
|
|
464
|
+
}
|
|
465
|
+
interface RowActionPreset {
|
|
466
|
+
label: string;
|
|
467
|
+
icon: IconType;
|
|
468
|
+
danger?: boolean;
|
|
469
|
+
iconClassName?: string;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
declare function RowActions<TRow = unknown>({ actions, data, mode, actionIcon, className, menuClassName, itemClassName, itemIconClassName, itemLabelClassName, iconSize, triggerTooltip, triggerAriaLabel, hasPermission, placement, tippyProps, presets, confirmFn, tooltipPlacement, tooltipDelayShow, tooltipDelayHide, tooltipClassName, tooltipStyle, renderItem, renderMenu, renderTrigger, }: RowActionsProps<TRow>): react.JSX.Element | null;
|
|
473
|
+
|
|
474
|
+
declare function ActionMenuItem({ label, icon: Icon, iconSize, iconClassName, labelClassName, tooltip, tooltipPlacement, tooltipDelayShow, tooltipDelayHide, tooltipClassName, tooltipStyle, disabled, danger, highlight, showLabel, className, onClick, }: ActionMenuItemProps): react.JSX.Element;
|
|
475
|
+
|
|
476
|
+
/** Settings-app hover: peach bg `#FFF1EB` + orange text (`primary-50` / `primary-150`). */
|
|
477
|
+
declare const ROW_ACTION_ITEM_HOVER_CLASS = "hover:bg-primary-50 hover:text-primary-150";
|
|
478
|
+
/** Settings/Department rest color (`#6C757D`). */
|
|
479
|
+
declare const ROW_ACTION_ITEM_TEXT_CLASS = "text-secondary";
|
|
480
|
+
declare const ROW_ACTION_DEFAULT_ICON_SIZE = 16;
|
|
481
|
+
declare const ROW_ACTION_DEFAULT_MENU_TOOLTIP_STYLE: CSSProperties;
|
|
482
|
+
declare const ROW_ACTION_PRESETS: Record<RowActionPresetName, RowActionPreset>;
|
|
483
|
+
|
|
484
|
+
declare function resolveActions<TRow>(actions: RowActionsList<TRow>, data: TRow | undefined, hasPermission?: (permission: string) => boolean, presets?: Partial<Record<RowActionPresetName, Partial<RowActionPreset>>>): ResolvedRowAction<TRow>[];
|
|
331
485
|
|
|
332
486
|
type TableErrorBoundaryProps = {
|
|
333
487
|
isError: boolean;
|
|
@@ -342,4 +496,4 @@ type TableErrorBoundaryProps = {
|
|
|
342
496
|
|
|
343
497
|
declare const TableErrorBoundary: react__default.FC<TableErrorBoundaryProps>;
|
|
344
498
|
|
|
345
|
-
export { CardSkeleton, type CardSkeletonProps, type CardSkeletonVariant, type CellEditPayload, type CellEditorInputType, CustomCellEditor, type CustomCellEditorProps, type CustomCellEditorRef, CustomPagination, type CustomPaginationClassNames, type CustomPaginationProps, DropdownFilter, type DropdownFilterProps, type DropdownOption, type EztrakTab, EztrakTabs, type EztrakTabsClassNames, type EztrakTabsProps, type LayoutStatus, Loader, type LoaderProps, Modal, type ModalProps, type PaginationData, type PopupActionHandler, PopupCellRenderer, type PopupCellRendererParams, type PopupCellRendererProps, type PopupDropDownContent, ResetColumnsButton, type ResetColumnsButtonProps, ResetFiltersButton, type ResetFiltersButtonProps, type ResetFiltersButtonVariant, SearchInput, type SearchInputProps, TableErrorBoundary, type TableErrorBoundaryProps, TableLayoutToolbarControls, type TableLayoutToolbarControlsProps, ToolTip, type ToolTipProps, TooltipText, type TooltipTextProps, dropdownStyles };
|
|
499
|
+
export { ActionMenuItem, type ActionMenuItemProps, CardSkeleton, type CardSkeletonProps, type CardSkeletonVariant, type CellEditPayload, type CellEditorInputType, CustomCellEditor, type CustomCellEditorProps, type CustomCellEditorRef, CustomPagination, type CustomPaginationClassNames, type CustomPaginationProps, DropdownFilter, type DropdownFilterProps, type DropdownOption, type EztrakTab, EztrakTabs, type EztrakTabsClassNames, type EztrakTabsProps, type LayoutStatus, Loader, type LoaderProps, Modal, type ModalProps, type PaginationData, type PopupActionHandler, PopupCellRenderer, type PopupCellRendererParams, type PopupCellRendererProps, type PopupDropDownContent, ROW_ACTION_DEFAULT_ICON_SIZE, ROW_ACTION_DEFAULT_MENU_TOOLTIP_STYLE, ROW_ACTION_ITEM_HOVER_CLASS, ROW_ACTION_ITEM_TEXT_CLASS, ROW_ACTION_PRESETS, ResetColumnsButton, type ResetColumnsButtonProps, ResetFiltersButton, type ResetFiltersButtonProps, type ResetFiltersButtonVariant, type ResolvedRowAction, type RowAction, type RowActionConfirmFn, type RowActionFlag, type RowActionItemRenderContext, type RowActionItemType, type RowActionPreset, type RowActionPresetName, RowActions, type RowActionsList, type RowActionsMode, type RowActionsProps, type RowActionsRenderContext, SearchInput, type SearchInputProps, TableErrorBoundary, type TableErrorBoundaryProps, TableLayoutToolbarControls, type TableLayoutToolbarControlsProps, ToolTip, type ToolTipProps, TooltipText, type TooltipTextProps, dropdownStyles, resolveActions };
|
package/dist/components/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/components/index.ts
|
|
31
31
|
var components_exports = {};
|
|
32
32
|
__export(components_exports, {
|
|
33
|
+
ActionMenuItem: () => ActionMenuItem,
|
|
33
34
|
CardSkeleton: () => CardSkeleton,
|
|
34
35
|
CustomCellEditor: () => CustomCellEditor,
|
|
35
36
|
CustomPagination: () => CustomPagination,
|
|
@@ -38,14 +39,21 @@ __export(components_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_ITEM_TEXT_CLASS: () => ROW_ACTION_ITEM_TEXT_CLASS,
|
|
46
|
+
ROW_ACTION_PRESETS: () => ROW_ACTION_PRESETS,
|
|
41
47
|
ResetColumnsButton: () => ResetColumnsButton,
|
|
42
48
|
ResetFiltersButton: () => ResetFiltersButton,
|
|
49
|
+
RowActions: () => RowActions,
|
|
43
50
|
SearchInput: () => SearchInput,
|
|
44
51
|
TableErrorBoundary: () => TableErrorBoundary,
|
|
45
52
|
TableLayoutToolbarControls: () => TableLayoutToolbarControls,
|
|
46
53
|
ToolTip: () => ToolTip,
|
|
47
54
|
TooltipText: () => TooltipText,
|
|
48
|
-
dropdownStyles: () => dropdownStyles
|
|
55
|
+
dropdownStyles: () => dropdownStyles,
|
|
56
|
+
resolveActions: () => resolveActions
|
|
49
57
|
});
|
|
50
58
|
module.exports = __toCommonJS(components_exports);
|
|
51
59
|
|
|
@@ -1749,7 +1757,8 @@ function PopupCellRenderer({
|
|
|
1749
1757
|
params,
|
|
1750
1758
|
onAction,
|
|
1751
1759
|
placement = "bottom-end",
|
|
1752
|
-
tippyProps
|
|
1760
|
+
tippyProps,
|
|
1761
|
+
ariaLabel = "Row actions"
|
|
1753
1762
|
}) {
|
|
1754
1763
|
const [visible, setVisible] = (0, import_react7.useState)(false);
|
|
1755
1764
|
const show = () => setVisible(true);
|
|
@@ -1785,7 +1794,7 @@ function PopupCellRenderer({
|
|
|
1785
1794
|
"flex items-center justify-center gap-2 rounded-full text-gray-500 hover:text-gray-800",
|
|
1786
1795
|
className
|
|
1787
1796
|
),
|
|
1788
|
-
"aria-label":
|
|
1797
|
+
"aria-label": ariaLabel,
|
|
1789
1798
|
children: [
|
|
1790
1799
|
!hideTitle && title,
|
|
1791
1800
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ActionIcon, { "aria-hidden": true })
|
|
@@ -1796,10 +1805,302 @@ function PopupCellRenderer({
|
|
|
1796
1805
|
) });
|
|
1797
1806
|
}
|
|
1798
1807
|
|
|
1808
|
+
// src/components/row-actions/presets.ts
|
|
1809
|
+
var import_fa2 = require("react-icons/fa");
|
|
1810
|
+
var ROW_ACTION_ITEM_HOVER_CLASS = "hover:bg-primary-50 hover:text-primary-150";
|
|
1811
|
+
var ROW_ACTION_ITEM_TEXT_CLASS = "text-secondary";
|
|
1812
|
+
var ROW_ACTION_DEFAULT_ICON_SIZE = 16;
|
|
1813
|
+
var ROW_ACTION_DEFAULT_MENU_TOOLTIP_STYLE = {
|
|
1814
|
+
zIndex: 1e4
|
|
1815
|
+
};
|
|
1816
|
+
var ROW_ACTION_PRESETS = {
|
|
1817
|
+
edit: { label: "Edit", icon: import_fa2.FaEdit },
|
|
1818
|
+
delete: { label: "Delete", icon: import_fa2.FaTrashAlt, danger: true, iconClassName: "text-red-500" },
|
|
1819
|
+
view: { label: "View", icon: import_fa2.FaEye },
|
|
1820
|
+
notes: { label: "Notes", icon: import_fa2.FaFileAlt },
|
|
1821
|
+
history: { label: "History", icon: import_fa2.FaHistory },
|
|
1822
|
+
download: { label: "Download", icon: import_fa2.FaDownload },
|
|
1823
|
+
archive: { label: "Archive", icon: import_fa2.FaArchive },
|
|
1824
|
+
resolve: { label: "Resolve", icon: import_fa2.FaCheckCircle }
|
|
1825
|
+
};
|
|
1826
|
+
|
|
1827
|
+
// src/components/row-actions/ActionMenuItem.tsx
|
|
1828
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1829
|
+
function ActionMenuItem({
|
|
1830
|
+
label,
|
|
1831
|
+
icon: Icon,
|
|
1832
|
+
iconSize = ROW_ACTION_DEFAULT_ICON_SIZE,
|
|
1833
|
+
iconClassName,
|
|
1834
|
+
labelClassName,
|
|
1835
|
+
tooltip,
|
|
1836
|
+
tooltipPlacement = "top",
|
|
1837
|
+
tooltipDelayShow,
|
|
1838
|
+
tooltipDelayHide,
|
|
1839
|
+
tooltipClassName,
|
|
1840
|
+
tooltipStyle,
|
|
1841
|
+
disabled = false,
|
|
1842
|
+
danger = false,
|
|
1843
|
+
highlight = false,
|
|
1844
|
+
showLabel = true,
|
|
1845
|
+
className,
|
|
1846
|
+
onClick
|
|
1847
|
+
}) {
|
|
1848
|
+
const tooltipText = tooltip ?? label;
|
|
1849
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1850
|
+
ToolTip,
|
|
1851
|
+
{
|
|
1852
|
+
text: tooltipText,
|
|
1853
|
+
disabled: !tooltipText,
|
|
1854
|
+
placement: tooltipPlacement,
|
|
1855
|
+
delayShow: tooltipDelayShow,
|
|
1856
|
+
delayHide: tooltipDelayHide,
|
|
1857
|
+
tooltipClassName,
|
|
1858
|
+
tooltipStyle: { ...ROW_ACTION_DEFAULT_MENU_TOOLTIP_STYLE, ...tooltipStyle },
|
|
1859
|
+
className: showLabel ? "block w-full" : "inline-flex",
|
|
1860
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1861
|
+
"button",
|
|
1862
|
+
{
|
|
1863
|
+
type: "button",
|
|
1864
|
+
disabled,
|
|
1865
|
+
"aria-label": label,
|
|
1866
|
+
onClick: (event) => {
|
|
1867
|
+
event.stopPropagation();
|
|
1868
|
+
if (disabled) return;
|
|
1869
|
+
onClick();
|
|
1870
|
+
},
|
|
1871
|
+
className: cn(
|
|
1872
|
+
"flex items-center gap-2 text-sm transition-colors duration-150",
|
|
1873
|
+
ROW_ACTION_ITEM_TEXT_CLASS,
|
|
1874
|
+
showLabel ? "w-full rounded-xl px-3 py-2 text-left" : "justify-center rounded-md p-1",
|
|
1875
|
+
disabled ? "cursor-not-allowed opacity-50" : ROW_ACTION_ITEM_HOVER_CLASS,
|
|
1876
|
+
highlight && !danger && "text-primary-150",
|
|
1877
|
+
className
|
|
1878
|
+
),
|
|
1879
|
+
children: [
|
|
1880
|
+
Icon ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1881
|
+
Icon,
|
|
1882
|
+
{
|
|
1883
|
+
className: cn("shrink-0", iconClassName),
|
|
1884
|
+
"aria-hidden": true,
|
|
1885
|
+
size: iconSize
|
|
1886
|
+
}
|
|
1887
|
+
) : null,
|
|
1888
|
+
showLabel ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: labelClassName, children: label }) : null
|
|
1889
|
+
]
|
|
1890
|
+
}
|
|
1891
|
+
)
|
|
1892
|
+
}
|
|
1893
|
+
);
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
// src/components/row-actions/resolveActions.ts
|
|
1897
|
+
function evalFlag(flag, data) {
|
|
1898
|
+
if (typeof flag === "function") return Boolean(flag(data));
|
|
1899
|
+
return Boolean(flag);
|
|
1900
|
+
}
|
|
1901
|
+
function mergePreset(name, overrides) {
|
|
1902
|
+
if (!name) return void 0;
|
|
1903
|
+
const base = ROW_ACTION_PRESETS[name];
|
|
1904
|
+
const extra = overrides?.[name];
|
|
1905
|
+
if (!extra) return base;
|
|
1906
|
+
return { ...base, ...extra };
|
|
1907
|
+
}
|
|
1908
|
+
function resolveActions(actions, data, hasPermission, presets) {
|
|
1909
|
+
const list = typeof actions === "function" ? actions(data) : actions;
|
|
1910
|
+
return list.flatMap((action, index) => {
|
|
1911
|
+
const type = action.type ?? "item";
|
|
1912
|
+
const preset = mergePreset(action.preset, presets);
|
|
1913
|
+
const key = action.key ?? action.preset ?? `action-${index}`;
|
|
1914
|
+
const label = action.label ?? preset?.label ?? key;
|
|
1915
|
+
if (action.permission && hasPermission && !hasPermission(action.permission)) {
|
|
1916
|
+
return [];
|
|
1917
|
+
}
|
|
1918
|
+
if (evalFlag(action.hidden, data)) {
|
|
1919
|
+
return [];
|
|
1920
|
+
}
|
|
1921
|
+
const tooltip = action.tooltip === false ? void 0 : action.tooltip ?? (type === "divider" ? void 0 : label);
|
|
1922
|
+
const resolved = {
|
|
1923
|
+
key,
|
|
1924
|
+
type,
|
|
1925
|
+
label,
|
|
1926
|
+
icon: action.icon ?? preset?.icon,
|
|
1927
|
+
iconSize: action.iconSize,
|
|
1928
|
+
content: action.content,
|
|
1929
|
+
onClick: action.onClick,
|
|
1930
|
+
disabled: evalFlag(action.disabled, data),
|
|
1931
|
+
danger: action.danger ?? preset?.danger ?? false,
|
|
1932
|
+
highlight: evalFlag(action.highlight, data),
|
|
1933
|
+
tooltip,
|
|
1934
|
+
tooltipPlacement: action.tooltipPlacement,
|
|
1935
|
+
confirm: action.confirm,
|
|
1936
|
+
closeOnClick: action.closeOnClick !== false,
|
|
1937
|
+
className: action.className,
|
|
1938
|
+
iconClassName: cn(preset?.iconClassName, action.iconClassName) || void 0,
|
|
1939
|
+
labelClassName: action.labelClassName
|
|
1940
|
+
};
|
|
1941
|
+
return [resolved];
|
|
1942
|
+
});
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
// src/components/row-actions/RowActions.tsx
|
|
1946
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1947
|
+
function runAction(action, data, hide, confirmFn = confirmationAlert) {
|
|
1948
|
+
if (!action.onClick) {
|
|
1949
|
+
if (action.closeOnClick) hide?.();
|
|
1950
|
+
return;
|
|
1951
|
+
}
|
|
1952
|
+
const execute = () => action.onClick?.(data);
|
|
1953
|
+
if (action.confirm) {
|
|
1954
|
+
confirmFn?.(execute, action.confirm);
|
|
1955
|
+
} else {
|
|
1956
|
+
execute();
|
|
1957
|
+
}
|
|
1958
|
+
if (action.closeOnClick) {
|
|
1959
|
+
hide?.();
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
function RowActions({
|
|
1963
|
+
actions,
|
|
1964
|
+
data,
|
|
1965
|
+
mode = "menu",
|
|
1966
|
+
actionIcon,
|
|
1967
|
+
className,
|
|
1968
|
+
menuClassName,
|
|
1969
|
+
itemClassName,
|
|
1970
|
+
itemIconClassName,
|
|
1971
|
+
itemLabelClassName,
|
|
1972
|
+
iconSize = ROW_ACTION_DEFAULT_ICON_SIZE,
|
|
1973
|
+
triggerTooltip = "Actions",
|
|
1974
|
+
triggerAriaLabel = "Row actions",
|
|
1975
|
+
hasPermission,
|
|
1976
|
+
placement = "bottom-end",
|
|
1977
|
+
tippyProps,
|
|
1978
|
+
presets,
|
|
1979
|
+
confirmFn = confirmationAlert,
|
|
1980
|
+
tooltipPlacement = "top",
|
|
1981
|
+
tooltipDelayShow,
|
|
1982
|
+
tooltipDelayHide,
|
|
1983
|
+
tooltipClassName,
|
|
1984
|
+
tooltipStyle,
|
|
1985
|
+
renderItem,
|
|
1986
|
+
renderMenu,
|
|
1987
|
+
renderTrigger
|
|
1988
|
+
}) {
|
|
1989
|
+
const resolved = resolveActions(actions, data, hasPermission, presets);
|
|
1990
|
+
if (resolved.length === 0) {
|
|
1991
|
+
return null;
|
|
1992
|
+
}
|
|
1993
|
+
const mergedTooltipStyle = {
|
|
1994
|
+
...ROW_ACTION_DEFAULT_MENU_TOOLTIP_STYLE,
|
|
1995
|
+
...tooltipStyle
|
|
1996
|
+
};
|
|
1997
|
+
const renderDefaultItem = (action, hide, showLabel = true) => {
|
|
1998
|
+
if (action.type === "divider") {
|
|
1999
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2000
|
+
"div",
|
|
2001
|
+
{
|
|
2002
|
+
role: "separator",
|
|
2003
|
+
className: cn("my-1 h-px bg-gray-100", action.className)
|
|
2004
|
+
},
|
|
2005
|
+
action.key
|
|
2006
|
+
);
|
|
2007
|
+
}
|
|
2008
|
+
if (action.content) {
|
|
2009
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: action.className, children: action.content }, action.key);
|
|
2010
|
+
}
|
|
2011
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2012
|
+
ActionMenuItem,
|
|
2013
|
+
{
|
|
2014
|
+
label: action.label,
|
|
2015
|
+
icon: action.icon,
|
|
2016
|
+
iconSize: action.iconSize ?? iconSize,
|
|
2017
|
+
iconClassName: cn(itemIconClassName, action.iconClassName),
|
|
2018
|
+
labelClassName: cn(itemLabelClassName, action.labelClassName),
|
|
2019
|
+
tooltip: action.tooltip,
|
|
2020
|
+
tooltipPlacement: action.tooltipPlacement ?? tooltipPlacement,
|
|
2021
|
+
tooltipDelayShow,
|
|
2022
|
+
tooltipDelayHide,
|
|
2023
|
+
tooltipClassName,
|
|
2024
|
+
tooltipStyle: mergedTooltipStyle,
|
|
2025
|
+
disabled: action.disabled,
|
|
2026
|
+
danger: action.danger,
|
|
2027
|
+
highlight: action.highlight,
|
|
2028
|
+
showLabel,
|
|
2029
|
+
className: cn(itemClassName, action.className),
|
|
2030
|
+
onClick: () => runAction(action, data, hide, confirmFn)
|
|
2031
|
+
},
|
|
2032
|
+
action.key
|
|
2033
|
+
);
|
|
2034
|
+
};
|
|
2035
|
+
const renderItems = (hide, showLabel = true) => resolved.map((action) => {
|
|
2036
|
+
const defaultItem = renderDefaultItem(action, hide, showLabel);
|
|
2037
|
+
if (!renderItem) return defaultItem;
|
|
2038
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { children: renderItem(action, { data, hide: hide ?? (() => void 0), defaultItem }) }, action.key);
|
|
2039
|
+
});
|
|
2040
|
+
if (mode === "inline") {
|
|
2041
|
+
const inlineItems = renderItems(void 0, false);
|
|
2042
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: cn("flex h-full items-center justify-center gap-1", className), children: inlineItems });
|
|
2043
|
+
}
|
|
2044
|
+
const triggerTooltipText = triggerTooltip === false ? void 0 : triggerTooltip;
|
|
2045
|
+
const buildMenu = (hide) => {
|
|
2046
|
+
const defaultMenu = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2047
|
+
"div",
|
|
2048
|
+
{
|
|
2049
|
+
className: cn(
|
|
2050
|
+
"flex min-w-[180px] flex-col rounded-lg border border-gray-100 bg-white p-2 shadow-lg",
|
|
2051
|
+
menuClassName
|
|
2052
|
+
),
|
|
2053
|
+
children: renderItems(hide, true)
|
|
2054
|
+
}
|
|
2055
|
+
);
|
|
2056
|
+
if (!renderMenu) return defaultMenu;
|
|
2057
|
+
return renderMenu({
|
|
2058
|
+
data,
|
|
2059
|
+
actions: resolved,
|
|
2060
|
+
hide,
|
|
2061
|
+
defaultMenu
|
|
2062
|
+
});
|
|
2063
|
+
};
|
|
2064
|
+
if (renderTrigger) {
|
|
2065
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, { children: renderTrigger({
|
|
2066
|
+
data,
|
|
2067
|
+
actions: resolved,
|
|
2068
|
+
hide: () => void 0,
|
|
2069
|
+
defaultMenu: buildMenu(() => void 0)
|
|
2070
|
+
}) });
|
|
2071
|
+
}
|
|
2072
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2073
|
+
ToolTip,
|
|
2074
|
+
{
|
|
2075
|
+
text: triggerTooltipText,
|
|
2076
|
+
disabled: !triggerTooltipText,
|
|
2077
|
+
placement: tooltipPlacement,
|
|
2078
|
+
delayShow: tooltipDelayShow,
|
|
2079
|
+
delayHide: tooltipDelayHide,
|
|
2080
|
+
tooltipClassName,
|
|
2081
|
+
tooltipStyle,
|
|
2082
|
+
className: "flex h-full items-center justify-center",
|
|
2083
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2084
|
+
PopupCellRenderer,
|
|
2085
|
+
{
|
|
2086
|
+
params: { data },
|
|
2087
|
+
actionIcon,
|
|
2088
|
+
hideTitle: true,
|
|
2089
|
+
className,
|
|
2090
|
+
placement,
|
|
2091
|
+
tippyProps,
|
|
2092
|
+
ariaLabel: triggerAriaLabel,
|
|
2093
|
+
dropDownContent: (handleAction) => buildMenu(() => handleAction("close"))
|
|
2094
|
+
}
|
|
2095
|
+
)
|
|
2096
|
+
}
|
|
2097
|
+
);
|
|
2098
|
+
}
|
|
2099
|
+
|
|
1799
2100
|
// src/components/table-error-boundary/TableErrorBoundary.tsx
|
|
1800
2101
|
var import_react9 = require("react");
|
|
1801
2102
|
var import_fa6 = require("react-icons/fa6");
|
|
1802
|
-
var
|
|
2103
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1803
2104
|
var TableErrorBoundary = ({
|
|
1804
2105
|
isError,
|
|
1805
2106
|
isLoading = false,
|
|
@@ -1816,7 +2117,7 @@ var TableErrorBoundary = ({
|
|
|
1816
2117
|
return "Unable to load table data. Please try again.";
|
|
1817
2118
|
}, [error, errorMessage]);
|
|
1818
2119
|
if (isLoading && !isError) {
|
|
1819
|
-
return /* @__PURE__ */ (0,
|
|
2120
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1820
2121
|
"div",
|
|
1821
2122
|
{
|
|
1822
2123
|
className: cn(
|
|
@@ -1827,12 +2128,12 @@ var TableErrorBoundary = ({
|
|
|
1827
2128
|
role: "status",
|
|
1828
2129
|
"aria-live": "polite",
|
|
1829
2130
|
"aria-busy": "true",
|
|
1830
|
-
children: /* @__PURE__ */ (0,
|
|
2131
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Loader, { size: "40px" })
|
|
1831
2132
|
}
|
|
1832
2133
|
);
|
|
1833
2134
|
}
|
|
1834
2135
|
if (isError) {
|
|
1835
|
-
return /* @__PURE__ */ (0,
|
|
2136
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1836
2137
|
"div",
|
|
1837
2138
|
{
|
|
1838
2139
|
className: cn(
|
|
@@ -1843,7 +2144,7 @@ var TableErrorBoundary = ({
|
|
|
1843
2144
|
role: "alert",
|
|
1844
2145
|
"aria-live": "assertive",
|
|
1845
2146
|
children: [
|
|
1846
|
-
/* @__PURE__ */ (0,
|
|
2147
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1847
2148
|
import_fa6.FaTriangleExclamation,
|
|
1848
2149
|
{
|
|
1849
2150
|
className: "text-red-500",
|
|
@@ -1851,11 +2152,11 @@ var TableErrorBoundary = ({
|
|
|
1851
2152
|
"aria-hidden": true
|
|
1852
2153
|
}
|
|
1853
2154
|
),
|
|
1854
|
-
/* @__PURE__ */ (0,
|
|
1855
|
-
/* @__PURE__ */ (0,
|
|
1856
|
-
/* @__PURE__ */ (0,
|
|
2155
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "max-w-md space-y-1", children: [
|
|
2156
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-base font-semibold text-gray-800", children: "Failed to load data" }),
|
|
2157
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-sm text-gray-600", children: message })
|
|
1857
2158
|
] }),
|
|
1858
|
-
refetch && /* @__PURE__ */ (0,
|
|
2159
|
+
refetch && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1859
2160
|
"button",
|
|
1860
2161
|
{
|
|
1861
2162
|
type: "button",
|
|
@@ -1863,7 +2164,7 @@ var TableErrorBoundary = ({
|
|
|
1863
2164
|
disabled: isLoading,
|
|
1864
2165
|
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",
|
|
1865
2166
|
children: [
|
|
1866
|
-
/* @__PURE__ */ (0,
|
|
2167
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_fa6.FaArrowsRotate, { className: cn(isLoading && "animate-spin") }),
|
|
1867
2168
|
isLoading ? "Retrying..." : "Try again"
|
|
1868
2169
|
]
|
|
1869
2170
|
}
|
|
@@ -1872,10 +2173,11 @@ var TableErrorBoundary = ({
|
|
|
1872
2173
|
}
|
|
1873
2174
|
);
|
|
1874
2175
|
}
|
|
1875
|
-
return /* @__PURE__ */ (0,
|
|
2176
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children });
|
|
1876
2177
|
};
|
|
1877
2178
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1878
2179
|
0 && (module.exports = {
|
|
2180
|
+
ActionMenuItem,
|
|
1879
2181
|
CardSkeleton,
|
|
1880
2182
|
CustomCellEditor,
|
|
1881
2183
|
CustomPagination,
|
|
@@ -1884,13 +2186,20 @@ var TableErrorBoundary = ({
|
|
|
1884
2186
|
Loader,
|
|
1885
2187
|
Modal,
|
|
1886
2188
|
PopupCellRenderer,
|
|
2189
|
+
ROW_ACTION_DEFAULT_ICON_SIZE,
|
|
2190
|
+
ROW_ACTION_DEFAULT_MENU_TOOLTIP_STYLE,
|
|
2191
|
+
ROW_ACTION_ITEM_HOVER_CLASS,
|
|
2192
|
+
ROW_ACTION_ITEM_TEXT_CLASS,
|
|
2193
|
+
ROW_ACTION_PRESETS,
|
|
1887
2194
|
ResetColumnsButton,
|
|
1888
2195
|
ResetFiltersButton,
|
|
2196
|
+
RowActions,
|
|
1889
2197
|
SearchInput,
|
|
1890
2198
|
TableErrorBoundary,
|
|
1891
2199
|
TableLayoutToolbarControls,
|
|
1892
2200
|
ToolTip,
|
|
1893
2201
|
TooltipText,
|
|
1894
|
-
dropdownStyles
|
|
2202
|
+
dropdownStyles,
|
|
2203
|
+
resolveActions
|
|
1895
2204
|
});
|
|
1896
2205
|
//# sourceMappingURL=index.js.map
|