@mbao01/common 0.4.2 → 0.4.4
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/Form/DatetimeInput/DatetimeInput.d.ts +1 -0
- package/dist/types/components/Form/Input/Input.d.ts +1 -0
- package/dist/types/components/Form/Input/constants.d.ts +2 -0
- package/dist/types/components/Form/Phone/Phone.d.ts +1 -2
- package/dist/types/components/Form/Phone/types.d.ts +2 -1
- package/dist/types/components/Form/TagsInput/TagsInput.d.ts +1 -0
- package/dist/types/components/Form/TextField/TextField.d.ts +1 -0
- package/dist/types/components/Sidebar/Sidebar.d.ts +1 -0
- package/package.json +21 -21
- package/src/components/Form/Input/Input.tsx +13 -4
- package/src/components/Form/Input/constants.ts +6 -0
- package/src/components/Form/Phone/Phone.tsx +3 -2
- package/src/components/Form/Phone/types.ts +3 -1
|
@@ -5,6 +5,7 @@ export declare const Input: React.ForwardRefExoticComponent<Omit<React.InputHTML
|
|
|
5
5
|
size?: "xs" | "sm" | "md" | "lg" | undefined;
|
|
6
6
|
outline?: boolean | undefined;
|
|
7
7
|
wide?: boolean | undefined;
|
|
8
|
+
readOnly?: boolean | undefined;
|
|
8
9
|
}, "type"> & {
|
|
9
10
|
label?: React.ReactNode;
|
|
10
11
|
labelPosition?: "start" | "end" | "floating";
|
|
@@ -4,6 +4,7 @@ export declare const getInputClasses: (props?: ({
|
|
|
4
4
|
wide?: boolean | null | undefined;
|
|
5
5
|
size?: "xs" | "sm" | "md" | "lg" | null | undefined;
|
|
6
6
|
type?: string | number | null | undefined;
|
|
7
|
+
readOnly?: boolean | null | undefined;
|
|
7
8
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
8
9
|
export declare const getFloatingLabelClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
|
|
9
10
|
export declare const getInputLabelClasses: (props?: ({
|
|
@@ -15,4 +16,5 @@ export declare const getInputCommonClasses: (props?: ({
|
|
|
15
16
|
disabled?: boolean | null | undefined;
|
|
16
17
|
wide?: boolean | null | undefined;
|
|
17
18
|
size?: "xs" | "sm" | "md" | "lg" | null | undefined;
|
|
19
|
+
readOnly?: boolean | null | undefined;
|
|
18
20
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import
|
|
3
|
-
declare const Phone: React.ForwardRefExoticComponent<PhoneProps & React.RefAttributes<HTMLInputElement>>;
|
|
2
|
+
declare const Phone: React.ForwardRefExoticComponent<Omit<import('../Input/types').InputProps, "type" | "inputMode" | "label"> & Pick<import('react-international-phone').UsePhoneInputConfig, "defaultCountry"> & React.RefAttributes<HTMLInputElement>>;
|
|
4
3
|
export { Phone };
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { UsePhoneInputConfig } from 'react-international-phone';
|
|
1
2
|
import { InputProps } from '../Input/types';
|
|
2
|
-
export type PhoneProps = Omit<InputProps, "type" | "label" | "inputMode">;
|
|
3
|
+
export type PhoneProps = Omit<InputProps, "type" | "label" | "inputMode"> & Pick<UsePhoneInputConfig, "defaultCountry">;
|
|
@@ -12,4 +12,5 @@ export declare const TagsInput: import('react').ForwardRefExoticComponent<import
|
|
|
12
12
|
outline?: boolean | undefined;
|
|
13
13
|
wide?: boolean | undefined;
|
|
14
14
|
disabled?: boolean | undefined;
|
|
15
|
+
readOnly?: boolean | undefined;
|
|
15
16
|
} & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -5,6 +5,7 @@ export declare const TextField: React.ForwardRefExoticComponent<Omit<React.Input
|
|
|
5
5
|
size?: "xs" | "sm" | "md" | "lg" | undefined;
|
|
6
6
|
outline?: boolean | undefined;
|
|
7
7
|
wide?: boolean | undefined;
|
|
8
|
+
readOnly?: boolean | undefined;
|
|
8
9
|
}, "type"> & {
|
|
9
10
|
label?: React.ReactNode;
|
|
10
11
|
labelPosition?: "start" | "end" | "floating";
|
|
@@ -13,6 +13,7 @@ declare const Sidebar: {
|
|
|
13
13
|
size?: "xs" | "sm" | "md" | "lg" | undefined;
|
|
14
14
|
outline?: boolean | undefined;
|
|
15
15
|
wide?: boolean | undefined;
|
|
16
|
+
readOnly?: boolean | undefined;
|
|
16
17
|
}, "type"> & {
|
|
17
18
|
label?: import('react').ReactNode;
|
|
18
19
|
labelPosition?: "start" | "end" | "floating";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mbao01/common",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Ayomide Bakare",
|
|
7
7
|
"license": "MIT",
|
|
@@ -99,28 +99,28 @@
|
|
|
99
99
|
"cmdk": "^1.1.1",
|
|
100
100
|
"date-fns": "^4.1.0",
|
|
101
101
|
"embla-carousel-react": "^8.6.0",
|
|
102
|
-
"lucide-react": "^0.
|
|
103
|
-
"react-day-picker": "^9.
|
|
102
|
+
"lucide-react": "^0.525.0",
|
|
103
|
+
"react-day-picker": "^9.8.0",
|
|
104
104
|
"react-dropzone": "^14.3.8",
|
|
105
105
|
"react-international-phone": "^4.5.0",
|
|
106
106
|
"react-otp-input": "^3.1.1",
|
|
107
107
|
"react-resizable-panels": "^3.0.3",
|
|
108
|
-
"sonner": "^2.0.
|
|
108
|
+
"sonner": "^2.0.6",
|
|
109
109
|
"tailwind-merge": "^3.3.1",
|
|
110
110
|
"timescape": "^0.7.1",
|
|
111
111
|
"universal-cookie": "^8.0.1",
|
|
112
112
|
"vaul": "^1.1.2"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
115
|
-
"@eslint/js": "^9.30.
|
|
116
|
-
"@ianvs/prettier-plugin-sort-imports": "^4.
|
|
117
|
-
"@storybook/addon-a11y": "^9.0.
|
|
115
|
+
"@eslint/js": "^9.30.1",
|
|
116
|
+
"@ianvs/prettier-plugin-sort-imports": "^4.5.1",
|
|
117
|
+
"@storybook/addon-a11y": "^9.0.16",
|
|
118
118
|
"@storybook/addon-coverage": "^2.0.0",
|
|
119
|
-
"@storybook/addon-docs": "^9.0.
|
|
120
|
-
"@storybook/addon-links": "^9.0.
|
|
121
|
-
"@storybook/addon-onboarding": "^9.0.
|
|
122
|
-
"@storybook/addon-themes": "^9.0.
|
|
123
|
-
"@storybook/react-vite": "^9.0.
|
|
119
|
+
"@storybook/addon-docs": "^9.0.16",
|
|
120
|
+
"@storybook/addon-links": "^9.0.16",
|
|
121
|
+
"@storybook/addon-onboarding": "^9.0.16",
|
|
122
|
+
"@storybook/addon-themes": "^9.0.16",
|
|
123
|
+
"@storybook/react-vite": "^9.0.16",
|
|
124
124
|
"@storybook/test-runner": "^0.23.0",
|
|
125
125
|
"@tailwindcss/postcss": "^4.1.11",
|
|
126
126
|
"@tailwindcss/vite": "^4.1.11",
|
|
@@ -128,21 +128,21 @@
|
|
|
128
128
|
"@testing-library/react": "^16.3.0",
|
|
129
129
|
"@testing-library/user-event": "^14.6.1",
|
|
130
130
|
"@types/jest-image-snapshot": "^6.4.0",
|
|
131
|
-
"@types/node": "^24.0.
|
|
131
|
+
"@types/node": "^24.0.13",
|
|
132
132
|
"@types/react": "^19.1.8",
|
|
133
133
|
"@types/react-dom": "^19.1.6",
|
|
134
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
135
|
-
"@typescript-eslint/parser": "^8.
|
|
134
|
+
"@typescript-eslint/eslint-plugin": "^8.36.0",
|
|
135
|
+
"@typescript-eslint/parser": "^8.36.0",
|
|
136
136
|
"@vitejs/plugin-react": "^4.6.0",
|
|
137
137
|
"@vitest/coverage-v8": "^3.2.4",
|
|
138
138
|
"@vitest/ui": "^3.2.4",
|
|
139
139
|
"axe-playwright": "^2.1.0",
|
|
140
|
-
"daisyui": "^5.0.
|
|
141
|
-
"eslint": "^9.30.
|
|
140
|
+
"daisyui": "^5.0.46",
|
|
141
|
+
"eslint": "^9.30.1",
|
|
142
142
|
"eslint-plugin-react": "^7.37.5",
|
|
143
143
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
144
144
|
"eslint-plugin-react-refresh": "^0.4.20",
|
|
145
|
-
"eslint-plugin-storybook": "^9.0.
|
|
145
|
+
"eslint-plugin-storybook": "^9.0.16",
|
|
146
146
|
"globals": "^16.3.0",
|
|
147
147
|
"jest-image-snapshot": "^6.5.1",
|
|
148
148
|
"jsdom": "^26.1.0",
|
|
@@ -153,10 +153,10 @@
|
|
|
153
153
|
"react-dom": "^19.1.0",
|
|
154
154
|
"react-router-dom": "^7.6.3",
|
|
155
155
|
"recharts": "^2.15.4",
|
|
156
|
-
"storybook": "^9.0.
|
|
156
|
+
"storybook": "^9.0.16",
|
|
157
157
|
"tailwindcss": "^4.1.11",
|
|
158
158
|
"typescript": "^5.8.3",
|
|
159
|
-
"typescript-eslint": "^8.
|
|
159
|
+
"typescript-eslint": "^8.36.0",
|
|
160
160
|
"vite": "^6.3.5",
|
|
161
161
|
"vite-plugin-dts": "^4.5.4",
|
|
162
162
|
"vitest": "^3.2.4"
|
|
@@ -168,5 +168,5 @@
|
|
|
168
168
|
"recharts": "2",
|
|
169
169
|
"typescript": "5"
|
|
170
170
|
},
|
|
171
|
-
"gitHead": "
|
|
171
|
+
"gitHead": "e3e23ca85c4e11eb4e1ce1c07bc110f9d639b818"
|
|
172
172
|
}
|
|
@@ -30,6 +30,7 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
|
30
30
|
outline,
|
|
31
31
|
className,
|
|
32
32
|
type,
|
|
33
|
+
readOnly,
|
|
33
34
|
...props
|
|
34
35
|
}: InputProps,
|
|
35
36
|
ref
|
|
@@ -43,7 +44,11 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
|
43
44
|
id={id}
|
|
44
45
|
ref={ref}
|
|
45
46
|
type={type}
|
|
46
|
-
|
|
47
|
+
readOnly={readOnly}
|
|
48
|
+
className={cn(
|
|
49
|
+
getInputClasses({ type, size, wide, variant, outline, readOnly }),
|
|
50
|
+
className
|
|
51
|
+
)}
|
|
47
52
|
{...props}
|
|
48
53
|
/>
|
|
49
54
|
</label>
|
|
@@ -53,10 +58,13 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
|
53
58
|
return (
|
|
54
59
|
<label
|
|
55
60
|
htmlFor={id}
|
|
56
|
-
className={cn(
|
|
61
|
+
className={cn(
|
|
62
|
+
getInputClasses({ type, size, wide, variant, outline, readOnly }),
|
|
63
|
+
className
|
|
64
|
+
)}
|
|
57
65
|
>
|
|
58
66
|
{labelPosition === "start" && <InputLabel>{label}</InputLabel>}
|
|
59
|
-
<input id={id} ref={ref} type={type} {...props} />
|
|
67
|
+
<input id={id} ref={ref} type={type} readOnly={readOnly} {...props} />
|
|
60
68
|
{labelPosition === "end" && <InputLabel>{label}</InputLabel>}
|
|
61
69
|
</label>
|
|
62
70
|
);
|
|
@@ -67,7 +75,8 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
|
67
75
|
id={id}
|
|
68
76
|
ref={ref}
|
|
69
77
|
type={type}
|
|
70
|
-
|
|
78
|
+
readOnly={readOnly}
|
|
79
|
+
className={cn(getInputClasses({ type, size, wide, variant, outline, readOnly }), className)}
|
|
71
80
|
{...props}
|
|
72
81
|
/>
|
|
73
82
|
);
|
|
@@ -29,6 +29,9 @@ export const getInputClasses = cva("input rounded-md transition-all duration-100
|
|
|
29
29
|
["file" as string]:
|
|
30
30
|
"file:border-0 file:bg-transparent file:text-sm file:font-medium file:h-full",
|
|
31
31
|
},
|
|
32
|
+
readOnly: {
|
|
33
|
+
true: "cursor-not-allowed! bg-base-200!",
|
|
34
|
+
},
|
|
32
35
|
},
|
|
33
36
|
compoundVariants: [
|
|
34
37
|
{
|
|
@@ -101,6 +104,9 @@ export const getInputCommonClasses = cva(
|
|
|
101
104
|
md: "h-12 leading-loose text-sm px-2",
|
|
102
105
|
lg: "h-16 leading-loose text-lg px-3",
|
|
103
106
|
},
|
|
107
|
+
readOnly: {
|
|
108
|
+
true: "cursor-not-allowed! bg-base-200!",
|
|
109
|
+
},
|
|
104
110
|
},
|
|
105
111
|
compoundVariants: [
|
|
106
112
|
{
|
|
@@ -22,14 +22,15 @@ const Phone = React.forwardRef<HTMLInputElement, PhoneProps>(
|
|
|
22
22
|
outline,
|
|
23
23
|
wide,
|
|
24
24
|
size,
|
|
25
|
+
defaultCountry = "us",
|
|
25
26
|
...props
|
|
26
27
|
},
|
|
27
28
|
ref
|
|
28
29
|
) => {
|
|
29
30
|
const [open, setOpen] = React.useState(false);
|
|
30
31
|
const { inputValue, handlePhoneValueChange, inputRef, country, setCountry } = usePhoneInput({
|
|
31
|
-
value: defaultValue ? String(defaultValue) : "
|
|
32
|
-
defaultCountry
|
|
32
|
+
value: defaultValue ? String(defaultValue) : "",
|
|
33
|
+
defaultCountry,
|
|
33
34
|
forceDialCode: true,
|
|
34
35
|
inputRef: ref as MutableRefObject<HTMLInputElement | null>,
|
|
35
36
|
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { UsePhoneInputConfig } from "react-international-phone";
|
|
1
2
|
import { type InputProps } from "../Input/types";
|
|
2
3
|
|
|
3
|
-
export type PhoneProps = Omit<InputProps, "type" | "label" | "inputMode"
|
|
4
|
+
export type PhoneProps = Omit<InputProps, "type" | "label" | "inputMode"> &
|
|
5
|
+
Pick<UsePhoneInputConfig, "defaultCountry">;
|