@eml-payments/ui-kit 1.6.0 → 1.7.1
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/index.css +1 -1
- package/dist/src/components/ButtonGroup/ButtonGroup.d.ts +3 -0
- package/dist/src/components/ButtonGroup/ButtonGroup.js +37 -0
- package/dist/src/components/ButtonGroup/ButtonGroup.stories.d.ts +8 -0
- package/dist/src/components/ButtonGroup/ButtonGroup.stories.js +44 -0
- package/dist/src/components/ButtonGroup/ButtonGroup.types.d.ts +18 -0
- package/dist/src/components/ButtonGroup/index.d.ts +2 -0
- package/dist/src/components/ButtonGroup/index.js +1 -0
- package/dist/src/components/Calendar/Calendar.js +15 -1
- package/dist/src/components/DatePicker/DatePicker.d.ts +7 -2
- package/dist/src/components/DatePicker/DatePicker.js +64 -12
- package/dist/src/components/DatePicker/DatePicker.stories.d.ts +1 -0
- package/dist/src/components/DatePicker/DatePicker.stories.js +32 -1
- package/dist/src/components/PhoneInput/PhoneInput.d.ts +4 -0
- package/dist/src/components/PhoneInput/PhoneInput.js +15 -0
- package/dist/src/components/PhoneInput/PhoneInput.stories.d.ts +15 -0
- package/dist/src/components/PhoneInput/PhoneInput.stories.js +66 -0
- package/dist/src/components/PhoneInput/PhoneInput.types.d.ts +14 -0
- package/dist/src/components/PhoneInput/PhoneInput.types.js +1 -0
- package/dist/src/components/PhoneInput/index.d.ts +2 -0
- package/dist/src/components/PhoneInput/index.js +2 -0
- package/dist/src/components/Table/StandardTable/StandardTable.js +1 -0
- package/dist/src/components/Table/StandardTable/StandardTable.stories.js +1 -1
- package/dist/src/components/Table/Table.types.d.ts +2 -0
- package/dist/src/components/Table/body/renderGroupRow.d.ts +2 -1
- package/dist/src/components/Table/body/renderGroupRow.js +2 -2
- package/dist/src/components/Table/body/renderTableBody.d.ts +2 -1
- package/dist/src/components/Table/body/renderTableBody.js +2 -1
- package/dist/src/components/Table/render-rows/renderTableRows.d.ts +2 -1
- package/dist/src/components/Table/render-rows/renderTableRows.js +2 -1
- package/dist/src/components/Tooltip/Tooltip.stories.js +1 -1
- package/dist/src/components/index.d.ts +2 -0
- package/dist/src/components/index.js +2 -0
- package/package.json +2 -1
- package/dist/index.d.cts +0 -488
- package/dist/index.d.ts +0 -488
- package/dist/src/components/Table/BaseTable/index.d.ts +0 -1
- package/dist/src/components/Table/BaseTable/index.js +0 -1
- 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/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
- /package/dist/src/components/{Table/Pagination/PaginationControls.types.js → ButtonGroup/ButtonGroup.types.js} +0 -0
|
@@ -8,31 +8,83 @@ import { Input } from '../Input';
|
|
|
8
8
|
const formatDate = (date, format) => {
|
|
9
9
|
return date ? dayjs(date).format(format) : '';
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const formatRangeDisplay = (dateRange, format) => {
|
|
12
|
+
if (!(dateRange === null || dateRange === void 0 ? void 0 : dateRange.from)) {
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
const fromStr = dayjs(dateRange.from).format(format);
|
|
16
|
+
if (!dateRange.to) {
|
|
17
|
+
return fromStr;
|
|
18
|
+
}
|
|
19
|
+
const today = dayjs();
|
|
20
|
+
const toDate = dayjs(dateRange.to);
|
|
21
|
+
const toStr = toDate.isSame(today, 'day') ? 'Today' : toDate.format(format);
|
|
22
|
+
return `${fromStr} - ${toStr}`;
|
|
23
|
+
};
|
|
24
|
+
const normalizeRangeSelection = (currentRange, nextRange) => {
|
|
25
|
+
if (!(nextRange === null || nextRange === void 0 ? void 0 : nextRange.from)) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
const isSameDayRange = nextRange.from && nextRange.to && dayjs(nextRange.from).isSame(dayjs(nextRange.to), 'day');
|
|
29
|
+
const hasOpenRange = Boolean((currentRange === null || currentRange === void 0 ? void 0 : currentRange.from) && !(currentRange === null || currentRange === void 0 ? void 0 : currentRange.to));
|
|
30
|
+
// Ensure first click always starts a new range and does not auto-fill the end date.
|
|
31
|
+
if (isSameDayRange && !hasOpenRange) {
|
|
32
|
+
return { from: nextRange.from, to: undefined };
|
|
33
|
+
}
|
|
34
|
+
return nextRange;
|
|
35
|
+
};
|
|
36
|
+
export const DatePicker = ({ mode = 'single', placeholder = 'DD/MM/YYYY', dateFormat = 'DD/MM/YYYY', rangeDateFormat, currentDate, minDate, maxDate, error, onChangeDate, ...inputProps }) => {
|
|
37
|
+
const isRangeMode = mode === 'range';
|
|
38
|
+
const effectiveRangeDateFormat = rangeDateFormat || dateFormat;
|
|
39
|
+
const computeDisplayValue = (date) => {
|
|
40
|
+
if (isRangeMode) {
|
|
41
|
+
return formatRangeDisplay(date, effectiveRangeDateFormat);
|
|
42
|
+
}
|
|
43
|
+
return formatDate(date, dateFormat);
|
|
44
|
+
};
|
|
45
|
+
const [date, setDate] = useState(() => currentDate);
|
|
46
|
+
const [value, setValue] = useState(() => computeDisplayValue(currentDate));
|
|
14
47
|
const [defaultError, setDefaultError] = useState('');
|
|
15
48
|
const [open, setOpen] = useState(false);
|
|
16
49
|
const [prevCurrentDate, setPrevCurrentDate] = useState(currentDate);
|
|
17
50
|
const [prevDateFormat, setPrevDateFormat] = useState(dateFormat);
|
|
18
|
-
|
|
51
|
+
const [prevRangeDateFormat, setPrevRangeDateFormat] = useState(effectiveRangeDateFormat);
|
|
52
|
+
const [prevMode, setPrevMode] = useState(mode);
|
|
53
|
+
if (currentDate !== prevCurrentDate ||
|
|
54
|
+
dateFormat !== prevDateFormat ||
|
|
55
|
+
effectiveRangeDateFormat !== prevRangeDateFormat ||
|
|
56
|
+
mode !== prevMode) {
|
|
19
57
|
setPrevCurrentDate(currentDate);
|
|
20
58
|
setPrevDateFormat(dateFormat);
|
|
59
|
+
setPrevRangeDateFormat(effectiveRangeDateFormat);
|
|
60
|
+
setPrevMode(mode);
|
|
21
61
|
setDate(currentDate);
|
|
22
|
-
setValue(
|
|
62
|
+
setValue(computeDisplayValue(currentDate));
|
|
23
63
|
setDefaultError('');
|
|
24
64
|
}
|
|
25
|
-
const onUpdateDate = (
|
|
26
|
-
setDate(
|
|
27
|
-
onChangeDate === null || onChangeDate === void 0 ? void 0 : onChangeDate(
|
|
65
|
+
const onUpdateDate = (selected) => {
|
|
66
|
+
setDate(selected);
|
|
67
|
+
onChangeDate === null || onChangeDate === void 0 ? void 0 : onChangeDate(selected);
|
|
28
68
|
setDefaultError('');
|
|
29
69
|
};
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
70
|
+
const handleChangeRangeDate = (selected) => {
|
|
71
|
+
const normalizedRange = normalizeRangeSelection(date, selected);
|
|
72
|
+
onUpdateDate(normalizedRange);
|
|
73
|
+
setValue(formatRangeDisplay(normalizedRange, effectiveRangeDateFormat));
|
|
74
|
+
if ((normalizedRange === null || normalizedRange === void 0 ? void 0 : normalizedRange.from) && (normalizedRange === null || normalizedRange === void 0 ? void 0 : normalizedRange.to)) {
|
|
75
|
+
setOpen(false);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const handleChangeSingleDate = (selected) => {
|
|
79
|
+
onUpdateDate(selected);
|
|
80
|
+
setValue(formatDate(selected, dateFormat));
|
|
33
81
|
setOpen(false);
|
|
34
82
|
};
|
|
35
83
|
const handleChangeInputValue = (e) => {
|
|
84
|
+
// In range mode, input is read-only and changes should be made via calendar
|
|
85
|
+
if (isRangeMode) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
36
88
|
setValue(e.target.value);
|
|
37
89
|
if (e.target.value === '') {
|
|
38
90
|
onUpdateDate(undefined);
|
|
@@ -53,5 +105,5 @@ export const DatePicker = ({ placeholder = 'DD/MM/YYYY', dateFormat = 'DD/MM/YYY
|
|
|
53
105
|
setDefaultError('Date is out of range');
|
|
54
106
|
}
|
|
55
107
|
};
|
|
56
|
-
return (_jsx("div", { className: "relative", children: _jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverAnchor, { children: _jsx(Input, { type: "text", value: value, placeholder: placeholder, error: error !== null && error !== void 0 ? error : defaultError, onChange: handleChangeInputValue, endAdornment: _jsx(PopoverTrigger, { asChild: true, children: _jsx("button", { type: "button", className: "p-1.5 hover:bg-gray-100 rounded-full transition-colors cursor-pointer flex items-center justify-center", "aria-label": "Open calendar", children: _jsx(CalendarIcon, { size: 16, className: "text-gray-500" }) }) }), ...inputProps }) }), _jsx(PopoverContent, { className: "w-auto p-0", align: "center", sideOffset: 0, children: _jsx(Calendar, { mode: "single", captionLayout: "dropdown", selected: date, startMonth: minDate, endMonth: maxDate, onSelect:
|
|
108
|
+
return (_jsx("div", { className: "relative", children: _jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverAnchor, { children: _jsx(Input, { type: "text", value: value, placeholder: placeholder, error: error !== null && error !== void 0 ? error : defaultError, readOnly: isRangeMode, onChange: handleChangeInputValue, endAdornment: _jsx(PopoverTrigger, { asChild: true, children: _jsx("button", { type: "button", className: "p-1.5 hover:bg-gray-100 rounded-full transition-colors cursor-pointer flex items-center justify-center", "aria-label": "Open calendar", children: _jsx(CalendarIcon, { size: 16, className: "text-gray-500" }) }) }), ...inputProps }) }), _jsx(PopoverContent, { className: "w-auto p-0", align: "center", sideOffset: 0, children: isRangeMode ? (_jsx(Calendar, { mode: "range", captionLayout: "dropdown", selected: date, startMonth: minDate, endMonth: maxDate, onSelect: handleChangeRangeDate, numberOfMonths: 2 })) : (_jsx(Calendar, { mode: "single", captionLayout: "dropdown", selected: date, startMonth: minDate, endMonth: maxDate, onSelect: handleChangeSingleDate, numberOfMonths: 1 })) })] }) }));
|
|
57
109
|
};
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
2
3
|
import { DatePicker } from './DatePicker';
|
|
4
|
+
const RangeModeExample = () => {
|
|
5
|
+
const [dateRange, setDateRange] = useState({
|
|
6
|
+
from: new Date(new Date().getFullYear(), 0, 20),
|
|
7
|
+
to: new Date(new Date().getFullYear(), 0, 27),
|
|
8
|
+
});
|
|
9
|
+
return (_jsx("div", { className: "space-y-4", children: _jsx(DatePicker, { mode: "range", label: "Select Date Range", rangeDateFormat: "D MMM YY", currentDate: dateRange, onChangeDate: (date) => setDateRange(date) }) }));
|
|
10
|
+
};
|
|
3
11
|
const meta = {
|
|
4
12
|
title: 'UIKit/DatePicker',
|
|
5
13
|
component: DatePicker,
|
|
@@ -12,9 +20,17 @@ const meta = {
|
|
|
12
20
|
},
|
|
13
21
|
},
|
|
14
22
|
render: (args) => {
|
|
23
|
+
const convertCurrentDate = () => {
|
|
24
|
+
if (!args.currentDate)
|
|
25
|
+
return undefined;
|
|
26
|
+
if (typeof args.currentDate === 'string' || typeof args.currentDate === 'number') {
|
|
27
|
+
return new Date(args.currentDate);
|
|
28
|
+
}
|
|
29
|
+
return args.currentDate;
|
|
30
|
+
};
|
|
15
31
|
const convertedArgs = {
|
|
16
32
|
...args,
|
|
17
|
-
currentDate:
|
|
33
|
+
currentDate: convertCurrentDate(),
|
|
18
34
|
minDate: args.minDate ? new Date(args.minDate) : undefined,
|
|
19
35
|
maxDate: args.maxDate ? new Date(args.maxDate) : undefined,
|
|
20
36
|
};
|
|
@@ -34,6 +50,11 @@ const meta = {
|
|
|
34
50
|
options: ['DD/MM/YYYY', 'MM/DD/YYYY', 'YYYY-MM-DD', 'DD-MM-YYYY'],
|
|
35
51
|
description: 'Format for displaying and parsing dates',
|
|
36
52
|
},
|
|
53
|
+
rangeDateFormat: {
|
|
54
|
+
control: 'select',
|
|
55
|
+
options: ['DD/MM/YYYY', 'MM/DD/YYYY', 'YYYY-MM-DD', 'DD-MM-YYYY', 'D MMM YY', 'MMMM D, YYYY'],
|
|
56
|
+
description: 'Format for displaying date ranges (defaults to dateFormat if not specified)',
|
|
57
|
+
},
|
|
37
58
|
currentDate: {
|
|
38
59
|
control: 'date',
|
|
39
60
|
description: 'Initial date value',
|
|
@@ -104,3 +125,13 @@ export const WithDateRange = {
|
|
|
104
125
|
},
|
|
105
126
|
},
|
|
106
127
|
};
|
|
128
|
+
export const RangeMode = {
|
|
129
|
+
render: () => _jsx(RangeModeExample, {}),
|
|
130
|
+
parameters: {
|
|
131
|
+
docs: {
|
|
132
|
+
description: {
|
|
133
|
+
story: 'Date picker in range mode allowing selection of start and end dates. Shows two months for easier navigation.',
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import IntlTelInput from 'intl-tel-input/reactWithUtils';
|
|
3
|
+
import 'intl-tel-input/styles';
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
export const PhoneInput = ({ label, error, helperText, disabled, initialValue, initOptions, inputProps, onChangeNumber, onChangeCountry, onChangeValidity, onChangeErrorCode, usePreciseValidation, }) => {
|
|
6
|
+
return (_jsxs("div", { className: cn('uikit-phone-input', { 'uikit-phone-input--error': error }), children: [label && _jsx("label", { className: "text-xs font-normal text-muted-foreground", children: label }), _jsx(IntlTelInput, { disabled: disabled, initialValue: initialValue, usePreciseValidation: usePreciseValidation, onChangeNumber: onChangeNumber, onChangeCountry: onChangeCountry, onChangeValidity: onChangeValidity, onChangeErrorCode: onChangeErrorCode, initOptions: {
|
|
7
|
+
initialCountry: 'gb',
|
|
8
|
+
countrySearch: true,
|
|
9
|
+
fixDropdownWidth: false,
|
|
10
|
+
...initOptions,
|
|
11
|
+
}, inputProps: {
|
|
12
|
+
...inputProps,
|
|
13
|
+
className: cn('!flex !h-10 !w-full !text-(--uikit-textSecondary) !rounded-(--uikit-radius) !border !border-(--uikit-inputEnabledBorder) !bg-background hover:!border-(--uikit-inputHoverBorder) !pr-3 !py-2 !text-base !ring-offset-background !placeholder:text-muted-foreground disabled:!cursor-not-allowed disabled:!opacity-50 md:!text-sm !transition focus-visible:!outline-none focus:!border-(--uikit-primary) focus:!ring-2 focus:!ring-(--uikit-primary)', { '!border-(--uikit-error)': error }, inputProps === null || inputProps === void 0 ? void 0 : inputProps.className),
|
|
14
|
+
} }), error && _jsx("label", { className: "text-sm font-medium text-error", children: error }), !error && helperText && (_jsx("label", { className: "mt-1 block text-xs font-normal text-muted-foreground", children: helperText }))] }));
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PhoneInputProps } from './PhoneInput.types';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
declare const meta: Meta<PhoneInputProps>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<PhoneInputProps>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const WithLabel: Story;
|
|
8
|
+
export declare const WithInitialValue: Story;
|
|
9
|
+
export declare const ControlledInput: Story;
|
|
10
|
+
export declare const WithError: Story;
|
|
11
|
+
export declare const WithHelperText: Story;
|
|
12
|
+
export declare const Disabled: Story;
|
|
13
|
+
export declare const PreferredCountries: Story;
|
|
14
|
+
export declare const SeparateDialCode: Story;
|
|
15
|
+
export declare const DisabledDropdown: Story;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { PhoneInput } from './PhoneInput';
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'UIKit/PhoneInput',
|
|
6
|
+
component: PhoneInput,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
args: {
|
|
9
|
+
initOptions: {
|
|
10
|
+
initialCountry: 'gb',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export default meta;
|
|
15
|
+
const Controlled = (args) => {
|
|
16
|
+
const [number, setNumber] = useState('');
|
|
17
|
+
const [isValid, setIsValid] = useState(false);
|
|
18
|
+
return (_jsxs("div", { children: [_jsx(PhoneInput, { ...args, onChangeNumber: setNumber, onChangeValidity: setIsValid }), _jsxs("p", { className: "mt-2 text-xs text-muted-foreground", children: ["Number: ", number || '(empty)', " | Valid: ", isValid ? 'Yes' : 'No'] })] }));
|
|
19
|
+
};
|
|
20
|
+
export const Default = {};
|
|
21
|
+
export const WithLabel = {
|
|
22
|
+
args: { label: 'Phone input' },
|
|
23
|
+
};
|
|
24
|
+
export const WithInitialValue = {
|
|
25
|
+
args: { label: 'Phone input', initialValue: '+447911123456' },
|
|
26
|
+
};
|
|
27
|
+
export const ControlledInput = {
|
|
28
|
+
args: { label: 'Phone input' },
|
|
29
|
+
render: (args) => _jsx(Controlled, { ...args }),
|
|
30
|
+
};
|
|
31
|
+
export const WithError = {
|
|
32
|
+
args: { label: 'Phone input', error: 'Invalid phone number' },
|
|
33
|
+
};
|
|
34
|
+
export const WithHelperText = {
|
|
35
|
+
args: { label: 'Phone input', helperText: 'Include country code' },
|
|
36
|
+
};
|
|
37
|
+
export const Disabled = {
|
|
38
|
+
args: { label: 'Phone input', disabled: true, initialValue: '+447911123456' },
|
|
39
|
+
};
|
|
40
|
+
export const PreferredCountries = {
|
|
41
|
+
args: {
|
|
42
|
+
label: 'Phone input',
|
|
43
|
+
initOptions: {
|
|
44
|
+
initialCountry: 'gb',
|
|
45
|
+
countryOrder: ['gb', 'us', 'au', 'nz'],
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
export const SeparateDialCode = {
|
|
50
|
+
args: {
|
|
51
|
+
label: 'Phone input',
|
|
52
|
+
initOptions: {
|
|
53
|
+
initialCountry: 'gb',
|
|
54
|
+
separateDialCode: true,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
export const DisabledDropdown = {
|
|
59
|
+
args: {
|
|
60
|
+
label: 'Phone input',
|
|
61
|
+
initOptions: {
|
|
62
|
+
initialCountry: 'gb',
|
|
63
|
+
allowDropdown: false,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface PhoneInputProps {
|
|
2
|
+
initialValue?: string;
|
|
3
|
+
label?: string;
|
|
4
|
+
error?: string;
|
|
5
|
+
helperText?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
initOptions?: Record<string, unknown>;
|
|
8
|
+
inputProps?: Omit<React.ComponentPropsWithoutRef<'input'>, 'onInput'>;
|
|
9
|
+
onChangeNumber?: (number: string) => void;
|
|
10
|
+
onChangeCountry?: (country: string) => void;
|
|
11
|
+
onChangeValidity?: (valid: boolean) => void;
|
|
12
|
+
onChangeErrorCode?: (errorCode: number | null) => void;
|
|
13
|
+
usePreciseValidation?: boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -45,5 +45,6 @@ export function StandardTable(props) {
|
|
|
45
45
|
tableActionsDropdown: props.tableActionsDropdown,
|
|
46
46
|
customNoRows: props.customNoRows,
|
|
47
47
|
accordion: enableAccordion,
|
|
48
|
+
showGroupedTotal: props.showGroupedTotal,
|
|
48
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
50
|
}
|
|
@@ -294,5 +294,5 @@ export const TwoTablesWithQueryParams = {
|
|
|
294
294
|
render: () => _jsx(TwoTablesWithQueryParamsExample, {}),
|
|
295
295
|
};
|
|
296
296
|
export const GroupedAccordion = {
|
|
297
|
-
render: () => (_jsx(StandardTable, { id: "grouped-accordion", data: groupingData, columns: groupingColumns, showHeader: false, grouping: ['date'], enableAccordion: true, paginationMode: "client" })),
|
|
297
|
+
render: () => (_jsx(StandardTable, { id: "grouped-accordion", data: groupingData, columns: groupingColumns, showHeader: false, grouping: ['date'], enableAccordion: true, paginationMode: "client", showGroupedTotal: true })),
|
|
298
298
|
};
|
|
@@ -62,11 +62,13 @@ type WithGrouping<T> = {
|
|
|
62
62
|
/** When true, grouped rows can be collapsed/expanded */
|
|
63
63
|
enableAccordion?: boolean;
|
|
64
64
|
onGroupRowClick?: GroupRowClickHandler<T>;
|
|
65
|
+
showGroupedTotal?: boolean;
|
|
65
66
|
};
|
|
66
67
|
type WithoutGrouping = {
|
|
67
68
|
grouping?: never;
|
|
68
69
|
enableAccordion?: never;
|
|
69
70
|
onGroupRowClick?: never;
|
|
71
|
+
showGroupedTotal?: never;
|
|
70
72
|
};
|
|
71
73
|
export type GroupingProps<T> = WithGrouping<T> | WithoutGrouping;
|
|
72
74
|
export interface TableInputPropsBase<T> {
|
|
@@ -12,6 +12,7 @@ interface RenderGroupRowProps<T> {
|
|
|
12
12
|
isExpanded?: boolean;
|
|
13
13
|
onToggle?: () => void;
|
|
14
14
|
isFirstGroup?: boolean;
|
|
15
|
+
showGroupedTotal?: boolean;
|
|
15
16
|
}
|
|
16
|
-
export declare function renderGroupRow<T>({ row, onGroupRowClick, accordion, isExpanded, onToggle, isFirstGroup, }: RenderGroupRowProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function renderGroupRow<T>({ row, onGroupRowClick, accordion, isExpanded, onToggle, isFirstGroup, showGroupedTotal, }: RenderGroupRowProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
17
18
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { classNames } from '../../../utils';
|
|
3
3
|
import { FaChevronDown, FaChevronRight } from 'react-icons/fa';
|
|
4
|
-
export function renderGroupRow({ row, onGroupRowClick, accordion, isExpanded, onToggle, isFirstGroup, }) {
|
|
4
|
+
export function renderGroupRow({ row, onGroupRowClick, accordion, isExpanded, onToggle, isFirstGroup, showGroupedTotal, }) {
|
|
5
5
|
var _a, _b;
|
|
6
6
|
const columnId = row.groupingColumnId;
|
|
7
7
|
const groupValue = row.getGroupingValue(columnId);
|
|
@@ -50,5 +50,5 @@ export function renderGroupRow({ row, onGroupRowClick, accordion, isExpanded, on
|
|
|
50
50
|
rows: row.subRows.map((r) => r.original),
|
|
51
51
|
});
|
|
52
52
|
}, children: _jsx("td", { colSpan: row.getVisibleCells().length, className: classNames('p-0', !isFirstGroup && 'pt-3'), children: _jsxs("div", { "data-uikit-group-header": "true", className: classNames('uikit-group-header flex items-center justify-between gap-4 border-x border-t border-border bg-(--uikit-tertiary) px-4 py-3 text-sm text-foreground', isCollapsed ? 'rounded-(--uikit-radius) border-b' : 'rounded-t-(--uikit-radius)'), children: [_jsxs("span", { "data-uikit-group-value": "true", className: "uikit-group-value flex items-center gap-2", children: [accordion &&
|
|
53
|
-
(isExpanded ? (_jsx(FaChevronDown, { className: "h-3 w-3 shrink-0 transition-transform duration-200" })) : (_jsx(FaChevronRight, { className: "h-3 w-3 shrink-0 transition-transform duration-200" }))), _jsx("span", { className: "font-semibold text-inherit", children: String(groupValue) })] }), formattedGroupedTotal !== null && (_jsx("span", { "data-uikit-group-total": "true", className: "uikit-group-total font-semibold text-inherit opacity-90", children: formattedGroupedTotal }))] }) }) }, row.id));
|
|
53
|
+
(isExpanded ? (_jsx(FaChevronDown, { className: "h-3 w-3 shrink-0 transition-transform duration-200" })) : (_jsx(FaChevronRight, { className: "h-3 w-3 shrink-0 transition-transform duration-200" }))), _jsx("span", { className: "font-semibold text-inherit", children: String(groupValue) })] }), showGroupedTotal && formattedGroupedTotal !== null && (_jsx("span", { "data-uikit-group-total": "true", className: "uikit-group-total font-semibold text-inherit opacity-90", children: formattedGroupedTotal }))] }) }) }, row.id));
|
|
54
54
|
}
|
|
@@ -20,8 +20,9 @@ interface RenderTableBodyProps<T extends {
|
|
|
20
20
|
messageClassName?: string;
|
|
21
21
|
};
|
|
22
22
|
accordion?: boolean;
|
|
23
|
+
showGroupedTotal?: boolean;
|
|
23
24
|
}
|
|
24
25
|
export declare function renderTableBody<T extends {
|
|
25
26
|
id: string;
|
|
26
|
-
}>({ table, state, colSpan, onRowClick, isRowClickable, onGroupRowClick, tableActionsDropdown, customNoRows, accordion, }: RenderTableBodyProps<T>): React.ReactNode;
|
|
27
|
+
}>({ table, state, colSpan, onRowClick, isRowClickable, onGroupRowClick, tableActionsDropdown, customNoRows, accordion, showGroupedTotal, }: RenderTableBodyProps<T>): React.ReactNode;
|
|
27
28
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { renderTableRows } from '../render-rows/renderTableRows';
|
|
3
|
-
export function renderTableBody({ table, state, colSpan, onRowClick, isRowClickable, onGroupRowClick, tableActionsDropdown, customNoRows, accordion, }) {
|
|
3
|
+
export function renderTableBody({ table, state, colSpan, onRowClick, isRowClickable, onGroupRowClick, tableActionsDropdown, customNoRows, accordion, showGroupedTotal, }) {
|
|
4
4
|
var _a;
|
|
5
5
|
switch (state.type) {
|
|
6
6
|
case 'loading':
|
|
@@ -12,6 +12,7 @@ export function renderTableBody({ table, state, colSpan, onRowClick, isRowClicka
|
|
|
12
12
|
rows: state.rows,
|
|
13
13
|
hasActions: Boolean((_a = table.options.meta) === null || _a === void 0 ? void 0 : _a.hasActions),
|
|
14
14
|
accordion,
|
|
15
|
+
showGroupedTotal,
|
|
15
16
|
onRowClick,
|
|
16
17
|
isRowClickable,
|
|
17
18
|
onGroupRowClick,
|
|
@@ -14,8 +14,9 @@ interface RenderTableRowsProps<T extends {
|
|
|
14
14
|
}) => void;
|
|
15
15
|
tableActionsDropdown?: ITableActionsDropdownProps<T>;
|
|
16
16
|
accordion?: boolean;
|
|
17
|
+
showGroupedTotal?: boolean;
|
|
17
18
|
}
|
|
18
19
|
export declare function renderTableRows<T extends {
|
|
19
20
|
id: string;
|
|
20
|
-
}>({ rows, onRowClick, isRowClickable, onGroupRowClick, tableActionsDropdown, hasActions, accordion, }: RenderTableRowsProps<T>): React.ReactNode[];
|
|
21
|
+
}>({ rows, onRowClick, isRowClickable, onGroupRowClick, tableActionsDropdown, hasActions, accordion, showGroupedTotal, }: RenderTableRowsProps<T>): React.ReactNode[];
|
|
21
22
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { renderGroupRow } from '../body/renderGroupRow';
|
|
2
2
|
import { renderLeafRow } from '../body/renderLeafRow';
|
|
3
|
-
export function renderTableRows({ rows, onRowClick, isRowClickable, onGroupRowClick, tableActionsDropdown, hasActions, accordion, }) {
|
|
3
|
+
export function renderTableRows({ rows, onRowClick, isRowClickable, onGroupRowClick, tableActionsDropdown, hasActions, accordion, showGroupedTotal, }) {
|
|
4
4
|
var _a;
|
|
5
5
|
const result = [];
|
|
6
6
|
const firstGroupId = (_a = rows.find((r) => r.getIsGrouped())) === null || _a === void 0 ? void 0 : _a.id;
|
|
@@ -14,6 +14,7 @@ export function renderTableRows({ rows, onRowClick, isRowClickable, onGroupRowCl
|
|
|
14
14
|
onToggle: accordion ? row.getToggleExpandedHandler() : undefined,
|
|
15
15
|
onGroupRowClick,
|
|
16
16
|
isFirstGroup: row.id === firstGroupId,
|
|
17
|
+
showGroupedTotal,
|
|
17
18
|
}));
|
|
18
19
|
continue;
|
|
19
20
|
}
|
|
@@ -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\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" }) })),
|
|
15
|
+
render: () => (_jsx(TooltipStoryWrapper, { content: "This tooltip contains a longer message that wraps gracefully across multiple lines. On smaller\r\n\t\tscreens, it narrows and stacks vertically so it's easier to read\u2014especially useful for\r\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" }) })] })),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eml-payments/ui-kit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "ARLO UIKit",
|
|
6
6
|
"homepage": "https://github.com/EML-Payments/arlo.npm.uikit#readme",
|
|
@@ -69,6 +69,7 @@
|
|
|
69
69
|
"class-variance-authority": "^0.7.1",
|
|
70
70
|
"clsx": "^2.1.1",
|
|
71
71
|
"dayjs": "^1.11.19",
|
|
72
|
+
"intl-tel-input": "^26.9.1",
|
|
72
73
|
"lucide-react": "^0.577.0",
|
|
73
74
|
"prettier": "^3.6.2",
|
|
74
75
|
"react": ">=18.0.0",
|