@eml-payments/ui-kit 1.8.0 → 1.8.2

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.
Files changed (42) hide show
  1. package/README.md +73 -13
  2. package/dist/index.css +2 -2
  3. package/dist/src/assets/index.d.ts +2 -0
  4. package/dist/src/assets/index.js +3 -0
  5. package/dist/src/assets/index.ts +3 -0
  6. package/dist/src/components/Checkbox/Checkbox.js +1 -1
  7. package/dist/src/components/DatePicker/index.d.ts +1 -1
  8. package/dist/src/components/Filters/FilterSelect.d.ts +21 -0
  9. package/dist/src/components/Filters/FilterSelect.js +11 -0
  10. package/dist/src/components/Filters/Filters.d.ts +3 -0
  11. package/dist/src/components/Filters/Filters.js +35 -0
  12. package/dist/src/components/Filters/Filters.stories.d.ts +12 -0
  13. package/dist/src/components/Filters/Filters.stories.js +235 -0
  14. package/dist/src/components/Filters/Filters.types.d.ts +27 -0
  15. package/dist/src/components/Filters/Filters.types.js +3 -0
  16. package/dist/src/components/Filters/index.d.ts +2 -0
  17. package/dist/src/components/Filters/index.js +1 -0
  18. package/dist/src/components/Table/Pagination/Pagination.types.d.ts +1 -0
  19. package/dist/src/components/Table/Pagination/PaginationFooter.d.ts +1 -1
  20. package/dist/src/components/Table/Pagination/PaginationFooter.js +2 -2
  21. package/dist/src/components/Table/StandardTable/StandardTable.js +1 -1
  22. package/dist/src/components/Table/StandardTable/StandardTable.stories.d.ts +1 -0
  23. package/dist/src/components/Table/StandardTable/StandardTable.stories.js +3 -0
  24. package/dist/src/components/Table/Table.types.d.ts +2 -0
  25. package/dist/src/components/Tooltip/Tooltip.stories.js +1 -1
  26. package/dist/src/components/index.d.ts +1 -0
  27. package/dist/src/components/index.js +1 -0
  28. package/package.json +132 -131
  29. package/dist/src/components/Table/Pagination/PaginationControls.d.ts +0 -3
  30. package/dist/src/components/Table/Pagination/PaginationControls.js +0 -22
  31. package/dist/src/components/Table/Pagination/PaginationControls.types.d.ts +0 -24
  32. package/dist/src/components/Table/Pagination/PaginationControls.types.js +0 -1
  33. package/dist/src/components/Table/Table.d.ts +0 -4
  34. package/dist/src/components/Table/Table.js +0 -93
  35. package/dist/src/components/Table/Table.stories.d.ts +0 -31
  36. package/dist/src/components/Table/Table.stories.js +0 -479
  37. package/dist/src/components/Table/hooks/useInfiniteScrolling.d.ts +0 -29
  38. package/dist/src/components/Table/hooks/useInfiniteScrolling.js +0 -96
  39. package/dist/src/components/Table/hooks/usePaginationController.d.ts +0 -16
  40. package/dist/src/components/Table/hooks/usePaginationController.js +0 -30
  41. package/dist/src/components/Table/hooks/useTableController.d.ts +0 -26
  42. package/dist/src/components/Table/hooks/useTableController.js +0 -146
