flikkui 0.1.0-beta.4 → 0.1.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/charts/AreaChart/AreaChart.js +434 -0
- package/dist/components/charts/AreaChart/AreaChart.types.js +7 -0
- package/dist/components/charts/BarChart/BarChart.js +402 -0
- package/dist/components/charts/BarChart/BarChart.types.js +7 -0
- package/dist/components/charts/ChartContainer.js +38 -0
- package/dist/components/charts/Heatmap/Heatmap.js +153 -0
- package/dist/components/charts/Heatmap/HeatmapCell.js +100 -0
- package/dist/components/charts/Heatmap/HeatmapLegend.js +20 -0
- package/dist/components/charts/Heatmap/utils/heatmapUtils.js +174 -0
- package/dist/components/charts/LineChart/LineChart.js +396 -0
- package/dist/components/charts/LineChart/LineChart.types.js +7 -0
- package/dist/components/charts/hooks/useChartAccessibility.js +127 -0
- package/dist/components/charts/hooks/useChartTheme.js +86 -0
- package/dist/components/charts/hooks/useChartValidation.js +59 -0
- package/dist/components/charts/hooks/useTooltipPosition.js +292 -0
- package/dist/components/charts/shared/ChartAxis/XAxis.js +30 -0
- package/dist/components/charts/shared/ChartAxis/YAxis.js +97 -0
- package/dist/components/charts/shared/ChartCrosshair/ChartCrosshair.js +35 -0
- package/dist/components/charts/shared/ChartCrosshair/ChartCrosshair.theme.js +11 -0
- package/dist/components/charts/shared/ChartErrorBoundary/ChartErrorBoundary.js +66 -0
- package/dist/components/charts/shared/ChartGrid/HorizontalGrid.js +22 -0
- package/dist/components/charts/shared/ChartLegend/ChartLegend.js +30 -0
- package/dist/components/charts/shared/ChartLegend/ChartLegendContent.js +22 -0
- package/dist/components/charts/shared/ChartMarker/ChartMarker.js +25 -0
- package/dist/components/charts/shared/ChartMarker/ChartMarker.theme.js +9 -0
- package/dist/components/charts/shared/ChartText/ChartText.js +33 -0
- package/dist/components/charts/shared/ChartText/ChartText.theme.js +9 -0
- package/dist/components/charts/shared/ChartTooltip/ChartTooltip.js +62 -0
- package/dist/components/charts/theme/chart.theme.js +73 -0
- package/dist/components/charts/types/chart.types.js +29 -0
- package/dist/components/charts/utils/chart-validation.js +292 -0
- package/dist/components/charts/utils/color-utils.js +175 -0
- package/dist/components/core/Accordion/Accordion.animations.js +45 -0
- package/dist/components/core/Accordion/Accordion.js +52 -0
- package/dist/components/core/Accordion/Accordion.theme.js +8 -0
- package/dist/components/core/Accordion/AccordionContent.js +25 -0
- package/dist/components/core/Accordion/AccordionItem.js +56 -0
- package/dist/components/core/Accordion/AccordionTrigger.js +32 -0
- package/dist/components/core/Accordion/index.js +5 -0
- package/dist/components/core/Avatar/Avatar.js +94 -0
- package/dist/components/core/Avatar/Avatar.theme.js +25 -0
- package/dist/components/core/AvatarGroup/AvatarGroup.animations.js +79 -0
- package/dist/components/core/AvatarGroup/AvatarGroup.js +67 -0
- package/dist/components/core/AvatarGroup/AvatarGroup.theme.js +23 -0
- package/dist/components/core/Badge/Badge.animations.js +109 -0
- package/dist/components/core/Badge/Badge.js +101 -0
- package/dist/components/core/Badge/Badge.theme.js +41 -0
- package/dist/components/core/Breadcrumbs/Breadcrumbs.theme.js +8 -8
- package/dist/components/core/Button/Button.theme.js +5 -5
- package/dist/components/core/Card/Card.js +46 -0
- package/dist/components/core/Card/Card.theme.js +5 -0
- package/dist/components/core/Divider/Divider.js +21 -0
- package/dist/components/core/Divider/Divider.theme.js +19 -0
- package/dist/components/core/Pagination/Pagination.js +113 -0
- package/dist/components/core/Pagination/Pagination.theme.js +27 -0
- package/dist/components/core/Segmented/Segmented.js +69 -0
- package/dist/components/core/Segmented/Segmented.theme.js +40 -0
- package/dist/components/core/Segmented/SegmentedContext.js +8 -0
- package/dist/components/core/Segmented/SegmentedItem.js +30 -0
- package/dist/components/core/Stepper/Stepper.js +57 -0
- package/dist/components/core/Stepper/Stepper.theme.js +9 -0
- package/dist/components/core/Stepper/components/ConnectorLine.js +42 -0
- package/dist/components/core/Stepper/components/IconCircle.js +44 -0
- package/dist/components/core/Stepper/components/ProgressIndicator.js +12 -0
- package/dist/components/core/Stepper/components/StepContent.js +36 -0
- package/dist/components/core/Stepper/components/StepperItem.js +22 -0
- package/dist/components/core/Tabs/Tabs.theme.js +2 -2
- package/dist/components/core/Tooltip/Tooltip.animations.js +46 -0
- package/dist/components/core/Tooltip/Tooltip.js +85 -0
- package/dist/components/core/Tooltip/Tooltip.theme.js +11 -0
- package/dist/components/core/Tooltip/useTooltipPositioning.js +59 -0
- package/dist/components/core/Tree/Tree.animations.js +38 -0
- package/dist/components/core/Tree/Tree.js +177 -0
- package/dist/components/core/Tree/Tree.theme.js +11 -0
- package/dist/components/data-display/Table/Table.js +177 -0
- package/dist/components/data-display/Table/Table.theme.js +28 -0
- package/dist/components/data-display/Table/Table.utils.js +28 -0
- package/dist/components/data-display/Table/components/DeclarativeComponents.js +123 -0
- package/dist/components/data-display/Table/components/TableActions/TableActions.js +56 -0
- package/dist/components/data-display/Table/components/TableActions/TableActionsMenu.js +29 -0
- package/dist/components/data-display/Table/components/TableColumnManager/TableColumnManager.js +85 -0
- package/dist/components/data-display/Table/components/TableColumnManager/TableColumnManager.theme.js +21 -0
- package/dist/components/data-display/Table/components/TablePagination/TablePagination.js +51 -0
- package/dist/components/data-display/Table/components/TableSelectionHeader/TableSelectionHeader.js +29 -0
- package/dist/components/data-display/Table/components/core/TableBody.js +32 -0
- package/dist/components/data-display/Table/components/core/TableCell.js +47 -0
- package/dist/components/data-display/Table/components/core/TableHeader.js +77 -0
- package/dist/components/data-display/Table/components/core/TableRow.js +46 -0
- package/dist/components/data-display/Table/index.js +20 -0
- package/dist/components/feedback/Alert/Alert.js +36 -0
- package/dist/components/feedback/Alert/Alert.theme.js +17 -0
- package/dist/components/feedback/ChatMessage/ChatMessage.js +26 -0
- package/dist/components/feedback/ChatMessage/ChatMessage.theme.js +16 -0
- package/dist/components/feedback/Empty/Empty.js +26 -0
- package/dist/components/feedback/Empty/Empty.theme.js +13 -0
- package/dist/components/feedback/Notification/Notification.js +41 -0
- package/dist/components/feedback/Notification/Notification.theme.js +49 -0
- package/dist/components/feedback/Spinner/Spinner.theme.js +3 -3
- package/dist/components/feedback/Toast/Toast.animations.js +58 -0
- package/dist/components/feedback/Toast/Toast.js +67 -0
- package/dist/components/feedback/Toast/Toast.theme.js +18 -0
- package/dist/components/feedback/Toast/ToastProvider.js +73 -0
- package/dist/components/feedback/Toast/useToast.js +91 -0
- package/dist/components/forms/Checkbox/Checkbox.theme.js +1 -1
- package/dist/components/forms/FormLabel/FormLabel.theme.js +2 -2
- package/dist/components/forms/Input/Input.theme.js +4 -4
- package/dist/components/forms/Radio/Radio.theme.js +2 -2
- package/dist/components/forms/Select/Select.js +1 -1
- package/dist/components/forms/Select/Select.theme.js +5 -5
- package/dist/components/forms/Switch/Switch.theme.js +1 -1
- package/dist/components/forms/TimePicker/TimePicker.theme.js +19 -19
- package/dist/components/forms/forms.theme.js +8 -8
- package/dist/components/navigation/NavItem/NavItem.js +93 -0
- package/dist/components/navigation/NavItem/NavItem.theme.js +27 -0
- package/dist/components/navigation/Sidebar/Sidebar.js +28 -0
- package/dist/components/navigation/Sidebar/Sidebar.theme.js +16 -0
- package/dist/components/navigation/Sidebar/SidebarContent.js +12 -0
- package/dist/components/navigation/Sidebar/SidebarContext.js +38 -0
- package/dist/components/navigation/Sidebar/SidebarFooter.js +11 -0
- package/dist/components/navigation/Sidebar/SidebarHeader.js +22 -0
- package/dist/components/navigation/Sidebar/SidebarNav.js +11 -0
- package/dist/components/navigation/Sidebar/SidebarNavGroup.js +19 -0
- package/dist/components/navigation/Sidebar/SidebarToggle.js +26 -0
- package/dist/icons/core/TickIcon.js +3 -1
- package/dist/index.d.ts +29 -4
- package/dist/index.js +64 -4
- package/dist/node_modules/@heroicons/react/20/solid/esm/ChevronDownIcon.js +26 -0
- package/dist/node_modules/@heroicons/react/24/outline/esm/ChevronDoubleLeftIcon.js +28 -0
- package/dist/node_modules/@heroicons/react/24/outline/esm/ChevronDoubleRightIcon.js +28 -0
- package/dist/node_modules/@heroicons/react/24/outline/esm/ChevronLeftIcon.js +28 -0
- package/dist/node_modules/@heroicons/react/24/outline/esm/Cog6ToothIcon.js +32 -0
- package/dist/node_modules/@heroicons/react/24/outline/esm/DocumentIcon.js +28 -0
- package/dist/node_modules/@heroicons/react/24/outline/esm/EllipsisVerticalIcon.js +28 -0
- package/dist/node_modules/@heroicons/react/24/outline/esm/PlusIcon.js +28 -0
- package/dist/node_modules/@heroicons/react/24/solid/esm/ArrowPathIcon.js +26 -0
- package/dist/node_modules/@heroicons/react/24/solid/esm/BellIcon.js +26 -0
- package/dist/node_modules/@heroicons/react/24/solid/esm/CheckCircleIcon.js +26 -0
- package/dist/node_modules/@heroicons/react/24/solid/esm/ExclamationTriangleIcon.js +26 -0
- package/dist/node_modules/@heroicons/react/24/solid/esm/InformationCircleIcon.js +26 -0
- package/dist/node_modules/@heroicons/react/24/solid/esm/XCircleIcon.js +26 -0
- package/dist/node_modules/@heroicons/react/24/solid/esm/XMarkIcon.js +26 -0
- package/dist/node_modules/tslib/tslib.es6.js +15 -1
- package/dist/utils/dateUtils.js +32 -0
- package/dist/utils/debounce.js +21 -0
- package/package.json +1 -1
- package/dist/styles.css +0 -2
package/dist/components/data-display/Table/components/TableColumnManager/TableColumnManager.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { __assign, __spreadArray } from '../../../../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import React__default, { useRef, useEffect } from 'react';
|
|
3
|
+
import { tableColumnManagerTheme } from './TableColumnManager.theme.js';
|
|
4
|
+
import { cn } from '../../../../../utils/cn.js';
|
|
5
|
+
import { Checkbox } from '../../../../forms/Checkbox/Checkbox.js';
|
|
6
|
+
import Button from '../../../../core/Button/Button.js';
|
|
7
|
+
import { Sortable, SortableItem } from '../../../../layout/Sortable/Sortable.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* TableColumnManager component for managing column visibility in tables
|
|
11
|
+
* Follows the established library patterns with proper theming and accessibility
|
|
12
|
+
*/
|
|
13
|
+
var TableColumnManagerComponent = function (_a) {
|
|
14
|
+
var columns = _a.columns, visibleColumns = _a.visibleColumns, initialVisibleColumns = _a.initialVisibleColumns, onVisibleColumnsChange = _a.onVisibleColumnsChange, onColumnReorder = _a.onColumnReorder, onColumnOrderReset = _a.onColumnOrderReset, onClose = _a.onClose, className = _a.className, themeOverrides = _a.theme;
|
|
15
|
+
var dialogRef = useRef(null);
|
|
16
|
+
// Focus management for accessibility
|
|
17
|
+
useEffect(function () {
|
|
18
|
+
var _a;
|
|
19
|
+
var focusableElements = (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('button, input, [tabindex]:not([tabindex="-1"])');
|
|
20
|
+
var firstElement = focusableElements === null || focusableElements === void 0 ? void 0 : focusableElements[0];
|
|
21
|
+
// Focus first interactive element when dialog opens
|
|
22
|
+
if (firstElement) {
|
|
23
|
+
firstElement.focus();
|
|
24
|
+
}
|
|
25
|
+
}, []);
|
|
26
|
+
// Handle keyboard navigation
|
|
27
|
+
var handleKeyDown = function (event) {
|
|
28
|
+
if (event.key === "Escape") {
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
onClose();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
// Merge theme with overrides
|
|
34
|
+
var theme = __assign(__assign({}, tableColumnManagerTheme), themeOverrides);
|
|
35
|
+
var handleToggleColumn = function (columnId) {
|
|
36
|
+
// Prevent toggling locked columns
|
|
37
|
+
var column = columns.find(function (col) { return col.id === columnId; });
|
|
38
|
+
if (column === null || column === void 0 ? void 0 : column.locked) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
var newVisibleColumns = visibleColumns.includes(columnId)
|
|
42
|
+
? visibleColumns.filter(function (id) { return id !== columnId; })
|
|
43
|
+
: __spreadArray(__spreadArray([], visibleColumns, true), [columnId], false);
|
|
44
|
+
onVisibleColumnsChange(newVisibleColumns);
|
|
45
|
+
};
|
|
46
|
+
var handleResetToDefault = function () {
|
|
47
|
+
// Get all locked column IDs to ensure they remain visible
|
|
48
|
+
var lockedColumnIds = columns.filter(function (col) { return col.locked; }).map(function (col) { return col.id; });
|
|
49
|
+
// Combine initial visible columns with locked columns (remove duplicates)
|
|
50
|
+
var resetVisibleColumns = Array.from(new Set(__spreadArray(__spreadArray([], initialVisibleColumns, true), lockedColumnIds, true)));
|
|
51
|
+
// Reset to initial visible columns with locked columns guaranteed to be visible
|
|
52
|
+
onVisibleColumnsChange(resetVisibleColumns);
|
|
53
|
+
// Reset column order to default if handler is provided
|
|
54
|
+
onColumnOrderReset === null || onColumnOrderReset === void 0 ? void 0 : onColumnOrderReset();
|
|
55
|
+
};
|
|
56
|
+
var handleColumnReorder = function (fromIndex, toIndex) {
|
|
57
|
+
if (onColumnReorder) {
|
|
58
|
+
onColumnReorder(fromIndex, toIndex);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
return (React__default.createElement("div", { ref: dialogRef, className: cn(theme.container, className), role: "dialog", "aria-labelledby": "column-manager-title", "aria-describedby": "column-manager-description", "aria-modal": "true", onKeyDown: handleKeyDown },
|
|
62
|
+
React__default.createElement("div", { id: "column-manager-title", className: theme.header }, "Manage Columns"),
|
|
63
|
+
React__default.createElement("div", { id: "column-manager-description", className: "sr-only" }, "Use checkboxes to control which columns are visible in the table. Locked columns cannot be hidden."),
|
|
64
|
+
React__default.createElement("div", { className: theme.columnList, role: "group", "aria-label": "Column visibility options" }, onColumnReorder ? (React__default.createElement(Sortable, { onReorder: handleColumnReorder, showDragHandle: true, className: "space-y-0.5" }, columns.map(function (column) {
|
|
65
|
+
var isVisible = visibleColumns.includes(column.id);
|
|
66
|
+
var isLocked = column.locked === true;
|
|
67
|
+
var displayName = typeof column.header === "string" ? column.header : column.id;
|
|
68
|
+
return (React__default.createElement(SortableItem, { key: column.id, id: column.id, disabled: isLocked, className: cn(theme.columnItem, isLocked && "bg-gray-50") },
|
|
69
|
+
React__default.createElement(Checkbox, { id: "column-checkbox-".concat(column.id), name: "column-".concat(column.id), value: column.id, checked: isVisible, onChange: function () { return handleToggleColumn(column.id); }, "aria-label": "Toggle visibility for ".concat(displayName, " column"), label: displayName, state: isLocked ? "disabled" : "default" })));
|
|
70
|
+
}))) : (columns.map(function (column) {
|
|
71
|
+
var isVisible = visibleColumns.includes(column.id);
|
|
72
|
+
var isLocked = column.locked === true;
|
|
73
|
+
var displayName = typeof column.header === "string" ? column.header : column.id;
|
|
74
|
+
return (React__default.createElement("div", { key: column.id, className: cn(theme.columnItem, isLocked && "bg-gray-50") },
|
|
75
|
+
React__default.createElement(Checkbox, { id: "column-checkbox-".concat(column.id), name: "column-".concat(column.id), value: column.id, checked: isVisible, onChange: function () { return handleToggleColumn(column.id); }, "aria-label": "Toggle visibility for ".concat(displayName, " column"), label: displayName, state: isLocked ? "disabled" : "default" })));
|
|
76
|
+
}))),
|
|
77
|
+
React__default.createElement("div", { className: theme.footer },
|
|
78
|
+
React__default.createElement(Button, { variant: "secondary", className: "w-full", onClick: handleResetToDefault }, "Reset to Default"))));
|
|
79
|
+
};
|
|
80
|
+
// Set display name for dev tools
|
|
81
|
+
TableColumnManagerComponent.displayName = "TableColumnManager";
|
|
82
|
+
// Memoize component to prevent unnecessary re-renders
|
|
83
|
+
var TableColumnManager = React__default.memo(TableColumnManagerComponent);
|
|
84
|
+
|
|
85
|
+
export { TableColumnManager };
|
package/dist/components/data-display/Table/components/TableColumnManager/TableColumnManager.theme.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var tableColumnManagerTheme = {
|
|
2
|
+
container: "w-64 z-50 p-3 overflow-hidden bg-white border border-border rounded-lg shadow-lg",
|
|
3
|
+
content: "space-y-3",
|
|
4
|
+
header: "text-xs uppercase font-bold mb-3 text-text-placeholder",
|
|
5
|
+
title: "text-sm font-medium text-text-primary",
|
|
6
|
+
description: "text-xs text-text-muted mt-1",
|
|
7
|
+
actions: "flex items-center gap-2 mb-3",
|
|
8
|
+
quickActionButton: "text-xs px-2 py-1 text-[var(--color-primary)] hover:text-[var(--color-primary)] hover:bg-[var(--color-primary-50)] rounded transition-colors",
|
|
9
|
+
quickActionButtonDisabled: "text-xs px-2 py-1 text-text-disabled cursor-not-allowed",
|
|
10
|
+
columnList: "space-y-2",
|
|
11
|
+
columnItem: "bg-white hover:bg-[var(--color-neutral-50)] rounded-lg p-1.5 transition-colors",
|
|
12
|
+
columnItemVisible: "bg-white hover:bg-[var(--color-neutral-50)] rounded-lg p-1.5",
|
|
13
|
+
checkbox: "",
|
|
14
|
+
columnLabel: "text-sm text-text-primary",
|
|
15
|
+
columnIcon: "w-4 h-4 text-text-muted",
|
|
16
|
+
footer: "mt-3 flex justify-end",
|
|
17
|
+
summary: "text-xs text-text-muted",
|
|
18
|
+
closeButton: "text-sm px-3 py-1.5 text-text-primary hover:bg-[var(--color-neutral-50)] rounded-md transition-colors",
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { tableColumnManagerTheme };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import Pagination from '../../../../core/Pagination/Pagination.js';
|
|
3
|
+
import { Select } from '../../../../forms/Select/Select.js';
|
|
4
|
+
import '../../../../forms/Select/Select.theme.js';
|
|
5
|
+
import { cn } from '../../../../../utils/cn.js';
|
|
6
|
+
import '../../../../../node_modules/tslib/tslib.es6.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* TablePagination provides a standardized pagination interface for tables
|
|
10
|
+
* Combines the core Pagination component with page size selection controls
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* <Table.Pagination
|
|
14
|
+
* currentPage={currentPage}
|
|
15
|
+
* totalItems={data.length}
|
|
16
|
+
* pageSize={pageSize}
|
|
17
|
+
* onPageChange={setCurrentPage}
|
|
18
|
+
* onPageSizeChange={setPageSize}
|
|
19
|
+
* pageSizeOptions={[10, 25, 50, 100]}
|
|
20
|
+
* />
|
|
21
|
+
*/
|
|
22
|
+
var TablePagination = function (_a) {
|
|
23
|
+
var currentPage = _a.currentPage, totalItems = _a.totalItems, pageSize = _a.pageSize, _b = _a.pageSizeOptions, pageSizeOptions = _b === void 0 ? [10, 25, 50, 100] : _b, onPageChange = _a.onPageChange, onPageSizeChange = _a.onPageSizeChange, _c = _a.showPageSizeSelector, showPageSizeSelector = _c === void 0 ? true : _c, className = _a.className;
|
|
24
|
+
var totalPages = Math.ceil(totalItems / pageSize);
|
|
25
|
+
var startItem = (currentPage - 1) * pageSize + 1;
|
|
26
|
+
var endItem = Math.min(currentPage * pageSize, totalItems);
|
|
27
|
+
// Create options for the Select component
|
|
28
|
+
var pageSizeSelectOptions = pageSizeOptions.map(function (option) { return ({
|
|
29
|
+
id: option,
|
|
30
|
+
label: option.toString(),
|
|
31
|
+
value: option,
|
|
32
|
+
}); });
|
|
33
|
+
return (React__default.createElement("div", { className: cn("flex items-center justify-between px-4 py-3 border-t border-border bg-white", className) },
|
|
34
|
+
React__default.createElement("div", { className: "flex items-center gap-4" },
|
|
35
|
+
showPageSizeSelector && (React__default.createElement("div", { className: "flex items-center gap-2" },
|
|
36
|
+
React__default.createElement("span", { className: "text-sm text-text-muted" }, "Rows per page:"),
|
|
37
|
+
React__default.createElement(Select, { value: pageSize, onChange: function (value) { return onPageSizeChange(value); }, options: pageSizeSelectOptions, size: "sm", className: "w-20" }))),
|
|
38
|
+
React__default.createElement("div", { className: "text-sm text-text-muted" }, totalItems > 0 ? (React__default.createElement(React__default.Fragment, null,
|
|
39
|
+
"Showing ",
|
|
40
|
+
startItem.toLocaleString(),
|
|
41
|
+
" to ",
|
|
42
|
+
endItem.toLocaleString(),
|
|
43
|
+
" of",
|
|
44
|
+
" ",
|
|
45
|
+
totalItems.toLocaleString(),
|
|
46
|
+
" results")) : ("No results"))),
|
|
47
|
+
totalPages > 1 && (React__default.createElement(Pagination, { currentPage: currentPage, totalPages: totalPages, onPageChange: onPageChange, showPrevNext: true, showFirstLast: false, siblingCount: 1 }))));
|
|
48
|
+
};
|
|
49
|
+
TablePagination.displayName = "Table.Pagination";
|
|
50
|
+
|
|
51
|
+
export { TablePagination };
|
package/dist/components/data-display/Table/components/TableSelectionHeader/TableSelectionHeader.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import Button from '../../../../core/Button/Button.js';
|
|
3
|
+
import { cn } from '../../../../../utils/cn.js';
|
|
4
|
+
import '../../../../../node_modules/tslib/tslib.es6.js';
|
|
5
|
+
import ForwardRef from '../../../../../node_modules/@heroicons/react/24/outline/esm/XMarkIcon.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Selection header that appears when rows are selected
|
|
9
|
+
* Shows selection count and bulk action buttons
|
|
10
|
+
*/
|
|
11
|
+
var TableSelectionHeader = function (_a) {
|
|
12
|
+
var selectedCount = _a.selectedCount, totalCount = _a.totalCount, selectedRows = _a.selectedRows, _b = _a.bulkActions, bulkActions = _b === void 0 ? [] : _b, onClearSelection = _a.onClearSelection, className = _a.className;
|
|
13
|
+
if (selectedCount === 0)
|
|
14
|
+
return null;
|
|
15
|
+
return (React__default.createElement("div", { className: cn("flex items-center justify-between px-3 py-1 rounded-lg shadow-xl bg-neutral-50 z-10", className) },
|
|
16
|
+
React__default.createElement("div", { className: "flex items-center gap-3" },
|
|
17
|
+
React__default.createElement("span", { className: "text-text-muted text-sm border-r border-border pr-3" }, selectedCount === totalCount
|
|
18
|
+
? "All ".concat(selectedCount, " selected")
|
|
19
|
+
: "".concat(selectedCount, " selected")),
|
|
20
|
+
bulkActions.length > 0 && (React__default.createElement("div", { className: "flex items-center gap-2" }, bulkActions.map(function (action) {
|
|
21
|
+
action.icon;
|
|
22
|
+
return (React__default.createElement(Button, { key: action.id, variant: "secondary", onClick: function () { return action.onClick(selectedRows); }, className: "text-text-secondary hover:text-text-primary", size: "sm" }, action.label));
|
|
23
|
+
})))),
|
|
24
|
+
React__default.createElement(Button, { variant: "link", onClick: onClearSelection, "aria-label": "Clear selection" },
|
|
25
|
+
React__default.createElement(ForwardRef, { className: "size-4" }),
|
|
26
|
+
"Clear")));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { TableSelectionHeader, TableSelectionHeader as default };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { __spreadArray } from '../../../../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { TableRow } from './TableRow.js';
|
|
4
|
+
import { getRowId } from '../../Table.utils.js';
|
|
5
|
+
|
|
6
|
+
function TableBodyComponent(_a) {
|
|
7
|
+
var data = _a.data, columns = _a.columns, rowKey = _a.rowKey, expandedRowRender = _a.expandedRowRender, _b = _a.expandedRows, expandedRows = _b === void 0 ? [] : _b, onExpandedRowsChange = _a.onExpandedRowsChange, selectable = _a.selectable, selectionType = _a.selectionType, _c = _a.selectedRows, selectedRows = _c === void 0 ? [] : _c, onSelectionChange = _a.onSelectionChange, freezeFirstColumn = _a.freezeFirstColumn, freezeLastColumn = _a.freezeLastColumn, theme = _a.theme;
|
|
8
|
+
var handleExpandChange = function (rowId, expanded) {
|
|
9
|
+
if (!onExpandedRowsChange)
|
|
10
|
+
return;
|
|
11
|
+
var newExpandedRows = expanded
|
|
12
|
+
? __spreadArray(__spreadArray([], expandedRows, true), [rowId], false) : expandedRows.filter(function (id) { return id !== rowId; });
|
|
13
|
+
onExpandedRowsChange(newExpandedRows);
|
|
14
|
+
};
|
|
15
|
+
var handleSelectionChange = function (rowId, selected) {
|
|
16
|
+
if (!onSelectionChange)
|
|
17
|
+
return;
|
|
18
|
+
var newSelectedRows = selectionType === 'checkbox'
|
|
19
|
+
? selected
|
|
20
|
+
? __spreadArray(__spreadArray([], selectedRows, true), [rowId], false) : selectedRows.filter(function (id) { return id !== rowId; })
|
|
21
|
+
: selected ? [rowId] : [];
|
|
22
|
+
onSelectionChange(newSelectedRows);
|
|
23
|
+
};
|
|
24
|
+
return (React__default.createElement("tbody", null, data.map(function (row, index) {
|
|
25
|
+
var rowId = getRowId(row, index, rowKey);
|
|
26
|
+
return (React__default.createElement(TableRow, { key: rowId, row: row, rowId: rowId, columns: columns, expandedRowRender: expandedRowRender, isExpanded: expandedRows.includes(rowId), onExpandChange: function (expanded) { return handleExpandChange(rowId, expanded); }, selectable: selectable, selectionType: selectionType, isSelected: selectedRows.includes(rowId), onSelectionChange: function (selected) { return handleSelectionChange(rowId, selected); }, freezeFirstColumn: freezeFirstColumn, freezeLastColumn: freezeLastColumn, theme: theme }));
|
|
27
|
+
})));
|
|
28
|
+
}
|
|
29
|
+
// Export with proper type annotation
|
|
30
|
+
var TableBody = TableBodyComponent;
|
|
31
|
+
|
|
32
|
+
export { TableBody };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { cn } from '../../../../../utils/cn.js';
|
|
3
|
+
import '../../../../../node_modules/tslib/tslib.es6.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Internal TableCell component used by the data-driven API
|
|
7
|
+
* Handles both header and data cells with proper theming and accessibility
|
|
8
|
+
*
|
|
9
|
+
* Features:
|
|
10
|
+
* - Dynamic cell type (th/td) based on isHeader prop
|
|
11
|
+
* - Frozen column support with visual indicators
|
|
12
|
+
* - Custom cell rendering via column.cell function
|
|
13
|
+
* - Tooltip support for truncated content
|
|
14
|
+
* - Alignment and width customization
|
|
15
|
+
* - Full accessibility with proper ARIA attributes
|
|
16
|
+
*
|
|
17
|
+
* @internal This component is used internally by the Table component
|
|
18
|
+
*/
|
|
19
|
+
function TableCellComponent(_a) {
|
|
20
|
+
var column = _a.column, row = _a.row; _a.rowId; var _b = _a.isHeader, isHeader = _b === void 0 ? false : _b, _c = _a.isFrozen, isFrozen = _c === void 0 ? false : _c, _d = _a.isLastFrozen, isLastFrozen = _d === void 0 ? false : _d, theme = _a.theme, children = _a.children;
|
|
21
|
+
var Cell = isHeader ? 'th' : 'td';
|
|
22
|
+
// For header cells, render the column header content
|
|
23
|
+
if (isHeader) {
|
|
24
|
+
var cellClasses_1 = cn(theme === null || theme === void 0 ? void 0 : theme.headerStyle, isFrozen && (theme === null || theme === void 0 ? void 0 : theme.frozenColumnStyle), isLastFrozen && (theme === null || theme === void 0 ? void 0 : theme.lastFrozenColumnStyle), column.align && "text-".concat(column.align));
|
|
25
|
+
return (React__default.createElement(Cell, { className: cellClasses_1, "data-frozen": isFrozen ? 'true' : isLastFrozen ? 'last' : undefined, style: { width: column.width }, role: "columnheader", "aria-label": typeof column.header === 'string' ? column.header : column.id }, children || column.header));
|
|
26
|
+
}
|
|
27
|
+
// For data cells, extract value using accessor (string key or function)
|
|
28
|
+
var value = typeof column.accessor === 'function'
|
|
29
|
+
? column.accessor(row)
|
|
30
|
+
: row[column.accessor];
|
|
31
|
+
// Use custom cell renderer if provided, otherwise display raw value
|
|
32
|
+
var content = column.cell ? column.cell(row) : value;
|
|
33
|
+
// Generate tooltip content if tooltip is enabled
|
|
34
|
+
var tooltipContent = typeof column.tooltip === 'function'
|
|
35
|
+
? column.tooltip(row)
|
|
36
|
+
: column.tooltip
|
|
37
|
+
? String(value)
|
|
38
|
+
: undefined;
|
|
39
|
+
var cellClasses = cn(theme === null || theme === void 0 ? void 0 : theme.cellStyle, isFrozen && (theme === null || theme === void 0 ? void 0 : theme.frozenColumnStyle), isLastFrozen && (theme === null || theme === void 0 ? void 0 : theme.lastFrozenColumnStyle), column.align && "text-".concat(column.align), column.ellipsis && 'truncate');
|
|
40
|
+
return (React__default.createElement(Cell, { className: cellClasses, "data-frozen": isFrozen ? 'true' : isLastFrozen ? 'last' : undefined, style: { width: column.width }, title: tooltipContent, role: "cell" }, children || content));
|
|
41
|
+
}
|
|
42
|
+
// Set display name for dev tools
|
|
43
|
+
TableCellComponent.displayName = 'TableCell';
|
|
44
|
+
// Memoize component to prevent unnecessary re-renders when props haven't changed
|
|
45
|
+
var TableCell = React__default.memo(TableCellComponent);
|
|
46
|
+
|
|
47
|
+
export { TableCell };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { __spreadArray } from '../../../../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { TableCell } from './TableCell.js';
|
|
4
|
+
import { Checkbox } from '../../../../forms/Checkbox/Checkbox.js';
|
|
5
|
+
import { getRowId } from '../../Table.utils.js';
|
|
6
|
+
|
|
7
|
+
function TableHeaderComponent(_a) {
|
|
8
|
+
var columns = _a.columns, _b = _a.sortConfig, sortConfig = _b === void 0 ? [] : _b, onSortChange = _a.onSortChange; _a.filterConfig; _a.onFilterChange; var freezeHeader = _a.freezeHeader, freezeFirstColumn = _a.freezeFirstColumn, freezeLastColumn = _a.freezeLastColumn, expandable = _a.expandable, expandedRowRender = _a.expandedRowRender, selectable = _a.selectable, selectionType = _a.selectionType, _d = _a.selectedRows, selectedRows = _d === void 0 ? [] : _d, onSelectionChange = _a.onSelectionChange; _a.totalRowCount; var theme = _a.theme, _f = _a.data, data = _f === void 0 ? [] : _f, rowKey = _a.rowKey;
|
|
9
|
+
var handleSort = function (columnId) {
|
|
10
|
+
if (!onSortChange)
|
|
11
|
+
return;
|
|
12
|
+
var currentSort = sortConfig.find(function (sort) { return sort.columnId === columnId; });
|
|
13
|
+
var newSortConfig = __spreadArray([], sortConfig.filter(function (sort) { return sort.columnId !== columnId; }), true);
|
|
14
|
+
if (!currentSort) {
|
|
15
|
+
// Add new sort
|
|
16
|
+
newSortConfig.push({
|
|
17
|
+
columnId: columnId,
|
|
18
|
+
direction: 'asc',
|
|
19
|
+
priority: sortConfig.length + 1,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
else if (currentSort.direction === 'asc') {
|
|
23
|
+
// Change to desc
|
|
24
|
+
newSortConfig.push({
|
|
25
|
+
columnId: columnId,
|
|
26
|
+
direction: 'desc',
|
|
27
|
+
priority: currentSort.priority,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// If desc, remove sort
|
|
31
|
+
onSortChange(newSortConfig);
|
|
32
|
+
};
|
|
33
|
+
var handleSelectAll = function (checked) {
|
|
34
|
+
if (!onSelectionChange || selectionType !== 'checkbox')
|
|
35
|
+
return;
|
|
36
|
+
if (checked) {
|
|
37
|
+
// Select all rows - generate row IDs using the same logic as TableBody
|
|
38
|
+
var allRowIds = data.map(function (row, index) { return getRowId(row, index, rowKey); });
|
|
39
|
+
onSelectionChange(allRowIds);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// Deselect all
|
|
43
|
+
onSelectionChange([]);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
// Calculate select all checkbox state
|
|
47
|
+
var dataLength = data.length;
|
|
48
|
+
var isAllSelected = selectedRows.length === dataLength && dataLength > 0;
|
|
49
|
+
var isIndeterminate = selectedRows.length > 0 && selectedRows.length < dataLength;
|
|
50
|
+
return (React__default.createElement("thead", { className: freezeHeader ? theme === null || theme === void 0 ? void 0 : theme.frozenHeaderStyle : '' },
|
|
51
|
+
React__default.createElement("tr", null,
|
|
52
|
+
selectable && (React__default.createElement(TableCell, { column: {
|
|
53
|
+
id: 'selection',
|
|
54
|
+
header: '',
|
|
55
|
+
accessor: function () { return ''; },
|
|
56
|
+
width: '48px',
|
|
57
|
+
align: 'center'
|
|
58
|
+
}, row: {}, rowId: "", isHeader: true, theme: theme }, selectionType === 'checkbox' && (React__default.createElement(Checkbox, { id: "table-select-all", name: "table-select-all", value: "select-all", checked: isAllSelected, indeterminate: isIndeterminate, onChange: handleSelectAll, "aria-label": "Select all rows" })))),
|
|
59
|
+
expandable && expandedRowRender && (React__default.createElement(TableCell, { column: {
|
|
60
|
+
id: 'expand',
|
|
61
|
+
header: '',
|
|
62
|
+
accessor: function () { return ''; },
|
|
63
|
+
width: '48px',
|
|
64
|
+
align: 'center'
|
|
65
|
+
}, row: {}, rowId: "", isHeader: true, theme: theme })),
|
|
66
|
+
columns.map(function (column, index) {
|
|
67
|
+
var currentSort = sortConfig.find(function (sort) { return sort.columnId === column.id; });
|
|
68
|
+
var isSortable = column.sortable && onSortChange;
|
|
69
|
+
return (React__default.createElement(TableCell, { key: column.id, column: column, row: {}, rowId: "header", isHeader: true, isFrozen: freezeFirstColumn && index === 0, isLastFrozen: freezeLastColumn && index === columns.length - 1, theme: theme }, isSortable ? (React__default.createElement("button", { onClick: function () { return handleSort(column.id); }, className: "flex items-center gap-1 w-full text-left hover:text-primary-600 transition-colors", "aria-label": "Sort by ".concat(typeof column.header === 'string' ? column.header : column.id) },
|
|
70
|
+
column.header,
|
|
71
|
+
currentSort && (React__default.createElement("span", { className: "text-xs" }, currentSort.direction === 'asc' ? '↑' : '↓')))) : (column.header)));
|
|
72
|
+
}))));
|
|
73
|
+
}
|
|
74
|
+
// Export with proper type annotation
|
|
75
|
+
var TableHeader = TableHeaderComponent;
|
|
76
|
+
|
|
77
|
+
export { TableHeader };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { TableCell } from './TableCell.js';
|
|
3
|
+
import Button from '../../../../core/Button/Button.js';
|
|
4
|
+
import { Checkbox } from '../../../../forms/Checkbox/Checkbox.js';
|
|
5
|
+
import { Radio } from '../../../../forms/Radio/Radio.js';
|
|
6
|
+
import ForwardRef from '../../../../../node_modules/@heroicons/react/24/outline/esm/MinusIcon.js';
|
|
7
|
+
import ForwardRef$1 from '../../../../../node_modules/@heroicons/react/24/outline/esm/PlusIcon.js';
|
|
8
|
+
|
|
9
|
+
function TableRowComponent(_a) {
|
|
10
|
+
var row = _a.row, rowId = _a.rowId, columns = _a.columns, expandedRowRender = _a.expandedRowRender, _b = _a.isExpanded, isExpanded = _b === void 0 ? false : _b, onExpandChange = _a.onExpandChange, selectable = _a.selectable, selectionType = _a.selectionType, _c = _a.isSelected, isSelected = _c === void 0 ? false : _c, onSelectionChange = _a.onSelectionChange, freezeFirstColumn = _a.freezeFirstColumn, freezeLastColumn = _a.freezeLastColumn, theme = _a.theme;
|
|
11
|
+
var rowClasses = [
|
|
12
|
+
(theme === null || theme === void 0 ? void 0 : theme.rowStyle) || "",
|
|
13
|
+
isSelected ? (theme === null || theme === void 0 ? void 0 : theme.selectedRowStyle) || "" : ""
|
|
14
|
+
].filter(Boolean).join(" ");
|
|
15
|
+
var handleExpandClick = function (e) {
|
|
16
|
+
e.stopPropagation();
|
|
17
|
+
onExpandChange === null || onExpandChange === void 0 ? void 0 : onExpandChange(!isExpanded);
|
|
18
|
+
};
|
|
19
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
20
|
+
React__default.createElement("tr", { className: rowClasses, "data-selected": isSelected, role: "row", "aria-selected": selectable ? isSelected : undefined, "aria-expanded": Boolean(expandedRowRender) ? isExpanded : undefined },
|
|
21
|
+
selectable && (React__default.createElement(TableCell, { column: {
|
|
22
|
+
id: 'selection',
|
|
23
|
+
header: '',
|
|
24
|
+
accessor: function () { return ''; },
|
|
25
|
+
width: '48px',
|
|
26
|
+
align: 'center'
|
|
27
|
+
}, row: row, rowId: rowId, theme: theme }, selectionType === "checkbox" ? (React__default.createElement(Checkbox, { id: "table-checkbox-".concat(rowId), name: "table-selection-".concat(rowId), value: String(rowId), checked: isSelected, onChange: function (checked) { return onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(checked); }, onClick: function (e) { return e.stopPropagation(); }, "aria-label": "Select row" })) : (React__default.createElement("div", { onClick: function (e) { return e.stopPropagation(); } },
|
|
28
|
+
React__default.createElement(Radio, { id: "table-radio-".concat(rowId), name: "table-selection", value: String(rowId), checked: isSelected, onChange: function (checked) { return onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(checked); }, "aria-label": "Select row" }))))),
|
|
29
|
+
expandedRowRender && (React__default.createElement(TableCell, { column: {
|
|
30
|
+
id: 'expand',
|
|
31
|
+
header: '',
|
|
32
|
+
accessor: function () { return ''; },
|
|
33
|
+
width: '48px',
|
|
34
|
+
align: 'center'
|
|
35
|
+
}, row: row, rowId: rowId, theme: theme },
|
|
36
|
+
React__default.createElement(Button, { variant: "clear", size: "sm", onClick: handleExpandClick, "aria-label": isExpanded ? "Collapse row" : "Expand row" }, isExpanded ? React__default.createElement(ForwardRef, { className: "w-4 h-4", strokeWidth: 2 }) : React__default.createElement(ForwardRef$1, { className: "w-4 h-4", strokeWidth: 2 })))),
|
|
37
|
+
columns.map(function (column, index) { return (React__default.createElement(TableCell, { key: column.id, column: column, row: row, rowId: rowId, isFrozen: freezeFirstColumn && index === 0, isLastFrozen: freezeLastColumn && index === columns.length - 1, theme: theme })); })),
|
|
38
|
+
isExpanded && expandedRowRender && (React__default.createElement("tr", null,
|
|
39
|
+
React__default.createElement("td", { colSpan: columns.length +
|
|
40
|
+
(selectable ? 1 : 0) +
|
|
41
|
+
1 }, expandedRowRender(row))))));
|
|
42
|
+
}
|
|
43
|
+
// Export with proper type annotation
|
|
44
|
+
var TableRow = TableRowComponent;
|
|
45
|
+
|
|
46
|
+
export { TableRow };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Table$1 from './Table.js';
|
|
2
|
+
import { HeaderCell, Cell, Row, Body, Header } from './components/DeclarativeComponents.js';
|
|
3
|
+
import { TableActions } from './components/TableActions/TableActions.js';
|
|
4
|
+
import 'react';
|
|
5
|
+
import '../../../node_modules/tslib/tslib.es6.js';
|
|
6
|
+
import { TablePagination } from './components/TablePagination/TablePagination.js';
|
|
7
|
+
|
|
8
|
+
// First import the Table component itself
|
|
9
|
+
// Create a compound component by attaching the subcomponents
|
|
10
|
+
var Table = Object.assign(Table$1, {
|
|
11
|
+
Header: Header,
|
|
12
|
+
Body: Body,
|
|
13
|
+
Row: Row,
|
|
14
|
+
Cell: Cell,
|
|
15
|
+
HeaderCell: HeaderCell,
|
|
16
|
+
Actions: TableActions,
|
|
17
|
+
Pagination: TablePagination
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export { Table, TableActions, TablePagination, Table as default };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { __rest, __assign } from '../../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { cn } from '../../../utils/cn.js';
|
|
4
|
+
import { alertTheme } from './Alert.theme.js';
|
|
5
|
+
import ForwardRef from '../../../node_modules/@heroicons/react/24/solid/esm/XCircleIcon.js';
|
|
6
|
+
import ForwardRef$1 from '../../../node_modules/@heroicons/react/24/solid/esm/ExclamationTriangleIcon.js';
|
|
7
|
+
import ForwardRef$2 from '../../../node_modules/@heroicons/react/24/solid/esm/CheckCircleIcon.js';
|
|
8
|
+
import ForwardRef$3 from '../../../node_modules/@heroicons/react/24/solid/esm/InformationCircleIcon.js';
|
|
9
|
+
import ForwardRef$4 from '../../../node_modules/@heroicons/react/24/solid/esm/XMarkIcon.js';
|
|
10
|
+
|
|
11
|
+
var variantIcons = {
|
|
12
|
+
info: ForwardRef$3,
|
|
13
|
+
success: ForwardRef$2,
|
|
14
|
+
warning: ForwardRef$1,
|
|
15
|
+
error: ForwardRef,
|
|
16
|
+
};
|
|
17
|
+
var Alert = React__default.forwardRef(function (_a, ref) {
|
|
18
|
+
var _b;
|
|
19
|
+
var _c = _a.variant, variant = _c === void 0 ? 'info' : _c, title = _a.title, description = _a.description, _d = _a.dismissible, dismissible = _d === void 0 ? false : _d, icon = _a.icon, _e = _a.showIcon, showIcon = _e === void 0 ? true : _e, onDismiss = _a.onDismiss, className = _a.className, _f = _a.theme, customTheme = _f === void 0 ? {} : _f, children = _a.children, props = __rest(_a, ["variant", "title", "description", "dismissible", "icon", "showIcon", "onDismiss", "className", "theme", "children"]);
|
|
20
|
+
var IconComponent = variantIcons[variant];
|
|
21
|
+
var handleDismiss = function () {
|
|
22
|
+
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
|
23
|
+
};
|
|
24
|
+
var hasContent = title || description || children;
|
|
25
|
+
return (React__default.createElement("div", __assign({ ref: ref, className: cn(alertTheme.baseStyle, alertTheme.variants[variant], customTheme.baseStyle, (_b = customTheme.variants) === null || _b === void 0 ? void 0 : _b[variant], className), role: "alert" }, props),
|
|
26
|
+
showIcon && (React__default.createElement("div", { className: cn(alertTheme.iconStyle, customTheme.iconStyle) }, icon || React__default.createElement(IconComponent, { className: "w-5 h-5" }))),
|
|
27
|
+
hasContent && (React__default.createElement("div", { className: cn(alertTheme.contentStyle, customTheme.contentStyle) },
|
|
28
|
+
title && (React__default.createElement("div", { className: cn(alertTheme.titleStyle, customTheme.titleStyle) }, title)),
|
|
29
|
+
description && (React__default.createElement("div", { className: cn(alertTheme.descriptionStyle, customTheme.descriptionStyle) }, description)),
|
|
30
|
+
children && (React__default.createElement("div", { className: cn(alertTheme.childrenStyle, customTheme.childrenStyle) }, children)))),
|
|
31
|
+
dismissible && (React__default.createElement("button", { type: "button", className: cn(alertTheme.closeButtonStyle, customTheme.closeButtonStyle), onClick: handleDismiss, "aria-label": "Dismiss alert" },
|
|
32
|
+
React__default.createElement(ForwardRef$4, { className: "w-5 h-5" })))));
|
|
33
|
+
});
|
|
34
|
+
Alert.displayName = 'Alert';
|
|
35
|
+
|
|
36
|
+
export { Alert };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var alertTheme = {
|
|
2
|
+
baseStyle: 'relative flex items-start gap-3 rounded-lg border px-4 py-3',
|
|
3
|
+
variants: {
|
|
4
|
+
info: 'bg-[var(--color-primary-50)] border-[var(--color-primary-200)] text-[var(--color-primary-900)]',
|
|
5
|
+
success: 'bg-[var(--color-success-50)] border-[var(--color-success-200)] text-[var(--color-success-900)]',
|
|
6
|
+
warning: 'bg-[var(--color-warning-50)] border-[var(--color-warning-200)] text-[var(--color-warning-900)]',
|
|
7
|
+
error: 'bg-[var(--color-danger-50)] border-[var(--color-danger-200)] text-[var(--color-danger-900)]',
|
|
8
|
+
},
|
|
9
|
+
iconStyle: 'flex-shrink-0 w-5 h-5 mt-0.5',
|
|
10
|
+
contentStyle: 'flex-1 min-w-0',
|
|
11
|
+
titleStyle: 'font-medium text-sm',
|
|
12
|
+
descriptionStyle: 'text-sm mt-1 opacity-90',
|
|
13
|
+
childrenStyle: 'mt-1',
|
|
14
|
+
closeButtonStyle: 'absolute top-3 right-3 flex-shrink-0 w-5 h-5 opacity-70 hover:opacity-100 transition-opacity cursor-pointer',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { alertTheme };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { __rest, __assign } from '../../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { cn } from '../../../utils/cn.js';
|
|
4
|
+
import { formatTimestamp } from '../../../utils/dateUtils.js';
|
|
5
|
+
import { chatMessageTheme } from './ChatMessage.theme.js';
|
|
6
|
+
import { Avatar } from '../../core/Avatar/Avatar.js';
|
|
7
|
+
|
|
8
|
+
var ChatMessage = React__default.forwardRef(function (_a, ref) {
|
|
9
|
+
var _b = _a.variant, variant = _b === void 0 ? 'receiver' : _b, message = _a.message, timestamp = _a.timestamp, avatar = _a.avatar, _c = _a.showTimestamp, showTimestamp = _c === void 0 ? true : _c, className = _a.className, _d = _a.theme, customTheme = _d === void 0 ? {} : _d, props = __rest(_a, ["variant", "message", "timestamp", "avatar", "showTimestamp", "className", "theme"]);
|
|
10
|
+
var isReceiver = variant === 'receiver';
|
|
11
|
+
var containerStyle = isReceiver ? chatMessageTheme.receiverContainerStyle : chatMessageTheme.senderContainerStyle;
|
|
12
|
+
var bubbleVariantStyle = isReceiver ? chatMessageTheme.receiverBubbleStyle : chatMessageTheme.senderBubbleStyle;
|
|
13
|
+
var timestampStyle = isReceiver ? chatMessageTheme.receiverTimestampStyle : chatMessageTheme.senderTimestampStyle;
|
|
14
|
+
return (React__default.createElement("div", __assign({ ref: ref, className: cn(chatMessageTheme.baseStyle, customTheme.baseStyle, className) }, props),
|
|
15
|
+
React__default.createElement("div", { className: cn(containerStyle, isReceiver ? customTheme.receiverContainerStyle : customTheme.senderContainerStyle) },
|
|
16
|
+
avatar && (React__default.createElement("div", { className: cn(chatMessageTheme.avatarContainerStyle, customTheme.avatarContainerStyle) },
|
|
17
|
+
React__default.createElement(Avatar, { src: avatar.src, alt: avatar.alt, fallback: avatar.fallback, size: "sm" }))),
|
|
18
|
+
React__default.createElement("div", { className: cn(chatMessageTheme.messageContainerStyle, customTheme.messageContainerStyle) },
|
|
19
|
+
React__default.createElement("div", { className: cn(chatMessageTheme.bubbleBaseStyle, bubbleVariantStyle, customTheme.bubbleBaseStyle, isReceiver ? customTheme.receiverBubbleStyle : customTheme.senderBubbleStyle) },
|
|
20
|
+
React__default.createElement("p", { className: cn(chatMessageTheme.messageTextStyle, customTheme.messageTextStyle) }, message)),
|
|
21
|
+
showTimestamp && (React__default.createElement("div", { className: cn(timestampStyle, isReceiver ? customTheme.receiverTimestampStyle : customTheme.senderTimestampStyle) },
|
|
22
|
+
React__default.createElement("time", { dateTime: typeof timestamp === 'string' ? timestamp : timestamp.toISOString(), className: cn(chatMessageTheme.timeStyle, customTheme.timeStyle) }, formatTimestamp(timestamp))))))));
|
|
23
|
+
});
|
|
24
|
+
ChatMessage.displayName = 'ChatMessage';
|
|
25
|
+
|
|
26
|
+
export { ChatMessage };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var chatMessageTheme = {
|
|
2
|
+
baseStyle: 'w-full max-w-full',
|
|
3
|
+
avatarContainerStyle: 'flex-shrink-0',
|
|
4
|
+
messageContainerStyle: 'flex flex-col min-w-0 flex-1',
|
|
5
|
+
bubbleBaseStyle: 'max-w-[80%] sm:max-w-[70%] rounded-3xl px-5 py-4 w-fit border-t-[0.5px] ring-1',
|
|
6
|
+
messageTextStyle: 'break-words text-base',
|
|
7
|
+
timeStyle: 'select-none',
|
|
8
|
+
senderContainerStyle: 'flex flex-row-reverse items-end gap-4',
|
|
9
|
+
senderBubbleStyle: 'bg-gradient-to-br from-primary-600 to-primary-700 text-white rounded-br-xs ml-auto ring-[var(--color-primary)] border-white/30',
|
|
10
|
+
senderTimestampStyle: 'text-xs text-gray-500 mt-1 text-right pr-1',
|
|
11
|
+
receiverContainerStyle: 'flex items-end gap-4',
|
|
12
|
+
receiverBubbleStyle: 'bg-gray-100 text-text-primary rounded-bl-xs shadow-black/10 ring-gray-100 border-white',
|
|
13
|
+
receiverTimestampStyle: 'text-xs text-text-placeholder mt-1 text-left pl-1',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { chatMessageTheme };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { __rest, __assign } from '../../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { emptyTheme } from './Empty.theme.js';
|
|
4
|
+
import { cn } from '../../../utils/cn.js';
|
|
5
|
+
|
|
6
|
+
var Empty = React__default.forwardRef(function (_a, ref) {
|
|
7
|
+
var title = _a.title, description = _a.description, image = _a.image, imageAlt = _a.imageAlt, icon = _a.icon, action = _a.action, className = _a.className, children = _a.children, props = __rest(_a, ["title", "description", "image", "imageAlt", "icon", "action", "className", "children"]);
|
|
8
|
+
// Fixed image and icon dimensions
|
|
9
|
+
var imageDimensions = "size-32";
|
|
10
|
+
var iconDimensions = "size-16";
|
|
11
|
+
// If children are provided, render them instead of the default layout
|
|
12
|
+
if (children) {
|
|
13
|
+
return (React__default.createElement("div", __assign({ ref: ref, className: cn(emptyTheme.baseStyle, className), role: "region", "aria-label": "Empty state" }, props), children));
|
|
14
|
+
}
|
|
15
|
+
return (React__default.createElement("div", __assign({ ref: ref, className: cn(emptyTheme.baseStyle, className), role: "region", "aria-label": "Empty state" }, props),
|
|
16
|
+
image ? (React__default.createElement("div", { className: "flex-shrink-0 mb-6" },
|
|
17
|
+
React__default.createElement("img", { src: image, alt: imageAlt || "Empty state illustration", className: cn("mx-auto object-cover", imageDimensions), loading: "lazy" }))) : icon ? (React__default.createElement("div", { className: cn("flex-shrink-0 mx-auto text-text-muted mb-6", iconDimensions), "aria-hidden": "true" }, icon)) : null,
|
|
18
|
+
React__default.createElement("div", { className: "flex flex-col items-center justify-center gap-1" },
|
|
19
|
+
title && React__default.createElement("div", { className: emptyTheme.titleStyle }, title),
|
|
20
|
+
description && (React__default.createElement("div", { className: emptyTheme.descriptionStyle }, description))),
|
|
21
|
+
action && (React__default.createElement("div", { className: "flex flex-col sm:flex-row gap-2 justify-center items-center mt-6" }, action))));
|
|
22
|
+
});
|
|
23
|
+
// Set display name for dev tools and Storybook
|
|
24
|
+
Empty.displayName = "Empty";
|
|
25
|
+
|
|
26
|
+
export { Empty as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default theme for the Empty component
|
|
3
|
+
*/
|
|
4
|
+
var emptyTheme = {
|
|
5
|
+
// Base container styles - customizable spacing, colors, and layout
|
|
6
|
+
baseStyle: "flex flex-col items-center justify-center text-center w-full max-w-md mx-auto space-y-4 py-12 px-6 ",
|
|
7
|
+
// Title text styles - customizable typography and colors
|
|
8
|
+
titleStyle: "text-base font-semibold text-text-primary",
|
|
9
|
+
// Description text styles - customizable typography and colors
|
|
10
|
+
descriptionStyle: "text-base text-text-secondary/70",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { emptyTheme };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { __rest, __assign } from '../../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { cn } from '../../../utils/cn.js';
|
|
4
|
+
import { notificationTheme } from './Notification.theme.js';
|
|
5
|
+
import ForwardRef from '../../../node_modules/@heroicons/react/24/solid/esm/XMarkIcon.js';
|
|
6
|
+
|
|
7
|
+
var Notification = React__default.forwardRef(function (_a, ref) {
|
|
8
|
+
var _b = _a.variant, variant = _b === void 0 ? 'default' : _b, title = _a.title, description = _a.description, avatar = _a.avatar, icon = _a.icon, actions = _a.actions, onDismiss = _a.onDismiss, className = _a.className, children = _a.children, props = __rest(_a, ["variant", "title", "description", "avatar", "icon", "actions", "onDismiss", "className", "children"]);
|
|
9
|
+
var handleDismiss = function () {
|
|
10
|
+
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
|
11
|
+
};
|
|
12
|
+
var variantTheme = notificationTheme.variants[variant];
|
|
13
|
+
var renderIconOrAvatar = function () {
|
|
14
|
+
if (avatar) {
|
|
15
|
+
return (React__default.createElement("div", { className: "flex-shrink-0 w-10 h-10 rounded-full" }, avatar));
|
|
16
|
+
}
|
|
17
|
+
// icon={null} means hide icon completely
|
|
18
|
+
if (icon === null) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
// Use custom icon if provided, otherwise use variant's default icon
|
|
22
|
+
var IconToRender = icon || variantTheme.defaultIcon;
|
|
23
|
+
return (React__default.createElement("div", { className: "flex-shrink-0 w-6 h-6 mt-1" }, React__default.isValidElement(IconToRender)
|
|
24
|
+
? IconToRender
|
|
25
|
+
: React__default.createElement(IconToRender, {
|
|
26
|
+
className: cn("w-6 h-6", variantTheme.iconColor)
|
|
27
|
+
})));
|
|
28
|
+
};
|
|
29
|
+
return (React__default.createElement("div", __assign({ ref: ref, className: cn(notificationTheme.baseStyle, variantTheme.containerStyle, className), role: "alert" }, props),
|
|
30
|
+
renderIconOrAvatar(),
|
|
31
|
+
React__default.createElement("div", { className: "flex-1 min-w-0 ".concat(onDismiss ? 'mr-5' : '') },
|
|
32
|
+
React__default.createElement("div", { className: cn(notificationTheme.titleStyle, variantTheme.titleColor) }, title),
|
|
33
|
+
description && (React__default.createElement("div", { className: notificationTheme.descriptionStyle }, description)),
|
|
34
|
+
children && (React__default.createElement("div", { className: "mt-2" }, children)),
|
|
35
|
+
actions && (React__default.createElement("div", { className: "flex items-center gap-2 mt-6" }, actions))),
|
|
36
|
+
onDismiss && (React__default.createElement("button", { type: "button", className: "absolute top-3 right-3 flex-shrink-0 size-5 text-text-muted hover:text-text-primary transition-colors cursor-pointer", onClick: handleDismiss, "aria-label": "Dismiss notification" },
|
|
37
|
+
React__default.createElement(ForwardRef, { className: "size-4" })))));
|
|
38
|
+
});
|
|
39
|
+
Notification.displayName = 'Notification';
|
|
40
|
+
|
|
41
|
+
export { Notification };
|