@vygruppen/spor-react 12.24.16 → 13.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.
- package/.turbo/turbo-build.log +10 -10
- package/.turbo/turbo-postinstall.log +4 -3
- package/CHANGELOG.md +18 -0
- package/dist/index.cjs +2753 -2646
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +887 -601
- package/dist/index.d.ts +887 -601
- package/dist/index.mjs +2712 -2605
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
- package/src/accordion/Accordion.tsx +34 -29
- package/src/accordion/Expandable.tsx +20 -21
- package/src/alert/Alert.tsx +7 -5
- package/src/alert/AlertIcon.tsx +19 -20
- package/src/alert/ExpandableAlert.tsx +65 -64
- package/src/alert/ServiceAlert.tsx +78 -78
- package/src/breadcrumb/Breadcrumb.tsx +37 -34
- package/src/button/Button.tsx +64 -57
- package/src/button/ButtonGroup.tsx +12 -10
- package/src/button/Clipboard.tsx +21 -18
- package/src/button/CloseButton.tsx +19 -17
- package/src/button/FloatingActionButton.tsx +41 -47
- package/src/button/IconButton.tsx +20 -18
- package/src/calendar/CalendarContext.tsx +1 -1
- package/src/color-mode/color-mode.tsx +7 -5
- package/src/datepicker/CalendarTriggerButton.tsx +11 -7
- package/src/datepicker/DateField.tsx +53 -51
- package/src/datepicker/DatePicker.tsx +127 -134
- package/src/datepicker/DateTimeSegment.tsx +44 -40
- package/src/datepicker/StyledField.tsx +39 -36
- package/src/dialog/Dialog.tsx +14 -11
- package/src/dialog/Drawer.tsx +74 -67
- package/src/input/AttachedInputs.tsx +35 -41
- package/src/input/Autocomplete.tsx +118 -129
- package/src/input/CardSelect.tsx +67 -65
- package/src/input/Checkbox.tsx +19 -17
- package/src/input/CheckboxGroup.tsx +0 -2
- package/src/input/ChoiceChip.tsx +42 -38
- package/src/input/Combobox.tsx +4 -4
- package/src/input/CountryCodeSelect.tsx +8 -8
- package/src/input/Field.tsx +78 -75
- package/src/input/FloatingLabel.tsx +6 -8
- package/src/input/Input.tsx +87 -92
- package/src/input/ListBox.tsx +3 -4
- package/src/input/Menu.tsx +149 -142
- package/src/input/NativeSelect.tsx +7 -5
- package/src/input/NumericStepper.tsx +15 -12
- package/src/input/PasswordInput.tsx +65 -61
- package/src/input/PhoneNumberInput.tsx +7 -7
- package/src/input/Popover.tsx +52 -55
- package/src/input/Radio.tsx +16 -11
- package/src/input/SearchInput.tsx +32 -31
- package/src/input/Select.tsx +106 -96
- package/src/input/Switch.tsx +43 -41
- package/src/input/Textarea.tsx +68 -66
- package/src/layout/PressableCard.tsx +11 -10
- package/src/layout/RadioCard.tsx +57 -53
- package/src/layout/Separator.tsx +8 -7
- package/src/layout/StaticCard.tsx +11 -10
- package/src/linjetag/LineIcon.tsx +48 -54
- package/src/linjetag/TravelTag.tsx +57 -59
- package/src/link/TextLink.tsx +50 -40
- package/src/loader/ProgressBar.tsx +41 -46
- package/src/loader/ProgressLoader.tsx +83 -86
- package/src/loader/Skeleton.tsx +56 -48
- package/src/logo/CargonetLogo.tsx +88 -87
- package/src/logo/VyLogo.tsx +80 -77
- package/src/logo/VyLogoPride.tsx +137 -135
- package/src/media-controller/JumpButton.tsx +30 -28
- package/src/media-controller/PlayPauseButton.tsx +8 -7
- package/src/media-controller/SkipButton.tsx +28 -26
- package/src/nudge/Nudge.tsx +66 -70
- package/src/pagination/Pagination.tsx +52 -46
- package/src/popover/index.tsx +46 -41
- package/src/progress-indicator/ProgressIndicator.tsx +10 -7
- package/src/stepper/Stepper.tsx +84 -81
- package/src/tab/Tabs.tsx +8 -4
- package/src/table/Table.tsx +89 -109
- package/src/tooltip.tsx +26 -22
- package/src/typography/Badge.tsx +8 -5
- package/src/typography/Code.tsx +8 -5
- package/src/typography/Heading.tsx +22 -23
- package/src/typography/Text.tsx +11 -9
- package/tsconfig.json +1 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { Button, useControllableState } from "@chakra-ui/react";
|
|
4
|
-
import React
|
|
4
|
+
import React from "react";
|
|
5
5
|
|
|
6
6
|
import { ButtonProps, Input, InputProps } from "..";
|
|
7
7
|
import { createTexts, useTranslation } from "..";
|
|
@@ -42,70 +42,74 @@ export interface PasswordInputProps
|
|
|
42
42
|
* @see https://spor.vy.no/components/password-input
|
|
43
43
|
*/
|
|
44
44
|
|
|
45
|
-
export const PasswordInput =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
export const PasswordInput = ({
|
|
46
|
+
ref,
|
|
47
|
+
...props
|
|
48
|
+
}: PasswordInputProps & {
|
|
49
|
+
ref?: React.RefObject<HTMLInputElement>;
|
|
50
|
+
}) => {
|
|
51
|
+
const {
|
|
52
|
+
defaultVisible,
|
|
53
|
+
visible: visibleProperty,
|
|
54
|
+
onVisibleChange,
|
|
55
|
+
label,
|
|
56
|
+
startElement,
|
|
57
|
+
...rest
|
|
58
|
+
} = props;
|
|
55
59
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
const [visible, setVisible] = useControllableState({
|
|
61
|
+
value: visibleProperty,
|
|
62
|
+
defaultValue: defaultVisible || false,
|
|
63
|
+
onChange: onVisibleChange,
|
|
64
|
+
});
|
|
61
65
|
|
|
62
|
-
|
|
66
|
+
const { t } = useTranslation();
|
|
63
67
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
);
|
|
89
|
-
PasswordInput.displayName = "PasswordInput";
|
|
68
|
+
return (
|
|
69
|
+
<Input
|
|
70
|
+
ref={ref}
|
|
71
|
+
startElement={startElement && startElement}
|
|
72
|
+
label={label}
|
|
73
|
+
type={visible ? "text" : "password"}
|
|
74
|
+
endElement={
|
|
75
|
+
<VisibilityTrigger
|
|
76
|
+
variant="ghost"
|
|
77
|
+
disabled={rest.disabled}
|
|
78
|
+
onPointerDown={(event) => {
|
|
79
|
+
if (rest.disabled) return;
|
|
80
|
+
if (event.button !== 0) return;
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
setVisible(!visible);
|
|
83
|
+
}}
|
|
84
|
+
>
|
|
85
|
+
{visible ? t(texts.hidePassword) : t(texts.showPassword)}
|
|
86
|
+
</VisibilityTrigger>
|
|
87
|
+
}
|
|
88
|
+
{...rest}
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
90
92
|
|
|
91
|
-
const VisibilityTrigger =
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
93
|
+
const VisibilityTrigger = ({
|
|
94
|
+
ref,
|
|
95
|
+
...props
|
|
96
|
+
}: ButtonProps & {
|
|
97
|
+
ref?: React.RefObject<HTMLButtonElement>;
|
|
98
|
+
}) => {
|
|
99
|
+
return (
|
|
100
|
+
<Button
|
|
101
|
+
ref={ref}
|
|
102
|
+
type="button"
|
|
103
|
+
fontWeight="normal"
|
|
104
|
+
size="sm"
|
|
105
|
+
borderRadius="sm"
|
|
106
|
+
marginRight={1}
|
|
107
|
+
{...props}
|
|
108
|
+
>
|
|
109
|
+
{props.children}
|
|
110
|
+
</Button>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
109
113
|
|
|
110
114
|
const texts = createTexts({
|
|
111
115
|
showPassword: {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useControllableState } from "@chakra-ui/react";
|
|
3
|
-
import { forwardRef } from "react";
|
|
4
3
|
|
|
5
4
|
import { createTexts, Input, InputProps, useTranslation } from "..";
|
|
6
5
|
import { AttachedInputs } from "./AttachedInputs";
|
|
@@ -42,10 +41,12 @@ type PhoneNumberInputProps = Omit<InputProps, "value"> & {
|
|
|
42
41
|
* ```
|
|
43
42
|
*/
|
|
44
43
|
|
|
45
|
-
export const PhoneNumberInput =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
export const PhoneNumberInput = ({
|
|
45
|
+
ref,
|
|
46
|
+
...props
|
|
47
|
+
}: PhoneNumberInputProps & {
|
|
48
|
+
ref?: React.RefObject<HTMLInputElement>;
|
|
49
|
+
}) => {
|
|
49
50
|
const {
|
|
50
51
|
label: externalLabel,
|
|
51
52
|
value: externalValue,
|
|
@@ -114,8 +115,7 @@ export const PhoneNumberInput = forwardRef<
|
|
|
114
115
|
/>
|
|
115
116
|
</AttachedInputs>
|
|
116
117
|
);
|
|
117
|
-
}
|
|
118
|
-
PhoneNumberInput.displayName = "PhoneNumberInput";
|
|
118
|
+
};
|
|
119
119
|
|
|
120
120
|
const texts = createTexts({
|
|
121
121
|
phoneNumber: {
|
package/src/input/Popover.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Box } from "@chakra-ui/react";
|
|
3
|
-
import React, {
|
|
3
|
+
import React, { useRef } from "react";
|
|
4
4
|
import {
|
|
5
5
|
AriaPopoverProps,
|
|
6
6
|
DismissButton,
|
|
@@ -56,62 +56,59 @@ type PopoverProps = {
|
|
|
56
56
|
*
|
|
57
57
|
* Used to render accessible popover content, only used in ComboBox.
|
|
58
58
|
*/
|
|
59
|
-
export const Popover =
|
|
60
|
-
|
|
59
|
+
export const Popover = ({
|
|
60
|
+
ref,
|
|
61
|
+
children,
|
|
62
|
+
state,
|
|
63
|
+
triggerRef,
|
|
64
|
+
offset = 0,
|
|
65
|
+
crossOffset = 0,
|
|
66
|
+
placement = "bottom",
|
|
67
|
+
shouldFlip = false,
|
|
68
|
+
isNonModal = false,
|
|
69
|
+
hasBackdrop = true,
|
|
70
|
+
containerPadding = 12,
|
|
71
|
+
}: PopoverProps & {
|
|
72
|
+
ref?: React.RefObject<HTMLDivElement | null>;
|
|
73
|
+
}) => {
|
|
74
|
+
const internalRef = useRef<HTMLDivElement>(null);
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
|
+
const popoverRef = ref ?? (internalRef as any);
|
|
77
|
+
|
|
78
|
+
const { popoverProps, underlayProps } = usePopover(
|
|
61
79
|
{
|
|
62
|
-
children,
|
|
63
|
-
state,
|
|
64
80
|
triggerRef,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
containerPadding
|
|
81
|
+
popoverRef,
|
|
82
|
+
offset,
|
|
83
|
+
crossOffset,
|
|
84
|
+
placement,
|
|
85
|
+
shouldFlip,
|
|
86
|
+
isNonModal,
|
|
87
|
+
containerPadding,
|
|
72
88
|
},
|
|
73
|
-
|
|
74
|
-
)
|
|
75
|
-
const internalRef = useRef<HTMLDivElement>(null);
|
|
76
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
77
|
-
const popoverRef = ref ?? (internalRef as any);
|
|
78
|
-
|
|
79
|
-
const { popoverProps, underlayProps } = usePopover(
|
|
80
|
-
{
|
|
81
|
-
triggerRef,
|
|
82
|
-
popoverRef,
|
|
83
|
-
offset,
|
|
84
|
-
crossOffset,
|
|
85
|
-
placement,
|
|
86
|
-
shouldFlip,
|
|
87
|
-
isNonModal,
|
|
88
|
-
containerPadding,
|
|
89
|
-
},
|
|
90
|
-
state,
|
|
91
|
-
);
|
|
89
|
+
state,
|
|
90
|
+
);
|
|
92
91
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
92
|
+
const popoverBox = (
|
|
93
|
+
<Box
|
|
94
|
+
{...popoverProps}
|
|
95
|
+
ref={popoverRef}
|
|
96
|
+
// eslint-disable-next-line react-hooks/refs
|
|
97
|
+
minWidth={triggerRef.current?.clientWidth ?? "auto"}
|
|
98
|
+
>
|
|
99
|
+
<DismissButton onDismiss={state.close} />
|
|
100
|
+
{children}
|
|
101
|
+
<DismissButton onDismiss={state.close} />
|
|
102
|
+
</Box>
|
|
103
|
+
);
|
|
105
104
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
);
|
|
117
|
-
Popover.displayName = "Popover";
|
|
105
|
+
if (isNonModal) {
|
|
106
|
+
return popoverBox;
|
|
107
|
+
}
|
|
108
|
+
return (
|
|
109
|
+
<Overlay>
|
|
110
|
+
{hasBackdrop && <Box {...underlayProps} position="fixed" inset="0" />}
|
|
111
|
+
{popoverBox}
|
|
112
|
+
</Overlay>
|
|
113
|
+
);
|
|
114
|
+
};
|
package/src/input/Radio.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { RecipeVariantProps } from "@chakra-ui/react";
|
|
3
3
|
import { RadioGroup as ChakraRadioGroup } from "@chakra-ui/react";
|
|
4
|
-
import React, {
|
|
4
|
+
import React, { PropsWithChildren } from "react";
|
|
5
5
|
|
|
6
6
|
import { radioGroupSlotRecipe } from "../theme/slot-recipes/radio";
|
|
7
7
|
|
|
@@ -28,7 +28,12 @@ export type RadioProps = PropsWithChildren<RadioVariants> &
|
|
|
28
28
|
* </RadioGroup>
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
-
export const Radio =
|
|
31
|
+
export const Radio = ({
|
|
32
|
+
ref,
|
|
33
|
+
...props
|
|
34
|
+
}: RadioProps & {
|
|
35
|
+
ref?: React.RefObject<HTMLInputElement>;
|
|
36
|
+
}) => {
|
|
32
37
|
const { children, inputProps, rootRef, ...rest } = props;
|
|
33
38
|
|
|
34
39
|
return (
|
|
@@ -40,17 +45,17 @@ export const Radio = forwardRef<HTMLInputElement, RadioProps>((props, ref) => {
|
|
|
40
45
|
)}
|
|
41
46
|
</ChakraRadioGroup.Item>
|
|
42
47
|
);
|
|
43
|
-
}
|
|
44
|
-
Radio.displayName = "Radio";
|
|
45
|
-
|
|
48
|
+
};
|
|
46
49
|
type RadioGroupProps = Omit<
|
|
47
50
|
ChakraRadioGroup.RootProps,
|
|
48
51
|
"colorPalette" | "variant" | "size"
|
|
49
52
|
> & {};
|
|
50
53
|
|
|
51
|
-
export const RadioGroup =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
export const RadioGroup = ({
|
|
55
|
+
ref,
|
|
56
|
+
...props
|
|
57
|
+
}: RadioGroupProps & {
|
|
58
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
59
|
+
}) => {
|
|
60
|
+
return <ChakraRadioGroup.Root ref={ref} {...props} aria-labelledby="" />;
|
|
61
|
+
};
|
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
CloseOutline24Icon,
|
|
5
5
|
SearchOutline24Icon,
|
|
6
6
|
} from "@vygruppen/spor-icon-react";
|
|
7
|
-
import { forwardRef } from "react";
|
|
8
7
|
|
|
9
8
|
import { createTexts, Input, InputProps, useTranslation } from "..";
|
|
10
9
|
import { IconButton } from "../button/IconButton";
|
|
@@ -19,37 +18,39 @@ export type SearchInputProps = InputProps & {
|
|
|
19
18
|
* Includes a search icon, a localized label and a reset button.
|
|
20
19
|
*/
|
|
21
20
|
|
|
22
|
-
export const SearchInput =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
export const SearchInput = ({
|
|
22
|
+
ref,
|
|
23
|
+
...props
|
|
24
|
+
}: SearchInputProps & {
|
|
25
|
+
ref?: React.RefObject<HTMLInputElement>;
|
|
26
|
+
}) => {
|
|
27
|
+
const { t } = useTranslation();
|
|
28
|
+
const { variant = "core", onReset, label, value } = props;
|
|
29
|
+
const clearButton = onReset && value;
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
);
|
|
52
|
-
SearchInput.displayName = "SearchInput";
|
|
31
|
+
return (
|
|
32
|
+
<Input
|
|
33
|
+
ref={ref}
|
|
34
|
+
type="search"
|
|
35
|
+
variant={variant}
|
|
36
|
+
{...props}
|
|
37
|
+
startElement={<SearchOutline24Icon color="icon" />}
|
|
38
|
+
endElement={
|
|
39
|
+
clearButton && (
|
|
40
|
+
<IconButton
|
|
41
|
+
variant="ghost"
|
|
42
|
+
type="button"
|
|
43
|
+
size="sm"
|
|
44
|
+
aria-label={t(texts.reset)}
|
|
45
|
+
icon={<CloseOutline24Icon />}
|
|
46
|
+
onClick={onReset}
|
|
47
|
+
/>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
label={(label as string) ?? t(texts.label)}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
53
54
|
|
|
54
55
|
const texts = createTexts({
|
|
55
56
|
label: {
|