@mbao01/common 0.7.1 → 0.7.2
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/dist/types/components/Combobox/Combobox.d.ts +1 -1
- package/dist/types/components/Combobox/types.d.ts +3 -1
- package/dist/types/components/Form/Select/Select.d.ts +2 -0
- package/dist/types/components/Form/Select/constants.d.ts +1 -0
- package/package.json +2 -2
- package/src/components/Combobox/Combobox.tsx +14 -2
- package/src/components/Combobox/types.ts +5 -1
- package/src/components/Form/Select/Select.tsx +16 -4
- package/src/components/Form/Select/constants.ts +3 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ComboboxProps, Item } from './types';
|
|
2
|
-
export declare const Combobox: <T extends Item>({ label, items, classes, emptyText, placeholder, getItemValue, getItemLabel, onSelectItem, }: ComboboxProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const Combobox: <T extends Item>({ label, items, classes, emptyText, placeholder, outline, variant, disabled, readOnly, getItemValue, getItemLabel, onSelectItem, }: ComboboxProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ButtonProps } from '../Button/types';
|
|
2
|
+
import { InputProps } from '../Form/Input/types';
|
|
1
3
|
export type Item = Record<string, any>;
|
|
2
4
|
export type ComboboxProps<T extends Item> = {
|
|
3
5
|
label: string;
|
|
@@ -17,4 +19,4 @@ export type ComboboxProps<T extends Item> = {
|
|
|
17
19
|
item: string;
|
|
18
20
|
popoverContent: string;
|
|
19
21
|
}>;
|
|
20
|
-
}
|
|
22
|
+
} & Pick<ButtonProps, "variant" | "disabled" | "outline"> & Pick<InputProps, "readOnly">;
|
|
@@ -9,6 +9,7 @@ declare const Select: {
|
|
|
9
9
|
outline?: boolean | undefined;
|
|
10
10
|
size?: "xs" | "sm" | "md" | "lg" | undefined;
|
|
11
11
|
wide?: boolean | undefined;
|
|
12
|
+
readOnly?: boolean | undefined;
|
|
12
13
|
} & {
|
|
13
14
|
label?: React.ReactNode;
|
|
14
15
|
labelPosition?: "start" | "end" | "floating";
|
|
@@ -22,6 +23,7 @@ declare const Select: {
|
|
|
22
23
|
outline?: boolean | undefined;
|
|
23
24
|
size?: "xs" | "sm" | "md" | "lg" | undefined;
|
|
24
25
|
wide?: boolean | undefined;
|
|
26
|
+
readOnly?: boolean | undefined;
|
|
25
27
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
26
28
|
Icon: React.ForwardRefExoticComponent<SelectPrimitive.SelectIconProps & React.RefAttributes<HTMLSpanElement>>;
|
|
27
29
|
ItemText: React.ForwardRefExoticComponent<SelectPrimitive.SelectItemTextProps & React.RefAttributes<HTMLSpanElement>>;
|
|
@@ -3,6 +3,7 @@ export declare const getSelectTriggerClasses: (props?: ({
|
|
|
3
3
|
wide?: boolean | null | undefined;
|
|
4
4
|
outline?: boolean | null | undefined;
|
|
5
5
|
size?: "xs" | "sm" | "md" | "lg" | null | undefined;
|
|
6
|
+
readOnly?: boolean | null | undefined;
|
|
6
7
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
7
8
|
export declare const getSelectItemClasses: (props?: ({
|
|
8
9
|
variant?: "accent" | "default" | "error" | "ghost" | "info" | "primary" | "secondary" | "success" | "warning" | null | undefined;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mbao01/common",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Ayomide Bakare",
|
|
7
7
|
"license": "MIT",
|
|
@@ -168,5 +168,5 @@
|
|
|
168
168
|
"recharts": "2",
|
|
169
169
|
"typescript": "5"
|
|
170
170
|
},
|
|
171
|
-
"gitHead": "
|
|
171
|
+
"gitHead": "605c1bb5b1367d8755951d5c5425ca86bcd5dd96"
|
|
172
172
|
}
|
|
@@ -14,6 +14,10 @@ export const Combobox = <T extends Item>({
|
|
|
14
14
|
classes,
|
|
15
15
|
emptyText,
|
|
16
16
|
placeholder,
|
|
17
|
+
outline,
|
|
18
|
+
variant,
|
|
19
|
+
disabled,
|
|
20
|
+
readOnly,
|
|
17
21
|
getItemValue = (item: T) => item.value as string,
|
|
18
22
|
getItemLabel = (item: T) => item.label as string,
|
|
19
23
|
onSelectItem,
|
|
@@ -27,9 +31,11 @@ export const Combobox = <T extends Item>({
|
|
|
27
31
|
<Popover open={open} onOpenChange={setOpen}>
|
|
28
32
|
<Popover.Trigger asChild>
|
|
29
33
|
<Button
|
|
30
|
-
outline
|
|
34
|
+
outline={outline}
|
|
31
35
|
role="combobox"
|
|
36
|
+
variant={variant}
|
|
32
37
|
aria-expanded={open}
|
|
38
|
+
disabled={disabled}
|
|
33
39
|
className={cn("justify-between", classes?.trigger)}
|
|
34
40
|
>
|
|
35
41
|
{value && currentItem ? getItemLabel(currentItem) : label}
|
|
@@ -38,12 +44,18 @@ export const Combobox = <T extends Item>({
|
|
|
38
44
|
</Popover.Trigger>
|
|
39
45
|
<Popover.Content className={cn("w-[200px] p-0", classes?.popoverContent)}>
|
|
40
46
|
<Command className={cn(classes?.content)}>
|
|
41
|
-
<Command.Input
|
|
47
|
+
<Command.Input
|
|
48
|
+
placeholder={placeholder}
|
|
49
|
+
disabled={disabled}
|
|
50
|
+
readOnly={readOnly}
|
|
51
|
+
className={cn(classes?.input)}
|
|
52
|
+
/>
|
|
42
53
|
<Command.Empty className={cn(classes?.empty)}>{emptyText}</Command.Empty>
|
|
43
54
|
<Command.List>
|
|
44
55
|
<Command.Group className={cn(classes?.group)}>
|
|
45
56
|
{items?.map((item) => (
|
|
46
57
|
<Command.Item
|
|
58
|
+
disabled={disabled}
|
|
47
59
|
key={getItemValue(item)}
|
|
48
60
|
value={getItemValue(item)}
|
|
49
61
|
onSelect={(currentValue) => {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { ButtonProps } from "../Button/types";
|
|
2
|
+
import { InputProps } from "../Form/Input/types";
|
|
3
|
+
|
|
1
4
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2
5
|
export type Item = Record<string, any>;
|
|
3
6
|
|
|
@@ -19,4 +22,5 @@ export type ComboboxProps<T extends Item> = {
|
|
|
19
22
|
item: string;
|
|
20
23
|
popoverContent: string;
|
|
21
24
|
}>;
|
|
22
|
-
}
|
|
25
|
+
} & Pick<ButtonProps, "variant" | "disabled" | "outline"> &
|
|
26
|
+
Pick<InputProps, "readOnly">;
|
|
@@ -55,6 +55,7 @@ const SelectTrigger = React.forwardRef<
|
|
|
55
55
|
wide,
|
|
56
56
|
variant,
|
|
57
57
|
outline,
|
|
58
|
+
readOnly,
|
|
58
59
|
...props
|
|
59
60
|
},
|
|
60
61
|
ref
|
|
@@ -67,7 +68,11 @@ const SelectTrigger = React.forwardRef<
|
|
|
67
68
|
<SelectPrimitive.Trigger
|
|
68
69
|
id={id}
|
|
69
70
|
ref={ref}
|
|
70
|
-
|
|
71
|
+
aria-readonly={readOnly}
|
|
72
|
+
className={cn(
|
|
73
|
+
getSelectTriggerClasses({ size, wide, variant, outline, readOnly }),
|
|
74
|
+
className
|
|
75
|
+
)}
|
|
71
76
|
{...props}
|
|
72
77
|
>
|
|
73
78
|
{children}
|
|
@@ -79,10 +84,13 @@ const SelectTrigger = React.forwardRef<
|
|
|
79
84
|
return (
|
|
80
85
|
<label
|
|
81
86
|
htmlFor={id}
|
|
82
|
-
className={cn(
|
|
87
|
+
className={cn(
|
|
88
|
+
getSelectTriggerClasses({ size, wide, variant, outline, readOnly }),
|
|
89
|
+
className
|
|
90
|
+
)}
|
|
83
91
|
>
|
|
84
92
|
{labelPosition === "start" && <LabelForSelect>{label}</LabelForSelect>}
|
|
85
|
-
<SelectPrimitive.Trigger id={id} ref={ref} {...props}>
|
|
93
|
+
<SelectPrimitive.Trigger id={id} ref={ref} aria-readonly={readOnly} {...props}>
|
|
86
94
|
{children}
|
|
87
95
|
</SelectPrimitive.Trigger>
|
|
88
96
|
{labelPosition === "end" && <LabelForSelect className="me-0!">{label}</LabelForSelect>}
|
|
@@ -94,7 +102,11 @@ const SelectTrigger = React.forwardRef<
|
|
|
94
102
|
<SelectPrimitive.Trigger
|
|
95
103
|
id={id}
|
|
96
104
|
ref={ref}
|
|
97
|
-
|
|
105
|
+
aria-readonly={readOnly}
|
|
106
|
+
className={cn(
|
|
107
|
+
getSelectTriggerClasses({ size, wide, variant, outline, readOnly }),
|
|
108
|
+
className
|
|
109
|
+
)}
|
|
98
110
|
{...props}
|
|
99
111
|
>
|
|
100
112
|
{children}
|