@vygruppen/spor-react 12.4.12 → 12.4.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vygruppen/spor-react",
3
- "version": "12.4.12",
3
+ "version": "12.4.14",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist/index.d.ts",
@@ -45,8 +45,8 @@
45
45
  "react-stately": "^3.31.1",
46
46
  "react-swipeable": "^7.0.1",
47
47
  "usehooks-ts": "^3.1.0",
48
- "@vygruppen/spor-icon-react": "4.1.0",
49
48
  "@vygruppen/spor-design-tokens": "4.0.7",
49
+ "@vygruppen/spor-icon-react": "4.1.0",
50
50
  "@vygruppen/spor-loader": "0.6.0"
51
51
  },
52
52
  "devDependencies": {
@@ -66,8 +66,8 @@
66
66
  "vitest": "^0.26.3",
67
67
  "vitest-axe": "^0.1.0",
68
68
  "vitest-canvas-mock": "^0.2.2",
69
- "@vygruppen/tsconfig": "0.1.0",
70
- "@vygruppen/eslint-config": "1.1.1"
69
+ "@vygruppen/eslint-config": "1.1.1",
70
+ "@vygruppen/tsconfig": "0.1.0"
71
71
  },
72
72
  "peerDependencies": {
73
73
  "react": ">=18.0.0 <19.0.0",
@@ -21,8 +21,8 @@ export type ComboboxProps<T> = Exclude<
21
21
  inputRef?: React.RefObject<HTMLInputElement>;
22
22
  /** If you want to allow an empty collection */
23
23
  allowsEmptyCollection?: boolean;
24
- lefticon?: ReactNode;
25
- righticon?: ReactNode;
24
+ leftIcon?: ReactNode;
25
+ rightIcon?: ReactNode;
26
26
  variant?: "core" | "floating";
27
27
  children?: React.ReactNode;
28
28
  };
