@modul/mbui 0.0.13-beta-pv-53127-63b6a630 → 0.0.13-beta-pv-53036-3ecb0556

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 (136) hide show
  1. package/dist/{Info/Info.d.ts → Alert/Alert.d.ts} +4 -4
  2. package/dist/{Info/Info.js → Alert/Alert.js} +7 -7
  3. package/dist/Alert/Alert.js.map +1 -0
  4. package/dist/Alert/index.d.ts +1 -0
  5. package/dist/Alert/index.js +6 -0
  6. package/dist/Alert/index.js.map +1 -0
  7. package/dist/AlertDialog/AlertDialog.d.ts +20 -0
  8. package/dist/AlertDialog/AlertDialog.js +42 -0
  9. package/dist/AlertDialog/AlertDialog.js.map +1 -0
  10. package/dist/AlertDialog/index.d.ts +1 -0
  11. package/dist/AlertDialog/index.js +16 -0
  12. package/dist/AlertDialog/index.js.map +1 -0
  13. package/dist/Button/Button.d.ts +1 -1
  14. package/dist/Calendar/Calendar.d.ts +8 -0
  15. package/dist/Calendar/Calendar.js +45 -0
  16. package/dist/Calendar/Calendar.js.map +1 -0
  17. package/dist/Calendar/index.d.ts +1 -0
  18. package/dist/Calendar/index.js +6 -0
  19. package/dist/Calendar/index.js.map +1 -0
  20. package/dist/Chip/Chip.d.ts +1 -1
  21. package/dist/DatePicker/DatePicker.d.ts +9 -0
  22. package/dist/DatePicker/DatePicker.js +23 -0
  23. package/dist/DatePicker/DatePicker.js.map +1 -0
  24. package/dist/DatePicker/index.d.ts +1 -0
  25. package/dist/DatePicker/index.js +6 -0
  26. package/dist/DatePicker/index.js.map +1 -0
  27. package/dist/Drawer/Drawer.js +1 -1
  28. package/dist/Drawer/Drawer.js.map +1 -1
  29. package/dist/Form/Form.d.ts +23 -0
  30. package/dist/Form/Form.js +73 -0
  31. package/dist/Form/Form.js.map +1 -0
  32. package/dist/Form/index.d.ts +1 -0
  33. package/dist/Form/index.js +13 -0
  34. package/dist/Form/index.js.map +1 -0
  35. package/dist/Input/Input.js +1 -1
  36. package/dist/Input/Input.js.map +1 -1
  37. package/dist/Input/InputMask.d.ts +3 -0
  38. package/dist/Input/InputMask.js +12 -0
  39. package/dist/Input/InputMask.js.map +1 -0
  40. package/dist/Input/index.d.ts +1 -0
  41. package/dist/Input/index.js +3 -1
  42. package/dist/Input/index.js.map +1 -1
  43. package/dist/Input-OTP/Input.d.ts +4 -4
  44. package/dist/Label/Label.d.ts +5 -0
  45. package/dist/Label/Label.js +13 -0
  46. package/dist/Label/Label.js.map +1 -0
  47. package/dist/Label/index.d.ts +1 -0
  48. package/dist/Label/index.js +6 -0
  49. package/dist/Label/index.js.map +1 -0
  50. package/dist/Page/Page.js +1 -1
  51. package/dist/Page/Page.js.map +1 -1
  52. package/dist/Select/Select.d.ts +3 -0
  53. package/dist/Select/Select.js +11 -0
  54. package/dist/Select/Select.js.map +1 -0
  55. package/dist/Select/SelectAccountCard.d.ts +5 -0
  56. package/dist/Select/SelectAccountCard.js +77 -0
  57. package/dist/Select/SelectAccountCard.js.map +1 -0
  58. package/dist/Select/SelectAsync.d.ts +8 -0
  59. package/dist/Select/SelectAsync.js +73 -0
  60. package/dist/Select/SelectAsync.js.map +1 -0
  61. package/dist/Select/SelectBase.d.ts +6 -0
  62. package/dist/Select/SelectBase.js +72 -0
  63. package/dist/Select/SelectBase.js.map +1 -0
  64. package/dist/Select/index.d.ts +4 -0
  65. package/dist/Select/index.js +12 -0
  66. package/dist/Select/index.js.map +1 -0
  67. package/dist/Switch/Switch.d.ts +4 -0
  68. package/dist/Switch/Switch.js +31 -0
  69. package/dist/Switch/Switch.js.map +1 -0
  70. package/dist/Switch/index.d.ts +1 -0
  71. package/dist/Switch/index.js +6 -0
  72. package/dist/Switch/index.js.map +1 -0
  73. package/dist/Textarea/Textarea.d.ts +5 -0
  74. package/dist/Textarea/Textarea.js +12 -0
  75. package/dist/Textarea/Textarea.js.map +1 -0
  76. package/dist/Textarea/index.d.ts +1 -0
  77. package/dist/Textarea/index.js +6 -0
  78. package/dist/Textarea/index.js.map +1 -0
  79. package/dist/index.d.ts +27 -20
  80. package/dist/index.js +41 -10
  81. package/dist/index.js.map +1 -1
  82. package/package.json +11 -4
  83. package/src/{Info/Info.tsx → Alert/Alert.tsx} +6 -6
  84. package/src/Alert/index.ts +1 -0
  85. package/src/AlertDialog/AlertDialog.tsx +138 -0
  86. package/src/AlertDialog/index.ts +13 -0
  87. package/src/Calendar/Calendar.tsx +61 -0
  88. package/src/Calendar/index.ts +1 -0
  89. package/src/DatePicker/DatePicker.tsx +38 -0
  90. package/src/DatePicker/index.ts +1 -0
  91. package/src/Drawer/Drawer.tsx +2 -2
  92. package/src/Form/Form.tsx +152 -0
  93. package/src/Form/index.ts +1 -0
  94. package/src/Input/Input.tsx +1 -1
  95. package/src/Input/InputMask.tsx +15 -0
  96. package/src/Input/index.ts +2 -1
  97. package/src/Label/Label.tsx +1 -1
  98. package/src/Page/Page.tsx +1 -1
  99. package/src/Select/Select.tsx +8 -0
  100. package/src/Select/SelectAccountCard.tsx +175 -0
  101. package/src/Select/SelectAsync.tsx +183 -0
  102. package/src/Select/SelectBase.tsx +181 -0
  103. package/src/Select/index.ts +4 -0
  104. package/src/Switch/Switch.tsx +47 -0
  105. package/src/Switch/index.ts +1 -0
  106. package/src/Textarea/Textarea.tsx +24 -0
  107. package/src/Textarea/index.ts +1 -0
  108. package/src/assets/css/global.css +22 -9
  109. package/src/index.ts +67 -41
  110. package/dist/Base/Input/Base.d.ts +0 -4
  111. package/dist/Base/Input/Base.js +0 -20
  112. package/dist/Base/Input/Base.js.map +0 -1
  113. package/dist/Base/Input/Input.d.ts +0 -4
  114. package/dist/Base/Input/Input.js +0 -18
  115. package/dist/Base/Input/Input.js.map +0 -1
  116. package/dist/Base/Input/index.d.ts +0 -2
  117. package/dist/Base/Input/index.js +0 -7
  118. package/dist/Base/Input/index.js.map +0 -1
  119. package/dist/Base/Input/types.d.ts +0 -9
  120. package/dist/Base/Input/types.js +0 -3
  121. package/dist/Base/Input/types.js.map +0 -1
  122. package/dist/Info/Info.js.map +0 -1
  123. package/dist/Info/index.d.ts +0 -1
  124. package/dist/Info/index.js +0 -6
  125. package/dist/Info/index.js.map +0 -1
  126. package/dist/Progress/Progress.d.ts +0 -4
  127. package/dist/Progress/Progress.js +0 -12
  128. package/dist/Progress/Progress.js.map +0 -1
  129. package/dist/Progress/index.d.ts +0 -1
  130. package/dist/Progress/index.js +0 -6
  131. package/dist/Progress/index.js.map +0 -1
  132. package/src/DrawerCompanyList/CompanyList.tsx +0 -63
  133. package/src/DrawerCompanyList/index.ts +0 -1
  134. package/src/Info/index.ts +0 -1
  135. package/src/Progress/Progress.tsx +0 -23
  136. package/src/Progress/index.ts +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modul/mbui",
