@vygruppen/spor-react 13.4.2 → 13.4.3
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/.turbo/turbo-build.log +10 -10
- package/.turbo/turbo-postinstall.log +4 -3
- package/CHANGELOG.md +12 -0
- package/dist/index.cjs +120 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +120 -64
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/datepicker/DateField.tsx +1 -1
- package/src/datepicker/DatePicker.tsx +1 -1
- package/src/datepicker/DateTimeSegment.tsx +4 -4
- package/src/datepicker/TimeField.tsx +54 -2
- package/src/datepicker/TimePicker.tsx +0 -1
- package/src/theme/recipes/textarea.ts +2 -0
- package/src/theme/slot-recipes/datepicker.ts +1 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vygruppen/spor-react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "13.4.
|
|
4
|
+
"version": "13.4.3",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"react-stately": "^3.31.1",
|
|
47
47
|
"react-swipeable": "^7.0.1",
|
|
48
48
|
"usehooks-ts": "^3.1.0",
|
|
49
|
-
"@vygruppen/spor-design-tokens": "5.0.
|
|
49
|
+
"@vygruppen/spor-design-tokens": "5.0.5",
|
|
50
50
|
"@vygruppen/spor-icon-react": "5.0.0",
|
|
51
51
|
"@vygruppen/spor-loader": "0.7.0"
|
|
52
52
|
},
|
|
@@ -115,7 +115,7 @@ export const DatePicker = ({
|
|
|
115
115
|
const popoverContent = (
|
|
116
116
|
<ChakraPopover.Positioner>
|
|
117
117
|
<ChakraPopover.Content css={styles.calendarPopover}>
|
|
118
|
-
<ChakraPopover.Body minWidth="
|
|
118
|
+
<ChakraPopover.Body minWidth="18rem">
|
|
119
119
|
<Calendar
|
|
120
120
|
{...calendarProps}
|
|
121
121
|
variant={variant}
|
|
@@ -10,7 +10,7 @@ type DateTimeSegmentProps = PropsWithChildren<DatePickerVariantProps> & {
|
|
|
10
10
|
segment: DateSegment;
|
|
11
11
|
state: DateFieldState;
|
|
12
12
|
ariaLabel?: string;
|
|
13
|
-
|
|
13
|
+
ariaLabelledby?: string;
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
16
|
* A date time segment is a part of a date or a time stamp.
|
|
@@ -24,7 +24,7 @@ export const DateTimeSegment = ({
|
|
|
24
24
|
segment,
|
|
25
25
|
state,
|
|
26
26
|
ariaLabel,
|
|
27
|
-
|
|
27
|
+
ariaLabelledby,
|
|
28
28
|
variant,
|
|
29
29
|
}: DateTimeSegmentProps & {
|
|
30
30
|
ref?: React.Ref<HTMLDivElement>;
|
|
@@ -59,8 +59,8 @@ export const DateTimeSegment = ({
|
|
|
59
59
|
borderRadius="xs"
|
|
60
60
|
fontSize={["mobile.sm", "desktop.sm"]}
|
|
61
61
|
css={styles.dateTimeSegment}
|
|
62
|
-
aria-label={
|
|
63
|
-
aria-labelledby={
|
|
62
|
+
aria-label={ariaLabel}
|
|
63
|
+
aria-labelledby={ariaLabelledby}
|
|
64
64
|
>
|
|
65
65
|
{isPaddable(segment.type) ? segment.text.padStart(2, "0") : segment.text}
|
|
66
66
|
</Box>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Box, Flex } from "@chakra-ui/react";
|
|
2
|
+
import { Box, Field as ChakraField, Flex } from "@chakra-ui/react";
|
|
3
3
|
import { CalendarDateTime, Time } from "@internationalized/date";
|
|
4
4
|
import { useRef } from "react";
|
|
5
5
|
import { AriaTimeFieldProps, useTimeField } from "react-aria";
|
|
@@ -7,6 +7,7 @@ import { DateSegment, TimeFieldState } from "react-stately";
|
|
|
7
7
|
|
|
8
8
|
import { spor } from "@/util";
|
|
9
9
|
|
|
10
|
+
import { createTexts, useTranslation } from "../i18n";
|
|
10
11
|
import { DateTimeSegment } from "./DateTimeSegment";
|
|
11
12
|
import { getTimestampFromTime } from "./utils";
|
|
12
13
|
|
|
@@ -23,6 +24,7 @@ type TimeFieldProps = AriaTimeFieldProps<Time> & {
|
|
|
23
24
|
export const TimeField = ({ state, ...props }: TimeFieldProps) => {
|
|
24
25
|
const ref = useRef<HTMLDivElement>(null);
|
|
25
26
|
const { labelProps, fieldProps } = useTimeField(props, state, ref);
|
|
27
|
+
const { t } = useTranslation();
|
|
26
28
|
|
|
27
29
|
return (
|
|
28
30
|
<Box>
|
|
@@ -43,10 +45,16 @@ export const TimeField = ({ state, ...props }: TimeFieldProps) => {
|
|
|
43
45
|
maxWidth="80%"
|
|
44
46
|
>
|
|
45
47
|
{props.label}
|
|
48
|
+
<ChakraField.RequiredIndicator />
|
|
46
49
|
</spor.label>
|
|
47
50
|
<Flex {...fieldProps} ref={ref} paddingTop="3" paddingBottom="0.5">
|
|
48
51
|
{state.segments.map((segment: DateSegment, index) => (
|
|
49
|
-
<DateTimeSegment
|
|
52
|
+
<DateTimeSegment
|
|
53
|
+
key={index}
|
|
54
|
+
segment={segment}
|
|
55
|
+
state={state}
|
|
56
|
+
ariaLabel={t(getAriaLabel(segment.type))}
|
|
57
|
+
/>
|
|
50
58
|
))}
|
|
51
59
|
</Flex>
|
|
52
60
|
<input
|
|
@@ -57,3 +65,47 @@ export const TimeField = ({ state, ...props }: TimeFieldProps) => {
|
|
|
57
65
|
</Box>
|
|
58
66
|
);
|
|
59
67
|
};
|
|
68
|
+
|
|
69
|
+
const getAriaLabel = (segmentType: DateSegment["type"]) => {
|
|
70
|
+
switch (segmentType) {
|
|
71
|
+
case "hour": {
|
|
72
|
+
return texts.hour;
|
|
73
|
+
}
|
|
74
|
+
case "minute": {
|
|
75
|
+
return texts.minute;
|
|
76
|
+
}
|
|
77
|
+
case "second": {
|
|
78
|
+
return texts.second;
|
|
79
|
+
}
|
|
80
|
+
default: {
|
|
81
|
+
return texts.default;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const texts = createTexts({
|
|
87
|
+
hour: {
|
|
88
|
+
nb: "Velg time",
|
|
89
|
+
nn: "Vel time",
|
|
90
|
+
sv: "Välj timme",
|
|
91
|
+
en: "Choose hour",
|
|
92
|
+
},
|
|
93
|
+
minute: {
|
|
94
|
+
nb: "Velg minutt",
|
|
95
|
+
nn: "Vel minutt",
|
|
96
|
+
sv: "Välj minut",
|
|
97
|
+
en: "Choose minute",
|
|
98
|
+
},
|
|
99
|
+
second: {
|
|
100
|
+
nb: "Velg sekund",
|
|
101
|
+
nn: "Vel sekund",
|
|
102
|
+
sv: "Välj sekund",
|
|
103
|
+
en: "Choose second",
|
|
104
|
+
},
|
|
105
|
+
default: {
|
|
106
|
+
nb: "Velg tid",
|
|
107
|
+
nn: "Vel tid",
|
|
108
|
+
sv: "Välj tid",
|
|
109
|
+
en: "Choose time",
|
|
110
|
+
},
|
|
111
|
+
});
|