@vygruppen/spor-react 3.8.0 → 4.0.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.
@@ -11,18 +11,13 @@ import {
11
11
  PopoverTrigger,
12
12
  Portal,
13
13
  ResponsiveValue,
14
- useBreakpointValue,
15
14
  useFormControlContext,
16
15
  useMultiStyleConfig,
17
16
  } from "@chakra-ui/react";
18
17
  import { DateValue } from "@internationalized/date";
19
18
  import { useDatePickerState } from "@react-stately/datepicker";
20
19
  import React, { forwardRef, useRef } from "react";
21
- import {
22
- AriaDatePickerProps,
23
- I18nProvider,
24
- useDatePicker,
25
- } from "react-aria";
20
+ import { AriaDatePickerProps, I18nProvider, useDatePicker } from "react-aria";
26
21
  import { FormErrorMessage } from "..";
27
22
  import { Calendar } from "./Calendar";
28
23
  import { CalendarTriggerButton } from "./CalendarTriggerButton";
@@ -41,10 +36,10 @@ type DatePickerProps = AriaDatePickerProps<DateValue> &
41
36
  /**
42
37
  * A date picker component.
43
38
  *
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.
39
+ * There are three different variants `base`, `floating` and `ghost`.
45
40
  *
46
41
  * ```tsx
47
- * <DatePicker label="Dato" variant="simple" />
42
+ * <DatePicker label="Dato" variant="base" />
48
43
  * ```
49
44
  */
50
45
 
@@ -109,14 +104,19 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
109
104
 
