@xjur-ui/react 2.0.0 → 2.1.0
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 +278 -119
- package/CHANGELOG.md +70 -0
- package/dist/chunk-2CM3SFOY.js +2 -0
- package/dist/chunk-2CM3SFOY.js.map +1 -0
- package/dist/chunk-2CTBH6VI.js +2 -0
- package/dist/chunk-2CTBH6VI.js.map +1 -0
- package/dist/chunk-4BGTC333.js +2 -0
- package/dist/chunk-4BGTC333.js.map +1 -0
- package/dist/chunk-5WLIDYZH.js +2 -0
- package/dist/chunk-5WLIDYZH.js.map +1 -0
- package/dist/chunk-6AD6O6II.js +2 -0
- package/dist/chunk-6AD6O6II.js.map +1 -0
- package/dist/chunk-AA6V5YEC.js +2 -0
- package/dist/chunk-AA6V5YEC.js.map +1 -0
- package/dist/chunk-BK6FP63A.js +2 -0
- package/dist/chunk-BK6FP63A.js.map +1 -0
- package/dist/chunk-BZDGWC5O.js +2 -0
- package/dist/chunk-BZDGWC5O.js.map +1 -0
- package/dist/chunk-CI3ZXWEX.js +2 -0
- package/dist/chunk-CI3ZXWEX.js.map +1 -0
- package/dist/chunk-DFXHNK5D.js +2 -0
- package/dist/chunk-DFXHNK5D.js.map +1 -0
- package/dist/chunk-EXC2XOL6.js +2 -0
- package/dist/chunk-EXC2XOL6.js.map +1 -0
- package/dist/chunk-F4DYKYWJ.js +2 -0
- package/dist/chunk-F4DYKYWJ.js.map +1 -0
- package/dist/chunk-F5ZLEQGN.js +2 -0
- package/dist/chunk-F5ZLEQGN.js.map +1 -0
- package/dist/chunk-IKL6PSXU.js +2 -0
- package/dist/chunk-IKL6PSXU.js.map +1 -0
- package/dist/chunk-IRHU7PDO.js +2 -0
- package/dist/chunk-IRHU7PDO.js.map +1 -0
- package/dist/chunk-J4X5RQTR.js +2 -0
- package/dist/chunk-J4X5RQTR.js.map +1 -0
- package/dist/chunk-L4ET6GIZ.js +2 -0
- package/dist/chunk-L4ET6GIZ.js.map +1 -0
- package/dist/chunk-MZSV4LNY.js +2 -0
- package/dist/chunk-MZSV4LNY.js.map +1 -0
- package/dist/chunk-OS53BV63.js +3 -0
- package/dist/chunk-OS53BV63.js.map +1 -0
- package/dist/{chunk-FASEHVMD.js → chunk-PKCW37CJ.js} +2 -2
- package/dist/chunk-PKCW37CJ.js.map +1 -0
- package/dist/chunk-SLAAEXWI.js +2 -0
- package/dist/chunk-SLAAEXWI.js.map +1 -0
- package/dist/chunk-SXGSWVMZ.js +2 -0
- package/dist/chunk-SXGSWVMZ.js.map +1 -0
- package/dist/chunk-TSVURBUY.js +2 -0
- package/dist/chunk-TSVURBUY.js.map +1 -0
- package/dist/chunk-UXIVZWLB.js +2 -0
- package/dist/chunk-UXIVZWLB.js.map +1 -0
- package/dist/chunk-WEBAXQID.js +2 -0
- package/dist/chunk-WEBAXQID.js.map +1 -0
- package/dist/chunk-WV7QV2PU.js +2 -0
- package/dist/chunk-WV7QV2PU.js.map +1 -0
- package/dist/{components/switch.js → chunk-Z47R2CIM.js} +2 -2
- package/dist/chunk-Z47R2CIM.js.map +1 -0
- package/dist/chunk-ZVVPUP7V.js +2 -0
- package/dist/chunk-ZVVPUP7V.js.map +1 -0
- package/dist/components/breadcrumb.d.ts +20 -0
- package/dist/components/breadcrumb.js +2 -0
- package/dist/components/breadcrumb.js.map +1 -0
- package/dist/components/chip.d.ts +2 -1
- package/dist/components/chip.js +1 -1
- package/dist/components/dialog.d.ts +51 -0
- package/dist/components/dialog.js +2 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/drag-and-drop/drag-handle.d.ts +15 -0
- package/dist/components/drag-and-drop/drag-handle.js +2 -0
- package/dist/components/drag-and-drop/drag-handle.js.map +1 -0
- package/dist/components/drag-and-drop/drag-list-item.d.ts +14 -0
- package/dist/components/drag-and-drop/drag-list-item.js +2 -0
- package/dist/components/drag-and-drop/drag-list-item.js.map +1 -0
- package/dist/components/drag-and-drop/drag-list.d.ts +14 -0
- package/dist/components/drag-and-drop/drag-list.js +2 -0
- package/dist/components/drag-and-drop/drag-list.js.map +1 -0
- package/dist/components/drag-and-drop/drag-root.d.ts +6 -0
- package/dist/components/drag-and-drop/drag-root.js +2 -0
- package/dist/components/drag-and-drop/drag-root.js.map +1 -0
- package/dist/components/drag-and-drop/index.d.ts +10 -0
- package/dist/components/drag-and-drop/index.js +2 -0
- package/dist/components/drag-and-drop/index.js.map +1 -0
- package/dist/components/drag-and-drop/types/drag-item.d.ts +9 -0
- package/dist/components/drag-and-drop/types/drag-item.js +2 -0
- package/dist/components/drag-and-drop/types/drag-item.js.map +1 -0
- package/dist/components/form/button.js +2 -0
- package/dist/components/form/calendar.js +2 -0
- package/dist/components/form/calendar.js.map +1 -0
- package/dist/components/form/checkbox.js +2 -0
- package/dist/components/form/checkbox.js.map +1 -0
- package/dist/components/form/context/field.context.d.ts +15 -0
- package/dist/components/form/context/field.context.js +2 -0
- package/dist/components/form/context/field.context.js.map +1 -0
- package/dist/components/form/date-picker.d.ts +84 -0
- package/dist/components/form/date-picker.js +2 -0
- package/dist/components/form/date-picker.js.map +1 -0
- package/dist/components/form/floating-label.d.ts +6 -0
- package/dist/components/form/floating-label.js +2 -0
- package/dist/components/form/floating-label.js.map +1 -0
- package/dist/components/form/input.d.ts +95 -0
- package/dist/components/form/input.js +2 -0
- package/dist/components/form/input.js.map +1 -0
- package/dist/components/form/otp-input.js.map +1 -0
- package/dist/components/form/radio.js +2 -0
- package/dist/components/form/radio.js.map +1 -0
- package/dist/components/form/rich-editor.js +2 -0
- package/dist/components/form/rich-editor.js.map +1 -0
- package/dist/components/form/search-input.js +2 -0
- package/dist/components/form/search-input.js.map +1 -0
- package/dist/components/form/select.d.ts +94 -0
- package/dist/components/form/select.js +2 -0
- package/dist/components/form/select.js.map +1 -0
- package/dist/components/form/switch.js +2 -0
- package/dist/components/form/switch.js.map +1 -0
- package/dist/components/full-calendar/calendar-add-event.d.ts +9 -0
- package/dist/components/full-calendar/calendar-add-event.js +2 -0
- package/dist/components/full-calendar/calendar-add-event.js.map +1 -0
- package/dist/components/full-calendar/calendar-body.d.ts +6 -0
- package/dist/components/full-calendar/calendar-body.js +2 -0
- package/dist/components/full-calendar/calendar-body.js.map +1 -0
- package/dist/components/full-calendar/calendar-cell.d.ts +11 -0
- package/dist/components/full-calendar/calendar-cell.js +2 -0
- package/dist/components/full-calendar/calendar-cell.js.map +1 -0
- package/dist/components/full-calendar/calendar-day-view.d.ts +5 -0
- package/dist/components/full-calendar/calendar-day-view.js +2 -0
- package/dist/components/full-calendar/calendar-day-view.js.map +1 -0
- package/dist/components/full-calendar/calendar-event.d.ts +18 -0
- package/dist/components/full-calendar/calendar-event.js +2 -0
- package/dist/components/full-calendar/calendar-event.js.map +1 -0
- package/dist/components/full-calendar/calendar-header.d.ts +6 -0
- package/dist/components/full-calendar/calendar-header.js +2 -0
- package/dist/components/full-calendar/calendar-header.js.map +1 -0
- package/dist/components/full-calendar/calendar-month-view.d.ts +5 -0
- package/dist/components/full-calendar/calendar-month-view.js +2 -0
- package/dist/components/full-calendar/calendar-month-view.js.map +1 -0
- package/dist/components/full-calendar/calendar-more-events-dropdown.d.ts +9 -0
- package/dist/components/full-calendar/calendar-more-events-dropdown.js +2 -0
- package/dist/components/full-calendar/calendar-more-events-dropdown.js.map +1 -0
- package/dist/components/full-calendar/calendar-navigator.d.ts +5 -0
- package/dist/components/full-calendar/calendar-navigator.js +2 -0
- package/dist/components/full-calendar/calendar-navigator.js.map +1 -0
- package/dist/components/full-calendar/calendar-root.d.ts +30 -0
- package/dist/components/full-calendar/calendar-root.js +2 -0
- package/dist/components/full-calendar/calendar-root.js.map +1 -0
- package/dist/components/full-calendar/calendar-today-button.d.ts +9 -0
- package/dist/components/full-calendar/calendar-today-button.js +2 -0
- package/dist/components/full-calendar/calendar-today-button.js.map +1 -0
- package/dist/components/full-calendar/calendar-toggle-view.d.ts +5 -0
- package/dist/components/full-calendar/calendar-toggle-view.js +2 -0
- package/dist/components/full-calendar/calendar-toggle-view.js.map +1 -0
- package/dist/components/full-calendar/calendar-view-renderer.d.ts +5 -0
- package/dist/components/full-calendar/calendar-view-renderer.js +2 -0
- package/dist/components/full-calendar/calendar-view-renderer.js.map +1 -0
- package/dist/components/full-calendar/calendar-week-day.d.ts +10 -0
- package/dist/components/full-calendar/calendar-week-day.js +2 -0
- package/dist/components/full-calendar/calendar-week-day.js.map +1 -0
- package/dist/components/full-calendar/calendar-week-view.d.ts +5 -0
- package/dist/components/full-calendar/calendar-week-view.js +2 -0
- package/dist/components/full-calendar/calendar-week-view.js.map +1 -0
- package/dist/components/full-calendar/helpers/calendar.d.ts +25 -0
- package/dist/components/full-calendar/helpers/calendar.js +2 -0
- package/dist/components/full-calendar/helpers/calendar.js.map +1 -0
- package/dist/components/full-calendar/index.d.ts +18 -0
- package/dist/components/full-calendar/index.js +2 -0
- package/dist/components/full-calendar/index.js.map +1 -0
- package/dist/components/full-calendar/types/calendar-cell.d.ts +6 -0
- package/dist/components/full-calendar/types/calendar-cell.js +2 -0
- package/dist/components/full-calendar/types/calendar-cell.js.map +1 -0
- package/dist/components/full-calendar/types/calendar-event.d.ts +8 -0
- package/dist/components/full-calendar/types/calendar-event.js +2 -0
- package/dist/components/full-calendar/types/calendar-event.js.map +1 -0
- package/dist/components/full-calendar/types/calendar-view.d.ts +3 -0
- package/dist/components/full-calendar/types/calendar-view.js +2 -0
- package/dist/components/full-calendar/types/calendar-view.js.map +1 -0
- package/dist/components/full-calendar/types/calendar-week-hour.d.ts +6 -0
- package/dist/components/full-calendar/types/calendar-week-hour.js +2 -0
- package/dist/components/full-calendar/types/calendar-week-hour.js.map +1 -0
- package/dist/components/horizontal-scroll.d.ts +11 -0
- package/dist/components/horizontal-scroll.js +2 -0
- package/dist/components/horizontal-scroll.js.map +1 -0
- package/dist/components/icon.d.ts +3 -4
- package/dist/components/icon.js +1 -1
- package/dist/components/selection-bar.d.ts +57 -0
- package/dist/components/selection-bar.js +2 -0
- package/dist/components/selection-bar.js.map +1 -0
- package/dist/components/sheet.d.ts +8 -8
- package/dist/components/sheet.js +1 -1
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/table.js +1 -1
- package/dist/components/tag.d.ts +2 -1
- package/dist/components/tag.js +1 -1
- package/dist/components/upload.d.ts +74 -0
- package/dist/components/upload.js +2 -0
- package/dist/components/upload.js.map +1 -0
- package/dist/icons-CmDuL0gZ.d.ts +4 -0
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/package.json +22 -13
- package/src/components/breadcrumb.tsx +119 -0
- package/src/components/dialog.tsx +242 -0
- package/src/components/drag-and-drop/drag-handle.tsx +46 -0
- package/src/components/drag-and-drop/drag-list-item.tsx +91 -0
- package/src/components/drag-and-drop/drag-list.tsx +47 -0
- package/src/components/drag-and-drop/drag-root.tsx +30 -0
- package/src/components/drag-and-drop/index.ts +39 -0
- package/src/components/drag-and-drop/types/drag-item.ts +7 -0
- package/src/components/{calendar.tsx → form/calendar.tsx} +2 -2
- package/src/components/{checkbox.tsx → form/checkbox.tsx} +2 -2
- package/src/components/form/context/field.context.ts +27 -0
- package/src/components/form/date-picker.tsx +199 -0
- package/src/components/form/floating-label.tsx +60 -0
- package/src/components/form/input.tsx +235 -0
- package/src/components/{radio.tsx → form/radio.tsx} +1 -1
- package/src/components/{rich-editor.tsx → form/rich-editor.tsx} +6 -6
- package/src/components/{search-input.tsx → form/search-input.tsx} +2 -2
- package/src/components/form/select.tsx +274 -0
- package/src/components/full-calendar/calendar-add-event.tsx +15 -0
- package/src/components/full-calendar/calendar-body.tsx +12 -0
- package/src/components/full-calendar/calendar-cell.tsx +120 -0
- package/src/components/full-calendar/calendar-day-view.tsx +76 -0
- package/src/components/full-calendar/calendar-event.tsx +178 -0
- package/src/components/full-calendar/calendar-header.tsx +14 -0
- package/src/components/full-calendar/calendar-month-view.tsx +69 -0
- package/src/components/full-calendar/calendar-more-events-dropdown.tsx +39 -0
- package/src/components/full-calendar/calendar-navigator.tsx +86 -0
- package/src/components/full-calendar/calendar-root.tsx +165 -0
- package/src/components/full-calendar/calendar-today-button.tsx +21 -0
- package/src/components/full-calendar/calendar-toggle-view.tsx +61 -0
- package/src/components/full-calendar/calendar-view-renderer.tsx +19 -0
- package/src/components/full-calendar/calendar-week-day.tsx +49 -0
- package/src/components/full-calendar/calendar-week-view.tsx +88 -0
- package/src/components/full-calendar/helpers/calendar.ts +158 -0
- package/src/components/full-calendar/index.ts +16 -0
- package/src/components/full-calendar/types/calendar-cell.ts +4 -0
- package/src/components/full-calendar/types/calendar-event.ts +7 -0
- package/src/components/full-calendar/types/calendar-view.ts +1 -0
- package/src/components/full-calendar/types/calendar-week-hour.ts +4 -0
- package/src/components/horizontal-scroll.tsx +159 -0
- package/src/components/selection-bar.tsx +273 -0
- package/src/components/sheet.tsx +2 -2
- package/src/components/upload.tsx +647 -0
- package/src/resources/icons.ts +4 -1
- package/dist/chunk-FASEHVMD.js.map +0 -1
- package/dist/chunk-NPTLORW5.js +0 -2
- package/dist/chunk-NPTLORW5.js.map +0 -1
- package/dist/chunk-SHHXKVVR.js +0 -2
- package/dist/chunk-SHHXKVVR.js.map +0 -1
- package/dist/components/button.js +0 -2
- package/dist/components/calendar.js +0 -2
- package/dist/components/calendar.js.map +0 -1
- package/dist/components/checkbox.js +0 -2
- package/dist/components/checkbox.js.map +0 -1
- package/dist/components/date-picker.d.ts +0 -25
- package/dist/components/date-picker.js +0 -2
- package/dist/components/date-picker.js.map +0 -1
- package/dist/components/input.d.ts +0 -37
- package/dist/components/input.js +0 -2
- package/dist/components/input.js.map +0 -1
- package/dist/components/otp-input.js.map +0 -1
- package/dist/components/radio.js +0 -2
- package/dist/components/radio.js.map +0 -1
- package/dist/components/rich-editor.js +0 -2
- package/dist/components/rich-editor.js.map +0 -1
- package/dist/components/search-input.js +0 -2
- package/dist/components/search-input.js.map +0 -1
- package/dist/components/select.d.ts +0 -36
- package/dist/components/select.js +0 -2
- package/dist/components/select.js.map +0 -1
- package/dist/components/switch.js.map +0 -1
- package/src/components/date-picker.tsx +0 -263
- package/src/components/input.tsx +0 -320
- package/src/components/select.tsx +0 -318
- /package/dist/components/{button.d.ts → form/button.d.ts} +0 -0
- /package/dist/components/{button.js.map → form/button.js.map} +0 -0
- /package/dist/components/{calendar.d.ts → form/calendar.d.ts} +0 -0
- /package/dist/components/{checkbox.d.ts → form/checkbox.d.ts} +0 -0
- /package/dist/components/{otp-input.d.ts → form/otp-input.d.ts} +0 -0
- /package/dist/components/{otp-input.js → form/otp-input.js} +0 -0
- /package/dist/components/{radio.d.ts → form/radio.d.ts} +0 -0
- /package/dist/components/{rich-editor.d.ts → form/rich-editor.d.ts} +0 -0
- /package/dist/components/{search-input.d.ts → form/search-input.d.ts} +0 -0
- /package/dist/components/{switch.d.ts → form/switch.d.ts} +0 -0
- /package/src/components/{button.tsx → form/button.tsx} +0 -0
- /package/src/components/{otp-input.tsx → form/otp-input.tsx} +0 -0
- /package/src/components/{switch.tsx → form/switch.tsx} +0 -0
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext } from 'react'
|
|
2
|
-
import type { ComponentProps } from 'react'
|
|
3
|
-
import * as RadixPopover from '@radix-ui/react-popover'
|
|
4
|
-
import { tv, twJoin, twMerge } from '@xjur-ui/util'
|
|
5
|
-
import { Typography, type TypographyProps } from './typography'
|
|
6
|
-
|
|
7
|
-
const DatePickerContext = createContext({
|
|
8
|
-
disabled: false,
|
|
9
|
-
variant: 'filled' as 'filled' | 'outlined',
|
|
10
|
-
hasError: false
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
function useDatePicker() {
|
|
14
|
-
const context = useContext(DatePickerContext)
|
|
15
|
-
if (!context) {
|
|
16
|
-
throw new Error('useDatePicker must be used within a DatePickerRoot')
|
|
17
|
-
}
|
|
18
|
-
return context
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function DatePickerRoot({
|
|
22
|
-
disabled = false,
|
|
23
|
-
variant = 'filled',
|
|
24
|
-
hasError = false,
|
|
25
|
-
...props
|
|
26
|
-
}: ComponentProps<typeof RadixPopover.Root> & {
|
|
27
|
-
disabled?: boolean
|
|
28
|
-
variant?: 'filled' | 'outlined'
|
|
29
|
-
hasError?: boolean
|
|
30
|
-
}) {
|
|
31
|
-
return (
|
|
32
|
-
<DatePickerContext.Provider value={{ disabled, variant, hasError }}>
|
|
33
|
-
<RadixPopover.Root {...props} />
|
|
34
|
-
</DatePickerContext.Provider>
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function DatePickerTrigger({
|
|
39
|
-
className,
|
|
40
|
-
...props
|
|
41
|
-
}: ComponentProps<typeof RadixPopover.Trigger>) {
|
|
42
|
-
const { disabled, variant, hasError } = useDatePicker()
|
|
43
|
-
|
|
44
|
-
const trigger = tv({
|
|
45
|
-
base: twMerge(
|
|
46
|
-
'border border-transparent group h-large-4x rounded-small-1x gap-small py-small_1x-alt px-small relative flex w-full items-center cursor-pointer',
|
|
47
|
-
'data-[state=open]:border-primary-idle',
|
|
48
|
-
'has-[input:not(:placeholder-shown)]:text-primary-idle',
|
|
49
|
-
'has-[input:not(:placeholder-shown)]:border-primary-idle',
|
|
50
|
-
'focus-within:border-primary-idle focus-within:hover:border-primary-idle',
|
|
51
|
-
'hover:border-border-layer-1'
|
|
52
|
-
),
|
|
53
|
-
variants: {
|
|
54
|
-
variant: {
|
|
55
|
-
filled: 'bg-layer-2-hover',
|
|
56
|
-
outlined:
|
|
57
|
-
'bg-layer-2-idle border-border-layer-2 hover:border-border-layer-3',
|
|
58
|
-
disabled:
|
|
59
|
-
'hover:border-transparent border-none bg-layer-2-idle cursor-text select-text'
|
|
60
|
-
},
|
|
61
|
-
state: {
|
|
62
|
-
idle: '',
|
|
63
|
-
error: twMerge(
|
|
64
|
-
'focus-within:border-danger-idle hover:border-danger-idle border-danger-idle focus-within:hover:border-danger-idle',
|
|
65
|
-
'data-[state=open]:border-danger-idle has-[input:not(:placeholder-shown)]:border-danger-idle'
|
|
66
|
-
)
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
defaultVariants: {
|
|
70
|
-
variant: 'filled',
|
|
71
|
-
state: 'idle'
|
|
72
|
-
}
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<RadixPopover.Trigger
|
|
77
|
-
className={trigger({
|
|
78
|
-
variant: disabled ? 'disabled' : variant,
|
|
79
|
-
state: hasError ? 'error' : 'idle',
|
|
80
|
-
className
|
|
81
|
-
})}
|
|
82
|
-
{...props}
|
|
83
|
-
disabled={disabled}
|
|
84
|
-
/>
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function DatePickerContent({
|
|
89
|
-
className,
|
|
90
|
-
sideOffset = 5,
|
|
91
|
-
side = 'bottom',
|
|
92
|
-
align = 'start',
|
|
93
|
-
...props
|
|
94
|
-
}: ComponentProps<typeof RadixPopover.Content>) {
|
|
95
|
-
return (
|
|
96
|
-
<RadixPopover.Portal>
|
|
97
|
-
<RadixPopover.Content
|
|
98
|
-
align={align}
|
|
99
|
-
className={twJoin(
|
|
100
|
-
className,
|
|
101
|
-
'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)]'
|
|
102
|
-
)}
|
|
103
|
-
side={side}
|
|
104
|
-
sideOffset={sideOffset}
|
|
105
|
-
{...props}
|
|
106
|
-
/>
|
|
107
|
-
</RadixPopover.Portal>
|
|
108
|
-
)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export function DatePickerValue({
|
|
112
|
-
className,
|
|
113
|
-
displayValue = '',
|
|
114
|
-
value,
|
|
115
|
-
...props
|
|
116
|
-
}: ComponentProps<'input'> & { displayValue?: string }) {
|
|
117
|
-
return (
|
|
118
|
-
<>
|
|
119
|
-
{!!displayValue && (
|
|
120
|
-
<Typography className="text-neutral-dark group-has-[div[data-slot=date-picker-left-slot]]:pl-large-1x">
|
|
121
|
-
{displayValue}
|
|
122
|
-
</Typography>
|
|
123
|
-
)}
|
|
124
|
-
|
|
125
|
-
<input
|
|
126
|
-
{...props}
|
|
127
|
-
aria-readonly={true}
|
|
128
|
-
className={twJoin('pointer-events-none', className)}
|
|
129
|
-
hidden={true}
|
|
130
|
-
placeholder={props.placeholder ?? ' '}
|
|
131
|
-
readOnly={true}
|
|
132
|
-
value={value ?? ''}
|
|
133
|
-
/>
|
|
134
|
-
</>
|
|
135
|
-
)
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export function DatePickerLabel({
|
|
139
|
-
className,
|
|
140
|
-
htmlFor,
|
|
141
|
-
children,
|
|
142
|
-
...props
|
|
143
|
-
}: TypographyProps & { htmlFor?: string }) {
|
|
144
|
-
const { variant, disabled, hasError } = useDatePicker()
|
|
145
|
-
|
|
146
|
-
return (
|
|
147
|
-
<Typography
|
|
148
|
-
asChild={true}
|
|
149
|
-
className={twJoin(
|
|
150
|
-
'group inline-block max-w-full truncate text-left font-normal',
|
|
151
|
-
'left-small right-small pointer-events-none absolute top-1/2 -translate-y-1/2',
|
|
152
|
-
'ease transition-all duration-250',
|
|
153
|
-
// Content Open
|
|
154
|
-
'group-data-[state=open]:text-primary-idle group-data-[state=open]:data-[error=true]:text-danger-label-active',
|
|
155
|
-
'group-data-[state=open]:-top-[3px]',
|
|
156
|
-
'group-data-[state=open]:text-size-label-sm-1x',
|
|
157
|
-
'group-data-[state=open]:font-medium',
|
|
158
|
-
// Filled
|
|
159
|
-
'group-has-[input:not(:placeholder-shown)]:text-primary-idle group-has-[input:not(:placeholder-shown)]:data-[error=true]:text-danger-label-active',
|
|
160
|
-
'group-has-[input:not(:placeholder-shown)]:-top-[3px]',
|
|
161
|
-
'group-has-[input:not(:placeholder-shown)]:text-size-label-sm-1x',
|
|
162
|
-
'group-has-[input:not(:placeholder-shown)]:font-medium',
|
|
163
|
-
// If has left slot
|
|
164
|
-
'group-has-[div[data-slot=date-picker-left-slot]]:left-large-4x',
|
|
165
|
-
'group-has-[div[data-slot=date-picker-left-slot]]:group-data-[state=open]:left-small',
|
|
166
|
-
'group-has-[div[data-slot=date-picker-left-slot]]:group-has-[input:not(:placeholder-shown)]:left-small',
|
|
167
|
-
// If has right slot
|
|
168
|
-
'group-has-[div[data-slot=date-picker-right-slot]]:right-large-4x',
|
|
169
|
-
'group-has-[div[data-slot=date-picker-right-slot]]:group-data-[state=open]:right-small',
|
|
170
|
-
'group-has-[div[data-slot=date-picker-right-slot]]:group-has-[input:not(:placeholder-shown)]:right-small',
|
|
171
|
-
// Animate
|
|
172
|
-
'group-data-[state=open]:animate-in',
|
|
173
|
-
'group-data-[state=closed]:animate-out',
|
|
174
|
-
'group-has-[input:not(:placeholder-shown)]:animate-out',
|
|
175
|
-
'data-[disabled=true]:hidden',
|
|
176
|
-
|
|
177
|
-
className
|
|
178
|
-
)}
|
|
179
|
-
data-disabled={disabled}
|
|
180
|
-
data-error={hasError}
|
|
181
|
-
data-variant={variant}
|
|
182
|
-
weight="medium"
|
|
183
|
-
{...props}
|
|
184
|
-
>
|
|
185
|
-
<label htmlFor={htmlFor}>
|
|
186
|
-
<span
|
|
187
|
-
className={twJoin(
|
|
188
|
-
'rounded-small-1x max-w-full',
|
|
189
|
-
'group-data-[variant=outlined]:bg-layer-2-idle',
|
|
190
|
-
'group-data-[variant=filled]:bg-layer-2-hover'
|
|
191
|
-
)}
|
|
192
|
-
>
|
|
193
|
-
{children}
|
|
194
|
-
</span>
|
|
195
|
-
</label>
|
|
196
|
-
</Typography>
|
|
197
|
-
)
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export function DatePickerLeftSlot({
|
|
201
|
-
className,
|
|
202
|
-
...props
|
|
203
|
-
}: ComponentProps<'div'>) {
|
|
204
|
-
return (
|
|
205
|
-
<div
|
|
206
|
-
{...props}
|
|
207
|
-
className={twJoin(
|
|
208
|
-
className,
|
|
209
|
-
'left-small absolute top-1/2 flex -translate-y-1/2 items-center justify-center'
|
|
210
|
-
)}
|
|
211
|
-
data-slot="date-picker-left-slot"
|
|
212
|
-
/>
|
|
213
|
-
)
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export function DatePickerRightSlot({
|
|
217
|
-
className,
|
|
218
|
-
...props
|
|
219
|
-
}: ComponentProps<'div'>) {
|
|
220
|
-
return (
|
|
221
|
-
<div
|
|
222
|
-
{...props}
|
|
223
|
-
className={twJoin(
|
|
224
|
-
className,
|
|
225
|
-
'right-small absolute top-1/2 flex -translate-y-1/2 items-center justify-center'
|
|
226
|
-
)}
|
|
227
|
-
data-slot="date-picker-right-slot"
|
|
228
|
-
/>
|
|
229
|
-
)
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export function DatePickerCaption({
|
|
233
|
-
className,
|
|
234
|
-
variant = 'body',
|
|
235
|
-
size = 'sm',
|
|
236
|
-
weight = 'normal',
|
|
237
|
-
...props
|
|
238
|
-
}: ComponentProps<typeof Typography>) {
|
|
239
|
-
const { hasError } = useDatePicker()
|
|
240
|
-
|
|
241
|
-
const caption = tv({
|
|
242
|
-
base: 'text-size-body-sm mt-small-1x font-normal',
|
|
243
|
-
variants: {
|
|
244
|
-
state: {
|
|
245
|
-
error: 'text-danger-label-active',
|
|
246
|
-
idle: 'text-neutral-dark'
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
})
|
|
250
|
-
|
|
251
|
-
return (
|
|
252
|
-
<Typography
|
|
253
|
-
className={caption({
|
|
254
|
-
state: hasError ? 'error' : 'idle',
|
|
255
|
-
className
|
|
256
|
-
})}
|
|
257
|
-
size={size}
|
|
258
|
-
variant={variant}
|
|
259
|
-
weight={weight}
|
|
260
|
-
{...props}
|
|
261
|
-
/>
|
|
262
|
-
)
|
|
263
|
-
}
|
package/src/components/input.tsx
DELETED
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
import { tv, twMerge } from '@xjur-ui/util'
|
|
2
|
-
import type { ComponentProps } from 'react'
|
|
3
|
-
import { createContext, useContext, useMemo } 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
|
-
import { Typography } from './typography'
|
|
11
|
-
|
|
12
|
-
export { inputMask, type InputMaskType, type MaskOptions }
|
|
13
|
-
|
|
14
|
-
export type InputProps = {
|
|
15
|
-
variant?: 'outlined' | 'filled'
|
|
16
|
-
disabled?: boolean
|
|
17
|
-
hasError?: boolean
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const FieldContext = createContext<InputProps>({
|
|
21
|
-
variant: 'filled',
|
|
22
|
-
disabled: false,
|
|
23
|
-
hasError: false
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
function useInput() {
|
|
27
|
-
const context = useContext(FieldContext)
|
|
28
|
-
if (!context) {
|
|
29
|
-
throw new Error('useInput must be used within a InputRoot')
|
|
30
|
-
}
|
|
31
|
-
return context
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function InputRoot({
|
|
35
|
-
className,
|
|
36
|
-
children,
|
|
37
|
-
variant = 'filled',
|
|
38
|
-
disabled = false,
|
|
39
|
-
hasError = false,
|
|
40
|
-
...props
|
|
41
|
-
}: ComponentProps<'div'> & InputProps) {
|
|
42
|
-
const providerValue = useMemo(
|
|
43
|
-
() => ({ variant, disabled, hasError }),
|
|
44
|
-
[variant, disabled, hasError]
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<FieldContext.Provider value={providerValue}>
|
|
49
|
-
<div
|
|
50
|
-
className={twMerge('group relative flex w-full flex-col', className)}
|
|
51
|
-
{...props}
|
|
52
|
-
>
|
|
53
|
-
{children}
|
|
54
|
-
</div>
|
|
55
|
-
</FieldContext.Provider>
|
|
56
|
-
)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function InputContent({ className, ...props }: ComponentProps<'div'>) {
|
|
60
|
-
const content = tv({
|
|
61
|
-
base: twMerge(
|
|
62
|
-
'border border-transparent relative h-large-4x rounded-small-1x gap-small py-small_1x-alt px-small flex items-center w-full',
|
|
63
|
-
'group-has-[div[data-slot=input-right-action-slot]]:rounded-r-none',
|
|
64
|
-
'group-has-[div[data-slot=input-left-action-slot]]:rounded-l-none',
|
|
65
|
-
'focus-within:border-primary-idle focus-within:hover:border-primary-idle',
|
|
66
|
-
'hover:border-border-layer-1'
|
|
67
|
-
),
|
|
68
|
-
variants: {
|
|
69
|
-
variant: {
|
|
70
|
-
filled: 'bg-layer-2-hover',
|
|
71
|
-
outlined:
|
|
72
|
-
'bg-layer-2-idle border-border-layer-2 hover:border-border-layer-3',
|
|
73
|
-
disabled: 'hover:border-transparent border-none bg-layer-2-idle'
|
|
74
|
-
},
|
|
75
|
-
state: {
|
|
76
|
-
idle: '',
|
|
77
|
-
error:
|
|
78
|
-
'focus-within:border-danger-idle hover:border-danger-idle border-danger-idle focus-within:hover:border-danger-idle'
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
defaultVariants: {
|
|
82
|
-
variant: 'filled',
|
|
83
|
-
state: 'idle'
|
|
84
|
-
}
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<FieldContext.Consumer>
|
|
89
|
-
{({ variant, disabled, hasError }) => {
|
|
90
|
-
return (
|
|
91
|
-
<div
|
|
92
|
-
className={content({
|
|
93
|
-
variant: disabled ? 'disabled' : variant,
|
|
94
|
-
state: hasError ? 'error' : 'idle',
|
|
95
|
-
className
|
|
96
|
-
})}
|
|
97
|
-
{...props}
|
|
98
|
-
/>
|
|
99
|
-
)
|
|
100
|
-
}}
|
|
101
|
-
</FieldContext.Consumer>
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export function InputLabel({
|
|
106
|
-
htmlFor,
|
|
107
|
-
className,
|
|
108
|
-
children,
|
|
109
|
-
...props
|
|
110
|
-
}: ComponentProps<typeof Typography> & { htmlFor: string }) {
|
|
111
|
-
return (
|
|
112
|
-
<FieldContext.Consumer>
|
|
113
|
-
{({ variant, disabled, hasError }) => {
|
|
114
|
-
return (
|
|
115
|
-
<Typography
|
|
116
|
-
asChild={true}
|
|
117
|
-
className={twMerge(
|
|
118
|
-
'group inline-block max-w-full truncate text-left',
|
|
119
|
-
'ease animate-in left-small right-small pointer-events-none absolute top-1/2 -translate-y-1/2 transition-all duration-250',
|
|
120
|
-
// Filled
|
|
121
|
-
'group-focus-within:!text-primary-idle group-focus-within:data-[has-error=true]:!text-danger-label-active group-focus-within:-top-[3px]',
|
|
122
|
-
'group-focus-within:text-size-label-sm-1x group-focus-within:font-medium',
|
|
123
|
-
'group-has-[input:not(:placeholder-shown)]:-top-[3px]',
|
|
124
|
-
'group-has-[input:not(:placeholder-shown)]:text-size-label-sm-1x',
|
|
125
|
-
'group-has-[input:not(:placeholder-shown)]:font-medium',
|
|
126
|
-
'group-has-[input:not(:placeholder-shown)]:!text-primary-idle',
|
|
127
|
-
'group-has-[input:not(:placeholder-shown)]:!text-danger-label-active',
|
|
128
|
-
// If has left slot
|
|
129
|
-
'group-has-[div[data-slot=input-left-slot]]:left-large-4x',
|
|
130
|
-
'group-has-[div[data-slot=input-left-slot]]:group-focus-within:left-small',
|
|
131
|
-
'group-has-[div[data-slot=input-left-slot]]:group-has-[input:not(:placeholder-shown)]:left-small',
|
|
132
|
-
// If has right slot
|
|
133
|
-
'group-has-[div[data-slot=input-right-slot]]:right-large-4x',
|
|
134
|
-
'group-has-[div[data-slot=input-right-slot]]:group-focus-within:right-small',
|
|
135
|
-
'group-has-[div[data-slot=input-right-slot]]:group-has-[input:not(:placeholder-shown)]:right-small',
|
|
136
|
-
// Animate
|
|
137
|
-
'group-focus-within:animate-in',
|
|
138
|
-
'group-has-[input:not(:placeholder-shown)]:animate-out',
|
|
139
|
-
'data-[disabled=true]:hidden',
|
|
140
|
-
className
|
|
141
|
-
)}
|
|
142
|
-
data-disabled={disabled}
|
|
143
|
-
data-has-error={hasError}
|
|
144
|
-
data-variant={variant}
|
|
145
|
-
{...props}
|
|
146
|
-
>
|
|
147
|
-
<label htmlFor={htmlFor}>
|
|
148
|
-
<span
|
|
149
|
-
className={twMerge(
|
|
150
|
-
'rounded-small-1x max-w-full',
|
|
151
|
-
'group-data-[variant=outlined]:group-focus-within:bg-layer-2-idle group-data-[variant=filled]:group-focus-within:bg-layer-2-hover',
|
|
152
|
-
'group-data-[variant=outlined]:bg-layer-2-idle group-data-[variant=filled]:bg-layer-2-hover'
|
|
153
|
-
)}
|
|
154
|
-
>
|
|
155
|
-
{children}
|
|
156
|
-
</span>
|
|
157
|
-
</label>
|
|
158
|
-
</Typography>
|
|
159
|
-
)
|
|
160
|
-
}}
|
|
161
|
-
</FieldContext.Consumer>
|
|
162
|
-
)
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export function InputText({
|
|
166
|
-
className,
|
|
167
|
-
maskOptions,
|
|
168
|
-
maskType,
|
|
169
|
-
...props
|
|
170
|
-
}: ComponentProps<'input'> & {
|
|
171
|
-
maskOptions?: MaskOptions
|
|
172
|
-
maskType?: InputMaskType
|
|
173
|
-
}) {
|
|
174
|
-
const { disabled } = useInput()
|
|
175
|
-
const Component = maskOptions || maskType ? InputMask : 'input'
|
|
176
|
-
|
|
177
|
-
return (
|
|
178
|
-
<Component
|
|
179
|
-
{...props}
|
|
180
|
-
disabled={disabled}
|
|
181
|
-
{...(maskType
|
|
182
|
-
? { ...inputMask(maskType) }
|
|
183
|
-
: maskOptions && { ...maskOptions })}
|
|
184
|
-
className={twMerge(
|
|
185
|
-
className,
|
|
186
|
-
'peer !text-size-body-md text-neutral-dark flex-1 outline-none',
|
|
187
|
-
'group-has-[div[data-slot=input-left-slot]]:pl-large-1x ml-small-1x'
|
|
188
|
-
)}
|
|
189
|
-
placeholder={props.placeholder || ' '}
|
|
190
|
-
{...(maskOptions && { ...maskOptions })}
|
|
191
|
-
/>
|
|
192
|
-
)
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export function InputNumber({
|
|
196
|
-
className,
|
|
197
|
-
locales = 'pt-BR',
|
|
198
|
-
...props
|
|
199
|
-
}: InputNumberFormatProps) {
|
|
200
|
-
const { disabled } = useInput()
|
|
201
|
-
return (
|
|
202
|
-
<InputNumberFormat
|
|
203
|
-
{...props}
|
|
204
|
-
className={twMerge(
|
|
205
|
-
className,
|
|
206
|
-
'peer !text-size-body-md text-neutral-dark flex-1 font-medium outline-none',
|
|
207
|
-
'group-has-[div[data-slot=input-left-slot]]:pl-large-1x ml-small-1x'
|
|
208
|
-
)}
|
|
209
|
-
disabled={disabled}
|
|
210
|
-
locales={locales}
|
|
211
|
-
placeholder={props.placeholder || ' '}
|
|
212
|
-
/>
|
|
213
|
-
)
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export function InputLeftSlot({ className, ...props }: ComponentProps<'div'>) {
|
|
217
|
-
return (
|
|
218
|
-
<div
|
|
219
|
-
{...props}
|
|
220
|
-
className={twMerge(
|
|
221
|
-
className,
|
|
222
|
-
'left-small absolute top-1/2 flex -translate-y-1/2 items-center justify-center'
|
|
223
|
-
)}
|
|
224
|
-
data-slot="input-left-slot"
|
|
225
|
-
/>
|
|
226
|
-
)
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export function InputRightSlot({ className, ...props }: ComponentProps<'div'>) {
|
|
230
|
-
return (
|
|
231
|
-
<div
|
|
232
|
-
{...props}
|
|
233
|
-
className={twMerge(
|
|
234
|
-
className,
|
|
235
|
-
'right-small absolute top-1/2 flex -translate-y-1/2 items-center justify-center'
|
|
236
|
-
)}
|
|
237
|
-
data-slot="input-right-slot"
|
|
238
|
-
/>
|
|
239
|
-
)
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
export function InputCaption({
|
|
243
|
-
className,
|
|
244
|
-
variant = 'body',
|
|
245
|
-
size = 'sm',
|
|
246
|
-
weight = 'normal',
|
|
247
|
-
...props
|
|
248
|
-
}: ComponentProps<typeof Typography>) {
|
|
249
|
-
const { hasError } = useInput()
|
|
250
|
-
|
|
251
|
-
const caption = tv({
|
|
252
|
-
base: 'text-size-body-sm mt-small-1x font-normal',
|
|
253
|
-
variants: {
|
|
254
|
-
state: {
|
|
255
|
-
error: 'text-danger-label-active',
|
|
256
|
-
idle: 'text-neutral-dark'
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
})
|
|
260
|
-
|
|
261
|
-
return (
|
|
262
|
-
<Typography
|
|
263
|
-
className={caption({
|
|
264
|
-
state: hasError ? 'error' : 'idle',
|
|
265
|
-
className
|
|
266
|
-
})}
|
|
267
|
-
size={size}
|
|
268
|
-
variant={variant}
|
|
269
|
-
weight={weight}
|
|
270
|
-
{...props}
|
|
271
|
-
/>
|
|
272
|
-
)
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
export function InputContainer({ className, ...props }: ComponentProps<'div'>) {
|
|
276
|
-
return (
|
|
277
|
-
<div
|
|
278
|
-
{...props}
|
|
279
|
-
className={twMerge(className, 'flex items-center')}
|
|
280
|
-
data-slot="input-content"
|
|
281
|
-
/>
|
|
282
|
-
)
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
export function InputAction({
|
|
286
|
-
className,
|
|
287
|
-
side,
|
|
288
|
-
...props
|
|
289
|
-
}: ComponentProps<'div'> & {
|
|
290
|
-
side: 'left' | 'right'
|
|
291
|
-
}) {
|
|
292
|
-
const { disabled } = useInput()
|
|
293
|
-
return (
|
|
294
|
-
<div
|
|
295
|
-
{...props}
|
|
296
|
-
className={twMerge(
|
|
297
|
-
className,
|
|
298
|
-
'group h-large-4x flex items-center justify-center data-[disabled=true]:hidden'
|
|
299
|
-
)}
|
|
300
|
-
data-disabled={disabled}
|
|
301
|
-
data-side={side}
|
|
302
|
-
data-slot={`input-${side}-action-slot`}
|
|
303
|
-
/>
|
|
304
|
-
)
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
export function InputActionButton({
|
|
308
|
-
className,
|
|
309
|
-
...props
|
|
310
|
-
}: ComponentProps<'div'>) {
|
|
311
|
-
return (
|
|
312
|
-
<div
|
|
313
|
-
{...props}
|
|
314
|
-
className={twMerge(
|
|
315
|
-
className,
|
|
316
|
-
'h-large-4x w-large-4x bg-layer-2-hover flex cursor-pointer items-center justify-center'
|
|
317
|
-
)}
|
|
318
|
-
/>
|
|
319
|
-
)
|
|
320
|
-
}
|