@vygruppen/spor-react 12.1.2 → 12.2.1
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 +31 -12
- package/.turbo/turbo-typegen.log +19 -1
- package/CHANGELOG.md +14 -0
- package/dist/index.d.mts +189 -243
- package/dist/index.d.ts +189 -243
- package/dist/index.js +2485 -2072
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2376 -1972
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/accordion/Accordion.tsx +2 -1
- package/src/accordion/Expandable.tsx +3 -1
- package/src/accordion/helpers.ts +2 -1
- package/src/alert/Alert.tsx +3 -1
- package/src/alert/AlertIcon.tsx +17 -10
- package/src/alert/ExpandableAlert.tsx +3 -2
- package/src/alert/ServiceAlert.tsx +2 -1
- package/src/breadcrumb/Breadcrumb.tsx +9 -8
- package/src/button/Button.tsx +2 -1
- package/src/button/ButtonGroup.tsx +2 -1
- package/src/button/Clipboard.tsx +3 -0
- package/src/button/CloseButton.tsx +8 -4
- package/src/button/FloatingActionButton.tsx +5 -5
- package/src/button/IconButton.tsx +1 -0
- package/src/color-mode/color-mode.tsx +2 -2
- package/src/datepicker/Calendar.tsx +0 -1
- package/src/datepicker/CalendarCell.tsx +5 -5
- package/src/datepicker/CalendarGrid.tsx +3 -2
- package/src/datepicker/CalendarHeader.tsx +1 -4
- package/src/datepicker/CalendarTriggerButton.tsx +3 -4
- package/src/datepicker/DateField.tsx +13 -6
- package/src/datepicker/DatePicker.tsx +2 -1
- package/src/datepicker/DateRangePicker.tsx +1 -1
- package/src/datepicker/DateTimeSegment.tsx +2 -1
- package/src/datepicker/RangeCalendar.tsx +1 -1
- package/src/datepicker/StyledField.tsx +1 -1
- package/src/datepicker/TimeField.tsx +3 -3
- package/src/datepicker/TimePicker.tsx +4 -2
- package/src/datepicker/utils.ts +10 -5
- package/src/dialog/Dialog.tsx +1 -0
- package/src/dialog/Drawer.tsx +28 -26
- package/src/i18n/index.tsx +1 -0
- package/src/input/AttachedInputs.tsx +6 -3
- package/src/input/CardSelect.tsx +3 -1
- package/src/input/Checkbox.tsx +1 -0
- package/src/input/CheckboxGroup.tsx +3 -1
- package/src/input/ChoiceChip.tsx +39 -66
- package/src/input/Combobox.tsx +6 -4
- package/src/input/CountryCodeSelect.tsx +10 -4
- package/src/input/Field.tsx +2 -0
- package/src/input/Input.tsx +2 -3
- package/src/input/InputGroup.tsx +1 -1
- package/src/input/ListBox.tsx +9 -8
- package/src/input/NativeSelect.tsx +1 -2
- package/src/input/NumericStepper.tsx +22 -23
- package/src/input/PasswordInput.tsx +2 -1
- package/src/input/PhoneNumberInput.tsx +6 -2
- package/src/input/Popover.tsx +2 -0
- package/src/input/Radio.tsx +2 -0
- package/src/input/SearchInput.tsx +2 -1
- package/src/input/Select.tsx +8 -2
- package/src/input/Switch.tsx +22 -34
- package/src/input/Textarea.tsx +6 -4
- package/src/input/index.ts +1 -1
- package/src/layout/PressableCard.tsx +5 -2
- package/src/layout/RadioCard.tsx +3 -1
- package/src/layout/Separator.tsx +2 -1
- package/src/layout/StaticCard.tsx +6 -3
- package/src/linjetag/InfoTag.tsx +3 -2
- package/src/linjetag/LineIcon.tsx +5 -4
- package/src/linjetag/TravelTag.tsx +12 -8
- package/src/link/TextLink.tsx +1 -1
- package/src/loader/ColorInlineLoader.tsx +0 -1
- package/src/loader/ColorSpinner.tsx +0 -1
- package/src/loader/ContentLoader.tsx +0 -1
- package/src/loader/DarkFullScreenLoader.tsx +0 -1
- package/src/loader/DarkInlineLoader.tsx +0 -1
- package/src/loader/DarkSpinner.tsx +0 -1
- package/src/loader/LightFullScreenLoader.tsx +0 -1
- package/src/loader/LightInlineLoader.tsx +0 -1
- package/src/loader/LightSpinner.tsx +0 -1
- package/src/loader/Lottie.tsx +1 -2
- package/src/loader/ProgressBar.tsx +1 -2
- package/src/loader/ProgressLoader.tsx +2 -7
- package/src/logo/CargonetLogo.tsx +2 -1
- package/src/logo/VyLogo.tsx +3 -4
- package/src/logo/VyLogoPride.tsx +4 -1
- package/src/media-controller/JumpButton.tsx +2 -1
- package/src/media-controller/PlayPauseButton.tsx +2 -1
- package/src/media-controller/SkipButton.tsx +2 -1
- package/src/nudge/Nudge.tsx +7 -14
- package/src/pagination/Pagination.tsx +5 -0
- package/src/popover/index.tsx +2 -0
- package/src/progress-indicator/ProgressDot.tsx +1 -1
- package/src/progress-indicator/ProgressIndicator.tsx +4 -2
- package/src/provider/SporProvider.tsx +0 -1
- package/src/stepper/Stepper.tsx +1 -1
- package/src/tab/Tabs.tsx +1 -1
- package/src/table/Table.tsx +2 -1
- package/src/theme/slot-recipes/alert-expandable.ts +0 -4
- package/src/theme/slot-recipes/anatomy.ts +10 -0
- package/src/theme/slot-recipes/choice-chip.ts +183 -0
- package/src/theme/slot-recipes/index.ts +2 -0
- package/src/theme/slot-recipes/info-tag.ts +0 -1
- package/src/theme/slot-recipes/popover.ts +0 -1
- package/src/theme/slot-recipes/radio-card.ts +0 -3
- package/src/theme/utils/accent-utils.ts +12 -6
- package/src/theme/utils/bg-utils.ts +6 -3
- package/src/theme/utils/brand-utils.ts +7 -7
- package/src/theme/utils/core-utils.ts +23 -13
- package/src/theme/utils/floating-utils.ts +16 -8
- package/src/theme/utils/ghost-utils.ts +8 -4
- package/src/theme/utils/input-utils.ts +7 -4
- package/src/theme/utils/outline-utils.ts +6 -3
- package/src/theme/utils/surface-utils.ts +8 -4
- package/src/toast/toast.tsx +0 -1
- package/src/typography/Badge.tsx +8 -5
- package/src/typography/Heading.tsx +1 -1
- package/src/typography/Text.tsx +1 -1
- package/src/util/slugify.tsx +8 -8
- package/tsconfig.json +1 -0
- package/src/theme/recipes/choice-chip.ts +0 -144
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vygruppen/spor-react",
|
3
|
-
"version": "12.1
|
3
|
+
"version": "12.2.1",
|
4
4
|
"main": "./dist/index.js",
|
5
5
|
"module": "./dist/index.mjs",
|
6
6
|
"types": "./dist/index.d.ts",
|
@@ -36,8 +36,8 @@
|
|
36
36
|
"react-swipeable": "^7.0.1",
|
37
37
|
"usehooks-ts": "^3.1.0",
|
38
38
|
"@vygruppen/spor-design-tokens": "4.0.5",
|
39
|
-
"@vygruppen/spor-
|
40
|
-
"@vygruppen/spor-
|
39
|
+
"@vygruppen/spor-loader": "0.6.0",
|
40
|
+
"@vygruppen/spor-icon-react": "4.0.4"
|
41
41
|
},
|
42
42
|
"devDependencies": {
|
43
43
|
"@chakra-ui/cli": "^3.8.0",
|
@@ -8,7 +8,7 @@ import {
|
|
8
8
|
useSlotRecipe,
|
9
9
|
} from "@chakra-ui/react";
|
10
10
|
import { DropdownDownFill24Icon } from "@vygruppen/spor-icon-react";
|
11
|
-
import
|
11
|
+
import { forwardRef } from "react";
|
12
12
|
|
13
13
|
import { warnAboutMismatchingIcon } from "./helpers";
|
14
14
|
import {
|
@@ -112,5 +112,6 @@ export const AccordionItemContent = forwardRef<
|
|
112
112
|
</ChakraAccordion.ItemContent>
|
113
113
|
);
|
114
114
|
});
|
115
|
+
Accordion.displayName = "Accordion";
|
115
116
|
|
116
117
|
export const AccordionItem = ChakraAccordion.Item;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use client";
|
2
2
|
|
3
|
-
import
|
3
|
+
import { forwardRef } from "react";
|
4
4
|
|
5
5
|
import {
|
6
6
|
Accordion,
|
@@ -85,3 +85,5 @@ export const ExpandableItem = (props: ExpandableItemProps) => {
|
|
85
85
|
</AccordionItem>
|
86
86
|
);
|
87
87
|
};
|
88
|
+
|
89
|
+
Expandable.displayName = "Expandable";
|
package/src/accordion/helpers.ts
CHANGED
package/src/alert/Alert.tsx
CHANGED
@@ -7,7 +7,7 @@ import {
|
|
7
7
|
useSlotRecipe,
|
8
8
|
} from "@chakra-ui/react";
|
9
9
|
import { IconComponent } from "@vygruppen/spor-icon-react";
|
10
|
-
import
|
10
|
+
import { forwardRef } from "react";
|
11
11
|
|
12
12
|
import { CloseButton } from "@/button";
|
13
13
|
|
@@ -101,3 +101,5 @@ export const Alert = forwardRef<HTMLDivElement, AlertProps>((props, ref) => {
|
|
101
101
|
</ChakraAlert.Root>
|
102
102
|
);
|
103
103
|
});
|
104
|
+
|
105
|
+
Alert.displayName = "Alert";
|
package/src/alert/AlertIcon.tsx
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use client";
|
2
2
|
|
3
|
-
import { Alert as ChakraAlert, Box
|
3
|
+
import { Alert as ChakraAlert, Box } from "@chakra-ui/react";
|
4
4
|
import {
|
5
5
|
AltTransportFill24Icon,
|
6
6
|
ErrorFill24Icon,
|
@@ -12,7 +12,6 @@ import {
|
|
12
12
|
SuccessFill24Icon,
|
13
13
|
WarningFill24Icon,
|
14
14
|
} from "@vygruppen/spor-icon-react";
|
15
|
-
import React, { PropsWithChildren } from "react";
|
16
15
|
|
17
16
|
import { createTexts, useTranslation } from "../i18n";
|
18
17
|
import { AlertProps } from "./Alert";
|
@@ -41,22 +40,30 @@ export const AlertIcon = ({ variant, customIcon }: AlertIconProps) => {
|
|
41
40
|
|
42
41
|
const getIcon = (variant: AlertProps["variant"]) => {
|
43
42
|
switch (variant) {
|
44
|
-
case "info":
|
43
|
+
case "info": {
|
45
44
|
return InformationFill24Icon;
|
46
|
-
|
45
|
+
}
|
46
|
+
case "success": {
|
47
47
|
return SuccessFill24Icon;
|
48
|
-
|
48
|
+
}
|
49
|
+
case "important": {
|
49
50
|
return WarningFill24Icon;
|
50
|
-
|
51
|
+
}
|
52
|
+
case "alt": {
|
51
53
|
return AltTransportFill24Icon;
|
52
|
-
|
54
|
+
}
|
55
|
+
case "error": {
|
53
56
|
return ErrorFill24Icon;
|
54
|
-
|
57
|
+
}
|
58
|
+
case "error-secondary": {
|
55
59
|
return ErrorOutline24Icon;
|
56
|
-
|
60
|
+
}
|
61
|
+
case "neutral": {
|
57
62
|
return QuestionFill24Icon;
|
58
|
-
|
63
|
+
}
|
64
|
+
case "service": {
|
59
65
|
return ServiceFill24Icon;
|
66
|
+
}
|
60
67
|
}
|
61
68
|
};
|
62
69
|
|
@@ -10,12 +10,11 @@ import {
|
|
10
10
|
useSlotRecipe,
|
11
11
|
} from "@chakra-ui/react";
|
12
12
|
import { DropdownDownFill18Icon } from "@vygruppen/spor-icon-react";
|
13
|
-
import
|
13
|
+
import { forwardRef, PropsWithChildren } from "react";
|
14
14
|
|
15
15
|
import { AccordionItemContent } from "@/accordion";
|
16
16
|
import { alertExpandableSlotRecipe } from "@/theme/slot-recipes/alert-expandable";
|
17
17
|
|
18
|
-
import { AlertProps } from "./Alert";
|
19
18
|
import { AlertIcon } from "./AlertIcon";
|
20
19
|
|
21
20
|
type ExpandableAlertVariantProps = RecipeVariantProps<
|
@@ -125,3 +124,5 @@ export const ExpandableAlert = forwardRef<HTMLDivElement, ExpandableAlertProps>(
|
|
125
124
|
);
|
126
125
|
},
|
127
126
|
);
|
127
|
+
|
128
|
+
ExpandableAlert.displayName = "ExpandableAlert";
|
@@ -15,7 +15,7 @@ import {
|
|
15
15
|
ServiceFill24Icon,
|
16
16
|
WarningFill24Icon,
|
17
17
|
} from "@vygruppen/spor-icon-react";
|
18
|
-
import
|
18
|
+
import { forwardRef, PropsWithChildren } from "react";
|
19
19
|
|
20
20
|
import { createTexts, useTranslation } from "../i18n";
|
21
21
|
import { alertServiceSlotRecipe } from "../theme/slot-recipes/alert-service";
|
@@ -143,6 +143,7 @@ export const ServiceAlert = forwardRef<HTMLDivElement, ServiceAlertProps>(
|
|
143
143
|
);
|
144
144
|
},
|
145
145
|
);
|
146
|
+
ServiceAlert.displayName = "ServiceAlert";
|
146
147
|
|
147
148
|
const texts = createTexts({
|
148
149
|
notification: (notification) => {
|
@@ -2,9 +2,6 @@
|
|
2
2
|
|
3
3
|
import {
|
4
4
|
Breadcrumb as ChakraBreadcrumb,
|
5
|
-
BreadcrumbCurrentLink as ChakraBreadcrumbCurrentLink,
|
6
|
-
BreadcrumbEllipsis as ChakraBreadcrumbEllipsis,
|
7
|
-
BreadcrumbLink as ChakraBreadcrumbLink,
|
8
5
|
BreadcrumbRootProps,
|
9
6
|
} from "@chakra-ui/react";
|
10
7
|
import { DropdownRightFill18Icon } from "@vygruppen/spor-icon-react";
|
@@ -25,8 +22,8 @@ import React, { forwardRef } from "react";
|
|
25
22
|
*/
|
26
23
|
export const Breadcrumb = forwardRef<HTMLDivElement, BreadcrumbRootProps>(
|
27
24
|
({ children, ...props }, ref) => {
|
28
|
-
const validChildren = React.Children.toArray(children).filter(
|
29
|
-
React.isValidElement,
|
25
|
+
const validChildren = React.Children.toArray(children).filter((element) =>
|
26
|
+
React.isValidElement(element),
|
30
27
|
);
|
31
28
|
|
32
29
|
return (
|
@@ -51,6 +48,10 @@ export const Breadcrumb = forwardRef<HTMLDivElement, BreadcrumbRootProps>(
|
|
51
48
|
},
|
52
49
|
);
|
53
50
|
|
54
|
-
|
55
|
-
|
56
|
-
export
|
51
|
+
Breadcrumb.displayName = "Breadcrumb";
|
52
|
+
|
53
|
+
export {
|
54
|
+
BreadcrumbCurrentLink,
|
55
|
+
BreadcrumbEllipsis,
|
56
|
+
BreadcrumbLink,
|
57
|
+
} from "@chakra-ui/react";
|
package/src/button/Button.tsx
CHANGED
@@ -92,7 +92,6 @@ const LoadingContent = ({
|
|
92
92
|
</>
|
93
93
|
);
|
94
94
|
|
95
|
-
// eslint-disable-next-line react/display-name
|
96
95
|
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
97
96
|
(
|
98
97
|
{
|
@@ -158,6 +157,8 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
158
157
|
},
|
159
158
|
);
|
160
159
|
|
160
|
+
Button.displayName = "Button";
|
161
|
+
|
161
162
|
const texts = createTexts({
|
162
163
|
loadingText: {
|
163
164
|
nb: "Laster…",
|
@@ -6,7 +6,7 @@ import {
|
|
6
6
|
type GroupProps as ChakraGroupProps,
|
7
7
|
type RecipeVariantProps,
|
8
8
|
} from "@chakra-ui/react";
|
9
|
-
import
|
9
|
+
import { forwardRef, PropsWithChildren } from "react";
|
10
10
|
|
11
11
|
import { groupRecipe } from "../theme/recipes/group";
|
12
12
|
|
@@ -67,3 +67,4 @@ export const ButtonGroup = forwardRef<HTMLDivElement, ButtonGroupProps>(
|
|
67
67
|
);
|
68
68
|
},
|
69
69
|
);
|
70
|
+
ButtonGroup.displayName = "ButtonGroup";
|
package/src/button/Clipboard.tsx
CHANGED
@@ -34,6 +34,7 @@ const ClipboardIcon = React.forwardRef<
|
|
34
34
|
</ChakraClipboard.Indicator>
|
35
35
|
);
|
36
36
|
});
|
37
|
+
ClipboardIcon.displayName = "ClipboardIcon";
|
37
38
|
|
38
39
|
const ClipboardCopyText = React.forwardRef<
|
39
40
|
HTMLDivElement,
|
@@ -50,6 +51,7 @@ const ClipboardCopyText = React.forwardRef<
|
|
50
51
|
</ChakraClipboard.Indicator>
|
51
52
|
);
|
52
53
|
});
|
54
|
+
ClipboardCopyText.displayName = "ClipboardCopyText";
|
53
55
|
|
54
56
|
type ClipboardButtonProps = ButtonProps;
|
55
57
|
|
@@ -65,6 +67,7 @@ export const ClipboardButton = React.forwardRef<
|
|
65
67
|
</ChakraClipboard.Trigger>
|
66
68
|
);
|
67
69
|
});
|
70
|
+
ClipboardButton.displayName = "ClipboardButton";
|
68
71
|
|
69
72
|
export const Clipboard = ChakraClipboard.Root;
|
70
73
|
|
@@ -5,7 +5,7 @@ import {
|
|
5
5
|
CloseFill24Icon,
|
6
6
|
CloseFill30Icon,
|
7
7
|
} from "@vygruppen/spor-icon-react";
|
8
|
-
import
|
8
|
+
import { forwardRef } from "react";
|
9
9
|
|
10
10
|
import { createTexts, useTranslation } from "../i18n";
|
11
11
|
import { IconButton, IconButtonProps } from "./IconButton";
|
@@ -42,16 +42,20 @@ export const CloseButton = forwardRef<HTMLButtonElement, CloseButtonProps>(
|
|
42
42
|
);
|
43
43
|
},
|
44
44
|
);
|
45
|
+
CloseButton.displayName = "CloseButton";
|
45
46
|
|
46
47
|
const getIcon = (size: CloseButtonProps["size"]) => {
|
47
48
|
switch (size) {
|
48
49
|
case "xs":
|
49
|
-
case "sm":
|
50
|
+
case "sm": {
|
50
51
|
return <CloseFill18Icon />;
|
51
|
-
|
52
|
+
}
|
53
|
+
case "md": {
|
52
54
|
return <CloseFill24Icon />;
|
53
|
-
|
55
|
+
}
|
56
|
+
case "lg": {
|
54
57
|
return <CloseFill30Icon />;
|
58
|
+
}
|
55
59
|
}
|
56
60
|
};
|
57
61
|
|
@@ -42,7 +42,6 @@ export const FloatingActionButton = forwardRef<
|
|
42
42
|
>(
|
43
43
|
(
|
44
44
|
{
|
45
|
-
as,
|
46
45
|
children,
|
47
46
|
icon,
|
48
47
|
variant,
|
@@ -53,18 +52,18 @@ export const FloatingActionButton = forwardRef<
|
|
53
52
|
ref,
|
54
53
|
) => {
|
55
54
|
const [isTextVisible, setIsTextVisible] = React.useState(
|
56
|
-
externalIsTextVisible
|
55
|
+
externalIsTextVisible === undefined ? false : externalIsTextVisible,
|
57
56
|
);
|
58
57
|
const scrollDirection = useScrollDirection();
|
59
58
|
useEffect(() => {
|
60
59
|
if (externalIsTextVisible !== undefined) {
|
61
60
|
return;
|
62
61
|
}
|
63
|
-
const id =
|
62
|
+
const id = globalThis.setTimeout(
|
64
63
|
() => setIsTextVisible(scrollDirection !== "down"),
|
65
64
|
1000,
|
66
65
|
);
|
67
|
-
return () =>
|
66
|
+
return () => globalThis.clearTimeout(id);
|
68
67
|
}, [scrollDirection, externalIsTextVisible]);
|
69
68
|
|
70
69
|
useEffect(() => {
|
@@ -96,13 +95,14 @@ export const FloatingActionButton = forwardRef<
|
|
96
95
|
);
|
97
96
|
},
|
98
97
|
);
|
98
|
+
FloatingActionButton.displayName = "FloatingActionButton";
|
99
99
|
|
100
100
|
type ScrollDirection = "up" | "down" | null;
|
101
101
|
const useScrollDirection = () => {
|
102
102
|
const [scrollDirection, setScrollDirection] =
|
103
103
|
React.useState<ScrollDirection>(null);
|
104
104
|
const lastScrollPosition = React.useRef(
|
105
|
-
|
105
|
+
globalThis.window === undefined ? 0 : window.scrollY,
|
106
106
|
);
|
107
107
|
React.useEffect(() => {
|
108
108
|
const onScroll = () => {
|
@@ -7,7 +7,7 @@ import { ThemeProvider, useTheme } from "next-themes";
|
|
7
7
|
import * as React from "react";
|
8
8
|
import { LuMoon, LuSun } from "react-icons/lu";
|
9
9
|
|
10
|
-
export
|
10
|
+
export type ColorModeProviderProps = ThemeProviderProps;
|
11
11
|
|
12
12
|
export function ColorModeProvider(props: ColorModeProviderProps) {
|
13
13
|
return (
|
@@ -45,7 +45,7 @@ export function ColorModeIcon() {
|
|
45
45
|
return colorMode === "dark" ? <LuMoon /> : <LuSun />;
|
46
46
|
}
|
47
47
|
|
48
|
-
|
48
|
+
type ColorModeButtonProps = Omit<IconButtonProps, "aria-label">;
|
49
49
|
|
50
50
|
export const ColorModeButton = React.forwardRef<
|
51
51
|
HTMLButtonElement,
|
@@ -1,13 +1,13 @@
|
|
1
1
|
"use client";
|
2
2
|
|
3
|
-
import { Box,
|
3
|
+
import { Box, useSlotRecipe } from "@chakra-ui/react";
|
4
4
|
import {
|
5
5
|
CalendarDate,
|
6
6
|
DateValue,
|
7
7
|
isSameMonth,
|
8
8
|
isToday,
|
9
9
|
} from "@internationalized/date";
|
10
|
-
import
|
10
|
+
import { PropsWithChildren, useEffect, useRef } from "react";
|
11
11
|
import { useCalendarCell } from "react-aria";
|
12
12
|
import { CalendarState, RangeCalendarState } from "react-stately";
|
13
13
|
|
@@ -27,7 +27,7 @@ export function CalendarCell({
|
|
27
27
|
currentMonth,
|
28
28
|
variant,
|
29
29
|
}: CalendarCellProps) {
|
30
|
-
const ref = useRef(null);
|
30
|
+
const ref = useRef<HTMLButtonElement>(null);
|
31
31
|
const {
|
32
32
|
cellProps,
|
33
33
|
buttonProps,
|
@@ -44,7 +44,7 @@ export function CalendarCell({
|
|
44
44
|
});
|
45
45
|
const styles = recipe({ variant });
|
46
46
|
|
47
|
-
const stateProps: Record<string,
|
47
|
+
const stateProps: Record<string, unknown> = {};
|
48
48
|
if (isSelected) {
|
49
49
|
stateProps["data-selected"] = true;
|
50
50
|
}
|
@@ -64,7 +64,7 @@ export function CalendarCell({
|
|
64
64
|
TODO: Follow up with react-spectrum to see if they can solve it on their end
|
65
65
|
*/
|
66
66
|
useEffect(() => {
|
67
|
-
|
67
|
+
ref.current?.addEventListener(
|
68
68
|
"touchend",
|
69
69
|
(event: TouchEvent) => {
|
70
70
|
event.preventDefault();
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
import { Box, useSlotRecipe } from "@chakra-ui/react";
|
4
4
|
import { endOfMonth, getWeeksInMonth } from "@internationalized/date";
|
5
|
-
import React from "react";
|
6
5
|
import { AriaCalendarGridProps, useCalendarGrid } from "react-aria";
|
7
6
|
import { CalendarState, RangeCalendarState } from "react-stately";
|
8
7
|
|
@@ -44,7 +43,9 @@ export function CalendarGrid({
|
|
44
43
|
|
45
44
|
// Get the number of weeks in the month so we can render the proper number of rows.
|
46
45
|
const weeksInMonth = getWeeksInMonth(state.visibleRange.start, locale);
|
47
|
-
const weeksInMonthRange =
|
46
|
+
const weeksInMonthRange = Array.from({ length: weeksInMonth })
|
47
|
+
.fill(0)
|
48
|
+
.map((_, i) => i);
|
48
49
|
const recipe = useSlotRecipe({
|
49
50
|
key: "datePicker",
|
50
51
|
recipe: datePickerSlotRecipe,
|
@@ -5,7 +5,6 @@ import {
|
|
5
5
|
ArrowLeftOutline24Icon,
|
6
6
|
ArrowRightOutline24Icon,
|
7
7
|
} from "@vygruppen/spor-icon-react";
|
8
|
-
import React from "react";
|
9
8
|
import { CalendarState, RangeCalendarState } from "react-stately";
|
10
9
|
|
11
10
|
import { createTexts, useTranslation } from "../i18n";
|
@@ -43,9 +42,7 @@ export function CalendarHeader({
|
|
43
42
|
return (
|
44
43
|
<Flex alignItems="center" paddingBottom="4" justifyContent="space-between">
|
45
44
|
<CalendarNavigator
|
46
|
-
title={
|
47
|
-
title ? title : isYearPickerVisible ? monthTitle : monthAndYearTitle
|
48
|
-
}
|
45
|
+
title={title || (isYearPickerVisible ? monthTitle : monthAndYearTitle)}
|
49
46
|
unit="month"
|
50
47
|
onPrevious={() =>
|
51
48
|
state.setFocusedDate(state.focusedDate.subtract({ months: 1 }))
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
import { BoxProps, PopoverAnchor, useSlotRecipe } from "@chakra-ui/react";
|
4
4
|
import { CalendarOutline24Icon } from "@vygruppen/spor-icon-react";
|
5
|
-
import
|
5
|
+
import { forwardRef, PropsWithChildren } from "react";
|
6
6
|
import { AriaButtonProps } from "react-aria";
|
7
7
|
|
8
8
|
import {
|
@@ -24,7 +24,7 @@ type CalendarTriggerButtonProps = AriaButtonProps<"button"> &
|
|
24
24
|
export const CalendarTriggerButton = forwardRef<
|
25
25
|
HTMLDivElement,
|
26
26
|
CalendarTriggerButtonProps
|
27
|
-
>(({ variant, disabled, ariaLabelledby, ...buttonProps }
|
27
|
+
>(({ variant, disabled, ariaLabelledby, ...buttonProps }) => {
|
28
28
|
const { t } = useTranslation();
|
29
29
|
const recipe = useSlotRecipe({
|
30
30
|
key: "datePicker",
|
@@ -32,8 +32,6 @@ export const CalendarTriggerButton = forwardRef<
|
|
32
32
|
});
|
33
33
|
const styles = recipe({ variant });
|
34
34
|
|
35
|
-
const { onPress, ...filteredButtonProps } = buttonProps;
|
36
|
-
|
37
35
|
return (
|
38
36
|
<PopoverAnchor {...buttonProps}>
|
39
37
|
<IconButton
|
@@ -47,6 +45,7 @@ export const CalendarTriggerButton = forwardRef<
|
|
47
45
|
</PopoverAnchor>
|
48
46
|
);
|
49
47
|
});
|
48
|
+
CalendarTriggerButton.displayName = "CalendarTriggerButton";
|
50
49
|
|
51
50
|
const texts = createTexts({
|
52
51
|
openCalendar: {
|
@@ -14,10 +14,12 @@ import { useCurrentLocale } from "./utils";
|
|
14
14
|
|
15
15
|
function createCalendar(identifier: string) {
|
16
16
|
switch (identifier) {
|
17
|
-
case "gregory":
|
17
|
+
case "gregory": {
|
18
18
|
return new GregorianCalendar();
|
19
|
-
|
19
|
+
}
|
20
|
+
default: {
|
20
21
|
throw new Error(`Unsupported calendar ${identifier}`);
|
22
|
+
}
|
21
23
|
}
|
22
24
|
}
|
23
25
|
|
@@ -85,6 +87,7 @@ export const DateField = forwardRef<HTMLDivElement, DateFieldProps>(
|
|
85
87
|
);
|
86
88
|
},
|
87
89
|
);
|
90
|
+
DateField.displayName = "DateField";
|
88
91
|
|
89
92
|
const texts = createTexts({
|
90
93
|
day: {
|
@@ -109,13 +112,17 @@ const texts = createTexts({
|
|
109
112
|
|
110
113
|
const getAriaLabel = (segmentType: DateSegment["type"]) => {
|
111
114
|
switch (segmentType) {
|
112
|
-
case "day":
|
115
|
+
case "day": {
|
113
116
|
return texts.day;
|
114
|
-
|
117
|
+
}
|
118
|
+
case "month": {
|
115
119
|
return texts.month;
|
116
|
-
|
120
|
+
}
|
121
|
+
case "year": {
|
117
122
|
return texts.year;
|
118
|
-
|
123
|
+
}
|
124
|
+
default: {
|
119
125
|
return texts.day;
|
126
|
+
}
|
120
127
|
}
|
121
128
|
};
|
@@ -52,7 +52,7 @@ type DatePickerProps = Omit<AriaDatePickerProps<DateValue>, "onChange"> &
|
|
52
52
|
/**
|
53
53
|
* A date picker component.
|
54
54
|
*
|
55
|
-
* There are three different variants
|
55
|
+
* There are three different variants –`core`, `floating` and `ghost`.
|
56
56
|
*
|
57
57
|
* ```tsx
|
58
58
|
* <DatePicker label="Dato" variant="core" />
|
@@ -171,3 +171,4 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
|
171
171
|
);
|
172
172
|
},
|
173
173
|
);
|
174
|
+
DatePicker.displayName = "DatePicker";
|
@@ -9,7 +9,7 @@ import {
|
|
9
9
|
useSlotRecipe,
|
10
10
|
} from "@chakra-ui/react";
|
11
11
|
import { DateValue } from "@internationalized/date";
|
12
|
-
import
|
12
|
+
import { PropsWithChildren, useRef } from "react";
|
13
13
|
import {
|
14
14
|
AriaDateRangePickerProps,
|
15
15
|
I18nProvider,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use client";
|
2
2
|
import { Box, useSlotRecipe } from "@chakra-ui/react";
|
3
|
-
import
|
3
|
+
import { forwardRef, PropsWithChildren, RefObject, useRef } from "react";
|
4
4
|
import { useDateSegment } from "react-aria";
|
5
5
|
import { DateFieldState, DateSegment } from "react-stately";
|
6
6
|
|
@@ -63,6 +63,7 @@ export const DateTimeSegment = forwardRef<HTMLDivElement, DateTimeSegmentProps>(
|
|
63
63
|
);
|
64
64
|
},
|
65
65
|
);
|
66
|
+
DateTimeSegment.displayName = "DateTimeSegment";
|
66
67
|
|
67
68
|
const isPaddable = (segmentType: DateSegment["type"]) =>
|
68
69
|
segmentType === "month" ||
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client";
|
2
2
|
import { Box, useSlotRecipe } from "@chakra-ui/react";
|
3
3
|
import { createCalendar, DateValue } from "@internationalized/date";
|
4
|
-
import
|
4
|
+
import { useRef } from "react";
|
5
5
|
import {
|
6
6
|
RangeCalendarProps as ReactAriaRangeCalendarProps,
|
7
7
|
useRangeCalendar,
|
@@ -5,7 +5,7 @@ import {
|
|
5
5
|
useFieldContext,
|
6
6
|
useSlotRecipe,
|
7
7
|
} from "@chakra-ui/react";
|
8
|
-
import
|
8
|
+
import { forwardRef, PropsWithChildren } from "react";
|
9
9
|
|
10
10
|
import { datePickerSlotRecipe } from "../theme/slot-recipes/datepicker";
|
11
11
|
import { DatePickerVariantProps } from "./DatePicker";
|
@@ -1,9 +1,9 @@
|
|
1
1
|
"use client";
|
2
2
|
import { Box, Flex } from "@chakra-ui/react";
|
3
3
|
import { CalendarDateTime, Time } from "@internationalized/date";
|
4
|
-
import {
|
5
|
-
import React, { useRef } from "react";
|
4
|
+
import { useRef } from "react";
|
6
5
|
import { AriaTimeFieldProps, useTimeField } from "react-aria";
|
6
|
+
import { DateSegment, TimeFieldState } from "react-stately";
|
7
7
|
|
8
8
|
import { DateTimeSegment } from "./DateTimeSegment";
|
9
9
|
import { getTimestampFromTime } from "./utils";
|
@@ -38,7 +38,7 @@ export const TimeField = ({ state, ...props }: TimeFieldProps) => {
|
|
38
38
|
{props.label}
|
39
39
|
</label>
|
40
40
|
<Flex {...fieldProps} ref={ref} paddingTop="3" paddingBottom="0.5">
|
41
|
-
{state.segments.map((segment) => (
|
41
|
+
{state.segments.map((segment: DateSegment) => (
|
42
42
|
<DateTimeSegment key={segment.type} segment={segment} state={state} />
|
43
43
|
))}
|
44
44
|
</Flex>
|
@@ -1,12 +1,11 @@
|
|
1
1
|
"use client";
|
2
|
-
import { BoxProps
|
2
|
+
import { BoxProps } from "@chakra-ui/react";
|
3
3
|
import { CalendarDateTime } from "@internationalized/date";
|
4
4
|
import { TimeValue } from "@react-types/datepicker";
|
5
5
|
import {
|
6
6
|
DropdownLeftFill18Icon,
|
7
7
|
DropdownRightFill18Icon,
|
8
8
|
} from "@vygruppen/spor-icon-react";
|
9
|
-
import React from "react";
|
10
9
|
import { useTimeFieldState } from "react-stately";
|
11
10
|
|
12
11
|
import { Field } from "@/input/Field";
|
@@ -202,3 +201,6 @@ const texts = createTexts({
|
|
202
201
|
sv: "minuter",
|
203
202
|
},
|
204
203
|
});
|
204
|
+
function useFieldContext(): { disabled: unknown; invalid: unknown } {
|
205
|
+
throw new Error("Function not implemented.");
|
206
|
+
}
|
package/src/datepicker/utils.ts
CHANGED
@@ -9,16 +9,21 @@ import { useTranslation } from "..";
|
|
9
9
|
export const useCurrentLocale = () => {
|
10
10
|
const { language } = useTranslation();
|
11
11
|
switch (language) {
|
12
|
-
case "nb":
|
12
|
+
case "nb": {
|
13
13
|
return "nb-NO";
|
14
|
-
|
14
|
+
}
|
15
|
+
case "nn": {
|
15
16
|
return "nb-NO";
|
16
|
-
|
17
|
+
}
|
18
|
+
case "sv": {
|
17
19
|
return "sv-SE";
|
18
|
-
|
20
|
+
}
|
21
|
+
case "en": {
|
19
22
|
return "en-GB";
|
20
|
-
|
23
|
+
}
|
24
|
+
default: {
|
21
25
|
return "nb-NO";
|
26
|
+
}
|
22
27
|
}
|
23
28
|
};
|
24
29
|
|