@universal-material/data-grid 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +155 -2
- package/custom-elements.json +4624 -0
- package/dist/attribute-converters.d.ts +53 -0
- package/dist/attribute-converters.js +98 -0
- package/dist/attribute-converters.js.map +1 -0
- package/dist/change-source.d.ts +3 -0
- package/dist/change-source.js +2 -0
- package/dist/change-source.js.map +1 -0
- package/dist/data/data-source.d.ts +164 -0
- package/dist/data/data-source.js +75 -0
- package/dist/data/data-source.js.map +1 -0
- package/dist/data/local-source.d.ts +20 -0
- package/dist/data/local-source.js +94 -0
- package/dist/data/local-source.js.map +1 -0
- package/dist/data/remote-loader.d.ts +190 -0
- package/dist/data/remote-loader.js +608 -0
- package/dist/data/remote-loader.js.map +1 -0
- package/dist/export/csv.d.ts +28 -0
- package/dist/export/csv.js +61 -0
- package/dist/export/csv.js.map +1 -0
- package/dist/export/download.d.ts +7 -0
- package/dist/export/download.js +17 -0
- package/dist/export/download.js.map +1 -0
- package/dist/export/rows.d.ts +75 -0
- package/dist/export/rows.js +134 -0
- package/dist/export/rows.js.map +1 -0
- package/dist/export/slice.d.ts +15 -0
- package/dist/export/slice.js +35 -0
- package/dist/export/slice.js.map +1 -0
- package/dist/export/types.d.ts +155 -0
- package/dist/export/types.js +2 -0
- package/dist/export/types.js.map +1 -0
- package/dist/export/write.d.ts +38 -0
- package/dist/export/write.js +178 -0
- package/dist/export/write.js.map +1 -0
- package/dist/export-pdf/client.d.ts +75 -0
- package/dist/export-pdf/client.js +155 -0
- package/dist/export-pdf/client.js.map +1 -0
- package/dist/export-pdf/engine.d.ts +73 -0
- package/dist/export-pdf/engine.js +131 -0
- package/dist/export-pdf/engine.js.map +1 -0
- package/dist/export-pdf/grid-pdf.wasm +0 -0
- package/dist/export-pdf/index.d.ts +27 -0
- package/dist/export-pdf/index.js +566 -0
- package/dist/export-pdf/index.js.map +1 -0
- package/dist/export-pdf/serialize.d.ts +23 -0
- package/dist/export-pdf/serialize.js +127 -0
- package/dist/export-pdf/serialize.js.map +1 -0
- package/dist/export-pdf/types.d.ts +150 -0
- package/dist/export-pdf/types.js +2 -0
- package/dist/export-pdf/types.js.map +1 -0
- package/dist/export-pdf/worker.d.ts +2 -0
- package/dist/export-pdf/worker.js +81 -0
- package/dist/export-pdf/worker.js.map +1 -0
- package/dist/export-xlsx/formats.d.ts +14 -0
- package/dist/export-xlsx/formats.js +40 -0
- package/dist/export-xlsx/formats.js.map +1 -0
- package/dist/export-xlsx/index.d.ts +74 -0
- package/dist/export-xlsx/index.js +137 -0
- package/dist/export-xlsx/index.js.map +1 -0
- package/dist/features/adaptive.d.ts +25 -0
- package/dist/features/adaptive.js +47 -0
- package/dist/features/adaptive.js.map +1 -0
- package/dist/features/cell-content-focus.d.ts +29 -0
- package/dist/features/cell-content-focus.js +95 -0
- package/dist/features/cell-content-focus.js.map +1 -0
- package/dist/features/cell-range.d.ts +97 -0
- package/dist/features/cell-range.js +75 -0
- package/dist/features/cell-range.js.map +1 -0
- package/dist/features/clipboard.d.ts +28 -0
- package/dist/features/clipboard.js +48 -0
- package/dist/features/clipboard.js.map +1 -0
- package/dist/features/column-chooser.d.ts +91 -0
- package/dist/features/column-chooser.js +450 -0
- package/dist/features/column-chooser.js.map +1 -0
- package/dist/features/column-dnd.d.ts +10 -0
- package/dist/features/column-dnd.js +126 -0
- package/dist/features/column-dnd.js.map +1 -0
- package/dist/features/context-menu.d.ts +122 -0
- package/dist/features/context-menu.js +153 -0
- package/dist/features/context-menu.js.map +1 -0
- package/dist/features/drag-helper.d.ts +39 -0
- package/dist/features/drag-helper.js +108 -0
- package/dist/features/drag-helper.js.map +1 -0
- package/dist/features/drop-position.d.ts +15 -0
- package/dist/features/drop-position.js +24 -0
- package/dist/features/drop-position.js.map +1 -0
- package/dist/features/editing.d.ts +111 -0
- package/dist/features/editing.js +244 -0
- package/dist/features/editing.js.map +1 -0
- package/dist/features/filter-row.d.ts +80 -0
- package/dist/features/filter-row.js +537 -0
- package/dist/features/filter-row.js.map +1 -0
- package/dist/features/filtering.d.ts +55 -0
- package/dist/features/filtering.js +209 -0
- package/dist/features/filtering.js.map +1 -0
- package/dist/features/group-dnd.d.ts +11 -0
- package/dist/features/group-dnd.js +119 -0
- package/dist/features/group-dnd.js.map +1 -0
- package/dist/features/header-filter.d.ts +96 -0
- package/dist/features/header-filter.js +579 -0
- package/dist/features/header-filter.js.map +1 -0
- package/dist/features/host-label.d.ts +36 -0
- package/dist/features/host-label.js +184 -0
- package/dist/features/host-label.js.map +1 -0
- package/dist/features/keyboard.d.ts +59 -0
- package/dist/features/keyboard.js +127 -0
- package/dist/features/keyboard.js.map +1 -0
- package/dist/features/menu.d.ts +113 -0
- package/dist/features/menu.js +491 -0
- package/dist/features/menu.js.map +1 -0
- package/dist/features/resize.d.ts +82 -0
- package/dist/features/resize.js +214 -0
- package/dist/features/resize.js.map +1 -0
- package/dist/features/search.d.ts +45 -0
- package/dist/features/search.js +123 -0
- package/dist/features/search.js.map +1 -0
- package/dist/features/selection.d.ts +37 -0
- package/dist/features/selection.js +103 -0
- package/dist/features/selection.js.map +1 -0
- package/dist/features/sorting.d.ts +39 -0
- package/dist/features/sorting.js +53 -0
- package/dist/features/sorting.js.map +1 -0
- package/dist/features/toolbar.d.ts +125 -0
- package/dist/features/toolbar.js +135 -0
- package/dist/features/toolbar.js.map +1 -0
- package/dist/features/tree.d.ts +53 -0
- package/dist/features/tree.js +94 -0
- package/dist/features/tree.js.map +1 -0
- package/dist/features/validation.d.ts +48 -0
- package/dist/features/validation.js +172 -0
- package/dist/features/validation.js.map +1 -0
- package/dist/grid-column-def.d.ts +509 -0
- package/dist/grid-column-def.js +32 -0
- package/dist/grid-column-def.js.map +1 -0
- package/dist/grid-column.d.ts +167 -0
- package/dist/grid-column.js +376 -0
- package/dist/grid-column.js.map +1 -0
- package/dist/grid-i18n.d.ts +469 -0
- package/dist/grid-i18n.js +3222 -0
- package/dist/grid-i18n.js.map +1 -0
- package/dist/grid.d.ts +1484 -0
- package/dist/grid.js +15579 -0
- package/dist/grid.js.map +1 -0
- package/dist/grid.min.js +3858 -0
- package/dist/grid.styles.d.ts +2 -0
- package/dist/grid.styles.js +2747 -0
- package/dist/grid.styles.js.map +1 -0
- package/dist/render/cell.d.ts +16 -0
- package/dist/render/cell.js +78 -0
- package/dist/render/cell.js.map +1 -0
- package/dist/render/column-window.d.ts +18 -0
- package/dist/render/column-window.js +50 -0
- package/dist/render/column-window.js.map +1 -0
- package/dist/render/content.d.ts +45 -0
- package/dist/render/content.js +140 -0
- package/dist/render/content.js.map +1 -0
- package/dist/render/editors.d.ts +28 -0
- package/dist/render/editors.js +41 -0
- package/dist/render/editors.js.map +1 -0
- package/dist/render/footer.d.ts +61 -0
- package/dist/render/footer.js +61 -0
- package/dist/render/footer.js.map +1 -0
- package/dist/render/group-row.d.ts +35 -0
- package/dist/render/group-row.js +59 -0
- package/dist/render/group-row.js.map +1 -0
- package/dist/render/header.d.ts +92 -0
- package/dist/render/header.js +103 -0
- package/dist/render/header.js.map +1 -0
- package/dist/render/keyed-rows.d.ts +25 -0
- package/dist/render/keyed-rows.js +98 -0
- package/dist/render/keyed-rows.js.map +1 -0
- package/dist/render/virtualizer.d.ts +110 -0
- package/dist/render/virtualizer.js +509 -0
- package/dist/render/virtualizer.js.map +1 -0
- package/dist/row-model/added-rows.d.ts +32 -0
- package/dist/row-model/added-rows.js +95 -0
- package/dist/row-model/added-rows.js.map +1 -0
- package/dist/row-model/cell-range.d.ts +71 -0
- package/dist/row-model/cell-range.js +187 -0
- package/dist/row-model/cell-range.js.map +1 -0
- package/dist/row-model/columns.d.ts +80 -0
- package/dist/row-model/columns.js +207 -0
- package/dist/row-model/columns.js.map +1 -0
- package/dist/row-model/compare.d.ts +40 -0
- package/dist/row-model/compare.js +590 -0
- package/dist/row-model/compare.js.map +1 -0
- package/dist/row-model/distinct.d.ts +39 -0
- package/dist/row-model/distinct.js +105 -0
- package/dist/row-model/distinct.js.map +1 -0
- package/dist/row-model/filter.d.ts +80 -0
- package/dist/row-model/filter.js +582 -0
- package/dist/row-model/filter.js.map +1 -0
- package/dist/row-model/flatten.d.ts +129 -0
- package/dist/row-model/flatten.js +511 -0
- package/dist/row-model/flatten.js.map +1 -0
- package/dist/row-model/fold.d.ts +25 -0
- package/dist/row-model/fold.js +104 -0
- package/dist/row-model/fold.js.map +1 -0
- package/dist/row-model/format.d.ts +58 -0
- package/dist/row-model/format.js +239 -0
- package/dist/row-model/format.js.map +1 -0
- package/dist/row-model/group.d.ts +30 -0
- package/dist/row-model/group.js +173 -0
- package/dist/row-model/group.js.map +1 -0
- package/dist/row-model/lru.d.ts +19 -0
- package/dist/row-model/lru.js +48 -0
- package/dist/row-model/lru.js.map +1 -0
- package/dist/row-model/sort.d.ts +30 -0
- package/dist/row-model/sort.js +107 -0
- package/dist/row-model/sort.js.map +1 -0
- package/dist/row-model/summary.d.ts +64 -0
- package/dist/row-model/summary.js +213 -0
- package/dist/row-model/summary.js.map +1 -0
- package/dist/row-model/tree.d.ts +116 -0
- package/dist/row-model/tree.js +478 -0
- package/dist/row-model/tree.js.map +1 -0
- package/dist/row-model/types.d.ts +109 -0
- package/dist/row-model/types.js +5 -0
- package/dist/row-model/types.js.map +1 -0
- package/dist/row-model/value.d.ts +20 -0
- package/dist/row-model/value.js +57 -0
- package/dist/row-model/value.js.map +1 -0
- package/dist/state/grid-state.d.ts +147 -0
- package/dist/state/grid-state.js +295 -0
- package/dist/state/grid-state.js.map +1 -0
- package/dist/state/storage.d.ts +33 -0
- package/dist/state/storage.js +62 -0
- package/dist/state/storage.js.map +1 -0
- package/dist/state/versioned.d.ts +18 -0
- package/dist/state/versioned.js +56 -0
- package/dist/state/versioned.js.map +1 -0
- package/package.json +141 -6
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { LitElement, type PropertyValues } from 'lit';
|
|
2
|
+
import type { GridCellRenderer, GridColumnAlignment, GridColumnBooleanDisplay, GridColumnComparator, GridColumnDataType, GridColumnDef, GridColumnFixed, GridColumnFormat, GridEditorRenderer, GridFilterOperation, GridGroupRenderer, GridHeaderRenderer, GridSortOrder, GridValidationRule, GridValueSetter } from './grid-column-def.js';
|
|
3
|
+
/**
|
|
4
|
+
* Declarative column of a `<u-grid>`: one direct child `<u-grid-column>` per
|
|
5
|
+
* column. The text content is the header label. Every option mirrors a
|
|
6
|
+
* `GridColumnDef` field with the same property name. A `<u-grid-column>`
|
|
7
|
+
* with nested `<u-grid-column>` elements is a band (multi-level header).
|
|
8
|
+
*
|
|
9
|
+
* @slot - Header label text and, in a band, the nested `<u-grid-column>` elements.
|
|
10
|
+
*/
|
|
11
|
+
export declare class DataGridColumn extends LitElement implements GridColumnDef {
|
|
12
|
+
#private;
|
|
13
|
+
static get observedAttributes(): string[];
|
|
14
|
+
/**
|
|
15
|
+
* Width in px. Changing it after the column is rendered overrides the width
|
|
16
|
+
* chosen by the user. Under virtual column rendering (`columnRenderingMode`)
|
|
17
|
+
* a column without `width` takes its auto-size width or `max(minWidth, 150)` px.
|
|
18
|
+
*/
|
|
19
|
+
get width(): number | null;
|
|
20
|
+
set width(value: number | null);
|
|
21
|
+
/**
|
|
22
|
+
* INITIAL grouping level. Afterwards grouping is grid state: use
|
|
23
|
+
* `grid.groupColumn()` / `grid.ungroupColumn()`. Changing it after the
|
|
24
|
+
* column is rendered still regroups, but is deprecated.
|
|
25
|
+
*/
|
|
26
|
+
get groupIndex(): number | null;
|
|
27
|
+
set groupIndex(value: number | null);
|
|
28
|
+
/** Dot path of the cell value in the row item (`"address.city"`). */
|
|
29
|
+
path: string;
|
|
30
|
+
/**
|
|
31
|
+
* Stable id of the column in the grid state (`getState`, `stateStorage`)
|
|
32
|
+
* and in string column references (`summary` items look it up before
|
|
33
|
+
* `path`). Default: `path`. A column without `name` and `path` is left out
|
|
34
|
+
* of the state.
|
|
35
|
+
*/
|
|
36
|
+
name: string;
|
|
37
|
+
/**
|
|
38
|
+
* Builds the cell content (property only): a Lit `TemplateResult`
|
|
39
|
+
* (recommended), a string (text) or an `HTMLElement` (placed in the grid's
|
|
40
|
+
* light DOM). `null`, `undefined` and Lit's `nothing` render an empty cell.
|
|
41
|
+
*/
|
|
42
|
+
renderer: GridCellRenderer | null;
|
|
43
|
+
/** Builds the header label (property only); sort arrow, filter button and resize handle stay. */
|
|
44
|
+
headerRenderer: GridHeaderRenderer | null;
|
|
45
|
+
/** Builds the label of the group rows of this column (property only); the expand button and aligned summaries stay. */
|
|
46
|
+
groupRenderer: GridGroupRenderer | null;
|
|
47
|
+
/**
|
|
48
|
+
* Data type of the column (`string`, `number`, `date`, `datetime`,
|
|
49
|
+
* `boolean`); attribute `type`. Without it, inferred from the first
|
|
50
|
+
* non-null value. The `data-type` attribute is deprecated (`data-*`
|
|
51
|
+
* belongs to the page author).
|
|
52
|
+
*/
|
|
53
|
+
dataType: GridColumnDataType | null;
|
|
54
|
+
/** `Intl` options or a formatter function (property only). */
|
|
55
|
+
format: GridColumnFormat | null;
|
|
56
|
+
/** Logical alignment (`start`, `center`, `end`); follows RTL. Default by data type. In a band, of the header label (default `start`). */
|
|
57
|
+
alignment: GridColumnAlignment | null;
|
|
58
|
+
/** Computes the cell value used to group, sort and filter (property only). Default: read `path`. */
|
|
59
|
+
valueGetter: ((item: any) => unknown) | null;
|
|
60
|
+
/** Displayed text (cell and group row); wins over `format` (property only). */
|
|
61
|
+
displayValue: ((value: unknown, item: any) => string) | null;
|
|
62
|
+
/** `text` (default) or `icon` (read-only check icon) for boolean columns. */
|
|
63
|
+
booleanDisplay: GridColumnBooleanDisplay | null;
|
|
64
|
+
/** Wraps the text in several lines instead of an ellipsis (`wrap="false"` turns it off). */
|
|
65
|
+
wrap: boolean;
|
|
66
|
+
/** Minimum width in px (also when resizing and auto-sizing). */
|
|
67
|
+
minWidth: number | null;
|
|
68
|
+
/** Text for empty values (`null`/`undefined`). */
|
|
69
|
+
emptyText: string | null;
|
|
70
|
+
/** Maximum width in px when resizing and auto-sizing. */
|
|
71
|
+
maxWidth: number | null;
|
|
72
|
+
/**
|
|
73
|
+
* Order in which the column leaves the table when the grid is too narrow
|
|
74
|
+
* (`auto-hide-columns`; its values move to the row details): the lowest
|
|
75
|
+
* goes first, ties from the end. When any column has a `hiding-priority`
|
|
76
|
+
* (grouped or hidden ones included), only those columns hide; otherwise
|
|
77
|
+
* columns hide from the last one. Fixed columns never hide. Empty or not a
|
|
78
|
+
* number = none. Ignored on bands.
|
|
79
|
+
*/
|
|
80
|
+
hidingPriority: number | null;
|
|
81
|
+
/** `resizable="false"` prevents resizing this column even with `column-resizing`. */
|
|
82
|
+
resizable: boolean | null;
|
|
83
|
+
/**
|
|
84
|
+
* Fixes the column at the `start` or `end` of the scrollable area (logical:
|
|
85
|
+
* mirrors in RTL). A fixed band fixes its columns; ignored on nested columns.
|
|
86
|
+
*/
|
|
87
|
+
fixed: GridColumnFixed;
|
|
88
|
+
/** INITIAL visibility (`visible="false"` hides). Afterwards the user changes it in the chooser. */
|
|
89
|
+
visible: boolean | null;
|
|
90
|
+
/** `show-in-chooser="false"` removes the column from the chooser (the user cannot hide it). */
|
|
91
|
+
showInChooser: boolean | null;
|
|
92
|
+
/** Allows sorting by this column. Default: `true` when it has a `path`, `valueGetter` or `comparator`. */
|
|
93
|
+
sortable: boolean | null;
|
|
94
|
+
/** Initial sort direction. Afterwards the sorting is grid state. */
|
|
95
|
+
sortOrder: GridSortOrder | null;
|
|
96
|
+
/** Priority of the initial sort among columns (lower first). */
|
|
97
|
+
sortIndex: number | null;
|
|
98
|
+
/** Custom ascending comparator: `(valueA, valueB, itemA, itemB) => number`. */
|
|
99
|
+
comparator: GridColumnComparator | null;
|
|
100
|
+
/**
|
|
101
|
+
* Value used to GROUP by this column (a range or bucket: decade, initial
|
|
102
|
+
* letter), property only. Groups are identified, sorted and shown by the
|
|
103
|
+
* returned value; `dataType`, `comparator`, `format` and `displayValue` do
|
|
104
|
+
* not apply to it.
|
|
105
|
+
*/
|
|
106
|
+
groupValueGetter: ((item: any) => unknown) | null;
|
|
107
|
+
/**
|
|
108
|
+
* Allows the user to group by this column (`groupable="false"` prevents
|
|
109
|
+
* it). Default: `true` when it has a `path`, `valueGetter` or
|
|
110
|
+
* `groupValueGetter`. Only limits the user: `groupColumn()` still works.
|
|
111
|
+
*/
|
|
112
|
+
groupable: boolean | null;
|
|
113
|
+
/**
|
|
114
|
+
* Allows filtering by this column (filter row, header filter and, by
|
|
115
|
+
* default, the search panel). Default (`null`): `true` when the column has
|
|
116
|
+
* a `path`. `filterable="false"` disables it.
|
|
117
|
+
*/
|
|
118
|
+
filterable: boolean | null;
|
|
119
|
+
/**
|
|
120
|
+
* Includes this column in exports (`exportCsv`, `getExportData`, the
|
|
121
|
+
* xlsx adapter) and in Ctrl+C. Default (`null`): `true` when it has a
|
|
122
|
+
* `path`, `valueGetter` or `displayValue` (a `renderer`-only column has no
|
|
123
|
+
* text). `exportable="false"` leaves it out.
|
|
124
|
+
*/
|
|
125
|
+
exportable: boolean | null;
|
|
126
|
+
/**
|
|
127
|
+
* Operations of the filter row operation menu. Attribute: space separated
|
|
128
|
+
* list (`filter-operations="contains startswith ="`); unknown tokens are
|
|
129
|
+
* ignored with a warning. Default by data type.
|
|
130
|
+
*/
|
|
131
|
+
filterOperations: readonly GridFilterOperation[] | null;
|
|
132
|
+
/**
|
|
133
|
+
* Operation of the filter row editor. Default: `contains` for text, `=`
|
|
134
|
+
* otherwise; one outside `filterOperations` falls back to the first of the
|
|
135
|
+
* list. Unknown attribute values are ignored with a warning.
|
|
136
|
+
*/
|
|
137
|
+
defaultFilterOperation: GridFilterOperation | null;
|
|
138
|
+
/**
|
|
139
|
+
* Allows editing the cells of this column (with `allow-editing` on the
|
|
140
|
+
* grid). Default (`null`): `true` when it has a `path` or a
|
|
141
|
+
* `valueSetter`. `editable="false"` makes it read-only.
|
|
142
|
+
*/
|
|
143
|
+
editable: boolean | null;
|
|
144
|
+
/** Builds the cell editor instead of the built-in one (property only). See `GridEditorRenderer`. */
|
|
145
|
+
editorRenderer: GridEditorRenderer | null;
|
|
146
|
+
/** Rules checked when a value is committed and before saving (property only). See `GridValidationRule`. */
|
|
147
|
+
validationRules: readonly GridValidationRule[] | null;
|
|
148
|
+
/** Writes an edited value into the pending change of the row (property only). Default: sets `path`. */
|
|
149
|
+
valueSetter: GridValueSetter | null;
|
|
150
|
+
attributeChangedCallback(name: string, old: string | null, value: string | null): void;
|
|
151
|
+
willUpdate(changed: PropertyValues<this>): void;
|
|
152
|
+
/**
|
|
153
|
+
* Nested `<u-grid-column>` elements (read-only): when there is at least
|
|
154
|
+
* one, this column is a band. `null` without nested columns. The array is
|
|
155
|
+
* frozen and stays the same while the nested columns don't change.
|
|
156
|
+
*/
|
|
157
|
+
get columns(): readonly DataGridColumn[] | null;
|
|
158
|
+
/** Header label: the trimmed text content of the element, without the text of nested columns. */
|
|
159
|
+
get label(): string;
|
|
160
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
161
|
+
}
|
|
162
|
+
declare global {
|
|
163
|
+
interface HTMLElementTagNameMap {
|
|
164
|
+
'u-grid-column': DataGridColumn;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=grid-column.d.ts.map
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html, LitElement } from 'lit';
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import { booleanAttribute, filterOperationAttribute, filterOperationsAttribute, optionalBooleanAttribute, optionalNumberAttribute } from './attribute-converters.js';
|
|
5
|
+
const optionalBoolean = optionalBooleanAttribute;
|
|
6
|
+
/** Atributos renomeados na revisão de API (spec 15): antigo → novo. */
|
|
7
|
+
const LEGACY_ATTRIBUTES = {
|
|
8
|
+
'data-type': 'type',
|
|
9
|
+
};
|
|
10
|
+
const isColumnHost = (element) => !!element && typeof element._columnChanged === 'function';
|
|
11
|
+
const isColumnElement = (node) => node instanceof Element && node.localName === 'u-grid-column';
|
|
12
|
+
const sameElements = (a, b) => a.length === b.length && a.every((element, index) => element === b[index]);
|
|
13
|
+
const fixedSide = {
|
|
14
|
+
fromAttribute: (value) => value === 'start' || value === 'end' ? value : null,
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Declarative column of a `<u-grid>`: one direct child `<u-grid-column>` per
|
|
18
|
+
* column. The text content is the header label. Every option mirrors a
|
|
19
|
+
* `GridColumnDef` field with the same property name. A `<u-grid-column>`
|
|
20
|
+
* with nested `<u-grid-column>` elements is a band (multi-level header).
|
|
21
|
+
*
|
|
22
|
+
* @slot - Header label text and, in a band, the nested `<u-grid-column>` elements.
|
|
23
|
+
*/
|
|
24
|
+
let DataGridColumn = class DataGridColumn extends LitElement {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
this.#warnedDeprecations = new Set();
|
|
28
|
+
this.#nested = Object.freeze([]);
|
|
29
|
+
this.#width = null;
|
|
30
|
+
this.#groupIndex = null;
|
|
31
|
+
/** Dot path of the cell value in the row item (`"address.city"`). */
|
|
32
|
+
this.path = '';
|
|
33
|
+
/**
|
|
34
|
+
* Stable id of the column in the grid state (`getState`, `stateStorage`)
|
|
35
|
+
* and in string column references (`summary` items look it up before
|
|
36
|
+
* `path`). Default: `path`. A column without `name` and `path` is left out
|
|
37
|
+
* of the state.
|
|
38
|
+
*/
|
|
39
|
+
this.name = '';
|
|
40
|
+
/**
|
|
41
|
+
* Builds the cell content (property only): a Lit `TemplateResult`
|
|
42
|
+
* (recommended), a string (text) or an `HTMLElement` (placed in the grid's
|
|
43
|
+
* light DOM). `null`, `undefined` and Lit's `nothing` render an empty cell.
|
|
44
|
+
*/
|
|
45
|
+
this.renderer = null;
|
|
46
|
+
/** Builds the header label (property only); sort arrow, filter button and resize handle stay. */
|
|
47
|
+
this.headerRenderer = null;
|
|
48
|
+
/** Builds the label of the group rows of this column (property only); the expand button and aligned summaries stay. */
|
|
49
|
+
this.groupRenderer = null;
|
|
50
|
+
/**
|
|
51
|
+
* Data type of the column (`string`, `number`, `date`, `datetime`,
|
|
52
|
+
* `boolean`); attribute `type`. Without it, inferred from the first
|
|
53
|
+
* non-null value. The `data-type` attribute is deprecated (`data-*`
|
|
54
|
+
* belongs to the page author).
|
|
55
|
+
*/
|
|
56
|
+
this.dataType = null;
|
|
57
|
+
/** `Intl` options or a formatter function (property only). */
|
|
58
|
+
this.format = null;
|
|
59
|
+
/** Logical alignment (`start`, `center`, `end`); follows RTL. Default by data type. In a band, of the header label (default `start`). */
|
|
60
|
+
this.alignment = null;
|
|
61
|
+
/** Computes the cell value used to group, sort and filter (property only). Default: read `path`. */
|
|
62
|
+
this.valueGetter = null;
|
|
63
|
+
/** Displayed text (cell and group row); wins over `format` (property only). */
|
|
64
|
+
this.displayValue = null;
|
|
65
|
+
/** `text` (default) or `icon` (read-only check icon) for boolean columns. */
|
|
66
|
+
this.booleanDisplay = null;
|
|
67
|
+
/** Wraps the text in several lines instead of an ellipsis (`wrap="false"` turns it off). */
|
|
68
|
+
this.wrap = false;
|
|
69
|
+
/** Minimum width in px (also when resizing and auto-sizing). */
|
|
70
|
+
this.minWidth = null;
|
|
71
|
+
/** Text for empty values (`null`/`undefined`). */
|
|
72
|
+
this.emptyText = null;
|
|
73
|
+
/** Maximum width in px when resizing and auto-sizing. */
|
|
74
|
+
this.maxWidth = null;
|
|
75
|
+
/**
|
|
76
|
+
* Order in which the column leaves the table when the grid is too narrow
|
|
77
|
+
* (`auto-hide-columns`; its values move to the row details): the lowest
|
|
78
|
+
* goes first, ties from the end. When any column has a `hiding-priority`
|
|
79
|
+
* (grouped or hidden ones included), only those columns hide; otherwise
|
|
80
|
+
* columns hide from the last one. Fixed columns never hide. Empty or not a
|
|
81
|
+
* number = none. Ignored on bands.
|
|
82
|
+
*/
|
|
83
|
+
this.hidingPriority = null;
|
|
84
|
+
/** `resizable="false"` prevents resizing this column even with `column-resizing`. */
|
|
85
|
+
this.resizable = null;
|
|
86
|
+
/**
|
|
87
|
+
* Fixes the column at the `start` or `end` of the scrollable area (logical:
|
|
88
|
+
* mirrors in RTL). A fixed band fixes its columns; ignored on nested columns.
|
|
89
|
+
*/
|
|
90
|
+
this.fixed = null;
|
|
91
|
+
/** INITIAL visibility (`visible="false"` hides). Afterwards the user changes it in the chooser. */
|
|
92
|
+
this.visible = null;
|
|
93
|
+
/** `show-in-chooser="false"` removes the column from the chooser (the user cannot hide it). */
|
|
94
|
+
this.showInChooser = null;
|
|
95
|
+
/** Allows sorting by this column. Default: `true` when it has a `path`, `valueGetter` or `comparator`. */
|
|
96
|
+
this.sortable = null;
|
|
97
|
+
/** Initial sort direction. Afterwards the sorting is grid state. */
|
|
98
|
+
this.sortOrder = null;
|
|
99
|
+
/** Priority of the initial sort among columns (lower first). */
|
|
100
|
+
this.sortIndex = null;
|
|
101
|
+
/** Custom ascending comparator: `(valueA, valueB, itemA, itemB) => number`. */
|
|
102
|
+
this.comparator = null;
|
|
103
|
+
/**
|
|
104
|
+
* Value used to GROUP by this column (a range or bucket: decade, initial
|
|
105
|
+
* letter), property only. Groups are identified, sorted and shown by the
|
|
106
|
+
* returned value; `dataType`, `comparator`, `format` and `displayValue` do
|
|
107
|
+
* not apply to it.
|
|
108
|
+
*/
|
|
109
|
+
this.groupValueGetter = null;
|
|
110
|
+
/**
|
|
111
|
+
* Allows the user to group by this column (`groupable="false"` prevents
|
|
112
|
+
* it). Default: `true` when it has a `path`, `valueGetter` or
|
|
113
|
+
* `groupValueGetter`. Only limits the user: `groupColumn()` still works.
|
|
114
|
+
*/
|
|
115
|
+
this.groupable = null;
|
|
116
|
+
/**
|
|
117
|
+
* Allows filtering by this column (filter row, header filter and, by
|
|
118
|
+
* default, the search panel). Default (`null`): `true` when the column has
|
|
119
|
+
* a `path`. `filterable="false"` disables it.
|
|
120
|
+
*/
|
|
121
|
+
this.filterable = null;
|
|
122
|
+
/**
|
|
123
|
+
* Includes this column in exports (`exportCsv`, `getExportData`, the
|
|
124
|
+
* xlsx adapter) and in Ctrl+C. Default (`null`): `true` when it has a
|
|
125
|
+
* `path`, `valueGetter` or `displayValue` (a `renderer`-only column has no
|
|
126
|
+
* text). `exportable="false"` leaves it out.
|
|
127
|
+
*/
|
|
128
|
+
this.exportable = null;
|
|
129
|
+
/**
|
|
130
|
+
* Operations of the filter row operation menu. Attribute: space separated
|
|
131
|
+
* list (`filter-operations="contains startswith ="`); unknown tokens are
|
|
132
|
+
* ignored with a warning. Default by data type.
|
|
133
|
+
*/
|
|
134
|
+
this.filterOperations = null;
|
|
135
|
+
/**
|
|
136
|
+
* Operation of the filter row editor. Default: `contains` for text, `=`
|
|
137
|
+
* otherwise; one outside `filterOperations` falls back to the first of the
|
|
138
|
+
* list. Unknown attribute values are ignored with a warning.
|
|
139
|
+
*/
|
|
140
|
+
this.defaultFilterOperation = null;
|
|
141
|
+
/**
|
|
142
|
+
* Allows editing the cells of this column (with `allow-editing` on the
|
|
143
|
+
* grid). Default (`null`): `true` when it has a `path` or a
|
|
144
|
+
* `valueSetter`. `editable="false"` makes it read-only.
|
|
145
|
+
*/
|
|
146
|
+
this.editable = null;
|
|
147
|
+
/** Builds the cell editor instead of the built-in one (property only). See `GridEditorRenderer`. */
|
|
148
|
+
this.editorRenderer = null;
|
|
149
|
+
/** Rules checked when a value is committed and before saving (property only). See `GridValidationRule`. */
|
|
150
|
+
this.validationRules = null;
|
|
151
|
+
/** Writes an edited value into the pending change of the row (property only). Default: sets `path`. */
|
|
152
|
+
this.valueSetter = null;
|
|
153
|
+
// O grid compara a árvore e ignora quando nada mudou.
|
|
154
|
+
this.#onSlotChange = () => this.#notify('columns');
|
|
155
|
+
}
|
|
156
|
+
static get observedAttributes() {
|
|
157
|
+
return [...super.observedAttributes, ...Object.keys(LEGACY_ATTRIBUTES)];
|
|
158
|
+
}
|
|
159
|
+
#warnedDeprecations;
|
|
160
|
+
#nested;
|
|
161
|
+
#width;
|
|
162
|
+
#groupIndex;
|
|
163
|
+
/**
|
|
164
|
+
* Width in px. Changing it after the column is rendered overrides the width
|
|
165
|
+
* chosen by the user. Under virtual column rendering (`columnRenderingMode`)
|
|
166
|
+
* a column without `width` takes its auto-size width or `max(minWidth, 150)` px.
|
|
167
|
+
*/
|
|
168
|
+
get width() {
|
|
169
|
+
return this.#width;
|
|
170
|
+
}
|
|
171
|
+
set width(value) {
|
|
172
|
+
if (this.#width === value) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
this.#width = value;
|
|
176
|
+
this.#notify('width');
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* INITIAL grouping level. Afterwards grouping is grid state: use
|
|
180
|
+
* `grid.groupColumn()` / `grid.ungroupColumn()`. Changing it after the
|
|
181
|
+
* column is rendered still regroups, but is deprecated.
|
|
182
|
+
*/
|
|
183
|
+
get groupIndex() {
|
|
184
|
+
return this.#groupIndex;
|
|
185
|
+
}
|
|
186
|
+
set groupIndex(value) {
|
|
187
|
+
if (this.#groupIndex === value) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
this.#groupIndex = value;
|
|
191
|
+
this.#notify('groupIndex');
|
|
192
|
+
}
|
|
193
|
+
attributeChangedCallback(name, old, value) {
|
|
194
|
+
const renamed = LEGACY_ATTRIBUTES[name];
|
|
195
|
+
if (renamed) {
|
|
196
|
+
this.#deprecated(`${name} attribute`, `${renamed} attribute`);
|
|
197
|
+
// Conversor e propriedade são os do atributo novo.
|
|
198
|
+
super.attributeChangedCallback(renamed, old, value);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
super.attributeChangedCallback(name, old, value);
|
|
202
|
+
}
|
|
203
|
+
willUpdate(changed) {
|
|
204
|
+
// Os valores iniciais o grid já lê ao montar as colunas.
|
|
205
|
+
if (!this.hasUpdated) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (changed.has('path') || changed.has('valueGetter') || changed.has('dataType') || changed.has('comparator') || changed.has('groupValueGetter')) {
|
|
209
|
+
this.#notify('value');
|
|
210
|
+
}
|
|
211
|
+
else if (changed.size) {
|
|
212
|
+
this.#notify('display');
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Nested `<u-grid-column>` elements (read-only): when there is at least
|
|
217
|
+
* one, this column is a band. `null` without nested columns. The array is
|
|
218
|
+
* frozen and stays the same while the nested columns don't change.
|
|
219
|
+
*/
|
|
220
|
+
get columns() {
|
|
221
|
+
const nested = Array.from(this.children).filter(isColumnElement);
|
|
222
|
+
if (!sameElements(nested, this.#nested)) {
|
|
223
|
+
this.#nested = Object.freeze(nested);
|
|
224
|
+
}
|
|
225
|
+
return this.#nested.length ? this.#nested : null;
|
|
226
|
+
}
|
|
227
|
+
/** Header label: the trimmed text content of the element, without the text of nested columns. */
|
|
228
|
+
get label() {
|
|
229
|
+
if (!this.columns) {
|
|
230
|
+
return (this.textContent ?? '').trim();
|
|
231
|
+
}
|
|
232
|
+
let text = '';
|
|
233
|
+
for (const node of this.childNodes) {
|
|
234
|
+
if (!isColumnElement(node)) {
|
|
235
|
+
text += node.textContent ?? '';
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return text.trim();
|
|
239
|
+
}
|
|
240
|
+
// Só para saber quando as colunas aninhadas mudam (o grid não mostra este conteúdo).
|
|
241
|
+
render() {
|
|
242
|
+
return html `<slot @slotchange=${this.#onSlotChange}></slot>`;
|
|
243
|
+
}
|
|
244
|
+
// O grid compara a árvore e ignora quando nada mudou.
|
|
245
|
+
#onSlotChange;
|
|
246
|
+
#deprecated(name, replacement) {
|
|
247
|
+
if (this.#warnedDeprecations.has(name)) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
this.#warnedDeprecations.add(name);
|
|
251
|
+
console.warn(`<u-grid-column>: "${name}" is deprecated, use "${replacement}" instead.`);
|
|
252
|
+
}
|
|
253
|
+
#notify(change) {
|
|
254
|
+
// Coluna aninhada: sobe pelas bandas até o grid.
|
|
255
|
+
let host = this.parentElement;
|
|
256
|
+
while (host && !isColumnHost(host) && isColumnElement(host)) {
|
|
257
|
+
host = host.parentElement;
|
|
258
|
+
}
|
|
259
|
+
if (isColumnHost(host)) {
|
|
260
|
+
host._columnChanged(this, change);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
__decorate([
|
|
265
|
+
property({ type: Number })
|
|
266
|
+
], DataGridColumn.prototype, "width", null);
|
|
267
|
+
__decorate([
|
|
268
|
+
property({ type: Number, attribute: 'group-index' })
|
|
269
|
+
], DataGridColumn.prototype, "groupIndex", null);
|
|
270
|
+
__decorate([
|
|
271
|
+
property()
|
|
272
|
+
], DataGridColumn.prototype, "path", void 0);
|
|
273
|
+
__decorate([
|
|
274
|
+
property()
|
|
275
|
+
], DataGridColumn.prototype, "name", void 0);
|
|
276
|
+
__decorate([
|
|
277
|
+
property({ attribute: false })
|
|
278
|
+
], DataGridColumn.prototype, "renderer", void 0);
|
|
279
|
+
__decorate([
|
|
280
|
+
property({ attribute: false })
|
|
281
|
+
], DataGridColumn.prototype, "headerRenderer", void 0);
|
|
282
|
+
__decorate([
|
|
283
|
+
property({ attribute: false })
|
|
284
|
+
], DataGridColumn.prototype, "groupRenderer", void 0);
|
|
285
|
+
__decorate([
|
|
286
|
+
property({ attribute: 'type' })
|
|
287
|
+
], DataGridColumn.prototype, "dataType", void 0);
|
|
288
|
+
__decorate([
|
|
289
|
+
property({ attribute: false })
|
|
290
|
+
], DataGridColumn.prototype, "format", void 0);
|
|
291
|
+
__decorate([
|
|
292
|
+
property()
|
|
293
|
+
], DataGridColumn.prototype, "alignment", void 0);
|
|
294
|
+
__decorate([
|
|
295
|
+
property({ attribute: false })
|
|
296
|
+
], DataGridColumn.prototype, "valueGetter", void 0);
|
|
297
|
+
__decorate([
|
|
298
|
+
property({ attribute: false })
|
|
299
|
+
], DataGridColumn.prototype, "displayValue", void 0);
|
|
300
|
+
__decorate([
|
|
301
|
+
property({ attribute: 'boolean-display' })
|
|
302
|
+
], DataGridColumn.prototype, "booleanDisplay", void 0);
|
|
303
|
+
__decorate([
|
|
304
|
+
property({ type: Boolean, converter: booleanAttribute(false) })
|
|
305
|
+
], DataGridColumn.prototype, "wrap", void 0);
|
|
306
|
+
__decorate([
|
|
307
|
+
property({ type: Number, attribute: 'min-width' })
|
|
308
|
+
], DataGridColumn.prototype, "minWidth", void 0);
|
|
309
|
+
__decorate([
|
|
310
|
+
property({ attribute: 'empty-text' })
|
|
311
|
+
], DataGridColumn.prototype, "emptyText", void 0);
|
|
312
|
+
__decorate([
|
|
313
|
+
property({ type: Number, attribute: 'max-width' })
|
|
314
|
+
], DataGridColumn.prototype, "maxWidth", void 0);
|
|
315
|
+
__decorate([
|
|
316
|
+
property({ converter: optionalNumberAttribute, attribute: 'hiding-priority' })
|
|
317
|
+
], DataGridColumn.prototype, "hidingPriority", void 0);
|
|
318
|
+
__decorate([
|
|
319
|
+
property({ converter: optionalBoolean })
|
|
320
|
+
], DataGridColumn.prototype, "resizable", void 0);
|
|
321
|
+
__decorate([
|
|
322
|
+
property({ converter: fixedSide })
|
|
323
|
+
], DataGridColumn.prototype, "fixed", void 0);
|
|
324
|
+
__decorate([
|
|
325
|
+
property({ converter: optionalBoolean })
|
|
326
|
+
], DataGridColumn.prototype, "visible", void 0);
|
|
327
|
+
__decorate([
|
|
328
|
+
property({ converter: optionalBoolean, attribute: 'show-in-chooser' })
|
|
329
|
+
], DataGridColumn.prototype, "showInChooser", void 0);
|
|
330
|
+
__decorate([
|
|
331
|
+
property({ converter: optionalBoolean })
|
|
332
|
+
], DataGridColumn.prototype, "sortable", void 0);
|
|
333
|
+
__decorate([
|
|
334
|
+
property({ attribute: 'sort-order' })
|
|
335
|
+
], DataGridColumn.prototype, "sortOrder", void 0);
|
|
336
|
+
__decorate([
|
|
337
|
+
property({ type: Number, attribute: 'sort-index' })
|
|
338
|
+
], DataGridColumn.prototype, "sortIndex", void 0);
|
|
339
|
+
__decorate([
|
|
340
|
+
property({ attribute: false })
|
|
341
|
+
], DataGridColumn.prototype, "comparator", void 0);
|
|
342
|
+
__decorate([
|
|
343
|
+
property({ attribute: false })
|
|
344
|
+
], DataGridColumn.prototype, "groupValueGetter", void 0);
|
|
345
|
+
__decorate([
|
|
346
|
+
property({ converter: optionalBoolean })
|
|
347
|
+
], DataGridColumn.prototype, "groupable", void 0);
|
|
348
|
+
__decorate([
|
|
349
|
+
property({ converter: optionalBoolean })
|
|
350
|
+
], DataGridColumn.prototype, "filterable", void 0);
|
|
351
|
+
__decorate([
|
|
352
|
+
property({ converter: optionalBoolean })
|
|
353
|
+
], DataGridColumn.prototype, "exportable", void 0);
|
|
354
|
+
__decorate([
|
|
355
|
+
property({ converter: filterOperationsAttribute, attribute: 'filter-operations' })
|
|
356
|
+
], DataGridColumn.prototype, "filterOperations", void 0);
|
|
357
|
+
__decorate([
|
|
358
|
+
property({ converter: filterOperationAttribute, attribute: 'default-filter-operation' })
|
|
359
|
+
], DataGridColumn.prototype, "defaultFilterOperation", void 0);
|
|
360
|
+
__decorate([
|
|
361
|
+
property({ converter: optionalBoolean })
|
|
362
|
+
], DataGridColumn.prototype, "editable", void 0);
|
|
363
|
+
__decorate([
|
|
364
|
+
property({ attribute: false })
|
|
365
|
+
], DataGridColumn.prototype, "editorRenderer", void 0);
|
|
366
|
+
__decorate([
|
|
367
|
+
property({ attribute: false })
|
|
368
|
+
], DataGridColumn.prototype, "validationRules", void 0);
|
|
369
|
+
__decorate([
|
|
370
|
+
property({ attribute: false })
|
|
371
|
+
], DataGridColumn.prototype, "valueSetter", void 0);
|
|
372
|
+
DataGridColumn = __decorate([
|
|
373
|
+
customElement('u-grid-column')
|
|
374
|
+
], DataGridColumn);
|
|
375
|
+
export { DataGridColumn };
|
|
376
|
+
//# sourceMappingURL=grid-column.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid-column.js","sourceRoot":"","sources":["../src/grid-column.ts"],"names":[],"mappings":";AAAA,OAAO,EAA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,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;kDAAmC;AAOQ;IAAnF,QAAQ,CAAC,EAAE,SAAS,EAAE,yBAAyB,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;wDAAgE;AAOzD;IAAzF,QAAQ,CAAC,EAAE,SAAS,EAAE,wBAAwB,EAAE,SAAS,EAAE,0BAA0B,EAAE,CAAC;8DAA2D;AAO1G;IAAzC,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;gDAAiC;AAG1C;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;sDAAkD;AAGjD;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;uDAA8D;AAG7D;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;mDAA4C;AA9MhE,cAAc;IAD1B,aAAa,CAAC,eAAe,CAAC;GAClB,cAAc,CAuS1B","sourcesContent":["import { html, LitElement, type PropertyValues } from 'lit';\r\nimport { customElement, property } from 'lit/decorators.js';\r\n\r\nimport { booleanAttribute, filterOperationAttribute, filterOperationsAttribute, type LegacyAttributes, optionalBooleanAttribute, optionalNumberAttribute } from './attribute-converters.js';\r\nimport type {\r\n GridCellRenderer,\r\n GridColumnAlignment,\r\n GridColumnBooleanDisplay,\r\n GridColumnComparator,\r\n GridColumnDataType,\r\n GridColumnDef,\r\n GridColumnFixed,\r\n GridColumnFormat,\r\n GridEditorRenderer,\r\n GridFilterOperation,\r\n GridGroupRenderer,\r\n GridHeaderRenderer,\r\n GridSortOrder,\r\n GridValidationRule,\r\n GridValueSetter,\r\n} from './grid-column-def.js';\r\n\r\n/**\r\n * `value`: muda o valor das células; `display`: só a exibição/layout.\r\n * @internal\r\n */\r\nexport type GridColumnChange = 'width' | 'groupIndex' | 'value' | 'display' | 'columns';\r\n\r\nconst optionalBoolean = optionalBooleanAttribute;\r\n\r\n/** Atributos renomeados na revisão de API (spec 15): antigo → novo. */\r\nconst LEGACY_ATTRIBUTES: LegacyAttributes = {\r\n 'data-type': 'type',\r\n};\r\n\r\n/** @internal */\r\ninterface ColumnHost extends HTMLElement {\r\n _columnChanged(column: GridColumnDef, change: GridColumnChange): void;\r\n}\r\n\r\nconst isColumnHost = (element: Element | null): element is ColumnHost =>\r\n !!element && typeof (element as Partial<ColumnHost>)._columnChanged === 'function';\r\n\r\nconst isColumnElement = (node: Node): node is DataGridColumn =>\r\n node instanceof Element && node.localName === 'u-grid-column';\r\n\r\nconst sameElements = (a: readonly Element[], b: readonly Element[]): boolean =>\r\n a.length === b.length && a.every((element, index) => element === b[index]);\r\n\r\nconst fixedSide = {\r\n fromAttribute: (value: string | null): GridColumnFixed =>\r\n value === 'start' || value === 'end' ? value : null,\r\n};\r\n\r\n/**\r\n * Declarative column of a `<u-grid>`: one direct child `<u-grid-column>` per\r\n * column. The text content is the header label. Every option mirrors a\r\n * `GridColumnDef` field with the same property name. A `<u-grid-column>`\r\n * with nested `<u-grid-column>` elements is a band (multi-level header).\r\n *\r\n * @slot - Header label text and, in a band, the nested `<u-grid-column>` elements.\r\n */\r\n@customElement('u-grid-column')\r\nexport class DataGridColumn extends LitElement implements GridColumnDef {\r\n\r\n static override get observedAttributes(): string[] {\r\n return [...super.observedAttributes, ...Object.keys(LEGACY_ATTRIBUTES)];\r\n }\r\n\r\n readonly #warnedDeprecations = new Set<string>();\r\n #nested: readonly DataGridColumn[] = Object.freeze([]);\r\n\r\n #width: number | null = null;\r\n #groupIndex: number | null = null;\r\n\r\n /**\r\n * Width in px. Changing it after the column is rendered overrides the width\r\n * chosen by the user. Under virtual column rendering (`columnRenderingMode`)\r\n * a column without `width` takes its auto-size width or `max(minWidth, 150)` px.\r\n */\r\n @property({ type: Number })\r\n get width(): number | null {\r\n return this.#width;\r\n }\r\n\r\n set width(value: number | null) {\r\n\r\n if (this.#width === value) {\r\n return;\r\n }\r\n\r\n this.#width = value;\r\n this.#notify('width');\r\n }\r\n\r\n /**\r\n * INITIAL grouping level. Afterwards grouping is grid state: use\r\n * `grid.groupColumn()` / `grid.ungroupColumn()`. Changing it after the\r\n * column is rendered still regroups, but is deprecated.\r\n */\r\n @property({ type: Number, attribute: 'group-index' })\r\n get groupIndex(): number | null {\r\n return this.#groupIndex;\r\n }\r\n\r\n set groupIndex(value: number | null) {\r\n\r\n if (this.#groupIndex === value) {\r\n return;\r\n }\r\n\r\n this.#groupIndex = value;\r\n this.#notify('groupIndex');\r\n }\r\n\r\n /** Dot path of the cell value in the row item (`\"address.city\"`). */\r\n @property() path = '';\r\n\r\n /**\r\n * Stable id of the column in the grid state (`getState`, `stateStorage`)\r\n * and in string column references (`summary` items look it up before\r\n * `path`). Default: `path`. A column without `name` and `path` is left out\r\n * of the state.\r\n */\r\n @property() name = '';\r\n\r\n /**\r\n * Builds the cell content (property only): a Lit `TemplateResult`\r\n * (recommended), a string (text) or an `HTMLElement` (placed in the grid's\r\n * light DOM). `null`, `undefined` and Lit's `nothing` render an empty cell.\r\n */\r\n @property({ attribute: false }) renderer: GridCellRenderer | null = null;\r\n\r\n /** Builds the header label (property only); sort arrow, filter button and resize handle stay. */\r\n @property({ attribute: false }) headerRenderer: GridHeaderRenderer | null = null;\r\n\r\n /** Builds the label of the group rows of this column (property only); the expand button and aligned summaries stay. */\r\n @property({ attribute: false }) groupRenderer: GridGroupRenderer | null = null;\r\n\r\n /**\r\n * Data type of the column (`string`, `number`, `date`, `datetime`,\r\n * `boolean`); attribute `type`. Without it, inferred from the first\r\n * non-null value. The `data-type` attribute is deprecated (`data-*`\r\n * belongs to the page author).\r\n */\r\n @property({ attribute: 'type' }) dataType: GridColumnDataType | null = null;\r\n\r\n /** `Intl` options or a formatter function (property only). */\r\n @property({ attribute: false }) format: GridColumnFormat | null = null;\r\n\r\n /** Logical alignment (`start`, `center`, `end`); follows RTL. Default by data type. In a band, of the header label (default `start`). */\r\n @property() alignment: GridColumnAlignment | null = null;\r\n\r\n /** Computes the cell value used to group, sort and filter (property only). Default: read `path`. */\r\n @property({ attribute: false }) valueGetter: ((item: any) => unknown) | null = null;\r\n\r\n /** Displayed text (cell and group row); wins over `format` (property only). */\r\n @property({ attribute: false }) displayValue: ((value: unknown, item: any) => string) | null = null;\r\n\r\n /** `text` (default) or `icon` (read-only check icon) for boolean columns. */\r\n @property({ attribute: 'boolean-display' }) booleanDisplay: GridColumnBooleanDisplay | null = null;\r\n\r\n /** Wraps the text in several lines instead of an ellipsis (`wrap=\"false\"` turns it off). */\r\n @property({ type: Boolean, converter: booleanAttribute(false) }) wrap = false;\r\n\r\n /** Minimum width in px (also when resizing and auto-sizing). */\r\n @property({ type: Number, attribute: 'min-width' }) minWidth: number | null = null;\r\n\r\n /** Text for empty values (`null`/`undefined`). */\r\n @property({ attribute: 'empty-text' }) emptyText: string | null = null;\r\n\r\n /** Maximum width in px when resizing and auto-sizing. */\r\n @property({ type: Number, attribute: 'max-width' }) maxWidth: number | null = null;\r\n\r\n /**\r\n * Order in which the column leaves the table when the grid is too narrow\r\n * (`auto-hide-columns`; its values move to the row details): the lowest\r\n * goes first, ties from the end. When any column has a `hiding-priority`\r\n * (grouped or hidden ones included), only those columns hide; otherwise\r\n * columns hide from the last one. Fixed columns never hide. Empty or not a\r\n * number = none. Ignored on bands.\r\n */\r\n @property({ converter: optionalNumberAttribute, attribute: 'hiding-priority' }) hidingPriority: number | null = null;\r\n\r\n /** `resizable=\"false\"` prevents resizing this column even with `column-resizing`. */\r\n @property({ converter: optionalBoolean }) resizable: boolean | null = null;\r\n\r\n /**\r\n * Fixes the column at the `start` or `end` of the scrollable area (logical:\r\n * mirrors in RTL). A fixed band fixes its columns; ignored on nested columns.\r\n */\r\n @property({ converter: fixedSide }) fixed: GridColumnFixed = null;\r\n\r\n /** INITIAL visibility (`visible=\"false\"` hides). Afterwards the user changes it in the chooser. */\r\n @property({ converter: optionalBoolean }) visible: boolean | null = null;\r\n\r\n /** `show-in-chooser=\"false\"` removes the column from the chooser (the user cannot hide it). */\r\n @property({ converter: optionalBoolean, attribute: 'show-in-chooser' }) showInChooser: boolean | null = null;\r\n\r\n /** Allows sorting by this column. Default: `true` when it has a `path`, `valueGetter` or `comparator`. */\r\n @property({ converter: optionalBoolean }) sortable: boolean | null = null;\r\n\r\n /** Initial sort direction. Afterwards the sorting is grid state. */\r\n @property({ attribute: 'sort-order' }) sortOrder: GridSortOrder | null = null;\r\n\r\n /** Priority of the initial sort among columns (lower first). */\r\n @property({ type: Number, attribute: 'sort-index' }) sortIndex: number | null = null;\r\n\r\n /** Custom ascending comparator: `(valueA, valueB, itemA, itemB) => number`. */\r\n @property({ attribute: false }) comparator: GridColumnComparator | null = null;\r\n\r\n /**\r\n * Value used to GROUP by this column (a range or bucket: decade, initial\r\n * letter), property only. Groups are identified, sorted and shown by the\r\n * returned value; `dataType`, `comparator`, `format` and `displayValue` do\r\n * not apply to it.\r\n */\r\n @property({ attribute: false }) groupValueGetter: ((item: any) => unknown) | null = null;\r\n\r\n /**\r\n * Allows the user to group by this column (`groupable=\"false\"` prevents\r\n * it). Default: `true` when it has a `path`, `valueGetter` or\r\n * `groupValueGetter`. Only limits the user: `groupColumn()` still works.\r\n */\r\n @property({ converter: optionalBoolean }) groupable: boolean | null = null;\r\n\r\n /**\r\n * Allows filtering by this column (filter row, header filter and, by\r\n * default, the search panel). Default (`null`): `true` when the column has\r\n * a `path`. `filterable=\"false\"` disables it.\r\n */\r\n @property({ converter: optionalBoolean }) filterable: boolean | null = null;\r\n\r\n /**\r\n * Includes this column in exports (`exportCsv`, `getExportData`, the\r\n * xlsx adapter) and in Ctrl+C. Default (`null`): `true` when it has a\r\n * `path`, `valueGetter` or `displayValue` (a `renderer`-only column has no\r\n * text). `exportable=\"false\"` leaves it out.\r\n */\r\n @property({ converter: optionalBoolean }) exportable: boolean | null = null;\r\n\r\n /**\r\n * Operations of the filter row operation menu. Attribute: space separated\r\n * list (`filter-operations=\"contains startswith =\"`); unknown tokens are\r\n * ignored with a warning. Default by data type.\r\n */\r\n @property({ converter: filterOperationsAttribute, attribute: 'filter-operations' }) filterOperations: readonly GridFilterOperation[] | null = null;\r\n\r\n /**\r\n * Operation of the filter row editor. Default: `contains` for text, `=`\r\n * otherwise; one outside `filterOperations` falls back to the first of the\r\n * list. Unknown attribute values are ignored with a warning.\r\n */\r\n @property({ converter: filterOperationAttribute, attribute: 'default-filter-operation' }) defaultFilterOperation: GridFilterOperation | null = null;\r\n\r\n /**\r\n * Allows editing the cells of this column (with `allow-editing` on the\r\n * grid). Default (`null`): `true` when it has a `path` or a\r\n * `valueSetter`. `editable=\"false\"` makes it read-only.\r\n */\r\n @property({ converter: optionalBoolean }) editable: boolean | null = null;\r\n\r\n /** Builds the cell editor instead of the built-in one (property only). See `GridEditorRenderer`. */\r\n @property({ attribute: false }) editorRenderer: GridEditorRenderer | null = null;\r\n\r\n /** Rules checked when a value is committed and before saving (property only). See `GridValidationRule`. */\r\n @property({ attribute: false }) validationRules: readonly GridValidationRule[] | null = null;\r\n\r\n /** Writes an edited value into the pending change of the row (property only). Default: sets `path`. */\r\n @property({ attribute: false }) valueSetter: GridValueSetter | null = null;\r\n\r\n override attributeChangedCallback(name: string, old: string | null, value: string | null): void {\r\n const renamed = LEGACY_ATTRIBUTES[name];\r\n\r\n if (renamed) {\r\n this.#deprecated(`${name} attribute`, `${renamed} attribute`);\r\n // Conversor e propriedade são os do atributo novo.\r\n super.attributeChangedCallback(renamed, old, value);\r\n return;\r\n }\r\n\r\n super.attributeChangedCallback(name, old, value);\r\n }\r\n\r\n override willUpdate(changed: PropertyValues<this>): void {\r\n // Os valores iniciais o grid já lê ao montar as colunas.\r\n if (!this.hasUpdated) {\r\n return;\r\n }\r\n\r\n if (changed.has('path') || changed.has('valueGetter') || changed.has('dataType') || changed.has('comparator') || changed.has('groupValueGetter')) {\r\n this.#notify('value');\r\n } else if (changed.size) {\r\n this.#notify('display');\r\n }\r\n }\r\n\r\n /**\r\n * Nested `<u-grid-column>` elements (read-only): when there is at least\r\n * one, this column is a band. `null` without nested columns. The array is\r\n * frozen and stays the same while the nested columns don't change.\r\n */\r\n get columns(): readonly DataGridColumn[] | null {\r\n const nested = Array.from(this.children).filter(isColumnElement);\r\n\r\n if (!sameElements(nested, this.#nested)) {\r\n this.#nested = Object.freeze(nested);\r\n }\r\n\r\n return this.#nested.length ? this.#nested : null;\r\n }\r\n\r\n /** Header label: the trimmed text content of the element, without the text of nested columns. */\r\n get label(): string {\r\n if (!this.columns) {\r\n return (this.textContent ?? '').trim();\r\n }\r\n\r\n let text = '';\r\n\r\n for (const node of this.childNodes) {\r\n if (!isColumnElement(node)) {\r\n text += node.textContent ?? '';\r\n }\r\n }\r\n\r\n return text.trim();\r\n }\r\n\r\n // Só para saber quando as colunas aninhadas mudam (o grid não mostra este conteúdo).\r\n protected override render() {\r\n return html`<slot @slotchange=${this.#onSlotChange}></slot>`;\r\n }\r\n\r\n // O grid compara a árvore e ignora quando nada mudou.\r\n readonly #onSlotChange = (): void => this.#notify('columns');\r\n\r\n #deprecated(name: string, replacement: string): void {\r\n if (this.#warnedDeprecations.has(name)) {\r\n return;\r\n }\r\n\r\n this.#warnedDeprecations.add(name);\r\n console.warn(`<u-grid-column>: \"${name}\" is deprecated, use \"${replacement}\" instead.`);\r\n }\r\n\r\n #notify(change: GridColumnChange): void {\r\n // Coluna aninhada: sobe pelas bandas até o grid.\r\n let host = this.parentElement;\r\n\r\n while (host && !isColumnHost(host) && isColumnElement(host)) {\r\n host = host.parentElement;\r\n }\r\n\r\n if (isColumnHost(host)) {\r\n host._columnChanged(this, change);\r\n }\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n 'u-grid-column': DataGridColumn;\r\n }\r\n}\r\n"]}
|