110
105
  return (
111
106
  <I18nProvider locale={locale}>
112
- <Box position="relative" display="inline-flex" flexDirection="column" width={width}>
107
+ <Box
108
+ position="relative"
109
+ display="inline-flex"
110
+ flexDirection="column"
111
+ width={width}
112
+ >
113
113
  <Popover
114
114
  {...dialogProps}
115
115
  isOpen={state.isOpen}
116
116
  onOpen={state.open}
117
117
  onClose={state.close}
118
118
  >
119
- <InputGroup {...groupProps} display="inline-flex">
119
+ <InputGroup {...groupProps} display="inline-flex">
120
120
  <PopoverAnchor>
121
121
  <StyledField
122
122
  variant={variant}
@@ -125,7 +125,11 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
125
125
  minHeight={minHeight}
126
126
  >
127
127
  <PopoverTrigger>
128
- <CalendarTriggerButton variant={variant} ref={ref} {...buttonProps} />
128
+ <CalendarTriggerButton
129
+ variant={variant}
130
+ ref={ref}
131
+ {...buttonProps}
132
+ />
129
133
  </PopoverTrigger>
130
134
  <DateField
131
135
  label={props.label}
@@ -136,8 +140,12 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
136
140
  </StyledField>
137
141
  </PopoverAnchor>
138
142
  </InputGroup>
139
- <FormErrorMessage {...errorMessageProps}>{errorMessage}</FormErrorMessage>
140
- {state.isOpen && !props.isDisabled && withPortal && <Portal>{popoverContent}</Portal>}
143
+ <FormErrorMessage {...errorMessageProps}>
144
+ {errorMessage}
145
+ </FormErrorMessage>
146
+ {state.isOpen && !props.isDisabled && withPortal && (
147
+ <Portal>{popoverContent}</Portal>
148
+ )}
141
149
  {state.isOpen && !props.isDisabled && !withPortal && popoverContent}
142
150
  </Popover>
143
151
  </Box>
@@ -46,10 +46,10 @@ type DateRangePickerProps = AriaDateRangePickerProps<DateValue> &
46
46
  /**
47
47
  * A date range picker component.
48
48
  *
49
- * 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.
49
+ * There are three variants to choose from`base`, `floating` and `ghost`.
50
50
  *
51
51
  * ```tsx
52
- * <DateRangePicker startLabel="From" startName="from" endLabel="To" endName="to" variant="simple" />
52
+ * <DateRangePicker startLabel="From" startName="from" endLabel="To" endName="to" variant="base" />
53
53
  * ```
54
54
  */
55
55
  export function DateRangePicker({
@@ -8,15 +8,11 @@ import React from "react";
8
8
  import { createTexts, useTranslation } from "..";
9
9
 
10
10
  type LinkProps = Omit<ChakraLinkProps, "variant"> & {
11
- variant?:
12
- | "primary"
13
- | "secondary"
14
- /** @deprecated Use `secondary` instead */
15
- | "tertiary";
11
+ variant?: "primary" | "secondary";
16
12
  };
17
13
  /** Link to different sites or parts of site
18
14
  *
19
- * You can specify the `variant` prop to get different link designs. `tertiary` should only be used on dark backgrounds.
15
+ * You can specify the `variant` prop to get different link designs.
20
16
  */
21
17
  export const TextLink = forwardRef<LinkProps, "a">(
22
18
  ({ children, ...props }, ref) => {
@@ -90,9 +90,9 @@ const Notch = forwardRef<BoxProps, any>((props, ref) => {
90
90
  ref={ref}
91
91
  >
92
92
  <Center
93
- background={`linear-gradient(to ${
93
+ background={
94
94
  placement === "bottom" ? "bottom" : "top"
95
- }, white 0%, white 60%, transparent)`}
95
+ }
96
96
  padding={2}
97
97
  borderRadius="md"
98
98
  >
package/src/tab/Tabs.tsx CHANGED
@@ -9,17 +9,7 @@ export type TabsProps = Exclude<
9
9
  ChakraTabsProps,
10
10
  "colorScheme" | "variant" | "orientation" | "size"
11
11
  > & {
12
- colorScheme:
13
- /** @deprecated dark is deprecated please use accent*/
14
- | "dark"
15
- /** @deprecated light is deprecated please use default*/
16
- | "light"
17
- /** @deprecated green is deprecated please use accent*/
18
- | "green"
19
- /** @deprecated grey is deprecated please use default*/
20
- | "grey"
21
- | "base"
22
- | "accent" ;
12
+ colorScheme: "base" | "accent";
23
13
  /** Defaults to `md` */
24
14
  size?: "sm" | "md" | "lg" | "xl";
25
15
  /** Defaults to `round` */
@@ -125,26 +125,6 @@ const config = defineStyleConfig({
125
125
  },
126
126
  },
127
127
  }),
128
- /**
129
- * @deprecated use `secondary` instead.
130
- */
131
- tertiary: {
132
- backgroundColor: "mint",
133
- color: "darkGrey",
134
- fontWeight: "normal",
135
- ...focusVisible({
136
- focus: {
137
- boxShadow: `inset 0 0 0 4px ${colors.mint}, inset 0 0 0 4px ${colors.mint}, inset 0 0 0 6px currentColor`,
138
- },
139
- notFocus: { boxShadow: "none" },
140
- }),
141
- _hover: {
142
- backgroundColor: "seaMist",
143
- },
144
- _active: {
145
- backgroundColor: "lightGrey",
146
- },
147
- },
148
128
  additional: (props) => ({
149
129
  backgroundColor: "transparent",
150
130
  color: mode("darkGrey", "white")(props),
@@ -1,8 +1,8 @@
1
1
  import { defineStyleConfig } from "@chakra-ui/react";
2
+ import { mode } from "@chakra-ui/theme-tools";
2
3
  import { colors } from "../foundations";
3
4
  import { getBoxShadowString } from "../utils/box-shadow-utils";
4
5
  import { focusVisible } from "../utils/focus-utils";
5
- import { mode } from "@chakra-ui/theme-tools";
6
6
 
7
7
  const config = defineStyleConfig({
8
8
  baseStyle: (props: any) => ({
@@ -16,7 +16,7 @@ const config = defineStyleConfig({
16
16
  borderRadius: "md",
17
17
  ...getColorSchemeBaseProps(props),
18
18
 
19
- "button&, a&": {
19
+ "button&, a&, label&, &.is-clickable": {
20
20
  ...getColorSchemeClickableProps(props),
21
21
  _hover: getColorSchemeHoverProps(props),
22
22
  _active: getColorSchemeActiveProps(props),
@@ -62,7 +62,7 @@ type CardThemeProps = {
62
62
  size: "sm" | "lg";
63
63
  };
64
64
 
65
- const getColorSchemeBaseProps= (props: CardThemeProps) => {
65
+ const getColorSchemeBaseProps = (props: CardThemeProps) => {
66
66
  const { colorScheme, size } = props;
67
67
  const baseShadow = size === "lg" ? "md" : "sm";
68
68
  switch (colorScheme) {
@@ -89,7 +89,7 @@ const getColorSchemeBaseProps= (props: CardThemeProps) => {
89
89
  backgroundColor: colors[colorScheme]?.[100] ?? "platinum",
90
90
  };
91
91
  }
92
- }
92
+ };
93
93
 
94
94
  function getColorSchemeClickableProps({ colorScheme, size }: CardThemeProps) {
95
95
  const baseShadow = size === "lg" ? "md" : "sm";
@@ -129,7 +129,7 @@ const getColorSchemeHoverProps = (props: CardThemeProps) => {
129
129
  case "white":
130
130
  return {
131
131
  backgroundColor: mode("white", "whiteAlpha.200")(props),
132
- boxShadow: getBoxShadowString({
132
+ boxShadow: getBoxShadowString({
133
133
  baseShadow,
134
134
  borderColor: colors.steel,
135
135
  isInset: false,
@@ -153,7 +153,7 @@ const getColorSchemeHoverProps = (props: CardThemeProps) => {
153
153
  }),
154
154
  };
155
155
  }
156
- }
156
+ };
157
157
  const getColorSchemeActiveProps = (props: CardThemeProps) => {
158
158
  const { colorScheme, size } = props;
159
159
  const baseShadow = size === "lg" ? "sm" : "none";
@@ -186,4 +186,4 @@ const getColorSchemeActiveProps = (props: CardThemeProps) => {
186
186
  }),
187
187
  };
188
188
  }
189
- }
189
+ };
@@ -26,7 +26,7 @@ const config = defineStyleConfig({
26
26
  },
27
27
  }),
28
28
  _hover: {
29
- backgroundColor: mode("seaMist", "pine")(props),
29
+ backgroundColor: mode("seaMist", "whiteAlpha.100")(props),
30
30
  _disabled: {
31
31
  color: "dimGrey",
32
32
  },
@@ -1,6 +1,6 @@
1
1
  import { modalAnatomy as parts } from "@chakra-ui/anatomy";
2
2
  import { createMultiStyleConfigHelpers } from "@chakra-ui/react";
3
- import type { PartsStyleObject } from "@chakra-ui/theme-tools";
3
+ import { mode, type PartsStyleObject } from "@chakra-ui/theme-tools";
4
4
 
5
5
  const helpers = createMultiStyleConfigHelpers(parts.keys);
6
6
 
@@ -9,6 +9,7 @@ const config = helpers.defineMultiStyleConfig({
9
9
  overlay: {
10
10
  backgroundColor: "blackAlpha.600",
11
11
  zIndex: "modal",
12
+ color: "red",
12
13
  },
13
14
  dialogContainer: {
14
15
  display: "flex",
@@ -18,8 +19,8 @@ const config = helpers.defineMultiStyleConfig({
18
19
  overflow: props.scrollBehavior === "inside" ? "hidden" : "auto",
19
20
  },
20
21
  dialog: {
21
- background: "white",
22
- color: "inherit",
22
+ backgroundColor: mode("white", "pine")(props),
23
+ color: mode("inherit", "white")(props),
23
24
  zIndex: "modal",
24
25
  maxHeight:
25
26
  props.scrollBehavior === "inside" ? "calc(100% - 7.5rem)" : undefined,
@@ -1,7 +1,7 @@
1
1
  import { defineStyleConfig } from "@chakra-ui/react";
2
+ import { mode } from "@chakra-ui/theme-tools";
2
3
  import { getBoxShadowString } from "../utils/box-shadow-utils";
3
4
  import { focusVisible } from "../utils/focus-utils";
4
- import { mode } from "@chakra-ui/theme-tools";
5
5
 
6
6
  const config = defineStyleConfig({
7
7
  baseStyle: {
@@ -55,7 +55,7 @@ const config = defineStyleConfig({
55
55
  }),
56
56
  _hover: {
57
57
  color: mode("darkTeal", "white")(props),
58
- backgroundColor: mode("coralGreen", "whiteAlpha.200")(props)
58
+ backgroundColor: mode("coralGreen", "whiteAlpha.200")(props),
59
59
  },
60
60
  _active: {
61
61
  color: mode("pine", "white")(props),
@@ -67,7 +67,7 @@ const config = defineStyleConfig({
67
67
  ...focusVisible({
68
68
  focus: {
69
69
  backgroundColor: mode("darkGrey", "white")(props),
70
- color: mode("white", "darkTeal")(props)
70
+ color: mode("white", "darkTeal")(props),
71
71
  },
72
72
  notFocus: {
73
73
  boxShadow: "none",
@@ -76,52 +76,11 @@ const config = defineStyleConfig({
76
76
  }),
77
77
  _hover: {
78
78
  backgroundColor: mode("blackAlpha.100", "whiteAlpha.200")(props),
79
- color: mode("darkGrey", "white")(props)
79
+ color: mode("darkGrey", "white")(props),
80
80
  },
81
81
  _active: {
82
82
  backgroundColor: mode("mint", "whiteAlpha.100")(props),
83
- color: mode("darkGrey", "white")(props)
84
- },
85
- }),
86
- /**
87
- * @deprecated tertiary style will be deprecated in the future.
88
- * Please use the secondary style instead.
89
- */
90
- tertiary: (props) => ({
91
- color: "white",
92
- ...focusVisible({
93
- focus: {
94
- color: "pine",
95
- backgroundColor: "white",
96
- boxShadow: getBoxShadowString({
97
- borderColor: "white",
98
- borderWidth: 3,
99
- isInset: false,
100
- }),
101
- },
102
- notFocus: {
103
- color: "white",
104
- boxShadow: "none",
105
- backgroundColor: "transparent",
106
- },
107
- }),
108
- _hover: {
109
- color: "white",
110
- backgroundColor: "whiteAlpha.200",
111
- boxShadow: getBoxShadowString({
112
- borderColor: props.theme.colors.whiteAlpha[200],
113
- borderWidth: 3,
114
- isInset: false,
115
- }),
116
- },
117
- _active: {
118
- color: "white",
119
- backgroundColor: "whiteAlpha.400",
120
- boxShadow: getBoxShadowString({
121
- borderColor: props.theme.colors.whiteAlpha[400],
122
- borderWidth: 3,
123
- isInset: false,
124
- }),
83
+ color: mode("darkGrey", "white")(props),
125
84
  },
126
85
  }),
127
86
  },
@@ -19,7 +19,7 @@ const config = helpers.defineMultiStyleConfig({
19
19
  },
20
20
  dialog: {
21
21
  borderRadius: "md",
22
- background: mode("white", "night")(props),
22
+ background: mode("white", "pine")(props),
23
23
  color: mode("inherit", "white")(props),
24
24
  my: "3.75rem",
25
25
  zIndex: "modal",
@@ -1,6 +1,8 @@
1
1
  import { popoverAnatomy as parts } from "@chakra-ui/anatomy";
2
2
  import { createMultiStyleConfigHelpers } from "@chakra-ui/react";
3
- import { cssVar } from "@chakra-ui/theme-tools";
3
+ import { cssVar, mode } from "@chakra-ui/theme-tools";
4
+ import { getBoxShadowString } from "../utils/box-shadow-utils";
5
+ import { focusVisible } from "../utils/focus-utils";
4
6
 
5
7
  const $popperBg = cssVar("popper-bg");
6
8
  const $arrowBg = cssVar("popper-arrow-bg");
@@ -9,12 +11,12 @@ const $arrowShadowColor = cssVar("popper-arrow-shadow-color");
9
11
  const helpers = createMultiStyleConfigHelpers(parts.keys);
10
12
 
11
13
  const config = helpers.defineMultiStyleConfig({
12
- baseStyle: {
14
+ baseStyle: (props) => ({
13
15
  popper: {
14
16
  zIndex: "popover",
15
17
  },
16
18
  content: {
17
- [$popperBg.variable]: `colors.darkTeal`,
19
+ [$popperBg.variable]: mode(`colors.darkTeal`, `colors.pine`)(props) ,
18
20
  backgroundColor: $popperBg.reference,
19
21
  [$arrowBg.variable]: $popperBg.reference,
20
22
  [$arrowShadowColor.variable]: `colors.blackAlpha.300`,
@@ -36,6 +38,20 @@ const config = helpers.defineMultiStyleConfig({
36
38
  },
37
39
  closeButton: {
38
40
  position: "absolute",
41
+ color: "white",
42
+ hover: "whiteAlpha.100",
43
+ ...focusVisible({
44
+ focus: {
45
+ boxShadow: getBoxShadowString({ borderColor: "azure" }),
46
+
47
+ },
48
+ notFocus: {
49
+ boxShadow: "none",
50
+ },
51
+ }),
52
+ _active: {
53
+ backgroundColor: "whiteAlpha.200",
54
+ },
39
55
  borderRadius: "xs",
40
56
  top: 1,
41
57
  insetEnd: 1,
@@ -43,7 +59,7 @@ const config = helpers.defineMultiStyleConfig({
43
59
  height: 2,
44
60
  padding: 1,
45
61
  },
46
- },
62
+ }),
47
63
  sizes: {
48
64
  sm: {
49
65
  content: {
@@ -2,6 +2,7 @@
2
2
  export {
3
3
  DarkMode,
4
4
  LightMode,
5
+ Portal,
5
6
  useBreakpointValue,
6
7
  useClipboard,
7
8
  useColorMode,
@@ -17,6 +18,7 @@ export {
17
18
  useToken,
18
19
  } from "@chakra-ui/react";
19
20
  export type {
21
+ PortalProps,
20
22
  UseClipboardOptions,
21
23
  UseDisclosureProps,
22
24
  UseOutsideClickProps,