@mbao01/common 0.2.2 → 0.2.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.
Files changed (137) hide show
  1. package/dist/types/components/Dock/Dock.d.ts +8 -0
  2. package/dist/types/components/Dock/constants.d.ts +12 -0
  3. package/dist/types/components/Dock/index.d.ts +1 -0
  4. package/dist/types/components/Dock/types.d.ts +12 -0
  5. package/dist/types/components/Form/DatetimeInput/constants.d.ts +0 -7
  6. package/dist/types/components/Form/DatetimeInput/types.d.ts +2 -2
  7. package/dist/types/components/Form/Input/Input.d.ts +5 -2
  8. package/dist/types/components/Form/Input/constants.d.ts +11 -0
  9. package/dist/types/components/Form/Input/types.d.ts +9 -2
  10. package/dist/types/components/Form/MultiSelect/constants.d.ts +1 -7
  11. package/dist/types/components/Form/MultiSelect/types.d.ts +3 -2
  12. package/dist/types/components/Form/Radio/Radio.d.ts +1 -1
  13. package/dist/types/components/Form/Radio/types.d.ts +1 -1
  14. package/dist/types/components/Form/Range/Range.d.ts +1 -1
  15. package/dist/types/components/Form/Range/types.d.ts +1 -1
  16. package/dist/types/components/Form/Select/Select.d.ts +5 -2
  17. package/dist/types/components/Form/Select/constants.d.ts +6 -2
  18. package/dist/types/components/Form/Select/types.d.ts +10 -2
  19. package/dist/types/components/Form/Switch/Switch.d.ts +1 -1
  20. package/dist/types/components/Form/Switch/types.d.ts +1 -1
  21. package/dist/types/components/Form/TagsInput/TagsInput.d.ts +2 -0
  22. package/dist/types/components/Form/TagsInput/constants.d.ts +0 -4
  23. package/dist/types/components/Form/TagsInput/types.d.ts +2 -1
  24. package/dist/types/components/Form/TextField/TextField.d.ts +5 -1
  25. package/dist/types/components/Form/TextField/types.d.ts +1 -0
  26. package/dist/types/components/Form/Textarea/Textarea.d.ts +2 -0
  27. package/dist/types/components/Form/Textarea/constants.d.ts +1 -0
  28. package/dist/types/components/Form/Textarea/types.d.ts +7 -1
  29. package/dist/types/components/Form/Validator/Validator.d.ts +6 -0
  30. package/dist/types/components/Form/Validator/constants.d.ts +4 -0
  31. package/dist/types/components/Form/Validator/index.d.ts +1 -0
  32. package/dist/types/components/Form/Validator/types.d.ts +14 -0
  33. package/dist/types/components/Form/components/Fieldset/types.d.ts +1 -1
  34. package/dist/types/components/Form/index.d.ts +1 -0
  35. package/dist/types/components/Indicator/Indicator.d.ts +6 -0
  36. package/dist/types/components/Indicator/constants.d.ts +15 -0
  37. package/dist/types/components/Indicator/index.d.ts +1 -0
  38. package/dist/types/components/Indicator/types.d.ts +14 -0
  39. package/dist/types/components/Join/Join.d.ts +6 -0
  40. package/dist/types/components/Join/constants.d.ts +2 -0
  41. package/dist/types/components/Join/index.d.ts +1 -0
  42. package/dist/types/components/Join/types.d.ts +13 -0
  43. package/dist/types/components/Kbd/Kbd.d.ts +2 -0
  44. package/dist/types/components/Kbd/constants.d.ts +5 -0
  45. package/dist/types/components/Kbd/index.d.ts +1 -0
  46. package/dist/types/components/Kbd/types.d.ts +3 -0
  47. package/dist/types/components/List/List.d.ts +7 -0
  48. package/dist/types/components/List/constants.d.ts +5 -0
  49. package/dist/types/components/List/index.d.ts +1 -0
  50. package/dist/types/components/List/types.d.ts +6 -0
  51. package/dist/types/components/Resizable/Resizable.d.ts +24 -0
  52. package/dist/types/components/Resizable/constants.d.ts +6 -0
  53. package/dist/types/components/Resizable/index.d.ts +1 -0
  54. package/dist/types/components/Resizable/types.d.ts +7 -0
  55. package/dist/types/components/Sidebar/Sidebar.d.ts +5 -2
  56. package/dist/types/components/Stack/Stack.d.ts +2 -0
  57. package/dist/types/components/Stack/constants.d.ts +3 -0
  58. package/dist/types/components/Stack/index.d.ts +1 -0
  59. package/dist/types/components/Stack/types.d.ts +3 -0
  60. package/dist/types/components/Stat/Stat.d.ts +11 -0
  61. package/dist/types/components/Stat/constants.d.ts +11 -0
  62. package/dist/types/components/Stat/index.d.ts +1 -0
  63. package/dist/types/components/Stat/types.d.ts +10 -0
  64. package/dist/types/components/Status/Status.d.ts +2 -0
  65. package/dist/types/components/Status/constants.d.ts +5 -0
  66. package/dist/types/components/Status/index.d.ts +1 -0
  67. package/dist/types/components/Status/types.d.ts +3 -0
  68. package/dist/types/components/Text/types.d.ts +1 -1
  69. package/dist/types/index.d.ts +9 -0
  70. package/package.json +44 -42
  71. package/src/components/Dock/Dock.tsx +41 -0
  72. package/src/components/Dock/constants.ts +62 -0
  73. package/src/components/Dock/index.ts +1 -0
  74. package/src/components/Dock/types.ts +23 -0
  75. package/src/components/Form/Checkbox/constants.ts +9 -8
  76. package/src/components/Form/DatetimeInput/DatetimeInput.tsx +2 -2
  77. package/src/components/Form/DatetimeInput/constants.ts +0 -53
  78. package/src/components/Form/DatetimeInput/types.ts +2 -2
  79. package/src/components/Form/Input/Input.tsx +71 -10
  80. package/src/components/Form/Input/constants.ts +78 -5
  81. package/src/components/Form/Input/types.ts +12 -4
  82. package/src/components/Form/MultiSelect/MultiSelect.tsx +3 -1
  83. package/src/components/Form/MultiSelect/constants.ts +8 -49
  84. package/src/components/Form/MultiSelect/types.ts +2 -2
  85. package/src/components/Form/Radio/types.ts +4 -1
  86. package/src/components/Form/Range/types.ts +4 -1
  87. package/src/components/Form/Select/Select.tsx +71 -10
  88. package/src/components/Form/Select/constants.ts +22 -12
  89. package/src/components/Form/Select/types.ts +11 -1
  90. package/src/components/Form/Switch/types.ts +4 -1
  91. package/src/components/Form/TagsInput/TagsInput.tsx +7 -2
  92. package/src/components/Form/TagsInput/constants.ts +15 -48
  93. package/src/components/Form/TagsInput/types.ts +3 -1
  94. package/src/components/Form/TextField/types.ts +1 -0
  95. package/src/components/Form/Textarea/Textarea.tsx +29 -3
  96. package/src/components/Form/Textarea/constants.ts +2 -15
  97. package/src/components/Form/Textarea/types.ts +9 -2
  98. package/src/components/Form/Validator/Validator.tsx +27 -0
  99. package/src/components/Form/Validator/constants.ts +18 -0
  100. package/src/components/Form/Validator/index.ts +1 -0
  101. package/src/components/Form/Validator/types.ts +30 -0
  102. package/src/components/Form/components/Fieldset/types.ts +1 -1
  103. package/src/components/Form/index.ts +1 -0
  104. package/src/components/Indicator/Indicator.tsx +46 -0
  105. package/src/components/Indicator/constants.ts +26 -0
  106. package/src/components/Indicator/index.ts +1 -0
  107. package/src/components/Indicator/types.ts +34 -0
  108. package/src/components/Join/Join.tsx +28 -0
  109. package/src/components/Join/constants.ts +5 -0
  110. package/src/components/Join/index.ts +1 -0
  111. package/src/components/Join/types.ts +29 -0
  112. package/src/components/Kbd/Kbd.tsx +7 -0
  113. package/src/components/Kbd/constants.ts +40 -0
  114. package/src/components/Kbd/index.ts +1 -0
  115. package/src/components/Kbd/types.ts +4 -0
  116. package/src/components/List/List.tsx +35 -0
  117. package/src/components/List/constants.ts +14 -0
  118. package/src/components/List/index.ts +1 -0
  119. package/src/components/List/types.ts +12 -0
  120. package/src/components/Resizable/Resizable.tsx +36 -0
  121. package/src/components/Resizable/constants.ts +22 -0
  122. package/src/components/Resizable/index.ts +1 -0
  123. package/src/components/Resizable/types.ts +13 -0
  124. package/src/components/Stack/Stack.tsx +11 -0
  125. package/src/components/Stack/constants.ts +12 -0
  126. package/src/components/Stack/index.ts +1 -0
  127. package/src/components/Stack/types.ts +5 -0
  128. package/src/components/Stat/Stat.tsx +55 -0
  129. package/src/components/Stat/constants.ts +33 -0
  130. package/src/components/Stat/index.ts +1 -0
  131. package/src/components/Stat/types.ts +31 -0
  132. package/src/components/Status/Status.tsx +7 -0
  133. package/src/components/Status/constants.ts +31 -0
  134. package/src/components/Status/index.ts +1 -0
  135. package/src/components/Status/types.ts +5 -0
  136. package/src/components/Text/types.ts +1 -1
  137. package/src/index.ts +9 -0
