@vygruppen/spor-react 12.1.1 → 12.2.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 +11 -11
- package/.turbo/turbo-typegen.log +1 -1
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +151 -190
- package/dist/index.d.ts +151 -190
- package/dist/index.js +2327 -1915
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2214 -1811
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/accordion/Accordion.tsx +2 -1
- package/src/accordion/Expandable.tsx +3 -1
- package/src/accordion/helpers.ts +2 -1
- package/src/alert/Alert.tsx +3 -1
- package/src/alert/AlertIcon.tsx +17 -10
- package/src/alert/ExpandableAlert.tsx +3 -2
- package/src/alert/ServiceAlert.tsx +2 -1
- package/src/breadcrumb/Breadcrumb.tsx +9 -8
- package/src/button/Button.tsx +65 -52
- package/src/button/ButtonGroup.tsx +2 -1
- package/src/button/Clipboard.tsx +3 -0
- package/src/button/CloseButton.tsx +8 -4
- package/src/button/FloatingActionButton.tsx +5 -5
- package/src/button/IconButton.tsx +1 -0
- package/src/color-mode/color-mode.tsx +2 -2
- package/src/datepicker/Calendar.tsx +0 -1
- package/src/datepicker/CalendarCell.tsx +5 -5
- package/src/datepicker/CalendarGrid.tsx +3 -2
- package/src/datepicker/CalendarHeader.tsx +1 -4
- package/src/datepicker/CalendarTriggerButton.tsx +3 -4
- package/src/datepicker/DateField.tsx +13 -6
- package/src/datepicker/DatePicker.tsx +2 -1
- package/src/datepicker/DateRangePicker.tsx +1 -1
- package/src/datepicker/DateTimeSegment.tsx +2 -1
- package/src/datepicker/RangeCalendar.tsx +1 -1
- package/src/datepicker/StyledField.tsx +1 -1
- package/src/datepicker/TimeField.tsx +3 -3
- package/src/datepicker/TimePicker.tsx +4 -2
- package/src/datepicker/utils.ts +10 -5
- package/src/dialog/Dialog.tsx +1 -0
- package/src/dialog/Drawer.tsx +28 -26
- package/src/i18n/index.tsx +1 -0
- package/src/input/AttachedInputs.tsx +6 -3
- package/src/input/CardSelect.tsx +3 -1
- package/src/input/Checkbox.tsx +1 -0
- package/src/input/CheckboxGroup.tsx +3 -1
- package/src/input/ChoiceChip.tsx +1 -1
- package/src/input/Combobox.tsx +6 -4
- package/src/input/CountryCodeSelect.tsx +10 -4
- package/src/input/Field.tsx +2 -0
- package/src/input/Input.tsx +2 -3
- package/src/input/InputGroup.tsx +1 -1
- package/src/input/ListBox.tsx +9 -8
- package/src/input/NativeSelect.tsx +1 -2
- package/src/input/NumericStepper.tsx +22 -23
- package/src/input/PasswordInput.tsx +2 -1
- package/src/input/PhoneNumberInput.tsx +6 -2
- package/src/input/Popover.tsx +2 -0
- package/src/input/Radio.tsx +2 -0
- package/src/input/SearchInput.tsx +2 -1
- package/src/input/Select.tsx +8 -2
- package/src/input/Switch.tsx +22 -34
- package/src/input/Textarea.tsx +6 -4
- package/src/input/index.ts +1 -1
- package/src/layout/PressableCard.tsx +5 -2
- package/src/layout/RadioCard.tsx +3 -1
- package/src/layout/Separator.tsx +2 -1
- package/src/layout/StaticCard.tsx +6 -3
- package/src/linjetag/InfoTag.tsx +3 -2
- package/src/linjetag/LineIcon.tsx +5 -4
- package/src/linjetag/TravelTag.tsx +12 -8
- package/src/link/TextLink.tsx +44 -9
- package/src/loader/ColorInlineLoader.tsx +0 -1
- package/src/loader/ColorSpinner.tsx +0 -1
- package/src/loader/ContentLoader.tsx +0 -1
- package/src/loader/DarkFullScreenLoader.tsx +0 -1
- package/src/loader/DarkInlineLoader.tsx +0 -1
- package/src/loader/DarkSpinner.tsx +0 -1
- package/src/loader/LightFullScreenLoader.tsx +0 -1
- package/src/loader/LightInlineLoader.tsx +0 -1
- package/src/loader/LightSpinner.tsx +0 -1
- package/src/loader/Lottie.tsx +1 -2
- package/src/loader/ProgressBar.tsx +1 -2
- package/src/loader/ProgressLoader.tsx +2 -7
- package/src/logo/CargonetLogo.tsx +2 -1
- package/src/logo/VyLogo.tsx +3 -4
- package/src/logo/VyLogoPride.tsx +4 -1
- package/src/media-controller/JumpButton.tsx +2 -1
- package/src/media-controller/PlayPauseButton.tsx +2 -1
- package/src/media-controller/SkipButton.tsx +2 -1
- package/src/nudge/Nudge.tsx +7 -14
- package/src/pagination/Pagination.tsx +5 -0
- package/src/popover/index.tsx +2 -0
- package/src/progress-indicator/ProgressDot.tsx +1 -1
- package/src/progress-indicator/ProgressIndicator.tsx +4 -2
- package/src/provider/SporProvider.tsx +0 -1
- package/src/stepper/Stepper.tsx +1 -1
- package/src/tab/Tabs.tsx +1 -1
- package/src/table/Table.tsx +2 -1
- package/src/theme/recipes/button.ts +5 -0
- package/src/theme/slot-recipes/alert-expandable.ts +0 -4
- package/src/theme/slot-recipes/info-tag.ts +0 -1
- package/src/theme/slot-recipes/popover.ts +0 -1
- package/src/theme/slot-recipes/radio-card.ts +0 -3
- package/src/theme/utils/accent-utils.ts +12 -6
- package/src/theme/utils/bg-utils.ts +6 -3
- package/src/theme/utils/brand-utils.ts +7 -7
- package/src/theme/utils/core-utils.ts +23 -13
- package/src/theme/utils/floating-utils.ts +16 -8
- package/src/theme/utils/ghost-utils.ts +8 -4
- package/src/theme/utils/input-utils.ts +7 -4
- package/src/theme/utils/outline-utils.ts +6 -3
- package/src/theme/utils/surface-utils.ts +8 -4
- package/src/toast/toast.tsx +0 -1
- package/src/typography/Badge.tsx +8 -5
- package/src/typography/Heading.tsx +1 -1
- package/src/typography/Text.tsx +1 -1
- package/src/util/slugify.tsx +8 -8
- package/tsconfig.json +1 -0
@@ -52,7 +52,7 @@ type DatePickerProps = Omit<AriaDatePickerProps<DateValue>, "onChange"> &
|
|
52
52
|
/**
|
53
53
|
* A date picker component.
|
54
54
|
*
|
55
|
-
* There are three different variants
|
55
|
+
* There are three different variants –`core`, `floating` and `ghost`.
|
56
56
|
*
|
57
57
|
* ```tsx
|
58
58
|
* <DatePicker label="Dato" variant="core" />
|
@@ -171,3 +171,4 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
|
171
171
|
);
|
172
172
|
},
|
173
173
|
);
|
174
|
+
DatePicker.displayName = "DatePicker";
|
@@ -9,7 +9,7 @@ import {
|
|
9
9
|
useSlotRecipe,
|
10
10
|
} from "@chakra-ui/react";
|
11
11
|
import { DateValue } from "@internationalized/date";
|
12
|
-
import
|
12
|
+
import { PropsWithChildren, useRef } from "react";
|
13
13
|
import {
|
14
14
|
AriaDateRangePickerProps,
|
15
15
|
I18nProvider,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use client";
|
2
2
|
import { Box, useSlotRecipe } from "@chakra-ui/react";
|
3
|
-
import
|
3
|
+
import { forwardRef, PropsWithChildren, RefObject, useRef } from "react";
|
4
4
|
import { useDateSegment } from "react-aria";
|
5
5
|
import { DateFieldState, DateSegment } from "react-stately";
|
6
6
|
|
@@ -63,6 +63,7 @@ export const DateTimeSegment = forwardRef<HTMLDivElement, DateTimeSegmentProps>(
|
|
63
63
|
);
|
64
64
|
},
|
65
65
|
);
|
66
|
+
DateTimeSegment.displayName = "DateTimeSegment";
|
66
67
|
|
67
68
|
const isPaddable = (segmentType: DateSegment["type"]) =>
|
68
69
|
segmentType === "month" ||
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client";
|
2
2
|
import { Box, useSlotRecipe } from "@chakra-ui/react";
|
3
3
|
import { createCalendar, DateValue } from "@internationalized/date";
|
4
|
-
import
|
4
|
+
import { useRef } from "react";
|
5
5
|
import {
|
6
6
|
RangeCalendarProps as ReactAriaRangeCalendarProps,
|
7
7
|
useRangeCalendar,
|
@@ -5,7 +5,7 @@ import {
|
|
5
5
|
useFieldContext,
|
6
6
|
useSlotRecipe,
|
7
7
|
} from "@chakra-ui/react";
|
8
|
-
import
|
8
|
+
import { forwardRef, PropsWithChildren } from "react";
|
9
9
|
|
10
10
|
import { datePickerSlotRecipe } from "../theme/slot-recipes/datepicker";
|
11
11
|
import { DatePickerVariantProps } from "./DatePicker";
|
@@ -1,9 +1,9 @@
|
|
1
1
|
"use client";
|
2
2
|
import { Box, Flex } from "@chakra-ui/react";
|
3
3
|
import { CalendarDateTime, Time } from "@internationalized/date";
|
4
|
-
import {
|
5
|
-
import React, { useRef } from "react";
|
4
|
+
import { useRef } from "react";
|
6
5
|
import { AriaTimeFieldProps, useTimeField } from "react-aria";
|
6
|
+
import { DateSegment, TimeFieldState } from "react-stately";
|
7
7
|
|
8
8
|
import { DateTimeSegment } from "./DateTimeSegment";
|
9
9
|
import { getTimestampFromTime } from "./utils";
|
@@ -38,7 +38,7 @@ export const TimeField = ({ state, ...props }: TimeFieldProps) => {
|
|
38
38
|
{props.label}
|
39
39
|
</label>
|
40
40
|
<Flex {...fieldProps} ref={ref} paddingTop="3" paddingBottom="0.5">
|
41
|
-
{state.segments.map((segment) => (
|
41
|
+
{state.segments.map((segment: DateSegment) => (
|
42
42
|
<DateTimeSegment key={segment.type} segment={segment} state={state} />
|
43
43
|
))}
|
44
44
|
</Flex>
|
@@ -1,12 +1,11 @@
|
|
1
1
|
"use client";
|
2
|
-
import { BoxProps
|
2
|
+
import { BoxProps } from "@chakra-ui/react";
|
3
3
|
import { CalendarDateTime } from "@internationalized/date";
|
4
4
|
import { TimeValue } from "@react-types/datepicker";
|
5
5
|
import {
|
6
6
|
DropdownLeftFill18Icon,
|
7
7
|
DropdownRightFill18Icon,
|
8
8
|
} from "@vygruppen/spor-icon-react";
|
9
|
-
import React from "react";
|
10
9
|
import { useTimeFieldState } from "react-stately";
|
11
10
|
|
12
11
|
import { Field } from "@/input/Field";
|
@@ -202,3 +201,6 @@ const texts = createTexts({
|
|
202
201
|
sv: "minuter",
|
203
202
|
},
|
204
203
|
});
|
204
|
+
function useFieldContext(): { disabled: unknown; invalid: unknown } {
|
205
|
+
throw new Error("Function not implemented.");
|
206
|
+
}
|
package/src/datepicker/utils.ts
CHANGED
@@ -9,16 +9,21 @@ import { useTranslation } from "..";
|
|
9
9
|
export const useCurrentLocale = () => {
|
10
10
|
const { language } = useTranslation();
|
11
11
|
switch (language) {
|
12
|
-
case "nb":
|
12
|
+
case "nb": {
|
13
13
|
return "nb-NO";
|
14
|
-
|
14
|
+
}
|
15
|
+
case "nn": {
|
15
16
|
return "nb-NO";
|
16
|
-
|
17
|
+
}
|
18
|
+
case "sv": {
|
17
19
|
return "sv-SE";
|
18
|
-
|
20
|
+
}
|
21
|
+
case "en": {
|
19
22
|
return "en-GB";
|
20
|
-
|
23
|
+
}
|
24
|
+
default: {
|
21
25
|
return "nb-NO";
|
26
|
+
}
|
22
27
|
}
|
23
28
|
};
|
24
29
|
|
package/src/dialog/Dialog.tsx
CHANGED
package/src/dialog/Drawer.tsx
CHANGED
@@ -12,7 +12,7 @@ import {
|
|
12
12
|
ArrowLeftFill24Icon,
|
13
13
|
CloseFill24Icon,
|
14
14
|
} from "@vygruppen/spor-icon-react";
|
15
|
-
import
|
15
|
+
import { forwardRef } from "react";
|
16
16
|
|
17
17
|
import { Button, CloseButton } from "../button";
|
18
18
|
import { createTexts, useTranslation } from "../i18n";
|
@@ -70,32 +70,32 @@ export const DrawerContent = forwardRef<HTMLDivElement, DrawerContentProps>(
|
|
70
70
|
);
|
71
71
|
},
|
72
72
|
);
|
73
|
+
DrawerContent.displayName = "DrawerContent";
|
73
74
|
|
74
|
-
export const CloseDrawerLine = forwardRef<HTMLButtonElement, {
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
);
|
75
|
+
export const CloseDrawerLine = forwardRef<HTMLButtonElement>((props, ref) => {
|
76
|
+
const { t } = useTranslation();
|
77
|
+
return (
|
78
|
+
<ChakraDrawer.CloseTrigger
|
79
|
+
{...props}
|
80
|
+
ref={ref}
|
81
|
+
position="relative"
|
82
|
+
insetEnd="unset"
|
83
|
+
aria-label={t(texts.close)}
|
84
|
+
cursor="pointer"
|
85
|
+
top={0}
|
86
|
+
paddingY={2}
|
87
|
+
>
|
88
|
+
<Box
|
89
|
+
width={7}
|
90
|
+
height={1}
|
91
|
+
backgroundColor="silver"
|
92
|
+
borderRadius="xs"
|
93
|
+
marginX="auto"
|
94
|
+
/>
|
95
|
+
</ChakraDrawer.CloseTrigger>
|
96
|
+
);
|
97
|
+
});
|
98
|
+
CloseDrawerLine.displayName = "CloseDrawerLine";
|
99
99
|
|
100
100
|
export const DrawerCloseTrigger = forwardRef<
|
101
101
|
HTMLButtonElement,
|
@@ -129,6 +129,7 @@ export const DrawerBackTrigger = forwardRef<
|
|
129
129
|
</ChakraDrawer.CloseTrigger>
|
130
130
|
);
|
131
131
|
});
|
132
|
+
DrawerBackTrigger.displayName = "DrawerBackTrigger";
|
132
133
|
|
133
134
|
export const DrawerFullScreenHeader = forwardRef<
|
134
135
|
HTMLDivElement,
|
@@ -151,6 +152,7 @@ export const DrawerFullScreenHeader = forwardRef<
|
|
151
152
|
</ChakraDrawer.Header>
|
152
153
|
);
|
153
154
|
});
|
155
|
+
DrawerFullScreenHeader.displayName = "DrawerFullScreenHeader";
|
154
156
|
|
155
157
|
export const Drawer = (props: DrawerProps) => {
|
156
158
|
const { children, placement, size = "md", ...rest } = props;
|
package/src/i18n/index.tsx
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client";
|
2
2
|
|
3
|
-
import { chakra, Group, RecipeVariantProps
|
4
|
-
import
|
3
|
+
import { chakra, Group, RecipeVariantProps } from "@chakra-ui/react";
|
4
|
+
import { forwardRef } from "react";
|
5
5
|
|
6
6
|
import { attachedInputsRecipe } from "@/theme/recipes/attached-inputs";
|
7
7
|
|
@@ -28,5 +28,8 @@ export type AttachedInputsProps = RecipeVariantProps<
|
|
28
28
|
const StyledGroup = chakra(Group, attachedInputsRecipe);
|
29
29
|
|
30
30
|
export const AttachedInputs = forwardRef<HTMLDivElement, AttachedInputsProps>(
|
31
|
-
(props, ref) =>
|
31
|
+
(props, ref) => {
|
32
|
+
return <StyledGroup ref={ref} attached {...props} />;
|
33
|
+
},
|
32
34
|
);
|
35
|
+
AttachedInputs.displayName = "AttachedInputs";
|
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 { forwardRef, ReactNode } from "react";
|
13
13
|
|
14
14
|
import { Button, ButtonProps, StaticCard, StaticCardProps } from "..";
|
15
15
|
|
@@ -40,6 +40,7 @@ export const CardSelectContent = forwardRef<HTMLDivElement, StaticCardProps>(
|
|
40
40
|
);
|
41
41
|
},
|
42
42
|
);
|
43
|
+
CardSelectContent.displayName = "CardSelectContent";
|
43
44
|
|
44
45
|
export type CardSelectTriggerProps = {
|
45
46
|
/** The design of the trigger button.
|
@@ -101,3 +102,4 @@ export const CardSelectTrigger = forwardRef<
|
|
101
102
|
);
|
102
103
|
},
|
103
104
|
);
|
105
|
+
CardSelectTrigger.displayName = "CardSelectTrigger";
|
package/src/input/Checkbox.tsx
CHANGED
@@ -14,7 +14,8 @@ export type CheckboxGroupProps = Exclude<
|
|
14
14
|
children: React.ReactNode;
|
15
15
|
/* Defaults to 1 */
|
16
16
|
gap?: number | string;
|
17
|
-
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
18
|
+
[key: string]: any; //Find a way to not use type any
|
18
19
|
};
|
19
20
|
/**
|
20
21
|
* Used to group several checkboxes together. You can pass the default value, as well as whether or not they're all disabled
|
@@ -50,3 +51,4 @@ export const CheckboxGroup = forwardRef<HTMLDivElement, CheckboxGroupProps>(
|
|
50
51
|
);
|
51
52
|
},
|
52
53
|
);
|
54
|
+
CheckboxGroup.displayName = "CheckboxGroup";
|
package/src/input/ChoiceChip.tsx
CHANGED
@@ -6,7 +6,7 @@ import {
|
|
6
6
|
useCheckbox,
|
7
7
|
} from "@chakra-ui/react";
|
8
8
|
import { CloseOutline24Icon } from "@vygruppen/spor-icon-react";
|
9
|
-
import React, { ChangeEvent, PropsWithChildren
|
9
|
+
import React, { ChangeEvent, PropsWithChildren } from "react";
|
10
10
|
|
11
11
|
import { choiceChipRecipe } from "@/theme/recipes/choice-chip";
|
12
12
|
|
package/src/input/Combobox.tsx
CHANGED
@@ -82,7 +82,6 @@ export const Combobox = forwardRef<HTMLDivElement, ComboboxProps<object>>(
|
|
82
82
|
paddingY,
|
83
83
|
emptyContent,
|
84
84
|
inputRef: externalInputRef,
|
85
|
-
allowsEmptyCollection /* Is this being used? */,
|
86
85
|
children,
|
87
86
|
variant,
|
88
87
|
} = props;
|
@@ -122,7 +121,7 @@ export const Combobox = forwardRef<HTMLDivElement, ComboboxProps<object>>(
|
|
122
121
|
};
|
123
122
|
|
124
123
|
const {
|
125
|
-
inputProps: {
|
124
|
+
inputProps: { ...inputProps },
|
126
125
|
listBoxProps,
|
127
126
|
} = useComboBox(
|
128
127
|
{
|
@@ -177,7 +176,8 @@ export const Combobox = forwardRef<HTMLDivElement, ComboboxProps<object>>(
|
|
177
176
|
{state.isOpen && !loading && (
|
178
177
|
<Popover
|
179
178
|
state={state}
|
180
|
-
|
179
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
180
|
+
triggerRef={inputRef as any} /* Find a way to not use type any */
|
181
181
|
ref={popoverRef}
|
182
182
|
isNonModal
|
183
183
|
placement="bottom start"
|
@@ -209,6 +209,7 @@ export const Combobox = forwardRef<HTMLDivElement, ComboboxProps<object>>(
|
|
209
209
|
);
|
210
210
|
},
|
211
211
|
);
|
212
|
+
Combobox.displayName = "Combobox";
|
212
213
|
|
213
214
|
const useInputWidth = (inputRef: React.RefObject<HTMLInputElement>) => {
|
214
215
|
const [inputWidth, setInputWidth] = useState("auto");
|
@@ -220,7 +221,7 @@ const useInputWidth = (inputRef: React.RefObject<HTMLInputElement>) => {
|
|
220
221
|
}, 67);
|
221
222
|
window.addEventListener("resize", onResize);
|
222
223
|
return () => window.removeEventListener("resize", onResize);
|
223
|
-
}, []);
|
224
|
+
}, [inputRef]);
|
224
225
|
return inputWidth;
|
225
226
|
};
|
226
227
|
|
@@ -231,6 +232,7 @@ function styleProps(obj: Record<string, unknown>): Record<string, unknown> {
|
|
231
232
|
}
|
232
233
|
|
233
234
|
const debounce = (fn: () => void, ms = 100) => {
|
235
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
234
236
|
let timer: any;
|
235
237
|
return () => {
|
236
238
|
clearTimeout(timer);
|
@@ -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 { forwardRef } from "react";
|
6
6
|
|
7
7
|
import {
|
8
8
|
createTexts,
|
@@ -33,15 +33,20 @@ export const callingCodes = createListCollection({
|
|
33
33
|
items: [...prioritizedCountryCodes, ...sortedCallingCodes],
|
34
34
|
});
|
35
35
|
|
36
|
-
type CountryCodeSelectProps = Omit<SelectProps, "label" | "collection"
|
36
|
+
type CountryCodeSelectProps = Omit<SelectProps, "label" | "collection"> & {
|
37
|
+
allowedCountryCodes?: string[];
|
38
|
+
};
|
37
39
|
|
38
40
|
export const CountryCodeSelect = forwardRef<
|
39
41
|
HTMLDivElement,
|
40
42
|
CountryCodeSelectProps
|
41
43
|
>((props, ref) => {
|
42
44
|
const { t } = useTranslation();
|
43
|
-
|
44
|
-
|
45
|
+
if (props.allowedCountryCodes) {
|
46
|
+
callingCodes.items = callingCodes.items.filter((callingCode) =>
|
47
|
+
props.allowedCountryCodes?.some((code) => code === callingCode.label),
|
48
|
+
);
|
49
|
+
}
|
45
50
|
return (
|
46
51
|
<Select
|
47
52
|
{...props}
|
@@ -60,6 +65,7 @@ export const CountryCodeSelect = forwardRef<
|
|
60
65
|
</Select>
|
61
66
|
);
|
62
67
|
});
|
68
|
+
CountryCodeSelect.displayName = "CountryCodeSelect";
|
63
69
|
|
64
70
|
const texts = createTexts({
|
65
71
|
countryCode: {
|
package/src/input/Field.tsx
CHANGED
@@ -59,6 +59,7 @@ export const Field = React.forwardRef<HTMLDivElement, FieldProps>(
|
|
59
59
|
);
|
60
60
|
},
|
61
61
|
);
|
62
|
+
Field.displayName = "Field";
|
62
63
|
|
63
64
|
export const FieldErrorText = React.forwardRef<
|
64
65
|
HTMLDivElement,
|
@@ -68,5 +69,6 @@ export const FieldErrorText = React.forwardRef<
|
|
68
69
|
<ChakraField.ErrorText ref={ref}>{props.children}</ChakraField.ErrorText>
|
69
70
|
);
|
70
71
|
});
|
72
|
+
FieldErrorText.displayName = "FieldErrorText";
|
71
73
|
|
72
74
|
export const FieldLabel = ChakraField.Label;
|
package/src/input/Input.tsx
CHANGED
@@ -4,10 +4,8 @@ import {
|
|
4
4
|
chakra,
|
5
5
|
Input as ChakraInput,
|
6
6
|
InputProps as ChakraInputProps,
|
7
|
-
type RecipeVariantProps,
|
8
|
-
useRecipe,
|
9
7
|
} from "@chakra-ui/react";
|
10
|
-
import React, { forwardRef
|
8
|
+
import React, { forwardRef } from "react";
|
11
9
|
|
12
10
|
import { inputRecipe } from "@/theme/recipes/input";
|
13
11
|
|
@@ -95,3 +93,4 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(
|
|
95
93
|
);
|
96
94
|
},
|
97
95
|
);
|
96
|
+
Input.displayName = "Input";
|
package/src/input/InputGroup.tsx
CHANGED
@@ -32,7 +32,6 @@ export const InputGroup = React.forwardRef<HTMLDivElement, InputGroupProps>(
|
|
32
32
|
endElementProps,
|
33
33
|
label,
|
34
34
|
children,
|
35
|
-
attached,
|
36
35
|
...rest
|
37
36
|
} = props;
|
38
37
|
|
@@ -65,3 +64,4 @@ export const InputGroup = React.forwardRef<HTMLDivElement, InputGroupProps>(
|
|
65
64
|
);
|
66
65
|
},
|
67
66
|
);
|
67
|
+
InputGroup.displayName = "InputGroup";
|
package/src/input/ListBox.tsx
CHANGED
@@ -40,7 +40,7 @@ type ListBoxProps<T> = AriaListBoxProps<T> &
|
|
40
40
|
/** Whether or not the listbox is waiting on new data, i.e. through a autosuggest search */
|
41
41
|
loading?: boolean;
|
42
42
|
/** The state of the listbox, provided externally somehow. */
|
43
|
-
state: ListState<T> | SelectState<
|
43
|
+
state: ListState<T> | SelectState<unknown>;
|
44
44
|
/** UI to render if the collection is empty */
|
45
45
|
emptyContent?: React.ReactNode;
|
46
46
|
maxWidth?: BoxProps["maxWidth"];
|
@@ -72,7 +72,7 @@ type ListBoxProps<T> = AriaListBoxProps<T> &
|
|
72
72
|
*
|
73
73
|
* @example
|
74
74
|
* ```jsx
|
75
|
-
* const { data, isLoading }
|
75
|
+
* const { data, isLoading } = useSWR('/api/options')
|
76
76
|
* const state = useListState({ items: data });
|
77
77
|
* const ref = useRef(null);
|
78
78
|
*
|
@@ -99,7 +99,7 @@ export const ListBox = forwardRef<HTMLDivElement, ListBoxProps<object>>(
|
|
99
99
|
maxWidth={maxWidth}
|
100
100
|
>
|
101
101
|
{state.collection.size === 0 && props.emptyContent}
|
102
|
-
{
|
102
|
+
{[...state.collection].map((item) =>
|
103
103
|
item.type === "section" ? (
|
104
104
|
<ListBoxSection key={item.key} section={item} state={state} />
|
105
105
|
) : (
|
@@ -111,6 +111,7 @@ export const ListBox = forwardRef<HTMLDivElement, ListBoxProps<object>>(
|
|
111
111
|
);
|
112
112
|
},
|
113
113
|
);
|
114
|
+
ListBox.displayName = "ListBox";
|
114
115
|
|
115
116
|
/**
|
116
117
|
* Renders a label for a listbox item.
|
@@ -140,7 +141,7 @@ export function ItemDescription({ children }: { children: React.ReactNode }) {
|
|
140
141
|
|
141
142
|
type OptionProps = {
|
142
143
|
item: Node<unknown>;
|
143
|
-
state: SelectState<
|
144
|
+
state: SelectState<unknown> | ListState<unknown>;
|
144
145
|
};
|
145
146
|
function Option({ item, state }: OptionProps) {
|
146
147
|
const ref = useRef(null);
|
@@ -177,7 +178,7 @@ function Option({ item, state }: OptionProps) {
|
|
177
178
|
TODO: Follow up with react-spectrum to see if they can solve it on their end
|
178
179
|
*/
|
179
180
|
useEffect(() => {
|
180
|
-
(ref as
|
181
|
+
(ref as React.RefObject<HTMLDivElement>)?.current?.addEventListener(
|
181
182
|
"touchend",
|
182
183
|
(event: TouchEvent) => {
|
183
184
|
event.preventDefault();
|
@@ -210,7 +211,7 @@ const useOptionContext = () => {
|
|
210
211
|
|
211
212
|
type ListBoxSectionProps = {
|
212
213
|
section: Node<unknown>;
|
213
|
-
state:
|
214
|
+
state: ListState<unknown> | SelectState<unknown>;
|
214
215
|
};
|
215
216
|
function ListBoxSection({ section, state }: ListBoxSectionProps) {
|
216
217
|
const { itemProps, headingProps, groupProps } = useListBoxSection({
|
@@ -239,8 +240,8 @@ function ListBoxSection({ section, state }: ListBoxSectionProps) {
|
|
239
240
|
</Box>
|
240
241
|
)}
|
241
242
|
<List {...groupProps} padding={0} listStyleType="none">
|
242
|
-
{
|
243
|
-
(item:
|
243
|
+
{[...(state.collection.getChildren?.(section.key) ?? [])].map(
|
244
|
+
(item: Node<unknown>) => (
|
244
245
|
<Option key={item.key} item={item} state={state} />
|
245
246
|
),
|
246
247
|
)}
|
@@ -1,9 +1,9 @@
|
|
1
1
|
"use client";
|
2
2
|
import {
|
3
3
|
NativeSelect as ChakraNativeSelect,
|
4
|
+
NativeSelectFieldProps as ChakraNativeSelectFieldProps,
|
4
5
|
RecipeVariantProps,
|
5
6
|
useSlotRecipe,
|
6
|
-
NativeSelectFieldProps as ChakraNativeSelectFieldProps,
|
7
7
|
} from "@chakra-ui/react";
|
8
8
|
import { DropdownDownFill18Icon } from "@vygruppen/spor-icon-react";
|
9
9
|
import * as React from "react";
|
@@ -46,7 +46,6 @@ export const NativeSelect = React.forwardRef<
|
|
46
46
|
NativeSelectdProps
|
47
47
|
>(function NativeSelect(props, ref) {
|
48
48
|
const {
|
49
|
-
icon,
|
50
49
|
children,
|
51
50
|
variant = "core",
|
52
51
|
label,
|
@@ -68,23 +68,20 @@ export const NumericStepper = React.forwardRef<
|
|
68
68
|
HTMLDivElement,
|
69
69
|
NumericStepperProps
|
70
70
|
>(
|
71
|
-
(
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
}: NumericStepperProps,
|
86
|
-
ref,
|
87
|
-
) => {
|
71
|
+
({
|
72
|
+
name: nameProp,
|
73
|
+
id: idProp,
|
74
|
+
value: valueProp,
|
75
|
+
defaultValue = 1,
|
76
|
+
onChange: onChangeProp,
|
77
|
+
minValue = 0,
|
78
|
+
maxValue = 99,
|
79
|
+
disabled,
|
80
|
+
withInput = true,
|
81
|
+
stepSize = 1,
|
82
|
+
showZero = false,
|
83
|
+
ariaLabelContext = { singular: "", plural: "" },
|
84
|
+
}: NumericStepperProps) => {
|
88
85
|
const addButtonRef = useRef<HTMLButtonElement>(null);
|
89
86
|
const { t } = useTranslation();
|
90
87
|
const recipe = useSlotRecipe({ recipe: numericStepperRecipe });
|
@@ -135,9 +132,9 @@ export const NumericStepper = React.forwardRef<
|
|
135
132
|
visibility={!showZero && value === 0 ? "hidden" : "visible"}
|
136
133
|
aria-live="assertive"
|
137
134
|
aria-label={
|
138
|
-
ariaLabelContext.plural
|
139
|
-
?
|
140
|
-
:
|
135
|
+
ariaLabelContext.plural === ""
|
136
|
+
? ""
|
137
|
+
: t(texts.currentNumberAriaLabel(ariaLabelContext.plural))
|
141
138
|
}
|
142
139
|
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
143
140
|
const numericInput = Number(e.target.value);
|
@@ -159,9 +156,9 @@ export const NumericStepper = React.forwardRef<
|
|
159
156
|
visibility={!showZero && value === 0 ? "hidden" : "visible"}
|
160
157
|
aria-live="assertive"
|
161
158
|
aria-label={
|
162
|
-
ariaLabelContext.plural
|
163
|
-
?
|
164
|
-
:
|
159
|
+
ariaLabelContext.plural === ""
|
160
|
+
? ""
|
161
|
+
: t(texts.currentNumberAriaLabel(ariaLabelContext.plural))
|
165
162
|
}
|
166
163
|
>
|
167
164
|
{value}
|
@@ -187,6 +184,7 @@ export const NumericStepper = React.forwardRef<
|
|
187
184
|
);
|
188
185
|
},
|
189
186
|
);
|
187
|
+
NumericStepper.displayName = "NumericStepper";
|
190
188
|
|
191
189
|
type VerySmallButtonProps = {
|
192
190
|
/** The icon to render */
|
@@ -220,6 +218,7 @@ const VerySmallButton = React.forwardRef<
|
|
220
218
|
/>
|
221
219
|
);
|
222
220
|
});
|
221
|
+
VerySmallButton.displayName = "VerySmallButton";
|
223
222
|
|
224
223
|
type IconPropTypes = BoxProps & { stepLabel: number };
|
225
224
|
|
@@ -47,7 +47,6 @@ export interface PasswordInputProps
|
|
47
47
|
export const PasswordInput = forwardRef<HTMLInputElement, PasswordInputProps>(
|
48
48
|
(props, ref) => {
|
49
49
|
const {
|
50
|
-
rootProps,
|
51
50
|
defaultVisible,
|
52
51
|
visible: visibleProp,
|
53
52
|
onVisibleChange,
|
@@ -89,6 +88,7 @@ export const PasswordInput = forwardRef<HTMLInputElement, PasswordInputProps>(
|
|
89
88
|
);
|
90
89
|
},
|
91
90
|
);
|
91
|
+
PasswordInput.displayName = "PasswordInput";
|
92
92
|
|
93
93
|
const VisibilityTrigger = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
94
94
|
(props, ref) => {
|
@@ -107,6 +107,7 @@ const VisibilityTrigger = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
107
107
|
);
|
108
108
|
},
|
109
109
|
);
|
110
|
+
VisibilityTrigger.displayName = "VisibilityTrigger";
|
110
111
|
|
111
112
|
const texts = createTexts({
|
112
113
|
showPassword: {
|