aplance-ui 1.0.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/LICENSE +21 -0
- package/README.md +29 -0
- package/dist/api.d.ts +175 -0
- package/dist/api.js +1954 -0
- package/dist/api.js.map +1 -0
- package/dist/frameworks/astro/astro.config.snippet.md +23 -0
- package/dist/frameworks/astro/postcss.config.mjs.template +20 -0
- package/dist/frameworks/astro/vite-inline.snippet.md +22 -0
- package/dist/frameworks/electron-vite/vite.config.snippet.md +44 -0
- package/dist/frameworks/next/layout-import.snippet.md +19 -0
- package/dist/frameworks/next/next.config.snippet.md +15 -0
- package/dist/frameworks/next/postcss.config.js.template +16 -0
- package/dist/frameworks/tanstack-start/postcss.config.ts.template +17 -0
- package/dist/frameworks/tanstack-start/vite-inline.snippet.md +22 -0
- package/dist/frameworks/vite-react/postcss.config.ts.template +16 -0
- package/dist/frameworks/vite-react/vite-inline.snippet.md +20 -0
- package/dist/frameworks/vite-react/vite.config.ts.template +48 -0
- package/dist/index.js +2047 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -0
- package/registry/components/primitives/icon/icon.module.css +63 -0
- package/registry/components/primitives/icon/icon.tsx +53 -0
- package/registry/components/primitives/modal/modal-context.ts +19 -0
- package/registry/components/primitives/modal/modal.module.css +415 -0
- package/registry/components/primitives/modal/modal.tsx +550 -0
- package/registry/components/primitives/popover/popover-context.ts +28 -0
- package/registry/components/primitives/popover/popover.module.css +28 -0
- package/registry/components/primitives/popover/popover.tsx +465 -0
- package/registry/components/ui/accordion/accordion.module.css +208 -0
- package/registry/components/ui/accordion/accordion.tsx +327 -0
- package/registry/components/ui/avatar/avatar.module.css +32 -0
- package/registry/components/ui/avatar/avatar.tsx +37 -0
- package/registry/components/ui/badge/badge.module.css +103 -0
- package/registry/components/ui/badge/badge.tsx +29 -0
- package/registry/components/ui/button/button.module.css +216 -0
- package/registry/components/ui/button/button.tsx +133 -0
- package/registry/components/ui/chart/chart.module.css +168 -0
- package/registry/components/ui/chart/chart.tsx +1293 -0
- package/registry/components/ui/chart/types.ts +210 -0
- package/registry/components/ui/chart/utils.ts +59 -0
- package/registry/components/ui/copy-button/copy-button.module.css +21 -0
- package/registry/components/ui/copy-button/copy-button.tsx +123 -0
- package/registry/components/ui/countdown/countdown.module.css +5 -0
- package/registry/components/ui/countdown/countdown.tsx +152 -0
- package/registry/components/ui/data-table/checkbox-column.tsx +59 -0
- package/registry/components/ui/data-table/data-table.module.css +594 -0
- package/registry/components/ui/data-table/data-table.tsx +1109 -0
- package/registry/components/ui/data-table/filter-bar.tsx +33 -0
- package/registry/components/ui/data-table/pagination-bar.tsx +125 -0
- package/registry/components/ui/data-table/types.ts +594 -0
- package/registry/components/ui/data-table/useDataTable.tsx +573 -0
- package/registry/components/ui/data-table/utils.ts +445 -0
- package/registry/components/ui/empty-state/empty-state.module.css +26 -0
- package/registry/components/ui/empty-state/empty-state.tsx +32 -0
- package/registry/components/ui/input-fields/color-picker/color-palette.module.css +102 -0
- package/registry/components/ui/input-fields/color-picker/color-palette.tsx +92 -0
- package/registry/components/ui/input-fields/color-picker/color-picker.module.css +29 -0
- package/registry/components/ui/input-fields/color-picker/color-picker.tsx +168 -0
- package/registry/components/ui/input-fields/common/field-message/field-message.module.css +28 -0
- package/registry/components/ui/input-fields/common/field-message/field-message.tsx +39 -0
- package/registry/components/ui/input-fields/common/input-field-common.module.css +318 -0
- package/registry/components/ui/input-fields/common/input-field-native.module.css +267 -0
- package/registry/components/ui/input-fields/common/picker-popover-common.module.css +40 -0
- package/registry/components/ui/input-fields/common/select-button/select-button.module.css +9 -0
- package/registry/components/ui/input-fields/common/select-button/select-button.tsx +171 -0
- package/registry/components/ui/input-fields/common/types.ts +38 -0
- package/registry/components/ui/input-fields/custom-select/custom-select.module.css +56 -0
- package/registry/components/ui/input-fields/custom-select/custom-select.tsx +403 -0
- package/registry/components/ui/input-fields/date-picker/calendar.module.css +311 -0
- package/registry/components/ui/input-fields/date-picker/calendar.tsx +186 -0
- package/registry/components/ui/input-fields/date-picker/date-picker.module.css +57 -0
- package/registry/components/ui/input-fields/date-picker/date-picker.tsx +945 -0
- package/registry/components/ui/input-fields/date-picker/types.ts +102 -0
- package/registry/components/ui/input-fields/date-picker/utils.ts +236 -0
- package/registry/components/ui/input-fields/emoji-picker/emoji-palette.module.css +90 -0
- package/registry/components/ui/input-fields/emoji-picker/emoji-palette.tsx +168 -0
- package/registry/components/ui/input-fields/emoji-picker/emoji-picker.module.css +8 -0
- package/registry/components/ui/input-fields/emoji-picker/emoji-picker.tsx +102 -0
- package/registry/components/ui/input-fields/emoji-picker/utils.ts +505 -0
- package/registry/components/ui/input-fields/field-group/field-group.module.css +86 -0
- package/registry/components/ui/input-fields/field-group/field-group.tsx +86 -0
- package/registry/components/ui/input-fields/input/input.tsx +319 -0
- package/registry/components/ui/input-fields/media-input/kind-icons.tsx +62 -0
- package/registry/components/ui/input-fields/media-input/media-input.module.css +294 -0
- package/registry/components/ui/input-fields/media-input/media-input.tsx +327 -0
- package/registry/components/ui/input-fields/media-input/media-preview.tsx +101 -0
- package/registry/components/ui/input-fields/media-input/types.ts +129 -0
- package/registry/components/ui/input-fields/media-input/useMediaUpload.tsx +302 -0
- package/registry/components/ui/input-fields/media-input/utils.ts +325 -0
- package/registry/components/ui/input-fields/otp-input/otp-input.module.css +24 -0
- package/registry/components/ui/input-fields/otp-input/otp-input.tsx +291 -0
- package/registry/components/ui/input-fields/select/select.tsx +118 -0
- package/registry/components/ui/input-fields/switch/switch.module.css +70 -0
- package/registry/components/ui/input-fields/switch/switch.tsx +59 -0
- package/registry/components/ui/input-fields/textarea/textarea.tsx +133 -0
- package/registry/components/ui/input-fields/time-picker/time-picker.module.css +57 -0
- package/registry/components/ui/input-fields/time-picker/time-picker.tsx +437 -0
- package/registry/components/ui/loader/loader.module.css +156 -0
- package/registry/components/ui/loader/loader.tsx +102 -0
- package/registry/components/ui/stepper/stepper.module.css +294 -0
- package/registry/components/ui/stepper/stepper.tsx +197 -0
- package/registry/components/ui/tabs/tabs.module.css +150 -0
- package/registry/components/ui/tabs/tabs.tsx +134 -0
- package/registry/components/ui/toast/toast.module.css +159 -0
- package/registry/components/ui/toast/toast.tsx +104 -0
- package/registry/components/ui/tooltip/tooltip.module.css +82 -0
- package/registry/components/ui/tooltip/tooltip.tsx +72 -0
- package/registry/global.d.ts +4 -0
- package/registry/hooks/useFocusOutside.tsx +33 -0
- package/registry/hooks/useResizeObserver.tsx +32 -0
- package/registry/lib/dom.ts +25 -0
- package/registry/lib/string.ts +23 -0
- package/registry/registry.json +719 -0
- package/registry/styles/app.css +240 -0
- package/registry/styles/components.css +78 -0
- package/registry/styles/fonts/geist-regular.woff2 +0 -0
- package/registry/styles/globals.css +7 -0
- package/registry/styles/media.css +25 -0
- package/registry/styles/utilities.css +90 -0
- package/registry/themes/colors/blue.css +37 -0
- package/registry/themes/colors/green.css +37 -0
- package/registry/themes/colors/rose.css +37 -0
- package/registry/themes/colors/slate.css +37 -0
- package/registry/themes/colors/stone.css +37 -0
- package/registry/themes/colors/violet.css +37 -0
- package/registry/themes/colors/zinc.css +37 -0
- package/registry/themes/radius/pill.css +8 -0
- package/registry/themes/radius/rounded.css +8 -0
- package/registry/themes/radius/sharp.css +8 -0
- package/registry/themes/spacing/compact.css +17 -0
- package/registry/themes/spacing/spacious.css +17 -0
- package/registry/tsconfig.json +25 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Fragment } from 'react'
|
|
2
|
+
import type { FilterBarProps } from './types'
|
|
3
|
+
import s from './data-table.module.css'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Headless single-row filter bar.
|
|
7
|
+
* Each field owns its rendering via a render-prop and sets its own grid
|
|
8
|
+
* column width. The bar never wraps - consumers pick widths that fit.
|
|
9
|
+
*
|
|
10
|
+
* Width defaults: input fields → `1fr`, actions → `auto`.
|
|
11
|
+
*/
|
|
12
|
+
export const FilterBar = ({ fields, values, onChange }: FilterBarProps) => {
|
|
13
|
+
const gridCols = fields
|
|
14
|
+
.map((f) => f.width ?? (f.type === 'action' ? 'auto' : '1fr'))
|
|
15
|
+
.join(' ')
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div className={s.filter_bar} style={{ gridTemplateColumns: gridCols }}>
|
|
19
|
+
{fields.map((field, i) => (
|
|
20
|
+
<Fragment
|
|
21
|
+
key={field.type === 'action' ? `act:${i}` : `k:${field.key}`}
|
|
22
|
+
>
|
|
23
|
+
{field.type === 'action'
|
|
24
|
+
? field.render()
|
|
25
|
+
: field.render({
|
|
26
|
+
value: values[field.key] ?? '',
|
|
27
|
+
onChange: (v) => onChange(field.key, v),
|
|
28
|
+
})}
|
|
29
|
+
</Fragment>
|
|
30
|
+
))}
|
|
31
|
+
</div>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Button } from '../button/button'
|
|
2
|
+
import { CustomSelect } from '../input-fields/custom-select/custom-select'
|
|
3
|
+
import type { PaginationBarProps } from './types'
|
|
4
|
+
import s from './data-table.module.css'
|
|
5
|
+
import {
|
|
6
|
+
IconChevronLeft,
|
|
7
|
+
IconChevronRight,
|
|
8
|
+
IconChevronsLeft,
|
|
9
|
+
IconChevronsRight,
|
|
10
|
+
} from '@tabler/icons-react'
|
|
11
|
+
|
|
12
|
+
export const PaginationBar = <TData,>({
|
|
13
|
+
table,
|
|
14
|
+
pagination,
|
|
15
|
+
onPaginationChange,
|
|
16
|
+
pageSizeOptions,
|
|
17
|
+
showPageSizeSelect,
|
|
18
|
+
totalCount,
|
|
19
|
+
rowLabel,
|
|
20
|
+
rowsSelectable,
|
|
21
|
+
selectedCount,
|
|
22
|
+
extra,
|
|
23
|
+
}: PaginationBarProps<TData>) => {
|
|
24
|
+
const pageCount = table.getPageCount()
|
|
25
|
+
const total = totalCount ?? table.getRowCount()
|
|
26
|
+
const canPrev = table.getCanPreviousPage()
|
|
27
|
+
const canNext = table.getCanNextPage()
|
|
28
|
+
|
|
29
|
+
const goTo = (i: number) =>
|
|
30
|
+
onPaginationChange({ ...pagination, pageIndex: i })
|
|
31
|
+
const setSize = (size: number) =>
|
|
32
|
+
onPaginationChange({ pageIndex: 0, pageSize: size })
|
|
33
|
+
|
|
34
|
+
// Always show all page size options - current pageSize is guaranteed in the list.
|
|
35
|
+
const sizeOptions = Array.from(
|
|
36
|
+
new Set([...pageSizeOptions, pagination.pageSize]),
|
|
37
|
+
)
|
|
38
|
+
.sort((a, b) => a - b)
|
|
39
|
+
.map((n) => ({ value: String(n), label: String(n) }))
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div className={s.pagination_bar}>
|
|
43
|
+
{/* left - count + optional bulk-action extra slot */}
|
|
44
|
+
<div className={s.pagination_left}>
|
|
45
|
+
<p className={s.pagination_count}>
|
|
46
|
+
{rowsSelectable && selectedCount > 0 ? (
|
|
47
|
+
<>
|
|
48
|
+
<span>{selectedCount}</span> of <span>{total}</span> {rowLabel}(s)
|
|
49
|
+
selected
|
|
50
|
+
</>
|
|
51
|
+
) : (
|
|
52
|
+
<>
|
|
53
|
+
<span>{total}</span> {rowLabel}(s)
|
|
54
|
+
</>
|
|
55
|
+
)}
|
|
56
|
+
</p>
|
|
57
|
+
{extra}
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
{/* right - rows-per-page + page x of y + nav buttons */}
|
|
61
|
+
{pageCount > 0 && (
|
|
62
|
+
<div className={s.pagination_controls}>
|
|
63
|
+
{showPageSizeSelect && (
|
|
64
|
+
<div className={s.page_size_wrap}>
|
|
65
|
+
<span className={s.page_size_label}>{rowLabel}s per page</span>
|
|
66
|
+
<CustomSelect
|
|
67
|
+
options={sizeOptions}
|
|
68
|
+
value={String(pagination.pageSize)}
|
|
69
|
+
popover={{position: "top"}}
|
|
70
|
+
onChange={(val) =>
|
|
71
|
+
setSize(Number(Array.isArray(val) ? val[0] : val))
|
|
72
|
+
}
|
|
73
|
+
selectButton={{ showChevron: true, showClear: false }}
|
|
74
|
+
/>
|
|
75
|
+
</div>
|
|
76
|
+
)}
|
|
77
|
+
|
|
78
|
+
<p className={s.page_indicator}>
|
|
79
|
+
Page <span>{pagination.pageIndex + 1}</span> of{' '}
|
|
80
|
+
<span>{pageCount}</span>
|
|
81
|
+
</p>
|
|
82
|
+
|
|
83
|
+
<div className={s.page_nav}>
|
|
84
|
+
<Button
|
|
85
|
+
variant="bordered"
|
|
86
|
+
layout="box"
|
|
87
|
+
onClick={() => goTo(0)}
|
|
88
|
+
disabled={!canPrev}
|
|
89
|
+
aria-label="First page"
|
|
90
|
+
>
|
|
91
|
+
<IconChevronsLeft size={14} stroke={2} />
|
|
92
|
+
</Button>
|
|
93
|
+
<Button
|
|
94
|
+
variant="bordered"
|
|
95
|
+
layout="box"
|
|
96
|
+
onClick={() => goTo(pagination.pageIndex - 1)}
|
|
97
|
+
disabled={!canPrev}
|
|
98
|
+
aria-label="Previous page"
|
|
99
|
+
>
|
|
100
|
+
<IconChevronLeft size={14} stroke={2} />
|
|
101
|
+
</Button>
|
|
102
|
+
<Button
|
|
103
|
+
variant="bordered"
|
|
104
|
+
layout="box"
|
|
105
|
+
onClick={() => goTo(pagination.pageIndex + 1)}
|
|
106
|
+
disabled={!canNext}
|
|
107
|
+
aria-label="Next page"
|
|
108
|
+
>
|
|
109
|
+
<IconChevronRight size={14} stroke={2} />
|
|
110
|
+
</Button>
|
|
111
|
+
<Button
|
|
112
|
+
variant="bordered"
|
|
113
|
+
layout="box"
|
|
114
|
+
onClick={() => goTo(pageCount - 1)}
|
|
115
|
+
disabled={!canNext}
|
|
116
|
+
aria-label="Last page"
|
|
117
|
+
>
|
|
118
|
+
<IconChevronsRight size={14} stroke={2} />
|
|
119
|
+
</Button>
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
)}
|
|
123
|
+
</div>
|
|
124
|
+
)
|
|
125
|
+
}
|