@vygruppen/spor-react 9.7.0 → 9.8.1

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.js CHANGED
@@ -907,12 +907,41 @@ var init_RadioCardGroup = __esm({
907
907
  };
908
908
  }
909
909
  });
910
+ exports.StaticCard = void 0;
911
+ var init_StaticCard = __esm({
912
+ "src/layout/StaticCard.tsx"() {
913
+ exports.StaticCard = react.forwardRef(
914
+ ({ colorScheme = "white", children, ...props }, ref) => {
915
+ const styles3 = react.useStyleConfig("StaticCard", {
916
+ colorScheme
917
+ });
918
+ return /* @__PURE__ */ React73__namespace.default.createElement(react.Box, { __css: styles3, ...props, ref }, children, /* @__PURE__ */ React73__namespace.default.createElement(react.Card, null));
919
+ }
920
+ );
921
+ }
922
+ });
923
+ exports.PressableCard = void 0;
924
+ var init_PressableCard = __esm({
925
+ "src/layout/PressableCard.tsx"() {
926
+ exports.PressableCard = ({
927
+ children,
928
+ as = "button",
929
+ variant = "base",
930
+ ...props
931
+ }) => {
932
+ const styles3 = react.useStyleConfig("PressableCard", { variant });
933
+ return /* @__PURE__ */ React73__namespace.default.createElement(react.Box, { as, __css: styles3, ...props }, children);
934
+ };
935
+ }
936
+ });
910
937
  var init_layout = __esm({
911
938
  "src/layout/index.tsx"() {
912
939
  init_Divider();
913
940
  init_Stack();
914
941
  init_RadioCard();
915
942
  init_RadioCardGroup();
943
+ init_StaticCard();
944
+ init_PressableCard();
916
945
  }
917
946
  });
918
947
  var AccordionContext, AccordionProvider, useAccordionContext;
