@vygruppen/spor-react 10.9.1 → 11.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.
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export { Accordion, AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, AttachedInputs, Badge, Box, Brand, Breadcrumb, BreadcrumbItem, BreadcrumbLink, Button, ButtonGroup, CardSelect, CargonetLogo, 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, FullScreenDrawer, 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, Nudge, NumericStepper, OrderedList, Pagination, PasswordInput, PhoneNumberInput, PlayPauseButton, Portal, PressableCard, ProgressBar, ProgressIndicator, ProgressLoader, Radio, RadioCard, RadioCardGroup, RadioCardGroupContext, RadioGroup, ScaleFade, SearchInput, Section, ServiceAlert, SimpleDrawer, SimpleGrid, Skeleton, SkeletonCircle, SkeletonText, SkipButton, Slide, SlideFade, Spacer, SporProvider, Stack, StaticAlert, StaticCard, Stepper, StepperStep, Switch, Tab, TabList, TabPanel, TabPanels, Table, TableCaption, Tabs, Tbody, Td, Text, TextLink, Textarea, Tfoot, Th, Thead, Time, TimePicker, Tooltip, Tr, TravelTag, UnorderedList, VStack, VyLogo, VyLogoPride, WizardNudge, Wrap, WrapItem, brandTheme, createTexts, defineStyleConfig, extendTheme, fontFaces, slugify, theme, tokens, useBreakpointValue, useClipboard, useColorMode, useColorModePreference, useColorModeValue, useControllableProp, useDisclosure, useMediaQuery, useMergeRefs, useOutsideClick, usePrefersReducedMotion, useSize, useTheme, useToast, useToken, useTranslation } from './chunk-RK3GOXNY.mjs';
1
+ export { Accordion, AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, AttachedInputs, Badge, Box, Brand, Breadcrumb, BreadcrumbItem, BreadcrumbLink, Button, ButtonGroup, CardSelect, CargonetLogo, 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, FullScreenDrawer, 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, Nudge, NumericStepper, OrderedList, Pagination, PasswordInput, PhoneNumberInput, PlayPauseButton, Portal, PressableCard, ProgressBar, ProgressIndicator, ProgressLoader, Radio, RadioCard, RadioCardGroup, RadioCardGroupContext, RadioGroup, ScaleFade, SearchInput, Section, ServiceAlert, SimpleDrawer, SimpleGrid, Skeleton, SkeletonCircle, SkeletonText, SkipButton, Slide, SlideFade, Spacer, SporProvider, Stack, StaticAlert, StaticCard, Stepper, StepperStep, Switch, Tab, TabList, TabPanel, TabPanels, Table, TableCaption, Tabs, Tbody, Td, Text, TextLink, Textarea, Tfoot, Th, Thead, Time, TimePicker, Tooltip, Tr, TravelTag, UnorderedList, VStack, VyLogo, VyLogoPride, WizardNudge, Wrap, WrapItem, brandTheme, createTexts, defineStyleConfig, extendTheme, fontFaces, slugify, theme, tokens, useBreakpointValue, useClipboard, useColorMode, useColorModePreference, useColorModeValue, useControllableProp, useDisclosure, useMediaQuery, useMergeRefs, useOutsideClick, usePrefersReducedMotion, useSize, useTheme, useToast, useToken, useTranslation } from './chunk-ROHXFJX2.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vygruppen/spor-react",
3
- "version": "10.9.1",
3
+ "version": "11.0.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -4,6 +4,7 @@ import {
4
4
  ButtonProps as ChakraButtonProps,
5
5
  Flex,
6
6
  forwardRef,
7
+ SpaceProps,
7
8
  useButtonGroup,
8
9
  useStyleConfig,
9
10
  } from "@chakra-ui/react";
@@ -11,9 +12,12 @@ import React from "react";
11
12
  import { createTexts, useTranslation } from "../i18n";
12
13
  import { ColorInlineLoader } from "../loader";
13
14
 
