@appcorp/shadcn 1.1.17 → 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.
|
@@ -136,12 +136,20 @@ export interface EnhancedTableProps {
|
|
|
136
136
|
testIdSearch?: string;
|
|
137
137
|
/** `data-testid` for the header actions wrapper. */
|
|
138
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;
|
|
139
145
|
/** `data-testid` for the table wrapper (the bordered `div` that contains the table). */
|
|
140
146
|
testIdTableWrapper?: string;
|
|
141
147
|
/** Prefix used for row test ids: `${prefix}-${rowIndex}`. */
|
|
142
148
|
testIdRowPrefix?: string;
|
|
143
149
|
/** Prefix used for cell test ids: `${prefix}-${rowIndex}-${colIndex}`. */
|
|
144
150
|
testIdCellPrefix?: string;
|
|
151
|
+
/** `data-testid` prefix for row action dropdown menu items: `${prefix}-${rowIndex}-${actionIndex}`. */
|
|
152
|
+
testIdRowActionPrefix?: string;
|
|
145
153
|
/** `data-testid` for the no-results empty state cell. */
|
|
146
154
|
testIdNoResults?: string;
|
|
147
155
|
/** Prefix used for loading row test ids: `${prefix}-${index}`. */
|
|
@@ -164,12 +172,20 @@ export interface EnhancedTableProps {
|
|
|
164
172
|
testIdSearchRtl?: string;
|
|
165
173
|
/** RTL `data-testid` for the header actions wrapper. */
|
|
166
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;
|
|
167
181
|
/** RTL `data-testid` for the table wrapper. */
|
|
168
182
|
testIdTableWrapperRtl?: string;
|
|
169
183
|
/** Prefix used for row test ids in RTL: `${prefix}-${rowIndex}`. */
|
|
170
184
|
testIdRowPrefixRtl?: string;
|
|
171
185
|
/** Prefix used for cell test ids in RTL: `${prefix}-${rowIndex}-${colIndex}`. */
|
|
172
186
|
testIdCellPrefixRtl?: string;
|
|
187
|
+
/** RTL `data-testid` prefix for row action dropdown menu items: `${prefix}-${rowIndex}-${actionIndex}`. */
|
|
188
|
+
testIdRowActionPrefixRtl?: string;
|
|
173
189
|
/** RTL `data-testid` for the no-results empty state cell. */
|
|
174
190
|
testIdNoResultsRtl?: string;
|
|
175
191
|
/** Prefix used for loading row test ids in RTL: `${prefix}-${index}`. */
|
|
@@ -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, testIdWrapper = _a.testIdWrapper, testIdHeading = _a.testIdHeading, testIdTableDescription = _a.testIdTableDescription, testIdSearch = _a.testIdSearch, testIdHeaderActions = _a.testIdHeaderActions, testIdTableWrapper = _a.testIdTableWrapper, testIdRowPrefix = _a.testIdRowPrefix, testIdCellPrefix = _a.testIdCellPrefix, 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, testIdTableWrapperRtl = _a.testIdTableWrapperRtl, testIdRowPrefixRtl = _a.testIdRowPrefixRtl, testIdCellPrefixRtl = _a.testIdCellPrefixRtl, testIdNoResultsRtl = _a.testIdNoResultsRtl, testIdLoadingRowPrefixRtl = _a.testIdLoadingRowPrefixRtl, testIdPaginationWrapperRtl = _a.testIdPaginationWrapperRtl, testIdFooterPaginationRtl = _a.testIdFooterPaginationRtl, testIdFooterPageRtl = _a.testIdFooterPageRtl, testIdFooterActionRtl = _a.testIdFooterActionRtl;
|
|
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",
|
|
@@ -72,6 +72,15 @@ var EnhancedTable = function (_a) {
|
|
|
72
72
|
var _testIdHeaderActions = isRTL
|
|
73
73
|
? (testIdHeaderActionsRtl !== null && testIdHeaderActionsRtl !== void 0 ? testIdHeaderActionsRtl : testIdHeaderActions)
|
|
74
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;
|
|
75
84
|
var _testIdTableWrapper = isRTL
|
|
76
85
|
? (testIdTableWrapperRtl !== null && testIdTableWrapperRtl !== void 0 ? testIdTableWrapperRtl : testIdTableWrapper)
|
|
77
86
|
: testIdTableWrapper;
|
|
@@ -81,6 +90,9 @@ var EnhancedTable = function (_a) {
|
|
|
81
90
|
var _testIdCellPrefix = isRTL
|
|
82
91
|
? (testIdCellPrefixRtl !== null && testIdCellPrefixRtl !== void 0 ? testIdCellPrefixRtl : testIdCellPrefix)
|
|
83
92
|
: testIdCellPrefix;
|
|
93
|
+
var _testIdRowActionPrefix = isRTL
|
|
94
|
+
? (testIdRowActionPrefixRtl !== null && testIdRowActionPrefixRtl !== void 0 ? testIdRowActionPrefixRtl : testIdRowActionPrefix)
|
|
95
|
+
: testIdRowActionPrefix;
|
|
84
96
|
var _testIdNoResults = isRTL
|
|
85
97
|
? (testIdNoResultsRtl !== null && testIdNoResultsRtl !== void 0 ? testIdNoResultsRtl : testIdNoResults)
|
|
86
98
|
: testIdNoResults;
|
|
@@ -99,7 +111,7 @@ var EnhancedTable = function (_a) {
|
|
|
99
111
|
var _testIdFooterAction = isRTL
|
|
100
112
|
? (testIdFooterActionRtl !== null && testIdFooterActionRtl !== void 0 ? testIdFooterActionRtl : testIdFooterAction)
|
|
101
113
|
: testIdFooterAction;
|
|
102
|
-
var renderCellContent = function (row, col) {
|
|
114
|
+
var renderCellContent = function (row, col, rowIndex) {
|
|
103
115
|
var _a, _b;
|
|
104
116
|
// Helper to safely resolve nested keys (max depth 3)
|
|
105
117
|
var resolveValue = function (source, key) {
|
|
@@ -170,7 +182,9 @@ var EnhancedTable = function (_a) {
|
|
|
170
182
|
react_1.default.createElement(dropdown_menu_1.DropdownMenuContent, { align: "end" }, rowActions
|
|
171
183
|
.filter(function (action) { return action.enabled !== false; })
|
|
172
184
|
.sort(function (a, b) { return (a.order || 0) - (b.order || 0); })
|
|
173
|
-
.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" &&
|
|
174
188
|
"text-destructive focus:text-destructive"), onClick: function () {
|
|
175
189
|
if (action.onClick)
|
|
176
190
|
action.onClick(row);
|
|
@@ -293,7 +307,7 @@ var EnhancedTable = function (_a) {
|
|
|
293
307
|
react_1.default.createElement("div", { "data-testid": _testIdSearch },
|
|
294
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 })),
|
|
295
309
|
react_1.default.createElement("div", { "data-testid": _testIdHeaderActions },
|
|
296
|
-
react_1.default.createElement(enhanced_table_header_action_1.EnhancedTableHeaderAction, { headerActions: headerActions, numberOfFilters: numberOfFilters, onClearFilters: onClearFilters })))),
|
|
310
|
+
react_1.default.createElement(enhanced_table_header_action_1.EnhancedTableHeaderAction, { headerActions: headerActions, numberOfFilters: numberOfFilters, onClearFilters: onClearFilters, testIdActionPrefix: _testIdHeaderActionPrefix, testIdClearFilters: _testIdHeaderActionClearFilters, testIdFilterBadge: _testIdHeaderActionFilterBadge })))),
|
|
297
311
|
react_1.default.createElement("div", { className: "border rounded-md", "data-testid": _testIdTableWrapper },
|
|
298
312
|
react_1.default.createElement(table_1.Table, null,
|
|
299
313
|
react_1.default.createElement(table_1.TableHeader, null,
|
|
@@ -303,7 +317,7 @@ var EnhancedTable = function (_a) {
|
|
|
303
317
|
? "".concat(_testIdRowPrefix, "-").concat(rowIndex)
|
|
304
318
|
: undefined }, tableBodyCols.map(function (col, colIndex) { return (react_1.default.createElement(table_1.TableCell, { key: colIndex, className: "py-4", "data-testid": _testIdCellPrefix
|
|
305
319
|
? "".concat(_testIdCellPrefix, "-").concat(rowIndex, "-").concat(colIndex)
|
|
306
|
-
: undefined }, renderCellContent(row, col))); }))); }))))),
|
|
320
|
+
: undefined }, renderCellContent(row, col, rowIndex))); }))); }))))),
|
|
307
321
|
react_1.default.createElement("div", { className: "flex items-center justify-between", "data-testid": _testIdPaginationWrapper },
|
|
308
322
|
react_1.default.createElement("div", { "data-testid": _testIdFooterPagination },
|
|
309
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 })),
|