@universal-material/data-grid 0.1.0 → 0.2.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.
Files changed (37) hide show
  1. package/README.md +37 -20
  2. package/custom-elements.json +35 -7
  3. package/dist/export/types.d.ts +1 -1
  4. package/dist/export/types.js.map +1 -1
  5. package/dist/features/column-chooser.js +3 -2
  6. package/dist/features/column-chooser.js.map +1 -1
  7. package/dist/features/filter-row.js +4 -3
  8. package/dist/features/filter-row.js.map +1 -1
  9. package/dist/features/header-filter.d.ts +5 -1
  10. package/dist/features/header-filter.js +15 -6
  11. package/dist/features/header-filter.js.map +1 -1
  12. package/dist/features/scroll-port.d.ts +51 -0
  13. package/dist/features/scroll-port.js +329 -0
  14. package/dist/features/scroll-port.js.map +1 -0
  15. package/dist/grid-column-def.d.ts +16 -4
  16. package/dist/grid-column-def.js.map +1 -1
  17. package/dist/grid-column.d.ts +8 -2
  18. package/dist/grid-column.js +8 -2
  19. package/dist/grid-column.js.map +1 -1
  20. package/dist/grid.d.ts +30 -4
  21. package/dist/grid.js +505 -112
  22. package/dist/grid.js.map +1 -1
  23. package/dist/grid.min.js +592 -484
  24. package/dist/grid.styles.js +111 -9
  25. package/dist/grid.styles.js.map +1 -1
  26. package/dist/render/group-row.js +2 -1
  27. package/dist/render/group-row.js.map +1 -1
  28. package/dist/render/header.d.ts +17 -1
  29. package/dist/render/header.js +23 -2
  30. package/dist/render/header.js.map +1 -1
  31. package/dist/render/virtualizer.d.ts +49 -1
  32. package/dist/render/virtualizer.js +229 -17
  33. package/dist/render/virtualizer.js.map +1 -1
  34. package/dist/row-model/columns.d.ts +22 -0
  35. package/dist/row-model/columns.js +15 -0
  36. package/dist/row-model/columns.js.map +1 -1
  37. package/package.json +7 -3
