@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
package/src/input/CardSelect.tsx
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
DropdownDownFill18Icon,
|
|
10
10
|
DropdownDownFill24Icon,
|
|
11
11
|
} from "@vygruppen/spor-icon-react";
|
|
12
|
-
import {
|
|
12
|
+
import { ReactNode } from "react";
|
|
13
13
|
|
|
14
14
|
import { Button, ButtonProps, StaticCard, StaticCardProps } from "..";
|
|
15
15
|
|
|
@@ -17,31 +17,34 @@ export const CardSelect = ({ size = "md", ...props }: PopoverRootProps) => {
|
|
|
17
17
|
return <ChakraPopover.Root size={size} {...props} />;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
export const CardSelectContent =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
20
|
+
export const CardSelectContent = ({
|
|
21
|
+
ref,
|
|
22
|
+
children,
|
|
23
|
+
...props
|
|
24
|
+
}: StaticCardProps & {
|
|
25
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
26
|
+
}) => {
|
|
27
|
+
return (
|
|
28
|
+
<Portal>
|
|
29
|
+
<ChakraPopover.Positioner>
|
|
30
|
+
<ChakraPopover.Content ref={ref} padding={0} bg="none">
|
|
31
|
+
<ChakraPopover.Body {...props}>
|
|
32
|
+
<StaticCard
|
|
33
|
+
p="2"
|
|
34
|
+
bg="bg"
|
|
35
|
+
border="sm"
|
|
36
|
+
borderColor="floating.outline"
|
|
37
|
+
borderRadius="sm"
|
|
38
|
+
{...props}
|
|
39
|
+
>
|
|
40
|
+
{children}
|
|
41
|
+
</StaticCard>
|
|
42
|
+
</ChakraPopover.Body>
|
|
43
|
+
</ChakraPopover.Content>
|
|
44
|
+
</ChakraPopover.Positioner>
|
|
45
|
+
</Portal>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
45
48
|
|
|
46
49
|
export type CardSelectTriggerProps = {
|
|
47
50
|
/** The design of the trigger button.
|
|
@@ -63,44 +66,43 @@ const bgActiveStyleMap = {
|
|
|
63
66
|
floating: "floating.surface.active",
|
|
64
67
|
};
|
|
65
68
|
|
|
66
|
-
export const CardSelectTrigger =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
export const CardSelectTrigger = ({
|
|
70
|
+
ref,
|
|
71
|
+
icon,
|
|
72
|
+
variant = "core",
|
|
73
|
+
withChevron = true,
|
|
74
|
+
size,
|
|
75
|
+
children,
|
|
76
|
+
...props
|
|
77
|
+
}: CardSelectTriggerProps & {
|
|
78
|
+
ref?: React.RefObject<HTMLButtonElement>;
|
|
79
|
+
}) => {
|
|
80
|
+
const ChevronIcon =
|
|
81
|
+
size === "sm" ? DropdownDownFill18Icon : DropdownDownFill24Icon;
|
|
76
82
|
|
|
77
|
-
|
|
83
|
+
const { open } = usePopoverContext();
|
|
78
84
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
);
|
|
104
|
-
},
|
|
105
|
-
);
|
|
106
|
-
CardSelectTrigger.displayName = "CardSelectTrigger";
|
|
85
|
+
return (
|
|
86
|
+
<ChakraPopover.Trigger asChild ref={ref}>
|
|
87
|
+
<Button
|
|
88
|
+
leftIcon={icon}
|
|
89
|
+
variant={
|
|
90
|
+
variant === "core" ? "tertiary" : (variant as ButtonProps["variant"])
|
|
91
|
+
}
|
|
92
|
+
size={size}
|
|
93
|
+
bg={open ? bgActiveStyleMap[variant] : undefined}
|
|
94
|
+
rightIcon={
|
|
95
|
+
withChevron ? (
|
|
96
|
+
<ChevronIcon
|
|
97
|
+
transform={open ? "rotate(180deg)" : undefined}
|
|
98
|
+
transition="transform 0.3s"
|
|
99
|
+
/>
|
|
100
|
+
) : null
|
|
101
|
+
}
|
|
102
|
+
{...props}
|
|
103
|
+
>
|
|
104
|
+
{children}
|
|
105
|
+
</Button>
|
|
106
|
+
</ChakraPopover.Trigger>
|
|
107
|
+
);
|
|
108
|
+
};
|
package/src/input/Checkbox.tsx
CHANGED
|
@@ -29,20 +29,22 @@ type CheckboxProps = Omit<ChakraCheckbox.RootProps, "onChange"> &
|
|
|
29
29
|
* You can group several of these together with a `CheckboxGroup`.
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
|
-
export const Checkbox =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
</ChakraCheckbox.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
)
|
|
48
|
-
|
|
32
|
+
export const Checkbox = ({
|
|
33
|
+
ref,
|
|
34
|
+
...props
|
|
35
|
+
}: CheckboxProps & {
|
|
36
|
+
ref?: React.RefObject<HTMLInputElement>;
|
|
37
|
+
}) => {
|
|
38
|
+
const { children, inputProps, rootRef, ...rest } = props;
|
|
39
|
+
return (
|
|
40
|
+
<ChakraCheckbox.Root ref={rootRef} {...rest}>
|
|
41
|
+
<ChakraCheckbox.HiddenInput ref={ref} {...inputProps} />
|
|
42
|
+
<ChakraCheckbox.Control>
|
|
43
|
+
<ChakraCheckbox.Indicator />
|
|
44
|
+
</ChakraCheckbox.Control>
|
|
45
|
+
{children != null && (
|
|
46
|
+
<ChakraCheckbox.Label>{children}</ChakraCheckbox.Label>
|
|
47
|
+
)}
|
|
48
|
+
</ChakraCheckbox.Root>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
@@ -29,7 +29,6 @@ export type CheckboxGroupProps = React.ComponentProps<
|
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
31
|
export const CheckboxGroup = (props: CheckboxGroupProps) => {
|
|
32
|
-
// Forwardref caues issue with prop types not working. Forwardref is unessessary here, as ChakraCheckbox already has a ref prop and is deprecated in react 19.
|
|
33
32
|
const { direction = "row", children, gap = 1, ...rest } = props;
|
|
34
33
|
|
|
35
34
|
return (
|
|
@@ -40,4 +39,3 @@ export const CheckboxGroup = (props: CheckboxGroupProps) => {
|
|
|
40
39
|
</ChakraCheckboxGroup>
|
|
41
40
|
);
|
|
42
41
|
};
|
|
43
|
-
CheckboxGroup.displayName = "CheckboxGroup";
|
package/src/input/ChoiceChip.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { CheckboxCard, CheckboxCardRootProps, Span } from "@chakra-ui/react";
|
|
3
3
|
import { CloseOutline24Icon } from "@vygruppen/spor-icon-react";
|
|
4
|
-
import React
|
|
4
|
+
import React from "react";
|
|
5
5
|
|
|
6
6
|
type CheckBoxIcon = {
|
|
7
7
|
default: React.ReactNode;
|
|
@@ -49,42 +49,46 @@ export type ChoiceChipProps = Omit<
|
|
|
49
49
|
* ```
|
|
50
50
|
*/
|
|
51
51
|
|
|
52
|
-
export const ChoiceChip =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
52
|
+
export const ChoiceChip = ({
|
|
53
|
+
ref,
|
|
54
|
+
children,
|
|
55
|
+
icon,
|
|
56
|
+
onCheckedChange,
|
|
57
|
+
...rootProps
|
|
58
|
+
}: ChoiceChipProps & {
|
|
59
|
+
ref?: React.RefObject<HTMLInputElement>;
|
|
60
|
+
}) => {
|
|
61
|
+
return (
|
|
62
|
+
<CheckboxCard.Root
|
|
63
|
+
{...rootProps}
|
|
64
|
+
{...(onCheckedChange && {
|
|
65
|
+
onCheckedChange: (details) => onCheckedChange(!!details.checked),
|
|
66
|
+
})}
|
|
67
|
+
>
|
|
68
|
+
<CheckboxCard.Context>
|
|
69
|
+
{({ checked }) => (
|
|
70
|
+
<>
|
|
71
|
+
<CheckboxCard.HiddenInput ref={ref} />
|
|
72
|
+
<CheckboxCard.Control>
|
|
73
|
+
<CheckboxCard.Content>
|
|
74
|
+
<CheckboxCard.Label>
|
|
75
|
+
{icon && (
|
|
76
|
+
<Span width="24px">
|
|
77
|
+
{checked ? icon.checked : icon.default}
|
|
78
|
+
</Span>
|
|
79
|
+
)}
|
|
73
80
|
|
|
74
|
-
|
|
81
|
+
{rootProps.chipType !== "icon" && children}
|
|
75
82
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
ChoiceChip.displayName = "ChoiceChip";
|
|
83
|
+
{rootProps.chipType === "filter" && checked && (
|
|
84
|
+
<CloseOutline24Icon />
|
|
85
|
+
)}
|
|
86
|
+
</CheckboxCard.Label>
|
|
87
|
+
</CheckboxCard.Content>
|
|
88
|
+
</CheckboxCard.Control>
|
|
89
|
+
</>
|
|
90
|
+
)}
|
|
91
|
+
</CheckboxCard.Context>
|
|
92
|
+
</CheckboxCard.Root>
|
|
93
|
+
);
|
|
94
|
+
};
|
package/src/input/Combobox.tsx
CHANGED
|
@@ -97,7 +97,9 @@ export const Combobox = (props: ComboboxProps<object>) => {
|
|
|
97
97
|
|
|
98
98
|
const listboxId = useId();
|
|
99
99
|
|
|
100
|
-
const inputWidth = useInputWidth(
|
|
100
|
+
const inputWidth = useInputWidth(
|
|
101
|
+
inputRef as React.RefObject<HTMLInputElement>,
|
|
102
|
+
);
|
|
101
103
|
|
|
102
104
|
const state = useComboBoxState({
|
|
103
105
|
defaultFilter: contains,
|
|
@@ -231,7 +233,7 @@ export const Combobox = (props: ComboboxProps<object>) => {
|
|
|
231
233
|
}}
|
|
232
234
|
state={state}
|
|
233
235
|
id={listboxId}
|
|
234
|
-
listBoxRef={listBoxRef}
|
|
236
|
+
listBoxRef={listBoxRef as React.RefObject<HTMLUListElement>}
|
|
235
237
|
emptyContent={emptyContent}
|
|
236
238
|
maxWidth={inputWidth}
|
|
237
239
|
variant={variant}
|
|
@@ -244,8 +246,6 @@ export const Combobox = (props: ComboboxProps<object>) => {
|
|
|
244
246
|
);
|
|
245
247
|
};
|
|
246
248
|
|
|
247
|
-
Combobox.displayName = "Combobox";
|
|
248
|
-
|
|
249
249
|
const useInputWidth = (inputRef: React.RefObject<HTMLInputElement>) => {
|
|
250
250
|
const [inputWidth, setInputWidth] = useState("auto");
|
|
251
251
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { createListCollection } from "@chakra-ui/react";
|
|
4
4
|
import { getSupportedCallingCodes } from "awesome-phonenumber";
|
|
5
|
-
import {
|
|
5
|
+
import { useMemo } from "react";
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
createTexts,
|
|
@@ -37,10 +37,12 @@ type CountryCodeSelectProps = Omit<SelectProps, "label" | "collection"> & {
|
|
|
37
37
|
allowedCountryCodes?: string[];
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
export const CountryCodeSelect =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
export const CountryCodeSelect = ({
|
|
41
|
+
ref,
|
|
42
|
+
...props
|
|
43
|
+
}: CountryCodeSelectProps & {
|
|
44
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
45
|
+
}) => {
|
|
44
46
|
const { t } = useTranslation();
|
|
45
47
|
|
|
46
48
|
const filteredCallingCodes = useMemo(() => {
|
|
@@ -71,9 +73,7 @@ export const CountryCodeSelect = forwardRef<
|
|
|
71
73
|
))}
|
|
72
74
|
</Select>
|
|
73
75
|
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
CountryCodeSelect.displayName = "CountryCodeSelect";
|
|
76
|
+
};
|
|
77
77
|
|
|
78
78
|
const texts = createTexts({
|
|
79
79
|
countryCode: {
|
package/src/input/Field.tsx
CHANGED
|
@@ -32,14 +32,14 @@ function renderLabelWithIndicator(
|
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
return React.cloneElement(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
return React.cloneElement(
|
|
36
|
+
label,
|
|
37
|
+
{},
|
|
38
|
+
<>
|
|
39
|
+
{(label.props as React.PropsWithChildren).children}
|
|
40
|
+
<ChakraField.RequiredIndicator />
|
|
41
|
+
</>,
|
|
42
|
+
);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export type FieldBaseProps = {
|
|
@@ -80,80 +80,83 @@ export type FieldProps = Omit<
|
|
|
80
80
|
* This component is not exported and should be used as a wrapper for other input components.
|
|
81
81
|
*/
|
|
82
82
|
|
|
83
|
-
export const Field =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
83
|
+
export const Field = ({
|
|
84
|
+
ref,
|
|
85
|
+
...props
|
|
86
|
+
}: FieldProps & {
|
|
87
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
88
|
+
}) => {
|
|
89
|
+
const {
|
|
90
|
+
label,
|
|
91
|
+
children,
|
|
92
|
+
helperText,
|
|
93
|
+
errorText,
|
|
94
|
+
floatingLabel = false,
|
|
95
|
+
disabled,
|
|
96
|
+
invalid,
|
|
97
|
+
readOnly,
|
|
98
|
+
required,
|
|
99
|
+
direction,
|
|
100
|
+
id,
|
|
101
|
+
shouldFloat,
|
|
102
|
+
labelAsChild,
|
|
103
|
+
...rest
|
|
104
|
+
} = props;
|
|
105
|
+
const recipe = useSlotRecipe({ key: "field" });
|
|
106
|
+
const styles = recipe();
|
|
103
107
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
108
|
+
return (
|
|
109
|
+
<Stack gap="2" ref={ref} width="100%" {...rest}>
|
|
110
|
+
<ChakraField.Root
|
|
111
|
+
disabled={disabled}
|
|
112
|
+
invalid={invalid}
|
|
113
|
+
readOnly={readOnly}
|
|
114
|
+
required={required}
|
|
115
|
+
css={styles.root}
|
|
116
|
+
direction={direction}
|
|
117
|
+
id={id}
|
|
118
|
+
>
|
|
119
|
+
{label && !floatingLabel && (
|
|
120
|
+
<Label asChild={labelAsChild} aria-hidden>
|
|
121
|
+
{renderLabelWithIndicator(label, labelAsChild)}
|
|
122
|
+
</Label>
|
|
123
|
+
)}
|
|
120
124
|
|
|
121
|
-
|
|
125
|
+
{children}
|
|
122
126
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
)}
|
|
132
|
-
{errorText && (
|
|
133
|
-
<ChakraField.ErrorText aria-live="polite">
|
|
134
|
-
{errorText}
|
|
135
|
-
</ChakraField.ErrorText>
|
|
136
|
-
)}
|
|
137
|
-
</ChakraField.Root>
|
|
138
|
-
{helperText && (
|
|
139
|
-
<Text variant="sm" color="text.tertiary">
|
|
140
|
-
{helperText}
|
|
141
|
-
</Text>
|
|
127
|
+
{label && floatingLabel && (
|
|
128
|
+
<FloatingLabel
|
|
129
|
+
data-float={shouldFloat ? true : undefined}
|
|
130
|
+
asChild={labelAsChild}
|
|
131
|
+
aria-hidden
|
|
132
|
+
>
|
|
133
|
+
{renderLabelWithIndicator(label, labelAsChild)}
|
|
134
|
+
</FloatingLabel>
|
|
142
135
|
)}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
136
|
+
{errorText && (
|
|
137
|
+
<ChakraField.ErrorText aria-live="polite">
|
|
138
|
+
{errorText}
|
|
139
|
+
</ChakraField.ErrorText>
|
|
140
|
+
)}
|
|
141
|
+
</ChakraField.Root>
|
|
142
|
+
{helperText && (
|
|
143
|
+
<Text variant="sm" color="text.tertiary">
|
|
144
|
+
{helperText}
|
|
145
|
+
</Text>
|
|
146
|
+
)}
|
|
147
|
+
</Stack>
|
|
148
|
+
);
|
|
149
|
+
};
|
|
148
150
|
|
|
149
|
-
export const FieldErrorText =
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
export const FieldErrorText = ({
|
|
152
|
+
ref,
|
|
153
|
+
...props
|
|
154
|
+
}: ChakraField.ErrorTextProps & {
|
|
155
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
156
|
+
}) => {
|
|
153
157
|
return (
|
|
154
158
|
<ChakraField.ErrorText ref={ref}>{props.children}</ChakraField.ErrorText>
|
|
155
159
|
);
|
|
156
|
-
}
|
|
157
|
-
FieldErrorText.displayName = "FieldErrorText";
|
|
160
|
+
};
|
|
158
161
|
|
|
159
162
|
export const FieldLabel = ChakraField.Label;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { defineStyle, Field, FieldLabelProps } from "@chakra-ui/react";
|
|
2
|
-
import { forwardRef } from "react";
|
|
3
2
|
|
|
4
|
-
export const FloatingLabel =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
FloatingLabel.displayName = "FloatingLabel";
|
|
3
|
+
export const FloatingLabel = ({
|
|
4
|
+
ref,
|
|
5
|
+
...props
|
|
6
|
+
}: FieldLabelProps & {
|
|
7
|
+
ref?: React.RefObject<HTMLLabelElement | null>;
|
|
8
|
+
}) => <Field.Label ref={ref} {...props} css={floatingLabelStyles} />;
|
|
11
9
|
|
|
12
10
|
const floatingLabelStyles = defineStyle({
|
|
13
11
|
paddingX: 3,
|