@vygruppen/spor-react 8.2.1 → 9.0.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 (67) hide show
  1. package/.turbo/turbo-build.log +10 -12
  2. package/CHANGELOG.md +34 -0
  3. package/dist/{CountryCodeSelect-NEASN3EC.mjs → CountryCodeSelect-LFDBAHV7.mjs} +1 -1
  4. package/dist/{chunk-AKOJGLTQ.mjs → chunk-BWLVKMWU.mjs} +1262 -1785
  5. package/dist/index.d.mts +1664 -813
  6. package/dist/index.d.ts +1664 -813
  7. package/dist/index.js +1551 -2011
  8. package/dist/index.mjs +1 -1
  9. package/package.json +1 -1
  10. package/src/accordion/Expandable.tsx +22 -2
  11. package/src/breadcrumb/Breadcrumb.tsx +4 -2
  12. package/src/datepicker/DateRangePicker.tsx +1 -0
  13. package/src/input/ChoiceChip.tsx +3 -3
  14. package/src/input/NumericStepper.tsx +7 -49
  15. package/src/input/PasswordInput.tsx +2 -0
  16. package/src/input/PhoneNumberInput.tsx +1 -1
  17. package/src/input/Switch.tsx +4 -7
  18. package/src/loader/ProgressBar.tsx +7 -24
  19. package/src/tab/Tabs.tsx +4 -5
  20. package/src/theme/components/accordion.ts +12 -16
  21. package/src/theme/components/alert-expandable.ts +10 -21
  22. package/src/theme/components/breadcrumb.ts +60 -5
  23. package/src/theme/components/button.ts +40 -75
  24. package/src/theme/components/card-select.ts +14 -56
  25. package/src/theme/components/card.ts +56 -63
  26. package/src/theme/components/checkbox.ts +20 -20
  27. package/src/theme/components/choice-chip.ts +28 -43
  28. package/src/theme/components/close-button.ts +1 -1
  29. package/src/theme/components/datepicker.ts +48 -166
  30. package/src/theme/components/drawer.ts +6 -4
  31. package/src/theme/components/fab.ts +35 -62
  32. package/src/theme/components/index.ts +3 -1
  33. package/src/theme/components/info-select.ts +5 -9
  34. package/src/theme/components/input.ts +17 -32
  35. package/src/theme/components/link.ts +8 -8
  36. package/src/theme/components/listbox.ts +5 -7
  37. package/src/theme/components/media-controller-button.ts +20 -25
  38. package/src/theme/components/modal.ts +8 -6
  39. package/src/theme/components/numeric-stepper.ts +65 -0
  40. package/src/theme/components/popover.ts +7 -8
  41. package/src/theme/components/progress-bar.ts +43 -0
  42. package/src/theme/components/progress-indicator.ts +5 -2
  43. package/src/theme/components/radio.ts +15 -12
  44. package/src/theme/components/select.ts +2 -2
  45. package/src/theme/components/stepper.ts +10 -7
  46. package/src/theme/components/switch.ts +35 -82
  47. package/src/theme/components/table.ts +10 -12
  48. package/src/theme/components/tabs.ts +55 -261
  49. package/src/theme/components/travel-tag.ts +3 -6
  50. package/src/theme/foundations/colors.ts +3 -1
  51. package/src/theme/foundations/fonts.ts +2 -2
  52. package/src/theme/index.ts +9 -6
  53. package/src/theme/utils/accent-utils.ts +54 -0
  54. package/src/theme/utils/base-utils.ts +94 -0
  55. package/src/theme/utils/bg-utils.ts +19 -0
  56. package/src/theme/utils/brand-utils.ts +42 -0
  57. package/src/theme/utils/floating-utils.ts +64 -0
  58. package/src/theme/utils/{focus-util.ts → focus-utils.ts} +1 -1
  59. package/src/theme/utils/ghost-utils.ts +40 -0
  60. package/src/theme/utils/surface-utils.ts +35 -0
  61. package/src/tooltip/Tooltip.tsx +17 -20
  62. package/src/typography/Heading.tsx +7 -2
  63. package/src/util/externals.tsx +0 -1
  64. package/src/theme/utils/background-utils.ts +0 -179
  65. package/src/theme/utils/border-utils.ts +0 -176
  66. package/src/theme/utils/box-shadow-utils.ts +0 -44
  67. package/src/theme/utils/text-utils.ts +0 -60