@@ -35,11 +35,6 @@ export const getInputClasses = cva("input rounded-md transition-all duration-100
35
35
  size: undefined,
36
36
  className: "min-h-fit h-10",
37
37
  },
38
- {
39
- variant: undefined,
40
- outline: true,
41
- className: "border-neutral-content",
42
- },
43
38
  {
44
39
  variant: "default",
45
40
  outline: true,
@@ -47,3 +42,81 @@ export const getInputClasses = cva("input rounded-md transition-all duration-100
47
42
  },
48
43
  ],
49
44
  });
45
+
46
+ export const getFloatingLabelClasses = cva("floating-label");
47
+
48
+ export const getInputLabelClasses = cva("", {
49
+ variants: {
50
+ floating: {
51
+ true: "",
52
+ false: "label",
53
+ },
54
+ },
55
+ compoundVariants: [
56
+ {
57
+ floating: undefined,
58
+ className: "label",
59
+ },
60
+ ],
61
+ });
62
+
63
+ export const getInputCommonClasses = cva(
64
+ `border border-base-content/20 shadow-2xs shadow-base-content/20 h-10 flex items-center justify-between w-fit px-2 rounded-md transition-all gap-1
65
+ [&:has(input:focus)]:duration-100 [&:has(input:focus)]:outline [&:has(input:focus)]:outline-2 [&:has(input:focus)]:outline-offset-2
66
+ [&:has(input:focus-within)]:duration-100 [&:has(input:focus-within)]:outline [&:has(input:focus-within)]:outline-2 [&:has(input:focus-within)]:outline-offset-2
67
+ `,
68
+ {
69
+ variants: {
70
+ variant: {
71
+ default:
72
+ "[&:has(input:focus)]:border-[currentColor] [&:has(input:focus-within)]:border-[currentColor] [&:has(input:focus)]:outline-ghost [&:has(input:focus-within)]:outline-ghost",
73
+ accent:
74
+ "border border-accent shadow-accent [&:has(input:focus)]:outline-accent [&:has(input:focus-within)]:outline-accent",
75
+ error:
76
+ "border border-error shadow-error [&:has(input:focus)]:outline-error [&:has(input:focus-within)]:outline-error",
77
+ ghost:
78
+ "border-0 shadow-none [&:has(input:focus)]:outline-ghost [&:has(input:focus-within)]:outline-ghost",
79
+ info: "border border-info shadow-info [&:has(input:focus)]:outline-info [&:has(input:focus-within)]:outline-info",
80
+ primary:
81
+ "border border-primary shadow-primary [&:has(input:focus)]:outline-primary [&:has(input:focus-within)]:outline-primary",
82
+ secondary:
83
+ "border border-secondary shadow-secondary [&:has(input:focus)]:outline-secondary [&:has(input:focus-within)]:outline-secondary",
84
+ success:
85
+ "border border-success shadow-success [&:has(input:focus)]:outline-success [&:has(input:focus-within)]:outline-success",
86
+ warning:
87
+ "border border-warning shadow-warning [&:has(input:focus)]:outline-warning [&:has(input:focus-within)]:outline-warning",
88
+ },
89
+ outline: {
90
+ true: "border",
91
+ },
92
+ disabled: {
93
+ true: "border border-base-200 shadow-none bg-base-200",
94
+ },
95
+ wide: {
96
+ true: "w-full",
97
+ },
98
+ size: {
99
+ xs: "h-6 leading-relaxed text-xs px-2",
100
+ sm: "h-8 leading-8 text-sm px-2",
101
+ md: "h-12 leading-loose text-sm px-2",
102
+ lg: "h-16 leading-loose text-lg px-3",
103
+ },
104
+ },
105
+ compoundVariants: [
106
+ {
107
+ size: undefined,
108
+ className: "min-h-fit h-10 text-sm",
109
+ },
110
+ {
111
+ variant: undefined,
112
+ outline: true,
113
+ className: "border-base-content/20",
114
+ },
115
+ {
116
+ variant: undefined,
117
+ className:
118
+ "[&:has(input:focus)]:border-base-content [&:has(input:focus-within)]:border-base-content",
119
+ },
120
+ ],
121
+ }
122
+ );
@@ -1,5 +1,13 @@
1
- import { type VariantProps } from "../../../libs";
2
- import { getInputClasses } from "./constants";
1
+ import type { ReactNode } from "react";
2
+ import type { VariantProps } from "../../../libs";
3
+ import { getInputClasses, getInputLabelClasses } from "./constants";
3
4
 
