@xjur-ui/react 2.1.1 → 2.2.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/CHANGELOG.md +12 -0
- package/dist/components/steps/index.js +1 -1
- package/package.json +7 -4
- 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
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
import { tv, twJoin, twMerge } from '@xjur-ui/util'
|
|
2
|
-
import { useMemo, type ComponentProps } from 'react'
|
|
3
|
-
import * as RadixPopover from '@radix-ui/react-popover'
|
|
4
|
-
import { Icon, type IconType } from '../icon'
|
|
5
|
-
import { Typography } from '../typography'
|
|
6
|
-
import {
|
|
7
|
-
ListHeaderTitle,
|
|
8
|
-
ListHeader,
|
|
9
|
-
ListContent,
|
|
10
|
-
ListItem,
|
|
11
|
-
ListRoot
|
|
12
|
-
} from '../list'
|
|
13
|
-
import {
|
|
14
|
-
FieldContext,
|
|
15
|
-
useFieldContext,
|
|
16
|
-
type FieldContextValue
|
|
17
|
-
} from './context/field.context'
|
|
18
|
-
import { FloatingLabel } from './floating-label'
|
|
19
|
-
|
|
20
|
-
export const select = tv({
|
|
21
|
-
slots: {
|
|
22
|
-
wrapper: 'group flex w-full flex-col gap-small-2x',
|
|
23
|
-
trigger: [
|
|
24
|
-
'h-large-4x w-full cursor-pointer relative',
|
|
25
|
-
'flex items-center gap-small rounded-small-1x justify-between',
|
|
26
|
-
'py-small_1x-alt px-small',
|
|
27
|
-
'bg-layer-2-idle border border-border-layer-2',
|
|
28
|
-
'group-has-[div[data-slot=input-action-slot]]:rounded-r-none',
|
|
29
|
-
'transition-all duration-200'
|
|
30
|
-
],
|
|
31
|
-
content: [
|
|
32
|
-
'group z-1000 max-h-[var(--radix-popover-content-available-height)] max-w-[var(--radix-popover-content-available-width)] min-w-[var(--radix-popover-trigger-width)]'
|
|
33
|
-
],
|
|
34
|
-
icon: 'size-large text-icon-neutral-3 flex items-center justify-center',
|
|
35
|
-
slotText:
|
|
36
|
-
'size-large flex items-center justify-center !text-size-label-md text-neutral-placeholder',
|
|
37
|
-
caption: '!text-size-body-sm font-normal'
|
|
38
|
-
},
|
|
39
|
-
variants: {
|
|
40
|
-
state: {
|
|
41
|
-
normal: {
|
|
42
|
-
trigger:
|
|
43
|
-
'hover:border-border-layer-3 data-[state=open]:border-primary-idle data-[state=open]:hover:border-primary-idle'
|
|
44
|
-
},
|
|
45
|
-
error: {
|
|
46
|
-
trigger:
|
|
47
|
-
'border-danger-idle hover:border-danger-idle data-[state=open]:border-danger-idle data-[state=open]:hover:border-danger-idle',
|
|
48
|
-
caption: 'text-danger-label-idle'
|
|
49
|
-
},
|
|
50
|
-
disabled: {
|
|
51
|
-
trigger: 'pointer-events-none border-transparent bg-layer-2-idle'
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
const { wrapper, trigger, icon, caption, slotText, content } = select()
|
|
58
|
-
|
|
59
|
-
export function SelectRoot({
|
|
60
|
-
className,
|
|
61
|
-
state = 'normal',
|
|
62
|
-
defaultOpen,
|
|
63
|
-
variant = 'normal',
|
|
64
|
-
modal,
|
|
65
|
-
open,
|
|
66
|
-
onOpenChange: handleOpenChange,
|
|
67
|
-
...props
|
|
68
|
-
}: ComponentProps<'div'> &
|
|
69
|
-
FieldContextValue &
|
|
70
|
-
ComponentProps<typeof RadixPopover.Root>) {
|
|
71
|
-
return (
|
|
72
|
-
<RadixPopover.Root
|
|
73
|
-
defaultOpen={defaultOpen}
|
|
74
|
-
modal={modal}
|
|
75
|
-
open={open}
|
|
76
|
-
onOpenChange={handleOpenChange}
|
|
77
|
-
>
|
|
78
|
-
<FieldContext.Provider value={{ state, variant }}>
|
|
79
|
-
<div className={wrapper({ className, state })} {...props} />
|
|
80
|
-
</FieldContext.Provider>
|
|
81
|
-
</RadixPopover.Root>
|
|
82
|
-
)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function SelectTrigger({
|
|
86
|
-
className,
|
|
87
|
-
...props
|
|
88
|
-
}: ComponentProps<typeof RadixPopover.Trigger>) {
|
|
89
|
-
const { state, variant } = useFieldContext()
|
|
90
|
-
|
|
91
|
-
const filterTrigger = tv({
|
|
92
|
-
base: ['group bg-layer-2-idle'],
|
|
93
|
-
variants: {
|
|
94
|
-
state: {
|
|
95
|
-
normal: [
|
|
96
|
-
'border-border-layer-2 hover:border-border-layer-3 has-[input:not(:placeholder-shown)]:border-primary-idle'
|
|
97
|
-
],
|
|
98
|
-
error: ['border-danger-idle hover:border-danger-idle'],
|
|
99
|
-
disabled: ['border border-border-layer-2 opacity-60']
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
const mergedClassName = twMerge(
|
|
105
|
-
trigger({ state, className }),
|
|
106
|
-
variant === 'filter' && filterTrigger({ state, className })
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
return (
|
|
110
|
-
<RadixPopover.Trigger
|
|
111
|
-
className={mergedClassName}
|
|
112
|
-
disabled={state === 'disabled'}
|
|
113
|
-
{...props}
|
|
114
|
-
/>
|
|
115
|
-
)
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export function SelectIcon({
|
|
119
|
-
className,
|
|
120
|
-
name,
|
|
121
|
-
...props
|
|
122
|
-
}: ComponentProps<'div'> & {
|
|
123
|
-
name: IconType
|
|
124
|
-
}) {
|
|
125
|
-
const { state } = useFieldContext()
|
|
126
|
-
|
|
127
|
-
return (
|
|
128
|
-
<div className={icon({ className, state })} {...props}>
|
|
129
|
-
<Icon name={name} />
|
|
130
|
-
</div>
|
|
131
|
-
)
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export function SelectLabel(props: ComponentProps<typeof FloatingLabel>) {
|
|
135
|
-
return <FloatingLabel {...props} />
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export function SelectValue({
|
|
139
|
-
className,
|
|
140
|
-
displayValue = '',
|
|
141
|
-
value,
|
|
142
|
-
placeholder,
|
|
143
|
-
...props
|
|
144
|
-
}: ComponentProps<'input'> & { displayValue?: string }) {
|
|
145
|
-
const { variant } = useFieldContext()
|
|
146
|
-
|
|
147
|
-
const valueOrPlaceholder = useMemo(() => {
|
|
148
|
-
if (variant === 'filter') return displayValue
|
|
149
|
-
return displayValue || placeholder
|
|
150
|
-
}, [displayValue, placeholder, variant])
|
|
151
|
-
|
|
152
|
-
return (
|
|
153
|
-
<div className="flex w-full">
|
|
154
|
-
<Typography className="text-neutral-dark group-has-[div[data-slot=date-picker-left-slot]]:pl-large-1x">
|
|
155
|
-
{valueOrPlaceholder}
|
|
156
|
-
</Typography>
|
|
157
|
-
|
|
158
|
-
<input
|
|
159
|
-
{...props}
|
|
160
|
-
aria-readonly={true}
|
|
161
|
-
className={twJoin('pointer-events-none', className)}
|
|
162
|
-
hidden={true}
|
|
163
|
-
placeholder={' '}
|
|
164
|
-
readOnly={true}
|
|
165
|
-
value={value ?? ''}
|
|
166
|
-
/>
|
|
167
|
-
</div>
|
|
168
|
-
)
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export function SelectMultiValue({
|
|
172
|
-
className,
|
|
173
|
-
value,
|
|
174
|
-
placeholder,
|
|
175
|
-
children,
|
|
176
|
-
...props
|
|
177
|
-
}: ComponentProps<'input'>) {
|
|
178
|
-
const { variant } = useFieldContext()
|
|
179
|
-
|
|
180
|
-
const shouldShowPlaceholder = useMemo(() => {
|
|
181
|
-
if (variant === 'filter') return false
|
|
182
|
-
return Array.isArray(value) && value.length === 0 && placeholder
|
|
183
|
-
}, [value, placeholder, variant])
|
|
184
|
-
|
|
185
|
-
return (
|
|
186
|
-
<div
|
|
187
|
-
className={twMerge(
|
|
188
|
-
className,
|
|
189
|
-
'gap-small-1x scrollbar-hide flex w-full overflow-x-hidden',
|
|
190
|
-
'group-disabled:!pl-0'
|
|
191
|
-
)}
|
|
192
|
-
>
|
|
193
|
-
{shouldShowPlaceholder && (
|
|
194
|
-
<Typography className="text-neutral-dark group-has-[div[data-slot=date-picker-left-slot]]:pl-large-1x">
|
|
195
|
-
{placeholder}
|
|
196
|
-
</Typography>
|
|
197
|
-
)}
|
|
198
|
-
|
|
199
|
-
{children}
|
|
200
|
-
|
|
201
|
-
<input
|
|
202
|
-
{...props}
|
|
203
|
-
aria-readonly={true}
|
|
204
|
-
className={twMerge(className, 'pointer-events-none')}
|
|
205
|
-
hidden={true}
|
|
206
|
-
placeholder={' '}
|
|
207
|
-
readOnly={true}
|
|
208
|
-
value={value}
|
|
209
|
-
/>
|
|
210
|
-
</div>
|
|
211
|
-
)
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
export function SelectContent({
|
|
215
|
-
className,
|
|
216
|
-
sideOffset = 5,
|
|
217
|
-
side = 'bottom',
|
|
218
|
-
align = 'start',
|
|
219
|
-
children,
|
|
220
|
-
...props
|
|
221
|
-
}: ComponentProps<typeof RadixPopover.Content>) {
|
|
222
|
-
const { state } = useFieldContext()
|
|
223
|
-
|
|
224
|
-
return (
|
|
225
|
-
<RadixPopover.Portal>
|
|
226
|
-
<RadixPopover.Content
|
|
227
|
-
align={align}
|
|
228
|
-
className={content({ className, state })}
|
|
229
|
-
side={side}
|
|
230
|
-
sideOffset={sideOffset}
|
|
231
|
-
{...props}
|
|
232
|
-
>
|
|
233
|
-
<ListRoot>{children}</ListRoot>
|
|
234
|
-
</RadixPopover.Content>
|
|
235
|
-
</RadixPopover.Portal>
|
|
236
|
-
)
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
export function SelectCaption({ className, ...props }: ComponentProps<'p'>) {
|
|
240
|
-
const { state } = useFieldContext()
|
|
241
|
-
return <p className={caption({ className, state })} {...props} />
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
export function SelectSlot({ className, ...props }: ComponentProps<'span'>) {
|
|
245
|
-
const { state } = useFieldContext()
|
|
246
|
-
return <span className={slotText({ className, state })} {...props} />
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export function SelectOptions(props: ComponentProps<typeof ListContent>) {
|
|
250
|
-
return <ListContent {...props} />
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
export function SelectOption({
|
|
254
|
-
className,
|
|
255
|
-
...props
|
|
256
|
-
}: ComponentProps<typeof ListItem>) {
|
|
257
|
-
return (
|
|
258
|
-
<ListItem className={twMerge(className, 'cursor-pointer')} {...props} />
|
|
259
|
-
)
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
export function SelectOptionText(props: ComponentProps<typeof Typography>) {
|
|
263
|
-
return <Typography {...props} />
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
export function SelectHeader(props: ComponentProps<typeof ListHeader>) {
|
|
267
|
-
return <ListHeader {...props} />
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
export function SelectHeaderTitle(
|
|
271
|
-
props: ComponentProps<typeof ListHeaderTitle>
|
|
272
|
-
) {
|
|
273
|
-
return <ListHeaderTitle {...props} />
|
|
274
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
import * as SwitchPrimitive from '@radix-ui/react-switch'
|
|
3
|
-
import { cx } from '@xjur-ui/util'
|
|
4
|
-
|
|
5
|
-
function Switch({
|
|
6
|
-
className,
|
|
7
|
-
...props
|
|
8
|
-
}: React.ComponentProps<typeof SwitchPrimitive.Root>) {
|
|
9
|
-
return (
|
|
10
|
-
<SwitchPrimitive.Root
|
|
11
|
-
className={cx(
|
|
12
|
-
'w-large-3x h-large rounded-circle inline-flex shrink-0 items-center border border-transparent',
|
|
13
|
-
'peer data-[state=checked]:bg-primary-idle data-[state=unchecked]:bg-alt-4',
|
|
14
|
-
'focus-visible:border-ring focus-visible:ring-ring/50 transition-all outline-none disabled:cursor-not-allowed disabled:opacity-50',
|
|
15
|
-
'hover:shadow-focus-primary p-[2px]',
|
|
16
|
-
className
|
|
17
|
-
)}
|
|
18
|
-
data-slot="switch"
|
|
19
|
-
{...props}
|
|
20
|
-
>
|
|
21
|
-
<SwitchPrimitive.Thumb
|
|
22
|
-
className={cx(
|
|
23
|
-
'bg-layer-2-idle size-medium pointer-events-none rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0'
|
|
24
|
-
)}
|
|
25
|
-
data-slot="switch-thumb"
|
|
26
|
-
/>
|
|
27
|
-
</SwitchPrimitive.Root>
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { Switch }
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from './pessoa'
|
|
2
|
-
export * from './pessoa.context'
|
|
3
|
-
export * from './pessoa-add-button'
|
|
4
|
-
export * from './pessoa-body'
|
|
5
|
-
export * from './pessoa-content'
|
|
6
|
-
export * from './pessoa-footer'
|
|
7
|
-
export * from './pessoa-header'
|
|
8
|
-
export * from './pessoa-trigger'
|
|
9
|
-
export * from './pessoa-close-button'
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { twMerge } from '@xjur-ui/util'
|
|
2
|
-
import { type ComponentProps, type MouseEvent, useCallback } from 'react'
|
|
3
|
-
import { Button } from '../../controls/button'
|
|
4
|
-
import { Icon } from '../../icon'
|
|
5
|
-
import { usePessoaContext } from './pessoa.context'
|
|
6
|
-
|
|
7
|
-
export function PessoaAddButton({
|
|
8
|
-
appearance = 'ghost',
|
|
9
|
-
onClick,
|
|
10
|
-
className,
|
|
11
|
-
children = 'Adicionar',
|
|
12
|
-
...props
|
|
13
|
-
}: ComponentProps<typeof Button>) {
|
|
14
|
-
const { changeCurrentView } = usePessoaContext()
|
|
15
|
-
|
|
16
|
-
const handleAddPessoaClick = useCallback(
|
|
17
|
-
(event: MouseEvent<HTMLButtonElement>) => {
|
|
18
|
-
changeCurrentView('form')
|
|
19
|
-
onClick?.(event)
|
|
20
|
-
},
|
|
21
|
-
[changeCurrentView, onClick]
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<Button
|
|
26
|
-
appearance={appearance}
|
|
27
|
-
className={twMerge('w-fit', className)}
|
|
28
|
-
onClick={handleAddPessoaClick}
|
|
29
|
-
{...props}
|
|
30
|
-
>
|
|
31
|
-
{children}
|
|
32
|
-
<Icon name="add" />
|
|
33
|
-
</Button>
|
|
34
|
-
)
|
|
35
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { twMerge } from '@xjur-ui/util'
|
|
2
|
-
import type { ComponentProps } from 'react'
|
|
3
|
-
import { SheetBody } from '../../sheet'
|
|
4
|
-
import { usePessoaContext } from './pessoa.context'
|
|
5
|
-
|
|
6
|
-
export function PessoaBody({
|
|
7
|
-
className,
|
|
8
|
-
...props
|
|
9
|
-
}: ComponentProps<typeof SheetBody>) {
|
|
10
|
-
const { currentView } = usePessoaContext()
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<SheetBody
|
|
14
|
-
className={twMerge(
|
|
15
|
-
'gap-large-2x data-[view=form]:!px-none flex flex-col',
|
|
16
|
-
className
|
|
17
|
-
)}
|
|
18
|
-
data-view={currentView}
|
|
19
|
-
{...props}
|
|
20
|
-
/>
|
|
21
|
-
)
|
|
22
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ComponentProps } from 'react'
|
|
2
|
-
import { SheetClose } from '../../sheet'
|
|
3
|
-
import { Button } from '../../controls/button'
|
|
4
|
-
|
|
5
|
-
export function PessoaCloseButton({
|
|
6
|
-
...props
|
|
7
|
-
}: ComponentProps<typeof SheetClose>) {
|
|
8
|
-
return (
|
|
9
|
-
<SheetClose {...props} asChild={true}>
|
|
10
|
-
<Button appearance="ghost">Cancelar</Button>
|
|
11
|
-
</SheetClose>
|
|
12
|
-
)
|
|
13
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { twMerge } from '@xjur-ui/util'
|
|
2
|
-
import type { ComponentProps } from 'react'
|
|
3
|
-
import { SheetContent } from '../../sheet'
|
|
4
|
-
import { usePessoaContext } from './pessoa.context'
|
|
5
|
-
|
|
6
|
-
export function PessoaContent({
|
|
7
|
-
className,
|
|
8
|
-
side = 'right',
|
|
9
|
-
...props
|
|
10
|
-
}: ComponentProps<typeof SheetContent>) {
|
|
11
|
-
const { currentView, isFullscreen } = usePessoaContext()
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<SheetContent
|
|
15
|
-
className={twMerge(
|
|
16
|
-
'min-w-[900px] data-[fullscreen=true]:min-w-full',
|
|
17
|
-
className
|
|
18
|
-
)}
|
|
19
|
-
data-fullscreen={isFullscreen}
|
|
20
|
-
data-view={currentView}
|
|
21
|
-
side={side}
|
|
22
|
-
{...props}
|
|
23
|
-
/>
|
|
24
|
-
)
|
|
25
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { twMerge } from '@xjur-ui/util'
|
|
2
|
-
import type { ComponentProps } from 'react'
|
|
3
|
-
import { SheetFooter } from '../../sheet'
|
|
4
|
-
|
|
5
|
-
export function PessoaFooter({
|
|
6
|
-
className,
|
|
7
|
-
...props
|
|
8
|
-
}: ComponentProps<typeof SheetFooter>) {
|
|
9
|
-
return (
|
|
10
|
-
<SheetFooter
|
|
11
|
-
className={twMerge('flex items-center justify-between', className)}
|
|
12
|
-
{...props}
|
|
13
|
-
/>
|
|
14
|
-
)
|
|
15
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { ComponentProps } from 'react'
|
|
2
|
-
import { twMerge } from '@xjur-ui/util'
|
|
3
|
-
import { SheetHeader, SheetTitle, SheetClose } from '../../sheet'
|
|
4
|
-
import { Button } from '../../controls/button'
|
|
5
|
-
import { Icon } from '../../icon'
|
|
6
|
-
import { usePessoaContext } from './pessoa.context'
|
|
7
|
-
|
|
8
|
-
export function PessoaHeader({
|
|
9
|
-
title,
|
|
10
|
-
className,
|
|
11
|
-
...props
|
|
12
|
-
}: ComponentProps<typeof SheetHeader> & { title: string }) {
|
|
13
|
-
const { changeIsFullscreen } = usePessoaContext()
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<SheetHeader
|
|
17
|
-
className={twMerge('flex items-center justify-between', className)}
|
|
18
|
-
{...props}
|
|
19
|
-
>
|
|
20
|
-
<SheetTitle>{title}</SheetTitle>
|
|
21
|
-
|
|
22
|
-
<div className="gap-small flex items-center">
|
|
23
|
-
<Button
|
|
24
|
-
appearance="ghost"
|
|
25
|
-
size="icon_md"
|
|
26
|
-
variant="tertiary"
|
|
27
|
-
onClick={() => changeIsFullscreen()}
|
|
28
|
-
>
|
|
29
|
-
<Icon className="text-icon-neutral-3" name="expand_content" />
|
|
30
|
-
</Button>
|
|
31
|
-
<SheetClose />
|
|
32
|
-
</div>
|
|
33
|
-
</SheetHeader>
|
|
34
|
-
)
|
|
35
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { ComponentProps } from 'react'
|
|
2
|
-
import { Button } from '../../controls/button'
|
|
3
|
-
import { SheetTrigger } from '../../sheet'
|
|
4
|
-
import { Icon } from '../../icon'
|
|
5
|
-
|
|
6
|
-
export function PessoaTrigger({
|
|
7
|
-
children = (
|
|
8
|
-
<Button
|
|
9
|
-
appearance="ghost"
|
|
10
|
-
className="border-border-layer-2 border"
|
|
11
|
-
variant="secondary"
|
|
12
|
-
>
|
|
13
|
-
<Icon className="text-icon-neutral-3" name="add" />
|
|
14
|
-
Adicionar
|
|
15
|
-
</Button>
|
|
16
|
-
),
|
|
17
|
-
asChild = true,
|
|
18
|
-
...props
|
|
19
|
-
}: ComponentProps<typeof SheetTrigger>) {
|
|
20
|
-
return (
|
|
21
|
-
<SheetTrigger asChild={asChild} {...props}>
|
|
22
|
-
{children}
|
|
23
|
-
</SheetTrigger>
|
|
24
|
-
)
|
|
25
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createContext,
|
|
3
|
-
useCallback,
|
|
4
|
-
useContext,
|
|
5
|
-
useState,
|
|
6
|
-
useMemo
|
|
7
|
-
} from 'react'
|
|
8
|
-
|
|
9
|
-
export interface PessoaContextValue {
|
|
10
|
-
currentView: 'list' | 'form'
|
|
11
|
-
isFullscreen: boolean
|
|
12
|
-
pessoas: unknown[]
|
|
13
|
-
changeCurrentView: (view: PessoaContextValue['currentView']) => void
|
|
14
|
-
changeIsFullscreen: () => void
|
|
15
|
-
setPessoas: React.Dispatch<React.SetStateAction<unknown[]>>
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const PessoaContext = createContext<PessoaContextValue>(
|
|
19
|
-
{} as PessoaContextValue
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
export function PessoaProvider({ children }: { children: React.ReactNode }) {
|
|
23
|
-
const [currentView, setCurrentView] = useState<'list' | 'form'>('list')
|
|
24
|
-
const [isFullscreen, setIsFullscreen] = useState(false)
|
|
25
|
-
const [pessoas, setPessoas] = useState<unknown[]>([])
|
|
26
|
-
|
|
27
|
-
const changeCurrentView = useCallback((view: 'list' | 'form') => {
|
|
28
|
-
setCurrentView(view)
|
|
29
|
-
}, [])
|
|
30
|
-
|
|
31
|
-
const changeIsFullscreen = useCallback(() => {
|
|
32
|
-
setIsFullscreen(state => !state)
|
|
33
|
-
}, [])
|
|
34
|
-
|
|
35
|
-
const providerValue = useMemo(
|
|
36
|
-
() => ({
|
|
37
|
-
currentView,
|
|
38
|
-
changeCurrentView,
|
|
39
|
-
isFullscreen,
|
|
40
|
-
changeIsFullscreen,
|
|
41
|
-
pessoas,
|
|
42
|
-
setPessoas
|
|
43
|
-
}),
|
|
44
|
-
[
|
|
45
|
-
currentView,
|
|
46
|
-
changeCurrentView,
|
|
47
|
-
isFullscreen,
|
|
48
|
-
changeIsFullscreen,
|
|
49
|
-
pessoas,
|
|
50
|
-
setPessoas
|
|
51
|
-
]
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<PessoaContext.Provider value={providerValue}>
|
|
56
|
-
{children}
|
|
57
|
-
</PessoaContext.Provider>
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function usePessoaContext<T = unknown>() {
|
|
62
|
-
const context = useContext(PessoaContext)
|
|
63
|
-
|
|
64
|
-
if (!context) {
|
|
65
|
-
throw new Error('usePessoaContext must be used within a PessoaProvider')
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
...context,
|
|
70
|
-
pessoas: context.pessoas as T[],
|
|
71
|
-
setPessoas: context.setPessoas as React.Dispatch<React.SetStateAction<T[]>>
|
|
72
|
-
}
|
|
73
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { type ComponentProps } from 'react'
|
|
2
|
-
import { SheetRoot } from '../../sheet'
|
|
3
|
-
import {
|
|
4
|
-
PessoaProvider,
|
|
5
|
-
PessoaContext,
|
|
6
|
-
type PessoaContextValue
|
|
7
|
-
} from './pessoa.context'
|
|
8
|
-
|
|
9
|
-
export function PessoaRoot({
|
|
10
|
-
onOpenChange,
|
|
11
|
-
children,
|
|
12
|
-
...props
|
|
13
|
-
}: Omit<ComponentProps<typeof SheetRoot>, 'children'> & {
|
|
14
|
-
children: React.ReactNode | ((context: PessoaContextValue) => React.ReactNode)
|
|
15
|
-
}) {
|
|
16
|
-
return (
|
|
17
|
-
<PessoaProvider>
|
|
18
|
-
<PessoaContext.Consumer>
|
|
19
|
-
{pessoaContext => (
|
|
20
|
-
<SheetRoot
|
|
21
|
-
onOpenChange={open => {
|
|
22
|
-
pessoaContext.changeCurrentView('list')
|
|
23
|
-
onOpenChange?.(open)
|
|
24
|
-
}}
|
|
25
|
-
{...props}
|
|
26
|
-
>
|
|
27
|
-
{typeof children === 'function'
|
|
28
|
-
? children(pessoaContext)
|
|
29
|
-
: children}
|
|
30
|
-
</SheetRoot>
|
|
31
|
-
)}
|
|
32
|
-
</PessoaContext.Consumer>
|
|
33
|
-
</PessoaProvider>
|
|
34
|
-
)
|
|
35
|
-
}
|