3
- "version": "0.0.13-beta-pv-53127-63b6a630",
3
+ "version": "0.0.13-beta-pv-53036-3ecb0556",
4
4
  "packageManager": "yarn@3.5.1",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -21,15 +21,17 @@
21
21
  "dist"
22
22
  ],
23
23
  "dependencies": {
24
+ "@hookform/resolvers": "3.9.0",
24
25
  "@radix-ui/react-accordion": "^1.2.0",
26
+ "@radix-ui/react-alert-dialog": "1.1.1",
25
27
  "@radix-ui/react-collapsible": "1.1.0",
26
28
  "@radix-ui/react-dropdown-menu": "2.1.1",
27
29
  "@radix-ui/react-label": "2.1.0",
28
30
  "@radix-ui/react-popover": "^1.1.1",
29
- "@radix-ui/react-progress": "^1.1.0",
30
31
  "@radix-ui/react-select": "2.1.1",
31
32
  "@radix-ui/react-slider": "^1.2.0",
32
33
  "@radix-ui/react-slot": "1.1.0",
34
+ "@radix-ui/react-switch": "1.1.0",
33
35
  "@radix-ui/react-tabs": "^1.1.0",
34
36
  "@radix-ui/react-tooltip": "^1.1.2",
35
37
  "@storybook/addon-storyshots": "latest",
@@ -39,11 +41,15 @@
39
41
  "input-otp": "1.2.4",
40
42
  "lodash": "4.17.5",
41
43
  "react-datepicker": "4.16.0",
42
- "react-imask": "7.1.3",
44
+ "react-day-picker": "^9.0.8",
45
+ "react-hook-form": "7.53.0",
46
+ "react-imask": "7.6.1",
47
+ "react-select": "5.8.0",
43
48
  "tailwind-merge": "^2.3.0",
44
49
  "tailwindcss": "^3.4.4",
45
50
  "tailwindcss-animate": "^1.0.7",
46
- "vaul": "0.9.1"
51
+ "vaul": "0.9.1",
52
+ "zod": "3.23.8"
47
53
  },