@@ -0,0 +1,329 @@
1
+ import { ScrollPort } from '../render/virtualizer.js';
2
+ /** Tempo máximo de espera pelo `scrollend` (navegador sem o evento, rolagem interrompida). */
3
+ const SCROLL_END_TIMEOUT = 2000;
4
+ /** `<html>`/`scrollingElement` = a janela (o `<body>` só no modo quirks, quando é o `scrollingElement`). */
5
+ const isViewportElement = (element) => {
6
+ const document = element.ownerDocument;
7
+ return element === document.documentElement || element === document.scrollingElement;
8
+ };
9
+ /** Pai na árvore "composta": o pai, ou o host da shadow root. */
10
+ const composedParent = (node) => {
11
+ if (node.parentElement) {
12
+ return node.parentElement;
13
+ }
14
+ const root = node.parentNode;
15
+ return root instanceof ShadowRoot ? root.host : null;
16
+ };
17
+ /**
18
+ * Rolagem por um contêiner externo (spec 27): resolve o contêiner pedido
19
+ * (`scroll-container` / `scrollContainerElement`), avisa no console quando
20
+ * ele não serve, liga o modo pela folha de estilo da instância e ouve a
21
+ * porta (rolagem, tamanho, linhas que se movem sem rolagem). Tudo é solto ao
22
+ * trocar de contêiner e no `hostDisconnected` (spec 14).
23
+ */
24
+ export class ScrollPortController {
25
+ #host;
26
+ #callbacks;
27
+ #port = null;
28
+ /** Já resolveu ao menos uma vez desde a conexão (antes disso, vale o pedido). */
29
+ #resolved = false;
30
+ #warned = new Set();
31
+ #sheet;
32
+ #sheetText = '';
33
+ #resizeObserver;
34
+ #intersectionObserver;
35
+ #observedRows = new Set();
36
+ /** Esperas de `scrollend` em curso: o temporizador de reserva de cada uma. */
37
+ #scrollEndWaits = new Map();
38
+ constructor(host, callbacks) {
39
+ this.#host = host;
40
+ this.#callbacks = callbacks;
41
+ host.addController(this);
42
+ }
43
+ hostConnected() {
44
+ this.resolve();
45
+ }
46
+ hostDisconnected() {
47
+ this.#detach();
48
+ this.#resolved = false;
49
+ }
50
+ /** Porta externa resolvida (`null` = rolagem interna). */
51
+ get port() {
52
+ return this.#port;
53
+ }
54
+ /**
55
+ * Modo externo no render: resolvido, ou pedido e ainda não resolvido (SSR,
56
+ * 1º render antes da conexão) — o servidor e a hidratação desenham igual.
57
+ */
58
+ get external() {
59
+ return this.#resolved ? this.#port !== null : this.#requested();
60
+ }
61
+ #requested() {
62
+ const { scrollContainer, scrollContainerElement } = this.#host;
63
+ return !!scrollContainerElement || !!scrollContainer?.trim();
64
+ }
65
+ /** Avisos por objeto (contêiner, ancestral, host): um por valor, sem segurar o objeto. */
66
+ #warnedObjects = new WeakMap();
67
+ #warnOnce(target, message) {
68
+ const seen = this.#warnedObjects.get(target) ?? new Set();
69
+ if (!seen.has(message)) {
70
+ seen.add(message);
71
+ this.#warnedObjects.set(target, seen);
72
+ console.warn(`<u-grid>: ${message}`);
73
+ }
74
+ }
75
+ /** Altura dada ao host no modo externo corta as linhas (o grid precisa crescer com o conteúdo). */
76
+ checkHeight() {
77
+ const host = this.#host;
78
+ if (this.#port && host.scrollHeight > host.clientHeight + 1) {
79
+ this.#warnOnce(host, 'with scroll-container the grid grows to its content; do not give it a height (it clips the rows).');
80
+ }
81
+ }
82
+ #warn(key, message) {
83
+ if (!this.#warned.has(key)) {
84
+ this.#warned.add(key);
85
+ console.warn(`<u-grid>: ${message}`);
86
+ }
87
+ }
88
+ /** Resolve o contêiner pedido; chamado na conexão e quando as duas propriedades mudam. */
89
+ resolve() {
90
+ const host = this.#host;
91
+ if (!host.isConnected) {
92
+ return;
93
+ }
94
+ const source = this.#find();
95
+ this.#resolved = true;
96
+ if (source !== (this.#port?.source ?? null)) {
97
+ this.#detach();
98
+ if (source) {
99
+ this.#attach(new ScrollPort(source));
100
+ }
101
+ host.requestUpdate();
102
+ }
103
+ this.#syncSheet();
104
+ }
105
+ #find() {
106
+ const host = this.#host;
107
+ const element = host.scrollContainerElement;
108
+ const view = host.ownerDocument.defaultView;
109
+ if (element) {
110
+ if (element === view || (element instanceof Element && isViewportElement(element))) {
111
+ this.#checkBetween(null);
112
+ return view;
113
+ }
114
+ // Outro realm (iframe), SVG ou algo que não é elemento ancestral nem a janela deste documento.
115
+ if (!(element instanceof HTMLElement) || !this.#isAncestor(element)) {
116
+ this.#warnOnce(element, 'scrollContainerElement must be an ancestor element of the grid (or window); using the grid\'s own scrolling.');
117
+ return null;
118
+ }
119
+ this.#checkBetween(element);
120
+ return element;
121
+ }
122
+ const id = host.scrollContainer;
123
+ if (id === null || id === undefined) {
124
+ return null;
125
+ }
126
+ const wanted = id.trim();
127
+ if (!wanted) {
128
+ this.#warn('empty', 'scroll-container is empty; using the grid\'s own scrolling.');
129
+ return null;
130
+ }
131
+ if (wanted === 'window') {
132
+ this.#checkBetween(null);
133
+ return view;
134
+ }
135
+ for (let node = composedParent(host); node; node = composedParent(node)) {
136
+ if (node.id === wanted) {
137
+ if (isViewportElement(node)) {
138
+ this.#checkBetween(null);
139
+ return view;
140
+ }
141
+ this.#checkBetween(node);
142
+ return node;
143
+ }
144
+ }
145
+ this.#warn(`id:${wanted}`, `scroll-container="${wanted}": no ancestor with this id; using the grid's own scrolling.`);
146
+ return null;
147
+ }
148
+ #isAncestor(element) {
149
+ for (let node = composedParent(this.#host); node; node = composedParent(node)) {
150
+ if (node === element) {
151
+ return true;
152
+ }
153
+ }
154
+ return false;
155
+ }
156
+ /** Ancestral entre o grid e o contêiner que corta/rola: o `sticky` gruda nele, não no contêiner. */
157
+ #checkBetween(container) {
158
+ const document = this.#host.ownerDocument;
159
+ for (let node = composedParent(this.#host); node && node !== container; node = composedParent(node)) {
160
+ if (node === document.documentElement || node === document.body) {
161
+ break;
162
+ }
163
+ const style = getComputedStyle(node);
164
+ if (![style.overflowX, style.overflowY].every(value => value === 'visible' || value === 'clip')) {
165
+ this.#warnOnce(node, 'an ancestor between the grid and its scroll container has overflow set; sticky headers will stick to it instead.');
166
+ return;
167
+ }
168
+ }
169
+ }
170
+ /**
171
+ * Folha da instância: o modo externo vindo só da propriedade (`height:
172
+ * auto` no host) e, com o atributo, a anulação quando ele não resolveu (o
173
+ * grid não pode ficar sem altura e sem rolagem).
174
+ */
175
+ #syncSheet() {
176
+ const root = this.#host.shadowRoot;
177
+ const attribute = this.#host.hasAttribute('scroll-container');
178
+ const text = this.#port && !attribute
179
+ ? ':host { height: auto; overflow-anchor: none; }'
180
+ : !this.#port && attribute
181
+ ? ':host([scroll-container]:not([scroll-container=""])) { height: 100%; overflow-anchor: auto; }'
182
+ : '';
183
+ if (!root || text === this.#sheetText || typeof CSSStyleSheet === 'undefined' || !('adoptedStyleSheets' in root)) {
184
+ return;
185
+ }
186
+ this.#sheetText = text;
187
+ const sheets = root.adoptedStyleSheets.filter(sheet => sheet !== this.#sheet);
188
+ if (text) {
189
+ this.#sheet ??= new CSSStyleSheet();
190
+ this.#sheet.replaceSync(text);
191
+ sheets.push(this.#sheet);
192
+ }
193
+ root.adoptedStyleSheets = sheets;
194
+ }
195
+ #attach(port) {
196
+ this.#port = port;
197
+ port.target.addEventListener('scroll', this.#onScroll, { passive: true });
198
+ if (port.isWindow) {
199
+ port.target.addEventListener('resize', this.#onMoved, { passive: true });
200
+ }
201
+ else if (typeof ResizeObserver !== 'undefined') {
202
+ this.#resizeObserver = new ResizeObserver(this.#onMoved);
203
+ this.#resizeObserver.observe(port.element);
204
+ }
205
+ if (typeof IntersectionObserver !== 'undefined') {
206
+ // O conteúdo acima do grid muda de altura sem rolagem: as linhas
207
+ // renderizadas entram/saem da porta e o grid relê a posição.
208
+ this.#intersectionObserver = new IntersectionObserver(this.#onIntersect, {
209
+ root: port.isWindow ? null : port.element,
210
+ threshold: [0, 1],
211
+ });
212
+ }
213
+ }
214
+ #detach() {
215
+ const port = this.#port;
216
+ if (port) {
217
+ port.target.removeEventListener('scroll', this.#onScroll);
218
+ port.target.removeEventListener('resize', this.#onMoved);
219
+ }
220
+ this.#resizeObserver?.disconnect();
221
+ this.#resizeObserver = undefined;
222
+ this.#intersectionObserver?.disconnect();
223
+ this.#intersectionObserver = undefined;
224
+ this.#observedRows.clear();
225
+ // Esperas em curso terminam já (soltam os próprios listeners e o quadro).
226
+ for (const done of [...this.#scrollEndWaits.keys()]) {
227
+ done();
228
+ }
229
+ this.#port = null;
230
+ }
231
+ #onScroll = () => {
232
+ this.#callbacks.scroll();
233
+ };
234
+ #onMoved = () => {
235
+ this.#callbacks.moved();
236
+ };
237
+ /** Ignora a 1ª entrega de cada alvo (o `observe` sempre entrega uma). */
238
+ #seen = new WeakSet();
239
+ #onIntersect = (entries) => {
240
+ let moved = false;
241
+ for (const entry of entries) {
242
+ if (this.#seen.has(entry.target)) {
243
+ moved = true;
244
+ }
245
+ else {
246
+ this.#seen.add(entry.target);
247
+ }
248
+ }
249
+ if (moved) {
250
+ this.#callbacks.moved();
251
+ }
252
+ };
253
+ /** Observa as linhas renderizadas do corpo (só as novas; solta as que saíram). */
254
+ observeRows(rows) {
255
+ const observer = this.#intersectionObserver;
256
+ if (!observer) {
257
+ return;
258
+ }
259
+ const wanted = new Set(rows);
260
+ for (const row of this.#observedRows) {
261
+ if (!wanted.has(row)) {
262
+ observer.unobserve(row);
263
+ this.#observedRows.delete(row);
264
+ }
265
+ }
266
+ for (const row of wanted) {
267
+ if (!this.#observedRows.has(row)) {
268
+ observer.observe(row);
269
+ this.#observedRows.add(row);
270
+ }
271
+ }
272
+ }
273
+ /** Quantas linhas estão observadas agora (diagnóstico, testes de vazamento). */
274
+ get observedRows() {
275
+ return this.#observedRows.size;
276
+ }
277
+ /** Esperas de `scrollend` em curso (diagnóstico, spec 14). */
278
+ get scrollEndWaits() {
279
+ return this.#scrollEndWaits.size;
280
+ }
281
+ /** Chama `callback` quando a rolagem da porta acabar (ou no tempo limite). */
282
+ afterScrollEnd(callback) {
283
+ const port = this.#port;
284
+ if (!port) {
285
+ callback();
286
+ return;
287
+ }
288
+ let moving = false;
289
+ let frame = 0;
290
+ const scrolled = () => {
291
+ moving = true;
292
+ };
293
+ const done = () => {
294
+ const timer = this.#scrollEndWaits.get(done);
295
+ if (timer === undefined) {
296
+ return;
297
+ }
298
+ clearTimeout(timer);
299
+ cancelAnimationFrame(frame);
300
+ this.#scrollEndWaits.delete(done);
301
+ port.target.removeEventListener('scrollend', done);
302
+ port.target.removeEventListener('scroll', scrolled);
303
+ callback();
304
+ };
305
+ this.#scrollEndWaits.set(done, setTimeout(done, SCROLL_END_TIMEOUT));
306
+ port.target.addEventListener('scrollend', done);
307
+ port.target.addEventListener('scroll', scrolled, { passive: true });
308
+ // Nada a rolar (o destino já estava à vista): não vem `scrollend`.
309
+ frame = requestAnimationFrame(() => {
310
+ frame = requestAnimationFrame(() => {
311
+ if (!moving) {
312
+ done();
313
+ }
314
+ });
315
+ });
316
+ }
317
+ /** `scroll-padding` do contêiner (o que o hospedeiro gruda nele), em px. */
318
+ padding() {
319
+ const port = this.#port;
320
+ if (!port) {
321
+ return { top: 0, bottom: 0 };
322
+ }
323
+ const style = getComputedStyle(port.element);
324
+ const top = parseFloat(style.scrollPaddingTop);
325
+ const bottom = parseFloat(style.scrollPaddingBottom);
326
+ return { top: Number.isFinite(top) ? top : 0, bottom: Number.isFinite(bottom) ? bottom : 0 };
327
+ }
328
+ }
329
+ //# sourceMappingURL=scroll-port.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scroll-port.js","sourceRoot":"","sources":["../../src/features/scroll-port.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAetD,8FAA8F;AAC9F,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEhC,4GAA4G;AAC5G,MAAM,iBAAiB,GAAG,CAAC,OAAgB,EAAW,EAAE;IACtD,MAAM,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC;IACvC,OAAO,OAAO,KAAK,QAAQ,CAAC,eAAe,IAAI,OAAO,KAAK,QAAQ,CAAC,gBAAgB,CAAC;AACvF,CAAC,CAAC;AAEF,iEAAiE;AACjE,MAAM,cAAc,GAAG,CAAC,IAAU,EAAkB,EAAE;IACpD,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;IAC7B,OAAO,IAAI,YAAY,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,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C;IAED,4EAA4E;IAC5E,OAAO;QACL,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;QAExB,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QAC/B,CAAC;QAED,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7C,MAAM,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAErD,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/F,CAAC;CACF","sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit';\n\nimport { ScrollPort } from '../render/virtualizer.js';\n\n/** O que o controller precisa do grid. */\nexport interface ScrollPortHost extends ReactiveControllerHost, HTMLElement {\n scrollContainer: string | null;\n scrollContainerElement: HTMLElement | Window | null;\n}\n\nexport interface ScrollPortCallbacks {\n /** Rolagem da porta externa (janela de colunas, sombras, painel de carga). */\n scroll: () => void;\n /** A porta externa mudou de tamanho ou o grid se moveu dentro dela sem rolagem. */\n moved: () => void;\n}\n\n/** Tempo máximo de espera pelo `scrollend` (navegador sem o evento, rolagem interrompida). */\nconst SCROLL_END_TIMEOUT = 2000;\n\n/** `<html>`/`scrollingElement` = a janela (o `<body>` só no modo quirks, quando é o `scrollingElement`). */\nconst isViewportElement = (element: Element): boolean => {\n const document = element.ownerDocument;\n return element === document.documentElement || element === document.scrollingElement;\n};\n\n/** Pai na árvore \"composta\": o pai, ou o host da shadow root. */\nconst composedParent = (node: Node): Element | null => {\n if (node.parentElement) {\n return node.parentElement;\n }\n\n const root = node.parentNode;\n return root instanceof ShadowRoot ? root.host : null;\n};\n\n/**\n * Rolagem por um contêiner externo (spec 27): resolve o contêiner pedido\n * (`scroll-container` / `scrollContainerElement`), avisa no console quando\n * ele não serve, liga o modo pela folha de estilo da instância e ouve a\n * porta (rolagem, tamanho, linhas que se movem sem rolagem). Tudo é solto ao\n * trocar de contêiner e no `hostDisconnected` (spec 14).\n */\nexport class ScrollPortController implements ReactiveController {\n readonly #host: ScrollPortHost;\n readonly #callbacks: ScrollPortCallbacks;\n\n #port: ScrollPort | null = null;\n /** Já resolveu ao menos uma vez desde a conexão (antes disso, vale o pedido). */\n #resolved = false;\n readonly #warned = new Set<string>();\n #sheet: CSSStyleSheet | undefined;\n #sheetText = '';\n #resizeObserver: ResizeObserver | undefined;\n #intersectionObserver: IntersectionObserver | undefined;\n readonly #observedRows = new Set<Element>();\n /** Esperas de `scrollend` em curso: o temporizador de reserva de cada uma. */\n readonly #scrollEndWaits = new Map<() => void, ReturnType<typeof setTimeout>>();\n\n constructor(host: ScrollPortHost, callbacks: ScrollPortCallbacks) {\n this.#host = host;\n this.#callbacks = callbacks;\n host.addController(this);\n }\n\n hostConnected(): void {\n this.resolve();\n }\n\n hostDisconnected(): void {\n this.#detach();\n this.#resolved = false;\n }\n\n /** Porta externa resolvida (`null` = rolagem interna). */\n get port(): ScrollPort | null {\n return this.#port;\n }\n\n /**\n * Modo externo no render: resolvido, ou pedido e ainda não resolvido (SSR,\n * 1º render antes da conexão) — o servidor e a hidratação desenham igual.\n */\n get external(): boolean {\n return this.#resolved ? this.#port !== null : this.#requested();\n }\n\n #requested(): boolean {\n const { scrollContainer, scrollContainerElement } = this.#host;\n return !!scrollContainerElement || !!scrollContainer?.trim();\n }\n\n /** Avisos por objeto (contêiner, ancestral, host): um por valor, sem segurar o objeto. */\n readonly #warnedObjects = new WeakMap<object, Set<string>>();\n\n #warnOnce(target: object, message: string): void {\n const seen = this.#warnedObjects.get(target) ?? new Set<string>();\n\n if (!seen.has(message)) {\n seen.add(message);\n this.#warnedObjects.set(target, seen);\n console.warn(`<u-grid>: ${message}`);\n }\n }\n\n /** Altura dada ao host no modo externo corta as linhas (o grid precisa crescer com o conteúdo). */\n checkHeight(): void {\n const host = this.#host;\n\n if (this.#port && host.scrollHeight > host.clientHeight + 1) {\n this.#warnOnce(host, 'with scroll-container the grid grows to its content; do not give it a height (it clips the rows).');\n }\n }\n\n #warn(key: string, message: string): void {\n if (!this.#warned.has(key)) {\n this.#warned.add(key);\n console.warn(`<u-grid>: ${message}`);\n }\n }\n\n /** Resolve o contêiner pedido; chamado na conexão e quando as duas propriedades mudam. */\n resolve(): void {\n const host = this.#host;\n\n if (!host.isConnected) {\n return;\n }\n\n const source = this.#find();\n this.#resolved = true;\n\n if (source !== (this.#port?.source ?? null)) {\n this.#detach();\n\n if (source) {\n this.#attach(new ScrollPort(source));\n }\n\n host.requestUpdate();\n }\n\n this.#syncSheet();\n }\n\n #find(): HTMLElement | Window | null {\n const host = this.#host;\n const element = host.scrollContainerElement;\n const view = host.ownerDocument.defaultView;\n\n if (element) {\n if (element === view || (element instanceof Element && isViewportElement(element))) {\n this.#checkBetween(null);\n return view;\n }\n\n // Outro realm (iframe), SVG ou algo que não é elemento ancestral nem a janela deste documento.\n if (!(element instanceof HTMLElement) || !this.#isAncestor(element)) {\n this.#warnOnce(element, 'scrollContainerElement must be an ancestor element of the grid (or window); using the grid\\'s own scrolling.');\n return null;\n }\n\n this.#checkBetween(element);\n return element;\n }\n\n const id = host.scrollContainer;\n\n if (id === null || id === undefined) {\n return null;\n }\n\n const wanted = id.trim();\n\n if (!wanted) {\n this.#warn('empty', 'scroll-container is empty; using the grid\\'s own scrolling.');\n return null;\n }\n\n if (wanted === 'window') {\n this.#checkBetween(null);\n return view;\n }\n\n for (let node = composedParent(host); node; node = composedParent(node)) {\n if (node.id === wanted) {\n if (isViewportElement(node)) {\n this.#checkBetween(null);\n return view;\n }\n\n this.#checkBetween(node as HTMLElement);\n return node as HTMLElement;\n }\n }\n\n this.#warn(`id:${wanted}`, `scroll-container=\"${wanted}\": no ancestor with this id; using the grid's own scrolling.`);\n return null;\n }\n\n #isAncestor(element: Element): boolean {\n for (let node = composedParent(this.#host); node; node = composedParent(node)) {\n if (node === element) {\n return true;\n }\n }\n\n return false;\n }\n\n /** Ancestral entre o grid e o contêiner que corta/rola: o `sticky` gruda nele, não no contêiner. */\n #checkBetween(container: HTMLElement | null): void {\n const document = this.#host.ownerDocument;\n\n for (let node = composedParent(this.#host); node && node !== container; node = composedParent(node)) {\n if (node === document.documentElement || node === document.body) {\n break;\n }\n\n const style = getComputedStyle(node);\n\n if (![style.overflowX, style.overflowY].every(value => value === 'visible' || value === 'clip')) {\n this.#warnOnce(node, 'an ancestor between the grid and its scroll container has overflow set; sticky headers will stick to it instead.');\n return;\n }\n }\n }\n\n /**\n * Folha da instância: o modo externo vindo só da propriedade (`height:\n * auto` no host) e, com o atributo, a anulação quando ele não resolveu (o\n * grid não pode ficar sem altura e sem rolagem).\n */\n #syncSheet(): void {\n const root = this.#host.shadowRoot;\n const attribute = this.#host.hasAttribute('scroll-container');\n const text = this.#port && !attribute\n ? ':host { height: auto; overflow-anchor: none; }'\n : !this.#port && attribute\n ? ':host([scroll-container]:not([scroll-container=\"\"])) { height: 100%; overflow-anchor: auto; }'\n : '';\n\n if (!root || text === this.#sheetText || typeof CSSStyleSheet === 'undefined' || !('adoptedStyleSheets' in root)) {\n return;\n }\n\n this.#sheetText = text;\n const sheets = root.adoptedStyleSheets.filter(sheet => sheet !== this.#sheet);\n\n if (text) {\n this.#sheet ??= new CSSStyleSheet();\n this.#sheet.replaceSync(text);\n sheets.push(this.#sheet);\n }\n\n root.adoptedStyleSheets = sheets;\n }\n\n #attach(port: ScrollPort): void {\n this.#port = port;\n port.target.addEventListener('scroll', this.#onScroll, { passive: true });\n\n if (port.isWindow) {\n port.target.addEventListener('resize', this.#onMoved, { passive: true });\n } else if (typeof ResizeObserver !== 'undefined') {\n this.#resizeObserver = new ResizeObserver(this.#onMoved);\n this.#resizeObserver.observe(port.element);\n }\n\n if (typeof IntersectionObserver !== 'undefined') {\n // O conteúdo acima do grid muda de altura sem rolagem: as linhas\n // renderizadas entram/saem da porta e o grid relê a posição.\n this.#intersectionObserver = new IntersectionObserver(this.#onIntersect, {\n root: port.isWindow ? null : port.element,\n threshold: [0, 1],\n });\n }\n }\n\n #detach(): void {\n const port = this.#port;\n\n if (port) {\n port.target.removeEventListener('scroll', this.#onScroll);\n port.target.removeEventListener('resize', this.#onMoved);\n }\n\n this.#resizeObserver?.disconnect();\n this.#resizeObserver = undefined;\n this.#intersectionObserver?.disconnect();\n this.#intersectionObserver = undefined;\n this.#observedRows.clear();\n\n // Esperas em curso terminam já (soltam os próprios listeners e o quadro).\n for (const done of [...this.#scrollEndWaits.keys()]) {\n done();\n }\n\n this.#port = null;\n }\n\n readonly #onScroll = (): void => {\n this.#callbacks.scroll();\n };\n\n readonly #onMoved = (): void => {\n this.#callbacks.moved();\n };\n\n /** Ignora a 1ª entrega de cada alvo (o `observe` sempre entrega uma). */\n readonly #seen = new WeakSet<Element>();\n\n readonly #onIntersect = (entries: IntersectionObserverEntry[]): void => {\n let moved = false;\n\n for (const entry of entries) {\n if (this.#seen.has(entry.target)) {\n moved = true;\n } else {\n this.#seen.add(entry.target);\n }\n }\n\n if (moved) {\n this.#callbacks.moved();\n }\n };\n\n /** Observa as linhas renderizadas do corpo (só as novas; solta as que saíram). */\n observeRows(rows: Iterable<Element>): void {\n const observer = this.#intersectionObserver;\n\n if (!observer) {\n return;\n }\n\n const wanted = new Set(rows);\n\n for (const row of this.#observedRows) {\n if (!wanted.has(row)) {\n observer.unobserve(row);\n this.#observedRows.delete(row);\n }\n }\n\n for (const row of wanted) {\n if (!this.#observedRows.has(row)) {\n observer.observe(row);\n this.#observedRows.add(row);\n }\n }\n }\n\n /** Quantas linhas estão observadas agora (diagnóstico, testes de vazamento). */\n get observedRows(): number {\n return this.#observedRows.size;\n }\n\n /** Esperas de `scrollend` em curso (diagnóstico, spec 14). */\n get scrollEndWaits(): number {\n return this.#scrollEndWaits.size;\n }\n\n /** Chama `callback` quando a rolagem da porta acabar (ou no tempo limite). */\n afterScrollEnd(callback: () => void): void {\n const port = this.#port;\n\n if (!port) {\n callback();\n return;\n }\n\n let moving = false;\n let frame = 0;\n\n const scrolled = (): void => {\n moving = true;\n };\n\n const done = (): void => {\n const timer = this.#scrollEndWaits.get(done);\n\n if (timer === undefined) {\n return;\n }\n\n clearTimeout(timer);\n cancelAnimationFrame(frame);\n this.#scrollEndWaits.delete(done);\n port.target.removeEventListener('scrollend', done);\n port.target.removeEventListener('scroll', scrolled);\n callback();\n };\n\n this.#scrollEndWaits.set(done, setTimeout(done, SCROLL_END_TIMEOUT));\n port.target.addEventListener('scrollend', done);\n port.target.addEventListener('scroll', scrolled, { passive: true });\n // Nada a rolar (o destino já estava à vista): não vem `scrollend`.\n frame = requestAnimationFrame(() => {\n frame = requestAnimationFrame(() => {\n if (!moving) {\n done();\n }\n });\n });\n }\n\n /** `scroll-padding` do contêiner (o que o hospedeiro gruda nele), em px. */\n padding(): { top: number; bottom: number } {\n const port = this.#port;\n\n if (!port) {\n return { top: 0, bottom: 0 };\n }\n\n const style = getComputedStyle(port.element);\n const top = parseFloat(style.scrollPaddingTop);\n const bottom = parseFloat(style.scrollPaddingBottom);\n\n return { top: Number.isFinite(top) ? top : 0, bottom: Number.isFinite(bottom) ? bottom : 0 };\n }\n}\n"]}
@@ -50,7 +50,7 @@ export interface GridColumnDef<TItem = any> {
50
50
  /**
51
51
  * Nested columns: a column with at least one nested column is a BAND (a
52
52
  * header over its columns, no cells). In a band only `label`,
53
- * `headerRenderer`, `alignment` (of the label; default `center`), `fixed`,
53
+ * `headerRenderer`, `alignment` (of the label; default `start`), `fixed`,
54
54
  * `visible` and `showInChooser` apply; the other fields are ignored. A band
55
55
  * is shown while it is visible and has a visible column. Columns reorder
56
56
  * only inside their own band; only leaf columns sort, group and export.
@@ -66,7 +66,12 @@ export interface GridColumnDef<TItem = any> {
66
66
  minWidth?: number | null;
67
67
  /** INITIAL grouping level; afterwards grouping is grid state (`groupColumn`, `ungroupColumn`). */
68
68
  groupIndex?: number | null;
69
- /** Header label. */
69
+ /**
70
+ * The column's name as text: the header text (unless `headerRenderer`;
71
+ * empty: `path`) and its name everywhere else (header buttons, group chip
72
+ * and rows, column chooser, row details, announcements, export; empty:
73
+ * `path`, then `name`, as is). Set it also with `headerRenderer`.
74
+ */
70
75
  label?: string;
71
76
  /** Dot path of the cell value in the row item (`"address.city"`). */
72
77
  path?: string;
@@ -99,7 +104,11 @@ export interface GridColumnDef<TItem = any> {
99
104
  * `null`, `undefined` and Lit's `nothing` render an empty cell. See `GridCellRenderer`.
100
105
  */
101
106
  renderer?: GridCellRenderer<TItem> | null;
102
- /** Builds the header label (sort arrow, filter button and resize handle stay). `label` is still required. */
107
+ /**
108
+ * Builds the header label (sort arrow, filter button and resize handle stay; their accessible names
109
+ * follow the rendered text). Set `label` too: it names the column outside the header (without it
110
+ * the grid warns once and uses `path`, then `name`).
111
+ */
103
112
  headerRenderer?: GridHeaderRenderer<TItem> | null;
104
113
  /** Builds the label of the group rows of this column (expand button and aligned summaries stay). */
105
114
  groupRenderer?: GridGroupRenderer<TItem> | null;
@@ -185,7 +194,10 @@ export interface GridColumnDef<TItem = any> {
185
194
  */
186
195
  valueSetter?: GridValueSetter<TItem> | null;
187
196
  }
188
- /** A column of the grid: its `name`, its `path` (first column with that name, else with that path) or the column itself. */
197
+ /**
198
+ * A column of the grid: its `name`, its `path` (first column with that name, else with that path) or the column itself.
199
+ * Leaf columns only, including columns inside a band; a band is not a column reference.
200
+ */
189
201
  export type GridColumnRef<TItem = any> = string | GridColumnDef<TItem>;
190
202
  /** Values of a group from the outermost level, e.g. `['Brazil', 'SP']`. */
191
203
  export type GridGroupPath = readonly unknown[];
@@ -1 +1 @@
1
- {"version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AC,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC","sourcesContent":["import type { nothing, TemplateResult } from 'lit';\r\n\r\nimport type { DataGrid } from './grid.js';\r\n\r\n/** Sort direction: ascending or descending. */\r\nexport type GridSortOrder = 'asc' | 'desc';\r\n\r\n/** A column of the current sorting and its direction (`getSorting()`). */\r\nexport interface GridSort {\r\n column: GridColumnDef;\r\n order: GridSortOrder;\r\n}\r\n\r\n/**\r\n * Custom comparator of a column, in ascending order (the grid applies the\r\n * direction). Receives the cell values and the row items.\r\n */\r\nexport type GridColumnComparator<TItem = any> = (a: any, b: any, itemA: TItem, itemB: TItem) => number;\r\n\r\n/** Data type of a column; without `dataType`, inferred from the first non-null value. */\r\nexport type GridColumnDataType = 'string' | 'number' | 'date' | 'datetime' | 'boolean';\r\n\r\n/** Logical alignment: `start`/`end` follow the direction (RTL). */\r\nexport type GridColumnAlignment = 'start' | 'center' | 'end';\r\n\r\n/** Boolean as text (`trueText`/`falseText`) or as a read-only check icon. */\r\nexport type GridColumnBooleanDisplay = 'text' | 'icon';\r\n\r\n/** Formats a cell value into its displayed text. */\r\nexport type GridColumnFormatter<TItem = any> = (value: unknown, item: TItem) => string;\r\n\r\n/** `Intl` number/date options or a formatter function. */\r\nexport type GridColumnFormat<TItem = any> = Intl.NumberFormatOptions | Intl.DateTimeFormatOptions | GridColumnFormatter<TItem>;\r\n\r\n/**\r\n * Filter operation of a condition. Text operations (`contains`, `notcontains`,\r\n * `startswith`, `endswith`) and `=` on text ignore case and accents.\r\n */\r\nexport type GridFilterOperation =\r\n | '=' | '<>' | '<' | '<=' | '>' | '>='\r\n | 'contains' | 'notcontains' | 'startswith' | 'endswith'\r\n | 'between' | 'anyof' | 'noneof' | 'isblank' | 'isnotblank';\r\n\r\n/**\r\n * One condition: `[path, operation, value]`. `path` is the column `path`;\r\n * `between` takes `[start, end]` (inclusive, either may be `null`), `anyof` /\r\n * `noneof` take a list, `isblank` / `isnotblank` take no value.\r\n */\r\nexport type GridFilterCondition =\r\n | readonly [path: string, operation: GridFilterOperation, value?: unknown]\r\n | readonly [path: string, value: unknown];\r\n\r\n/**\r\n * Serializable filter expression (same shape as DevExtreme): a condition, a\r\n * negation `['!', expression]` or a group of expressions joined by `'and'` /\r\n * `'or'` (`and` binds tighter; two expressions in a row mean `and`).\r\n */\r\nexport type GridFilterExpression =\r\n | GridFilterCondition\r\n | readonly ['!', GridFilterExpression]\r\n | readonly (GridFilterExpression | 'and' | 'or')[];\r\n\r\n/** Side a column is fixed to (logical: mirrors in RTL). */\r\nexport type GridColumnFixed = 'start' | 'end' | null;\r\n\r\n/**\r\n * Column definition (the `columns` property of `<u-grid>`). Mirrors the\r\n * `<u-grid-column>` element: same names, types and defaults. `TItem` types\r\n * the row item in the callbacks.\r\n */\r\nexport interface GridColumnDef<TItem = any> {\r\n /**\r\n * Nested columns: a column with at least one nested column is a BAND (a\r\n * header over its columns, no cells). In a band only `label`,\r\n * `headerRenderer`, `alignment` (of the label; default `center`), `fixed`,\r\n * `visible` and `showInChooser` apply; the other fields are ignored. A band\r\n * is shown while it is visible and has a visible column. Columns reorder\r\n * only inside their own band; only leaf columns sort, group and export.\r\n * `null` or `[]` = a regular column.\r\n */\r\n columns?: readonly GridColumnDef<TItem>[] | null;\r\n /**\r\n * Width in px. Under virtual column rendering (`columnRenderingMode`) a\r\n * column without `width` takes its auto-size width or `max(minWidth, 150)` px.\r\n */\r\n width?: number | null;\r\n /** Minimum width in px (also when resizing and auto-sizing). */\r\n minWidth?: number | null;\r\n /** INITIAL grouping level; afterwards grouping is grid state (`groupColumn`, `ungroupColumn`). */\r\n groupIndex?: number | null;\r\n /** Header label. */\r\n label?: string;\r\n /** Dot path of the cell value in the row item (`\"address.city\"`). */\r\n path?: string;\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 name?: string;\r\n /** Data type; without it, inferred from the first non-null value. */\r\n dataType?: GridColumnDataType | null;\r\n /** `Intl` options or a formatter function. */\r\n format?: GridColumnFormat<TItem> | null;\r\n /** Logical alignment; default by data type (numbers at the end). In a band, of the header label (default `start`). */\r\n alignment?: GridColumnAlignment | null;\r\n /** Cell value used to group, sort and filter. Default: read `path`. */\r\n valueGetter?: ((item: TItem) => unknown) | null;\r\n /** Displayed text (cell and group row); wins over `format`. */\r\n displayValue?: ((value: unknown, item: TItem) => string) | null;\r\n /** Boolean as text (default) or icon; the icon has the text as its accessible name. */\r\n booleanDisplay?: GridColumnBooleanDisplay | null;\r\n /** Wraps the text in several lines instead of an ellipsis. */\r\n wrap?: boolean;\r\n /** Text for empty values (`null`/`undefined`). */\r\n emptyText?: string | null;\r\n /**\r\n * Builds the cell content: a Lit `TemplateResult` (recommended), a string\r\n * (text, never HTML) or an `HTMLElement` (placed in the grid's light DOM).\r\n * `null`, `undefined` and Lit's `nothing` render an empty cell. See `GridCellRenderer`.\r\n */\r\n renderer?: GridCellRenderer<TItem> | null;\r\n /** Builds the header label (sort arrow, filter button and resize handle stay). `label` is still required. */\r\n headerRenderer?: GridHeaderRenderer<TItem> | null;\r\n /** Builds the label of the group rows of this column (expand button and aligned summaries stay). */\r\n groupRenderer?: GridGroupRenderer<TItem> | null;\r\n /** Allows sorting from the header. Default: `true` when the column has a `path`, `valueGetter` or `comparator`. */\r\n sortable?: boolean | null;\r\n /** INITIAL sort direction; afterwards sorting is grid state (`sortColumn`, `getSorting`). */\r\n sortOrder?: GridSortOrder | null;\r\n /** Priority of the initial sort among columns (lower first). */\r\n sortIndex?: number | null;\r\n /** Custom ascending comparator. */\r\n comparator?: GridColumnComparator<TItem> | null;\r\n /**\r\n * Allows filtering by this column (filter row, header filter and, by\r\n * default, the search panel). Default: `true` when the column has a `path`\r\n * (the filter expression refers to columns by `path`).\r\n */\r\n filterable?: boolean | null;\r\n /**\r\n * Operations offered in the filter row operation menu (only the menu: the\r\n * header filter and `filterValue` are not checked). Default by data type.\r\n */\r\n filterOperations?: readonly GridFilterOperation[] | null;\r\n /** Operation of the filter row editor. Default: `contains` for text, `=` otherwise (or the first of `filterOperations`). */\r\n defaultFilterOperation?: GridFilterOperation | null;\r\n /** `false` prevents resizing this column even with `column-resizing`. */\r\n resizable?: boolean | null;\r\n /** Maximum width in px when resizing and auto-sizing. */\r\n maxWidth?: number | null;\r\n /**\r\n * Order in which the column leaves the table when the grid is too narrow\r\n * (`autoHideColumns`; its values move to the row details): the lowest goes\r\n * first, ties from the end. When any column of `columns` has a\r\n * `hidingPriority` (grouped or hidden ones included), only those columns\r\n * hide; otherwise columns hide from the last one. Fixed\r\n * columns never hide. Ignored on bands.\r\n */\r\n hidingPriority?: number | null;\r\n /**\r\n * Fixes the column at the start or end of the scrollable area. A fixed band\r\n * fixes its columns; ignored on nested columns (they follow the top band).\r\n */\r\n fixed?: GridColumnFixed;\r\n /** INITIAL visibility (default `true`); afterwards the user changes it in the chooser. */\r\n visible?: boolean | null;\r\n /** `false` removes the column from the chooser (the user cannot hide it). */\r\n showInChooser?: boolean | null;\r\n /**\r\n * Value used to GROUP by this column instead of the cell value: a range or\r\n * bucket (decade, initial letter). Groups are identified, sorted and shown\r\n * by the returned value; the column `dataType`, `comparator`, `format` and\r\n * `displayValue` do not apply to it. Return a string or a number.\r\n */\r\n groupValueGetter?: ((item: TItem) => unknown) | null;\r\n /**\r\n * Allows the user to group by this column (drag to the group panel).\r\n * Default: `true` when the column has a `path`, `valueGetter` or\r\n * `groupValueGetter`. Only limits the user: `groupColumn()` still works.\r\n */\r\n groupable?: boolean | null;\r\n /**\r\n * Includes this column in exports (`exportCsv`, `getExportData`, the xlsx\r\n * adapter) and in Ctrl+C. Default: `true` when the column has a `path`,\r\n * `valueGetter` or `displayValue` (a `renderer`-only column has no text).\r\n */\r\n exportable?: boolean | null;\r\n /**\r\n * Allows editing the cells of this column (with `allowEditing` on the grid;\r\n * new rows with `allowAdding`). Default: `true` when the column has a\r\n * `path` or a `valueSetter`.\r\n */\r\n editable?: boolean | null;\r\n /**\r\n * Builds the editor of a cell instead of the built-in one (text, number,\r\n * date, checkbox). See `GridEditorRenderer`.\r\n */\r\n editorRenderer?: GridEditorRenderer<TItem> | null;\r\n /** Rules checked when a value is committed and before saving. See `GridValidationRule`. */\r\n validationRules?: readonly GridValidationRule<TItem>[] | null;\r\n /**\r\n * Writes an edited value into `data`, the pending change of the row (a\r\n * partial item owned by the grid). Default: sets `path` (dots create nested\r\n * objects). Set other fields too to edit computed columns.\r\n */\r\n valueSetter?: GridValueSetter<TItem> | null;\r\n}\r\n\r\n/** A column of the grid: its `name`, its `path` (first column with that name, else with that path) or the column itself. */\r\nexport type GridColumnRef<TItem = any> = string | GridColumnDef<TItem>;\r\n\r\n/** Values of a group from the outermost level, e.g. `['Brazil', 'SP']`. */\r\nexport type GridGroupPath = readonly unknown[];\r\n\r\n/** Built-in summary aggregates. `sum`/`min`/`max`/`avg` ignore empty values; `count` counts rows. */\r\nexport type GridSummaryType = 'sum' | 'min' | 'max' | 'avg' | 'count';\r\n\r\n/** Custom aggregate: receives the column values and the row items of the group (or of all rows). */\r\nexport type GridSummaryAggregator<TItem = any> = (values: readonly unknown[], items: readonly TItem[]) => unknown;\r\n\r\n/** `Intl` options or a function that formats the summary value. */\r\nexport type GridSummaryFormat = Intl.NumberFormatOptions | Intl.DateTimeFormatOptions | ((value: unknown) => string);\r\n\r\n/** A summary (aggregate) of a column. */\r\nexport interface GridSummaryItem<TItem = any> {\r\n /** Column whose values are aggregated and under which the summary is shown. */\r\n column: GridColumnRef<TItem>;\r\n /** Built-in aggregate or a custom function. */\r\n type: GridSummaryType | GridSummaryAggregator<TItem>;\r\n /**\r\n * Replaces the aggregate name in the text (`\"Total: 1,234\"`). Without it a\r\n * custom aggregate shows `\"{column}: {value}\"` in group rows and only the\r\n * value in cells.\r\n */\r\n label?: string;\r\n /**\r\n * Formats the value. Default: the column `format` when it is `Intl`\r\n * options (a formatter function is not inherited); `count` uses the\r\n * integer format of the language.\r\n */\r\n format?: GridSummaryFormat | null;\r\n /** Identifies the summary in `getSummaryValues()`. */\r\n name?: string;\r\n}\r\n\r\n/** A summary of each group. */\r\nexport interface GridGroupSummaryItem<TItem = any> extends GridSummaryItem<TItem> {\r\n /**\r\n * Where it is shown: `inline` (default) in the group row text,\r\n * `column` in the group row under its column, `footer` in a footer row\r\n * after the group items.\r\n */\r\n display?: 'inline' | 'column' | 'footer';\r\n}\r\n\r\n/** The `summary` property of `<u-grid>`. */\r\nexport interface GridSummary<TItem = any> {\r\n /** Totals: a footer fixed at the bottom, under the columns. */\r\n total?: GridSummaryItem<TItem>[];\r\n /** Summaries of each group (ignored with `treeMode`). */\r\n group?: GridGroupSummaryItem<TItem>[];\r\n /**\r\n * Tree data (`treeMode`): summaries of each node with children, over its\r\n * visible descendants (not the node itself). Off with `dataSource`.\r\n */\r\n node?: GridNodeSummaryItem<TItem>[];\r\n}\r\n\r\n/**\r\n * A summary of each tree node: `inline` (default) after the tree cell text,\r\n * `column` instead of the node value in that column, `footer` in a row after\r\n * the children of an expanded node.\r\n */\r\nexport interface GridNodeSummaryItem<TItem = any> extends GridSummaryItem<TItem> {\r\n /**\r\n * Where it is shown: `inline` (default) after the tree cell text, `column`\r\n * instead of the node value in its column, `footer` in a row after the\r\n * children of an expanded node.\r\n */\r\n display?: 'inline' | 'column' | 'footer';\r\n}\r\n\r\n/** A computed summary (`getSummaryValues()`). */\r\nexport interface GridSummaryValue<TItem = any> {\r\n /** The summary definition. */\r\n item: GridSummaryItem<TItem>;\r\n /** Raw aggregate (without values: `sum` = `0`, the others `null`). */\r\n value: unknown;\r\n /** Formatted value, as shown. */\r\n text: string;\r\n}\r\n\r\n// --------------------------------------------------------------- renderers\r\n\r\n/**\r\n * What a renderer returns. A Lit `TemplateResult` (recommended) or a string\r\n * (always text, never parsed as HTML) is rendered inside the grid's shadow\r\n * DOM — also on the server — and styled through the `part` names the\r\n * template declares (`u-grid::part(my-badge)`). An `HTMLElement` is placed\r\n * in the grid's light DOM and projected by a slot: page styles apply, but it\r\n * only renders in the browser (the server leaves the slot empty). `null`,\r\n * `undefined` and Lit's `nothing` render nothing. Return the same kind of\r\n * result on the server and on the client (don't branch on `typeof document`).\r\n */\r\nexport type GridRenderResult = TemplateResult | HTMLElement | string | typeof nothing | null | undefined;\r\n\r\n/** Members shared by every renderer context. */\r\nexport interface GridRenderContextBase {\r\n /** The grid rendering the content (a renderer may be shared by several grids). */\r\n readonly grid: DataGrid;\r\n /**\r\n * Aborted when the grid discards this content (the row leaves the virtual\r\n * window, the detail is collapsed, the column or the renderer changes, the\r\n * grid is disconnected): unmount framework roots here. Created on first\r\n * access.\r\n */\r\n readonly signal: AbortSignal;\r\n}\r\n\r\n/** Context of a cell `renderer`. */\r\nexport interface GridCellRenderContext<TItem = any> extends GridRenderContextBase {\r\n /** The row item. */\r\n readonly item: TItem;\r\n /** Cell value (`valueGetter` or `path`). */\r\n readonly value: unknown;\r\n /** The text the native cell would show (`format`, `displayValue`, `emptyText`, boolean texts). */\r\n readonly text: string;\r\n /** The column of the cell. */\r\n readonly column: GridColumnDef<TItem>;\r\n /** Row key (without `keyExpr`, the item itself). */\r\n readonly rowKey: unknown;\r\n /**\r\n * `true` when the value is drawn in the row details because the column is\r\n * hidden for lack of space (`autoHideColumns`), `false` in the table cell.\r\n * Moving between the two discards the content (the `signal` aborts).\r\n */\r\n readonly adaptive: boolean;\r\n}\r\n\r\n/** Context of a `headerRenderer`. */\r\nexport interface GridHeaderRenderContext<TItem = any> extends GridRenderContextBase {\r\n /** The column of the header; in a band header, the band (it has `columns` and no `path`). */\r\n readonly column: GridColumnDef<TItem>;\r\n}\r\n\r\n/** Context of a `groupRenderer`. */\r\nexport interface GridGroupRenderContext<TItem = any> extends GridRenderContextBase {\r\n /** The grouped column. */\r\n readonly column: GridColumnDef<TItem>;\r\n /** Group value. */\r\n readonly value: unknown;\r\n /** Group value formatted as the grid shows it. */\r\n readonly text: string;\r\n /** Values of the group from the outermost level. */\r\n readonly groupPath: GridGroupPath;\r\n /** Grouping level (0-based). */\r\n readonly groupIndex: number;\r\n /** Rows in the group (after filtering). */\r\n readonly itemCount: number;\r\n /** Whether the group is expanded. */\r\n readonly expanded: boolean;\r\n /** Summaries shown in the group row text (`display: 'inline'`). */\r\n readonly summaries: readonly GridSummaryValue<TItem>[];\r\n /** The full label the grid would show (`\"Country: Brazil (3, Sum of Population: 1,234)\"`). */\r\n readonly defaultText: string;\r\n}\r\n\r\n/** Context of the grid `detailRenderer`. */\r\nexport interface GridDetailRenderContext<TItem = any> extends GridRenderContextBase {\r\n /** The master row item. */\r\n readonly item: TItem;\r\n /** Key of the master row. */\r\n readonly rowKey: unknown;\r\n}\r\n\r\n/** Side a row is fixed to (`fixedTopItems` / `fixedBottomItems`); `null` = a body row. */\r\nexport type GridRowFixed = 'top' | 'bottom' | null;\r\n\r\n/** Context of the grid `rowRenderer`. */\r\nexport interface GridRowRenderContext<TItem = any> extends GridRenderContextBase {\r\n /** The row item. */\r\n readonly item: TItem;\r\n /** Row key (without `keyExpr`, the item itself). */\r\n readonly rowKey: unknown;\r\n /** `'top'`/`'bottom'` in a fixed row, `null` in a body row. */\r\n readonly fixed: GridRowFixed;\r\n /**\r\n * Aborted when the grid discards this content (the row leaves the virtual\r\n * window, the item or the renderer changes, the grid is disconnected) and\r\n * immediately when the renderer returns `false`. Created on first access.\r\n */\r\n readonly signal: AbortSignal;\r\n}\r\n\r\n/** Context of the grid `noDataRenderer`. */\r\nexport interface GridNoDataRenderContext extends GridRenderContextBase {\r\n /** `true` when there are items but the filter or the search hides them all. */\r\n readonly filtered: boolean;\r\n}\r\n\r\n/**\r\n * Cell renderer: a pure function of the item and the column. It runs again\r\n * when the item, the column object or the language change and when the row\r\n * comes back to the virtual window — so it may run several times for the\r\n * same item —, never when selecting, focusing or sorting (nor when the item\r\n * is mutated).\r\n */\r\nexport type GridCellRenderer<TItem = any> = (item: TItem, ctx: GridCellRenderContext<TItem>) => GridRenderResult;\r\n\r\n/** Header label renderer (runs again when the column or the language change). */\r\nexport type GridHeaderRenderer<TItem = any> = (ctx: GridHeaderRenderContext<TItem>) => GridRenderResult;\r\n\r\n/** Group row label renderer (runs again when any member of the context changes). */\r\nexport type GridGroupRenderer<TItem = any> = (ctx: GridGroupRenderContext<TItem>) => GridRenderResult;\r\n\r\n/** Detail row renderer (master-detail). `null` renders an empty detail row (the toggle stays). */\r\nexport type GridDetailRenderer<TItem = any> = (item: TItem, ctx: GridDetailRenderContext<TItem>) => GridRenderResult;\r\n\r\n/**\r\n * What a `rowRenderer` returns: the content of a full-width row, or `false`\r\n * to keep the row's columns. `null`, `undefined`, `''` and Lit's `nothing`\r\n * are an EMPTY full-width row, not a normal one.\r\n */\r\nexport type GridRowRenderResult = GridRenderResult | false;\r\n\r\n/**\r\n * Full-width row renderer: the content of ONE cell spanning the data\r\n * columns of a data or fixed row (the group indents, the detail toggle and\r\n * the selection checkbox stay). Return `false` (not `nothing`/`null`/`''`)\r\n * to keep that row's columns — `cond && html\\`…\\`` works,\r\n * `cond ? html\\`…\\` : nothing` gives empty full-width rows.\r\n *\r\n * Called for every rendered data or fixed row: decide `false` first,\r\n * deterministically and without touching `document` (the server and the\r\n * client must take the same decision), before building any content. The\r\n * result (including `false`) is cached per row: it runs again when the item\r\n * object, the `rowRenderer` function or the language change and when the\r\n * row comes back to the virtual window — to re-decide, assign a new item\r\n * object or a new function. A renderer that throws keeps the row's columns\r\n * (one `console.error`). Never called for group, summary, detail and\r\n * skeleton rows nor for a row being added (`addRow`).\r\n */\r\nexport type GridRowRenderer<TItem = any> = (item: TItem, ctx: GridRowRenderContext<TItem>) => GridRowRenderResult;\r\n\r\n/** Empty state renderer (no rows to show). */\r\nexport type GridNoDataRenderer = (ctx: GridNoDataRenderContext) => GridRenderResult;\r\n\r\n/**\r\n * O usuário pode agrupar pela coluna?\r\n * @internal\r\n */\r\nexport const isColumnGroupable = (column: GridColumnDef): boolean =>\r\n column.groupable ?? (!!column.path || !!column.valueGetter || !!column.groupValueGetter);\r\n\r\n/**\r\n * A coluna pode ser ordenada pelo usuário?\r\n * @internal\r\n */\r\nexport const isColumnSortable = (column: GridColumnDef): boolean =>\r\n column.sortable ?? (!!column.path || !!column.valueGetter || !!column.comparator);\r\n\r\n/**\r\n * A coluna entra na exportação e na área de transferência?\r\n * @internal\r\n */\r\nexport const isColumnExportable = (column: GridColumnDef): boolean =>\r\n column.exportable ?? (!!column.path || !!column.valueGetter || !!column.displayValue);\r\n\r\n/**\r\n * A coluna pode ser filtrada pelo usuário? (a expressão aponta a coluna pelo `path`)\r\n * @internal\r\n */\r\nexport const isColumnFilterable = (column: GridColumnDef): boolean =>\r\n !!column.path && column.filterable !== false;\r\n\r\n// ----------------------------------------------------------------- edição\r\n\r\n/** Writes an edited `value` into `data` (the pending change of the row); `item` is the original row (empty object for new rows). */\r\nexport type GridValueSetter<TItem = any> = (data: Partial<TItem>, value: unknown, item: TItem) => void;\r\n\r\n/** What a validation rule receives. */\r\nexport interface GridValidationContext<TItem = any> {\r\n /** The value being checked. */\r\n readonly value: unknown;\r\n /** The original row item (empty object for a new row). */\r\n readonly item: TItem;\r\n /** The pending change of the row (fields edited so far, this value included). */\r\n readonly data: Partial<TItem>;\r\n /** The column of the value. */\r\n readonly column: GridColumnDef<TItem>;\r\n /** Row key (a new row has an opaque provisional key). */\r\n readonly rowKey: unknown;\r\n}\r\n\r\n/** Members shared by every validation rule. */\r\nexport interface GridValidationRuleBase {\r\n /** Error text; default: the grid translation of the rule. */\r\n message?: string;\r\n}\r\n\r\n/** The value cannot be empty (`null`, `undefined`, `''`, or only spaces with `trim`). */\r\nexport interface GridRequiredRule extends GridValidationRuleBase {\r\n type: 'required';\r\n /** Spaces only count as empty. Default `true`. */\r\n trim?: boolean;\r\n}\r\n\r\n/** A number or date between `min` and `max` (inclusive). */\r\nexport interface GridRangeRule extends GridValidationRuleBase {\r\n type: 'range';\r\n min?: number | Date;\r\n max?: number | Date;\r\n}\r\n\r\n/** Text length between `min` and `max` characters. */\r\nexport interface GridStringLengthRule extends GridValidationRuleBase {\r\n type: 'stringLength';\r\n min?: number;\r\n max?: number;\r\n}\r\n\r\n/** The text matches `pattern`; a string matches the whole value, like the HTML `pattern` attribute. */\r\nexport interface GridPatternRule extends GridValidationRuleBase {\r\n type: 'pattern';\r\n pattern: RegExp | string;\r\n}\r\n\r\n/** An e-mail address (the rule of `<input type=\"email\">`). */\r\nexport interface GridEmailRule extends GridValidationRuleBase {\r\n type: 'email';\r\n}\r\n\r\n/**\r\n * Host check: return `true` (valid), `false` (invalid, `message` or the\r\n * default text) or an error text; or a promise of it (server check). The\r\n * `signal` aborts when the value changes again or the edit ends: a stale\r\n * answer is ignored.\r\n */\r\nexport interface GridCustomRule<TItem = any> extends GridValidationRuleBase {\r\n type: 'custom';\r\n validate: (ctx: GridValidationContext<TItem>, signal: AbortSignal) => boolean | string | Promise<boolean | string>;\r\n}\r\n\r\n/**\r\n * A validation rule of `validationRules`. Empty values only fail `required`\r\n * (and `custom`, which always runs).\r\n */\r\nexport type GridValidationRule<TItem = any> =\r\n | GridRequiredRule\r\n | GridRangeRule\r\n | GridStringLengthRule\r\n | GridPatternRule\r\n | GridEmailRule\r\n | GridCustomRule<TItem>;\r\n\r\n/** Context of an `editorRenderer`. */\r\nexport interface GridEditorRenderContext<TItem = any> extends GridRenderContextBase {\r\n /** The original row item (empty object for a new row). */\r\n readonly item: TItem;\r\n /** The value being edited (pending, not yet saved). */\r\n readonly value: unknown;\r\n /** The pending change of the row. */\r\n readonly data: Partial<TItem>;\r\n /** The column of the cell. */\r\n readonly column: GridColumnDef<TItem>;\r\n /** Row key (a new row has an opaque provisional key). */\r\n readonly rowKey: unknown;\r\n /** Accessible name for the editor (the column label). */\r\n readonly label: string;\r\n /** `true` when the editor is in the row details (column hidden for lack of space, `autoHideColumns`). */\r\n readonly adaptive: boolean;\r\n /** The value failed a validation rule. */\r\n readonly invalid: boolean;\r\n /** Error text of the value (`''` when valid). */\r\n readonly errorMessage: string;\r\n /**\r\n * Id of the element with the error text, for `aria-describedby` — only for\r\n * editors rendered in the grid's shadow DOM (`TemplateResult`). For an\r\n * `HTMLElement` editor the grid places the text in its light DOM and sets\r\n * `aria-label`, `aria-invalid` and `aria-describedby` when missing.\r\n */\r\n readonly describedBy: string;\r\n /** Changes the edited value (the grid validates it on commit). */\r\n setValue(value: unknown): void;\r\n /** Commits the value (like Enter, without moving). */\r\n commit(): void;\r\n /** Discards the value and closes the editor (like Esc). */\r\n cancel(): void;\r\n}\r\n\r\n/**\r\n * Editor of a cell: focus goes to the first focusable element it renders.\r\n * It runs when the editor opens and again when the validity of the value\r\n * changes (`invalid`, `errorMessage`): keep the value in `setValue`.\r\n * The grid handles Enter, Tab and Esc unless the editor calls\r\n * `preventDefault()` on the `keydown` (a combobox that uses Enter).\r\n */\r\nexport type GridEditorRenderer<TItem = any> = (item: TItem, ctx: GridEditorRenderContext<TItem>) => GridRenderResult;\r\n\r\n/**\r\n * A coluna é editável (sem olhar o `allowEditing` do grid)? Padrão: com\r\n * `path` ou `valueSetter`.\r\n * @internal\r\n */\r\nexport const isColumnEditable = (column: GridColumnDef): boolean =>\r\n column.editable ?? (!!column.path || !!column.valueSetter);\r\n\r\n/**\r\n * A coluna é banda (`columns` com pelo menos 1 item).\r\n * @internal\r\n */\r\nexport const isBand = (column: GridColumnDef | null | undefined): boolean =>\r\n !!column && Array.isArray(column.columns) && column.columns.length > 0;\r\n\r\n/**\r\n * How columns are rendered: `virtual` keeps only the columns in view (plus the\r\n * fixed ones and the focused one) in the DOM; `standard` renders all;\r\n * `auto` is `virtual` with more than 50 leaf columns defined.\r\n */\r\nexport type GridColumnRenderingMode = 'auto' | 'virtual' | 'standard';\r\n"]}
1
+ {"version":3,"file":"grid-column-def.js","sourceRoot":"","sources":["../src/grid-column-def.ts"],"names":[],"mappings":"AA6cA;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAqB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{ DataGrid } from './grid.js';\r\n\r\n/** Sort direction: ascending or descending. */\r\nexport type GridSortOrder = 'asc' | 'desc';\r\n\r\n/** A column of the current sorting and its direction (`getSorting()`). */\r\nexport interface GridSort {\r\n column: GridColumnDef;\r\n order: GridSortOrder;\r\n}\r\n\r\n/**\r\n * Custom comparator of a column, in ascending order (the grid applies the\r\n * direction). Receives the cell values and the row items.\r\n */\r\nexport type GridColumnComparator<TItem = any> = (a: any, b: any, itemA: TItem, itemB: TItem) => number;\r\n\r\n/** Data type of a column; without `dataType`, inferred from the first non-null value. */\r\nexport type GridColumnDataType = 'string' | 'number' | 'date' | 'datetime' | 'boolean';\r\n\r\n/** Logical alignment: `start`/`end` follow the direction (RTL). */\r\nexport type GridColumnAlignment = 'start' | 'center' | 'end';\r\n\r\n/** Boolean as text (`trueText`/`falseText`) or as a read-only check icon. */\r\nexport type GridColumnBooleanDisplay = 'text' | 'icon';\r\n\r\n/** Formats a cell value into its displayed text. */\r\nexport type GridColumnFormatter<TItem = any> = (value: unknown, item: TItem) => string;\r\n\r\n/** `Intl` number/date options or a formatter function. */\r\nexport type GridColumnFormat<TItem = any> = Intl.NumberFormatOptions | Intl.DateTimeFormatOptions | GridColumnFormatter<TItem>;\r\n\r\n/**\r\n * Filter operation of a condition. Text operations (`contains`, `notcontains`,\r\n * `startswith`, `endswith`) and `=` on text ignore case and accents.\r\n */\r\nexport type GridFilterOperation =\r\n | '=' | '<>' | '<' | '<=' | '>' | '>='\r\n | 'contains' | 'notcontains' | 'startswith' | 'endswith'\r\n | 'between' | 'anyof' | 'noneof' | 'isblank' | 'isnotblank';\r\n\r\n/**\r\n * One condition: `[path, operation, value]`. `path` is the column `path`;\r\n * `between` takes `[start, end]` (inclusive, either may be `null`), `anyof` /\r\n * `noneof` take a list, `isblank` / `isnotblank` take no value.\r\n */\r\nexport type GridFilterCondition =\r\n | readonly [path: string, operation: GridFilterOperation, value?: unknown]\r\n | readonly [path: string, value: unknown];\r\n\r\n/**\r\n * Serializable filter expression (same shape as DevExtreme): a condition, a\r\n * negation `['!', expression]` or a group of expressions joined by `'and'` /\r\n * `'or'` (`and` binds tighter; two expressions in a row mean `and`).\r\n */\r\nexport type GridFilterExpression =\r\n | GridFilterCondition\r\n | readonly ['!', GridFilterExpression]\r\n | readonly (GridFilterExpression | 'and' | 'or')[];\r\n\r\n/** Side a column is fixed to (logical: mirrors in RTL). */\r\nexport type GridColumnFixed = 'start' | 'end' | null;\r\n\r\n/**\r\n * Column definition (the `columns` property of `<u-grid>`). Mirrors the\r\n * `<u-grid-column>` element: same names, types and defaults. `TItem` types\r\n * the row item in the callbacks.\r\n */\r\nexport interface GridColumnDef<TItem = any> {\r\n /**\r\n * Nested columns: a column with at least one nested column is a BAND (a\r\n * header over its columns, no cells). In a band only `label`,\r\n * `headerRenderer`, `alignment` (of the label; default `start`), `fixed`,\r\n * `visible` and `showInChooser` apply; the other fields are ignored. A band\r\n * is shown while it is visible and has a visible column. Columns reorder\r\n * only inside their own band; only leaf columns sort, group and export.\r\n * `null` or `[]` = a regular column.\r\n */\r\n columns?: readonly GridColumnDef<TItem>[] | null;\r\n /**\r\n * Width in px. Under virtual column rendering (`columnRenderingMode`) a\r\n * column without `width` takes its auto-size width or `max(minWidth, 150)` px.\r\n */\r\n width?: number | null;\r\n /** Minimum width in px (also when resizing and auto-sizing). */\r\n minWidth?: number | null;\r\n /** INITIAL grouping level; afterwards grouping is grid state (`groupColumn`, `ungroupColumn`). */\r\n groupIndex?: number | null;\r\n /**\r\n * The column's name as text: the header text (unless `headerRenderer`;\r\n * empty: `path`) and its name everywhere else (header buttons, group chip\r\n * and rows, column chooser, row details, announcements, export; empty:\r\n * `path`, then `name`, as is). Set it also with `headerRenderer`.\r\n */\r\n label?: string;\r\n /** Dot path of the cell value in the row item (`\"address.city\"`). */\r\n path?: string;\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 name?: string;\r\n /** Data type; without it, inferred from the first non-null value. */\r\n dataType?: GridColumnDataType | null;\r\n /** `Intl` options or a formatter function. */\r\n format?: GridColumnFormat<TItem> | null;\r\n /** Logical alignment; default by data type (numbers at the end). In a band, of the header label (default `start`). */\r\n alignment?: GridColumnAlignment | null;\r\n /** Cell value used to group, sort and filter. Default: read `path`. */\r\n valueGetter?: ((item: TItem) => unknown) | null;\r\n /** Displayed text (cell and group row); wins over `format`. */\r\n displayValue?: ((value: unknown, item: TItem) => string) | null;\r\n /** Boolean as text (default) or icon; the icon has the text as its accessible name. */\r\n booleanDisplay?: GridColumnBooleanDisplay | null;\r\n /** Wraps the text in several lines instead of an ellipsis. */\r\n wrap?: boolean;\r\n /** Text for empty values (`null`/`undefined`). */\r\n emptyText?: string | null;\r\n /**\r\n * Builds the cell content: a Lit `TemplateResult` (recommended), a string\r\n * (text, never HTML) or an `HTMLElement` (placed in the grid's light DOM).\r\n * `null`, `undefined` and Lit's `nothing` render an empty cell. See `GridCellRenderer`.\r\n */\r\n renderer?: GridCellRenderer<TItem> | null;\r\n /**\r\n * Builds the header label (sort arrow, filter button and resize handle stay; their accessible names\r\n * follow the rendered text). Set `label` too: it names the column outside the header (without it\r\n * the grid warns once and uses `path`, then `name`).\r\n */\r\n headerRenderer?: GridHeaderRenderer<TItem> | null;\r\n /** Builds the label of the group rows of this column (expand button and aligned summaries stay). */\r\n groupRenderer?: GridGroupRenderer<TItem> | null;\r\n /** Allows sorting from the header. Default: `true` when the column has a `path`, `valueGetter` or `comparator`. */\r\n sortable?: boolean | null;\r\n /** INITIAL sort direction; afterwards sorting is grid state (`sortColumn`, `getSorting`). */\r\n sortOrder?: GridSortOrder | null;\r\n /** Priority of the initial sort among columns (lower first). */\r\n sortIndex?: number | null;\r\n /** Custom ascending comparator. */\r\n comparator?: GridColumnComparator<TItem> | null;\r\n /**\r\n * Allows filtering by this column (filter row, header filter and, by\r\n * default, the search panel). Default: `true` when the column has a `path`\r\n * (the filter expression refers to columns by `path`).\r\n */\r\n filterable?: boolean | null;\r\n /**\r\n * Operations offered in the filter row operation menu (only the menu: the\r\n * header filter and `filterValue` are not checked). Default by data type.\r\n */\r\n filterOperations?: readonly GridFilterOperation[] | null;\r\n /** Operation of the filter row editor. Default: `contains` for text, `=` otherwise (or the first of `filterOperations`). */\r\n defaultFilterOperation?: GridFilterOperation | null;\r\n /** `false` prevents resizing this column even with `column-resizing`. */\r\n resizable?: boolean | null;\r\n /** Maximum width in px when resizing and auto-sizing. */\r\n maxWidth?: number | null;\r\n /**\r\n * Order in which the column leaves the table when the grid is too narrow\r\n * (`autoHideColumns`; its values move to the row details): the lowest goes\r\n * first, ties from the end. When any column of `columns` has a\r\n * `hidingPriority` (grouped or hidden ones included), only those columns\r\n * hide; otherwise columns hide from the last one. Fixed\r\n * columns never hide. Ignored on bands.\r\n */\r\n hidingPriority?: number | null;\r\n /**\r\n * Fixes the column at the start or end of the scrollable area. A fixed band\r\n * fixes its columns; ignored on nested columns (they follow the top band).\r\n */\r\n fixed?: GridColumnFixed;\r\n /** INITIAL visibility (default `true`); afterwards the user changes it in the chooser. */\r\n visible?: boolean | null;\r\n /** `false` removes the column from the chooser (the user cannot hide it). */\r\n showInChooser?: boolean | null;\r\n /**\r\n * Value used to GROUP by this column instead of the cell value: a range or\r\n * bucket (decade, initial letter). Groups are identified, sorted and shown\r\n * by the returned value; the column `dataType`, `comparator`, `format` and\r\n * `displayValue` do not apply to it. Return a string or a number.\r\n */\r\n groupValueGetter?: ((item: TItem) => unknown) | null;\r\n /**\r\n * Allows the user to group by this column (drag to the group panel).\r\n * Default: `true` when the column has a `path`, `valueGetter` or\r\n * `groupValueGetter`. Only limits the user: `groupColumn()` still works.\r\n */\r\n groupable?: boolean | null;\r\n /**\r\n * Includes this column in exports (`exportCsv`, `getExportData`, the xlsx\r\n * adapter) and in Ctrl+C. Default: `true` when the column has a `path`,\r\n * `valueGetter` or `displayValue` (a `renderer`-only column has no text).\r\n */\r\n exportable?: boolean | null;\r\n /**\r\n * Allows editing the cells of this column (with `allowEditing` on the grid;\r\n * new rows with `allowAdding`). Default: `true` when the column has a\r\n * `path` or a `valueSetter`.\r\n */\r\n editable?: boolean | null;\r\n /**\r\n * Builds the editor of a cell instead of the built-in one (text, number,\r\n * date, checkbox). See `GridEditorRenderer`.\r\n */\r\n editorRenderer?: GridEditorRenderer<TItem> | null;\r\n /** Rules checked when a value is committed and before saving. See `GridValidationRule`. */\r\n validationRules?: readonly GridValidationRule<TItem>[] | null;\r\n /**\r\n * Writes an edited value into `data`, the pending change of the row (a\r\n * partial item owned by the grid). Default: sets `path` (dots create nested\r\n * objects). Set other fields too to edit computed columns.\r\n */\r\n valueSetter?: GridValueSetter<TItem> | null;\r\n}\r\n\r\n/**\r\n * A column of the grid: its `name`, its `path` (first column with that name, else with that path) or the column itself.\r\n * Leaf columns only, including columns inside a band; a band is not a column reference.\r\n */\r\nexport type GridColumnRef<TItem = any> = string | GridColumnDef<TItem>;\r\n\r\n/** Values of a group from the outermost level, e.g. `['Brazil', 'SP']`. */\r\nexport type GridGroupPath = readonly unknown[];\r\n\r\n/** Built-in summary aggregates. `sum`/`min`/`max`/`avg` ignore empty values; `count` counts rows. */\r\nexport type GridSummaryType = 'sum' | 'min' | 'max' | 'avg' | 'count';\r\n\r\n/** Custom aggregate: receives the column values and the row items of the group (or of all rows). */\r\nexport type GridSummaryAggregator<TItem = any> = (values: readonly unknown[], items: readonly TItem[]) => unknown;\r\n\r\n/** `Intl` options or a function that formats the summary value. */\r\nexport type GridSummaryFormat = Intl.NumberFormatOptions | Intl.DateTimeFormatOptions | ((value: unknown) => string);\r\n\r\n/** A summary (aggregate) of a column. */\r\nexport interface GridSummaryItem<TItem = any> {\r\n /** Column whose values are aggregated and under which the summary is shown. */\r\n column: GridColumnRef<TItem>;\r\n /** Built-in aggregate or a custom function. */\r\n type: GridSummaryType | GridSummaryAggregator<TItem>;\r\n /**\r\n * Replaces the aggregate name in the text (`\"Total: 1,234\"`). Without it a\r\n * custom aggregate shows `\"{column}: {value}\"` in group rows and only the\r\n * value in cells.\r\n */\r\n label?: string;\r\n /**\r\n * Formats the value. Default: the column `format` when it is `Intl`\r\n * options (a formatter function is not inherited); `count` uses the\r\n * integer format of the language.\r\n */\r\n format?: GridSummaryFormat | null;\r\n /** Identifies the summary in `getSummaryValues()`. */\r\n name?: string;\r\n}\r\n\r\n/** A summary of each group. */\r\nexport interface GridGroupSummaryItem<TItem = any> extends GridSummaryItem<TItem> {\r\n /**\r\n * Where it is shown: `inline` (default) in the group row text,\r\n * `column` in the group row under its column, `footer` in a footer row\r\n * after the group items.\r\n */\r\n display?: 'inline' | 'column' | 'footer';\r\n}\r\n\r\n/** The `summary` property of `<u-grid>`. */\r\nexport interface GridSummary<TItem = any> {\r\n /** Totals: a footer fixed at the bottom, under the columns. */\r\n total?: GridSummaryItem<TItem>[];\r\n /** Summaries of each group (ignored with `treeMode`). */\r\n group?: GridGroupSummaryItem<TItem>[];\r\n /**\r\n * Tree data (`treeMode`): summaries of each node with children, over its\r\n * visible descendants (not the node itself). Off with `dataSource`.\r\n */\r\n node?: GridNodeSummaryItem<TItem>[];\r\n}\r\n\r\n/**\r\n * A summary of each tree node: `inline` (default) after the tree cell text,\r\n * `column` instead of the node value in that column, `footer` in a row after\r\n * the children of an expanded node.\r\n */\r\nexport interface GridNodeSummaryItem<TItem = any> extends GridSummaryItem<TItem> {\r\n /**\r\n * Where it is shown: `inline` (default) after the tree cell text, `column`\r\n * instead of the node value in its column, `footer` in a row after the\r\n * children of an expanded node.\r\n */\r\n display?: 'inline' | 'column' | 'footer';\r\n}\r\n\r\n/** A computed summary (`getSummaryValues()`). */\r\nexport interface GridSummaryValue<TItem = any> {\r\n /** The summary definition. */\r\n item: GridSummaryItem<TItem>;\r\n /** Raw aggregate (without values: `sum` = `0`, the others `null`). */\r\n value: unknown;\r\n /** Formatted value, as shown. */\r\n text: string;\r\n}\r\n\r\n// --------------------------------------------------------------- renderers\r\n\r\n/**\r\n * What a renderer returns. A Lit `TemplateResult` (recommended) or a string\r\n * (always text, never parsed as HTML) is rendered inside the grid's shadow\r\n * DOM — also on the server — and styled through the `part` names the\r\n * template declares (`u-grid::part(my-badge)`). An `HTMLElement` is placed\r\n * in the grid's light DOM and projected by a slot: page styles apply, but it\r\n * only renders in the browser (the server leaves the slot empty). `null`,\r\n * `undefined` and Lit's `nothing` render nothing. Return the same kind of\r\n * result on the server and on the client (don't branch on `typeof document`).\r\n */\r\nexport type GridRenderResult = TemplateResult | HTMLElement | string | typeof nothing | null | undefined;\r\n\r\n/** Members shared by every renderer context. */\r\nexport interface GridRenderContextBase {\r\n /** The grid rendering the content (a renderer may be shared by several grids). */\r\n readonly grid: DataGrid;\r\n /**\r\n * Aborted when the grid discards this content (the row leaves the virtual\r\n * window, the detail is collapsed, the column or the renderer changes, the\r\n * grid is disconnected): unmount framework roots here. Created on first\r\n * access.\r\n */\r\n readonly signal: AbortSignal;\r\n}\r\n\r\n/** Context of a cell `renderer`. */\r\nexport interface GridCellRenderContext<TItem = any> extends GridRenderContextBase {\r\n /** The row item. */\r\n readonly item: TItem;\r\n /** Cell value (`valueGetter` or `path`). */\r\n readonly value: unknown;\r\n /** The text the native cell would show (`format`, `displayValue`, `emptyText`, boolean texts). */\r\n readonly text: string;\r\n /** The column of the cell. */\r\n readonly column: GridColumnDef<TItem>;\r\n /** Row key (without `keyExpr`, the item itself). */\r\n readonly rowKey: unknown;\r\n /**\r\n * `true` when the value is drawn in the row details because the column is\r\n * hidden for lack of space (`autoHideColumns`), `false` in the table cell.\r\n * Moving between the two discards the content (the `signal` aborts).\r\n */\r\n readonly adaptive: boolean;\r\n}\r\n\r\n/** Context of a `headerRenderer`. */\r\nexport interface GridHeaderRenderContext<TItem = any> extends GridRenderContextBase {\r\n /** The column of the header; in a band header, the band (it has `columns` and no `path`). */\r\n readonly column: GridColumnDef<TItem>;\r\n}\r\n\r\n/** Context of a `groupRenderer`. */\r\nexport interface GridGroupRenderContext<TItem = any> extends GridRenderContextBase {\r\n /** The grouped column. */\r\n readonly column: GridColumnDef<TItem>;\r\n /** Group value. */\r\n readonly value: unknown;\r\n /** Group value formatted as the grid shows it. */\r\n readonly text: string;\r\n /** Values of the group from the outermost level. */\r\n readonly groupPath: GridGroupPath;\r\n /** Grouping level (0-based). */\r\n readonly groupIndex: number;\r\n /** Rows in the group (after filtering). */\r\n readonly itemCount: number;\r\n /** Whether the group is expanded. */\r\n readonly expanded: boolean;\r\n /** Summaries shown in the group row text (`display: 'inline'`). */\r\n readonly summaries: readonly GridSummaryValue<TItem>[];\r\n /** The full label the grid would show (`\"Country: Brazil (3, Sum of Population: 1,234)\"`). */\r\n readonly defaultText: string;\r\n}\r\n\r\n/** Context of the grid `detailRenderer`. */\r\nexport interface GridDetailRenderContext<TItem = any> extends GridRenderContextBase {\r\n /** The master row item. */\r\n readonly item: TItem;\r\n /** Key of the master row. */\r\n readonly rowKey: unknown;\r\n}\r\n\r\n/** Side a row is fixed to (`fixedTopItems` / `fixedBottomItems`); `null` = a body row. */\r\nexport type GridRowFixed = 'top' | 'bottom' | null;\r\n\r\n/** Context of the grid `rowRenderer`. */\r\nexport interface GridRowRenderContext<TItem = any> extends GridRenderContextBase {\r\n /** The row item. */\r\n readonly item: TItem;\r\n /** Row key (without `keyExpr`, the item itself). */\r\n readonly rowKey: unknown;\r\n /** `'top'`/`'bottom'` in a fixed row, `null` in a body row. */\r\n readonly fixed: GridRowFixed;\r\n /**\r\n * Aborted when the grid discards this content (the row leaves the virtual\r\n * window, the item or the renderer changes, the grid is disconnected) and\r\n * immediately when the renderer returns `false`. Created on first access.\r\n */\r\n readonly signal: AbortSignal;\r\n}\r\n\r\n/** Context of the grid `noDataRenderer`. */\r\nexport interface GridNoDataRenderContext extends GridRenderContextBase {\r\n /** `true` when there are items but the filter or the search hides them all. */\r\n readonly filtered: boolean;\r\n}\r\n\r\n/**\r\n * Cell renderer: a pure function of the item and the column. It runs again\r\n * when the item, the column object or the language change and when the row\r\n * comes back to the virtual window — so it may run several times for the\r\n * same item —, never when selecting, focusing or sorting (nor when the item\r\n * is mutated).\r\n */\r\nexport type GridCellRenderer<TItem = any> = (item: TItem, ctx: GridCellRenderContext<TItem>) => GridRenderResult;\r\n\r\n/** Header label renderer (runs again when the column or the language change). */\r\nexport type GridHeaderRenderer<TItem = any> = (ctx: GridHeaderRenderContext<TItem>) => GridRenderResult;\r\n\r\n/** Group row label renderer (runs again when any member of the context changes). */\r\nexport type GridGroupRenderer<TItem = any> = (ctx: GridGroupRenderContext<TItem>) => GridRenderResult;\r\n\r\n/** Detail row renderer (master-detail). `null` renders an empty detail row (the toggle stays). */\r\nexport type GridDetailRenderer<TItem = any> = (item: TItem, ctx: GridDetailRenderContext<TItem>) => GridRenderResult;\r\n\r\n/**\r\n * What a `rowRenderer` returns: the content of a full-width row, or `false`\r\n * to keep the row's columns. `null`, `undefined`, `''` and Lit's `nothing`\r\n * are an EMPTY full-width row, not a normal one.\r\n */\r\nexport type GridRowRenderResult = GridRenderResult | false;\r\n\r\n/**\r\n * Full-width row renderer: the content of ONE cell spanning the data\r\n * columns of a data or fixed row (the group indents, the detail toggle and\r\n * the selection checkbox stay). Return `false` (not `nothing`/`null`/`''`)\r\n * to keep that row's columns — `cond && html\\`…\\`` works,\r\n * `cond ? html\\`…\\` : nothing` gives empty full-width rows.\r\n *\r\n * Called for every rendered data or fixed row: decide `false` first,\r\n * deterministically and without touching `document` (the server and the\r\n * client must take the same decision), before building any content. The\r\n * result (including `false`) is cached per row: it runs again when the item\r\n * object, the `rowRenderer` function or the language change and when the\r\n * row comes back to the virtual window — to re-decide, assign a new item\r\n * object or a new function. A renderer that throws keeps the row's columns\r\n * (one `console.error`). Never called for group, summary, detail and\r\n * skeleton rows nor for a row being added (`addRow`).\r\n */\r\nexport type GridRowRenderer<TItem = any> = (item: TItem, ctx: GridRowRenderContext<TItem>) => GridRowRenderResult;\r\n\r\n/** Empty state renderer (no rows to show). */\r\nexport type GridNoDataRenderer = (ctx: GridNoDataRenderContext) => GridRenderResult;\r\n\r\n/**\r\n * O usuário pode agrupar pela coluna?\r\n * @internal\r\n */\r\nexport const isColumnGroupable = (column: GridColumnDef): boolean =>\r\n column.groupable ?? (!!column.path || !!column.valueGetter || !!column.groupValueGetter);\r\n\r\n/**\r\n * A coluna pode ser ordenada pelo usuário?\r\n * @internal\r\n */\r\nexport const isColumnSortable = (column: GridColumnDef): boolean =>\r\n column.sortable ?? (!!column.path || !!column.valueGetter || !!column.comparator);\r\n\r\n/**\r\n * A coluna entra na exportação e na área de transferência?\r\n * @internal\r\n */\r\nexport const isColumnExportable = (column: GridColumnDef): boolean =>\r\n column.exportable ?? (!!column.path || !!column.valueGetter || !!column.displayValue);\r\n\r\n/**\r\n * A coluna pode ser filtrada pelo usuário? (a expressão aponta a coluna pelo `path`)\r\n * @internal\r\n */\r\nexport const isColumnFilterable = (column: GridColumnDef): boolean =>\r\n !!column.path && column.filterable !== false;\r\n\r\n// ----------------------------------------------------------------- edição\r\n\r\n/** Writes an edited `value` into `data` (the pending change of the row); `item` is the original row (empty object for new rows). */\r\nexport type GridValueSetter<TItem = any> = (data: Partial<TItem>, value: unknown, item: TItem) => void;\r\n\r\n/** What a validation rule receives. */\r\nexport interface GridValidationContext<TItem = any> {\r\n /** The value being checked. */\r\n readonly value: unknown;\r\n /** The original row item (empty object for a new row). */\r\n readonly item: TItem;\r\n /** The pending change of the row (fields edited so far, this value included). */\r\n readonly data: Partial<TItem>;\r\n /** The column of the value. */\r\n readonly column: GridColumnDef<TItem>;\r\n /** Row key (a new row has an opaque provisional key). */\r\n readonly rowKey: unknown;\r\n}\r\n\r\n/** Members shared by every validation rule. */\r\nexport interface GridValidationRuleBase {\r\n /** Error text; default: the grid translation of the rule. */\r\n message?: string;\r\n}\r\n\r\n/** The value cannot be empty (`null`, `undefined`, `''`, or only spaces with `trim`). */\r\nexport interface GridRequiredRule extends GridValidationRuleBase {\r\n type: 'required';\r\n /** Spaces only count as empty. Default `true`. */\r\n trim?: boolean;\r\n}\r\n\r\n/** A number or date between `min` and `max` (inclusive). */\r\nexport interface GridRangeRule extends GridValidationRuleBase {\r\n type: 'range';\r\n min?: number | Date;\r\n max?: number | Date;\r\n}\r\n\r\n/** Text length between `min` and `max` characters. */\r\nexport interface GridStringLengthRule extends GridValidationRuleBase {\r\n type: 'stringLength';\r\n min?: number;\r\n max?: number;\r\n}\r\n\r\n/** The text matches `pattern`; a string matches the whole value, like the HTML `pattern` attribute. */\r\nexport interface GridPatternRule extends GridValidationRuleBase {\r\n type: 'pattern';\r\n pattern: RegExp | string;\r\n}\r\n\r\n/** An e-mail address (the rule of `<input type=\"email\">`). */\r\nexport interface GridEmailRule extends GridValidationRuleBase {\r\n type: 'email';\r\n}\r\n\r\n/**\r\n * Host check: return `true` (valid), `false` (invalid, `message` or the\r\n * default text) or an error text; or a promise of it (server check). The\r\n * `signal` aborts when the value changes again or the edit ends: a stale\r\n * answer is ignored.\r\n */\r\nexport interface GridCustomRule<TItem = any> extends GridValidationRuleBase {\r\n type: 'custom';\r\n validate: (ctx: GridValidationContext<TItem>, signal: AbortSignal) => boolean | string | Promise<boolean | string>;\r\n}\r\n\r\n/**\r\n * A validation rule of `validationRules`. Empty values only fail `required`\r\n * (and `custom`, which always runs).\r\n */\r\nexport type GridValidationRule<TItem = any> =\r\n | GridRequiredRule\r\n | GridRangeRule\r\n | GridStringLengthRule\r\n | GridPatternRule\r\n | GridEmailRule\r\n | GridCustomRule<TItem>;\r\n\r\n/** Context of an `editorRenderer`. */\r\nexport interface GridEditorRenderContext<TItem = any> extends GridRenderContextBase {\r\n /** The original row item (empty object for a new row). */\r\n readonly item: TItem;\r\n /** The value being edited (pending, not yet saved). */\r\n readonly value: unknown;\r\n /** The pending change of the row. */\r\n readonly data: Partial<TItem>;\r\n /** The column of the cell. */\r\n readonly column: GridColumnDef<TItem>;\r\n /** Row key (a new row has an opaque provisional key). */\r\n readonly rowKey: unknown;\r\n /** Accessible name for the editor (the column label). */\r\n readonly label: string;\r\n /** `true` when the editor is in the row details (column hidden for lack of space, `autoHideColumns`). */\r\n readonly adaptive: boolean;\r\n /** The value failed a validation rule. */\r\n readonly invalid: boolean;\r\n /** Error text of the value (`''` when valid). */\r\n readonly errorMessage: string;\r\n /**\r\n * Id of the element with the error text, for `aria-describedby` — only for\r\n * editors rendered in the grid's shadow DOM (`TemplateResult`). For an\r\n * `HTMLElement` editor the grid places the text in its light DOM and sets\r\n * `aria-label`, `aria-invalid` and `aria-describedby` when missing.\r\n */\r\n readonly describedBy: string;\r\n /** Changes the edited value (the grid validates it on commit). */\r\n setValue(value: unknown): void;\r\n /** Commits the value (like Enter, without moving). */\r\n commit(): void;\r\n /** Discards the value and closes the editor (like Esc). */\r\n cancel(): void;\r\n}\r\n\r\n/**\r\n * Editor of a cell: focus goes to the first focusable element it renders.\r\n * It runs when the editor opens and again when the validity of the value\r\n * changes (`invalid`, `errorMessage`): keep the value in `setValue`.\r\n * The grid handles Enter, Tab and Esc unless the editor calls\r\n * `preventDefault()` on the `keydown` (a combobox that uses Enter).\r\n */\r\nexport type GridEditorRenderer<TItem = any> = (item: TItem, ctx: GridEditorRenderContext<TItem>) => GridRenderResult;\r\n\r\n/**\r\n * A coluna é editável (sem olhar o `allowEditing` do grid)? Padrão: com\r\n * `path` ou `valueSetter`.\r\n * @internal\r\n */\r\nexport const isColumnEditable = (column: GridColumnDef): boolean =>\r\n column.editable ?? (!!column.path || !!column.valueSetter);\r\n\r\n/**\r\n * A coluna é banda (`columns` com pelo menos 1 item).\r\n * @internal\r\n */\r\nexport const isBand = (column: GridColumnDef | null | undefined): boolean =>\r\n !!column && Array.isArray(column.columns) && column.columns.length > 0;\r\n\r\n/**\r\n * How columns are rendered: `virtual` keeps only the columns in view (plus the\r\n * fixed ones and the focused one) in the DOM; `standard` renders all;\r\n * `auto` is `virtual` with more than 50 leaf columns defined.\r\n */\r\nexport type GridColumnRenderingMode = 'auto' | 'virtual' | 'standard';\r\n"]}
@@ -40,7 +40,10 @@ export declare class DataGridColumn extends LitElement implements GridColumnDef
40
40
  * light DOM). `null`, `undefined` and Lit's `nothing` render an empty cell.
