Skip to content

Commit 0087ab4

Browse files
authored
Merge pull request #29 from kubit-ui/feature/improvements-components-and-utilities
Feature/improvements components and utilities
2 parents 29a50b4 + 0ea04cb commit 0087ab4

File tree

136 files changed

+4139
-1870
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+4139
-1870
lines changed

.prettierrc.cjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
tabWidth: 2,
3+
useTabs: false,
4+
semi: true,
5+
singleQuote: true,
6+
quoteProps: 'consistent',
7+
jsxSingleQuote: false,
8+
trailingComma: 'es5',
9+
bracketSpacing: true,
10+
bracketSameLine: false,
11+
arrowParens: 'avoid',
12+
printWidth: 100,
13+
endOfLine: 'lf',
14+
plugins: [require.resolve('@trivago/prettier-plugin-sort-imports')],
15+
importOrder: ['react', 'styled-components', 'dayjs', '^(?!\\.|@)', '^@/', '^\\.'],
16+
importOrderSeparation: true,
17+
importOrderSortSpecifiers: true,
18+
overrides: [
19+
{
20+
files: ['config/**/*.js'],
21+
options: {
22+
printWidth: 160,
23+
},
24+
},
25+
],
26+
};

.prettierrc.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

package.json

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kubit-ui-web/react-components",
3-
"version": "1.12.0",
3+
"version": "1.13.0",
44
"description": "Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience",
55
"author": {
66
"name": "Kubit",
@@ -93,54 +93,54 @@
9393
"@babel/preset-typescript": "^7.24.7",
9494
"@eslint/compat": "^1.1.1",
9595
"@eslint/eslintrc": "^3.1.0",
96-
"@eslint/js": "^9.9.1",
97-
"@storybook/addon-a11y": "^8.2.9",
98-
"@storybook/addon-controls": "^8.2.9",
96+
"@eslint/js": "^9.11.1",
97+
"@storybook/addon-a11y": "^8.3.2",
98+
"@storybook/addon-controls": "^8.3.2",
9999
"@storybook/addon-coverage": "^1.0.4",
100-
"@storybook/addon-essentials": "^8.2.9",
101-
"@storybook/addon-interactions": "^8.2.9",
102-
"@storybook/addon-links": "^8.2.9",
103-
"@storybook/addon-themes": "^8.2.9",
104-
"@storybook/blocks": "^8.2.9",
105-
"@storybook/react": "^8.2.9",
106-
"@storybook/react-vite": "^8.2.9",
100+
"@storybook/addon-essentials": "^8.3.2",
101+
"@storybook/addon-interactions": "^8.3.2",
102+
"@storybook/addon-links": "^8.3.2",
103+
"@storybook/addon-themes": "^8.3.2",
104+
"@storybook/blocks": "^8.3.2",
105+
"@storybook/react": "^8.3.2",
106+
"@storybook/react-vite": "^8.3.2",
107107
"@testing-library/jest-dom": "^6.5.0",
108-
"@testing-library/react": "^16.0.0",
108+
"@testing-library/react": "^16.0.1",
109109
"@testing-library/react-hooks": "^8.0.1",
110110
"@testing-library/user-event": "^14.5.2",
111111
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
112-
"@types/jest": "^29.5.12",
112+
"@types/jest": "^29.5.13",
113113
"@types/jest-axe": "^3.5.9",
114-
"@types/mocha": "^10.0.7",
115-
"@types/react": "^18.3.4",
114+
"@types/mocha": "^10.0.8",
115+
"@types/react": "^18.3.8",
116116
"@types/react-dom": "^18.3.0",
117117
"@types/styled-components": "^5.1.34",
118118
"@types/ungap__structured-clone": "^1.2.0",
119-
"@typescript-eslint/eslint-plugin": "^8.3.0",
120-
"@typescript-eslint/parser": "^8.3.0",
119+
"@typescript-eslint/eslint-plugin": "^8.7.0",
120+
"@typescript-eslint/parser": "^8.7.0",
121121
"@ungap/structured-clone": "^1.2.0",
122122
"@vitejs/plugin-react": "^4.3.1",
123123
"babel-jest": "^29.7.0",
124124
"cpy-cli": "^5.0.0",
125-
"eslint": "^9.9.1",
125+
"eslint": "^9.11.1",
126126
"eslint-config-prettier": "^9.1.0",
127127
"eslint-config-standard-with-typescript": "^43.0.1",
128128
"eslint-import-resolver-typescript": "^3.6.3",
129-
"eslint-plugin-import": "^2.29.1",
130-
"eslint-plugin-jest": "^28.8.0",
131-
"eslint-plugin-jsx-a11y": "^6.9.0",
132-
"eslint-plugin-n": "^17.10.2",
129+
"eslint-plugin-import": "^2.30.0",
130+
"eslint-plugin-jest": "^28.8.3",
131+
"eslint-plugin-jsx-a11y": "^6.10.0",
132+
"eslint-plugin-n": "^17.10.3",
133133
"eslint-plugin-node": "^11.1.0",
134134
"eslint-plugin-prettier": "5.2.1",
135135
"eslint-plugin-promise": "^7.1.0",
136-
"eslint-plugin-react": "^7.35.0",
136+
"eslint-plugin-react": "^7.36.1",
137137
"eslint-plugin-react-hooks": "^4.6.2",
138-
"eslint-plugin-react-refresh": "^0.4.11",
138+
"eslint-plugin-react-refresh": "^0.4.12",
139139
"eslint-plugin-storybook": "^0.8.0",
140-
"eslint-plugin-unused-imports": "^4.1.3",
140+
"eslint-plugin-unused-imports": "^4.1.4",
141141
"globals": "^15.9.0",
142142
"gts": "^5.3.1",
143-
"html-validate": "^8.21.0",
143+
"html-validate": "^8.23.0",
144144
"jest": "^29.7.0",
145145
"jest-axe": "^9.0.0",
146146
"jest-canvas-mock": "^2.5.2",
@@ -152,23 +152,23 @@
152152
"prettier": "^3.3.3",
153153
"react-transition-group": "^4.4.5",
154154
"sort-imports": "^1.1.0",
155-
"storybook": "^8.2.9",
155+
"storybook": "^8.3.2",
156156
"ts-jest": "^29.2.5",
157157
"tsc-alias": "1.8.10",
158-
"typedoc": "^0.26.6",
159-
"typedoc-plugin-markdown": "^4.2.6",
160-
"typescript": "^5.5.4",
161-
"vite": "^5.4.2",
158+
"typedoc": "^0.26.7",
159+
"typedoc-plugin-markdown": "^4.2.8",
160+
"typescript": "^5.6.2",
161+
"vite": "^5.4.7",
162162
"vite-tsconfig-paths": "^5.0.1",
163163
"yarn-deduplicate": "^6.0.2"
164164
},
165165
"dependencies": {
166-
"@emotion/is-prop-valid": "^1.3.0",
166+
"@emotion/is-prop-valid": "^1.3.1",
167167
"lottie-web": "^5.12.2",
168168
"react": "^18.3.1",
169169
"react-dom": "^18.3.1",
170170
"react-transition-group": "^4.4.5",
171-
"styled-components": "^6.1.12"
171+
"styled-components": "^6.1.13"
172172
},
173173
"resolutions": {
174174
"strip-ansi": "^6.0.1",
@@ -180,4 +180,4 @@
180180
"url": "https://github.com/kubit-ui/kubit-react-components/issues"
181181
},
182182
"homepage": "https://www.kubit-ui.com/"
183-
}
183+
}
Lines changed: 3 additions & 0 deletions
Loading

