@komensal/ui 0.1.0 → 0.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/dist/index.d.ts +420 -0
- package/dist/index.js +1710 -0
- package/dist/index.js.map +1 -0
- package/dist/locales/index.d.ts +34 -0
- package/dist/locales/index.js +40 -0
- package/dist/locales/index.js.map +1 -0
- package/dist/styles/index.css +8 -0
- package/package.json +24 -8
- package/src/components/alert.tsx +0 -45
- package/src/components/auth-header.tsx +0 -26
- package/src/components/button.tsx +0 -121
- package/src/components/command.tsx +0 -125
- package/src/components/dialog.tsx +0 -118
- package/src/components/form-fields/index.ts +0 -5
- package/src/components/form-fields/input-field.tsx +0 -131
- package/src/components/form-fields/label-field.tsx +0 -20
- package/src/components/form-fields/map-picker-field.tsx +0 -49
- package/src/components/form-fields/otp-field.tsx +0 -76
- package/src/components/form-fields/select-field.tsx +0 -77
- package/src/components/form.tsx +0 -138
- package/src/components/google-map-picker.tsx +0 -243
- package/src/components/input.tsx +0 -40
- package/src/components/label.tsx +0 -17
- package/src/components/loading.tsx +0 -19
- package/src/components/otp-input.tsx +0 -62
- package/src/components/password-checklist.tsx +0 -37
- package/src/components/popover.tsx +0 -31
- package/src/components/select-input.tsx +0 -236
- package/src/components/select.tsx +0 -143
- package/src/components/spinner.tsx +0 -61
- package/src/components/step-header.tsx +0 -16
- package/src/components/stepper.tsx +0 -69
- package/src/components/toast/index.ts +0 -2
- package/src/components/toast/toast-provider.tsx +0 -123
- package/src/components/toast/toast.tsx +0 -106
- package/src/components/tooltip.tsx +0 -56
- package/src/components/wrapper.tsx +0 -12
- package/src/index.ts +0 -27
- package/src/locales/es/ui.json +0 -28
- package/src/locales/index.ts +0 -7
- package/src/styles/index.css +0 -1
- package/src/types/password.ts +0 -12
- package/src/types/toast.ts +0 -19
- package/src/utils/cn.ts +0 -6
- package/src/utils/index.ts +0 -3
- package/src/utils/styles.ts +0 -19
- package/src/utils/toast-emitter.ts +0 -37
- package/src/vite-env.d.ts +0 -3
- /package/{src → dist}/styles/theme.css +0 -0
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { AlertTriangle, Check, X } from 'lucide-react'
|
|
2
|
-
import { useEffect, useMemo, useRef, useState } from 'react'
|
|
3
|
-
import { IoDocumentLockOutline, IoInformationCircle } from 'react-icons/io5'
|
|
4
|
-
|
|
5
|
-
import { ToastType } from '../../types/toast'
|
|
6
|
-
|
|
7
|
-
interface ToastProps {
|
|
8
|
-
duration?: number
|
|
9
|
-
id: string
|
|
10
|
-
onClose: (id: string) => void
|
|
11
|
-
subtitle?: string
|
|
12
|
-
title: string
|
|
13
|
-
type: ToastType
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const EXIT_ANIMATION_MS = 200
|
|
17
|
-
|
|
18
|
-
export function Toast({ duration = 2500, id, onClose, subtitle, title, type }: ToastProps) {
|
|
19
|
-
const [leaving, setLeaving] = useState(false)
|
|
20
|
-
const startedAtRef = useRef<number>(Date.now())
|
|
21
|
-
const timeoutRef = useRef<null | ReturnType<typeof setTimeout>>(null)
|
|
22
|
-
const exitRef = useRef<null | ReturnType<typeof setTimeout>>(null)
|
|
23
|
-
|
|
24
|
-
const Icon = useMemo(() => {
|
|
25
|
-
if (type === 'success') return Check
|
|
26
|
-
if (type === 'error') return X
|
|
27
|
-
if (type === 'warning') return AlertTriangle
|
|
28
|
-
if (type === 'info') return IoInformationCircle
|
|
29
|
-
return IoDocumentLockOutline
|
|
30
|
-
}, [type])
|
|
31
|
-
|
|
32
|
-
const styles = useMemo(() => {
|
|
33
|
-
if (type === 'success') {
|
|
34
|
-
return { border: 'border-success', icon: 'text-success', iconBorder: 'border-success' }
|
|
35
|
-
}
|
|
36
|
-
if (type === 'error') {
|
|
37
|
-
return { border: 'border-destructive', icon: 'text-destructive', iconBorder: 'border-destructive' }
|
|
38
|
-
}
|
|
39
|
-
if (type === 'warning') {
|
|
40
|
-
return { border: 'border-warning', icon: 'text-warning', iconBorder: 'border-warning' }
|
|
41
|
-
}
|
|
42
|
-
if (type === 'info') {
|
|
43
|
-
return { border: 'border-info', icon: 'text-info', iconBorder: 'border-info' }
|
|
44
|
-
}
|
|
45
|
-
return { border: 'border-wait', icon: 'text-wait', iconBorder: 'border-wait' }
|
|
46
|
-
}, [type])
|
|
47
|
-
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
if (timeoutRef.current) clearTimeout(timeoutRef.current)
|
|
50
|
-
if (exitRef.current) clearTimeout(exitRef.current)
|
|
51
|
-
|
|
52
|
-
const elapsed = Date.now() - startedAtRef.current
|
|
53
|
-
const remaining = Math.max(0, duration - elapsed)
|
|
54
|
-
|
|
55
|
-
timeoutRef.current = setTimeout(() => {
|
|
56
|
-
setLeaving(true)
|
|
57
|
-
exitRef.current = setTimeout(() => onClose(id), EXIT_ANIMATION_MS)
|
|
58
|
-
}, remaining)
|
|
59
|
-
|
|
60
|
-
return () => {
|
|
61
|
-
if (timeoutRef.current) clearTimeout(timeoutRef.current)
|
|
62
|
-
if (exitRef.current) clearTimeout(exitRef.current)
|
|
63
|
-
}
|
|
64
|
-
}, [id, duration, onClose])
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<div
|
|
68
|
-
aria-live='polite'
|
|
69
|
-
className={[
|
|
70
|
-
'relative',
|
|
71
|
-
leaving ? 'absolute top-0 right-0 left-0' : '',
|
|
72
|
-
'flex w-108.5 max-w-[calc(100vw-2rem)] items-center justify-between',
|
|
73
|
-
'min-h-16',
|
|
74
|
-
'bg-surface rounded-[10px] border-2',
|
|
75
|
-
'px-5 py-4.5',
|
|
76
|
-
'shadow-[0_4px_20px_rgba(0,0,0,0.05)]',
|
|
77
|
-
'transition-all duration-200 ease-out',
|
|
78
|
-
styles.border,
|
|
79
|
-
leaving ? 'translate-y-2 opacity-0' : 'translate-y-0 opacity-100'
|
|
80
|
-
].join(' ')}
|
|
81
|
-
role='status'
|
|
82
|
-
>
|
|
83
|
-
<div className='min-w-0 pr-4'>
|
|
84
|
-
<h4 className={['text-[16px] leading-normal font-semibold', 'text-foreground', 'line-clamp-2'].join(' ')}>
|
|
85
|
-
{title}
|
|
86
|
-
</h4>
|
|
87
|
-
</div>
|
|
88
|
-
|
|
89
|
-
{subtitle ? (
|
|
90
|
-
<div className='shrink-0 pr-4 text-left'>
|
|
91
|
-
<div className={['max-w-28 text-[14px] leading-[19.5px] font-normal', 'text-body'].join(' ')}>{subtitle}</div>
|
|
92
|
-
</div>
|
|
93
|
-
) : null}
|
|
94
|
-
|
|
95
|
-
<div
|
|
96
|
-
className={[
|
|
97
|
-
'shrink-0',
|
|
98
|
-
'flex h-8 w-8 min-w-8 items-center justify-center rounded-full border-2',
|
|
99
|
-
styles.iconBorder
|
|
100
|
-
].join(' ')}
|
|
101
|
-
>
|
|
102
|
-
<Icon className={['h-5 w-5', styles.icon].join(' ')} />
|
|
103
|
-
</div>
|
|
104
|
-
</div>
|
|
105
|
-
)
|
|
106
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import * as TooltipPrimitive from '@radix-ui/react-tooltip'
|
|
2
|
-
import * as React from 'react'
|
|
3
|
-
|
|
4
|
-
import { cn } from '../utils'
|
|
5
|
-
|
|
6
|
-
interface TooltipProps {
|
|
7
|
-
children: React.ReactNode
|
|
8
|
-
childrenClassName?: string
|
|
9
|
-
className?: string
|
|
10
|
-
message: string
|
|
11
|
-
sideTooltip?: 'bottom' | 'left' | 'right' | 'top'
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const TooltipProvider = TooltipPrimitive.Provider
|
|
15
|
-
const TooltipRoot = TooltipPrimitive.Root
|
|
16
|
-
const TooltipTrigger = TooltipPrimitive.Trigger
|
|
17
|
-
|
|
18
|
-
const TooltipContent = React.forwardRef<
|
|
19
|
-
React.ElementRef<typeof TooltipPrimitive.Content>,
|
|
20
|
-
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
|
|
21
|
-
>(({ className, sideOffset = 4, ...props }, ref) => (
|
|
22
|
-
<TooltipPrimitive.Portal>
|
|
23
|
-
<TooltipPrimitive.Content
|
|
24
|
-
className={cn(
|
|
25
|
-
'bg-tooltip text-tooltip-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 overflow-hidden rounded-md px-3 py-1.5 text-sm font-semibold shadow-sm',
|
|
26
|
-
className
|
|
27
|
-
)}
|
|
28
|
-
ref={ref}
|
|
29
|
-
sideOffset={sideOffset}
|
|
30
|
-
{...props}
|
|
31
|
-
/>
|
|
32
|
-
</TooltipPrimitive.Portal>
|
|
33
|
-
))
|
|
34
|
-
|
|
35
|
-
TooltipContent.displayName = TooltipPrimitive.Content.displayName
|
|
36
|
-
|
|
37
|
-
export const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>(
|
|
38
|
-
({ children, childrenClassName, className, message, sideTooltip = 'top' }, ref) => {
|
|
39
|
-
return (
|
|
40
|
-
<TooltipProvider>
|
|
41
|
-
<TooltipRoot>
|
|
42
|
-
<TooltipTrigger asChild>
|
|
43
|
-
<div className={cn('', childrenClassName)} ref={ref}>
|
|
44
|
-
{children}
|
|
45
|
-
</div>
|
|
46
|
-
</TooltipTrigger>
|
|
47
|
-
<TooltipContent className={cn('', className)} side={sideTooltip}>
|
|
48
|
-
<p>{message}</p>
|
|
49
|
-
</TooltipContent>
|
|
50
|
-
</TooltipRoot>
|
|
51
|
-
</TooltipProvider>
|
|
52
|
-
)
|
|
53
|
-
}
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
Tooltip.displayName = 'Tooltip'
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react'
|
|
2
|
-
|
|
3
|
-
import { cn } from '../utils'
|
|
4
|
-
|
|
5
|
-
export interface WrapperProps {
|
|
6
|
-
children: ReactNode
|
|
7
|
-
className?: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const Wrapper = ({ children, className }: WrapperProps) => {
|
|
11
|
-
return <div className={cn('mx-auto h-full w-full', className)}>{children}</div>
|
|
12
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export * from './components/alert'
|
|
2
|
-
export * from './components/auth-header'
|
|
3
|
-
export * from './components/button'
|
|
4
|
-
export * from './components/command'
|
|
5
|
-
export * from './components/dialog'
|
|
6
|
-
export * from './components/form'
|
|
7
|
-
export * from './components/form-fields'
|
|
8
|
-
export * from './components/google-map-picker'
|
|
9
|
-
export * from './components/input'
|
|
10
|
-
export * from './components/label'
|
|
11
|
-
export * from './components/loading'
|
|
12
|
-
export * from './components/otp-input'
|
|
13
|
-
export * from './components/password-checklist'
|
|
14
|
-
export * from './components/popover'
|
|
15
|
-
export * from './components/select'
|
|
16
|
-
export * from './components/select-input'
|
|
17
|
-
export * from './components/spinner'
|
|
18
|
-
export * from './components/step-header'
|
|
19
|
-
export * from './components/stepper'
|
|
20
|
-
export * from './components/toast'
|
|
21
|
-
export * from './components/tooltip'
|
|
22
|
-
export * from './components/wrapper'
|
|
23
|
-
|
|
24
|
-
export * from './types/toast'
|
|
25
|
-
export * from './types/password'
|
|
26
|
-
|
|
27
|
-
export { cn, inputBase, inputDisabled, inputFocus, inputPlaceholder, registerToastEmitter, toast } from './utils'
|
package/src/locales/es/ui.json
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"otpField": {
|
|
3
|
-
"description": "Se ha enviado un código OTP a tu correo . Revisa tu bandeja de entrada."
|
|
4
|
-
},
|
|
5
|
-
"inputField": {
|
|
6
|
-
"showPassword": "Mostrar contraseña",
|
|
7
|
-
"hidePassword": "Ocultar contraseña",
|
|
8
|
-
"clear": "Limpiar"
|
|
9
|
-
},
|
|
10
|
-
"dialog": {
|
|
11
|
-
"close": "Cerrar"
|
|
12
|
-
},
|
|
13
|
-
"selectInput": {
|
|
14
|
-
"placeholder": "Selecciona...",
|
|
15
|
-
"loading": "Cargando...",
|
|
16
|
-
"search": "Buscar...",
|
|
17
|
-
"noResults": "Sin resultados."
|
|
18
|
-
},
|
|
19
|
-
"passwordChecklist": {
|
|
20
|
-
"minLength": "Mínimo {{min}} caracteres",
|
|
21
|
-
"hasUpperAndLower": "Una mayúscula y minúscula",
|
|
22
|
-
"hasNumber": "Un número",
|
|
23
|
-
"hasSpecialChar": "Un carácter especial"
|
|
24
|
-
},
|
|
25
|
-
"spinner": {
|
|
26
|
-
"loading": "Cargando..."
|
|
27
|
-
}
|
|
28
|
-
}
|
package/src/locales/index.ts
DELETED
package/src/styles/index.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import './theme.css';
|
package/src/types/password.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface PasswordRule {
|
|
2
|
-
key: string
|
|
3
|
-
label: string
|
|
4
|
-
test: (value: string) => boolean
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface PasswordRulesConfig {
|
|
8
|
-
hasNumber?: boolean
|
|
9
|
-
hasSpecialChar?: boolean
|
|
10
|
-
hasUpperAndLower?: boolean
|
|
11
|
-
minLength?: false | number
|
|
12
|
-
}
|
package/src/types/toast.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export interface ToastOptions {
|
|
2
|
-
duration?: number
|
|
3
|
-
position?: ToastPosition
|
|
4
|
-
subtitle?: string
|
|
5
|
-
title: string
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export type ToastPosition =
|
|
9
|
-
| 'bottom'
|
|
10
|
-
| 'bottom-left'
|
|
11
|
-
| 'bottom-right'
|
|
12
|
-
| 'center'
|
|
13
|
-
| 'middle-bottom'
|
|
14
|
-
| 'middle-top'
|
|
15
|
-
| 'top'
|
|
16
|
-
| 'top-left'
|
|
17
|
-
| 'top-right'
|
|
18
|
-
|
|
19
|
-
export type ToastType = 'error' | 'info' | 'success' | 'wait' | 'warning'
|
package/src/utils/cn.ts
DELETED
package/src/utils/index.ts
DELETED
package/src/utils/styles.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { cn } from './cn'
|
|
2
|
-
|
|
3
|
-
export const inputBase = cn(
|
|
4
|
-
'flex w-full !h-[50px] rounded-[10px] px-3 gap-[10px] text-base font-normal justify-between items-center',
|
|
5
|
-
'border border-border bg-surface text-foreground',
|
|
6
|
-
'transition-all duration-200 ease-in-out',
|
|
7
|
-
'placeholder:text-icon-muted placeholder:text-sm placeholder:font-normal placeholder:leading-none',
|
|
8
|
-
'disabled:cursor-not-allowed disabled:bg-inactive disabled:text-inactive-text disabled:border-inactive disabled:placeholder:text-inactive-text'
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
export const inputPlaceholder = cn('text-icon-muted text-sm font-normal leading-none')
|
|
12
|
-
|
|
13
|
-
export const inputDisabled = cn('cursor-not-allowed opacity-50')
|
|
14
|
-
|
|
15
|
-
export const inputFocus = cn(
|
|
16
|
-
'focus:outline-none focus-visible:outline-none',
|
|
17
|
-
'focus-visible:ring-2 focus-visible:ring-ring focus-visible:border-primary',
|
|
18
|
-
'data-[state=open]:ring-2 data-[state=open]:ring-ring data-[state=open]:border-primary'
|
|
19
|
-
)
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { ToastOptions, ToastType } from '../types/toast'
|
|
2
|
-
|
|
3
|
-
type ToastEmitter = ((type: ToastType, options: ToastOptions) => void) | null
|
|
4
|
-
|
|
5
|
-
let emitToast: ToastEmitter = null
|
|
6
|
-
|
|
7
|
-
export const toast = {
|
|
8
|
-
error(options: string | ToastOptions) {
|
|
9
|
-
emit('error', options)
|
|
10
|
-
},
|
|
11
|
-
info(options: string | ToastOptions) {
|
|
12
|
-
emit('info', options)
|
|
13
|
-
},
|
|
14
|
-
success(options: string | ToastOptions) {
|
|
15
|
-
emit('success', options)
|
|
16
|
-
},
|
|
17
|
-
wait(options: string | ToastOptions) {
|
|
18
|
-
emit('wait', options)
|
|
19
|
-
},
|
|
20
|
-
warning(options: string | ToastOptions) {
|
|
21
|
-
emit('warning', options)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function registerToastEmitter(fn: ToastEmitter) {
|
|
26
|
-
emitToast = fn
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function emit(type: ToastType, options: string | ToastOptions) {
|
|
30
|
-
if (!emitToast) return
|
|
31
|
-
|
|
32
|
-
if (typeof options === 'string') {
|
|
33
|
-
emitToast(type, { title: options })
|
|
34
|
-
} else {
|
|
35
|
-
emitToast(type, options)
|
|
36
|
-
}
|
|
37
|
-
}
|
package/src/vite-env.d.ts
DELETED
|
File without changes
|