4
- export type InputProps = Omit<React.HTMLProps<HTMLInputElement>, "size" | "ref"> &
5
- Omit<VariantProps<typeof getInputClasses>, "type">;
5
+ export type InputProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "ref"> &
6
+ Omit<VariantProps<typeof getInputClasses>, "type"> & {
7
+ label?: ReactNode;
8
+ labelPosition?: "start" | "end" | "floating";
9
+ };
10
+
11
+ export type InputLabelProps = VariantProps<typeof getInputLabelClasses> & {
12
+ children: ReactNode;
13
+ };
@@ -16,6 +16,7 @@ import type {
16
16
  import { cn } from "../../../utilities";
17
17
  import { Badge } from "../../Badge";
18
18
  import { Command } from "../../Command";
19
+ import { getInputCommonClasses } from "../Input/constants";
19
20
  import {
20
21
  getMultiSelectClasses,
21
22
  getMultiSelectInputClasses,
@@ -207,7 +208,8 @@ export const MultiSelectTrigger = ({
207
208
  return (
208
209
  <div
209
210
  className={cn(
210
- getMultiSelectTriggerClasses({ size, wide, outline, variant, disabled }),
211
+ getInputCommonClasses({ outline, disabled, size, variant, wide }),
212
+ getMultiSelectTriggerClasses(),
211
213
  className
212
214
  )}
213
215
  {...props}
@@ -2,54 +2,7 @@ import { cva } from "../../../libs";
2
2
 
3
3
  export const getMultiSelectClasses = cva("overflow-visible bg-transparent flex flex-col h-fit");
4
4
 
5
- export const getMultiSelectTriggerClasses = cva(
6
- "flex items-center flex-wrap gap-1 h-fit w-fit px-1 py-2 rounded-md transition-all overflow-hidden",
7
- {
8
- variants: {
9
- variant: {
10
- default: "border-0",
11
- accent: "border border-accent",
12
- error: "border border-error",
13
- info: "border border-info",
14
- primary: "border border-primary",
15
- secondary: "border border-secondary",
16
- success: "border border-success",
17
- warning: "border border-warning",
18
- },
19
- outline: {
20
- true: "border",
21
- },
22
- disabled: {
23
- true: "border-base-300",
24
- },
25
- wide: {
26
- true: "w-full",
27
- },
28
- size: {
29
- xs: "min-h-6 leading-relaxed px-2 py-1 text-xs",
30
- sm: "min-h-8 leading-8 px-3 py-1.5 text-sm",
31
- md: "min-h-12 leading-loose px-4 text-sm",
32
- lg: "min-h-16 leading-loose px-6 text-lg",
33
- },
34
- },
35
- compoundVariants: [
36
- {
37
- size: undefined,
38
- className: "min-h-10 px-4",
39
- },
40
- {
41
- variant: undefined,
42
- outline: true,
43
- className: "border-neutral-content",
44
- },
45
- {
46
- variant: "default",
47
- outline: true,
48
- className: "border-base-content",
49
- },
50
- ],
51
- }
52
- );
5
+ export const getMultiSelectTriggerClasses = cva("flex-wrap h-fit w-fit py-2 overflow-hidden");
53
6
 
54
7
  export const getMultiSelectItemClasses = cva(
55
8
  "cursor-pointer transition-colors flex justify-between aria-selected:bg-base-300 aria-selected:text-base-content rounded-xs py-1.5 px-2 text-sm outline-hidden",
@@ -106,10 +59,16 @@ export const getMultiSelectTagClasses = cva(
106
59
  lg: "px-2 [&>span]:max-w-32",
107
60
  },
108
61
  },
62
+ compoundVariants: [
63
+ {
64
+ size: undefined,
65
+ className: "max-h-5",
66
+ },
67
+ ],
109
68
  }
110
69
  );
111
70
 
112
- export const getMultiSelectInputClasses = cva("bg-transparent outline-hidden flex-1", {
71
+ export const getMultiSelectInputClasses = cva("bg-transparent outline-hidden flex-1 my-px", {
113
72
  variants: {
114
73
  size: {
115
74
  xs: "text-xs",
@@ -1,11 +1,11 @@
1
1
  import { ComponentPropsWithoutRef, HTMLAttributes } from "react";
2
2
  import { VariantProps } from "../../../libs";
3
3
  import { Command } from "../../Command";
4
+ import { getInputCommonClasses } from "../Input/constants";
4
5
  import {
5
6
  getMultiSelectInputClasses,
6
7
  getMultiSelectItemClasses,
7
8
  getMultiSelectListClasses,
8
- getMultiSelectTriggerClasses,
9
9
  } from "./constants";
10
10
 
11
11
  export type Item = {
@@ -34,7 +34,7 @@ export type MultiSelectContextProps = {
34
34
  };
35
35
 
36
36
  export type MultiSelectTriggerProps = HTMLAttributes<HTMLDivElement> &
37
- VariantProps<typeof getMultiSelectTriggerClasses>;
37
+ VariantProps<typeof getInputCommonClasses>;
38
38
 
39
39
  export type MultiSelectInputProps = Omit<ComponentPropsWithoutRef<typeof Command.Input>, "size"> &
40
40
  VariantProps<typeof getMultiSelectInputClasses>;
@@ -1,5 +1,8 @@
1
1
  import { type VariantProps } from "../../../libs";
2
2
  import { getRadioClasses } from "./constants";
3
3
 
4
- export type RadioProps = Omit<React.HTMLProps<HTMLInputElement>, "size" | "ref" | "type"> &
4
+ export type RadioProps = Omit<
5
+ React.InputHTMLAttributes<HTMLInputElement>,
6
+ "size" | "ref" | "type"
7
+ > &
5
8
  VariantProps<typeof getRadioClasses>;
@@ -1,5 +1,8 @@
1
1
  import { type VariantProps } from "../../../libs";
2
2
  import { getRangeClasses } from "./constants";
3
3
 
4
- export type RangeProps = Omit<React.HTMLProps<HTMLInputElement>, "size" | "ref" | "type"> &
4
+ export type RangeProps = Omit<
5
+ React.InputHTMLAttributes<HTMLInputElement>,
6
+ "size" | "ref" | "type"
7
+ > &
5
8
  VariantProps<typeof getRangeClasses>;
@@ -2,10 +2,18 @@
2
2
 
3
3
  import * as React from "react";
4
4
  import * as SelectPrimitive from "@radix-ui/react-select";
5
+ import { Slot } from "@radix-ui/react-slot";
5
6
  import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react";
6
- import type { SelectContentProps, SelectItemProps, SelectTriggerProps } from "./types";
7
+ import type {
8
+ LabelForSelectProps,
9
+ SelectContentProps,
10
+ SelectItemProps,
11
+ SelectTriggerProps,
12
+ } from "./types";
7
13
  import { cn } from "../../../utilities";
8
14
  import {
15
+ getFloatingLabelClasses,
16
+ getLabelForSelectClasses,
9
17
  getSelectContentClasses,
10
18
  getSelectItemClasses,
11
19
  getSelectLabelClasses,
@@ -18,18 +26,71 @@ const Select = (props: React.ComponentPropsWithoutRef<typeof SelectPrimitive.Roo
18
26
  <SelectPrimitive.Root {...props} />
19
27
  );
20
28
 
29
+ const LabelForSelect = ({ children, className, floating, ...props }: LabelForSelectProps) => {
30
+ const SlotChild = ["string", "number", "boolean", "undefined"].includes(typeof children) ? (
31
+ <span>{children}</span>
32
+ ) : (
33
+ children
34
+ );
35
+
36
+ return (
37
+ <Slot className={cn(getLabelForSelectClasses({ floating }), className)} {...props}>
38
+ {SlotChild}
39
+ </Slot>
40
+ );
41
+ };
42
+
21
43
  const SelectTrigger = React.forwardRef<
22
44
  React.ElementRef<typeof SelectPrimitive.Trigger>,
23
45
  SelectTriggerProps
24
- >(({ className, children, size, variant, outline, ...props }, ref) => (
25
- <SelectPrimitive.Trigger
26
- ref={ref}
27
- className={cn(getSelectTriggerClasses({ size, variant, outline }), className)}
28
- {...props}
29
- >
30
- {children}
31
- </SelectPrimitive.Trigger>
32
- ));
46
+ >(
47
+ (
48
+ { id, label, labelPosition = "start", className, children, size, variant, outline, ...props },
49
+ ref
50
+ ) => {
51
+ if (label) {
52
+ if (labelPosition === "floating") {
53
+ return (
54
+ <label htmlFor={id} className={getFloatingLabelClasses()}>
55
+ <LabelForSelect floating>{label}</LabelForSelect>
56
+ <SelectPrimitive.Trigger
57
+ id={id}
58
+ ref={ref}
59
+ className={cn(getSelectTriggerClasses({ size, variant, outline }), className)}
60
+ {...props}
61
+ >
62
+ {children}
63
+ </SelectPrimitive.Trigger>
64
+ </label>
65
+ );
66
+ }
67
+
68
+ return (
69
+ <label
70
+ htmlFor={id}
71
+ className={cn(getSelectTriggerClasses({ size, variant, outline }), className)}
72
+ >
73
+ {labelPosition === "start" && <LabelForSelect>{label}</LabelForSelect>}
74
+ <SelectPrimitive.Trigger id={id} ref={ref} {...props}>
75
+ {children}
76
+ </SelectPrimitive.Trigger>
77
+ {labelPosition === "end" && <LabelForSelect className="me-0!">{label}</LabelForSelect>}
78
+ </label>
79
+ );
80
+ }
81
+
82
+ return (
83
+ <SelectPrimitive.Trigger
84
+ id={id}
85
+ ref={ref}
86
+ className={cn(getSelectTriggerClasses({ size, variant, outline }), className)}
87
+ {...props}
88
+ >
89
+ {children}
90
+ </SelectPrimitive.Trigger>
91
+ );
92
+ }
93
+ );
33
94
  SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
34
95
 
35
96
  const SelectScrollUpButton = React.forwardRef<
@@ -5,7 +5,8 @@ export const getSelectTriggerClasses = cva(
5
5
  {
6
6
  variants: {
7
7
  variant: {
8
- default: "bg-transparent",
8
+ default:
9
+ "border border-base-content/20 [&:has(input:focus)]:border-[currentColor] [&:has(input:focus-within)]:border-[currentColor] [&:has(input:focus)]:outline-ghost [&:has(input:focus-within)]:outline-ghost",
9
10
  primary: "select-primary",
10
11
  secondary: "select-secondary",
11
12
  accent: "select-accent",
@@ -13,10 +14,10 @@ export const getSelectTriggerClasses = cva(
13
14
  warning: "select-warning",
14
15
  info: "select-info",
15
16
  error: "select-error",
17
+ ghost: "select-ghost bg-transparent",
16
18
  },
17
19
  outline: {
18
20
  true: "border border-input",
19
- false: "select-ghost",
20
21
  },
21
22
  size: {
22
23
  xs: "select-xs",
@@ -30,19 +31,10 @@ export const getSelectTriggerClasses = cva(
30
31
  size: undefined,
31
32
  className: "min-h-fit h-10",
32
33
  },
33
- {
34
- outline: undefined,
35
- className: "select-ghost",
36
- },
37
34
  {
38
35
  variant: undefined,
39
36
  outline: true,
40
- className: "border-neutral-content",
41
- },
42
- {
43
- variant: "default",
44
- outline: true,
45
- className: "border-base-content",
37
+ className: "border-base-content/20",
46
38
  },
47
39
  ],
48
40
  }
@@ -61,6 +53,7 @@ export const getSelectItemClasses = cva(
61
53
  warning: "focus:bg-warning focus:text-warning-content",
62
54
  info: "focus:bg-info focus:text-info-content",
63
55
  error: "focus:bg-error focus:text-error-content",
56
+ ghost: "",
64
57
  },
65
58
  },
66
59
  }
@@ -103,3 +96,20 @@ export const getSelectViewportClasses = cva("p-1", {
103
96
  },
104
97
  },
105
98
  });
99
+
100
+ export const getFloatingLabelClasses = cva("floating-label");
101
+
102
+ export const getLabelForSelectClasses = cva("", {
103
+ variants: {
104
+ floating: {
105
+ true: "",
106
+ false: "label",
107
+ },
108
+ },
109
+ compoundVariants: [
110
+ {
111
+ floating: undefined,
112
+ className: "label",
113
+ },
114
+ ],
115
+ });
@@ -1,13 +1,18 @@
1
+ import { ReactNode } from "react";
1
2
  import * as SelectPrimitive from "@radix-ui/react-select";
2
3
  import { type VariantProps } from "../../../libs";
3
4
  import {
5
+ getLabelForSelectClasses,
4
6
  getSelectContentClasses,
5
7
  getSelectTriggerClasses,
6
8
  getSelectValueClasses,
7
9
  } from "./constants";
8
10
 
9
11
  export type SelectTriggerProps = React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger> &
10
- VariantProps<typeof getSelectTriggerClasses>;
12
+ VariantProps<typeof getSelectTriggerClasses> & {
13
+ label?: ReactNode;
14
+ labelPosition?: "start" | "end" | "floating";
15
+ };
11
16
 
12
17
  export type SelectItemProps = React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item> &
13
18
  VariantProps<typeof getSelectTriggerClasses>;
@@ -17,3 +22,8 @@ export type SelectContentProps = React.ComponentPropsWithoutRef<typeof SelectPri
17
22
 
18
23
  export type SelectValueProps = React.ComponentPropsWithoutRef<typeof SelectPrimitive.Value> &
19
24
  VariantProps<typeof getSelectValueClasses>;
25
+
26
+ export type LabelForSelectProps = VariantProps<typeof getLabelForSelectClasses> & {
27
+ children: ReactNode;
28
+ className?: string;
29
+ };
@@ -1,5 +1,8 @@
1
1
  import { type VariantProps } from "../../../libs";
2
2
  import { getSwitchClasses } from "./constants";
3
3
 
4
- export type SwitchProps = Omit<React.HTMLProps<HTMLInputElement>, "size" | "ref" | "type"> &
4
+ export type SwitchProps = Omit<
5
+ React.InputHTMLAttributes<HTMLInputElement>,
6
+ "size" | "ref" | "type"
7
+ > &
5
8
  VariantProps<typeof getSwitchClasses>;
@@ -7,6 +7,7 @@ import type { TagsInputProps } from "./types";
7
7
  import { cn } from "../../../utilities";
8
8
  import { Badge } from "../../Badge";
9
9
  import { Input } from "../Input";
10
+ import { getInputCommonClasses } from "../Input/constants";
10
11
  import {
11
12
  FORMATTING_REGEX,
12
13
  getTagClasses,
@@ -225,7 +226,11 @@ export const TagsInput = forwardRef<HTMLDivElement, TagsInputProps>(
225
226
  {...props}
226
227
  ref={ref}
227
228
  dir={dir}
228
- className={cn(getTagsClasses({ size, wide, outline, variant, disabled }), className)}
229
+ className={cn(
230
+ getInputCommonClasses({ outline, disabled, variant, wide }),
231
+ getTagsClasses({ size }),
232
+ className
233
+ )}
229
234
  >
230
235
  {tags.map((tag, index) => (
231
236
  <Badge
@@ -259,7 +264,7 @@ export const TagsInput = forwardRef<HTMLDivElement, TagsInputProps>(
259
264
  tabIndex={0}
260
265
  onSelect={handleSelect}
261
266
  aria-label={ariaLabel}
262
- disabled={disableInput}
267
+ disabled={disabled || disableInput}
263
268
  onKeyDown={handleKeyDown}
264
269
  onPaste={handlePaste}
265
270
  value={inputValue}
@@ -4,55 +4,22 @@ export const SPLITTER_REGEX = /[\n#?=&\t,./-]+/; // used for identifying the spl
4
4
 
5
5
  export const FORMATTING_REGEX = /^[^a-zA-Z0-9]*|[^a-zA-Z0-9]*$/g; // used for formatting the pasted element for the correct value format to be added
6
6
 
7
- export const getTagsClasses = cva(
8
- "flex items-center flex-wrap gap-1 h-fit px-1 py-2 rounded-md transition-all overflow-hidden",
9
- {
10
- variants: {
11
- variant: {
12
- default: "border-0",
13
- accent: "border border-accent",
14
- error: "border border-error",
15
- ghost: "border border-ghost",
16
- info: "border border-info",
17
- primary: "border border-primary",
18
- secondary: "border border-secondary",
19
- success: "border border-success",
20
- warning: "border border-warning",
21
- },
22
- outline: {
23
- true: "border",
24
- },
25
- disabled: {
26
- true: "border-base-300",
27
- },
28
- wide: {
29
- true: "w-full",
30
- },
31
- size: {
32
- xs: "min-h-6 leading-relaxed px-2 py-1 text-xs",
33
- sm: "min-h-8 leading-8 px-3 py-1.5 text-sm",
34
- md: "min-h-12 leading-loose px-4 text-sm",
35
- lg: "min-h-16 leading-loose px-5 text-lg",
36
- },
7
+ export const getTagsClasses = cva("flex-wrap h-fit py-2 overflow-hidden", {
8
+ variants: {
9
+ size: {
10
+ xs: "min-h-6 leading-relaxed px-2 py-1 text-xs",
11
+ sm: "min-h-8 leading-8 px-3 py-1.5 text-sm",
12
+ md: "min-h-12 leading-loose px-4 text-sm",
13
+ lg: "min-h-16 leading-loose px-5 text-lg",
37
14
  },
38
- compoundVariants: [
39
- {
40
- size: undefined,
41
- className: "min-h-10 px-4",
42
- },
43
- {
44
- variant: undefined,
45
- outline: true,
46
- className: "border-neutral-content",
47
- },
48
- {
49
- variant: "default",
50
- outline: true,
51
- className: "border-base-content",
52
- },
53
- ],
54
- }
55
- );
15
+ },
16
+ compoundVariants: [
17
+ {
18
+ size: undefined,
19
+ className: "min-h-10 px-4",
20
+ },
21
+ ],
22
+ });
56
23
 
57
24
  export const getTagClasses = cva(
58
25
  "relative flex items-center gap-1 [&>span]:truncate [&>span]:max-w-24 aria-disabled:opacity-50 aria-disabled:cursor-not-allowed focus-visible:outline-hidden",
@@ -1,4 +1,5 @@
1
1
  import { type VariantProps } from "../../../libs";
2
+ import { getInputCommonClasses } from "../Input/constants";
2
3
  import { getTagsClasses } from "./constants";
3
4
 
4
5
  export type TagsInputProps = React.HTMLAttributes<HTMLDivElement> & {
@@ -7,4 +8,5 @@ export type TagsInputProps = React.HTMLAttributes<HTMLDivElement> & {
7
8
  placeholder?: string;
8
9
  maxItems?: number;
9
10
  minItems?: number;
10
- } & VariantProps<typeof getTagsClasses>;
11
+ } & VariantProps<typeof getTagsClasses> &
12
+ VariantProps<typeof getInputCommonClasses>;
@@ -3,5 +3,6 @@ import { type InputProps } from "../Input/types";
3
3
 
4
4
  export type TextFieldProps = InputProps & {
5
5
  info?: ReactNode;
6
+ label?: ReactNode;
6
7
  error?: string | string[] | null;
7
8
  };
@@ -1,12 +1,38 @@
1
1
  import * as React from "react";
2
+ import { Slot } from "@radix-ui/react-slot";
3
+ import type { TextareaLabelProps, TextareaProps } from "./types";
2
4
  import { cn } from "../../../utilities";
3
- import { getTextareaClasses } from "./constants";
4
- import { type TextareaProps } from "./types";
5
+ import { getFloatingLabelClasses, getTextareaClasses } from "./constants";
6
+
7
+ const TextareaLabel = ({ children, ...props }: TextareaLabelProps) => {
8
+ const SlotChild = ["string", "number", "boolean", "undefined"].includes(typeof children) ? (
9
+ <span>{children}</span>
10
+ ) : (
11
+ children
12
+ );
13
+
14
+ return <Slot {...props}>{SlotChild}</Slot>;
15
+ };
5
16
 
6
17
  const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
7
- ({ size, variant, wide, outline, className, ...props }, ref) => {
18
+ ({ id, label, size, variant, wide, outline, className, ...props }, ref) => {
19
+ if (label) {
20
+ return (
21
+ <label htmlFor={id} className={getFloatingLabelClasses()}>
22
+ <TextareaLabel>{label}</TextareaLabel>
23
+ <textarea
24
+ id={id}
25
+ ref={ref}
26
+ className={cn(getTextareaClasses({ size, wide, variant, outline }), className)}
27
+ {...props}
28
+ />
29
+ </label>
30
+ );
31
+ }
32
+
8
33
  return (
9
34
  <textarea
35
+ id={id}
10
36
  ref={ref}
11
37
  className={cn(getTextareaClasses({ size, wide, variant, outline }), className)}
12
38
  {...props}
@@ -31,20 +31,7 @@ export const getTextareaClasses = cva("textarea rounded-md transition-all durati
31
31
  size: undefined,
32
32
  className: "min-h-fit h-10",
33
33
  },
34
- {
35
- variant: undefined,
36
- outline: undefined,
37
- className: "textarea-ghost",
38
- },
39
- {
40
- variant: undefined,
41
- outline: true,
42
- className: "border-neutral-content",
43
- },
44
- {
45
- variant: "default",
46
- outline: true,
47
- className: "border-base-content",
48
- },
49
34
  ],
50
35
  });
36
+
37
+ export const getFloatingLabelClasses = cva("floating-label");
@@ -1,8 +1,15 @@
1
- import { type VariantProps } from "../../../libs";
1
+ import type { ReactNode } from "react";
2
+ import type { VariantProps } from "../../../libs";
2
3
  import { getTextareaClasses } from "./constants";
3
4
 
4
5
  export type TextareaProps = Omit<
5
6
  React.TextareaHTMLAttributes<HTMLTextAreaElement>,
6
7
  "size" | "ref"
7
8
  > &
8
- VariantProps<typeof getTextareaClasses>;
9
+ VariantProps<typeof getTextareaClasses> & {
10
+ label?: ReactNode;
11
+ };
12
+
13
+ export type TextareaLabelProps = {
14
+ children: ReactNode;
15
+ };