src/assets/storybook/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import ICON_CHEVRON_DOWN from './icons/icon_chevron_down.svg';
33
import ICON_CHEVRON_LEFT from './icons/icon_chevron_left.svg';
44
import ICON_CHEVRON_RIGHT from './icons/icon_chevron_right.svg';
55
import ICON_CHEVRON_UP from './icons/icon_chevron_up.svg';
6+
import ICON_DRAG from './icons/icon_ds_handle.svg';
67
import ICON_GHOST from './icons/icon_ghost.svg';
78
import ICON_PLACEHOLDER from './icons/icon_placeholder.svg';
89
import ICON_CLOSE from './icons/icon_x_close.svg';
@@ -26,6 +27,7 @@ export const ICONS = {
2627
ICON_PLAY_BUTTON,
2728
ICON_CHECKMARK_THICK,
2829
ICON_REPLACE,
30+
ICON_DRAG,
2931
};
3032

3133
export const ILLUSTRATIONS = {

src/components/button/button.styled.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export const ButtonStyled = styled.button<IButtonStyled>`
4949
align-items: center;
5050
justify-content: center;
5151
text-align: ${({ alignText }) => alignText ?? 'left'};
52-
min-width: ${props => props.minWidth};
5352
cursor: pointer;
5453
flex-direction: ${props =>
5554
props.$iconPosition === IconPositionType.LEFT ? 'row' : 'row-reverse'};
@@ -86,7 +85,7 @@ export const ButtonStyled = styled.button<IButtonStyled>`
8685
${({ $styles, $sizeStyles }) => setTokens(ButtonStateType.DEFAULT, $styles, $sizeStyles)}
8786
}
8887
}
89-
88+
min-width: ${props => props.minWidth};
9089
width: ${props => (props.$fullWidth ? '100%' : 'auto')};
9190
9291
&::after {

src/components/calendar/selector/monthSelector/utils/monthSelector.test.ts

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,20 @@ describe('Month Selector utils', () => {
5252
const result2 = keyLeftFunction(previous2);
5353
expect(result2).toBe(previous2 - 1);
5454
});
55+
it('keyLeftMove - maxDate and minDate in same year - should move to the left when left arrow key is pressed', () => {
56+
const maxDate = new Date(2023, 8, 15);
57+
const currentDate = new Date(2023, 8, 22);
58+
const minDate = new Date(2023, 4, 15);
59+
60+
const keyLeftFunction = keyLeftMove({ currentDate, maxDate, minDate });
61+
62+
const previous1 = minDate.getMonth();
63+
const previous2 = minDate.getMonth() + 1;
64+
const result1 = keyLeftFunction(previous1);
65+
expect(result1).toBe(maxDate.getMonth());
66+
const result2 = keyLeftFunction(previous2);
67+
expect(result2).toBe(previous2 - 1);
68+
});
5569
it('keyRightMove - maxDate and currentDate in same year - should move to the right when right arrow key is pressed', () => {
5670
const maxDate = new Date(2023, 8, 15);
5771
const currentDate = new Date(2023, 8, 22);
@@ -94,6 +108,21 @@ describe('Month Selector utils', () => {
94108
const result2 = keyRightFunction(previous2);
95109
expect(result2).toBe(previous2 + 1);
96110
});
111+
112+
it('keyRightMove - maxDate and minDate in same year - should move to the right when right arrow key is pressed', () => {
113+
const maxDate = new Date(2023, 8, 15);
114+
const currentDate = new Date(2023, 8, 22);
115+
const minDate = new Date(2023, 4, 15);
116+
117+
const keyRightFunction = keyRightMove({ currentDate, maxDate, minDate });
118+
119+
const previous1 = maxDate.getMonth();
120+
const previous2 = maxDate.getMonth() - 1;
121+
const result1 = keyRightFunction(previous1);
122+
expect(result1).toBe(minDate.getMonth());
123+
const result2 = keyRightFunction(previous2);
124+
expect(result2).toBe(previous2 + 1);
125+
});
97126
it('keyUpMove - maxDate and currentDate in same year - should move up when up arrow key is pressed', () => {
98127
const maxDate = new Date(2023, 8, 15);
99128
const currentDate = new Date(2023, 8, 22);
@@ -145,7 +174,24 @@ describe('Month Selector utils', () => {
145174
const result3 = keyUpFunction(previous3);
146175
expect(result3).toBe(firstMonth);
147176
});
148-
it('keyDownMove - maxDate and currentDate in same year - should move up when up arrow key is pressed', () => {
177+
it('keyUpMove - maxDate and minDate in same year - should move up when up arrow key is pressed', () => {
178+
const maxDate = new Date(2023, 8, 15);
179+
const currentDate = new Date(2023, 8, 22);
180+
const minDate = new Date(2023, 0, 15);
181+
182+
const keyUpFunction = keyUpMove({ currentDate, maxDate, minDate });
183+
184+
const previous1 = minDate.getMonth();
185+
const previous2 = minDate.getMonth() + 3;
186+
const previous3 = minDate.getMonth() + 2;
187+
const result1 = keyUpFunction(previous1);
188+
expect(result1).toBe(maxDate.getMonth());
189+
const result2 = keyUpFunction(previous2);
190+
expect(result2).toBe(previous2 - 3);
191+
const result3 = keyUpFunction(previous3);
192+
expect(result3).toBe(minDate.getMonth());
193+
});
194+
it('keyDownMove - maxDate and currentDate in same year - should move down when down arrow key is pressed', () => {
149195
const maxDate = new Date(2023, 8, 15);
150196
const currentDate = new Date(2023, 8, 22);
151197
const minDate = new Date(2000, 0, 15);
@@ -162,7 +208,7 @@ describe('Month Selector utils', () => {
162208
const result3 = keyDownFunction(previous3);
163209
expect(result3).toBe(maxDate.getMonth());
164210
});
165-
it('keyDownMove - minDate and currentDate in same year - should move up when up arrow key is pressed', () => {
211+
it('keyDownMove - minDate and currentDate in same year - should move down when down arrow key is pressed', () => {
166212
const maxDate = new Date(2025, 8, 15);
167213
const currentDate = new Date(2023, 8, 22);
168214
const minDate = new Date(2023, 0, 15);
@@ -179,7 +225,7 @@ describe('Month Selector utils', () => {
179225
const result3 = keyDownFunction(previous3);
180226
expect(result3).toBe(previous3 + 3);
181227
});
182-
it('keyDownMove - currentDate year is different than minDate and maxDate - should move up when up arrow key is pressed', () => {
228+
it('keyDownMove - currentDate year is different than minDate and maxDate - should move down when down arrow key is pressed', () => {
183229
const maxDate = new Date(2025, 8, 15);
184230
const currentDate = new Date(2023, 8, 22);
185231
const minDate = new Date(2000, 0, 15);
@@ -196,6 +242,23 @@ describe('Month Selector utils', () => {
196242
const result3 = keyDownFunction(previous3);
197243
expect(result3).toBe(previous3 + 3);
198244
});
245+
it('keyDownMove - maxDate and minDate in same year - should move down when down arrow key is pressed', () => {
246+
const maxDate = new Date(2023, 8, 15);
247+
const currentDate = new Date(2023, 8, 22);
248+
const minDate = new Date(2023, 0, 15);
249+
250+
const keyDownFunction = keyDownMove({ currentDate, maxDate, minDate });
251+
252+
const previous1 = maxDate.getMonth();
253+
const previous2 = 1;
254+
const previous3 = maxDate.getMonth() + 3;
255+
const result1 = keyDownFunction(previous1);
256+
expect(result1).toBe(firstMonth);
257+
const result2 = keyDownFunction(previous2);
258+
expect(result2).toBe(previous2 + 3);
259+
const result3 = keyDownFunction(previous3);
260+
expect(result3).toBe(maxDate.getMonth());
261+
});
199262
it('keyTabMove - should return previous', () => {
200263
const previous = 5;
201264
const result = keyTabMove(previous);

src/components/calendar/selector/monthSelector/utils/monthSelector.utils.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ export const keyLeftMove = ({
1818
minDate,
1919
}: HandleKeyMoveType): ((previous: number) => number) => {
2020
return previous => {
21+
if (isSameYear(maxDate, minDate)) {
22+
return previous === minDate.getMonth() ? maxDate.getMonth() : previous - 1;
23+
}
2124
if (isSameYear(maxDate, currentDate)) {
2225
return previous === FIRST_MONTH ? maxDate.getMonth() : previous - 1;
2326
}
@@ -34,6 +37,9 @@ export const keyRightMove = ({
3437
minDate,
3538
}: HandleKeyMoveType): ((previous: number) => number) => {
3639
return previous => {
40+
if (isSameYear(maxDate, minDate)) {
41+
return previous === maxDate.getMonth() ? minDate.getMonth() : previous + 1;
42+
}
3743
if (isSameYear(maxDate, currentDate)) {
3844
return previous === maxDate.getMonth() ? FIRST_MONTH : previous + 1;
3945
}
@@ -50,6 +56,14 @@ export const keyUpMove = ({
5056
minDate,
5157
}: HandleKeyMoveType): ((previous: number) => number) => {
5258
return previous => {
59+
if (isSameYear(maxDate, minDate)) {
60+
if (previous === minDate.getMonth()) {
61+
return maxDate.getMonth();
62+
}
63+
return previous <= minDate.getMonth() + NUM_DAYS_IN_ROW
64+
? minDate.getMonth()
65+
: previous - NUM_DAYS_IN_ROW;
66+
}
5367
if (isSameYear(minDate, currentDate)) {
5468
if (previous === minDate.getMonth()) {
5569
return LAST_MONTH;
@@ -77,6 +91,14 @@ export const keyDownMove = ({
7791
minDate,
7892
}: HandleKeyMoveType): ((previous: number) => number) => {
7993
return previous => {
94+
if (isSameYear(maxDate, minDate)) {
95+
if (previous === maxDate.getMonth()) {
96+
return minDate.getMonth();
97+
}
98+
return previous >= maxDate.getMonth() - NUM_DAYS_IN_ROW
99+
? maxDate.getMonth()
100+
: previous + NUM_DAYS_IN_ROW;
101+
}
80102
if (isSameYear(minDate, currentDate)) {
81103
if (previous === LAST_MONTH) {
82104
return minDate.getMonth();

0 commit comments

Comments
 (0)