@vygruppen/spor-react 12.1.2 → 12.2.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.
Files changed (118) hide show
  1. package/.turbo/turbo-build.log +11 -11
  2. package/.turbo/turbo-typegen.log +1 -1
  3. package/CHANGELOG.md +6 -0
  4. package/dist/index.d.mts +148 -151
  5. package/dist/index.d.ts +148 -151
  6. package/dist/index.js +2284 -1880
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +2169 -1774
  9. package/dist/index.mjs.map +1 -1
  10. package/package.json +3 -3
  11. package/src/accordion/Accordion.tsx +2 -1
  12. package/src/accordion/Expandable.tsx +3 -1
  13. package/src/accordion/helpers.ts +2 -1
  14. package/src/alert/Alert.tsx +3 -1
  15. package/src/alert/AlertIcon.tsx +17 -10
  16. package/src/alert/ExpandableAlert.tsx +3 -2
  17. package/src/alert/ServiceAlert.tsx +2 -1
  18. package/src/breadcrumb/Breadcrumb.tsx +9 -8
  19. package/src/button/Button.tsx +2 -1
  20. package/src/button/ButtonGroup.tsx +2 -1
  21. package/src/button/Clipboard.tsx +3 -0
  22. package/src/button/CloseButton.tsx +8 -4
  23. package/src/button/FloatingActionButton.tsx +5 -5
  24. package/src/button/IconButton.tsx +1 -0
  25. package/src/color-mode/color-mode.tsx +2 -2
  26. package/src/datepicker/Calendar.tsx +0 -1
  27. package/src/datepicker/CalendarCell.tsx +5 -5
  28. package/src/datepicker/CalendarGrid.tsx +3 -2
  29. package/src/datepicker/CalendarHeader.tsx +1 -4
  30. package/src/datepicker/CalendarTriggerButton.tsx +3 -4
  31. package/src/datepicker/DateField.tsx +13 -6
  32. package/src/datepicker/DatePicker.tsx +2 -1
  33. package/src/datepicker/DateRangePicker.tsx +1 -1
  34. package/src/datepicker/DateTimeSegment.tsx +2 -1
  35. package/src/datepicker/RangeCalendar.tsx +1 -1
  36. package/src/datepicker/StyledField.tsx +1 -1
  37. package/src/datepicker/TimeField.tsx +3 -3
  38. package/src/datepicker/TimePicker.tsx +4 -2
  39. package/src/datepicker/utils.ts +10 -5
  40. package/src/dialog/Dialog.tsx +1 -0
  41. package/src/dialog/Drawer.tsx +28 -26
  42. package/src/i18n/index.tsx +1 -0
  43. package/src/input/AttachedInputs.tsx +6 -3
  44. package/src/input/CardSelect.tsx +3 -1
  45. package/src/input/Checkbox.tsx +1 -0
  46. package/src/input/CheckboxGroup.tsx +3 -1
  47. package/src/input/ChoiceChip.tsx +1 -1
  48. package/src/input/Combobox.tsx +6 -4
  49. package/src/input/CountryCodeSelect.tsx +10 -4
  50. package/src/input/Field.tsx +2 -0
  51. package/src/input/Input.tsx +2 -3
  52. package/src/input/InputGroup.tsx +1 -1
  53. package/src/input/ListBox.tsx +9 -8
  54. package/src/input/NativeSelect.tsx +1 -2
  55. package/src/input/NumericStepper.tsx +22 -23
  56. package/src/input/PasswordInput.tsx +2 -1
  57. package/src/input/PhoneNumberInput.tsx +6 -2
  58. package/src/input/Popover.tsx +2 -0
  59. package/src/input/Radio.tsx +2 -0
  60. package/src/input/SearchInput.tsx +2 -1
  61. package/src/input/Select.tsx +8 -2
  62. package/src/input/Switch.tsx +22 -34
  63. package/src/input/Textarea.tsx +6 -4
  64. package/src/input/index.ts +1 -1
  65. package/src/layout/PressableCard.tsx +5 -2
  66. package/src/layout/RadioCard.tsx +3 -1
  67. package/src/layout/Separator.tsx +2 -1
  68. package/src/layout/StaticCard.tsx +6 -3
  69. package/src/linjetag/InfoTag.tsx +3 -2
  70. package/src/linjetag/LineIcon.tsx +5 -4
  71. package/src/linjetag/TravelTag.tsx +12 -8
  72. package/src/link/TextLink.tsx +1 -1
  73. package/src/loader/ColorInlineLoader.tsx +0 -1
  74. package/src/loader/ColorSpinner.tsx +0 -1
  75. package/src/loader/ContentLoader.tsx +0 -1
  76. package/src/loader/DarkFullScreenLoader.tsx +0 -1
  77. package/src/loader/DarkInlineLoader.tsx +0 -1
  78. package/src/loader/DarkSpinner.tsx +0 -1
  79. package/src/loader/LightFullScreenLoader.tsx +0 -1
  80. package/src/loader/LightInlineLoader.tsx +0 -1
  81. package/src/loader/LightSpinner.tsx +0 -1
  82. package/src/loader/Lottie.tsx +1 -2
  83. package/src/loader/ProgressBar.tsx +1 -2
  84. package/src/loader/ProgressLoader.tsx +2 -7
  85. package/src/logo/CargonetLogo.tsx +2 -1
  86. package/src/logo/VyLogo.tsx +3 -4
  87. package/src/logo/VyLogoPride.tsx +4 -1
  88. package/src/media-controller/JumpButton.tsx +2 -1
  89. package/src/media-controller/PlayPauseButton.tsx +2 -1
  90. package/src/media-controller/SkipButton.tsx +2 -1
  91. package/src/nudge/Nudge.tsx +7 -14
  92. package/src/pagination/Pagination.tsx +5 -0
  93. package/src/popover/index.tsx +2 -0
  94. package/src/progress-indicator/ProgressDot.tsx +1 -1
  95. package/src/progress-indicator/ProgressIndicator.tsx +4 -2
  96. package/src/provider/SporProvider.tsx +0 -1
  97. package/src/stepper/Stepper.tsx +1 -1
  98. package/src/tab/Tabs.tsx +1 -1
  99. package/src/table/Table.tsx +2 -1
  100. package/src/theme/slot-recipes/alert-expandable.ts +0 -4
  101. package/src/theme/slot-recipes/info-tag.ts +0 -1
  102. package/src/theme/slot-recipes/popover.ts +0 -1
  103. package/src/theme/slot-recipes/radio-card.ts +0 -3
  104. package/src/theme/utils/accent-utils.ts +12 -6
  105. package/src/theme/utils/bg-utils.ts +6 -3
  106. package/src/theme/utils/brand-utils.ts +7 -7
  107. package/src/theme/utils/core-utils.ts +23 -13
  108. package/src/theme/utils/floating-utils.ts +16 -8
  109. package/src/theme/utils/ghost-utils.ts +8 -4
  110. package/src/theme/utils/input-utils.ts +7 -4
  111. package/src/theme/utils/outline-utils.ts +6 -3
  112. package/src/theme/utils/surface-utils.ts +8 -4
  113. package/src/toast/toast.tsx +0 -1
  114. package/src/typography/Badge.tsx +8 -5
  115. package/src/typography/Heading.tsx +1 -1
  116. package/src/typography/Text.tsx +1 -1
  117. package/src/util/slugify.tsx +8 -8
  118. package/tsconfig.json +1 -0
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { chakra, useSlotRecipe } from "@chakra-ui/react";
3
- import React, { PropsWithChildren } from "react";
3
+ import { PropsWithChildren } from "react";
4
4
 
