@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/dialog/Drawer.tsx
CHANGED
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
ArrowLeftFill24Icon,
|
|
12
12
|
CloseFill24Icon,
|
|
13
13
|
} from "@vygruppen/spor-icon-react";
|
|
14
|
-
import { forwardRef } from "react";
|
|
15
14
|
import { useSwipeable } from "react-swipeable";
|
|
16
15
|
|
|
17
16
|
import { ResponsiveButton } from "@/button/ResponsiveButton";
|
|
@@ -55,55 +54,60 @@ const [RootDrawerProvider, useRootDrawerProps] =
|
|
|
55
54
|
name: "RootDrawerProvider",
|
|
56
55
|
});
|
|
57
56
|
|
|
58
|
-
export const DrawerContent =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
57
|
+
export const DrawerContent = ({
|
|
58
|
+
ref,
|
|
59
|
+
...props
|
|
60
|
+
}: DrawerContentProps & {
|
|
61
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
62
|
+
}) => {
|
|
63
|
+
const {
|
|
64
|
+
children,
|
|
65
|
+
portalled = true,
|
|
66
|
+
portalRef,
|
|
67
|
+
hideHandle = false,
|
|
68
|
+
...rest
|
|
69
|
+
} = props;
|
|
70
|
+
const { size, placement } = useRootDrawerProps();
|
|
71
|
+
const { setOpen } = useDialogContext();
|
|
72
|
+
const handlers = useSwipeable({
|
|
73
|
+
onSwiped: ({ dir }) => {
|
|
74
|
+
const shouldClose =
|
|
75
|
+
(placement === "bottom" && dir === "Down") ||
|
|
76
|
+
(placement === "top" && dir === "Up") ||
|
|
77
|
+
(placement === "end" && dir === "Right") ||
|
|
78
|
+
(placement === "start" && dir === "Left");
|
|
79
|
+
if (shouldClose) {
|
|
80
|
+
setOpen(false);
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
swipeDuration: 250,
|
|
84
|
+
});
|
|
85
|
+
const sizeNotFull = size !== "full";
|
|
86
|
+
const showHandle = !hideHandle;
|
|
84
87
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
);
|
|
104
|
-
DrawerContent.displayName = "DrawerContent";
|
|
88
|
+
return (
|
|
89
|
+
<Portal disabled={!portalled} container={portalRef}>
|
|
90
|
+
<ChakraDrawer.Positioner asChild>
|
|
91
|
+
<Box {...handlers} width="100%">
|
|
92
|
+
<ChakraDrawer.Content ref={ref} {...rest}>
|
|
93
|
+
{showHandle && sizeNotFull && placement === "bottom" && (
|
|
94
|
+
<CloseDrawerLine />
|
|
95
|
+
)}
|
|
96
|
+
{children}
|
|
97
|
+
{showHandle && sizeNotFull && placement === "top" && (
|
|
98
|
+
<CloseDrawerLine />
|
|
99
|
+
)}
|
|
100
|
+
</ChakraDrawer.Content>
|
|
101
|
+
</Box>
|
|
102
|
+
</ChakraDrawer.Positioner>
|
|
103
|
+
</Portal>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
105
106
|
|
|
106
|
-
export const CloseDrawerLine =
|
|
107
|
+
export const CloseDrawerLine = ({
|
|
108
|
+
ref,
|
|
109
|
+
...props
|
|
110
|
+
}: React.ComponentProps<typeof Box>) => {
|
|
107
111
|
return (
|
|
108
112
|
<Box
|
|
109
113
|
width={7}
|
|
@@ -117,13 +121,14 @@ export const CloseDrawerLine = forwardRef<HTMLButtonElement>((props, ref) => {
|
|
|
117
121
|
ref={ref}
|
|
118
122
|
/>
|
|
119
123
|
);
|
|
120
|
-
}
|
|
121
|
-
CloseDrawerLine.displayName = "CloseDrawerLine";
|
|
124
|
+
};
|
|
122
125
|
|
|
123
|
-
export const DrawerCloseTrigger =
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
export const DrawerCloseTrigger = function DrawerCloseTrigger({
|
|
127
|
+
ref,
|
|
128
|
+
...props
|
|
129
|
+
}: DrawerCloseTriggerProps & {
|
|
130
|
+
ref?: React.RefObject<HTMLButtonElement>;
|
|
131
|
+
}) {
|
|
127
132
|
const { showText = false, ...rest } = props;
|
|
128
133
|
const { size } = useRootDrawerProps();
|
|
129
134
|
const { t } = useTranslation();
|
|
@@ -140,12 +145,14 @@ export const DrawerCloseTrigger = forwardRef<
|
|
|
140
145
|
)}
|
|
141
146
|
</ChakraDrawer.CloseTrigger>
|
|
142
147
|
);
|
|
143
|
-
}
|
|
148
|
+
};
|
|
144
149
|
|
|
145
|
-
export const DrawerBackTrigger =
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
150
|
+
export const DrawerBackTrigger = ({
|
|
151
|
+
ref,
|
|
152
|
+
...props
|
|
153
|
+
}: ChakraDrawer.CloseTriggerProps & {
|
|
154
|
+
ref?: React.RefObject<HTMLButtonElement>;
|
|
155
|
+
}) => {
|
|
149
156
|
const { t } = useTranslation();
|
|
150
157
|
return (
|
|
151
158
|
<ChakraDrawer.CloseTrigger asChild {...props} ref={ref}>
|
|
@@ -156,13 +163,14 @@ export const DrawerBackTrigger = forwardRef<
|
|
|
156
163
|
/>
|
|
157
164
|
</ChakraDrawer.CloseTrigger>
|
|
158
165
|
);
|
|
159
|
-
}
|
|
160
|
-
DrawerBackTrigger.displayName = "DrawerBackTrigger";
|
|
166
|
+
};
|
|
161
167
|
|
|
162
|
-
export const DrawerFullScreenHeader =
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
168
|
+
export const DrawerFullScreenHeader = ({
|
|
169
|
+
ref,
|
|
170
|
+
...props
|
|
171
|
+
}: DrawerFullScreenHeaderProps & {
|
|
172
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
173
|
+
}) => {
|
|
166
174
|
const { backTrigger = true, closeTrigger = true, children } = props;
|
|
167
175
|
return (
|
|
168
176
|
<ChakraDrawer.Header {...props} ref={ref}>
|
|
@@ -171,8 +179,7 @@ export const DrawerFullScreenHeader = forwardRef<
|
|
|
171
179
|
<Box> {closeTrigger && <DrawerCloseTrigger />}</Box>
|
|
172
180
|
</ChakraDrawer.Header>
|
|
173
181
|
);
|
|
174
|
-
}
|
|
175
|
-
DrawerFullScreenHeader.displayName = "DrawerFullScreenHeader";
|
|
182
|
+
};
|
|
176
183
|
|
|
177
184
|
export const Drawer = (props: DrawerProps) => {
|
|
178
185
|
const { children, placement, size = "md", ...rest } = props;
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
useRecipe,
|
|
11
11
|
} from "@chakra-ui/react";
|
|
12
12
|
import { ChangeDirectionOutline24Icon } from "@vygruppen/spor-icon-react";
|
|
13
|
-
import { forwardRef } from "react";
|
|
14
13
|
|
|
15
14
|
import { IconButton } from "@/button";
|
|
16
15
|
import { attachedInputsRecipe } from "@/theme/recipes/attached-inputs";
|
|
@@ -43,47 +42,44 @@ export type AttachedInputsProps = RecipeVariantProps<
|
|
|
43
42
|
}
|
|
44
43
|
);
|
|
45
44
|
|
|
46
|
-
export const AttachedInputs =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
ref={ref}
|
|
57
|
-
css={styles}
|
|
58
|
-
attached
|
|
59
|
-
isolation="auto"
|
|
60
|
-
{...restProps}
|
|
61
|
-
/>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
45
|
+
export const AttachedInputs = ({
|
|
46
|
+
ref,
|
|
47
|
+
...props
|
|
48
|
+
}: AttachedInputsProps & {
|
|
49
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
50
|
+
}) => {
|
|
51
|
+
const recipe = useRecipe({ key: "attachedInputs" });
|
|
52
|
+
const [recipeProps, { onFlip, flipAriaLabel, ...restProps }] =
|
|
53
|
+
recipe.splitVariantProps(props);
|
|
54
|
+
const styles = recipe(recipeProps);
|
|
64
55
|
|
|
56
|
+
if (!onFlip) {
|
|
65
57
|
return (
|
|
66
|
-
<
|
|
67
|
-
<Group
|
|
68
|
-
ref={ref}
|
|
69
|
-
css={styles}
|
|
70
|
-
attached
|
|
71
|
-
isolation="auto"
|
|
72
|
-
data-with-flip-button
|
|
73
|
-
{...restProps}
|
|
74
|
-
/>
|
|
75
|
-
<SwitchButton
|
|
76
|
-
icon={<ChangeDirectionOutline24Icon />}
|
|
77
|
-
orientation={props.orientation}
|
|
78
|
-
variant="tertiary"
|
|
79
|
-
size={["xs", null, "sm"]}
|
|
80
|
-
aria-label={flipAriaLabel}
|
|
81
|
-
onClick={onFlip}
|
|
82
|
-
/>
|
|
83
|
-
</Box>
|
|
58
|
+
<Group ref={ref} css={styles} attached isolation="auto" {...restProps} />
|
|
84
59
|
);
|
|
85
|
-
}
|
|
86
|
-
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<Box position="relative">
|
|
64
|
+
<Group
|
|
65
|
+
ref={ref}
|
|
66
|
+
css={styles}
|
|
67
|
+
attached
|
|
68
|
+
isolation="auto"
|
|
69
|
+
data-with-flip-button
|
|
70
|
+
{...restProps}
|
|
71
|
+
/>
|
|
72
|
+
<SwitchButton
|
|
73
|
+
icon={<ChangeDirectionOutline24Icon />}
|
|
74
|
+
orientation={props.orientation}
|
|
75
|
+
variant="tertiary"
|
|
76
|
+
size={["xs", null, "sm"]}
|
|
77
|
+
aria-label={flipAriaLabel}
|
|
78
|
+
onClick={onFlip}
|
|
79
|
+
/>
|
|
80
|
+
</Box>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
87
83
|
|
|
88
84
|
const SwitchButton = chakra(
|
|
89
85
|
IconButton,
|
|
@@ -117,5 +113,3 @@ const SwitchButton = chakra(
|
|
|
117
113
|
},
|
|
118
114
|
}),
|
|
119
115
|
);
|
|
120
|
-
|
|
121
|
-
AttachedInputs.displayName = "AttachedInputs";
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
useListCollection,
|
|
9
9
|
} from "@chakra-ui/react";
|
|
10
10
|
import { CheckmarkFill18Icon } from "@vygruppen/spor-icon-react";
|
|
11
|
-
import React
|
|
11
|
+
import React from "react";
|
|
12
12
|
|
|
13
13
|
import { CloseButton } from "@/button";
|
|
14
14
|
import { ColorSpinner } from "@/loader";
|
|
@@ -27,139 +27,131 @@ type Props = {
|
|
|
27
27
|
loading?: boolean;
|
|
28
28
|
emptyLabel?: React.ReactNode;
|
|
29
29
|
openOnFocus?: boolean;
|
|
30
|
+
ref?: React.RefObject<HTMLInputElement | null>;
|
|
30
31
|
} & Omit<ComboboxRootProps, "collection"> &
|
|
31
32
|
FieldProps;
|
|
32
33
|
|
|
33
|
-
export
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
34
|
+
export function Autocomplete({
|
|
35
|
+
variant = "core",
|
|
36
|
+
children,
|
|
37
|
+
css,
|
|
38
|
+
label,
|
|
39
|
+
leftIcon,
|
|
40
|
+
onInputValueChange,
|
|
41
|
+
invalid,
|
|
42
|
+
helperText,
|
|
43
|
+
errorText,
|
|
44
|
+
required,
|
|
45
|
+
filteredExternally,
|
|
46
|
+
loading,
|
|
47
|
+
disabled,
|
|
48
|
+
emptyLabel,
|
|
49
|
+
onFocus,
|
|
50
|
+
openOnClick = true,
|
|
51
|
+
openOnFocus = true,
|
|
52
|
+
ref,
|
|
53
|
+
...rest
|
|
54
|
+
}: Props) {
|
|
55
|
+
const { contains } = useFilter({ sensitivity: "base" });
|
|
56
|
+
const { t } = useTranslation();
|
|
57
|
+
|
|
58
|
+
const extractedItems = React.useMemo(
|
|
59
|
+
() => extractItemsFromChildren(children),
|
|
60
|
+
[children],
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const { collection, filter, reset } = useListCollection({
|
|
64
|
+
initialItems: extractedItems,
|
|
65
|
+
filter: filteredExternally ? undefined : contains,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
React.useEffect(() => {
|
|
69
|
+
if (filteredExternally) reset();
|
|
70
|
+
}, [extractedItems, reset, filteredExternally]);
|
|
71
|
+
|
|
72
|
+
const filteredChildren = React.useMemo(
|
|
73
|
+
() => filterChildren(children, collection.items),
|
|
74
|
+
[children, collection.items],
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const combobox = useCombobox({
|
|
78
|
+
collection,
|
|
79
|
+
openOnClick: filteredChildren.length > 0 ? openOnClick : false,
|
|
80
|
+
onInputValueChange: (event) => {
|
|
81
|
+
if (!filteredExternally) {
|
|
82
|
+
filter(event.inputValue);
|
|
83
|
+
}
|
|
84
|
+
onInputValueChange?.(event);
|
|
54
85
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const extractedItems = React.useMemo(
|
|
61
|
-
() => extractItemsFromChildren(children),
|
|
62
|
-
[children],
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const { collection, filter, reset } = useListCollection({
|
|
66
|
-
initialItems: extractedItems,
|
|
67
|
-
filter: filteredExternally ? undefined : contains,
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
React.useEffect(() => {
|
|
71
|
-
if (filteredExternally) reset();
|
|
72
|
-
}, [extractedItems, reset, filteredExternally]);
|
|
73
|
-
|
|
74
|
-
const filteredChildren = React.useMemo(
|
|
75
|
-
() => filterChildren(children, collection.items),
|
|
76
|
-
[children, collection.items],
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
const combobox = useCombobox({
|
|
80
|
-
collection,
|
|
81
|
-
openOnClick: filteredChildren.length > 0 ? openOnClick : false,
|
|
82
|
-
onInputValueChange: (event) => {
|
|
83
|
-
if (!filteredExternally) {
|
|
84
|
-
filter(event.inputValue);
|
|
85
|
-
}
|
|
86
|
-
onInputValueChange?.(event);
|
|
86
|
+
positioning: {
|
|
87
|
+
placement: "bottom",
|
|
88
|
+
offset: {
|
|
89
|
+
mainAxis: 3,
|
|
90
|
+
crossAxis: -1,
|
|
87
91
|
},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
<
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
{loading ? <ColorSpinner width="1.5rem" p="2" /> : filteredChildren}
|
|
135
|
-
</Combobox.Content>
|
|
136
|
-
</Combobox.Positioner>
|
|
137
|
-
</Combobox.RootProvider>
|
|
138
|
-
);
|
|
139
|
-
},
|
|
140
|
-
);
|
|
92
|
+
flip: false,
|
|
93
|
+
},
|
|
94
|
+
disabled,
|
|
95
|
+
...rest,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<Combobox.RootProvider value={combobox}>
|
|
100
|
+
<Combobox.Control css={css}>
|
|
101
|
+
<Combobox.Input asChild>
|
|
102
|
+
<Input
|
|
103
|
+
ref={ref}
|
|
104
|
+
label={<Combobox.Label>{label}</Combobox.Label>}
|
|
105
|
+
variant={variant}
|
|
106
|
+
labelAsChild
|
|
107
|
+
startElement={leftIcon}
|
|
108
|
+
invalid={invalid}
|
|
109
|
+
helperText={helperText}
|
|
110
|
+
errorText={errorText}
|
|
111
|
+
required={required}
|
|
112
|
+
onFocus={(event) => {
|
|
113
|
+
onFocus?.(event);
|
|
114
|
+
if (openOnFocus && filteredChildren.length > 0)
|
|
115
|
+
combobox.setOpen(true);
|
|
116
|
+
}}
|
|
117
|
+
/>
|
|
118
|
+
</Combobox.Input>
|
|
119
|
+
<Combobox.IndicatorGroup>
|
|
120
|
+
<Combobox.ClearTrigger asChild aria-label={t(texts.clearValue)}>
|
|
121
|
+
<CloseButton size="xs" tabIndex={0} />
|
|
122
|
+
</Combobox.ClearTrigger>
|
|
123
|
+
</Combobox.IndicatorGroup>
|
|
124
|
+
</Combobox.Control>
|
|
125
|
+
<Combobox.Positioner>
|
|
126
|
+
<Combobox.Content>
|
|
127
|
+
{!loading && (
|
|
128
|
+
<Combobox.Empty>
|
|
129
|
+
{emptyLabel ?? t(texts.noItemsFound)}
|
|
130
|
+
</Combobox.Empty>
|
|
131
|
+
)}
|
|
132
|
+
{loading ? <ColorSpinner width="1.5rem" p="2" /> : filteredChildren}
|
|
133
|
+
</Combobox.Content>
|
|
134
|
+
</Combobox.Positioner>
|
|
135
|
+
</Combobox.RootProvider>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
141
138
|
|
|
142
139
|
export const AutocompleteItemGroup = Combobox.ItemGroup;
|
|
143
140
|
export const AutocompleteItemGroupLabel = Combobox.ItemGroupLabel;
|
|
144
141
|
|
|
145
|
-
export const AutocompleteItem =
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
...props
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
)}
|
|
159
|
-
</Combobox.Item>
|
|
160
|
-
);
|
|
161
|
-
},
|
|
162
|
-
);
|
|
142
|
+
export const AutocompleteItem = ({ children, ...props }: ComboboxItemProps) => {
|
|
143
|
+
const { multiple } = useComboboxContext();
|
|
144
|
+
return (
|
|
145
|
+
<Combobox.Item {...props}>
|
|
146
|
+
{children}
|
|
147
|
+
{multiple && (
|
|
148
|
+
<Combobox.ItemIndicator asChild>
|
|
149
|
+
<CheckmarkFill18Icon />
|
|
150
|
+
</Combobox.ItemIndicator>
|
|
151
|
+
)}
|
|
152
|
+
</Combobox.Item>
|
|
153
|
+
);
|
|
154
|
+
};
|
|
163
155
|
|
|
164
156
|
const filterChildren = (
|
|
165
157
|
children: React.ReactNode,
|
|
@@ -187,10 +179,7 @@ const filterChildren = (
|
|
|
187
179
|
|
|
188
180
|
if (!hasItems) return null;
|
|
189
181
|
|
|
190
|
-
return React.cloneElement(child,
|
|
191
|
-
...groupProps,
|
|
192
|
-
children: filteredGroupChildren,
|
|
193
|
-
});
|
|
182
|
+
return React.cloneElement(child, groupProps, ...filteredGroupChildren);
|
|
194
183
|
}
|
|
195
184
|
|
|
196
185
|
const itemProps = (child.props as { item?: Item })?.item;
|