@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
|
@@ -0,0 +1,647 @@
|
|
|
1
|
+
import type { ComponentProps, DragEvent, ChangeEvent } from 'react'
|
|
2
|
+
import { useRef, useState, useCallback, createContext, useContext } from 'react'
|
|
3
|
+
import { cva, cx, type ClassVariantProps } from '@xjur-ui/util'
|
|
4
|
+
import { Icon, type IconType } from './icon'
|
|
5
|
+
import { Button } from './form/button'
|
|
6
|
+
import { Switch } from './form/switch'
|
|
7
|
+
import { InputRoot, InputContent, InputText } from './form/input'
|
|
8
|
+
import {
|
|
9
|
+
SelectRoot,
|
|
10
|
+
SelectTrigger,
|
|
11
|
+
SelectContent,
|
|
12
|
+
SelectOption
|
|
13
|
+
} from './form/select'
|
|
14
|
+
|
|
15
|
+
export interface FileFormat {
|
|
16
|
+
name: string
|
|
17
|
+
type: string
|
|
18
|
+
fileBinary: File
|
|
19
|
+
restrict?: boolean
|
|
20
|
+
description?: string
|
|
21
|
+
fileType?: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface FileTypeOption {
|
|
25
|
+
value: string
|
|
26
|
+
label: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface UploadContextValue {
|
|
30
|
+
files: FileFormat[]
|
|
31
|
+
onFilesChange?: (files: FileFormat[]) => void
|
|
32
|
+
accept?: string
|
|
33
|
+
multiple?: boolean
|
|
34
|
+
disabled?: boolean
|
|
35
|
+
maxFiles?: number
|
|
36
|
+
maxSize?: number
|
|
37
|
+
acceptedFormats?: string[]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const UploadContext = createContext<UploadContextValue | null>(null)
|
|
41
|
+
|
|
42
|
+
function useUploadContext() {
|
|
43
|
+
const context = useContext(UploadContext)
|
|
44
|
+
if (!context) {
|
|
45
|
+
throw new Error('Upload components must be used within UploadRoot')
|
|
46
|
+
}
|
|
47
|
+
return context
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface UploadRootProps extends ComponentProps<'div'> {
|
|
51
|
+
files: FileFormat[]
|
|
52
|
+
onFilesChange?: (files: FileFormat[]) => void
|
|
53
|
+
accept?: string
|
|
54
|
+
multiple?: boolean
|
|
55
|
+
disabled?: boolean
|
|
56
|
+
maxFiles?: number
|
|
57
|
+
maxSize?: number
|
|
58
|
+
acceptedFormats?: string[]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function UploadRoot({
|
|
62
|
+
children,
|
|
63
|
+
className,
|
|
64
|
+
files,
|
|
65
|
+
onFilesChange,
|
|
66
|
+
accept,
|
|
67
|
+
multiple = false,
|
|
68
|
+
disabled = false,
|
|
69
|
+
maxFiles = 1,
|
|
70
|
+
maxSize,
|
|
71
|
+
acceptedFormats = ['.jpeg', '.png', '.webp'],
|
|
72
|
+
...props
|
|
73
|
+
}: UploadRootProps) {
|
|
74
|
+
return (
|
|
75
|
+
<UploadContext.Provider
|
|
76
|
+
value={{
|
|
77
|
+
files,
|
|
78
|
+
onFilesChange,
|
|
79
|
+
accept,
|
|
80
|
+
multiple,
|
|
81
|
+
disabled,
|
|
82
|
+
maxFiles,
|
|
83
|
+
maxSize,
|
|
84
|
+
acceptedFormats
|
|
85
|
+
}}
|
|
86
|
+
>
|
|
87
|
+
<div className={cx('flex flex-col gap-4', className)} {...props}>
|
|
88
|
+
{children}
|
|
89
|
+
</div>
|
|
90
|
+
</UploadContext.Provider>
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const uploadAreaVariants = cva(
|
|
95
|
+
[
|
|
96
|
+
'flex flex-col items-center justify-center',
|
|
97
|
+
'relative border-2 border-dashed border-border-layer-2 rounded-lg transition-all duration-200 ease-in-out cursor-pointer',
|
|
98
|
+
'hover:border-border-layer-2 hover:bg-transparent',
|
|
99
|
+
'focus-within:border-primary-idle focus-within:ring-2 focus-within:ring-primary-idle/20',
|
|
100
|
+
'data-[drag-over=true]:border-primary-idle data-[drag-over=true]:bg-primary-alt-idle/10'
|
|
101
|
+
],
|
|
102
|
+
{
|
|
103
|
+
variants: {
|
|
104
|
+
size: {
|
|
105
|
+
large: 'p-6 min-h-[200px] ',
|
|
106
|
+
medium: 'p-6 min-h-[160px]',
|
|
107
|
+
small: 'p-6 min-h-[130px]',
|
|
108
|
+
oneLine: 'p-4 min-h-[18px]'
|
|
109
|
+
},
|
|
110
|
+
showButton: {
|
|
111
|
+
true: '',
|
|
112
|
+
false: ''
|
|
113
|
+
},
|
|
114
|
+
variant: {
|
|
115
|
+
default: 'bg-white',
|
|
116
|
+
transparent: 'bg-transparent',
|
|
117
|
+
minimal: 'bg-white',
|
|
118
|
+
oneLineWhite: 'bg-white',
|
|
119
|
+
oneLineTransparent: 'bg-transparent'
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
compoundVariants: [
|
|
123
|
+
{
|
|
124
|
+
size: 'large',
|
|
125
|
+
showButton: true
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
size: 'medium',
|
|
129
|
+
showButton: true
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
size: 'small',
|
|
133
|
+
showButton: true
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
variant: 'oneLineWhite',
|
|
137
|
+
showButton: false,
|
|
138
|
+
className: 'items-center flex flex-row justify-center'
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
variant: 'oneLineTransparent',
|
|
142
|
+
showButton: false,
|
|
143
|
+
className: 'items-center flex flex-row justify-center'
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
defaultVariants: {
|
|
147
|
+
size: 'large',
|
|
148
|
+
variant: 'default',
|
|
149
|
+
showButton: true
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
interface UploadAreaProps
|
|
155
|
+
extends Omit<ComponentProps<'div'>, 'onChange'>,
|
|
156
|
+
ClassVariantProps<typeof uploadAreaVariants> {
|
|
157
|
+
showAcceptedFormats?: boolean
|
|
158
|
+
buttonText?: string
|
|
159
|
+
description?: string
|
|
160
|
+
icon?: string
|
|
161
|
+
showButton?: boolean
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function UploadArea({
|
|
165
|
+
className,
|
|
166
|
+
size = 'large',
|
|
167
|
+
showButton = true,
|
|
168
|
+
variant = 'default',
|
|
169
|
+
showAcceptedFormats = true,
|
|
170
|
+
buttonText = 'Selecionar arquivo',
|
|
171
|
+
description = 'Clique ou solte os arquivos para fazer o upload',
|
|
172
|
+
icon = 'upload',
|
|
173
|
+
...props
|
|
174
|
+
}: UploadAreaProps) {
|
|
175
|
+
const {
|
|
176
|
+
onFilesChange,
|
|
177
|
+
accept,
|
|
178
|
+
multiple,
|
|
179
|
+
disabled,
|
|
180
|
+
maxFiles,
|
|
181
|
+
maxSize,
|
|
182
|
+
acceptedFormats
|
|
183
|
+
} = useUploadContext()
|
|
184
|
+
const [isDragOver, setIsDragOver] = useState(false)
|
|
185
|
+
const fileInputRef = useRef<HTMLInputElement>(null)
|
|
186
|
+
const [dragCounter, setDragCounter] = useState(0)
|
|
187
|
+
|
|
188
|
+
const validateFiles = useCallback(
|
|
189
|
+
(files: File[]): FileFormat[] => {
|
|
190
|
+
let validFiles = files
|
|
191
|
+
|
|
192
|
+
if (maxFiles && maxFiles > 0) {
|
|
193
|
+
validFiles = validFiles.slice(0, maxFiles)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (maxSize) {
|
|
197
|
+
validFiles = validFiles.filter(file => file.size <= maxSize)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (accept) {
|
|
201
|
+
validFiles = validFiles.filter(file => {
|
|
202
|
+
const fileExtension = `.${file.name.split('.').pop()?.toLowerCase()}`
|
|
203
|
+
return acceptedFormats?.some(format =>
|
|
204
|
+
format.startsWith('.')
|
|
205
|
+
? format === fileExtension
|
|
206
|
+
: file.type.includes(format)
|
|
207
|
+
)
|
|
208
|
+
})
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return validFiles.map(file => ({
|
|
212
|
+
name: file.name,
|
|
213
|
+
type: file.type,
|
|
214
|
+
fileBinary: file,
|
|
215
|
+
restrict: false
|
|
216
|
+
}))
|
|
217
|
+
},
|
|
218
|
+
[maxFiles, maxSize, accept, acceptedFormats]
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
const handleDragEnter = useCallback((e: DragEvent<HTMLDivElement>) => {
|
|
222
|
+
e.preventDefault()
|
|
223
|
+
e.stopPropagation()
|
|
224
|
+
setDragCounter(prev => prev + 1)
|
|
225
|
+
setIsDragOver(true)
|
|
226
|
+
}, [])
|
|
227
|
+
|
|
228
|
+
const handleDragLeave = useCallback(
|
|
229
|
+
(e: DragEvent<HTMLDivElement>) => {
|
|
230
|
+
e.preventDefault()
|
|
231
|
+
e.stopPropagation()
|
|
232
|
+
setDragCounter(prev => prev - 1)
|
|
233
|
+
if (dragCounter <= 1) {
|
|
234
|
+
setIsDragOver(false)
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
[dragCounter]
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
const handleDragOver = useCallback((e: DragEvent<HTMLDivElement>) => {
|
|
241
|
+
e.preventDefault()
|
|
242
|
+
e.stopPropagation()
|
|
243
|
+
}, [])
|
|
244
|
+
|
|
245
|
+
const handleDrop = useCallback(
|
|
246
|
+
(e: DragEvent<HTMLDivElement>) => {
|
|
247
|
+
e.preventDefault()
|
|
248
|
+
e.stopPropagation()
|
|
249
|
+
setIsDragOver(false)
|
|
250
|
+
setDragCounter(0)
|
|
251
|
+
|
|
252
|
+
if (disabled) return
|
|
253
|
+
|
|
254
|
+
const files = Array.from(e.dataTransfer.files)
|
|
255
|
+
const validFiles = validateFiles(files)
|
|
256
|
+
|
|
257
|
+
if (validFiles.length > 0) {
|
|
258
|
+
onFilesChange?.(validFiles)
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
[disabled, onFilesChange, validateFiles]
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
const handleFileSelect = useCallback(
|
|
265
|
+
(e: ChangeEvent<HTMLInputElement>) => {
|
|
266
|
+
if (disabled) return
|
|
267
|
+
|
|
268
|
+
const files = Array.from(e.target.files || [])
|
|
269
|
+
const validFiles = validateFiles(files)
|
|
270
|
+
|
|
271
|
+
if (validFiles.length > 0) {
|
|
272
|
+
onFilesChange?.(validFiles)
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
[disabled, onFilesChange, validateFiles]
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
return (
|
|
279
|
+
<UploadAreaTrigger
|
|
280
|
+
{...props}
|
|
281
|
+
aria-disabled={disabled}
|
|
282
|
+
aria-label={description}
|
|
283
|
+
className={cx(
|
|
284
|
+
uploadAreaVariants({ size, showButton, variant }),
|
|
285
|
+
className
|
|
286
|
+
)}
|
|
287
|
+
data-drag-over={isDragOver}
|
|
288
|
+
fileInputRef={fileInputRef}
|
|
289
|
+
onDragEnter={handleDragEnter}
|
|
290
|
+
onDragLeave={handleDragLeave}
|
|
291
|
+
onDragOver={handleDragOver}
|
|
292
|
+
onDrop={handleDrop}
|
|
293
|
+
>
|
|
294
|
+
<input
|
|
295
|
+
accept={accept}
|
|
296
|
+
className="hidden"
|
|
297
|
+
disabled={disabled}
|
|
298
|
+
multiple={multiple}
|
|
299
|
+
ref={fileInputRef}
|
|
300
|
+
type="file"
|
|
301
|
+
onChange={handleFileSelect}
|
|
302
|
+
/>
|
|
303
|
+
|
|
304
|
+
<UploadAreaContent
|
|
305
|
+
buttonText={buttonText}
|
|
306
|
+
description={description}
|
|
307
|
+
icon={icon}
|
|
308
|
+
showAcceptedFormats={showAcceptedFormats}
|
|
309
|
+
showButton={showButton}
|
|
310
|
+
variant={variant || 'default'}
|
|
311
|
+
onButtonClick={() => {
|
|
312
|
+
if (!disabled && fileInputRef.current) {
|
|
313
|
+
fileInputRef.current.click()
|
|
314
|
+
}
|
|
315
|
+
}}
|
|
316
|
+
/>
|
|
317
|
+
</UploadAreaTrigger>
|
|
318
|
+
)
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function UploadTitle({ children, className, ...props }: ComponentProps<'h3'>) {
|
|
322
|
+
return (
|
|
323
|
+
<h3
|
|
324
|
+
className={cx('text-neutral-dark text-lg font-semibold', className)}
|
|
325
|
+
{...props}
|
|
326
|
+
>
|
|
327
|
+
{children}
|
|
328
|
+
</h3>
|
|
329
|
+
)
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
interface UploadAreaContentProps extends ComponentProps<'div'> {
|
|
333
|
+
description?: string
|
|
334
|
+
icon?: string
|
|
335
|
+
showAcceptedFormats?: boolean
|
|
336
|
+
buttonText?: string
|
|
337
|
+
showButton?: boolean
|
|
338
|
+
onButtonClick?: () => void
|
|
339
|
+
variant?:
|
|
340
|
+
| 'default'
|
|
341
|
+
| 'transparent'
|
|
342
|
+
| 'minimal'
|
|
343
|
+
| 'oneLineWhite'
|
|
344
|
+
| 'oneLineTransparent'
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function UploadAreaContent({
|
|
348
|
+
description = 'Clique ou solte os arquivos para fazer o upload',
|
|
349
|
+
icon = 'upload',
|
|
350
|
+
showAcceptedFormats = true,
|
|
351
|
+
buttonText = 'Selecionar arquivo',
|
|
352
|
+
showButton = true,
|
|
353
|
+
onButtonClick,
|
|
354
|
+
variant = 'default',
|
|
355
|
+
className,
|
|
356
|
+
...props
|
|
357
|
+
}: UploadAreaContentProps) {
|
|
358
|
+
const { acceptedFormats } = useUploadContext()
|
|
359
|
+
|
|
360
|
+
const formatAcceptedFormats = () => {
|
|
361
|
+
if (!showAcceptedFormats) return null
|
|
362
|
+
|
|
363
|
+
return (
|
|
364
|
+
<p className="text-neutral-secondary mt-2 text-sm">
|
|
365
|
+
Formatos aceitos: {acceptedFormats?.join(' ')}
|
|
366
|
+
</p>
|
|
367
|
+
)
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
const isOneLineVariant =
|
|
371
|
+
variant === 'oneLineWhite' || variant === 'oneLineTransparent'
|
|
372
|
+
|
|
373
|
+
if (isOneLineVariant) {
|
|
374
|
+
return (
|
|
375
|
+
<div
|
|
376
|
+
{...props}
|
|
377
|
+
className={cx(
|
|
378
|
+
'flex h-full items-center justify-center gap-4 text-center',
|
|
379
|
+
className
|
|
380
|
+
)}
|
|
381
|
+
>
|
|
382
|
+
<Icon
|
|
383
|
+
className="text-neutral-secondary text-4xl"
|
|
384
|
+
name={icon as IconType}
|
|
385
|
+
/>
|
|
386
|
+
<p className="text-neutral-dark text-base font-medium">{description}</p>
|
|
387
|
+
{formatAcceptedFormats()}
|
|
388
|
+
</div>
|
|
389
|
+
)
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
return (
|
|
393
|
+
<div
|
|
394
|
+
{...props}
|
|
395
|
+
className={cx(
|
|
396
|
+
'flex h-full w-full flex-col items-center gap-4 text-center',
|
|
397
|
+
className
|
|
398
|
+
)}
|
|
399
|
+
>
|
|
400
|
+
<div className="flex flex-col items-center">
|
|
401
|
+
<Icon
|
|
402
|
+
className="text-neutral-secondary mb-3 text-4xl"
|
|
403
|
+
name={icon as IconType}
|
|
404
|
+
/>
|
|
405
|
+
|
|
406
|
+
<p className="text-neutral-dark mb-2 text-base font-medium">
|
|
407
|
+
{description}
|
|
408
|
+
</p>
|
|
409
|
+
|
|
410
|
+
{formatAcceptedFormats()}
|
|
411
|
+
</div>
|
|
412
|
+
|
|
413
|
+
{showButton && (
|
|
414
|
+
<div>
|
|
415
|
+
<Button
|
|
416
|
+
size="md"
|
|
417
|
+
variant="primary"
|
|
418
|
+
onClick={e => {
|
|
419
|
+
e.stopPropagation()
|
|
420
|
+
onButtonClick?.()
|
|
421
|
+
}}
|
|
422
|
+
>
|
|
423
|
+
{buttonText}
|
|
424
|
+
</Button>
|
|
425
|
+
</div>
|
|
426
|
+
)}
|
|
427
|
+
</div>
|
|
428
|
+
)
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
interface UploadAreaTriggerProps extends ComponentProps<'div'> {
|
|
432
|
+
fileInputRef?: React.RefObject<HTMLInputElement | null>
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
function UploadAreaTrigger({
|
|
436
|
+
children,
|
|
437
|
+
fileInputRef,
|
|
438
|
+
...props
|
|
439
|
+
}: UploadAreaTriggerProps) {
|
|
440
|
+
const { disabled } = useUploadContext()
|
|
441
|
+
|
|
442
|
+
const handleClick = useCallback(() => {
|
|
443
|
+
if (!disabled && fileInputRef?.current) {
|
|
444
|
+
fileInputRef.current.click()
|
|
445
|
+
}
|
|
446
|
+
}, [disabled, fileInputRef])
|
|
447
|
+
|
|
448
|
+
return (
|
|
449
|
+
<div
|
|
450
|
+
role="button"
|
|
451
|
+
tabIndex={disabled ? -1 : 0}
|
|
452
|
+
onClick={handleClick}
|
|
453
|
+
onKeyDown={e => {
|
|
454
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
455
|
+
e.preventDefault()
|
|
456
|
+
handleClick()
|
|
457
|
+
}
|
|
458
|
+
}}
|
|
459
|
+
{...props}
|
|
460
|
+
>
|
|
461
|
+
{children}
|
|
462
|
+
</div>
|
|
463
|
+
)
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
interface EditableFilesListProps {
|
|
467
|
+
fileTypeOptions?: FileTypeOption[]
|
|
468
|
+
onUpdateFile?: (index: number, file: Partial<FileFormat>) => void
|
|
469
|
+
onDeleteFile?: (index: number) => void
|
|
470
|
+
onReorderFiles?: (fromIndex: number, toIndex: number) => void
|
|
471
|
+
className?: string
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function EditableFilesList({
|
|
475
|
+
fileTypeOptions = [
|
|
476
|
+
{ value: 'document', label: 'Documento' },
|
|
477
|
+
{ value: 'image', label: 'Imagem' },
|
|
478
|
+
{ value: 'video', label: 'Vídeo' },
|
|
479
|
+
{ value: 'audio', label: 'Áudio' },
|
|
480
|
+
{ value: 'other', label: 'Outro' }
|
|
481
|
+
],
|
|
482
|
+
onUpdateFile,
|
|
483
|
+
onDeleteFile,
|
|
484
|
+
className,
|
|
485
|
+
...props
|
|
486
|
+
}: EditableFilesListProps) {
|
|
487
|
+
const { files, onFilesChange } = useUploadContext()
|
|
488
|
+
|
|
489
|
+
if (!files || files.length === 0) return null
|
|
490
|
+
|
|
491
|
+
const handleDescriptionChange = (index: number, description: string) => {
|
|
492
|
+
if (onUpdateFile) {
|
|
493
|
+
onUpdateFile(index, { description })
|
|
494
|
+
} else {
|
|
495
|
+
const updatedFiles = [...files]
|
|
496
|
+
updatedFiles[index] = { ...updatedFiles[index], description }
|
|
497
|
+
onFilesChange?.(updatedFiles)
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
const handleFileTypeChange = (index: number, fileType: string) => {
|
|
502
|
+
if (onUpdateFile) {
|
|
503
|
+
onUpdateFile(index, { fileType })
|
|
504
|
+
} else {
|
|
505
|
+
const updatedFiles = [...files]
|
|
506
|
+
updatedFiles[index] = { ...updatedFiles[index], fileType }
|
|
507
|
+
onFilesChange?.(updatedFiles)
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
const handleRestrictChange = (index: number, restrict: boolean) => {
|
|
512
|
+
if (onUpdateFile) {
|
|
513
|
+
onUpdateFile(index, { restrict })
|
|
514
|
+
} else {
|
|
515
|
+
const updatedFiles = [...files]
|
|
516
|
+
updatedFiles[index] = { ...updatedFiles[index], restrict }
|
|
517
|
+
onFilesChange?.(updatedFiles)
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
const handleDelete = (index: number) => {
|
|
522
|
+
if (onDeleteFile) {
|
|
523
|
+
onDeleteFile(index)
|
|
524
|
+
} else {
|
|
525
|
+
const updatedFiles = files.filter((_, i) => i !== index)
|
|
526
|
+
onFilesChange?.(updatedFiles)
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
return (
|
|
531
|
+
<div className={cx('space-y-2', className)} {...props}>
|
|
532
|
+
<div className="border-border-layer-2 p-4">
|
|
533
|
+
<div className="border-border-layer-2 mb-3 flex w-full flex-row items-center justify-between gap-4 border-b pb-2">
|
|
534
|
+
<div className="w-full">
|
|
535
|
+
<span className="text-sm font-medium text-gray-300">Descrição</span>
|
|
536
|
+
</div>
|
|
537
|
+
<div className="w-full">
|
|
538
|
+
<span className="text-sm font-medium text-gray-300">Tipo</span>
|
|
539
|
+
</div>
|
|
540
|
+
<div className="flex justify-end">
|
|
541
|
+
<span className="text-sm font-medium text-gray-300">Restrito</span>
|
|
542
|
+
</div>
|
|
543
|
+
</div>
|
|
544
|
+
|
|
545
|
+
<div className="space-y-3">
|
|
546
|
+
{files.map((file, index) => (
|
|
547
|
+
<div className="flex flex-row items-center gap-4 py-3" key={index}>
|
|
548
|
+
<div className="flex justify-start">
|
|
549
|
+
<Icon
|
|
550
|
+
className="text-neutral-secondary hover:text-neutral-dark cursor-grab"
|
|
551
|
+
name="drag_indicator"
|
|
552
|
+
/>
|
|
553
|
+
</div>
|
|
554
|
+
|
|
555
|
+
<div className="w-full">
|
|
556
|
+
<InputRoot>
|
|
557
|
+
<InputContent>
|
|
558
|
+
<InputText
|
|
559
|
+
placeholder="Nome do arquivo"
|
|
560
|
+
value={file.description || file.name}
|
|
561
|
+
onChange={e =>
|
|
562
|
+
handleDescriptionChange(index, e.target.value)
|
|
563
|
+
}
|
|
564
|
+
/>
|
|
565
|
+
</InputContent>
|
|
566
|
+
</InputRoot>
|
|
567
|
+
</div>
|
|
568
|
+
|
|
569
|
+
<div className="w-full">
|
|
570
|
+
<SelectRoot>
|
|
571
|
+
<SelectTrigger className="flex justify-between">
|
|
572
|
+
<span className="text-neutral-dark">
|
|
573
|
+
{fileTypeOptions.find(
|
|
574
|
+
option => option.value === file.fileType
|
|
575
|
+
)?.label || 'Tipo'}
|
|
576
|
+
</span>
|
|
577
|
+
<Icon
|
|
578
|
+
className="text-neutral-secondary"
|
|
579
|
+
name="keyboard_arrow_down"
|
|
580
|
+
/>
|
|
581
|
+
</SelectTrigger>
|
|
582
|
+
<SelectContent>
|
|
583
|
+
{fileTypeOptions.map(option => (
|
|
584
|
+
<SelectOption
|
|
585
|
+
key={option.value}
|
|
586
|
+
value={option.value}
|
|
587
|
+
onSelect={() =>
|
|
588
|
+
handleFileTypeChange(index, option.value)
|
|
589
|
+
}
|
|
590
|
+
>
|
|
591
|
+
{option.label}
|
|
592
|
+
</SelectOption>
|
|
593
|
+
))}
|
|
594
|
+
</SelectContent>
|
|
595
|
+
</SelectRoot>
|
|
596
|
+
</div>
|
|
597
|
+
|
|
598
|
+
<div className="flex justify-end">
|
|
599
|
+
<Switch
|
|
600
|
+
checked={file.restrict || false}
|
|
601
|
+
onCheckedChange={checked =>
|
|
602
|
+
handleRestrictChange(index, checked)
|
|
603
|
+
}
|
|
604
|
+
/>
|
|
605
|
+
</div>
|
|
606
|
+
|
|
607
|
+
<div className="flex justify-end">
|
|
608
|
+
<Button
|
|
609
|
+
appearance="ghost"
|
|
610
|
+
size="sm"
|
|
611
|
+
variant="destructive"
|
|
612
|
+
onClick={() => handleDelete(index)}
|
|
613
|
+
>
|
|
614
|
+
<Icon name="delete" />
|
|
615
|
+
</Button>
|
|
616
|
+
</div>
|
|
617
|
+
</div>
|
|
618
|
+
))}
|
|
619
|
+
</div>
|
|
620
|
+
</div>
|
|
621
|
+
</div>
|
|
622
|
+
)
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
export const Upload = {
|
|
626
|
+
Root: UploadRoot,
|
|
627
|
+
Area: UploadArea,
|
|
628
|
+
Title: UploadTitle,
|
|
629
|
+
AreaContent: UploadAreaContent,
|
|
630
|
+
AreaTrigger: UploadAreaTrigger,
|
|
631
|
+
EditableList: EditableFilesList
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
export { UploadRoot }
|
|
635
|
+
export { UploadArea }
|
|
636
|
+
export { UploadTitle }
|
|
637
|
+
export { UploadAreaContent }
|
|
638
|
+
export { UploadAreaTrigger }
|
|
639
|
+
export { EditableFilesList }
|
|
640
|
+
export { uploadAreaVariants }
|
|
641
|
+
export type {
|
|
642
|
+
UploadRootProps,
|
|
643
|
+
UploadAreaProps,
|
|
644
|
+
UploadAreaContentProps,
|
|
645
|
+
UploadAreaTriggerProps,
|
|
646
|
+
EditableFilesListProps
|
|
647
|
+
}
|
package/src/resources/icons.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export const icons = [
|
|
2
2
|
'account_balance',
|
|
3
|
+
'assignment',
|
|
4
|
+
'task',
|
|
3
5
|
'ad_units',
|
|
4
6
|
'add_a_photo',
|
|
5
7
|
'add',
|
|
@@ -144,7 +146,8 @@ export const icons = [
|
|
|
144
146
|
'format_underlined',
|
|
145
147
|
'format_list_bulleted',
|
|
146
148
|
'format_list_numbered',
|
|
147
|
-
'redo'
|
|
149
|
+
'redo',
|
|
150
|
+
'more_horiz'
|
|
148
151
|
] as const
|
|
149
152
|
|
|
150
153
|
export type IconType = (typeof icons)[number]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/button.tsx"],"names":["buttonVariants","cva","Button","asChild","className","variant","size","appearance","props","jsx","Slot","cx"],"mappings":"+GAIO,IAAMA,CAAAA,CAAiBC,IAC5B,CACE,iKACF,EACA,CACE,QAAA,CAAU,CACR,IAAA,CAAM,CACJ,EAAA,CAAI,6CAAA,CACJ,GAAI,yCAAA,CACJ,OAAA,CAAS,kDACT,OAAA,CAAS,qDACX,CAAA,CACA,OAAA,CAAS,CACP,OAAA,CAAS,EAAA,CACT,UAAW,EAAA,CACX,QAAA,CAAU,GACV,WAAA,CAAa,EAAA,CACb,QAAA,CACE,+FACJ,EACA,UAAA,CAAY,CACV,MAAO,EAAA,CACP,KAAA,CAAO,gBACT,CACF,CAAA,CACA,gBAAA,CAAkB,CAChB,CACE,OAAA,CAAS,SAAA,CACT,WAAY,OAAA,CACZ,KAAA,CACE,qFACJ,CAAA,CACA,CACE,OAAA,CAAS,SAAA,CACT,WAAY,OAAA,CACZ,KAAA,CACE,2EACJ,CAAA,CACA,CACE,QAAS,WAAA,CACT,UAAA,CAAY,OAAA,CACZ,KAAA,CACE,sFACJ,CAAA,CACA,CACE,QAAS,WAAA,CACT,UAAA,CAAY,QACZ,KAAA,CAAO,kDACT,CAAA,CACA,CACE,QAAS,UAAA,CACT,UAAA,CAAY,QACZ,KAAA,CACE,sFACJ,EACA,CACE,OAAA,CAAS,UAAA,CACT,UAAA,CAAY,QACZ,KAAA,CAAO,kDACT,EACA,CACE,OAAA,CAAS,cACT,UAAA,CAAY,OAAA,CACZ,KAAA,CACE,kFACJ,EACA,CACE,OAAA,CAAS,cACT,UAAA,CAAY,OAAA,CACZ,MACE,8EACJ,CACF,CAAA,CACA,eAAA,CAAiB,CACf,IAAA,CAAM,IAAA,CACN,QAAS,SAAA,CACT,UAAA,CAAY,OACd,CACF,CACF,EAQO,SAASC,EAAO,CACrB,OAAA,CAAAC,EACA,SAAA,CAAAC,CAAAA,CACA,QAAAC,CAAAA,CAAU,SAAA,CACV,IAAA,CAAAC,CAAAA,CAAO,KACP,UAAA,CAAAC,CAAAA,CAAa,QACb,GAAGC,CACL,EAAgB,CAEd,OACEC,GAAAA,CAFgBN,CAAAA,CAAUO,KAAO,QAAA,CAEhC,CACC,UAAWC,EAAAA,CAAGX,CAAAA,CAAe,CAAE,OAAA,CAAAK,CAAAA,CAAS,WAAAE,CAAAA,CAAY,IAAA,CAAAD,CAAK,CAAC,CAAA,CAAGF,CAAS,CAAA,CACrE,GAAGI,EACN,CAEJ","file":"chunk-FASEHVMD.js","sourcesContent":["import { Slot } from '@radix-ui/react-slot'\nimport type { ComponentProps } from 'react'\nimport { cva, cx, type ClassVariantProps } from '@xjur-ui/util'\n\nexport const buttonVariants = cva(\n [\n 'outline-none inline-flex items-center justify-center rounded-circle gap-small cursor-pointer disabled:opacity-38 disabled:pointer-events-none transition-colors'\n ],\n {\n variants: {\n size: {\n md: 'py-small_1x-alt px-medium text-size-body-md',\n sm: 'py-small-1x px-small text-size-label-sm',\n icon_md: 'p-small text-size-body-md h-large-4x w-large-4x',\n icon_sm: 'p-small-1x text-size-label-sm h-large-2x w-large-2x'\n },\n variant: {\n primary: '',\n secondary: '',\n tertiary: '',\n destructive: '',\n outlined:\n 'bg-layer-2-idle border border-border-layer-2 hover:bg-layer-2-hover active:bg-layer-2-pressed'\n },\n appearance: {\n solid: '',\n ghost: 'bg-transparent'\n }\n },\n compoundVariants: [\n {\n variant: 'primary',\n appearance: 'solid',\n class:\n 'bg-primary-idle text-neutral-label hover:bg-primary-hover active:bg-primary-pressed'\n },\n {\n variant: 'primary',\n appearance: 'ghost',\n class:\n 'text-primary-idle hover:bg-primary-alt-idle active:bg-primary-alt-pressed'\n },\n {\n variant: 'secondary',\n appearance: 'solid',\n class:\n 'bg-layer-1-hover text-neutral-dark hover:bg-layer-1-pressed active:bg-layer-1-active'\n },\n {\n variant: 'secondary',\n appearance: 'ghost',\n class: 'hover:bg-layer-1-hover active:bg-layer-1-pressed'\n },\n {\n variant: 'tertiary',\n appearance: 'solid',\n class:\n 'bg-layer-2-hover text-neutral-dark hover:bg-layer-2-pressed active:bg-layer-2-active'\n },\n {\n variant: 'tertiary',\n appearance: 'ghost',\n class: 'hover:bg-layer-2-hover active:bg-layer-2-pressed'\n },\n {\n variant: 'destructive',\n appearance: 'solid',\n class:\n 'bg-danger-idle text-neutral-label hover:bg-danger-hover active:bg-danger-pressed'\n },\n {\n variant: 'destructive',\n appearance: 'ghost',\n class:\n 'text-danger-label-idle hover:bg-danger-alt-idle active:bg-danger-alt-pressed'\n }\n ],\n defaultVariants: {\n size: 'md',\n variant: 'primary',\n appearance: 'solid'\n }\n }\n)\n\nexport interface ButtonProps\n extends ComponentProps<'button'>,\n ClassVariantProps<typeof buttonVariants> {\n asChild?: boolean\n}\n\nexport function Button({\n asChild,\n className,\n variant = 'primary',\n size = 'md',\n appearance = 'solid',\n ...props\n}: ButtonProps) {\n const Component = asChild ? Slot : 'button'\n return (\n <Component\n className={cx(buttonVariants({ variant, appearance, size }), className)}\n {...props}\n />\n )\n}\n"]}
|
package/dist/chunk-NPTLORW5.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {b as b$1}from'./chunk-FASEHVMD.js';import {a}from'./chunk-EIG6CBTQ.js';import {cx,cva}from'@xjur-ui/util';import {createContext}from'react';import {jsx}from'react/jsx-runtime';var i=createContext({variant:"outlined"});function h({className:e,variant:r="outlined",...o}){return jsx(i.Provider,{value:{variant:r},children:jsx("div",{className:cx(e,"relative flex w-full"),...o})})}function b({className:e,...r}){let o=cva(["gap-small py-small_1x-alt px-small flex items-center w-full","h-large-4x rounded-circle","border-border-layer-2 placeholder:placeholder-neutral-placeholder text-size-body-md text-neutral-dark border font-normal","group-hover:border-border-layer-3 transition-colors duration-200","disabled:opacity-60","focus-within:border-primary-idle"],{variants:{variant:{outlined:"rounded-circle focus-within:border-primary-idle ",line:"rounded-none border-t-0 border-b-1 border-x-0",action:"rounded-tr-none rounded-br-none border-r-0"}}});return jsx(i.Consumer,{children:({variant:a})=>jsx("div",{className:cx(e,o({variant:a})),"data-variant":a,...r})})}function f({htmlFor:e,...r}){return jsx(a,{asChild:true,className:cx("absolute -top-[22px] left-0"),size:"sm",variant:"label",weight:"medium",children:jsx("label",{htmlFor:e,...r})})}function v({className:e,...r}){return jsx("input",{className:cx(e,"flex-1 outline-none"),...r})}function y(e){return jsx("div",{...e,"data-slot":"search-input-slot"})}function C({className:e,appearance:r="ghost",variant:o="outlined",...a}){return jsx(b$1,{...a,appearance:r,className:cx(e,"cursor-pointer","h-large-4x rounded-tr-circle rounded-br-circle px-small py-small_1x-alt flex items-center justify-center rounded-none","text-size-body-md text-neutral-dark gap-small-1x"),"data-slot":"search-input-action",variant:o})}export{h as a,b,f as c,v as d,y as e,C as f};//# sourceMappingURL=chunk-NPTLORW5.js.map
|
|
2
|
-
//# sourceMappingURL=chunk-NPTLORW5.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/search-input.tsx"],"names":["SearchInputRootContext","createContext","SearchInputRoot","className","variant","props","jsx","cx","SearchInputContent","contentVarians","cva","SearchInputLabel","htmlFor","Typography","SearchInputText","SearchInputSlot","SearchInputAction","appearance","Button"],"mappings":"wLASA,IAAMA,CAAAA,CAAyBC,aAAAA,CAAgC,CAC7D,OAAA,CAAS,UACX,CAAC,EAEM,SAASC,CAAAA,CAAgB,CAC9B,SAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,EAAU,UAAA,CACV,GAAGC,CACL,CAAA,CAA6C,CAC3C,OACEC,IAACN,CAAAA,CAAuB,QAAA,CAAvB,CAAgC,KAAA,CAAO,CAAE,OAAA,CAAAI,CAAQ,CAAA,CAChD,QAAA,CAAAE,GAAAA,CAAC,KAAA,CAAA,CAAI,SAAA,CAAWC,EAAAA,CAAGJ,EAAW,sBAAsB,CAAA,CAAI,GAAGE,CAAAA,CAAO,CAAA,CACpE,CAEJ,CAEO,SAASG,CAAAA,CAAmB,CACjC,SAAA,CAAAL,CAAAA,CACA,GAAGE,CACL,CAAA,CAA0B,CACxB,IAAMI,CAAAA,CAAiBC,GAAAA,CACrB,CACE,8DACA,2BAAA,CACA,0HAAA,CACA,kEAAA,CACA,qBAAA,CACA,kCACF,CAAA,CACA,CACE,QAAA,CAAU,CACR,OAAA,CAAS,CACP,QAAA,CAAU,kDAAA,CACV,KAAM,+CAAA,CACN,MAAA,CAAQ,4CACV,CACF,CACF,CACF,EAEA,OACEJ,GAAAA,CAACN,CAAAA,CAAuB,QAAA,CAAvB,CACE,QAAA,CAAA,CAAC,CAAE,OAAA,CAAAI,CAAQ,CAAA,GACVE,GAAAA,CAAC,KAAA,CAAA,CACC,SAAA,CAAWC,EAAAA,CAAGJ,CAAAA,CAAWM,CAAAA,CAAe,CAAE,OAAA,CAAAL,CAAQ,CAAC,CAAC,EACpD,cAAA,CAAcA,CAAAA,CACb,GAAGC,CAAAA,CACN,CAAA,CAEJ,CAEJ,CAEO,SAASM,CAAAA,CAAiB,CAC/B,OAAA,CAAAC,CAAAA,CACA,GAAGP,CACL,CAAA,CAA4B,CAC1B,OACEC,GAAAA,CAACO,CAAAA,CAAA,CACC,QAAS,IAAA,CACT,SAAA,CAAWN,EAAAA,CAAG,6BAA6B,CAAA,CAC3C,IAAA,CAAK,KACL,OAAA,CAAQ,OAAA,CACR,MAAA,CAAO,QAAA,CAEP,QAAA,CAAAD,GAAAA,CAAC,SAAM,OAAA,CAASM,CAAAA,CAAU,GAAGP,CAAAA,CAAO,CAAA,CACtC,CAEJ,CAEO,SAASS,CAAAA,CAAgB,CAC9B,SAAA,CAAAX,CAAAA,CACA,GAAGE,CACL,CAAA,CAA4B,CAC1B,OAAOC,GAAAA,CAAC,OAAA,CAAA,CAAM,SAAA,CAAWC,GAAGJ,CAAAA,CAAW,qBAAqB,CAAA,CAAI,GAAGE,CAAAA,CAAO,CAC5E,CAEO,SAASU,CAAAA,CAAgBV,CAAAA,CAA8B,CAC5D,OAAOC,GAAAA,CAAC,OAAK,GAAGD,CAAAA,CAAO,WAAA,CAAU,mBAAA,CAAoB,CACvD,CAEO,SAASW,CAAAA,CAAkB,CAChC,SAAA,CAAAb,CAAAA,CACA,UAAA,CAAAc,CAAAA,CAAa,QACb,OAAA,CAAAb,CAAAA,CAAU,UAAA,CACV,GAAGC,CACL,CAAA,CAAgB,CACd,OACEC,GAAAA,CAACY,GAAAA,CAAA,CACE,GAAGb,CAAAA,CACJ,WAAYY,CAAAA,CACZ,SAAA,CAAWV,EAAAA,CACTJ,CAAAA,CACA,gBAAA,CACA,uHAAA,CACA,kDACF,CAAA,CACA,WAAA,CAAU,qBAAA,CACV,OAAA,CAASC,CAAAA,CACX,CAEJ","file":"chunk-NPTLORW5.js","sourcesContent":["import { cva, cx } from '@xjur-ui/util'\nimport { createContext, type ComponentProps } from 'react'\nimport { Typography } from './typography'\nimport { Button, type ButtonProps } from './button'\n\nexport type SearchInputProps = {\n variant?: 'outlined' | 'line' | 'action'\n}\n\nconst SearchInputRootContext = createContext<SearchInputProps>({\n variant: 'outlined'\n})\n\nexport function SearchInputRoot({\n className,\n variant = 'outlined',\n ...props\n}: ComponentProps<'div'> & SearchInputProps) {\n return (\n <SearchInputRootContext.Provider value={{ variant }}>\n <div className={cx(className, 'relative flex w-full')} {...props} />\n </SearchInputRootContext.Provider>\n )\n}\n\nexport function SearchInputContent({\n className,\n ...props\n}: ComponentProps<'div'>) {\n const contentVarians = cva(\n [\n 'gap-small py-small_1x-alt px-small flex items-center w-full',\n 'h-large-4x rounded-circle',\n 'border-border-layer-2 placeholder:placeholder-neutral-placeholder text-size-body-md text-neutral-dark border font-normal',\n 'group-hover:border-border-layer-3 transition-colors duration-200',\n 'disabled:opacity-60',\n 'focus-within:border-primary-idle'\n ],\n {\n variants: {\n variant: {\n outlined: 'rounded-circle focus-within:border-primary-idle ',\n line: 'rounded-none border-t-0 border-b-1 border-x-0',\n action: 'rounded-tr-none rounded-br-none border-r-0'\n }\n }\n }\n )\n\n return (\n <SearchInputRootContext.Consumer>\n {({ variant }) => (\n <div\n className={cx(className, contentVarians({ variant }))}\n data-variant={variant}\n {...props}\n />\n )}\n </SearchInputRootContext.Consumer>\n )\n}\n\nexport function SearchInputLabel({\n htmlFor,\n ...props\n}: ComponentProps<'label'>) {\n return (\n <Typography\n asChild={true}\n className={cx('absolute -top-[22px] left-0')}\n size=\"sm\"\n variant=\"label\"\n weight=\"medium\"\n >\n <label htmlFor={htmlFor} {...props} />\n </Typography>\n )\n}\n\nexport function SearchInputText({\n className,\n ...props\n}: ComponentProps<'input'>) {\n return <input className={cx(className, 'flex-1 outline-none')} {...props} />\n}\n\nexport function SearchInputSlot(props: ComponentProps<'div'>) {\n return <div {...props} data-slot=\"search-input-slot\" />\n}\n\nexport function SearchInputAction({\n className,\n appearance = 'ghost',\n variant = 'outlined',\n ...props\n}: ButtonProps) {\n return (\n <Button\n {...props}\n appearance={appearance}\n className={cx(\n className,\n 'cursor-pointer',\n 'h-large-4x rounded-tr-circle rounded-br-circle px-small py-small_1x-alt flex items-center justify-center rounded-none',\n 'text-size-body-md text-neutral-dark gap-small-1x'\n )}\n data-slot=\"search-input-action\"\n variant={variant}\n />\n )\n}\n"]}
|