48
54
  "devDependencies": {
49
55
  "@babel/core": "^7.9.0",
@@ -54,6 +60,7 @@
54
60
  "@storybook/addon-essentials": "^8.2.8",
55
61
  "@storybook/addon-interactions": "^8.2.8",
56
62
  "@storybook/addon-links": "^8.2.8",
63
+ "@storybook/addon-onboarding": "^8.2.8",
57
64
  "@storybook/addon-webpack5-compiler-babel": "^3.0.3",
58
65
  "@storybook/blocks": "^8.2.8",
59
66
  "@storybook/react": "^8.2.8",
@@ -4,7 +4,7 @@ import { cva, type VariantProps } from 'class-variance-authority'
4
4
  import { cn } from '../@/lib/utils'
5
5
  // import { cn } from "@/lib/utils" порешать с алиасами
6
6
 
7
- const infoVariants = cva('px-[16px] py-[12px] rounded-1 text-[14px]', {
7
+ const alertVariants = cva('px-[16px] py-[12px] rounded-sm text-[14px]', {
8
8
  variants: {
9
9
  variant: {
10
10
  light: 'bg-[--cl-graphite-7]',
@@ -19,13 +19,13 @@ const infoVariants = cva('px-[16px] py-[12px] rounded-1 text-[14px]', {
19
19
  })
20
20
 
21
21
 
22
- export interface IProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof infoVariants> {
22
+ export interface IProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof alertVariants> {
23
23
  }
24
24
 
25
- const Info = React.forwardRef<HTMLDivElement, IProps>(({ className, variant, children, ...props }, ref) => {
25
+ const Alert = React.forwardRef<HTMLDivElement, IProps>(({ className, variant, children, ...props }, ref) => {
26
26
  return (
27
27
  <div
28
- className={cn(infoVariants({ variant, className }))}
28
+ className={cn(alertVariants({ variant, className }))}
29
29
  {...props}
30
30
  >
31
31
  {children}
@@ -33,6 +33,6 @@ const Info = React.forwardRef<HTMLDivElement, IProps>(({ className, variant, chi
33
33
  )
34
34
  })
35
35
 
36
- Info.displayName = 'Info'
36
+ Alert.displayName = 'Alert'
37
37
 
38
- export { Info }
38
+ export { Alert }
@@ -0,0 +1 @@
1
+ export { Alert } from './Alert'
@@ -0,0 +1,138 @@
1
+ import * as React from "react"
2
+ import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"
3
+
4
+ import { cn } from "../@/lib/utils"
5
+ import { buttonVariants } from "../Button"
6
+
7
+ const AlertDialog = AlertDialogPrimitive.Root
8
+
9
+ const AlertDialogTrigger = AlertDialogPrimitive.Trigger
10
+
11
+ const AlertDialogPortal = AlertDialogPrimitive.Portal
12
+
13
+ const AlertDialogOverlay = React.forwardRef<
14
+ React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
15
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
16
+ >(({ className, ...props }, ref) => (
17
+ <AlertDialogPrimitive.Overlay
18
+ className={cn(
19
+ "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
20
+ className
21
+ )}
22
+ {...props}
23
+ ref={ref}
24
+ />
25
+ ))
26
+ AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName
27
+
28
+ const AlertDialogContent = React.forwardRef<
29
+ React.ElementRef<typeof AlertDialogPrimitive.Content>,
30
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
31
+ >(({ className, ...props }, ref) => (
32
+ <AlertDialogPortal>
33
+ <AlertDialogOverlay />
34
+ <AlertDialogPrimitive.Content
35
+ ref={ref}
36
+ className={cn(
37
+ "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-input bg-dialog p-[16px] shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-md",
38
+ className
39
+ )}
40
+ {...props}
41
+ />
42
+ </AlertDialogPortal>
43
+ ))
44
+ AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName
45
+
46
+ const AlertDialogHeader = ({
47
+ className,
48
+ ...props
49
+ }: React.HTMLAttributes<HTMLDivElement>) => (
50
+ <div
51
+ className={cn(
52
+ "flex flex-col space-y-2 text-center sm:text-left",
53
+ className
54
+ )}
55
+ {...props}
56
+ />
57
+ )
58
+ AlertDialogHeader.displayName = "AlertDialogHeader"
59
+
60
+ const AlertDialogFooter = ({
61
+ className,
62
+ ...props
63
+ }: React.HTMLAttributes<HTMLDivElement>) => (
64
+ <div
65
+ className={cn(
66
+ "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
67
+ className
68
+ )}
69
+ {...props}
70
+ />
71
+ )
72
+ AlertDialogFooter.displayName = "AlertDialogFooter"
73
+
74
+ const AlertDialogTitle = React.forwardRef<
75
+ React.ElementRef<typeof AlertDialogPrimitive.Title>,
76
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
77
+ >(({ className, ...props }, ref) => (
78
+ <AlertDialogPrimitive.Title
79
+ ref={ref}
80
+ className={cn("text-lg font-semibold", className)}
81
+ {...props}
82
+ />
83
+ ))
84
+ AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName
85
+
86
+ const AlertDialogDescription = React.forwardRef<
87
+ React.ElementRef<typeof AlertDialogPrimitive.Description>,
88
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
89
+ >(({ className, ...props }, ref) => (
90
+ <AlertDialogPrimitive.Description
91
+ ref={ref}
92
+ className={cn("text-sm text-muted-foreground", className)}
93
+ {...props}
94
+ />
95
+ ))
96
+ AlertDialogDescription.displayName =
97
+ AlertDialogPrimitive.Description.displayName
98
+
99
+ const AlertDialogAction = React.forwardRef<
100
+ React.ElementRef<typeof AlertDialogPrimitive.Action>,
101
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
102
+ >(({ className, ...props }, ref) => (
103
+ <AlertDialogPrimitive.Action
104
+ ref={ref}
105
+ className={cn(buttonVariants({variant: 'primary', size: 'sm'}), className)}
106
+ {...props}
107
+ />
108
+ ))
109
+ AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName
110
+
111
+ const AlertDialogCancel = React.forwardRef<
112
+ React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
113
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
114
+ >(({ className, ...props }, ref) => (
115
+ <AlertDialogPrimitive.Cancel
116
+ ref={ref}
117
+ className={cn(
118
+ buttonVariants({ variant: "outline", size: 'sm' }),
119
+ className
120
+ )}
121
+ {...props}
122
+ />
123
+ ))
124
+ AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName
125
+
126
+ export {
127
+ AlertDialog,
128
+ AlertDialogPortal,
129
+ AlertDialogOverlay,
130
+ AlertDialogTrigger,
131
+ AlertDialogContent,
132
+ AlertDialogHeader,
133
+ AlertDialogFooter,
134
+ AlertDialogTitle,
135
+ AlertDialogDescription,
136
+ AlertDialogAction,
137
+ AlertDialogCancel,
138
+ }
@@ -0,0 +1,13 @@
1
+ export {
2
+ AlertDialog,
3
+ AlertDialogPortal,
4
+ AlertDialogOverlay,
5
+ AlertDialogTrigger,
6
+ AlertDialogContent,
7
+ AlertDialogHeader,
8
+ AlertDialogFooter,
9
+ AlertDialogTitle,
10
+ AlertDialogDescription,
11
+ AlertDialogAction,
12
+ AlertDialogCancel,
13
+ } from './AlertDialog'
@@ -0,0 +1,61 @@
1
+ import * as React from 'react'
2
+ import { DayPicker } from 'react-day-picker'
3
+ import { cn } from '../@/lib/utils'
4
+ import { ru } from 'date-fns/locale'
5
+
6
+ const daySelectedClasses = 'bg-btn-primary text-btn-primary rounded-sm'
7
+ const dayTodayClasses = 'bg-btn-secondary text-btn-secondary rounded-sm'
8
+ const rangeMiddleClasses = 'date-range-middle aria-selected:bg-btn-primary/50 aria-selected:text-white'
9
+ const btnNavClasses =
10
+ 'opacity-50 hover:opacity-100 ring-offset-2 focus-visible:opacity-100 focus-visible:outline-primary border-input border rounded-sm shadow-sm'
11
+
12
+ export type CalendarProps = React.ComponentProps<typeof DayPicker>
13
+ function Calendar({ className, classNames, showOutsideDays = true, ...props }: CalendarProps) {
14
+ return (
15
+ <DayPicker
16
+ locale={ru}
17
+ showOutsideDays={showOutsideDays}
18
+ className={cn('inline-flex', className)}
19
+ classNames={{
20
+ months: 'relative',
21
+ month: 'flex flex-col space-y-[16px] items-center',
22
+ month_grid: 'w-full border-collapse',
23
+ month_caption: 'inline m-x-auto',
24
+ caption_label: 'text-sm font-medium capitalize',
25
+ nav: 'flex justify-between absolute start-0 end-0',
26
+ button_previous: btnNavClasses,
27
+ button_next: btnNavClasses,
28
+ weekdays: 'flex',
29
+ weekday: 'text-light w-[32px] font-normal text-[14px]',
30
+ week: 'flex w-full mt-2',
31
+ day_button: 'w-[32px] h-[32px] p-0',
32
+ day: cn(
33
+ 'aria-selected:opacity-100 text-[14px] leading-[1]',
34
+ props.mode === 'range'
35
+ ? '[&:(.day-range-middle)]:rounded-0 [&:has(>.day-range-end)]:rounded-r-sm [&:has(>.day-range-start)]:rounded-l-sm first:[&:has([aria-selected])]:rounded-l-sm last:[&:has([aria-selected])]:rounded-r-sm'
36
+ : '[&:([aria-selected])]:rounded-sm'
37
+ ),
38
+ range_start: 'day-range-start',
39
+ range_end: 'day-range-end',
40
+ range_middle: rangeMiddleClasses,
41
+ selected: daySelectedClasses,
42
+ today: dayTodayClasses,
43
+ outside:
44
+ 'day-outside opacity-50 aria-selected:bg-primary aria-selected:text-[white] aria-selected:opacity-30',
45
+ disabled: 'text-light opacity-50',
46
+ hidden: 'invisible',
47
+ ...classNames,
48
+ }}
49
+ components={
50
+ {
51
+ // Chevron: () => <Left className="w-4 h-4" />,
52
+ }
53
+ }
54
+ {...props}
55
+ />
56
+ )
57
+ }
58
+
59
+ Calendar.displayName = 'Calendar'
60
+
61
+ export { Calendar }
@@ -0,0 +1 @@
1
+ export { Calendar } from './Calendar'
@@ -0,0 +1,38 @@
1
+ import * as React from 'react'
2
+ import { format } from 'date-fns'
3
+ import { cn } from '../@/lib/utils'
4
+ import { Calendar } from '../Calendar'
5
+ import { Calendar as CalendarIcon } from '../Icon'
6
+ import { Popover } from '../Popover'
7
+ import { ru } from 'date-fns/locale'
8
+
9
+ const trigegrClasses = 'inline-flex items-center border-input px-[12px] border rounded-sm h-[44px] text-left'
10
+
11
+ interface IProps {
12
+ placeholder?: string,
13
+ date: Date,
14
+ classTrigger?: string,
15
+ triggerDisabled: boolean,
16
+ }
17
+
18
+ const DatePicker: React.FC<IProps> = ({placeholder, triggerDisabled, date, classTrigger, ...props}) => {
19
+
20
+ return (
21
+ <Popover>
22
+ <Popover.Trigger asChild>
23
+ <button className={cn(trigegrClasses, {'bg-light text-light':triggerDisabled}, classTrigger)} disabled={triggerDisabled}>
24
+ {date ? <span className='w-[calc(100%-26px)] truncate'>{format(date ,'PPP', {locale: ru})}</span> : <span className='w-[calc(100%-26px)] text-light truncate'>{placeholder}</span>}
25
+ <CalendarIcon width={18} height={18} className="ml-[8px] text-light shrink-0" />
26
+ </button>
27
+ </Popover.Trigger>
28
+ <Popover.Content
29
+ className="bg-page p-0 w-auto"
30
+ align="center"
31
+ >
32
+ <Calendar {...props}/>
33
+ </Popover.Content>
34
+ </Popover>
35
+ )
36
+ }
37
+
38
+ export { DatePicker }
@@ -0,0 +1 @@
1
+ export { DatePicker } from './DatePicker'
@@ -47,8 +47,8 @@ const DrawerContent = React.forwardRef<
47
47
  <DrawerPrimitive.Content
48
48
  ref={ref}
49
49
  className={cn(
50
- `z-50 fixed inset-x-0 flex flex-col bg-page drop-shadow-1 max-h-[94%] sm:container`,
51
- direction === 'top' ? 'top-0 rounded-b-1 ' : 'bottom-0 rounded-t-1',
50
+ `z-50 fixed inset-x-0 flex flex-col bg-page shadow-sm max-h-[94%] sm:container`,
51
+ direction === 'top' ? 'top-0 rounded-b-sm ' : 'bottom-0 rounded-t-sm',
52
52
  className
53
53
  )}
54
54
  {...props}
@@ -0,0 +1,152 @@
1
+ import * as React from 'react'
2
+ import * as LabelPrimitive from '@radix-ui/react-label'
3
+ import { Slot } from '@radix-ui/react-slot'
4
+ import { Controller, ControllerProps, FieldPath, FieldValues, FormProvider, useFormContext } from 'react-hook-form'
5
+
6
+ import { cn } from '../@/lib/utils'
7
+ import { Label } from '../Label'
8
+
9
+ const Form = FormProvider
10
+
11
+ type FormFieldContextValue<
12
+ TFieldValues extends FieldValues = FieldValues,
13
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
14
+ > = {
15
+ name: TName
16
+ }
17
+
18
+ const FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue)
19
+
20
+ const FormField = <
21
+ TFieldValues extends FieldValues = FieldValues,
22
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
23
+ >({
24
+ ...props
25
+ }: ControllerProps<TFieldValues, TName>) => {
26
+ return (
27
+ <FormFieldContext.Provider value={{ name: props.name }}>
28
+ <Controller {...props} />
29
+ </FormFieldContext.Provider>
30
+ )
31
+ }
32
+
33
+ const useFormField = () => {
34
+ const fieldContext = React.useContext(FormFieldContext)
35
+ const itemContext = React.useContext(FormItemContext)
36
+ const { getFieldState, formState } = useFormContext()
37
+
38
+ const fieldState = getFieldState(fieldContext.name, formState)
39
+
40
+ if (!fieldContext) {
41
+ throw new Error('useFormField should be used within <FormField>')
42
+ }
43
+
44
+ const { id } = itemContext
45
+
46
+ return {
47
+ id,
48
+ name: fieldContext.name,
49
+ formItemId: `${id}-form-item`,
50
+ formDescriptionId: `${id}-form-item-description`,
51
+ formMessageId: `${id}-form-item-message`,
52
+ ...fieldState,
53
+ }
54
+ }
55
+
56
+ type FormItemContextValue = {
57
+ id: string
58
+ }
59
+
60
+ const FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue)
61
+
62
+ const FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
63
+ ({ className, ...props }, ref) => {
64
+ const id = React.useId()
65
+
66
+ return (
67
+ <FormItemContext.Provider value={{ id }}>
68
+ <div
69
+ ref={ref}
70
+ className={cn('space-y-2', className)}
71
+ {...props}
72
+ />
73
+ </FormItemContext.Provider>
74
+ )
75
+ }
76
+ )
77
+ FormItem.displayName = 'FormItem'
78
+
79
+ const FormLabel = React.forwardRef<
80
+ React.ElementRef<typeof LabelPrimitive.Root>,
81
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
82
+ >(({ className, ...props }, ref) => {
83
+ const { error, formItemId } = useFormField()
84
+
85
+ return (
86
+ <Label
87
+ ref={ref}
88
+ className={cn(error && 'text-destructive', className)}
89
+ htmlFor={formItemId}
90
+ {...props}
91
+ />
92
+ )
93
+ })
94
+ FormLabel.displayName = 'FormLabel'
95
+
96
+ const FormControl = React.forwardRef<React.ElementRef<typeof Slot>, React.ComponentPropsWithoutRef<typeof Slot>>(
97
+ ({ ...props }, ref) => {
98
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField()
99
+
100
+ return (
101
+ <Slot
102
+ ref={ref}
103
+ id={formItemId}
104
+ aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}
105
+ aria-invalid={!!error}
106
+ {...props}
107
+ />
108
+ )
109
+ }
110
+ )
111
+ FormControl.displayName = 'FormControl'
112
+
113
+ const FormDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
114
+ ({ className, ...props }, ref) => {
115
+ const { formDescriptionId } = useFormField()
116
+
117
+ return (
118
+ <p
119
+ ref={ref}
120
+ id={formDescriptionId}
121
+ className={cn('text-[0.8rem] text-light', className)}
122
+ {...props}
123
+ />
124
+ )
125
+ }
126
+ )
127
+ FormDescription.displayName = 'FormDescription'
128
+
129
+ const FormMessage = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
130
+ ({ className, children, ...props }, ref) => {
131
+ const { error, formMessageId } = useFormField()
132
+ const body = error ? String(error?.message) : children
133
+
134
+ if (!body) {
135
+ return null
136
+ }
137
+
138
+ return (
139
+ <p
140
+ ref={ref}
141
+ id={formMessageId}
142
+ className={cn('text-[0.8rem] font-medium text-destructive', className)}
143
+ {...props}
144
+ >
145
+ {body}
146
+ </p>
147
+ )
148
+ }
149
+ )
150
+ FormMessage.displayName = 'FormMessage'
151
+
152
+ export { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField }
@@ -0,0 +1 @@
1
+ export { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField } from './Form'
@@ -21,7 +21,7 @@ const InputField = React.forwardRef<HTMLInputElement, React.InputHTMLAttributes<
21
21
  <input
22
22
  type={type}
23
23
  className={cn(
24
- 'border-input file:border-0 bg-transparent font-normal file:bg-transparent disabled:opacity-50 border rounded-1 focus-visible:ring-1 focus-visible:ring-ring w-full h-[44px] file:font-medium file:text-sm placeholder:text-muted-foreground leading-[1.17] transition-colors focus-visible:outline-none disabled:cursor-not-allowed',
24
+ 'form-input px-[16px] border-input file:border-0 bg-transparent font-normal file:bg-transparent disabled:opacity-50 border rounded-sm focus-visible:ring-1 focus-visible:ring-ring w-full h-[44px] file:font-medium file:text-sm placeholder:text-muted-foreground leading-[1.17] transition-colors focus-visible:outline-none disabled:cursor-not-allowed',
25
25
  className
26
26
  )}
27
27
  ref={ref}
@@ -0,0 +1,15 @@
1
+ import * as React from 'react'
2
+ import { IMaskInput } from 'react-imask'
3
+
4
+ const inputClasses = 'form-input border-input file:border-0 bg-transparent font-normal file:bg-transparent disabled:opacity-50 border rounded-sm focus-visible:ring-1 focus-visible:ring-ring w-full h-[44px] file:font-medium file:text-sm placeholder:text-muted-foreground leading-[1.17] transition-colors focus-visible:outline-none disabled:cursor-not-allowed'
5
+
6
+ const InputMask: React.FC = ({ ...props }) => {
7
+ return (
8
+ <IMaskInput
9
+ className={inputClasses}
10
+ {...props}
11
+ />
12
+ )
13
+ }
14
+
15
+ export { InputMask }
@@ -1 +1,2 @@
1
- export { InputField, InputLabel } from './Input'
1
+ export { InputField, InputLabel } from './Input'
2
+ export { InputMask } from './InputMask'
@@ -3,7 +3,7 @@ import * as LabelPrimitive from '@radix-ui/react-label'
3
3
  import { cva, type VariantProps } from 'class-variance-authority'
4
4
  import { cn } from '../@/lib/utils'
5
5
 
6
- const labelVariants = cva('peer-disabled:opacity-70 font-medium text-[12px] leading-[1.33] peer-disabled:cursor-not-allowed')
6
+ const labelVariants = cva('peer-disabled:opacity-70 peer-disabled:cursor-not-allowed')
7
7
 
8
8
  const Label = React.forwardRef<
9
9
  React.ElementRef<typeof LabelPrimitive.Root>,
package/src/Page/Page.tsx CHANGED
@@ -15,7 +15,7 @@ const Navbar: FC<IProps> = ({ children, className }) => {
15
15
  }
16
16
 
17
17
  const Content: FC<IProps> = ({ children, className }) => {
18
- return <div className={cn('px-[20px] py-[16px]', className)}>{children}</div>
18
+ return <div className={cn('px-[20px] py-[16px] overflow-y-auto', className)}>{children}</div>
19
19
  }
20
20
 
21
21
  const Page: IPage = ({ children, className }: IProps) => {
@@ -0,0 +1,8 @@
1
+ import * as React from 'react'
2
+ import { SelectBase } from './SelectBase'
3
+
4
+ const Select: React.FC = (props) => {
5
+ return <SelectBase {...props}/>
6
+ }
7
+
8
+ export { Select }