@vygruppen/spor-react 13.3.2 → 13.4.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/.turbo/turbo-build.log +12 -12
- package/.turbo/turbo-postinstall.log +1 -1
- package/CHANGELOG.md +19 -0
- package/__tests__/radio.test.tsx +69 -0
- package/dist/index.cjs +257 -179
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +73 -60
- package/dist/index.d.ts +73 -60
- package/dist/index.mjs +258 -180
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -2
- package/setupTests.ts +84 -0
- package/src/input/Combobox.tsx +1 -0
- package/src/input/CountryCodeSelect.tsx +1 -0
- package/src/input/Field.tsx +8 -6
- package/src/input/FloatingLabel.tsx +2 -13
- package/src/input/Input.tsx +32 -15
- package/src/input/Label.tsx +2 -3
- package/src/input/PasswordInput.tsx +3 -1
- package/src/input/PhoneNumberInput.tsx +3 -1
- package/src/input/SearchInput.tsx +14 -3
- package/src/input/Select.tsx +23 -33
- package/src/linjetag/InfoTag.tsx +4 -2
- package/src/linjetag/LineIcon.tsx +1 -1
- package/src/linjetag/TravelTag.tsx +4 -4
- package/src/linjetag/types.ts +4 -0
- package/src/theme/recipes/input.ts +15 -4
- package/src/theme/slot-recipes/anatomy.ts +1 -3
- package/src/theme/slot-recipes/breadcrumb.ts +0 -1
- package/src/theme/slot-recipes/field.ts +38 -4
- package/src/theme/slot-recipes/native-select.ts +15 -0
- package/src/theme/slot-recipes/select.ts +88 -35
- package/src/theme/slot-recipes/travel-tag.ts +15 -58
- package/vitest.config.ts +12 -0
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
WarningFill18Icon,
|
|
15
15
|
WarningFill24Icon,
|
|
16
16
|
} from "@vygruppen/spor-icon-react";
|
|
17
|
-
import clsx from "clsx";
|
|
18
17
|
import { PropsWithChildren } from "react";
|
|
19
18
|
|
|
20
19
|
import { travelTagSlotRecipe } from "../theme/slot-recipes/travel-tag";
|
|
@@ -139,6 +138,8 @@ export const TravelTag = function TravelTag({
|
|
|
139
138
|
foregroundColor,
|
|
140
139
|
backgroundColor,
|
|
141
140
|
customIconVariant,
|
|
141
|
+
descriptionProps,
|
|
142
|
+
titleProps,
|
|
142
143
|
...rest
|
|
143
144
|
}: TravelTagProps & {
|
|
144
145
|
ref?: React.Ref<HTMLDivElement>;
|
|
@@ -155,7 +156,6 @@ export const TravelTag = function TravelTag({
|
|
|
155
156
|
css={styles.container}
|
|
156
157
|
aria-disabled={disabled}
|
|
157
158
|
ref={ref}
|
|
158
|
-
className={clsx("light", rest.className)}
|
|
159
159
|
backgroundColor={backgroundColor}
|
|
160
160
|
{...rest}
|
|
161
161
|
>
|
|
@@ -172,13 +172,13 @@ export const TravelTag = function TravelTag({
|
|
|
172
172
|
/>
|
|
173
173
|
<Box css={styles.textContainer}>
|
|
174
174
|
{title && (
|
|
175
|
-
<Box as="span" css={styles.title}>
|
|
175
|
+
<Box as="span" css={styles.title} {...titleProps}>
|
|
176
176
|
{title}
|
|
177
177
|
</Box>
|
|
178
178
|
)}
|
|
179
179
|
{title && description && " "}
|
|
180
180
|
{description && (
|
|
181
|
-
<Box as="span" css={styles.description}>
|
|
181
|
+
<Box as="span" css={styles.description} {...descriptionProps}>
|
|
182
182
|
{description}
|
|
183
183
|
</Box>
|
|
184
184
|
)}
|
package/src/linjetag/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { BoxProps } from "@chakra-ui/react";
|
|
2
|
+
|
|
1
3
|
export type Variant =
|
|
2
4
|
| "local-train"
|
|
3
5
|
| "region-train"
|
|
@@ -20,6 +22,8 @@ export type TagProps = VariantProps & {
|
|
|
20
22
|
size?: Size;
|
|
21
23
|
title: string;
|
|
22
24
|
description?: string;
|
|
25
|
+
descriptionProps?: BoxProps;
|
|
26
|
+
titleProps?: BoxProps;
|
|
23
27
|
};
|
|
24
28
|
|
|
25
29
|
type DefaultVariantProps = {
|
|
@@ -13,10 +13,6 @@ export const inputRecipe = defineRecipe({
|
|
|
13
13
|
transitionDuration: "fast",
|
|
14
14
|
color: "text",
|
|
15
15
|
position: "relative",
|
|
16
|
-
paddingX: 3,
|
|
17
|
-
paddingTop: 3,
|
|
18
|
-
height: 8,
|
|
19
|
-
fontSize: "mobile.md",
|
|
20
16
|
|
|
21
17
|
_disabled: {
|
|
22
18
|
backgroundColor: "surface.disabled",
|
|
@@ -83,8 +79,23 @@ export const inputRecipe = defineRecipe({
|
|
|
83
79
|
},
|
|
84
80
|
},
|
|
85
81
|
},
|
|
82
|
+
size: {
|
|
83
|
+
sm: {
|
|
84
|
+
paddingTop: 2,
|
|
85
|
+
height: 7,
|
|
86
|
+
fontSize: "xs",
|
|
87
|
+
paddingX: 2,
|
|
88
|
+
},
|
|
89
|
+
md: {
|
|
90
|
+
paddingX: 3,
|
|
91
|
+
paddingTop: 3,
|
|
92
|
+
height: 8,
|
|
93
|
+
fontSize: "mobile.md",
|
|
94
|
+
},
|
|
95
|
+
},
|
|
86
96
|
},
|
|
87
97
|
defaultVariants: {
|
|
88
98
|
variant: "core",
|
|
99
|
+
size: "md",
|
|
89
100
|
},
|
|
90
101
|
});
|
|
@@ -201,12 +201,10 @@ export const selectAnatomy = createAnatomy("select").parts(
|
|
|
201
201
|
"root",
|
|
202
202
|
"trigger",
|
|
203
203
|
"indicatorGroup",
|
|
204
|
-
"
|
|
205
|
-
"selectContent",
|
|
204
|
+
"content",
|
|
206
205
|
"item",
|
|
207
206
|
"control",
|
|
208
207
|
"itemText",
|
|
209
|
-
"itemDescription",
|
|
210
208
|
"itemGroup",
|
|
211
209
|
"itemGroupLabel",
|
|
212
210
|
"label",
|
|
@@ -14,17 +14,15 @@ export const fieldSlotRecipe = defineSlotRecipe({
|
|
|
14
14
|
},
|
|
15
15
|
requiredIndicator: {
|
|
16
16
|
marginStart: 1,
|
|
17
|
-
|
|
18
|
-
color: "brightRed",
|
|
17
|
+
color: "outline.error",
|
|
19
18
|
},
|
|
20
19
|
label: {
|
|
21
20
|
display: "flex",
|
|
22
21
|
},
|
|
23
22
|
helperText: {
|
|
24
|
-
marginTop: 2,
|
|
25
23
|
color: "text.subtle",
|
|
26
24
|
lineHeight: "normal",
|
|
27
|
-
fontSize: "sm",
|
|
25
|
+
fontSize: ["mobile.sm", "desktop.sm"],
|
|
28
26
|
},
|
|
29
27
|
errorText: {
|
|
30
28
|
borderRadius: "xs",
|
|
@@ -52,4 +50,40 @@ export const fieldSlotRecipe = defineSlotRecipe({
|
|
|
52
50
|
},
|
|
53
51
|
},
|
|
54
52
|
},
|
|
53
|
+
variants: {
|
|
54
|
+
size: {
|
|
55
|
+
sm: {
|
|
56
|
+
label: {
|
|
57
|
+
fontSize: ["mobile.xs", "desktop.xs"],
|
|
58
|
+
paddingX: 2,
|
|
59
|
+
|
|
60
|
+
"&[data-float]": {
|
|
61
|
+
fontSize: ["mobile.2xs", "desktop.2xs"],
|
|
62
|
+
top: 0,
|
|
63
|
+
},
|
|
64
|
+
top: "0.5rem",
|
|
65
|
+
},
|
|
66
|
+
helperText: {
|
|
67
|
+
color: "text.subtle",
|
|
68
|
+
lineHeight: "normal",
|
|
69
|
+
fontSize: ["mobile.xs", "desktop.xs"],
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
md: {
|
|
73
|
+
label: {
|
|
74
|
+
paddingX: 3,
|
|
75
|
+
fontSize: ["mobile.sm", "desktop.sm"],
|
|
76
|
+
"&[data-float]": {
|
|
77
|
+
fontSize: ["mobile.2xs", "desktop.2xs"],
|
|
78
|
+
color: "text.subtle",
|
|
79
|
+
top: "0.3rem",
|
|
80
|
+
},
|
|
81
|
+
top: "0.9rem",
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
defaultVariants: {
|
|
87
|
+
size: "md",
|
|
88
|
+
},
|
|
55
89
|
});
|
|
@@ -55,5 +55,20 @@ export const nativeSelectSlotRecipe = defineSlotRecipe({
|
|
|
55
55
|
},
|
|
56
56
|
},
|
|
57
57
|
},
|
|
58
|
+
size: {
|
|
59
|
+
sm: {
|
|
60
|
+
field: {
|
|
61
|
+
...inputRecipe.variants?.size?.sm,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
md: {
|
|
65
|
+
field: {
|
|
66
|
+
...inputRecipe.variants?.size?.md,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
defaultVariants: {
|
|
72
|
+
size: "md",
|
|
58
73
|
},
|
|
59
74
|
});
|
|
@@ -16,15 +16,9 @@ export const selectSlotRecipe = defineSlotRecipe({
|
|
|
16
16
|
label: {
|
|
17
17
|
fontSize: ["mobile.sm", "desktop.sm"],
|
|
18
18
|
top: 0,
|
|
19
|
-
left: 3,
|
|
20
19
|
zIndex: 0,
|
|
21
20
|
position: "absolute",
|
|
22
21
|
color: "text",
|
|
23
|
-
marginY: 2,
|
|
24
|
-
|
|
25
|
-
_selected: {
|
|
26
|
-
transform: ["scale(0.825) translateY(-10px)"],
|
|
27
|
-
},
|
|
28
22
|
|
|
29
23
|
transitionProperty: "transform",
|
|
30
24
|
transitionDuration: "fast",
|
|
@@ -36,14 +30,10 @@ export const selectSlotRecipe = defineSlotRecipe({
|
|
|
36
30
|
display: "flex",
|
|
37
31
|
appearance: "none",
|
|
38
32
|
width: "100%",
|
|
39
|
-
height: 8,
|
|
40
33
|
color: "text",
|
|
41
|
-
paddingY: 1.5,
|
|
42
|
-
paddingX: 3,
|
|
43
34
|
|
|
44
35
|
justifyContent: "space-between",
|
|
45
36
|
alignItems: "center",
|
|
46
|
-
fontSize: "mobile.md",
|
|
47
37
|
borderRadius: "sm",
|
|
48
38
|
cursor: "pointer",
|
|
49
39
|
|
|
@@ -52,11 +42,14 @@ export const selectSlotRecipe = defineSlotRecipe({
|
|
|
52
42
|
transform: "rotate(180deg)",
|
|
53
43
|
},
|
|
54
44
|
},
|
|
45
|
+
_active: {
|
|
46
|
+
backgroundColor: "surface",
|
|
47
|
+
},
|
|
55
48
|
},
|
|
56
49
|
indicatorGroup: {
|
|
57
50
|
display: "flex",
|
|
58
51
|
alignItems: "center",
|
|
59
|
-
gap: "
|
|
52
|
+
gap: "0.5",
|
|
60
53
|
position: "absolute",
|
|
61
54
|
right: "0",
|
|
62
55
|
top: "0",
|
|
@@ -64,22 +57,22 @@ export const selectSlotRecipe = defineSlotRecipe({
|
|
|
64
57
|
paddingX: 2,
|
|
65
58
|
|
|
66
59
|
pointerEvents: "none",
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
60
|
+
"& [data-part='indicator']": {
|
|
61
|
+
display: "flex",
|
|
62
|
+
alignItems: "center",
|
|
63
|
+
justifyContent: "center",
|
|
64
|
+
color: {
|
|
65
|
+
base: "text",
|
|
66
|
+
_disabled: "text.disabled",
|
|
67
|
+
_invalid: "text.highlight",
|
|
68
|
+
},
|
|
69
|
+
_icon: {
|
|
70
|
+
width: 3,
|
|
71
|
+
height: 3,
|
|
72
|
+
},
|
|
80
73
|
},
|
|
81
74
|
},
|
|
82
|
-
|
|
75
|
+
content: {
|
|
83
76
|
backgroundColor: "surface",
|
|
84
77
|
boxShadow: "sm",
|
|
85
78
|
overflowY: "auto",
|
|
@@ -134,8 +127,6 @@ export const selectSlotRecipe = defineSlotRecipe({
|
|
|
134
127
|
},
|
|
135
128
|
_hover: {
|
|
136
129
|
backgroundColor: "surface.accent.hover",
|
|
137
|
-
outline: "2px solid core.outline",
|
|
138
|
-
outlineOffset: "2px",
|
|
139
130
|
},
|
|
140
131
|
_selected: {
|
|
141
132
|
backgroundColor: "surface.accent",
|
|
@@ -144,6 +135,10 @@ export const selectSlotRecipe = defineSlotRecipe({
|
|
|
144
135
|
width: 3,
|
|
145
136
|
height: 3,
|
|
146
137
|
},
|
|
138
|
+
"& [data-part='item-description']": {
|
|
139
|
+
fontSize: ["mobile.xs", "desktop.xs"],
|
|
140
|
+
color: "text.ghost",
|
|
141
|
+
},
|
|
147
142
|
},
|
|
148
143
|
control: {
|
|
149
144
|
position: "relative",
|
|
@@ -162,6 +157,7 @@ export const selectSlotRecipe = defineSlotRecipe({
|
|
|
162
157
|
},
|
|
163
158
|
itemText: {
|
|
164
159
|
flex: "1",
|
|
160
|
+
alignItems: "center",
|
|
165
161
|
},
|
|
166
162
|
itemGroup: {
|
|
167
163
|
_first: { mt: "0" },
|
|
@@ -170,14 +166,6 @@ export const selectSlotRecipe = defineSlotRecipe({
|
|
|
170
166
|
py: "1",
|
|
171
167
|
fontWeight: "medium",
|
|
172
168
|
},
|
|
173
|
-
valueText: {},
|
|
174
|
-
itemDescription: {
|
|
175
|
-
fontSize: ["mobile.xs", "desktop.xs"],
|
|
176
|
-
color: "text.ghost",
|
|
177
|
-
"[aria-selected='true'] &": {
|
|
178
|
-
color: "text.ghost",
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
169
|
},
|
|
182
170
|
variants: {
|
|
183
171
|
variant: {
|
|
@@ -198,6 +186,10 @@ export const selectSlotRecipe = defineSlotRecipe({
|
|
|
198
186
|
backgroundColor: "surface.disabled",
|
|
199
187
|
},
|
|
200
188
|
},
|
|
189
|
+
content: {
|
|
190
|
+
outline: "2px solid",
|
|
191
|
+
outlineColor: "outline.core",
|
|
192
|
+
},
|
|
201
193
|
},
|
|
202
194
|
floating: {
|
|
203
195
|
control: {
|
|
@@ -242,5 +234,66 @@ export const selectSlotRecipe = defineSlotRecipe({
|
|
|
242
234
|
},
|
|
243
235
|
},
|
|
244
236
|
},
|
|
237
|
+
size: {
|
|
238
|
+
sm: {
|
|
239
|
+
trigger: {
|
|
240
|
+
height: 7,
|
|
241
|
+
paddingY: 1.5,
|
|
242
|
+
fontSize: "xs",
|
|
243
|
+
paddingX: 2,
|
|
244
|
+
},
|
|
245
|
+
label: {
|
|
246
|
+
fontSize: ["mobile.xs", "desktop.xs"],
|
|
247
|
+
left: 2,
|
|
248
|
+
marginY: 1.5,
|
|
249
|
+
_selected: {
|
|
250
|
+
transform: ["scale(0.85) translateY(-9px)"],
|
|
251
|
+
fontSize: "desktop.2xs",
|
|
252
|
+
color: "text.subtle",
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
item: {
|
|
256
|
+
paddingX: 2,
|
|
257
|
+
paddingY: 1,
|
|
258
|
+
fontSize: "xs",
|
|
259
|
+
"& [data-part='item-description']": {
|
|
260
|
+
fontSize: ["mobile.2xs", "desktop.2xs"],
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
itemGroupLabel: {
|
|
264
|
+
py: 0.5,
|
|
265
|
+
fontSize: "xs",
|
|
266
|
+
},
|
|
267
|
+
valueText: {
|
|
268
|
+
paddingTop: 0,
|
|
269
|
+
"&[data-with-placeholder]": {
|
|
270
|
+
paddingTop: "1.5",
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
md: {
|
|
275
|
+
trigger: {
|
|
276
|
+
height: 8,
|
|
277
|
+
paddingY: 1.5,
|
|
278
|
+
paddingX: 3,
|
|
279
|
+
fontSize: "sm",
|
|
280
|
+
},
|
|
281
|
+
label: {
|
|
282
|
+
left: 3,
|
|
283
|
+
marginY: 2,
|
|
284
|
+
_selected: {
|
|
285
|
+
transform: ["scale(0.825) translateY(-10px)"],
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
valueText: {
|
|
289
|
+
"&[data-with-placeholder]": {
|
|
290
|
+
paddingTop: "4",
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
defaultVariants: {
|
|
297
|
+
size: "md",
|
|
245
298
|
},
|
|
246
299
|
});
|
|
@@ -11,10 +11,7 @@ export const travelTagSlotRecipe = defineSlotRecipe({
|
|
|
11
11
|
display: "flex",
|
|
12
12
|
alignItems: "center",
|
|
13
13
|
padding: 0.5,
|
|
14
|
-
|
|
15
|
-
_disabled: {
|
|
16
|
-
background: "surface.disabled",
|
|
17
|
-
},
|
|
14
|
+
backgroundColor: "surface.disabled",
|
|
18
15
|
|
|
19
16
|
width: "fit-content",
|
|
20
17
|
transitionDuration: "fast",
|
|
@@ -79,62 +76,22 @@ export const travelTagSlotRecipe = defineSlotRecipe({
|
|
|
79
76
|
none: {},
|
|
80
77
|
},
|
|
81
78
|
variant: {
|
|
82
|
-
"local-train": {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
},
|
|
87
|
-
"
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
},
|
|
92
|
-
"
|
|
93
|
-
|
|
94
|
-
backgroundColor: "linjetag.regionEkspressLight",
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
"long-distance-train": {
|
|
98
|
-
container: {
|
|
99
|
-
backgroundColor: "linjetag.fjerntogLight",
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
"airport-express-train": {
|
|
103
|
-
container: {
|
|
104
|
-
backgroundColor: "linjetag.flytogLight",
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
"vy-bus": {
|
|
108
|
-
container: {
|
|
109
|
-
backgroundColor: "linjetag.vyBussLight",
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
"local-bus": {
|
|
113
|
-
container: {
|
|
114
|
-
backgroundColor: "linjetag.lokalbussLight",
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
ferry: {
|
|
118
|
-
container: {
|
|
119
|
-
backgroundColor: "linjetag.fergeLight",
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
subway: {
|
|
123
|
-
container: {
|
|
124
|
-
backgroundColor: "linjetag.tbaneLight",
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
tram: {
|
|
128
|
-
container: {
|
|
129
|
-
backgroundColor: "linjetag.trikkLight",
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
"alt-transport": {
|
|
79
|
+
"local-train": {},
|
|
80
|
+
"region-train": {},
|
|
81
|
+
"region-express-train": {},
|
|
82
|
+
"long-distance-train": {},
|
|
83
|
+
"airport-express-train": {},
|
|
84
|
+
"vy-bus": {},
|
|
85
|
+
"local-bus": {},
|
|
86
|
+
ferry: {},
|
|
87
|
+
subway: {},
|
|
88
|
+
tram: {},
|
|
89
|
+
"alt-transport": {},
|
|
90
|
+
walk: {
|
|
133
91
|
container: {
|
|
134
|
-
backgroundColor: "
|
|
92
|
+
backgroundColor: "none",
|
|
135
93
|
},
|
|
136
|
-
|
|
137
|
-
walk: {
|
|
94
|
+
|
|
138
95
|
textContainer: {
|
|
139
96
|
position: "absolute",
|
|
140
97
|
left: "0.875rem",
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
globals: true, // Allows using 'describe', 'test', and 'expect' without importing them
|
|
6
|
+
environment: "jsdom",
|
|
7
|
+
setupFiles: "./setupTests.ts", // Global test helpers or mocks
|
|
8
|
+
typecheck: {
|
|
9
|
+
enabled: true,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
});
|