@@ -0,0 +1,54 @@
1
+ import { mode, StyleFunctionProps } from "@chakra-ui/theme-tools";
2
+ import { brandBackground } from "./brand-utils";
3
+ import { State, Subset } from "./types";
4
+
5
+ type AccentBackgroundState = Subset<
6
+ State,
7
+ "default" | "hover" | "active" | "selected"
8
+ >;
9
+
10
+ export function accentBackground(
11
+ state: AccentBackgroundState,
12
+ props: StyleFunctionProps,
13
+ ) {
14
+ switch (state) {
15
+ case "selected":
16
+ return brandBackground("default", props);
17
+ case "active":
18
+ return {
19
+ backgroundColor: mode(
20
+ "accent.surface.active.light",
21
+ "accent.surface.active.dark",
22
+ )(props),
23
+ };
24
+ case "hover":
25
+ return {
26
+ backgroundColor: mode(
27
+ "accent.surface.hover.light",
28
+ "accent.surface.hover.dark",
29
+ )(props),
30
+ };
31
+ default:
32
+ return {
33
+ backgroundColor: mode(
34
+ "accent.surface.default.light",
35
+ "accent.surface.default.dark",
36
+ )(props),
37
+ };
38
+ }
39
+ }
40
+
41
+ type AccentTextState = Subset<State, "default" | "selected">;
42
+
43
+ export function accentText(state: AccentTextState, props: StyleFunctionProps) {
44
+ switch (state) {
45
+ case "selected":
46
+ return {
47
+ color: mode("brand.text.light", "brand.text.dark")(props),
48
+ };
49
+ default:
50
+ return {
51
+ color: mode("accent.text.light", "accent.text.dark")(props),
52
+ };
53
+ }
54
+ }
@@ -0,0 +1,94 @@
1
+ import { mode, StyleFunctionProps } from "@chakra-ui/theme-tools";
2
+ import { brandBackground } from "./brand-utils";
3
+ import { focusVisibleStyles } from "./focus-utils";
4
+ import { surface } from "./surface-utils";
5
+ import { State, Subset } from "./types";
6
+
7
+ type BaseBackgroundState = Subset<
8
+ State,
9
+ "default" | "active" | "selected" | "hover" | "disabled"
10
+ >;
11
+ export function baseBackground(
12
+ state: BaseBackgroundState,
13
+ props: StyleFunctionProps,
14
+ ) {
15
+ switch (state) {
16
+ case "active":
17
+ return {
18
+ backgroundColor: mode(
19
+ "base.surface.active.light",
20
+ "base.surface.active.dark",
21
+ )(props),
22
+ };
23
+ case "selected":
24
+ return brandBackground("default", props);
25
+ case "disabled":
26
+ return surface("disabled", props);
27
+ case "hover":
28
+ default:
29
+ return surface("default", props);
30
+ }
31
+ }
32
+
33
+ type BorderState = Subset<
34
+ State,
35
+ "hover" | "focus" | "disabled" | "selected" | "invalid" | "default"
36
+ >;
37
+
38
+ export function baseBorder(state: BorderState, props: StyleFunctionProps) {
39
+ switch (state) {
40
+ case "hover":
41
+ return {
42
+ outline: "2px solid",
43
+ outlineColor: mode(
44
+ "base.outline.hover.light",
45
+ "base.outline.hover.dark",
46
+ )(props),
47
+ };
48
+ case "focus": {
49
+ return focusVisibleStyles(props)._focusVisible;
50
+ }
51
+ case "disabled": {
52
+ return {
53
+ outline: "1px solid",
54
+ outlineColor: mode(
55
+ "outline.disabled.light",
56
+ "outline.disabled.dark",
57
+ )(props),
58
+ };
59
+ }
60
+ case "invalid": {
61
+ return {
62
+ outline: "2px solid",
63
+ outlineColor: mode("outline.error.light", "outline.error.dark")(props),
64
+ };
65
+ }
66
+ case "default":
67
+ default:
68
+ return {
69
+ outline: "1px solid",
70
+ outlineColor: mode(
71
+ "base.outline.default.light",
72
+ "base.outline.default.dark",
73
+ )(props),
74
+ };
75
+ }
76
+ }
77
+
78
+ type BaseTextState = Subset<State, "default" | "selected" | "disabled">;
79
+ export function baseText(state: BaseTextState, props: StyleFunctionProps) {
80
+ switch (state) {
81
+ case "selected":
82
+ return {
83
+ color: mode("brand.text.light", "brand.text.dark")(props),
84
+ };
85
+ case "disabled":
86
+ return {
87
+ color: mode("text.disabled.light", "text.disabled.dark")(props),
88
+ };
89
+ default:
90
+ return {
91
+ color: mode("base.text.light", "base.text.dark")(props),
92
+ };
93
+ }
94
+ }
@@ -0,0 +1,19 @@
1
+ import { mode } from "@chakra-ui/theme-tools";
2
+
3
+ type Bg = "default" | "secondary" | "tertiary";
4
+ export const bg = (bg: Bg, props: any) => {
5
+ switch (bg) {
6
+ case "default":
7
+ return {
8
+ backgroundColor: mode("bg.default.light", "bg.default.dark")(props),
9
+ };
10
+ case "secondary":
11
+ return {
12
+ backgroundColor: mode("bg.secondary.light", "bg.secondary.dark")(props),
13
+ };
14
+ case "tertiary":
15
+ return {
16
+ backgroundColor: mode("bg.tertiary.light", "bg.tertiary.dark")(props),
17
+ };
18
+ }
19
+ };
@@ -0,0 +1,42 @@
1
+ import { mode, StyleFunctionProps } from "@chakra-ui/theme-tools";
2
+ import { State, Subset } from "./types";
3
+
4
+ type BrandBackgroundState = Subset<State, "default" | "hover" | "active">;
5
+
6
+ export function brandBackground(
7
+ state: BrandBackgroundState,
8
+ props: StyleFunctionProps,
9
+ ) {
10
+ switch (state) {
11
+ case "active":
12
+ return {
13
+ backgroundColor: mode(
14
+ "brand.surface.active.light",
15
+ "brand.surface.active.dark",
16
+ )(props),
17
+ };
18
+ case "hover":
19
+ return {
20
+ backgroundColor: mode(
21
+ "brand.surface.hover.light",
22
+ "brand.surface.hover.dark",
23
+ )(props),
24
+ };
25
+ case "default":
26
+ default:
27
+ return {
28
+ backgroundColor: mode(
29
+ "brand.surface.default.light",
30
+ "brand.surface.default.dark",
31
+ )(props),
32
+ };
33
+ }
34
+ }
35
+
36
+ type BrandTextState = Subset<State, "hover" | "active" | "default">;
37
+
38
+ export function brandText(state: BrandTextState, props: StyleFunctionProps) {
39
+ return {
40
+ color: mode("brand.text.light", "brand.text.dark")(props),
41
+ };
42
+ }
@@ -0,0 +1,64 @@
1
+ import { mode, StyleFunctionProps } from "@chakra-ui/theme-tools";
2
+ import { brandBackground } from "./brand-utils";
3
+ import { State, Subset } from "./types";
4
+
5
+ type FloatingBackgroundState = Subset<
6
+ State,
7
+ "default" | "hover" | "active" | "selected"
8
+ >;
9
+
10
+ export function floatingBackground(
11
+ state: FloatingBackgroundState,
12
+ props: StyleFunctionProps,
13
+ ) {
14
+ switch (state) {
15
+ case "selected":
16
+ return brandBackground("default", props);
17
+ case "active":
18
+ return {
19
+ backgroundColor: mode(
20
+ "floating.surface.active.light",
21
+ "floating.surface.active.dark",
22
+ )(props),
23
+ };
24
+ case "hover":
25
+ return {
26
+ backgroundColor: mode(
27
+ "floating.surface.hover.light",
28
+ "floating.surface.hover.dark",
29
+ )(props),
30
+ };
31
+ case "default":
32
+ return {
33
+ backgroundColor: mode(
34
+ "floating.surface.default.light",
35
+ "floating.surface.default.dark",
36
+ )(props),
37
+ };
38
+ }
39
+ }
40
+
41
+ type FloatingBorderState = Subset<State, "default" | "hover" | "active">;
42
+ export function floatingBorder(
43
+ state: FloatingBorderState,
44
+ props: StyleFunctionProps,
45
+ ) {
46
+ switch (state) {
47
+ case "hover":
48
+ return {
49
+ outline: "1px solid",
50
+ outlineColor: mode(
51
+ "floating.outline.hover.light",
52
+ "floating.outline.hover.dark",
53
+ )(props),
54
+ };
55
+ default:
56
+ return {
57
+ outline: "1px solid",
58
+ outlineColor: mode(
59
+ "floating.outline.default.light",
60
+ "floating.outline.default.dark",
61
+ )(props),
62
+ };
63
+ }
64
+ }
@@ -3,7 +3,7 @@ import { mode } from "@chakra-ui/theme-tools";
3
3
  export const focusVisibleStyles = (props: any) => ({
4
4
  _focusVisible: {
5
5
  outlineWidth: "2px",
6
- outlineColor: mode("greenHaze", "azure")(props),
6
+ outlineColor: mode("outline.focus.light", "outline.focus.dark")(props),
7
7
  outlineStyle: "solid",
8
8
  outlineOffset: "1px",
9
9
  },
@@ -0,0 +1,40 @@
1
+ import { mode, StyleFunctionProps } from "@chakra-ui/theme-tools";
2
+ import { State, Subset } from "./types";
3
+
4
+ type GhostBackgroundState = Subset<
5
+ State,
6
+ "default" | "hover" | "active" | "selected"
7
+ >;
8
+
9
+ /** 👻👻👻👻👻👻👻👻👻👻👻👻👻👻 */
10
+ export function ghostBackground(
11
+ state: GhostBackgroundState,
12
+ props: StyleFunctionProps,
13
+ ) {
14
+ switch (state) {
15
+ case "hover": {
16
+ return {
17
+ backgroundColor: mode(
18
+ "ghost.surface.hover.light",
19
+ "ghost.surface.hover.dark",
20
+ )(props),
21
+ };
22
+ }
23
+ case "active":
24
+ return {
25
+ backgroundColor: mode(
26
+ "ghost.surface.active.light",
27
+ "ghost.surface.active.dark",
28
+ )(props),
29
+ };
30
+ case "selected": {
31
+ return {
32
+ backgroundColor: mode("mint", "whiteAlpha.200")(props),
33
+ };
34
+ }
35
+ case "default":
36
+ return {
37
+ backgroundColor: "transparent",
38
+ };
39
+ }
40
+ }
@@ -0,0 +1,35 @@
1
+ import { mode } from "@chakra-ui/theme-tools";
2
+
3
+ type Surface = "default" | "secondary" | "tertiary" | "disabled";
4
+ export const surface = (surface: Surface, props: any) => {
5
+ switch (surface) {
6
+ case "default":
7
+ return {
8
+ backgroundColor: mode(
9
+ "surface.default.light",
10
+ "surface.default.dark",
11
+ )(props),
12
+ };
13
+ case "secondary":
14
+ return {
15
+ backgroundColor: mode(
16
+ "surface.secondary.light",
17
+ "surface.secondary.dark",
18
+ )(props),
19
+ };
20
+ case "tertiary":
21
+ return {
22
+ backgroundColor: mode(
23
+ "surface.tertiary.light",
24
+ "surface.tertiary.dark",
25
+ )(props),
26
+ };
27
+ case "disabled":
28
+ return {
29
+ backgroundColor: mode(
30
+ "surface.disabled.light",
31
+ "surface.disabled.dark",
32
+ )(props),
33
+ };
34
+ }
35
+ };
@@ -1,5 +1,4 @@
1
1
  import {
2
- DarkMode,
3
2
  Popover,
4
3
  PopoverArrow,
5
4
  PopoverBody,
@@ -50,24 +49,22 @@ export const Tooltip = ({
50
49
  ...props
51
50
  }: TooltipProps) => {
52
51
  return (
53
- <DarkMode>
54
- <Popover
55
- onClose={onClose}
56
- isOpen={isOpen}
57
- defaultIsOpen={defaultIsOpen}
58
- placement={placement}
59
- size={size}
60
- arrowSize={12}
61
- arrowShadowColor="none"
62
- {...props}
63
- >
64
- <PopoverTrigger>{children}</PopoverTrigger>
65
- <PopoverContent>
66
- <PopoverArrow />
67
- {withCloseButton && <PopoverCloseButton />}
68
- <PopoverBody>{content}</PopoverBody>
69
- </PopoverContent>
70
- </Popover>
71
- </DarkMode>
52
+ <Popover
53
+ onClose={onClose}
54
+ isOpen={isOpen}
55
+ defaultIsOpen={defaultIsOpen}
56
+ placement={placement}
57
+ size={size}
58
+ arrowSize={12}
59
+ arrowShadowColor="none"
60
+ {...props}
61
+ >
62
+ <PopoverTrigger>{children}</PopoverTrigger>
63
+ <PopoverContent>
64
+ <PopoverArrow />
65
+ {withCloseButton && <PopoverCloseButton />}
66
+ <PopoverBody>{content}</PopoverBody>
67
+ </PopoverContent>
68
+ </Popover>
72
69
  );
73
70
  };
@@ -1,4 +1,8 @@
1
- import { HeadingProps as ChakraHeadingProps, Text } from "@chakra-ui/react";
1
+ import {
2
+ HeadingProps as ChakraHeadingProps,
3
+ Text,
4
+ useColorModeValue,
5
+ } from "@chakra-ui/react";
2
6
  import React from "react";
3
7
  import { slugify } from "..";
4
8
  import type { textStyles } from "../theme/foundations";
@@ -45,5 +49,6 @@ export const Heading = ({
45
49
  externalId ?? (autoId && typeof props.children === "string")
46
50
  ? slugify(props.children as string)
47
51
  : undefined;
48
- return <Text as={as} textStyle={variant} id={id} {...props} />;
52
+ const color = useColorModeValue("text.primary.light", "text.primary.dark");
53
+ return <Text as={as} textStyle={variant} id={id} color={color} {...props} />;
49
54
  };
@@ -1,6 +1,5 @@
1
1
  /** This file works as a proxy for all Chakra UI exports */
2
2
  export {
3
- Collapse,
4
3
  DarkMode,
5
4
  LightMode,
6
5
  Portal,
@@ -1,179 +0,0 @@
1
- import { mode, StyleFunctionProps } from "@chakra-ui/theme-tools";
2
- import { State, Subset } from "./types";
3
- import { colors } from "../foundations";
4
-
5
- type BaseBackgroundState = Subset<
6
- State,
7
- "default" | "active" | "selected" | "hover" | "disabled"
8
- >;
9
- export function baseBackground(
10
- state: BaseBackgroundState,
11
- props: StyleFunctionProps,
12
- ) {
13
- switch (state) {
14
- case "active":
15
- return {
16
- backgroundColor: mode("mint", "whiteAlpha.100")(props),
17
- };
18
- case "selected":
19
- return {
20
- backgroundColor: mode("pine", "coralGreen")(props),
21
- };
22
- case "disabled":
23
- return {
24
- backgroundColor: mode("blackAlpha.100", "whiteAlpha.100")(props),
25
- };
26
- case "hover":
27
- return {
28
- backgroundColor: "transparent",
29
- };
30
- default:
31
- return {
32
- backgroundColor: "transparent",
33
- };
34
- }
35
- }
36
-
37
- type GhostBackgroundState = Subset<
38
- State,
39
- "default" | "hover" | "focus" | "active" | "selected"
40
- >;
41
-
42
- export function ghostBackground(
43
- state: GhostBackgroundState,
44
- props: StyleFunctionProps,
45
- ) {
46
- switch (state) {
47
- case "hover": {
48
- return {
49
- backgroundColor: mode("seaMist", "whiteAlpha.100")(props),
50
- };
51
- }
52
- case "active":
53
- return {
54
- backgroundColor: mode("mint", "whiteAlpha.200")(props),
55
- };
56
- case "focus":
57
- return {
58
- backgroundColor: "transparent",
59
- };
60
- case "selected": {
61
- return {
62
- backgroundColor: mode("mint", "whiteAlpha.200")(props),
63
- };
64
- }
65
- case "default":
66
- default:
67
- return {
68
- backgroundColor: "transparent",
69
- };
70
- }
71
- }
72
-
73
- type FloatingBackgroundState = Subset<
74
- State,
75
- "default" | "hover" | "focus" | "active" | "selected"
76
- >;
77
-
78
- export function floatingBackground(
79
- state: FloatingBackgroundState,
80
- props: StyleFunctionProps,
81
- ) {
82
- switch (state) {
83
- case "selected":
84
- return {
85
- backgroundColor: mode("mint", "pine")(props),
86
- };
87
- case "active":
88
- return {
89
- backgroundColor: mode(
90
- "mint",
91
- `color-mix(in srgb, ${props.theme.colors.accent}, ${colors.white} 30%)`,
92
- )(props),
93
- };
94
- case "hover":
95
- return {
96
- backgroundColor: mode(
97
- "white",
98
- `color-mix(in srgb, ${props.theme.colors.accent}, ${colors.white} 20%)`,
99
- )(props),
100
- };
101
- case "focus":
102
- return {
103
- backgroundColor: mode(
104
- "white",
105
- `color-mix(in srgb, ${props.theme.colors.accent}, ${colors.white} 40%)`,
106
- )(props),
107
- };
108
- case "default":
109
- default:
110
- return {
111
- backgroundColor: mode(
112
- "white",
113
- `color-mix(in srgb, ${props.theme.colors.accent}, ${colors.white} 10%)`,
114
- )(props),
115
- };
116
- }
117
- }
118
-
119
- type AccentBackgroundState = Subset<
120
- State,
121
- "default" | "hover" | "focus" | "active" | "selected"
122
- >;
123
-
124
- export function accentBackground(
125
- state: AccentBackgroundState,
126
- props: StyleFunctionProps,
127
- ) {
128
- switch (state) {
129
- case "selected":
130
- return {
131
- backgroundColor: mode("primaryGreen", "coralGreen")(props),
132
- };
133
- case "active":
134
- return {
135
- backgroundColor: mode("mint", "darkTeal")(props),
136
- };
137
- case "hover":
138
- return {
139
- backgroundColor: mode("coralGreen", "greenHaze")(props),
140
- };
141
- case "focus":
142
- return {
143
- backgroundColor: mode("greenHaze", "azure")(props),
144
- };
145
- case "default":
146
- default:
147
- return {
148
- backgroundColor: mode("seaMist", "pine")(props),
149
- };
150
- }
151
- }
152
-
153
- type BrandBackgroundState = Subset<
154
- State,
155
- "default" | "hover" | "focus" | "active" | "selected"
156
- >;
157
-
158
- export function brandBackground(
159
- state: BrandBackgroundState,
160
- props: StyleFunctionProps,
161
- ) {
162
- switch (state) {
163
- case "selected":
164
- case "active":
165
- return {
166
- backgroundColor: mode("greenHaze", "seaMist")(props),
167
- };
168
- case "hover":
169
- return {
170
- backgroundColor: mode("darkTeal", "blueGreen")(props),
171
- };
172
- case "focus":
173
- case "default":
174
- default:
175
- return {
176
- backgroundColor: mode("pine", "coralGreen")(props),
177
- };
178
- }
179
- }