@vygruppen/spor-react 2.2.1 → 2.3.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 +11 -0
- package/dist/{CountryCodeSelect-GRUCXLDJ.mjs → CountryCodeSelect-B2GP2C3U.mjs} +93 -92
- package/dist/{chunk-JG5DQFJS.mjs → chunk-NYC3Z75S.mjs} +1103 -724
- package/dist/index.d.ts +152 -74
- package/dist/index.js +1412 -1015
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/datepicker/CalendarGrid.tsx +14 -10
- package/src/datepicker/DatePicker.tsx +5 -2
- package/src/datepicker/DateRangePicker.tsx +2 -3
- package/src/datepicker/DateTimeSegment.tsx +8 -8
- package/src/input/Counter.tsx +238 -0
- package/src/input/index.tsx +1 -0
- package/src/theme/components/button.ts +11 -11
- package/src/theme/components/datepicker.ts +53 -26
- package/src/theme/components/tabs.ts +1 -0
package/dist/index.mjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export { Accordion, AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, AttachedInputs, Badge, Box, Button, ButtonGroup, Card, CardSelect, Center, Checkbox, CheckboxGroup, ChoiceChip, ClosableAlert, CloseButton, Code, Collapse, ColorInlineLoader, ColorSpinner, 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, JumpButton, Language, LanguageProvider, LightFullScreenLoader, LightInlineLoader, LightMode, LightSpinner, LineIcon, ListBox, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, NativeSelect, PasswordInput, PhoneNumberInput, PlayPauseButton, Popover, PopoverAnchor, PopoverArrow, PopoverBody, PopoverCloseButton, PopoverContent, PopoverFooter, PopoverHeader, PopoverTrigger, PopoverWizardBody, ProgressBar, ProgressLoader, Radio, RadioGroup, ScaleFade, SearchInput, Item as SelectItem, SelectItemDescription, SelectItemLabel, 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, 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, Button, ButtonGroup, Card, CardSelect, Center, Checkbox, CheckboxGroup, ChoiceChip, ClosableAlert, CloseButton, Code, Collapse, ColorInlineLoader, ColorSpinner, Container, ContentLoader, Counter, 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, JumpButton, Language, LanguageProvider, LightFullScreenLoader, LightInlineLoader, LightMode, LightSpinner, LineIcon, ListBox, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, NativeSelect, PasswordInput, PhoneNumberInput, PlayPauseButton, Popover, PopoverAnchor, PopoverArrow, PopoverBody, PopoverCloseButton, PopoverContent, PopoverFooter, PopoverHeader, PopoverTrigger, PopoverWizardBody, ProgressBar, ProgressLoader, Radio, RadioGroup, ScaleFade, SearchInput, Item as SelectItem, SelectItemDescription, SelectItemLabel, 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, 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-NYC3Z75S.mjs';
|
package/package.json
CHANGED
@@ -6,6 +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
10
|
|
10
11
|
const weekDays: Record<Language, string[]> = {
|
11
12
|
nb: ["Ma", "Ti", "On", "To", "Fr", "Lø", "Sø"],
|
@@ -34,21 +35,24 @@ export function CalendarGrid({ state, offset = {} }: CalendarGridProps) {
|
|
34
35
|
// Get the number of weeks in the month so we can render the proper number of rows.
|
35
36
|
const weeksInMonth = getWeeksInMonth(state.visibleRange.start, locale);
|
36
37
|
const weeksInMonthRange = new Array(weeksInMonth).fill(0).map((_, i) => i);
|
38
|
+
const styles = useMultiStyleConfig("Datepicker", {});
|
37
39
|
|
38
40
|
return (
|
39
41
|
<table {...gridProps}>
|
40
42
|
<thead {...headerProps}>
|
41
43
|
<tr>
|
42
|
-
{weekDays[language].map((day, index) =>
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
44
|
+
{weekDays[language].map((day, index) => {
|
45
|
+
return (
|
46
|
+
<Text
|
47
|
+
as="th"
|
48
|
+
key={index}
|
49
|
+
sx={index < 5 ? styles.weekdays : styles.weekend}
|
50
|
+
variant="sm"
|
51
|
+
>
|
52
|
+
{day}
|
53
|
+
</Text>
|
54
|
+
);
|
55
|
+
})}
|
52
56
|
</tr>
|
53
57
|
</thead>
|
54
58
|
<tbody>
|
@@ -11,6 +11,7 @@ import {
|
|
11
11
|
ResponsiveValue,
|
12
12
|
useBreakpointValue,
|
13
13
|
useFormControlContext,
|
14
|
+
useMultiStyleConfig,
|
14
15
|
} from "@chakra-ui/react";
|
15
16
|
import { DateValue } from "@internationalized/date";
|
16
17
|
import { useDatePickerState } from "@react-stately/datepicker";
|
@@ -87,6 +88,8 @@ export function DatePicker({
|
|
87
88
|
|
88
89
|
const hasTrigger = responsiveVariant === "with-trigger";
|
89
90
|
|
91
|
+
const styles = useMultiStyleConfig("Datepicker", {});
|
92
|
+
|
90
93
|
return (
|
91
94
|
<I18nProvider locale={locale}>
|
92
95
|
<Box position="relative" display="inline-flex" flexDirection="column">
|
@@ -132,11 +135,11 @@ export function DatePicker({
|
|
132
135
|
{state.isOpen && !props.isDisabled && (
|
133
136
|
<Portal>
|
134
137
|
<PopoverContent
|
135
|
-
backgroundColor="white"
|
136
138
|
color="darkGrey"
|
137
139
|
boxShadow="md"
|
140
|
+
sx={styles.calendar}
|
138
141
|
>
|
139
|
-
<PopoverArrow
|
142
|
+
<PopoverArrow sx={styles.arrow} />
|
140
143
|
<PopoverBody>
|
141
144
|
<Calendar
|
142
145
|
{...calendarProps}
|
@@ -152,12 +152,11 @@ export function DateRangePicker({
|
|
152
152
|
{state.isOpen && (
|
153
153
|
<Portal>
|
154
154
|
<PopoverContent
|
155
|
-
|
156
|
-
color="darkGrey"
|
155
|
+
sx={styles.calendar}
|
157
156
|
boxShadow="md"
|
158
157
|
maxWidth="none"
|
159
158
|
>
|
160
|
-
<PopoverArrow
|
159
|
+
<PopoverArrow sx={styles.arrow} />
|
161
160
|
<PopoverBody>
|
162
161
|
<RangeCalendar {...calendarProps} />
|
163
162
|
</PopoverBody>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Box } from "@chakra-ui/react";
|
1
|
+
import { Box, useMultiStyleConfig } from "@chakra-ui/react";
|
2
2
|
import React, { useRef } from "react";
|
3
3
|
import { useDateSegment } from "react-aria";
|
4
4
|
import { DateFieldState, DateSegment } from "react-stately";
|
@@ -18,6 +18,12 @@ export const DateTimeSegment = ({ segment, state }: DateTimeSegmentProps) => {
|
|
18
18
|
const ref = useRef(null);
|
19
19
|
|
20
20
|
const { segmentProps } = useDateSegment(segment, state, ref);
|
21
|
+
|
22
|
+
const styles = useMultiStyleConfig("Datepicker", {
|
23
|
+
isPlaceholder: segment.isPlaceholder,
|
24
|
+
isEditable: segment.isEditable,
|
25
|
+
});
|
26
|
+
|
21
27
|
return (
|
22
28
|
<Box
|
23
29
|
{...segmentProps}
|
@@ -32,13 +38,7 @@ export const DateTimeSegment = ({ segment, state }: DateTimeSegmentProps) => {
|
|
32
38
|
outline="none"
|
33
39
|
borderRadius="xs"
|
34
40
|
fontSize="mobile.md"
|
35
|
-
|
36
|
-
segment.isPlaceholder
|
37
|
-
? "dimGrey"
|
38
|
-
: segment.isEditable
|
39
|
-
? "darkGrey"
|
40
|
-
: "osloGrey"
|
41
|
-
}
|
41
|
+
sx={styles.dateTimeSegment}
|
42
42
|
_focus={{
|
43
43
|
backgroundColor: "darkTeal",
|
44
44
|
color: "white",
|
@@ -0,0 +1,238 @@
|
|
1
|
+
import {
|
2
|
+
chakra,
|
3
|
+
useColorModeValue,
|
4
|
+
useControllableState,
|
5
|
+
useFormControl,
|
6
|
+
} from "@chakra-ui/react";
|
7
|
+
import React from "react";
|
8
|
+
import {
|
9
|
+
Box,
|
10
|
+
BoxProps,
|
11
|
+
Flex,
|
12
|
+
IconButton,
|
13
|
+
createTexts,
|
14
|
+
useTranslation,
|
15
|
+
} from "..";
|
16
|
+
import { getBoxShadowString } from "../theme/utils/box-shadow-utils";
|
17
|
+
import { focusVisible } from "../theme/utils/focus-utils";
|
18
|
+
|
19
|
+
type CounterProps = {
|
20
|
+
/** The name of the input field */
|
21
|
+
name?: string;
|
22
|
+
/** The current value */
|
23
|
+
value?: number;
|
24
|
+
/** A default value, if uncontrolled */
|
25
|
+
defaultValue?: number;
|
26
|
+
/** Callback for when the value changes */
|
27
|
+
onChange?: (value: number) => void;
|
28
|
+
/** Optional minimum value. Defaults to 0 */
|
29
|
+
minValue?: number;
|
30
|
+
/** Optional maximum value. Defaults to 99 */
|
31
|
+
maxValue?: number;
|
32
|
+
/** Whether the counter is disabled or not */
|
33
|
+
isDisabled?: boolean;
|
34
|
+
} & BoxProps;
|
35
|
+
/** A simple counter component
|
36
|
+
*
|
37
|
+
* Allows you to choose a given integer value, like for example the number of
|
38
|
+
* adults on your journey.
|
39
|
+
*
|
40
|
+
* ```tsx
|
41
|
+
* <Counter value={value} onChange={setValue} />
|
42
|
+
* ```
|
43
|
+
*
|
44
|
+
* You can also set a minimum and/or maximum value:
|
45
|
+
*
|
46
|
+
* ```tsx
|
47
|
+
* <Counter value={value} onChange={setValue} minValue={1} maxValue={10} />
|
48
|
+
* ```
|
49
|
+
*
|
50
|
+
* You can use the Counter inside of a FormControl component to get IDs etc linked up automatically:
|
51
|
+
*
|
52
|
+
* ```tsx
|
53
|
+
* <FormControl>
|
54
|
+
* <FormLabel>Number of adults</FormLabel>
|
55
|
+
* <Counter />
|
56
|
+
* </FormControl>
|
57
|
+
* ```
|
58
|
+
*/
|
59
|
+
export function Counter({
|
60
|
+
name: nameProp,
|
61
|
+
id: idProp,
|
62
|
+
value: valueProp,
|
63
|
+
defaultValue = 1,
|
64
|
+
onChange: onChangeProp,
|
65
|
+
minValue = 0,
|
66
|
+
maxValue = 99,
|
67
|
+
isDisabled,
|
68
|
+
...boxProps
|
69
|
+
}: CounterProps) {
|
70
|
+
const { t } = useTranslation();
|
71
|
+
const [value, onChange] = useControllableState<number>({
|
72
|
+
value: valueProp,
|
73
|
+
onChange: onChangeProp,
|
74
|
+
defaultValue,
|
75
|
+
});
|
76
|
+
const formControlProps = useFormControl({ id: idProp, isDisabled });
|
77
|
+
const textColor = useColorModeValue("darkGrey", "white");
|
78
|
+
const backgroundColor = useColorModeValue("white", "darkGrey");
|
79
|
+
const focusColor = useColorModeValue("greenHaze", "azure");
|
80
|
+
|
81
|
+
return (
|
82
|
+
<Flex alignItems="center" {...boxProps}>
|
83
|
+
<VerySmallButton
|
84
|
+
icon={<SubtractIcon color="white" />}
|
85
|
+
aria-label={t(texts.decrementButtonAriaLabel)}
|
86
|
+
onClick={() => onChange(value - 1)}
|
87
|
+
visibility={value <= minValue ? "hidden" : "visible"}
|
88
|
+
isDisabled={formControlProps.disabled}
|
89
|
+
/>
|
90
|
+
<chakra.input
|
91
|
+
type="number"
|
92
|
+
min={minValue}
|
93
|
+
max={maxValue}
|
94
|
+
name={nameProp}
|
95
|
+
value={value}
|
96
|
+
{...formControlProps}
|
97
|
+
fontSize="sm"
|
98
|
+
fontWeight="bold"
|
99
|
+
width="3ch"
|
100
|
+
marginX={1}
|
101
|
+
paddingX={1}
|
102
|
+
borderRadius="xs"
|
103
|
+
textAlign="center"
|
104
|
+
backgroundColor={backgroundColor}
|
105
|
+
color={textColor}
|
106
|
+
transition="all .1s ease-out"
|
107
|
+
_hover={{
|
108
|
+
boxShadow: getBoxShadowString({
|
109
|
+
borderColor: "currentColor",
|
110
|
+
borderWidth: 1,
|
111
|
+
}),
|
112
|
+
_disabled: {
|
113
|
+
boxShadow: "none",
|
114
|
+
},
|
115
|
+
}}
|
116
|
+
_disabled={{
|
117
|
+
opacity: 0.5,
|
118
|
+
}}
|
119
|
+
_focus={{
|
120
|
+
outline: "none",
|
121
|
+
boxShadow: getBoxShadowString({
|
122
|
+
borderColor: focusColor,
|
123
|
+
borderWidth: 1,
|
124
|
+
}),
|
125
|
+
}}
|
126
|
+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
127
|
+
const numericInput = Number(e.target.value);
|
128
|
+
if (Number.isNaN(numericInput)) {
|
129
|
+
return;
|
130
|
+
}
|
131
|
+
onChange(numericInput);
|
132
|
+
}}
|
133
|
+
/>
|
134
|
+
<VerySmallButton
|
135
|
+
icon={<AddIcon color="white" />}
|
136
|
+
aria-label={t(texts.incrementButtonAriaLabel)}
|
137
|
+
onClick={() => onChange(value + 1)}
|
138
|
+
visibility={value >= maxValue ? "hidden" : "visible"}
|
139
|
+
isDisabled={formControlProps.disabled}
|
140
|
+
/>
|
141
|
+
</Flex>
|
142
|
+
);
|
143
|
+
}
|
144
|
+
|
145
|
+
type VerySmallButtonProps = {
|
146
|
+
/** The icon to render */
|
147
|
+
icon: React.ReactElement;
|
148
|
+
/** Accessible label for the icon */
|
149
|
+
"aria-label": string;
|
150
|
+
/** Callback for when the button is clicked */
|
151
|
+
onClick: () => void;
|
152
|
+
/** Whether or not the button is hidden */
|
153
|
+
visibility?: "visible" | "hidden";
|
154
|
+
/** Whether or not the button is disabled */
|
155
|
+
isDisabled?: boolean;
|
156
|
+
};
|
157
|
+
/** Internal override for extra small icon buttons */
|
158
|
+
const VerySmallButton = (props: VerySmallButtonProps) => {
|
159
|
+
return (
|
160
|
+
<IconButton
|
161
|
+
variant="primary"
|
162
|
+
size="xs"
|
163
|
+
minWidth="24px"
|
164
|
+
minHeight="24px"
|
165
|
+
sx={focusVisible({
|
166
|
+
notFocus: { boxShadow: "none" },
|
167
|
+
focus: {
|
168
|
+
boxShadow:
|
169
|
+
"inset 0 0 0 2px var(--spor-colors-pine), inset 0 0 0 3px white",
|
170
|
+
},
|
171
|
+
})}
|
172
|
+
{...props}
|
173
|
+
/>
|
174
|
+
);
|
175
|
+
};
|
176
|
+
|
177
|
+
const SubtractIcon = (props: BoxProps) => (
|
178
|
+
<Box
|
179
|
+
as="svg"
|
180
|
+
viewBox="0 0 30 30"
|
181
|
+
width="24"
|
182
|
+
height="24"
|
183
|
+
stroke="currentColor"
|
184
|
+
{...props}
|
185
|
+
>
|
186
|
+
<line
|
187
|
+
x1="9"
|
188
|
+
y1="15"
|
189
|
+
x2="21"
|
190
|
+
y2="15"
|
191
|
+
strokeWidth="1.5"
|
192
|
+
strokeLinecap="round"
|
193
|
+
/>
|
194
|
+
</Box>
|
195
|
+
);
|
196
|
+
|
197
|
+
const AddIcon = (props: BoxProps) => (
|
198
|
+
<Box
|
199
|
+
as="svg"
|
200
|
+
viewBox="0 0 30 30"
|
201
|
+
width="24"
|
202
|
+
height="24"
|
203
|
+
stroke="currentColor"
|
204
|
+
{...props}
|
205
|
+
>
|
206
|
+
<line
|
207
|
+
x1="9"
|
208
|
+
y1="15"
|
209
|
+
x2="21"
|
210
|
+
y2="15"
|
211
|
+
strokeWidth="1.5"
|
212
|
+
strokeLinecap="round"
|
213
|
+
/>
|
214
|
+
<line
|
215
|
+
x1="15"
|
216
|
+
y1="9"
|
217
|
+
x2="15"
|
218
|
+
y2="21"
|
219
|
+
strokeWidth="1.5"
|
220
|
+
strokeLinecap="round"
|
221
|
+
/>
|
222
|
+
</Box>
|
223
|
+
);
|
224
|
+
|
225
|
+
const texts = createTexts({
|
226
|
+
decrementButtonAriaLabel: {
|
227
|
+
nb: "Trekk fra 1",
|
228
|
+
en: "Subtract 1",
|
229
|
+
nn: "Trekk frå 1",
|
230
|
+
sv: "Subtrahera 1",
|
231
|
+
},
|
232
|
+
incrementButtonAriaLabel: {
|
233
|
+
nb: "Legg til 1",
|
234
|
+
en: "Add 1",
|
235
|
+
nn: "Legg til 1",
|
236
|
+
sv: "Lägg till 1",
|
237
|
+
},
|
238
|
+
});
|
package/src/input/index.tsx
CHANGED
@@ -96,14 +96,14 @@ const config = defineStyleConfig({
|
|
96
96
|
backgroundColor: "lightGrey",
|
97
97
|
},
|
98
98
|
},
|
99
|
-
additional: (
|
99
|
+
additional: (props) => ({
|
100
100
|
backgroundColor: "transparent",
|
101
|
-
color: mode("darkGrey", "white")(
|
101
|
+
color: mode("darkGrey", "white")(props),
|
102
102
|
fontWeight: "normal",
|
103
103
|
boxShadow: `inset 0 0 0 1px ${mode(
|
104
104
|
colors.blackAlpha[400],
|
105
105
|
colors.whiteAlpha[400]
|
106
|
-
)(
|
106
|
+
)(props)}`,
|
107
107
|
...focusVisible({
|
108
108
|
focus: {
|
109
109
|
boxShadow: getBoxShadowString({
|
@@ -115,7 +115,7 @@ const config = defineStyleConfig({
|
|
115
115
|
boxShadow: `inset 0 0 0 1px ${mode(
|
116
116
|
colors.blackAlpha[400],
|
117
117
|
colors.whiteAlpha[400]
|
118
|
-
)(
|
118
|
+
)(props)}`,
|
119
119
|
},
|
120
120
|
}),
|
121
121
|
_hover: {
|
@@ -125,18 +125,18 @@ const config = defineStyleConfig({
|
|
125
125
|
boxShadow: `inset 0 0 0 1px ${mode(
|
126
126
|
colors.blackAlpha[400],
|
127
127
|
colors.whiteAlpha[300]
|
128
|
-
)(
|
129
|
-
backgroundColor: mode("mint",
|
128
|
+
)(props)}`,
|
129
|
+
backgroundColor: mode("mint", "whiteAlpha.300")(props),
|
130
130
|
},
|
131
131
|
}),
|
132
|
-
ghost: () => ({
|
132
|
+
ghost: (props) => ({
|
133
133
|
backgroundColor: "transparent",
|
134
|
-
color: "darkGrey",
|
134
|
+
color: mode("darkGrey", "white")(props),
|
135
135
|
fontWeight: "normal",
|
136
136
|
...focusVisible({
|
137
137
|
focus: {
|
138
138
|
boxShadow: getBoxShadowString({
|
139
|
-
borderColor: "greenHaze",
|
139
|
+
borderColor: mode("greenHaze", "azure")(props),
|
140
140
|
borderWidth: 2,
|
141
141
|
}),
|
142
142
|
},
|
@@ -145,13 +145,13 @@ const config = defineStyleConfig({
|
|
145
145
|
},
|
146
146
|
}),
|
147
147
|
_hover: {
|
148
|
-
backgroundColor: "seaMist",
|
148
|
+
backgroundColor: mode("seaMist", "pine")(props),
|
149
149
|
_disabled: {
|
150
150
|
color: "blackAlpha.300",
|
151
151
|
},
|
152
152
|
},
|
153
153
|
_active: {
|
154
|
-
backgroundColor: "mint",
|
154
|
+
backgroundColor: mode("mint", "whiteAlpha.300")(props),
|
155
155
|
},
|
156
156
|
}),
|
157
157
|
floating: {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { createMultiStyleConfigHelpers } from "@chakra-ui/react";
|
2
|
-
import { anatomy } from "@chakra-ui/theme-tools";
|
2
|
+
import { anatomy, cssVar, mode } from "@chakra-ui/theme-tools";
|
3
3
|
import { colors, zIndices } from "../foundations";
|
4
4
|
import { getBoxShadowString } from "../utils/box-shadow-utils";
|
5
5
|
import { focusVisible } from "../utils/focus-utils";
|
@@ -7,18 +7,25 @@ import { focusVisible } from "../utils/focus-utils";
|
|
7
7
|
const parts = anatomy("datepicker").parts(
|
8
8
|
"wrapper",
|
9
9
|
"calendarTriggerButton",
|
10
|
+
"arrow",
|
11
|
+
"calendar",
|
12
|
+
"weekdays",
|
13
|
+
"weekend",
|
10
14
|
"dateCell",
|
11
|
-
"inputLabel"
|
15
|
+
"inputLabel",
|
16
|
+
"dateTimeSegment"
|
12
17
|
);
|
13
18
|
|
19
|
+
const $arrowBackground = cssVar("popper-arrow-bg");
|
20
|
+
|
14
21
|
const helpers = createMultiStyleConfigHelpers(parts.keys);
|
15
22
|
|
16
23
|
const config = helpers.defineMultiStyleConfig({
|
17
|
-
baseStyle: {
|
24
|
+
baseStyle: (props) => ({
|
18
25
|
wrapper: {
|
19
|
-
backgroundColor: "white",
|
26
|
+
backgroundColor: mode("white", "night")(props),
|
20
27
|
boxShadow: getBoxShadowString({
|
21
|
-
borderColor:
|
28
|
+
borderColor: mode("blackAlpha.400", "whiteAlpha.400")(props),
|
22
29
|
}),
|
23
30
|
transitionProperty: "box-shadow",
|
24
31
|
transitionDuration: "fast",
|
@@ -28,14 +35,14 @@ const config = helpers.defineMultiStyleConfig({
|
|
28
35
|
alignItems: "center",
|
29
36
|
_hover: {
|
30
37
|
boxShadow: getBoxShadowString({
|
31
|
-
borderColor: "darkGrey",
|
38
|
+
borderColor: mode("darkGrey", "white")(props),
|
32
39
|
borderWidth: 2,
|
33
40
|
}),
|
34
41
|
zIndex: zIndices.docked,
|
35
42
|
},
|
36
43
|
_focusWithin: {
|
37
44
|
boxShadow: getBoxShadowString({
|
38
|
-
borderColor: "greenHaze",
|
45
|
+
borderColor: mode("greenHaze", "azure")(props),
|
39
46
|
borderWidth: 2,
|
40
47
|
}),
|
41
48
|
},
|
@@ -48,12 +55,12 @@ const config = helpers.defineMultiStyleConfig({
|
|
48
55
|
_disabled: {
|
49
56
|
pointerEvents: "none",
|
50
57
|
boxShadow: getBoxShadowString({
|
51
|
-
borderColor: "osloGrey",
|
58
|
+
borderColor: mode("osloGrey", "whiteAlpha.400")(props),
|
52
59
|
borderWidth: 1,
|
53
60
|
}),
|
54
61
|
_focus: {
|
55
62
|
boxShadow: getBoxShadowString({
|
56
|
-
borderColor: "osloGrey",
|
63
|
+
borderColor: mode("osloGrey", "whiteAlpha.400")(props),
|
57
64
|
borderWidth: 1,
|
58
65
|
}),
|
59
66
|
},
|
@@ -61,13 +68,20 @@ const config = helpers.defineMultiStyleConfig({
|
|
61
68
|
},
|
62
69
|
inputLabel: {
|
63
70
|
fontSize: "mobile.xs",
|
64
|
-
color: "darkGrey",
|
71
|
+
color: mode("darkGrey", "white")(props),
|
65
72
|
margin: 0,
|
66
73
|
},
|
74
|
+
dateTimeSegment: {
|
75
|
+
color: mode(
|
76
|
+
props.isPlaceholder ? "dimGrey" : props.isEditable ? "darkGrey" : "osloGrey",
|
77
|
+
props.isPlaceholder ? "whiteAlpha.400" : "white"
|
78
|
+
)(props),
|
79
|
+
},
|
67
80
|
calendarTriggerButton: {
|
81
|
+
backgroundColor: mode("white", "night")(props),
|
68
82
|
boxShadow: `${getBoxShadowString({
|
69
|
-
borderColor:
|
70
|
-
})}, inset 1px 0 0 1px white`, // to make the shadow colors not multiply
|
83
|
+
borderColor: mode("blackAlpha.400", "whiteAlpha.400")(props),
|
84
|
+
})}, inset 1px 0 0 1px ${mode("white", colors.night)(props)}`, // to make the shadow colors not multiply
|
71
85
|
width: 8,
|
72
86
|
display: "flex",
|
73
87
|
alignItems: "center",
|
@@ -80,24 +94,24 @@ const config = helpers.defineMultiStyleConfig({
|
|
80
94
|
|
81
95
|
_hover: {
|
82
96
|
boxShadow: `${getBoxShadowString({
|
83
|
-
borderColor: "darkGrey",
|
97
|
+
borderColor: mode("darkGrey", "white")(props),
|
84
98
|
borderWidth: 2,
|
85
|
-
})}, inset 2px 0 0 2px white`,
|
99
|
+
})}, inset 2px 0 0 2px ${mode("white", colors.night)(props)}`,
|
86
100
|
},
|
87
101
|
_active: {
|
88
|
-
backgroundColor: "mint",
|
102
|
+
backgroundColor: mode("mint", "azure")(props),
|
89
103
|
},
|
90
104
|
...focusVisible({
|
91
105
|
focus: {
|
92
106
|
outline: "none",
|
93
107
|
boxShadow: getBoxShadowString({
|
94
|
-
borderColor: "greenHaze",
|
108
|
+
borderColor: mode("greenHaze", "azure")(props),
|
95
109
|
borderWidth: 2,
|
96
110
|
}),
|
97
111
|
},
|
98
112
|
notFocus: {
|
99
113
|
boxShadow: getBoxShadowString({
|
100
|
-
borderColor: "darkGrey",
|
114
|
+
borderColor: mode("darkGrey", "white")(props),
|
101
115
|
borderWidth: 1,
|
102
116
|
}),
|
103
117
|
},
|
@@ -109,9 +123,22 @@ const config = helpers.defineMultiStyleConfig({
|
|
109
123
|
}),
|
110
124
|
},
|
111
125
|
},
|
126
|
+
arrow: {
|
127
|
+
[$arrowBackground.variable]: mode("white", colors.night)(props)
|
128
|
+
},
|
129
|
+
calendar: {
|
130
|
+
backgroundColor: mode("white", "night")(props),
|
131
|
+
color: mode("darkGrey", "white")(props)
|
132
|
+
},
|
133
|
+
weekdays: {
|
134
|
+
color: mode("darkGrey", "white")(props),
|
135
|
+
},
|
136
|
+
weekend: {
|
137
|
+
color: mode("greenHaze", "azure")(props),
|
138
|
+
},
|
112
139
|
dateCell: {
|
113
|
-
backgroundColor: "white",
|
114
|
-
color: "darkGrey",
|
140
|
+
backgroundColor: mode("white", "night")(props),
|
141
|
+
color: mode("darkGrey", "white")(props),
|
115
142
|
borderRadius: "50%",
|
116
143
|
position: "relative",
|
117
144
|
transition: ".1s ease-in-out",
|
@@ -122,14 +149,14 @@ const config = helpers.defineMultiStyleConfig({
|
|
122
149
|
transitionSpeed: "fast",
|
123
150
|
|
124
151
|
_hover: {
|
125
|
-
backgroundColor: "seaMist",
|
152
|
+
backgroundColor: mode("seaMist", "pine")(props),
|
126
153
|
},
|
127
154
|
...focusVisible({
|
128
155
|
focus: {
|
129
156
|
outline: "none",
|
130
157
|
boxShadow: getBoxShadowString({
|
131
158
|
borderWidth: 2,
|
132
|
-
borderColor: "greenHaze",
|
159
|
+
borderColor: mode("greenHaze", "azure")(props),
|
133
160
|
}),
|
134
161
|
},
|
135
162
|
notFocus: {
|
@@ -141,14 +168,14 @@ const config = helpers.defineMultiStyleConfig({
|
|
141
168
|
}),
|
142
169
|
},
|
143
170
|
_active: {
|
144
|
-
color: "darkGrey",
|
171
|
+
color: mode("darkGrey", "white")(props),
|
145
172
|
},
|
146
173
|
},
|
147
174
|
}),
|
148
175
|
_active: {
|
149
176
|
backgroundColor: "seaMist",
|
150
177
|
boxShadow: "none",
|
151
|
-
color: "darkGrey",
|
178
|
+
color: mode("darkGrey", "white")(props),
|
152
179
|
},
|
153
180
|
_disabled: {
|
154
181
|
color: "osloGrey",
|
@@ -156,7 +183,7 @@ const config = helpers.defineMultiStyleConfig({
|
|
156
183
|
pointerEvents: "none",
|
157
184
|
},
|
158
185
|
_selected: {
|
159
|
-
backgroundColor: "darkTeal",
|
186
|
+
backgroundColor: mode("darkTeal", "pine")(props),
|
160
187
|
color: "white",
|
161
188
|
_active: {
|
162
189
|
backgroundColor: "seaMist",
|
@@ -167,7 +194,7 @@ const config = helpers.defineMultiStyleConfig({
|
|
167
194
|
"&[data-today]": {
|
168
195
|
boxShadow: getBoxShadowString({
|
169
196
|
borderWidth: 1,
|
170
|
-
borderColor: "osloGrey",
|
197
|
+
borderColor: mode("osloGrey", "dimGrey")(props),
|
171
198
|
}),
|
172
199
|
},
|
173
200
|
"&[data-unavailable]": {
|
@@ -175,7 +202,7 @@ const config = helpers.defineMultiStyleConfig({
|
|
175
202
|
color: "osloGrey",
|
176
203
|
},
|
177
204
|
},
|
178
|
-
},
|
205
|
+
}),
|
179
206
|
variants: {
|
180
207
|
simple: {
|
181
208
|
wrapper: {
|