@xjur-ui/react 1.0.0 → 1.0.2
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/.turbo/turbo-build.log +63 -57
- package/CHANGELOG.md +18 -0
- package/dist/components/avatar.d.ts +11 -0
- package/dist/components/avatar.js +58 -0
- package/dist/components/badge.d.ts +13 -0
- package/dist/components/{ui/input/message.js → badge.js} +30 -47
- package/dist/components/{ui/button.d.ts → button.d.ts} +2 -2
- package/dist/components/{ui/button.js → button.js} +9 -6
- package/dist/components/calendar.d.ts +11 -0
- package/dist/components/calendar.js +751 -0
- package/dist/components/checkbox.d.ts +8 -0
- package/dist/components/{ui/input/root.js → checkbox.js} +69 -79
- package/dist/components/chip.d.ts +24 -0
- package/dist/components/chip.js +255 -0
- package/dist/components/collapsible.d.ts +8 -0
- package/dist/components/collapsible.js +41 -0
- package/dist/components/date-picker.d.ts +20 -0
- package/dist/components/date-picker.js +232 -0
- package/dist/components/divider.d.ts +7 -0
- package/dist/components/divider.js +28 -0
- package/dist/components/dropdown-menu.d.ts +22 -0
- package/dist/components/dropdown-menu.js +294 -0
- package/dist/components/{resources/icons.d.ts → icon.d.ts} +11 -2
- package/dist/components/{ui/icon.js → icon.js} +20 -5
- package/dist/components/input.d.ts +32 -0
- package/dist/components/input.js +315 -0
- package/dist/components/list.d.ts +25 -0
- package/dist/components/{ui/input/content.js → list.js} +83 -87
- package/dist/components/{ui/logo.d.ts → logo.d.ts} +2 -2
- package/dist/components/{ui/logo.js → logo.js} +5 -5
- package/dist/components/{ui/otp-input.js → otp-input.js} +1 -1
- package/dist/components/radio.d.ts +10 -0
- package/dist/components/{ui/input/label.js → radio.js} +68 -77
- package/dist/components/search-input.d.ts +17 -0
- package/dist/components/search-input.js +274 -0
- package/dist/components/select.d.ts +33 -0
- package/dist/components/select.js +550 -0
- package/dist/components/sheet.d.ts +19 -0
- package/dist/components/sheet.js +251 -0
- package/dist/components/switch.d.ts +7 -0
- package/dist/components/switch.js +36 -0
- package/dist/components/tabs.d.ts +11 -0
- package/dist/components/tabs.js +54 -0
- package/dist/components/tag.d.ts +18 -0
- package/dist/components/tag.js +189 -0
- package/dist/components/{ui/typography.d.ts → typography.d.ts} +4 -4
- package/dist/components/{ui/typography.js → typography.js} +1 -1
- package/dist/index.css +1233 -62
- package/dist/index.d.ts +2 -17
- package/dist/index.js +0 -788
- package/eslint.config.js +8 -1
- package/package.json +41 -10
- package/src/components/avatar.tsx +53 -0
- package/src/components/badge.tsx +40 -0
- package/src/components/{ui/button.tsx → button.tsx} +7 -5
- package/src/components/calendar.tsx +123 -0
- package/src/components/checkbox.tsx +57 -0
- package/src/components/chip.tsx +109 -0
- package/src/components/collapsible.tsx +35 -0
- package/src/components/date-picker.tsx +160 -0
- package/src/components/divider.tsx +23 -0
- package/src/components/dropdown-menu.tsx +101 -0
- package/src/components/{ui/icon.tsx → icon.tsx} +1 -1
- package/src/components/input.tsx +256 -0
- package/src/components/list.tsx +111 -0
- package/src/components/radio.tsx +74 -0
- package/src/components/search-input.tsx +112 -0
- package/src/components/select.tsx +240 -0
- package/src/components/sheet.tsx +141 -0
- package/src/components/switch.tsx +31 -0
- package/src/components/tabs.tsx +53 -0
- package/src/components/tag.tsx +91 -0
- package/src/index.css +4 -1
- package/src/index.ts +0 -1
- package/src/{components/resources → resources}/icons.ts +16 -1
- package/src/resources/input-mask.ts +91 -0
- package/dist/components/resources/icons.js +0 -133
- package/dist/components/resources/logo/horizontal.d.ts +0 -12
- package/dist/components/resources/logo/horizontal.js +0 -107
- package/dist/components/resources/logo/icon.d.ts +0 -12
- package/dist/components/resources/logo/icon.js +0 -79
- package/dist/components/resources/logo/index.d.ts +0 -4
- package/dist/components/resources/logo/index.js +0 -291
- package/dist/components/resources/logo/vertical.d.ts +0 -12
- package/dist/components/resources/logo/vertical.js +0 -107
- package/dist/components/ui/accordion.d.ts +0 -5
- package/dist/components/ui/accordion.js +0 -8
- package/dist/components/ui/icon.d.ts +0 -12
- package/dist/components/ui/index.d.ts +0 -17
- package/dist/components/ui/index.js +0 -788
- package/dist/components/ui/input/content.d.ts +0 -9
- package/dist/components/ui/input/index.d.ts +0 -12
- package/dist/components/ui/input/index.js +0 -335
- package/dist/components/ui/input/label.d.ts +0 -12
- package/dist/components/ui/input/message.d.ts +0 -10
- package/dist/components/ui/input/root.d.ts +0 -18
- package/dist/components/ui/input/slot.d.ts +0 -10
- package/dist/components/ui/input/slot.js +0 -20
- package/dist/components/ui/input/text.d.ts +0 -10
- package/dist/components/ui/input/text.js +0 -195
- package/src/components/ui/accordion.tsx +0 -3
- package/src/components/ui/index.ts +0 -13
- package/src/components/ui/input/content.tsx +0 -59
- package/src/components/ui/input/index.ts +0 -6
- package/src/components/ui/input/label.tsx +0 -41
- package/src/components/ui/input/message.tsx +0 -37
- package/src/components/ui/input/root.tsx +0 -57
- package/src/components/ui/input/slot.tsx +0 -21
- package/src/components/ui/input/text.tsx +0 -69
- /package/dist/components/{ui/otp-input.d.ts → otp-input.d.ts} +0 -0
- /package/src/components/{ui/logo.tsx → logo.tsx} +0 -0
- /package/src/components/{ui/otp-input.tsx → otp-input.tsx} +0 -0
- /package/src/components/{ui/typography.tsx → typography.tsx} +0 -0
- /package/src/{components/resources → resources}/logo/horizontal.tsx +0 -0
- /package/src/{components/resources → resources}/logo/icon.tsx +0 -0
- /package/src/{components/resources → resources}/logo/index.ts +0 -0
- /package/src/{components/resources → resources}/logo/vertical.tsx +0 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react'
|
|
2
|
+
import * as RadixPopover from '@radix-ui/react-popover'
|
|
3
|
+
import { cx } from '@xjur-ui/util'
|
|
4
|
+
import { Typography, type TypographyProps } from './typography'
|
|
5
|
+
|
|
6
|
+
export function DatePickerRoot(
|
|
7
|
+
props: ComponentProps<typeof RadixPopover.Root>
|
|
8
|
+
) {
|
|
9
|
+
return <RadixPopover.Root {...props} />
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function DatePickerTrigger({
|
|
13
|
+
className,
|
|
14
|
+
...props
|
|
15
|
+
}: ComponentProps<typeof RadixPopover.Trigger>) {
|
|
16
|
+
return (
|
|
17
|
+
<RadixPopover.Trigger
|
|
18
|
+
className={cx(
|
|
19
|
+
className,
|
|
20
|
+
'group h-large-4x rounded-small-1x gap-small py-small_1x-alt px-small relative flex w-full cursor-pointer items-center',
|
|
21
|
+
'bg-layer-2-idle border-border-layer-2 hover:border-border-layer-3 border',
|
|
22
|
+
'data-[state=open]:border-primary-idle data-[state=open]:shadow-focus-primary',
|
|
23
|
+
'has-[input:not(:placeholder-shown)]:text-primary-idle',
|
|
24
|
+
'has-[input:not(:placeholder-shown)]:border-primary-idle'
|
|
25
|
+
)}
|
|
26
|
+
{...props}
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function DatePickerContent({
|
|
32
|
+
className,
|
|
33
|
+
sideOffset = 5,
|
|
34
|
+
side = 'bottom',
|
|
35
|
+
align = 'start',
|
|
36
|
+
...props
|
|
37
|
+
}: ComponentProps<typeof RadixPopover.Content>) {
|
|
38
|
+
return (
|
|
39
|
+
<RadixPopover.Portal>
|
|
40
|
+
<RadixPopover.Content
|
|
41
|
+
align={align}
|
|
42
|
+
className={cx(
|
|
43
|
+
className,
|
|
44
|
+
'group z-10 max-h-[var(--radix-popover-content-available-height)] max-w-[var(--radix-popover-content-available-width)] min-w-[var(--radix-popover-trigger-width)]'
|
|
45
|
+
)}
|
|
46
|
+
side={side}
|
|
47
|
+
sideOffset={sideOffset}
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
</RadixPopover.Portal>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function DatePickerValue({
|
|
55
|
+
className,
|
|
56
|
+
displayValue = '',
|
|
57
|
+
value,
|
|
58
|
+
...props
|
|
59
|
+
}: ComponentProps<'input'> & { displayValue?: string }) {
|
|
60
|
+
return (
|
|
61
|
+
<>
|
|
62
|
+
{!!displayValue && (
|
|
63
|
+
<Typography className="text-neutral-dark group-has-[div[data-slot=date-picker-left-slot]]:pl-large-1x">
|
|
64
|
+
{displayValue}
|
|
65
|
+
</Typography>
|
|
66
|
+
)}
|
|
67
|
+
|
|
68
|
+
<input
|
|
69
|
+
{...props}
|
|
70
|
+
aria-readonly={true}
|
|
71
|
+
className={cx('pointer-events-none', className)}
|
|
72
|
+
hidden={true}
|
|
73
|
+
placeholder={props.placeholder ?? ' '}
|
|
74
|
+
readOnly={true}
|
|
75
|
+
value={value ?? ''}
|
|
76
|
+
/>
|
|
77
|
+
</>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function DatePickerLabel({
|
|
82
|
+
className,
|
|
83
|
+
htmlFor,
|
|
84
|
+
children,
|
|
85
|
+
...props
|
|
86
|
+
}: TypographyProps & { htmlFor?: string }) {
|
|
87
|
+
return (
|
|
88
|
+
<Typography
|
|
89
|
+
asChild={true}
|
|
90
|
+
className={cx(
|
|
91
|
+
'inline-block max-w-full truncate text-left font-normal',
|
|
92
|
+
'left-small right-small pointer-events-none absolute top-1/2 -translate-y-1/2',
|
|
93
|
+
'ease transition-all duration-250',
|
|
94
|
+
// Content Open
|
|
95
|
+
'group-data-[state=open]:text-primary-idle',
|
|
96
|
+
'group-data-[state=open]:-top-[3px]',
|
|
97
|
+
'group-data-[state=open]:text-size-label-sm-1x',
|
|
98
|
+
'group-data-[state=open]:font-medium',
|
|
99
|
+
// Filled
|
|
100
|
+
'group-has-[input:not(:placeholder-shown)]:text-primary-idle',
|
|
101
|
+
'group-has-[input:not(:placeholder-shown)]:-top-[3px]',
|
|
102
|
+
'group-has-[input:not(:placeholder-shown)]:text-size-label-sm-1x',
|
|
103
|
+
'group-has-[input:not(:placeholder-shown)]:font-medium',
|
|
104
|
+
// If has left slot
|
|
105
|
+
'group-has-[div[data-slot=date-picker-left-slot]]:left-large-4x',
|
|
106
|
+
'group-has-[div[data-slot=date-picker-left-slot]]:group-data-[state=open]:left-small',
|
|
107
|
+
'group-has-[div[data-slot=date-picker-left-slot]]:group-has-[input:not(:placeholder-shown)]:left-small',
|
|
108
|
+
// If has right slot
|
|
109
|
+
'group-has-[div[data-slot=date-picker-right-slot]]:right-large-4x',
|
|
110
|
+
'group-has-[div[data-slot=date-picker-right-slot]]:group-data-[state=open]:right-small',
|
|
111
|
+
'group-has-[div[data-slot=date-picker-right-slot]]:group-has-[input:not(:placeholder-shown)]:right-small',
|
|
112
|
+
// Animate
|
|
113
|
+
'group-data-[state=open]:animate-in',
|
|
114
|
+
'group-data-[state=closed]:animate-out',
|
|
115
|
+
'group-has-[input:not(:placeholder-shown)]:animate-out',
|
|
116
|
+
className
|
|
117
|
+
)}
|
|
118
|
+
weight="medium"
|
|
119
|
+
{...props}
|
|
120
|
+
>
|
|
121
|
+
<label htmlFor={htmlFor}>
|
|
122
|
+
<span className="bg-layer-2-idle rounded-small-1x max-w-full">
|
|
123
|
+
{children}
|
|
124
|
+
</span>
|
|
125
|
+
</label>
|
|
126
|
+
</Typography>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function DatePickerLeftSlot({
|
|
131
|
+
className,
|
|
132
|
+
...props
|
|
133
|
+
}: ComponentProps<'div'>) {
|
|
134
|
+
return (
|
|
135
|
+
<div
|
|
136
|
+
{...props}
|
|
137
|
+
className={cx(
|
|
138
|
+
className,
|
|
139
|
+
'left-small absolute top-1/2 flex -translate-y-1/2 items-center justify-center'
|
|
140
|
+
)}
|
|
141
|
+
data-slot="date-picker-left-slot"
|
|
142
|
+
/>
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function DatePickerRightSlot({
|
|
147
|
+
className,
|
|
148
|
+
...props
|
|
149
|
+
}: ComponentProps<'div'>) {
|
|
150
|
+
return (
|
|
151
|
+
<div
|
|
152
|
+
{...props}
|
|
153
|
+
className={cx(
|
|
154
|
+
className,
|
|
155
|
+
'right-small absolute top-1/2 flex -translate-y-1/2 items-center justify-center'
|
|
156
|
+
)}
|
|
157
|
+
data-slot="date-picker-right-slot"
|
|
158
|
+
/>
|
|
159
|
+
)
|
|
160
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import * as SeparatorPrimitive from '@radix-ui/react-separator'
|
|
3
|
+
import { cx } from '@xjur-ui/util'
|
|
4
|
+
|
|
5
|
+
export function Divider({
|
|
6
|
+
className,
|
|
7
|
+
orientation = 'horizontal',
|
|
8
|
+
decorative = true,
|
|
9
|
+
...props
|
|
10
|
+
}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
|
|
11
|
+
return (
|
|
12
|
+
<SeparatorPrimitive.Root
|
|
13
|
+
className={cx(
|
|
14
|
+
'bg-border-layer-2 shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px',
|
|
15
|
+
className
|
|
16
|
+
)}
|
|
17
|
+
data-slot="separator"
|
|
18
|
+
decorative={decorative}
|
|
19
|
+
orientation={orientation}
|
|
20
|
+
{...props}
|
|
21
|
+
/>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu'
|
|
3
|
+
import { cx } from '@xjur-ui/util'
|
|
4
|
+
import {
|
|
5
|
+
ListContent,
|
|
6
|
+
ListHeader,
|
|
7
|
+
ListHeaderTitle,
|
|
8
|
+
ListItem,
|
|
9
|
+
ListRoot
|
|
10
|
+
} from './list'
|
|
11
|
+
import { Typography } from './typography'
|
|
12
|
+
import { Divider } from './divider'
|
|
13
|
+
|
|
14
|
+
export function DropdownMenuRoot({
|
|
15
|
+
...props
|
|
16
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
|
|
17
|
+
return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function DropdownMenuPortal({
|
|
21
|
+
...props
|
|
22
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {
|
|
23
|
+
return (
|
|
24
|
+
<DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function DropdownMenuTrigger({
|
|
29
|
+
...props
|
|
30
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
|
|
31
|
+
return (
|
|
32
|
+
<DropdownMenuPrimitive.Trigger
|
|
33
|
+
data-slot="dropdown-menu-trigger"
|
|
34
|
+
{...props}
|
|
35
|
+
/>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function DropdownMenuContent({
|
|
40
|
+
className,
|
|
41
|
+
sideOffset = 4,
|
|
42
|
+
align = 'start',
|
|
43
|
+
side = 'bottom',
|
|
44
|
+
children,
|
|
45
|
+
...props
|
|
46
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
|
|
47
|
+
return (
|
|
48
|
+
<DropdownMenuPrimitive.Portal>
|
|
49
|
+
<DropdownMenuPrimitive.Content
|
|
50
|
+
align={align}
|
|
51
|
+
className={cx(
|
|
52
|
+
'group z-10 max-h-[var(--radix-popover-content-available-height)] max-w-[var(--radix-popover-trigger-width)] min-w-[240px]',
|
|
53
|
+
className
|
|
54
|
+
)}
|
|
55
|
+
data-slot="dropdown-menu-content"
|
|
56
|
+
side={side}
|
|
57
|
+
sideOffset={sideOffset}
|
|
58
|
+
{...props}
|
|
59
|
+
>
|
|
60
|
+
<ListRoot>{children}</ListRoot>
|
|
61
|
+
</DropdownMenuPrimitive.Content>
|
|
62
|
+
</DropdownMenuPrimitive.Portal>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function DropdownMenuList({
|
|
67
|
+
...props
|
|
68
|
+
}: React.ComponentProps<typeof ListContent>) {
|
|
69
|
+
return <ListContent {...props} />
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function DropdownMenuHeader({
|
|
73
|
+
...props
|
|
74
|
+
}: React.ComponentProps<typeof ListHeader>) {
|
|
75
|
+
return <ListHeader {...props} />
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function DropdownMenuHeaderTitle({
|
|
79
|
+
...props
|
|
80
|
+
}: React.ComponentProps<typeof ListHeaderTitle>) {
|
|
81
|
+
return <ListHeaderTitle {...props} />
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function DropdownMenuItem({
|
|
85
|
+
className,
|
|
86
|
+
...props
|
|
87
|
+
}: React.ComponentProps<typeof ListItem>) {
|
|
88
|
+
return <ListItem className={cx(className, 'cursor-pointer')} {...props} />
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function DropdownMenuItemText({
|
|
92
|
+
...props
|
|
93
|
+
}: React.ComponentProps<typeof Typography>) {
|
|
94
|
+
return <Typography {...props} />
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function DropdownMenuItemDivider({
|
|
98
|
+
...props
|
|
99
|
+
}: React.ComponentProps<typeof Divider>) {
|
|
100
|
+
return <Divider {...props} />
|
|
101
|
+
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { cva, cx } from '@xjur-ui/util'
|
|
2
|
+
import type { ComponentProps } from 'react'
|
|
3
|
+
import { createContext } from 'react'
|
|
4
|
+
import { InputMask, type MaskOptions } from '@react-input/mask'
|
|
5
|
+
import {
|
|
6
|
+
InputNumberFormat,
|
|
7
|
+
type InputNumberFormatProps
|
|
8
|
+
} from '@react-input/number-format'
|
|
9
|
+
import { inputMask, type InputMaskType } from '../resources/input-mask'
|
|
10
|
+
|
|
11
|
+
export { inputMask, type InputMaskType, type MaskOptions }
|
|
12
|
+
|
|
13
|
+
export type InputProps = {
|
|
14
|
+
variant?: 'outlined' | 'filled'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const FieldContext = createContext<InputProps>({
|
|
18
|
+
variant: 'filled'
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
export function InputRoot({
|
|
22
|
+
className,
|
|
23
|
+
children,
|
|
24
|
+
variant = 'filled',
|
|
25
|
+
...props
|
|
26
|
+
}: ComponentProps<'div'> & InputProps) {
|
|
27
|
+
return (
|
|
28
|
+
<FieldContext.Provider value={{ variant }}>
|
|
29
|
+
<div
|
|
30
|
+
className={cx(
|
|
31
|
+
'group gap-small relative flex w-full flex-col',
|
|
32
|
+
className
|
|
33
|
+
)}
|
|
34
|
+
{...props}
|
|
35
|
+
>
|
|
36
|
+
{children}
|
|
37
|
+
</div>
|
|
38
|
+
</FieldContext.Provider>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function InputContent({ className, ...props }: ComponentProps<'div'>) {
|
|
43
|
+
const variants = cva(
|
|
44
|
+
[
|
|
45
|
+
'relative h-large-4x rounded-small-1x gap-small py-small_1x-alt px-small flex items-center w-full',
|
|
46
|
+
'focus-within:border-primary-idle focus-within:shadow-focus-primary focus-within:border',
|
|
47
|
+
'group-has-[div[data-slot=input-right-action-slot]]:rounded-r-none',
|
|
48
|
+
'group-has-[div[data-slot=input-left-action-slot]]:rounded-l-none'
|
|
49
|
+
],
|
|
50
|
+
{
|
|
51
|
+
variants: {
|
|
52
|
+
variant: {
|
|
53
|
+
default: '',
|
|
54
|
+
outlined:
|
|
55
|
+
'bg-layer-2-idle border-border-layer-2 border hover:group-has-[input:not(:focus-within)]:border-border-layer-3 has-[input:not(:placeholder-shown)]:border-primary-idle',
|
|
56
|
+
filled:
|
|
57
|
+
'bg-layer-2-hover group-hover:border-border-layer-1 group-hover:border-1'
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<FieldContext.Consumer>
|
|
65
|
+
{({ variant }) => {
|
|
66
|
+
return (
|
|
67
|
+
<div className={cx(className, variants({ variant }))} {...props} />
|
|
68
|
+
)
|
|
69
|
+
}}
|
|
70
|
+
</FieldContext.Consumer>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function InputLabel({
|
|
75
|
+
htmlFor,
|
|
76
|
+
className,
|
|
77
|
+
children,
|
|
78
|
+
...props
|
|
79
|
+
}: ComponentProps<'label'> & { htmlFor: string }) {
|
|
80
|
+
return (
|
|
81
|
+
<FieldContext.Consumer>
|
|
82
|
+
{({ variant }) => {
|
|
83
|
+
return (
|
|
84
|
+
<label
|
|
85
|
+
className={cx(
|
|
86
|
+
'group text-size-body-md text-neutral-dark inline-block max-w-full truncate text-left',
|
|
87
|
+
'ease animate-in left-small right-small pointer-events-none absolute top-1/2 -translate-y-1/2 transition-all duration-250',
|
|
88
|
+
// Filled
|
|
89
|
+
'group-focus-within:text-primary-idle group-focus-within:-top-[3px]',
|
|
90
|
+
'group-focus-within:text-size-label-sm-1x group-focus-within:font-medium',
|
|
91
|
+
'group-has-[input:not(:placeholder-shown)]:-top-[3px]',
|
|
92
|
+
'group-has-[input:not(:placeholder-shown)]:text-size-label-sm-1x',
|
|
93
|
+
'group-has-[input:not(:placeholder-shown)]:font-medium',
|
|
94
|
+
'data-[variant=outlined]:group-has-[input:not(:placeholder-shown)]:text-primary-idle',
|
|
95
|
+
// If has left slot
|
|
96
|
+
'group-has-[div[data-slot=input-left-slot]]:left-large-4x',
|
|
97
|
+
'group-has-[div[data-slot=input-left-slot]]:group-focus-within:left-small',
|
|
98
|
+
'group-has-[div[data-slot=input-left-slot]]:group-has-[input:not(:placeholder-shown)]:left-small',
|
|
99
|
+
// If has right slot
|
|
100
|
+
'group-has-[div[data-slot=input-right-slot]]:right-large-4x',
|
|
101
|
+
'group-has-[div[data-slot=input-right-slot]]:group-focus-within:right-small',
|
|
102
|
+
'group-has-[div[data-slot=input-right-slot]]:group-has-[input:not(:placeholder-shown)]:right-small',
|
|
103
|
+
// Animate
|
|
104
|
+
'group-focus-within:animate-in',
|
|
105
|
+
'group-has-[input:not(:placeholder-shown)]:animate-out',
|
|
106
|
+
className
|
|
107
|
+
)}
|
|
108
|
+
data-variant={variant}
|
|
109
|
+
htmlFor={htmlFor}
|
|
110
|
+
{...props}
|
|
111
|
+
>
|
|
112
|
+
<span
|
|
113
|
+
className={cx(
|
|
114
|
+
'rounded-small-1x max-w-full',
|
|
115
|
+
'group-data-[variant=outlined]:group-focus-within:bg-layer-2-idle group-data-[variant=filled]:group-focus-within:bg-layer-2-hover',
|
|
116
|
+
'group-data-[variant=outlined]:bg-layer-2-idle group-data-[variant=filled]:bg-layer-2-hover'
|
|
117
|
+
)}
|
|
118
|
+
>
|
|
119
|
+
{children}
|
|
120
|
+
</span>
|
|
121
|
+
</label>
|
|
122
|
+
)
|
|
123
|
+
}}
|
|
124
|
+
</FieldContext.Consumer>
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function InputText({
|
|
129
|
+
className,
|
|
130
|
+
maskOptions,
|
|
131
|
+
maskType,
|
|
132
|
+
...props
|
|
133
|
+
}: ComponentProps<'input'> & {
|
|
134
|
+
maskOptions?: MaskOptions
|
|
135
|
+
maskType?: InputMaskType
|
|
136
|
+
}) {
|
|
137
|
+
const Component = maskOptions || maskType ? InputMask : 'input'
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<Component
|
|
141
|
+
{...props}
|
|
142
|
+
{...(maskType
|
|
143
|
+
? { ...inputMask(maskType) }
|
|
144
|
+
: maskOptions && { ...maskOptions })}
|
|
145
|
+
className={cx(
|
|
146
|
+
className,
|
|
147
|
+
'peer text-size-body-md text-neutral-dark flex-1 font-medium outline-none',
|
|
148
|
+
'group-has-[div[data-slot=input-left-slot]]:pl-large-1x ml-small-1x'
|
|
149
|
+
)}
|
|
150
|
+
placeholder={props.placeholder || ' '}
|
|
151
|
+
{...(maskOptions && { ...maskOptions })}
|
|
152
|
+
/>
|
|
153
|
+
)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function InputNumber({
|
|
157
|
+
className,
|
|
158
|
+
locales = 'pt-BR',
|
|
159
|
+
...props
|
|
160
|
+
}: InputNumberFormatProps) {
|
|
161
|
+
return (
|
|
162
|
+
<InputNumberFormat
|
|
163
|
+
{...props}
|
|
164
|
+
className={cx(
|
|
165
|
+
className,
|
|
166
|
+
'peer text-size-body-md text-neutral-dark flex-1 font-medium outline-none',
|
|
167
|
+
'group-has-[div[data-slot=input-left-slot]]:pl-large-1x ml-small-1x'
|
|
168
|
+
)}
|
|
169
|
+
locales={locales}
|
|
170
|
+
placeholder={props.placeholder || ' '}
|
|
171
|
+
/>
|
|
172
|
+
)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export function InputLeftSlot({ className, ...props }: ComponentProps<'div'>) {
|
|
176
|
+
return (
|
|
177
|
+
<div
|
|
178
|
+
{...props}
|
|
179
|
+
className={cx(
|
|
180
|
+
className,
|
|
181
|
+
'left-small absolute top-1/2 flex -translate-y-1/2 items-center justify-center'
|
|
182
|
+
)}
|
|
183
|
+
data-slot="input-left-slot"
|
|
184
|
+
/>
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export function InputRightSlot({ className, ...props }: ComponentProps<'div'>) {
|
|
189
|
+
return (
|
|
190
|
+
<div
|
|
191
|
+
{...props}
|
|
192
|
+
className={cx(
|
|
193
|
+
className,
|
|
194
|
+
'right-small absolute top-1/2 flex -translate-y-1/2 items-center justify-center'
|
|
195
|
+
)}
|
|
196
|
+
data-slot="input-right-slot"
|
|
197
|
+
/>
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export function InputMessage({ className, ...props }: ComponentProps<'p'>) {
|
|
202
|
+
return (
|
|
203
|
+
<p
|
|
204
|
+
{...props}
|
|
205
|
+
className={cx(
|
|
206
|
+
'text-size-body-sm text-neutral-dark font-normal',
|
|
207
|
+
className
|
|
208
|
+
)}
|
|
209
|
+
/>
|
|
210
|
+
)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export function InputContainer({ className, ...props }: ComponentProps<'div'>) {
|
|
214
|
+
return (
|
|
215
|
+
<div
|
|
216
|
+
{...props}
|
|
217
|
+
className={cx(className, 'flex items-center')}
|
|
218
|
+
data-slot="input-content"
|
|
219
|
+
/>
|
|
220
|
+
)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export function InputAction({
|
|
224
|
+
className,
|
|
225
|
+
side,
|
|
226
|
+
...props
|
|
227
|
+
}: ComponentProps<'div'> & {
|
|
228
|
+
side: 'left' | 'right'
|
|
229
|
+
}) {
|
|
230
|
+
return (
|
|
231
|
+
<div
|
|
232
|
+
{...props}
|
|
233
|
+
className={cx(
|
|
234
|
+
className,
|
|
235
|
+
'group h-large-4x flex items-center justify-center'
|
|
236
|
+
)}
|
|
237
|
+
data-side={side}
|
|
238
|
+
data-slot={`input-${side}-action-slot`}
|
|
239
|
+
/>
|
|
240
|
+
)
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export function InputActionButton({
|
|
244
|
+
className,
|
|
245
|
+
...props
|
|
246
|
+
}: ComponentProps<'div'>) {
|
|
247
|
+
return (
|
|
248
|
+
<div
|
|
249
|
+
{...props}
|
|
250
|
+
className={cx(
|
|
251
|
+
className,
|
|
252
|
+
'h-large-4x w-large-4x bg-layer-2-hover flex cursor-pointer items-center justify-center'
|
|
253
|
+
)}
|
|
254
|
+
/>
|
|
255
|
+
)
|
|
256
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Slot } from '@radix-ui/react-slot'
|
|
2
|
+
import { cx, cva, type ClassVariantProps } from '@xjur-ui/util'
|
|
3
|
+
import type { ComponentProps } from 'react'
|
|
4
|
+
import { type TypographyProps, Typography } from './typography'
|
|
5
|
+
|
|
6
|
+
export function ListRoot({
|
|
7
|
+
className,
|
|
8
|
+
asChild,
|
|
9
|
+
...props
|
|
10
|
+
}: ComponentProps<'div'> & {
|
|
11
|
+
asChild?: boolean
|
|
12
|
+
}) {
|
|
13
|
+
const Comp = asChild ? Slot : 'div'
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Comp
|
|
17
|
+
{...props}
|
|
18
|
+
className={cx(
|
|
19
|
+
className,
|
|
20
|
+
'rounded-small scrollbar-hide bg-layer-2-idle border-border-layer-2 shadow-elevation-3 z-10 max-h-[400px] list-none overflow-y-auto border'
|
|
21
|
+
)}
|
|
22
|
+
/>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function ListHeader({
|
|
27
|
+
className,
|
|
28
|
+
asChild,
|
|
29
|
+
...props
|
|
30
|
+
}: ComponentProps<'div'> & {
|
|
31
|
+
asChild?: boolean
|
|
32
|
+
}) {
|
|
33
|
+
const Comp = asChild ? Slot : 'div'
|
|
34
|
+
return <Comp {...props} className={cx(className, 'px-small pt-small-1x')} />
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function ListHeaderTitle({
|
|
38
|
+
variant = 'label',
|
|
39
|
+
size = 'sm',
|
|
40
|
+
weight = 'medium',
|
|
41
|
+
className,
|
|
42
|
+
...props
|
|
43
|
+
}: TypographyProps) {
|
|
44
|
+
return (
|
|
45
|
+
<Typography
|
|
46
|
+
className={cx(className, 'text-neutral-placeholder')}
|
|
47
|
+
size={size}
|
|
48
|
+
variant={variant}
|
|
49
|
+
weight={weight}
|
|
50
|
+
{...props}
|
|
51
|
+
/>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function ListContent({
|
|
56
|
+
className,
|
|
57
|
+
asChild,
|
|
58
|
+
...props
|
|
59
|
+
}: ComponentProps<'ul'> & {
|
|
60
|
+
asChild?: boolean
|
|
61
|
+
}) {
|
|
62
|
+
const Comp = asChild ? Slot : 'ul'
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<Comp
|
|
66
|
+
{...props}
|
|
67
|
+
className={cx('gap-small-1x p-small flex flex-col', className)}
|
|
68
|
+
/>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const variants = cva(
|
|
73
|
+
[
|
|
74
|
+
'py-medium px-small flex items-center gap-small rounded-small-1x',
|
|
75
|
+
'bg-layer-2-idle text-neutral-dark',
|
|
76
|
+
'hover:bg-layer-2-hover transition-colors duration-100 ease-out',
|
|
77
|
+
'active:bg-layer-2-pressed'
|
|
78
|
+
],
|
|
79
|
+
{
|
|
80
|
+
variants: {
|
|
81
|
+
size: {
|
|
82
|
+
md: 'h-large-4x',
|
|
83
|
+
lg: 'h-large-7x'
|
|
84
|
+
},
|
|
85
|
+
isActive: {
|
|
86
|
+
true: 'bg-primary-alt-active text-primary-label-active hover:bg-primary-alt-hover active:bg-primary-alt-pressed'
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
defaultVariants: {
|
|
90
|
+
size: 'md',
|
|
91
|
+
isActive: false
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
export function ListItem({
|
|
97
|
+
className,
|
|
98
|
+
size,
|
|
99
|
+
isActive,
|
|
100
|
+
asChild,
|
|
101
|
+
...props
|
|
102
|
+
}: ComponentProps<'li'> &
|
|
103
|
+
ClassVariantProps<typeof variants> & {
|
|
104
|
+
asChild?: boolean
|
|
105
|
+
}) {
|
|
106
|
+
const Comp = asChild ? Slot : 'li'
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<Comp {...props} className={cx(variants({ size, isActive }), className)} />
|
|
110
|
+
)
|
|
111
|
+
}
|