@appcorp/shadcn 1.1.16 → 1.1.18
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/components/enhanced-checkbox.d.ts +1 -0
- package/components/enhanced-checkbox.js +2 -2
- package/components/enhanced-combobox.d.ts +46 -1
- package/components/enhanced-combobox.js +12 -12
- package/components/enhanced-dropzone.d.ts +45 -3
- package/components/enhanced-dropzone.js +14 -14
- package/components/enhanced-input.d.ts +16 -0
- package/components/enhanced-input.js +7 -7
- package/components/enhanced-label.d.ts +7 -1
- package/components/enhanced-label.js +3 -3
- package/components/enhanced-select.d.ts +30 -1
- package/components/enhanced-select.js +4 -4
- package/components/enhanced-switch.d.ts +21 -0
- package/components/enhanced-switch.js +9 -9
- package/components/enhanced-table-footer-action.d.ts +10 -0
- package/components/enhanced-table-footer-action.js +6 -6
- package/components/enhanced-table-footer-page.d.ts +14 -0
- package/components/enhanced-table-footer-page.js +12 -12
- package/components/enhanced-table-footer-pagination.d.ts +12 -0
- package/components/enhanced-table-footer-pagination.js +8 -6
- package/components/enhanced-table-header-action.d.ts +11 -0
- package/components/enhanced-table-header-action.js +7 -5
- package/components/enhanced-table-header-search.d.ts +15 -0
- package/components/enhanced-table-header-search.js +5 -4
- package/components/enhanced-table.d.ts +112 -0
- package/components/enhanced-table.js +83 -15
- package/components/enhanced-textarea.d.ts +16 -0
- package/components/enhanced-textarea.js +7 -7
- package/package.json +1 -1
|
@@ -22,17 +22,17 @@ var react_1 = __importDefault(require("react"));
|
|
|
22
22
|
var lucide_react_1 = require("lucide-react");
|
|
23
23
|
var button_1 = require("./ui/button");
|
|
24
24
|
var EnhancedTableFooterAction = function (_a) {
|
|
25
|
-
var handleNextOnClick = _a.handleNextOnClick, handlePreviousOnClick = _a.handlePreviousOnClick, isNextDisabled = _a.isNextDisabled, isPreviousDisabled = _a.isPreviousDisabled, _b = _a.isRTL, isRTL = _b === void 0 ? false : _b, loading = _a.loading, _c = _a.nextPageLabel, nextPageLabel = _c === void 0 ? "Next page" : _c, _d = _a.previousPageLabel, previousPageLabel = _d === void 0 ? "Previous page" : _d;
|
|
25
|
+
var handleNextOnClick = _a.handleNextOnClick, handlePreviousOnClick = _a.handlePreviousOnClick, isNextDisabled = _a.isNextDisabled, isPreviousDisabled = _a.isPreviousDisabled, _b = _a.isRTL, isRTL = _b === void 0 ? false : _b, loading = _a.loading, _c = _a.nextPageLabel, nextPageLabel = _c === void 0 ? "Next page" : _c, _d = _a.previousPageLabel, previousPageLabel = _d === void 0 ? "Previous page" : _d, testIdWrapper = _a.testIdWrapper, testIdPrevious = _a.testIdPrevious, testIdNext = _a.testIdNext, testIdPreviousIcon = _a.testIdPreviousIcon, testIdNextIcon = _a.testIdNextIcon;
|
|
26
26
|
// In RTL, arrows should be swapped:
|
|
27
27
|
// Previous should show → (ChevronRight) as it goes to the right in RTL reading order
|
|
28
28
|
// Next should show ← (ChevronLeft) as it goes to the left in RTL reading order
|
|
29
29
|
var PreviousIcon = isRTL ? lucide_react_1.ChevronRight : lucide_react_1.ChevronLeft;
|
|
30
30
|
var NextIcon = isRTL ? lucide_react_1.ChevronLeft : lucide_react_1.ChevronRight;
|
|
31
|
-
return (react_1.default.createElement("div", { className: "flex gap-1 ".concat(isRTL ? "flex-row-reverse" : "") },
|
|
32
|
-
react_1.default.createElement(button_1.Button, { variant: "outline", size: "icon", onClick: handlePreviousOnClick, disabled: isPreviousDisabled || loading, "aria-label": previousPageLabel, title: previousPageLabel, className: "".concat(isRTL ? "rotate-180" : "") },
|
|
33
|
-
react_1.default.createElement(PreviousIcon, { className: "h-4 w-4" })),
|
|
34
|
-
react_1.default.createElement(button_1.Button, { variant: "outline", size: "icon", onClick: handleNextOnClick, disabled: isNextDisabled || loading, "aria-label": nextPageLabel, title: nextPageLabel, className: "".concat(isRTL ? "rotate-180" : "") },
|
|
35
|
-
react_1.default.createElement(NextIcon, { className: "h-4 w-4" }))));
|
|
31
|
+
return (react_1.default.createElement("div", { className: "flex gap-1 ".concat(isRTL ? "flex-row-reverse" : ""), "data-testid": testIdWrapper },
|
|
32
|
+
react_1.default.createElement(button_1.Button, { variant: "outline", size: "icon", "data-testid": testIdPrevious, onClick: handlePreviousOnClick, disabled: isPreviousDisabled || loading, "aria-label": previousPageLabel, title: previousPageLabel, className: "".concat(isRTL ? "rotate-180" : "") },
|
|
33
|
+
react_1.default.createElement(PreviousIcon, { className: "h-4 w-4", "data-testid": testIdPreviousIcon })),
|
|
34
|
+
react_1.default.createElement(button_1.Button, { variant: "outline", size: "icon", "data-testid": testIdNext, onClick: handleNextOnClick, disabled: isNextDisabled || loading, "aria-label": nextPageLabel, title: nextPageLabel, className: "".concat(isRTL ? "rotate-180" : "") },
|
|
35
|
+
react_1.default.createElement(NextIcon, { className: "h-4 w-4", "data-testid": testIdNextIcon }))));
|
|
36
36
|
};
|
|
37
37
|
exports.EnhancedTableFooterAction = EnhancedTableFooterAction;
|
|
38
38
|
// ============================================================================
|
|
@@ -29,6 +29,20 @@ interface EnhancedTableFooterPageProps {
|
|
|
29
29
|
loadingLabel?: string;
|
|
30
30
|
/** Optional CSS classes for custom styling */
|
|
31
31
|
className?: string;
|
|
32
|
+
/** `data-testid` for the root wrapper element. */
|
|
33
|
+
testIdWrapper?: string;
|
|
34
|
+
/** `data-testid` for the current page number element. */
|
|
35
|
+
testIdCurrent?: string;
|
|
36
|
+
/** `data-testid` for the page label element (the word "Page"). */
|
|
37
|
+
testIdPageLabel?: string;
|
|
38
|
+
/** `data-testid` for the "of" label element. */
|
|
39
|
+
testIdOfLabel?: string;
|
|
40
|
+
/** `data-testid` for the total pages element. */
|
|
41
|
+
testIdTotal?: string;
|
|
42
|
+
/** `data-testid` for the loading wrapper when `loading` is true. */
|
|
43
|
+
testIdLoadingWrapper?: string;
|
|
44
|
+
/** `data-testid` for the loading spinner (progressbar). */
|
|
45
|
+
testIdLoadingSpinner?: string;
|
|
32
46
|
}
|
|
33
47
|
export declare const EnhancedTableFooterPage: FC<EnhancedTableFooterPageProps>;
|
|
34
48
|
export {};
|
|
@@ -19,23 +19,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
exports.EnhancedTableFooterPage = void 0;
|
|
20
20
|
var react_1 = __importDefault(require("react"));
|
|
21
21
|
var EnhancedTableFooterPage = function (_a) {
|
|
22
|
-
var currentPage = _a.currentPage, _b = _a.isRTL, isRTL = _b === void 0 ? false : _b, loading = _a.loading, _c = _a.loadingLabel, loadingLabel = _c === void 0 ? "Loading" : _c, _d = _a.ofLabel, ofLabel = _d === void 0 ? "of" : _d, _e = _a.pageLabel, pageLabel = _e === void 0 ? "Page" : _e, totalPages = _a.totalPages, _f = _a.className, className = _f === void 0 ? "" : _f;
|
|
23
|
-
return (react_1.default.createElement("div", { className: "flex items-center gap-2 ".concat(isRTL ? "rtl" : "ltr", " ").concat(className), dir: isRTL ? "rtl" : "ltr", role: "status", "aria-live": "polite", "aria-label": "".concat(pageLabel, " ").concat(currentPage, " ").concat(ofLabel, " ").concat(totalPages) },
|
|
22
|
+
var currentPage = _a.currentPage, _b = _a.isRTL, isRTL = _b === void 0 ? false : _b, loading = _a.loading, _c = _a.loadingLabel, loadingLabel = _c === void 0 ? "Loading" : _c, _d = _a.ofLabel, ofLabel = _d === void 0 ? "of" : _d, _e = _a.pageLabel, pageLabel = _e === void 0 ? "Page" : _e, totalPages = _a.totalPages, _f = _a.className, className = _f === void 0 ? "" : _f, testIdWrapper = _a.testIdWrapper, testIdCurrent = _a.testIdCurrent, testIdPageLabel = _a.testIdPageLabel, testIdOfLabel = _a.testIdOfLabel, testIdTotal = _a.testIdTotal, testIdLoadingWrapper = _a.testIdLoadingWrapper, testIdLoadingSpinner = _a.testIdLoadingSpinner;
|
|
23
|
+
return (react_1.default.createElement("div", { className: "flex items-center gap-2 ".concat(isRTL ? "rtl" : "ltr", " ").concat(className), dir: isRTL ? "rtl" : "ltr", role: "status", "aria-live": "polite", "aria-label": "".concat(pageLabel, " ").concat(currentPage, " ").concat(ofLabel, " ").concat(totalPages), "data-testid": testIdWrapper },
|
|
24
24
|
react_1.default.createElement("span", { className: "text-sm text-muted-foreground" }, isRTL ? (
|
|
25
25
|
// RTL layout: Numbers read right-to-left but maintain logical order
|
|
26
26
|
react_1.default.createElement("span", { className: "inline-flex items-center gap-1" },
|
|
27
|
-
react_1.default.createElement("span",
|
|
28
|
-
react_1.default.createElement("span",
|
|
29
|
-
react_1.default.createElement("span",
|
|
30
|
-
react_1.default.createElement("span",
|
|
27
|
+
react_1.default.createElement("span", { "data-testid": testIdTotal }, totalPages),
|
|
28
|
+
react_1.default.createElement("span", { "data-testid": testIdOfLabel }, ofLabel),
|
|
29
|
+
react_1.default.createElement("span", { "data-testid": testIdCurrent }, currentPage),
|
|
30
|
+
react_1.default.createElement("span", { "data-testid": testIdPageLabel }, pageLabel))) : (
|
|
31
31
|
// LTR layout: "Page currentPage of totalPages"
|
|
32
32
|
react_1.default.createElement("span", { className: "inline-flex items-center gap-1" },
|
|
33
|
-
react_1.default.createElement("span",
|
|
34
|
-
react_1.default.createElement("span",
|
|
35
|
-
react_1.default.createElement("span",
|
|
36
|
-
react_1.default.createElement("span",
|
|
37
|
-
loading && (react_1.default.createElement("div", { className: "flex items-center gap-2 ".concat(isRTL ? "order-first" : "order-last"), "aria-label": loadingLabel },
|
|
38
|
-
react_1.default.createElement("div", { className: "w-4 h-4 border-2 border-primary border-t-transparent rounded-full animate-spin", role: "progressbar", "aria-label": loadingLabel })))));
|
|
33
|
+
react_1.default.createElement("span", { "data-testid": testIdPageLabel }, pageLabel),
|
|
34
|
+
react_1.default.createElement("span", { "data-testid": testIdCurrent }, currentPage),
|
|
35
|
+
react_1.default.createElement("span", { "data-testid": testIdOfLabel }, ofLabel),
|
|
36
|
+
react_1.default.createElement("span", { "data-testid": testIdTotal }, totalPages)))),
|
|
37
|
+
loading && (react_1.default.createElement("div", { className: "flex items-center gap-2 ".concat(isRTL ? "order-first" : "order-last"), "aria-label": loadingLabel, "data-testid": testIdLoadingWrapper },
|
|
38
|
+
react_1.default.createElement("div", { className: "w-4 h-4 border-2 border-primary border-t-transparent rounded-full animate-spin", role: "progressbar", "aria-label": loadingLabel, "data-testid": testIdLoadingSpinner })))));
|
|
39
39
|
};
|
|
40
40
|
exports.EnhancedTableFooterPage = EnhancedTableFooterPage;
|
|
41
41
|
// ============================================================================
|
|
@@ -33,6 +33,18 @@ interface EnhancedTableFooterPageProps {
|
|
|
33
33
|
rowsPerPageLabel?: string;
|
|
34
34
|
/** Optional CSS classes for custom styling */
|
|
35
35
|
className?: string;
|
|
36
|
+
/** `data-testid` for the root pagination wrapper element. */
|
|
37
|
+
testIdWrapper?: string;
|
|
38
|
+
/** `data-testid` for the label element. */
|
|
39
|
+
testIdLabel?: string;
|
|
40
|
+
/** `data-testid` for the SelectTrigger element. */
|
|
41
|
+
testIdSelectTrigger?: string;
|
|
42
|
+
/** `data-testid` for the SelectValue element (shows current value). */
|
|
43
|
+
testIdSelectValue?: string;
|
|
44
|
+
/** `data-testid` for the SelectContent container (popup). */
|
|
45
|
+
testIdSelectContent?: string;
|
|
46
|
+
/** Prefix used for option test ids: `${prefix}-${option}`. */
|
|
47
|
+
testIdOptionPrefix?: string;
|
|
36
48
|
}
|
|
37
49
|
export declare const EnhancedTableFooterPagination: FC<EnhancedTableFooterPageProps>;
|
|
38
50
|
export {};
|
|
@@ -21,15 +21,17 @@ exports.EnhancedTableFooterPagination = void 0;
|
|
|
21
21
|
var select_1 = require("./ui/select");
|
|
22
22
|
var react_1 = __importDefault(require("react"));
|
|
23
23
|
var EnhancedTableFooterPagination = function (_a) {
|
|
24
|
-
var handleOnSelect = _a.handleOnSelect, _b = _a.isRTL, isRTL = _b === void 0 ? false : _b, listOptions = _a.listOptions, loading = _a.loading, nodeSelectKey = _a.nodeSelectKey, pageLimit = _a.pageLimit, _c = _a.rowsPerPageLabel, rowsPerPageLabel = _c === void 0 ? "Rows per page:" : _c, _d = _a.className, className = _d === void 0 ? "" : _d;
|
|
25
|
-
return (react_1.default.createElement("div", { className: "flex items-center gap-2 ".concat(className), dir: isRTL ? "rtl" : "ltr" },
|
|
26
|
-
react_1.default.createElement("label", { htmlFor: "page-limit-select-".concat(nodeSelectKey), className: "text-sm text-muted-foreground whitespace-nowrap" }, rowsPerPageLabel),
|
|
24
|
+
var handleOnSelect = _a.handleOnSelect, _b = _a.isRTL, isRTL = _b === void 0 ? false : _b, listOptions = _a.listOptions, loading = _a.loading, nodeSelectKey = _a.nodeSelectKey, pageLimit = _a.pageLimit, _c = _a.rowsPerPageLabel, rowsPerPageLabel = _c === void 0 ? "Rows per page:" : _c, _d = _a.className, className = _d === void 0 ? "" : _d, testIdWrapper = _a.testIdWrapper, testIdLabel = _a.testIdLabel, testIdSelectTrigger = _a.testIdSelectTrigger, testIdSelectValue = _a.testIdSelectValue, testIdSelectContent = _a.testIdSelectContent, testIdOptionPrefix = _a.testIdOptionPrefix;
|
|
25
|
+
return (react_1.default.createElement("div", { className: "flex items-center gap-2 ".concat(className), dir: isRTL ? "rtl" : "ltr", "data-testid": testIdWrapper },
|
|
26
|
+
react_1.default.createElement("label", { htmlFor: "page-limit-select-".concat(nodeSelectKey), className: "text-sm text-muted-foreground whitespace-nowrap", "data-testid": testIdLabel }, rowsPerPageLabel),
|
|
27
27
|
react_1.default.createElement(select_1.Select, { value: String(pageLimit), onValueChange: function (value) {
|
|
28
28
|
return handleOnSelect(nodeSelectKey, { option: value });
|
|
29
29
|
}, disabled: loading },
|
|
30
|
-
react_1.default.createElement(select_1.SelectTrigger, { id: "page-limit-select-".concat(nodeSelectKey), className: "w-20", "aria-label": "".concat(rowsPerPageLabel, " ").concat(pageLimit) },
|
|
31
|
-
react_1.default.createElement(select_1.SelectValue,
|
|
32
|
-
react_1.default.createElement(select_1.SelectContent,
|
|
30
|
+
react_1.default.createElement(select_1.SelectTrigger, { id: "page-limit-select-".concat(nodeSelectKey), className: "w-20", "aria-label": "".concat(rowsPerPageLabel, " ").concat(pageLimit), "data-testid": testIdSelectTrigger },
|
|
31
|
+
react_1.default.createElement(select_1.SelectValue, { "data-testid": testIdSelectValue })),
|
|
32
|
+
react_1.default.createElement(select_1.SelectContent, { "data-testid": testIdSelectContent }, listOptions.map(function (option) { return (react_1.default.createElement(select_1.SelectItem, { key: option.option, value: option.option, "aria-label": "".concat(option.option, " rows per page"), "data-testid": testIdOptionPrefix
|
|
33
|
+
? "".concat(testIdOptionPrefix, "-").concat(option.option)
|
|
34
|
+
: undefined }, option.option)); })))));
|
|
33
35
|
};
|
|
34
36
|
exports.EnhancedTableFooterPagination = EnhancedTableFooterPagination;
|
|
35
37
|
// ============================================================================
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
2
|
import { HeaderAction } from "./enhanced-table";
|
|
3
3
|
interface EnhancedTableHeaderActionProps {
|
|
4
|
+
/** Header-level actions to show as buttons in the table header. */
|
|
4
5
|
headerActions: HeaderAction[];
|
|
6
|
+
/** Number of active filters (used to show a badge on filter buttons). */
|
|
5
7
|
numberOfFilters?: number;
|
|
8
|
+
/** Callback invoked when the user clears all filters (clear icon). */
|
|
6
9
|
onClearFilters?: () => void;
|
|
10
|
+
/** `data-testid` for the wrapper containing all header action buttons. */
|
|
11
|
+
testIdWrapper?: string;
|
|
12
|
+
/** `data-testid` prefix for individual action buttons: `${prefix}-${index}`. */
|
|
13
|
+
testIdActionPrefix?: string;
|
|
14
|
+
/** `data-testid` for the badge that shows number of filters. */
|
|
15
|
+
testIdFilterBadge?: string;
|
|
16
|
+
/** `data-testid` for the clear-filters button/icon. */
|
|
17
|
+
testIdClearFilters?: string;
|
|
7
18
|
}
|
|
8
19
|
export declare const EnhancedTableHeaderAction: FC<EnhancedTableHeaderActionProps>;
|
|
9
20
|
export {};
|
|
@@ -9,8 +9,8 @@ var lucide_react_1 = require("lucide-react");
|
|
|
9
9
|
var button_1 = require("./ui/button");
|
|
10
10
|
var badge_1 = require("./ui/badge");
|
|
11
11
|
var EnhancedTableHeaderAction = function (_a) {
|
|
12
|
-
var headerActions = _a.headerActions, numberOfFilters = _a.numberOfFilters, onClearFilters = _a.onClearFilters;
|
|
13
|
-
return (react_1.default.createElement(react_1.default.Fragment, null, headerActions.length > 0 && (react_1.default.createElement("div", { className: "flex gap-2" }, headerActions
|
|
12
|
+
var headerActions = _a.headerActions, numberOfFilters = _a.numberOfFilters, onClearFilters = _a.onClearFilters, testIdWrapper = _a.testIdWrapper, testIdActionPrefix = _a.testIdActionPrefix, testIdFilterBadge = _a.testIdFilterBadge, testIdClearFilters = _a.testIdClearFilters;
|
|
13
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, headerActions.length > 0 && (react_1.default.createElement("div", { className: "flex gap-2", "data-testid": testIdWrapper }, headerActions
|
|
14
14
|
.filter(function (action) { return action.enabled !== false; })
|
|
15
15
|
.sort(function (a, b) { return (a.order || 0) - (b.order || 0); })
|
|
16
16
|
.map(function (action, index) {
|
|
@@ -21,15 +21,17 @@ var EnhancedTableHeaderAction = function (_a) {
|
|
|
21
21
|
typeof numberOfFilters === "number" &&
|
|
22
22
|
numberOfFilters > 0;
|
|
23
23
|
return (react_1.default.createElement("div", { key: action.id || action.key || index, className: "relative" },
|
|
24
|
-
react_1.default.createElement(button_1.Button, { variant: action.variant || "default",
|
|
24
|
+
react_1.default.createElement(button_1.Button, { variant: action.variant || "default", "data-testid": testIdActionPrefix
|
|
25
|
+
? "".concat(testIdActionPrefix, "-").concat(index)
|
|
26
|
+
: undefined, onClick: function () {
|
|
25
27
|
if (action.onClick)
|
|
26
28
|
action.onClick();
|
|
27
29
|
if (action.handleOnClick)
|
|
28
30
|
action.handleOnClick();
|
|
29
31
|
} }, action.label),
|
|
30
32
|
showFilterIndicators && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
31
|
-
react_1.default.createElement(badge_1.Badge, { variant: "secondary", className: "absolute -top-2 -right-2 h-5 w-5 flex items-center justify-center p-0 text-xs rounded-full" }, numberOfFilters),
|
|
32
|
-
onClearFilters && (react_1.default.createElement("button", { onClick: function (e) {
|
|
33
|
+
react_1.default.createElement(badge_1.Badge, { variant: "secondary", className: "absolute -top-2 -right-2 h-5 w-5 flex items-center justify-center p-0 text-xs rounded-full", "data-testid": testIdFilterBadge }, numberOfFilters),
|
|
34
|
+
onClearFilters && (react_1.default.createElement("button", { "data-testid": testIdClearFilters, onClick: function (e) {
|
|
33
35
|
e.stopPropagation();
|
|
34
36
|
onClearFilters();
|
|
35
37
|
}, className: "absolute -top-2 -left-2 h-5 w-5 rounded-full bg-muted hover:bg-muted/80 flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors", "aria-label": "Clear all filters" },
|
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
2
|
interface EnhancedTableHeaderSearchProps {
|
|
3
|
+
/** Called when the search input changes. */
|
|
3
4
|
handleSearchInput: (key: string, value: string) => void;
|
|
5
|
+
/** Whether the search area is currently loading. */
|
|
4
6
|
loading: boolean;
|
|
7
|
+
/** Disable the search input. */
|
|
5
8
|
searchDisabled?: boolean;
|
|
9
|
+
/** Enable or disable rendering of the search field. */
|
|
6
10
|
searchEnabled?: boolean;
|
|
11
|
+
/** `id` applied to the native search input. */
|
|
7
12
|
searchId?: string;
|
|
13
|
+
/** Placeholder text for the search input. */
|
|
8
14
|
searchPlaceholder?: string;
|
|
15
|
+
/** Controlled search input value. */
|
|
9
16
|
searchValue: string;
|
|
17
|
+
/** `data-testid` for the wrapper containing the search input. */
|
|
18
|
+
testIdWrapper?: string;
|
|
19
|
+
/** `data-testid` for the native input element. */
|
|
20
|
+
testIdInput?: string;
|
|
21
|
+
/** `data-testid` for the search icon element. */
|
|
22
|
+
testIdIcon?: string;
|
|
23
|
+
/** `data-testid` for a potential loading indicator. */
|
|
24
|
+
testIdLoading?: string;
|
|
10
25
|
}
|
|
11
26
|
export declare const EnhancedTableHeaderSearch: FC<EnhancedTableHeaderSearchProps>;
|
|
12
27
|
export {};
|
|
@@ -8,10 +8,11 @@ var react_1 = __importDefault(require("react"));
|
|
|
8
8
|
var lucide_react_1 = require("lucide-react");
|
|
9
9
|
var input_1 = require("./ui/input");
|
|
10
10
|
var EnhancedTableHeaderSearch = function (_a) {
|
|
11
|
-
var handleSearchInput = _a.handleSearchInput, loading = _a.loading, _b = _a.searchDisabled, searchDisabled = _b === void 0 ? false : _b, _c = _a.searchEnabled, searchEnabled = _c === void 0 ? true : _c, _d = _a.searchId, searchId = _d === void 0 ? "table-search" : _d, _e = _a.searchPlaceholder, searchPlaceholder = _e === void 0 ? "Search..." : _e, searchValue = _a.searchValue;
|
|
12
|
-
return (react_1.default.createElement(react_1.default.Fragment, null, searchEnabled && (react_1.default.createElement("div", { className: "flex items-center gap-2 max-w-xl" },
|
|
11
|
+
var handleSearchInput = _a.handleSearchInput, loading = _a.loading, _b = _a.searchDisabled, searchDisabled = _b === void 0 ? false : _b, _c = _a.searchEnabled, searchEnabled = _c === void 0 ? true : _c, _d = _a.searchId, searchId = _d === void 0 ? "table-search" : _d, _e = _a.searchPlaceholder, searchPlaceholder = _e === void 0 ? "Search..." : _e, searchValue = _a.searchValue, testIdWrapper = _a.testIdWrapper, testIdInput = _a.testIdInput, testIdIcon = _a.testIdIcon, testIdLoading = _a.testIdLoading;
|
|
12
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, searchEnabled && (react_1.default.createElement("div", { className: "flex items-center gap-2 max-w-xl", "data-testid": testIdWrapper },
|
|
13
13
|
react_1.default.createElement("div", { className: "relative flex-1" },
|
|
14
|
-
react_1.default.createElement(lucide_react_1.Search, { className: "absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground" }),
|
|
15
|
-
react_1.default.createElement(input_1.Input, { id: searchId, placeholder: searchPlaceholder, value: searchValue, onChange: function (e) { return handleSearchInput("search", e.target.value); }, disabled: searchDisabled || loading, className: "pl-9" })
|
|
14
|
+
react_1.default.createElement(lucide_react_1.Search, { className: "absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground", "data-testid": testIdIcon }),
|
|
15
|
+
react_1.default.createElement(input_1.Input, { id: searchId, placeholder: searchPlaceholder, value: searchValue, onChange: function (e) { return handleSearchInput("search", e.target.value); }, disabled: searchDisabled || loading, className: "pl-9", "data-testid": testIdInput }),
|
|
16
|
+
loading && testIdLoading && (react_1.default.createElement("span", { className: "sr-only", "data-testid": testIdLoading })))))));
|
|
16
17
|
};
|
|
17
18
|
exports.EnhancedTableHeaderSearch = EnhancedTableHeaderSearch;
|
|
@@ -44,47 +44,159 @@ export interface PageLimitOption {
|
|
|
44
44
|
option: string;
|
|
45
45
|
}
|
|
46
46
|
export interface EnhancedTableProps {
|
|
47
|
+
/** Columns configuration for the table header. */
|
|
47
48
|
tableHeadItems: TableColumn[];
|
|
49
|
+
/** Row data to render in the table body. */
|
|
48
50
|
tableBodyRows: TableRow[];
|
|
51
|
+
/** Column definitions describing how to render each cell. */
|
|
49
52
|
tableBodyCols: Array<{
|
|
53
|
+
/** Key path(s) used to resolve the value from a row. Supports colon-separated nested paths. */
|
|
50
54
|
key?: string | string[];
|
|
55
|
+
/** Component type (from `COMPONENT_TYPE`) or a compatible external string. */
|
|
51
56
|
componentType: COMPONENT_TYPE | string;
|
|
57
|
+
/** Optional custom formatter invoked with `(value, row)` to render the cell. */
|
|
52
58
|
textFormatter?: (value: unknown, row: unknown) => React.ReactNode;
|
|
53
59
|
}>;
|
|
60
|
+
/** Visible table heading shown above the table. */
|
|
54
61
|
tableHeading: string;
|
|
62
|
+
/** Optional description text shown beneath the heading. */
|
|
55
63
|
tableDescription?: string;
|
|
64
|
+
/** Current page number (1-based). */
|
|
56
65
|
currentPage: number;
|
|
66
|
+
/** Total number of pages available. */
|
|
57
67
|
totalPages: number;
|
|
68
|
+
/** Items per page (page size). */
|
|
58
69
|
pageLimit: number;
|
|
70
|
+
/** Options for rows-per-page selector. */
|
|
59
71
|
listOptions: PageLimitOption[];
|
|
72
|
+
/** Called when the user navigates to the next page. */
|
|
60
73
|
handleNextOnClick: () => void;
|
|
74
|
+
/** Called when the user navigates to the previous page. */
|
|
61
75
|
handlePreviousOnClick: () => void;
|
|
76
|
+
/** Handler for select changes in pagination controls. */
|
|
62
77
|
handleOnSelect: (node: string, value: object) => void;
|
|
78
|
+
/** Whether the "next" control is disabled. */
|
|
63
79
|
isNextDisabled: boolean;
|
|
80
|
+
/** Whether the "previous" control is disabled. */
|
|
64
81
|
isPreviousDisabled: boolean;
|
|
82
|
+
/** Enable/disable the search input in the table header. */
|
|
65
83
|
searchEnabled?: boolean;
|
|
84
|
+
/** Current search input value. */
|
|
66
85
|
searchValue: string;
|
|
86
|
+
/** Placeholder text for the search input. */
|
|
67
87
|
searchPlaceholder?: string;
|
|
88
|
+
/** Optional id attribute for the search input element. */
|
|
68
89
|
searchId?: string;
|
|
90
|
+
/** Disable the search input. */
|
|
69
91
|
searchDisabled?: boolean;
|
|
92
|
+
/** Called when the search input value changes. */
|
|
70
93
|
handleSearchInput: (key: string, value: string) => void;
|
|
94
|
+
/** Header-level actions to show in the table header. */
|
|
71
95
|
headerActions: HeaderAction[];
|
|
96
|
+
/** Row-level actions for each row. */
|
|
72
97
|
rowActions: RowAction[];
|
|
98
|
+
/** Number of active filters (shown in header actions). */
|
|
73
99
|
numberOfFilters?: number;
|
|
100
|
+
/** Called to clear applied filters. */
|
|
74
101
|
onClearFilters?: () => void;
|
|
102
|
+
/** Whether the table is currently loading data. */
|
|
75
103
|
loading: boolean;
|
|
104
|
+
/** Render layout in right-to-left mode when true. */
|
|
76
105
|
isRTL?: boolean;
|
|
106
|
+
/** Optional override labels used for UI text in the table. */
|
|
77
107
|
translationLabels?: {
|
|
108
|
+
/** Label to use for boolean `true`. */
|
|
78
109
|
booleanYes?: string;
|
|
110
|
+
/** Label to use for boolean `false`. */
|
|
79
111
|
booleanNo?: string;
|
|
112
|
+
/** Empty-state text when no rows exist. */
|
|
80
113
|
noResultsFound?: string;
|
|
114
|
+
/** Label for the previous page control. */
|
|
81
115
|
previousPage?: string;
|
|
116
|
+
/** Label for the next page control. */
|
|
82
117
|
nextPage?: string;
|
|
118
|
+
/** Label for the word "page" used in pagination. */
|
|
83
119
|
page?: string;
|
|
120
|
+
/** Label for the word "of" used in pagination. */
|
|
84
121
|
of?: string;
|
|
122
|
+
/** Label used while loading. */
|
|
85
123
|
loading?: string;
|
|
124
|
+
/** Label for the rows-per-page control. */
|
|
86
125
|
rowsPerPage?: string;
|
|
87
126
|
};
|
|
127
|
+
/** Optional key name used by the pagination select control (defaults to "pageLimit"). */
|
|
88
128
|
nodeSelectKey?: string;
|
|
129
|
+
/** `data-testid` for the root container wrapping the whole component. */
|
|
130
|
+
testIdWrapper?: string;
|
|
131
|
+
/** `data-testid` for the table heading (`h2`). */
|
|
132
|
+
testIdHeading?: string;
|
|
133
|
+
/** `data-testid` for the optional table description paragraph. */
|
|
134
|
+
testIdTableDescription?: string;
|
|
135
|
+
/** `data-testid` for the search wrapper (contains the header search component). */
|
|
136
|
+
testIdSearch?: string;
|
|
137
|
+
/** `data-testid` for the header actions wrapper. */
|
|
138
|
+
testIdHeaderActions?: string;
|
|
139
|
+
/** `data-testid` prefix for individual header action buttons: `${prefix}-${index}`. */
|
|
140
|
+
testIdHeaderActionPrefix?: string;
|
|
141
|
+
/** `data-testid` for the filter badge showing number of active filters. */
|
|
142
|
+
testIdHeaderActionFilterBadge?: string;
|
|
143
|
+
/** `data-testid` for the clear filters button/icon. */
|
|
144
|
+
testIdHeaderActionClearFilters?: string;
|
|
145
|
+
/** `data-testid` for the table wrapper (the bordered `div` that contains the table). */
|
|
146
|
+
testIdTableWrapper?: string;
|
|
147
|
+
/** Prefix used for row test ids: `${prefix}-${rowIndex}`. */
|
|
148
|
+
testIdRowPrefix?: string;
|
|
149
|
+
/** Prefix used for cell test ids: `${prefix}-${rowIndex}-${colIndex}`. */
|
|
150
|
+
testIdCellPrefix?: string;
|
|
151
|
+
/** `data-testid` prefix for row action dropdown menu items: `${prefix}-${rowIndex}-${actionIndex}`. */
|
|
152
|
+
testIdRowActionPrefix?: string;
|
|
153
|
+
/** `data-testid` for the no-results empty state cell. */
|
|
154
|
+
testIdNoResults?: string;
|
|
155
|
+
/** Prefix used for loading row test ids: `${prefix}-${index}`. */
|
|
156
|
+
testIdLoadingRowPrefix?: string;
|
|
157
|
+
/** `data-testid` for the pagination wrapper area. */
|
|
158
|
+
testIdPaginationWrapper?: string;
|
|
159
|
+
/** `data-testid` forwarded to the footer pagination component. */
|
|
160
|
+
testIdFooterPagination?: string;
|
|
161
|
+
/** `data-testid` forwarded to the footer page component. */
|
|
162
|
+
testIdFooterPage?: string;
|
|
163
|
+
/** `data-testid` forwarded to the footer action component. */
|
|
164
|
+
testIdFooterAction?: string;
|
|
165
|
+
/** RTL `data-testid` for the root container. */
|
|
166
|
+
testIdWrapperRtl?: string;
|
|
167
|
+
/** RTL `data-testid` for the table heading. */
|
|
168
|
+
testIdHeadingRtl?: string;
|
|
169
|
+
/** RTL `data-testid` for the table description. */
|
|
170
|
+
testIdTableDescriptionRtl?: string;
|
|
171
|
+
/** RTL `data-testid` for the search wrapper. */
|
|
172
|
+
testIdSearchRtl?: string;
|
|
173
|
+
/** RTL `data-testid` for the header actions wrapper. */
|
|
174
|
+
testIdHeaderActionsRtl?: string;
|
|
175
|
+
/** RTL `data-testid` prefix for individual header action buttons: `${prefix}-${index}`. */
|
|
176
|
+
testIdHeaderActionPrefixRtl?: string;
|
|
177
|
+
/** RTL `data-testid` for the filter badge showing number of active filters. */
|
|
178
|
+
testIdHeaderActionFilterBadgeRtl?: string;
|
|
179
|
+
/** RTL `data-testid` for the clear filters button/icon. */
|
|
180
|
+
testIdHeaderActionClearFiltersRtl?: string;
|
|
181
|
+
/** RTL `data-testid` for the table wrapper. */
|
|
182
|
+
testIdTableWrapperRtl?: string;
|
|
183
|
+
/** Prefix used for row test ids in RTL: `${prefix}-${rowIndex}`. */
|
|
184
|
+
testIdRowPrefixRtl?: string;
|
|
185
|
+
/** Prefix used for cell test ids in RTL: `${prefix}-${rowIndex}-${colIndex}`. */
|
|
186
|
+
testIdCellPrefixRtl?: string;
|
|
187
|
+
/** RTL `data-testid` prefix for row action dropdown menu items: `${prefix}-${rowIndex}-${actionIndex}`. */
|
|
188
|
+
testIdRowActionPrefixRtl?: string;
|
|
189
|
+
/** RTL `data-testid` for the no-results empty state cell. */
|
|
190
|
+
testIdNoResultsRtl?: string;
|
|
191
|
+
/** Prefix used for loading row test ids in RTL: `${prefix}-${index}`. */
|
|
192
|
+
testIdLoadingRowPrefixRtl?: string;
|
|
193
|
+
/** RTL `data-testid` for the pagination wrapper area. */
|
|
194
|
+
testIdPaginationWrapperRtl?: string;
|
|
195
|
+
/** RTL `data-testid` forwarded to the footer pagination component. */
|
|
196
|
+
testIdFooterPaginationRtl?: string;
|
|
197
|
+
/** RTL `data-testid` forwarded to the footer page component. */
|
|
198
|
+
testIdFooterPageRtl?: string;
|
|
199
|
+
/** RTL `data-testid` forwarded to the footer action component. */
|
|
200
|
+
testIdFooterActionRtl?: string;
|
|
89
201
|
}
|
|
90
202
|
export declare const EnhancedTable: React.FC<EnhancedTableProps>;
|
|
@@ -41,7 +41,7 @@ var COMPONENT_TYPE;
|
|
|
41
41
|
COMPONENT_TYPE["BOOLEAN"] = "BOOLEAN";
|
|
42
42
|
})(COMPONENT_TYPE || (exports.COMPONENT_TYPE = COMPONENT_TYPE = {}));
|
|
43
43
|
var EnhancedTable = function (_a) {
|
|
44
|
-
var currentPage = _a.currentPage, handleNextOnClick = _a.handleNextOnClick, handleOnSelect = _a.handleOnSelect, handlePreviousOnClick = _a.handlePreviousOnClick, handleSearchInput = _a.handleSearchInput, headerActions = _a.headerActions, isNextDisabled = _a.isNextDisabled, isPreviousDisabled = _a.isPreviousDisabled, _b = _a.isRTL, isRTL = _b === void 0 ? false : _b, listOptions = _a.listOptions, loading = _a.loading, _c = _a.nodeSelectKey, nodeSelectKey = _c === void 0 ? "pageLimit" : _c, numberOfFilters = _a.numberOfFilters, onClearFilters = _a.onClearFilters, pageLimit = _a.pageLimit, rowActions = _a.rowActions, _d = _a.searchDisabled, searchDisabled = _d === void 0 ? false : _d, _e = _a.searchEnabled, searchEnabled = _e === void 0 ? true : _e, _f = _a.searchId, searchId = _f === void 0 ? "table-search" : _f, _g = _a.searchPlaceholder, searchPlaceholder = _g === void 0 ? "Search..." : _g, searchValue = _a.searchValue, tableBodyCols = _a.tableBodyCols, tableBodyRows = _a.tableBodyRows, tableDescription = _a.tableDescription, tableHeading = _a.tableHeading, tableHeadItems = _a.tableHeadItems, totalPages = _a.totalPages, _h = _a.translationLabels, translationLabels = _h === void 0 ? {} : _h;
|
|
44
|
+
var currentPage = _a.currentPage, handleNextOnClick = _a.handleNextOnClick, handleOnSelect = _a.handleOnSelect, handlePreviousOnClick = _a.handlePreviousOnClick, handleSearchInput = _a.handleSearchInput, headerActions = _a.headerActions, isNextDisabled = _a.isNextDisabled, isPreviousDisabled = _a.isPreviousDisabled, _b = _a.isRTL, isRTL = _b === void 0 ? false : _b, listOptions = _a.listOptions, loading = _a.loading, _c = _a.nodeSelectKey, nodeSelectKey = _c === void 0 ? "pageLimit" : _c, numberOfFilters = _a.numberOfFilters, onClearFilters = _a.onClearFilters, pageLimit = _a.pageLimit, rowActions = _a.rowActions, _d = _a.searchDisabled, searchDisabled = _d === void 0 ? false : _d, _e = _a.searchEnabled, searchEnabled = _e === void 0 ? true : _e, _f = _a.searchId, searchId = _f === void 0 ? "table-search" : _f, _g = _a.searchPlaceholder, searchPlaceholder = _g === void 0 ? "Search..." : _g, searchValue = _a.searchValue, tableBodyCols = _a.tableBodyCols, tableBodyRows = _a.tableBodyRows, tableDescription = _a.tableDescription, tableHeading = _a.tableHeading, tableHeadItems = _a.tableHeadItems, totalPages = _a.totalPages, _h = _a.translationLabels, translationLabels = _h === void 0 ? {} : _h, testIdWrapper = _a.testIdWrapper, testIdHeading = _a.testIdHeading, testIdTableDescription = _a.testIdTableDescription, testIdSearch = _a.testIdSearch, testIdHeaderActions = _a.testIdHeaderActions, testIdHeaderActionPrefix = _a.testIdHeaderActionPrefix, testIdHeaderActionFilterBadge = _a.testIdHeaderActionFilterBadge, testIdHeaderActionClearFilters = _a.testIdHeaderActionClearFilters, testIdTableWrapper = _a.testIdTableWrapper, testIdRowPrefix = _a.testIdRowPrefix, testIdCellPrefix = _a.testIdCellPrefix, testIdRowActionPrefix = _a.testIdRowActionPrefix, testIdNoResults = _a.testIdNoResults, testIdLoadingRowPrefix = _a.testIdLoadingRowPrefix, testIdPaginationWrapper = _a.testIdPaginationWrapper, testIdFooterPagination = _a.testIdFooterPagination, testIdFooterPage = _a.testIdFooterPage, testIdFooterAction = _a.testIdFooterAction, testIdWrapperRtl = _a.testIdWrapperRtl, testIdHeadingRtl = _a.testIdHeadingRtl, testIdTableDescriptionRtl = _a.testIdTableDescriptionRtl, testIdSearchRtl = _a.testIdSearchRtl, testIdHeaderActionsRtl = _a.testIdHeaderActionsRtl, testIdHeaderActionPrefixRtl = _a.testIdHeaderActionPrefixRtl, testIdHeaderActionFilterBadgeRtl = _a.testIdHeaderActionFilterBadgeRtl, testIdHeaderActionClearFiltersRtl = _a.testIdHeaderActionClearFiltersRtl, testIdTableWrapperRtl = _a.testIdTableWrapperRtl, testIdRowPrefixRtl = _a.testIdRowPrefixRtl, testIdCellPrefixRtl = _a.testIdCellPrefixRtl, testIdRowActionPrefixRtl = _a.testIdRowActionPrefixRtl, testIdNoResultsRtl = _a.testIdNoResultsRtl, testIdLoadingRowPrefixRtl = _a.testIdLoadingRowPrefixRtl, testIdPaginationWrapperRtl = _a.testIdPaginationWrapperRtl, testIdFooterPaginationRtl = _a.testIdFooterPaginationRtl, testIdFooterPageRtl = _a.testIdFooterPageRtl, testIdFooterActionRtl = _a.testIdFooterActionRtl;
|
|
45
45
|
// Default translation values
|
|
46
46
|
var defaultLabels = {
|
|
47
47
|
booleanYes: "Yes",
|
|
@@ -56,7 +56,62 @@ var EnhancedTable = function (_a) {
|
|
|
56
56
|
};
|
|
57
57
|
// Merge provided labels with defaults
|
|
58
58
|
var labels = __assign(__assign({}, defaultLabels), translationLabels);
|
|
59
|
-
|
|
59
|
+
// Resolve which test ids to use depending on `isRTL` mode.
|
|
60
|
+
var _testIdWrapper = isRTL
|
|
61
|
+
? (testIdWrapperRtl !== null && testIdWrapperRtl !== void 0 ? testIdWrapperRtl : testIdWrapper)
|
|
62
|
+
: testIdWrapper;
|
|
63
|
+
var _testIdHeading = isRTL
|
|
64
|
+
? (testIdHeadingRtl !== null && testIdHeadingRtl !== void 0 ? testIdHeadingRtl : testIdHeading)
|
|
65
|
+
: testIdHeading;
|
|
66
|
+
var _testIdTableDescription = isRTL
|
|
67
|
+
? (testIdTableDescriptionRtl !== null && testIdTableDescriptionRtl !== void 0 ? testIdTableDescriptionRtl : testIdTableDescription)
|
|
68
|
+
: testIdTableDescription;
|
|
69
|
+
var _testIdSearch = isRTL
|
|
70
|
+
? (testIdSearchRtl !== null && testIdSearchRtl !== void 0 ? testIdSearchRtl : testIdSearch)
|
|
71
|
+
: testIdSearch;
|
|
72
|
+
var _testIdHeaderActions = isRTL
|
|
73
|
+
? (testIdHeaderActionsRtl !== null && testIdHeaderActionsRtl !== void 0 ? testIdHeaderActionsRtl : testIdHeaderActions)
|
|
74
|
+
: testIdHeaderActions;
|
|
75
|
+
var _testIdHeaderActionPrefix = isRTL
|
|
76
|
+
? (testIdHeaderActionPrefixRtl !== null && testIdHeaderActionPrefixRtl !== void 0 ? testIdHeaderActionPrefixRtl : testIdHeaderActionPrefix)
|
|
77
|
+
: testIdHeaderActionPrefix;
|
|
78
|
+
var _testIdHeaderActionFilterBadge = isRTL
|
|
79
|
+
? (testIdHeaderActionFilterBadgeRtl !== null && testIdHeaderActionFilterBadgeRtl !== void 0 ? testIdHeaderActionFilterBadgeRtl : testIdHeaderActionFilterBadge)
|
|
80
|
+
: testIdHeaderActionFilterBadge;
|
|
81
|
+
var _testIdHeaderActionClearFilters = isRTL
|
|
82
|
+
? (testIdHeaderActionClearFiltersRtl !== null && testIdHeaderActionClearFiltersRtl !== void 0 ? testIdHeaderActionClearFiltersRtl : testIdHeaderActionClearFilters)
|
|
83
|
+
: testIdHeaderActionClearFilters;
|
|
84
|
+
var _testIdTableWrapper = isRTL
|
|
85
|
+
? (testIdTableWrapperRtl !== null && testIdTableWrapperRtl !== void 0 ? testIdTableWrapperRtl : testIdTableWrapper)
|
|
86
|
+
: testIdTableWrapper;
|
|
87
|
+
var _testIdRowPrefix = isRTL
|
|
88
|
+
? (testIdRowPrefixRtl !== null && testIdRowPrefixRtl !== void 0 ? testIdRowPrefixRtl : testIdRowPrefix)
|
|
89
|
+
: testIdRowPrefix;
|
|
90
|
+
var _testIdCellPrefix = isRTL
|
|
91
|
+
? (testIdCellPrefixRtl !== null && testIdCellPrefixRtl !== void 0 ? testIdCellPrefixRtl : testIdCellPrefix)
|
|
92
|
+
: testIdCellPrefix;
|
|
93
|
+
var _testIdRowActionPrefix = isRTL
|
|
94
|
+
? (testIdRowActionPrefixRtl !== null && testIdRowActionPrefixRtl !== void 0 ? testIdRowActionPrefixRtl : testIdRowActionPrefix)
|
|
95
|
+
: testIdRowActionPrefix;
|
|
96
|
+
var _testIdNoResults = isRTL
|
|
97
|
+
? (testIdNoResultsRtl !== null && testIdNoResultsRtl !== void 0 ? testIdNoResultsRtl : testIdNoResults)
|
|
98
|
+
: testIdNoResults;
|
|
99
|
+
var _testIdLoadingRowPrefix = isRTL
|
|
100
|
+
? (testIdLoadingRowPrefixRtl !== null && testIdLoadingRowPrefixRtl !== void 0 ? testIdLoadingRowPrefixRtl : testIdLoadingRowPrefix)
|
|
101
|
+
: testIdLoadingRowPrefix;
|
|
102
|
+
var _testIdPaginationWrapper = isRTL
|
|
103
|
+
? (testIdPaginationWrapperRtl !== null && testIdPaginationWrapperRtl !== void 0 ? testIdPaginationWrapperRtl : testIdPaginationWrapper)
|
|
104
|
+
: testIdPaginationWrapper;
|
|
105
|
+
var _testIdFooterPagination = isRTL
|
|
106
|
+
? (testIdFooterPaginationRtl !== null && testIdFooterPaginationRtl !== void 0 ? testIdFooterPaginationRtl : testIdFooterPagination)
|
|
107
|
+
: testIdFooterPagination;
|
|
108
|
+
var _testIdFooterPage = isRTL
|
|
109
|
+
? (testIdFooterPageRtl !== null && testIdFooterPageRtl !== void 0 ? testIdFooterPageRtl : testIdFooterPage)
|
|
110
|
+
: testIdFooterPage;
|
|
111
|
+
var _testIdFooterAction = isRTL
|
|
112
|
+
? (testIdFooterActionRtl !== null && testIdFooterActionRtl !== void 0 ? testIdFooterActionRtl : testIdFooterAction)
|
|
113
|
+
: testIdFooterAction;
|
|
114
|
+
var renderCellContent = function (row, col, rowIndex) {
|
|
60
115
|
var _a, _b;
|
|
61
116
|
// Helper to safely resolve nested keys (max depth 3)
|
|
62
117
|
var resolveValue = function (source, key) {
|
|
@@ -127,7 +182,9 @@ var EnhancedTable = function (_a) {
|
|
|
127
182
|
react_1.default.createElement(dropdown_menu_1.DropdownMenuContent, { align: "end" }, rowActions
|
|
128
183
|
.filter(function (action) { return action.enabled !== false; })
|
|
129
184
|
.sort(function (a, b) { return (a.order || 0) - (b.order || 0); })
|
|
130
|
-
.map(function (action, index) { return (react_1.default.createElement(dropdown_menu_1.DropdownMenuItem, { key: action.id || action.key || index,
|
|
185
|
+
.map(function (action, index) { return (react_1.default.createElement(dropdown_menu_1.DropdownMenuItem, { key: action.id || action.key || index, "data-testid": _testIdRowActionPrefix
|
|
186
|
+
? "".concat(_testIdRowActionPrefix, "-").concat(rowIndex, "-").concat(index)
|
|
187
|
+
: undefined, className: (0, utils_1.cn)(action.variant === "destructive" &&
|
|
131
188
|
"text-destructive focus:text-destructive"), onClick: function () {
|
|
132
189
|
if (action.onClick)
|
|
133
190
|
action.onClick(row);
|
|
@@ -236,27 +293,38 @@ var EnhancedTable = function (_a) {
|
|
|
236
293
|
};
|
|
237
294
|
// Create loading skeleton rows
|
|
238
295
|
var renderLoadingRows = function () {
|
|
239
|
-
return Array.from({ length: pageLimit || 5 }).map(function (_, index) { return (react_1.default.createElement(table_1.TableRow, { key: "loading-".concat(index), className: "hover:bg-muted/50"
|
|
296
|
+
return Array.from({ length: pageLimit || 5 }).map(function (_, index) { return (react_1.default.createElement(table_1.TableRow, { key: "loading-".concat(index), className: "hover:bg-muted/50", "data-testid": _testIdLoadingRowPrefix
|
|
297
|
+
? "".concat(_testIdLoadingRowPrefix, "-").concat(index)
|
|
298
|
+
: undefined }, tableHeadItems.map(function (_, colIndex) { return (react_1.default.createElement(table_1.TableCell, { key: colIndex, className: "py-4" },
|
|
240
299
|
react_1.default.createElement("div", { className: "h-4 bg-muted animate-pulse rounded w-full" }))); }))); });
|
|
241
300
|
};
|
|
242
|
-
return (react_1.default.createElement("div", { className: "space-y-4" },
|
|
301
|
+
return (react_1.default.createElement("div", { className: "space-y-4", "data-testid": _testIdWrapper },
|
|
243
302
|
react_1.default.createElement("div", { className: "flex items-center justify-between" },
|
|
244
303
|
react_1.default.createElement("div", { className: "space-y-1" },
|
|
245
|
-
react_1.default.createElement("h2", { className: "text-2xl font-bold tracking-tight" }, tableHeading),
|
|
246
|
-
tableDescription && (react_1.default.createElement("p", { className: "text-muted-foreground" }, tableDescription))),
|
|
304
|
+
react_1.default.createElement("h2", { className: "text-2xl font-bold tracking-tight", "data-testid": _testIdHeading }, tableHeading),
|
|
305
|
+
tableDescription && (react_1.default.createElement("p", { className: "text-muted-foreground", "data-testid": _testIdTableDescription }, tableDescription))),
|
|
247
306
|
react_1.default.createElement("div", { className: "flex flex-row items-center justify-end gap-2" },
|
|
248
|
-
react_1.default.createElement(
|
|
249
|
-
|
|
250
|
-
|
|
307
|
+
react_1.default.createElement("div", { "data-testid": _testIdSearch },
|
|
308
|
+
react_1.default.createElement(enhanced_table_header_search_1.EnhancedTableHeaderSearch, { handleSearchInput: handleSearchInput, loading: loading, searchDisabled: searchDisabled, searchEnabled: searchEnabled, searchId: searchId, searchPlaceholder: searchPlaceholder, searchValue: searchValue })),
|
|
309
|
+
react_1.default.createElement("div", { "data-testid": _testIdHeaderActions },
|
|
310
|
+
react_1.default.createElement(enhanced_table_header_action_1.EnhancedTableHeaderAction, { headerActions: headerActions, numberOfFilters: numberOfFilters, onClearFilters: onClearFilters, testIdActionPrefix: _testIdHeaderActionPrefix, testIdClearFilters: _testIdHeaderActionClearFilters, testIdFilterBadge: _testIdHeaderActionFilterBadge })))),
|
|
311
|
+
react_1.default.createElement("div", { className: "border rounded-md", "data-testid": _testIdTableWrapper },
|
|
251
312
|
react_1.default.createElement(table_1.Table, null,
|
|
252
313
|
react_1.default.createElement(table_1.TableHeader, null,
|
|
253
314
|
react_1.default.createElement(table_1.TableRow, null, tableHeadItems.map(function (header, index) { return (react_1.default.createElement(table_1.TableHead, { key: index, style: { width: header.width }, className: (0, utils_1.cn)("font-medium", index === 0 && "rounded-tl-md", index === tableHeadItems.length - 1 && "rounded-tr-md") }, header.label)); }))),
|
|
254
315
|
react_1.default.createElement(table_1.TableBody, null, loading ? (renderLoadingRows()) : tableBodyRows.length === 0 ? (react_1.default.createElement(table_1.TableRow, null,
|
|
255
|
-
react_1.default.createElement(table_1.TableCell, { colSpan: tableHeadItems.length, className: "h-24 text-center text-muted-foreground" }, labels.noResultsFound))) : (tableBodyRows.map(function (row, rowIndex) { return (react_1.default.createElement(table_1.TableRow, { key: rowIndex, className: "hover:bg-muted/50"
|
|
256
|
-
|
|
257
|
-
|
|
316
|
+
react_1.default.createElement(table_1.TableCell, { colSpan: tableHeadItems.length, className: "h-24 text-center text-muted-foreground", "data-testid": _testIdNoResults }, labels.noResultsFound))) : (tableBodyRows.map(function (row, rowIndex) { return (react_1.default.createElement(table_1.TableRow, { key: rowIndex, className: "hover:bg-muted/50", "data-testid": _testIdRowPrefix
|
|
317
|
+
? "".concat(_testIdRowPrefix, "-").concat(rowIndex)
|
|
318
|
+
: undefined }, tableBodyCols.map(function (col, colIndex) { return (react_1.default.createElement(table_1.TableCell, { key: colIndex, className: "py-4", "data-testid": _testIdCellPrefix
|
|
319
|
+
? "".concat(_testIdCellPrefix, "-").concat(rowIndex, "-").concat(colIndex)
|
|
320
|
+
: undefined }, renderCellContent(row, col, rowIndex))); }))); }))))),
|
|
321
|
+
react_1.default.createElement("div", { className: "flex items-center justify-between", "data-testid": _testIdPaginationWrapper },
|
|
322
|
+
react_1.default.createElement("div", { "data-testid": _testIdFooterPagination },
|
|
323
|
+
react_1.default.createElement(enhanced_table_footer_pagination_1.EnhancedTableFooterPagination, { handleOnSelect: handleOnSelect, isRTL: isRTL, listOptions: listOptions, loading: loading, nodeSelectKey: nodeSelectKey, pageLimit: pageLimit, rowsPerPageLabel: labels.rowsPerPage, totalPages: totalPages })),
|
|
258
324
|
react_1.default.createElement("div", { className: "flex items-center gap-4" },
|
|
259
|
-
react_1.default.createElement(
|
|
260
|
-
|
|
325
|
+
react_1.default.createElement("div", { "data-testid": _testIdFooterPage },
|
|
326
|
+
react_1.default.createElement(enhanced_table_footer_page_1.EnhancedTableFooterPage, { currentPage: currentPage, isRTL: isRTL, loading: loading, loadingLabel: labels.loading, ofLabel: labels.of, pageLabel: labels.page, totalPages: totalPages })),
|
|
327
|
+
react_1.default.createElement("div", { "data-testid": _testIdFooterAction },
|
|
328
|
+
react_1.default.createElement(enhanced_table_footer_action_1.EnhancedTableFooterAction, { handleNextOnClick: handleNextOnClick, handlePreviousOnClick: handlePreviousOnClick, isNextDisabled: isNextDisabled, isPreviousDisabled: isPreviousDisabled, isRTL: isRTL, loading: loading, nextPageLabel: labels.nextPage, previousPageLabel: labels.previousPage }))))));
|
|
261
329
|
};
|
|
262
330
|
exports.EnhancedTable = EnhancedTable;
|
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
/** Props for `EnhancedTextarea` component. */
|
|
2
3
|
interface EnhancedTextareaProps extends React.ComponentProps<"textarea"> {
|
|
4
|
+
/** Error message text shown below the textarea; sets error styling when present. */
|
|
3
5
|
error?: string;
|
|
6
|
+
/** Informational helper text shown below the textarea (when no error). */
|
|
4
7
|
info?: string;
|
|
8
|
+
/** Optional label text displayed above the textarea. */
|
|
5
9
|
label?: string;
|
|
10
|
+
/** `data-testid` for the root wrapper (outermost `div`). */
|
|
11
|
+
testIdWrapper?: string;
|
|
12
|
+
/** `data-testid` for the label element (forwards to `EnhancedLabel`). */
|
|
13
|
+
testIdLabel?: string;
|
|
14
|
+
/** `data-testid` for the native textarea element. */
|
|
15
|
+
testIdTextarea?: string;
|
|
16
|
+
/** `data-testid` for the message container (holds error/info). */
|
|
17
|
+
testIdMessage?: string;
|
|
18
|
+
/** `data-testid` for the error text element. */
|
|
19
|
+
testIdError?: string;
|
|
20
|
+
/** `data-testid` for the info text element. */
|
|
21
|
+
testIdInfo?: string;
|
|
6
22
|
}
|
|
7
23
|
declare const EnhancedTextarea: React.ForwardRefExoticComponent<Omit<EnhancedTextareaProps, "ref"> & React.RefAttributes<HTMLTextAreaElement>>;
|
|
8
24
|
export { EnhancedTextarea };
|