@takaro/lib-components 0.0.7 → 0.0.9
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/Dockerfile.dev +1 -1
- package/package.json +4 -6
- package/src/components/charts/AreaChart/AreaChart.stories.tsx +2 -2
- package/src/components/inputs/Date/DatePicker/DatePicker.stories.tsx +35 -1
- package/src/components/inputs/Date/DatePicker/Generic.tsx +6 -4
- package/src/components/inputs/Date/DatePicker/formats.tsx +2 -2
- package/src/helpers/makeData.ts +2 -2
package/Dockerfile.dev
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takaro/lib-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Takaro UI is a simple and customizable component library to build React apps faster within the Takaro eco system",
|
|
6
6
|
"license": "AGPL-3.0-or-later",
|
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
"_test": "jest",
|
|
13
13
|
"test:unit": "CI=true vitest",
|
|
14
14
|
"test:watch": "jest --watch",
|
|
15
|
-
"test:update": "jest --updateSnapshot"
|
|
16
|
-
"sort-package": "sort-package-json"
|
|
15
|
+
"test:update": "jest --updateSnapshot"
|
|
17
16
|
},
|
|
18
17
|
"devDependencies": {
|
|
19
18
|
"@hookform/devtools": "^4.2.2",
|
|
@@ -24,7 +23,6 @@
|
|
|
24
23
|
"@types/topojson-client": "^3.1.4",
|
|
25
24
|
"react": "^18.2.0",
|
|
26
25
|
"react-dom": "^18.2.0",
|
|
27
|
-
"sort-package-json": "^1.53.1",
|
|
28
26
|
"storybook": "7.6.20"
|
|
29
27
|
},
|
|
30
28
|
"peerDependencies": {
|
|
@@ -37,7 +35,7 @@
|
|
|
37
35
|
"@tanstack/react-router": "1.35.3",
|
|
38
36
|
"@types/luxon": "3.4.2",
|
|
39
37
|
"framer-motion": "^10.16.12",
|
|
40
|
-
"luxon": "3.
|
|
38
|
+
"luxon": "3.5.0",
|
|
41
39
|
"notistack": "^3.0.1",
|
|
42
40
|
"polished": "^4.1.3",
|
|
43
41
|
"rc-slider": "^9.7.5",
|
|
@@ -47,7 +45,7 @@
|
|
|
47
45
|
"react-dnd-html5-backend": "^16.0.1",
|
|
48
46
|
"react-dom": "^18.2.0",
|
|
49
47
|
"react-hook-form": "^7.50.1",
|
|
50
|
-
"react-icons": "^4.11.0",
|
|
48
|
+
"react-icons": "^4.11.0 || ^5.0.0",
|
|
51
49
|
"react-intersection-observer": "^9.5.1",
|
|
52
50
|
"react-virtualized-auto-sizer": "^1.0.9",
|
|
53
51
|
"react-window": "^1.8.8",
|
|
@@ -56,8 +56,8 @@ interface PingData {
|
|
|
56
56
|
function generateData() {
|
|
57
57
|
const data: PingData[] = [];
|
|
58
58
|
for (let i = 0; i < 100; i++) {
|
|
59
|
-
const timestamp = faker.date.between('2021-01-01T00:00:00Z', '2021-01-31T23:59:59Z').toISOString();
|
|
60
|
-
const latency = faker.
|
|
59
|
+
const timestamp = faker.date.between({ from: '2021-01-01T00:00:00Z', to: '2021-01-31T23:59:59Z' }).toISOString();
|
|
60
|
+
const latency = faker.number.float({ min: 0, max: 70, precision: 1 });
|
|
61
61
|
data.push({ timestamp, latency });
|
|
62
62
|
}
|
|
63
63
|
data.sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { StrictMode, useState } from 'react';
|
|
2
2
|
import { Meta, StoryFn } from '@storybook/react';
|
|
3
3
|
import { styled } from '../../../../styled';
|
|
4
4
|
import { Button, DatePicker, DatePickerProps } from '../../../../components';
|
|
@@ -231,3 +231,37 @@ export const RelativeSubmit: StoryFn<DatePickerProps> = (args) => {
|
|
|
231
231
|
</Wrapper>
|
|
232
232
|
);
|
|
233
233
|
};
|
|
234
|
+
|
|
235
|
+
export const AbsoluteSubmit = () => {
|
|
236
|
+
const [result, setResult] = useState<string>();
|
|
237
|
+
const { control, handleSubmit } = useForm<FormFields>({
|
|
238
|
+
mode: 'onSubmit',
|
|
239
|
+
resolver: zodResolver(validationSchema),
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
const onSubmit: SubmitHandler<FormFields> = ({ date }) => {
|
|
243
|
+
setResult(date);
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
return (
|
|
247
|
+
<StrictMode>
|
|
248
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
249
|
+
<DatePicker
|
|
250
|
+
mode="absolute"
|
|
251
|
+
control={control}
|
|
252
|
+
label="Expiration date"
|
|
253
|
+
name="date"
|
|
254
|
+
required={false}
|
|
255
|
+
loading={false}
|
|
256
|
+
description={'The role will be automatically removed after this date'}
|
|
257
|
+
popOverPlacement={'bottom'}
|
|
258
|
+
timePickerOptions={{ interval: 30 }}
|
|
259
|
+
allowPastDates={false}
|
|
260
|
+
format={DateTime.TIME_SIMPLE}
|
|
261
|
+
/>
|
|
262
|
+
<Button type="submit" text="Submit form" />
|
|
263
|
+
</form>
|
|
264
|
+
<p>result: {result}</p>
|
|
265
|
+
</StrictMode>
|
|
266
|
+
);
|
|
267
|
+
};
|
|
@@ -103,8 +103,10 @@ export const GenericDatePicker: FC<GenericDatePickerProps> = ({
|
|
|
103
103
|
const [selectedDateTime, setSelectedDateTime] = useState<DateTime>(initialSelectedDateTime);
|
|
104
104
|
const [friendlyName, setFriendlyName] = useState<string | undefined>(undefined);
|
|
105
105
|
|
|
106
|
-
const
|
|
107
|
-
const
|
|
106
|
+
const isFormatInTimeFormats = timeFormats.includes(JSON.stringify(format));
|
|
107
|
+
const isFormatInDateFormats = dateFormats.includes(JSON.stringify(format));
|
|
108
|
+
const isDateOnly = !isFormatInTimeFormats;
|
|
109
|
+
const isTimeOnly = !isFormatInDateFormats;
|
|
108
110
|
const isDateTime = !isDateOnly && !isTimeOnly;
|
|
109
111
|
|
|
110
112
|
const isAbsolute = mode === 'absolute';
|
|
@@ -181,7 +183,7 @@ export const GenericDatePicker: FC<GenericDatePickerProps> = ({
|
|
|
181
183
|
<ContentContainer>
|
|
182
184
|
{isAbsolute && (
|
|
183
185
|
<InnerContainer>
|
|
184
|
-
{
|
|
186
|
+
{isFormatInDateFormats && (
|
|
185
187
|
<Calendar
|
|
186
188
|
id={`calendar-${id}`}
|
|
187
189
|
// should be start of day to not update the time when only selecting a date
|
|
@@ -200,7 +202,7 @@ export const GenericDatePicker: FC<GenericDatePickerProps> = ({
|
|
|
200
202
|
}}
|
|
201
203
|
/>
|
|
202
204
|
)}
|
|
203
|
-
{
|
|
205
|
+
{isFormatInTimeFormats && (
|
|
204
206
|
<TimePicker
|
|
205
207
|
selectedDate={selectedDateTime}
|
|
206
208
|
interval={timePickerOptions?.interval}
|
|
@@ -21,7 +21,7 @@ export const timeFormats = [
|
|
|
21
21
|
DateTime.TIME_24_WITH_SHORT_OFFSET,
|
|
22
22
|
DateTime.TIME_24_WITH_LONG_OFFSET,
|
|
23
23
|
...DateAndTimeFormats,
|
|
24
|
-
];
|
|
24
|
+
].map((format) => JSON.stringify(format));
|
|
25
25
|
|
|
26
26
|
export const dateFormats = [
|
|
27
27
|
DateTime.DATE_SHORT,
|
|
@@ -29,4 +29,4 @@ export const dateFormats = [
|
|
|
29
29
|
DateTime.DATE_FULL,
|
|
30
30
|
DateTime.DATE_HUGE,
|
|
31
31
|
...DateAndTimeFormats,
|
|
32
|
-
];
|
|
32
|
+
].map((format) => JSON.stringify(format));
|
package/src/helpers/makeData.ts
CHANGED
|
@@ -11,8 +11,8 @@ const range = (len: number) => {
|
|
|
11
11
|
const newPerson = () => {
|
|
12
12
|
const statusChance = Math.random();
|
|
13
13
|
return {
|
|
14
|
-
firstName: faker.
|
|
15
|
-
lastName: faker.
|
|
14
|
+
firstName: faker.person.firstName(),
|
|
15
|
+
lastName: faker.person.lastName(),
|
|
16
16
|
age: Math.floor(Math.random() * 30),
|
|
17
17
|
visits: Math.floor(Math.random() * 100),
|
|
18
18
|
progress: Math.floor(Math.random() * 100),
|