14
- export type ButtonProps = Exclude<
15
- ChakraButtonProps,
16
- "colorScheme" | "loadingText" | "size" | "variant"
15
+ export type ButtonProps = Omit<
16
+ Exclude<
17
+ ChakraButtonProps,
18
+ "colorScheme" | "loadingText" | "size" | "variant"
19
+ >,
20
+ keyof SpaceProps
17
21
  > & {
18
22
  /**
19
23
  * The size of the button.
@@ -122,7 +122,6 @@ export const CardSelect = forwardRef<CardSelectProps, "button">(
122
122
  <chakra.button
123
123
  type="button"
124
124
  ref={triggerRef}
125
- fontWeight="bold"
126
125
  sx={styles.trigger}
127
126
  aria-label={label}
128
127
  {...buttonProps}
@@ -148,14 +147,17 @@ export const CardSelect = forwardRef<CardSelectProps, "button">(
148
147
  offset={size === "sm" ? 6 : 12}
149
148
  crossOffset={crossOffset}
150
149
  placement={placement}
150
+ containerPadding={0}
151
151
  >
152
152
  <StaticCard
153
153
  colorScheme="white"
154
- size="lg"
154
+ size="md"
155
+ fontSize={"xs"}
155
156
  border={"sm"}
156
- borderColor={"grey"}
157
+ borderColor={"silver"}
157
158
  sx={styles.card}
158
159
  {...overlayProps}
160
+ maxWidth={(triggerRef.current?.clientWidth ?? 1) * 2}
159
161
  >
160
162
  <Dialog aria-label={label}>{children}</Dialog>
161
163
  </StaticCard>
@@ -2,6 +2,7 @@ import {
2
2
  Input as ChakraInput,
3
3
  InputProps as ChakraInputProps,
4
4
  IconButton,
5
+ LayoutProps,
5
6
  forwardRef,
6
7
  useFormControlContext,
7
8
  } from "@chakra-ui/react";
@@ -33,15 +34,18 @@ export const SearchInput = forwardRef<SearchInputProps, "input">(
33
34
  const formControlProps = useFormControlContext();
34
35
  const autoGeneratedId = useId();
35
36
  const inputId = props.id ?? formControlProps?.id ?? autoGeneratedId;
37
+
38
+ const { outerProps, innerProps } = getOuterProps(props);
39
+
36
40
  return (
37
- <InputGroup position="relative">
41
+ <InputGroup position="relative" {...outerProps}>
38
42
  <InputLeftElement>
39
43
  <SearchOutline24Icon />
40
44
  </InputLeftElement>
41
45
  <ChakraInput
42
46
  paddingLeft={7}
43
47
  paddingRight={7}
44
- {...props}
48
+ {...innerProps}
45
49
  id={inputId}
46
50
  type="search"
47
51
  css={{
@@ -74,6 +78,22 @@ export const SearchInput = forwardRef<SearchInputProps, "input">(
74
78
  },
75
79
  );
76
80
 
81
+ const getOuterProps = (props: Record<string, any>) => {
82
+ const layoutKeys = new Set(["w, width, maxW, minW, maxWidth, minWidth"]); // add more keys here if neccessary
83
+ const outerProps: LayoutProps = {};
84
+ const innerProps: Record<string, any> = {};
85
+
86
+ for (const key in props) {
87
+ if (layoutKeys.has(key)) {
88
+ (outerProps as any)[key] = props[key];
89
+ } else {
90
+ (innerProps as any)[key] = props[key];
91
+ }
92
+ }
93
+
94
+ return { outerProps, innerProps };
95
+ };
96
+
77
97
  const texts = createTexts({
78
98
  label: {
79
99
  nb: "Søk",
@@ -19,10 +19,23 @@ import type { TagProps } from "./types";
19
19
 
20
20
  export type TravelTagProps = TagProps &
21
21
  BoxProps & {
22
+ /**
23
+ * Defines the level of importance
24
+ * Default to none
25
+ */
22
26
  deviationLevel?: "critical" | "major" | "minor" | "info" | "none";
23
27
  isDisabled?: boolean;
28
+ /**
29
+ * Needs to be defined if variant is custom
30
+ */
24
31
  foregroundColor?: string;
32
+ /**
33
+ * Needs to be defined if variant is custom
34
+ */
25
35
  backgroundColor?: string;
36
+ /**
37
+ * Define a custom icon variant
38
+ */
26
39
  customIconVariant?: string;
27
40
  };
28
41
 
