@peasant-labs/fairtrade 0.0.28 → 0.0.29

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.
@@ -2,8 +2,8 @@
2
2
  * a sortable + selectable data table. square, hairline, mono headers; both themes
3
3
  * via tokens. sort + selection state/logic are powered by TanStack Table
4
4
  * (@tanstack/react-table, headless) while this component still renders its own markup
5
- * + token classes. Search, column filters and pagination can each be host-controlled
6
- * or seeded by defaults. Sorting cycles none -> asc -> desc -> none on a
5
+ * + token classes. Search and filter controls are opt-in toolbar content. Pagination
6
+ * is enabled only by explicit pagination/defaultPagination props. Sorting cycles none -> asc -> desc -> none on a
7
7
  * sortable header (a real <button>, so it is keyboard-operable), exposes aria-sort on the
8
8
  * <th>, and shows a lucide chevron indicator. selection reuses the existing .check-box control:
9
9
  * a header checkbox selects/clears all (with an indeterminate middle state) and
@@ -47,11 +47,14 @@
47
47
  * @param {DataTableColumnFilters} [props.defaultColumnFilters=[]] initial column filters.
48
48
  * @param {(next: DataTableColumnFilters) => void} [props.onColumnFiltersChange] next filters.
49
49
  * @param {DataTablePagination} [props.pagination] controlled pagination (zero-based pageIndex).
50
- * @param {DataTablePagination} [props.defaultPagination] defaults to pageIndex 0, pageSize 10.
50
+ * @param {DataTablePagination} [props.defaultPagination] enables local pagination with this initial state.
51
51
  * @param {(next: DataTablePagination) => void} [props.onPaginationChange] next pagination.
52
52
  * @param {number} [props.rowCount] host total for host-sliced data: pagination stays manual (the page count comes from rowCount) and sorting stays local, while search and column filters still apply to the rows given; with a partial window and an active filter the footer reports the loaded rows, never the host total.
53
+ * @param {(controls: Parameters<typeof import('./DataTableControls.jsx').DataTableToolbar>[0]) => React.ReactNode} [props.toolbar] optional controls; render DataTableToolbar or importer-owned content.
54
+ * @param {(controls: Parameters<typeof DataTablePaginationControls>[0]) => React.ReactNode} [props.footer] optional footer; replaces the default pager when pagination is enabled.
55
+ * @param {React.CSSProperties['maxHeight']} [props.maxHeight] explicit inner scroll bound; natural height when omitted.
53
56
  */
