@vygruppen/spor-react 4.0.3 → 4.1.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 +9 -11
- package/CHANGELOG.md +26 -0
- package/dist/{CountryCodeSelect-RUH47EQH.mjs → CountryCodeSelect-7MAIS4VT.mjs} +1 -1
- package/dist/{chunk-XT6QVKN5.mjs → chunk-U2IWIWOD.mjs} +152 -1953
- package/dist/index.d.mts +17 -93
- package/dist/index.d.ts +17 -93
- package/dist/index.js +151 -1980
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
- package/src/accordion/Accordion.test.tsx +1 -1
- package/src/accordion/Accordion.tsx +1 -1
- package/src/accordion/AccordionContext.tsx +1 -1
- package/src/accordion/Expandable.tsx +6 -6
- package/src/alert/BaseAlert.test.tsx +5 -5
- package/src/alert/BaseAlert.tsx +5 -1
- package/src/alert/ClosableAlert.test.tsx +3 -3
- package/src/alert/ExpandableAlert.test.tsx +5 -5
- package/src/button/Button.test.tsx +1 -1
- package/src/button/Button.tsx +1 -1
- package/src/button/CloseButton.tsx +1 -1
- package/src/button/FloatingActionButton.tsx +5 -5
- package/src/button/IconButton.tsx +1 -1
- package/src/card/Card.tsx +3 -2
- package/src/card/index.tsx +1 -1
- package/src/datepicker/Calendar.tsx +9 -9
- package/src/datepicker/CalendarCell.tsx +9 -8
- package/src/datepicker/CalendarGrid.tsx +9 -9
- package/src/datepicker/CalendarHeader.tsx +2 -2
- package/src/datepicker/CalendarTriggerButton.tsx +5 -10
- package/src/datepicker/DateField.tsx +3 -3
- package/src/datepicker/DatePicker.tsx +6 -6
- package/src/datepicker/DateRangePicker.tsx +1 -1
- package/src/datepicker/DateTimeSegment.tsx +2 -2
- package/src/datepicker/RangeCalendar.tsx +8 -5
- package/src/datepicker/StyledField.tsx +2 -6
- package/src/datepicker/TimePicker.test.tsx +4 -4
- package/src/datepicker/TimePicker.tsx +5 -5
- package/src/index.tsx +0 -1
- package/src/input/CardSelect.tsx +3 -3
- package/src/input/Combobox.tsx +1 -1
- package/src/input/CountryCodeSelect.tsx +1 -1
- package/src/input/FormErrorMessage.tsx +1 -1
- package/src/input/InfoSelect.tsx +1 -1
- package/src/input/Input.tsx +1 -1
- package/src/input/InputElement.tsx +2 -2
- package/src/input/ListBox.tsx +3 -3
- package/src/input/NativeSelect.tsx +1 -1
- package/src/input/PasswordInput.tsx +1 -1
- package/src/input/PhoneNumberInput.tsx +13 -4
- package/src/input/Popover.tsx +4 -4
- package/src/input/RadioGroup.tsx +1 -1
- package/src/input/SearchInput.tsx +1 -1
- package/src/input/Switch.tsx +1 -1
- package/src/layout/Stack.tsx +1 -1
- package/src/linjetag/TravelTag.tsx +2 -2
- package/src/link/TextLink.tsx +1 -1
- package/src/list/index.tsx +0 -1
- package/src/loader/DarkSpinner.tsx +2 -4
- package/src/loader/SkeletonText.tsx +6 -3
- package/src/loader/useRotatingLabel.tsx +2 -2
- package/src/media-controller/index.test.tsx +6 -6
- package/src/modal/Drawer.tsx +2 -4
- package/src/modal/ModalHeader.tsx +1 -1
- package/src/provider/index.tsx +1 -1
- package/src/stepper/Stepper.tsx +10 -6
- package/src/stepper/StepperContext.tsx +7 -7
- package/src/stepper/StepperStep.tsx +56 -16
- package/src/theme/components/button.ts +25 -44
- package/src/theme/components/card.ts +7 -1
- package/src/theme/components/close-button.ts +3 -1
- package/src/theme/components/datepicker.ts +2 -2
- package/src/theme/components/divider.ts +17 -17
- package/src/theme/components/fab.ts +16 -13
- package/src/theme/components/info-tag.ts +7 -8
- package/src/theme/components/input.ts +4 -2
- package/src/theme/components/line-icon.ts +1 -2
- package/src/theme/components/media-controller-button.ts +1 -1
- package/src/theme/components/popover.ts +1 -2
- package/src/theme/components/select.ts +4 -4
- package/src/theme/components/stepper.ts +8 -155
- package/src/theme/components/switch.ts +9 -9
- package/src/theme/components/table.ts +3 -3
- package/src/theme/components/tabs.ts +24 -18
- package/src/theme/components/textarea.ts +1 -1
- package/src/theme/components/travel-tag.ts +2 -2
- package/src/theme/foundations/spacing.ts +1 -1
- package/src/theme/foundations/styles.ts +10 -10
- package/src/theme/utils/box-shadow-utils.ts +2 -2
- package/src/toast/ActionToast.test.tsx +1 -1
- package/src/toast/BaseToast.test.tsx +3 -3
- package/src/toast/ClosableToast.test.tsx +1 -1
- package/src/toast/index.tsx +1 -1
- package/src/toast/useToast.tsx +3 -3
- package/src/typography/Badge.tsx +1 -1
- package/src/typography/Text.tsx +1 -1
- package/tsconfig.json +1 -1
package/dist/index.mjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export { Accordion, AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, AttachedInputs, Badge, Box, Breadcrumb, BreadcrumbItem, BreadcrumbLink, Button, ButtonGroup, Card, CardSelect, Center, Checkbox, CheckboxGroup, ChoiceChip, ClosableAlert, CloseButton, Code, Collapse, ColorInlineLoader, ColorSpinner, Combobox, Container, ContentLoader, DarkFullScreenLoader, DarkInlineLoader, DarkMode, DarkSpinner, DatePicker, DateRangePicker, Divider, Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerFooter, ModalHeader as DrawerHeader, DrawerOverlay, Expandable, ExpandableAlert, ExpandableItem, Fade, Flex, FloatingActionButton, FormControl, FormErrorMessage, FormHelperText, FormLabel, Grid, GridItem, HStack, Heading, IconButton, Image, Img, InfoSelect, InfoTag, Input, InputGroup, InputLeftElement, InputRightElement, Item, ItemDescription, ItemLabel, JumpButton, Language, LanguageProvider, LightFullScreenLoader, LightInlineLoader, LightMode, LightSpinner, LineIcon, ListBox, ListItem, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, NativeSelect, NumericStepper, OrderedList, PasswordInput, PhoneNumberInput, PlayPauseButton, Popover, PopoverAnchor, PopoverArrow, PopoverBody, PopoverCloseButton, PopoverContent, PopoverFooter, PopoverHeader, PopoverTrigger, PopoverWizardBody, Portal, ProgressBar, ProgressLoader, Radio, RadioGroup, ScaleFade, SearchInput, Section, SimpleDrawer, SimpleGrid, SimplePopover, Skeleton, SkeletonCircle, SkeletonText, SkipButton, Slide, SlideFade, Spacer, SporProvider, Stack, StaticAlert, Stepper, StepperStep, Switch, Tab, TabList, TabPanel, TabPanels, Table, TableCaption, Tabs, Tbody, Td, Text, TextLink, Textarea, Tfoot, Th, Thead, Time, TimePicker, Tr, TravelTag, UnorderedList, VStack, VyLogo, WizardPopover, Wrap, WrapItem, createTexts, extendTheme, fontFaces, theme, tokens, useBreakpointValue, useClipboard, useColorMode, useColorModePreference, useColorModeValue, useControllableProp, useDisclosure, useMediaQuery, useMergeRefs, useOutsideClick, usePrefersReducedMotion, useTheme, useToast, useToken, useTranslation } from './chunk-
|
1
|
+
export { Accordion, AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, AttachedInputs, Badge, Box, Breadcrumb, BreadcrumbItem, BreadcrumbLink, Button, ButtonGroup, Card, CardSelect, Center, Checkbox, CheckboxGroup, ChoiceChip, ClosableAlert, CloseButton, Code, Collapse, ColorInlineLoader, ColorSpinner, Combobox, Container, ContentLoader, DarkFullScreenLoader, DarkInlineLoader, DarkMode, DarkSpinner, DatePicker, DateRangePicker, Divider, Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerFooter, ModalHeader as DrawerHeader, DrawerOverlay, Expandable, ExpandableAlert, ExpandableItem, Fade, Flex, FloatingActionButton, FormControl, FormErrorMessage, FormHelperText, FormLabel, Grid, GridItem, HStack, Heading, IconButton, Image, Img, InfoSelect, InfoTag, Input, InputGroup, InputLeftElement, InputRightElement, Item, ItemDescription, ItemLabel, JumpButton, Language, LanguageProvider, LightFullScreenLoader, LightInlineLoader, LightMode, LightSpinner, LineIcon, ListBox, ListItem, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, NativeSelect, NumericStepper, OrderedList, PasswordInput, PhoneNumberInput, PlayPauseButton, Popover, PopoverAnchor, PopoverArrow, PopoverBody, PopoverCloseButton, PopoverContent, PopoverFooter, PopoverHeader, PopoverTrigger, PopoverWizardBody, Portal, ProgressBar, ProgressLoader, Radio, RadioGroup, ScaleFade, SearchInput, Section, SimpleDrawer, SimpleGrid, SimplePopover, Skeleton, SkeletonCircle, SkeletonText, SkipButton, Slide, SlideFade, Spacer, SporProvider, Stack, StaticAlert, Stepper, StepperStep, Switch, Tab, TabList, TabPanel, TabPanels, Table, TableCaption, Tabs, Tbody, Td, Text, TextLink, Textarea, Tfoot, Th, Thead, Time, TimePicker, Tr, TravelTag, UnorderedList, VStack, VyLogo, WizardPopover, Wrap, WrapItem, createTexts, extendTheme, fontFaces, theme, tokens, useBreakpointValue, useClipboard, useColorMode, useColorModePreference, useColorModeValue, useControllableProp, useDisclosure, useMediaQuery, useMergeRefs, useOutsideClick, usePrefersReducedMotion, useTheme, useToast, useToken, useTranslation } from './chunk-U2IWIWOD.mjs';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vygruppen/spor-react",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.1.1",
|
4
4
|
"main": "./dist/index.js",
|
5
5
|
"module": "./dist/index.mjs",
|
6
6
|
"types": "./dist/index.d.ts",
|
@@ -28,8 +28,8 @@
|
|
28
28
|
"awesome-phonenumber": "^5.10.0",
|
29
29
|
"framer-motion": "^9.1.7",
|
30
30
|
"lottie-react": "^2.3.1",
|
31
|
-
"react-aria": "^3.
|
32
|
-
"react-stately": "^3.
|
31
|
+
"react-aria": "^3.30.0",
|
32
|
+
"react-stately": "^3.28.0",
|
33
33
|
"react-swipeable": "^7.0.0"
|
34
34
|
},
|
35
35
|
"devDependencies": {
|
@@ -9,7 +9,7 @@ describe("<Accordion />", () => {
|
|
9
9
|
const { container, getByRole } = render(
|
10
10
|
<Accordion>
|
11
11
|
<ExpandableItem title="Title">Content</ExpandableItem>
|
12
|
-
</Accordion
|
12
|
+
</Accordion>,
|
13
13
|
);
|
14
14
|
await act(async () => {
|
15
15
|
expect(await axe(container)).toHaveNoViolations();
|
@@ -20,7 +20,7 @@ export const useAccordionContext = () => {
|
|
20
20
|
const context = React.useContext(AccordionContext);
|
21
21
|
if (context === null) {
|
22
22
|
throw new Error(
|
23
|
-
"useAccordionContext must be used within AccordionProvider"
|
23
|
+
"useAccordionContext must be used within AccordionProvider",
|
24
24
|
);
|
25
25
|
}
|
26
26
|
return context;
|
@@ -131,8 +131,8 @@ const warnAboutMismatchingIcon = ({ icon, size }: WarnAboutMismatchingIcon) => {
|
|
131
131
|
console.warn(
|
132
132
|
`You passed a filled icon. This component requires outlined icons. You passed ${displayName}, replace it with ${displayName.replace(
|
133
133
|
"Fill",
|
134
|
-
"Outline"
|
135
|
-
)}
|
134
|
+
"Outline",
|
135
|
+
)}.`,
|
136
136
|
);
|
137
137
|
return;
|
138
138
|
}
|
@@ -140,8 +140,8 @@ const warnAboutMismatchingIcon = ({ icon, size }: WarnAboutMismatchingIcon) => {
|
|
140
140
|
console.warn(
|
141
141
|
`The icon you passed was of the wrong size for the lg size. You passed ${displayName}, replace it with ${displayName.replace(
|
142
142
|
/(\d{2})Icon/,
|
143
|
-
"30Icon"
|
144
|
-
)}
|
143
|
+
"30Icon",
|
144
|
+
)}.`,
|
145
145
|
);
|
146
146
|
return;
|
147
147
|
}
|
@@ -149,8 +149,8 @@ const warnAboutMismatchingIcon = ({ icon, size }: WarnAboutMismatchingIcon) => {
|
|
149
149
|
console.warn(
|
150
150
|
`The icon you passed was of the wrong size for the ${size} size. You passed ${displayName}, replace it with ${displayName.replace(
|
151
151
|
/(\d{2})Icon/,
|
152
|
-
"24Icon"
|
153
|
-
)}
|
152
|
+
"24Icon",
|
153
|
+
)}.`,
|
154
154
|
);
|
155
155
|
}
|
156
156
|
}
|
@@ -6,31 +6,31 @@ import { BaseAlert } from "./BaseAlert";
|
|
6
6
|
describe("<BaseAlert />", () => {
|
7
7
|
it("is accessible as variant='success'", async () => {
|
8
8
|
const { container } = render(
|
9
|
-
<BaseAlert variant="success">Test text</BaseAlert
|
9
|
+
<BaseAlert variant="success">Test text</BaseAlert>,
|
10
10
|
);
|
11
11
|
expect(await axe(container)).toHaveNoViolations();
|
12
12
|
});
|
13
13
|
it("is accessible as variant='info'", async () => {
|
14
14
|
const { container } = render(
|
15
|
-
<BaseAlert variant="info">Test text</BaseAlert
|
15
|
+
<BaseAlert variant="info">Test text</BaseAlert>,
|
16
16
|
);
|
17
17
|
expect(await axe(container)).toHaveNoViolations();
|
18
18
|
});
|
19
19
|
it("is accessible as variant='warning'", async () => {
|
20
20
|
const { container } = render(
|
21
|
-
<BaseAlert variant="warning">Test text</BaseAlert
|
21
|
+
<BaseAlert variant="warning">Test text</BaseAlert>,
|
22
22
|
);
|
23
23
|
expect(await axe(container)).toHaveNoViolations();
|
24
24
|
});
|
25
25
|
it("is accessible as variant='error'", async () => {
|
26
26
|
const { container } = render(
|
27
|
-
<BaseAlert variant="error">Test text</BaseAlert
|
27
|
+
<BaseAlert variant="error">Test text</BaseAlert>,
|
28
28
|
);
|
29
29
|
expect(await axe(container)).toHaveNoViolations();
|
30
30
|
});
|
31
31
|
it("is accessible as variant='alt-transport'", async () => {
|
32
32
|
const { container } = render(
|
33
|
-
<BaseAlert variant="alt-transport">Test text</BaseAlert
|
33
|
+
<BaseAlert variant="alt-transport">Test text</BaseAlert>,
|
34
34
|
);
|
35
35
|
expect(await axe(container)).toHaveNoViolations();
|
36
36
|
});
|
package/src/alert/BaseAlert.tsx
CHANGED
@@ -11,7 +11,11 @@ export type BaseAlertProps = BoxProps & {
|
|
11
11
|
/**
|
12
12
|
* A base alert box component. Should only be composed by other alert components.
|
13
13
|
*/
|
14
|
-
export const BaseAlert = ({
|
14
|
+
export const BaseAlert = ({
|
15
|
+
variant,
|
16
|
+
children,
|
17
|
+
...boxProps
|
18
|
+
}: BaseAlertProps) => {
|
15
19
|
const styles = useMultiStyleConfig("Alert", { variant });
|
16
20
|
return (
|
17
21
|
<Box __css={styles.container} {...boxProps}>
|
@@ -7,7 +7,7 @@ import { ClosableAlert } from ".";
|
|
7
7
|
describe("<ClosableAlert />", () => {
|
8
8
|
it("closes when you click the close button", async () => {
|
9
9
|
const { getByRole, queryByRole } = render(
|
10
|
-
<ClosableAlert variant="info">Test text</ClosableAlert
|
10
|
+
<ClosableAlert variant="info">Test text</ClosableAlert>,
|
11
11
|
);
|
12
12
|
act(() => {
|
13
13
|
getByRole("button").click();
|
@@ -20,7 +20,7 @@ describe("<ClosableAlert />", () => {
|
|
20
20
|
const { getByRole } = render(
|
21
21
|
<ClosableAlert variant="info" onClose={handleClick}>
|
22
22
|
Test text
|
23
|
-
</ClosableAlert
|
23
|
+
</ClosableAlert>,
|
24
24
|
);
|
25
25
|
act(() => {
|
26
26
|
getByRole("button").click();
|
@@ -30,7 +30,7 @@ describe("<ClosableAlert />", () => {
|
|
30
30
|
|
31
31
|
it("is accessible", async () => {
|
32
32
|
const { container } = render(
|
33
|
-
<ClosableAlert variant="info">Test text</ClosableAlert
|
33
|
+
<ClosableAlert variant="info">Test text</ClosableAlert>,
|
34
34
|
);
|
35
35
|
expect(await axe(container)).toHaveNoViolations();
|
36
36
|
});
|
@@ -9,7 +9,7 @@ describe("<ExpandableAlert />", () => {
|
|
9
9
|
const { getByRole, getByText } = render(
|
10
10
|
<ExpandableAlert variant="info" title="Title">
|
11
11
|
Test text
|
12
|
-
</ExpandableAlert
|
12
|
+
</ExpandableAlert>,
|
13
13
|
);
|
14
14
|
await waitFor(() => expect(getByText("Test text")).not.toBeVisible());
|
15
15
|
act(() => {
|
@@ -27,7 +27,7 @@ describe("<ExpandableAlert />", () => {
|
|
27
27
|
const { getByRole } = render(
|
28
28
|
<ExpandableAlert variant="info" title="Title" onToggle={handleClick}>
|
29
29
|
Test text
|
30
|
-
</ExpandableAlert
|
30
|
+
</ExpandableAlert>,
|
31
31
|
);
|
32
32
|
|
33
33
|
act(() => {
|
@@ -47,13 +47,13 @@ describe("<ExpandableAlert />", () => {
|
|
47
47
|
const { queryByRole, rerender } = render(
|
48
48
|
<ExpandableAlert variant="info" title="Title" headingLevel="h2">
|
49
49
|
Test text
|
50
|
-
</ExpandableAlert
|
50
|
+
</ExpandableAlert>,
|
51
51
|
);
|
52
52
|
expect(queryByRole("heading", { level: 2 })).toBeInTheDocument();
|
53
53
|
rerender(
|
54
54
|
<ExpandableAlert variant="info" title="Title" headingLevel="h3">
|
55
55
|
Test text
|
56
|
-
</ExpandableAlert
|
56
|
+
</ExpandableAlert>,
|
57
57
|
);
|
58
58
|
expect(queryByRole("heading", { level: 2 })).not.toBeInTheDocument();
|
59
59
|
expect(queryByRole("heading", { level: 3 })).toBeInTheDocument();
|
@@ -63,7 +63,7 @@ describe("<ExpandableAlert />", () => {
|
|
63
63
|
const { container, getByRole } = render(
|
64
64
|
<ExpandableAlert variant="info" title="Title">
|
65
65
|
Test text
|
66
|
-
</ExpandableAlert
|
66
|
+
</ExpandableAlert>,
|
67
67
|
);
|
68
68
|
await act(async () => {
|
69
69
|
expect(await axe(container)).toHaveNoViolations();
|
package/src/button/Button.tsx
CHANGED
@@ -44,10 +44,10 @@ export const FloatingActionButton = forwardRef<
|
|
44
44
|
placement = "bottom right",
|
45
45
|
...props
|
46
46
|
},
|
47
|
-
ref
|
47
|
+
ref,
|
48
48
|
) => {
|
49
49
|
const [isTextVisible, setIsTextVisible] = React.useState(
|
50
|
-
externalIsTextVisible !== undefined ? externalIsTextVisible : false
|
50
|
+
externalIsTextVisible !== undefined ? externalIsTextVisible : false,
|
51
51
|
);
|
52
52
|
const scrollDirection = useScrollDirection();
|
53
53
|
useEffect(() => {
|
@@ -56,7 +56,7 @@ export const FloatingActionButton = forwardRef<
|
|
56
56
|
}
|
57
57
|
const id = window.setTimeout(
|
58
58
|
() => setIsTextVisible(scrollDirection !== "down"),
|
59
|
-
1000
|
59
|
+
1000,
|
60
60
|
);
|
61
61
|
return () => window.clearTimeout(id);
|
62
62
|
}, [scrollDirection, externalIsTextVisible]);
|
@@ -99,7 +99,7 @@ export const FloatingActionButton = forwardRef<
|
|
99
99
|
</MotionBox>
|
100
100
|
</MotionBox>
|
101
101
|
);
|
102
|
-
}
|
102
|
+
},
|
103
103
|
);
|
104
104
|
|
105
105
|
type ScrollDirection = "up" | "down" | null;
|
@@ -107,7 +107,7 @@ const useScrollDirection = () => {
|
|
107
107
|
const [scrollDirection, setScrollDirection] =
|
108
108
|
React.useState<ScrollDirection>(null);
|
109
109
|
const lastScrollPosition = React.useRef(
|
110
|
-
typeof window !== "undefined" ? window.scrollY : 0
|
110
|
+
typeof window !== "undefined" ? window.scrollY : 0,
|
111
111
|
);
|
112
112
|
React.useEffect(() => {
|
113
113
|
const onScroll = () => {
|
package/src/card/Card.tsx
CHANGED
@@ -12,7 +12,8 @@ export type CardProps = Exclude<BoxProps, "size"> & {
|
|
12
12
|
| "green"
|
13
13
|
| "teal"
|
14
14
|
| "yellow"
|
15
|
-
| "orange"
|
15
|
+
| "orange"
|
16
|
+
| "red";
|
16
17
|
};
|
17
18
|
/**
|
18
19
|
* Renders a card.
|
@@ -55,5 +56,5 @@ export const Card = forwardRef<CardProps, As>(
|
|
55
56
|
{children}
|
56
57
|
</Box>
|
57
58
|
);
|
58
|
-
}
|
59
|
+
},
|
59
60
|
);
|
package/src/card/index.tsx
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export * from "./Card";
|
1
|
+
export * from "./Card";
|
@@ -1,25 +1,25 @@
|
|
1
1
|
import { Box, ResponsiveValue } from "@chakra-ui/react";
|
2
|
-
import {
|
3
|
-
import { useCalendarState } from "@react-stately/calendar";
|
2
|
+
import { DateValue, createCalendar } from "@internationalized/date";
|
4
3
|
import React from "react";
|
5
4
|
import {
|
6
5
|
CalendarProps as ReactAriaCalendarProps,
|
7
6
|
useCalendar,
|
8
7
|
} from "react-aria";
|
8
|
+
import { useCalendarState } from "react-stately";
|
9
|
+
import { createTexts, useTranslation } from "../i18n";
|
9
10
|
import { CalendarGrid } from "./CalendarGrid";
|
10
11
|
import { CalendarHeader } from "./CalendarHeader";
|
11
12
|
import { useCurrentLocale } from "./utils";
|
12
|
-
import { createTexts, useTranslation } from "../i18n";
|
13
13
|
|
14
14
|
type CalendarProps = ReactAriaCalendarProps<DateValue> & {
|
15
15
|
showYearNavigation?: boolean;
|
16
|
-
variant: ResponsiveValue<
|
17
|
-
"base"
|
18
|
-
| "floating"
|
19
|
-
| "ghost"
|
20
|
-
>;
|
16
|
+
variant: ResponsiveValue<"base" | "floating" | "ghost">;
|
21
17
|
};
|
22
|
-
export function Calendar({
|
18
|
+
export function Calendar({
|
19
|
+
showYearNavigation,
|
20
|
+
variant,
|
21
|
+
...props
|
22
|
+
}: CalendarProps) {
|
23
23
|
const { t } = useTranslation();
|
24
24
|
const locale = useCurrentLocale();
|
25
25
|
const state = useCalendarState({
|
@@ -10,16 +10,17 @@ import { useCalendarCell } from "react-aria";
|
|
10
10
|
import { CalendarState, RangeCalendarState } from "react-stately";
|
11
11
|
|
12
12
|
type CalendarCellProps = {
|
13
|
-
variant: ResponsiveValue<
|
14
|
-
"base"
|
15
|
-
| "floating"
|
16
|
-
| "ghost"
|
17
|
-
>;
|
13
|
+
variant: ResponsiveValue<"base" | "floating" | "ghost">;
|
18
14
|
state: CalendarState | RangeCalendarState;
|
19
15
|
date: CalendarDate;
|
20
16
|
currentMonth: DateValue;
|
21
17
|
};
|
22
|
-
export function CalendarCell({
|
18
|
+
export function CalendarCell({
|
19
|
+
state,
|
20
|
+
date,
|
21
|
+
currentMonth,
|
22
|
+
variant,
|
23
|
+
}: CalendarCellProps) {
|
23
24
|
const ref = useRef(null);
|
24
25
|
const {
|
25
26
|
cellProps,
|
@@ -31,7 +32,7 @@ export function CalendarCell({ state, date, currentMonth, variant }: CalendarCel
|
|
31
32
|
} = useCalendarCell({ date }, state, ref);
|
32
33
|
|
33
34
|
const isOutsideMonth = !isSameMonth(currentMonth, date);
|
34
|
-
const styles = useMultiStyleConfig("Datepicker", {variant});
|
35
|
+
const styles = useMultiStyleConfig("Datepicker", { variant });
|
35
36
|
|
36
37
|
const stateProps: Record<string, any> = {};
|
37
38
|
if (isSelected) {
|
@@ -58,7 +59,7 @@ export function CalendarCell({ state, date, currentMonth, variant }: CalendarCel
|
|
58
59
|
(event: TouchEvent) => {
|
59
60
|
event.preventDefault();
|
60
61
|
},
|
61
|
-
{ passive: false, once: true }
|
62
|
+
{ passive: false, once: true },
|
62
63
|
);
|
63
64
|
}, []);
|
64
65
|
|
@@ -16,15 +16,15 @@ const weekDays: Record<Language, string[]> = {
|
|
16
16
|
};
|
17
17
|
|
18
18
|
type CalendarGridProps = AriaCalendarGridProps & {
|
19
|
-
variant: ResponsiveValue<
|
20
|
-
"base"
|
21
|
-
| "floating"
|
22
|
-
| "ghost"
|
23
|
-
>;
|
19
|
+
variant: ResponsiveValue<"base" | "floating" | "ghost">;
|
24
20
|
state: CalendarState | RangeCalendarState;
|
25
21
|
offset?: { months?: number };
|
26
22
|
};
|
27
|
-
export function CalendarGrid({
|
23
|
+
export function CalendarGrid({
|
24
|
+
state,
|
25
|
+
variant,
|
26
|
+
offset = {},
|
27
|
+
}: CalendarGridProps) {
|
28
28
|
const { language } = useTranslation();
|
29
29
|
const locale = useCurrentLocale();
|
30
30
|
const startDate = state.visibleRange.start.add(offset);
|
@@ -34,13 +34,13 @@ export function CalendarGrid({ state, variant ,offset = {} }: CalendarGridProps)
|
|
34
34
|
startDate,
|
35
35
|
endDate,
|
36
36
|
},
|
37
|
-
state
|
37
|
+
state,
|
38
38
|
);
|
39
39
|
|
40
40
|
// Get the number of weeks in the month so we can render the proper number of rows.
|
41
41
|
const weeksInMonth = getWeeksInMonth(state.visibleRange.start, locale);
|
42
42
|
const weeksInMonthRange = new Array(weeksInMonth).fill(0).map((_, i) => i);
|
43
|
-
const styles = useMultiStyleConfig("Datepicker", {variant});
|
43
|
+
const styles = useMultiStyleConfig("Datepicker", { variant });
|
44
44
|
|
45
45
|
return (
|
46
46
|
<table {...gridProps}>
|
@@ -76,7 +76,7 @@ export function CalendarGrid({ state, variant ,offset = {} }: CalendarGridProps)
|
|
76
76
|
/>
|
77
77
|
) : (
|
78
78
|
<td key={dayIndex} />
|
79
|
-
)
|
79
|
+
),
|
80
80
|
)}
|
81
81
|
</tr>
|
82
82
|
))}
|
@@ -31,10 +31,10 @@ export function CalendarHeader({
|
|
31
31
|
const monthAndYearTitle = `${monthTitle} ${state.focusedDate.year}`;
|
32
32
|
|
33
33
|
const isPreviousYearDisabled = state.isInvalid(
|
34
|
-
state.visibleRange.start.subtract({ years: 1 })
|
34
|
+
state.visibleRange.start.subtract({ years: 1 }),
|
35
35
|
);
|
36
36
|
const isNextYearDisabled = state.isInvalid(
|
37
|
-
state.visibleRange.start.add({ years: 1 })
|
37
|
+
state.visibleRange.start.add({ years: 1 }),
|
38
38
|
);
|
39
39
|
const areAllOtherYearsDisabled = isPreviousYearDisabled && isNextYearDisabled;
|
40
40
|
const isYearPickerVisible = showYearNavigation && !areAllOtherYearsDisabled;
|
@@ -12,25 +12,20 @@ import { AriaButtonProps } from "react-aria";
|
|
12
12
|
import { createTexts, useTranslation } from "..";
|
13
13
|
|
14
14
|
type CalendarTriggerButtonProps = AriaButtonProps<"button"> & {
|
15
|
-
variant: ResponsiveValue<
|
16
|
-
"base"
|
17
|
-
| "floating"
|
18
|
-
| "ghost"
|
19
|
-
>;
|
15
|
+
variant: ResponsiveValue<"base" | "floating" | "ghost">;
|
20
16
|
};
|
21
17
|
export const CalendarTriggerButton = forwardRef<CalendarTriggerButtonProps, As>(
|
22
18
|
({ variant, ...buttonProps }, ref) => {
|
23
19
|
const { t } = useTranslation();
|
24
|
-
const styles = useMultiStyleConfig("Datepicker", {variant});
|
20
|
+
const styles = useMultiStyleConfig("Datepicker", { variant });
|
25
21
|
|
26
22
|
const { onPress, ...filteredButtonProps } = buttonProps;
|
27
23
|
|
28
24
|
const handleOnPress = (event: KeyboardEvent) => {
|
29
25
|
if (onPress) {
|
30
|
-
if (event.key == "Enter" || event.key == " ")
|
31
|
-
onPress(event as any)
|
26
|
+
if (event.key == "Enter" || event.key == " ") onPress(event as any);
|
32
27
|
}
|
33
|
-
}
|
28
|
+
};
|
34
29
|
|
35
30
|
return (
|
36
31
|
<PopoverAnchor>
|
@@ -47,7 +42,7 @@ export const CalendarTriggerButton = forwardRef<CalendarTriggerButtonProps, As>(
|
|
47
42
|
</Box>
|
48
43
|
</PopoverAnchor>
|
49
44
|
);
|
50
|
-
}
|
45
|
+
},
|
51
46
|
);
|
52
47
|
|
53
48
|
const texts = createTexts({
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { Box, Flex, FormLabel, useMultiStyleConfig } from "@chakra-ui/react";
|
2
2
|
import { DateValue, GregorianCalendar } from "@internationalized/date";
|
3
|
-
import { useDateFieldState } from "@react-stately/datepicker";
|
4
3
|
import { DOMAttributes, FocusableElement } from "@react-types/shared";
|
5
4
|
import React, { RefObject, forwardRef, useRef } from "react";
|
6
5
|
import { AriaDateFieldProps, useDateField } from "react-aria";
|
6
|
+
import { useDateFieldState } from "react-stately";
|
7
7
|
import { DateTimeSegment } from "./DateTimeSegment";
|
8
8
|
import { useCurrentLocale } from "./utils";
|
9
9
|
|
@@ -36,7 +36,7 @@ export const DateField = forwardRef<HTMLDivElement, DateFieldProps>(
|
|
36
36
|
const { fieldProps, labelProps } = useDateField(
|
37
37
|
props,
|
38
38
|
state,
|
39
|
-
ref as RefObject<HTMLDivElement
|
39
|
+
ref as RefObject<HTMLDivElement>,
|
40
40
|
);
|
41
41
|
|
42
42
|
return (
|
@@ -69,5 +69,5 @@ export const DateField = forwardRef<HTMLDivElement, DateFieldProps>(
|
|
69
69
|
/>
|
70
70
|
</Box>
|
71
71
|
);
|
72
|
-
}
|
72
|
+
},
|
73
73
|
);
|
@@ -15,9 +15,9 @@ import {
|
|
15
15
|
useMultiStyleConfig,
|
16
16
|
} from "@chakra-ui/react";
|
17
17
|
import { DateValue } from "@internationalized/date";
|
18
|
-
import {
|
19
|
-
import React, { forwardRef, useRef } from "react";
|
18
|
+
import React, { ReactNode, forwardRef, useRef } from "react";
|
20
19
|
import { AriaDatePickerProps, I18nProvider, useDatePicker } from "react-aria";
|
20
|
+
import { useDatePickerState } from "react-stately";
|
21
21
|
import { FormErrorMessage } from "..";
|
22
22
|
import { Calendar } from "./Calendar";
|
23
23
|
import { CalendarTriggerButton } from "./CalendarTriggerButton";
|
@@ -54,7 +54,7 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
|
54
54
|
width = "auto",
|
55
55
|
...props
|
56
56
|
},
|
57
|
-
externalRef
|
57
|
+
externalRef,
|
58
58
|
) => {
|
59
59
|
const formControlProps = useFormControlContext();
|
60
60
|
const state = useDatePickerState({
|
@@ -77,7 +77,7 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
|
77
77
|
} = useDatePicker(
|
78
78
|
props,
|
79
79
|
state,
|
80
|
-
ref as React.MutableRefObject<HTMLDivElement
|
80
|
+
ref as React.MutableRefObject<HTMLDivElement>,
|
81
81
|
);
|
82
82
|
|
83
83
|
const styles = useMultiStyleConfig("Datepicker", { variant });
|
@@ -141,7 +141,7 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
|
141
141
|
</PopoverAnchor>
|
142
142
|
</InputGroup>
|
143
143
|
<FormErrorMessage {...errorMessageProps}>
|
144
|
-
{errorMessage}
|
144
|
+
{errorMessage as ReactNode}
|
145
145
|
</FormErrorMessage>
|
146
146
|
{state.isOpen && !props.isDisabled && withPortal && (
|
147
147
|
<Portal>{popoverContent}</Portal>
|
@@ -151,5 +151,5 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
|
151
151
|
</Box>
|
152
152
|
</I18nProvider>
|
153
153
|
);
|
154
|
-
}
|
154
|
+
},
|
155
155
|
);
|
@@ -16,13 +16,13 @@ import {
|
|
16
16
|
useMultiStyleConfig,
|
17
17
|
} from "@chakra-ui/react";
|
18
18
|
import { DateValue } from "@internationalized/date";
|
19
|
-
import { useDateRangePickerState } from "@react-stately/datepicker";
|
20
19
|
import React, { useRef } from "react";
|
21
20
|
import {
|
22
21
|
AriaDateRangePickerProps,
|
23
22
|
I18nProvider,
|
24
23
|
useDateRangePicker,
|
25
24
|
} from "react-aria";
|
25
|
+
import { useDateRangePickerState } from "react-stately";
|
26
26
|
import { CalendarTriggerButton } from "./CalendarTriggerButton";
|
27
27
|
import { DateField } from "./DateField";
|
28
28
|
import { RangeCalendar } from "./RangeCalendar";
|
@@ -22,7 +22,7 @@ export const DateTimeSegment = forwardRef<HTMLDivElement, DateTimeSegmentProps>(
|
|
22
22
|
const { segmentProps } = useDateSegment(
|
23
23
|
segment,
|
24
24
|
state,
|
25
|
-
ref as RefObject<HTMLDivElement
|
25
|
+
ref as RefObject<HTMLDivElement>,
|
26
26
|
);
|
27
27
|
|
28
28
|
const styles = useMultiStyleConfig("Datepicker", {
|
@@ -52,7 +52,7 @@ export const DateTimeSegment = forwardRef<HTMLDivElement, DateTimeSegmentProps>(
|
|
52
52
|
: segment.text}
|
53
53
|
</Box>
|
54
54
|
);
|
55
|
-
}
|
55
|
+
},
|
56
56
|
);
|
57
57
|
|
58
58
|
const isPaddable = (segmentType: DateSegment["type"]) =>
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import { Box, ResponsiveValue
|
2
|
-
import {
|
3
|
-
import { useRangeCalendarState } from "@react-stately/calendar";
|
1
|
+
import { Box, ResponsiveValue } from "@chakra-ui/react";
|
2
|
+
import { DateValue, createCalendar } from "@internationalized/date";
|
4
3
|
import React, { useRef } from "react";
|
5
4
|
import {
|
6
5
|
RangeCalendarProps as ReactAriaRangeCalendarProps,
|
7
6
|
useRangeCalendar,
|
8
7
|
} from "react-aria";
|
8
|
+
import { useRangeCalendarState } from "react-stately";
|
9
9
|
import { CalendarGrid } from "./CalendarGrid";
|
10
10
|
import { CalendarHeader } from "./CalendarHeader";
|
11
11
|
import { useCurrentLocale } from "./utils";
|
@@ -26,13 +26,16 @@ export function RangeCalendar(props: RangeCalendarProps) {
|
|
26
26
|
const ref = useRef(null);
|
27
27
|
const { calendarProps, title } = useRangeCalendar(props, state, ref);
|
28
28
|
|
29
|
-
|
30
29
|
return (
|
31
30
|
<Box {...calendarProps} ref={ref}>
|
32
31
|
<CalendarHeader state={state} title={title} />
|
33
32
|
<Box display="flex" gap="8">
|
34
33
|
<CalendarGrid variant={props.variant} state={state} />
|
35
|
-
<CalendarGrid
|
34
|
+
<CalendarGrid
|
35
|
+
variant={props.variant}
|
36
|
+
state={state}
|
37
|
+
offset={{ months: 1 }}
|
38
|
+
/>
|
36
39
|
</Box>
|
37
40
|
</Box>
|
38
41
|
);
|
@@ -10,11 +10,7 @@ import {
|
|
10
10
|
import React from "react";
|
11
11
|
|
12
12
|
type StyledFieldProps = BoxProps & {
|
13
|
-
variant: ResponsiveValue<
|
14
|
-
"base"
|
15
|
-
| "floating"
|
16
|
-
| "ghost"
|
17
|
-
>;
|
13
|
+
variant: ResponsiveValue<"base" | "floating" | "ghost">;
|
18
14
|
};
|
19
15
|
export const StyledField = forwardRef<StyledFieldProps, As>(
|
20
16
|
({ children, variant, ...otherProps }, ref) => {
|
@@ -32,5 +28,5 @@ export const StyledField = forwardRef<StyledFieldProps, As>(
|
|
32
28
|
{children}
|
33
29
|
</Box>
|
34
30
|
);
|
35
|
-
}
|
31
|
+
},
|
36
32
|
);
|