@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.
@@ -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;
@@ -129,6 +129,11 @@ interface SearchInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "
129
129
  debounceDelay?: number;
130
130
  customIcon?: ReactNode | null;
131
131
  defaultValue?: string;
132
+ /**
133
+ * Pagination param reset to page 1 when the query changes. Defaults to "page";
134
+ * match `CustomPagination`'s `paramNames.page` if the screen overrides it.
135
+ */
136
+ pageParam?: string;
132
137
  }
133
138
  interface DropdownFilterProps<Option extends Record<string, unknown>> extends Omit<Props<Option, false>, "value" | "onChange" | "options" | "styles" | "name"> {
134
139
  /** URL search param key synced with the selected option. */
@@ -142,13 +147,18 @@ interface DropdownFilterProps<Option extends Record<string, unknown>> extends Om
142
147
  borderRadius?: string;
143
148
  /** When true, persists the selected value in localStorage under `name`. */
144
149
  saveToLocalStorage?: boolean;
150
+ /**
151
+ * Pagination param reset to page 1 when the selection changes. Defaults to
152
+ * "page"; match `CustomPagination`'s `paramNames.page` if the screen overrides it.
153
+ */
154
+ pageParam?: string;
145
155
  }
146
156
 
147
- declare function DropdownFilter<Option extends Record<string, unknown>>({ name, valueKey, options, placeholder, borderRadius, className, isClearable, isSearchable, isDisabled, isLoading, saveToLocalStorage, ...otherProps }: DropdownFilterProps<Option>): react.JSX.Element;
157
+ declare function DropdownFilter<Option extends Record<string, unknown>>({ name, valueKey, options, placeholder, borderRadius, className, isClearable, isSearchable, isDisabled, isLoading, saveToLocalStorage, pageParam, ...otherProps }: DropdownFilterProps<Option>): react.JSX.Element;
148
158
 
149
159
  declare function ResetFiltersButton({ label, showLabel, icon, variant, className, onReset, disabled, }: ResetFiltersButtonProps): react.JSX.Element;
150
160
 
151
- declare function SearchInput({ placeholder, searchBtn, searchClassName, searchWrapperClass, searchIconClassName, defaultParam, showIcon, name, type, liveSearch, debounceDelay, customIcon, defaultValue, ...props }: SearchInputProps): react.JSX.Element;
161
+ declare function SearchInput({ placeholder, searchBtn, searchClassName, searchWrapperClass, searchIconClassName, defaultParam, showIcon, name, type, liveSearch, debounceDelay, customIcon, defaultValue, pageParam, ...props }: SearchInputProps): react.JSX.Element;
152
162
 
153
163
  declare const dropdownStyles: <Option>(_borderRadius: string) => StylesConfig<Option, false>;
154
164
 
@@ -307,6 +317,8 @@ interface PopupCellRendererProps<TRow = unknown> {
307
317
  params?: PopupCellRendererParams<TRow>;
308
318
  onAction?: (actionType: string, rowData: TRow | undefined, hide: () => void) => void;
309
319
  placement?: TippyProps["placement"];
320
+ /** Default `"Row actions"`. */
321
+ ariaLabel?: string;
310
322
  tippyProps?: Omit<Partial<TippyProps>, "children" | "content" | "visible" | "placement">;
311
323
  }
312
324
 
