@mbao01/common 0.4.1 → 0.4.3

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.
@@ -1,2 +1,2 @@
1
1
  import { DatePickerProps } from './types';
2
- export declare const DatePicker: ({ name, size, wide, label, outline, variant, disabled, defaultDate, children, getDateValue, getDateLabel, triggerClassName, ...props }: DatePickerProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const DatePicker: ({ name, size, wide, label, outline, variant, disabled, defaultDate, disabledDates, children, onSelect, getDateValue, getDateLabel, triggerClassName, ...props }: DatePickerProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import { MultipleDatesPickerProps } from './types';
2
- export declare const MultipleDatesPicker: ({ name, size, wide, label, outline, variant, disabled, defaultDates, getDatesValue, getDatesLabel, ...props }: MultipleDatesPickerProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const MultipleDatesPicker: ({ name, size, wide, label, outline, variant, disabled, defaultDates, disabledDates, getDatesValue, getDatesLabel, ...props }: MultipleDatesPickerProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { DateRange, PropsBase, PropsMulti, PropsRange, PropsSingle } from 'react-day-picker';
2
2
  import { ButtonProps } from '../Button/types';
3
- type BaseDatePickerProps = Omit<PropsBase, "mode"> & Pick<ButtonProps, "variant" | "outline" | "wide" | "size" | "name" | "disabled"> & {
3
+ type BaseDatePickerProps = Omit<PropsBase, "mode" | "disabled"> & Pick<ButtonProps, "variant" | "outline" | "wide" | "size" | "name" | "disabled"> & {
4
4
  label?: string;
5
5
  triggerClassName?: string;
6
6
  };
@@ -10,6 +10,7 @@ export type DatePickerProps = BaseDatePickerProps & Omit<PropsSingle, "mode"> &
10
10
  setDate: React.Dispatch<React.SetStateAction<Date | undefined>>;
11
11
  }) => React.JSX.Element | null;
12
12
  defaultDate?: Date;
13
+ disabledDates?: PropsBase["disabled"];
13
14
  getDateLabel?: (date: Date | undefined) => string | undefined;
14
15
  getDateValue?: (date: Date | undefined) => string | undefined;
15
16
  };
@@ -24,6 +25,7 @@ export type DateRangePickerProps = BaseDatePickerProps & Omit<PropsRange, "mode"
24
25
  };
25
26
  export type MultipleDatesPickerProps = BaseDatePickerProps & Omit<PropsMulti, "mode"> & {
26
27
  defaultDates?: Date[];
28
+ disabledDates?: PropsBase["disabled"];
27
29
  getDatesValue?: (dates: Date[] | undefined) => string[] | undefined;
28
30
  getDatesLabel?: (dates: Date[] | undefined) => string | React.JSX.Element | undefined;
29
31
  };
@@ -8,6 +8,7 @@ export declare const DatetimeInput: import('react').ForwardRefExoticComponent<{
8
8
  outline?: boolean | undefined;
9
9
  wide?: boolean | undefined;
10
10
  disabled?: boolean | undefined;
11
+ readOnly?: boolean | undefined;
11
12
  } & {
12
13
  date?: Date;
13
14
  calendar?: {
@@ -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;
@@ -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.1",
4
+ "version": "0.4.3",
5
5
  "type": "module",
6
6
  "author": "Ayomide Bakare",
7
7
  "license": "MIT",
@@ -99,64 +99,64 @@
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.522.0",
103
- "react-day-picker": "^9.7.0",
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.5",
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.29.0",
116
- "@ianvs/prettier-plugin-sort-imports": "^4.4.2",
117
- "@storybook/addon-a11y": "^9.0.12",
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.12",
120
- "@storybook/addon-links": "^9.0.12",
121
- "@storybook/addon-onboarding": "^9.0.12",
122
- "@storybook/addon-themes": "^9.0.12",
123
- "@storybook/react-vite": "^9.0.12",
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
- "@tailwindcss/postcss": "^4.1.10",
126
- "@tailwindcss/vite": "^4.1.10",
125
+ "@tailwindcss/postcss": "^4.1.11",
126
+ "@tailwindcss/vite": "^4.1.11",
127
127
  "@testing-library/jest-dom": "^6.6.3",
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.3",
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.34.1",
135
- "@typescript-eslint/parser": "^8.34.1",
136
- "@vitejs/plugin-react": "^4.5.2",
134
+ "@typescript-eslint/eslint-plugin": "^8.36.0",
135
+ "@typescript-eslint/parser": "^8.36.0",
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.43",
141
- "eslint": "^9.29.0",
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.12",
146
- "globals": "^16.2.0",
145
+ "eslint-plugin-storybook": "^9.0.16",
146
+ "globals": "^16.3.0",
147
147
  "jest-image-snapshot": "^6.5.1",
148
148
  "jsdom": "^26.1.0",
149
149
  "path": "^0.12.7",
150
150
  "postcss": "^8.5.6",
151
- "prettier": "^3.5.3",
151
+ "prettier": "^3.6.2",
152
152
  "react": "^19.1.0",
153
153
  "react-dom": "^19.1.0",
154
- "react-router-dom": "^7.6.2",
154
+ "react-router-dom": "^7.6.3",
155
155
  "recharts": "^2.15.4",
156
- "storybook": "^9.0.12",
157
- "tailwindcss": "^4.1.10",
156
+ "storybook": "^9.0.16",
157
+ "tailwindcss": "^4.1.11",
158
158
  "typescript": "^5.8.3",
159
- "typescript-eslint": "^8.34.1",
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": "dbd7ef70a813c7ebfde498a82a6646a907370555"
171
+ "gitHead": "f1e87f8fc6fc61de80777905e5d8e3bb214fab28"
172
172
  }
@@ -18,7 +18,9 @@ export const DatePicker = ({
18
18
  variant,
19
19
  disabled,
20
20
  defaultDate,
21
+ disabledDates,
21
22
  children,
23
+ onSelect,
22
24
  getDateValue = (date) => date?.toUTCString(),
23
25
  getDateLabel = (date) => (date ? format(date, "PPP") : undefined),
24
26
  triggerClassName,
@@ -34,7 +36,11 @@ export const DatePicker = ({
34
36
  autoFocus
35
37
  mode="single"
36
38
  selected={date}
37
- onSelect={setDate}
39
+ onSelect={(...args) => {
40
+ setDate(args[0]);
41
+ onSelect?.(...args);
42
+ }}
43
+ disabled={disabledDates}
38
44
  captionLayout="label"
39
45
  {...props}
40
46
  />
@@ -50,7 +56,7 @@ export const DatePicker = ({
50
56
  outline={outline}
51
57
  variant={variant}
52
58
  disabled={disabled}
53
- className={cn("justify-start", !date && "font-normal", triggerClassName)}
59
+ className={cn("justify-start", !dateValue && "font-normal", triggerClassName)}
54
60
  value={dateValue}
55
61
  >
56
62
  {dateLabel ?? <span>{label ?? "Pick a date"}</span>}
@@ -18,6 +18,7 @@ export const MultipleDatesPicker = ({
18
18
  variant,
19
19
  disabled,
20
20
  defaultDates,
21
+ disabledDates,
21
22
  getDatesValue = (dates) => dates?.map((date) => date.toUTCString()),
22
23
  getDatesLabel = (dates) => {
23
24
  if (!dates?.length) return undefined;
@@ -67,6 +68,7 @@ export const MultipleDatesPicker = ({
67
68
  mode="multiple"
68
69
  selected={dates}
69
70
  onSelect={setDates}
71
+ disabled={disabledDates}
70
72
  captionLayout="label"
71
73
  {...props}
72
74
  />
@@ -1,7 +1,7 @@
1
1
  import type { DateRange, PropsBase, PropsMulti, PropsRange, PropsSingle } from "react-day-picker";
2
2
  import { type ButtonProps } from "../Button/types";
3
3
 
4
- type BaseDatePickerProps = Omit<PropsBase, "mode"> &
4
+ type BaseDatePickerProps = Omit<PropsBase, "mode" | "disabled"> &
5
5
  Pick<ButtonProps, "variant" | "outline" | "wide" | "size" | "name" | "disabled"> & {
6
6
  label?: string;
7
7
  triggerClassName?: string;
@@ -17,6 +17,7 @@ export type DatePickerProps = BaseDatePickerProps &
17
17
  setDate: React.Dispatch<React.SetStateAction<Date | undefined>>;
18
18
  }) => React.JSX.Element | null;
19
19
  defaultDate?: Date;
20
+ disabledDates?: PropsBase["disabled"];
20
21
  getDateLabel?: (date: Date | undefined) => string | undefined;
21
22
  getDateValue?: (date: Date | undefined) => string | undefined;
22
23
  };
@@ -35,6 +36,7 @@ export type DateRangePickerProps = BaseDatePickerProps &
35
36
  export type MultipleDatesPickerProps = BaseDatePickerProps &
36
37
  Omit<PropsMulti, "mode"> & {
37
38
  defaultDates?: Date[];
39
+ disabledDates?: PropsBase["disabled"];
38
40
  getDatesValue?: (dates: Date[] | undefined) => string[] | undefined;
39
41
  getDatesLabel?: (dates: Date[] | undefined) => string | React.JSX.Element | undefined;
40
42
  };
@@ -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
- className={cn(getInputClasses({ type, size, wide, variant, outline }), className)}
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(getInputClasses({ type, size, wide, variant, outline }), className)}
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
- className={cn(getInputClasses({ type, size, wide, variant, outline }), className)}
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
  {