@@ -12,5 +12,11 @@ export type SkeletonProps = BoxProps & {
12
12
  * Skeleton renders a loading animation for a given box. It works great as a placeholder to avoid layout shifts.
13
13
  */
14
14
  export const Skeleton = forwardRef<SkeletonProps, "div">((props, ref) => (
15
- <ChakraSkeleton {...props} ref={ref} />
15
+ <ChakraSkeleton
16
+ {...props}
17
+ ref={ref}
18
+ aria-busy="true"
19
+ aria-hidden="true"
20
+ role="alert"
21
+ />
16
22
  ));
@@ -163,7 +163,6 @@ const DrawerCloseButton = () => {
163
163
  onClick={onClose}
164
164
  aria-label={t(texts.close)}
165
165
  width="fit-content"
166
- marginLeft="auto"
167
166
  >
168
167
  {t(texts.close)}
169
168
  </Button>
@@ -196,7 +195,6 @@ const DrawerBackButton = () => {
196
195
  onClick={onClose}
197
196
  aria-label={t(texts.backAriaLabel)}
198
197
  width="fit-content"
199
- marginLeft="auto"
200
198
  >
201
199
  {t(texts.back)}
202
200
  </Button>
@@ -27,11 +27,15 @@ const config = helpers.defineMultiStyleConfig({
27
27
  },
28
28
  container: {
29
29
  _hover: {
30
+ backgroundColor: "cloudy",
30
31
  outlineColor: "sky",
31
32
  },
32
33
  _active: {
33
34
  backgroundColor: "icyBlue",
34
35
  },
36
+ _focus: {
37
+ outlineColor: "greenHaze",
38
+ },
35
39
  },
36
40
  },
37
41
  success: {
@@ -40,11 +44,15 @@ const config = helpers.defineMultiStyleConfig({
40
44
  },
41
45
  container: {
42
46
  _hover: {
47
+ backgroundColor: "coralGreen",
43
48
  outlineColor: "blueGreen",
44
49
  },
45
50
  _active: {
46
51
  backgroundColor: "mint",
47
52
  },
53
+ _focus: {
54
+ outlineColor: "greenHaze",
55
+ },
48
56
  },
49
57
  },
50
58
  warning: {
@@ -53,7 +61,11 @@ const config = helpers.defineMultiStyleConfig({
53
61
  },
54
62
  container: {
55
63
  _hover: {
56
- outlineColor: "sunshine",
64
+ backgroundColor: "primrose",
65
+ outlineColor: "banana",
66
+ },
67
+ _focus: {
68
+ outlineColor: "greenHaze",
57
69
  },
58
70
  _active: {
59
71
  backgroundColor: "cornSilk",
@@ -66,8 +78,12 @@ const config = helpers.defineMultiStyleConfig({
66
78
  },
67
79
  container: {
68
80
  _hover: {
81
+ backgroundColor: "burntYellow",
69
82
  outlineColor: "golden",
70
83
  },
84
+ _focus: {
85
+ outlineColor: "greenHaze",
86
+ },
71
87
  _active: {
72
88
  backgroundColor: "sunshine",
73
89
  },
@@ -79,11 +95,15 @@ const config = helpers.defineMultiStyleConfig({
79
95
  },
80
96
  container: {
81
97
  _hover: {
98
+ backgroundColor: "salmon",
82
99
  outlineColor: "apricot",
83
100
  },
84
101
  _active: {
85
102
  backgroundColor: "pink",
86
103
  },
104
+ _focus: {
105
+ outlineColor: "greenHaze",
106
+ },
87
107
  },
88
108
  },
89
109
  service: {
@@ -65,10 +65,14 @@ const config = helpers.defineMultiStyleConfig({
65
65
  service: {
66
66
  container: {
67
67
  _hover: {
68
- outlineColor: "blueGreen",
68
+ backgroundColor: "teal.600",
69
+ outlineColor: "teal.600",
70
+ },
71
+ _focus: {
72
+ outlineColor: "green.500",
69
73
  },
70
74
  _active: {
71
- backgroundColor: "pine",
75
+ backgroundColor: "teal.400",
72
76
  outlineColor: "pine",
73
77
  },
74
78
  color: "white",
@@ -5,6 +5,7 @@ import { baseBackground, baseBorder, baseText } from "../utils/base-utils";
5
5
  import { floatingBackground, floatingBorder } from "../utils/floating-utils";
6
6
  import { focusVisibleStyles } from "../utils/focus-utils";
7
7
  import { ghostBackground, ghostText } from "../utils/ghost-utils";
8
+ import { fontWeights } from "../foundations";
8
9
 
9
10
  const parts = anatomy("card-select").parts("trigger", "card");
10
11
 
@@ -22,8 +23,8 @@ const config = helpers.defineMultiStyleConfig({
22
23
  },
23
24
  card: {
24
25
  borderRadius: "sm",
25
- boxShadow: "md",
26
- padding: 3,
26
+ boxShadow: "xs",
27
+ padding: 2,
27
28
  ...baseText("default", props),
28
29
  backgroundColor: mode(
29
30
  "white",
@@ -56,7 +57,8 @@ const config = helpers.defineMultiStyleConfig({
56
57
  ...ghostBackground("active", props),
57
58
  },
58
59
  _expanded: {
59
- ...ghostBackground("selected", props),
60
+ ...ghostBackground("active", props),
61
+ fontWeight: fontWeights.bold,
60
62
  },
61
63
  },
62
64
  }),
@@ -88,7 +90,7 @@ const config = helpers.defineMultiStyleConfig({
88
90
  paddingY: 1,
89
91
  minHeight: "1.25rem",
90
92
  fontSize: "xs",
91
- borderRadius: "sm",
93
+ borderRadius: "lg",
92
94
  },
93
95
  },
94
96
  md: {
@@ -96,8 +98,8 @@ const config = helpers.defineMultiStyleConfig({
96
98
  paddingX: 2,
97
99
  paddingY: 1.5,
98
100
  minHeight: "2.625rem",
99
- fontSize: "sm",
100
- borderRadius: "sm",
101
+ fontSize: "xs",
102
+ borderRadius: "lg",
101
103
  },
102
104
  },
103
105
  lg: {
@@ -106,7 +108,7 @@ const config = helpers.defineMultiStyleConfig({
106
108
  paddingY: 2,
107
109
  minHeight: "3.375rem",
108
110
  fontSize: "sm",
109
- borderRadius: "sm",
111
+ borderRadius: "lg",
110
112
  },
111
113
  },
112
114
  },
@@ -1,42 +1,47 @@
1
1
  import { defineStyleConfig } from "@chakra-ui/styled-system";
2
- import { mode, StyleFunctionProps } from "@chakra-ui/theme-tools";
2
+ import { mode } from "@chakra-ui/theme-tools";
3
3
 
4
- const isSolid = (props: StyleFunctionProps) => props.variant === "solid";
5
- const isDashed = (props: StyleFunctionProps) => props.variant === "dashed";
4
+ const borderColor = mode("blackAlpha.300", "whiteAlpha.300");
5
+
6
+ function getSizes(size: string) {
7
+ const sizes: Record<string, { height: string; dash: string; gap: string }> = {
8
+ sm: {
9
+ height: "1px",
10
+ dash: "1px",
11
+ gap: "4px",
12
+ },
13
+ md: {
14
+ height: "2px",
15
+ dash: "3px",
16
+ gap: "6px",
17
+ },
18
+ lg: {
19
+ height: "3px",
20
+ dash: "3px",
21
+ gap: "9px",
22
+ },
23
+ };
24
+ return sizes[size] || sizes["md"];
25
+ }
6
26
 
7
27
  export default defineStyleConfig({
8
28
  baseStyle: (props) => ({
9
- borderColor: mode("blackAlpha.300", "whiteAlpha.300")(props),
29
+ borderColor: borderColor(props),
10
30
  }),
11
31
  variants: {
12
32
  solid: {
13
33
  borderStyle: "solid",
14
34
  },
15
- dashed: (props) => ({
16
- backgroundImage: `repeating-linear-gradient(90deg, ${mode("blackAlpha.300", "whiteAlpha.300")(props)}, ${mode("blackAlpha.300", "whiteAlpha.300")(props)} 4px, transparent 4px, transparent 10px)`,
17
- backgroundPosition: "left bottom",
18
- backgroundRepeat: "repeat-x",
19
- backgroundSize: "100% 3px",
20
- borderRadius:
21
- props.size === "sm" ? "0.5px" : props.size === "md" ? "1px" : "1.5px",
22
- }),
23
- },
24
- sizes: {
25
- sm: (props) => ({
26
- borderWidth: isSolid(props) ? "1px" : undefined,
27
- borderRadius: isSolid(props) ? "0.5px" : undefined,
28
- height: isDashed(props) ? "1px" : undefined,
29
- }),
30
- md: (props) => ({
31
- borderWidth: isSolid(props) ? "2px" : undefined,
32
- borderRadius: isSolid(props) ? "1px" : "10px",
33
- height: isDashed(props) ? "2px" : undefined,
34
- }),
35
- lg: (props) => ({
36
- borderWidth: isSolid(props) ? "3px" : undefined,
37
- borderRadius: isSolid(props) ? "1.5px" : undefined,
38
- height: isDashed(props) ? "3px" : undefined,
39
- }),
35
+ dashed: (props) => {
36
+ const { height, dash, gap } = getSizes(props.size);
37
+ return {
38
+ height: height,
39
+ backgroundImage: `linear-gradient(90deg, ${borderColor(props)}, ${borderColor(props)} ${dash}, transparent ${dash}, transparent ${gap})`,
40
+ backgroundPosition: "left bottom",
41
+ backgroundRepeat: "repeat-x",
42
+ backgroundSize: `${gap} ${height}`,
43
+ };
44
+ },
40
45
  },
41
46
  defaultProps: {
42
47
  variant: "solid",
@@ -13,6 +13,9 @@ const config = helpers.defineMultiStyleConfig({
13
13
  },
14
14
  icon: {
15
15
  color: "white",
16
+ "[aria-disabled=true] &": {
17
+ color: mode("icon.disabled.light", "icon.disabled.dark"),
18
+ },
16
19
  },
17
20
  },
18
21
  variants: {
@@ -2,6 +2,8 @@ import { createMultiStyleConfigHelpers } from "@chakra-ui/react";
2
2
  import type { StyleFunctionProps } from "@chakra-ui/theme-tools";
3
3
  import { anatomy, mode } from "@chakra-ui/theme-tools";
4
4
  import { focusVisibleStyles } from "../utils/focus-utils";
5
+ import { surface } from "../utils/surface-utils";
6
+ import { baseText } from "../utils/base-utils";
5
7
 
6
8
  const parts = anatomy("travel-tag").parts(
7
9
  "container",
@@ -27,7 +29,7 @@ const config = helpers.defineMultiStyleConfig({
27
29
  transitionDuration: "fast",
28
30
  transitionProperty: "common",
29
31
  _disabled: {
30
- backgroundColor: "silver",
32
+ ...surface("disabled", props),
31
33
  },
32
34
  "button&, a&": {
33
35
  boxShadow: "sm",
@@ -44,8 +46,7 @@ const config = helpers.defineMultiStyleConfig({
44
46
  iconContainer: {
45
47
  padding: 0.5,
46
48
  "[aria-disabled=true] &": {
47
- backgroundColor: "osloGrey",
48
- color: "white",
49
+ ...surface("disabled", props),
49
50
  },
50
51
  },
51
52
  textContainer: {
@@ -53,7 +54,7 @@ const config = helpers.defineMultiStyleConfig({
53
54
  paddingRight: 0.5,
54
55
  whiteSpace: "nowrap",
55
56
  "[aria-disabled=true] &": {
56
- color: "dimGrey",
57
+ ...baseText("disabled", props),
57
58
  },
58
59
  },
59
60
  title: {
@@ -1,3 +1,4 @@
1
+ import tokens from "@vygruppen/spor-design-tokens";
1
2
  import { spacing } from "./spacing";
2
3
 
3
4
  const largeSizes = {
@@ -21,10 +22,11 @@ const largeSizes = {
21
22
  };
22
23
 
23
24
  const container = {
24
- sm: "640px",
25
- md: "768px",
26
- lg: "1024px",
27
- xl: "1280px",
25
+ base: "0px",
26
+ sm: tokens.size.breakpoint.sm,
27
+ md: tokens.size.breakpoint.md,
28
+ lg: tokens.size.breakpoint.lg,
29
+ xl: tokens.size.breakpoint.xl,
28
30
  };
29
31
 
30
32
  export const sizes = {
@@ -1,5 +1,6 @@
1
1
  import { mode, StyleFunctionProps } from "@chakra-ui/theme-tools";
2
2
  import { State, Subset } from "./types";
3
+ import { fontWeights } from "../foundations";
3
4
 
4
5
  type GhostBackgroundState = Subset<
5
6
  State,
@@ -30,8 +31,8 @@ export function ghostBackground(
30
31
  case "selected": {
31
32
  return {
32
33
  backgroundColor: mode(
33
- "ghost.surface.selected.light",
34
- "ghost.surface.selected.dark",
34
+ "ghost.surface.hover.light",
35
+ "ghost.surface.hover.dark",
35
36
  )(props),
36
37
  };
37
38
  }