41
41
  */
42
42
  renderer: GridCellRenderer | null;
43
- /** Builds the header label (property only); sort arrow, filter button and resize handle stay. */
43
+ /**
44
+ * Builds the header label (property only); sort arrow, filter button and resize handle stay. Keep
45
+ * the text content: it still names the column outside the header (menus, chooser, announcements, export).
46
+ */
44
47
  headerRenderer: GridHeaderRenderer | null;
45
48
  /** Builds the label of the group rows of this column (property only); the expand button and aligned summaries stay. */
46
49
  groupRenderer: GridGroupRenderer | null;
@@ -155,7 +158,10 @@ export declare class DataGridColumn extends LitElement implements GridColumnDef
155
158
  * frozen and stays the same while the nested columns don't change.
156
159
  */
157
160
  get columns(): readonly DataGridColumn[] | null;
158
- /** Header label: the trimmed text content of the element, without the text of nested columns. */
161
+ /**
162
+ * Header label: the trimmed text content of the element, without the text of nested columns. Also
163
+ * the column's name outside the header. Empty: the header shows `path`; elsewhere `path`, then `name`, as is.
164
+ */
159
165
  get label(): string;
160
166
  protected render(): import("lit-html").TemplateResult<1>;
161
167
  }
@@ -43,7 +43,10 @@ let DataGridColumn = class DataGridColumn extends LitElement {
43
43
  * light DOM). `null`, `undefined` and Lit's `nothing` render an empty cell.
44
44
  */
45
45
  this.renderer = null;
46
- /** Builds the header label (property only); sort arrow, filter button and resize handle stay. */
46
+ /**
47
+ * Builds the header label (property only); sort arrow, filter button and resize handle stay. Keep
48
+ * the text content: it still names the column outside the header (menus, chooser, announcements, export).
49
+ */
47
50
  this.headerRenderer = null;
48
51
  /** Builds the label of the group rows of this column (property only); the expand button and aligned summaries stay. */
49
52
  this.groupRenderer = null;
@@ -224,7 +227,10 @@ let DataGridColumn = class DataGridColumn extends LitElement {
224
227
  }
225
228
  return this.#nested.length ? this.#nested : null;
226
229
  }
227
- /** Header label: the trimmed text content of the element, without the text of nested columns. */
230
+ /**
231
+ * Header label: the trimmed text content of the element, without the text of nested columns. Also
232
+ * the column's name outside the header. Empty: the header shows `path`; elsewhere `path`, then `name`, as is.
233
+ */
228
234
  get label() {
229
235
  if (!this.columns) {
230
236
  return (this.textContent ?? '').trim();