@@ -317,7 +329,147 @@ interface PopupCellRendererProps<TRow = unknown> {
317
329
  * `import "tippy.js/dist/tippy.css"`
318
330
  * `import "tippy.js/themes/light.css"`
319
331
  */
320
- 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
+ };
367
+ type RowActionsList<TRow = unknown> = RowAction<TRow>[] | ((data: TRow | undefined) => RowAction<TRow>[]);
368
+ interface RowActionsRenderContext<TRow = unknown> {
369
+ data: TRow | undefined;
370
+ actions: ResolvedRowAction<TRow>[];
371
+ hide: () => void;
372
+ defaultMenu: ReactNode;
373
+ }
374
+ interface RowActionItemRenderContext<TRow = unknown> {
375
+ data: TRow | undefined;
376
+ hide: () => void;
377
+ defaultItem: ReactNode;
378
+ }
379
+ interface RowActionsProps<TRow = unknown> {
380
+ actions: RowActionsList<TRow>;
381
+ data?: TRow;
382
+ mode?: RowActionsMode;
383
+ /** Override the default vertical 3-dots trigger. */
384
+ actionIcon?: IconType;
385
+ /** Extra classes on the trigger button (merged with defaults). */
386
+ className?: string;
387
+ /** Extra classes on the dropdown panel (merged with defaults). */
388
+ menuClassName?: string;
389
+ /**
390
+ * Extra classes on every menu/inline item (merged after defaults).
391
+ * Override hover here, e.g. `hover:bg-gray-100 hover:text-gray-800`.
392
+ */
393
+ itemClassName?: string;
394
+ itemIconClassName?: string;
395
+ /** Default `16`. */
396
+ iconSize?: number;
397
+ /** Default `"Actions"`. Pass `false` to hide. */
398
+ triggerTooltip?: string | false;
399
+ triggerAriaLabel?: string;
400
+ hasPermission?: (permission: string) => boolean;
401
+ placement?: TippyProps["placement"];
402
+ tippyProps?: PopupCellRendererProps<TRow>["tippyProps"];
403
+ /** Override default `Fa*` preset icons/labels for this instance. */
404
+ presets?: Partial<Record<RowActionPresetName, Partial<RowActionPreset>>>;
405
+ /** Default: shared `confirmationAlert`. */
406
+ confirmFn?: RowActionConfirmFn;
407
+ tooltipPlacement?: PlacesType;
408
+ tooltipDelayShow?: number;
409
+ tooltipDelayHide?: number;
410
+ tooltipClassName?: string;
411
+ tooltipStyle?: CSSProperties;
412
+ /** Replace one item’s markup. */
413
+ renderItem?: (action: ResolvedRowAction<TRow>, ctx: RowActionItemRenderContext<TRow>) => ReactNode;
414
+ /** Replace the dropdown panel. Still opened by the default trigger unless `renderTrigger` is set. */
415
+ renderMenu?: (ctx: RowActionsRenderContext<TRow>) => ReactNode;
416
+ /** Replace trigger + popup engine entirely (e.g. a custom popover). */
417
+ renderTrigger?: (ctx: Omit<RowActionsRenderContext<TRow>, "hide"> & {
418
+ hide: () => void;
419
+ }) => ReactNode;
420
+ }
421
+ interface ActionMenuItemProps {
422
+ label: string;
423
+ icon?: IconType;
424
+ iconSize?: number;
425
+ iconClassName?: string;
426
+ tooltip?: string;
427
+ tooltipPlacement?: PlacesType;
428
+ tooltipDelayShow?: number;
429
+ tooltipDelayHide?: number;
430
+ tooltipClassName?: string;
431
+ tooltipStyle?: CSSProperties;
432
+ disabled?: boolean;
433
+ danger?: boolean;
434
+ highlight?: boolean;
435
+ showLabel?: boolean;
436
+ className?: string;
437
+ onClick: () => void;
438
+ }
439
+ interface ResolvedRowAction<TRow = unknown> {
440
+ key: string;
441
+ type: RowActionItemType;
442
+ label: string;
443
+ icon?: IconType;
444
+ iconSize?: number;
445
+ content?: ReactNode;
446
+ onClick?: (row: TRow | undefined) => void;
447
+ disabled: boolean;
448
+ danger: boolean;
449
+ highlight: boolean;
450
+ tooltip?: string;
451
+ tooltipPlacement?: PlacesType;
452
+ confirm?: ConfirmationAlertOptions;
453
+ closeOnClick: boolean;
454
+ className?: string;
455
+ }
456
+ interface RowActionPreset {
457
+ label: string;
458
+ icon: IconType;
459
+ danger?: boolean;
460
+ }
461
+
462
+ declare function RowActions<TRow = unknown>({ actions, data, mode, actionIcon, className, menuClassName, itemClassName, itemIconClassName, iconSize, triggerTooltip, triggerAriaLabel, hasPermission, placement, tippyProps, presets, confirmFn, tooltipPlacement, tooltipDelayShow, tooltipDelayHide, tooltipClassName, tooltipStyle, renderItem, renderMenu, renderTrigger, }: RowActionsProps<TRow>): react.JSX.Element | null;
463
+
464
+ declare function ActionMenuItem({ label, icon: Icon, iconSize, iconClassName, tooltip, tooltipPlacement, tooltipDelayShow, tooltipDelayHide, tooltipClassName, tooltipStyle, disabled, danger, highlight, showLabel, className, onClick, }: ActionMenuItemProps): react.JSX.Element;
465
+
466
+ /** Settings-app hover: peach bg `#FFF1EB` + orange text (`primary-50` / `primary-150`). */
467
+ declare const ROW_ACTION_ITEM_HOVER_CLASS = "hover:bg-primary-50 hover:text-primary-150";
468
+ declare const ROW_ACTION_DEFAULT_ICON_SIZE = 16;
469
+ declare const ROW_ACTION_DEFAULT_MENU_TOOLTIP_STYLE: CSSProperties;
470
+ declare const ROW_ACTION_PRESETS: Record<RowActionPresetName, RowActionPreset>;
471
+
472
+ declare function resolveActions<TRow>(actions: RowActionsList<TRow>, data: TRow | undefined, hasPermission?: (permission: string) => boolean, presets?: Partial<Record<RowActionPresetName, Partial<RowActionPreset>>>): ResolvedRowAction<TRow>[];
321
473
 
322
474
  type TableErrorBoundaryProps = {
323
475
  isError: boolean;
@@ -332,4 +484,4 @@ type TableErrorBoundaryProps = {
332
484
 
333
485
  declare const TableErrorBoundary: react__default.FC<TableErrorBoundaryProps>;
334
486
 
335
- 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 };
487
+ 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_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 };