@vygruppen/spor-react 12.24.16 → 13.0.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 +10 -10
- package/.turbo/turbo-postinstall.log +2 -2
- package/CHANGELOG.md +24 -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 +10 -10
- 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/input/useFLoatingInputState.tsx +1 -1
- 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
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
BreadcrumbRootProps,
|
|
6
6
|
} from "@chakra-ui/react";
|
|
7
7
|
import { DropdownRightFill18Icon } from "@vygruppen/spor-icon-react";
|
|
8
|
-
import React
|
|
8
|
+
import React from "react";
|
|
9
9
|
/**
|
|
10
10
|
* A breadcrumb component.
|
|
11
11
|
*
|
|
@@ -20,40 +20,43 @@ import React, { forwardRef } from "react";
|
|
|
20
20
|
* </Breadcrumb>
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
export const Breadcrumb =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
export const Breadcrumb = ({
|
|
24
|
+
ref,
|
|
25
|
+
children,
|
|
26
|
+
css,
|
|
27
|
+
...props
|
|
28
|
+
}: BreadcrumbRootProps & {
|
|
29
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
30
|
+
}) => {
|
|
31
|
+
const validChildren = React.Children.toArray(children).filter((element) =>
|
|
32
|
+
React.isValidElement(element),
|
|
33
|
+
);
|
|
28
34
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
Breadcrumb.displayName = "Breadcrumb";
|
|
35
|
+
return (
|
|
36
|
+
<ChakraBreadcrumb.Root ref={ref} css={css} {...props}>
|
|
37
|
+
<ChakraBreadcrumb.List data-part="list">
|
|
38
|
+
{validChildren.map((child, index) => {
|
|
39
|
+
const isLast = index === validChildren.length - 1;
|
|
40
|
+
return (
|
|
41
|
+
<React.Fragment key={index}>
|
|
42
|
+
<ChakraBreadcrumb.Item data-part="item">
|
|
43
|
+
{child}
|
|
44
|
+
</ChakraBreadcrumb.Item>
|
|
45
|
+
{!isLast && (
|
|
46
|
+
<ChakraBreadcrumb.Separator
|
|
47
|
+
aria-hidden="true"
|
|
48
|
+
data-part="separator"
|
|
49
|
+
>
|
|
50
|
+
<DropdownRightFill18Icon />
|
|
51
|
+
</ChakraBreadcrumb.Separator>
|
|
52
|
+
)}
|
|
53
|
+
</React.Fragment>
|
|
54
|
+
);
|
|
55
|
+
})}
|
|
56
|
+
</ChakraBreadcrumb.List>
|
|
57
|
+
</ChakraBreadcrumb.Root>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
57
60
|
|
|
58
61
|
export {
|
|
59
62
|
BreadcrumbCurrentLink,
|
package/src/button/Button.tsx
CHANGED
|
@@ -7,7 +7,13 @@ import {
|
|
|
7
7
|
type RecipeVariantProps,
|
|
8
8
|
Span,
|
|
9
9
|
} from "@chakra-ui/react";
|
|
10
|
-
import React, {
|
|
10
|
+
import React, {
|
|
11
|
+
cloneElement,
|
|
12
|
+
isValidElement,
|
|
13
|
+
PropsWithChildren,
|
|
14
|
+
ReactElement,
|
|
15
|
+
ReactNode,
|
|
16
|
+
} from "react";
|
|
11
17
|
|
|
12
18
|
import { createTexts, useTranslation } from "../i18n";
|
|
13
19
|
import { ColorInlineLoader } from "../loader";
|
|
@@ -92,72 +98,73 @@ const LoadingContent = ({
|
|
|
92
98
|
</>
|
|
93
99
|
);
|
|
94
100
|
|
|
95
|
-
|
|
96
|
-
(
|
|
97
|
-
{
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
variant = "primary",
|
|
102
|
-
size = "md",
|
|
103
|
-
leftIcon,
|
|
104
|
-
rightIcon,
|
|
105
|
-
type = "button",
|
|
106
|
-
children,
|
|
107
|
-
...rest
|
|
108
|
-
},
|
|
109
|
-
ref,
|
|
110
|
-
) => {
|
|
111
|
-
const { t } = useTranslation();
|
|
101
|
+
const getChildContent = (child: ReactNode): ReactNode => {
|
|
102
|
+
if (isValidElement(child)) {
|
|
103
|
+
return (child.props as { children?: ReactNode }).children;
|
|
104
|
+
}
|
|
105
|
+
return child;
|
|
106
|
+
};
|
|
112
107
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
108
|
+
export const Button = ({
|
|
109
|
+
ref,
|
|
110
|
+
loading,
|
|
111
|
+
disabled,
|
|
112
|
+
loadingText,
|
|
113
|
+
variant = "primary",
|
|
114
|
+
size = "md",
|
|
115
|
+
leftIcon,
|
|
116
|
+
rightIcon,
|
|
117
|
+
type = "button",
|
|
118
|
+
children,
|
|
119
|
+
...rest
|
|
120
|
+
}: ButtonProps & {
|
|
121
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
122
|
+
}) => {
|
|
123
|
+
const { t } = useTranslation();
|
|
116
124
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
: children;
|
|
125
|
+
const ariaLabel = loading
|
|
126
|
+
? String(loadingText ?? t(texts.loadingText))
|
|
127
|
+
: (rest["aria-label"] as string);
|
|
121
128
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
<LoadingContent size={size} loadingText={loadingText}>
|
|
125
|
-
<ButtonContent leftIcon={leftIcon} rightIcon={rightIcon}>
|
|
126
|
-
{content}
|
|
127
|
-
</ButtonContent>
|
|
128
|
-
</LoadingContent>
|
|
129
|
-
);
|
|
129
|
+
const renderContent = () => {
|
|
130
|
+
const content = rest.asChild ? getChildContent(children) : children;
|
|
130
131
|
|
|
132
|
+
if (loading)
|
|
131
133
|
return (
|
|
132
|
-
<
|
|
133
|
-
{
|
|
134
|
-
|
|
134
|
+
<LoadingContent size={size} loadingText={loadingText}>
|
|
135
|
+
<ButtonContent leftIcon={leftIcon} rightIcon={rightIcon}>
|
|
136
|
+
{content}
|
|
137
|
+
</ButtonContent>
|
|
138
|
+
</LoadingContent>
|
|
135
139
|
);
|
|
136
|
-
};
|
|
137
140
|
|
|
138
141
|
return (
|
|
139
|
-
<
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
aria-label={ariaLabel}
|
|
143
|
-
aria-busy={loading}
|
|
144
|
-
disabled={disabled || loading}
|
|
145
|
-
position="relative"
|
|
146
|
-
variant={variant}
|
|
147
|
-
size={size}
|
|
148
|
-
{...rest}
|
|
149
|
-
>
|
|
150
|
-
{rest.asChild
|
|
151
|
-
? cloneElement(children as React.ReactElement, {
|
|
152
|
-
children: renderContent(),
|
|
153
|
-
})
|
|
154
|
-
: renderContent()}
|
|
155
|
-
</ChakraButton>
|
|
142
|
+
<ButtonContent leftIcon={leftIcon} rightIcon={rightIcon}>
|
|
143
|
+
{content}
|
|
144
|
+
</ButtonContent>
|
|
156
145
|
);
|
|
157
|
-
}
|
|
158
|
-
);
|
|
146
|
+
};
|
|
159
147
|
|
|
160
|
-
|
|
148
|
+
return (
|
|
149
|
+
<ChakraButton
|
|
150
|
+
type={type}
|
|
151
|
+
ref={ref}
|
|
152
|
+
aria-label={ariaLabel}
|
|
153
|
+
aria-busy={loading}
|
|
154
|
+
disabled={disabled || loading}
|
|
155
|
+
position="relative"
|
|
156
|
+
variant={variant}
|
|
157
|
+
size={size}
|
|
158
|
+
{...rest}
|
|
159
|
+
>
|
|
160
|
+
{rest.asChild && isValidElement(children)
|
|
161
|
+
? cloneElement(children as ReactElement<{ children: ReactNode }>, {
|
|
162
|
+
children: renderContent(),
|
|
163
|
+
})
|
|
164
|
+
: renderContent()}
|
|
165
|
+
</ChakraButton>
|
|
166
|
+
);
|
|
167
|
+
};
|
|
161
168
|
|
|
162
169
|
const texts = createTexts({
|
|
163
170
|
loadingText: {
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
type RecipeVariantProps,
|
|
7
7
|
useRecipe,
|
|
8
8
|
} from "@chakra-ui/react";
|
|
9
|
-
import {
|
|
9
|
+
import { PropsWithChildren } from "react";
|
|
10
10
|
|
|
11
11
|
import { groupRecipe } from "../theme/recipes/group";
|
|
12
12
|
|
|
@@ -48,13 +48,15 @@ export type ButtonGroupProps = ChakraGroupProps &
|
|
|
48
48
|
* </ButtonGroup>
|
|
49
49
|
*/
|
|
50
50
|
|
|
51
|
-
export const ButtonGroup =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
export const ButtonGroup = ({
|
|
52
|
+
ref,
|
|
53
|
+
...props
|
|
54
|
+
}: ButtonGroupProps & {
|
|
55
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
56
|
+
}) => {
|
|
57
|
+
const recipe = useRecipe({ key: "buttonGroup" });
|
|
58
|
+
const [recipeProps, restProps] = recipe.splitVariantProps(props);
|
|
59
|
+
const styles = recipe(recipeProps);
|
|
56
60
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
);
|
|
60
|
-
ButtonGroup.displayName = "ButtonGroup";
|
|
61
|
+
return <ChakraGroup {...restProps} ref={ref} css={styles} />;
|
|
62
|
+
};
|
package/src/button/Clipboard.tsx
CHANGED
|
@@ -20,10 +20,12 @@ import { Button, ButtonProps } from "./Button";
|
|
|
20
20
|
* </Clipboard>
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
const ClipboardIcon =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const ClipboardIcon = ({
|
|
24
|
+
ref,
|
|
25
|
+
...props
|
|
26
|
+
}: ChakraClipboard.IndicatorProps & {
|
|
27
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
28
|
+
}) => {
|
|
27
29
|
return (
|
|
28
30
|
<ChakraClipboard.Indicator
|
|
29
31
|
copied={<CheckmarkFill18Icon />}
|
|
@@ -33,13 +35,14 @@ const ClipboardIcon = React.forwardRef<
|
|
|
33
35
|
<CopyOutline18Icon />
|
|
34
36
|
</ChakraClipboard.Indicator>
|
|
35
37
|
);
|
|
36
|
-
}
|
|
37
|
-
ClipboardIcon.displayName = "ClipboardIcon";
|
|
38
|
+
};
|
|
38
39
|
|
|
39
|
-
const ClipboardCopyText =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
const ClipboardCopyText = ({
|
|
41
|
+
ref,
|
|
42
|
+
...props
|
|
43
|
+
}: ChakraClipboard.IndicatorProps & {
|
|
44
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
45
|
+
}) => {
|
|
43
46
|
const { t } = useTranslation();
|
|
44
47
|
return (
|
|
45
48
|
<ChakraClipboard.Indicator
|
|
@@ -50,15 +53,16 @@ const ClipboardCopyText = React.forwardRef<
|
|
|
50
53
|
<Text variant="xs">{t(texts.copy)}</Text>
|
|
51
54
|
</ChakraClipboard.Indicator>
|
|
52
55
|
);
|
|
53
|
-
}
|
|
54
|
-
ClipboardCopyText.displayName = "ClipboardCopyText";
|
|
56
|
+
};
|
|
55
57
|
|
|
56
58
|
type ClipboardButtonProps = ButtonProps;
|
|
57
59
|
|
|
58
|
-
export const ClipboardButton =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
export const ClipboardButton = ({
|
|
61
|
+
ref,
|
|
62
|
+
...props
|
|
63
|
+
}: ClipboardButtonProps & {
|
|
64
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
65
|
+
}) => {
|
|
62
66
|
return (
|
|
63
67
|
<ChakraClipboard.Trigger asChild>
|
|
64
68
|
<Button ref={ref} size="xs" leftIcon={<ClipboardIcon />} {...props}>
|
|
@@ -66,8 +70,7 @@ export const ClipboardButton = React.forwardRef<
|
|
|
66
70
|
</Button>
|
|
67
71
|
</ChakraClipboard.Trigger>
|
|
68
72
|
);
|
|
69
|
-
}
|
|
70
|
-
ClipboardButton.displayName = "ClipboardButton";
|
|
73
|
+
};
|
|
71
74
|
|
|
72
75
|
export const Clipboard = ChakraClipboard.Root;
|
|
73
76
|
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
CloseFill24Icon,
|
|
6
6
|
CloseFill30Icon,
|
|
7
7
|
} from "@vygruppen/spor-icon-react";
|
|
8
|
-
import { forwardRef } from "react";
|
|
9
8
|
|
|
10
9
|
import { createTexts, useTranslation } from "../i18n";
|
|
11
10
|
import { IconButton, IconButtonProps } from "./IconButton";
|
|
@@ -27,22 +26,25 @@ export type CloseButtonProps = Omit<
|
|
|
27
26
|
* <CloseButton onClick={closeModal} />
|
|
28
27
|
* ```
|
|
29
28
|
*/
|
|
30
|
-
export const CloseButton =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
29
|
+
export const CloseButton = ({
|
|
30
|
+
ref,
|
|
31
|
+
size = "sm",
|
|
32
|
+
...props
|
|
33
|
+
}: CloseButtonProps & {
|
|
34
|
+
ref?: React.Ref<HTMLButtonElement | null>;
|
|
35
|
+
}) => {
|
|
36
|
+
const { t } = useTranslation();
|
|
37
|
+
return (
|
|
38
|
+
<IconButton
|
|
39
|
+
variant="ghost"
|
|
40
|
+
icon={<CloseIcon size={size} />}
|
|
41
|
+
size={size}
|
|
42
|
+
aria-label={props["aria-label"] || t(texts.close)}
|
|
43
|
+
{...props}
|
|
44
|
+
ref={ref}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
46
48
|
|
|
47
49
|
const CloseIcon = ({ size }: { size: CloseButtonProps["size"] }) => {
|
|
48
50
|
switch (size) {
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
Text,
|
|
8
8
|
useSlotRecipe,
|
|
9
9
|
} from "@chakra-ui/react";
|
|
10
|
-
import React, {
|
|
10
|
+
import React, { PropsWithChildren } from "react";
|
|
11
11
|
|
|
12
12
|
import { floatingActionButtonSlotRecipe } from "../theme/slot-recipes/floating-action-button";
|
|
13
13
|
|
|
@@ -36,55 +36,49 @@ type FloatingActionButtonProps = BoxProps &
|
|
|
36
36
|
* placement="bottom right"
|
|
37
37
|
* />
|
|
38
38
|
*/
|
|
39
|
-
export const FloatingActionButton =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
},
|
|
52
|
-
ref,
|
|
53
|
-
) => {
|
|
54
|
-
const scrollDirection = useScrollDirection();
|
|
39
|
+
export const FloatingActionButton = ({
|
|
40
|
+
ref,
|
|
41
|
+
children,
|
|
42
|
+
icon,
|
|
43
|
+
variant,
|
|
44
|
+
isTextVisible: externalIsTextVisible,
|
|
45
|
+
placement = "bottom right",
|
|
46
|
+
...props
|
|
47
|
+
}: FloatingActionButtonProps & {
|
|
48
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
49
|
+
}) => {
|
|
50
|
+
const scrollDirection = useScrollDirection();
|
|
55
51
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
// Use derived value instead of setState in effect
|
|
53
|
+
const isTextVisible =
|
|
54
|
+
externalIsTextVisible === undefined
|
|
55
|
+
? scrollDirection !== "down"
|
|
56
|
+
: !!externalIsTextVisible;
|
|
61
57
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
58
|
+
const recipe = useSlotRecipe({ key: "floatingActionButton" });
|
|
59
|
+
const style = recipe({
|
|
60
|
+
variant,
|
|
61
|
+
placement,
|
|
62
|
+
});
|
|
67
63
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
);
|
|
87
|
-
FloatingActionButton.displayName = "FloatingActionButton";
|
|
64
|
+
return (
|
|
65
|
+
<Box
|
|
66
|
+
css={style.root}
|
|
67
|
+
as="button"
|
|
68
|
+
aria-label={typeof children === "string" ? children : undefined}
|
|
69
|
+
ref={ref}
|
|
70
|
+
{...props}
|
|
71
|
+
aria-expanded={isTextVisible}
|
|
72
|
+
>
|
|
73
|
+
<Box css={style.icon}>{icon}</Box>
|
|
74
|
+
{isTextVisible && (
|
|
75
|
+
<Text data-state="open" css={style.text}>
|
|
76
|
+
{children}
|
|
77
|
+
</Text>
|
|
78
|
+
)}
|
|
79
|
+
</Box>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
88
82
|
|
|
89
83
|
type ScrollDirection = "up" | "down" | null;
|
|
90
84
|
const useScrollDirection = () => {
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
IconButton as ChakraIconButton,
|
|
3
3
|
type IconButtonProps as ChakraIconButtonProps,
|
|
4
4
|
} from "@chakra-ui/react";
|
|
5
|
-
import React, {
|
|
5
|
+
import React, { PropsWithChildren } from "react";
|
|
6
6
|
|
|
7
7
|
import { ButtonVariantProps, ColorSpinner } from "..";
|
|
8
8
|
|
|
@@ -56,20 +56,22 @@ export type IconButtonProps = Exclude<
|
|
|
56
56
|
* />
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
|
-
export const IconButton =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
59
|
+
export const IconButton = ({
|
|
60
|
+
ref,
|
|
61
|
+
...props
|
|
62
|
+
}: IconButtonProps & {
|
|
63
|
+
ref?: React.Ref<HTMLButtonElement | null>;
|
|
64
|
+
}) => {
|
|
65
|
+
const { icon, size = "sm", loading = false, ...rest } = props;
|
|
66
|
+
return (
|
|
67
|
+
<ChakraIconButton
|
|
68
|
+
aria-label={props["aria-label"]}
|
|
69
|
+
size={size}
|
|
70
|
+
position="relative"
|
|
71
|
+
{...rest}
|
|
72
|
+
ref={ref}
|
|
73
|
+
>
|
|
74
|
+
{loading ? <ColorSpinner width="2em" height="2em" margin={1} /> : icon}
|
|
75
|
+
</ChakraIconButton>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
@@ -34,7 +34,7 @@ type BaseCalendarState = {
|
|
|
34
34
|
prevButtonProps: AriaButtonProps<"button">;
|
|
35
35
|
startValue: CalendarDate | null;
|
|
36
36
|
isSelectingRange: boolean;
|
|
37
|
-
ref
|
|
37
|
+
ref?: React.Ref<HTMLDivElement | null>;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
type SingleCalendarState = BaseCalendarState & {
|
|
@@ -47,10 +47,12 @@ export function ColorModeIcon() {
|
|
|
47
47
|
|
|
48
48
|
type ColorModeButtonProps = Omit<IconButtonProps, "aria-label">;
|
|
49
49
|
|
|
50
|
-
export const ColorModeButton =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
export const ColorModeButton = function ColorModeButton({
|
|
51
|
+
ref,
|
|
52
|
+
...props
|
|
53
|
+
}: ColorModeButtonProps & {
|
|
54
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
55
|
+
}) {
|
|
54
56
|
const { toggleColorMode } = useColorMode();
|
|
55
57
|
return (
|
|
56
58
|
<ClientOnly fallback={<Skeleton boxSize="8" />}>
|
|
@@ -72,4 +74,4 @@ export const ColorModeButton = React.forwardRef<
|
|
|
72
74
|
</IconButton>
|
|
73
75
|
</ClientOnly>
|
|
74
76
|
);
|
|
75
|
-
}
|
|
77
|
+
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { BoxProps, PopoverAnchor, useSlotRecipe } from "@chakra-ui/react";
|
|
4
4
|
import { CalendarOutline24Icon } from "@vygruppen/spor-icon-react";
|
|
5
|
-
import {
|
|
5
|
+
import { PropsWithChildren } from "react";
|
|
6
6
|
import { AriaButtonProps } from "react-aria";
|
|
7
7
|
|
|
8
8
|
import {
|
|
@@ -19,12 +19,17 @@ type CalendarTriggerButtonProps = AriaButtonProps<"button"> &
|
|
|
19
19
|
CalendarVariants & {
|
|
20
20
|
disabled?: boolean;
|
|
21
21
|
};
|
|
22
|
-
export const CalendarTriggerButton =
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
export const CalendarTriggerButton = ({
|
|
23
|
+
ref,
|
|
24
|
+
variant,
|
|
25
|
+
disabled,
|
|
25
26
|
// onPress is extracted because it is not supported by chakra.
|
|
26
27
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
27
|
-
|
|
28
|
+
onPress: _,
|
|
29
|
+
...buttonProps
|
|
30
|
+
}: CalendarTriggerButtonProps & {
|
|
31
|
+
ref?: React.Ref<HTMLDivElement | null>;
|
|
32
|
+
}) => {
|
|
28
33
|
const { t } = useTranslation();
|
|
29
34
|
|
|
30
35
|
const recipe = useSlotRecipe({
|
|
@@ -43,8 +48,7 @@ export const CalendarTriggerButton = forwardRef<
|
|
|
43
48
|
/>
|
|
44
49
|
</PopoverAnchor>
|
|
45
50
|
);
|
|
46
|
-
}
|
|
47
|
-
CalendarTriggerButton.displayName = "CalendarTriggerButton";
|
|
51
|
+
};
|
|
48
52
|
|
|
49
53
|
const texts = createTexts({
|
|
50
54
|
openCalendar: {
|