@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.
- package/README.md +73 -13
- package/dist/index.css +2 -2
- package/dist/src/assets/index.d.ts +2 -0
- package/dist/src/assets/index.js +3 -0
- package/dist/src/assets/index.ts +3 -0
- package/dist/src/components/Checkbox/Checkbox.js +1 -1
- package/dist/src/components/DatePicker/index.d.ts +1 -1
- package/dist/src/components/Filters/FilterSelect.d.ts +21 -0
- package/dist/src/components/Filters/FilterSelect.js +11 -0
- package/dist/src/components/Filters/Filters.d.ts +3 -0
- package/dist/src/components/Filters/Filters.js +35 -0
- package/dist/src/components/Filters/Filters.stories.d.ts +12 -0
- package/dist/src/components/Filters/Filters.stories.js +235 -0
- package/dist/src/components/Filters/Filters.types.d.ts +27 -0
- package/dist/src/components/Filters/Filters.types.js +3 -0
- package/dist/src/components/Filters/index.d.ts +2 -0
- package/dist/src/components/Filters/index.js +1 -0
- package/dist/src/components/Table/Pagination/Pagination.types.d.ts +1 -0
- package/dist/src/components/Table/Pagination/PaginationFooter.d.ts +1 -1
- package/dist/src/components/Table/Pagination/PaginationFooter.js +2 -2
- package/dist/src/components/Table/StandardTable/StandardTable.js +1 -1
- package/dist/src/components/Table/StandardTable/StandardTable.stories.d.ts +1 -0
- package/dist/src/components/Table/StandardTable/StandardTable.stories.js +3 -0
- package/dist/src/components/Table/Table.types.d.ts +2 -0
- package/dist/src/components/Tooltip/Tooltip.stories.js +1 -1
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.js +1 -0
- package/package.json +132 -131
- package/dist/src/components/Table/Pagination/PaginationControls.d.ts +0 -3
- package/dist/src/components/Table/Pagination/PaginationControls.js +0 -22
- package/dist/src/components/Table/Pagination/PaginationControls.types.d.ts +0 -24
- package/dist/src/components/Table/Pagination/PaginationControls.types.js +0 -1
- package/dist/src/components/Table/Table.d.ts +0 -4
- package/dist/src/components/Table/Table.js +0 -93
- package/dist/src/components/Table/Table.stories.d.ts +0 -31
- package/dist/src/components/Table/Table.stories.js +0 -479
- package/dist/src/components/Table/hooks/useInfiniteScrolling.d.ts +0 -29
- package/dist/src/components/Table/hooks/useInfiniteScrolling.js +0 -96
- package/dist/src/components/Table/hooks/usePaginationController.d.ts +0 -16
- package/dist/src/components/Table/hooks/usePaginationController.js +0 -30
- package/dist/src/components/Table/hooks/useTableController.d.ts +0 -26
- package/dist/src/components/Table/hooks/useTableController.js +0 -146
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
export type FilterSelectOption = {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
icon?: React.ReactNode;
|
|
6
|
+
description?: React.ReactNode;
|
|
7
|
+
};
|
|
8
|
+
export interface FilterSelectProps {
|
|
9
|
+
value?: string;
|
|
10
|
+
onValueChange?: (value: string) => void;
|
|
11
|
+
onChange?: (value: string) => void;
|
|
12
|
+
onBlur?: () => void;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
options: FilterSelectOption[];
|
|
16
|
+
showAlwaysSearch?: boolean;
|
|
17
|
+
error?: boolean;
|
|
18
|
+
className?: string;
|
|
19
|
+
label?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const FilterSelect: FC<FilterSelectProps>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FaChevronUp, FaChevronDown } from 'react-icons/fa';
|
|
3
|
+
import { Select, SelectTrigger, SelectValue, SelectContent, SelectGroup, SelectItem, SelectScrollUpButton, SelectScrollDownButton, } from '../Select';
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
export const FilterSelect = ({ value, onValueChange, onChange, onBlur, disabled, placeholder = 'Select an option...', options, showAlwaysSearch, error, className, }) => {
|
|
6
|
+
const handleValueChange = (newValue) => {
|
|
7
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue);
|
|
8
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
9
|
+
};
|
|
10
|
+
return (_jsxs(Select, { value: value, onValueChange: handleValueChange, disabled: disabled, children: [_jsx(SelectTrigger, { onBlur: onBlur, error: error, className: cn('h-full', className), children: _jsx(SelectValue, { placeholder: placeholder }) }), _jsxs(SelectContent, { showAlwaysSearch: showAlwaysSearch, children: [_jsx(SelectScrollUpButton, { children: _jsx(FaChevronUp, { className: "h-4 w-4" }) }), _jsx(SelectScrollDownButton, { children: _jsx(FaChevronDown, { className: "h-4 w-4" }) }), _jsx(SelectGroup, { children: options.map((option) => (_jsx(SelectItem, { value: option.value, children: _jsxs("div", { className: "flex items-center gap-2", children: [option.icon, _jsx("span", { children: option.label }), option.description] }) }, option.value))) })] })] }));
|
|
11
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { useForm, Controller, useWatch } from 'react-hook-form';
|
|
4
|
+
import { DatePicker } from '../DatePicker';
|
|
5
|
+
import { FilterSelect } from './FilterSelect';
|
|
6
|
+
import { Checkbox } from '../Checkbox';
|
|
7
|
+
import { CHECKBOX_TYPE, DATE_RANGE_TYPE, SELECT_TYPE } from './Filters.types';
|
|
8
|
+
import { cn } from '../../lib/utils';
|
|
9
|
+
export const Filters = ({ filters, defaultValues, onChange }) => {
|
|
10
|
+
const { control } = useForm({
|
|
11
|
+
defaultValues,
|
|
12
|
+
});
|
|
13
|
+
const values = useWatch({ control });
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(values);
|
|
16
|
+
}, [values, onChange]);
|
|
17
|
+
const renderFilterComponent = (filterConfig, field) => {
|
|
18
|
+
const { type, ...filterProps } = filterConfig;
|
|
19
|
+
switch (type) {
|
|
20
|
+
case DATE_RANGE_TYPE: {
|
|
21
|
+
const dateProps = filterProps;
|
|
22
|
+
return (_jsx(DatePicker, { mode: "range", currentDate: field.value, onChangeDate: field.onChange, onBlur: field.onBlur, ...dateProps, className: cn('min-w-[200px]', dateProps.className) }));
|
|
23
|
+
}
|
|
24
|
+
case SELECT_TYPE: {
|
|
25
|
+
const selectProps = filterProps;
|
|
26
|
+
return (_jsx(FilterSelect, { value: field.value, onChange: field.onChange, onBlur: field.onBlur, ...selectProps, className: cn('min-w-[200px]', selectProps.className) }));
|
|
27
|
+
}
|
|
28
|
+
case CHECKBOX_TYPE:
|
|
29
|
+
return (_jsx(Checkbox, { checked: field.value, onCheckedChange: field.onChange, labelPosition: "right", className: "border-(--uikit-inputEnabledBorder)", ...filterProps }));
|
|
30
|
+
default:
|
|
31
|
+
throw new Error(`Unknown filter type: ${type}`);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
return (_jsx("div", { className: "flex items-center gap-3 h-15", children: filters.map((filterConfig) => (_jsx("div", { className: "flex items-center mb-3 h-10", children: _jsx(Controller, { name: filterConfig.name, control: control, render: ({ field }) => renderFilterComponent(filterConfig, field) }) }, filterConfig.name))) }));
|
|
35
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FiltersProps } from './Filters.types';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
declare const meta: Meta<FiltersProps>;
|
|
4
|
+
type Story = StoryObj<FiltersProps>;
|
|
5
|
+
export declare const Default: Story;
|
|
6
|
+
export declare const DateRangeOnly: Story;
|
|
7
|
+
export declare const SelectOnly: Story;
|
|
8
|
+
export declare const CheckboxOnly: Story;
|
|
9
|
+
export declare const WithDefaultValues: Story;
|
|
10
|
+
export declare const MultipleSelects: Story;
|
|
11
|
+
export declare const ComplexFilters: Story;
|
|
12
|
+
export default meta;
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Filters } from './Filters';
|
|
4
|
+
import { dayjs } from '../../utils/dayjs';
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'UIKit/Filters',
|
|
7
|
+
component: Filters,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
args: {
|
|
10
|
+
onChange: (values) => console.log('Filters changed:', values),
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
// Sample data for filter options
|
|
14
|
+
const selectOptions = [
|
|
15
|
+
{ label: 'Active', value: 'active' },
|
|
16
|
+
{ label: 'Inactive', value: 'inactive' },
|
|
17
|
+
{ label: 'Pending', value: 'pending' },
|
|
18
|
+
];
|
|
19
|
+
const statusOptions = [
|
|
20
|
+
{ label: 'Approved', value: 'approved' },
|
|
21
|
+
{ label: 'Rejected', value: 'rejected' },
|
|
22
|
+
{ label: 'Under Review', value: 'under-review' },
|
|
23
|
+
];
|
|
24
|
+
export const Default = {
|
|
25
|
+
args: {
|
|
26
|
+
filters: [
|
|
27
|
+
{
|
|
28
|
+
type: 'dateRange',
|
|
29
|
+
name: 'dateRange',
|
|
30
|
+
rangeDateFormat: 'D MMM YY',
|
|
31
|
+
placeholder: `${dayjs().subtract(6, 'month').format('D MMM YY')} - Today`,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
type: 'select',
|
|
35
|
+
name: 'status',
|
|
36
|
+
label: 'Status',
|
|
37
|
+
options: selectOptions,
|
|
38
|
+
placeholder: 'Select status...',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: 'checkbox',
|
|
42
|
+
name: 'active',
|
|
43
|
+
label: 'Active Only',
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
render: (args) => {
|
|
48
|
+
const [values, setValues] = useState({});
|
|
49
|
+
return (_jsxs("div", { children: [_jsx(Filters, { ...args, onChange: (newValues) => {
|
|
50
|
+
var _a;
|
|
51
|
+
setValues(newValues);
|
|
52
|
+
(_a = args.onChange) === null || _a === void 0 ? void 0 : _a.call(args, newValues);
|
|
53
|
+
} }), _jsxs("div", { className: "mt-4 rounded border border-gray-200 bg-gray-50 p-4", children: [_jsx("p", { className: "text-sm font-semibold", children: "Current Values:" }), _jsx("pre", { className: "mt-2 text-xs", children: JSON.stringify(values, null, 2) })] })] }));
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
export const DateRangeOnly = {
|
|
57
|
+
args: {
|
|
58
|
+
filters: [
|
|
59
|
+
{
|
|
60
|
+
type: 'dateRange',
|
|
61
|
+
name: 'dateRange',
|
|
62
|
+
rangeDateFormat: 'D MMM YY',
|
|
63
|
+
placeholder: `${dayjs().subtract(1, 'month').format('D MMM YY')} - Today`,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
render: (args) => {
|
|
68
|
+
const [values, setValues] = useState({});
|
|
69
|
+
return (_jsxs("div", { children: [_jsx(Filters, { ...args, onChange: (newValues) => {
|
|
70
|
+
var _a;
|
|
71
|
+
setValues(newValues);
|
|
72
|
+
(_a = args.onChange) === null || _a === void 0 ? void 0 : _a.call(args, newValues);
|
|
73
|
+
} }), _jsxs("div", { className: "mt-4 rounded border border-gray-200 bg-gray-50 p-4", children: [_jsx("p", { className: "text-sm font-semibold", children: "Selected Dates:" }), _jsx("pre", { className: "mt-2 text-xs", children: JSON.stringify(values, null, 2) })] })] }));
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
export const SelectOnly = {
|
|
77
|
+
args: {
|
|
78
|
+
filters: [
|
|
79
|
+
{
|
|
80
|
+
type: 'select',
|
|
81
|
+
name: 'status',
|
|
82
|
+
label: 'Filter by Status',
|
|
83
|
+
options: statusOptions,
|
|
84
|
+
placeholder: 'Choose a status...',
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
render: (args) => {
|
|
89
|
+
const [values, setValues] = useState({});
|
|
90
|
+
return (_jsxs("div", { children: [_jsx(Filters, { ...args, onChange: (newValues) => {
|
|
91
|
+
var _a;
|
|
92
|
+
setValues(newValues);
|
|
93
|
+
(_a = args.onChange) === null || _a === void 0 ? void 0 : _a.call(args, newValues);
|
|
94
|
+
} }), _jsxs("div", { className: "mt-4 rounded border border-gray-200 bg-gray-50 p-4", children: [_jsx("p", { className: "text-sm font-semibold", children: "Selected Value:" }), _jsx("pre", { className: "mt-2 text-xs", children: JSON.stringify(values, null, 2) })] })] }));
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
export const CheckboxOnly = {
|
|
98
|
+
args: {
|
|
99
|
+
filters: [
|
|
100
|
+
{
|
|
101
|
+
type: 'checkbox',
|
|
102
|
+
name: 'verified',
|
|
103
|
+
label: 'Verified Only',
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
type: 'checkbox',
|
|
107
|
+
name: 'archived',
|
|
108
|
+
label: 'Show Archived',
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
},
|
|
112
|
+
render: (args) => {
|
|
113
|
+
const [values, setValues] = useState({});
|
|
114
|
+
return (_jsxs("div", { children: [_jsx(Filters, { ...args, onChange: (newValues) => {
|
|
115
|
+
var _a;
|
|
116
|
+
setValues(newValues);
|
|
117
|
+
(_a = args.onChange) === null || _a === void 0 ? void 0 : _a.call(args, newValues);
|
|
118
|
+
} }), _jsxs("div", { className: "mt-4 rounded border border-gray-200 bg-gray-50 p-4", children: [_jsx("p", { className: "text-sm font-semibold", children: "Checked Items:" }), _jsx("pre", { className: "mt-2 text-xs", children: JSON.stringify(values, null, 2) })] })] }));
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
export const WithDefaultValues = {
|
|
122
|
+
args: {
|
|
123
|
+
filters: [
|
|
124
|
+
{
|
|
125
|
+
type: 'select',
|
|
126
|
+
name: 'category',
|
|
127
|
+
label: 'Category',
|
|
128
|
+
options: [
|
|
129
|
+
{ label: 'Electronics', value: 'electronics' },
|
|
130
|
+
{ label: 'Clothing', value: 'clothing' },
|
|
131
|
+
{ label: 'Food', value: 'food' },
|
|
132
|
+
],
|
|
133
|
+
placeholder: 'Select category...',
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
type: 'checkbox',
|
|
137
|
+
name: 'inStock',
|
|
138
|
+
label: 'In Stock Only',
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
defaultValues: {
|
|
142
|
+
category: 'electronics',
|
|
143
|
+
inStock: true,
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
render: (args) => {
|
|
147
|
+
const [values, setValues] = useState(args.defaultValues || {});
|
|
148
|
+
return (_jsxs("div", { children: [_jsx(Filters, { ...args, onChange: (newValues) => {
|
|
149
|
+
var _a;
|
|
150
|
+
setValues(newValues);
|
|
151
|
+
(_a = args.onChange) === null || _a === void 0 ? void 0 : _a.call(args, newValues);
|
|
152
|
+
} }), _jsxs("div", { className: "mt-4 rounded border border-gray-200 bg-gray-50 p-4", children: [_jsx("p", { className: "text-sm font-semibold", children: "Current Values:" }), _jsx("pre", { className: "mt-2 text-xs", children: JSON.stringify(values, null, 2) })] })] }));
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
export const MultipleSelects = {
|
|
156
|
+
args: {
|
|
157
|
+
filters: [
|
|
158
|
+
{
|
|
159
|
+
type: 'select',
|
|
160
|
+
name: 'department',
|
|
161
|
+
label: 'Department',
|
|
162
|
+
options: [
|
|
163
|
+
{ label: 'Sales', value: 'sales' },
|
|
164
|
+
{ label: 'Engineering', value: 'engineering' },
|
|
165
|
+
{ label: 'HR', value: 'hr' },
|
|
166
|
+
{ label: 'Finance', value: 'finance' },
|
|
167
|
+
],
|
|
168
|
+
placeholder: 'Select department...',
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
type: 'select',
|
|
172
|
+
name: 'region',
|
|
173
|
+
label: 'Region',
|
|
174
|
+
options: [
|
|
175
|
+
{ label: 'North America', value: 'na' },
|
|
176
|
+
{ label: 'Europe', value: 'eu' },
|
|
177
|
+
{ label: 'Asia', value: 'asia' },
|
|
178
|
+
{ label: 'Australia', value: 'au' },
|
|
179
|
+
],
|
|
180
|
+
placeholder: 'Select region...',
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
},
|
|
184
|
+
render: (args) => {
|
|
185
|
+
const [values, setValues] = useState({});
|
|
186
|
+
return (_jsxs("div", { children: [_jsx(Filters, { ...args, onChange: (newValues) => {
|
|
187
|
+
var _a;
|
|
188
|
+
setValues(newValues);
|
|
189
|
+
(_a = args.onChange) === null || _a === void 0 ? void 0 : _a.call(args, newValues);
|
|
190
|
+
} }), _jsxs("div", { className: "mt-4 rounded border border-gray-200 bg-gray-50 p-4", children: [_jsx("p", { className: "text-sm font-semibold", children: "Selected Filters:" }), _jsx("pre", { className: "mt-2 text-xs", children: JSON.stringify(values, null, 2) })] })] }));
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
export const ComplexFilters = {
|
|
194
|
+
args: {
|
|
195
|
+
filters: [
|
|
196
|
+
{
|
|
197
|
+
type: 'dateRange',
|
|
198
|
+
name: 'createdDate',
|
|
199
|
+
rangeDateFormat: 'D MMM YY',
|
|
200
|
+
placeholder: `${dayjs().subtract(3, 'month').format('D MMM YY')} - Today`,
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
type: 'select',
|
|
204
|
+
name: 'priority',
|
|
205
|
+
label: 'Priority',
|
|
206
|
+
options: [
|
|
207
|
+
{ label: 'Low', value: 'low' },
|
|
208
|
+
{ label: 'Medium', value: 'medium' },
|
|
209
|
+
{ label: 'High', value: 'high' },
|
|
210
|
+
{ label: 'Critical', value: 'critical' },
|
|
211
|
+
],
|
|
212
|
+
placeholder: 'Select priority...',
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
type: 'checkbox',
|
|
216
|
+
name: 'urgent',
|
|
217
|
+
label: 'Urgent Only',
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
type: 'checkbox',
|
|
221
|
+
name: 'assigned',
|
|
222
|
+
label: 'Assigned to Me',
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
},
|
|
226
|
+
render: (args) => {
|
|
227
|
+
const [values, setValues] = useState({});
|
|
228
|
+
return (_jsxs("div", { children: [_jsx(Filters, { ...args, onChange: (newValues) => {
|
|
229
|
+
var _a;
|
|
230
|
+
setValues(newValues);
|
|
231
|
+
(_a = args.onChange) === null || _a === void 0 ? void 0 : _a.call(args, newValues);
|
|
232
|
+
} }), _jsxs("div", { className: "mt-4 rounded border border-gray-200 bg-gray-50 p-4", children: [_jsx("p", { className: "text-sm font-semibold", children: "Applied Filters:" }), _jsx("pre", { className: "mt-2 text-xs", children: JSON.stringify(values, null, 2) })] })] }));
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
export default meta;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { DatePickerProps } from '../DatePicker';
|
|
2
|
+
import type { CheckboxProps } from '../Checkbox';
|
|
3
|
+
import type { FilterSelectProps } from './FilterSelect';
|
|
4
|
+
export declare const DATE_RANGE_TYPE = "dateRange";
|
|
5
|
+
export declare const SELECT_TYPE = "select";
|
|
6
|
+
export declare const CHECKBOX_TYPE = "checkbox";
|
|
7
|
+
export type FilterType = typeof DATE_RANGE_TYPE | typeof SELECT_TYPE | typeof CHECKBOX_TYPE;
|
|
8
|
+
type DateRangeFilterOption = Omit<DatePickerProps, 'type'> & {
|
|
9
|
+
type: typeof DATE_RANGE_TYPE;
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
12
|
+
type SelectFilterOption = Omit<FilterSelectProps, 'value' | 'onValueChange'> & {
|
|
13
|
+
type: typeof SELECT_TYPE;
|
|
14
|
+
name: string;
|
|
15
|
+
label?: string;
|
|
16
|
+
};
|
|
17
|
+
type CheckboxFilterOption = Omit<CheckboxProps, 'type'> & {
|
|
18
|
+
type: typeof CHECKBOX_TYPE;
|
|
19
|
+
name: string;
|
|
20
|
+
};
|
|
21
|
+
export type FilterConfigType = DateRangeFilterOption | SelectFilterOption | CheckboxFilterOption;
|
|
22
|
+
export type FiltersProps = {
|
|
23
|
+
filters: FilterConfigType[];
|
|
24
|
+
defaultValues?: Record<string, unknown>;
|
|
25
|
+
onChange: (values: Record<string, unknown>) => void;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Filters } from './Filters';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { PaginationControlsProps } from './Pagination.types';
|
|
2
|
-
export declare const PaginationFooter: ({ tableId, pageIndex, pageSize, totalRows, canNextPage, canPrevPage, onNextPage, onPrevPage, onPageSizeChange, }: PaginationControlsProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const PaginationFooter: ({ tableId, pageIndex, pageSize, totalRows, canNextPage, canPrevPage, onNextPage, onPrevPage, onPageSizeChange, showPageSizeSelector, }: PaginationControlsProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,8 +3,8 @@ import { FaChevronLeft, FaChevronRight } from 'react-icons/fa6';
|
|
|
3
3
|
import { PageSizeSelector } from './PageSizeSelector';
|
|
4
4
|
import { Button } from '../../Button';
|
|
5
5
|
import { cn } from '../../../lib/utils';
|
|
6
|
-
export const PaginationFooter = ({ tableId, pageIndex, pageSize, totalRows, canNextPage, canPrevPage, onNextPage, onPrevPage, onPageSizeChange, }) => {
|
|
6
|
+
export const PaginationFooter = ({ tableId, pageIndex, pageSize, totalRows, canNextPage, canPrevPage, onNextPage, onPrevPage, onPageSizeChange, showPageSizeSelector = true, }) => {
|
|
7
7
|
const startRow = totalRows === 0 ? 0 : pageIndex * pageSize + 1;
|
|
8
8
|
const endRow = totalRows === 0 ? 0 : Math.min((pageIndex + 1) * pageSize, totalRows);
|
|
9
|
-
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) => onPageSizeChange(Number(val)), 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", onClick: onPrevPage, disabled: !canPrevPage, className: cn({ '!bg-transparent': !canPrevPage }), children: _jsx(FaChevronLeft, { className: "!w-3 !h-3" }) }), _jsx(Button, { variant: "ghost", size: "icon", "aria-label": "Next page", onClick: onNextPage, disabled: !canNextPage, className: cn({ '!bg-transparent': !canNextPage }), children: _jsx(FaChevronRight, { className: "!w-3 !h-3" }) })] }))] }));
|
|
9
|
+
return (_jsxs("div", { className: "flex justify-end items-center gap-6 px-4 py-2 text-xs text-(--uikit-textSecondary) w-full", children: [showPageSizeSelector && (_jsx(PageSizeSelector, { id: tableId, value: String(pageSize), onChange: (val) => onPageSizeChange(Number(val)), 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", onClick: onPrevPage, disabled: !canPrevPage, className: cn({ '!bg-transparent': !canPrevPage }), children: _jsx(FaChevronLeft, { className: "!w-3 !h-3" }) }), _jsx(Button, { variant: "ghost", size: "icon", "aria-label": "Next page", onClick: onNextPage, disabled: !canNextPage, className: cn({ '!bg-transparent': !canNextPage }), children: _jsx(FaChevronRight, { className: "!w-3 !h-3" }) })] }))] }));
|
|
10
10
|
};
|
|
@@ -46,5 +46,5 @@ export function StandardTable(props) {
|
|
|
46
46
|
customNoRows: props.customNoRows,
|
|
47
47
|
accordion: enableAccordion,
|
|
48
48
|
showGroupedTotal: props.showGroupedTotal,
|
|
49
|
-
}), footer: props.paginationMode === 'client' || props.paginationMode === 'server' ? (_jsx(PaginationFooter, { tableId: props.id, pageIndex: pagination.pageIndex, pageSize: pagination.pageSize, totalRows: totalRows, canNextPage: pagination.canNextPage, canPrevPage: pagination.canPrevPage, onNextPage: pagination.onNextPage, onPrevPage: pagination.onPrevPage, onPageSizeChange: pagination.setPageSize })) : null }) }));
|
|
49
|
+
}), footer: props.paginationMode === 'client' || props.paginationMode === 'server' ? (_jsx(PaginationFooter, { tableId: props.id, pageIndex: pagination.pageIndex, pageSize: pagination.pageSize, totalRows: totalRows, canNextPage: pagination.canNextPage, canPrevPage: pagination.canPrevPage, onNextPage: pagination.onNextPage, onPrevPage: pagination.onPrevPage, onPageSizeChange: pagination.setPageSize, showPageSizeSelector: props.showPageSizeSelector })) : null }) }));
|
|
50
50
|
}
|
|
@@ -15,6 +15,7 @@ export declare const EmptyState: Story;
|
|
|
15
15
|
export declare const EmptyStateWithIcon: Story;
|
|
16
16
|
export declare const Loading: Story;
|
|
17
17
|
export declare const ClientPagination: Story;
|
|
18
|
+
export declare const HiddenPageSizeSelector: Story;
|
|
18
19
|
export declare const ServerPagination: Story;
|
|
19
20
|
export declare const RowClick: Story;
|
|
20
21
|
export declare const ControlledSorting: Story;
|
|
@@ -68,6 +68,9 @@ export const Loading = {
|
|
|
68
68
|
export const ClientPagination = {
|
|
69
69
|
render: () => (_jsx(StandardTable, { id: "client-pagination", data: data, columns: columns, paginationMode: "client", rowsPerPage: 5 })),
|
|
70
70
|
};
|
|
71
|
+
export const HiddenPageSizeSelector = {
|
|
72
|
+
render: () => (_jsx(StandardTable, { id: "hidden-page-size", data: data, columns: columns, paginationMode: "client", rowsPerPage: 5, showPageSizeSelector: false })),
|
|
73
|
+
};
|
|
71
74
|
function ServerPaginationExample() {
|
|
72
75
|
const [rows, setRows] = useState([]);
|
|
73
76
|
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -35,12 +35,14 @@ export type VirtualizationOptions = {
|
|
|
35
35
|
export type ClientPaginationProps = {
|
|
36
36
|
paginationMode?: 'client' | 'none';
|
|
37
37
|
rowsPerPage?: number;
|
|
38
|
+
showPageSizeSelector?: boolean;
|
|
38
39
|
onRefetch?: never;
|
|
39
40
|
totalServerRows?: never;
|
|
40
41
|
};
|
|
41
42
|
export type ServerPaginationProps = {
|
|
42
43
|
paginationMode: 'server';
|
|
43
44
|
rowsPerPage?: number;
|
|
45
|
+
showPageSizeSelector?: boolean;
|
|
44
46
|
onRefetch: (pageIndex: number, pageSize: number) => void;
|
|
45
47
|
totalServerRows: number;
|
|
46
48
|
};
|
|
@@ -12,7 +12,7 @@ export const Default = {
|
|
|
12
12
|
render: () => (_jsx(TooltipStoryWrapper, { content: "Simple tooltip", children: _jsx(Button, { children: "Hover me" }) })),
|
|
13
13
|
};
|
|
14
14
|
export const LongTextResponsive = {
|
|
15
|
-
render: () => (_jsx(TooltipStoryWrapper, { content: "This tooltip contains a longer message that wraps gracefully across multiple lines. On smaller\
|
|
15
|
+
render: () => (_jsx(TooltipStoryWrapper, { content: "This tooltip contains a longer message that wraps gracefully across multiple lines. On smaller\n\t\tscreens, it narrows and stacks vertically so it's easier to read\u2014especially useful for\n\t\taccessibility, mobile devices, or multi-language support.", side: "top", children: _jsx(Button, { children: "Hover me" }) })),
|
|
16
16
|
};
|
|
17
17
|
export const OnDifferentSides = {
|
|
18
18
|
render: () => (_jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsx(TooltipStoryWrapper, { content: "Top tooltip", side: "top", children: _jsx(Button, { children: "Top" }) }), _jsx(TooltipStoryWrapper, { content: "Bottom tooltip", side: "bottom", children: _jsx(Button, { children: "Bottom" }) }), _jsx(TooltipStoryWrapper, { content: "Left tooltip", side: "left", children: _jsx(Button, { children: "Left" }) }), _jsx(TooltipStoryWrapper, { content: "Right tooltip", side: "right", children: _jsx(Button, { children: "Right" }) })] })),
|