@appcorp/shadcn 1.1.99 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/app-sidebar.js +16 -23
- package/components/audio.js +11 -19
- package/components/dashboard.js +27 -65
- package/components/drawer-generic.js +20 -28
- package/components/enhanced-checkbox.js +10 -57
- package/components/enhanced-combobox.js +99 -143
- package/components/enhanced-drawer-footer.js +22 -31
- package/components/enhanced-drawer-header.js +6 -14
- package/components/enhanced-dropzone-impl.d.ts +32 -0
- package/components/enhanced-dropzone-impl.js +218 -0
- package/components/enhanced-dropzone.d.ts +2 -63
- package/components/enhanced-dropzone.js +6 -294
- package/components/enhanced-input.js +10 -57
- package/components/enhanced-label.js +6 -52
- package/components/enhanced-radio.js +12 -20
- package/components/enhanced-select.js +13 -61
- package/components/enhanced-slider.js +11 -58
- package/components/enhanced-switch.js +11 -58
- package/components/enhanced-table-footer-action.js +11 -19
- package/components/enhanced-table-footer-page.js +16 -24
- package/components/enhanced-table-footer-pagination.js +11 -21
- package/components/enhanced-table-header-action.js +22 -30
- package/components/enhanced-table-header-search.js +9 -17
- package/components/enhanced-table.js +125 -153
- package/components/enhanced-textarea.js +10 -57
- package/components/field.d.ts +1 -1
- package/components/field.js +31 -88
- package/components/image-resize-dialog.js +61 -159
- package/components/nav-main.js +32 -78
- package/components/nav-projects.js +37 -48
- package/components/nav-user.js +41 -51
- package/components/show-toast.d.ts +2 -0
- package/components/show-toast.js +7 -0
- package/components/sidebar.d.ts +1 -1
- package/components/sidebar.js +115 -184
- package/components/team-switcher.js +36 -47
- package/components/theme-provider.js +36 -84
- package/components/timeline.d.ts +12 -0
- package/components/timeline.js +13 -0
- package/components/tooltip.js +10 -59
- package/components/ui/accordion.js +17 -67
- package/components/ui/alert-dialog.js +32 -89
- package/components/ui/alert.d.ts +1 -1
- package/components/ui/alert.js +14 -63
- package/components/ui/area-chart-v1-impl.d.ts +19 -0
- package/components/ui/area-chart-v1-impl.js +75 -0
- package/components/ui/area-chart-v1.d.ts +2 -19
- package/components/ui/area-chart-v1.js +4 -113
- package/components/ui/aspect-ratio.js +3 -39
- package/components/ui/avatar.js +13 -62
- package/components/ui/badge.d.ts +2 -2
- package/components/ui/badge.js +7 -55
- package/components/ui/breadcrumb.js +27 -80
- package/components/ui/button.d.ts +2 -2
- package/components/ui/button.js +10 -58
- package/components/ui/calendar-impl.d.ts +8 -0
- package/components/ui/calendar-impl.js +55 -0
- package/components/ui/calendar.d.ts +2 -8
- package/components/ui/calendar.js +5 -108
- package/components/ui/card.js +21 -73
- package/components/ui/carousel-impl.d.ts +18 -0
- package/components/ui/carousel-impl.js +117 -0
- package/components/ui/carousel.d.ts +6 -18
- package/components/ui/carousel.js +8 -170
- package/components/ui/chart-impl.d.ts +62 -0
- package/components/ui/chart-impl.js +162 -0
- package/components/ui/chart.d.ts +7 -62
- package/components/ui/chart.js +9 -219
- package/components/ui/checkbox.js +10 -57
- package/components/ui/collapsible.js +5 -43
- package/components/ui/combobox.js +22 -58
- package/components/ui/command-impl.d.ts +80 -0
- package/components/ui/command-impl.js +63 -0
- package/components/ui/command.d.ts +9 -80
- package/components/ui/command.js +12 -117
- package/components/ui/context-menu.js +41 -102
- package/components/ui/dialog.js +28 -84
- package/components/ui/drawer-impl.d.ts +22 -0
- package/components/ui/drawer-impl.js +56 -0
- package/components/ui/drawer.d.ts +10 -22
- package/components/ui/drawer.js +13 -111
- package/components/ui/dropdown-menu.js +41 -102
- package/components/ui/form.d.ts +4 -2
- package/components/ui/form.js +41 -95
- package/components/ui/hover-card.js +9 -58
- package/components/ui/input-otp-impl.d.ts +34 -0
- package/components/ui/input-otp-impl.js +43 -0
- package/components/ui/input-otp.d.ts +4 -34
- package/components/ui/input-otp.js +7 -92
- package/components/ui/input.js +6 -53
- package/components/ui/label.d.ts +1 -1
- package/components/ui/label.js +9 -56
- package/components/ui/language-selector.js +17 -55
- package/components/ui/menubar.js +46 -108
- package/components/ui/navigation-menu.d.ts +1 -1
- package/components/ui/navigation-menu.js +29 -84
- package/components/ui/pagination.js +30 -83
- package/components/ui/popover.js +10 -60
- package/components/ui/progress.js +8 -55
- package/components/ui/radio-group.js +12 -60
- package/components/ui/resizable-impl.d.ts +24 -0
- package/components/ui/resizable-impl.js +27 -0
- package/components/ui/resizable.d.ts +3 -24
- package/components/ui/resizable.js +6 -78
- package/components/ui/scroll-area.js +10 -58
- package/components/ui/select.js +34 -90
- package/components/ui/separator.js +7 -54
- package/components/ui/sheet.d.ts +1 -1
- package/components/ui/sheet.js +30 -86
- package/components/ui/skeleton.js +5 -21
- package/components/ui/slider.js +10 -57
- package/components/ui/sonner.js +7 -24
- package/components/ui/switch.js +8 -55
- package/components/ui/table.js +27 -81
- package/components/ui/tabs.js +14 -64
- package/components/ui/textarea.js +6 -53
- package/components/ui/theme-switcher.js +41 -91
- package/components/ui/toggle.d.ts +2 -2
- package/components/ui/toggle.js +9 -57
- package/data/admin-dashboard.js +16 -19
- package/hooks/use-enhanced-combobox.js +47 -124
- package/hooks/use-mobile.js +8 -44
- package/hooks/use-outside-click.js +6 -10
- package/lib/themes.js +1 -4
- package/lib/toast-utils.js +78 -120
- package/lib/utils.js +4 -11
- package/package.json +9 -90
- package/utils/transform-breadcrumbs.js +4 -8
- package/utils/transform-navitems.js +7 -22
- package/components/aceternity-ui/apple-cards-carousel.d.ts +0 -35
- package/components/aceternity-ui/apple-cards-carousel.js +0 -263
- package/components/shadcn-example/ai-chat/chat-interface.d.ts +0 -11
- package/components/shadcn-example/ai-chat/chat-interface.js +0 -70
- package/components/shadcn-example/ai-chat/index.d.ts +0 -38
- package/components/shadcn-example/ai-chat/index.js +0 -66
- package/components/shadcn-example/ai-chat/sidebar.d.ts +0 -15
- package/components/shadcn-example/ai-chat/sidebar.js +0 -68
- package/components/shadcn-example/ai-chat/welcome-section.d.ts +0 -12
- package/components/shadcn-example/ai-chat/welcome-section.js +0 -26
- package/components/shadcn-example/authentication/index.d.ts +0 -24
- package/components/shadcn-example/authentication/index.js +0 -59
- package/components/shadcn-example/authentication/user-auth-form.d.ts +0 -11
- package/components/shadcn-example/authentication/user-auth-form.js +0 -54
- package/components/shadcn-example/blog-detail-page/comment-section.d.ts +0 -15
- package/components/shadcn-example/blog-detail-page/comment-section.js +0 -83
- package/components/shadcn-example/blog-detail-page/content.d.ts +0 -7
- package/components/shadcn-example/blog-detail-page/content.js +0 -15
- package/components/shadcn-example/blog-detail-page/header.d.ts +0 -11
- package/components/shadcn-example/blog-detail-page/header.js +0 -36
- package/components/shadcn-example/blog-detail-page/index.d.ts +0 -25
- package/components/shadcn-example/blog-detail-page/index.js +0 -74
- package/components/shadcn-example/blog-page/blog-post-card.d.ts +0 -13
- package/components/shadcn-example/blog-page/blog-post-card.js +0 -30
- package/components/shadcn-example/blog-page/featured-post-sidebar-item.d.ts +0 -10
- package/components/shadcn-example/blog-page/featured-post-sidebar-item.js +0 -19
- package/components/shadcn-example/blog-page/index.d.ts +0 -20
- package/components/shadcn-example/blog-page/index.js +0 -36
- package/components/shadcn-example/coming-soon/countdown.d.ts +0 -2
- package/components/shadcn-example/coming-soon/countdown.js +0 -82
- package/components/shadcn-example/coming-soon/index.d.ts +0 -10
- package/components/shadcn-example/coming-soon/index.js +0 -41
- package/components/shadcn-io/color-picker/index.d.ts +0 -43
- package/components/shadcn-io/color-picker/index.js +0 -304
- package/components/shadcn-io/copy-button/index.d.ts +0 -16
- package/components/shadcn-io/copy-button/index.js +0 -121
- package/components/shadcn-io/dropzone/index.d.ts +0 -19
- package/components/shadcn-io/dropzone/index.js +0 -131
- package/components/shadcn-io/gantt/index.d.ts +0 -145
- package/components/shadcn-io/gantt/index.js +0 -766
- package/components/shadcn-io/table/index.d.ts +0 -60
- package/components/shadcn-io/table/index.js +0 -138
- package/templates/appcorp-v1/footer/bottom-bar.d.ts +0 -6
- package/templates/appcorp-v1/footer/bottom-bar.js +0 -25
- package/templates/appcorp-v1/footer/cta.d.ts +0 -6
- package/templates/appcorp-v1/footer/cta.js +0 -21
- package/templates/appcorp-v1/footer/footer-grid.d.ts +0 -14
- package/templates/appcorp-v1/footer/footer-grid.js +0 -52
- package/templates/appcorp-v1/footer/index.d.ts +0 -3
- package/templates/appcorp-v1/footer/index.js +0 -28
- package/templates/appcorp-v1/footer/newsletter.d.ts +0 -11
- package/templates/appcorp-v1/footer/newsletter.js +0 -28
- package/templates/appcorp-v1/footer/stats.d.ts +0 -6
- package/templates/appcorp-v1/footer/stats.js +0 -15
- package/templates/appcorp-v1/header/announcement-bar.d.ts +0 -3
- package/templates/appcorp-v1/header/announcement-bar.js +0 -15
- package/templates/appcorp-v1/header/dropdown-panel.d.ts +0 -8
- package/templates/appcorp-v1/header/dropdown-panel.js +0 -72
- package/templates/appcorp-v1/header/index.d.ts +0 -12
- package/templates/appcorp-v1/header/index.js +0 -16
- package/templates/appcorp-v1/header/mobile-menu.d.ts +0 -14
- package/templates/appcorp-v1/header/mobile-menu.js +0 -101
- package/templates/appcorp-v1/header/navigation-bar.d.ts +0 -3
- package/templates/appcorp-v1/header/navigation-bar.js +0 -117
- package/templates/appcorp-v1/header/social-button.d.ts +0 -7
- package/templates/appcorp-v1/header/social-button.js +0 -48
- package/templates/appcorp-v1/home.d.ts +0 -3
- package/templates/appcorp-v1/home.js +0 -27
- package/templates/data/appcorp-v1.d.ts +0 -93
- package/templates/data/appcorp-v1.js +0 -348
- package/templates/data/edupilotpro-v1.d.ts +0 -33
- package/templates/data/edupilotpro-v1.js +0 -116
- package/templates/data/school-v1.d.ts +0 -328
- package/templates/data/school-v1.js +0 -1563
- package/templates/edupilotpro-v1/feature-card.d.ts +0 -13
- package/templates/edupilotpro-v1/feature-card.js +0 -28
- package/templates/edupilotpro-v1/mockups/dashboard-mockup.d.ts +0 -3
- package/templates/edupilotpro-v1/mockups/dashboard-mockup.js +0 -55
- package/templates/school-v1/footer.d.ts +0 -3
- package/templates/school-v1/footer.js +0 -75
- package/templates/school-v1/index.d.ts +0 -18
- package/templates/school-v1/index.js +0 -60
- package/templates/school-v1/navigation.d.ts +0 -3
- package/templates/school-v1/navigation.js +0 -123
- package/templates/school-v1/sections/about.d.ts +0 -3
- package/templates/school-v1/sections/about.js +0 -49
- package/templates/school-v1/sections/admissions.d.ts +0 -3
- package/templates/school-v1/sections/admissions.js +0 -77
- package/templates/school-v1/sections/contact.d.ts +0 -3
- package/templates/school-v1/sections/contact.js +0 -67
- package/templates/school-v1/sections/faqs.d.ts +0 -3
- package/templates/school-v1/sections/faqs.js +0 -50
- package/templates/school-v1/sections/hero.d.ts +0 -3
- package/templates/school-v1/sections/hero.js +0 -132
- package/templates/school-v1/sections/management.d.ts +0 -3
- package/templates/school-v1/sections/management.js +0 -34
- package/templates/school-v1/sections/policies.d.ts +0 -3
- package/templates/school-v1/sections/policies.js +0 -127
- package/templates/school-v1/sections/programs.d.ts +0 -3
- package/templates/school-v1/sections/programs.js +0 -107
- package/templates/school-v1/sections/testimonials.d.ts +0 -3
- package/templates/school-v1/sections/testimonials.js +0 -46
- package/templates/school-v1/sections/why-choose-us.d.ts +0 -3
- package/templates/school-v1/sections/why-choose-us.js +0 -57
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Enhanced Table Footer Pagination Component
|
|
4
3
|
*
|
|
@@ -13,27 +12,18 @@
|
|
|
13
12
|
* - Custom translation overrides
|
|
14
13
|
* - Responsive design
|
|
15
14
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "./ui/select";
|
|
16
|
+
import React from "react";
|
|
17
|
+
export const EnhancedTableFooterPagination = ({ handleOnSelect, isRTL = false, listOptions, loading, nodeSelectKey, pageLimit, rowsPerPageLabel = "Rows per page:", className = "", testIdWrapper, testIdLabel, testIdSelectTrigger, testIdSelectValue, testIdSelectContent, testIdOptionPrefix, }) => {
|
|
18
|
+
return (React.createElement("div", { className: `flex items-center gap-2 ${className}`, dir: isRTL ? "rtl" : "ltr", "data-testid": testIdWrapper },
|
|
19
|
+
React.createElement("label", { htmlFor: `page-limit-select-${nodeSelectKey}`, className: "text-sm text-muted-foreground whitespace-nowrap", "data-testid": testIdLabel }, rowsPerPageLabel),
|
|
20
|
+
React.createElement(Select, { value: String(pageLimit), onValueChange: (value) => handleOnSelect(nodeSelectKey, { option: value }), disabled: loading },
|
|
21
|
+
React.createElement(SelectTrigger, { id: `page-limit-select-${nodeSelectKey}`, className: "w-20", "aria-label": `${rowsPerPageLabel} ${pageLimit}`, "data-testid": testIdSelectTrigger },
|
|
22
|
+
React.createElement(SelectValue, { "data-testid": testIdSelectValue })),
|
|
23
|
+
React.createElement(SelectContent, { "data-testid": testIdSelectContent }, listOptions.map((option) => (React.createElement(SelectItem, { key: option.option, value: option.option, "aria-label": `${option.option} rows per page`, "data-testid": testIdOptionPrefix
|
|
24
|
+
? `${testIdOptionPrefix}-${option.option}`
|
|
25
|
+
: undefined }, option.option)))))));
|
|
18
26
|
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.EnhancedTableFooterPagination = void 0;
|
|
21
|
-
var select_1 = require("./ui/select");
|
|
22
|
-
var react_1 = __importDefault(require("react"));
|
|
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, 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
|
-
react_1.default.createElement(select_1.Select, { value: String(pageLimit), onValueChange: function (value) {
|
|
28
|
-
return handleOnSelect(nodeSelectKey, { option: value });
|
|
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), "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)); })))));
|
|
35
|
-
};
|
|
36
|
-
exports.EnhancedTableFooterPagination = EnhancedTableFooterPagination;
|
|
37
27
|
// ============================================================================
|
|
38
28
|
// USAGE EXAMPLES
|
|
39
29
|
// ============================================================================
|
|
@@ -1,40 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var EnhancedTableHeaderAction = function (_a) {
|
|
13
|
-
var headerActions = _a.headerActions, numberOfFilters = _a.numberOfFilters, onClearFilters = _a.onClearFilters, testIdWrapper = _a.testIdWrapper, testIdActionPrefix = _a.testIdActionPrefix, testIdFilterBadge = _a.testIdFilterBadge, testIdClearFilters = _a.testIdClearFilters;
|
|
14
|
-
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
|
|
15
|
-
.filter(function (action) { return action.enabled !== false; })
|
|
16
|
-
.sort(function (a, b) { return (a.order || 0) - (b.order || 0); })
|
|
17
|
-
.map(function (action, index) {
|
|
18
|
-
var isFilterButton = action.label
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { X } from "lucide-react";
|
|
3
|
+
import { Badge } from "./ui/badge";
|
|
4
|
+
import { Button } from "./ui/button";
|
|
5
|
+
import { cn } from "../lib/utils";
|
|
6
|
+
export const EnhancedTableHeaderAction = ({ headerActions, numberOfFilters, onClearFilters, testIdWrapper, testIdActionPrefix, testIdFilterBadge, testIdClearFilters, }) => {
|
|
7
|
+
return (React.createElement(React.Fragment, null, headerActions.length > 0 && (React.createElement("div", { className: "flex gap-2", "data-testid": testIdWrapper }, headerActions
|
|
8
|
+
.filter((action) => action.enabled !== false)
|
|
9
|
+
.sort((a, b) => (a.order || 0) - (b.order || 0))
|
|
10
|
+
.map((action, index) => {
|
|
11
|
+
const isFilterButton = action.label
|
|
19
12
|
.toLowerCase()
|
|
20
13
|
.includes("filter");
|
|
21
|
-
|
|
14
|
+
const showFilterIndicators = isFilterButton &&
|
|
22
15
|
typeof numberOfFilters === "number" &&
|
|
23
16
|
numberOfFilters > 0;
|
|
24
|
-
return (
|
|
25
|
-
|
|
26
|
-
?
|
|
27
|
-
: undefined, onClick:
|
|
28
|
-
showFilterIndicators && (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
?
|
|
17
|
+
return (React.createElement("div", { key: action.id || action.key || index, className: "relative" },
|
|
18
|
+
React.createElement(Button, { variant: action.variant || "default", "data-testid": testIdActionPrefix
|
|
19
|
+
? `${testIdActionPrefix}-${index}`
|
|
20
|
+
: undefined, onClick: () => { var _a; return (_a = action.handleOnClick) === null || _a === void 0 ? void 0 : _a.call(action, undefined); } }, action.label),
|
|
21
|
+
showFilterIndicators && (React.createElement(React.Fragment, null,
|
|
22
|
+
React.createElement("div", { className: "absolute -top-2 -left-2 group" },
|
|
23
|
+
React.createElement(Badge, { variant: "secondary", className: cn("h-5 w-5 flex items-center justify-center p-0 text-xs rounded-full transition-all relative", onClearFilters && "cursor-pointer"), "data-testid": testIdFilterBadge, onClick: onClearFilters
|
|
24
|
+
? (e) => {
|
|
32
25
|
e.stopPropagation();
|
|
33
26
|
onClearFilters();
|
|
34
27
|
}
|
|
35
28
|
: undefined },
|
|
36
|
-
|
|
37
|
-
onClearFilters && (
|
|
29
|
+
React.createElement("span", { className: cn("transition-opacity absolute", onClearFilters && "group-hover:opacity-0") }, numberOfFilters),
|
|
30
|
+
onClearFilters && (React.createElement(X, { className: "h-3 w-3 absolute opacity-0 group-hover:opacity-100 transition-opacity", "data-testid": testIdClearFilters }))))))));
|
|
38
31
|
})))));
|
|
39
32
|
};
|
|
40
|
-
exports.EnhancedTableHeaderAction = EnhancedTableHeaderAction;
|
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Search } from "lucide-react";
|
|
3
|
+
import { Input } from "./ui/input";
|
|
4
|
+
export const EnhancedTableHeaderSearch = ({ handleSearchInput, loading, searchDisabled = false, searchEnabled = true, searchId = "table-search", searchPlaceholder = "Search...", searchValue, testIdWrapper, testIdInput, testIdIcon, testIdLoading, }) => {
|
|
5
|
+
return (React.createElement(React.Fragment, null, searchEnabled && (React.createElement("div", { className: "flex items-center gap-2 max-w-xl", "data-testid": testIdWrapper },
|
|
6
|
+
React.createElement("div", { className: "relative flex-1" },
|
|
7
|
+
React.createElement(Search, { className: "absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground", "data-testid": testIdIcon }),
|
|
8
|
+
React.createElement(Input, { id: searchId, placeholder: searchPlaceholder, value: searchValue, onChange: (e) => handleSearchInput("search", e.target.value), disabled: searchDisabled || loading, className: "pl-9", "data-testid": testIdInput }),
|
|
9
|
+
loading && testIdLoading && (React.createElement("span", { className: "sr-only", "data-testid": testIdLoading })))))));
|
|
4
10
|
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.EnhancedTableHeaderSearch = void 0;
|
|
7
|
-
var react_1 = __importDefault(require("react"));
|
|
8
|
-
var lucide_react_1 = require("lucide-react");
|
|
9
|
-
var input_1 = require("./ui/input");
|
|
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, 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
|
-
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", "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 })))))));
|
|
17
|
-
};
|
|
18
|
-
exports.EnhancedTableHeaderSearch = EnhancedTableHeaderSearch;
|
|
@@ -1,35 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
-
};
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.EnhancedTable = exports.COMPONENT_TYPE = void 0;
|
|
19
|
-
var react_1 = __importDefault(require("react"));
|
|
20
|
-
var lucide_react_1 = require("lucide-react");
|
|
21
|
-
var table_1 = require("./ui/table");
|
|
22
|
-
var dropdown_menu_1 = require("./ui/dropdown-menu");
|
|
23
|
-
var utils_1 = require("../lib/utils");
|
|
24
|
-
var enhanced_table_footer_action_1 = require("./enhanced-table-footer-action");
|
|
25
|
-
var enhanced_table_footer_page_1 = require("./enhanced-table-footer-page");
|
|
26
|
-
var enhanced_table_footer_pagination_1 = require("./enhanced-table-footer-pagination");
|
|
27
|
-
var popover_1 = require("./ui/popover");
|
|
28
|
-
var enhanced_table_header_action_1 = require("./enhanced-table-header-action");
|
|
29
|
-
var enhanced_table_header_search_1 = require("./enhanced-table-header-search");
|
|
30
|
-
var badge_1 = require("./ui/badge");
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { MoreHorizontal } from "lucide-react";
|
|
4
|
+
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "./ui/table";
|
|
5
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "./ui/dropdown-menu";
|
|
6
|
+
import { cn } from "../lib/utils";
|
|
7
|
+
import { EnhancedTableFooterAction } from "./enhanced-table-footer-action";
|
|
8
|
+
import { EnhancedTableFooterPage } from "./enhanced-table-footer-page";
|
|
9
|
+
import { EnhancedTableFooterPagination } from "./enhanced-table-footer-pagination";
|
|
10
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover";
|
|
11
|
+
import { EnhancedTableHeaderAction } from "./enhanced-table-header-action";
|
|
12
|
+
import { EnhancedTableHeaderSearch } from "./enhanced-table-header-search";
|
|
13
|
+
import { Badge } from "./ui/badge";
|
|
31
14
|
// Centralized component type values for table cell rendering
|
|
32
|
-
var COMPONENT_TYPE;
|
|
15
|
+
export var COMPONENT_TYPE;
|
|
33
16
|
(function (COMPONENT_TYPE) {
|
|
34
17
|
COMPONENT_TYPE["ID"] = "ID";
|
|
35
18
|
COMPONENT_TYPE["BOLD_TEXT"] = "BOLD_TEXT";
|
|
@@ -39,11 +22,10 @@ var COMPONENT_TYPE;
|
|
|
39
22
|
COMPONENT_TYPE["CREATED_UPDATED_AT"] = "CREATED_UPDATED_AT";
|
|
40
23
|
COMPONENT_TYPE["ACTIONS"] = "ACTIONS";
|
|
41
24
|
COMPONENT_TYPE["BOOLEAN"] = "BOOLEAN";
|
|
42
|
-
})(COMPONENT_TYPE || (
|
|
43
|
-
|
|
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;
|
|
25
|
+
})(COMPONENT_TYPE || (COMPONENT_TYPE = {}));
|
|
26
|
+
export const EnhancedTable = ({ currentPage, handleNextOnClick, handleOnSelect, handlePreviousOnClick, handleSearchInput, headerActions, isNextDisabled, isPreviousDisabled, isRTL = false, listOptions, loading, nodeSelectKey = "pageLimit", numberOfFilters, onClearFilters, pageLimit, rowActions, searchDisabled = false, searchEnabled = true, searchId = "table-search", searchPlaceholder = "Search...", searchValue, tableBodyCols, tableBodyRows, tableDescription, tableHeading, tableHeadItems, totalPages, translationLabels = {}, testIdWrapper, testIdHeading, testIdTableDescription, testIdSearch, testIdHeaderActions, testIdHeaderActionPrefix, testIdHeaderActionFilterBadge, testIdHeaderActionClearFilters, testIdTableWrapper, testIdRowPrefix, testIdCellPrefix, testIdRowActionPrefix, testIdNoResults, testIdLoadingRowPrefix, testIdPaginationWrapper, testIdFooterPagination, testIdFooterPage, testIdFooterAction, testIdWrapperRtl, testIdHeadingRtl, testIdTableDescriptionRtl, testIdSearchRtl, testIdHeaderActionsRtl, testIdHeaderActionPrefixRtl, testIdHeaderActionFilterBadgeRtl, testIdHeaderActionClearFiltersRtl, testIdTableWrapperRtl, testIdRowPrefixRtl, testIdCellPrefixRtl, testIdRowActionPrefixRtl, testIdNoResultsRtl, testIdLoadingRowPrefixRtl, testIdPaginationWrapperRtl, testIdFooterPaginationRtl, testIdFooterPageRtl, testIdFooterActionRtl, }) => {
|
|
45
27
|
// Default translation values
|
|
46
|
-
|
|
28
|
+
const defaultLabels = {
|
|
47
29
|
booleanYes: "Yes",
|
|
48
30
|
booleanNo: "No",
|
|
49
31
|
noResultsFound: "No results found.",
|
|
@@ -55,75 +37,74 @@ var EnhancedTable = function (_a) {
|
|
|
55
37
|
rowsPerPage: "Rows per page:",
|
|
56
38
|
};
|
|
57
39
|
// Merge provided labels with defaults
|
|
58
|
-
|
|
40
|
+
const labels = Object.assign(Object.assign({}, defaultLabels), translationLabels);
|
|
59
41
|
// Resolve which test ids to use depending on `isRTL` mode.
|
|
60
|
-
|
|
42
|
+
const _testIdWrapper = isRTL
|
|
61
43
|
? (testIdWrapperRtl !== null && testIdWrapperRtl !== void 0 ? testIdWrapperRtl : testIdWrapper)
|
|
62
44
|
: testIdWrapper;
|
|
63
|
-
|
|
45
|
+
const _testIdHeading = isRTL
|
|
64
46
|
? (testIdHeadingRtl !== null && testIdHeadingRtl !== void 0 ? testIdHeadingRtl : testIdHeading)
|
|
65
47
|
: testIdHeading;
|
|
66
|
-
|
|
48
|
+
const _testIdTableDescription = isRTL
|
|
67
49
|
? (testIdTableDescriptionRtl !== null && testIdTableDescriptionRtl !== void 0 ? testIdTableDescriptionRtl : testIdTableDescription)
|
|
68
50
|
: testIdTableDescription;
|
|
69
|
-
|
|
51
|
+
const _testIdSearch = isRTL
|
|
70
52
|
? (testIdSearchRtl !== null && testIdSearchRtl !== void 0 ? testIdSearchRtl : testIdSearch)
|
|
71
53
|
: testIdSearch;
|
|
72
|
-
|
|
54
|
+
const _testIdHeaderActions = isRTL
|
|
73
55
|
? (testIdHeaderActionsRtl !== null && testIdHeaderActionsRtl !== void 0 ? testIdHeaderActionsRtl : testIdHeaderActions)
|
|
74
56
|
: testIdHeaderActions;
|
|
75
|
-
|
|
57
|
+
const _testIdHeaderActionPrefix = isRTL
|
|
76
58
|
? (testIdHeaderActionPrefixRtl !== null && testIdHeaderActionPrefixRtl !== void 0 ? testIdHeaderActionPrefixRtl : testIdHeaderActionPrefix)
|
|
77
59
|
: testIdHeaderActionPrefix;
|
|
78
|
-
|
|
60
|
+
const _testIdHeaderActionFilterBadge = isRTL
|
|
79
61
|
? (testIdHeaderActionFilterBadgeRtl !== null && testIdHeaderActionFilterBadgeRtl !== void 0 ? testIdHeaderActionFilterBadgeRtl : testIdHeaderActionFilterBadge)
|
|
80
62
|
: testIdHeaderActionFilterBadge;
|
|
81
|
-
|
|
63
|
+
const _testIdHeaderActionClearFilters = isRTL
|
|
82
64
|
? (testIdHeaderActionClearFiltersRtl !== null && testIdHeaderActionClearFiltersRtl !== void 0 ? testIdHeaderActionClearFiltersRtl : testIdHeaderActionClearFilters)
|
|
83
65
|
: testIdHeaderActionClearFilters;
|
|
84
|
-
|
|
66
|
+
const _testIdTableWrapper = isRTL
|
|
85
67
|
? (testIdTableWrapperRtl !== null && testIdTableWrapperRtl !== void 0 ? testIdTableWrapperRtl : testIdTableWrapper)
|
|
86
68
|
: testIdTableWrapper;
|
|
87
|
-
|
|
69
|
+
const _testIdRowPrefix = isRTL
|
|
88
70
|
? (testIdRowPrefixRtl !== null && testIdRowPrefixRtl !== void 0 ? testIdRowPrefixRtl : testIdRowPrefix)
|
|
89
71
|
: testIdRowPrefix;
|
|
90
|
-
|
|
72
|
+
const _testIdCellPrefix = isRTL
|
|
91
73
|
? (testIdCellPrefixRtl !== null && testIdCellPrefixRtl !== void 0 ? testIdCellPrefixRtl : testIdCellPrefix)
|
|
92
74
|
: testIdCellPrefix;
|
|
93
|
-
|
|
75
|
+
const _testIdRowActionPrefix = isRTL
|
|
94
76
|
? (testIdRowActionPrefixRtl !== null && testIdRowActionPrefixRtl !== void 0 ? testIdRowActionPrefixRtl : testIdRowActionPrefix)
|
|
95
77
|
: testIdRowActionPrefix;
|
|
96
|
-
|
|
78
|
+
const _testIdNoResults = isRTL
|
|
97
79
|
? (testIdNoResultsRtl !== null && testIdNoResultsRtl !== void 0 ? testIdNoResultsRtl : testIdNoResults)
|
|
98
80
|
: testIdNoResults;
|
|
99
|
-
|
|
81
|
+
const _testIdLoadingRowPrefix = isRTL
|
|
100
82
|
? (testIdLoadingRowPrefixRtl !== null && testIdLoadingRowPrefixRtl !== void 0 ? testIdLoadingRowPrefixRtl : testIdLoadingRowPrefix)
|
|
101
83
|
: testIdLoadingRowPrefix;
|
|
102
|
-
|
|
84
|
+
const _testIdPaginationWrapper = isRTL
|
|
103
85
|
? (testIdPaginationWrapperRtl !== null && testIdPaginationWrapperRtl !== void 0 ? testIdPaginationWrapperRtl : testIdPaginationWrapper)
|
|
104
86
|
: testIdPaginationWrapper;
|
|
105
|
-
|
|
87
|
+
const _testIdFooterPagination = isRTL
|
|
106
88
|
? (testIdFooterPaginationRtl !== null && testIdFooterPaginationRtl !== void 0 ? testIdFooterPaginationRtl : testIdFooterPagination)
|
|
107
89
|
: testIdFooterPagination;
|
|
108
|
-
|
|
90
|
+
const _testIdFooterPage = isRTL
|
|
109
91
|
? (testIdFooterPageRtl !== null && testIdFooterPageRtl !== void 0 ? testIdFooterPageRtl : testIdFooterPage)
|
|
110
92
|
: testIdFooterPage;
|
|
111
|
-
|
|
93
|
+
const _testIdFooterAction = isRTL
|
|
112
94
|
? (testIdFooterActionRtl !== null && testIdFooterActionRtl !== void 0 ? testIdFooterActionRtl : testIdFooterAction)
|
|
113
95
|
: testIdFooterAction;
|
|
114
|
-
|
|
96
|
+
const renderCellContent = (row, col, rowIndex) => {
|
|
115
97
|
var _a, _b;
|
|
116
98
|
// Helper to safely resolve nested keys (max depth 3)
|
|
117
|
-
|
|
99
|
+
const resolveValue = (source, key) => {
|
|
118
100
|
if (!key)
|
|
119
101
|
return source;
|
|
120
102
|
if (typeof key === "string") {
|
|
121
103
|
// Handle colon-separated nested keys
|
|
122
104
|
if (key.includes(":")) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
for (
|
|
126
|
-
var k = keys_2[_i];
|
|
105
|
+
const keys = key.split(":");
|
|
106
|
+
let cur = source;
|
|
107
|
+
for (const k of keys) {
|
|
127
108
|
if (cur == null || typeof cur !== "object")
|
|
128
109
|
return undefined;
|
|
129
110
|
cur = cur[k];
|
|
@@ -136,15 +117,14 @@ var EnhancedTable = function (_a) {
|
|
|
136
117
|
return undefined;
|
|
137
118
|
}
|
|
138
119
|
// array of keys - try each until we find a defined value
|
|
139
|
-
for (
|
|
140
|
-
|
|
141
|
-
var val = resolveValue(source, k);
|
|
120
|
+
for (const k of key) {
|
|
121
|
+
const val = resolveValue(source, k);
|
|
142
122
|
if (val != null)
|
|
143
123
|
return val;
|
|
144
124
|
}
|
|
145
125
|
return undefined;
|
|
146
126
|
};
|
|
147
|
-
|
|
127
|
+
const getProp = (obj, prop) => {
|
|
148
128
|
if (obj &&
|
|
149
129
|
typeof obj === "object" &&
|
|
150
130
|
prop in obj)
|
|
@@ -152,17 +132,17 @@ var EnhancedTable = function (_a) {
|
|
|
152
132
|
return undefined;
|
|
153
133
|
};
|
|
154
134
|
// Resolve value (supports nested key arrays)
|
|
155
|
-
|
|
135
|
+
const value = resolveValue(row, col.key);
|
|
156
136
|
// Normalize componentType so external string enums (like VISTA_TABLE_CELL_TYPE)
|
|
157
137
|
// remain compatible with this table. Unknown/unsupported types fall back to TEXT.
|
|
158
|
-
|
|
138
|
+
const normalizeComponentType = (c) => {
|
|
159
139
|
var _a;
|
|
160
140
|
if (!c)
|
|
161
141
|
return undefined;
|
|
162
142
|
if (Object.values(COMPONENT_TYPE).includes(c))
|
|
163
143
|
return c;
|
|
164
144
|
// Map common external values to our ComponentType using object notation
|
|
165
|
-
|
|
145
|
+
const MAP = {
|
|
166
146
|
ID: COMPONENT_TYPE.ID,
|
|
167
147
|
BOLD_TEXT: COMPONENT_TYPE.BOLD_TEXT,
|
|
168
148
|
BOOLEAN: COMPONENT_TYPE.BOOLEAN,
|
|
@@ -174,42 +154,39 @@ var EnhancedTable = function (_a) {
|
|
|
174
154
|
};
|
|
175
155
|
return (_a = MAP[String(c)]) !== null && _a !== void 0 ? _a : COMPONENT_TYPE.TEXT;
|
|
176
156
|
};
|
|
177
|
-
|
|
157
|
+
const normalizedType = normalizeComponentType(col.componentType);
|
|
178
158
|
if (normalizedType === COMPONENT_TYPE.ACTIONS) {
|
|
179
|
-
return (
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
.filter(function (
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
? "".concat(_testIdRowActionPrefix, "-").concat(rowIndex, "-").concat(index)
|
|
190
|
-
: undefined, className: (0, utils_1.cn)(action.variant === "destructive" &&
|
|
191
|
-
"text-destructive focus:text-destructive"), onClick: function () { var _a; return (_a = action.handleOnClick) === null || _a === void 0 ? void 0 : _a.call(action, row); } }, action.label)); }))));
|
|
159
|
+
return (React.createElement(DropdownMenu, null,
|
|
160
|
+
React.createElement(DropdownMenuTrigger, { asChild: true },
|
|
161
|
+
React.createElement(MoreHorizontal, { className: "h-4 w-4" })),
|
|
162
|
+
React.createElement(DropdownMenuContent, { align: "end" }, rowActions
|
|
163
|
+
.filter(({ enabled }) => typeof enabled === "function" ? enabled(row) : enabled)
|
|
164
|
+
.sort((a, b) => (a.order || 0) - (b.order || 0))
|
|
165
|
+
.map((action, index) => (React.createElement(DropdownMenuItem, { key: action.id || action.key || index, "data-testid": _testIdRowActionPrefix
|
|
166
|
+
? `${_testIdRowActionPrefix}-${rowIndex}-${index}`
|
|
167
|
+
: undefined, className: cn(action.variant === "destructive" &&
|
|
168
|
+
"text-destructive focus:text-destructive"), onClick: () => { var _a; return (_a = action.handleOnClick) === null || _a === void 0 ? void 0 : _a.call(action, row); } }, action.label))))));
|
|
192
169
|
}
|
|
193
170
|
if (normalizedType === COMPONENT_TYPE.ID) {
|
|
194
|
-
return (
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
?
|
|
171
|
+
return (React.createElement(Popover, null,
|
|
172
|
+
React.createElement(PopoverTrigger, { asChild: true },
|
|
173
|
+
React.createElement("span", { className: "text-xs text-muted-foreground font-mono" }, typeof value === "string"
|
|
174
|
+
? `${value.substring(0, 8)}...`
|
|
198
175
|
: String(value || ""))),
|
|
199
|
-
|
|
200
|
-
|
|
176
|
+
React.createElement(PopoverContent, null,
|
|
177
|
+
React.createElement("span", { className: "text-xs text-muted-foreground font-mono" }, col.textFormatter
|
|
201
178
|
? col.textFormatter(value, row)
|
|
202
179
|
: String(value)))));
|
|
203
180
|
}
|
|
204
181
|
if (normalizedType === COMPONENT_TYPE.BOLD_TEXT) {
|
|
205
|
-
|
|
182
|
+
const formatted = col.textFormatter
|
|
206
183
|
? col.textFormatter(value, row)
|
|
207
184
|
: String(value || "");
|
|
208
|
-
return
|
|
185
|
+
return React.createElement("span", { className: "font-semibold" }, formatted);
|
|
209
186
|
}
|
|
210
187
|
if (normalizedType === COMPONENT_TYPE.BOOLEAN) {
|
|
211
|
-
|
|
212
|
-
return (
|
|
188
|
+
const isTrue = Boolean(value);
|
|
189
|
+
return (React.createElement(Badge, { variant: "secondary", className: cn("text-white font-medium", isTrue
|
|
213
190
|
? "bg-green-500 hover:bg-green-600"
|
|
214
191
|
: "bg-red-500 hover:bg-red-600") }, isTrue ? labels.booleanYes : labels.booleanNo));
|
|
215
192
|
}
|
|
@@ -217,18 +194,16 @@ var EnhancedTable = function (_a) {
|
|
|
217
194
|
// e.g., ["user:company", "profile:department"] with fallback support
|
|
218
195
|
// If first path is undefined, try the next one. If all undefined, render '-'
|
|
219
196
|
if (normalizedType === COMPONENT_TYPE.OBJECT) {
|
|
220
|
-
|
|
197
|
+
let nested;
|
|
221
198
|
// Key must be an array of colon-separated strings
|
|
222
199
|
if (Array.isArray(col.key)) {
|
|
223
200
|
// Try each key path until we find a defined value
|
|
224
|
-
for (
|
|
225
|
-
var keyPath = _c[_i];
|
|
201
|
+
for (const keyPath of col.key) {
|
|
226
202
|
if (typeof keyPath === "string" && keyPath.includes(":")) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
for (
|
|
231
|
-
var k = keys_1[_d];
|
|
203
|
+
const keys = keyPath.split(":");
|
|
204
|
+
let cur = row;
|
|
205
|
+
let found = true;
|
|
206
|
+
for (const k of keys) {
|
|
232
207
|
if (cur == null || typeof cur !== "object") {
|
|
233
208
|
found = false;
|
|
234
209
|
break;
|
|
@@ -244,86 +219,83 @@ var EnhancedTable = function (_a) {
|
|
|
244
219
|
}
|
|
245
220
|
// If all paths are undefined, render '-'
|
|
246
221
|
if (nested == null)
|
|
247
|
-
return
|
|
222
|
+
return React.createElement("span", null, "-");
|
|
248
223
|
// If nested is an object, try to find a primitive value
|
|
249
224
|
if (typeof nested === "object") {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
var toRender = primitive !== null && primitive !== void 0 ? primitive : JSON.stringify(nested);
|
|
254
|
-
return (react_1.default.createElement("span", null, col.textFormatter
|
|
225
|
+
const primitive = Object.values(nested).find((v) => ["string", "number", "boolean"].includes(typeof v));
|
|
226
|
+
const toRender = primitive !== null && primitive !== void 0 ? primitive : JSON.stringify(nested);
|
|
227
|
+
return (React.createElement("span", null, col.textFormatter
|
|
255
228
|
? col.textFormatter(toRender, row)
|
|
256
229
|
: String(toRender)));
|
|
257
230
|
}
|
|
258
231
|
// Nested is a primitive value
|
|
259
|
-
return (
|
|
232
|
+
return (React.createElement("span", null, col.textFormatter ? col.textFormatter(nested, row) : String(nested)));
|
|
260
233
|
} // MULTIPLE_TEXT_LINES => col.key is an array of keys, render up to 3 lines
|
|
261
234
|
if (normalizedType === COMPONENT_TYPE.MULTIPLE_TEXT_LINES) {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
235
|
+
const keys = Array.isArray(col.key) ? col.key : [];
|
|
236
|
+
const lines = keys.slice(0, 3).map((k) => {
|
|
237
|
+
const v = resolveValue(row, k);
|
|
265
238
|
return v == null ? "" : String(v);
|
|
266
239
|
});
|
|
267
|
-
return (
|
|
240
|
+
return (React.createElement("div", { className: "flex flex-col" }, lines.map((line, idx) => (React.createElement("span", { key: idx, className: "text-sm" }, col.textFormatter ? col.textFormatter(line, row) : line)))));
|
|
268
241
|
}
|
|
269
242
|
// CREATED_UPDATED_AT => show createdAt and updatedAt from the object (or nested object)
|
|
270
243
|
if (normalizedType === COMPONENT_TYPE.CREATED_UPDATED_AT) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
244
|
+
const target = resolveValue(row, col.key);
|
|
245
|
+
const created = (_a = getProp(target, "createdAt")) !== null && _a !== void 0 ? _a : getProp(row, "createdAt");
|
|
246
|
+
const updated = (_b = getProp(target, "updatedAt")) !== null && _b !== void 0 ? _b : getProp(row, "updatedAt");
|
|
247
|
+
const fmt = (d) => {
|
|
275
248
|
if (d == null)
|
|
276
249
|
return "";
|
|
277
|
-
|
|
250
|
+
const date = d instanceof Date ? d : new Date(String(d));
|
|
278
251
|
if (isNaN(date.getTime()))
|
|
279
252
|
return String(d);
|
|
280
253
|
return date.toLocaleString();
|
|
281
254
|
};
|
|
282
|
-
return (
|
|
283
|
-
|
|
284
|
-
|
|
255
|
+
return (React.createElement("div", { className: "flex flex-col text-sm text-muted-foreground" },
|
|
256
|
+
React.createElement("span", null, fmt(created)),
|
|
257
|
+
React.createElement("span", null, fmt(updated))));
|
|
285
258
|
}
|
|
286
|
-
return (
|
|
259
|
+
return (React.createElement("span", null, col.textFormatter
|
|
287
260
|
? col.textFormatter(value, row)
|
|
288
261
|
: String(value || "")));
|
|
289
262
|
};
|
|
290
263
|
// Create loading skeleton rows
|
|
291
|
-
|
|
292
|
-
return Array.from({ length: pageLimit || 5 }).map(
|
|
293
|
-
?
|
|
294
|
-
: undefined }, tableHeadItems.map(
|
|
295
|
-
|
|
264
|
+
const renderLoadingRows = () => {
|
|
265
|
+
return Array.from({ length: pageLimit || 5 }).map((_, index) => (React.createElement(TableRow, { key: `loading-${index}`, className: "hover:bg-muted/50", "data-testid": _testIdLoadingRowPrefix
|
|
266
|
+
? `${_testIdLoadingRowPrefix}-${index}`
|
|
267
|
+
: undefined }, tableHeadItems.map((_, colIndex) => (React.createElement(TableCell, { key: colIndex, className: "py-4" },
|
|
268
|
+
React.createElement("div", { className: "h-4 bg-muted animate-pulse rounded w-full" })))))));
|
|
296
269
|
};
|
|
297
|
-
return (
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
tableDescription && (
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
?
|
|
314
|
-
: undefined }, tableBodyCols.map(
|
|
315
|
-
?
|
|
316
|
-
: undefined, onClick:
|
|
270
|
+
return (React.createElement("div", { className: "space-y-4", "data-testid": _testIdWrapper },
|
|
271
|
+
React.createElement("div", { className: "flex items-center justify-between" },
|
|
272
|
+
React.createElement("div", { className: "space-y-1" },
|
|
273
|
+
React.createElement("h2", { className: "text-2xl font-bold tracking-tight", "data-testid": _testIdHeading }, tableHeading),
|
|
274
|
+
tableDescription && (React.createElement("p", { className: "text-muted-foreground", "data-testid": _testIdTableDescription }, tableDescription))),
|
|
275
|
+
React.createElement("div", { className: "flex flex-row items-center justify-end gap-2" },
|
|
276
|
+
React.createElement("div", { "data-testid": _testIdSearch },
|
|
277
|
+
React.createElement(EnhancedTableHeaderSearch, { handleSearchInput: handleSearchInput, loading: loading, searchDisabled: searchDisabled, searchEnabled: searchEnabled, searchId: searchId, searchPlaceholder: searchPlaceholder, searchValue: searchValue })),
|
|
278
|
+
React.createElement("div", { "data-testid": _testIdHeaderActions },
|
|
279
|
+
React.createElement(EnhancedTableHeaderAction, { headerActions: headerActions, numberOfFilters: numberOfFilters, onClearFilters: onClearFilters, testIdActionPrefix: _testIdHeaderActionPrefix, testIdClearFilters: _testIdHeaderActionClearFilters, testIdFilterBadge: _testIdHeaderActionFilterBadge })))),
|
|
280
|
+
React.createElement("div", { className: "border rounded-md", "data-testid": _testIdTableWrapper },
|
|
281
|
+
React.createElement(Table, null,
|
|
282
|
+
React.createElement(TableHeader, null,
|
|
283
|
+
React.createElement(TableRow, null, tableHeadItems.map((header, index) => (React.createElement(TableHead, { key: index, style: { width: header.width }, className: cn("font-medium", index === 0 && "rounded-tl-md", index === tableHeadItems.length - 1 && "rounded-tr-md") }, header.label))))),
|
|
284
|
+
React.createElement(TableBody, null, loading ? (renderLoadingRows()) : tableBodyRows.length === 0 ? (React.createElement(TableRow, null,
|
|
285
|
+
React.createElement(TableCell, { colSpan: tableHeadItems.length, className: "h-24 text-center text-muted-foreground", "data-testid": _testIdNoResults }, labels.noResultsFound))) : (tableBodyRows.map((row, rowIndex) => (React.createElement(TableRow, { key: rowIndex, className: "hover:bg-muted/50", "data-testid": _testIdRowPrefix
|
|
286
|
+
? `${_testIdRowPrefix}-${rowIndex}`
|
|
287
|
+
: undefined }, tableBodyCols.map((col, colIndex) => (React.createElement(TableCell, { key: colIndex, className: cn("py-4 cursor-pointer"), "data-testid": _testIdCellPrefix
|
|
288
|
+
? `${_testIdCellPrefix}-${rowIndex}-${colIndex}`
|
|
289
|
+
: undefined, onClick: (e) => {
|
|
317
290
|
var _a;
|
|
318
291
|
return (_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText(e.currentTarget.textContent || "");
|
|
319
|
-
} }, renderCellContent(row, col, rowIndex)))
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
292
|
+
} }, renderCellContent(row, col, rowIndex))))))))))),
|
|
293
|
+
React.createElement("div", { className: "flex items-center justify-between", "data-testid": _testIdPaginationWrapper },
|
|
294
|
+
React.createElement("div", { "data-testid": _testIdFooterPagination },
|
|
295
|
+
React.createElement(EnhancedTableFooterPagination, { handleOnSelect: handleOnSelect, isRTL: isRTL, listOptions: listOptions, loading: loading, nodeSelectKey: nodeSelectKey, pageLimit: pageLimit, rowsPerPageLabel: labels.rowsPerPage, totalPages: totalPages })),
|
|
296
|
+
React.createElement("div", { className: "flex items-center gap-4" },
|
|
297
|
+
React.createElement("div", { "data-testid": _testIdFooterPage },
|
|
298
|
+
React.createElement(EnhancedTableFooterPage, { currentPage: currentPage, isRTL: isRTL, loading: loading, loadingLabel: labels.loading, ofLabel: labels.of, pageLabel: labels.page, totalPages: totalPages })),
|
|
299
|
+
React.createElement("div", { "data-testid": _testIdFooterAction },
|
|
300
|
+
React.createElement(EnhancedTableFooterAction, { handleNextOnClick: handleNextOnClick, handlePreviousOnClick: handlePreviousOnClick, isNextDisabled: isNextDisabled, isPreviousDisabled: isPreviousDisabled, isRTL: isRTL, loading: loading, nextPageLabel: labels.nextPage, previousPageLabel: labels.previousPage }))))));
|
|
328
301
|
};
|
|
329
|
-
exports.EnhancedTable = EnhancedTable;
|