@vygruppen/spor-react 12.1.2 → 12.2.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.
Files changed (122) hide show
  1. package/.turbo/turbo-build.log +31 -12
  2. package/.turbo/turbo-typegen.log +19 -1
  3. package/CHANGELOG.md +14 -0
  4. package/dist/index.d.mts +189 -243
  5. package/dist/index.d.ts +189 -243
  6. package/dist/index.js +2485 -2072
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +2376 -1972
  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 +39 -66
  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/anatomy.ts +10 -0
  102. package/src/theme/slot-recipes/choice-chip.ts +183 -0
  103. package/src/theme/slot-recipes/index.ts +2 -0
  104. package/src/theme/slot-recipes/info-tag.ts +0 -1
  105. package/src/theme/slot-recipes/popover.ts +0 -1
  106. package/src/theme/slot-recipes/radio-card.ts +0 -3
  107. package/src/theme/utils/accent-utils.ts +12 -6
  108. package/src/theme/utils/bg-utils.ts +6 -3
  109. package/src/theme/utils/brand-utils.ts +7 -7
  110. package/src/theme/utils/core-utils.ts +23 -13
  111. package/src/theme/utils/floating-utils.ts +16 -8
  112. package/src/theme/utils/ghost-utils.ts +8 -4
  113. package/src/theme/utils/input-utils.ts +7 -4
  114. package/src/theme/utils/outline-utils.ts +6 -3
  115. package/src/theme/utils/surface-utils.ts +8 -4
  116. package/src/toast/toast.tsx +0 -1
  117. package/src/typography/Badge.tsx +8 -5
  118. package/src/typography/Heading.tsx +1 -1
  119. package/src/typography/Text.tsx +1 -1
  120. package/src/util/slugify.tsx +8 -8
  121. package/tsconfig.json +1 -0
  122. package/src/theme/recipes/choice-chip.ts +0 -144
@@ -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/*"]
@@ -1,144 +0,0 @@
1
- import { defineRecipe } from "@chakra-ui/react";
2
-
3
- export const choiceChipRecipe = defineRecipe({
4
- base: {
5
- display: "inline-flex",
6
- alignItems: "center",
7
- boxAlign: "center",
8
- fontSize: "xs",
9
- cursor: "pointer",
10
- transitionProperty: "all",
11
- borderRadius: "xl",
12
- transitionDuration: "fast",
13
- height: 6,
14
- paddingInlineStart: "2",
15
- paddingInlineEnd: "2",
16
-
17
- outline: "1px solid",
18
- outlineColor: "base.outline",
19
- _checked: {
20
- backgroundColor: "brand.surface",
21
- borderRadius: "sm",
22
- outline: "none",
23
- color: "brand.text",
24
- _hover: {
25
- backgroundColor: "brand.surface.hover",
26
- _active: {
27
- backgroundColor: "brand.surface.active",
28
- },
29
- },
30
- },
31
-
32
- _focusVisible: {
33
- outline: "2px solid",
34
- outlineColor: "outline.focus",
35
- outlineOffset: "1px",
36
- },
37
-
38
- _disabled: {
39
- pointerEvents: "none",
40
- boxShadow: "none",
41
- backgroundColor: "surface.disabled",
42
- color: "text.disabled",
43
- outline: "none",
44
-
45
- _hover: {
46
- backgroundColor: "core.surface.disabled",
47
- boxShadow: "none",
48
- color: "core.text.disabled",
49
- },
50
- _checked: {
51
- cursor: "not-allowed",
52
- boxShadow: "none",
53
- color: "core.text.disabled",
54
- backgroundColor: "core.surface.disabled",
55
- _hover: {
56
- backgroundColor: "core.surface.disabled",
57
- boxShadow: "none",
58
- color: "core.text.disabled",
59
- },
60
- },
61
- },
62
- },
63
- variants: {
64
- variant: {
65
- core: {
66
- color: "core.text",
67
- outlineColor: "core.outline",
68
-
69
- _hover: {
70
- outline: "2px solid",
71
- outlineColor: "core.outline.hover",
72
-
73
- _active: {
74
- outline: "1px solid",
75
- outlineColor: "core.outline",
76
- backgroundColor: "core.surface.active",
77
- },
78
- },
79
- },
80
- accent: {
81
- backgroundColor: "accent.surface",
82
- color: "accent.text",
83
- outline: "none",
84
-
85
- _hover: {
86
- backgroundColor: "accent.surface.hover",
87
-
88
- _active: {
89
- backgroundColor: "accent.surface.active",
90
- },
91
- },
92
- },
93
- floating: {
94
- backgroundColor: "floating.surface",
95
- outline: "1px solid",
96
- outlineColor: "floating.outline",
97
- color: "floating.text",
98
-
99
- boxShadow: "sm",
100
- _hover: {
101
- backgroundColor: "floating.surface.hover",
102
- outline: "1px solid",
103
- outlineColor: "floating.outline.hover",
104
-
105
- _active: {
106
- backgroundColor: "floating.surface.active",
107
- outline: "1px solid",
108
- outlineColor: "floating.outline",
109
- },
110
- },
111
- },
112
- },
113
- size: {
114
- xs: {
115
- _checked: {
116
- borderRadius: "0.563rem",
117
- },
118
- height: 5,
119
- paddingX: 1.5,
120
- },
121
- sm: {
122
- _checked: {
123
- borderRadius: "sm",
124
- },
125
- height: 6,
126
- paddingX: 2,
127
- },
128
- md: {
129
- _checked: {
130
- borderRadius: "sm",
131
- },
132
- height: 7,
133
- paddingX: 2,
134
- },
135
- lg: {
136
- _checked: {
137
- borderRadius: "md",
138
- },
139
- height: 8,
140
- paddingX: 3,
141
- },
142
- },
143
- },
144
- });