uikit-react-public 0.11.16 → 0.11.20
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/components/Datepicker/Datepicker.d.ts +5 -1
- package/dist/components/Datepicker/Datepicker.stories.d.ts +8 -1
- package/dist/components/Datepicker/Datepicker.types.d.ts +7 -0
- package/dist/components/Datepicker/index.d.ts +1 -0
- package/dist/components/Datepicker/subcomponents/AcademicWeek.d.ts +5 -0
- package/dist/components/Datepicker/subcomponents/AcademicWeeks.d.ts +7 -0
- package/dist/components/Datepicker/subcomponents/CalendarGrid/CalendarGrid.d.ts +3 -1
- package/dist/components/Datepicker/subcomponents/CalendarMenu/CalendarMenu.d.ts +5 -1
- package/dist/components/Datepicker/subcomponents/Day/Day.d.ts +4 -2
- package/dist/components/Datepicker/subcomponents/Day/Day.stories.d.ts +9 -1
- package/dist/components/Datepicker/subcomponents/EventDot.d.ts +6 -0
- package/dist/components/Datepicker/utils/getAcademicWeekNumbers/getAcademicWeekNumbers.d.ts +24 -0
- package/dist/components/Datepicker/utils/getAcademicWeekNumbers/getAcademicWeekNumbers.test.d.ts +1 -0
- package/dist/components/Datepicker/utils/index.d.ts +1 -0
- package/dist/components/Header/Header.d.ts +5 -4
- package/dist/components/Header/index.d.ts +1 -1
- package/dist/components/Select/Select.stories.d.ts +1 -1
- package/dist/components/Select/Select.types.d.ts +10 -50
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/Select/subcomponents/CustomSelect.d.ts +2 -1
- package/dist/index.js +1865 -1748
- package/lib/components/Datepicker/Datepicker.stories.tsx +133 -0
- package/lib/components/Datepicker/Datepicker.tsx +23 -46
- package/lib/components/Datepicker/Datepicker.types.ts +9 -0
- package/lib/components/Datepicker/__tests__/__snapshots__/Datepicker.test.tsx.snap +487 -378
- package/lib/components/Datepicker/index.ts +1 -0
- package/lib/components/Datepicker/subcomponents/AcademicWeek.tsx +36 -0
- package/lib/components/Datepicker/subcomponents/AcademicWeeks.tsx +44 -0
- package/lib/components/Datepicker/subcomponents/CalendarGrid/CalendarGrid.tsx +9 -14
- package/lib/components/Datepicker/subcomponents/CalendarMenu/CalendarMenu.tsx +32 -6
- package/lib/components/Datepicker/subcomponents/Day/Day.stories.tsx +23 -0
- package/lib/components/Datepicker/subcomponents/Day/Day.tsx +31 -7
- package/lib/components/Datepicker/subcomponents/EventDot.tsx +40 -0
- package/lib/components/Datepicker/utils/getAcademicWeekNumbers/getAcademicWeekNumbers.test.ts +104 -0
- package/lib/components/Datepicker/utils/getAcademicWeekNumbers/getAcademicWeekNumbers.ts +85 -0
- package/lib/components/Datepicker/utils/index.ts +1 -0
- package/lib/components/Header/Header.tsx +32 -33
- package/lib/components/Header/HeaderMenu.tsx +9 -2
- package/lib/components/Header/__tests__/__snapshots__/Header.test.tsx.snap +40 -48
- package/lib/components/Header/index.ts +5 -1
- package/lib/components/Select/Select.stories.tsx +38 -39
- package/lib/components/Select/Select.tsx +4 -18
- package/lib/components/Select/Select.types.ts +30 -69
- package/lib/components/Select/__tests__/Select.test.tsx +6 -6
- package/lib/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +1 -1
- package/lib/components/Select/index.ts +1 -1
- package/lib/components/Select/subcomponents/CustomSelect.tsx +22 -12
- package/lib/components/Select/subcomponents/NativeSelect.tsx +7 -3
- package/lib/components/Select/subcomponents/Panel.tsx +4 -4
- package/lib/components/Select/subcomponents/VisibleField.tsx +1 -1
- package/package.json +3 -3
- package/LICENSE +0 -9
|
@@ -5,14 +5,15 @@ import { useTheme } from '../../../theme';
|
|
|
5
5
|
import type { CustomSelectProps } from '../Select.types';
|
|
6
6
|
|
|
7
7
|
const NAME = 'ucl-uikit-select';
|
|
8
|
+
export const DEFAULT_WIDTH_PX = 200;
|
|
8
9
|
|
|
9
10
|
const CustomSelect = ({
|
|
10
11
|
value,
|
|
11
12
|
options = [],
|
|
12
|
-
|
|
13
|
+
onValueChange,
|
|
13
14
|
disabled,
|
|
14
15
|
placeholder,
|
|
15
|
-
width =
|
|
16
|
+
width = DEFAULT_WIDTH_PX,
|
|
16
17
|
testId = NAME,
|
|
17
18
|
className,
|
|
18
19
|
ref,
|
|
@@ -58,7 +59,7 @@ const CustomSelect = ({
|
|
|
58
59
|
|
|
59
60
|
// Used by <CustomOption> and passed as prop
|
|
60
61
|
const handleSelect = (event: React.MouseEvent, optionValue: string) => {
|
|
61
|
-
if (
|
|
62
|
+
if (onValueChange) onValueChange(optionValue, event);
|
|
62
63
|
closePanel();
|
|
63
64
|
};
|
|
64
65
|
|
|
@@ -96,7 +97,7 @@ const CustomSelect = ({
|
|
|
96
97
|
}
|
|
97
98
|
if (!value) {
|
|
98
99
|
// Initialise at the last option if no value provided
|
|
99
|
-
|
|
100
|
+
onValueChange?.(options[options.length - 1].value, event);
|
|
100
101
|
return;
|
|
101
102
|
}
|
|
102
103
|
const currentOptionIndex = options.findIndex(
|
|
@@ -104,7 +105,7 @@ const CustomSelect = ({
|
|
|
104
105
|
);
|
|
105
106
|
const previousOptionIndex =
|
|
106
107
|
(currentOptionIndex - 1 + options.length) % options.length;
|
|
107
|
-
|
|
108
|
+
onValueChange?.(options[previousOptionIndex].value, event);
|
|
108
109
|
return;
|
|
109
110
|
}
|
|
110
111
|
// Select the next option
|
|
@@ -115,26 +116,25 @@ const CustomSelect = ({
|
|
|
115
116
|
}
|
|
116
117
|
if (!value) {
|
|
117
118
|
// Initialise at the first option if no value provided
|
|
118
|
-
|
|
119
|
+
onValueChange?.(options[0].value, event);
|
|
119
120
|
return;
|
|
120
121
|
}
|
|
121
122
|
const currentOptionIndex = options.findIndex(
|
|
122
123
|
(option) => option.value === value
|
|
123
124
|
);
|
|
124
125
|
const nextOptionIndex = (currentOptionIndex + 1) % options.length;
|
|
125
|
-
|
|
126
|
+
onValueChange?.(options[nextOptionIndex].value, event);
|
|
126
127
|
return;
|
|
127
128
|
}
|
|
128
129
|
};
|
|
129
130
|
|
|
130
131
|
const baseStyle = css`
|
|
131
|
-
display: flex;
|
|
132
|
+
display: inline-flex;
|
|
132
133
|
align-items: center;
|
|
133
134
|
justify-content: space-between;
|
|
134
135
|
position: relative;
|
|
135
|
-
width: ${width}px;
|
|
136
136
|
min-width: 80px;
|
|
137
|
-
|
|
137
|
+
width: fit-content;
|
|
138
138
|
height: 48px;
|
|
139
139
|
box-sizing: border-box;
|
|
140
140
|
padding: 0 16px;
|
|
@@ -156,6 +156,10 @@ const CustomSelect = ({
|
|
|
156
156
|
}
|
|
157
157
|
`;
|
|
158
158
|
|
|
159
|
+
const widthStyle = css`
|
|
160
|
+
width: ${width}px;
|
|
161
|
+
`;
|
|
162
|
+
|
|
159
163
|
const disabledStyle = css`
|
|
160
164
|
color: ${theme.color.text.disabled};
|
|
161
165
|
border: ${theme.border.b1} solid ${theme.color.neutral.grey20};
|
|
@@ -166,7 +170,13 @@ const CustomSelect = ({
|
|
|
166
170
|
}
|
|
167
171
|
`;
|
|
168
172
|
|
|
169
|
-
const style = cx(
|
|
173
|
+
const style = cx(
|
|
174
|
+
NAME,
|
|
175
|
+
baseStyle,
|
|
176
|
+
!!width && widthStyle,
|
|
177
|
+
disabled && disabledStyle,
|
|
178
|
+
className
|
|
179
|
+
);
|
|
170
180
|
|
|
171
181
|
return (
|
|
172
182
|
<div
|
|
@@ -199,7 +209,7 @@ const CustomSelect = ({
|
|
|
199
209
|
aria-selected={value === option.value}
|
|
200
210
|
>
|
|
201
211
|
{option.icon}
|
|
202
|
-
{option.
|
|
212
|
+
{option.label}
|
|
203
213
|
</CustomOption>
|
|
204
214
|
))}
|
|
205
215
|
</Panel>
|
|
@@ -7,7 +7,7 @@ const NAME = 'ucl-uikit-select--native';
|
|
|
7
7
|
|
|
8
8
|
const NativeSelect = ({
|
|
9
9
|
options,
|
|
10
|
-
width
|
|
10
|
+
width,
|
|
11
11
|
disabled,
|
|
12
12
|
placeholder,
|
|
13
13
|
testId = NAME,
|
|
@@ -22,7 +22,6 @@ const NativeSelect = ({
|
|
|
22
22
|
const chevronDownSvg = chevronDownSvgDataUri(chevronColour);
|
|
23
23
|
|
|
24
24
|
const baseStyle = css`
|
|
25
|
-
width: ${width}px;
|
|
26
25
|
padding: 0 ${theme.padding.p40} 0 ${theme.padding.p16};
|
|
27
26
|
height: ${theme.padding.p48};
|
|
28
27
|
line-height: ${theme.font.lineHeight.h150};
|
|
@@ -43,6 +42,10 @@ const NativeSelect = ({
|
|
|
43
42
|
background-repeat: no-repeat;
|
|
44
43
|
`;
|
|
45
44
|
|
|
45
|
+
const widthStyle = css`
|
|
46
|
+
width: ${width}px;
|
|
47
|
+
`;
|
|
48
|
+
|
|
46
49
|
const hoverStyle = css`
|
|
47
50
|
&:hover {
|
|
48
51
|
border-color: ${theme.color.neutral.grey60};
|
|
@@ -70,6 +73,7 @@ const NativeSelect = ({
|
|
|
70
73
|
const style = cx(
|
|
71
74
|
NAME,
|
|
72
75
|
baseStyle,
|
|
76
|
+
!!width && widthStyle,
|
|
73
77
|
!disabled && hoverStyle,
|
|
74
78
|
!disabled && focusStyle,
|
|
75
79
|
disabled && disabledStyle,
|
|
@@ -98,7 +102,7 @@ const NativeSelect = ({
|
|
|
98
102
|
key={option.value}
|
|
99
103
|
value={option.value}
|
|
100
104
|
>
|
|
101
|
-
{option.
|
|
105
|
+
{option.label}
|
|
102
106
|
</option>
|
|
103
107
|
))
|
|
104
108
|
: null}
|
|
@@ -19,14 +19,14 @@ const Panel = (props: PanelProps) => {
|
|
|
19
19
|
position: absolute;
|
|
20
20
|
top: 46px;
|
|
21
21
|
left: -1px; // -1px to align with the border of the field
|
|
22
|
-
|
|
23
22
|
z-index: 10; // Required: panel must be 'above' subsquent DOM elements
|
|
24
|
-
width: 100%;
|
|
25
|
-
|
|
23
|
+
min-width: 100%;
|
|
24
|
+
width: fit-content;
|
|
25
|
+
max-height: 300px;
|
|
26
26
|
overflow-y: auto;
|
|
27
27
|
overflow-x: hidden;
|
|
28
28
|
box-sizing: content-box;
|
|
29
|
-
padding:
|
|
29
|
+
padding: ${theme.padding.p8} 0;
|
|
30
30
|
border: ${theme.border.b1} solid ${theme.color.neutral.grey20};
|
|
31
31
|
background-color: ${theme.color.neutral.white};
|
|
32
32
|
`;
|
package/package.json
CHANGED
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
"name": "uikit-react-public",
|
|
3
3
|
"private": false,
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.11.
|
|
5
|
+
"version": "0.11.20",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist",
|
|
11
|
-
"lib"
|
|
12
|
-
"README.md"
|
|
11
|
+
"lib"
|
|
13
12
|
],
|
|
14
13
|
"publishConfig": {
|
|
15
14
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -25,6 +24,7 @@
|
|
|
25
24
|
"typecheck": "tsc --noemit",
|
|
26
25
|
"test": "vitest",
|
|
27
26
|
"test:nowatch": "vitest run",
|
|
27
|
+
"check": "npm run lint && npm run typecheck && npm run test",
|
|
28
28
|
"coverage": "vitest run --coverage",
|
|
29
29
|
"report": "vite ./coverage",
|
|
30
30
|
"preview": "vite preview",
|
package/LICENSE
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright 2025 UCL
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|