@gentleduck/registry-ui 0.3.0 → 0.3.2
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/.turbo/turbo-test.log +19 -19
- package/CHANGELOG.md +14 -0
- package/LICENSE +21 -0
- package/SECURITY.md +19 -0
- package/bunfig.toml +2 -0
- package/package.json +12 -4
- package/src/calendar/calendar-day.tsx +131 -0
- package/src/calendar/calendar-header.tsx +291 -0
- package/src/calendar/calendar.tsx +195 -182
- package/src/calendar/calendar.types.ts +135 -0
- package/src/calendar/calendar.utils.ts +23 -0
- package/src/calendar/index.ts +2 -1
- package/src/sonner/sonner.chunks.tsx +0 -1
- package/tsconfig.json +1 -1
- package/src/_old/_table/index.ts +0 -14
- package/src/_old/_table/table-advanced.constants.tsx +0 -24
- package/src/_old/_table/table-advanced.tsx +0 -311
- package/src/_old/_table/table-advanced.types.ts +0 -272
- package/src/_old/_table/table.constants.ts +0 -2
- package/src/_old/_table/table.hook.tsx +0 -115
- package/src/_old/_table/table.lib.ts +0 -85
- package/src/_old/_table/table.tsx +0 -916
- package/src/_old/_table/table.types.ts +0 -118
- package/src/_old/_table/todo.md +0 -11
- package/src/_old/_upload/index.ts +0 -22
- package/src/_old/_upload/todo.md +0 -38
- package/src/_old/_upload/upload-advanced-chunks.tsx +0 -1624
- package/src/_old/_upload/upload-advanced.tsx +0 -507
- package/src/_old/_upload/upload-sonner.tsx +0 -58
- package/src/_old/_upload/upload.assets.tsx +0 -239
- package/src/_old/_upload/upload.constants.tsx +0 -75
- package/src/_old/_upload/upload.dto.ts +0 -19
- package/src/_old/_upload/upload.lib.tsx +0 -630
- package/src/_old/_upload/upload.tsx +0 -491
- package/src/_old/_upload/upload.types.ts +0 -436
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
// @ts-noCheck
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import { DuckTableContext } from './table-advanced'
|
|
4
|
-
import { DuckTableContextType } from './table-advanced.types'
|
|
5
|
-
|
|
6
|
-
export const useDuckTable = <
|
|
7
|
-
Column extends Record<string, unknown> = Record<string, unknown>,
|
|
8
|
-
>(): DuckTableContextType<Column> | null => {
|
|
9
|
-
const context = React.useContext(DuckTableContext)
|
|
10
|
-
if (!context) {
|
|
11
|
-
throw new Error('useTableProvider must be used within an TableProvider')
|
|
12
|
-
}
|
|
13
|
-
return context
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// <TableRow key={idx}>
|
|
17
|
-
// {tableDataFiltered.map(([key, value], idx) => {
|
|
18
|
-
// const headersEntries = headers.map(
|
|
19
|
-
// item => item.label.toString().toLowerCase() ?? item.children?.toString().toLowerCase()
|
|
20
|
-
// )
|
|
21
|
-
// const { className, children, withLabel, ...props } = value
|
|
22
|
-
// const {
|
|
23
|
-
// className: labelClassName,
|
|
24
|
-
// children: labelChildren,
|
|
25
|
-
// type: labelType = 'default',
|
|
26
|
-
// ...labelProps
|
|
27
|
-
// } = item?.[key]?.withLabel ?? {}
|
|
28
|
-
//
|
|
29
|
-
// return (
|
|
30
|
-
// headersEntries.includes(key.toString().toLowerCase()) && (
|
|
31
|
-
// <TableCell
|
|
32
|
-
// key={key}
|
|
33
|
-
// className={cn('py-2 h-[50px]', selected.includes(item) && 'bg-muted', className)}
|
|
34
|
-
// {...props}
|
|
35
|
-
// >
|
|
36
|
-
// <div
|
|
37
|
-
// className={cn(
|
|
38
|
-
// 'items-center gap-2 flex w-full',
|
|
39
|
-
// headers?.[idx]?.className,
|
|
40
|
-
// className,
|
|
41
|
-
// idx === headersEntries.length - 1 && dropdownMenu && 'justify-between w-full'
|
|
42
|
-
// )}
|
|
43
|
-
// >
|
|
44
|
-
// {/*NOTE: Rendering Checkbox */}
|
|
45
|
-
// {selection && idx === 0 && (
|
|
46
|
-
// <Checkbox
|
|
47
|
-
// className="border-border"
|
|
48
|
-
// onClick={() =>
|
|
49
|
-
// setSelected(
|
|
50
|
-
// selected.includes(item) ? selected.filter(i => i !== item) : [...selected, item]
|
|
51
|
-
// )
|
|
52
|
-
// }
|
|
53
|
-
// checked={selected.includes(item)}
|
|
54
|
-
// />
|
|
55
|
-
// )}
|
|
56
|
-
//
|
|
57
|
-
// {/*NOTE: Rendering Label */}
|
|
58
|
-
// {labelChildren && (
|
|
59
|
-
// <Badge
|
|
60
|
-
// variant={'outline'}
|
|
61
|
-
// size={'sm'}
|
|
62
|
-
// className={cn(labelType === 'default' ? '' : 'bg-red-500', labelClassName)}
|
|
63
|
-
// {...labelProps}
|
|
64
|
-
// >
|
|
65
|
-
// {labelChildren}
|
|
66
|
-
// </Badge>
|
|
67
|
-
// )}
|
|
68
|
-
//
|
|
69
|
-
// <div className="flex items-center gap-2 text-ellipsis overflow-hidden whitespace-nowrap">
|
|
70
|
-
// {/*NOTE: Getting Icons from Filter Data */}
|
|
71
|
-
// {filtersData?.length &&
|
|
72
|
-
// filtersData?.map(item => {
|
|
73
|
-
// return item?.content?.data.map((item, idx) => {
|
|
74
|
-
// const { children: Icon, ...props } = item?.element?.icon ?? {}
|
|
75
|
-
// return item.label?.toString().toLowerCase() ===
|
|
76
|
-
// (children as string).toString().toLowerCase() ? (
|
|
77
|
-
// <span
|
|
78
|
-
// className="whitespace-nowrap"
|
|
79
|
-
// key={idx}
|
|
80
|
-
// >
|
|
81
|
-
// {(Icon ? <Icon {...props} /> : '') as React.ReactNode}
|
|
82
|
-
// </span>
|
|
83
|
-
// ) : null
|
|
84
|
-
// })
|
|
85
|
-
// })}
|
|
86
|
-
//
|
|
87
|
-
// {/*NOTE: Rendering the row column childrend */}
|
|
88
|
-
// <span className="text-ellipsis overflow-hidden whitespace-nowrap">{children}</span>
|
|
89
|
-
// </div>
|
|
90
|
-
// {/*NOTE: Dropdown Menu */}
|
|
91
|
-
// {idx === headersEntries.length - 1 && dropdownMenu.optionsData?.length && (
|
|
92
|
-
// <DropdownMenuView
|
|
93
|
-
// trigger={{
|
|
94
|
-
// className: 'flex h-8 w-8 p-0 data-[state=open]:bg-muted',
|
|
95
|
-
// children: <span className="sr-only">Open menu</span>,
|
|
96
|
-
// variant: 'ghost',
|
|
97
|
-
// size: 'icon',
|
|
98
|
-
// icon: {
|
|
99
|
-
// children: Ellipsis,
|
|
100
|
-
// className: 'h-4 w-4',
|
|
101
|
-
// },
|
|
102
|
-
// }}
|
|
103
|
-
// content={{
|
|
104
|
-
// align: 'end',
|
|
105
|
-
// options: dropdownMenu,
|
|
106
|
-
// }}
|
|
107
|
-
// />
|
|
108
|
-
// )}
|
|
109
|
-
// </div>
|
|
110
|
-
// </TableCell>
|
|
111
|
-
// )
|
|
112
|
-
// )
|
|
113
|
-
// })}
|
|
114
|
-
// </TableRow>
|
|
115
|
-
//
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
// @ts-noCheck
|
|
2
|
-
import { DropdownMenuOptionsDataType } from '@/registry/default/ui/dropdown-menu'
|
|
3
|
-
import { Order, TableHeaderType } from './table.types'
|
|
4
|
-
import { ColumnsViewedStateType, TableContentDataType } from './table-advanced.types'
|
|
5
|
-
|
|
6
|
-
export function sortArray<T>(columns: TableHeaderType[], array: T[], key?: keyof T, order: Order = 'desc') {
|
|
7
|
-
const toggleSortOrder = (currentOrder: Order): Order => {
|
|
8
|
-
if (currentOrder === 'not sorted') return order
|
|
9
|
-
if (currentOrder === 'asc' && order === 'asc') return 'not sorted'
|
|
10
|
-
if (currentOrder === 'asc' && order === 'desc') return 'desc'
|
|
11
|
-
if (currentOrder === 'desc' && order === 'desc') return 'not sorted'
|
|
12
|
-
if (currentOrder === 'desc' && order === 'asc') return 'asc'
|
|
13
|
-
return 'not sorted'
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const updatedColumns = columns.map((col) => {
|
|
17
|
-
if (col.label === key) {
|
|
18
|
-
return {
|
|
19
|
-
...col,
|
|
20
|
-
currentSort: toggleSortOrder(col.currentSort ?? 'not sorted'),
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return col
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
const sortedData = array.toSorted((a, b) => {
|
|
27
|
-
const valueA = key ? (a[key] as TableContentDataType).children : a
|
|
28
|
-
const valueB = key ? (b[key] as TableContentDataType).children : b
|
|
29
|
-
|
|
30
|
-
if (order === 'not sorted' || !key) return 0
|
|
31
|
-
|
|
32
|
-
if (typeof valueA === 'string' && typeof valueB === 'string') {
|
|
33
|
-
return order === 'asc' ? valueA.localeCompare(valueB) : valueB.localeCompare(valueA)
|
|
34
|
-
} else if (typeof valueA === 'number' && typeof valueB === 'number') {
|
|
35
|
-
return order === 'asc' ? valueA - valueB : valueB - valueA
|
|
36
|
-
} else {
|
|
37
|
-
return order === 'asc' ? (valueA > valueB ? 1 : -1) : valueA < valueB ? 1 : -1
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
return { sortedData, updatedColumns }
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export type OptionsDataType<T extends Record<string, unknown>> = {
|
|
45
|
-
header: ColumnsViewedStateType<T>[]
|
|
46
|
-
columnsViewed?: ColumnsViewedStateType<T>[]
|
|
47
|
-
setColumnsViewed?: React.Dispatch<React.SetStateAction<ColumnsViewedStateType<T>[]>>
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function get_options_data<T extends Record<string, unknown> = Record<string, string>>({
|
|
51
|
-
header,
|
|
52
|
-
columnsViewed,
|
|
53
|
-
setColumnsViewed,
|
|
54
|
-
}: OptionsDataType<T>) {
|
|
55
|
-
return header.map((column, idx) => {
|
|
56
|
-
const { children, className, label, sortable, disabled, currentSort, dropdownMenuOptions, ...props } = column ?? {}
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
checked: columnsViewed?.some((headerItem) => headerItem?.label === label),
|
|
60
|
-
children: label ?? children,
|
|
61
|
-
className: 'capitalize',
|
|
62
|
-
disabled: disabled,
|
|
63
|
-
key: idx,
|
|
64
|
-
onCheckedChange: () => {
|
|
65
|
-
setColumnsViewed?.((prevHeaders) => {
|
|
66
|
-
const exists = prevHeaders.some((headerItem) => headerItem?.label === label)
|
|
67
|
-
|
|
68
|
-
if (exists) {
|
|
69
|
-
return prevHeaders.filter((headerItem) => headerItem?.label !== label)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const originalIndex = header.findIndex((headerItem) => headerItem?.label === label)
|
|
73
|
-
const newHeaders = [...prevHeaders]
|
|
74
|
-
newHeaders.splice(originalIndex, 0, column)
|
|
75
|
-
return newHeaders.sort(
|
|
76
|
-
(a, b) =>
|
|
77
|
-
header.findIndex((headerItem) => headerItem?.label === a?.label) -
|
|
78
|
-
header.findIndex((headerItem) => headerItem?.label === b?.label),
|
|
79
|
-
)
|
|
80
|
-
})
|
|
81
|
-
},
|
|
82
|
-
...props,
|
|
83
|
-
}
|
|
84
|
-
}) as DropdownMenuOptionsDataType<T>[]
|
|
85
|
-
}
|