54
- export default function DataTable({ columns, rows, selectable, disabled, rowKey, defaultSort, sort: sortProp, onSortChange, defaultSelectedKeys, selectedKeys: selectedProp, onSelectionChange, caption, className, search: searchProp, defaultSearch, onSearchChange, columnFilters: filtersProp, defaultColumnFilters, onColumnFiltersChange, pagination: paginationProp, defaultPagination, onPaginationChange, rowCount, }: {
57
+ export default function DataTable({ columns, rows, selectable, disabled, rowKey, defaultSort, sort: sortProp, onSortChange, defaultSelectedKeys, selectedKeys: selectedProp, onSelectionChange, caption, className, search: searchProp, defaultSearch, onSearchChange, columnFilters: filtersProp, defaultColumnFilters, onColumnFiltersChange, pagination: paginationProp, defaultPagination, onPaginationChange, rowCount, toolbar, footer, maxHeight, }: {
55
58
  columns: DataTableColumn[];
56
59
  rows: any[];
57
60
  selectable?: boolean;
@@ -75,13 +78,16 @@ export default function DataTable({ columns, rows, selectable, disabled, rowKey,
75
78
  defaultPagination?: DataTablePagination;
76
79
  onPaginationChange?: (next: DataTablePagination) => void;
77
80
  rowCount?: number;
81
+ toolbar?: (controls: Parameters<typeof import("./DataTableControls.jsx").DataTableToolbar>[0]) => React.ReactNode;
82
+ footer?: (controls: Parameters<typeof DataTablePaginationControls>[0]) => React.ReactNode;
83
+ maxHeight?: React.CSSProperties["maxHeight"];
78
84
  }): import("react").JSX.Element;
79
85
  /**
80
86
  * a sortable + selectable data table. square, hairline, mono headers; both themes
81
87
  * via tokens. sort + selection state/logic are powered by TanStack Table
82
88
  * (@tanstack/react-table, headless) while this component still renders its own markup
83
- * + token classes. Search, column filters and pagination can each be host-controlled
84
- * or seeded by defaults. Sorting cycles none -> asc -> desc -> none on a
89
+ * + token classes. Search and filter controls are opt-in toolbar content. Pagination
90
+ * is enabled only by explicit pagination/defaultPagination props. Sorting cycles none -> asc -> desc -> none on a
85
91
  * sortable header (a real <button>, so it is keyboard-operable), exposes aria-sort on the
86
92
  * <th>, and shows a lucide chevron indicator. selection reuses the existing .check-box control:
87
93
  * a header checkbox selects/clears all (with an indeterminate middle state) and
@@ -122,8 +128,8 @@ export type DataTableColumn = {
122
128
  * a sortable + selectable data table. square, hairline, mono headers; both themes
123
129
  * via tokens. sort + selection state/logic are powered by TanStack Table
124
130
  * (@tanstack/react-table, headless) while this component still renders its own markup
125
- * + token classes. Search, column filters and pagination can each be host-controlled
126
- * or seeded by defaults. Sorting cycles none -> asc -> desc -> none on a
131
+ * + token classes. Search and filter controls are opt-in toolbar content. Pagination
132
+ * is enabled only by explicit pagination/defaultPagination props. Sorting cycles none -> asc -> desc -> none on a
127
133
  * sortable header (a real <button>, so it is keyboard-operable), exposes aria-sort on the
128
134
  * <th>, and shows a lucide chevron indicator. selection reuses the existing .check-box control:
129
135
  * a header checkbox selects/clears all (with an indeterminate middle state) and
@@ -142,8 +148,8 @@ export type DataTableSort = {
142
148
  * a sortable + selectable data table. square, hairline, mono headers; both themes
143
149
  * via tokens. sort + selection state/logic are powered by TanStack Table
144
150
  * (@tanstack/react-table, headless) while this component still renders its own markup
145
- * + token classes. Search, column filters and pagination can each be host-controlled
146
- * or seeded by defaults. Sorting cycles none -> asc -> desc -> none on a
151
+ * + token classes. Search and filter controls are opt-in toolbar content. Pagination
152
+ * is enabled only by explicit pagination/defaultPagination props. Sorting cycles none -> asc -> desc -> none on a
147
153
  * sortable header (a real <button>, so it is keyboard-operable), exposes aria-sort on the
148
154
  * <th>, and shows a lucide chevron indicator. selection reuses the existing .check-box control:
149
155
  * a header checkbox selects/clears all (with an indeterminate middle state) and
@@ -162,8 +168,8 @@ export type DataTableColumnFilters = {
162
168
  * a sortable + selectable data table. square, hairline, mono headers; both themes
163
169
  * via tokens. sort + selection state/logic are powered by TanStack Table
164
170
  * (@tanstack/react-table, headless) while this component still renders its own markup
165
- * + token classes. Search, column filters and pagination can each be host-controlled
166
- * or seeded by defaults. Sorting cycles none -> asc -> desc -> none on a
171
+ * + token classes. Search and filter controls are opt-in toolbar content. Pagination
172
+ * is enabled only by explicit pagination/defaultPagination props. Sorting cycles none -> asc -> desc -> none on a
167
173
  * sortable header (a real <button>, so it is keyboard-operable), exposes aria-sort on the
168
174
  * <th>, and shows a lucide chevron indicator. selection reuses the existing .check-box control:
169
175
  * a header checkbox selects/clears all (with an indeterminate middle state) and
@@ -178,3 +184,4 @@ export type DataTablePagination = {
178
184
  pageIndex: number;
179
185
  pageSize: number;
180
186
  };
187
+ import { DataTablePaginationControls } from './DataTableControls.jsx';
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Optional table controls. Omit search or columnFilters to leave that control out;
3
+ * children extend the toolbar with importer-owned actions.
4
+ * @param {Object} props
5
+ * @param {{ value: string, onChange: (value: string) => void }} [props.search]
6
+ * @param {{ columns: import('./DataTable.jsx').DataTableColumn[], value: import('./DataTable.jsx').DataTableColumnFilters, onChange: (value: import('./DataTable.jsx').DataTableColumnFilters) => void }} [props.columnFilters]
7
+ * @param {boolean} [props.disabled=false]
8
+ * @param {React.ReactNode} [props.children]
9
+ */
10
+ export function DataTableToolbar({ search, columnFilters, disabled, children }: {
11
+ search?: {
12
+ value: string;
13
+ onChange: (value: string) => void;
14
+ };
15
+ columnFilters?: {
16
+ columns: import("./DataTable.jsx").DataTableColumn[];
17
+ value: import("./DataTable.jsx").DataTableColumnFilters;
18
+ onChange: (value: import("./DataTable.jsx").DataTableColumnFilters) => void;
19
+ };
20
+ disabled?: boolean;
21
+ children?: React.ReactNode;
22
+ }): import("react").JSX.Element;
23
+ /**
24
+ * Optional pagination/footer presentation, independent of the table's row markup.
25
+ * @param {Object} props
26
+ * @param {string} props.countLabel
27
+ * @param {number} props.pageIndex
28
+ * @param {number} props.pageCount
29
+ * @param {boolean} props.canPreviousPage
30
+ * @param {boolean} props.canNextPage
31
+ * @param {() => void} props.onPreviousPage
32
+ * @param {() => void} props.onNextPage
33
+ * @param {boolean} [props.disabled=false]
34
+ */
35
+ export function DataTablePaginationControls({ countLabel, pageIndex, pageCount, canPreviousPage, canNextPage, onPreviousPage, onNextPage, disabled }: {
36
+ countLabel: string;
37
+ pageIndex: number;
38
+ pageCount: number;
39
+ canPreviousPage: boolean;
40
+ canNextPage: boolean;
41
+ onPreviousPage: () => void;
42
+ onNextPage: () => void;
43
+ disabled?: boolean;
44
+ }): import("react").JSX.Element;
@@ -41,6 +41,7 @@ export { Avatar, AvatarGroup, Kbd, KbdChord, Tag } from "./Avatar.jsx";
41
41
  export { default as BrandMark, resolveBrand } from "./BrandMark.jsx";
42
42
  export { providerAccent, providerDisplayName } from "./provider-policy.js";
43
43
  export { Skeleton, Progress, Spinner, Toast, FeedbackPanel } from "./Feedback.jsx";
44
+ export { DataTableToolbar, DataTablePaginationControls } from "./DataTableControls.jsx";
44
45
  export { default as HelperGroup, HelperGroupListItem, HelperThreadRow, useHelperSelection, helperOwnerState, helperSelectionIds, helperOwnerToggle, helperMemberToggle, HELPER_OWNER_STATE } from "./HelperGroup.jsx";
45
46
  export { default as Timeline, TimelineItem, ToolCall, ThinkingBlock } from "./Timeline.jsx";
46
47
  export { default as ToastProvider, useToast } from "./ToastHost.jsx";