@xjur-ui/react 2.1.1 → 2.2.1
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/CHANGELOG.md +18 -0
- package/dist/{chunk-DT44JTXB.js → chunk-4M3WR2KJ.js} +2 -2
- package/dist/{chunk-DT44JTXB.js.map → chunk-4M3WR2KJ.js.map} +1 -1
- package/dist/{chunk-7HG6Y3VV.js → chunk-BYXTOSM6.js} +2 -2
- package/dist/{chunk-7HG6Y3VV.js.map → chunk-BYXTOSM6.js.map} +1 -1
- package/dist/{chunk-4PTFZTVU.js → chunk-HLWHETF5.js} +2 -2
- package/dist/{chunk-4PTFZTVU.js.map → chunk-HLWHETF5.js.map} +1 -1
- package/dist/{chunk-ASZAHSU5.js → chunk-SLMHDBWO.js} +2 -2
- package/dist/{chunk-ASZAHSU5.js.map → chunk-SLMHDBWO.js.map} +1 -1
- package/dist/{chunk-MQ7YTZBI.js → chunk-TTKENFBF.js} +2 -2
- package/dist/{chunk-MQ7YTZBI.js.map → chunk-TTKENFBF.js.map} +1 -1
- package/dist/components/accordion.d.ts +54 -0
- package/dist/components/accordion.js +2 -0
- package/dist/components/accordion.js.map +1 -0
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/controls/rating.d.ts +137 -0
- package/dist/components/controls/rating.js +2 -0
- package/dist/components/controls/rating.js.map +1 -0
- package/dist/components/controls/rich-editor.js +1 -1
- package/dist/components/controls/slider.d.ts +172 -0
- package/dist/components/controls/slider.js +2 -0
- package/dist/components/controls/slider.js.map +1 -0
- package/dist/components/custom/pessoa/index.js +1 -1
- package/dist/components/drag-and-drop/index.js +1 -1
- package/dist/components/full-calendar/calendar-cell.js +1 -1
- package/dist/components/full-calendar/calendar-day-view.js +1 -1
- package/dist/components/full-calendar/calendar-month-view.js +1 -1
- package/dist/components/full-calendar/calendar-view-renderer.js +1 -1
- package/dist/components/full-calendar/calendar-week-view.js +1 -1
- package/dist/components/full-calendar/index.js +1 -1
- package/dist/components/selection-bar.d.ts +1 -1
- package/dist/components/status.d.ts +1 -1
- package/dist/components/steps/index.js +1 -1
- package/dist/components/table/index.js +1 -1
- package/dist/components/toast.d.ts +27 -0
- package/dist/components/toast.js +2 -0
- package/dist/components/toast.js.map +1 -0
- package/dist/components/typography.d.ts +1 -1
- package/dist/components/upload.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/package.json +25 -16
- package/.turbo/turbo-build.log +0 -419
- package/eslint.config.js +0 -10
- package/postcss.config.js +0 -5
- package/prettier.config.js +0 -7
- package/src/components/avatar-group.tsx +0 -76
- package/src/components/avatar.tsx +0 -54
- package/src/components/badge.tsx +0 -40
- package/src/components/breadcrumb.tsx +0 -119
- package/src/components/chip.tsx +0 -117
- package/src/components/collapsible.tsx +0 -35
- package/src/components/controls/button.tsx +0 -107
- package/src/components/controls/calendar.tsx +0 -124
- package/src/components/controls/checkbox.tsx +0 -57
- package/src/components/controls/context/field.context.ts +0 -27
- package/src/components/controls/date-picker.tsx +0 -199
- package/src/components/controls/floating-label.tsx +0 -60
- package/src/components/controls/input.tsx +0 -237
- package/src/components/controls/otp-input.tsx +0 -45
- package/src/components/controls/radio.tsx +0 -74
- package/src/components/controls/rich-editor.tsx +0 -372
- package/src/components/controls/search-input.tsx +0 -154
- package/src/components/controls/search-selector.tsx +0 -98
- package/src/components/controls/select.tsx +0 -274
- package/src/components/controls/switch.tsx +0 -31
- package/src/components/custom/pessoa/index.ts +0 -9
- package/src/components/custom/pessoa/pessoa-add-button.tsx +0 -35
- package/src/components/custom/pessoa/pessoa-body.tsx +0 -22
- package/src/components/custom/pessoa/pessoa-close-button.tsx +0 -13
- package/src/components/custom/pessoa/pessoa-content.tsx +0 -25
- package/src/components/custom/pessoa/pessoa-footer.tsx +0 -15
- package/src/components/custom/pessoa/pessoa-header.tsx +0 -35
- package/src/components/custom/pessoa/pessoa-trigger.tsx +0 -25
- package/src/components/custom/pessoa/pessoa.context.tsx +0 -73
- package/src/components/custom/pessoa/pessoa.tsx +0 -35
- package/src/components/dialog.tsx +0 -242
- package/src/components/divider.tsx +0 -24
- package/src/components/drag-and-drop/drag-handle.tsx +0 -46
- package/src/components/drag-and-drop/drag-list-item.tsx +0 -91
- package/src/components/drag-and-drop/drag-list.tsx +0 -47
- package/src/components/drag-and-drop/drag-root.tsx +0 -30
- package/src/components/drag-and-drop/index.ts +0 -39
- package/src/components/drag-and-drop/types/drag-item.ts +0 -7
- package/src/components/dropdown-menu.tsx +0 -101
- package/src/components/full-calendar/calendar-add-event.tsx +0 -15
- package/src/components/full-calendar/calendar-body.tsx +0 -12
- package/src/components/full-calendar/calendar-cell.tsx +0 -120
- package/src/components/full-calendar/calendar-day-view.tsx +0 -76
- package/src/components/full-calendar/calendar-event.tsx +0 -178
- package/src/components/full-calendar/calendar-header.tsx +0 -14
- package/src/components/full-calendar/calendar-month-view.tsx +0 -69
- package/src/components/full-calendar/calendar-more-events-dropdown.tsx +0 -39
- package/src/components/full-calendar/calendar-navigator.tsx +0 -86
- package/src/components/full-calendar/calendar-root.tsx +0 -165
- package/src/components/full-calendar/calendar-today-button.tsx +0 -21
- package/src/components/full-calendar/calendar-toggle-view.tsx +0 -61
- package/src/components/full-calendar/calendar-view-renderer.tsx +0 -19
- package/src/components/full-calendar/calendar-week-day.tsx +0 -49
- package/src/components/full-calendar/calendar-week-view.tsx +0 -88
- package/src/components/full-calendar/helpers/calendar.ts +0 -158
- package/src/components/full-calendar/index.ts +0 -16
- package/src/components/full-calendar/types/calendar-cell.ts +0 -4
- package/src/components/full-calendar/types/calendar-event.ts +0 -7
- package/src/components/full-calendar/types/calendar-view.ts +0 -1
- package/src/components/full-calendar/types/calendar-week-hour.ts +0 -4
- package/src/components/horizontal-scroll.tsx +0 -159
- package/src/components/icon.tsx +0 -29
- package/src/components/list.tsx +0 -111
- package/src/components/logo.tsx +0 -44
- package/src/components/selection-bar.tsx +0 -273
- package/src/components/sheet.tsx +0 -150
- package/src/components/skeleton.tsx +0 -12
- package/src/components/status.tsx +0 -43
- package/src/components/steps/index.ts +0 -6
- package/src/components/steps/step.tsx +0 -23
- package/src/components/steps/steps-action.tsx +0 -65
- package/src/components/steps/steps-content.tsx +0 -12
- package/src/components/steps/steps-context.tsx +0 -121
- package/src/components/steps/steps-navigation.tsx +0 -80
- package/src/components/steps/steps-root.tsx +0 -9
- package/src/components/table/index.ts +0 -8
- package/src/components/table/table-body.tsx +0 -17
- package/src/components/table/table-cell.tsx +0 -14
- package/src/components/table/table-footer.tsx +0 -17
- package/src/components/table/table-head.tsx +0 -31
- package/src/components/table/table-header.tsx +0 -17
- package/src/components/table/table-row.tsx +0 -21
- package/src/components/table/table-sort.tsx +0 -34
- package/src/components/table/table.tsx +0 -16
- package/src/components/tabs.tsx +0 -72
- package/src/components/tag.tsx +0 -99
- package/src/components/tooltip.tsx +0 -63
- package/src/components/typography.tsx +0 -85
- package/src/components/upload.tsx +0 -647
- package/src/hooks/index.ts +0 -1
- package/src/hooks/use-os.ts +0 -32
- package/src/index.css +0 -5
- package/src/resources/icons.ts +0 -154
- package/src/resources/input-mask.ts +0 -91
- package/src/resources/logo/horizontal.tsx +0 -70
- package/src/resources/logo/icon.tsx +0 -54
- package/src/resources/logo/index.tsx +0 -33
- package/src/resources/logo/vertical.tsx +0 -70
- package/src/types.d.ts +0 -4
- package/tsconfig.json +0 -4
- package/tsup.config.ts +0 -30
package/src/components/sheet.tsx
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
import * as SheetPrimitive from '@radix-ui/react-dialog'
|
|
3
|
-
import { cx, tv } from '@xjur-ui/util'
|
|
4
|
-
import { Button } from './controls/button'
|
|
5
|
-
import { Icon } from './icon'
|
|
6
|
-
|
|
7
|
-
export function SheetRoot({
|
|
8
|
-
...props
|
|
9
|
-
}: React.ComponentProps<typeof SheetPrimitive.Root>) {
|
|
10
|
-
return <SheetPrimitive.Root data-slot="sheet" {...props} />
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function SheetTrigger({
|
|
14
|
-
...props
|
|
15
|
-
}: React.ComponentProps<typeof SheetPrimitive.Trigger>) {
|
|
16
|
-
return <SheetPrimitive.Trigger data-slot="sheet-trigger" {...props} />
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function SheetClose({
|
|
20
|
-
children = (
|
|
21
|
-
<Button appearance="ghost" size="icon_md" variant="tertiary">
|
|
22
|
-
<Icon className="text-icon-neutral-3" name="close" />
|
|
23
|
-
</Button>
|
|
24
|
-
),
|
|
25
|
-
...props
|
|
26
|
-
}: React.ComponentProps<typeof SheetPrimitive.Close>) {
|
|
27
|
-
return (
|
|
28
|
-
<SheetPrimitive.Close data-slot="sheet-close" {...props}>
|
|
29
|
-
{children}
|
|
30
|
-
</SheetPrimitive.Close>
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function SheetPortal({
|
|
35
|
-
...props
|
|
36
|
-
}: React.ComponentProps<typeof SheetPrimitive.Portal>) {
|
|
37
|
-
return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function SheetOverlay({
|
|
41
|
-
className,
|
|
42
|
-
...props
|
|
43
|
-
}: React.ComponentProps<typeof SheetPrimitive.Overlay>) {
|
|
44
|
-
return (
|
|
45
|
-
<SheetPrimitive.Overlay
|
|
46
|
-
className={cx(
|
|
47
|
-
'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50',
|
|
48
|
-
className
|
|
49
|
-
)}
|
|
50
|
-
data-slot="sheet-overlay"
|
|
51
|
-
{...props}
|
|
52
|
-
/>
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function SheetContent({
|
|
57
|
-
className,
|
|
58
|
-
children,
|
|
59
|
-
side = 'right',
|
|
60
|
-
overlay = false,
|
|
61
|
-
...props
|
|
62
|
-
}: React.ComponentProps<typeof SheetPrimitive.Content> & {
|
|
63
|
-
side?: 'top' | 'right' | 'bottom' | 'left'
|
|
64
|
-
overlay?: boolean
|
|
65
|
-
}) {
|
|
66
|
-
const content = tv({
|
|
67
|
-
base: [
|
|
68
|
-
'border-border-layer-2 bg-layer-2-idle shadow-elevation-2 fixed z-50 flex flex-col gap-medium',
|
|
69
|
-
'data-[state=open]:animate-in data-[state=closed]:animate-out transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500'
|
|
70
|
-
],
|
|
71
|
-
variants: {
|
|
72
|
-
side: {
|
|
73
|
-
right:
|
|
74
|
-
'data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full border-l sm:max-w-sm',
|
|
75
|
-
left: 'data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full border-r sm:max-w-sm',
|
|
76
|
-
top: 'data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b',
|
|
77
|
-
bottom:
|
|
78
|
-
'data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t'
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
defaultVariants: {
|
|
82
|
-
side: 'right'
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
return (
|
|
87
|
-
<SheetPortal>
|
|
88
|
-
{overlay && <SheetOverlay />}
|
|
89
|
-
<SheetPrimitive.Content
|
|
90
|
-
className={content({ side, className })}
|
|
91
|
-
data-slot="sheet-content"
|
|
92
|
-
{...props}
|
|
93
|
-
>
|
|
94
|
-
{children}
|
|
95
|
-
</SheetPrimitive.Content>
|
|
96
|
-
</SheetPortal>
|
|
97
|
-
)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export function SheetBody({
|
|
101
|
-
className,
|
|
102
|
-
...props
|
|
103
|
-
}: React.ComponentProps<'div'>) {
|
|
104
|
-
return <div className={cx('px-large-2x h-full', className)} {...props} />
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export function SheetHeader({
|
|
108
|
-
className,
|
|
109
|
-
...props
|
|
110
|
-
}: React.ComponentProps<'div'>) {
|
|
111
|
-
return (
|
|
112
|
-
<div
|
|
113
|
-
className={cx(
|
|
114
|
-
'py-large px-large-2x border-b-border-layer-2 border-b',
|
|
115
|
-
className
|
|
116
|
-
)}
|
|
117
|
-
data-slot="sheet-header"
|
|
118
|
-
{...props}
|
|
119
|
-
/>
|
|
120
|
-
)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export function SheetFooter({
|
|
124
|
-
className,
|
|
125
|
-
...props
|
|
126
|
-
}: React.ComponentProps<'div'>) {
|
|
127
|
-
return (
|
|
128
|
-
<div
|
|
129
|
-
className={cx(
|
|
130
|
-
'py-large px-large-2x border-t-border-layer-2 mt-auto border-t',
|
|
131
|
-
className
|
|
132
|
-
)}
|
|
133
|
-
data-slot="sheet-footer"
|
|
134
|
-
{...props}
|
|
135
|
-
/>
|
|
136
|
-
)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export function SheetTitle({
|
|
140
|
-
className,
|
|
141
|
-
...props
|
|
142
|
-
}: React.ComponentProps<typeof SheetPrimitive.Title>) {
|
|
143
|
-
return (
|
|
144
|
-
<SheetPrimitive.Title
|
|
145
|
-
className={cx('text-size-title-lg font-normal', className)}
|
|
146
|
-
data-slot="sheet-title"
|
|
147
|
-
{...props}
|
|
148
|
-
/>
|
|
149
|
-
)
|
|
150
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ComponentProps } from 'react'
|
|
2
|
-
import { cx } from '@xjur-ui/util'
|
|
3
|
-
|
|
4
|
-
export function Skeleton({ className, ...props }: ComponentProps<'div'>) {
|
|
5
|
-
return (
|
|
6
|
-
<div
|
|
7
|
-
className={cx('bg-layer-skeleton animate-pulse', className)}
|
|
8
|
-
data-slot="skeleton"
|
|
9
|
-
{...props}
|
|
10
|
-
/>
|
|
11
|
-
)
|
|
12
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { ComponentProps } from 'react'
|
|
2
|
-
import { cva, cx, type ClassVariantProps } from '@xjur-ui/util'
|
|
3
|
-
import { Typography } from './typography'
|
|
4
|
-
|
|
5
|
-
export const statusVariants = cva(
|
|
6
|
-
[
|
|
7
|
-
'inline-flex items-center justify-center px-small py-small-1x rounded-small-1x text-label-sm font-medium text-neutral-label h-large-2x'
|
|
8
|
-
],
|
|
9
|
-
{
|
|
10
|
-
variants: {
|
|
11
|
-
variant: {
|
|
12
|
-
success: 'bg-success-idle',
|
|
13
|
-
warning: 'bg-warning-idle',
|
|
14
|
-
danger: 'bg-danger-idle',
|
|
15
|
-
neutral: 'bg-alt-3'
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
defaultVariants: {
|
|
19
|
-
variant: 'neutral'
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
export interface StatusProps
|
|
25
|
-
extends ComponentProps<'div'>,
|
|
26
|
-
ClassVariantProps<typeof statusVariants> {
|
|
27
|
-
text?: string
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function Status({
|
|
31
|
-
text = 'Status',
|
|
32
|
-
variant = 'neutral',
|
|
33
|
-
className,
|
|
34
|
-
...props
|
|
35
|
-
}: StatusProps) {
|
|
36
|
-
return (
|
|
37
|
-
<div className={cx(statusVariants({ variant }), className)} {...props}>
|
|
38
|
-
<Typography size="sm" variant="label" weight="medium">
|
|
39
|
-
{text}
|
|
40
|
-
</Typography>
|
|
41
|
-
</div>
|
|
42
|
-
)
|
|
43
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { ComponentProps } from 'react'
|
|
2
|
-
import { twMerge } from '@xjur-ui/util'
|
|
3
|
-
import { useSteps } from './steps-context'
|
|
4
|
-
|
|
5
|
-
export function Step({
|
|
6
|
-
stepIndex,
|
|
7
|
-
className,
|
|
8
|
-
...props
|
|
9
|
-
}: ComponentProps<'div'> & { stepIndex: number }) {
|
|
10
|
-
const { currentStepIndex } = useSteps()
|
|
11
|
-
|
|
12
|
-
if (currentStepIndex !== stepIndex) {
|
|
13
|
-
return null
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<div
|
|
18
|
-
className={twMerge('h-full w-full', className)}
|
|
19
|
-
data-slot="step-item"
|
|
20
|
-
{...props}
|
|
21
|
-
/>
|
|
22
|
-
)
|
|
23
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { useCallback, type ComponentProps } from 'react'
|
|
2
|
-
import { Button } from '../controls/button'
|
|
3
|
-
import { useSteps } from './steps-context'
|
|
4
|
-
|
|
5
|
-
export function NextStep({
|
|
6
|
-
children = 'Próximo',
|
|
7
|
-
type,
|
|
8
|
-
onClick,
|
|
9
|
-
...props
|
|
10
|
-
}: Omit<ComponentProps<typeof Button>, 'children'> & {
|
|
11
|
-
children?: React.ReactNode | ((stepIndex: number) => React.ReactNode)
|
|
12
|
-
}) {
|
|
13
|
-
const { handleNextStep, currentStepIndex, isLastStep } = useSteps()
|
|
14
|
-
|
|
15
|
-
const handleClick = useCallback(
|
|
16
|
-
(event: React.MouseEvent<HTMLButtonElement>) => {
|
|
17
|
-
if (onClick) {
|
|
18
|
-
onClick(event)
|
|
19
|
-
} else {
|
|
20
|
-
event.preventDefault()
|
|
21
|
-
handleNextStep()
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
[onClick, handleNextStep]
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
const buttonType = type || (isLastStep ? 'submit' : 'button')
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<Button
|
|
31
|
-
type={buttonType}
|
|
32
|
-
{...(buttonType === 'button' ? { onClick: handleClick } : {})}
|
|
33
|
-
{...props}
|
|
34
|
-
>
|
|
35
|
-
{typeof children === 'function' ? children(currentStepIndex) : children}
|
|
36
|
-
</Button>
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function PreviousStep({
|
|
41
|
-
appearance = 'ghost',
|
|
42
|
-
children = 'Anterior',
|
|
43
|
-
onClick,
|
|
44
|
-
...props
|
|
45
|
-
}: ComponentProps<typeof Button>) {
|
|
46
|
-
const { handlePreviousStep } = useSteps()
|
|
47
|
-
|
|
48
|
-
const handleClick = useCallback(
|
|
49
|
-
(event: React.MouseEvent<HTMLButtonElement>) => {
|
|
50
|
-
if (onClick) {
|
|
51
|
-
onClick(event)
|
|
52
|
-
} else {
|
|
53
|
-
event.preventDefault()
|
|
54
|
-
handlePreviousStep()
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
[onClick, handlePreviousStep]
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<Button appearance={appearance} onClick={handleClick} {...props}>
|
|
62
|
-
{children}
|
|
63
|
-
</Button>
|
|
64
|
-
)
|
|
65
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { twMerge } from '@xjur-ui/util'
|
|
2
|
-
import type { ComponentProps } from 'react'
|
|
3
|
-
|
|
4
|
-
export function Steps({ className, ...props }: ComponentProps<'div'>) {
|
|
5
|
-
return (
|
|
6
|
-
<div
|
|
7
|
-
className={twMerge('h-full w-full', className)}
|
|
8
|
-
data-slot="steps-content"
|
|
9
|
-
{...props}
|
|
10
|
-
/>
|
|
11
|
-
)
|
|
12
|
-
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { twMerge } from '@xjur-ui/util'
|
|
2
|
-
import {
|
|
3
|
-
createContext,
|
|
4
|
-
useCallback,
|
|
5
|
-
useContext,
|
|
6
|
-
useMemo,
|
|
7
|
-
useState,
|
|
8
|
-
type ComponentProps
|
|
9
|
-
} from 'react'
|
|
10
|
-
|
|
11
|
-
export interface StepsContextValue {
|
|
12
|
-
steps: string[]
|
|
13
|
-
currentStepIndex: number
|
|
14
|
-
isLastStep: boolean
|
|
15
|
-
|
|
16
|
-
handleStepChange: (index: number) => void
|
|
17
|
-
handleNextStep: () => void
|
|
18
|
-
handlePreviousStep: () => void
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const StepsContext = createContext<StepsContextValue>({
|
|
22
|
-
steps: [],
|
|
23
|
-
currentStepIndex: 0,
|
|
24
|
-
isLastStep: false,
|
|
25
|
-
handleStepChange: () => {},
|
|
26
|
-
handleNextStep: () => {},
|
|
27
|
-
handlePreviousStep: () => {}
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
export function StepsProvider({
|
|
31
|
-
steps,
|
|
32
|
-
currentStepIndex: currentStepIndexProp = 0,
|
|
33
|
-
onStepChange,
|
|
34
|
-
children,
|
|
35
|
-
className,
|
|
36
|
-
...props
|
|
37
|
-
}: {
|
|
38
|
-
steps: string[]
|
|
39
|
-
currentStepIndex?: number
|
|
40
|
-
onStepChange?: (index: number) => void
|
|
41
|
-
children: React.ReactNode | ((context: StepsContextValue) => React.ReactNode)
|
|
42
|
-
} & Omit<ComponentProps<'div'>, 'children'>) {
|
|
43
|
-
const [currentStepIndex, setCurrentStepIndex] = useState(currentStepIndexProp)
|
|
44
|
-
|
|
45
|
-
const handleStepChange = useCallback(
|
|
46
|
-
(index: number) => {
|
|
47
|
-
setCurrentStepIndex(index)
|
|
48
|
-
onStepChange?.(index)
|
|
49
|
-
},
|
|
50
|
-
[onStepChange]
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
const handleNextStep = useCallback(() => {
|
|
54
|
-
const isLastStep = currentStepIndex === steps.length - 1
|
|
55
|
-
|
|
56
|
-
if (isLastStep) {
|
|
57
|
-
return
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
setCurrentStepIndex(prev => prev + 1)
|
|
61
|
-
onStepChange?.(currentStepIndex + 1)
|
|
62
|
-
}, [currentStepIndex, onStepChange, steps])
|
|
63
|
-
|
|
64
|
-
const handlePreviousStep = useCallback(() => {
|
|
65
|
-
if (currentStepIndex === 0) {
|
|
66
|
-
return
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
setCurrentStepIndex(prev => prev - 1)
|
|
70
|
-
onStepChange?.(currentStepIndex - 1)
|
|
71
|
-
}, [currentStepIndex, onStepChange])
|
|
72
|
-
|
|
73
|
-
const isLastStep = useMemo(
|
|
74
|
-
() => currentStepIndex === steps.length - 1,
|
|
75
|
-
[currentStepIndex, steps]
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
const providerValue = useMemo(
|
|
79
|
-
() => ({
|
|
80
|
-
steps,
|
|
81
|
-
currentStepIndex,
|
|
82
|
-
isLastStep,
|
|
83
|
-
setCurrentStepIndex,
|
|
84
|
-
|
|
85
|
-
handleStepChange,
|
|
86
|
-
handleNextStep,
|
|
87
|
-
handlePreviousStep
|
|
88
|
-
}),
|
|
89
|
-
[
|
|
90
|
-
steps,
|
|
91
|
-
currentStepIndex,
|
|
92
|
-
isLastStep,
|
|
93
|
-
setCurrentStepIndex,
|
|
94
|
-
handleStepChange,
|
|
95
|
-
handleNextStep,
|
|
96
|
-
handlePreviousStep
|
|
97
|
-
]
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
return (
|
|
101
|
-
<StepsContext.Provider value={providerValue}>
|
|
102
|
-
<div
|
|
103
|
-
className={twMerge('h-full w-full', className)}
|
|
104
|
-
data-slot="steps-root"
|
|
105
|
-
{...props}
|
|
106
|
-
>
|
|
107
|
-
{typeof children === 'function' ? children(providerValue) : children}
|
|
108
|
-
</div>
|
|
109
|
-
</StepsContext.Provider>
|
|
110
|
-
)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export function useSteps() {
|
|
114
|
-
const context = useContext(StepsContext)
|
|
115
|
-
|
|
116
|
-
if (!context) {
|
|
117
|
-
throw new Error('useSteps must be used within a StepsContext.Provider')
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return context
|
|
121
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { Fragment, useCallback, type ComponentProps } from 'react'
|
|
2
|
-
import { twMerge } from '@xjur-ui/util'
|
|
3
|
-
import { useSteps } from './steps-context'
|
|
4
|
-
|
|
5
|
-
export function StepsNavigation({
|
|
6
|
-
className,
|
|
7
|
-
...props
|
|
8
|
-
}: ComponentProps<'div'>) {
|
|
9
|
-
const { steps, currentStepIndex } = useSteps()
|
|
10
|
-
|
|
11
|
-
const isLastStep = useCallback(
|
|
12
|
-
(stepIndex: number) => stepIndex === steps.length - 1,
|
|
13
|
-
[steps]
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
const stepState = useCallback(
|
|
17
|
-
(stepIndex: number) => {
|
|
18
|
-
const isActive = stepIndex === currentStepIndex
|
|
19
|
-
const isPassed = stepIndex < currentStepIndex
|
|
20
|
-
|
|
21
|
-
if (isPassed) {
|
|
22
|
-
return 'disabled'
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return isActive ? 'active' : 'normal'
|
|
26
|
-
},
|
|
27
|
-
[currentStepIndex]
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<div
|
|
32
|
-
className={twMerge('gap-small flex items-center', className)}
|
|
33
|
-
data-slot="steps-navigation"
|
|
34
|
-
{...props}
|
|
35
|
-
>
|
|
36
|
-
{steps.map((step, stepIndex) => {
|
|
37
|
-
const state = stepState(stepIndex)
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<Fragment key={`${step}-${stepIndex}`}>
|
|
41
|
-
<div
|
|
42
|
-
className="group gap-small flex items-center"
|
|
43
|
-
data-disabled={state === 'disabled'}
|
|
44
|
-
data-slot="step-trigger"
|
|
45
|
-
data-state={state}
|
|
46
|
-
{...props}
|
|
47
|
-
>
|
|
48
|
-
<div
|
|
49
|
-
className={twMerge(
|
|
50
|
-
'size-large-4x rounded-circle border-border-layer-2 text-size-label-sm bg-layer-2-idle flex items-center justify-center border',
|
|
51
|
-
'group-data-[state=active]:border-primary-active group-data-[state=active]:bg-primary-alt-active group-data-[state=active]:text-primary-label-active',
|
|
52
|
-
'group-data-[state=disabled]:bg-layer-1-idle group-data-[state=disabled]:border-border-layer-2 group-data-[state=disabled]:text-neutral-light'
|
|
53
|
-
)}
|
|
54
|
-
data-slot="step-number"
|
|
55
|
-
>
|
|
56
|
-
{stepIndex + 1}
|
|
57
|
-
</div>
|
|
58
|
-
|
|
59
|
-
<span
|
|
60
|
-
className="text-size-label-sm group-data-[state=active]:text-primary-label-active group-data-[state=disabled]:text-neutral-light font-medium"
|
|
61
|
-
data-slot="step-title"
|
|
62
|
-
>
|
|
63
|
-
{step}
|
|
64
|
-
</span>
|
|
65
|
-
</div>
|
|
66
|
-
|
|
67
|
-
{!isLastStep(stepIndex) && (
|
|
68
|
-
<div
|
|
69
|
-
className={twMerge(
|
|
70
|
-
'bg-border-layer-2 mx-2 h-px flex-1',
|
|
71
|
-
className
|
|
72
|
-
)}
|
|
73
|
-
/>
|
|
74
|
-
)}
|
|
75
|
-
</Fragment>
|
|
76
|
-
)
|
|
77
|
-
})}
|
|
78
|
-
</div>
|
|
79
|
-
)
|
|
80
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { cx } from '@xjur-ui/util'
|
|
2
|
-
|
|
3
|
-
export function TableBody({
|
|
4
|
-
className,
|
|
5
|
-
...props
|
|
6
|
-
}: React.ComponentProps<'tbody'>) {
|
|
7
|
-
return (
|
|
8
|
-
<tbody
|
|
9
|
-
className={cx(
|
|
10
|
-
'[&_tr]:border-border-layer-2 [&_tr]:border-b [&_tr:last-child]:border-0',
|
|
11
|
-
className
|
|
12
|
-
)}
|
|
13
|
-
data-slot="table-body"
|
|
14
|
-
{...props}
|
|
15
|
-
/>
|
|
16
|
-
)
|
|
17
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { cx } from '@xjur-ui/util'
|
|
2
|
-
|
|
3
|
-
export function TableCell({ className, ...props }: React.ComponentProps<'td'>) {
|
|
4
|
-
return (
|
|
5
|
-
<td
|
|
6
|
-
className={cx(
|
|
7
|
-
'px-small py-none h-large-8x text-left align-middle whitespace-nowrap',
|
|
8
|
-
className
|
|
9
|
-
)}
|
|
10
|
-
data-slot="table-cell"
|
|
11
|
-
{...props}
|
|
12
|
-
/>
|
|
13
|
-
)
|
|
14
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { cx } from '@xjur-ui/util'
|
|
2
|
-
|
|
3
|
-
export function TableFooter({
|
|
4
|
-
className,
|
|
5
|
-
...props
|
|
6
|
-
}: React.ComponentProps<'tfoot'>) {
|
|
7
|
-
return (
|
|
8
|
-
<tfoot
|
|
9
|
-
className={cx(
|
|
10
|
-
'border-border-layer-2 border-t font-medium [&>tr]:last:border-b-0',
|
|
11
|
-
className
|
|
12
|
-
)}
|
|
13
|
-
data-slot="table-footer"
|
|
14
|
-
{...props}
|
|
15
|
-
/>
|
|
16
|
-
)
|
|
17
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { cx } from '@xjur-ui/util'
|
|
2
|
-
|
|
3
|
-
export function TableHead({ className, ...props }: React.ComponentProps<'th'>) {
|
|
4
|
-
return (
|
|
5
|
-
<th
|
|
6
|
-
className={cx(
|
|
7
|
-
'group/th text-neutral-placeholder text-size-label-sm h-large-4x py-small-1x px-small text-left align-middle font-medium whitespace-nowrap',
|
|
8
|
-
'pr-large-2x relative',
|
|
9
|
-
'animate-in fade-in duration-200 ease-in',
|
|
10
|
-
className
|
|
11
|
-
)}
|
|
12
|
-
data-slot="table-head"
|
|
13
|
-
{...props}
|
|
14
|
-
/>
|
|
15
|
-
)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function TableHeadContent({
|
|
19
|
-
className,
|
|
20
|
-
...props
|
|
21
|
-
}: React.ComponentProps<'div'>) {
|
|
22
|
-
return (
|
|
23
|
-
<div
|
|
24
|
-
className={cx(
|
|
25
|
-
'gap-small pr-large-3x relative flex w-fit items-center',
|
|
26
|
-
className
|
|
27
|
-
)}
|
|
28
|
-
{...props}
|
|
29
|
-
/>
|
|
30
|
-
)
|
|
31
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { cx } from '@xjur-ui/util'
|
|
2
|
-
|
|
3
|
-
export function TableHeader({
|
|
4
|
-
className,
|
|
5
|
-
...props
|
|
6
|
-
}: React.ComponentProps<'thead'>) {
|
|
7
|
-
return (
|
|
8
|
-
<thead
|
|
9
|
-
className={cx(
|
|
10
|
-
'group/table-header [&_tr]:border-border-layer-2 hover:bg-layer-2-hover [&_tr]:border-b',
|
|
11
|
-
className
|
|
12
|
-
)}
|
|
13
|
-
data-slot="table-header"
|
|
14
|
-
{...props}
|
|
15
|
-
/>
|
|
16
|
-
)
|
|
17
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { cx } from '@xjur-ui/util'
|
|
2
|
-
|
|
3
|
-
export function TableRow({
|
|
4
|
-
className,
|
|
5
|
-
isSelected = false,
|
|
6
|
-
...props
|
|
7
|
-
}: React.ComponentProps<'tr'> & { isSelected?: boolean }) {
|
|
8
|
-
return (
|
|
9
|
-
<tr
|
|
10
|
-
className={cx(
|
|
11
|
-
'bg-layer-2-idle hover:bg-layer-2-hover ease border-b transition-colors duration-100',
|
|
12
|
-
'active:bg-layer-2-pressed',
|
|
13
|
-
'data-[selected=true]:bg-primary-alt-active',
|
|
14
|
-
className
|
|
15
|
-
)}
|
|
16
|
-
data-selected={isSelected}
|
|
17
|
-
data-slot="table-row"
|
|
18
|
-
{...props}
|
|
19
|
-
/>
|
|
20
|
-
)
|
|
21
|
-
}
|