@vygruppen/spor-react 11.2.0 → 11.3.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.
- package/.turbo/turbo-build.log +19 -16
- package/CHANGELOG.md +26 -0
- package/README.md +1 -0
- package/dist/index.d.mts +243 -241
- package/dist/index.d.ts +243 -241
- package/dist/index.js +916 -6798
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +834 -6719
- package/dist/index.mjs.map +1 -0
- package/package.json +25 -12
- package/src/button/IconButton.tsx +1 -1
- package/src/datepicker/CalendarTriggerButton.tsx +1 -1
- package/src/datepicker/StyledField.tsx +1 -1
- package/src/datepicker/TimePicker.tsx +3 -2
- package/src/input/ChoiceChip.tsx +1 -1
- package/src/input/InfoSelect.tsx +2 -2
- package/src/input/InputElement.tsx +0 -1
- package/src/input/PhoneNumberInput.tsx +2 -6
- package/src/input/Switch.tsx +2 -3
- package/src/layout/Divider.tsx +1 -1
- package/src/layout/PressableCard.tsx +2 -7
- package/src/layout/StaticCard.tsx +2 -7
- package/src/linjetag/TravelTag.tsx +1 -1
- package/src/toast/useToast.tsx +58 -36
- package/src/typography/Badge.tsx +1 -1
- package/src/typography/Code.tsx +1 -1
- package/src/typography/Heading.tsx +1 -1
- package/tsup.config.ts +9 -0
package/package.json
CHANGED
@@ -1,15 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vygruppen/spor-react",
|
3
|
-
"version": "11.
|
3
|
+
"version": "11.3.0",
|
4
4
|
"main": "./dist/index.js",
|
5
5
|
"module": "./dist/index.mjs",
|
6
6
|
"types": "./dist/index.d.ts",
|
7
7
|
"license": "MIT",
|
8
8
|
"sideEffects": false,
|
9
|
-
"scripts": {
|
10
|
-
"build": "tsup src/index.tsx --dts --treeshake --format cjs,esm",
|
11
|
-
"dev": "tsup src/index.tsx --watch --format esm"
|
12
|
-
},
|
13
9
|
"homepage": "https://github.com/nsbno/spor/tree/main/packages/spor-react",
|
14
10
|
"repository": {
|
15
11
|
"type": "git",
|
@@ -17,34 +13,51 @@
|
|
17
13
|
"directory": "packages/spor-react"
|
18
14
|
},
|
19
15
|
"dependencies": {
|
16
|
+
"@chakra-ui/anatomy": "^2.3.4",
|
20
17
|
"@chakra-ui/react": "^2.8.2",
|
18
|
+
"@chakra-ui/react-use-size": "^2.1.0",
|
19
|
+
"@chakra-ui/styled-system": "^2.12.0",
|
20
|
+
"@chakra-ui/system": "^2.6.2",
|
21
|
+
"@chakra-ui/theme": "^3.4.6",
|
21
22
|
"@chakra-ui/theme-tools": "^2.0.12",
|
23
|
+
"@chakra-ui/utils": "^2.2.2",
|
22
24
|
"@emotion/react": "^11.11.4",
|
23
25
|
"@emotion/styled": "^11.11.5",
|
24
26
|
"@internationalized/date": "^3.5.4",
|
25
|
-
"@vygruppen/spor-design-tokens": "^3.9.0",
|
26
|
-
"@vygruppen/spor-icon-react": "^3.12.0",
|
27
|
-
"@vygruppen/spor-loader": "^0.4.0",
|
28
27
|
"awesome-phonenumber": "^5.11.0",
|
29
28
|
"deepmerge": "^4.3.1",
|
30
|
-
"framer-motion": "^
|
29
|
+
"framer-motion": "^8.5.5",
|
31
30
|
"lottie-react": "^2.4.0",
|
32
31
|
"react-aria": "^3.33.1",
|
33
32
|
"react-stately": "^3.31.1",
|
34
|
-
"react-swipeable": "^7.0.1"
|
33
|
+
"react-swipeable": "^7.0.1",
|
34
|
+
"@vygruppen/spor-design-tokens": "3.10.0",
|
35
|
+
"@vygruppen/spor-icon-react": "3.13.0",
|
36
|
+
"@vygruppen/spor-loader": "0.5.0"
|
35
37
|
},
|
36
38
|
"devDependencies": {
|
39
|
+
"@react-types/datepicker": "^3.10.0",
|
40
|
+
"@react-types/shared": "^3.27.0",
|
37
41
|
"@testing-library/jest-dom": "^6.4.5",
|
38
42
|
"@testing-library/react": "^14.3.1",
|
43
|
+
"@types/node": "^22.13.4",
|
44
|
+
"@types/react": "^18.3.3",
|
45
|
+
"@types/react-dom": "^18.3.0",
|
39
46
|
"react": "^18.3.1",
|
40
47
|
"react-dom": "^18.3.1",
|
41
48
|
"tsup": "^7.2.0",
|
42
49
|
"vitest": "^0.26.3",
|
43
50
|
"vitest-axe": "^0.1.0",
|
44
|
-
"vitest-canvas-mock": "^0.2.2"
|
51
|
+
"vitest-canvas-mock": "^0.2.2",
|
52
|
+
"typescript": "^5.7.3",
|
53
|
+
"@vygruppen/tsconfig": "0.0.0"
|
45
54
|
},
|
46
55
|
"peerDependencies": {
|
47
56
|
"react": "^18.2.0",
|
48
57
|
"react-dom": "^18.2.0"
|
58
|
+
},
|
59
|
+
"scripts": {
|
60
|
+
"build": "tsup",
|
61
|
+
"dev": "tsup --watch"
|
49
62
|
}
|
50
|
-
}
|
63
|
+
}
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import {
|
2
|
-
As,
|
3
2
|
IconButton as ChakraIconButton,
|
4
3
|
IconButtonProps as ChakraIconButtonProps,
|
5
4
|
forwardRef,
|
6
5
|
} from "@chakra-ui/react";
|
7
6
|
import React from "react";
|
8
7
|
import { ColorSpinner } from "..";
|
8
|
+
import { As } from "@chakra-ui/system";
|
9
9
|
|
10
10
|
export type IconButtonProps = Omit<ChakraIconButtonProps, "variant"> & {
|
11
11
|
/** The button variant.
|
@@ -3,13 +3,13 @@ import {
|
|
3
3
|
PopoverAnchor,
|
4
4
|
useMultiStyleConfig,
|
5
5
|
forwardRef,
|
6
|
-
As,
|
7
6
|
ResponsiveValue,
|
8
7
|
} from "@chakra-ui/react";
|
9
8
|
import { CalendarOutline24Icon } from "@vygruppen/spor-icon-react";
|
10
9
|
import React, { KeyboardEventHandler } from "react";
|
11
10
|
import { AriaButtonProps } from "react-aria";
|
12
11
|
import { IconButton, createTexts, useTranslation } from "..";
|
12
|
+
import { As } from "@chakra-ui/system";
|
13
13
|
|
14
14
|
type CalendarTriggerButtonProps = AriaButtonProps<"button"> & {
|
15
15
|
variant: ResponsiveValue<"base" | "floating" | "ghost">;
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import {
|
2
|
-
As,
|
3
2
|
Box,
|
4
3
|
BoxProps,
|
5
4
|
ResponsiveValue,
|
@@ -7,6 +6,7 @@ import {
|
|
7
6
|
useFormControlContext,
|
8
7
|
useMultiStyleConfig,
|
9
8
|
} from "@chakra-ui/react";
|
9
|
+
import { As } from "@chakra-ui/system";
|
10
10
|
import React from "react";
|
11
11
|
|
12
12
|
type StyledFieldProps = BoxProps & {
|
@@ -95,11 +95,12 @@ export const TimePicker = ({
|
|
95
95
|
const minutesToSubtract =
|
96
96
|
dateTime.minute % minuteInterval || minuteInterval;
|
97
97
|
state.setValue(
|
98
|
-
|
98
|
+
dateTime.subtract({
|
99
99
|
minutes: minutesToSubtract,
|
100
100
|
}),
|
101
101
|
);
|
102
102
|
};
|
103
|
+
|
103
104
|
const handleForwardClick = () => {
|
104
105
|
if (!dateTime) {
|
105
106
|
return;
|
@@ -107,7 +108,7 @@ export const TimePicker = ({
|
|
107
108
|
const minutesToAdd =
|
108
109
|
minuteInterval - (dateTime.minute % minuteInterval) || minuteInterval;
|
109
110
|
state.setValue(
|
110
|
-
|
111
|
+
dateTime.add({
|
111
112
|
minutes: minutesToAdd,
|
112
113
|
}),
|
113
114
|
);
|
package/src/input/ChoiceChip.tsx
CHANGED
package/src/input/InfoSelect.tsx
CHANGED
@@ -232,8 +232,8 @@ export function InfoSelect<T extends object>({
|
|
232
232
|
transitionDuration={"var(--spor-transition-duration-normal)"}
|
233
233
|
>
|
234
234
|
{state.selectedItem
|
235
|
-
? state.selectedItem.textValue ?? state.selectedItem.rendered
|
236
|
-
: placeholder ?? t(texts.selectAnOption)}
|
235
|
+
? (state.selectedItem.textValue ?? state.selectedItem.rendered)
|
236
|
+
: (placeholder ?? t(texts.selectAnOption))}
|
237
237
|
</Box>
|
238
238
|
</chakra.div>
|
239
239
|
<Box sx={styles.arrowIcon}>
|
@@ -1,13 +1,9 @@
|
|
1
|
-
import {
|
2
|
-
As,
|
3
|
-
BoxProps,
|
4
|
-
forwardRef,
|
5
|
-
useControllableState,
|
6
|
-
} from "@chakra-ui/react";
|
1
|
+
import { BoxProps, forwardRef, useControllableState } from "@chakra-ui/react";
|
7
2
|
import React from "react";
|
8
3
|
import { Input, createTexts, useTranslation } from "..";
|
9
4
|
import { AttachedInputs } from "./AttachedInputs";
|
10
5
|
import { CountryCodeSelect } from "./CountryCodeSelect";
|
6
|
+
import { As } from "@chakra-ui/system";
|
11
7
|
|
12
8
|
type CountryCodeAndPhoneNumber = {
|
13
9
|
countryCode: string;
|
package/src/input/Switch.tsx
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
import {
|
2
|
-
As,
|
3
2
|
Switch as ChakraSwitch,
|
4
3
|
SwitchProps as ChakraSwitchProps,
|
5
4
|
forwardRef,
|
6
5
|
} from "@chakra-ui/react";
|
6
|
+
import { As } from "@chakra-ui/system";
|
7
7
|
import React from "react";
|
8
8
|
|
9
9
|
export type SwitchProps = Omit<ChakraSwitchProps, "colorScheme" | "variant"> & {
|
10
10
|
size?: "sm" | "md" | "lg";
|
11
|
-
as?: As;
|
12
11
|
};
|
13
12
|
|
14
13
|
/**
|
@@ -33,7 +32,7 @@ export type SwitchProps = Omit<ChakraSwitchProps, "colorScheme" | "variant"> & {
|
|
33
32
|
* ```
|
34
33
|
*/
|
35
34
|
export const Switch = forwardRef<SwitchProps, "input">(
|
36
|
-
({ size = "md", as
|
35
|
+
({ size = "md", as, ...props }, ref) => {
|
37
36
|
return <ChakraSwitch as={as} size={size} {...props} ref={ref} />;
|
38
37
|
},
|
39
38
|
);
|
package/src/layout/Divider.tsx
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
import {
|
2
|
-
As,
|
3
2
|
BoxProps,
|
4
3
|
Divider as ChakraDivider,
|
5
4
|
DividerProps as ChakraDividerProps,
|
6
5
|
forwardRef,
|
7
6
|
} from "@chakra-ui/react";
|
7
|
+
import { As } from "@chakra-ui/system";
|
8
8
|
import React from "react";
|
9
9
|
|
10
10
|
export type DividerProps = ChakraDividerProps & {
|
@@ -1,11 +1,6 @@
|
|
1
1
|
import React from "react";
|
2
|
-
import {
|
3
|
-
|
4
|
-
Box,
|
5
|
-
BoxProps,
|
6
|
-
forwardRef,
|
7
|
-
useStyleConfig,
|
8
|
-
} from "@chakra-ui/react";
|
2
|
+
import { Box, BoxProps, forwardRef, useStyleConfig } from "@chakra-ui/react";
|
3
|
+
import { As } from "@chakra-ui/system";
|
9
4
|
|
10
5
|
type PressableCardProps = BoxProps & {
|
11
6
|
/** Defaults to "base" */
|
@@ -1,11 +1,6 @@
|
|
1
1
|
import React from "react";
|
2
|
-
import {
|
3
|
-
|
4
|
-
Box,
|
5
|
-
BoxProps,
|
6
|
-
useStyleConfig,
|
7
|
-
forwardRef,
|
8
|
-
} from "@chakra-ui/react";
|
2
|
+
import { Box, BoxProps, useStyleConfig, forwardRef } from "@chakra-ui/react";
|
3
|
+
import { As } from "@chakra-ui/system";
|
9
4
|
|
10
5
|
export type StaticCardProps = BoxProps & {
|
11
6
|
children: React.ReactNode;
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import {
|
2
|
-
As,
|
3
2
|
Box,
|
4
3
|
BoxProps,
|
5
4
|
forwardRef,
|
@@ -16,6 +15,7 @@ import {
|
|
16
15
|
import React from "react";
|
17
16
|
import { LineIcon } from "./LineIcon";
|
18
17
|
import type { TagProps } from "./types";
|
18
|
+
import { As } from "@chakra-ui/system";
|
19
19
|
|
20
20
|
export type TravelTagProps = TagProps &
|
21
21
|
BoxProps & {
|
package/src/toast/useToast.tsx
CHANGED
@@ -51,49 +51,71 @@ export type ToastOptions = BaseToastOptions &
|
|
51
51
|
*/
|
52
52
|
export const useToast = () => {
|
53
53
|
const toast = useChakraToast();
|
54
|
-
const wrappedToast = useCallback(
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
54
|
+
const wrappedToast = useCallback(
|
55
|
+
(opts: ToastOptions) => {
|
56
|
+
const Toast = getToastComponent(opts);
|
57
|
+
toast({
|
58
|
+
...opts,
|
59
|
+
render: Toast,
|
60
|
+
});
|
61
|
+
},
|
62
|
+
[toast],
|
63
|
+
);
|
61
64
|
return wrappedToast;
|
62
65
|
};
|
63
66
|
|
64
|
-
type RenderArgs = { onClose: () => void; id
|
67
|
+
type RenderArgs = { onClose: () => void; id?: string | number };
|
68
|
+
|
65
69
|
const getToastComponent = (opts: ToastOptions) => {
|
66
70
|
if ("isClosable" in opts && opts.isClosable) {
|
67
|
-
return ({ onClose, id }: RenderArgs) =>
|
68
|
-
|
69
|
-
id
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
}
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
71
|
+
return ({ onClose, id }: RenderArgs) => {
|
72
|
+
if (id === undefined) {
|
73
|
+
return null; // Handle the case where id is undefined
|
74
|
+
}
|
75
|
+
|
76
|
+
return (
|
77
|
+
<ClosableToast
|
78
|
+
id={id.toString()}
|
79
|
+
variant={opts.variant}
|
80
|
+
onClose={() => {
|
81
|
+
if (opts.onClose) {
|
82
|
+
opts.onClose();
|
83
|
+
}
|
84
|
+
onClose();
|
85
|
+
}}
|
86
|
+
>
|
87
|
+
{opts.text}
|
88
|
+
</ClosableToast>
|
89
|
+
);
|
90
|
+
};
|
81
91
|
}
|
82
92
|
if ("buttonText" in opts) {
|
83
|
-
return ({ id }: RenderArgs) =>
|
84
|
-
|
85
|
-
id
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
93
|
+
return ({ id }: RenderArgs) => {
|
94
|
+
if (id === undefined) {
|
95
|
+
return null; // Handle the case where id is undefined
|
96
|
+
}
|
97
|
+
|
98
|
+
return (
|
99
|
+
<ActionToast
|
100
|
+
id={id.toString()}
|
101
|
+
variant={opts.variant}
|
102
|
+
buttonText={opts.buttonText}
|
103
|
+
onClick={opts.onClick}
|
104
|
+
>
|
105
|
+
{opts.text}
|
106
|
+
</ActionToast>
|
107
|
+
);
|
108
|
+
};
|
109
|
+
}
|
110
|
+
return ({ id }: RenderArgs) => {
|
111
|
+
if (id === undefined) {
|
112
|
+
return null; // Handle the case where id is undefined
|
113
|
+
}
|
114
|
+
|
115
|
+
return (
|
116
|
+
<BaseToast id={id.toString()} variant={opts.variant}>
|
90
117
|
{opts.text}
|
91
|
-
</
|
118
|
+
</BaseToast>
|
92
119
|
);
|
93
|
-
}
|
94
|
-
return ({ id }: RenderArgs) => (
|
95
|
-
<BaseToast id={id} variant={opts.variant}>
|
96
|
-
{opts.text}
|
97
|
-
</BaseToast>
|
98
|
-
);
|
120
|
+
};
|
99
121
|
};
|
package/src/typography/Badge.tsx
CHANGED
package/src/typography/Code.tsx
CHANGED
@@ -46,7 +46,7 @@ export const Heading = ({
|
|
46
46
|
...props
|
47
47
|
}: HeadingProps) => {
|
48
48
|
const id =
|
49
|
-
externalId ?? (autoId && typeof props.children === "string")
|
49
|
+
(externalId ?? (autoId && typeof props.children === "string"))
|
50
50
|
? slugify(props.children as string)
|
51
51
|
: undefined;
|
52
52
|
const color = useColorModeValue("text.primary.light", "text.primary.dark");
|