@vygruppen/spor-react 12.24.15 → 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 +25 -0
- package/dist/index.cjs +2888 -2534
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +921 -572
- package/dist/index.d.ts +921 -572
- package/dist/index.mjs +2860 -2517
- 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 +241 -0
- 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/index.ts +1 -0
- 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/theme/slot-recipes/anatomy.ts +14 -0
- package/src/theme/slot-recipes/index.ts +2 -0
- package/src/theme/slot-recipes/menu.ts +111 -0
- 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,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: {
|
package/src/input/Select.tsx
CHANGED
|
@@ -57,51 +57,54 @@ export type SelectProps = ChakraSelectRootProps &
|
|
|
57
57
|
*
|
|
58
58
|
*/
|
|
59
59
|
|
|
60
|
-
export const Select =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
60
|
+
export const Select = ({
|
|
61
|
+
ref,
|
|
62
|
+
...props
|
|
63
|
+
}: SelectProps & {
|
|
64
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
65
|
+
}) => {
|
|
66
|
+
const {
|
|
67
|
+
variant = "core",
|
|
68
|
+
children,
|
|
69
|
+
positioning,
|
|
70
|
+
label,
|
|
71
|
+
errorText,
|
|
72
|
+
invalid,
|
|
73
|
+
helperText,
|
|
74
|
+
css,
|
|
75
|
+
...rest
|
|
76
|
+
} = props;
|
|
77
|
+
const recipe = useSlotRecipe({ key: "select" });
|
|
78
|
+
const styles = recipe({ variant });
|
|
75
79
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
return (
|
|
81
|
+
<Field
|
|
82
|
+
errorText={errorText}
|
|
83
|
+
invalid={invalid}
|
|
84
|
+
helperText={helperText}
|
|
85
|
+
required={props.required}
|
|
86
|
+
id={rest.id}
|
|
87
|
+
css={css}
|
|
88
|
+
>
|
|
89
|
+
<ChakraSelect.Root
|
|
90
|
+
{...rest}
|
|
91
|
+
ref={ref}
|
|
92
|
+
positioning={{ sameWidth: true, ...positioning }}
|
|
93
|
+
variant={variant}
|
|
94
|
+
css={styles.root}
|
|
95
|
+
position="relative"
|
|
84
96
|
>
|
|
85
|
-
<
|
|
86
|
-
{
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
{label && <SelectLabel css={styles.label}>{label}</SelectLabel>}
|
|
97
|
-
<SelectContent css={styles.selectContent} baseStyle={css}>
|
|
98
|
-
{children}
|
|
99
|
-
</SelectContent>
|
|
100
|
-
</ChakraSelect.Root>
|
|
101
|
-
</Field>
|
|
102
|
-
);
|
|
103
|
-
},
|
|
104
|
-
);
|
|
97
|
+
<SelectTrigger data-attachable>
|
|
98
|
+
<SelectValueText withPlaceholder={label ? true : false} />
|
|
99
|
+
</SelectTrigger>
|
|
100
|
+
{label && <SelectLabel css={styles.label}>{label}</SelectLabel>}
|
|
101
|
+
<SelectContent css={styles.selectContent} baseStyle={css}>
|
|
102
|
+
{children}
|
|
103
|
+
</SelectContent>
|
|
104
|
+
</ChakraSelect.Root>
|
|
105
|
+
</Field>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
105
108
|
|
|
106
109
|
export const SelectLabel = (props: SelectLabelProps) => {
|
|
107
110
|
const { value } = useSelectContext();
|
|
@@ -114,49 +117,49 @@ export const SelectLabel = (props: SelectLabelProps) => {
|
|
|
114
117
|
);
|
|
115
118
|
};
|
|
116
119
|
|
|
117
|
-
Select.displayName = "Select";
|
|
118
|
-
|
|
119
120
|
type SelectItemProps = ChakraSelect.ItemProps & {
|
|
120
121
|
children: React.ReactNode;
|
|
121
122
|
description?: React.ReactNode;
|
|
122
123
|
};
|
|
123
124
|
|
|
124
|
-
export const SelectItem =
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
125
|
+
export const SelectItem = ({
|
|
126
|
+
ref,
|
|
127
|
+
...props
|
|
128
|
+
}: SelectItemProps & {
|
|
129
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
130
|
+
}) => {
|
|
131
|
+
const { item, children, description, ...rest } = props;
|
|
132
|
+
const recipe = useSlotRecipe({ key: "select" });
|
|
133
|
+
const styles = recipe();
|
|
134
|
+
return (
|
|
135
|
+
<ChakraSelect.Item item={item} {...rest} ref={ref} css={styles.item}>
|
|
136
|
+
<Box width="100%">
|
|
137
|
+
<ChakraSelect.ItemText display="flex">{children}</ChakraSelect.ItemText>
|
|
138
|
+
{description && (
|
|
139
|
+
<Box data-part="item-description" css={styles.itemDescription}>
|
|
140
|
+
{description}
|
|
141
|
+
</Box>
|
|
142
|
+
)}
|
|
143
|
+
</Box>
|
|
141
144
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
);
|
|
149
|
-
SelectItem.displayName = "SelectItem";
|
|
145
|
+
<ChakraSelect.ItemIndicator>
|
|
146
|
+
<CheckmarkFill18Icon />
|
|
147
|
+
</ChakraSelect.ItemIndicator>
|
|
148
|
+
</ChakraSelect.Item>
|
|
149
|
+
);
|
|
150
|
+
};
|
|
150
151
|
|
|
151
152
|
type SelectItemGroupProps = ChakraSelect.ItemGroupProps & {
|
|
152
153
|
label: React.ReactNode;
|
|
153
154
|
children: React.ReactNode;
|
|
154
155
|
};
|
|
155
156
|
|
|
156
|
-
export const SelectItemGroup =
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
export const SelectItemGroup = function SelectItemGroup({
|
|
158
|
+
ref,
|
|
159
|
+
...props
|
|
160
|
+
}: SelectItemGroupProps & {
|
|
161
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
162
|
+
}) {
|
|
160
163
|
const { children, label, ...rest } = props;
|
|
161
164
|
return (
|
|
162
165
|
<ChakraSelect.ItemGroup {...rest} ref={ref}>
|
|
@@ -164,17 +167,19 @@ export const SelectItemGroup = React.forwardRef<
|
|
|
164
167
|
{children}
|
|
165
168
|
</ChakraSelect.ItemGroup>
|
|
166
169
|
);
|
|
167
|
-
}
|
|
170
|
+
};
|
|
168
171
|
|
|
169
172
|
type SelectTriggerProps = ChakraSelect.ControlProps & {
|
|
170
173
|
clearable?: boolean;
|
|
171
174
|
children?: React.ReactNode;
|
|
172
175
|
};
|
|
173
176
|
|
|
174
|
-
export const SelectTrigger =
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
177
|
+
export const SelectTrigger = function SelectTrigger({
|
|
178
|
+
ref,
|
|
179
|
+
...props
|
|
180
|
+
}: SelectTriggerProps & {
|
|
181
|
+
ref?: React.RefObject<HTMLButtonElement>;
|
|
182
|
+
}) {
|
|
178
183
|
const { children, clearable, ...rest } = props;
|
|
179
184
|
const recipe = useSlotRecipe({ key: "select" });
|
|
180
185
|
const styles = recipe();
|
|
@@ -194,16 +199,18 @@ export const SelectTrigger = React.forwardRef<
|
|
|
194
199
|
</ChakraSelect.IndicatorGroup>
|
|
195
200
|
</ChakraSelect.Control>
|
|
196
201
|
);
|
|
197
|
-
}
|
|
202
|
+
};
|
|
198
203
|
|
|
199
204
|
type SelectClearTriggerProps = ChakraSelect.ClearTriggerProps & {
|
|
200
205
|
children?: React.ReactNode;
|
|
201
206
|
};
|
|
202
207
|
|
|
203
|
-
const SelectClearTrigger =
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
208
|
+
const SelectClearTrigger = function SelectClearTrigger({
|
|
209
|
+
ref,
|
|
210
|
+
...props
|
|
211
|
+
}: SelectClearTriggerProps & {
|
|
212
|
+
ref?: React.RefObject<HTMLButtonElement>;
|
|
213
|
+
}) {
|
|
207
214
|
return (
|
|
208
215
|
<ChakraSelect.ClearTrigger asChild {...props} ref={ref}>
|
|
209
216
|
<CloseButton
|
|
@@ -214,7 +221,7 @@ const SelectClearTrigger = React.forwardRef<
|
|
|
214
221
|
/>
|
|
215
222
|
</ChakraSelect.ClearTrigger>
|
|
216
223
|
);
|
|
217
|
-
}
|
|
224
|
+
};
|
|
218
225
|
|
|
219
226
|
type SelectContentProps = ChakraSelect.ContentProps & {
|
|
220
227
|
portalled?: boolean;
|
|
@@ -222,12 +229,13 @@ type SelectContentProps = ChakraSelect.ContentProps & {
|
|
|
222
229
|
baseStyle?: SystemStyleObject;
|
|
223
230
|
};
|
|
224
231
|
|
|
225
|
-
export const SelectContent =
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
232
|
+
export const SelectContent = function SelectContent({
|
|
233
|
+
ref,
|
|
234
|
+
...props
|
|
235
|
+
}: SelectContentProps & {
|
|
236
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
237
|
+
}) {
|
|
229
238
|
const { portalled = true, portalRef, baseStyle, ...rest } = props;
|
|
230
|
-
|
|
231
239
|
return (
|
|
232
240
|
<Portal disabled={!portalled} container={portalRef}>
|
|
233
241
|
<ChakraSelect.Positioner css={baseStyle}>
|
|
@@ -235,7 +243,7 @@ export const SelectContent = React.forwardRef<
|
|
|
235
243
|
</ChakraSelect.Positioner>
|
|
236
244
|
</Portal>
|
|
237
245
|
);
|
|
238
|
-
}
|
|
246
|
+
};
|
|
239
247
|
|
|
240
248
|
type SelectValueTextProps = Omit<ChakraSelect.ValueTextProps, "children"> & {
|
|
241
249
|
children?(items: CollectionItem[]): React.ReactNode;
|
|
@@ -243,10 +251,12 @@ type SelectValueTextProps = Omit<ChakraSelect.ValueTextProps, "children"> & {
|
|
|
243
251
|
withPlaceholder?: boolean;
|
|
244
252
|
};
|
|
245
253
|
|
|
246
|
-
export const SelectValueText =
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
254
|
+
export const SelectValueText = function SelectValueText({
|
|
255
|
+
ref,
|
|
256
|
+
...props
|
|
257
|
+
}: SelectValueTextProps & {
|
|
258
|
+
ref?: React.RefObject<HTMLSpanElement>;
|
|
259
|
+
}) {
|
|
250
260
|
const { children, withPlaceholder, placeholder, ...rest } = props;
|
|
251
261
|
return (
|
|
252
262
|
<ChakraSelect.ValueText
|
|
@@ -274,7 +284,7 @@ export const SelectValueText = React.forwardRef<
|
|
|
274
284
|
</ChakraSelect.Context>
|
|
275
285
|
</ChakraSelect.ValueText>
|
|
276
286
|
);
|
|
277
|
-
}
|
|
287
|
+
};
|
|
278
288
|
|
|
279
289
|
export const SelectItemText = ChakraSelect.ItemText;
|
|
280
290
|
export const SelectRoot = ChakraSelect.Root;
|
package/src/input/Switch.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
Switch as ChakraSwitch,
|
|
6
6
|
useSlotRecipe,
|
|
7
7
|
} from "@chakra-ui/react";
|
|
8
|
-
import React, {
|
|
8
|
+
import React, { PropsWithChildren } from "react";
|
|
9
9
|
|
|
10
10
|
import { switchSlotRecipe } from "../theme/slot-recipes/switch";
|
|
11
11
|
import { Field, FieldBaseProps } from "./Field";
|
|
@@ -45,45 +45,47 @@ export type SwitchProps = Exclude<
|
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
47
|
|
|
48
|
-
export const Switch =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
export const Switch = ({
|
|
49
|
+
ref,
|
|
50
|
+
...props
|
|
51
|
+
}: SwitchProps & {
|
|
52
|
+
ref?: React.RefObject<HTMLInputElement>;
|
|
53
|
+
}) => {
|
|
54
|
+
const {
|
|
55
|
+
rootRef,
|
|
56
|
+
size = "md",
|
|
57
|
+
label,
|
|
58
|
+
invalid,
|
|
59
|
+
errorText,
|
|
60
|
+
helperText,
|
|
61
|
+
css,
|
|
62
|
+
...rest
|
|
63
|
+
} = props;
|
|
64
|
+
const recipe = useSlotRecipe({ key: "switch" });
|
|
65
|
+
const styles = recipe({ size });
|
|
62
66
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
return (
|
|
68
|
+
<Field
|
|
69
|
+
style={{ width: "auto" }}
|
|
70
|
+
invalid={invalid}
|
|
71
|
+
errorText={errorText}
|
|
72
|
+
helperText={helperText}
|
|
73
|
+
required={props.required}
|
|
74
|
+
id={rest.id}
|
|
75
|
+
css={css}
|
|
76
|
+
>
|
|
77
|
+
<ChakraSwitch.Root
|
|
78
|
+
ref={rootRef}
|
|
79
|
+
{...rest}
|
|
80
|
+
checked={props.checked}
|
|
81
|
+
css={styles.root}
|
|
72
82
|
>
|
|
73
|
-
<ChakraSwitch.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
</ChakraSwitch.Control>
|
|
83
|
-
{label && <ChakraSwitch.Label>{label}</ChakraSwitch.Label>}
|
|
84
|
-
</ChakraSwitch.Root>
|
|
85
|
-
</Field>
|
|
86
|
-
);
|
|
87
|
-
},
|
|
88
|
-
);
|
|
89
|
-
Switch.displayName = "Switch";
|
|
83
|
+
<ChakraSwitch.HiddenInput ref={ref} />
|
|
84
|
+
<ChakraSwitch.Control css={styles.control}>
|
|
85
|
+
<ChakraSwitch.Thumb />
|
|
86
|
+
</ChakraSwitch.Control>
|
|
87
|
+
{label && <ChakraSwitch.Label>{label}</ChakraSwitch.Label>}
|
|
88
|
+
</ChakraSwitch.Root>
|
|
89
|
+
</Field>
|
|
90
|
+
);
|
|
91
|
+
};
|