@modul/mbui 0.0.13-beta-pv-53036-cf3bc48d → 0.0.13-beta-pv-53127-63b6a630
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/Base/Input/Base.d.ts +4 -0
- package/dist/Base/Input/Base.js +20 -0
- package/dist/Base/Input/Base.js.map +1 -0
- package/dist/Base/Input/Input.d.ts +4 -0
- package/dist/Base/Input/Input.js +18 -0
- package/dist/Base/Input/Input.js.map +1 -0
- package/dist/Base/Input/index.d.ts +2 -0
- package/dist/Base/Input/index.js +7 -0
- package/dist/Base/Input/index.js.map +1 -0
- package/dist/Base/Input/types.d.ts +9 -0
- package/dist/Base/Input/types.js +3 -0
- package/dist/Base/Input/types.js.map +1 -0
- package/dist/Button/Button.d.ts +1 -1
- package/dist/Chip/Chip.d.ts +1 -1
- package/dist/Drawer/Drawer.js +1 -1
- package/dist/Drawer/Drawer.js.map +1 -1
- package/dist/{Alert/Alert.d.ts → Info/Info.d.ts} +4 -4
- package/dist/{Alert/Alert.js → Info/Info.js} +7 -7
- package/dist/Info/Info.js.map +1 -0
- package/dist/Info/index.d.ts +1 -0
- package/dist/Info/index.js +6 -0
- package/dist/Info/index.js.map +1 -0
- package/dist/Input/Input.js +1 -1
- package/dist/Input/Input.js.map +1 -1
- package/dist/Input/index.d.ts +0 -1
- package/dist/Input/index.js +1 -3
- package/dist/Input/index.js.map +1 -1
- package/dist/Input-OTP/Input.d.ts +4 -4
- package/dist/Page/Page.js +1 -1
- package/dist/Page/Page.js.map +1 -1
- package/dist/Progress/Progress.d.ts +4 -0
- package/dist/Progress/Progress.js +12 -0
- package/dist/Progress/Progress.js.map +1 -0
- package/dist/Progress/index.d.ts +1 -0
- package/dist/Progress/index.js +6 -0
- package/dist/Progress/index.js.map +1 -0
- package/dist/index.d.ts +20 -27
- package/dist/index.js +10 -41
- package/dist/index.js.map +1 -1
- package/package.json +4 -11
- package/src/Drawer/Drawer.tsx +2 -2
- package/src/DrawerCompanyList/CompanyList.tsx +63 -0
- package/src/DrawerCompanyList/index.ts +1 -0
- package/src/{Alert/Alert.tsx → Info/Info.tsx} +6 -6
- package/src/Info/index.ts +1 -0
- package/src/Input/Input.tsx +1 -1
- package/src/Input/index.ts +1 -2
- package/src/Label/Label.tsx +1 -1
- package/src/Page/Page.tsx +1 -1
- package/src/Progress/Progress.tsx +23 -0
- package/src/Progress/index.ts +1 -0
- package/src/assets/css/global.css +9 -22
- package/src/index.ts +41 -67
- package/dist/Alert/Alert.js.map +0 -1
- package/dist/Alert/index.d.ts +0 -1
- package/dist/Alert/index.js +0 -6
- package/dist/Alert/index.js.map +0 -1
- package/dist/AlertDialog/AlertDialog.d.ts +0 -20
- package/dist/AlertDialog/AlertDialog.js +0 -42
- package/dist/AlertDialog/AlertDialog.js.map +0 -1
- package/dist/AlertDialog/index.d.ts +0 -1
- package/dist/AlertDialog/index.js +0 -16
- package/dist/AlertDialog/index.js.map +0 -1
- package/dist/Calendar/Calendar.d.ts +0 -8
- package/dist/Calendar/Calendar.js +0 -45
- package/dist/Calendar/Calendar.js.map +0 -1
- package/dist/Calendar/index.d.ts +0 -1
- package/dist/Calendar/index.js +0 -6
- package/dist/Calendar/index.js.map +0 -1
- package/dist/DatePicker/DatePicker.d.ts +0 -9
- package/dist/DatePicker/DatePicker.js +0 -23
- package/dist/DatePicker/DatePicker.js.map +0 -1
- package/dist/DatePicker/index.d.ts +0 -1
- package/dist/DatePicker/index.js +0 -6
- package/dist/DatePicker/index.js.map +0 -1
- package/dist/Form/Form.d.ts +0 -23
- package/dist/Form/Form.js +0 -73
- package/dist/Form/Form.js.map +0 -1
- package/dist/Form/index.d.ts +0 -1
- package/dist/Form/index.js +0 -13
- package/dist/Form/index.js.map +0 -1
- package/dist/Input/InputMask.d.ts +0 -3
- package/dist/Input/InputMask.js +0 -12
- package/dist/Input/InputMask.js.map +0 -1
- package/dist/Label/Label.d.ts +0 -5
- package/dist/Label/Label.js +0 -13
- package/dist/Label/Label.js.map +0 -1
- package/dist/Label/index.d.ts +0 -1
- package/dist/Label/index.js +0 -6
- package/dist/Label/index.js.map +0 -1
- package/dist/Select/Select.d.ts +0 -3
- package/dist/Select/Select.js +0 -11
- package/dist/Select/Select.js.map +0 -1
- package/dist/Select/SelectAccountCard.d.ts +0 -4
- package/dist/Select/SelectAccountCard.js +0 -75
- package/dist/Select/SelectAccountCard.js.map +0 -1
- package/dist/Select/SelectAsync.d.ts +0 -8
- package/dist/Select/SelectAsync.js +0 -73
- package/dist/Select/SelectAsync.js.map +0 -1
- package/dist/Select/SelectBase.d.ts +0 -6
- package/dist/Select/SelectBase.js +0 -72
- package/dist/Select/SelectBase.js.map +0 -1
- package/dist/Select/index.d.ts +0 -4
- package/dist/Select/index.js +0 -12
- package/dist/Select/index.js.map +0 -1
- package/dist/Switch/Switch.d.ts +0 -4
- package/dist/Switch/Switch.js +0 -31
- package/dist/Switch/Switch.js.map +0 -1
- package/dist/Switch/index.d.ts +0 -1
- package/dist/Switch/index.js +0 -6
- package/dist/Switch/index.js.map +0 -1
- package/dist/Textarea/Textarea.d.ts +0 -5
- package/dist/Textarea/Textarea.js +0 -12
- package/dist/Textarea/Textarea.js.map +0 -1
- package/dist/Textarea/index.d.ts +0 -1
- package/dist/Textarea/index.js +0 -6
- package/dist/Textarea/index.js.map +0 -1
- package/src/Alert/index.ts +0 -1
- package/src/AlertDialog/AlertDialog.tsx +0 -138
- package/src/AlertDialog/index.ts +0 -13
- package/src/Calendar/Calendar.tsx +0 -61
- package/src/Calendar/index.ts +0 -1
- package/src/DatePicker/DatePicker.tsx +0 -38
- package/src/DatePicker/index.ts +0 -1
- package/src/Form/Form.tsx +0 -152
- package/src/Form/index.ts +0 -1
- package/src/Input/InputMask.tsx +0 -15
- package/src/Select/Select.tsx +0 -8
- package/src/Select/SelectAccountCard.tsx +0 -162
- package/src/Select/SelectAsync.tsx +0 -183
- package/src/Select/SelectBase.tsx +0 -181
- package/src/Select/index.ts +0 -4
- package/src/Switch/Switch.tsx +0 -47
- package/src/Switch/index.ts +0 -1
- package/src/Textarea/Textarea.tsx +0 -24
- package/src/Textarea/index.ts +0 -1
|
@@ -1,138 +0,0 @@
|
|
|
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
|
-
}
|
package/src/AlertDialog/index.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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'
|
|
@@ -1,61 +0,0 @@
|
|
|
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 }
|
package/src/Calendar/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Calendar } from './Calendar'
|
|
@@ -1,38 +0,0 @@
|
|
|
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 }
|
package/src/DatePicker/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { DatePicker } from './DatePicker'
|
package/src/Form/Form.tsx
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
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 }
|
package/src/Form/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField } from './Form'
|
package/src/Input/InputMask.tsx
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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 }
|
package/src/Select/Select.tsx
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
|
|
3
|
-
import { DropdownSmallOld, CheckSmall } from '../Icon'
|
|
4
|
-
|
|
5
|
-
import Select, {
|
|
6
|
-
components,
|
|
7
|
-
ControlProps,
|
|
8
|
-
OptionProps,
|
|
9
|
-
DropdownIndicatorProps,
|
|
10
|
-
StylesConfig,
|
|
11
|
-
SingleValueProps,
|
|
12
|
-
MenuProps,
|
|
13
|
-
ValueContainerProps,
|
|
14
|
-
} from 'react-select'
|
|
15
|
-
|
|
16
|
-
import { cn } from '../@/lib/utils'
|
|
17
|
-
|
|
18
|
-
const selectTriggerClasses: string =
|
|
19
|
-
'flex items-center bg-gradient-to-r from-[--cl-blue-3] to-primary shadow-[0px_8px_18px_0px_rgba(73,113,208,0.38)] px-[16px] py-[8px] border-none rounded-md min-h-[80px] text-left text-white cursor-pointer'
|
|
20
|
-
|
|
21
|
-
const colourStyles: StylesConfig = {
|
|
22
|
-
control: () => ({}),
|
|
23
|
-
option: () => ({}),
|
|
24
|
-
input: () => ({}),
|
|
25
|
-
dropdownIndicator: () => ({}),
|
|
26
|
-
indicatorsContainer: () => ({}),
|
|
27
|
-
menu: () => ({}),
|
|
28
|
-
menuList: () => ({}),
|
|
29
|
-
singleValue: () => ({}),
|
|
30
|
-
valueContainer: () => ({}),
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const Control = ({ children, ...props }: ControlProps) => {
|
|
34
|
-
const { isFocused } = props
|
|
35
|
-
return (
|
|
36
|
-
<components.Control
|
|
37
|
-
className={cn(
|
|
38
|
-
selectTriggerClasses,
|
|
39
|
-
{ 'outline outline-primary outline-offset-2 outline-2': isFocused }
|
|
40
|
-
)}
|
|
41
|
-
{...props}
|
|
42
|
-
>
|
|
43
|
-
{children}
|
|
44
|
-
</components.Control>
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const optionClasses =
|
|
49
|
-
'flex items-center first:rounded-t-md last:rounded-b-md px-[12px] py-[16px] w-full cursor-default select-none outline-none'
|
|
50
|
-
|
|
51
|
-
const Option = ({ children, ...props }: OptionProps) => {
|
|
52
|
-
const {
|
|
53
|
-
isSelected,
|
|
54
|
-
isFocused,
|
|
55
|
-
isDisabled,
|
|
56
|
-
// @ts-ignore
|
|
57
|
-
data: { label, account, balance, cur },
|
|
58
|
-
} = props
|
|
59
|
-
return (
|
|
60
|
-
<components.Option
|
|
61
|
-
className={cn(optionClasses, { 'bg-light': isFocused }, { 'opacity-50 pointer-events-none': isDisabled })}
|
|
62
|
-
{...props}
|
|
63
|
-
>
|
|
64
|
-
<span className="flex basis-0 grow">
|
|
65
|
-
<span>
|
|
66
|
-
<span>{label}</span>
|
|
67
|
-
<br />
|
|
68
|
-
<span className="text-[14px] text-light">{account}</span>
|
|
69
|
-
</span>
|
|
70
|
-
<span className="ml-auto shrink-0">
|
|
71
|
-
{balance} {cur}
|
|
72
|
-
</span>
|
|
73
|
-
</span>
|
|
74
|
-
|
|
75
|
-
<span className="ml-[16px] w-[24px] h-[24px] shrink-0">
|
|
76
|
-
{isSelected && (
|
|
77
|
-
<CheckSmall
|
|
78
|
-
width="24"
|
|
79
|
-
height="24"
|
|
80
|
-
className="text-primary"
|
|
81
|
-
/>
|
|
82
|
-
)}
|
|
83
|
-
</span>
|
|
84
|
-
</components.Option>
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const DropdownIndicator = ({ children, ...props }: DropdownIndicatorProps) => {
|
|
89
|
-
return (
|
|
90
|
-
<components.DropdownIndicator
|
|
91
|
-
className="shrink-0"
|
|
92
|
-
{...props}
|
|
93
|
-
>
|
|
94
|
-
<DropdownSmallOld
|
|
95
|
-
className="text-white"
|
|
96
|
-
width="16"
|
|
97
|
-
height="16"
|
|
98
|
-
/>
|
|
99
|
-
</components.DropdownIndicator>
|
|
100
|
-
)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const ValueContainer = ({ children, ...props }: ValueContainerProps) => {
|
|
104
|
-
return (
|
|
105
|
-
<components.ValueContainer
|
|
106
|
-
className="flex-1 grid"
|
|
107
|
-
{...props}
|
|
108
|
-
>
|
|
109
|
-
{children}
|
|
110
|
-
</components.ValueContainer>
|
|
111
|
-
)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const SingleValue = ({ children, ...props }: SingleValueProps) => {
|
|
115
|
-
// @ts-ignore
|
|
116
|
-
const { label, account, balance, cur } = props.data
|
|
117
|
-
return (
|
|
118
|
-
<components.SingleValue
|
|
119
|
-
className="col-start-1 col-end-3 row-start-1 row-end-2"
|
|
120
|
-
{...props}
|
|
121
|
-
>
|
|
122
|
-
<span className="block max-w-full text-[16px] truncate leading-[1.5]">
|
|
123
|
-
{label} <span className="opacity-75 text-[14px] leading-[1.42]">{account}</span>
|
|
124
|
-
</span>
|
|
125
|
-
<span className="block mt-[8px] font-medium text-[24px] leading-[1.333]">
|
|
126
|
-
{balance} {cur}
|
|
127
|
-
</span>
|
|
128
|
-
</components.SingleValue>
|
|
129
|
-
)
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const Menu = ({ children, ...props }: MenuProps) => {
|
|
133
|
-
return (
|
|
134
|
-
<components.Menu
|
|
135
|
-
className="z-[1] absolute inset-x-0 bg-page shadow-md mt-[8px] rounded-md"
|
|
136
|
-
{...props}
|
|
137
|
-
>
|
|
138
|
-
{children}
|
|
139
|
-
</components.Menu>
|
|
140
|
-
)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const SelectAccountCard = React.forwardRef<Select>(({ ...props }, ref) => (
|
|
144
|
-
<Select
|
|
145
|
-
isSearchable={false}
|
|
146
|
-
components={{
|
|
147
|
-
Control,
|
|
148
|
-
Option,
|
|
149
|
-
SingleValue,
|
|
150
|
-
DropdownIndicator,
|
|
151
|
-
IndicatorSeparator: () => null,
|
|
152
|
-
Menu,
|
|
153
|
-
ValueContainer,
|
|
154
|
-
}}
|
|
155
|
-
styles={colourStyles}
|
|
156
|
-
unstyled={true}
|
|
157
|
-
{...props}
|
|
158
|
-
/>
|
|
159
|
-
))
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
export { SelectAccountCard }
|