uibee 2.12.3 → 2.13.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/src/components/index.d.ts +1 -0
- package/dist/src/components/index.js +1 -0
- package/dist/src/components/inputs/searchInput.d.ts +6 -0
- package/dist/src/components/inputs/searchInput.js +42 -0
- package/package.json +1 -1
- package/src/components/index.ts +1 -0
- package/src/components/inputs/searchInput.tsx +72 -0
- package/src/components/table/body.tsx +3 -3
- package/src/components/table/header.tsx +4 -4
- package/src/components/table/table.tsx +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as Input } from './inputs/input';
|
|
2
|
+
export { default as SearchInput } from './inputs/searchInput';
|
|
2
3
|
export { default as Textarea } from './inputs/textarea';
|
|
3
4
|
export { default as Checkbox } from './inputs/checkbox';
|
|
4
5
|
export { default as Select } from './inputs/select';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Input components
|
|
2
2
|
export { default as Input } from './inputs/input';
|
|
3
|
+
export { default as SearchInput } from './inputs/searchInput';
|
|
3
4
|
export { default as Textarea } from './inputs/textarea';
|
|
4
5
|
export { default as Checkbox } from './inputs/checkbox';
|
|
5
6
|
export { default as Select } from './inputs/select';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
|
+
import { useRouter, usePathname, useSearchParams } from 'next/navigation';
|
|
5
|
+
import { Search } from 'lucide-react';
|
|
6
|
+
import Input from './input';
|
|
7
|
+
export default function SearchInput({ placeholder = 'Search...', variant = 'default' }) {
|
|
8
|
+
const router = useRouter();
|
|
9
|
+
const pathname = usePathname();
|
|
10
|
+
const searchParams = useSearchParams();
|
|
11
|
+
const [searchValue, setSearchValue] = useState(searchParams.get('q') || '');
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const currentQ = searchParams.get('q') || '';
|
|
14
|
+
setSearchValue(currentQ);
|
|
15
|
+
}, [searchParams]);
|
|
16
|
+
function handleSearch(value) {
|
|
17
|
+
setSearchValue(value);
|
|
18
|
+
const params = new URLSearchParams(searchParams.toString());
|
|
19
|
+
if (value.trim()) {
|
|
20
|
+
params.set('q', value.trim());
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
params.delete('q');
|
|
24
|
+
}
|
|
25
|
+
params.delete('page');
|
|
26
|
+
router.push(`${pathname}?${params.toString()}`);
|
|
27
|
+
}
|
|
28
|
+
function handleKeyDown(e) {
|
|
29
|
+
if (e.key === 'Enter') {
|
|
30
|
+
handleSearch(searchValue);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function handleChange(e) {
|
|
34
|
+
setSearchValue(e.target.value);
|
|
35
|
+
}
|
|
36
|
+
if (variant === 'minimal') {
|
|
37
|
+
return (_jsxs("div", { className: 'relative', children: [_jsx(Search, { className: 'absolute left-3 top-1/2 transform -translate-y-1/2 h-5 w-5' }), _jsx("input", { type: 'text', value: searchValue, onChange: (e) => setSearchValue(e.target.value), onKeyDown: handleKeyDown, onBlur: () => handleSearch(searchValue), placeholder: placeholder, className: 'pl-10 pr-4 py-2 border-b outline-none w-64' })] }));
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
_jsx(Input, { name: 'search', icon: _jsx(Search, { className: 'w-5 h-5' }), value: searchValue, onChange: handleChange, onKeyDown: handleKeyDown, onBlur: () => handleSearch(searchValue), placeholder: placeholder });
|
|
41
|
+
}
|
|
42
|
+
}
|
package/package.json
CHANGED
package/src/components/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Input components
|
|
2
2
|
export { default as Input } from './inputs/input'
|
|
3
|
+
export { default as SearchInput } from './inputs/searchInput'
|
|
3
4
|
export { default as Textarea } from './inputs/textarea'
|
|
4
5
|
export { default as Checkbox } from './inputs/checkbox'
|
|
5
6
|
export { default as Select } from './inputs/select'
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useState, useEffect, type KeyboardEvent, type ChangeEvent } from 'react'
|
|
4
|
+
import { useRouter, usePathname, useSearchParams } from 'next/navigation'
|
|
5
|
+
import { Search } from 'lucide-react'
|
|
6
|
+
import Input from './input'
|
|
7
|
+
|
|
8
|
+
interface SearchInputProps {
|
|
9
|
+
placeholder?: string
|
|
10
|
+
variant?: 'default' | 'minimal'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default function SearchInput({ placeholder = 'Search...', variant = 'default' }: SearchInputProps) {
|
|
14
|
+
const router = useRouter()
|
|
15
|
+
const pathname = usePathname()
|
|
16
|
+
const searchParams = useSearchParams()
|
|
17
|
+
const [searchValue, setSearchValue] = useState(searchParams.get('q') || '')
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const currentQ = searchParams.get('q') || ''
|
|
21
|
+
setSearchValue(currentQ)
|
|
22
|
+
}, [searchParams])
|
|
23
|
+
|
|
24
|
+
function handleSearch(value: string) {
|
|
25
|
+
setSearchValue(value)
|
|
26
|
+
const params = new URLSearchParams(searchParams.toString())
|
|
27
|
+
if (value.trim()) {
|
|
28
|
+
params.set('q', value.trim())
|
|
29
|
+
} else {
|
|
30
|
+
params.delete('q')
|
|
31
|
+
}
|
|
32
|
+
params.delete('page')
|
|
33
|
+
router.push(`${pathname}?${params.toString()}`)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function handleKeyDown(e: KeyboardEvent<HTMLInputElement>) {
|
|
37
|
+
if (e.key === 'Enter') {
|
|
38
|
+
handleSearch(searchValue)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function handleChange(e: ChangeEvent<HTMLInputElement>) {
|
|
43
|
+
setSearchValue(e.target.value)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (variant === 'minimal') {
|
|
47
|
+
return (
|
|
48
|
+
<div className='relative'>
|
|
49
|
+
<Search className='absolute left-3 top-1/2 transform -translate-y-1/2 h-5 w-5' />
|
|
50
|
+
<input
|
|
51
|
+
type='text'
|
|
52
|
+
value={searchValue}
|
|
53
|
+
onChange={(e) => setSearchValue(e.target.value)}
|
|
54
|
+
onKeyDown={handleKeyDown}
|
|
55
|
+
onBlur={() => handleSearch(searchValue)}
|
|
56
|
+
placeholder={placeholder}
|
|
57
|
+
className='pl-10 pr-4 py-2 border-b outline-none w-64'
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
)
|
|
61
|
+
} else {
|
|
62
|
+
<Input
|
|
63
|
+
name='search'
|
|
64
|
+
icon={<Search className='w-5 h-5' />}
|
|
65
|
+
value={searchValue}
|
|
66
|
+
onChange={handleChange}
|
|
67
|
+
onKeyDown={handleKeyDown}
|
|
68
|
+
onBlur={() => handleSearch(searchValue)}
|
|
69
|
+
placeholder={placeholder}
|
|
70
|
+
/>
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -130,12 +130,12 @@ export default function Body({ list, columns, menuItems, redirectPath, variant =
|
|
|
130
130
|
<td
|
|
131
131
|
key={col.key}
|
|
132
132
|
className={`
|
|
133
|
-
flex-1 px-6 py-4 whitespace-nowrap text-sm
|
|
133
|
+
flex-1 min-w-0 px-6 py-4 whitespace-nowrap text-sm flex items-center text-login-100
|
|
134
134
|
${variant === 'minimal' ? 'px-4! py-2!' : ''}
|
|
135
135
|
`}
|
|
136
136
|
>
|
|
137
|
-
<div className='relative'>
|
|
138
|
-
<h1 className={badgeClass}>
|
|
137
|
+
<div className='relative w-full min-w-0'>
|
|
138
|
+
<h1 className={`block max-w-full truncate ${badgeClass}`}>
|
|
139
139
|
{formatValue(col.key, value as string | number)}
|
|
140
140
|
</h1>
|
|
141
141
|
</div>
|
|
@@ -53,16 +53,16 @@ export default function Header({ columns, hideMenu, variant = 'default' }: Heade
|
|
|
53
53
|
<th
|
|
54
54
|
key={key}
|
|
55
55
|
className={`
|
|
56
|
-
flex-1 px-6 py-3 text-xs font-medium uppercase tracking-wider text-left
|
|
56
|
+
flex-1 min-w-0 px-6 py-3 text-xs font-medium uppercase tracking-wider text-left
|
|
57
57
|
${variant === 'default' ? 'text-login-200' : 'text-login-100'}
|
|
58
|
-
${variant === 'minimal' ? 'px-4
|
|
58
|
+
${variant === 'minimal' ? 'px-4!' : ''}
|
|
59
59
|
`}
|
|
60
60
|
>
|
|
61
61
|
<button
|
|
62
|
-
className='flex flex-row items-center gap-2 group uppercase'
|
|
62
|
+
className='flex w-full min-w-0 flex-row items-center gap-2 group uppercase whitespace-nowrap'
|
|
63
63
|
onClick={() => handleChange(key)}
|
|
64
64
|
>
|
|
65
|
-
{value}
|
|
65
|
+
<span className='min-w-0 truncate'>{value}</span>
|
|
66
66
|
<span className='flex flex-col'>
|
|
67
67
|
{column === key ? (
|
|
68
68
|
order === 'asc' ? (
|
|
@@ -20,7 +20,7 @@ export default function Table({ data, columns, menuItems, redirectPath, variant
|
|
|
20
20
|
|
|
21
21
|
return (
|
|
22
22
|
<div className={`
|
|
23
|
-
flex-1 flex flex-col min-h-0 overflow-x-auto h-full w-full
|
|
23
|
+
flex-1 flex flex-col min-h-0 overflow-x-auto overflow-y-hidden h-full w-full
|
|
24
24
|
${variant === 'default' ? 'bg-login-500/50 rounded-lg shadow border border-login-600' : ''}
|
|
25
25
|
${variant === 'minimal' ? 'bg-transparent' : ''}
|
|
26
26
|
`}>
|