@@ -54,8 +54,8 @@ export const Combobox = (props: ComboboxProps<object>) => {
54
54
  const {
55
55
  label,
56
56
  loading,
57
- lefticon,
58
- righticon,
57
+ leftIcon,
58
+ rightIcon,
59
59
  borderBottomLeftRadius = "sm",
60
60
  borderBottomRightRadius = "sm",
61
61
  borderTopLeftRadius = "sm",
@@ -109,7 +109,7 @@ export const Combobox = (props: ComboboxProps<object>) => {
109
109
  paddingLeft,
110
110
  paddingX,
111
111
  paddingY,
112
- lefticon,
112
+ leftIcon,
113
113
  };
114
114
 
115
115
  const {
@@ -150,6 +150,7 @@ export const Combobox = (props: ComboboxProps<object>) => {
150
150
  }
151
151
  _active={{ backgroundColor: "core.surface.active" }}
152
152
  {...inputProps}
153
+ startElement={leftIcon}
153
154
  endElement={
154
155
  loading ? (
155
156
  <ColorSpinner
@@ -164,7 +165,7 @@ export const Combobox = (props: ComboboxProps<object>) => {
164
165
  }}
165
166
  />
166
167
  ) : (
167
- righticon
168
+ rightIcon
168
169
  )
169
170
  }
170
171
  placeholder=""
@@ -68,7 +68,7 @@ export const Field = React.forwardRef<HTMLDivElement, FieldProps>(
68
68
  const styles = recipe();
69
69
 
70
70
  return (
71
- <Stack gap="2" ref={ref} {...rest} width="100%">
71
+ <Stack gap="2" ref={ref} {...rest}>
72
72
  <ChakraField.Root
73
73
  disabled={disabled}
74
74
  invalid={invalid}
@@ -2,30 +2,22 @@
2
2
  import {
3
3
  Link as ChakraLink,
4
4
  LinkProps as ChakraLinkProps,
5
- RecipeVariantProps,
6
5
  VisuallyHidden,
7
6
  } from "@chakra-ui/react";
8
- import { LinkOutOutline24Icon } from "@vygruppen/spor-icon-react";
9
- import React, {
10
- cloneElement,
11
- forwardRef,
12
- isValidElement,
13
- PropsWithChildren,
14
- } from "react";
7
+ import {
8
+ LinkOutOutline18Icon,
9
+ LinkOutOutline24Icon,
10
+ } from "@vygruppen/spor-icon-react";
11
+ import React, { cloneElement, forwardRef, isValidElement } from "react";
15
12
 
16
13
  import { createTexts, useTranslation } from "@/i18n";
17
14
 
18
- import { linkRecipe } from "../theme/recipes/link";
19
-
20
- type linkVariantProps = RecipeVariantProps<typeof linkRecipe>;
21
-
22
- export type LinkProps = Exclude<ChakraLinkProps, "variant"> &
23
- PropsWithChildren<linkVariantProps> & {
24
- /** Defaults to primary */
25
- variant?: "primary" | "secondary";
26
- /** Define if the link shows an icon on the right that indicate it is an external link */
27
- external?: boolean;
28
- };
15
+ export type LinkProps = ChakraLinkProps & {
16
+ /** Defaults to primary */
17
+ variant?: "primary" | "secondary";
18
+ /** Define if the link shows an icon on the right that indicate it is an external link */
19
+ external?: boolean;
20
+ };
29
21
 
30
22
  /** Link to different sites or parts of site
31
23
  *
@@ -36,9 +28,20 @@ export type LinkProps = Exclude<ChakraLinkProps, "variant"> &
36
28
  * </TextLink>
37
29
  * ```
38
30
  */
39
- const ExternalIcon = ({ label }: { label: string }) => (
31
+ const ExternalIcon = ({
32
+ label,
33
+ size,
34
+ }: {
35
+ label: string;
36
+ size: LinkProps["size"];
37
+ }) => (
40
38
  <>
41
- <LinkOutOutline24Icon aria-hidden />
39
+ {size === "lg" || size === "md" ? (
40
+ <LinkOutOutline24Icon aria-hidden />
41
+ ) : (
42
+ <LinkOutOutline18Icon aria-hidden />
43
+ )}
44
+ {/* Visually hidden text for screen readers */}
42
45
  <VisuallyHidden>{label}</VisuallyHidden>
43
46
  </>
44
47
  );
@@ -62,7 +65,9 @@ export const TextLink = forwardRef<HTMLAnchorElement, LinkProps>(
62
65
  children: (
63
66
  <>
64
67
  {children.props.children}
65
- {isExternal && <ExternalIcon label={externalLabel} />}
68
+ {isExternal && (
69
+ <ExternalIcon label={externalLabel} size={props.size} />
70
+ )}
66
71
  </>
67
72
  ),
68
73
  })}
@@ -73,7 +78,7 @@ export const TextLink = forwardRef<HTMLAnchorElement, LinkProps>(
73
78
  return (
74
79
  <ChakraLink href={href} {...props} ref={ref}>
75
80
  {children}
76
- {isExternal && <ExternalIcon label={externalLabel} />}
81
+ {isExternal && <ExternalIcon label={externalLabel} size={props.size} />}
77
82
  </ChakraLink>
78
83
  );
79
84
  },
@@ -15,6 +15,7 @@ export const linkRecipe = defineRecipe({
15
15
  paddingY: "0",
16
16
  color: "inherit",
17
17
  display: "inline-flex",
18
+ alignItems: "center",
18
19
  gap: "0",
19
20
  position: "relative",
20
21
  boxDecorationBreak: "clone",
@@ -59,5 +60,23 @@ export const linkRecipe = defineRecipe({
59
60
  },
60
61
  },
61
62
  },
63
+ size: {
64
+ xs: {
65
+ fontSize: { base: "mobile.xs", sm: "desktop.xs" },
66
+ },
67
+ sm: {
68
+ fontSize: { base: "mobile.sm", sm: "desktop.sm" },
69
+ },
70
+ md: {
71
+ fontSize: { base: "mobile.md", sm: "desktop.md" },
72
+ },
73
+ lg: {
74
+ fontSize: { base: "mobile.lg", sm: "desktop.lg" },
75
+ },
76
+ },
77
+ },
78
+ defaultVariants: {
79
+ variant: "primary",
80
+ size: "sm",
62
81
  },
63
82
  });