@mbao01/common 0.0.55 → 0.0.57

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.
@@ -6,7 +6,7 @@ declare const MultiSelect: {
6
6
  displayName: string;
7
7
  };
8
8
  Input: {
9
- ({ className, ...props }: MultiSelectInputProps): import("react/jsx-runtime").JSX.Element;
9
+ ({ className, size, ...props }: MultiSelectInputProps): import("react/jsx-runtime").JSX.Element;
10
10
  displayName: string;
11
11
  };
12
12
  Content: import('react').ForwardRefExoticComponent<MultiSelectContentProps & import('react').RefAttributes<HTMLDivElement>>;
@@ -34,6 +34,7 @@ declare const MultiSelect: {
34
34
  keywords?: string[];
35
35
  forceMount?: boolean;
36
36
  } & import('react').RefAttributes<HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>, "ref"> & {
37
+ variant?: "accent" | "default" | "error" | "info" | "primary" | "secondary" | "success" | "warning" | undefined;
37
38
  size?: "xs" | "sm" | "md" | "lg" | undefined;
38
39
  disabled?: boolean | undefined;
39
40
  included?: boolean | undefined;
@@ -1,6 +1,6 @@
1
1
  export declare const getMultiSelectClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
2
2
  export declare const getMultiSelectTriggerClasses: (props?: ({
3
- variant?: "accent" | "default" | "error" | "info" | "primary" | "secondary" | "success" | "warning" | "ghost" | null | undefined;
3
+ variant?: "accent" | "default" | "error" | "info" | "primary" | "secondary" | "success" | "warning" | null | undefined;
4
4
  outline?: boolean | null | undefined;
5
5
  disabled?: boolean | null | undefined;
6
6
  wide?: boolean | null | undefined;
@@ -10,6 +10,7 @@ export declare const getMultiSelectItemClasses: (props?: ({
10
10
  included?: boolean | null | undefined;
11
11
  disabled?: boolean | null | undefined;
12
12
  size?: "xs" | "sm" | "md" | "lg" | null | undefined;
13
+ variant?: "accent" | "default" | "error" | "info" | "primary" | "secondary" | "success" | "warning" | null | undefined;
13
14
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
14
15
  export declare const getMultiSelectListClasses: (props?: ({
15
16
  size?: "xs" | "sm" | "md" | "lg" | null | undefined;
@@ -17,3 +18,6 @@ export declare const getMultiSelectListClasses: (props?: ({
17
18
  export declare const getMultiSelectTagClasses: (props?: ({
18
19
  size?: "xs" | "sm" | "md" | "lg" | null | undefined;
19
20
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
21
+ export declare const getMultiSelectInputClasses: (props?: ({
22
+ size?: "xs" | "sm" | "md" | "lg" | null | undefined;
23
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
@@ -1,7 +1,7 @@
1
1
  import { ComponentPropsWithoutRef, HTMLAttributes } from 'react';
2
2
  import { VariantProps } from '../../../libs';
3
3
  import { Command } from '../../Command';
4
- import { getMultiSelectItemClasses, getMultiSelectListClasses, getMultiSelectTriggerClasses } from './constants';
4
+ import { getMultiSelectInputClasses, getMultiSelectItemClasses, getMultiSelectListClasses, getMultiSelectTriggerClasses } from './constants';
5
5
  export type Item = {
6
6
  value: string;
7
7
  label?: string;
@@ -25,7 +25,7 @@ export type MultiSelectContextProps = {
25
25
  handleSelect: (e: React.SyntheticEvent<HTMLInputElement>) => void;
26
26
  };
27
27
  export type MultiSelectTriggerProps = HTMLAttributes<HTMLDivElement> & VariantProps<typeof getMultiSelectTriggerClasses>;
28
- export type MultiSelectInputProps = ComponentPropsWithoutRef<typeof Command.Input>;
28
+ export type MultiSelectInputProps = Omit<ComponentPropsWithoutRef<typeof Command.Input>, "size"> & VariantProps<typeof getMultiSelectInputClasses>;
29
29
  export type MultiSelectContentProps = HTMLAttributes<HTMLDivElement>;
30
30
  export type MultiSelectListProps = ComponentPropsWithoutRef<typeof Command.List> & VariantProps<typeof getMultiSelectListClasses>;
31
31
  export type MultiSelectItemProps = Item & ComponentPropsWithoutRef<typeof Command.Item> & VariantProps<typeof getMultiSelectItemClasses>;
@@ -8,6 +8,9 @@ export declare const getSelectItemClasses: (props?: ({
8
8
  variant?: "accent" | "default" | "error" | "info" | "primary" | "secondary" | "success" | "warning" | null | undefined;
9
9
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
10
10
  export declare const getSelectLabelClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
11
+ export declare const getSelectValueClasses: (props?: ({
12
+ size?: "xs" | "sm" | "md" | "lg" | null | undefined;
13
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
11
14
  export declare const getSelectSeparatorClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
12
15
  export declare const getSelectContentClasses: (props?: ({
13
16
  position?: "popper" | "item-aligned" | null | undefined;
@@ -1,6 +1,7 @@
1
1
  import { VariantProps } from '../../../libs';
2
- import { getSelectContentClasses, getSelectTriggerClasses } from './constants';
2
+ import { getSelectContentClasses, getSelectTriggerClasses, getSelectValueClasses } from './constants';
3
3
  import * as SelectPrimitive from "@radix-ui/react-select";
4
4
  export type SelectTriggerProps = React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger> & VariantProps<typeof getSelectTriggerClasses>;
5
5
  export type SelectItemProps = React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item> & VariantProps<typeof getSelectTriggerClasses>;
6
6
  export type SelectContentProps = React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content> & VariantProps<typeof getSelectContentClasses>;
7
+ export type SelectValueProps = React.ComponentPropsWithoutRef<typeof SelectPrimitive.Value> & VariantProps<typeof getSelectValueClasses>;
@@ -1,5 +1,6 @@
1
1
  export { DatetimeInput } from './DatetimeInput';
2
2
  export { Input } from './Input';
3
+ export { MultiSelect } from './MultiSelect';
3
4
  export { OtpInput } from './OtpInput';
4
5
  export { Phone } from './Phone';
5
6
  export { Radio } from './Radio';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mbao01/common",
3
3
  "private": false,
4
- "version": "0.0.55",
4
+ "version": "0.0.57",
5
5
  "type": "module",
6
6
  "author": "Ayomide Bakare",
7
7
  "license": "MIT",
@@ -172,5 +172,5 @@
172
172
  "recharts": "^2.13.0",
173
173
  "typescript": "^5.2.2"
174
174
  },
175
- "gitHead": "a1cade5cde1e079c2746a9c703f7bd5def5063f4"
175
+ "gitHead": "da184d4f814a6be9bdab346555fad9809f0eb427"
176
176
  }
@@ -18,6 +18,7 @@ import { Badge } from "../../Badge";
18
18
  import { Command } from "../../Command";
19
19
  import {
20
20
  getMultiSelectClasses,
21
+ getMultiSelectInputClasses,
21
22
  getMultiSelectItemClasses,
22
23
  getMultiSelectListClasses,
23
24
  getMultiSelectTagClasses,
@@ -247,7 +248,7 @@ export const MultiSelectTrigger = ({
247
248
 
248
249
  MultiSelectTrigger.displayName = "MultiSelectTrigger";
249
250
 
250
- const MultiSelectInput = ({ className, ...props }: MultiSelectInputProps) => {
251
+ const MultiSelectInput = ({ className, size, ...props }: MultiSelectInputProps) => {
251
252
  const {
252
253
  setOpen,
253
254
  inputValue,
@@ -270,9 +271,9 @@ const MultiSelectInput = ({ className, ...props }: MultiSelectInputProps) => {
270
271
  onFocus={() => setOpen(true)}
271
272
  onClick={() => setActiveIndex(-1)}
272
273
  className={cn(
273
- "bg-transparent outline-none flex-1",
274
- className,
275
- activeIndex !== -1 && "caret-transparent"
274
+ getMultiSelectInputClasses({ size }),
275
+ { "caret-transparent": activeIndex !== -1 },
276
+ className
276
277
  )}
277
278
  />
278
279
  );
@@ -309,7 +310,7 @@ const MultiSelectList = forwardRef<ComponentRef<typeof Command.List>, MultiSelec
309
310
  MultiSelectList.displayName = "MultiSelectList";
310
311
 
311
312
  const MultiSelectItem = forwardRef<ComponentRef<typeof Command.Item>, MultiSelectItemProps>(
312
- ({ className, value, label, children, size, disabled, ...props }, ref) => {
313
+ ({ className, value, label, children, size, disabled, variant, ...props }, ref) => {
313
314
  const { values: options, onValueChange, setInputValue } = useMultiSelect();
314
315
 
315
316
  const mousePreventDefault = useCallback((e: MouseEvent) => {
@@ -327,7 +328,7 @@ const MultiSelectItem = forwardRef<ComponentRef<typeof Command.Item>, MultiSelec
327
328
  onValueChange(value, label);
328
329
  setInputValue("");
329
330
  }}
330
- className={cn(getMultiSelectItemClasses({ included, disabled, size }), className)}
331
+ className={cn(getMultiSelectItemClasses({ included, disabled, variant, size }), className)}
331
332
  onMouseDown={mousePreventDefault}
332
333
  >
333
334
  {children}
@@ -1,18 +1,15 @@
1
1
  import { cva } from "../../../libs";
2
2
 
3
- export const getMultiSelectClasses = cva(
4
- "overflow-visible bg-transparent flex flex-col h-fit w-fit"
5
- );
3
+ export const getMultiSelectClasses = cva("overflow-visible bg-transparent flex flex-col h-fit");
6
4
 
7
5
  export const getMultiSelectTriggerClasses = cva(
8
- "flex items-center flex-wrap gap-1 h-fit px-1 py-2 rounded-md transition-all overflow-hidden",
6
+ "flex items-center flex-wrap gap-1 h-fit w-fit px-1 py-2 rounded-md transition-all overflow-hidden",
9
7
  {
10
8
  variants: {
11
9
  variant: {
12
10
  default: "border-0",
13
11
  accent: "border border-accent",
14
12
  error: "border border-error",
15
- ghost: "border border-ghost",
16
13
  info: "border border-info",
17
14
  primary: "border border-primary",
18
15
  secondary: "border border-secondary",
@@ -55,7 +52,7 @@ export const getMultiSelectTriggerClasses = cva(
55
52
  );
56
53
 
57
54
  export const getMultiSelectItemClasses = cva(
58
- "rounded-md cursor-pointer px-2 py-1 transition-colors flex justify-between",
55
+ "cursor-pointer transition-colors flex justify-between aria-selected:bg-base-300 aria-selected:text-base-content rounded-sm py-1.5 px-2 text-sm outline-none",
59
56
  {
60
57
  variants: {
61
58
  included: {
@@ -70,12 +67,22 @@ export const getMultiSelectItemClasses = cva(
70
67
  md: "px-2 text-sm",
71
68
  lg: "px-3 text-lg",
72
69
  },
70
+ variant: {
71
+ default: "aria-selected:bg-transparent aria-selected:text-base-content",
72
+ primary: "aria-selected:bg-primary aria-selected:text-primary-content",
73
+ secondary: "aria-selected:bg-secondary aria-selected:text-secondary-content",
74
+ accent: "aria-selected:bg-accent aria-selected:text-accent-content",
75
+ success: "aria-selected:bg-success aria-selected:text-success-content",
76
+ warning: "aria-selected:bg-warning aria-selected:text-warning-content",
77
+ info: "aria-selected:bg-info aria-selected:text-info-content",
78
+ error: "aria-selected:bg-error aria-selected:text-error-content",
79
+ },
73
80
  },
74
81
  }
75
82
  );
76
83
 
77
84
  export const getMultiSelectListClasses = cva(
78
- "p-2 flex flex-col gap-2 rounded-md scrollbar-thin scrollbar-track-transparent transition-colors scrollbar-thumb-muted-foreground dark:scrollbar-thumb-muted scrollbar-thumb-rounded-lg w-full absolute bg-background shadow-md z-10 border border-muted top-0",
85
+ "p-1 bg-base-100 flex flex-col gap-2 rounded-md scrollbar-thin scrollbar-track-transparent transition-colors scrollbar-thumb-muted-foreground dark:scrollbar-thumb-muted scrollbar-thumb-rounded-lg w-full absolute bg-background shadow-md z-10 border border-muted top-1",
79
86
  {
80
87
  variants: {
81
88
  size: {
@@ -101,3 +108,14 @@ export const getMultiSelectTagClasses = cva(
101
108
  },
102
109
  }
103
110
  );
111
+
112
+ export const getMultiSelectInputClasses = cva("bg-transparent outline-none flex-1", {
113
+ variants: {
114
+ size: {
115
+ xs: "text-xs",
116
+ sm: "text-sm",
117
+ md: "text-md",
118
+ lg: "text-lg",
119
+ },
120
+ },
121
+ });
@@ -2,6 +2,7 @@ import { ComponentPropsWithoutRef, HTMLAttributes } from "react";
2
2
  import { VariantProps } from "../../../libs";
3
3
  import { Command } from "../../Command";
4
4
  import {
5
+ getMultiSelectInputClasses,
5
6
  getMultiSelectItemClasses,
6
7
  getMultiSelectListClasses,
7
8
  getMultiSelectTriggerClasses,
@@ -35,7 +36,8 @@ export type MultiSelectContextProps = {
35
36
  export type MultiSelectTriggerProps = HTMLAttributes<HTMLDivElement> &
36
37
  VariantProps<typeof getMultiSelectTriggerClasses>;
37
38
 
38
- export type MultiSelectInputProps = ComponentPropsWithoutRef<typeof Command.Input>;
39
+ export type MultiSelectInputProps = Omit<ComponentPropsWithoutRef<typeof Command.Input>, "size"> &
40
+ VariantProps<typeof getMultiSelectInputClasses>;
39
41
 
40
42
  export type MultiSelectContentProps = HTMLAttributes<HTMLDivElement>;
41
43
 
@@ -47,7 +47,7 @@ export const getSelectTriggerClasses = cva(
47
47
  );
48
48
 
49
49
  export const getSelectItemClasses = cva(
50
- "relative flex w-full cursor-pointer select-none items-center focus:bg-neutral focus:text-neutral-content rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
50
+ "relative flex w-full cursor-pointer select-none items-center focus:bg-base-300 focus:text-base-content rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
51
51
  {
52
52
  variants: {
53
53
  variant: {
@@ -66,6 +66,17 @@ export const getSelectItemClasses = cva(
66
66
 
67
67
  export const getSelectLabelClasses = cva("px-2 py-1.5 text-sm font-semibold");
68
68
 
69
+ export const getSelectValueClasses = cva("", {
70
+ variants: {
71
+ size: {
72
+ xs: "text-xs",
73
+ sm: "text-sm",
74
+ md: "text-md",
75
+ lg: "text-lg",
76
+ },
77
+ },
78
+ });
79
+
69
80
  export const getSelectSeparatorClasses = cva("-mx-1 my-1 h-px bg-muted");
70
81
 
71
82
  export const getSelectContentClasses = cva(
@@ -1,6 +1,10 @@
1
1
  import * as SelectPrimitive from "@radix-ui/react-select";
2
2
  import { type VariantProps } from "../../../libs";
3
- import { getSelectContentClasses, getSelectTriggerClasses } from "./constants";
3
+ import {
4
+ getSelectContentClasses,
5
+ getSelectTriggerClasses,
6
+ getSelectValueClasses,
7
+ } from "./constants";
4
8
 
5
9
  export type SelectTriggerProps = React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger> &
6
10
  VariantProps<typeof getSelectTriggerClasses>;
@@ -10,3 +14,6 @@ export type SelectItemProps = React.ComponentPropsWithoutRef<typeof SelectPrimit
10
14
 
11
15
  export type SelectContentProps = React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content> &
12
16
  VariantProps<typeof getSelectContentClasses>;
17
+
18
+ export type SelectValueProps = React.ComponentPropsWithoutRef<typeof SelectPrimitive.Value> &
19
+ VariantProps<typeof getSelectValueClasses>;
@@ -1,5 +1,6 @@
1
1
  export { DatetimeInput } from "./DatetimeInput";
2
2
  export { Input } from "./Input";
3
+ export { MultiSelect } from "./MultiSelect";
3
4
  export { OtpInput } from "./OtpInput";
4
5
  export { Phone } from "./Phone";
5
6
  export { Radio } from "./Radio";