260713_01_ENH: 테이블 스티키 헤더 수정, KriSelect에 disabled 추가, 타임 피커 시간 내림차순에서 오른 차순으로 변경
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "kri-ui-registry",
|
"name": "kri-ui-registry",
|
||||||
"version": "0.5.1",
|
"version": "0.6.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "KRI internal shadcn UI registry",
|
"description": "KRI internal shadcn UI registry",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export type KriSelectProps<T> = {
|
|||||||
getValue?: (item: T) => string
|
getValue?: (item: T) => string
|
||||||
getLabel?: (item: T) => string
|
getLabel?: (item: T) => string
|
||||||
useAll?: boolean
|
useAll?: boolean
|
||||||
|
disabled?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const HEIGHT_CLASS_VALUE: Record<string, CSSProperties['height']> = {
|
const HEIGHT_CLASS_VALUE: Record<string, CSSProperties['height']> = {
|
||||||
@@ -47,6 +48,7 @@ export function KriSelect<T>({
|
|||||||
getValue,
|
getValue,
|
||||||
getLabel,
|
getLabel,
|
||||||
useAll = true,
|
useAll = true,
|
||||||
|
disabled,
|
||||||
}: KriSelectProps<T>) {
|
}: KriSelectProps<T>) {
|
||||||
const extractValue = (item: T) => (getValue ? getValue(item) : String(item))
|
const extractValue = (item: T) => (getValue ? getValue(item) : String(item))
|
||||||
const extractLabel = (item: T) => (getLabel ? getLabel(item) : String(item))
|
const extractLabel = (item: T) => (getLabel ? getLabel(item) : String(item))
|
||||||
@@ -57,6 +59,7 @@ export function KriSelect<T>({
|
|||||||
return (
|
return (
|
||||||
<Select
|
<Select
|
||||||
value={value}
|
value={value}
|
||||||
|
disabled={disabled}
|
||||||
onValueChange={(selectedValue) => {
|
onValueChange={(selectedValue) => {
|
||||||
onChange?.(selectedValue)
|
onChange?.(selectedValue)
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export function KriTimePicker({
|
|||||||
const normalizedMinuteStep = Number.isFinite(minuteStep) && minuteStep > 0
|
const normalizedMinuteStep = Number.isFinite(minuteStep) && minuteStep > 0
|
||||||
? Math.min(Math.floor(minuteStep), 60)
|
? Math.min(Math.floor(minuteStep), 60)
|
||||||
: 5
|
: 5
|
||||||
const hours = Array.from({ length: 24 }, (_, index) => 23 - index)
|
const hours = Array.from({ length: 24 }, (_, index) => index)
|
||||||
const minutes = Array.from(
|
const minutes = Array.from(
|
||||||
{ length: Math.ceil(60 / normalizedMinuteStep) },
|
{ length: Math.ceil(60 / normalizedMinuteStep) },
|
||||||
(_, index) => index * normalizedMinuteStep,
|
(_, index) => index * normalizedMinuteStep,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { flexRender, getCoreRowModel, getPaginationRowModel, getSortedRowModel,
|
|||||||
import { ArrowDown, ArrowUp, ArrowUpDown } from 'lucide-react'
|
import { ArrowDown, ArrowUp, ArrowUpDown } from 'lucide-react'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { Checkbox } from '@/components/ui/checkbox'
|
import { Checkbox } from '@/components/ui/checkbox'
|
||||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'
|
import { TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'
|
||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
import type { DataTableColumn, DataTableProps } from './DataTable.type'
|
import type { DataTableColumn, DataTableProps } from './DataTable.type'
|
||||||
import { DataTablePagination } from './DataTablePagination'
|
import { DataTablePagination } from './DataTablePagination'
|
||||||
@@ -31,6 +31,7 @@ export function DataTable<TData, TValue = unknown>({
|
|||||||
paginationItemsToDisplay = 5,
|
paginationItemsToDisplay = 5,
|
||||||
emptyText = '데이터가 없습니다.',
|
emptyText = '데이터가 없습니다.',
|
||||||
className,
|
className,
|
||||||
|
maxBodyHeight,
|
||||||
}: Readonly<DataTableProps<TData, TValue>>) {
|
}: Readonly<DataTableProps<TData, TValue>>) {
|
||||||
const [internalPagination, setInternalPagination] = useState<PaginationState>({ pageIndex: 0, pageSize: defaultPageSize })
|
const [internalPagination, setInternalPagination] = useState<PaginationState>({ pageIndex: 0, pageSize: defaultPageSize })
|
||||||
const [sorting, setSorting] = useState<SortingState>([])
|
const [sorting, setSorting] = useState<SortingState>([])
|
||||||
@@ -133,8 +134,12 @@ export function DataTable<TData, TValue = unknown>({
|
|||||||
return (
|
return (
|
||||||
<div className={cn('w-full space-y-4', className)}>
|
<div className={cn('w-full space-y-4', className)}>
|
||||||
<div className="rounded-md border">
|
<div className="rounded-md border">
|
||||||
<Table>
|
<div
|
||||||
<TableHeader>
|
className={cn('relative w-full overflow-x-auto', maxBodyHeight && 'overflow-y-auto')}
|
||||||
|
style={maxBodyHeight ? { maxHeight: maxBodyHeight } : undefined}
|
||||||
|
>
|
||||||
|
<table className="w-full caption-bottom text-sm">
|
||||||
|
<TableHeader className={cn(maxBodyHeight && 'sticky top-0 z-10 bg-background')}>
|
||||||
{table.getHeaderGroups().map((headerGroup) => (
|
{table.getHeaderGroups().map((headerGroup) => (
|
||||||
<TableRow key={headerGroup.id} className="hover:bg-transparent">
|
<TableRow key={headerGroup.id} className="hover:bg-transparent">
|
||||||
{headerGroup.headers.map((header) => {
|
{headerGroup.headers.map((header) => {
|
||||||
@@ -183,7 +188,8 @@ export function DataTable<TData, TValue = unknown>({
|
|||||||
<TableRow><TableCell colSpan={enhancedColumns.length} className="h-24 text-center">{emptyText}</TableCell></TableRow>
|
<TableRow><TableCell colSpan={enhancedColumns.length} className="h-24 text-center">{emptyText}</TableCell></TableRow>
|
||||||
)}
|
)}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<DataTablePagination
|
<DataTablePagination
|
||||||
|
|||||||
@@ -34,4 +34,5 @@ export interface DataTableProps<TData, TValue = unknown> {
|
|||||||
paginationItemsToDisplay?: number
|
paginationItemsToDisplay?: number
|
||||||
emptyText?: string
|
emptyText?: string
|
||||||
className?: string
|
className?: string
|
||||||
|
maxBodyHeight?: string
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user