@20baht/ui 0.0.0-stage → 0.1.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 +512 -2
- package/dist/components/baht-form.d.ts +206 -0
- package/dist/components/baht-form.js +630 -0
- package/dist/components/baht-workflow.d.ts +187 -0
- package/dist/components/baht-workflow.js +455 -0
- package/dist/components/base.d.ts +92 -0
- package/dist/components/base.js +138 -0
- package/dist/components/combobox-controller.d.ts +65 -0
- package/dist/components/combobox-controller.js +82 -0
- package/dist/components/define.d.ts +7 -0
- package/dist/components/define.js +16 -0
- package/dist/components/field-base.d.ts +84 -0
- package/dist/components/field-base.js +152 -0
- package/dist/components/floating.d.ts +84 -0
- package/dist/components/floating.js +182 -0
- package/dist/components/form-layout.d.ts +39 -0
- package/dist/components/form-layout.js +67 -0
- package/dist/components/form-options.d.ts +39 -0
- package/dist/components/form-options.js +65 -0
- package/dist/components/form-readonly.d.ts +20 -0
- package/dist/components/form-readonly.js +70 -0
- package/dist/components/layers.d.ts +4 -0
- package/dist/components/layers.js +15 -0
- package/dist/components/menu-controller.d.ts +65 -0
- package/dist/components/menu-controller.js +134 -0
- package/dist/components/motion.d.ts +9 -0
- package/dist/components/motion.js +16 -0
- package/dist/components/primitives/baht-accordion.d.ts +29 -0
- package/dist/components/primitives/baht-accordion.js +66 -0
- package/dist/components/primitives/baht-alert.d.ts +20 -0
- package/dist/components/primitives/baht-alert.js +62 -0
- package/dist/components/primitives/baht-app-shell.d.ts +81 -0
- package/dist/components/primitives/baht-app-shell.js +161 -0
- package/dist/components/primitives/baht-approval-chain.d.ts +59 -0
- package/dist/components/primitives/baht-approval-chain.js +80 -0
- package/dist/components/primitives/baht-avatar.d.ts +19 -0
- package/dist/components/primitives/baht-avatar.js +43 -0
- package/dist/components/primitives/baht-badge.d.ts +24 -0
- package/dist/components/primitives/baht-badge.js +41 -0
- package/dist/components/primitives/baht-bar-chart.d.ts +78 -0
- package/dist/components/primitives/baht-bar-chart.js +361 -0
- package/dist/components/primitives/baht-breadcrumbs.d.ts +23 -0
- package/dist/components/primitives/baht-breadcrumbs.js +45 -0
- package/dist/components/primitives/baht-button.d.ts +89 -0
- package/dist/components/primitives/baht-button.js +146 -0
- package/dist/components/primitives/baht-calendar.d.ts +96 -0
- package/dist/components/primitives/baht-calendar.js +398 -0
- package/dist/components/primitives/baht-card.d.ts +34 -0
- package/dist/components/primitives/baht-card.js +70 -0
- package/dist/components/primitives/baht-catalog-card.d.ts +52 -0
- package/dist/components/primitives/baht-catalog-card.js +90 -0
- package/dist/components/primitives/baht-checkbox.d.ts +7 -0
- package/dist/components/primitives/baht-checkbox.js +40 -0
- package/dist/components/primitives/baht-choice-group.d.ts +52 -0
- package/dist/components/primitives/baht-choice-group.js +71 -0
- package/dist/components/primitives/baht-code.d.ts +18 -0
- package/dist/components/primitives/baht-code.js +33 -0
- package/dist/components/primitives/baht-column-picker.d.ts +69 -0
- package/dist/components/primitives/baht-column-picker.js +234 -0
- package/dist/components/primitives/baht-comments.d.ts +38 -0
- package/dist/components/primitives/baht-comments.js +102 -0
- package/dist/components/primitives/baht-currency.d.ts +13 -0
- package/dist/components/primitives/baht-currency.js +69 -0
- package/dist/components/primitives/baht-datepicker.d.ts +77 -0
- package/dist/components/primitives/baht-datepicker.js +235 -0
- package/dist/components/primitives/baht-donut-chart.d.ts +24 -0
- package/dist/components/primitives/baht-donut-chart.js +88 -0
- package/dist/components/primitives/baht-edit-table.d.ts +45 -0
- package/dist/components/primitives/baht-edit-table.js +176 -0
- package/dist/components/primitives/baht-empty-state.d.ts +26 -0
- package/dist/components/primitives/baht-empty-state.js +51 -0
- package/dist/components/primitives/baht-error-state.d.ts +21 -0
- package/dist/components/primitives/baht-error-state.js +44 -0
- package/dist/components/primitives/baht-facts.d.ts +42 -0
- package/dist/components/primitives/baht-facts.js +49 -0
- package/dist/components/primitives/baht-fieldset.d.ts +19 -0
- package/dist/components/primitives/baht-fieldset.js +42 -0
- package/dist/components/primitives/baht-file.d.ts +27 -0
- package/dist/components/primitives/baht-file.js +158 -0
- package/dist/components/primitives/baht-filter-builder.d.ts +39 -0
- package/dist/components/primitives/baht-filter-builder.js +201 -0
- package/dist/components/primitives/baht-filter.d.ts +36 -0
- package/dist/components/primitives/baht-filter.js +64 -0
- package/dist/components/primitives/baht-heatmap.d.ts +49 -0
- package/dist/components/primitives/baht-heatmap.js +168 -0
- package/dist/components/primitives/baht-input.d.ts +10 -0
- package/dist/components/primitives/baht-input.js +44 -0
- package/dist/components/primitives/baht-keyvalue-editor.d.ts +28 -0
- package/dist/components/primitives/baht-keyvalue-editor.js +106 -0
- package/dist/components/primitives/baht-line-chart.d.ts +45 -0
- package/dist/components/primitives/baht-line-chart.js +183 -0
- package/dist/components/primitives/baht-link.d.ts +26 -0
- package/dist/components/primitives/baht-link.js +48 -0
- package/dist/components/primitives/baht-list.d.ts +29 -0
- package/dist/components/primitives/baht-list.js +79 -0
- package/dist/components/primitives/baht-loading-overlay.d.ts +15 -0
- package/dist/components/primitives/baht-loading-overlay.js +33 -0
- package/dist/components/primitives/baht-markdown-view.d.ts +17 -0
- package/dist/components/primitives/baht-markdown-view.js +39 -0
- package/dist/components/primitives/baht-markdown.d.ts +34 -0
- package/dist/components/primitives/baht-markdown.js +177 -0
- package/dist/components/primitives/baht-menu.d.ts +53 -0
- package/dist/components/primitives/baht-menu.js +100 -0
- package/dist/components/primitives/baht-meter.d.ts +67 -0
- package/dist/components/primitives/baht-meter.js +107 -0
- package/dist/components/primitives/baht-modal.d.ts +71 -0
- package/dist/components/primitives/baht-modal.js +164 -0
- package/dist/components/primitives/baht-multiselect.d.ts +8 -0
- package/dist/components/primitives/baht-multiselect.js +47 -0
- package/dist/components/primitives/baht-notification-bell.d.ts +54 -0
- package/dist/components/primitives/baht-notification-bell.js +143 -0
- package/dist/components/primitives/baht-number.d.ts +5 -0
- package/dist/components/primitives/baht-number.js +39 -0
- package/dist/components/primitives/baht-order-box.d.ts +24 -0
- package/dist/components/primitives/baht-order-box.js +50 -0
- package/dist/components/primitives/baht-otp.d.ts +49 -0
- package/dist/components/primitives/baht-otp.js +109 -0
- package/dist/components/primitives/baht-page-header.d.ts +43 -0
- package/dist/components/primitives/baht-page-header.js +78 -0
- package/dist/components/primitives/baht-pagination.d.ts +33 -0
- package/dist/components/primitives/baht-pagination.js +86 -0
- package/dist/components/primitives/baht-popover.d.ts +45 -0
- package/dist/components/primitives/baht-popover.js +112 -0
- package/dist/components/primitives/baht-progress-ring.d.ts +22 -0
- package/dist/components/primitives/baht-progress-ring.js +62 -0
- package/dist/components/primitives/baht-progress.d.ts +17 -0
- package/dist/components/primitives/baht-progress.js +48 -0
- package/dist/components/primitives/baht-radio.d.ts +7 -0
- package/dist/components/primitives/baht-radio.js +74 -0
- package/dist/components/primitives/baht-range.d.ts +38 -0
- package/dist/components/primitives/baht-range.js +88 -0
- package/dist/components/primitives/baht-rating.d.ts +40 -0
- package/dist/components/primitives/baht-rating.js +107 -0
- package/dist/components/primitives/baht-record-bar.d.ts +30 -0
- package/dist/components/primitives/baht-record-bar.js +60 -0
- package/dist/components/primitives/baht-reference-dialog.d.ts +87 -0
- package/dist/components/primitives/baht-reference-dialog.js +418 -0
- package/dist/components/primitives/baht-reference-picker.d.ts +110 -0
- package/dist/components/primitives/baht-reference-picker.js +321 -0
- package/dist/components/primitives/baht-repeater.d.ts +59 -0
- package/dist/components/primitives/baht-repeater.js +315 -0
- package/dist/components/primitives/baht-rule-builder.d.ts +24 -0
- package/dist/components/primitives/baht-rule-builder.js +177 -0
- package/dist/components/primitives/baht-saved-filters.d.ts +41 -0
- package/dist/components/primitives/baht-saved-filters.js +126 -0
- package/dist/components/primitives/baht-search.d.ts +34 -0
- package/dist/components/primitives/baht-search.js +71 -0
- package/dist/components/primitives/baht-section-header.d.ts +28 -0
- package/dist/components/primitives/baht-section-header.js +48 -0
- package/dist/components/primitives/baht-section.d.ts +23 -0
- package/dist/components/primitives/baht-section.js +49 -0
- package/dist/components/primitives/baht-select.d.ts +49 -0
- package/dist/components/primitives/baht-select.js +197 -0
- package/dist/components/primitives/baht-skeleton.d.ts +16 -0
- package/dist/components/primitives/baht-skeleton.js +37 -0
- package/dist/components/primitives/baht-sparkline.d.ts +23 -0
- package/dist/components/primitives/baht-sparkline.js +56 -0
- package/dist/components/primitives/baht-spinner.d.ts +13 -0
- package/dist/components/primitives/baht-spinner.js +30 -0
- package/dist/components/primitives/baht-split-button.d.ts +43 -0
- package/dist/components/primitives/baht-split-button.js +87 -0
- package/dist/components/primitives/baht-stat-chart.d.ts +14 -0
- package/dist/components/primitives/baht-stat-chart.js +38 -0
- package/dist/components/primitives/baht-stat.d.ts +56 -0
- package/dist/components/primitives/baht-stat.js +117 -0
- package/dist/components/primitives/baht-steps.d.ts +33 -0
- package/dist/components/primitives/baht-steps.js +60 -0
- package/dist/components/primitives/baht-swipe-row.d.ts +64 -0
- package/dist/components/primitives/baht-swipe-row.js +178 -0
- package/dist/components/primitives/baht-table.d.ts +315 -0
- package/dist/components/primitives/baht-table.js +640 -0
- package/dist/components/primitives/baht-tabs.d.ts +54 -0
- package/dist/components/primitives/baht-tabs.js +128 -0
- package/dist/components/primitives/baht-tags.d.ts +96 -0
- package/dist/components/primitives/baht-tags.js +323 -0
- package/dist/components/primitives/baht-text.d.ts +10 -0
- package/dist/components/primitives/baht-text.js +29 -0
- package/dist/components/primitives/baht-textarea.d.ts +5 -0
- package/dist/components/primitives/baht-textarea.js +40 -0
- package/dist/components/primitives/baht-theme-toggle.d.ts +44 -0
- package/dist/components/primitives/baht-theme-toggle.js +101 -0
- package/dist/components/primitives/baht-timeline.d.ts +21 -0
- package/dist/components/primitives/baht-timeline.js +42 -0
- package/dist/components/primitives/baht-toast.d.ts +29 -0
- package/dist/components/primitives/baht-toast.js +83 -0
- package/dist/components/primitives/baht-toggle.d.ts +6 -0
- package/dist/components/primitives/baht-toggle.js +42 -0
- package/dist/components/primitives/baht-tooltip.d.ts +34 -0
- package/dist/components/primitives/baht-tooltip.js +85 -0
- package/dist/components/primitives/baht-tree.d.ts +58 -0
- package/dist/components/primitives/baht-tree.js +159 -0
- package/dist/components/primitives/baht-typeahead.d.ts +92 -0
- package/dist/components/primitives/baht-typeahead.js +258 -0
- package/dist/components/primitives/baht-upload.d.ts +108 -0
- package/dist/components/primitives/baht-upload.js +325 -0
- package/dist/components/primitives/baht-wizard.d.ts +57 -0
- package/dist/components/primitives/baht-wizard.js +147 -0
- package/dist/components/primitives/charts.d.ts +134 -0
- package/dist/components/primitives/charts.js +184 -0
- package/dist/components/primitives/column-map.d.ts +56 -0
- package/dist/components/primitives/column-map.js +70 -0
- package/dist/components/primitives/control-icons.d.ts +2 -0
- package/dist/components/primitives/control-icons.js +40 -0
- package/dist/components/primitives/icons.d.ts +24 -0
- package/dist/components/primitives/icons.js +86 -0
- package/dist/components/primitives/illustrations.d.ts +21 -0
- package/dist/components/primitives/illustrations.js +78 -0
- package/dist/components/primitives/index.d.ts +89 -0
- package/dist/components/primitives/kbd.d.ts +6 -0
- package/dist/components/primitives/kbd.js +9 -0
- package/dist/components/primitives/listbox.d.ts +2 -0
- package/dist/components/primitives/listbox.js +7 -0
- package/dist/components/primitives/markdown-render.d.ts +9 -0
- package/dist/components/primitives/markdown-render.js +77 -0
- package/dist/components/primitives/rule-rows.d.ts +55 -0
- package/dist/components/primitives/rule-rows.js +75 -0
- package/dist/components/primitives/tag-map.d.ts +6 -0
- package/dist/components/primitives/tag-map.js +39 -0
- package/dist/components/reference-labels.d.ts +22 -0
- package/dist/components/reference-labels.js +29 -0
- package/dist/components/shortcuts.d.ts +7 -0
- package/dist/components/shortcuts.js +43 -0
- package/dist/css/components.css +7517 -0
- package/dist/css/datepicker.css +346 -0
- package/dist/css/tokens.css +679 -0
- package/dist/custom-elements.json +45172 -0
- package/dist/engine.d.ts +1 -0
- package/dist/engine.js +1 -0
- package/dist/hydrate.d.ts +9 -0
- package/dist/hydrate.js +46 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +210 -0
- package/dist/overlay.d.ts +50 -0
- package/dist/overlay.js +140 -0
- package/dist/react.d.ts +557 -0
- package/dist/react.js +1 -0
- package/dist/register.d.ts +106 -0
- package/dist/register.js +99 -0
- package/dist/ssr.d.ts +16 -0
- package/dist/ssr.js +125 -0
- package/dist/tokens.css +8197 -0
- package/dist/vscode.css-custom-data.json +6 -0
- package/dist/vscode.html-custom-data.json +2261 -0
- package/dist/web-types.json +6523 -0
- package/package.json +157 -4
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import { BahtElement } from '../base.js';
|
|
3
|
+
import { FilterValue, SavedFilter } from '@20baht/engine';
|
|
4
|
+
import { ColumnMap } from './column-map.js';
|
|
5
|
+
import { MenuItem } from '../menu-controller.js';
|
|
6
|
+
export type { CellFn, CellKind, ColumnAlign, ColumnMap, ColumnSpec } from './column-map.js';
|
|
7
|
+
export type { ColumnsChangeDetail } from './baht-column-picker.js';
|
|
8
|
+
export type CellRenderer = (value: unknown, row: Record<string, unknown>) => unknown;
|
|
9
|
+
/** Group key for `groupBy`: a (dotted) row key, or a function of the row. */
|
|
10
|
+
export type GroupKey = string | ((row: Record<string, unknown>) => unknown);
|
|
11
|
+
/** Group header content: the group's value plus the rows in that group. */
|
|
12
|
+
export type GroupLabelRenderer = (value: unknown, rows: Record<string, unknown>[]) => unknown;
|
|
13
|
+
/** `baht-group-toggle` detail: which group and whether it is now collapsed. */
|
|
14
|
+
export interface GroupToggleDetail {
|
|
15
|
+
value: unknown;
|
|
16
|
+
collapsed: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** Row action menu: the same items on every row, or a function of the row for per-row items. */
|
|
19
|
+
export type RowMenu = MenuItem[] | ((row: Record<string, unknown>, index: number) => MenuItem[]);
|
|
20
|
+
/** `baht-row-menu-select` detail: the picked item and the row it belongs to. */
|
|
21
|
+
export interface RowMenuSelectDetail {
|
|
22
|
+
value: string;
|
|
23
|
+
item: MenuItem;
|
|
24
|
+
row: Record<string, unknown>;
|
|
25
|
+
index: number;
|
|
26
|
+
id: unknown;
|
|
27
|
+
}
|
|
28
|
+
/** `default`: the full table. `plain`: a small table, no column picker and no index column. */
|
|
29
|
+
export type TableVariant = 'default' | 'plain';
|
|
30
|
+
export type SortDirection = 'asc' | 'desc';
|
|
31
|
+
export interface SortState {
|
|
32
|
+
key: string;
|
|
33
|
+
direction: SortDirection;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Server-side data table. `items` is ONE page of rows — the component never
|
|
37
|
+
* slices or fetches; on `baht-page-change` the host fetches the next page and
|
|
38
|
+
* re-feeds `items`/`page`. While that fetch runs, set `loading` to show
|
|
39
|
+
* skeleton rows.
|
|
40
|
+
*
|
|
41
|
+
* const t = document.querySelector('baht-table');
|
|
42
|
+
* t.columns = { name: 'Name', created_at: 'Created' };
|
|
43
|
+
* t.items = pageRows; // current page only
|
|
44
|
+
* t.loading = false; t.page = 1; t.totalPages = 12;
|
|
45
|
+
* t.addEventListener('baht-page-change', (e) => fetchPage(e.detail.page));
|
|
46
|
+
* t.addEventListener('baht-row-click', (e) => open(e.detail.id));
|
|
47
|
+
*
|
|
48
|
+
* Set `cursor-mode` for cursor-based APIs (no total count) — the footer
|
|
49
|
+
* becomes a Prev/Next pair gated by `has-next`/`has-prev`, and the host
|
|
50
|
+
* listens for `baht-cursor-change` instead of `baht-page-change`:
|
|
51
|
+
*
|
|
52
|
+
* t.cursorMode = true; t.hasNext = true; t.hasPrev = false;
|
|
53
|
+
* t.addEventListener('baht-cursor-change', (e) => fetchPage(e.detail.direction));
|
|
54
|
+
*
|
|
55
|
+
* A built-in "Columns" button is ON by default — it opens a ServiceNow-style
|
|
56
|
+
* Available/Selected dual-list modal (add/remove, reorder, Select all/Clear
|
|
57
|
+
* all) derived from `columns` (or the first row's keys), no host wiring
|
|
58
|
+
* required. Set `t.columnPicker = false` (JS property — a boolean attribute
|
|
59
|
+
* can't express "off") to hide it. OK emits `baht-columns-change` with the
|
|
60
|
+
* chosen keys and their labels; persist that and feed it back as
|
|
61
|
+
* `visibleColumns` to remember a person's layout:
|
|
62
|
+
*
|
|
63
|
+
* t.addEventListener('baht-columns-change', (e) => save(e.detail.visibleColumns));
|
|
64
|
+
*
|
|
65
|
+
* Dot-walking (spec: reference columns). A column may declare `fields`, in
|
|
66
|
+
* which case the picker lets the person expand it and pick a sub-field —
|
|
67
|
+
* the key becomes `requester.department`, the header reads
|
|
68
|
+
* "Requested by › Department", and the cell resolves the path on the row.
|
|
69
|
+
* Rows whose values are plain objects get the same treatment automatically
|
|
70
|
+
* when no `columns` map is given.
|
|
71
|
+
*
|
|
72
|
+
* t.columns = {
|
|
73
|
+
* number: 'Number',
|
|
74
|
+
* requester: { label: 'Requested by', fields: { name: 'Name', department: 'Department' } },
|
|
75
|
+
* };
|
|
76
|
+
* t.visibleColumns = ['number', 'requester.name'];
|
|
77
|
+
*
|
|
78
|
+
* Cell kinds: a column renders a `<baht-badge>` or a `<baht-code>` chip without a renderer.
|
|
79
|
+
* `tone`, `labels` and `busy` (a badge's spinner) map a value (JSON) or are functions of the value
|
|
80
|
+
* and row (property); `empty` is plain text for an empty value; a `renderers` entry still wins.
|
|
81
|
+
*
|
|
82
|
+
* t.columns = {
|
|
83
|
+
* state: { label: 'State', cell: 'badge', tone: { ACTIVE: 'success' }, labels: { ACTIVE: 'Running' }, busy: { BUILD: true } },
|
|
84
|
+
* address: { label: 'Address', cell: 'code', empty: '-' },
|
|
85
|
+
* };
|
|
86
|
+
*
|
|
87
|
+
* `variant="plain"` turns both the picker and the "No." column off in one go (small tables).
|
|
88
|
+
*
|
|
89
|
+
* Empty state: a child with `data-slot="empty"` (an illustration, a button) takes the place
|
|
90
|
+
* of the `empty-message` text when there are no rows; it is hidden while loading or on error.
|
|
91
|
+
*
|
|
92
|
+
* `visibleColumns` still works standalone for a host-controlled subset (no
|
|
93
|
+
* refetch) — pass it explicitly and the built-in picker (if also enabled)
|
|
94
|
+
* starts from that selection and keeps emitting updates for it.
|
|
95
|
+
*
|
|
96
|
+
* Toolbar, selection, sorting, row actions (all server-side, all off by default):
|
|
97
|
+
*
|
|
98
|
+
* t.total = 143; // "143 results" in the toolbar (search/filter UI lives outside)
|
|
99
|
+
* t.selectable = true; t.selected = ['g1']; // checkbox column, controlled by row key
|
|
100
|
+
* t.addEventListener('baht-selection-change', (e) => (t.selected = e.detail.selected));
|
|
101
|
+
* t.columns = { amount: { label: 'Amount', numeric: true, sortable: true } };
|
|
102
|
+
* t.sort = { key: 'amount', direction: 'desc' };
|
|
103
|
+
* t.addEventListener('baht-sort-change', (e) => refetch({ sort: e.detail }));
|
|
104
|
+
* t.rowActions = true; // trailing "..." button -> baht-row-actions { row, index, id }
|
|
105
|
+
* t.rowMenu = [{ value: 'delete', label: 'Delete', danger: true }]; // a real menu per row
|
|
106
|
+
* t.rowMenu = (row) => itemsFor(row); // or per-row items
|
|
107
|
+
* t.addEventListener('baht-row-menu-select', (e) => run(e.detail.value, e.detail.row));
|
|
108
|
+
*
|
|
109
|
+
* Grouping (ServiceNow "Group by" on a list): `group-by` names a (dotted)
|
|
110
|
+
* row key, or pass a function as the property. Every row on the CURRENT page
|
|
111
|
+
* is bucketed by that value in first-appearance order; each bucket is its own
|
|
112
|
+
* `<tbody>` headed by a `th[scope=rowgroup]` disclosure reading
|
|
113
|
+
* "Column: value (n)". Click the header to collapse/expand the group
|
|
114
|
+
* (`baht-group-toggle`); `group-collapsed` starts them all closed, and the
|
|
115
|
+
* open/closed state resets when `items`/`page` change. Grouping is per page
|
|
116
|
+
* only — it rides on the existing pagination and never fetches or sorts, so
|
|
117
|
+
* a value split across pages shows up on each. `groupLabel` replaces the
|
|
118
|
+
* default header text (it still sits inside the toggle). Row numbers and
|
|
119
|
+
* event indexes stay page-global. `hide-header` drops the column header row
|
|
120
|
+
* for list-style layouts.
|
|
121
|
+
*
|
|
122
|
+
* t.groupBy = 'state'; // "State: Open (12)"
|
|
123
|
+
* t.groupBy = (row) => row.occurred_at.slice(0, 10);
|
|
124
|
+
* t.groupLabel = (day, rows) => `${formatDay(day)} · ${rows.length}`;
|
|
125
|
+
* t.groupCollapsed = true;
|
|
126
|
+
* t.addEventListener('baht-group-toggle', (e) => console.log(e.detail)); // { value, collapsed }
|
|
127
|
+
*
|
|
128
|
+
* Filter (ServiceNow's condition builder and breadcrumbs): `filterable` adds a Filter button. Its
|
|
129
|
+
* panel builds conditions on any column, dot-walked ones included; Run emits `baht-filter-change`
|
|
130
|
+
* and the conditions stay above the table, each one removable. The table never filters: the host
|
|
131
|
+
* refetches, or tests rows with `matchesFilter`, and feeds `filter` back. `type` and `options` on a
|
|
132
|
+
* column say how it compares.
|
|
133
|
+
*
|
|
134
|
+
* t.filterable = true;
|
|
135
|
+
* t.columns = { state: { label: 'State', type: 'choice', options: [...] } };
|
|
136
|
+
* t.addEventListener('baht-filter-change', (e) => refetch({ filter: e.detail.value }));
|
|
137
|
+
*
|
|
138
|
+
* Save Filters: set `savedFilters` (an empty list will do) and the panel can name a filter, apply
|
|
139
|
+
* one and delete one. The host keeps the list, in localStorage or on a server:
|
|
140
|
+
*
|
|
141
|
+
* t.savedFilters = load();
|
|
142
|
+
* t.addEventListener('baht-saved-filters-change', (e) => store(e.detail.filters));
|
|
143
|
+
* @fires {CustomEvent<{ row: Record<string, unknown>; index: number; id: unknown }>} baht-row-click - A row was pressed.
|
|
144
|
+
* @fires {CustomEvent<{ selected: unknown[]; rows: Record<string, unknown>[] }>} baht-selection-change - The selection changed.
|
|
145
|
+
* @fires {CustomEvent<{ key: string; direction: SortDirection }>} baht-sort-change - A sortable header was pressed.
|
|
146
|
+
* @fires {CustomEvent<ColumnsChangeDetail>} baht-columns-change - The column picker was confirmed.
|
|
147
|
+
* @fires {CustomEvent<{ value: FilterValue }>} baht-filter-change - The filter changed.
|
|
148
|
+
* @fires {CustomEvent<GroupToggleDetail>} baht-group-toggle - A group was collapsed or expanded.
|
|
149
|
+
* @fires {CustomEvent<{ row: Record<string, unknown>; index: number; id: unknown }>} baht-row-actions - A row's actions button was pressed.
|
|
150
|
+
* @fires {CustomEvent<RowMenuSelectDetail>} baht-row-menu-select - An item was picked from a row's `rowMenu`.
|
|
151
|
+
* @fires {CustomEvent<{ page: number }>} baht-page-change - A page was picked in the footer; the host fetches it.
|
|
152
|
+
* @fires {CustomEvent<{ direction: 'next' | 'prev' }>} baht-cursor-change - Cursor mode: next or previous was pressed.
|
|
153
|
+
* @fires {CustomEvent<{ filters: SavedFilter[] }>} baht-saved-filters-change - A filter was saved or deleted.
|
|
154
|
+
*/
|
|
155
|
+
export declare class BahtTable extends BahtElement {
|
|
156
|
+
/** Rows of the CURRENT page. */
|
|
157
|
+
items: Record<string, unknown>[];
|
|
158
|
+
/** column key -> display name, or a spec: a reference column with `fields`, a cell kind (`cell: 'badge' | 'code'`, `tone`, `labels`) (property); empty = derive keys from the first row (`snake_case` -> `Title Case`). */
|
|
159
|
+
columns: ColumnMap;
|
|
160
|
+
loading: boolean;
|
|
161
|
+
error: boolean;
|
|
162
|
+
errorMessage: string;
|
|
163
|
+
emptyMessage: string;
|
|
164
|
+
/** Row-number column (No.). Offset lets numbering continue across pages. */
|
|
165
|
+
showIndex: boolean;
|
|
166
|
+
indexOffset: number;
|
|
167
|
+
skeletonRows: number;
|
|
168
|
+
/** Which row key identifies a row in baht-row-click detail.id (e.g. 'group_id'). */
|
|
169
|
+
rowKey: string;
|
|
170
|
+
/** Rows emit baht-row-click + get hover/keyboard affordances. */
|
|
171
|
+
clickable: boolean;
|
|
172
|
+
/** Custom cell renderers by column key, dotted keys included (functions — a property, never JSON). */
|
|
173
|
+
renderers: Record<string, CellRenderer>;
|
|
174
|
+
/** Subset + order of columns to render (dotted keys allowed); empty/omitted = show all top-level columns. */
|
|
175
|
+
visibleColumns: string[];
|
|
176
|
+
/** Group the page's rows by this (dotted) column key — or a function of the row (property). Unset = no grouping. */
|
|
177
|
+
groupBy?: GroupKey;
|
|
178
|
+
/** Group header content (property); default is "Column: value (n)". */
|
|
179
|
+
groupLabel?: GroupLabelRenderer;
|
|
180
|
+
/** Group headers are disclosures (click to collapse). Set the JS property to `false` for static headers. */
|
|
181
|
+
groupCollapsible: boolean;
|
|
182
|
+
/** Start every group collapsed (per page — resets when `items`/`page` change). */
|
|
183
|
+
groupCollapsed: boolean;
|
|
184
|
+
/** Drop the column header row (list-style tables, e.g. grouped ledgers). */
|
|
185
|
+
hideHeader: boolean;
|
|
186
|
+
/** Built-in "Columns" toggle — derives its options from `columns`/rows. Set `column-picker="false"` to hide it. */
|
|
187
|
+
columnPicker: boolean;
|
|
188
|
+
/**
|
|
189
|
+
* `plain` is a small table in one switch: no column picker and no "No." column, whatever
|
|
190
|
+
* `column-picker` and `show-index` say. `default` leaves both to those props.
|
|
191
|
+
*/
|
|
192
|
+
variant: TableVariant;
|
|
193
|
+
/** Total matching rows across all pages — renders "{n} results" in the toolbar. Unset = no count. */
|
|
194
|
+
total?: number | undefined;
|
|
195
|
+
selectable: boolean;
|
|
196
|
+
selected: unknown[];
|
|
197
|
+
/** Make every column sortable (or set `sortable` per column in `columns`). */
|
|
198
|
+
sortable: boolean;
|
|
199
|
+
/** Current sort, mirrored in the header (`aria-sort`); the host keeps it in sync with the fetch. */
|
|
200
|
+
sort: SortState | null;
|
|
201
|
+
/** A Filter button: a condition builder over every column, and the applied conditions as breadcrumbs. */
|
|
202
|
+
filterable: boolean;
|
|
203
|
+
/** The applied filter; the host applies it and keeps it in sync. */
|
|
204
|
+
filter: FilterValue;
|
|
205
|
+
/** The filters this person saved; null hides saving. The host keeps them. */
|
|
206
|
+
savedFilters: SavedFilter[] | null;
|
|
207
|
+
/** Trailing "..." button per row; emits `baht-row-actions { row, index, id }`. */
|
|
208
|
+
rowActions: boolean;
|
|
209
|
+
/**
|
|
210
|
+
* A `<baht-menu>` per row (property): the items, or a function of the row and its index for
|
|
211
|
+
* per-row items (an empty list leaves that row's cell empty). A pick emits
|
|
212
|
+
* `baht-row-menu-select { value, item, row, index, id }`. When set it takes the place of the
|
|
213
|
+
* `row-actions` button.
|
|
214
|
+
*/
|
|
215
|
+
rowMenu: RowMenu | null;
|
|
216
|
+
page: number;
|
|
217
|
+
totalPages: number;
|
|
218
|
+
/** Keep the footer with one page too, so a list always shows where the pages are. */
|
|
219
|
+
alwaysPaginate: boolean;
|
|
220
|
+
/** Switch the footer to Prev/Next (cursor-based API, no total count). */
|
|
221
|
+
cursorMode: boolean;
|
|
222
|
+
hasNext: boolean;
|
|
223
|
+
hasPrev: boolean;
|
|
224
|
+
private pickerOpen;
|
|
225
|
+
/** User's picks once they've touched the picker; null = follow `visibleColumns`/all. */
|
|
226
|
+
private pickedColumns;
|
|
227
|
+
private filterOpen;
|
|
228
|
+
/** The conditions being edited; Run applies them. */
|
|
229
|
+
private draftFilter;
|
|
230
|
+
/** Group keys the person toggled away from `groupCollapsed`; reset on a new page. */
|
|
231
|
+
private toggledGroups;
|
|
232
|
+
/** The author's `data-slot="empty"` child: shown in the empty row, else parked (hidden) in the host. */
|
|
233
|
+
private emptySlot;
|
|
234
|
+
/** The picker is its own element: done means done rendering it too. */
|
|
235
|
+
protected getUpdateComplete(): Promise<boolean>;
|
|
236
|
+
protected willUpdate(changed: Map<PropertyKey, unknown>): void;
|
|
237
|
+
/**
|
|
238
|
+
* A `data-slot="empty"` child of the host, else the one already taken unless the host removed
|
|
239
|
+
* it. None during a server render or the hydrating render, so both match the server's markup.
|
|
240
|
+
*/
|
|
241
|
+
private findEmptySlot;
|
|
242
|
+
/** The empty row went away with the slot inside it: park the slot back in the host. */
|
|
243
|
+
protected updated(): void;
|
|
244
|
+
/** The declared map, or one derived from the first row (nested objects become reference columns). */
|
|
245
|
+
private get spec();
|
|
246
|
+
/** The column map last derived from a first row, and the row it came from. */
|
|
247
|
+
private derivedSpec;
|
|
248
|
+
private specAt;
|
|
249
|
+
private get allColumnKeys();
|
|
250
|
+
private get columnKeys();
|
|
251
|
+
private labelFor;
|
|
252
|
+
private readonly onOpenPicker;
|
|
253
|
+
private readonly onClosePicker;
|
|
254
|
+
private readonly onSavedFilterPick;
|
|
255
|
+
private readonly onSavedFiltersChange;
|
|
256
|
+
private readonly onPageChange;
|
|
257
|
+
private readonly onCursorChange;
|
|
258
|
+
private readonly onToggleFilterPanel;
|
|
259
|
+
private confirmPicker;
|
|
260
|
+
private get filterFields();
|
|
261
|
+
private applyFilter;
|
|
262
|
+
/** Run: a condition still waiting for its value is not applied. */
|
|
263
|
+
private runFilter;
|
|
264
|
+
private renderFilterToggle;
|
|
265
|
+
private renderFilterPanel;
|
|
266
|
+
/** The applied conditions, each one removable (ServiceNow's breadcrumbs). */
|
|
267
|
+
private renderFilterCrumbs;
|
|
268
|
+
private idOf;
|
|
269
|
+
private emitRow;
|
|
270
|
+
/** Selection key of a row: its `rowKey` value, else its index on this page. */
|
|
271
|
+
private keyOf;
|
|
272
|
+
private isSelected;
|
|
273
|
+
private emitSelection;
|
|
274
|
+
private toggleRow;
|
|
275
|
+
private get pageKeys();
|
|
276
|
+
private get allOnPageSelected();
|
|
277
|
+
private get someOnPageSelected();
|
|
278
|
+
private toggleAll;
|
|
279
|
+
private isSortable;
|
|
280
|
+
private requestSort;
|
|
281
|
+
/** Alignment class for a column (explicit `align` beats `numeric`). */
|
|
282
|
+
private alignClass;
|
|
283
|
+
private cell;
|
|
284
|
+
private span;
|
|
285
|
+
private groupValue;
|
|
286
|
+
/** Stable identity of a group value for the collapsed set (objects by JSON, else by type+string). */
|
|
287
|
+
private static groupId;
|
|
288
|
+
/**
|
|
289
|
+
* The page's rows bucketed by group value, in first-appearance order. Each
|
|
290
|
+
* row keeps its page index so numbering and event indexes stay host-order.
|
|
291
|
+
*/
|
|
292
|
+
private get groups();
|
|
293
|
+
private get isGrouped();
|
|
294
|
+
private isCollapsed;
|
|
295
|
+
private toggleGroup;
|
|
296
|
+
/** Default header: "Column: value (n)" — no column prefix for a function key. */
|
|
297
|
+
private defaultGroupLabel;
|
|
298
|
+
private renderGroups;
|
|
299
|
+
private renderBody;
|
|
300
|
+
private renderRow;
|
|
301
|
+
/** The "No." column is on: `show-index`, unless the table is plain. */
|
|
302
|
+
private get hasIndex();
|
|
303
|
+
/** The "Columns" button is on: `column-picker`, unless the table is plain. */
|
|
304
|
+
private get hasPicker();
|
|
305
|
+
/** Has a trailing actions column: the `row-actions` button or a `rowMenu`. */
|
|
306
|
+
private get hasActions();
|
|
307
|
+
private renderActions;
|
|
308
|
+
private renderHeaderCell;
|
|
309
|
+
private get hasToolbar();
|
|
310
|
+
private renderToolbar;
|
|
311
|
+
private renderColumnToggle;
|
|
312
|
+
protected render(): TemplateResult;
|
|
313
|
+
private renderHead;
|
|
314
|
+
private renderFooter;
|
|
315
|
+
}
|