Skip to content

Commit c53ac96

Browse files
author
Hector Arce De Las Heras
committed
Update themeProvider from storybook
Update themeProvider from storybook configuration
1 parent 00f0293 commit c53ac96

File tree

1 file changed

+1
-69
lines changed

1 file changed

+1
-69
lines changed

.storybook/provider/themeProvider.tsx

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -28,71 +28,6 @@ import {
2828
transformDate,
2929
} from '../../src/utils/date';
3030

31-
const orderDate = (
32-
date: string,
33-
format: string,
34-
isRange?: boolean
35-
): { formatSeparator: string | undefined; formattedDate: string } => {
36-
const formatRegex = /[^\p{L}]+/gu;
37-
const dateRegex = /[^\d]+/g;
38-
39-
const formatValueDate = (value: string): string =>
40-
value.replace(/[a-zA-Z,]+/, '').replace(/\s/g, '');
41-
42-
const formattedValue = formatValueDate(date);
43-
44-
// we want always this YYYY-MM-DD format
45-
const formatToOrderDate = 'YYYY-MM-DD';
46-
47-
const correctOrder = formatToOrderDate.split('-');
48-
49-
const newFormat =
50-
format.length > 8
51-
? format
52-
: `${format.slice(0, 2)}-${format.slice(2, 4)}-${format.slice(4)}`;
53-
54-
// to get separator
55-
const formatSeparator = newFormat.match(formatRegex)?.[0];
56-
57-
const formatSplit = newFormat.split(formatRegex);
58-
59-
let dateToCheck: string[] = [];
60-
61-
let formattedDate = '';
62-
63-
// Transform date into YYYY-MM-DD format
64-
const splitDate = (date) => {
65-
return correctOrder.map((element: string) => {
66-
if (element.includes('Y')) {
67-
return date[formatSplit.findIndex((x: string) => x.includes('Y'))];
68-
} else if (element.includes('M')) {
69-
return date[formatSplit.findIndex((x: string) => x.includes('M'))];
70-
} else if (element.includes('D')) {
71-
return date[formatSplit.findIndex((x: string) => x.includes('D'))];
72-
}
73-
});
74-
};
75-
76-
if (formattedValue.length === newFormat.length) {
77-
const dateSplit = formattedValue.split(dateRegex);
78-
79-
dateToCheck = splitDate(dateSplit);
80-
81-
formattedDate = dateToCheck.join('-');
82-
} else if (isRange && date.length > newFormat.length) {
83-
const dateRangeSplit = date.split(dateRegex);
84-
//just take the second date to check
85-
const secondDate = dateRangeSplit.splice(3, 5);
86-
dateToCheck = splitDate(secondDate);
87-
formattedDate = dateToCheck.join('-');
88-
}
89-
90-
return {
91-
formatSeparator,
92-
formattedDate,
93-
};
94-
};
95-
9631
const link = React.forwardRef((props: IGenericLink, ref: unknown) => {
9732
return (
9833
<a
@@ -136,10 +71,7 @@ export const ThemeProvider = ({ children, theme, themeName = 'kubit' }) => {
13671
isBefore: (date1: Date, date2: Date) => {
13772
return isBefore(date1, date2);
13873
},
139-
isDatesEqual: (
140-
firsDate: string | number | Date,
141-
secondDate: string | number | Date
142-
) => {
74+
isDatesEqual: (firsDate: string | number | Date, secondDate: string | number | Date) => {
14375
return isDatesEqual(firsDate, secondDate);
14476
},
14577
getAddDays: (date: Date, days: number) => {

0 commit comments

Comments
 (0)