@fusion.dev/helix-headless 0.238.1 → 0.240.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/api.json +1 -1
- package/custom-elements.json +1 -1
- package/dist/column-manager/index.d.ts +1 -0
- package/dist/column-manager/index.js +1 -0
- package/dist/column-manager/root/column-manager-root.d.ts +137 -0
- package/dist/column-manager/root/column-manager-root.js +253 -0
- package/dist/data-table/binding.d.ts +85 -0
- package/dist/data-table/binding.js +58 -0
- package/dist/data-table/edit.d.ts +47 -0
- package/dist/data-table/edit.js +60 -0
- package/dist/data-table/events/before-cell-commit.d.ts +16 -0
- package/dist/data-table/events/before-cell-commit.js +11 -0
- package/dist/data-table/events/before-cell-edit.d.ts +13 -0
- package/dist/data-table/events/before-cell-edit.js +11 -0
- package/dist/data-table/events/before-export.d.ts +15 -0
- package/dist/data-table/events/before-export.js +11 -0
- package/dist/data-table/events/before-view-change.d.ts +16 -0
- package/dist/data-table/events/before-view-change.js +11 -0
- package/dist/data-table/events/cell-commit.d.ts +12 -0
- package/dist/data-table/events/cell-commit.js +11 -0
- package/dist/data-table/events/cell-edit.d.ts +11 -0
- package/dist/data-table/events/cell-edit.js +11 -0
- package/dist/data-table/events/details.d.ts +47 -0
- package/dist/data-table/events/export.d.ts +11 -0
- package/dist/data-table/events/export.js +11 -0
- package/dist/data-table/events/index.d.ts +18 -2
- package/dist/data-table/events/index.js +17 -1
- package/dist/data-table/events/view-change.d.ts +12 -0
- package/dist/data-table/events/view-change.js +11 -0
- package/dist/data-table/export.d.ts +43 -0
- package/dist/data-table/export.js +26 -0
- package/dist/data-table/index.d.ts +2 -0
- package/dist/data-table/index.js +2 -0
- package/dist/data-table/root/data-table-root.d.ts +406 -26
- package/dist/data-table/root/data-table-root.js +959 -30
- package/dist/data-table/view.d.ts +124 -0
- package/dist/data-table/view.js +249 -0
- package/dist/data-table/xlsx/index.d.ts +27 -0
- package/dist/data-table/xlsx/index.js +119 -0
- package/dist/date-input/root/date-input-root.d.ts +7 -0
- package/dist/date-input/root/date-input-root.js +9 -1
- package/dist/editor/root/editor-root.d.ts +106 -7
- package/dist/editor/root/editor-root.js +273 -50
- package/dist/element-events.generated.js +9 -0
- package/dist/filter-input/root/filter-input-root.d.ts +31 -0
- package/dist/filter-input/root/filter-input-root.js +94 -12
- package/dist/filter-input/table.d.ts +64 -0
- package/dist/filter-input/table.js +76 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/input/root/input-root.d.ts +7 -0
- package/dist/input/root/input-root.js +9 -1
- package/dist/navigation/root/navigation-root.d.ts +115 -1
- package/dist/navigation/root/navigation-root.js +220 -8
- package/dist/number-input/root/number-input-root.d.ts +7 -0
- package/dist/number-input/root/number-input-root.js +9 -1
- package/dist/quick-filters/events/before-view-save.d.ts +14 -0
- package/dist/quick-filters/events/before-view-save.js +11 -0
- package/dist/quick-filters/events/details.d.ts +10 -0
- package/dist/quick-filters/events/details.js +1 -0
- package/dist/quick-filters/events/index.d.ts +16 -0
- package/dist/quick-filters/events/index.js +9 -0
- package/dist/quick-filters/events/view-save.d.ts +11 -0
- package/dist/quick-filters/events/view-save.js +11 -0
- package/dist/quick-filters/filter/quick-filter.d.ts +48 -0
- package/dist/quick-filters/filter/quick-filter.js +33 -0
- package/dist/quick-filters/index.d.ts +3 -0
- package/dist/quick-filters/index.js +3 -0
- package/dist/quick-filters/root/quick-filters-root.d.ts +118 -0
- package/dist/quick-filters/root/quick-filters-root.js +183 -0
- package/dist/selection-bar/index.d.ts +1 -0
- package/dist/selection-bar/index.js +1 -0
- package/dist/selection-bar/root/selection-bar-root.d.ts +65 -0
- package/dist/selection-bar/root/selection-bar-root.js +44 -0
- package/dist/table/column/table-column.d.ts +82 -0
- package/dist/table/column/table-column.js +54 -0
- package/dist/table/column-type.d.ts +7 -0
- package/dist/table/column-type.js +1 -0
- package/dist/table-export/index.d.ts +1 -0
- package/dist/table-export/index.js +1 -0
- package/dist/table-export/root/table-export-root.d.ts +132 -0
- package/dist/table-export/root/table-export-root.js +233 -0
- package/dist/view-panel/index.d.ts +1 -0
- package/dist/view-panel/index.js +1 -0
- package/dist/view-panel/root/view-panel-root.d.ts +132 -0
- package/dist/view-panel/root/view-panel-root.js +209 -0
- package/examples.json +1 -1
- package/lint.json +1 -1
- package/package.json +5 -5
- package/types/jsx.d.ts +1353 -10
- package/types/svelte.d.ts +6 -0
- package/types/vue.d.ts +651 -6
- package/types/words.d.ts +325 -5
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { customElement, formatWords, HelixElement, ToolbarController, words, } from '@fusion.dev/helix-core';
|
|
3
|
+
import { html, nothing } from 'lit';
|
|
4
|
+
import { property, state } from 'lit/decorators.js';
|
|
5
|
+
import { TableBinding } from '../../data-table/binding.js';
|
|
6
|
+
import { holdsView, readView } from '../../data-table/view.js';
|
|
7
|
+
import { HelixBeforeViewSaveEvent, HelixViewSaveEvent } from '../events/index.js';
|
|
8
|
+
const storage = () => {
|
|
9
|
+
try {
|
|
10
|
+
return globalThis.localStorage;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
let HelixHeadlessQuickFilters = class HelixHeadlessQuickFilters extends HelixElement {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.fallbackLabel = 'Quick filters';
|
|
20
|
+
this.for = '';
|
|
21
|
+
this.label = '';
|
|
22
|
+
this.removeLabel = 'Remove {name}';
|
|
23
|
+
this.savedLabel = 'View {count}';
|
|
24
|
+
this.saveLabel = 'Save view';
|
|
25
|
+
this.viewKey = '';
|
|
26
|
+
this.saved = [];
|
|
27
|
+
this.binding = new TableBinding(this);
|
|
28
|
+
this.keys = new ToolbarController(this, {
|
|
29
|
+
arrows: () => 'horizontal',
|
|
30
|
+
members: () => [
|
|
31
|
+
...(this.renderRoot.querySelectorAll?.('[part~="preset"], [part="save"]') ?? []),
|
|
32
|
+
],
|
|
33
|
+
own: true,
|
|
34
|
+
watch: () => this.renderRoot,
|
|
35
|
+
words: (button) => button.textContent?.trim() ?? '',
|
|
36
|
+
});
|
|
37
|
+
this.handleSlotChange = () => {
|
|
38
|
+
this.requestUpdate();
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
static { this.words = 'helix-quick-filters'; }
|
|
42
|
+
get table() {
|
|
43
|
+
return this.binding.table;
|
|
44
|
+
}
|
|
45
|
+
get presets() {
|
|
46
|
+
const written = this.knownChildren
|
|
47
|
+
.filter((child) => child.isQuickFilter === true)
|
|
48
|
+
.map((child) => ({
|
|
49
|
+
count: child.count,
|
|
50
|
+
label: child.textContent?.trim() ?? '',
|
|
51
|
+
saved: false,
|
|
52
|
+
view: child.parts,
|
|
53
|
+
}));
|
|
54
|
+
return [...written, ...this.saved.map((one) => ({ ...one, saved: true }))];
|
|
55
|
+
}
|
|
56
|
+
get storageName() {
|
|
57
|
+
return `helix-views:${this.viewKey}`;
|
|
58
|
+
}
|
|
59
|
+
readSaved() {
|
|
60
|
+
if (!this.viewKey) {
|
|
61
|
+
this.saved = [];
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const kept = JSON.parse(storage()?.getItem(this.storageName) ?? '[]');
|
|
66
|
+
this.saved = Array.isArray(kept)
|
|
67
|
+
? kept.flatMap((one) => one && typeof one.label === 'string'
|
|
68
|
+
? [{ label: one.label, view: readView(one.view) }]
|
|
69
|
+
: [])
|
|
70
|
+
: [];
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
this.saved = [];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
writeSaved() {
|
|
77
|
+
try {
|
|
78
|
+
storage()?.setItem(this.storageName, JSON.stringify(this.saved));
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
choose(view) {
|
|
84
|
+
return this.table?.requestView(view) ?? false;
|
|
85
|
+
}
|
|
86
|
+
saveView(label = formatWords(this, 'savedLabel', { count: this.saved.length + 1 })) {
|
|
87
|
+
const table = this.table;
|
|
88
|
+
if (!table) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
const view = table.view;
|
|
92
|
+
const detail = { label, value: JSON.stringify(view), view };
|
|
93
|
+
if (!this.dispatchEvent(new HelixBeforeViewSaveEvent(detail))) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
if (this.viewKey) {
|
|
97
|
+
this.saved = [...this.saved, { label, view }];
|
|
98
|
+
this.writeSaved();
|
|
99
|
+
}
|
|
100
|
+
this.dispatchEvent(new HelixViewSaveEvent(detail));
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
removeSaved(index) {
|
|
104
|
+
this.saved = this.saved.filter((_, at) => at !== index);
|
|
105
|
+
this.writeSaved();
|
|
106
|
+
}
|
|
107
|
+
willUpdate(changed) {
|
|
108
|
+
super.willUpdate(changed);
|
|
109
|
+
if (changed.has('viewKey') && typeof window !== 'undefined') {
|
|
110
|
+
this.readSaved();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
firstUpdated(changed) {
|
|
114
|
+
super.firstUpdated(changed);
|
|
115
|
+
this.finishHydration();
|
|
116
|
+
}
|
|
117
|
+
renderPreset(table, preset, savedAt) {
|
|
118
|
+
const pressed = table ? holdsView(table.view, preset.view) : false;
|
|
119
|
+
const count = preset.count ?? table?.countView(preset.view);
|
|
120
|
+
return html `<button
|
|
121
|
+
part="preset${pressed ? ' preset-pressed' : ''}${preset.saved ? ' preset-saved' : ''}"
|
|
122
|
+
type="button"
|
|
123
|
+
aria-pressed=${pressed ? 'true' : 'false'}
|
|
124
|
+
@click=${() => this.choose(preset.view)}
|
|
125
|
+
><span part="name">${preset.label}</span>${count === undefined ? nothing : html ` <span part="count">${count}</span>`}</button
|
|
126
|
+
>${preset.saved
|
|
127
|
+
? html `<button
|
|
128
|
+
part="remove"
|
|
129
|
+
type="button"
|
|
130
|
+
tabindex="-1"
|
|
131
|
+
aria-label=${formatWords(this, 'removeLabel', { name: preset.label })}
|
|
132
|
+
@click=${() => this.removeSaved(savedAt)}
|
|
133
|
+
>×</button>`
|
|
134
|
+
: nothing}`;
|
|
135
|
+
}
|
|
136
|
+
render() {
|
|
137
|
+
const table = this.table;
|
|
138
|
+
let savedAt = -1;
|
|
139
|
+
return html `<div part="list" role="toolbar" aria-label=${this.label || this.fallbackLabel}>
|
|
140
|
+
${this.presets.map((preset) => {
|
|
141
|
+
if (preset.saved) {
|
|
142
|
+
savedAt += 1;
|
|
143
|
+
}
|
|
144
|
+
return this.renderPreset(table, preset, savedAt);
|
|
145
|
+
})}${this.saveLabel
|
|
146
|
+
? html `<button part="save" type="button" @click=${() => this.saveView()}>${this.saveLabel}</button>`
|
|
147
|
+
: nothing}
|
|
148
|
+
</div>
|
|
149
|
+
<slot @slotchange=${this.handleSlotChange} hidden></slot>`;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
__decorate([
|
|
153
|
+
words,
|
|
154
|
+
property({ attribute: 'fallback-label' })
|
|
155
|
+
], HelixHeadlessQuickFilters.prototype, "fallbackLabel", void 0);
|
|
156
|
+
__decorate([
|
|
157
|
+
property()
|
|
158
|
+
], HelixHeadlessQuickFilters.prototype, "for", void 0);
|
|
159
|
+
__decorate([
|
|
160
|
+
property()
|
|
161
|
+
], HelixHeadlessQuickFilters.prototype, "label", void 0);
|
|
162
|
+
__decorate([
|
|
163
|
+
words,
|
|
164
|
+
property({ attribute: 'remove-label' })
|
|
165
|
+
], HelixHeadlessQuickFilters.prototype, "removeLabel", void 0);
|
|
166
|
+
__decorate([
|
|
167
|
+
words,
|
|
168
|
+
property({ attribute: 'saved-label' })
|
|
169
|
+
], HelixHeadlessQuickFilters.prototype, "savedLabel", void 0);
|
|
170
|
+
__decorate([
|
|
171
|
+
words,
|
|
172
|
+
property({ attribute: 'save-label' })
|
|
173
|
+
], HelixHeadlessQuickFilters.prototype, "saveLabel", void 0);
|
|
174
|
+
__decorate([
|
|
175
|
+
property({ attribute: 'view-key' })
|
|
176
|
+
], HelixHeadlessQuickFilters.prototype, "viewKey", void 0);
|
|
177
|
+
__decorate([
|
|
178
|
+
state()
|
|
179
|
+
], HelixHeadlessQuickFilters.prototype, "saved", void 0);
|
|
180
|
+
HelixHeadlessQuickFilters = __decorate([
|
|
181
|
+
customElement('helix-headless-quick-filters')
|
|
182
|
+
], HelixHeadlessQuickFilters);
|
|
183
|
+
export { HelixHeadlessQuickFilters };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './root/selection-bar-root.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './root/selection-bar-root.js';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { HelixElement } from '@fusion.dev/helix-core';
|
|
2
|
+
import { type TemplateResult } from 'lit';
|
|
3
|
+
import { TableBinding, type ToolTable } from '../../data-table/binding.js';
|
|
4
|
+
/**
|
|
5
|
+
* @summary A bar that says how many of a Data Table's rows are selected, with what you can do to them and a way to clear them.
|
|
6
|
+
*
|
|
7
|
+
* @description
|
|
8
|
+
* Put it in a `DataTable`'s `selection` slot, and it takes the toolbar's
|
|
9
|
+
* place while rows are selected. Slot your actions into it, such as Archive
|
|
10
|
+
* and Export, and Clear unselects every row.
|
|
11
|
+
*
|
|
12
|
+
* ```html
|
|
13
|
+
* <helix-data-table selectable row-key="id">
|
|
14
|
+
* <helix-selection-bar slot="selection">
|
|
15
|
+
* <helix-button>Archive</helix-button>
|
|
16
|
+
* </helix-selection-bar>
|
|
17
|
+
* </helix-data-table>
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Written inside the table, it finds the table. Written anywhere else, set
|
|
21
|
+
* `for` to the table's id. Clear asks the table with `helix-before-select`,
|
|
22
|
+
* as a reader's own choice does.
|
|
23
|
+
*
|
|
24
|
+
* @since 0.238.0
|
|
25
|
+
* @status experimental
|
|
26
|
+
* @category data
|
|
27
|
+
* @aliases Bulk actions, Action bar
|
|
28
|
+
* @documentation https://fusion.dev/helix/components/selection-bar
|
|
29
|
+
*
|
|
30
|
+
* @slot - What you can do to the selected rows, such as buttons.
|
|
31
|
+
*
|
|
32
|
+
* @csspart actions - The region that holds the slotted actions.
|
|
33
|
+
* @csspart clear - The button that clears the selection.
|
|
34
|
+
* @csspart count - Says how many rows are selected.
|
|
35
|
+
*/
|
|
36
|
+
export declare class HelixHeadlessSelectionBar extends HelixElement {
|
|
37
|
+
/**
|
|
38
|
+
* The key this family's words are registered under, its styled tag:
|
|
39
|
+
* `registerWords('de', { 'helix-selection-bar': { clearLabel: 'Auswahl aufheben' } })`.
|
|
40
|
+
*/
|
|
41
|
+
static words: string;
|
|
42
|
+
/** The words on the button that clears the selection. */
|
|
43
|
+
clearLabel: string;
|
|
44
|
+
/** What the bar says. `{count}` is how many rows are selected. */
|
|
45
|
+
countLabel: string;
|
|
46
|
+
/**
|
|
47
|
+
* The id of the `DataTable` whose selection the bar shows, in the same
|
|
48
|
+
* document or shadow root. Left empty, the bar takes the table it is written
|
|
49
|
+
* in.
|
|
50
|
+
*/
|
|
51
|
+
for: string;
|
|
52
|
+
protected readonly binding: TableBinding;
|
|
53
|
+
/** The bound table, once it is in the tree. */
|
|
54
|
+
get table(): ToolTable | null;
|
|
55
|
+
/** How many rows are selected. */
|
|
56
|
+
get count(): number;
|
|
57
|
+
/** Unselects every row, as Clear does. Returns whether the selection changed. */
|
|
58
|
+
clear(): boolean;
|
|
59
|
+
protected render(): TemplateResult;
|
|
60
|
+
}
|
|
61
|
+
declare global {
|
|
62
|
+
interface HTMLElementTagNameMap {
|
|
63
|
+
'helix-headless-selection-bar': HelixHeadlessSelectionBar;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { customElement, formatWords, HelixElement, words } from '@fusion.dev/helix-core';
|
|
3
|
+
import { html } from 'lit';
|
|
4
|
+
import { property } from 'lit/decorators.js';
|
|
5
|
+
import { TableBinding } from '../../data-table/binding.js';
|
|
6
|
+
let HelixHeadlessSelectionBar = class HelixHeadlessSelectionBar extends HelixElement {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.clearLabel = 'Clear';
|
|
10
|
+
this.countLabel = '{count} selected';
|
|
11
|
+
this.for = '';
|
|
12
|
+
this.binding = new TableBinding(this);
|
|
13
|
+
}
|
|
14
|
+
static { this.words = 'helix-selection-bar'; }
|
|
15
|
+
get table() {
|
|
16
|
+
return this.binding.table;
|
|
17
|
+
}
|
|
18
|
+
get count() {
|
|
19
|
+
return this.table?.selected.split(',').filter(Boolean).length ?? 0;
|
|
20
|
+
}
|
|
21
|
+
clear() {
|
|
22
|
+
return this.table?.selectRows([]) ?? false;
|
|
23
|
+
}
|
|
24
|
+
render() {
|
|
25
|
+
return html `<span part="count">${formatWords(this, 'countLabel', { count: this.count })}</span>
|
|
26
|
+
<div part="actions"><slot></slot></div>
|
|
27
|
+
<button part="clear" type="button" @click=${() => this.clear()}>${this.clearLabel}</button>`;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
__decorate([
|
|
31
|
+
words,
|
|
32
|
+
property({ attribute: 'clear-label' })
|
|
33
|
+
], HelixHeadlessSelectionBar.prototype, "clearLabel", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
words,
|
|
36
|
+
property({ attribute: 'count-label' })
|
|
37
|
+
], HelixHeadlessSelectionBar.prototype, "countLabel", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
property()
|
|
40
|
+
], HelixHeadlessSelectionBar.prototype, "for", void 0);
|
|
41
|
+
HelixHeadlessSelectionBar = __decorate([
|
|
42
|
+
customElement('helix-headless-selection-bar')
|
|
43
|
+
], HelixHeadlessSelectionBar);
|
|
44
|
+
export { HelixHeadlessSelectionBar };
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { HelixElement } from '@fusion.dev/helix-core';
|
|
2
2
|
import { type PropertyValues, type TemplateResult } from 'lit';
|
|
3
|
+
import type { ColumnType } from '../column-type.js';
|
|
4
|
+
/** What a column's `editor` is given to draw a field for an edited cell. */
|
|
5
|
+
export interface CellEditorContext {
|
|
6
|
+
/** Puts the old value back and closes the cell. */
|
|
7
|
+
cancel: () => void;
|
|
8
|
+
/** Saves a new value, as Enter does on the table's own field. */
|
|
9
|
+
commit: (value: unknown) => void;
|
|
10
|
+
/** The row. */
|
|
11
|
+
row: Readonly<Record<string, unknown>>;
|
|
12
|
+
/** The value the cell holds now. */
|
|
13
|
+
value: unknown;
|
|
14
|
+
}
|
|
15
|
+
/** Draws the field for an edited cell: anything a Lit template can render. */
|
|
16
|
+
export type CellEditor = (context: CellEditorContext) => unknown;
|
|
3
17
|
/**
|
|
4
18
|
* How a column is read out of a row, once the row is data rather than markup.
|
|
5
19
|
*
|
|
@@ -86,7 +100,11 @@ export { edgeOf } from '../edge.js';
|
|
|
86
100
|
* @csspart sort-mark - The two chevrons on a sortable heading. To remove them, set `display: none` on this part.
|
|
87
101
|
* @csspart sort-up - The upper chevron of `sort-mark`, which shows an ascending sort.
|
|
88
102
|
*
|
|
103
|
+
* @cssproperty --table-column-pin-offset - How far a pinned column's heading stays from its end of the row, in pixels: the width of the pinned columns before it. The column writes it on `column` while a `DataTable` pins it.
|
|
104
|
+
*
|
|
89
105
|
* @cssstate has-menu - While the heading draws its menu button.
|
|
106
|
+
* @cssstate pinned-end - While a `DataTable` pins the column to the end of the row.
|
|
107
|
+
* @cssstate pinned-start - While a `DataTable` pins the column to the start of the row.
|
|
90
108
|
* @cssstate sorted-ascending - While the table is sorted by this column, smallest first.
|
|
91
109
|
* @cssstate sorted-descending - While the table is sorted by this column, largest first.
|
|
92
110
|
*/
|
|
@@ -117,6 +135,26 @@ export declare class HelixHeadlessTableColumn extends HelixElement {
|
|
|
117
135
|
* correct default: the raw value is what an API sorted by.
|
|
118
136
|
*/
|
|
119
137
|
compare: CellReader | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* Lets a reader edit the column's cells, in a `DataTable`.
|
|
140
|
+
*
|
|
141
|
+
* Enter, F2, a double click, or typing opens a cell in the field the
|
|
142
|
+
* column's `type` picks: a text field, a number field, a date field, or a
|
|
143
|
+
* select of an enum column's values. A boolean toggles in place. Enter saves
|
|
144
|
+
* and moves down, Tab saves and moves to the next cell, leaving the cell
|
|
145
|
+
* saves, and Escape puts the old value back. `required`, `min`, `max`,
|
|
146
|
+
* `pattern` and `validate` check the value first. Set `rowEditable` to
|
|
147
|
+
* decide row by row.
|
|
148
|
+
*/
|
|
149
|
+
editable: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* A function that draws your own field for an edited cell, in place of the
|
|
152
|
+
* one the column's `type` picks. It is given the row, the value, and
|
|
153
|
+
* `commit` and `cancel`: call `commit` with the new value to save it, and
|
|
154
|
+
* `cancel` to put the old one back. Enter, Tab and Escape on your field
|
|
155
|
+
* work as they do on the table's own.
|
|
156
|
+
*/
|
|
157
|
+
editor: CellEditor | undefined;
|
|
120
158
|
/**
|
|
121
159
|
* The key this column reads out of a row.
|
|
122
160
|
*
|
|
@@ -133,6 +171,14 @@ export declare class HelixHeadlessTableColumn extends HelixElement {
|
|
|
133
171
|
* such a column is never sortable however it is marked.
|
|
134
172
|
*/
|
|
135
173
|
field: string;
|
|
174
|
+
/**
|
|
175
|
+
* Offers the column as a filter, in a `DataTable` bound to a `FilterInput`.
|
|
176
|
+
* The field lists the column with the comparisons its `type` offers, and an
|
|
177
|
+
* enum column lists its values with how many rows hold each.
|
|
178
|
+
*/
|
|
179
|
+
filterable: boolean;
|
|
180
|
+
/** The largest value an edited cell may hold: a number, or a date as `YYYY-MM-DD`. */
|
|
181
|
+
max: string;
|
|
136
182
|
/**
|
|
137
183
|
* Draws a button in the heading that opens a menu of what you can do with the
|
|
138
184
|
* column, in a `DataTable`.
|
|
@@ -147,6 +193,8 @@ export declare class HelixHeadlessTableColumn extends HelixElement {
|
|
|
147
193
|
* `{named}` is `no` for a column without one.
|
|
148
194
|
*/
|
|
149
195
|
menuLabel: string;
|
|
196
|
+
/** The smallest value an edited cell may hold: a number, or a date as `YYYY-MM-DD`. */
|
|
197
|
+
min: string;
|
|
150
198
|
/**
|
|
151
199
|
* The narrowest a `DataTable` can be with this column showing, as a length
|
|
152
200
|
* in `px`, `rem` or `em`, such as `40rem`. While the table is narrower, it
|
|
@@ -175,6 +223,10 @@ export declare class HelixHeadlessTableColumn extends HelixElement {
|
|
|
175
223
|
* language hears its own rather than English around its own headings.
|
|
176
224
|
*/
|
|
177
225
|
moveLabel: string;
|
|
226
|
+
/** A pattern an edited text cell matches whole, as an input's `pattern` is matched. */
|
|
227
|
+
pattern: string;
|
|
228
|
+
/** Whether an edited cell may be left empty. */
|
|
229
|
+
required: boolean;
|
|
178
230
|
/**
|
|
179
231
|
* Whether the column can be resized.
|
|
180
232
|
*
|
|
@@ -189,6 +241,12 @@ export declare class HelixHeadlessTableColumn extends HelixElement {
|
|
|
189
241
|
* the heading text, and `{named}` is `no` for a column without one.
|
|
190
242
|
*/
|
|
191
243
|
resizeLabel: string;
|
|
244
|
+
/**
|
|
245
|
+
* A function that decides whether a row's cell in this column can be
|
|
246
|
+
* edited, for a column that is `editable`. Given the row, it returns `true`
|
|
247
|
+
* or `false`. A property only, being a function.
|
|
248
|
+
*/
|
|
249
|
+
rowEditable: ((row: Readonly<Record<string, unknown>>) => boolean) | undefined;
|
|
192
250
|
/**
|
|
193
251
|
* Makes this column's cells the headers of their rows, in `DataTable`.
|
|
194
252
|
*
|
|
@@ -199,6 +257,12 @@ export declare class HelixHeadlessTableColumn extends HelixElement {
|
|
|
199
257
|
* a cell is a row header through its own `header` attribute.
|
|
200
258
|
*/
|
|
201
259
|
rowHeader: boolean;
|
|
260
|
+
/**
|
|
261
|
+
* Searches the column's values, in a `DataTable`. While no column sets it,
|
|
262
|
+
* the search reads every column with a `field`. Once one does, it reads only
|
|
263
|
+
* the columns that set it, so a search for a name does not match an id.
|
|
264
|
+
*/
|
|
265
|
+
searchable: boolean;
|
|
202
266
|
/**
|
|
203
267
|
* Whether the table can be sorted by this column.
|
|
204
268
|
*
|
|
@@ -244,6 +308,24 @@ export declare class HelixHeadlessTableColumn extends HelixElement {
|
|
|
244
308
|
* state instead. No default, so an unset column writes nothing onto its host.
|
|
245
309
|
*/
|
|
246
310
|
textAlign?: 'center' | 'end' | 'start';
|
|
311
|
+
/**
|
|
312
|
+
* What the column holds: `text`, `number`, `date`, `enum` or `boolean`.
|
|
313
|
+
*
|
|
314
|
+
* In a `DataTable` the type picks the comparisons the column's filter
|
|
315
|
+
* offers. Text is contains, is, is not and is empty. Numbers compare as
|
|
316
|
+
* numbers, with between. Dates compare by the day, with before, after and
|
|
317
|
+
* between. An enum is any of or none of its values, and the table counts how
|
|
318
|
+
* many rows hold each value. A boolean is yes or no. Left unset, the column
|
|
319
|
+
* holds text.
|
|
320
|
+
*/
|
|
321
|
+
type?: ColumnType;
|
|
322
|
+
/**
|
|
323
|
+
* A function that checks an edited cell's value, after `required`, `min`,
|
|
324
|
+
* `max` and `pattern`. Given the value and the row, it returns a message to
|
|
325
|
+
* refuse the value with, or nothing to accept it, or a promise of either. A
|
|
326
|
+
* property only, being a function.
|
|
327
|
+
*/
|
|
328
|
+
validate: ((value: unknown, row: Readonly<Record<string, unknown>>) => string | undefined | PromiseLike<string | undefined>) | undefined;
|
|
247
329
|
/**
|
|
248
330
|
* Where the content of this column's cells sits from top to bottom, when a
|
|
249
331
|
* row is taller than it: `start`, `center` or `end`.
|
|
@@ -11,20 +11,32 @@ let HelixHeadlessTableColumn = class HelixHeadlessTableColumn extends HelixEleme
|
|
|
11
11
|
super(...arguments);
|
|
12
12
|
this.cell = undefined;
|
|
13
13
|
this.compare = undefined;
|
|
14
|
+
this.editable = false;
|
|
15
|
+
this.editor = undefined;
|
|
14
16
|
this.field = '';
|
|
17
|
+
this.filterable = false;
|
|
18
|
+
this.max = '';
|
|
15
19
|
this.menu = false;
|
|
16
20
|
this.menuLabel = '{named, select, no {Column menu} other {{name} column menu}}';
|
|
21
|
+
this.min = '';
|
|
17
22
|
this.minTableWidth = '';
|
|
18
23
|
this.moveLabel = '{named, select, no {Move column} other {Move {name}}}';
|
|
24
|
+
this.pattern = '';
|
|
25
|
+
this.required = false;
|
|
19
26
|
this.resizable = false;
|
|
20
27
|
this.resizeLabel = '{named, select, no {Resize column} other {Resize {name}}}';
|
|
28
|
+
this.rowEditable = undefined;
|
|
21
29
|
this.rowHeader = false;
|
|
30
|
+
this.searchable = false;
|
|
22
31
|
this.sortable = false;
|
|
32
|
+
this.validate = undefined;
|
|
23
33
|
this.width = '';
|
|
24
34
|
this.widthLabel = '{width, plural, one {# pixel} other {# pixels}}';
|
|
25
35
|
this.isTableColumn = true;
|
|
26
36
|
this.sorted = undefined;
|
|
27
37
|
this.movable = false;
|
|
38
|
+
this.pinned = undefined;
|
|
39
|
+
this.pinOffset = 0;
|
|
28
40
|
this.gridCell = false;
|
|
29
41
|
this.tabStop = false;
|
|
30
42
|
this.sortWords = '';
|
|
@@ -99,6 +111,8 @@ let HelixHeadlessTableColumn = class HelixHeadlessTableColumn extends HelixEleme
|
|
|
99
111
|
this.toggleState('has-menu', this.drawsMenu);
|
|
100
112
|
this.toggleState('sorted-ascending', this.sorted === 'ascending');
|
|
101
113
|
this.toggleState('sorted-descending', this.sorted === 'descending');
|
|
114
|
+
this.toggleState('pinned-start', this.pinned === 'start');
|
|
115
|
+
this.toggleState('pinned-end', this.pinned === 'end');
|
|
102
116
|
}
|
|
103
117
|
get cellBox() {
|
|
104
118
|
return this.partNamed('column');
|
|
@@ -190,6 +204,7 @@ let HelixHeadlessTableColumn = class HelixHeadlessTableColumn extends HelixEleme
|
|
|
190
204
|
const hasMenu = this.drawsMenu;
|
|
191
205
|
return html `<span
|
|
192
206
|
part="column"
|
|
207
|
+
style=${this.pinned ? `--table-column-pin-offset: ${this.pinOffset}px` : nothing}
|
|
193
208
|
role=${grid ? 'columnheader' : nothing}
|
|
194
209
|
tabindex=${grid ? (this.tabStop ? '0' : '-1') : nothing}
|
|
195
210
|
aria-sort=${grid && this.canSort ? (this.sorted ?? 'none') : nothing}
|
|
@@ -243,9 +258,21 @@ __decorate([
|
|
|
243
258
|
__decorate([
|
|
244
259
|
property({ attribute: false })
|
|
245
260
|
], HelixHeadlessTableColumn.prototype, "compare", void 0);
|
|
261
|
+
__decorate([
|
|
262
|
+
property({ type: Boolean })
|
|
263
|
+
], HelixHeadlessTableColumn.prototype, "editable", void 0);
|
|
264
|
+
__decorate([
|
|
265
|
+
property({ attribute: false })
|
|
266
|
+
], HelixHeadlessTableColumn.prototype, "editor", void 0);
|
|
246
267
|
__decorate([
|
|
247
268
|
property()
|
|
248
269
|
], HelixHeadlessTableColumn.prototype, "field", void 0);
|
|
270
|
+
__decorate([
|
|
271
|
+
property({ type: Boolean })
|
|
272
|
+
], HelixHeadlessTableColumn.prototype, "filterable", void 0);
|
|
273
|
+
__decorate([
|
|
274
|
+
property()
|
|
275
|
+
], HelixHeadlessTableColumn.prototype, "max", void 0);
|
|
249
276
|
__decorate([
|
|
250
277
|
property({ type: Boolean })
|
|
251
278
|
], HelixHeadlessTableColumn.prototype, "menu", void 0);
|
|
@@ -253,6 +280,9 @@ __decorate([
|
|
|
253
280
|
words,
|
|
254
281
|
property({ attribute: 'menu-label' })
|
|
255
282
|
], HelixHeadlessTableColumn.prototype, "menuLabel", void 0);
|
|
283
|
+
__decorate([
|
|
284
|
+
property()
|
|
285
|
+
], HelixHeadlessTableColumn.prototype, "min", void 0);
|
|
256
286
|
__decorate([
|
|
257
287
|
property({ attribute: 'min-table-width' })
|
|
258
288
|
], HelixHeadlessTableColumn.prototype, "minTableWidth", void 0);
|
|
@@ -260,6 +290,12 @@ __decorate([
|
|
|
260
290
|
words,
|
|
261
291
|
property({ attribute: 'move-label' })
|
|
262
292
|
], HelixHeadlessTableColumn.prototype, "moveLabel", void 0);
|
|
293
|
+
__decorate([
|
|
294
|
+
property()
|
|
295
|
+
], HelixHeadlessTableColumn.prototype, "pattern", void 0);
|
|
296
|
+
__decorate([
|
|
297
|
+
property({ type: Boolean })
|
|
298
|
+
], HelixHeadlessTableColumn.prototype, "required", void 0);
|
|
263
299
|
__decorate([
|
|
264
300
|
property({ type: Boolean })
|
|
265
301
|
], HelixHeadlessTableColumn.prototype, "resizable", void 0);
|
|
@@ -267,15 +303,27 @@ __decorate([
|
|
|
267
303
|
words,
|
|
268
304
|
property({ attribute: 'resize-label' })
|
|
269
305
|
], HelixHeadlessTableColumn.prototype, "resizeLabel", void 0);
|
|
306
|
+
__decorate([
|
|
307
|
+
property({ attribute: false })
|
|
308
|
+
], HelixHeadlessTableColumn.prototype, "rowEditable", void 0);
|
|
270
309
|
__decorate([
|
|
271
310
|
property({ attribute: 'row-header', type: Boolean })
|
|
272
311
|
], HelixHeadlessTableColumn.prototype, "rowHeader", void 0);
|
|
312
|
+
__decorate([
|
|
313
|
+
property({ type: Boolean })
|
|
314
|
+
], HelixHeadlessTableColumn.prototype, "searchable", void 0);
|
|
273
315
|
__decorate([
|
|
274
316
|
property({ reflect: true, type: Boolean })
|
|
275
317
|
], HelixHeadlessTableColumn.prototype, "sortable", void 0);
|
|
276
318
|
__decorate([
|
|
277
319
|
property({ attribute: 'text-align', reflect: true })
|
|
278
320
|
], HelixHeadlessTableColumn.prototype, "textAlign", void 0);
|
|
321
|
+
__decorate([
|
|
322
|
+
property()
|
|
323
|
+
], HelixHeadlessTableColumn.prototype, "type", void 0);
|
|
324
|
+
__decorate([
|
|
325
|
+
property({ attribute: false })
|
|
326
|
+
], HelixHeadlessTableColumn.prototype, "validate", void 0);
|
|
279
327
|
__decorate([
|
|
280
328
|
property({ attribute: 'vertical-align', reflect: true })
|
|
281
329
|
], HelixHeadlessTableColumn.prototype, "verticalAlign", void 0);
|
|
@@ -292,6 +340,12 @@ __decorate([
|
|
|
292
340
|
__decorate([
|
|
293
341
|
state()
|
|
294
342
|
], HelixHeadlessTableColumn.prototype, "movable", void 0);
|
|
343
|
+
__decorate([
|
|
344
|
+
state()
|
|
345
|
+
], HelixHeadlessTableColumn.prototype, "pinned", void 0);
|
|
346
|
+
__decorate([
|
|
347
|
+
state()
|
|
348
|
+
], HelixHeadlessTableColumn.prototype, "pinOffset", void 0);
|
|
295
349
|
__decorate([
|
|
296
350
|
state()
|
|
297
351
|
], HelixHeadlessTableColumn.prototype, "gridCell", void 0);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a column holds, shared by the Table family and the families that read
|
|
3
|
+
* its columns. A module that registers nothing, so a reader of the type does
|
|
4
|
+
* not register the column.
|
|
5
|
+
*/
|
|
6
|
+
/** What a column holds, which picks the comparisons its filter offers and the field an edit opens. */
|
|
7
|
+
export type ColumnType = 'boolean' | 'date' | 'enum' | 'number' | 'text';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './root/table-export-root.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './root/table-export-root.js';
|