package/package.json CHANGED
@@ -1,131 +1,132 @@
1
- {
2
- "name": "@eml-payments/ui-kit",
3
- "version": "1.8.0",
4
- "private": false,
5
- "description": "ARLO UIKit",
6
- "homepage": "https://github.com/EML-Payments/arlo.npm.uikit#readme",
7
- "bugs": {
8
- "url": "https://github.com/EML-Payments/arlo.npm.uikit/issues"
9
- },
10
- "repository": {
11
- "type": "git",
12
- "url": "git+https://github.com/EML-Payments/arlo.npm.uikit.git"
13
- },
14
- "license": "MIT",
15
- "author": "EML Payments",
16
- "type": "commonjs",
17
- "main": "dist/src/index.js",
18
- "types": "dist/src/index.d.ts",
19
- "exports": {
20
- ".": {
21
- "import": "./dist/src/index.js",
22
- "require": "./dist/src/index.js",
23
- "types": "./dist/src/index.d.ts"
24
- },
25
- "./style.css": "./dist/index.css",
26
- "./index.css": "./dist/index.css",
27
- "./assets/*": "./dist/src/assets/*"
28
- },
29
- "directories": {
30
- "doc": "docs",
31
- "lib": "lib"
32
- },
33
- "files": [
34
- "dist"
35
- ],
36
- "scripts": {
37
- "prepare": "husky install",
38
- "storybook": "storybook dev -p 6006",
39
- "build-storybook": "storybook build",
40
- "build:assets": "copyfiles -u 2 \"src/assets/**/*\" dist/src/assets",
41
- "build:css": "npx tailwindcss -i ./src/index.css -o ./dist/index.css --minify",
42
- "build:intl-tel-input:flags": "copyfiles -u 4 \"node_modules/intl-tel-input/build/img/flags*.webp\" \"node_modules/intl-tel-input/build/img/flags*.png\" dist/img",
43
- "build": "npm run build:assets && npm run build:css && npm run build:intl-tel-input:flags && tsc",
44
- "validate:dist": "node scripts/validate-dist.js",
45
- "lint": "eslint . --ext .ts,.tsx --fix",
46
- "format": "prettier --list-different \"**/*.{js,jsx,ts,tsx,json,htm,html,yml,yaml}\"",
47
- "format:fix": "prettier --write \"**/*.{js,jsx,ts,tsx,json,htm,html,yml,yaml}\"",
48
- "task:prettier": "prettier \"./src/**/*.{ts,tsx}\" --check --log-level error",
49
- "task:prettier:fix": "prettier --write \"./src/**/*.{ts,tsx}\" --check --log-level error",
50
- "task:eslint": "eslint \"src/**/*.{ts,tsx}\" --cache",
51
- "task:eslint:fix": "eslint \"src/**/*.{ts,tsx}\" --fix --cache",
52
- "task:typecheck": "tsc",
53
- "formatx": "npm run task:prettier:fix && npm run task:eslint:fix && npm run task:typecheck"
54
- },
55
- "dependencies": {
56
- "@base-ui/react": "^1.3.0",
57
- "@radix-ui/react-accordion": "^1.2.12",
58
- "@radix-ui/react-avatar": "^1.1.10",
59
- "@radix-ui/react-checkbox": "^1.3.2",
60
- "@radix-ui/react-dialog": "^1.1.14",
61
- "@radix-ui/react-dropdown-menu": "^2.1.15",
62
- "@radix-ui/react-label": "^2.1.7",
63
- "@radix-ui/react-popover": "^1.1.15",
64
- "@radix-ui/react-radio-group": "^1.3.7",
65
- "@radix-ui/react-select": "^2.2.5",
66
- "@radix-ui/react-slot": "^1.2.4",
67
- "@radix-ui/react-switch": "^1.2.5",
68
- "@radix-ui/react-tabs": "^1.1.12",
69
- "@radix-ui/react-tooltip": "^1.2.7",
70
- "@tailwindcss/postcss": "^4.1.11",
71
- "@tanstack/react-table": "^8.12.0",
72
- "@tanstack/react-virtual": "^3.13.13",
73
- "class-variance-authority": "^0.7.1",
74
- "clsx": "^2.1.1",
75
- "dayjs": "^1.11.19",
76
- "intl-tel-input": "^26.9.1",
77
- "lucide-react": "^1.8.0",
78
- "prettier": "^3.6.2",
79
- "react": ">=18.0.0",
80
- "react-day-picker": "^9.13.0",
81
- "react-dom": ">=18.0.0",
82
- "react-icons": "^5.5.0",
83
- "react-router-dom": "^7.9.5",
84
- "tailwind-merge": "^3.4.0",
85
- "tailwindcss": "^4.1.11",
86
- "tailwindcss-animate": "^1.0.7",
87
- "tw-animate-css": "^1.4.0"
88
- },
89
- "devDependencies": {
90
- "@eslint/js": "^9.30.1",
91
- "@storybook/addon-a11y": "^10.0.6",
92
- "@storybook/addon-docs": "^10.0.2",
93
- "@storybook/addon-themes": "^10.0.2",
94
- "@storybook/react-vite": "^10.0.6",
95
- "@tailwindcss/cli": "^4.1.12",
96
- "@typescript-eslint/eslint-plugin": "^8.35.1",
97
- "baseline-browser-mapping": "^2.10.0",
98
- "copyfiles": "^2.4.1",
99
- "eslint": "^9.31.0",
100
- "eslint-config-prettier": "^10.1.5",
101
- "eslint-plugin-import": "^2.32.0",
102
- "eslint-plugin-jsx-a11y": "^6.10.2",
103
- "eslint-plugin-prettier": "^5.5.1",
104
- "eslint-plugin-react": "^7.37.5",
105
- "eslint-plugin-react-hooks": "^7.0.0",
106
- "eslint-plugin-react-refresh": "^0.5.0",
107
- "eslint-plugin-storybook": "^10.0.6",
108
- "husky": "^9.1.7",
109
- "lint-staged": "^16.1.2",
110
- "postcss": "^8.4.21",
111
- "storybook": "^10.0.6",
112
- "typescript": "^5.4.0",
113
- "typescript-eslint": "^8.36.0"
114
- },
115
- "peerDependencies": {
116
- "react": ">=18.0.0",
117
- "react-dom": ">=18.0.0"
118
- },
119
- "eslintConfig": {
120
- "extends": [
121
- "plugin:storybook/recommended"
122
- ]
123
- },
124
- "lint-staged": {
125
- "*.{js,ts,tsx}": [
126
- "prettier --write",
127
- "eslint --fix"
128
- ],
129
- "*.{json,md,css}": "prettier --write"
130
- }
131
- }
1
+ {
2
+ "name": "@eml-payments/ui-kit",
3
+ "version": "1.8.2",
4
+ "private": false,
5
+ "description": "ARLO UIKit",
6
+ "homepage": "https://github.com/EML-Payments/arlo.npm.uikit#readme",
7
+ "bugs": {
8
+ "url": "https://github.com/EML-Payments/arlo.npm.uikit/issues"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/EML-Payments/arlo.npm.uikit.git"
13
+ },
14
+ "license": "MIT",
15
+ "author": "EML Payments",
16
+ "type": "commonjs",
17
+ "main": "dist/src/index.js",
18
+ "types": "dist/src/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "import": "./dist/src/index.js",
22
+ "require": "./dist/src/index.js",
23
+ "types": "./dist/src/index.d.ts"
24
+ },
25
+ "./style.css": "./dist/index.css",
26
+ "./index.css": "./dist/index.css",
27
+ "./assets/*": "./dist/src/assets/*"
28
+ },
29
+ "directories": {
30
+ "doc": "docs",
31
+ "lib": "lib"
32
+ },
33
+ "files": [
34
+ "dist"
35
+ ],
36
+ "scripts": {
37
+ "prepare": "husky install",
38
+ "storybook": "storybook dev -p 6006",
39
+ "build-storybook": "storybook build",
40
+ "build:assets": "copyfiles -u 2 \"src/assets/**/*\" dist/src/assets",
41
+ "build:css": "npx tailwindcss -i ./src/index.css -o ./dist/index.css --minify",
42
+ "build:intl-tel-input:flags": "copyfiles -u 4 \"node_modules/intl-tel-input/build/img/flags*.webp\" \"node_modules/intl-tel-input/build/img/flags*.png\" dist/img",
43
+ "build": "npm run build:assets && npm run build:css && npm run build:intl-tel-input:flags && tsc",
44
+ "validate:dist": "node scripts/validate-dist.js",
45
+ "lint": "eslint . --ext .ts,.tsx --fix",
46
+ "format": "prettier --list-different \"**/*.{js,jsx,ts,tsx,json,htm,html,yml,yaml}\"",
47
+ "format:fix": "prettier --write \"**/*.{js,jsx,ts,tsx,json,htm,html,yml,yaml}\"",
48
+ "task:prettier": "prettier \"./src/**/*.{ts,tsx}\" --check --log-level error",
49
+ "task:prettier:fix": "prettier --write \"./src/**/*.{ts,tsx}\" --check --log-level error",
50
+ "task:eslint": "eslint \"src/**/*.{ts,tsx}\" --cache",
51
+ "task:eslint:fix": "eslint \"src/**/*.{ts,tsx}\" --fix --cache",
52
+ "task:typecheck": "tsc",
53
+ "formatx": "npm run task:prettier:fix && npm run task:eslint:fix && npm run task:typecheck"
54
+ },
55
+ "dependencies": {
56
+ "@base-ui/react": "^1.3.0",
57
+ "@radix-ui/react-accordion": "^1.2.12",
58
+ "@radix-ui/react-avatar": "^1.1.10",
59
+ "@radix-ui/react-checkbox": "^1.3.2",
60
+ "@radix-ui/react-dialog": "^1.1.14",
61
+ "@radix-ui/react-dropdown-menu": "^2.1.15",
62
+ "@radix-ui/react-label": "^2.1.7",
63
+ "@radix-ui/react-popover": "^1.1.15",
64
+ "@radix-ui/react-radio-group": "^1.3.7",
65
+ "@radix-ui/react-select": "^2.2.5",
66
+ "@radix-ui/react-slot": "^1.2.4",
67
+ "@radix-ui/react-switch": "^1.2.5",
68
+ "@radix-ui/react-tabs": "^1.1.12",
69
+ "@radix-ui/react-tooltip": "^1.2.7",
70
+ "@tailwindcss/postcss": "^4.1.11",
71
+ "@tanstack/react-table": "^8.12.0",
72
+ "@tanstack/react-virtual": "^3.13.13",
73
+ "class-variance-authority": "^0.7.1",
74
+ "clsx": "^2.1.1",
75
+ "dayjs": "^1.11.19",
76
+ "intl-tel-input": "^26.9.1",
77
+ "lucide-react": "^1.8.0",
78
+ "prettier": "^3.6.2",
79
+ "react": ">=18.0.0",
80
+ "react-day-picker": "^9.13.0",
81
+ "react-dom": ">=18.0.0",
82
+ "react-hook-form": "^7.75.0",
83
+ "react-icons": "^5.5.0",
84
+ "react-router-dom": "^7.9.5",
85
+ "tailwind-merge": "^3.4.0",
86
+ "tailwindcss": "^4.1.11",
87
+ "tailwindcss-animate": "^1.0.7",
88
+ "tw-animate-css": "^1.4.0"
89
+ },
90
+ "devDependencies": {
91
+ "@eslint/js": "^9.30.1",
92
+ "@storybook/addon-a11y": "^10.0.6",
93
+ "@storybook/addon-docs": "^10.0.2",
94
+ "@storybook/addon-themes": "^10.0.2",
95
+ "@storybook/react-vite": "^10.0.6",
96
+ "@tailwindcss/cli": "^4.1.12",
97
+ "@typescript-eslint/eslint-plugin": "^8.35.1",
98
+ "baseline-browser-mapping": "^2.10.0",
99
+ "copyfiles": "^2.4.1",
100
+ "eslint": "^9.31.0",
101
+ "eslint-config-prettier": "^10.1.5",
102
+ "eslint-plugin-import": "^2.32.0",
103
+ "eslint-plugin-jsx-a11y": "^6.10.2",
104
+ "eslint-plugin-prettier": "^5.5.1",
105
+ "eslint-plugin-react": "^7.37.5",
106
+ "eslint-plugin-react-hooks": "^7.0.0",
107
+ "eslint-plugin-react-refresh": "^0.5.0",
108
+ "eslint-plugin-storybook": "^10.0.6",
109
+ "husky": "^9.1.7",
110
+ "lint-staged": "^16.1.2",
111
+ "postcss": "^8.4.21",
112
+ "storybook": "^10.0.6",
113
+ "typescript": "^6.0.3",
114
+ "typescript-eslint": "^8.36.0"
115
+ },
116
+ "peerDependencies": {
117
+ "react": ">=18.0.0",
118
+ "react-dom": ">=18.0.0"
119
+ },
120
+ "eslintConfig": {
121
+ "extends": [
122
+ "plugin:storybook/recommended"
123
+ ]
124
+ },
125
+ "lint-staged": {
126
+ "*.{js,ts,tsx}": [
127
+ "prettier --write",
128
+ "eslint --fix"
129
+ ],
130
+ "*.{json,md,css}": "prettier --write"
131
+ }
132
+ }
@@ -1,3 +0,0 @@
1
- import type { PageSizeSelectorProps, PaginationControlsProps } from './PaginationControls.types';
2
- export declare const PageSizeSelector: ({ id, value, onChange, options, label, className, size, }: PageSizeSelectorProps) => import("react/jsx-runtime").JSX.Element;
3
- export declare const PaginationFooter: <T>({ table, tableId, paginationMode, onPageSizeChange, totalServerRows, onNextPage, onPrevPage, }: PaginationControlsProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -1,22 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { SelectWrapper } from '../../SelectWrapper';
3
- import { cn } from '../../../lib/utils';
4
- import { FaChevronLeft, FaChevronRight } from 'react-icons/fa';
5
- import { Button } from '../../Button';
6
- export const PageSizeSelector = ({ id, value, onChange, options = ['5', '10', '20', '50', '100'], label = 'Rows per page:', className, size = 'default', }) => {
7
- return (_jsxs("div", { className: cn('flex items-center gap-2 text-xs', className), id: `page-size-select-${id}`, children: [_jsx("label", { htmlFor: `page-size-select-${id}`, children: label }), _jsx("div", { className: "w-fit", children: _jsx(SelectWrapper, { size: size, value: value, onChange: onChange, options: options.map((option) => ({
8
- label: option,
9
- value: option,
10
- })), className: "bg-transparent shadow-none border-none gap-1" }) })] }));
11
- };
12
- export const PaginationFooter = ({ table, tableId, paginationMode = 'client', onPageSizeChange, totalServerRows, onNextPage, onPrevPage, }) => {
13
- const { pageIndex, pageSize } = table.getState().pagination;
14
- const totalRows = paginationMode === 'server' ? (totalServerRows !== null && totalServerRows !== void 0 ? totalServerRows : 0) : table.getFilteredRowModel().rows.length;
15
- const startRow = pageIndex * pageSize + 1;
16
- const endRow = Math.min((pageIndex + 1) * pageSize, totalRows);
17
- return (_jsxs("div", { className: "flex justify-end items-center gap-6 px-4 py-2 text-xs text-(--uikit-textSecondary) w-full", children: [_jsx(PageSizeSelector, { id: tableId, value: String(pageSize), onChange: (val) => {
18
- const newSize = Number(val);
19
- table.setPageSize(newSize);
20
- onPageSizeChange === null || onPageSizeChange === void 0 ? void 0 : onPageSizeChange(newSize);
21
- }, size: "small", label: "Rows per page" }), totalRows > 0 && _jsx("div", { id: `page-indicator-${tableId}`, children: `${startRow} - ${endRow} of ${totalRows}` }), totalRows > 0 && (_jsxs("div", { className: "flex gap-2", id: `pagination-controls-${tableId}`, children: [_jsx(Button, { variant: "ghost", size: "icon", "aria-label": "Previous page", className: cn({ '!bg-transparent': !table.getCanPreviousPage() }), onClick: onPrevPage, disabled: !table.getCanPreviousPage(), children: _jsx(FaChevronLeft, { className: "!w-3 !h-3" }) }), _jsx(Button, { variant: "ghost", size: "icon", "aria-label": "Next page", onClick: onNextPage, className: cn({ '!bg-transparent': !table.getCanNextPage() }), disabled: !table.getCanNextPage(), children: _jsx(FaChevronRight, { className: "w-3! h-3!" }) })] }))] }));
22
- };
@@ -1,24 +0,0 @@
1
- import type { Table } from '@tanstack/react-table';
2
- import type { SelectWrapperProps } from '../../SelectWrapper';
3
- import { PaginationMode } from '../Table.types';
4
- export interface PaginationControlsProps<T> {
5
- tableId: string;
6
- table: Table<T>;
7
- paginationMode?: PaginationMode;
8
- totalServerRows?: number;
9
- pageSizeOptions?: string[];
10
- onPageSizeChange?: (size: number) => void;
11
- onNextPage: () => void;
12
- onPrevPage: () => void;
13
- canNextPage: boolean;
14
- canPrevPage: boolean;
15
- }
16
- export type PageSizeSelectorProps = {
17
- id: string;
18
- value: string;
19
- onChange: (val: string) => void;
20
- options?: string[];
21
- label?: string;
22
- className?: SelectWrapperProps['className'];
23
- size?: SelectWrapperProps['size'];
24
- };
@@ -1,4 +0,0 @@
1
- import type { TableProps } from './Table.types';
2
- export declare function Table<T extends {
3
- id: string;
4
- }>(props: Readonly<TableProps<T>>): import("react/jsx-runtime").JSX.Element;
@@ -1,93 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { flexRender } from '@tanstack/react-table';
3
- import { classNames } from '../../utils/classNames';
4
- import { PaginationFooter } from './Pagination/PaginationControls';
5
- import { useTableController } from './hooks/useTableController';
6
- import { FaChevronDown, FaChevronUp } from 'react-icons/fa';
7
- import { DropdownWrapper } from '../DropdownWrapper';
8
- import { FiMoreHorizontal } from 'react-icons/fi';
9
- import { Button } from '../Button';
10
- export function Table(props) {
11
- var _a, _b, _c, _d, _e, _f, _g;
12
- const { table, setPageSize, showHeader, height, virtualizationEnabled, rowVirtualizer, hasNextPage, parentScrollRef, loaderRef, infiniteScroll, ...pagination } = useTableController(props);
13
- let tableContent;
14
- const noResultsMessage = props.isSearchActive
15
- ? ((_a = props.noSearchResultsMessage) !== null && _a !== void 0 ? _a : 'No results meet your search criteria')
16
- : ((_b = props.noRowsMessage) !== null && _b !== void 0 ? _b : 'No rows to display');
17
- if (props.isLoading && props.showSkeletonRows) {
18
- tableContent = Array.from({ length: 3 }).map(() => (_jsx("tr", { className: "border-t animate-pulse", children: table.getVisibleFlatColumns().map((__c) => (_jsx("td", { className: "px-4 py-2", children: _jsx("div", { className: "h-4 w-3/4 bg-(--uikit-tertiary) rounded" }) }, `skeleton-cell-${__c.id}`))) }, "skeleton-row")));
19
- }
20
- else if (!virtualizationEnabled &&
21
- table.getRowModel().rows.length === 0 &&
22
- !props.isLoading &&
23
- (!(infiniteScroll === null || infiniteScroll === void 0 ? void 0 : infiniteScroll.enabled) || !hasNextPage)) {
24
- tableContent = (_jsx("tr", { children: _jsx("td", { colSpan: table.getVisibleFlatColumns().length + (props.tableActionsDropdown ? 1 : 0), className: "px-4 py-8 text-center text-muted-foreground", children: noResultsMessage }) }));
25
- }
26
- else if (!virtualizationEnabled) {
27
- const renderRow = (row) => {
28
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
29
- const rows = [];
30
- const isRowClickable = (_a = props.isRowClickable) === null || _a === void 0 ? void 0 : _a.call(props, row.original);
31
- if (row.getIsGrouped() && row.groupingColumnId) {
32
- const column = table.getColumn(row.groupingColumnId);
33
- const bgColor = (_c = (_b = column === null || column === void 0 ? void 0 : column.columnDef.meta) === null || _b === void 0 ? void 0 : _b.bgColor) !== null && _c !== void 0 ? _c : 'transparent';
34
- rows.push(_jsx("tr", { className: "border-none", children: _jsx("td", { colSpan: table.getVisibleLeafColumns().length, className: "p-0", children: _jsx("div", { className: "px-4 py-4 text-sm text-muted-foreground", style: { backgroundColor: bgColor }, children: row.getGroupingValue(row.groupingColumnId) }) }) }, `group-${row.id}`));
35
- row.subRows.forEach((subRow) => {
36
- rows.push(...renderRow(subRow));
37
- });
38
- }
39
- else {
40
- rows.push(_jsxs("tr", { className: classNames('border-t', isRowClickable && 'cursor-pointer', row.getIsSelected() && 'bg-(--uikit-primary-10)'), onClick: () => { var _a; return isRowClickable && ((_a = props.onRowClick) === null || _a === void 0 ? void 0 : _a.call(props, row.original)); }, children: [row.getVisibleCells().map((cell) => {
41
- const width = cell.column.getSize();
42
- return (_jsx("td", { style: { width }, className: cell.column.id === 'select' ? 'p-1' : 'p-4', children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
43
- }), props.tableActionsDropdown && (_jsx("td", { className: "w-[40px] px-2 py-2 text-right", children: _jsx(DropdownWrapper, { structure: (_d = props.tableActionsDropdown.structure) !== null && _d !== void 0 ? _d : 'default', options: props.tableActionsDropdown.getOptions(row.original), menuAlignment: props.tableActionsDropdown.menuAlignment, isTriggerElementDisabled: typeof props.tableActionsDropdown.isDisabled === 'function'
44
- ? props.tableActionsDropdown.isDisabled(row.original)
45
- : props.tableActionsDropdown.isDisabled, triggerElement: (_g = (_f = (_e = props.tableActionsDropdown).renderCustomTrigger) === null || _f === void 0 ? void 0 : _f.call(_e, row.original)) !== null && _g !== void 0 ? _g : (_jsx(Button, { "aria-label": "Open actions menu", title: "Open actions menu", size: "icon", variant: "ghost", disabled: typeof props.tableActionsDropdown.isDisabled === 'function'
46
- ? props.tableActionsDropdown.isDisabled(row.original)
47
- : ((_h = props.tableActionsDropdown.isDisabled) !== null && _h !== void 0 ? _h : false), className: "p-1 focus-visible:outline-hidden focus-visible:ring-0", children: _jsx(FiMoreHorizontal, { size: 16 }) })) }) }))] }, row.original[((_j = props.rowIdKey) !== null && _j !== void 0 ? _j : 'id')]));
48
- }
49
- return rows;
50
- };
51
- tableContent = table.getRowModel().rows.flatMap(renderRow);
52
- }
53
- const virtualItems = virtualizationEnabled && rowVirtualizer ? rowVirtualizer.getVirtualItems() : [];
54
- const colSpanFull = table.getVisibleFlatColumns().length + (props.tableActionsDropdown ? 1 : 0);
55
- const paddingTop = virtualItems.length ? virtualItems[0].start : 0;
56
- const lastVirtual = virtualItems[virtualItems.length - 1];
57
- const totalSize = (_d = (_c = rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.getTotalSize) === null || _c === void 0 ? void 0 : _c.call(rowVirtualizer)) !== null && _d !== void 0 ? _d : 0;
58
- const end = lastVirtual ? lastVirtual.end : 0;
59
- const paddingBottom = Math.max(totalSize - end, 0);
60
- const tableRows = table.getRowModel().rows;
61
- const isTrulyEmpty = tableRows.length === 0 && !props.isLoading && !hasNextPage;
62
- return (_jsxs("div", { ref: parentScrollRef, style: { height }, className: "relative w-full overflow-auto", children: [props.isLoading && (_jsx("div", { className: classNames('mui-loader', showHeader ? 'mt-4' : 'mt-0') })), _jsx("div", { className: "rounded-t-(--uikit-radius) overflow-y-hidden overflow-x-auto", children: _jsxs("table", { className: classNames('min-w-full text-sm table-fixed bg-[#ffffff]', props.className), role: "table", id: props.id, children: [showHeader && (_jsx("thead", { className: "bg-(--uikit-tertiary)", children: table.getHeaderGroups().map((headerGroup) => (_jsxs("tr", { className: "p-4", children: [headerGroup.headers.map((header) => {
63
- return (_jsx("th", { scope: "col", style: { width: header.getSize() }, className: classNames('select-none text-[14px] font-bold ', header.id === 'select' ? 'p-0' : ' p-4 text-left cursor-pointer'), onClick: !(infiniteScroll === null || infiniteScroll === void 0 ? void 0 : infiniteScroll.enabled) && header.column.getCanSort()
64
- ? header.column.getToggleSortingHandler()
65
- : undefined, children: _jsxs("div", { className: classNames('w-full h-full', header.id === 'select'
66
- ? 'flex justify-center items-center'
67
- : 'flex items-center gap-2'), children: [flexRender(header.column.columnDef.header, header.getContext()), !(infiniteScroll === null || infiniteScroll === void 0 ? void 0 : infiniteScroll.enabled) && header.column.getCanSort() && (_jsx("span", { className: "text-xs", children: {
68
- asc: _jsx(FaChevronUp, {}),
69
- desc: _jsx(FaChevronDown, {}),
70
- }[header.column.getIsSorted()] || null }))] }) }, header.id));
71
- }), props.tableActionsDropdown && _jsx("th", { className: "w-[40px] px-2 py-2 text-right" })] }, headerGroup.id))) })), _jsx("tbody", { children: virtualizationEnabled && rowVirtualizer ? (_jsxs(_Fragment, { children: [_jsx("tr", { style: { height: `${paddingTop}px` }, children: _jsx("td", { colSpan: colSpanFull }) }), isTrulyEmpty && (_jsx("tr", { children: _jsx("td", { colSpan: colSpanFull, className: "px-4 py-8 text-center text-muted-foreground", children: noResultsMessage }) })), virtualItems.map((vi) => {
72
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
73
- const isLoaderRow = vi.index >= tableRows.length;
74
- if (isLoaderRow) {
75
- return (_jsx("tr", { className: "border-t", children: _jsx("td", { colSpan: colSpanFull, className: "px-4 py-2", children: hasNextPage
76
- ? ((_a = infiniteScroll === null || infiniteScroll === void 0 ? void 0 : infiniteScroll.loadingMoreMessage) !== null && _a !== void 0 ? _a : 'Loading more...')
77
- : ((_b = infiniteScroll === null || infiniteScroll === void 0 ? void 0 : infiniteScroll.noMoreDataMessage) !== null && _b !== void 0 ? _b : 'Nothing more to load') }) }, `loader-${vi.key}`));
78
- }
79
- const row = tableRows[vi.index];
80
- const isRowClickable = (_c = props.isRowClickable) === null || _c === void 0 ? void 0 : _c.call(props, row.original);
81
- return (_jsxs("tr", { className: classNames('border-t', isRowClickable && 'cursor-pointer', (row === null || row === void 0 ? void 0 : row.getIsSelected()) && 'bg-(--uikit-primary-10)'), onClick: () => { var _a; return isRowClickable && ((_a = props.onRowClick) === null || _a === void 0 ? void 0 : _a.call(props, row.original)); }, children: [row === null || row === void 0 ? void 0 : row.getVisibleCells().map((cell) => {
82
- const width = cell.column.getSize();
83
- return (_jsx("td", { style: { width }, className: cell.column.id === 'select' ? 'p-1' : 'p-4', children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
84
- }), props.tableActionsDropdown && (_jsx("td", { className: "w-[40px] px-2 py-2 text-right", children: _jsx(DropdownWrapper, { structure: (_d = props.tableActionsDropdown.structure) !== null && _d !== void 0 ? _d : 'default', options: props.tableActionsDropdown.getOptions(row.original), menuAlignment: props.tableActionsDropdown.menuAlignment, isTriggerElementDisabled: typeof props.tableActionsDropdown.isDisabled === 'function'
85
- ? props.tableActionsDropdown.isDisabled(row.original)
86
- : props.tableActionsDropdown.isDisabled, triggerElement: (_g = (_f = (_e = props.tableActionsDropdown).renderCustomTrigger) === null || _f === void 0 ? void 0 : _f.call(_e, row.original)) !== null && _g !== void 0 ? _g : (_jsx(Button, { "aria-label": "Open actions menu", title: "Open actions menu", size: "icon", variant: "ghost", disabled: typeof props.tableActionsDropdown.isDisabled ===
87
- 'function'
88
- ? props.tableActionsDropdown.isDisabled(row.original)
89
- : ((_h = props.tableActionsDropdown.isDisabled) !== null && _h !== void 0 ? _h : false), className: "p-1 focus-visible:outline-hidden focus-visible:ring-0", children: _jsx(FiMoreHorizontal, { size: 16 }) })) }) }))] }, row.original[((_j = props.rowIdKey) !== null && _j !== void 0 ? _j : 'id')]));
90
- }), _jsx("tr", { style: { height: `${paddingBottom}px` }, children: _jsx("td", { colSpan: colSpanFull }) })] })) : (_jsxs(_Fragment, { children: [tableContent, (infiniteScroll === null || infiniteScroll === void 0 ? void 0 : infiniteScroll.enabled) && !isTrulyEmpty && (_jsx("tr", { ref: loaderRef, className: "border-t", children: _jsx("td", { colSpan: colSpanFull, className: "px-4 py-2", children: props.isLoading || hasNextPage
91
- ? ((_e = infiniteScroll.loadingMoreMessage) !== null && _e !== void 0 ? _e : 'Loading more...')
92
- : ((_f = infiniteScroll.noMoreDataMessage) !== null && _f !== void 0 ? _f : 'Nothing more to load') }) }))] })) })] }) }), !((_g = props.infiniteScroll) === null || _g === void 0 ? void 0 : _g.enabled) && (_jsx(PaginationFooter, { tableId: props.id, table: table, paginationMode: props.paginationMode, totalServerRows: props.totalServerRows, onPageSizeChange: setPageSize, ...pagination }))] }));
93
- }
@@ -1,31 +0,0 @@
1
- import { Table } from './Table';
2
- import type { Meta, StoryObj } from '@storybook/react';
3
- declare const meta: Meta<typeof Table>;
4
- export default meta;
5
- type Story = StoryObj<typeof Table>;
6
- export declare const Basic: Story;
7
- export declare const NoRows: Story;
8
- export declare const LoadingWithSkeleton: Story;
9
- export declare const ClientPagination: Story;
10
- export declare const ServerSidePagination: Story;
11
- export declare const WithCheckboxSelection: Story;
12
- export declare const WithDisabledSelection: Story;
13
- export declare const WithSingleRowSelection: Story;
14
- export declare const WithDefaultRowsSelected: Story;
15
- export declare const FlexColumnWidths: Story;
16
- export declare const WithControlledSorting: Story;
17
- export declare const WithRowActionsDropdown: Story;
18
- export declare const WithPartiallyDisabledRowActionsDropdown: Story;
19
- export declare const WithDisabledRowActionsDropdownItem: Story;
20
- export declare const WithRowClickHandler: Story;
21
- export declare const WithHiddenHeader: Story;
22
- export declare const GroupedByDate: Story;
23
- export declare const WithSearch: Story;
24
- export declare const ServerSideSearch: Story;
25
- export declare const ClientPaginationWithQueryParams: StoryObj;
26
- export declare const ServerPaginationWithQueryParams: StoryObj;
27
- export declare const TwoTablesWithQueryParams: StoryObj;
28
- export declare const InfiniteScrollVirtualized: StoryObj;
29
- export declare const InfiniteScrollNonVirtual: StoryObj;
30
- export declare const NoRowsInfiniteScrollNonVirtual: StoryObj;
31
- export declare const NoRowsInfiniteScrollVirtualized: StoryObj;