@vygruppen/spor-react 3.7.7 → 3.8.0
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 +11 -11
- package/CHANGELOG.md +13 -0
- package/dist/{CountryCodeSelect-IAYKP6P5.mjs → CountryCodeSelect-BA3A7ODU.mjs} +1 -1
- package/dist/{chunk-QJI3YQWW.mjs → chunk-HL3ESNVB.mjs} +429 -390
- package/dist/index.d.mts +64 -17
- package/dist/index.d.ts +64 -17
- package/dist/index.js +526 -487
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
- package/src/datepicker/Calendar.tsx +8 -3
- package/src/datepicker/CalendarCell.tsx +8 -3
- package/src/datepicker/CalendarGrid.tsx +9 -3
- package/src/datepicker/CalendarTriggerButton.tsx +10 -3
- package/src/datepicker/DatePicker.tsx +15 -35
- package/src/datepicker/DateRangePicker.tsx +14 -25
- package/src/datepicker/DateTimeSegment.tsx +0 -2
- package/src/datepicker/RangeCalendar.tsx +8 -4
- package/src/datepicker/StyledField.tsx +6 -1
- package/src/datepicker/TimePicker.tsx +1 -1
- package/src/input/NumericStepper.tsx +91 -68
- package/src/theme/components/close-button.ts +9 -8
- package/src/theme/components/datepicker.ts +74 -23
- package/src/theme/components/modal.ts +4 -3
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, 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, 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-HL3ESNVB.mjs';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vygruppen/spor-react",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.8.0",
|
4
4
|
"main": "./dist/index.js",
|
5
5
|
"module": "./dist/index.mjs",
|
6
6
|
"types": "./dist/index.d.ts",
|
@@ -26,7 +26,7 @@
|
|
26
26
|
"@vygruppen/spor-icon-react": "*",
|
27
27
|
"@vygruppen/spor-loader": "*",
|
28
28
|
"awesome-phonenumber": "^5.10.0",
|
29
|
-
"framer-motion": "^
|
29
|
+
"framer-motion": "^9.1.7",
|
30
30
|
"lottie-react": "^2.3.1",
|
31
31
|
"react-aria": "^3.27.0",
|
32
32
|
"react-stately": "^3.25.0",
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Box } from "@chakra-ui/react";
|
1
|
+
import { Box, ResponsiveValue } from "@chakra-ui/react";
|
2
2
|
import { createCalendar, DateValue } from "@internationalized/date";
|
3
3
|
import { useCalendarState } from "@react-stately/calendar";
|
4
4
|
import React from "react";
|
@@ -13,8 +13,13 @@ 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
21
|
};
|
17
|
-
export function Calendar({ showYearNavigation, ...props }: CalendarProps) {
|
22
|
+
export function Calendar({ showYearNavigation, variant, ...props }: CalendarProps) {
|
18
23
|
const { t } = useTranslation();
|
19
24
|
const locale = useCurrentLocale();
|
20
25
|
const state = useCalendarState({
|
@@ -32,7 +37,7 @@ export function Calendar({ showYearNavigation, ...props }: CalendarProps) {
|
|
32
37
|
return (
|
33
38
|
<Box {...calendarProps} aria-label={ariaLabel}>
|
34
39
|
<CalendarHeader state={state} showYearNavigation={showYearNavigation} />
|
35
|
-
<CalendarGrid state={state} />
|
40
|
+
<CalendarGrid variant={variant} state={state} />
|
36
41
|
</Box>
|
37
42
|
);
|
38
43
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Box, useMultiStyleConfig } from "@chakra-ui/react";
|
1
|
+
import { Box, ResponsiveValue, useMultiStyleConfig } from "@chakra-ui/react";
|
2
2
|
import {
|
3
3
|
CalendarDate,
|
4
4
|
DateValue,
|
@@ -10,11 +10,16 @@ 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
18
|
state: CalendarState | RangeCalendarState;
|
14
19
|
date: CalendarDate;
|
15
20
|
currentMonth: DateValue;
|
16
21
|
};
|
17
|
-
export function CalendarCell({ state, date, currentMonth }: CalendarCellProps) {
|
22
|
+
export function CalendarCell({ state, date, currentMonth, variant }: CalendarCellProps) {
|
18
23
|
const ref = useRef(null);
|
19
24
|
const {
|
20
25
|
cellProps,
|
@@ -26,7 +31,7 @@ export function CalendarCell({ state, date, currentMonth }: CalendarCellProps) {
|
|
26
31
|
} = useCalendarCell({ date }, state, ref);
|
27
32
|
|
28
33
|
const isOutsideMonth = !isSameMonth(currentMonth, date);
|
29
|
-
const styles = useMultiStyleConfig("Datepicker", {});
|
34
|
+
const styles = useMultiStyleConfig("Datepicker", {variant});
|
30
35
|
|
31
36
|
const stateProps: Record<string, any> = {};
|
32
37
|
if (isSelected) {
|
@@ -6,7 +6,7 @@ import { Language, useTranslation } from "../i18n";
|
|
6
6
|
import { Text } from "../typography";
|
7
7
|
import { CalendarCell } from "./CalendarCell";
|
8
8
|
import { useCurrentLocale } from "./utils";
|
9
|
-
import { useMultiStyleConfig } from "@chakra-ui/react";
|
9
|
+
import { ResponsiveValue, useMultiStyleConfig } from "@chakra-ui/react";
|
10
10
|
|
11
11
|
const weekDays: Record<Language, string[]> = {
|
12
12
|
nb: ["Ma", "Ti", "On", "To", "Fr", "Lø", "Sø"],
|
@@ -16,10 +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
24
|
state: CalendarState | RangeCalendarState;
|
20
25
|
offset?: { months?: number };
|
21
26
|
};
|
22
|
-
export function CalendarGrid({ state, offset = {} }: CalendarGridProps) {
|
27
|
+
export function CalendarGrid({ state, variant ,offset = {} }: CalendarGridProps) {
|
23
28
|
const { language } = useTranslation();
|
24
29
|
const locale = useCurrentLocale();
|
25
30
|
const startDate = state.visibleRange.start.add(offset);
|
@@ -35,7 +40,7 @@ export function CalendarGrid({ state, offset = {} }: CalendarGridProps) {
|
|
35
40
|
// Get the number of weeks in the month so we can render the proper number of rows.
|
36
41
|
const weeksInMonth = getWeeksInMonth(state.visibleRange.start, locale);
|
37
42
|
const weeksInMonthRange = new Array(weeksInMonth).fill(0).map((_, i) => i);
|
38
|
-
const styles = useMultiStyleConfig("Datepicker", {});
|
43
|
+
const styles = useMultiStyleConfig("Datepicker", {variant});
|
39
44
|
|
40
45
|
return (
|
41
46
|
<table {...gridProps}>
|
@@ -63,6 +68,7 @@ export function CalendarGrid({ state, offset = {} }: CalendarGridProps) {
|
|
63
68
|
.map((date, dayIndex) =>
|
64
69
|
date ? (
|
65
70
|
<CalendarCell
|
71
|
+
variant={variant}
|
66
72
|
key={dayIndex}
|
67
73
|
state={state}
|
68
74
|
date={date}
|
@@ -4,17 +4,24 @@ import {
|
|
4
4
|
useMultiStyleConfig,
|
5
5
|
forwardRef,
|
6
6
|
As,
|
7
|
+
ResponsiveValue,
|
7
8
|
} from "@chakra-ui/react";
|
8
9
|
import { CalendarOutline24Icon } from "@vygruppen/spor-icon-react";
|
9
10
|
import React, { useEffect } from "react";
|
10
11
|
import { AriaButtonProps } from "react-aria";
|
11
12
|
import { createTexts, useTranslation } from "..";
|
12
13
|
|
13
|
-
type CalendarTriggerButtonProps = AriaButtonProps<"button"
|
14
|
+
type CalendarTriggerButtonProps = AriaButtonProps<"button"> & {
|
15
|
+
variant: ResponsiveValue<
|
16
|
+
"base"
|
17
|
+
| "floating"
|
18
|
+
| "ghost"
|
19
|
+
>;
|
20
|
+
};
|
14
21
|
export const CalendarTriggerButton = forwardRef<CalendarTriggerButtonProps, As>(
|
15
|
-
({ ...buttonProps }, ref) => {
|
22
|
+
({ variant, ...buttonProps }, ref) => {
|
16
23
|
const { t } = useTranslation();
|
17
|
-
const styles = useMultiStyleConfig("Datepicker", {});
|
24
|
+
const styles = useMultiStyleConfig("Datepicker", {variant});
|
18
25
|
|
19
26
|
const { onPress, ...filteredButtonProps } = buttonProps;
|
20
27
|
|
@@ -17,7 +17,6 @@ import {
|
|
17
17
|
} from "@chakra-ui/react";
|
18
18
|
import { DateValue } from "@internationalized/date";
|
19
19
|
import { useDatePickerState } from "@react-stately/datepicker";
|
20
|
-
import { CalendarOutline24Icon } from "@vygruppen/spor-icon-react";
|
21
20
|
import React, { forwardRef, useRef } from "react";
|
22
21
|
import {
|
23
22
|
AriaDatePickerProps,
|
@@ -33,20 +32,22 @@ import { useCurrentLocale } from "./utils";
|
|
33
32
|
|
34
33
|
type DatePickerProps = AriaDatePickerProps<DateValue> &
|
35
34
|
Pick<BoxProps, "minHeight" | "width"> & {
|
36
|
-
variant: ResponsiveValue<"
|
35
|
+
variant: ResponsiveValue<"base" | "floating" | "ghost">;
|
37
36
|
name?: string;
|
38
37
|
showYearNavigation?: boolean;
|
39
38
|
withPortal?: boolean;
|
40
39
|
};
|
40
|
+
|
41
41
|
/**
|
42
42
|
* A date picker component.
|
43
43
|
*
|
44
|
-
* There are two versions of this component –
|
44
|
+
* There are two versions of this component – a simple one, and one with a trigger button for showing the calendar. Use whatever fits your design.
|
45
45
|
*
|
46
46
|
* ```tsx
|
47
47
|
* <DatePicker label="Dato" variant="simple" />
|
48
48
|
* ```
|
49
49
|
*/
|
50
|
+
|
50
51
|
export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
51
52
|
(
|
52
53
|
{
|
@@ -84,18 +85,11 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
|
84
85
|
ref as React.MutableRefObject<HTMLDivElement>
|
85
86
|
);
|
86
87
|
|
87
|
-
const styles = useMultiStyleConfig("Datepicker", {});
|
88
|
+
const styles = useMultiStyleConfig("Datepicker", { variant });
|
88
89
|
const locale = useCurrentLocale();
|
89
90
|
|
90
|
-
const responsiveVariant =
|
91
|
-
useBreakpointValue(typeof variant === "string" ? [variant] : variant) ??
|
92
|
-
"simple";
|
93
|
-
const hasTrigger = responsiveVariant === "with-trigger";
|
94
|
-
|
95
91
|
const onFieldClick = () => {
|
96
|
-
|
97
|
-
state.setOpen(true);
|
98
|
-
}
|
92
|
+
state.setOpen(true);
|
99
93
|
};
|
100
94
|
|
101
95
|
const popoverContent = (
|
@@ -105,6 +99,7 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
|
105
99
|
<FocusLock>
|
106
100
|
<Calendar
|
107
101
|
{...calendarProps}
|
102
|
+
variant={variant}
|
108
103
|
showYearNavigation={showYearNavigation}
|
109
104
|
/>
|
110
105
|
</FocusLock>
|
@@ -114,50 +109,35 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
|
114
109
|
|
115
110
|
return (
|
116
111
|
<I18nProvider locale={locale}>
|
117
|
-
<Box
|
118
|
-
position="relative"
|
119
|
-
display="inline-flex"
|
120
|
-
flexDirection="column"
|
121
|
-
width={width}
|
122
|
-
>
|
112
|
+
<Box position="relative" display="inline-flex" flexDirection="column" width={width}>
|
123
113
|
<Popover
|
124
114
|
{...dialogProps}
|
125
115
|
isOpen={state.isOpen}
|
126
116
|
onOpen={state.open}
|
127
117
|
onClose={state.close}
|
128
118
|
>
|
129
|
-
<InputGroup {...groupProps} display="inline-flex">
|
119
|
+
<InputGroup {...groupProps} display="inline-flex">
|
130
120
|
<PopoverAnchor>
|
131
121
|
<StyledField
|
132
|
-
variant={
|
122
|
+
variant={variant}
|
133
123
|
onClick={onFieldClick}
|
134
124
|
paddingX={3}
|
135
125
|
minHeight={minHeight}
|
136
126
|
>
|
137
|
-
|
138
|
-
<
|
139
|
-
|
127
|
+
<PopoverTrigger>
|
128
|
+
<CalendarTriggerButton variant={variant} ref={ref} {...buttonProps} />
|
129
|
+
</PopoverTrigger>
|
140
130
|
<DateField
|
141
131
|
label={props.label}
|
142
132
|
labelProps={labelProps}
|
143
133
|
name={props.name}
|
144
|
-
ref={hasTrigger ? undefined : ref}
|
145
134
|
{...fieldProps}
|
146
135
|
/>
|
147
136
|
</StyledField>
|
148
137
|
</PopoverAnchor>
|
149
|
-
{hasTrigger && (
|
150
|
-
<PopoverTrigger>
|
151
|
-
<CalendarTriggerButton ref={ref} {...buttonProps} />
|
152
|
-
</PopoverTrigger>
|
153
|
-
)}
|
154
138
|
</InputGroup>
|
155
|
-
<FormErrorMessage {...errorMessageProps}>
|
156
|
-
|
157
|
-
</FormErrorMessage>
|
158
|
-
{state.isOpen && !props.isDisabled && withPortal && (
|
159
|
-
<Portal>{popoverContent}</Portal>
|
160
|
-
)}
|
139
|
+
<FormErrorMessage {...errorMessageProps}>{errorMessage}</FormErrorMessage>
|
140
|
+
{state.isOpen && !props.isDisabled && withPortal && <Portal>{popoverContent}</Portal>}
|
161
141
|
{state.isOpen && !props.isDisabled && !withPortal && popoverContent}
|
162
142
|
</Popover>
|
163
143
|
</Box>
|
@@ -18,7 +18,6 @@ import {
|
|
18
18
|
} from "@chakra-ui/react";
|
19
19
|
import { DateValue } from "@internationalized/date";
|
20
20
|
import { useDateRangePickerState } from "@react-stately/datepicker";
|
21
|
-
import { CalendarOutline24Icon } from "@vygruppen/spor-icon-react";
|
22
21
|
import React, { useRef } from "react";
|
23
22
|
import {
|
24
23
|
AriaDateRangePickerProps,
|
@@ -37,7 +36,11 @@ type DateRangePickerProps = AriaDateRangePickerProps<DateValue> &
|
|
37
36
|
startName?: string;
|
38
37
|
endLabel?: string;
|
39
38
|
endName?: string;
|
40
|
-
variant: ResponsiveValue<
|
39
|
+
variant: ResponsiveValue<
|
40
|
+
"base"
|
41
|
+
| "floating"
|
42
|
+
| "ghost"
|
43
|
+
>;
|
41
44
|
withPortal?: boolean;
|
42
45
|
};
|
43
46
|
/**
|
@@ -75,17 +78,11 @@ export function DateRangePicker({
|
|
75
78
|
calendarProps,
|
76
79
|
} = useDateRangePicker(props, state, ref);
|
77
80
|
|
78
|
-
const
|
79
|
-
useBreakpointValue(typeof variant === "string" ? [variant] : variant) ??
|
80
|
-
"simple";
|
81
|
-
|
82
|
-
const styles = useMultiStyleConfig("Datepicker", {
|
83
|
-
variant: responsiveVariant,
|
84
|
-
});
|
81
|
+
const styles = useMultiStyleConfig("Datepicker", {variant});
|
85
82
|
const locale = useCurrentLocale();
|
86
83
|
|
87
84
|
const handleEnterClick = (e: React.KeyboardEvent) => {
|
88
|
-
if (e.key === "Enter" && !state.isOpen &&
|
85
|
+
if (e.key === "Enter" && !state.isOpen && variant === "base") {
|
89
86
|
// Don't submit the form
|
90
87
|
e.stopPropagation();
|
91
88
|
state.setOpen(true);
|
@@ -93,19 +90,15 @@ export function DateRangePicker({
|
|
93
90
|
};
|
94
91
|
|
95
92
|
const onFieldClick = () => {
|
96
|
-
if (!hasTrigger) {
|
97
93
|
state.setOpen(true);
|
98
|
-
}
|
99
94
|
};
|
100
95
|
|
101
|
-
const hasTrigger = responsiveVariant === "with-trigger";
|
102
|
-
|
103
96
|
const popoverContent = (
|
104
97
|
<PopoverContent sx={styles.calendar} boxShadow="md" maxWidth="none">
|
105
98
|
<PopoverArrow sx={styles.arrow} />
|
106
99
|
<PopoverBody>
|
107
100
|
<FocusLock>
|
108
|
-
<RangeCalendar {...calendarProps} />
|
101
|
+
<RangeCalendar variant={"base"} {...calendarProps} />
|
109
102
|
</FocusLock>
|
110
103
|
</PopoverBody>
|
111
104
|
</PopoverContent>
|
@@ -130,22 +123,23 @@ export function DateRangePicker({
|
|
130
123
|
<StyledField
|
131
124
|
alignItems="center"
|
132
125
|
paddingX={3}
|
133
|
-
variant={
|
126
|
+
variant={variant}
|
134
127
|
onClick={onFieldClick}
|
135
128
|
onKeyPress={handleEnterClick}
|
136
129
|
minHeight={minHeight}
|
137
130
|
>
|
138
|
-
{
|
139
|
-
<
|
131
|
+
{variant && (
|
132
|
+
<PopoverTrigger>
|
133
|
+
<CalendarTriggerButton paddingLeft={1} paddingRight={1} variant={variant} ref={ref} {...buttonProps} />
|
134
|
+
</PopoverTrigger>
|
140
135
|
)}
|
141
136
|
<DateField
|
142
137
|
{...startFieldProps}
|
143
138
|
name={startName}
|
144
139
|
label={props.startLabel}
|
145
|
-
ref={hasTrigger ? undefined : ref}
|
146
140
|
labelProps={labelProps}
|
147
141
|
/>
|
148
|
-
|
142
|
+
<Box as="span" aria-hidden="true" paddingRight="2">
|
149
143
|
–
|
150
144
|
</Box>
|
151
145
|
<DateField
|
@@ -156,11 +150,6 @@ export function DateRangePicker({
|
|
156
150
|
/>
|
157
151
|
</StyledField>
|
158
152
|
</PopoverAnchor>
|
159
|
-
{hasTrigger && (
|
160
|
-
<PopoverTrigger>
|
161
|
-
<CalendarTriggerButton ref={ref} {...buttonProps} />
|
162
|
-
</PopoverTrigger>
|
163
|
-
)}
|
164
153
|
</InputGroup>
|
165
154
|
{state.isOpen && withPortal && <Portal>{popoverContent}</Portal>}
|
166
155
|
{state.isOpen && !withPortal && popoverContent}
|
@@ -37,12 +37,10 @@ export const DateTimeSegment = forwardRef<HTMLDivElement, DateTimeSegmentProps>(
|
|
37
37
|
...segmentProps.style,
|
38
38
|
boxSizing: "content-box",
|
39
39
|
}}
|
40
|
-
paddingX="1px"
|
41
40
|
textAlign="center"
|
42
41
|
outline="none"
|
43
42
|
borderRadius="xs"
|
44
43
|
fontSize={["mobile.sm", "desktop.sm"]}
|
45
|
-
minWidth={isPaddable(segment.type) ? "1.3em" : "auto"}
|
46
44
|
sx={styles.dateTimeSegment}
|
47
45
|
_focus={{
|
48
46
|
backgroundColor: "darkTeal",
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Box } from "@chakra-ui/react";
|
1
|
+
import { Box, ResponsiveValue, useMultiStyleConfig } from "@chakra-ui/react";
|
2
2
|
import { createCalendar, DateValue } from "@internationalized/date";
|
3
3
|
import { useRangeCalendarState } from "@react-stately/calendar";
|
4
4
|
import React, { useRef } from "react";
|
@@ -10,7 +10,10 @@ import { CalendarGrid } from "./CalendarGrid";
|
|
10
10
|
import { CalendarHeader } from "./CalendarHeader";
|
11
11
|
import { useCurrentLocale } from "./utils";
|
12
12
|
|
13
|
-
type RangeCalendarProps = ReactAriaRangeCalendarProps<DateValue
|
13
|
+
type RangeCalendarProps = ReactAriaRangeCalendarProps<DateValue> & {
|
14
|
+
variant: ResponsiveValue<"base" | "floating" | "ghost">;
|
15
|
+
};
|
16
|
+
|
14
17
|
export function RangeCalendar(props: RangeCalendarProps) {
|
15
18
|
const locale = useCurrentLocale();
|
16
19
|
const state = useRangeCalendarState({
|
@@ -23,12 +26,13 @@ export function RangeCalendar(props: RangeCalendarProps) {
|
|
23
26
|
const ref = useRef(null);
|
24
27
|
const { calendarProps, title } = useRangeCalendar(props, state, ref);
|
25
28
|
|
29
|
+
|
26
30
|
return (
|
27
31
|
<Box {...calendarProps} ref={ref}>
|
28
32
|
<CalendarHeader state={state} title={title} />
|
29
33
|
<Box display="flex" gap="8">
|
30
|
-
<CalendarGrid state={state} />
|
31
|
-
<CalendarGrid state={state} offset={{ months: 1 }} />
|
34
|
+
<CalendarGrid variant={props.variant} state={state} />
|
35
|
+
<CalendarGrid variant={props.variant} state={state} offset={{ months: 1 }} />
|
32
36
|
</Box>
|
33
37
|
</Box>
|
34
38
|
);
|
@@ -2,6 +2,7 @@ import {
|
|
2
2
|
As,
|
3
3
|
Box,
|
4
4
|
BoxProps,
|
5
|
+
ResponsiveValue,
|
5
6
|
forwardRef,
|
6
7
|
useFormControlContext,
|
7
8
|
useMultiStyleConfig,
|
@@ -9,7 +10,11 @@ import {
|
|
9
10
|
import React from "react";
|
10
11
|
|
11
12
|
type StyledFieldProps = BoxProps & {
|
12
|
-
variant:
|
13
|
+
variant: ResponsiveValue<
|
14
|
+
"base"
|
15
|
+
| "floating"
|
16
|
+
| "ghost"
|
17
|
+
>;
|
13
18
|
};
|
14
19
|
export const StyledField = forwardRef<StyledFieldProps, As>(
|
15
20
|
({ children, variant, ...otherProps }, ref) => {
|