@upbound/monarch-blocks 0.4.1 → 0.6.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/README.md +17 -0
- package/dist/cel-filter-bar.js +29 -15
- package/dist/cel-filter-bar.js.map +1 -1
- package/dist/chart.js.map +1 -1
- package/dist/chat-interface.js +1 -1
- package/dist/chat-interface.js.map +1 -1
- package/dist/code-block.js.map +1 -1
- package/dist/data-table.d.ts +33 -180
- package/dist/data-table.js +452 -307
- package/dist/data-table.js.map +1 -1
- package/dist/empty-view-DO36LNvk.d.ts +179 -0
- package/dist/filter-bar.d.ts +6 -2
- package/dist/filter-bar.js +102 -54
- package/dist/filter-bar.js.map +1 -1
- package/dist/floating-widget.js.map +1 -1
- package/dist/graph.css +73 -0
- package/dist/graph.d.ts +182 -0
- package/dist/graph.js +1780 -0
- package/dist/graph.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1444 -369
- package/dist/index.js.map +1 -1
- package/dist/page-header.js.map +1 -1
- package/dist/relative-time.js.map +1 -1
- package/dist/section-header.js.map +1 -1
- package/dist/section-nav.js.map +1 -1
- package/dist/timeline.js.map +1 -1
- package/package.json +7 -3
package/dist/data-table.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as React$1 from 'react';
|
|
2
2
|
import { ReactNode, Dispatch, SetStateAction, ComponentType } from 'react';
|
|
3
3
|
import { RowData, ColumnFilter, Cell, Column, ColumnOrderState, Row, ColumnDef, CellContext, HeaderGroup, TableOptions, TableState, InitialTableState, SortingFn, FilterFn, ExpandedState, ColumnFiltersState, PaginationState, SortingState, VisibilityState, ColumnPinningState, GroupingState, OnChangeFn, ColumnSizingState } from '@tanstack/react-table';
|
|
4
|
-
import { DropdownMenuItem
|
|
4
|
+
import { DropdownMenuItem } from '@upbound/monarch-core';
|
|
5
5
|
import { f as CelFilterSchema, g as CelFilterTree, k as CompileResult, i as CelRestrictedOptionSelectPayload } from './types-BULiU2qC.js';
|
|
6
|
+
import { T as TableDataState, a as DataTableEmptyView } from './empty-view-DO36LNvk.js';
|
|
7
|
+
export { D as DataTableEmptyConfig, d as defaultEmptyConfig, b as defaultErrorConfig, c as defaultNoFilterFoundConfig } from './empty-view-DO36LNvk.js';
|
|
6
8
|
|
|
7
9
|
/** A single entry (or nested submenu) in a cell's contextual right-click menu, alongside the built-in "Filter by this value" item. */
|
|
8
10
|
type ContextualMenuAction<TData extends RowData = RowData, TValue = unknown> = {
|
|
@@ -77,9 +79,8 @@ type DataTableValueCellProps = {
|
|
|
77
79
|
/**
|
|
78
80
|
* A generic cell renderer: a link (when `href` is set), a dashed-underline
|
|
79
81
|
* value with a hover tooltip (when `title` is set), or plain content — with
|
|
80
|
-
* an em-dash placeholder when `content` is empty.
|
|
81
|
-
*
|
|
82
|
-
* branch renders a plain `<a>`.
|
|
82
|
+
* an em-dash placeholder when `content` is empty. Consumers who need router
|
|
83
|
+
* navigation wrap their own router link with `Link asChild` at the call site.
|
|
83
84
|
*/
|
|
84
85
|
declare function DataTableValueCell({ content, title, className, href, onClick }: DataTableValueCellProps): React$1.JSX.Element;
|
|
85
86
|
/** A timestamp cell — relative time in the cell, absolute time on hover (via Monarch's `RelativeTime`); an em-dash when absent. */
|
|
@@ -87,180 +88,6 @@ declare function TimestampCell({ timestamp }: {
|
|
|
87
88
|
timestamp?: Date | string | number;
|
|
88
89
|
}): React$1.JSX.Element;
|
|
89
90
|
|
|
90
|
-
/**
|
|
91
|
-
* Non-CEL column filter definitions — the `meta.filter` vocabulary consumed by
|
|
92
|
-
* contextual (right-click cell) filtering and by the plain filter bar.
|
|
93
|
-
* Mirrors TableWrapper's `Filters/types.ts` shapes; `id` is omitted here since
|
|
94
|
-
* it comes from the owning `ColumnDef.id`, not the filter definition itself.
|
|
95
|
-
*/
|
|
96
|
-
type ColumnFilterType = 'checkbox' | 'radio' | 'dateRange' | 'text' | 'multiText';
|
|
97
|
-
type ColumnFilterOption = {
|
|
98
|
-
label: string;
|
|
99
|
-
value: string;
|
|
100
|
-
disabled?: boolean;
|
|
101
|
-
children?: ColumnFilterOption[];
|
|
102
|
-
};
|
|
103
|
-
type FetchColumnFilterOptionsArgs = {
|
|
104
|
-
query: string;
|
|
105
|
-
page: number;
|
|
106
|
-
signal: AbortSignal;
|
|
107
|
-
};
|
|
108
|
-
type FetchColumnFilterOptionsResult = {
|
|
109
|
-
items: ColumnFilterOption[];
|
|
110
|
-
hasMore: boolean;
|
|
111
|
-
};
|
|
112
|
-
type FetchColumnFilterOptions = (args: FetchColumnFilterOptionsArgs) => Promise<FetchColumnFilterOptionsResult>;
|
|
113
|
-
type ColumnFilterBase = {
|
|
114
|
-
title: string;
|
|
115
|
-
type: ColumnFilterType;
|
|
116
|
-
order?: number;
|
|
117
|
-
};
|
|
118
|
-
type StaticCheckboxColumnFilter = ColumnFilterBase & {
|
|
119
|
-
type: 'checkbox';
|
|
120
|
-
options: string[] | ColumnFilterOption[];
|
|
121
|
-
fetchFilterOptions?: never;
|
|
122
|
-
/** Whether the chip's value popup is a searchable Combobox. Defaults to `true`. */
|
|
123
|
-
searchable?: boolean;
|
|
124
|
-
};
|
|
125
|
-
type AsyncCheckboxColumnFilter = ColumnFilterBase & {
|
|
126
|
-
type: 'checkbox';
|
|
127
|
-
fetchFilterOptions: FetchColumnFilterOptions;
|
|
128
|
-
options?: never;
|
|
129
|
-
/** Whether the chip's value popup is a searchable Combobox. Defaults to `true`. */
|
|
130
|
-
searchable?: boolean;
|
|
131
|
-
};
|
|
132
|
-
type CheckboxColumnFilter = StaticCheckboxColumnFilter | AsyncCheckboxColumnFilter;
|
|
133
|
-
type RadioColumnFilter = ColumnFilterBase & {
|
|
134
|
-
type: 'radio';
|
|
135
|
-
options: string[] | ColumnFilterOption[];
|
|
136
|
-
/** Whether the chip's value popup is a searchable Combobox. Defaults to `true`. */
|
|
137
|
-
searchable?: boolean;
|
|
138
|
-
};
|
|
139
|
-
type DateRangeColumnFilter = ColumnFilterBase & {
|
|
140
|
-
type: 'dateRange';
|
|
141
|
-
/** When true, always show time inputs. When false, never show them. When omitted, auto-detect from value. */
|
|
142
|
-
includeTime?: boolean;
|
|
143
|
-
};
|
|
144
|
-
type TextColumnFilter = ColumnFilterBase & {
|
|
145
|
-
type: 'text';
|
|
146
|
-
placeholder?: string;
|
|
147
|
-
};
|
|
148
|
-
type MultiTextColumnFilter = ColumnFilterBase & {
|
|
149
|
-
type: 'multiText';
|
|
150
|
-
/** Defaults to comma (`,`) when omitted. */
|
|
151
|
-
delimiter?: string;
|
|
152
|
-
description?: string;
|
|
153
|
-
placeholder?: string;
|
|
154
|
-
};
|
|
155
|
-
type ColumnFilterDefinition = CheckboxColumnFilter | DateRangeColumnFilter | RadioColumnFilter | TextColumnFilter | MultiTextColumnFilter;
|
|
156
|
-
type CheckboxColumnFilterValue = string[] | undefined;
|
|
157
|
-
type RadioColumnFilterValue = string | undefined;
|
|
158
|
-
type DateRangeColumnFilterValue = {
|
|
159
|
-
startDate: Date | null;
|
|
160
|
-
endDate: Date | null;
|
|
161
|
-
} | undefined;
|
|
162
|
-
type TextColumnFilterValue = string | undefined;
|
|
163
|
-
type MultiTextColumnFilterValue = string[] | undefined;
|
|
164
|
-
type ColumnFilterValue = CheckboxColumnFilterValue | RadioColumnFilterValue | DateRangeColumnFilterValue | TextColumnFilterValue | MultiTextColumnFilterValue;
|
|
165
|
-
|
|
166
|
-
/** Derives a contextual (right-click cell) column-filter value from a cell. */
|
|
167
|
-
type ContextualFilterValueParser<TData extends RowData, TValue> = (cell: Cell<TData, TValue>) => ColumnFilterValue | undefined;
|
|
168
|
-
/** Derives a contextual (right-click cell) global-search term from a cell. */
|
|
169
|
-
type ContextualGlobalSearchValueParser<TData extends RowData, TValue> = (cell: Cell<TData, TValue>) => string | undefined;
|
|
170
|
-
/** A fixed-width grid track: sizes to content or an explicit CSS length. */
|
|
171
|
-
type GridColumnFixed = {
|
|
172
|
-
fixed: string;
|
|
173
|
-
flex?: never;
|
|
174
|
-
};
|
|
175
|
-
type GridColumnFlexContentMin = {
|
|
176
|
-
min: 'max-content' | 'min-content';
|
|
177
|
-
minCap?: string;
|
|
178
|
-
};
|
|
179
|
-
type GridColumnFlexFixedMin = {
|
|
180
|
-
min?: string;
|
|
181
|
-
minCap?: never;
|
|
182
|
-
};
|
|
183
|
-
/** A proportional grid track: shares space by weight, with optional min/max. */
|
|
184
|
-
type GridColumnFlex = {
|
|
185
|
-
flex: number;
|
|
186
|
-
max?: string;
|
|
187
|
-
fixed?: never;
|
|
188
|
-
} & (GridColumnFlexContentMin | GridColumnFlexFixedMin);
|
|
189
|
-
/**
|
|
190
|
-
* Column sizing for grid layout mode.
|
|
191
|
-
*
|
|
192
|
-
* Fixed column (sizes to content or explicit value):
|
|
193
|
-
* { fixed: 'max-content' }
|
|
194
|
-
* { fixed: '200px' }
|
|
195
|
-
*
|
|
196
|
-
* Proportional column (shares space by weight, with optional min/max):
|
|
197
|
-
* { flex: 2, min: '100px' }
|
|
198
|
-
* { flex: 0.5, min: 'max-content' }
|
|
199
|
-
* { flex: 0.5, min: 'max-content', minCap: '200px' }
|
|
200
|
-
* { flex: 1, min: '80px', max: '500px' }
|
|
201
|
-
*/
|
|
202
|
-
type GridColumnSizing = GridColumnFixed | GridColumnFlex;
|
|
203
|
-
/**
|
|
204
|
-
* Column-def metadata `DataTable` reads — a straight port of TableWrapper's
|
|
205
|
-
* `ColumnMeta` module augmentation. Import this file for its side effect
|
|
206
|
-
* (`import '@/lib/data-table/table-meta'`) wherever a `ColumnDef` is authored
|
|
207
|
-
* with any of these fields.
|
|
208
|
-
*/
|
|
209
|
-
declare module '@tanstack/react-table' {
|
|
210
|
-
interface ColumnMeta<TData extends RowData, TValue> {
|
|
211
|
-
/** Pins the column left or right. Pinned columns are excluded from column reordering. */
|
|
212
|
-
pinning?: 'left' | 'right';
|
|
213
|
-
/** Marks an actions column — hides its header label and excludes it from contextual filtering. */
|
|
214
|
-
actions?: boolean;
|
|
215
|
-
/** The column's non-CEL filter definition, read by the plain filter bar and contextual filtering. */
|
|
216
|
-
filter?: ColumnFilterDefinition;
|
|
217
|
-
/** Parses a cell into a filter value for contextual (right-click) cell filtering. */
|
|
218
|
-
contextualFilterValue?: ContextualFilterValueParser<TData, TValue>;
|
|
219
|
-
/** Parses a cell into a search term for contextual (right-click) global search. */
|
|
220
|
-
contextualGlobalSearchValue?: ContextualGlobalSearchValueParser<TData, TValue>;
|
|
221
|
-
/** When true, the column is used only for filtering and is never rendered in the table. */
|
|
222
|
-
filterOnly?: boolean;
|
|
223
|
-
/** Column sizing for `layout="grid"` mode — see `GridColumnSizing`. */
|
|
224
|
-
grid?: GridColumnSizing;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
type TableDataState = 'empty' | 'loading' | 'error' | 'success';
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Monarch-native equivalent of TableWrapper's `EmptyConfig` — same four
|
|
232
|
-
* states (error / empty / filtered-empty), rebuilt on Monarch's `Empty`
|
|
233
|
-
* compound API instead of a single props-driven component. Two deliberate
|
|
234
|
-
* adaptations: `icon` takes a Monarch `IconName` (no FontAwesome dependency),
|
|
235
|
-
* and `action` is a rendered node rather than a `ComponentType` reference.
|
|
236
|
-
* `details` has no native `Empty` slot — it composes `Alert` instead.
|
|
237
|
-
*/
|
|
238
|
-
type DataTableEmptyConfig = {
|
|
239
|
-
icon?: IconName;
|
|
240
|
-
header?: React$1.ReactNode;
|
|
241
|
-
subheader?: React$1.ReactNode;
|
|
242
|
-
details?: React$1.ReactNode;
|
|
243
|
-
action?: React$1.ReactNode;
|
|
244
|
-
className?: string;
|
|
245
|
-
wrapperClassName?: string;
|
|
246
|
-
};
|
|
247
|
-
declare const defaultErrorConfig: DataTableEmptyConfig;
|
|
248
|
-
declare const defaultEmptyConfig: DataTableEmptyConfig;
|
|
249
|
-
declare const defaultNoFilterFoundConfig: DataTableEmptyConfig;
|
|
250
|
-
type DataTableEmptyView = {
|
|
251
|
-
empty?: DataTableEmptyConfig;
|
|
252
|
-
error?: DataTableEmptyConfig;
|
|
253
|
-
filter?: DataTableEmptyConfig;
|
|
254
|
-
};
|
|
255
|
-
declare function DataTableEmptyView({ emptyView, tableState, filterCount, resetFilters, className, }: {
|
|
256
|
-
emptyView?: DataTableEmptyView;
|
|
257
|
-
/** `'success'`/`'loading'` render nothing here — the table body handles those. */
|
|
258
|
-
tableState: TableDataState;
|
|
259
|
-
filterCount: number;
|
|
260
|
-
resetFilters: () => void;
|
|
261
|
-
className?: string;
|
|
262
|
-
}): React$1.JSX.Element;
|
|
263
|
-
|
|
264
91
|
type RowCountRelation = 'eq' | 'gt';
|
|
265
92
|
/** Pass `true` for defaults, `false` to disable the footer entirely (handled by the caller, not this component), or an object to toggle individual parts. */
|
|
266
93
|
type DataTablePaginationConfig = boolean | {
|
|
@@ -385,6 +212,16 @@ interface TableHookOptions<TData extends RowData> extends Omit<TableOptions<TDat
|
|
|
385
212
|
enablePagination?: boolean;
|
|
386
213
|
rowCountRelation?: RowCountRelation;
|
|
387
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* Configures the "Filter" toolbar toggle that shows/hides the filter row
|
|
217
|
+
*/
|
|
218
|
+
type DataTableFilterVisibilityConfig = {
|
|
219
|
+
/** Controlled visibility. Omit for an uncontrolled toggle (DataTable owns the state). */
|
|
220
|
+
visible?: boolean;
|
|
221
|
+
onVisibleChange?: (visible: boolean) => void;
|
|
222
|
+
/** Initial visibility when uncontrolled. @default false */
|
|
223
|
+
defaultVisible?: boolean;
|
|
224
|
+
};
|
|
388
225
|
/** Wires the CEL filter builder into the filter row in place of plain column filters. */
|
|
389
226
|
type DataTableCelFilterConfig<TData extends RowData> = {
|
|
390
227
|
schema: CelFilterSchema;
|
|
@@ -479,6 +316,22 @@ interface DataTableProps<TData extends RowData> {
|
|
|
479
316
|
stickyHeader?: StickyHeaderConfig;
|
|
480
317
|
/** When set, renders the CEL filter builder in the filter row instead of column filters. */
|
|
481
318
|
celFilterConfig?: DataTableCelFilterConfig<TData>;
|
|
319
|
+
/**
|
|
320
|
+
* Controls the "Filter" toggle button in the toolbar, immediately to the left of
|
|
321
|
+
* `ActionsComponent`, that shows/hides the filter row (CEL filter bar or plain
|
|
322
|
+
* `ViewFilter`) without touching filter state — only the row's presence changes.
|
|
323
|
+
* The toggle renders by default (whether this prop is omitted or set to `true`),
|
|
324
|
+
* with the filter row starting hidden. Pass an object for a controlled toggle
|
|
325
|
+
* (e.g. to persist the preference in the consumer) or to change the uncontrolled
|
|
326
|
+
* initial state via `defaultVisible`. Pass `false` to disable the toggle entirely
|
|
327
|
+
* and always show the filter row whenever filtering is enabled — the pre-toggle
|
|
328
|
+
* behavior.
|
|
329
|
+
*
|
|
330
|
+
* The button never renders if there's nothing to filter — no column has a
|
|
331
|
+
* `meta.filter` and no `celFilterConfig` is set — or if `disableFilters` is
|
|
332
|
+
* `true`, regardless of this prop's value.
|
|
333
|
+
*/
|
|
334
|
+
filterVisibility?: boolean | DataTableFilterVisibilityConfig;
|
|
482
335
|
}
|
|
483
336
|
|
|
484
337
|
/**
|
|
@@ -488,7 +341,7 @@ interface DataTableProps<TData extends RowData> {
|
|
|
488
341
|
* difference is that columns, headers, rows, cells, and menus render through
|
|
489
342
|
* Monarch's own primitives instead of legacy's hand-rolled ones.
|
|
490
343
|
*/
|
|
491
|
-
declare function DataTable<TData extends RowData>({ id, config, title, description, emptyView, showError, className, fitContent, loading, renderSkeletonCell, serverSidePagination, ActionsComponent: Actions, onRowRender, renderExpandedRow, expanded: parentExpanded, onExpandedChange: parentOnExpandedChange, disableSearch, disableFilters, disableSorting, paginationConfig, disableColumnReordering, disableColumnVisibility, disableColumnResizing, disableColumnPinning, searchTerm: parentGlobalFilter, onSearchTermChange: parentSetGlobalFilter, filters: parentColumnFilters, onFiltersChange: parentSetColumnFilters, pagination: parentPagination, onPaginationChange: parentSetPagination, sorting: parentSorting, onSortingChange: parentSetSorting, columnOrdering: parentColumnOrdering, onColumnOrderingChange: parentSetColumnOrdering, columnVisibility: parentColumnVisibility, onColumnVisibilityChange: parentSetColumnVisibility, columnPinning: parentColumnPinning, onColumnPinningChange: parentSetColumnPinning, grouping: parentGrouping, onGroupingChange: parentSetGrouping, celFilterClassName, showContextualFilter, onContextCell, contextualMenuActions, layout, initialColumnSizing, onColumnSizingPersist, stickyHeader, celFilterConfig, }: DataTableProps<TData>): React$1.JSX.Element;
|
|
344
|
+
declare function DataTable<TData extends RowData>({ id, config, title, description, emptyView, showError, className, fitContent, loading, renderSkeletonCell, serverSidePagination, ActionsComponent: Actions, onRowRender, renderExpandedRow, expanded: parentExpanded, onExpandedChange: parentOnExpandedChange, disableSearch, disableFilters, disableSorting, paginationConfig, disableColumnReordering, disableColumnVisibility, disableColumnResizing, disableColumnPinning, searchTerm: parentGlobalFilter, onSearchTermChange: parentSetGlobalFilter, filters: parentColumnFilters, onFiltersChange: parentSetColumnFilters, pagination: parentPagination, onPaginationChange: parentSetPagination, sorting: parentSorting, onSortingChange: parentSetSorting, columnOrdering: parentColumnOrdering, onColumnOrderingChange: parentSetColumnOrdering, columnVisibility: parentColumnVisibility, onColumnVisibilityChange: parentSetColumnVisibility, columnPinning: parentColumnPinning, onColumnPinningChange: parentSetColumnPinning, grouping: parentGrouping, onGroupingChange: parentSetGrouping, celFilterClassName, showContextualFilter, onContextCell, contextualMenuActions, layout, initialColumnSizing, onColumnSizingPersist, stickyHeader, celFilterConfig, filterVisibility, }: DataTableProps<TData>): React$1.JSX.Element;
|
|
492
345
|
|
|
493
346
|
type ViewFilterProps<TData extends RowData> = {
|
|
494
347
|
columns: Column<TData, unknown>[];
|
|
@@ -508,4 +361,4 @@ type ViewFilterProps<TData extends RowData> = {
|
|
|
508
361
|
*/
|
|
509
362
|
declare function ViewFilter<TData extends RowData>({ columns, columnFilters, onColumnFiltersChange, className, }: ViewFilterProps<TData>): React$1.JSX.Element;
|
|
510
363
|
|
|
511
|
-
export { CellContextualFilter, type CellContextualFilterProps, ColumnOptions, type ColumnOptionsProps, type ContextualMenuAction, DataTable, DataTableBody, type DataTableCelFilterConfig, DataTableCell,
|
|
364
|
+
export { CellContextualFilter, type CellContextualFilterProps, ColumnOptions, type ColumnOptionsProps, type ContextualMenuAction, DataTable, DataTableBody, type DataTableCelFilterConfig, DataTableCell, DataTableEmptyView, DataTableExpandedRow, type DataTableFilterVisibilityConfig, DataTableGroupRow, DataTableHeader, DataTablePagination, type DataTablePaginationConfig, type DataTablePaginationProps, type DataTableProps, DataTableRow, type DataTableRowProps, DataTableSkeletonBody, DataTableValueCell, type DataTableValueCellProps, ExpandButton, RowActionItem, RowActions, type RowCountRelation, type StickyHeaderConfig, type TableHookOptions, type TableLayout, TimestampCell, ViewFilter, type ViewFilterProps, getActionsColumnDefinition, getExpandColumnDefinition, normalizePageSizeOptions };
|