@vygruppen/spor-react 12.8.2 → 12.8.5
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 +1 -1
- package/CHANGELOG.md +18 -0
- package/dist/index.cjs +59 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.mjs +58 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/index.tsx +1 -0
- package/src/input/Combobox.tsx +42 -8
- package/src/theme/slot-recipes/index.ts +1 -0
- package/src/theme/slot-recipes/popover.ts +2 -0
- package/src/tooltip.tsx +38 -0
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vygruppen/spor-react",
|
3
3
|
"type": "module",
|
4
|
-
"version": "12.8.
|
4
|
+
"version": "12.8.5",
|
5
5
|
"exports": {
|
6
6
|
".": {
|
7
7
|
"types": "./dist/index.d.ts",
|
@@ -46,9 +46,9 @@
|
|
46
46
|
"react-stately": "^3.31.1",
|
47
47
|
"react-swipeable": "^7.0.1",
|
48
48
|
"usehooks-ts": "^3.1.0",
|
49
|
+
"@vygruppen/spor-design-tokens": "4.0.7",
|
49
50
|
"@vygruppen/spor-icon-react": "4.2.1",
|
50
|
-
"@vygruppen/spor-loader": "0.7.0"
|
51
|
-
"@vygruppen/spor-design-tokens": "4.0.7"
|
51
|
+
"@vygruppen/spor-loader": "0.7.0"
|
52
52
|
},
|
53
53
|
"devDependencies": {
|
54
54
|
"@react-types/datepicker": "^3.10.0",
|
package/src/index.tsx
CHANGED
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) {
|
package/src/tooltip.tsx
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
import { Portal, Tooltip as ChakraTooltip } from "@chakra-ui/react";
|
4
|
+
import { forwardRef } from "react";
|
5
|
+
|
6
|
+
export const Tooltip = ChakraTooltip.Root;
|
7
|
+
|
8
|
+
export const TooltipTrigger = forwardRef<
|
9
|
+
HTMLButtonElement,
|
10
|
+
ChakraTooltip.TriggerProps
|
11
|
+
>(({ children, ...props }, ref) => {
|
12
|
+
const isStringChild = typeof children === "string";
|
13
|
+
|
14
|
+
return (
|
15
|
+
<ChakraTooltip.Trigger {...props} ref={ref} asChild={!isStringChild}>
|
16
|
+
{children}
|
17
|
+
</ChakraTooltip.Trigger>
|
18
|
+
);
|
19
|
+
});
|
20
|
+
TooltipTrigger.displayName = "TooltipTrigger";
|
21
|
+
|
22
|
+
export type TooltipProps = ChakraTooltip.ContentProps;
|
23
|
+
|
24
|
+
export const TooltipContent = forwardRef<HTMLDivElement, TooltipProps>(
|
25
|
+
({ children, ...props }, ref) => {
|
26
|
+
return (
|
27
|
+
<Portal>
|
28
|
+
<ChakraTooltip.Positioner>
|
29
|
+
<ChakraTooltip.Content ref={ref} {...props}>
|
30
|
+
<ChakraTooltip.Arrow />
|
31
|
+
<ChakraTooltip.Content {...props}>{children}</ChakraTooltip.Content>
|
32
|
+
</ChakraTooltip.Content>
|
33
|
+
</ChakraTooltip.Positioner>
|
34
|
+
</Portal>
|
35
|
+
);
|
36
|
+
},
|
37
|
+
);
|
38
|
+
TooltipContent.displayName = "TooltipContent";
|