@tempots/beatui 0.94.0 → 1.0.0
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/ar-CuI1Jgt6.cjs +1 -0
- package/dist/{ar-8Cko5i-Z.js → ar-DaKbK_t8.js} +88 -11
- package/dist/auth/index.cjs.js +1 -1
- package/dist/auth/index.es.js +1 -1
- package/dist/{auth-divider-Rt0WDKAe.js → auth-divider-BQIhr3-R.js} +99 -98
- package/dist/auth-divider-DvnUModP.cjs +1 -0
- package/dist/beatui.css +1628 -541
- package/dist/beatui.tailwind.css +1629 -542
- package/dist/better-auth/index.cjs.js +1 -1
- package/dist/better-auth/index.es.js +9 -9
- package/dist/codehighlight/index.cjs.js +22 -0
- package/dist/codehighlight/index.es.js +76 -0
- package/dist/colors-B-p6IzX9.cjs +1 -0
- package/dist/{colors-BY0Ja_bf.js → colors-DwufPN8S.js} +18 -18
- package/dist/{de-Bt-d2iKj.js → de-3MTPDS1i.js} +83 -6
- package/dist/de-DthHehbh.cjs +1 -0
- package/dist/{deep-merge-CoLO4id0.js → deep-merge-BzIheQtH.js} +511 -517
- package/dist/deep-merge-EkjEgK0N.cjs +1 -0
- package/dist/{duration-input-47x7nbGh.cjs → duration-input-ClgYjeBa.cjs} +1 -1
- package/dist/{duration-input-DrVonjKK.js → duration-input-DGzmIImj.js} +5 -5
- package/dist/{editor-toolbar-group-CzdBZ1yr.js → editor-toolbar-group-Crlu1QJw.js} +3 -3
- package/dist/{editor-toolbar-group-DhKJdqER.cjs → editor-toolbar-group-mkL4QozO.cjs} +1 -1
- package/dist/es-B6GJLk9h.cjs +1 -0
- package/dist/{es-2llfNFX2.js → es-DwMUvBeU.js} +95 -18
- package/dist/{fa-CQVIBjKP.js → fa-0rvQiKrJ.js} +88 -11
- package/dist/fa-BwgP93iV.cjs +1 -0
- package/dist/{fr-CC3smTlW.js → fr-B4i6NzLl.js} +87 -10
- package/dist/fr-CQzk5zqY.cjs +1 -0
- package/dist/{he-CZilsN75.js → he-C71n-hsn.js} +88 -11
- package/dist/he-DcxxvRfs.cjs +1 -0
- package/dist/hi-D-KHVWg4.cjs +1 -0
- package/dist/{hi-CAZjwGv-.js → hi-xmrXpeVU.js} +88 -11
- package/dist/index-B5MAsOC-.cjs +1 -0
- package/dist/{index-B8cqD9ny.js → index-C3o9GSH6.js} +106 -105
- package/dist/index.cjs.js +4 -4
- package/dist/index.es.js +8055 -5285
- package/dist/input-container-BvEcp7FU.js +275 -0
- package/dist/input-container-Di1YvVB_.cjs +1 -0
- package/dist/{it-D6RXFIL6.js → it-CDZTtOBC.js} +84 -7
- package/dist/it-D344Dutu.cjs +1 -0
- package/dist/ja-BNgnDZ27.cjs +1 -0
- package/dist/{ja-D7zsz4Ij.js → ja-Zz1LzidW.js} +92 -15
- package/dist/json-schema/index.cjs.js +1 -1
- package/dist/json-schema/index.es.js +261 -257
- package/dist/json-schema-display/index.cjs.js +1 -1
- package/dist/json-schema-display/index.es.js +2 -2
- package/dist/json-structure/index.cjs.js +1 -1
- package/dist/json-structure/index.es.js +132 -133
- package/dist/{ko-taN2Npr4.js → ko-9laUsZDL.js} +91 -14
- package/dist/ko-D-WJ9NK7.cjs +1 -0
- package/dist/lexical/index.cjs.js +2 -39
- package/dist/lexical/index.es.js +2102 -20521
- package/dist/markdown/index.cjs.js +1 -1
- package/dist/markdown/index.es.js +41 -4
- package/dist/{menu-CV85y3Xf.js → menu-B8yoDMRS.js} +23 -23
- package/dist/menu-B92oSDct.cjs +1 -0
- package/dist/modal-BT0jjDqX.cjs +1 -0
- package/dist/{modal-ZitwUeXx.js → modal-DBguyX-b.js} +9 -9
- package/dist/monaco/index.cjs.js +2 -2
- package/dist/monaco/index.es.js +7 -7
- package/dist/nl-CrqUlFie.cjs +1 -0
- package/dist/{nl-CRC6r4Q4.js → nl-Dcll9fVA.js} +87 -10
- package/dist/{notice-E_p2hg1G.js → notice-E19wu9lA.js} +51 -51
- package/dist/notice-_9XhdrFw.cjs +1 -0
- package/dist/oneof-branch-detection-J_DYEEcD.js +1077 -0
- package/dist/oneof-branch-detection-ZUBZ6hqy.cjs +1 -0
- package/dist/pl-9UksIrvX.cjs +1 -0
- package/dist/{pl-C6qNs0Lq.js → pl-Dm9N9Gbr.js} +84 -7
- package/dist/prosemirror/index.cjs.js +3 -1
- package/dist/prosemirror/index.es.js +636 -4
- package/dist/{pt-CcWPLqBh.js → pt-CFi5cn0k.js} +89 -12
- package/dist/pt-_kfdzwqi.cjs +1 -0
- package/dist/{ru-Dt9-9m0E.js → ru-CEhZUw8R.js} +92 -15
- package/dist/ru-CW1WNNlr.cjs +1 -0
- package/dist/stack-BLMteGTn.js +15 -0
- package/dist/stack-dwLevGa2.cjs +1 -0
- package/dist/tailwind/preset.cjs.js +1 -1
- package/dist/tailwind/preset.es.js +2 -2
- package/dist/tailwind/vite-plugin.cjs.js +1 -1
- package/dist/tailwind/vite-plugin.es.js +1 -1
- package/dist/text-input-DfqXolVe.js +55 -0
- package/dist/text-input-X_q01NsY.cjs +1 -0
- package/dist/toolbar-DY0ax2Qd.js +130 -0
- package/dist/toolbar-DoKdYXIL.cjs +1 -0
- package/dist/tr-B6GIRegf.cjs +1 -0
- package/dist/{tr-CDTWeRY0.js → tr-ZmnVDhLP.js} +83 -6
- package/dist/{translations-NBY7SubC.js → translations-A4kR7CW8.js} +1 -1
- package/dist/{translations-CiBhB2FV.js → translations-B1_yyDUK.js} +185 -106
- package/dist/{translations-BdCtLBZt.cjs → translations-C81buKAw.cjs} +1 -1
- package/dist/translations-Dbx7L7Q1.cjs +1 -0
- package/dist/types/beatui-i18n/default.d.ts +72 -0
- package/dist/types/beatui-i18n/locales/en.d.ts +72 -0
- package/dist/types/beatui-i18n/translations.d.ts +72 -0
- package/dist/types/codehighlight/code-highlight.d.ts +21 -0
- package/dist/types/codehighlight/index.d.ts +14 -0
- package/dist/types/components/button/toggle-button.d.ts +4 -4
- package/dist/types/components/data/avatar.d.ts +3 -1
- package/dist/types/components/data/badge.d.ts +10 -18
- package/dist/types/components/data/column-filter-panel.d.ts +31 -0
- package/dist/types/components/data/column-filter.d.ts +110 -0
- package/dist/types/components/data/column-header-menu.d.ts +42 -0
- package/dist/types/components/data/data-source.d.ts +190 -0
- package/dist/types/components/data/data-table-body.d.ts +12 -0
- package/dist/types/components/data/data-table-column-toggle.d.ts +4 -0
- package/dist/types/components/data/data-table-context.d.ts +53 -0
- package/dist/types/components/data/data-table-header.d.ts +6 -0
- package/dist/types/components/data/data-table-resolve.d.ts +26 -0
- package/dist/types/components/data/data-table-types.d.ts +201 -0
- package/dist/types/components/data/data-table.d.ts +38 -0
- package/dist/types/components/data/data-toolbar.d.ts +44 -0
- package/dist/types/components/data/date-picker-shared.d.ts +55 -0
- package/dist/types/components/data/date-picker.d.ts +58 -0
- package/dist/types/components/data/date-range-picker.d.ts +56 -0
- package/dist/types/components/data/filter.d.ts +268 -0
- package/dist/types/components/data/index.d.ts +13 -4
- package/dist/types/components/data/indicator.d.ts +41 -0
- package/dist/types/components/data/progress-bar.d.ts +2 -2
- package/dist/types/components/data/selection-checkbox.d.ts +63 -0
- package/dist/types/components/data/skeleton.d.ts +1 -1
- package/dist/types/components/data/sortable-header.d.ts +55 -0
- package/dist/types/components/data/unstyled-drop-zone.d.ts +2 -2
- package/dist/types/components/form/control/control.d.ts +9 -9
- package/dist/types/components/form/input/advanced-slider.d.ts +6 -6
- package/dist/types/components/form/input/appearance-selector.d.ts +9 -2
- package/dist/types/components/form/input/checkbox-input.d.ts +6 -7
- package/dist/types/components/form/input/color-input.d.ts +1 -1
- package/dist/types/components/form/input/color-swatch-input.d.ts +3 -3
- package/dist/types/components/form/input/combobox-input.d.ts +5 -5
- package/dist/types/components/form/input/combobox-tags-input.d.ts +5 -5
- package/dist/types/components/form/input/create-nullable-string-input.d.ts +2 -2
- package/dist/types/components/form/input/date-input.d.ts +4 -4
- package/dist/types/components/form/input/dropdown-input.d.ts +5 -5
- package/dist/types/components/form/input/editable-text.d.ts +2 -2
- package/dist/types/components/form/input/email-input.d.ts +4 -4
- package/dist/types/components/form/input/index.d.ts +1 -0
- package/dist/types/components/form/input/input-container.d.ts +1 -1
- package/dist/types/components/form/input/input-options.d.ts +28 -1
- package/dist/types/components/form/input/mask-input.d.ts +8 -2
- package/dist/types/components/form/input/native-select.d.ts +3 -3
- package/dist/types/components/form/input/nullable-date-input.d.ts +2 -2
- package/dist/types/components/form/input/nullable-email-input.d.ts +3 -3
- package/dist/types/components/form/input/nullable-rating-input.d.ts +8 -8
- package/dist/types/components/form/input/nullable-uuid-input.d.ts +4 -4
- package/dist/types/components/form/input/number-input.d.ts +3 -3
- package/dist/types/components/form/input/otp-input.d.ts +12 -12
- package/dist/types/components/form/input/rating-input.d.ts +7 -8
- package/dist/types/components/form/input/select-tags-input.d.ts +5 -5
- package/dist/types/components/form/input/switch.d.ts +2 -2
- package/dist/types/components/form/input/tri-state-checkbox-input.d.ts +82 -0
- package/dist/types/components/form/input/uuid-input.d.ts +2 -2
- package/dist/types/components/json-structure/controls/uuid-control.d.ts +1 -1
- package/dist/types/components/layout/card.d.ts +66 -0
- package/dist/types/components/layout/collapse.d.ts +2 -2
- package/dist/types/components/layout/flex.d.ts +26 -0
- package/dist/types/components/layout/index.d.ts +1 -0
- package/dist/types/components/lexical/floating/slash-command-palette.d.ts +2 -2
- package/dist/types/components/lexical/toolbar/toolbar-registry.d.ts +2 -1
- package/dist/types/components/media/pdf-page-viewer.d.ts +8 -5
- package/dist/types/components/misc/index.d.ts +1 -0
- package/dist/types/components/misc/loading-overlay.d.ts +29 -0
- package/dist/types/components/misc/notice.d.ts +4 -4
- package/dist/types/components/misc/notification-provider.d.ts +9 -3
- package/dist/types/components/misc/notification.d.ts +9 -9
- package/dist/types/components/navigation/breadcrumbs.d.ts +1 -1
- package/dist/types/components/navigation/menu.d.ts +6 -6
- package/dist/types/components/navigation/pagination.d.ts +17 -4
- package/dist/types/components/navigation/sidebar/sidebar-link.d.ts +2 -2
- package/dist/types/components/navigation/tabs/tabs.d.ts +17 -8
- package/dist/types/components/navigation/toolbar/toolbar.d.ts +12 -6
- package/dist/types/components/overlay/announcement-bar.d.ts +12 -4
- package/dist/types/components/overlay/dialogs.d.ts +2 -2
- package/dist/types/components/overlay/modal.d.ts +9 -2
- package/dist/types/components/overlay/tooltip.d.ts +6 -6
- package/dist/types/components/theme/types.d.ts +15 -4
- package/dist/types/lexical/index.d.ts +2 -2
- package/dist/types/lexical/plugins/index.d.ts +1 -1
- package/dist/types/lexical/plugins/slash-commands.d.ts +1 -1
- package/dist/types/lexical/plugins/text.d.ts +5 -0
- package/dist/types/lexical/types.d.ts +126 -5
- package/dist/types/lexical-i18n/default.d.ts +1 -0
- package/dist/types/lexical-i18n/locales/ar.d.ts +1 -0
- package/dist/types/lexical-i18n/locales/de.d.ts +1 -0
- package/dist/types/lexical-i18n/locales/en.d.ts +1 -0
- package/dist/types/lexical-i18n/locales/es.d.ts +1 -0
- package/dist/types/lexical-i18n/locales/fa.d.ts +1 -0
- package/dist/types/lexical-i18n/locales/fr.d.ts +1 -0
- package/dist/types/lexical-i18n/locales/he.d.ts +1 -0
- package/dist/types/lexical-i18n/locales/hi.d.ts +1 -0
- package/dist/types/lexical-i18n/locales/it.d.ts +1 -0
- package/dist/types/lexical-i18n/locales/ja.d.ts +1 -0
- package/dist/types/lexical-i18n/locales/ko.d.ts +1 -0
- package/dist/types/lexical-i18n/locales/nl.d.ts +1 -0
- package/dist/types/lexical-i18n/locales/pl.d.ts +1 -0
- package/dist/types/lexical-i18n/locales/pt.d.ts +1 -0
- package/dist/types/lexical-i18n/locales/ru.d.ts +1 -0
- package/dist/types/lexical-i18n/locales/tr.d.ts +1 -0
- package/dist/types/lexical-i18n/locales/ur.d.ts +1 -0
- package/dist/types/lexical-i18n/locales/vi.d.ts +1 -0
- package/dist/types/lexical-i18n/locales/zh.d.ts +1 -0
- package/dist/types/tokens/z-index.d.ts +18 -18
- package/dist/types/utils/use-animated-toggle.d.ts +12 -4
- package/dist/ur-CtFl_tz6.cjs +1 -0
- package/dist/{ur-CLrK5FPQ.js → ur-yYgj3NmT.js} +88 -11
- package/dist/use-animated-toggle-C3asw_Sg.js +207 -0
- package/dist/use-animated-toggle-cKcuItmz.cjs +1 -0
- package/dist/use-form-CaW192gw.cjs +2 -0
- package/dist/{use-form-BQRVnIp9.js → use-form-Dn6v2tEh.js} +153 -152
- package/dist/utils-DmEuG3Np.cjs +1 -0
- package/dist/utils-vUtP6iPG.js +165 -0
- package/dist/{vi-B1_QDUQJ.js → vi-D5u4CLQO.js} +89 -12
- package/dist/vi-DyCZSpsk.cjs +1 -0
- package/dist/widget-customization-DgW1SXN6.cjs +1 -0
- package/dist/{widget-customization-C-fSx3RB.js → widget-customization-Dkx7kNSe.js} +413 -398
- package/dist/{zh-rDtQ92Pp.js → zh-B0kwMMer.js} +91 -14
- package/dist/zh-C3ZxMQKb.cjs +1 -0
- package/package.json +209 -38
- package/dist/_commonjsHelpers-DKOUU3wS.cjs +0 -1
- package/dist/_commonjsHelpers-DaMA6jEr.js +0 -8
- package/dist/ar-D2DjoXta.cjs +0 -1
- package/dist/auth-divider-C3E16pml.cjs +0 -1
- package/dist/colors-BI0YhONJ.cjs +0 -1
- package/dist/de-Cdf3432J.cjs +0 -1
- package/dist/deep-merge-Blrucd-E.cjs +0 -1
- package/dist/es-6fFPkKHL.cjs +0 -1
- package/dist/fa-GXyNzAXz.cjs +0 -1
- package/dist/fr-C6EYTwSH.cjs +0 -1
- package/dist/he-CJUgxvi8.cjs +0 -1
- package/dist/hi-DqIR4VtX.cjs +0 -1
- package/dist/hls.light.min-C6xKDzRR.cjs +0 -27
- package/dist/hls.light.min-hEMf_E8u.js +0 -8311
- package/dist/index-1JaBwDB-.js +0 -921
- package/dist/index-B-cwxUsP.cjs +0 -1
- package/dist/index-BFzxpY7y.js +0 -68
- package/dist/index-BOC0cVoY.cjs +0 -36
- package/dist/index-CN10Cyqr.cjs +0 -1
- package/dist/index-CTcbhnPw.cjs +0 -4
- package/dist/index-DF7RFzD9.cjs +0 -1
- package/dist/index-DJ9YIJcG.js +0 -14308
- package/dist/index-DfPkCwdC.js +0 -2709
- package/dist/input-container-9r1F3KuX.js +0 -263
- package/dist/input-container-DiYEl_y8.cjs +0 -1
- package/dist/it-BvHsJ7fH.cjs +0 -1
- package/dist/ja-B2gP7OHY.cjs +0 -1
- package/dist/ko-BddhddIA.cjs +0 -1
- package/dist/menu-De_-sGeb.cjs +0 -1
- package/dist/modal-DUlqGUW7.cjs +0 -1
- package/dist/nl-COrtZUnH.cjs +0 -1
- package/dist/notice-DAVOTnfA.cjs +0 -1
- package/dist/oneof-branch-detection-D6Xa8qNR.cjs +0 -8
- package/dist/oneof-branch-detection-DCPwyutI.js +0 -6290
- package/dist/pl-BHI4zBgV.cjs +0 -1
- package/dist/pt-BGzC9MhU.cjs +0 -1
- package/dist/ru-CXeFbIPb.cjs +0 -1
- package/dist/stack-4VUGISn6.cjs +0 -1
- package/dist/stack-Bm-UZosx.js +0 -879
- package/dist/string-B9vVyfq3.cjs +0 -1
- package/dist/string-DYyMxBl-.js +0 -19
- package/dist/text-input-BgPx8BbG.js +0 -45
- package/dist/text-input-DUnhBUd6.cjs +0 -1
- package/dist/timer-BJHOsuS6.cjs +0 -1
- package/dist/timer-Rd2sKnvH.js +0 -65
- package/dist/toolbar-DKOh_gbA.js +0 -118
- package/dist/toolbar-Dkc2y1dI.cjs +0 -1
- package/dist/tr-CdOtQAtA.cjs +0 -1
- package/dist/translations-Cy9hoMGV.cjs +0 -1
- package/dist/types/components/data/calendar-shared.d.ts +0 -59
- package/dist/types/components/data/calendar.d.ts +0 -107
- package/dist/types/components/data/icon-badge.d.ts +0 -14
- package/dist/types/components/data/range-calendar.d.ts +0 -104
- package/dist/types/components/data/tag.d.ts +0 -51
- package/dist/ur-C7itXvnC.cjs +0 -1
- package/dist/use-animated-toggle-C7PTmnZi.js +0 -195
- package/dist/use-animated-toggle-DrqK7nUS.cjs +0 -1
- package/dist/use-form-DTyNw0kM.cjs +0 -2
- package/dist/utils-DEbsp9Q9.js +0 -129
- package/dist/utils-DIUEhA-Z.cjs +0 -1
- package/dist/vi-CQrUWB3y.cjs +0 -1
- package/dist/widget-customization-xEBfEPhQ.cjs +0 -1
- package/dist/zh-DWswYYTS.cjs +0 -1
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { Signal, Value } from '@tempots/dom';
|
|
2
|
+
import { FilterBase } from './filter';
|
|
3
|
+
/**
|
|
4
|
+
* Sort direction for a column.
|
|
5
|
+
*/
|
|
6
|
+
export type SortDirection = 'asc' | 'desc';
|
|
7
|
+
/**
|
|
8
|
+
* Describes how a column should be sorted.
|
|
9
|
+
*
|
|
10
|
+
* @typeParam C - Column identifier type. Defaults to `string`; narrow to a
|
|
11
|
+
* union of literal column IDs for compile-time safety.
|
|
12
|
+
*/
|
|
13
|
+
export interface SortDescriptor<C extends string = string> {
|
|
14
|
+
/** Column identifier */
|
|
15
|
+
column: C;
|
|
16
|
+
/** Sort direction */
|
|
17
|
+
direction: SortDirection;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* An action available when rows are selected.
|
|
21
|
+
*/
|
|
22
|
+
export interface BulkAction {
|
|
23
|
+
/** Display label */
|
|
24
|
+
label: string;
|
|
25
|
+
/** Optional icon identifier */
|
|
26
|
+
icon?: string;
|
|
27
|
+
/** Callback receiving the set of selected row IDs */
|
|
28
|
+
onClick: (selected: Set<string>) => void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Configuration options for {@link createDataSource}.
|
|
32
|
+
*
|
|
33
|
+
* @typeParam T - The type of data rows
|
|
34
|
+
* @typeParam C - Column identifier type (defaults to `string`)
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* A group of rows sharing the same group-by value.
|
|
38
|
+
*
|
|
39
|
+
* @typeParam T - The type of data rows
|
|
40
|
+
*/
|
|
41
|
+
export interface RowGroup<T> {
|
|
42
|
+
/** The stringified group key */
|
|
43
|
+
key: string;
|
|
44
|
+
/** Rows belonging to this group */
|
|
45
|
+
rows: T[];
|
|
46
|
+
}
|
|
47
|
+
export interface DataSourceOptions<T, C extends string = string> {
|
|
48
|
+
/** The source data array (static or reactive) */
|
|
49
|
+
data: Value<T[]>;
|
|
50
|
+
/** Returns a unique string ID for each row */
|
|
51
|
+
rowId: (row: T) => string;
|
|
52
|
+
/** Maps column IDs to accessor functions that extract the column value from a row */
|
|
53
|
+
accessors?: Partial<Record<C, (row: T) => unknown>>;
|
|
54
|
+
/** Maps column IDs to custom comparator functions for sorting */
|
|
55
|
+
comparators?: Partial<Record<C, (a: unknown, b: unknown) => number>>;
|
|
56
|
+
/** Initial sort state */
|
|
57
|
+
initialSort?: SortDescriptor<C>[];
|
|
58
|
+
/** Initial filter state */
|
|
59
|
+
initialFilters?: FilterBase<C>[];
|
|
60
|
+
/** Page size (undefined = no pagination) */
|
|
61
|
+
pageSize?: Value<number>;
|
|
62
|
+
/** Allow sorting on multiple columns simultaneously. @default false */
|
|
63
|
+
multiSort?: Value<boolean>;
|
|
64
|
+
/** When true, skips client-side sort/filter/paginate (caller drives rows externally). @default false */
|
|
65
|
+
serverSide?: Value<boolean>;
|
|
66
|
+
/** Column to group rows by. `undefined` disables grouping. */
|
|
67
|
+
groupBy?: Value<C | undefined>;
|
|
68
|
+
/** Called whenever sort state changes */
|
|
69
|
+
onSortChange?: (sort: SortDescriptor<C>[]) => void;
|
|
70
|
+
/** Called whenever filter state changes */
|
|
71
|
+
onFilterChange?: (filters: FilterBase<C>[]) => void;
|
|
72
|
+
/** Called whenever the current page changes */
|
|
73
|
+
onPageChange?: (page: number) => void;
|
|
74
|
+
/** Called whenever selection changes */
|
|
75
|
+
onSelectionChange?: (selected: Set<string>) => void;
|
|
76
|
+
/** Called whenever the group-by column changes */
|
|
77
|
+
onGroupByChange?: (column: C | undefined) => void;
|
|
78
|
+
/** Evaluate a custom (non-builtin) filter kind. Return `true` to include the row. */
|
|
79
|
+
evaluateFilter?: (filter: FilterBase<C>, row: T) => boolean;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A headless reactive data source managing sort, filter, selection, and pagination state.
|
|
83
|
+
*
|
|
84
|
+
* @typeParam T - The type of data rows
|
|
85
|
+
* @typeParam C - Column identifier type (defaults to `string`)
|
|
86
|
+
*/
|
|
87
|
+
export interface DataSource<T, C extends string = string> {
|
|
88
|
+
/** Final visible rows (sorted, filtered, paginated) */
|
|
89
|
+
rows: Signal<T[]>;
|
|
90
|
+
/** Total number of rows in source data */
|
|
91
|
+
totalRows: Signal<number>;
|
|
92
|
+
/** Number of rows after filtering (before pagination) */
|
|
93
|
+
totalFilteredRows: Signal<number>;
|
|
94
|
+
/** Current sort descriptors */
|
|
95
|
+
sort: Signal<SortDescriptor<C>[]>;
|
|
96
|
+
/** Toggle sort on a column: none → asc → desc → none. Pass `{ multi: true }` to add/modify without replacing other sorts. */
|
|
97
|
+
toggleSort: (column: C, opts?: {
|
|
98
|
+
multi?: boolean;
|
|
99
|
+
}) => void;
|
|
100
|
+
/** Replace the full sort state */
|
|
101
|
+
setSort: (sort: SortDescriptor<C>[]) => void;
|
|
102
|
+
/** Reactive sort direction for a specific column */
|
|
103
|
+
getSortDirection: (column: C) => Signal<SortDirection | undefined>;
|
|
104
|
+
/** Clear all sorts */
|
|
105
|
+
resetSort: () => void;
|
|
106
|
+
/** Current filter descriptors */
|
|
107
|
+
filters: Signal<FilterBase<C>[]>;
|
|
108
|
+
/** Set or replace all filters on a column */
|
|
109
|
+
setFilter: (filter: FilterBase<C>) => void;
|
|
110
|
+
/** Add a filter alongside existing ones on the same column */
|
|
111
|
+
addFilter: (filter: FilterBase<C>) => void;
|
|
112
|
+
/** Remove all filters from a column */
|
|
113
|
+
removeFilter: (column: C) => void;
|
|
114
|
+
/** Reactive list of filters for a specific column */
|
|
115
|
+
getColumnFilters: (column: C) => Signal<FilterBase<C>[]>;
|
|
116
|
+
/** Reactive text filter value for a specific column (value from first TextFilter, or '') */
|
|
117
|
+
getTextFilterValue: (column: C) => Signal<string>;
|
|
118
|
+
/** Clear all filters */
|
|
119
|
+
resetFilters: () => void;
|
|
120
|
+
/** Set of selected row IDs */
|
|
121
|
+
selected: Signal<Set<string>>;
|
|
122
|
+
/** Toggle selection of a row */
|
|
123
|
+
toggleSelect: (id: string) => void;
|
|
124
|
+
/** Add rows to selection */
|
|
125
|
+
select: (ids: string[]) => void;
|
|
126
|
+
/** Remove rows from selection */
|
|
127
|
+
deselect: (ids: string[]) => void;
|
|
128
|
+
/** Select all currently visible (filtered) rows */
|
|
129
|
+
selectAll: () => void;
|
|
130
|
+
/** Clear selection */
|
|
131
|
+
deselectAll: () => void;
|
|
132
|
+
/** Whether all filtered rows are selected */
|
|
133
|
+
isAllSelected: Signal<boolean>;
|
|
134
|
+
/** Whether some (but not all) filtered rows are selected */
|
|
135
|
+
isSomeSelected: Signal<boolean>;
|
|
136
|
+
/** Count of selected rows */
|
|
137
|
+
selectedCount: Signal<number>;
|
|
138
|
+
/** Current page (1-indexed) */
|
|
139
|
+
currentPage: Signal<number>;
|
|
140
|
+
/** Total number of pages */
|
|
141
|
+
totalPages: Signal<number>;
|
|
142
|
+
/** Current page size */
|
|
143
|
+
pageSize: Signal<number>;
|
|
144
|
+
/** Navigate to a page */
|
|
145
|
+
setPage: (page: number) => void;
|
|
146
|
+
/** Change page size (resets to page 1) */
|
|
147
|
+
setPageSize: (size: number) => void;
|
|
148
|
+
/** Current group-by column (undefined = no grouping) */
|
|
149
|
+
groupBy: Signal<C | undefined>;
|
|
150
|
+
/** Set or clear group-by column */
|
|
151
|
+
setGroupBy: (column: C | undefined) => void;
|
|
152
|
+
/** Grouped rows (empty array when groupBy is undefined) */
|
|
153
|
+
groups: Signal<RowGroup<T>[]>;
|
|
154
|
+
/** All rows after sort and filter, before pagination */
|
|
155
|
+
allFilteredRows: Signal<T[]>;
|
|
156
|
+
/** Swap two rows by ID (only effective when no sort active) */
|
|
157
|
+
moveRow: (fromId: string, toId: string) => void;
|
|
158
|
+
/** Reset sort, filters, selection, page, and groupBy */
|
|
159
|
+
resetAll: () => void;
|
|
160
|
+
/** Clean up all reactive subscriptions */
|
|
161
|
+
dispose: () => void;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Creates a headless reactive data source for managing tabular data operations.
|
|
165
|
+
*
|
|
166
|
+
* Provides sorting, filtering, selection, pagination, and manual reorder as
|
|
167
|
+
* reactive signals and imperative methods. All processing happens client-side
|
|
168
|
+
* unless `serverSide` is true.
|
|
169
|
+
*
|
|
170
|
+
* @typeParam T - The type of data rows
|
|
171
|
+
* @param options - Configuration for the data source
|
|
172
|
+
* @returns A {@link DataSource} object with reactive state and methods
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* const ds = createDataSource({
|
|
177
|
+
* data: prop([
|
|
178
|
+
* { id: '1', name: 'Alice', age: 30 },
|
|
179
|
+
* { id: '2', name: 'Bob', age: 25 },
|
|
180
|
+
* ]),
|
|
181
|
+
* rowId: row => row.id,
|
|
182
|
+
* })
|
|
183
|
+
*
|
|
184
|
+
* ds.toggleSort('name') // sort by name ascending
|
|
185
|
+
* ds.setFilter(Filter.contains('name', 'ali')) // filter name containing "ali"
|
|
186
|
+
* ds.rows.value // [{ id: '1', name: 'Alice', age: 30 }]
|
|
187
|
+
* ds.dispose()
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
export declare function createDataSource<T, C extends string = string>(options: DataSourceOptions<T, C>): DataSource<T, C>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TNode } from '@tempots/dom';
|
|
2
|
+
import { DataTableContext } from './data-table-context';
|
|
3
|
+
/** Render non-grouped data rows. */
|
|
4
|
+
export declare function renderBody<T, C extends string>(ctx: DataTableContext<T, C>): TNode;
|
|
5
|
+
/** Render grouped body with collapse, footers, and group headers. */
|
|
6
|
+
export declare function renderGroupedBody<T, C extends string>(ctx: DataTableContext<T, C>): TNode;
|
|
7
|
+
/** Render the "no results" empty state. */
|
|
8
|
+
export declare function renderEmpty<T, C extends string>(ctx: DataTableContext<T, C>): TNode;
|
|
9
|
+
/** Render the loading overlay. */
|
|
10
|
+
export declare function renderLoading<T, C extends string>(ctx: DataTableContext<T, C>): TNode;
|
|
11
|
+
/** Render the footer row with column aggregations. */
|
|
12
|
+
export declare function renderFooter<T, C extends string>(ctx: DataTableContext<T, C>): TNode;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Prop, Signal, TNode, Value } from '@tempots/dom';
|
|
2
|
+
import { ControlSize } from '../theme';
|
|
3
|
+
import { DataSource, RowGroup } from './data-source';
|
|
4
|
+
import { DataColumnDef, DataTableOptions, DataTablePaginationOptions, DataTableToolbarOptions } from './data-table-types';
|
|
5
|
+
export interface DataTableContext<T, C extends string = string> {
|
|
6
|
+
ds: DataSource<T, C>;
|
|
7
|
+
columns: DataColumnDef<T, C>[];
|
|
8
|
+
columnMap: Map<C, DataColumnDef<T, C>>;
|
|
9
|
+
getCol: (id: C) => DataColumnDef<T, C>;
|
|
10
|
+
rowId: (row: T) => string;
|
|
11
|
+
visibleColumns: Signal<C[]>;
|
|
12
|
+
hiddenColumns: Signal<C[]>;
|
|
13
|
+
hideableColumns: DataColumnDef<T, C>[];
|
|
14
|
+
hasColumnVisibility: Value<boolean>;
|
|
15
|
+
toggleColumnVisibility: (colId: C) => void;
|
|
16
|
+
showAllColumns: () => void;
|
|
17
|
+
columnOrder: Prop<C[]>;
|
|
18
|
+
reorderableColumns: Value<boolean>;
|
|
19
|
+
onColumnOrderChange?: (columnIds: C[]) => void;
|
|
20
|
+
dragState: {
|
|
21
|
+
columnId: C | null;
|
|
22
|
+
};
|
|
23
|
+
selectable: Value<boolean>;
|
|
24
|
+
selectableSignal: Signal<boolean>;
|
|
25
|
+
selectOnRowClickSignal: Signal<boolean>;
|
|
26
|
+
selectionAfter: boolean;
|
|
27
|
+
sortable: Value<boolean>;
|
|
28
|
+
size: Value<ControlSize>;
|
|
29
|
+
onRowClick?: (row: T) => void;
|
|
30
|
+
filterLayout: 'header' | 'row';
|
|
31
|
+
hasFilters: boolean;
|
|
32
|
+
loading: Value<boolean>;
|
|
33
|
+
showFooter: Value<boolean>;
|
|
34
|
+
emptyContent?: TNode;
|
|
35
|
+
groupCollapsible: boolean;
|
|
36
|
+
groupSummary?: (groupKey: string, rows: T[]) => TNode;
|
|
37
|
+
hasFooter: boolean;
|
|
38
|
+
rowClickable: Signal<boolean>;
|
|
39
|
+
effectiveHoverable: Signal<boolean>;
|
|
40
|
+
totalColSpan: Signal<number>;
|
|
41
|
+
collapsedGroups: Prop<Set<string>>;
|
|
42
|
+
currentGroupPageGroups: Signal<RowGroup<T>[]>;
|
|
43
|
+
toolbarConfig: Signal<DataTableToolbarOptions | false>;
|
|
44
|
+
paginationConfig: Value<DataTablePaginationOptions | false>;
|
|
45
|
+
paginationEnabledSignal: Signal<boolean>;
|
|
46
|
+
pageSizeSignal: Signal<number>;
|
|
47
|
+
effectiveTotalPages: Signal<number>;
|
|
48
|
+
effectiveCurrentPage: Signal<number>;
|
|
49
|
+
setEffectivePage: (page: number) => void;
|
|
50
|
+
showPagination: Signal<boolean>;
|
|
51
|
+
dispose: () => void;
|
|
52
|
+
}
|
|
53
|
+
export declare function createDataTableContext<T, C extends string = string>(options: DataTableOptions<T, C>): DataTableContext<T, C>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TNode } from '@tempots/dom';
|
|
2
|
+
import { DataTableContext } from './data-table-context';
|
|
3
|
+
/** Render the header row. */
|
|
4
|
+
export declare function renderHeaderRow<T, C extends string>(ctx: DataTableContext<T, C>): TNode;
|
|
5
|
+
/** Render the filter row (only when filterLayout is 'row'). */
|
|
6
|
+
export declare function renderFilterRow<T, C extends string>(ctx: DataTableContext<T, C>): TNode;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TNode, Value } from '@tempots/dom';
|
|
2
|
+
import { ControlSize } from '../theme';
|
|
3
|
+
import { DataSource } from './data-source';
|
|
4
|
+
import { ColumnFilterConfig, DataColumnDef, DataTablePaginationOptions, DataTableToolbarOptions } from './data-table-types';
|
|
5
|
+
import { RowGroup } from './data-source';
|
|
6
|
+
export declare function resolveToolbarOptions(toolbar: boolean | DataTableToolbarOptions): DataTableToolbarOptions | false;
|
|
7
|
+
/**
|
|
8
|
+
* Partition groups into pages, keeping whole groups together.
|
|
9
|
+
* A group only spans multiple pages if it alone exceeds pageSize.
|
|
10
|
+
* Collapsed groups count as 1 row (just the header) for page capacity.
|
|
11
|
+
*/
|
|
12
|
+
export declare function paginateGroups<T>(groups: RowGroup<T>[], pageSize: number, collapsed: Set<string>): RowGroup<T>[][];
|
|
13
|
+
export declare function resolvePaginationOptions(pagination: boolean | DataTablePaginationOptions): DataTablePaginationOptions | false;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve a static ColumnFilterConfig into filter UI content.
|
|
16
|
+
* Returns null when the config disables filtering.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveFilterContent<T, C extends string>(config: ColumnFilterConfig<T, C> | false | undefined, ds: DataSource<T, C>, colId: C, size: Value<ControlSize>): TNode;
|
|
19
|
+
/**
|
|
20
|
+
* Resolve a static ColumnFilterConfig into filter cell content (for 'row' layout).
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveFilterCell<T, C extends string>(config: ColumnFilterConfig<T, C> | false | undefined, ds: DataSource<T, C>, colId: C, size: Value<ControlSize>): TNode;
|
|
23
|
+
/** Resolve the current filter config for a column (static snapshot) */
|
|
24
|
+
export declare function getFilterConfig<T, C extends string>(col: DataColumnDef<T, C>): ColumnFilterConfig<T, C> | false | undefined;
|
|
25
|
+
/** Check if a column has any filter configured (non-reactive check for setup) */
|
|
26
|
+
export declare function colHasFilter<T, C extends string>(col: DataColumnDef<T, C>): boolean;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { Signal, TNode, Value } from '@tempots/dom';
|
|
2
|
+
import { ControlSize } from '../theme';
|
|
3
|
+
import { BulkAction, DataSource, SortDescriptor } from './data-source';
|
|
4
|
+
import { FilterBase } from './filter';
|
|
5
|
+
/** The value type of a column, used by the filter panel to determine available operators. */
|
|
6
|
+
export type ColumnValueType = 'text' | 'number';
|
|
7
|
+
/**
|
|
8
|
+
* Props passed to a custom filter render function.
|
|
9
|
+
*
|
|
10
|
+
* @typeParam T - The type of data rows
|
|
11
|
+
* @typeParam C - Column identifier type (defaults to `string`)
|
|
12
|
+
*/
|
|
13
|
+
export interface FilterRenderProps<T, C extends string = string> {
|
|
14
|
+
dataSource: DataSource<T, C>;
|
|
15
|
+
column: C;
|
|
16
|
+
size: Value<ControlSize>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Filter configuration for a column.
|
|
20
|
+
*
|
|
21
|
+
* - `boolean` — `true` enables a text filter
|
|
22
|
+
* - `'text'` — explicit text filter
|
|
23
|
+
* - `'number'` — shortcut for `{ type: 'panel', valueType: 'number' }`
|
|
24
|
+
* - `{ type: 'select', options }` — dropdown filter
|
|
25
|
+
* - `{ type: 'tags', options }` — multi-select tag filter
|
|
26
|
+
* - `{ type: 'panel', valueType? }` — advanced filter panel
|
|
27
|
+
* - `{ render }` — fully custom filter UI
|
|
28
|
+
*
|
|
29
|
+
* @typeParam T - The type of data rows
|
|
30
|
+
* @typeParam C - Column identifier type (defaults to `string`)
|
|
31
|
+
*/
|
|
32
|
+
export type ColumnFilterConfig<T, C extends string = string> = boolean | 'text' | 'number' | {
|
|
33
|
+
type: 'select';
|
|
34
|
+
options: {
|
|
35
|
+
value: string;
|
|
36
|
+
label: string;
|
|
37
|
+
}[];
|
|
38
|
+
} | {
|
|
39
|
+
type: 'tags';
|
|
40
|
+
options: {
|
|
41
|
+
value: string;
|
|
42
|
+
label: string;
|
|
43
|
+
}[];
|
|
44
|
+
} | {
|
|
45
|
+
type: 'panel';
|
|
46
|
+
valueType?: ColumnValueType;
|
|
47
|
+
} | {
|
|
48
|
+
render: (props: FilterRenderProps<T, C>) => TNode;
|
|
49
|
+
} | {
|
|
50
|
+
input: (value: Signal<string>, size: Value<ControlSize>) => TNode;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Column definition for a {@link DataTable}.
|
|
54
|
+
*
|
|
55
|
+
* @typeParam T - The type of data rows
|
|
56
|
+
* @typeParam C - Column identifier type (defaults to `string`)
|
|
57
|
+
*/
|
|
58
|
+
export interface DataColumnDef<T, C extends string = string> {
|
|
59
|
+
/** Unique column identifier. Used as key for value accessor, sort, and filter. */
|
|
60
|
+
id: C;
|
|
61
|
+
/** Column header content. String or render function. */
|
|
62
|
+
header: string | (() => TNode);
|
|
63
|
+
/** Render function for cell content. Receives a reactive row signal and the column index. */
|
|
64
|
+
cell: (row: Signal<T>, index: number) => TNode;
|
|
65
|
+
/**
|
|
66
|
+
* Accessor function to extract the column value from a row.
|
|
67
|
+
* If omitted, defaults to `row[id]`.
|
|
68
|
+
*/
|
|
69
|
+
value?: (row: T) => unknown;
|
|
70
|
+
/** Whether this column is sortable. @default false */
|
|
71
|
+
sortable?: Value<boolean>;
|
|
72
|
+
/** Custom comparator for sorting this column */
|
|
73
|
+
comparator?: (a: unknown, b: unknown) => number;
|
|
74
|
+
/** Filter configuration for this column. Reactive — can be toggled at runtime. */
|
|
75
|
+
filter?: Value<ColumnFilterConfig<T, C>>;
|
|
76
|
+
/** Footer render function. Receives all filtered rows as a reactive signal. */
|
|
77
|
+
footer?: (rows: Signal<T[]>) => TNode;
|
|
78
|
+
/** Column width (e.g., '200px', '20%') */
|
|
79
|
+
width?: Value<string>;
|
|
80
|
+
/** Minimum column width */
|
|
81
|
+
minWidth?: Value<string>;
|
|
82
|
+
/** Maximum column width */
|
|
83
|
+
maxWidth?: Value<string>;
|
|
84
|
+
/** Text alignment within cells. @default 'left' */
|
|
85
|
+
align?: Value<'left' | 'center' | 'right'>;
|
|
86
|
+
/** Whether this column can be hidden via the column visibility toggle. @default false */
|
|
87
|
+
hideable?: Value<boolean>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Pagination options for {@link DataTable}.
|
|
91
|
+
*/
|
|
92
|
+
export interface DataTablePaginationOptions {
|
|
93
|
+
/** Number of rows per page. @default 10 */
|
|
94
|
+
pageSize?: number;
|
|
95
|
+
/** Show first/last page buttons. @default false */
|
|
96
|
+
showFirstLast?: boolean;
|
|
97
|
+
/** Number of page siblings to show. @default 1 */
|
|
98
|
+
siblings?: number;
|
|
99
|
+
/** Enable responsive page number display. @default false */
|
|
100
|
+
responsive?: boolean;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Toolbar options for {@link DataTable}.
|
|
104
|
+
*/
|
|
105
|
+
export interface DataTableToolbarOptions {
|
|
106
|
+
/** Show active sort indicators in toolbar. @default true */
|
|
107
|
+
showSort?: boolean;
|
|
108
|
+
/** Show active filter chips in toolbar. @default true */
|
|
109
|
+
showFilters?: boolean;
|
|
110
|
+
/** Show selection count in toolbar. @default true */
|
|
111
|
+
showSelection?: boolean;
|
|
112
|
+
/** Bulk actions available when rows are selected */
|
|
113
|
+
bulkActions?: BulkAction[];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Configuration options for the {@link DataTable} component.
|
|
117
|
+
*
|
|
118
|
+
* @typeParam T - The type of data rows
|
|
119
|
+
* @typeParam C - Column identifier type (defaults to `string`)
|
|
120
|
+
*/
|
|
121
|
+
export interface DataTableOptions<T, C extends string = string> {
|
|
122
|
+
/** Source data array (static or reactive) */
|
|
123
|
+
data: Value<T[]>;
|
|
124
|
+
/** Column definitions */
|
|
125
|
+
columns: DataColumnDef<T, C>[];
|
|
126
|
+
/** Returns a unique string ID for each row */
|
|
127
|
+
rowId: (row: T) => string;
|
|
128
|
+
/** Enable sorting (columns opt-in via `column.sortable`). @default false */
|
|
129
|
+
sortable?: Value<boolean>;
|
|
130
|
+
/** Allow sorting by multiple columns. @default false */
|
|
131
|
+
multiSort?: Value<boolean>;
|
|
132
|
+
/** Enable filtering (columns opt-in via `column.filter`). @default false */
|
|
133
|
+
filterable?: Value<boolean>;
|
|
134
|
+
/**
|
|
135
|
+
* Where to render filter controls.
|
|
136
|
+
* - `'header'`: all filters render inline in the header row as icon triggers
|
|
137
|
+
* - `'row'`: all filters render in a dedicated row below the header
|
|
138
|
+
* @default 'header'
|
|
139
|
+
*/
|
|
140
|
+
filterLayout?: 'header' | 'row';
|
|
141
|
+
/** Show selection checkboxes. @default false */
|
|
142
|
+
selectable?: Value<boolean>;
|
|
143
|
+
/** Position of selection checkboxes. @default 'before' */
|
|
144
|
+
selectionPosition?: 'before' | 'after';
|
|
145
|
+
/** Toggle row selection when clicking anywhere on the row. @default false */
|
|
146
|
+
selectOnRowClick?: Value<boolean>;
|
|
147
|
+
/** Enable drag-to-reorder columns. @default false */
|
|
148
|
+
reorderableColumns?: Value<boolean>;
|
|
149
|
+
/** Called when column order changes via drag-and-drop */
|
|
150
|
+
onColumnOrderChange?: (columnIds: C[]) => void;
|
|
151
|
+
/** Pagination config. `true` uses defaults, `false`/undefined disables. */
|
|
152
|
+
pagination?: Value<DataTablePaginationOptions | boolean>;
|
|
153
|
+
/** Toolbar config. `true` uses defaults, `false`/undefined disables. */
|
|
154
|
+
toolbar?: Value<DataTableToolbarOptions | boolean>;
|
|
155
|
+
/** Size variant. @default 'md' */
|
|
156
|
+
size?: Value<ControlSize>;
|
|
157
|
+
/** Enable hover effect on rows. @default false */
|
|
158
|
+
hoverable?: Value<boolean>;
|
|
159
|
+
/** Make header sticky. @default false */
|
|
160
|
+
stickyHeader?: Value<boolean>;
|
|
161
|
+
/** Full width table. @default false */
|
|
162
|
+
fullWidth?: Value<boolean>;
|
|
163
|
+
/** Striped rows. @default false */
|
|
164
|
+
withStripedRows?: Value<boolean>;
|
|
165
|
+
/** Table border. @default true */
|
|
166
|
+
withTableBorder?: Value<boolean>;
|
|
167
|
+
/** Column borders. @default false */
|
|
168
|
+
withColumnBorders?: Value<boolean>;
|
|
169
|
+
/** Row borders. @default true */
|
|
170
|
+
withRowBorders?: Value<boolean>;
|
|
171
|
+
/** Called when sort state changes */
|
|
172
|
+
onSortChange?: (sort: SortDescriptor<C>[]) => void;
|
|
173
|
+
/** Called when filter state changes */
|
|
174
|
+
onFilterChange?: (filters: FilterBase<C>[]) => void;
|
|
175
|
+
/** Called when selection changes */
|
|
176
|
+
onSelectionChange?: (selected: Set<string>) => void;
|
|
177
|
+
/** Called when the group-by column changes */
|
|
178
|
+
onGroupByChange?: (column: C | undefined) => void;
|
|
179
|
+
/** Called when a row is clicked */
|
|
180
|
+
onRowClick?: (row: T) => void;
|
|
181
|
+
/** Skip client-side processing. @default false */
|
|
182
|
+
serverSide?: Value<boolean>;
|
|
183
|
+
/** Total rows for server-side pagination */
|
|
184
|
+
totalRows?: Value<number>;
|
|
185
|
+
/** Loading state */
|
|
186
|
+
loading?: Value<boolean>;
|
|
187
|
+
/** Column to group rows by. Renders collapsible group header rows. */
|
|
188
|
+
groupBy?: Value<C | undefined>;
|
|
189
|
+
/** Whether groups are collapsible. @default true */
|
|
190
|
+
groupCollapsible?: boolean;
|
|
191
|
+
/** Show footer row. Columns opt-in via `column.footer`. @default false */
|
|
192
|
+
showFooter?: Value<boolean>;
|
|
193
|
+
/** Custom render function for collapsed group summaries. */
|
|
194
|
+
groupSummary?: (groupKey: string, rows: T[]) => TNode;
|
|
195
|
+
/** Content to show when no rows match */
|
|
196
|
+
emptyContent?: TNode;
|
|
197
|
+
/** Column visibility options. When set, a column toggle button appears. */
|
|
198
|
+
hiddenColumns?: Value<C[]>;
|
|
199
|
+
/** Callback to receive the internal DataSource for external integration */
|
|
200
|
+
onDataSource?: (ds: DataSource<T, C>) => void;
|
|
201
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { DataTableOptions } from './data-table-types';
|
|
2
|
+
/**
|
|
3
|
+
* A full-featured data table component built by composing headless {@link DataSource}
|
|
4
|
+
* state management with composable UI primitives and the existing {@link Table}
|
|
5
|
+
* and {@link Pagination} components.
|
|
6
|
+
*
|
|
7
|
+
* Supports column-level sorting, filtering, row selection, pagination, bulk actions,
|
|
8
|
+
* and server-side mode. Each feature is opt-in and configurable per column.
|
|
9
|
+
*
|
|
10
|
+
* @typeParam T - The type of data rows
|
|
11
|
+
* @param options - Full configuration for the data table
|
|
12
|
+
* @returns A composed data table element
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* DataTable({
|
|
17
|
+
* data: prop(users),
|
|
18
|
+
* columns: [
|
|
19
|
+
* { id: 'name', header: 'Name', cell: row => Value.map(row, r => r.name),
|
|
20
|
+
* sortable: true, filter: true },
|
|
21
|
+
* { id: 'email', header: 'Email', cell: row => Value.map(row, r => r.email),
|
|
22
|
+
* sortable: true },
|
|
23
|
+
* { id: 'role', header: 'Role', cell: row => Value.map(row, r => r.role),
|
|
24
|
+
* filter: { type: 'select', options: [
|
|
25
|
+
* { value: 'admin', label: 'Admin' }, { value: 'user', label: 'User' }
|
|
26
|
+
* ] } },
|
|
27
|
+
* ],
|
|
28
|
+
* rowId: u => u.id,
|
|
29
|
+
* sortable: true,
|
|
30
|
+
* filterable: true,
|
|
31
|
+
* selectable: true,
|
|
32
|
+
* pagination: { pageSize: 20 },
|
|
33
|
+
* toolbar: { bulkActions: [{ label: 'Delete', onClick: sel => deleteUsers(sel) }] },
|
|
34
|
+
* fullWidth: true,
|
|
35
|
+
* })
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function DataTable<T, C extends string = string>(options: DataTableOptions<T, C>): import("@tempots/core").Renderable<import("@tempots/dom").DOMContext, typeof import("@tempots/dom").DOM_RENDERABLE_TYPE>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Value } from '@tempots/dom';
|
|
2
|
+
import { BulkAction, DataSource } from './data-source';
|
|
3
|
+
import { DescribeFilterOptions } from './filter';
|
|
4
|
+
/**
|
|
5
|
+
* Options for the {@link DataToolbar} component.
|
|
6
|
+
*
|
|
7
|
+
* @typeParam T - The type of data rows in the data source
|
|
8
|
+
* @typeParam C - Column identifier type (defaults to `string`)
|
|
9
|
+
*/
|
|
10
|
+
export interface DataToolbarOptions<T, C extends string = string> {
|
|
11
|
+
/** The data source to display state for */
|
|
12
|
+
dataSource: DataSource<T, C>;
|
|
13
|
+
/** Show active sort indicators. @default true */
|
|
14
|
+
showSort?: Value<boolean>;
|
|
15
|
+
/** Show active filter chips. @default true */
|
|
16
|
+
showFilters?: Value<boolean>;
|
|
17
|
+
/** Show selection count and bulk actions. @default true */
|
|
18
|
+
showSelection?: Value<boolean>;
|
|
19
|
+
/** Available bulk actions when rows are selected */
|
|
20
|
+
bulkActions?: BulkAction[];
|
|
21
|
+
/** Custom label for the reset button */
|
|
22
|
+
resetLabel?: Value<string>;
|
|
23
|
+
/** Optional callback to describe custom (non-builtin) filter kinds */
|
|
24
|
+
describeFilter?: DescribeFilterOptions<C>['describeFilter'];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A toolbar displaying the active state of a {@link DataSource}: active sort indicators,
|
|
28
|
+
* filter chips with remove buttons, selection count, bulk action buttons, and a "Reset all" control.
|
|
29
|
+
*
|
|
30
|
+
* @typeParam T - The type of data rows
|
|
31
|
+
* @param options - Toolbar configuration
|
|
32
|
+
* @returns A toolbar element
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* DataToolbar({
|
|
37
|
+
* dataSource: ds,
|
|
38
|
+
* bulkActions: [
|
|
39
|
+
* { label: 'Delete', icon: 'mdi:delete', onClick: (sel) => deleteRows(sel) },
|
|
40
|
+
* ],
|
|
41
|
+
* })
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function DataToolbar<T, C extends string = string>({ dataSource, showSort, showFilters, showSelection, bulkActions, resetLabel, describeFilter: describeFilterCb, }: DataToolbarOptions<T, C>): import("@tempots/core").Renderable<import("@tempots/dom").DOMContext, typeof import("@tempots/dom").DOM_RENDERABLE_TYPE>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Value, type Prop, type TNode } from '@tempots/dom';
|
|
2
|
+
import { ControlSize } from '../theme';
|
|
3
|
+
import { ThemeColorName } from '../../tokens';
|
|
4
|
+
import type { BeatUITemporal, PlainDate } from '../../temporal/types';
|
|
5
|
+
export declare const YEARS_PER_PAGE = 20;
|
|
6
|
+
export declare const DAYS_IN_WEEK = 7;
|
|
7
|
+
export declare const MONTH_NAMES: string[];
|
|
8
|
+
export declare const SHORT_MONTH_NAMES: string[];
|
|
9
|
+
export declare const DAY_NAMES: string[];
|
|
10
|
+
export type DatePickerView = 'days' | 'months' | 'years';
|
|
11
|
+
export declare function generateDatePickerClasses(size: ControlSize, disabled: boolean): string;
|
|
12
|
+
export declare function generateDatePickerStyles(color: ThemeColorName): string;
|
|
13
|
+
/** Base cell data computed by {@link buildDatePickerGrid}. */
|
|
14
|
+
export interface DatePickerBaseCell {
|
|
15
|
+
day: number;
|
|
16
|
+
date: PlainDate;
|
|
17
|
+
inMonth: boolean;
|
|
18
|
+
isToday: boolean;
|
|
19
|
+
isDisabled: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** Builds the base array of day cells for a given month. */
|
|
22
|
+
export declare function buildDatePickerGrid(T: BeatUITemporal, year: number, month: number, weekStartsOn: number, today: PlainDate, isDateDisabled?: (date: PlainDate) => boolean): DatePickerBaseCell[];
|
|
23
|
+
/** State and actions returned by {@link createDatePickerNav}. */
|
|
24
|
+
export interface DatePickerNav {
|
|
25
|
+
today: PlainDate;
|
|
26
|
+
currentYear: Prop<number>;
|
|
27
|
+
currentMonth: Prop<number>;
|
|
28
|
+
view: Prop<DatePickerView>;
|
|
29
|
+
yearPageStart: Prop<number>;
|
|
30
|
+
shiftedDayNames: Value<string[]>;
|
|
31
|
+
prevMonth: () => void;
|
|
32
|
+
nextMonth: () => void;
|
|
33
|
+
prevYear: () => void;
|
|
34
|
+
nextYear: () => void;
|
|
35
|
+
prevYearPage: () => void;
|
|
36
|
+
nextYearPage: () => void;
|
|
37
|
+
switchToMonthsView: () => void;
|
|
38
|
+
switchToYearsView: () => void;
|
|
39
|
+
selectMonth: (month: number) => void;
|
|
40
|
+
selectYear: (year: number) => void;
|
|
41
|
+
}
|
|
42
|
+
/** Creates the shared navigation state for a date picker. */
|
|
43
|
+
export declare function createDatePickerNav(T: BeatUITemporal, initialYear: number, initialMonth: number, disabled: Value<boolean>, weekStartsOn: Value<number>): DatePickerNav;
|
|
44
|
+
export interface DatePickerShellOptions {
|
|
45
|
+
size: Value<ControlSize>;
|
|
46
|
+
disabled: Value<boolean>;
|
|
47
|
+
color: Value<ThemeColorName>;
|
|
48
|
+
ariaLabel: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Renders the full date picker shell: outer wrapper, navigation header
|
|
52
|
+
* (days/months/years), weekday headers, month picker, year picker,
|
|
53
|
+
* and a custom day grid.
|
|
54
|
+
*/
|
|
55
|
+
export declare function renderDatePickerShell(nav: DatePickerNav, opts: DatePickerShellOptions, renderGrid: () => TNode): TNode;
|