@vygruppen/spor-react 12.8.3 → 12.8.6
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 +12 -12
- package/.turbo/turbo-postinstall.log +1 -1
- package/CHANGELOG.md +18 -0
- package/dist/index.cjs +54 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.mjs +54 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/datepicker/CalendarTriggerButton.tsx +3 -3
- package/src/datepicker/DateField.tsx +4 -6
- package/src/datepicker/DatePicker.tsx +0 -4
- package/src/datepicker/StyledField.tsx +1 -4
- package/src/datepicker/TimeField.tsx +5 -1
- package/src/input/Combobox.tsx +42 -8
package/package.json
CHANGED
@@ -18,12 +18,13 @@ type CalendarTriggerButtonProps = AriaButtonProps<"button"> &
|
|
18
18
|
BoxProps &
|
19
19
|
CalendarVariants & {
|
20
20
|
disabled?: boolean;
|
21
|
-
ariaLabelledby?: string;
|
22
21
|
};
|
23
22
|
export const CalendarTriggerButton = forwardRef<
|
24
23
|
HTMLDivElement,
|
25
24
|
CalendarTriggerButtonProps
|
26
|
-
|
25
|
+
// onPress is extracted because it is not supported by chakra.
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
27
|
+
>(({ variant, disabled, onPress: _, ...buttonProps }, ref) => {
|
27
28
|
const { t } = useTranslation();
|
28
29
|
|
29
30
|
const recipe = useSlotRecipe({
|
@@ -39,7 +40,6 @@ export const CalendarTriggerButton = forwardRef<
|
|
39
40
|
css={styles.calendarTriggerButton}
|
40
41
|
variant="ghost"
|
41
42
|
disabled={disabled}
|
42
|
-
aria-labelledby={ariaLabelledby}
|
43
43
|
/>
|
44
44
|
</PopoverAnchor>
|
45
45
|
);
|
@@ -27,10 +27,9 @@ type DateFieldProps = AriaDateFieldProps<DateValue> &
|
|
27
27
|
label?: React.ReactNode;
|
28
28
|
labelProps?: DOMAttributes<FocusableElement>;
|
29
29
|
name?: string;
|
30
|
-
labelId?: string;
|
31
30
|
};
|
32
31
|
export const DateField = forwardRef<HTMLDivElement, DateFieldProps>(
|
33
|
-
(
|
32
|
+
(props, externalRef) => {
|
34
33
|
const locale = useCurrentLocale();
|
35
34
|
|
36
35
|
const recipe = useSlotRecipe({
|
@@ -57,13 +56,12 @@ export const DateField = forwardRef<HTMLDivElement, DateFieldProps>(
|
|
57
56
|
<Box minWidth="6rem" width="100%">
|
58
57
|
{props.label && (
|
59
58
|
<Box
|
60
|
-
|
59
|
+
asChild
|
61
60
|
css={styles.inputLabel}
|
62
61
|
position="absolute"
|
63
62
|
paddingTop="2px"
|
64
|
-
id={labelId}
|
65
63
|
>
|
66
|
-
{props.label}
|
64
|
+
<label {...props.labelProps}>{props.label}</label>
|
67
65
|
</Box>
|
68
66
|
)}
|
69
67
|
<Flex {...fieldProps} ref={ref} paddingTop="3" paddingBottom="0.5">
|
@@ -72,7 +70,6 @@ export const DateField = forwardRef<HTMLDivElement, DateFieldProps>(
|
|
72
70
|
key={i}
|
73
71
|
segment={segment}
|
74
72
|
ariaDescription={t(getAriaLabel(segment.type))}
|
75
|
-
ariaLabel={labelId}
|
76
73
|
state={state}
|
77
74
|
/>
|
78
75
|
))}
|
@@ -81,6 +78,7 @@ export const DateField = forwardRef<HTMLDivElement, DateFieldProps>(
|
|
81
78
|
type="hidden"
|
82
79
|
value={state.value?.toString() ?? ""}
|
83
80
|
name={props.name}
|
81
|
+
id={props.id}
|
84
82
|
/>
|
85
83
|
</Box>
|
86
84
|
);
|
@@ -88,7 +88,6 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
|
88
88
|
ref as React.MutableRefObject<HTMLDivElement>,
|
89
89
|
);
|
90
90
|
|
91
|
-
const labelId = `label-${useId()}`;
|
92
91
|
const inputGroupId = `input-group-${useId()}`;
|
93
92
|
|
94
93
|
const recipe = useSlotRecipe({
|
@@ -128,7 +127,6 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
|
128
127
|
<Field
|
129
128
|
display="inline-flex"
|
130
129
|
id={inputGroupId}
|
131
|
-
aria-labelledby={labelId}
|
132
130
|
errorText={errorText}
|
133
131
|
invalid={invalid}
|
134
132
|
helperText={helperText}
|
@@ -140,7 +138,6 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
|
140
138
|
paddingX={3}
|
141
139
|
minHeight={minHeight}
|
142
140
|
isDisabled={props.isDisabled}
|
143
|
-
ariaLabelledby={labelId}
|
144
141
|
>
|
145
142
|
<ChakraPopover.Trigger asChild>
|
146
143
|
<CalendarTriggerButton
|
@@ -154,7 +151,6 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
|
154
151
|
<DateField
|
155
152
|
label={props.label}
|
156
153
|
labelProps={labelProps}
|
157
|
-
labelId={labelId}
|
158
154
|
name={props.name}
|
159
155
|
{...fieldProps}
|
160
156
|
/>
|
@@ -14,12 +14,10 @@ type StyledFieldProps = BoxProps &
|
|
14
14
|
PropsWithChildren<DatePickerVariantProps> &
|
15
15
|
CalendarVariants & {
|
16
16
|
isDisabled?: boolean;
|
17
|
-
ariaLabelledby?: string;
|
18
17
|
};
|
19
18
|
export const StyledField = forwardRef<HTMLDivElement, StyledFieldProps>(
|
20
19
|
function StyledField(props, ref) {
|
21
|
-
const { children, variant, isDisabled,
|
22
|
-
props;
|
20
|
+
const { children, variant, isDisabled, ...otherProps } = props;
|
23
21
|
const { invalid } = useFieldContext() ?? {
|
24
22
|
isInvalid: false,
|
25
23
|
};
|
@@ -36,7 +34,6 @@ export const StyledField = forwardRef<HTMLDivElement, StyledFieldProps>(
|
|
36
34
|
ref={ref}
|
37
35
|
aria-invalid={invalid}
|
38
36
|
aria-disabled={isDisabled}
|
39
|
-
aria-labelledby={ariaLabelledby}
|
40
37
|
>
|
41
38
|
{children}
|
42
39
|
</Box>
|
@@ -39,7 +39,11 @@ export const TimeField = ({ state, ...props }: TimeFieldProps) => {
|
|
39
39
|
</label>
|
40
40
|
<Flex {...fieldProps} ref={ref} paddingTop="3" paddingBottom="0.5">
|
41
41
|
{state.segments.map((segment: DateSegment) => (
|
42
|
-
<DateTimeSegment
|
42
|
+
<DateTimeSegment
|
43
|
+
key={JSON.stringify(segment)}
|
44
|
+
segment={segment}
|
45
|
+
state={state}
|
46
|
+
/>
|
43
47
|
))}
|
44
48
|
</Flex>
|
45
49
|
<input
|
package/src/input/Combobox.tsx
CHANGED
@@ -24,7 +24,6 @@ export type ComboboxProps<T> = Exclude<
|
|
24
24
|
leftIcon?: ReactNode;
|
25
25
|
rightIcon?: ReactNode;
|
26
26
|
variant?: "core" | "floating";
|
27
|
-
children?: React.ReactNode;
|
28
27
|
};
|
29
28
|
/**
|
30
29
|
* A combobox is a combination of an input and a list of suggestions.
|
@@ -76,6 +75,17 @@ export const Combobox = (props: ComboboxProps<object>) => {
|
|
76
75
|
inputRef: externalInputRef,
|
77
76
|
children,
|
78
77
|
variant,
|
78
|
+
allowsEmptyCollection,
|
79
|
+
onSelectionChange,
|
80
|
+
inputValue,
|
81
|
+
onInputChange,
|
82
|
+
menuTrigger,
|
83
|
+
allowsCustomValue,
|
84
|
+
onFocusChange,
|
85
|
+
defaultInputValue,
|
86
|
+
defaultItems,
|
87
|
+
defaultSelectedKey,
|
88
|
+
onOpenChange,
|
79
89
|
...restProps
|
80
90
|
} = props;
|
81
91
|
const { contains } = useFilter({ sensitivity: "base" });
|
@@ -85,13 +95,24 @@ export const Combobox = (props: ComboboxProps<object>) => {
|
|
85
95
|
const listBoxRef = useRef<HTMLUListElement>(null);
|
86
96
|
const popoverRef = useRef(null);
|
87
97
|
|
88
|
-
const listboxId =
|
98
|
+
const listboxId = useId();
|
89
99
|
|
90
100
|
const inputWidth = useInputWidth(inputRef);
|
91
101
|
|
92
102
|
const state = useComboBoxState({
|
93
103
|
defaultFilter: contains,
|
94
104
|
shouldCloseOnBlur: true,
|
105
|
+
allowsEmptyCollection,
|
106
|
+
onSelectionChange,
|
107
|
+
inputValue,
|
108
|
+
onInputChange,
|
109
|
+
menuTrigger,
|
110
|
+
allowsCustomValue,
|
111
|
+
onFocusChange,
|
112
|
+
defaultInputValue,
|
113
|
+
defaultItems,
|
114
|
+
defaultSelectedKey,
|
115
|
+
onOpenChange,
|
95
116
|
...props,
|
96
117
|
});
|
97
118
|
|
@@ -110,22 +131,34 @@ export const Combobox = (props: ComboboxProps<object>) => {
|
|
110
131
|
paddingLeft,
|
111
132
|
paddingX,
|
112
133
|
paddingY,
|
113
|
-
leftIcon,
|
114
134
|
};
|
115
135
|
|
116
|
-
const {
|
117
|
-
inputProps: { ...inputProps },
|
118
|
-
listBoxProps,
|
119
|
-
} = useComboBox(
|
136
|
+
const { inputProps, listBoxProps } = useComboBox(
|
120
137
|
{
|
121
138
|
...props,
|
122
139
|
inputRef,
|
123
140
|
listBoxRef,
|
124
141
|
popoverRef,
|
125
142
|
label,
|
143
|
+
onSelectionChange,
|
144
|
+
inputValue,
|
145
|
+
onInputChange,
|
146
|
+
menuTrigger,
|
147
|
+
allowsCustomValue,
|
148
|
+
onFocusChange,
|
149
|
+
defaultInputValue,
|
150
|
+
defaultItems,
|
151
|
+
defaultSelectedKey,
|
152
|
+
onOpenChange,
|
126
153
|
},
|
127
154
|
state,
|
128
155
|
);
|
156
|
+
|
157
|
+
// Remove aria-labelledby and id from inputProps, as these are handled by the Input component
|
158
|
+
// This prevents potential conflicts or duplication of accessibility attributes
|
159
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
160
|
+
const { "aria-labelledby": _, id: __, ...filteredInputProps } = inputProps;
|
161
|
+
|
129
162
|
return (
|
130
163
|
<>
|
131
164
|
<Input
|
@@ -151,7 +184,7 @@ export const Combobox = (props: ComboboxProps<object>) => {
|
|
151
184
|
state.isOpen && !loading ? 0 : borderBottomRightRadius
|
152
185
|
}
|
153
186
|
_active={{ backgroundColor: "core.surface.active" }}
|
154
|
-
{...
|
187
|
+
{...filteredInputProps}
|
155
188
|
startElement={leftIcon}
|
156
189
|
endElement={
|
157
190
|
loading ? (
|
@@ -215,6 +248,7 @@ Combobox.displayName = "Combobox";
|
|
215
248
|
|
216
249
|
const useInputWidth = (inputRef: React.RefObject<HTMLInputElement>) => {
|
217
250
|
const [inputWidth, setInputWidth] = useState("auto");
|
251
|
+
|
218
252
|
useEffect(() => {
|
219
253
|
const onResize = debounce(() => {
|
220
254
|
if (inputRef.current) {
|