@vygruppen/spor-react 9.6.4 → 9.7.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, 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, 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, RadioGroup, ScaleFade, SearchInput, Section, 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, 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-V5JHGMIB.mjs';
1
+ export { Accordion, AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, AttachedInputs, Badge, Box, Brand, 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, 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, RadioGroup, ScaleFade, SearchInput, Section, 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, 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-QGMF2EAE.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vygruppen/spor-react",
3
- "version": "9.6.4",
3
+ "version": "9.7.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -0,0 +1,95 @@
1
+ import {
2
+ BoxProps,
3
+ UseRadioProps,
4
+ chakra,
5
+ forwardRef,
6
+ useRadio,
7
+ useStyleConfig,
8
+ } from "@chakra-ui/react";
9
+ import { dataAttr } from "@chakra-ui/utils";
10
+ import React, { useId } from "react";
11
+
12
+ type RadioCardProps = UseRadioProps &
13
+ BoxProps & {
14
+ children: React.ReactNode;
15
+ variant: "floating" | "base";
16
+ };
17
+
18
+ /**
19
+ * Renders a radio card.
20
+ *
21
+ * The most basic version looks like this:
22
+ *
23
+ * ```tsx
24
+ * <RadioCard>
25
+ * Content
26
+ * </RadioCard>
27
+ * ```
28
+ *
29
+ * In order to use RadioCard, you typically want to place these components in a group with several other RadioCards.
30
+ *
31
+ * ```tsx
32
+ * <RadioCardGroup name="ticket">
33
+ * <RadioCard value="economy">Economy</RadioCard>
34
+ * <RadioCard value="business">Business</RadioCard>
35
+ * <RadioCard value="first-class">First Class</RadioCard>
36
+ * </RadioCardGroup>
37
+ * ```
38
+ *
39
+ * You can add styling to each card seperately, or you can add a common style to the group.
40
+ * Group styling overrides single styling if both are present.
41
+ *
42
+ * This example shows how to style all cards in a group:
43
+ *
44
+ * ```tsx
45
+ * <RadioCardGroup name="ticket" variant="floating" padding={3}>
46
+ * <RadioCard value="economy">Economy</RadioCard>
47
+ * <RadioCard value="business">Business</RadioCard>
48
+ * <RadioCard value="first-class">First Class</RadioCard>
49
+ * </RadioCardGroup>
50
+ * ```
51
+ *
52
+ * This example shows how to style a single card:
53
+ *
54
+ * ```tsx
55
+ * <RadioCard variant="floating" padding={3}>
56
+ * Economy
57
+ * </RadioCard>
58
+ * ```
59
+ */
60
+
61
+ export const RadioCard = forwardRef<RadioCardProps, "div">(
62
+ ({ children, variant = "base", ...props }, ref) => {
63
+ const { getInputProps, getRadioProps, getRootProps, state } =
64
+ useRadio(props);
65
+
66
+ const styles = useStyleConfig("RadioCard", { variant });
67
+
68
+ const input = getInputProps({}, ref);
69
+ const radio = getRadioProps();
70
+
71
+ const id = `radio-card-${useId()}`;
72
+
73
+ return (
74
+ <chakra.label
75
+ htmlFor={id}
76
+ {...getRootProps()}
77
+ aria-label={String(children)}
78
+ >
79
+ <chakra.input {...input} id={id} disabled={state.isDisabled} />
80
+ <chakra.div
81
+ __css={styles}
82
+ {...radio}
83
+ data-checked={dataAttr(state.isChecked)}
84
+ data-hover={dataAttr(state.isHovered)}
85
+ data-focus={dataAttr(state.isFocused)}
86
+ data-active={dataAttr(state.isActive)}
87
+ data-disabled={dataAttr(state.isDisabled)}
88
+ {...props}
89
+ >
90
+ {children}
91
+ </chakra.div>
92
+ </chakra.label>
93
+ );
94
+ },
95
+ );
@@ -0,0 +1,81 @@
1
+ import {
2
+ useRadioGroup,
3
+ RadioGroupProps,
4
+ StackDirection,
5
+ Stack,
6
+ } from "@chakra-ui/react";
7
+ import React, { Children } from "react";
8
+
9
+ type RadioCardGroupProps = RadioGroupProps & {
10
+ children: React.ReactNode;
11
+ props?: RadioGroupProps;
12
+ direction?: StackDirection;
13
+ };
14
+
15
+ /**
16
+ * Radio card groups are used to group several radio cards together.
17
+ *
18
+ * You can and should pass the common `name` prop to the `RadioGroup`, instead of to each `Radio` component.
19
+ *
20
+ * ```tsx
21
+ * <RadioCardGroup name="ticket">
22
+ * <RadioCard>Economy</RadioCard>
23
+ * <RadioCard>Business</RadioCard>
24
+ * <RadioCard>First Class</RadioCard>
25
+ * </RadioCardGroup>
26
+ * ```
27
+ *
28
+ * By default, radio cards show up horizontally. If you want them to show up vertically, please specify the `direction="column"` prop.
29
+ *
30
+ * ```tsx
31
+ * <RadioCardGroup name="ticket" direction="column">
32
+ * <RadioCard>Economy</RadioCard>
33
+ * <RadioCard>Business</RadioCard>
34
+ * <RadioCard>First Class</RadioCard>
35
+ * </RadioCardGroup>
36
+ * ```
37
+ *
38
+ * You can also specify the `defaultValue` prop to set the default value of the radio group.
39
+ *
40
+ * ```tsx
41
+ * <RadioCardGroup name="ticket" defaultValue="Economy">
42
+ * <RadioCard>Economy</RadioCard>
43
+ * <RadioCard>Business</RadioCard>
44
+ * <RadioCard>First Class</RadioCard>
45
+ * </RadioCardGroup>
46
+ * ```
47
+ *
48
+ * Check out RadioCard for more information on how to style the radio cards.
49
+ * @see RadioCard
50
+ */
51
+
52
+ export const RadioCardGroup = ({
53
+ children,
54
+ name,
55
+ direction = "row",
56
+ onChange,
57
+ defaultValue,
58
+ variant = "base",
59
+ ...props
60
+ }: RadioCardGroupProps) => {
61
+ const { getRootProps, getRadioProps } = useRadioGroup({
62
+ defaultValue: defaultValue,
63
+ name: name,
64
+ onChange: onChange,
65
+ ...props,
66
+ });
67
+
68
+ const group = getRootProps();
69
+
70
+ return (
71
+ <Stack direction={direction} {...group}>
72
+ {Children.map(
73
+ children as React.ReactElement[],
74
+ (child: React.ReactElement) => {
75
+ const radio = getRadioProps({ value: child.props.value });
76
+ return React.cloneElement(child, { ...radio, variant, ...props });
77
+ },
78
+ )}
79
+ </Stack>
80
+ );
81
+ };
@@ -26,3 +26,5 @@ export type {
26
26
  } from "@chakra-ui/react";
27
27
  export * from "./Divider";
28
28
  export * from "./Stack";
29
+ export * from "./RadioCard";
30
+ export * from "./RadioCardGroup";
@@ -30,6 +30,7 @@ export { default as Pagination } from "./pagination";
30
30
  export { default as Popover } from "./popover";
31
31
  export { default as ProgressBar } from "./progress-bar";
32
32
  export { default as ProgressIndicator } from "./progress-indicator";
33
+ export { default as RadioCard } from "./radio-card";
33
34
  export { default as Radio } from "./radio";
34
35
  export { default as Select } from "./select";
35
36
  export { default as Skeleton } from "./skeleton";
@@ -0,0 +1,64 @@
1
+ import { defineStyleConfig } from "@chakra-ui/react";
2
+ import { baseBackground, baseBorder, baseText } from "../utils/base-utils";
3
+ import { floatingBackground, floatingBorder } from "../utils/floating-utils";
4
+ import { focusVisibleStyles } from "../utils/focus-utils";
5
+
6
+ const config = defineStyleConfig({
7
+ baseStyle: (props: any) => ({
8
+ appearance: "none",
9
+ border: "none",
10
+ overflow: "hidden",
11
+ fontSize: "inherit",
12
+ display: "block",
13
+ borderRadius: "sm",
14
+ ...focusVisibleStyles(props),
15
+ _checked: {
16
+ outline: "1px solid",
17
+ outlineColor: "greenHaze",
18
+ ...floatingBackground("active", props),
19
+ _hover: {
20
+ ...floatingBackground("active", props),
21
+ },
22
+ },
23
+ _disabled: {
24
+ pointerEvents: "none",
25
+ ...baseBackground("disabled", props),
26
+ ...baseBorder("disabled", props),
27
+ ...baseText("disabled", props),
28
+ },
29
+ }),
30
+ variants: {
31
+ base: (props) => ({
32
+ ...baseBackground("default", props),
33
+ ...baseBorder("default", props),
34
+ _hover: {
35
+ ...baseBackground("hover", props),
36
+ ...baseBorder("hover", props),
37
+ },
38
+ _active: {
39
+ ...baseBackground("active", props),
40
+ },
41
+ }),
42
+ floating: (props) => ({
43
+ ...floatingBackground("default", props),
44
+ boxShadow: "sm",
45
+ _hover: {
46
+ ...floatingBackground("hover", props),
47
+ ...floatingBorder("hover", props),
48
+ boxShadow: "md",
49
+ },
50
+ _active: {
51
+ ...floatingBackground("active", props),
52
+ ...floatingBorder("active", props),
53
+ },
54
+ _checked: {
55
+ _hover: {
56
+ outline: "1px solid",
57
+ outlineColor: "silver",
58
+ },
59
+ },
60
+ }),
61
+ },
62
+ });
63
+
64
+ export default config;
@@ -2,6 +2,7 @@ import { defineStyleConfig } from "@chakra-ui/react";
2
2
  import { mode } from "@chakra-ui/theme-tools";
3
3
  import { colors } from "../foundations";
4
4
  import { baseBorder, baseText } from "../utils/base-utils";
5
+ import { focusVisibleStyles } from "../utils/focus-utils";
5
6
 
6
7
  const config = defineStyleConfig({
7
8
  baseStyle: (props: any) => ({
@@ -13,6 +14,7 @@ const config = defineStyleConfig({
13
14
  borderRadius: "md",
14
15
  // Except for white cards, all cards are light mode always
15
16
  color: "text.default.light",
17
+ ...focusVisibleStyles(props),
16
18
  ...getColorSchemeBaseProps(props),
17
19
  }),
18
20
  });
@@ -23,12 +25,14 @@ type CardThemeProps = {
23
25
  colorScheme:
24
26
  | "white"
25
27
  | "grey"
26
- | "blue"
27
28
  | "green"
28
- | "teal"
29
- | "yellow"
30
29
  | "orange"
31
- | "red";
30
+ | "red"
31
+ | "yellow"
32
+ | "blue"
33
+ | "darkBlue"
34
+ | "darkGreen"
35
+ | "darkYellow";
32
36
  theme: any;
33
37
  colorMode: "light" | "dark";
34
38
  };
@@ -58,6 +62,23 @@ const getColorSchemeBaseProps = (props: CardThemeProps) => {
58
62
  backgroundColor: "pink",
59
63
  };
60
64
  }
65
+ case "darkBlue": {
66
+ return {
67
+ backgroundColor: "darkBlue",
68
+ color: "white",
69
+ };
70
+ }
71
+ case "darkGreen": {
72
+ return {
73
+ backgroundColor: "pine",
74
+ color: "white",
75
+ };
76
+ }
77
+ case "darkYellow": {
78
+ return {
79
+ backgroundColor: "banana",
80
+ };
81
+ }
61
82
  default:
62
83
  return {
63
84
  backgroundColor: colors[props.colorScheme]?.[100] ?? "default",
@@ -22,12 +22,10 @@ const config = helpers.defineMultiStyleConfig({
22
22
  th: {
23
23
  fontWeight: "bold",
24
24
  textAlign: "start",
25
- verticalAlign: "top",
26
25
  minWidth: "68px",
27
26
  },
28
27
  td: {
29
28
  textAlign: "start",
30
- verticalAlign: "top",
31
29
  },
32
30
  tfoot: {
33
31
  tr: {
@@ -38,7 +38,10 @@ export function floatingBackground(
38
38
  }
39
39
  }
40
40
 
41
- type FloatingBorderState = Subset<State, "default" | "hover" | "active">;
41
+ type FloatingBorderState = Subset<
42
+ State,
43
+ "default" | "hover" | "active" | "selected"
44
+ >;
42
45
  export function floatingBorder(
43
46
  state: FloatingBorderState,
44
47
  props: StyleFunctionProps,
@@ -52,6 +55,19 @@ export function floatingBorder(
52
55
  "floating.outline.hover.dark",
53
56
  )(props),
54
57
  };
58
+ case "selected":
59
+ return {
60
+ outline: "1px solid",
61
+ outlineColor: mode("outline.focus.light", "outline.focus.dark")(props),
62
+ };
63
+ case "active":
64
+ return {
65
+ outline: "1px solid",
66
+ outlineColor: mode(
67
+ "floating.outline.active.light",
68
+ "floating.outline.active.dark",
69
+ )(props),
70
+ };
55
71
  default:
56
72
  return {
57
73
  outline: "1px solid",