5
5
  import { ProgressIndicatorVariantProps } from "./ProgressIndicator";
6
6
 
@@ -35,7 +35,7 @@ export type ProgressIndicatorProps = BoxProps &
35
35
  export const ProgressIndicator = forwardRef<
36
36
  HTMLDivElement,
37
37
  ProgressIndicatorProps
38
- >(({ numberOfSteps, activeStep, colorPalette = "brand" }) => {
38
+ >(({ numberOfSteps, activeStep }) => {
39
39
  const { t } = useTranslation();
40
40
  const recipe = useSlotRecipe({
41
41
  key: "progressIndicator",
@@ -56,7 +56,7 @@ export const ProgressIndicator = forwardRef<
56
56
  {Array.from({ length: numberOfSteps }, (_, i) => (
57
57
  <ProgressDot
58
58
  key={i}
59
- aria-value={i + 1}
59
+ aria-valuenow={i + 1}
60
60
  isActive={activeStep === i + 1}
61
61
  />
62
62
  ))}
@@ -64,6 +64,8 @@ export const ProgressIndicator = forwardRef<
64
64
  </Box>
65
65
  );
66
66
  });
67
+ ProgressIndicator.displayName = "ProgressIndicator";
68
+
67
69
  const texts = createTexts({
68
70
  stepsOf: (activeStep, numberOfSteps) => ({
69
71
  nb: `Steg ${activeStep} av ${numberOfSteps}`,
@@ -5,7 +5,6 @@ import {
5
5
  SystemContext,
6
6
  } from "@chakra-ui/react";
7
7
  import { Global } from "@emotion/react";
8
- import React from "react";
9
8
 
10
9
  import { Language, LanguageProvider, system } from "..";
11
10
  import { ColorModeProvider } from "../color-mode";
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { Flex, RecipeVariantProps, useSlotRecipe } from "@chakra-ui/react";
3
3
  import { ArrowLeftFill24Icon } from "@vygruppen/spor-icon-react";
4
- import React, { forwardRef, PropsWithChildren } from "react";
4
+ import { forwardRef, PropsWithChildren } from "react";
5
5
 
6
6
  import { Box, createTexts, IconButton, Text, useTranslation } from "..";
7
7
  import { stepperSlotRecipe } from "../theme/slot-recipes/stepper";
package/src/tab/Tabs.tsx CHANGED
@@ -4,7 +4,6 @@ import {
4
4
  Tabs as ChakraTabs,
5
5
  TabsRootProps as ChakraTabsRootProps,
6
6
  } from "@chakra-ui/react";
7
- import * as React from "react";
8
7
  import { forwardRef, PropsWithChildren } from "react";
9
8
 
10
9
  import { tabsSlotRecipe } from "../theme/slot-recipes/tabs";
@@ -63,6 +62,7 @@ export const Tabs = forwardRef<HTMLDivElement, TabsProps>((props, ref) => {
63
62
  const { variant = "core", size = "sm" } = props;
64
63
  return <ChakraTabs.Root {...props} ref={ref} variant={variant} size={size} />;
65
64
  });
65
+ Tabs.displayName = "Tabs";
66
66
 
67
67
  export const TabsList = ChakraTabs.List;
68
68
  export const TabsTrigger = ChakraTabs.Trigger;
@@ -6,7 +6,7 @@ import {
6
6
  TableRootProps as ChakraTableProps,
7
7
  useSlotRecipe,
8
8
  } from "@chakra-ui/react";
9
- import React, { forwardRef, PropsWithChildren } from "react";
9
+ import { forwardRef, PropsWithChildren } from "react";
10
10
 
11
11
  import { tableSlotRecipe } from "../theme/slot-recipes/table";
12
12
 
@@ -52,6 +52,7 @@ export const Table = forwardRef<HTMLTableElement, TableProps>((props, ref) => {
52
52
  </Box>
53
53
  );
54
54
  });
55
+ Table.displayName = "Table";
55
56
 
56
57
  function getStyleProps(props: TableProps) {
57
58
  return props.variant === "core"
@@ -1,9 +1,5 @@
1
1
  import { defineSlotRecipe } from "@chakra-ui/react";
2
2
 
3
- import tokens from "@vygruppen/spor-design-tokens";
4
-
5
- import { alertSlotRecipe } from "./alert";
6
-
7
3
  import { alertExpandableAnatomy } from "./anatomy";
8
4
 
9
5
  export const alertExpandableSlotRecipe = defineSlotRecipe({
@@ -1,6 +1,5 @@
1
1
  import { defineSlotRecipe } from "@chakra-ui/react";
2
2
 
3
- import { coreBorder } from "../utils/core-utils";
4
3
  import { infoTagAnatomy } from "./anatomy";
5
4
  import { travelTagSlotRecipe } from "./travel-tag";
6
5
 
@@ -1,6 +1,5 @@
1
1
  import { defineSlotRecipe } from "@chakra-ui/react";
2
2
 
3
- import { surface } from "./../utils/surface-utils";
4
3
  import { popoverAnatomy } from "./anatomy";
5
4
 
6
5
  export const popoverSlotRecipe = defineSlotRecipe({
@@ -1,9 +1,6 @@
1
1
  import { defineSlotRecipe } from "@chakra-ui/react";
2
2
  import tokens from "@vygruppen/spor-design-tokens";
3
3
 
4
- import { coreBackground, coreBorder, coreText } from "../utils/core-utils";
5
- import { floatingBackground, floatingBorder } from "../utils/floating-utils";
6
- import { outlineBorder } from "../utils/outline-utils";
7
4
  import { radioCardAnatomy } from "./anatomy";
8
5
 
9
6
  export const radioCardSlotRecipe = defineSlotRecipe({
@@ -8,20 +8,24 @@ type AccentBackgroundState = Subset<
8
8
 
9
9
  export function accentBackground(state: AccentBackgroundState) {
10
10
  switch (state) {
11
- case "selected":
11
+ case "selected": {
12
12
  return brandBackground("default");
13
- case "active":
13
+ }
14
+ case "active": {
14
15
  return {
15
16
  backgroundColor: "accent.surface.active",
16
17
  };
17
- case "hover":
18
+ }
19
+ case "hover": {
18
20
  return {
19
21
  backgroundColor: "accent.surface.hover",
20
22
  };
21
- default:
23
+ }
24
+ default: {
22
25
  return {
23
26
  backgroundColor: "accent.surface",
24
27
  };
28
+ }
25
29
  }
26
30
  }
27
31
 
@@ -29,13 +33,15 @@ type AccentTextState = Subset<State, "default" | "selected">;
29
33
 
30
34
  export function accentText(state: AccentTextState) {
31
35
  switch (state) {
32
- case "selected":
36
+ case "selected": {
33
37
  return {
34
38
  color: "brand.text",
35
39
  };
36
- default:
40
+ }
41
+ default: {
37
42
  return {
38
43
  color: "accent.text",
39
44
  };
45
+ }
40
46
  }
41
47
  }
@@ -1,17 +1,20 @@
1
1
  type Bg = "default" | "secondary" | "tertiary";
2
2
  export const bg = (bg: Bg) => {
3
3
  switch (bg) {
4
- case "default":
4
+ case "default": {
5
5
  return {
6
6
  backgroundColor: "bg",
7
7
  };
8
- case "secondary":
8
+ }
9
+ case "secondary": {
9
10
  return {
10
11
  backgroundColor: "bg.secondary",
11
12
  };
12
- case "tertiary":
13
+ }
14
+ case "tertiary": {
13
15
  return {
14
16
  backgroundColor: "bg.tertiary",
15
17
  };
18
+ }
16
19
  }
17
20
  };
@@ -4,25 +4,25 @@ type BrandBackgroundState = Subset<State, "default" | "hover" | "active">;
4
4
 
5
5
  export function brandBackground(state: BrandBackgroundState) {
6
6
  switch (state) {
7
- case "active":
7
+ case "active": {
8
8
  return {
9
9
  backgroundColor: "brand.surface.active",
10
10
  };
11
- case "hover":
11
+ }
12
+ case "hover": {
12
13
  return {
13
14
  backgroundColor: "brand.surface.hover",
14
15
  };
15
- case "default":
16
- default:
16
+ }
17
+ default: {
17
18
  return {
18
19
  backgroundColor: "brand.surface",
19
20
  };
21
+ }
20
22
  }
21
23
  }
22
24
 
23
- type BrandTextState = Subset<State, "hover" | "active" | "default">;
24
-
25
- export function brandText(state: BrandTextState) {
25
+ export function brandText() {
26
26
  return {
27
27
  color: "brand.text",
28
28
  };
@@ -8,16 +8,20 @@ type coreBackgroundState = Subset<
8
8
  >;
9
9
  export function coreBackground(state: coreBackgroundState) {
10
10
  switch (state) {
11
- case "active":
11
+ case "active": {
12
12
  return brandBackground("active");
13
- case "selected":
13
+ }
14
+ case "selected": {
14
15
  return brandBackground("default");
16
+ }
15
17
 
16
- case "disabled":
18
+ case "disabled": {
17
19
  return surface("disabled");
18
- case "hover":
19
- default:
20
+ }
21
+
22
+ default: {
20
23
  return { backgroundColor: "transparent" };
24
+ }
21
25
  }
22
26
  }
23
27
 
@@ -28,11 +32,12 @@ type BorderState = Subset<
28
32
 
29
33
  export function coreBorder(state: BorderState) {
30
34
  switch (state) {
31
- case "hover":
35
+ case "hover": {
32
36
  return {
33
37
  outline: "2px solid",
34
38
  outlineColor: "core.outline",
35
39
  };
40
+ }
36
41
 
37
42
  case "disabled": {
38
43
  return {
@@ -52,12 +57,12 @@ export function coreBorder(state: BorderState) {
52
57
  outlineColor: "outline.error",
53
58
  };
54
59
  }
55
- case "default":
56
- default:
60
+ default: {
57
61
  return {
58
62
  outline: "1px solid",
59
63
  outlineColor: "core.outline",
60
64
  };
65
+ }
61
66
  }
62
67
  }
63
68
 
@@ -67,25 +72,30 @@ type coreTextState = Subset<
67
72
  >;
68
73
  export function coreText(state: coreTextState) {
69
74
  switch (state) {
70
- case "selected":
75
+ case "selected": {
71
76
  return {
72
77
  color: "brand.text",
73
78
  };
74
- case "active":
79
+ }
80
+ case "active": {
75
81
  return {
76
82
  color: "brand.text",
77
83
  };
78
- case "highlight":
84
+ }
85
+ case "highlight": {
79
86
  return {
80
87
  color: "text.highlight",
81
88
  };
82
- case "disabled":
89
+ }
90
+ case "disabled": {
83
91
  return {
84
92
  color: "text.disabled",
85
93
  };
86
- default:
94
+ }
95
+ default: {
87
96
  return {
88
97
  color: "core.text",
89
98
  };
99
+ }
90
100
  }
91
101
  }
@@ -8,26 +8,30 @@ type FloatingBackgroundState = Subset<
8
8
 
9
9
  export function floatingBackground(state: FloatingBackgroundState) {
10
10
  switch (state) {
11
- case "focus":
11
+ case "focus": {
12
12
  return brandBackground("default");
13
- case "active":
13
+ }
14
+ case "active": {
14
15
  return {
15
16
  backgroundColor: "floating.surface.active",
16
17
  };
17
- case "hover":
18
+ }
19
+ case "hover": {
18
20
  return {
19
21
  backgroundColor: {
20
22
  _light: "floating.surface.hover",
21
23
  _dark: `color-mix(in srgb, white 10%, var(--spor-colors-bg))`,
22
24
  },
23
25
  };
24
- case "default":
26
+ }
27
+ case "default": {
25
28
  return {
26
29
  backgroundColor: {
27
30
  _light: "bg",
28
31
  _dark: `color-mix(in srgb, white 10%, var(--spor-colors-bg))`,
29
32
  },
30
33
  };
34
+ }
31
35
  }
32
36
  }
33
37
 
@@ -37,25 +41,29 @@ type FloatingBorderState = Subset<
37
41
  >;
38
42
  export function floatingBorder(state: FloatingBorderState) {
39
43
  switch (state) {
40
- case "hover":
44
+ case "hover": {
41
45
  return {
42
46
  outline: "1px solid",
43
47
  outlineColor: "floating.outline.hover",
44
48
  };
45
- case "focus":
49
+ }
50
+ case "focus": {
46
51
  return {
47
52
  outline: "1px solid",
48
53
  outlineColor: "outline.focus",
49
54
  };
50
- case "active":
55
+ }
56
+ case "active": {
51
57
  return {
52
58
  outline: "1px solid",
53
59
  outlineColor: "floating.outline.active",
54
60
  };
55
- default:
61
+ }
62
+ default: {
56
63
  return {
57
64
  outline: "1px solid",
58
65
  outlineColor: "floating.outline",
59
66
  };
67
+ }
60
68
  }
61
69
  }
@@ -13,19 +13,21 @@ export function ghostBackground(state: GhostBackgroundState) {
13
13
  backgroundColor: "ghost.surface.hover",
14
14
  };
15
15
  }
16
- case "active":
16
+ case "active": {
17
17
  return {
18
18
  backgroundColor: "ghost.surface.active",
19
19
  };
20
+ }
20
21
  case "selected": {
21
22
  return {
22
23
  backgroundColor: "ghost.surface.selected",
23
24
  };
24
25
  }
25
- case "default":
26
+ case "default": {
26
27
  return {
27
28
  backgroundColor: "transparent",
28
29
  };
30
+ }
29
31
  }
30
32
  }
31
33
 
@@ -33,13 +35,15 @@ type GhostTextState = Subset<State, "default" | "selected">;
33
35
 
34
36
  export function ghostText(state: GhostTextState) {
35
37
  switch (state) {
36
- case "selected":
38
+ case "selected": {
37
39
  return {
38
40
  color: "ghost.text",
39
41
  };
40
- default:
42
+ }
43
+ default: {
41
44
  return {
42
45
  color: "ghost.text",
43
46
  };
47
+ }
44
48
  }
45
49
  }
@@ -5,7 +5,7 @@ import { InputState } from "./types";
5
5
 
6
6
  export function inputVariant(state: InputState) {
7
7
  switch (state) {
8
- case "base":
8
+ case "base": {
9
9
  return {
10
10
  ...coreBackground("default"),
11
11
  ...coreBorder("default"),
@@ -21,7 +21,8 @@ export function inputVariant(state: InputState) {
21
21
  ...coreBorder("selected"),
22
22
  },
23
23
  };
24
- case "floating":
24
+ }
25
+ case "floating": {
25
26
  return {
26
27
  boxShadow: "sm",
27
28
  ...floatingBackground("default"),
@@ -40,8 +41,9 @@ export function inputVariant(state: InputState) {
40
41
  borderColor: "floating.border.selected",
41
42
  },
42
43
  };
43
- case "default":
44
- default:
44
+ }
45
+
46
+ default: {
45
47
  return {
46
48
  ...coreBackground("default"),
47
49
  ...coreBorder("default"),
@@ -57,6 +59,7 @@ export function inputVariant(state: InputState) {
57
59
  ...coreBorder("selected"),
58
60
  },
59
61
  };
62
+ }
60
63
  }
61
64
  }
62
65
 
@@ -3,17 +3,20 @@ import { State, Subset } from "./types";
3
3
  type OutlineBorderState = Subset<State, "default" | "error" | "focus">;
4
4
  export function outlineBorder(state: OutlineBorderState) {
5
5
  switch (state) {
6
- case "error":
6
+ case "error": {
7
7
  return {
8
8
  outlineColor: "outline.error",
9
9
  };
10
- case "focus":
10
+ }
11
+ case "focus": {
11
12
  return {
12
13
  outlineColor: "outline.focus",
13
14
  };
14
- default:
15
+ }
16
+ default: {
15
17
  return {
16
18
  outlineColor: "outline",
17
19
  };
20
+ }
18
21
  }
19
22
  }
@@ -1,21 +1,25 @@
1
1
  type Surface = "default" | "secondary" | "tertiary" | "disabled";
2
2
  export const surface = (surface: Surface) => {
3
3
  switch (surface) {
4
- case "default":
4
+ case "default": {
5
5
  return {
6
6
  backgroundColor: "surface",
7
7
  };
8
- case "secondary":
8
+ }
9
+ case "secondary": {
9
10
  return {
10
11
  backgroundColor: "surface.secondary",
11
12
  };
12
- case "tertiary":
13
+ }
14
+ case "tertiary": {
13
15
  return {
14
16
  backgroundColor: "surface.tertiary",
15
17
  };
16
- case "disabled":
18
+ }
19
+ case "disabled": {
17
20
  return {
18
21
  backgroundColor: "surface.disabled",
19
22
  };
23
+ }
20
24
  }
21
25
  };
@@ -13,7 +13,6 @@ import {
13
13
  InformationFill18Icon,
14
14
  SuccessFill18Icon,
15
15
  } from "@vygruppen/spor-icon-react";
16
- import React from "react";
17
16
 
18
17
  import { createTexts, useTranslation } from "@/i18n";
19
18
 
@@ -5,17 +5,20 @@ import {
5
5
  Box,
6
6
  } from "@chakra-ui/react";
7
7
  import { IconComponent } from "@vygruppen/spor-icon-react";
8
- import React, { forwardRef } from "react";
8
+ import { forwardRef } from "react";
9
9
 
10
10
  export type BadgeProps = ChakraBadgeProps & {
11
11
  icon?: IconComponent;
12
12
  };
13
13
 
14
- export const Badge = forwardRef<HTMLSpanElement, BadgeProps>(
15
- ({ icon, children, ...props }, ref) => (
14
+ export const Badge = forwardRef<HTMLSpanElement, BadgeProps>(function Badge(
15
+ { icon, children, ...props },
16
+ ref,
17
+ ) {
18
+ return (
16
19
  <ChakraBadge ref={ref} {...props}>
17
20
  {children}
18
21
  {icon && <Box as={icon} />}
19
22
  </ChakraBadge>
20
- ),
21
- );
23
+ );
24
+ });
@@ -4,7 +4,7 @@ import {
4
4
  HeadingProps as ChakraHeadingProps,
5
5
  Text,
6
6
  } from "@chakra-ui/react";
7
- import React, { forwardRef } from "react";
7
+ import { forwardRef } from "react";
8
8
 
9
9
  import { slugify } from "..";
10
10
 
@@ -3,7 +3,7 @@ import {
3
3
  Text as ChakraText,
4
4
  TextProps as ChakraTextProps,
5
5
  } from "@chakra-ui/react";
6
- import React, { forwardRef } from "react";
6
+ import { forwardRef } from "react";
7
7
 
8
8
  export type TextProps = Omit<ChakraTextProps, "textStyle"> & {
9
9
  /** The size and style of the text.
@@ -20,17 +20,17 @@ export function slugify(text: string | string[], maxLength = 50): string {
20
20
  return (
21
21
  text
22
22
  .normalize("NFD") // Normalize to NFD Unicode form
23
- .replace(/[\u0300-\u036f]/g, "") // Remove diacritics
24
- .replace(/[\u00C6\u00E6]/g, "ae") // Replace Æ, æ
25
- .replace(/[\u00D8\u00F8]/g, "oe") // Replace Ø, ø
26
- .replace(/[\u00C5\u00E5]/g, "aa") // Replace Å, å
23
+ .replaceAll(/[\u0300-\u036F]/g, "") // Remove diacritics
24
+ .replaceAll(/[\u00C6\u00E6]/g, "ae") // Replace Æ, æ
25
+ .replaceAll(/[\u00D8\u00F8]/g, "oe") // Replace Ø, ø
26
+ .replaceAll(/[\u00C5\u00E5]/g, "aa") // Replace Å, å
27
27
  // Extend the replacement rules as needed
28
28
  .toLowerCase()
29
- .replace(/\s+/g, "-") // Replace spaces with -
30
- .replace(/[^\w-]+/g, "") // Remove all non-word chars
31
- .replace(/--+/g, "-") // Replace multiple - with single -
29
+ .replaceAll(/\s+/g, "-") // Replace spaces with -
30
+ .replaceAll(/[^\w-]+/g, "") // Remove all non-word chars
31
+ .replaceAll(/--+/g, "-") // Replace multiple - with single -
32
32
  .replace(/^-+/, "") // Trim - from start of text
33
33
  .replace(/-+$/, "")
34
- .substring(0, maxLength)
34
+ .slice(0, Math.max(0, maxLength))
35
35
  );
36
36
  }
package/tsconfig.json CHANGED
@@ -3,6 +3,7 @@
3
3
  "include": ["."],
4
4
  "exclude": ["dist", "build", "node_modules"],
5
5
  "compilerOptions": {
6
+ "lib": ["dom", "es2021"],
6
7
  "rootDir": ".",
7
8
  "paths": {
8
9
  "@/*": ["./src/*"]