@@ -1938,6 +1967,9 @@ var init_Card = __esm({
1938
1967
  "src/card/Card.tsx"() {
1939
1968
  exports.Card = react.forwardRef(
1940
1969
  ({ size: size2 = "sm", colorScheme = "white", children, ...props }, ref) => {
1970
+ console.warn(
1971
+ "Warning: Card is deprecated. Use `StaticCard` or `PressableCard` instead."
1972
+ );
1941
1973
  const styles3 = react.useStyleConfig("Card", {
1942
1974
  colorScheme,
1943
1975
  size: size2
@@ -1947,37 +1979,11 @@ var init_Card = __esm({
1947
1979
  );
1948
1980
  }
1949
1981
  });
1950
- exports.StaticCard = void 0;
1951
- var init_StaticCard = __esm({
1952
- "src/card/StaticCard.tsx"() {
1953
- exports.StaticCard = ({ colorScheme, ...props }) => {
1954
- const styles3 = react.useStyleConfig("StaticCard", { colorScheme });
1955
- return /* @__PURE__ */ React73__namespace.default.createElement(react.Box, { __css: styles3, ...props });
1956
- };
1957
- }
1958
- });
1959
- exports.PressableCard = void 0;
1960
- var init_PressableCard = __esm({
1961
- "src/card/PressableCard.tsx"() {
1962
- exports.PressableCard = ({
1963
- children,
1964
- as = "button",
1965
- size: size2 = "sm",
1966
- variant = "base",
1967
- ...props
1968
- }) => {
1969
- const styles3 = react.useStyleConfig("PressableCard", { variant, size: size2 });
1970
- return /* @__PURE__ */ React73__namespace.default.createElement(react.Box, { as, __css: styles3, ...props }, children);
1971
- };
1972
- }
1973
- });
1974
1982
 
1975
1983
  // src/card/index.tsx
1976
1984
  var init_card = __esm({
1977
1985
  "src/card/index.tsx"() {
1978
1986
  init_Card();
1979
- init_StaticCard();
1980
- init_PressableCard();
1981
1987
  }
1982
1988
  });
1983
1989
  exports.Badge = void 0;
@@ -11231,6 +11237,12 @@ function baseBorder(state2, props) {
11231
11237
  )(props)
11232
11238
  };
11233
11239
  }
11240
+ case "active": {
11241
+ return {
11242
+ outline: "2px solid",
11243
+ outlineColor: themeTools.mode("base.outline.light", "base.outline.dark")(props)
11244
+ };
11245
+ }
11234
11246
  case "invalid": {
11235
11247
  return {
11236
11248
  outline: "2px solid",
@@ -15449,7 +15461,6 @@ var config43, static_card_default, getColorSchemeBaseProps2;
15449
15461
  var init_static_card = __esm({
15450
15462
  "src/theme/components/static-card.ts"() {
15451
15463
  init_foundations();
15452
- init_base_utils();
15453
15464
  init_focus_utils();
15454
15465
  config43 = react.defineStyleConfig({
15455
15466
  baseStyle: (props) => ({
@@ -15459,7 +15470,6 @@ var init_static_card = __esm({
15459
15470
  fontSize: "inherit",
15460
15471
  display: "block",
15461
15472
  borderRadius: "md",
15462
- // Except for white cards, all cards are light mode always
15463
15473
  color: "text.default.light",
15464
15474
  ...focusVisibleStyles(props),
15465
15475
  ...getColorSchemeBaseProps2(props)
@@ -15471,12 +15481,8 @@ var init_static_card = __esm({
15471
15481
  switch (props.colorScheme) {
15472
15482
  case "white":
15473
15483
  return {
15474
- ...baseBorder("default", props),
15475
- backgroundColor: themeTools.mode(
15476
- "white",
15477
- `color-mix(in srgb, white 10%, var(--spor-colors-bg-default-dark))`
15478
- )(props),
15479
- color: "inherit"
15484
+ backgroundColor: "white",
15485
+ color: "darkGrey"
15480
15486
  };
15481
15487
  case "grey":
15482
15488
  return {
@@ -15511,33 +15517,13 @@ var init_static_card = __esm({
15511
15517
  }
15512
15518
  default:
15513
15519
  return {
15514
- backgroundColor: ((_a6 = colors2[props.colorScheme]) == null ? void 0 : _a6[100]) ?? "default",
15515
- ...baseText("default", props)
15520
+ backgroundColor: ((_a6 = colors2[props.colorScheme]) == null ? void 0 : _a6[100]) ?? "default"
15516
15521
  };
15517
15522
  }
15518
15523
  };
15519
15524
  }
15520
15525
  });
15521
- function getColorSchemeClickableProps2(props) {
15522
- switch (props.colorScheme) {
15523
- case "default":
15524
- return {
15525
- ...floatingBorder("default", props)
15526
- };
15527
- case "accent":
15528
- return {
15529
- ...accentBackground("default", props),
15530
- ...accentText("default", props),
15531
- _hover: {
15532
- ...accentBackground("hover", props)
15533
- },
15534
- _active: {
15535
- ...accentBackground("active", props)
15536
- }
15537
- };
15538
- }
15539
- }
15540
- var config44, pressable_card_default, getColorSchemeBaseProps3, getColorSchemeHoverProps2, getColorSchemeActiveProps2;
15526
+ var config44, pressable_card_default;
15541
15527
  var init_pressable_card = __esm({
15542
15528
  "src/theme/components/pressable-card.ts"() {
15543
15529
  init_base_utils();
@@ -15552,137 +15538,52 @@ var init_pressable_card = __esm({
15552
15538
  fontSize: "inherit",
15553
15539
  display: "block",
15554
15540
  borderRadius: "md",
15555
- ...getColorSchemeBaseProps3(props),
15556
- ...getColorSchemeClickableProps2(props),
15557
15541
  ...focusVisibleStyles(props),
15558
- ...getColorSchemeActiveProps2(props),
15559
- _hover: getColorSchemeHoverProps2(props),
15560
15542
  _disabled: {
15561
15543
  ...baseBackground("disabled", props),
15562
- ...baseBorder("disabled", props),
15563
15544
  ...baseText("disabled", props),
15545
+ outline: "none",
15564
15546
  pointerEvents: "none"
15565
15547
  }
15566
15548
  }),
15567
15549
  variants: {
15568
15550
  base: (props) => ({
15569
- ...baseBackground("default", props),
15551
+ ...baseBorder("default", props),
15570
15552
  _hover: {
15571
- ...baseBackground("hover", props)
15553
+ ...baseBorder("hover", props)
15572
15554
  },
15573
15555
  _active: {
15574
- ...baseBackground("active", props)
15556
+ ...baseBackground("active", props),
15557
+ ...baseBorder("active", props)
15575
15558
  }
15576
15559
  }),
15577
15560
  accent: (props) => ({
15578
15561
  ...accentBackground("default", props),
15562
+ boxShadow: "sm",
15579
15563
  _hover: {
15580
- ...accentBackground("hover", props)
15564
+ ...accentBackground("hover", props),
15565
+ boxShadow: "sm"
15581
15566
  },
15582
15567
  _active: {
15583
- ...accentBackground("active", props)
15568
+ ...accentBackground("active", props),
15569
+ boxShadow: "none"
15584
15570
  }
15585
15571
  }),
15586
15572
  floating: (props) => ({
15587
15573
  ...floatingBackground("default", props),
15588
- _hover: {
15589
- ...floatingBackground("hover", props)
15590
- },
15591
- _active: {
15592
- ...floatingBackground("active", props)
15593
- }
15594
- })
15595
- },
15596
- sizes: {
15597
- sm: {
15598
15574
  boxShadow: "sm",
15599
15575
  _hover: {
15576
+ ...floatingBackground("hover", props),
15600
15577
  boxShadow: "md"
15601
15578
  },
15602
15579
  _active: {
15580
+ ...floatingBackground("active", props),
15603
15581
  boxShadow: "none"
15604
15582
  }
15605
- },
15606
- lg: {
15607
- boxShadow: "md",
15608
- _hover: {
15609
- boxShadow: "lg"
15610
- },
15611
- _active: {
15612
- boxShadow: "sm"
15613
- }
15614
- }
15583
+ })
15615
15584
  }
15616
15585
  });
15617
15586
  pressable_card_default = config44;
15618
- getColorSchemeBaseProps3 = (props) => {
15619
- switch (props.colorScheme) {
15620
- case "default":
15621
- return {
15622
- ...baseBorder("default", props),
15623
- backgroundColor: themeTools.mode(
15624
- "white",
15625
- `color-mix(in srgb, white 10%, var(--spor-colors-bg-default-dark))`
15626
- )(props),
15627
- color: "inherit"
15628
- };
15629
- case "accent":
15630
- return {
15631
- ...accentBackground("default", props),
15632
- ...accentText("default", props),
15633
- _hover: {
15634
- ...accentBackground("hover", props)
15635
- },
15636
- _active: {
15637
- ...accentBackground("active", props)
15638
- }
15639
- };
15640
- }
15641
- };
15642
- getColorSchemeHoverProps2 = (props) => {
15643
- switch (props.colorScheme) {
15644
- case "default":
15645
- return {
15646
- backgroundColor: themeTools.mode(
15647
- "white",
15648
- `color-mix(in srgb, white 20%, var(--spor-colors-bg-default-dark))`
15649
- )(props),
15650
- ...floatingBorder("hover", props)
15651
- };
15652
- case "accent":
15653
- return {
15654
- ...accentBackground("default", props),
15655
- ...accentText("default", props),
15656
- _hover: {
15657
- ...accentBackground("hover", props)
15658
- },
15659
- _active: {
15660
- ...accentBackground("active", props)
15661
- }
15662
- };
15663
- }
15664
- };
15665
- getColorSchemeActiveProps2 = (props) => {
15666
- const { colorScheme } = props;
15667
- switch (colorScheme) {
15668
- case "default":
15669
- return {
15670
- backgroundColor: themeTools.mode("bg.tertiary.light", `bg.default.dark`)(props),
15671
- ...floatingBorder("active", props)
15672
- };
15673
- case "accent":
15674
- return {
15675
- ...accentBackground("default", props),
15676
- ...accentText("default", props),
15677
- _hover: {
15678
- ...accentBackground("hover", props)
15679
- },
15680
- _active: {
15681
- ...accentBackground("active", props)
15682
- }
15683
- };
15684
- }
15685
- };
15686
15587
  }
15687
15588
  });
15688
15589
 
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, 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';
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-S335RZ6M.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vygruppen/spor-react",
3
- "version": "9.7.0",
3
+ "version": "9.8.1",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
package/src/card/Card.tsx CHANGED
@@ -50,8 +50,15 @@ export type CardProps = Exclude<BoxProps, "size"> & {
50
50
  * </Card>
51
51
  * ```
52
52
  */
53
+
54
+ /**
55
+ * @deprecated Card is deprecated. Use `StaticCard` or `PressableCard` instead.
56
+ */
53
57
  export const Card = forwardRef<CardProps, As>(
54
58
  ({ size = "sm", colorScheme = "white", children, ...props }, ref) => {
59
+ console.warn(
60
+ "Warning: Card is deprecated. Use `StaticCard` or `PressableCard` instead.",
61
+ );
55
62
  const styles = useStyleConfig("Card", {
56
63
  colorScheme,
57
64
  size,
@@ -1,3 +1 @@
1
1
  export * from "./Card";
2
- export * from "./StaticCard";
3
- export * from "./PressableCard";
@@ -0,0 +1,54 @@
1
+ import React from "react";
2
+ import { Box, BoxProps, useStyleConfig } from "@chakra-ui/react";
3
+
4
+ type PressableCardProps = Omit<BoxProps, "as"> & {
5
+ /** Defaults to "base" */
6
+ variant: "floating" | "accent" | "base";
7
+ /** Defaults to "button" */
8
+ as: "button" | "a" | "label";
9
+ };
10
+
11
+ /**
12
+ * `PressableCard` is a component that renders a pressable card.
13
+ *
14
+ * The `PressableCard` component can be used to create a card that responds to user interactions.
15
+ * It can be rendered as a button, link, label, or any other HTML element by specifying the `as` prop.
16
+ * If no `as` prop is provided, it defaults to a button.
17
+ *
18
+ * The `size` prop can be used to control the size of the card. It defaults to "sm".
19
+ * The `variant` prop can be used to control the style variant of the card. It defaults to "base".
20
+ *
21
+ * Example usage:
22
+ *
23
+ * ```tsx
24
+ * <PressableCard>
25
+ * Content
26
+ * </PressableCard>
27
+ * ```
28
+ *
29
+ * To render the card as a different HTML element, specify the `as` prop:
30
+ *
31
+ * ```tsx
32
+ * <PressableCard as="a">
33
+ * This is now a <a /> element
34
+ * </PressableCard>
35
+ * ```
36
+ *
37
+ * For a static card with other color schemes, use the `StaticCard` component.
38
+ *
39
+ * @see StaticCard
40
+ */
41
+
42
+ export const PressableCard = ({
43
+ children,
44
+ as = "button",
45
+ variant = "base",
46
+ ...props
47
+ }: PressableCardProps) => {
48
+ const styles = useStyleConfig("PressableCard", { variant });
49
+ return (
50
+ <Box as={as} __css={styles} {...props}>
51
+ {children}
52
+ </Box>
53
+ );
54
+ };
@@ -12,6 +12,7 @@ import React, { useId } from "react";
12
12
  type RadioCardProps = UseRadioProps &
13
13
  BoxProps & {
14
14
  children: React.ReactNode;
15
+ /** Defaults to "base" */
15
16
  variant: "floating" | "base";
16
17
  };
17
18
 
@@ -9,7 +9,16 @@ import React, { Children } from "react";
9
9
  type RadioCardGroupProps = RadioGroupProps & {
10
10
  children: React.ReactNode;
11
11
  props?: RadioGroupProps;
12
+ /** Defaults to "row" */
12
13
  direction?: StackDirection;
14
+ /** Defaults to "base" */
15
+ variant?: string;
16
+ /** The name of the radio group */
17
+ name?: string;
18
+ /** The default value of the radio group */
19
+ defaultValue?: string;
20
+ /** The callback function to be called when the radio group value changes */
21
+ onChange?: (value: string) => void;
13
22
  };
14
23
 
15
24
  /**
@@ -0,0 +1,77 @@
1
+ import React from "react";
2
+ import {
3
+ As,
4
+ Box,
5
+ BoxProps,
6
+ useStyleConfig,
7
+ forwardRef,
8
+ Card,
9
+ } from "@chakra-ui/react";
10
+
11
+ export type StaticCardProps = BoxProps & {
12
+ children: React.ReactNode;
13
+ /** Defaults to "white" */
14
+ colorScheme:
15
+ | "white"
16
+ | "grey"
17
+ | "green"
18
+ | "orange"
19
+ | "red"
20
+ | "yellow"
21
+ | "blue"
22
+ | "darkBlue"
23
+ | "darkGreen"
24
+ | "darkYellow";
25
+ };
26
+
27
+ /**
28
+ * `StaticCard` is a component that renders a static card.
29
+ *
30
+ * The `StaticCard` component can be used to create a card that does not respond to user interactions.
31
+ * It can be rendered as any HTML element by specifying the `as` prop.
32
+ *
33
+ * The `colorScheme` prop can be used to control the color scheme of the card. It defaults to "white".
34
+ *
35
+ * Example usage:
36
+ *
37
+ * ```tsx
38
+ * <StaticCard>
39
+ * Content
40
+ * </StaticCard>
41
+ * ```
42
+ *
43
+ * To render the card as a different HTML element, specify the `as` prop:
44
+ *
45
+ * ```tsx
46
+ * <StaticCard as="section">
47
+ * This is now a <section /> element
48
+ * </StaticCard>
49
+ * ```
50
+ *
51
+ * To change the color scheme of the card, specify the `colorScheme` prop:
52
+ *
53
+ * ```tsx
54
+ * <StaticCard colorScheme="orange">
55
+ * An orange card
56
+ * </StaticCard>
57
+ * ```
58
+ *
59
+ * For a card with click functionality, use the `PressableCard` component.
60
+ *
61
+ * @see PressableCard
62
+ */
63
+
64
+ export const StaticCard = forwardRef<StaticCardProps, As>(
65
+ ({ colorScheme = "white", children, ...props }, ref) => {
66
+ const styles = useStyleConfig("StaticCard", {
67
+ colorScheme,
68
+ });
69
+
70
+ return (
71
+ <Box __css={styles} {...props} ref={ref}>
72
+ {children}
73
+ <Card />
74
+ </Box>
75
+ );
76
+ },
77
+ );
@@ -28,3 +28,5 @@ export * from "./Divider";
28
28
  export * from "./Stack";
29
29
  export * from "./RadioCard";
30
30
  export * from "./RadioCardGroup";
31
+ export * from "./StaticCard";
32
+ export * from "./PressableCard";