@universal-material/data-grid 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -76,6 +76,10 @@
76
76
  "description": "Header cell font weight.",
77
77
  "name": "--u-grid-header-cell-font-weight"
78
78
  },
79
+ {
80
+ "description": "With `header-wrap`, max lines of the default header label (ellipsis on the last). Integer or `none` (default).",
81
+ "name": "--u-grid-header-cell-max-lines"
82
+ },
79
83
  {
80
84
  "description": "Data cell padding (shorthand; wins over the longhands). Default `13px 16px`.",
81
85
  "name": "--u-grid-cell-padding"
@@ -706,7 +710,7 @@
706
710
  "text": "boolean"
707
711
  },
708
712
  "default": "false",
709
- "description": "Wraps the column header labels in several lines instead of an ellipsis\n(the header row grows; `--u-grid-header-cell-height` is its minimum). A\ncolumn's `headerWrap` wins. Auto-size measures the label in one line. If\nthe toolbar and the headers take more than half of the visible height,\nthe headers stop sticking (WCAG 2.4.11).",
713
+ "description": "Wraps the column header labels in several lines instead of an ellipsis\n(the header row grows; `--u-grid-header-cell-height` is its minimum). It\nbreaks only between words (hyphenation follows the `lang`); a word longer\nthan the column ends in an ellipsis, and `--u-grid-header-cell-max-lines`\nlimits the lines. A cut default label shows its full text as a tooltip on\nhover; from the keyboard, widen the column (Alt+→) or auto-size it from\nthe header menu. A column's `headerWrap` wins. Auto-size measures the\nlabel in one line. If the toolbar and the headers take more than half of\nthe visible height, the headers stop sticking (WCAG 2.4.11).",
710
714
  "attribute": "header-wrap"
711
715
  },
712
716
  {
@@ -2857,7 +2861,7 @@
2857
2861
  "text": "boolean"
2858
2862
  },
2859
2863
  "default": "false",
2860
- "description": "Wraps the column header labels in several lines instead of an ellipsis\n(the header row grows; `--u-grid-header-cell-height` is its minimum). A\ncolumn's `headerWrap` wins. Auto-size measures the label in one line. If\nthe toolbar and the headers take more than half of the visible height,\nthe headers stop sticking (WCAG 2.4.11).",
2864
+ "description": "Wraps the column header labels in several lines instead of an ellipsis\n(the header row grows; `--u-grid-header-cell-height` is its minimum). It\nbreaks only between words (hyphenation follows the `lang`); a word longer\nthan the column ends in an ellipsis, and `--u-grid-header-cell-max-lines`\nlimits the lines. A cut default label shows its full text as a tooltip on\nhover; from the keyboard, widen the column (Alt+→) or auto-size it from\nthe header menu. A column's `headerWrap` wins. Auto-size measures the\nlabel in one line. If the toolbar and the headers take more than half of\nthe visible height, the headers stop sticking (WCAG 2.4.11).",
2861
2865
  "fieldName": "headerWrap"
2862
2866
  },
2863
2867
  {
@@ -32,6 +32,13 @@ export declare class ScrollPortController implements ReactiveController {
32
32
  get external(): boolean;
33
33
  /** Altura dada ao host no modo externo corta as linhas (o grid precisa crescer com o conteúdo). */
34
34
  checkHeight(): void;
35
+ /**
36
+ * A tabela mais larga que o grid transborda no contêiner (que rola nas duas
37
+ * direções, spec 27). Com \`overflow-x: hidden\`/\`clip\` nele (ou em
38
+ * \`html\`/\`body\`, com a janela), o transbordo some sem rolagem possível
39
+ * e sem nenhum sinal: avisa uma vez (relato de uso, 0.3.0).
40
+ */
41
+ checkHorizontalClip(tableWidth: number): void;
35
42
  /** Resolve o contêiner pedido; chamado na conexão e quando as duas propriedades mudam. */
36
43
  resolve(): void;
37
44
  /** Observa as linhas renderizadas do corpo (só as novas; solta as que saíram). */
@@ -79,6 +79,28 @@ export class ScrollPortController {
79
79
  this.#warnOnce(host, 'with scroll-container the grid grows to its content; do not give it a height (it clips the rows).');
80
80
  }
81
81
  }
82
+ /**
83
+ * A tabela mais larga que o grid transborda no contêiner (que rola nas duas
84
+ * direções, spec 27). Com \`overflow-x: hidden\`/\`clip\` nele (ou em
85
+ * \`html\`/\`body\`, com a janela), o transbordo some sem rolagem possível
86
+ * e sem nenhum sinal: avisa uma vez (relato de uso, 0.3.0).
87
+ */
88
+ checkHorizontalClip(tableWidth) {
89
+ const port = this.#port;
90
+ const host = this.#host;
91
+ if (!port || tableWidth <= host.clientWidth + 1) {
92
+ return;
93
+ }
94
+ const document = host.ownerDocument;
95
+ const clipping = (element) => ['hidden', 'clip'].includes(getComputedStyle(element).overflowX);
96
+ const culprit = port.isWindow
97
+ ? [document.documentElement, document.body].find(element => element && clipping(element))
98
+ : clipping(port.source) ? port.source : undefined;
99
+ if (culprit) {
100
+ this.#warnOnce(culprit, `the table is wider than the grid, but ${port.isWindow ? `<${culprit.tagName.toLowerCase()}>` : 'its scroll container'} has `
101
+ + 'overflow-x: hidden/clip, so the extra columns cannot be scrolled to; use overflow-x: auto (or give the columns less width).');
102
+ }
103
+ }
82
104
  #warn(key, message) {
83
105
  if (!this.#warned.has(key)) {
84
106
  this.#warned.add(key);
@@ -1 +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,IAAI,CAAC;AACvD,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,OAAO,oBAAoB;IACtB,KAAK,CAAiB;IACtB,UAAU,CAAsB;IAEzC,KAAK,GAAsB,IAAI,CAAC;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C,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"]}
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;AAE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AI,EAAE,CAAC;gBACT,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;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 /**\n * A tabela mais larga que o grid transborda no contêiner (que rola nas duas\n * direções, spec 27). Com \\`overflow-x: hidden\\`/\\`clip\\` nele (ou em\n * \\`html\\`/\\`body\\`, com a janela), o transbordo some sem rolagem possível\n * e sem nenhum sinal: avisa uma vez (relato de uso, 0.3.0).\n */\n checkHorizontalClip(tableWidth: number): void {\n const port = this.#port;\n const host = this.#host;\n\n if (!port || tableWidth <= host.clientWidth + 1) {\n return;\n }\n\n const document = host.ownerDocument;\n const clipping = (element: Element) => ['hidden', 'clip'].includes(getComputedStyle(element).overflowX);\n const culprit = port.isWindow\n ? [document.documentElement, document.body].find(element => element && clipping(element))\n : clipping(port.source as HTMLElement) ? port.source as HTMLElement : undefined;\n\n if (culprit) {\n this.#warnOnce(culprit, `the table is wider than the grid, but ${port.isWindow ? `<${culprit.tagName.toLowerCase()}>` : 'its scroll container'} has `\n + 'overflow-x: hidden/clip, so the extra columns cannot be scrolled to; use overflow-x: auto (or give the columns less width).');\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"]}
@@ -118,8 +118,8 @@ export interface GridColumnDef<TItem = any> {
118
118
  /** Wraps the cell text in several lines instead of an ellipsis (cells only; see `headerWrap`). */
119
119
  wrap?: boolean;
120
120
  /**
121
- * Wraps the header label in several lines instead of an ellipsis; the
122
- * header row grows. `null`/absent: the grid's `headerWrap`; `false` turns it
121
+ * Wraps the header label in several lines (between words) instead of an
122
+ * ellipsis; the header row grows. `null`/absent: the grid's `headerWrap`; `false` turns it
123
123
  * off for this column.
124
124
  */
125
125
  headerWrap?: boolean | null;
@@ -1 +1 @@
1
- {"version":3,"file":"grid-column-def.js","sourceRoot":"","sources":["../src/grid-column-def.ts"],"names":[],"mappings":"AA+eA;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAqB,EAAW,EAAE,CAClE,MAAM,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAE3F;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAqB,EAAW,EAAE,CACjE,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AAEpF;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAqB,EAAW,EAAE,CACnE,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AAExF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAqB,EAAW,EAAE,CACnE,MAAM,CAAC,UAAU,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AA8H5F;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAqB,EAAW,EAAE,CACjE,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAE7D;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,MAAwC,EAAW,EAAE,CAC1E,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,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/**\r\n * Boolean as text (`trueText`/`falseText`), as a read-only check/cross icon\r\n * (`icon`) or as a check for `true` only (`check`: `false` shows nothing, its\r\n * text stays for screen readers).\r\n */\r\nexport type GridColumnBooleanDisplay = 'text' | 'icon' | 'check';\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: `[field, operation, value]`. `field` is the column `path`\r\n * or, for a column without `path` (computed by `valueGetter`), its `name`;\r\n * a `path` match wins over a `name` (the reverse of `GridColumnRef`), and a\r\n * field that matches no column is read from the items as a dot 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 [field: string, operation: GridFilterOperation, value?: unknown]\r\n | readonly [field: 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`, or the `name` of a column with a `valueGetter`) 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`) and, for a column without `path`, in filter conditions\r\n * (`filterValue`). Default: `path`. A column without `name` and `path` is\r\n * left out 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 /**\r\n * `'text'` (default: `trueText`/`falseText`), `'icon'` (read-only check/cross,\r\n * the text as its accessible name) or `'check'` (check for `true` only;\r\n * `false` keeps its text for screen readers).\r\n */\r\n booleanDisplay?: GridColumnBooleanDisplay | null;\r\n /**\r\n * Text of `true` in a boolean column (declared or inferred): cell, icon\r\n * name, group row, filters, copy/paste, summaries and export. Empty or\r\n * `null`: the language's `trueText`. A fixed text: it does not follow\r\n * `language`.\r\n */\r\n trueText?: string | null;\r\n /** Text of `false` in a boolean column, like `trueText`. Empty or `null`: the language's `falseText`. */\r\n falseText?: string | null;\r\n /** Wraps the cell text in several lines instead of an ellipsis (cells only; see `headerWrap`). */\r\n wrap?: boolean;\r\n /**\r\n * Wraps the header label in several lines instead of an ellipsis; the\r\n * header row grows. `null`/absent: the grid's `headerWrap`; `false` turns it\r\n * off for this column.\r\n */\r\n headerWrap?: boolean | null;\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` with a `path`, or with a\r\n * `valueGetter` and a `name` (not with remote filtering). The filter\r\n * expression refers to the column by `path` or, without one, by `name`.\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 /**\r\n * The first row of the group in the current order (after filtering), to\r\n * show data of the group's rows (an icon, a link); `undefined` when the\r\n * group has no loaded rows (remote groups).\r\n */\r\n readonly firstItem: TItem | undefined;\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, olhando só a coluna? A condição a\r\n * aponta pelo `path` ou, sem `path`, pelo `name` (spec 28). Padrão: com\r\n * `path`, ou com `valueGetter` e `name` (sem getter a coluna sem `path` não\r\n * tem valor; `filterable: true` não muda isso). O grid ainda tira a colisão\r\n * de `name` e o remoto.\r\n * @internal\r\n */\r\nexport const isColumnFilterable = (column: GridColumnDef): boolean =>\r\n column.filterable !== false && (!!column.path || (!!column.valueGetter && !!column.name));\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":"AA+eA;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAqB,EAAW,EAAE,CAClE,MAAM,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAE3F;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAqB,EAAW,EAAE,CACjE,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AAEpF;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAqB,EAAW,EAAE,CACnE,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AAExF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAqB,EAAW,EAAE,CACnE,MAAM,CAAC,UAAU,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AA8H5F;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAqB,EAAW,EAAE,CACjE,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAE7D;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,MAAwC,EAAW,EAAE,CAC1E,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,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/**\r\n * Boolean as text (`trueText`/`falseText`), as a read-only check/cross icon\r\n * (`icon`) or as a check for `true` only (`check`: `false` shows nothing, its\r\n * text stays for screen readers).\r\n */\r\nexport type GridColumnBooleanDisplay = 'text' | 'icon' | 'check';\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: `[field, operation, value]`. `field` is the column `path`\r\n * or, for a column without `path` (computed by `valueGetter`), its `name`;\r\n * a `path` match wins over a `name` (the reverse of `GridColumnRef`), and a\r\n * field that matches no column is read from the items as a dot 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 [field: string, operation: GridFilterOperation, value?: unknown]\r\n | readonly [field: 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`, or the `name` of a column with a `valueGetter`) 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`) and, for a column without `path`, in filter conditions\r\n * (`filterValue`). Default: `path`. A column without `name` and `path` is\r\n * left out 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 /**\r\n * `'text'` (default: `trueText`/`falseText`), `'icon'` (read-only check/cross,\r\n * the text as its accessible name) or `'check'` (check for `true` only;\r\n * `false` keeps its text for screen readers).\r\n */\r\n booleanDisplay?: GridColumnBooleanDisplay | null;\r\n /**\r\n * Text of `true` in a boolean column (declared or inferred): cell, icon\r\n * name, group row, filters, copy/paste, summaries and export. Empty or\r\n * `null`: the language's `trueText`. A fixed text: it does not follow\r\n * `language`.\r\n */\r\n trueText?: string | null;\r\n /** Text of `false` in a boolean column, like `trueText`. Empty or `null`: the language's `falseText`. */\r\n falseText?: string | null;\r\n /** Wraps the cell text in several lines instead of an ellipsis (cells only; see `headerWrap`). */\r\n wrap?: boolean;\r\n /**\r\n * Wraps the header label in several lines (between words) instead of an\r\n * ellipsis; the header row grows. `null`/absent: the grid's `headerWrap`; `false` turns it\r\n * off for this column.\r\n */\r\n headerWrap?: boolean | null;\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` with a `path`, or with a\r\n * `valueGetter` and a `name` (not with remote filtering). The filter\r\n * expression refers to the column by `path` or, without one, by `name`.\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 /**\r\n * The first row of the group in the current order (after filtering), to\r\n * show data of the group's rows (an icon, a link); `undefined` when the\r\n * group has no loaded rows (remote groups).\r\n */\r\n readonly firstItem: TItem | undefined;\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, olhando só a coluna? A condição a\r\n * aponta pelo `path` ou, sem `path`, pelo `name` (spec 28). Padrão: com\r\n * `path`, ou com `valueGetter` e `name` (sem getter a coluna sem `path` não\r\n * tem valor; `filterable: true` não muda isso). O grid ainda tira a colisão\r\n * de `name` e o remoto.\r\n * @internal\r\n */\r\nexport const isColumnFilterable = (column: GridColumnDef): boolean =>\r\n column.filterable !== false && (!!column.path || (!!column.valueGetter && !!column.name));\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"]}
package/dist/grid.d.ts CHANGED
@@ -436,6 +436,7 @@ export interface GridColumnReorderEventDetail {
436
436
  * @cssprop --u-grid-header-cell-padding - Header cell padding.
437
437
  * @cssprop --u-grid-header-cell-font-size - Header cell font size. Default `0.8125rem`.
438
438
  * @cssprop --u-grid-header-cell-font-weight - Header cell font weight.
439
+ * @cssprop --u-grid-header-cell-max-lines - With `header-wrap`, max lines of the default header label (ellipsis on the last). Integer or `none` (default).
439
440
  * @cssprop --u-grid-cell-padding - Data cell padding (shorthand; wins over the longhands). Default `13px 16px`.
440
441
  * @cssprop --u-grid-cell-block-padding - Block padding of data and header cells; wins over the old `--u-table-cell-padding` and `--u-grid-data-cell-padding`. Default `13px`.
441
442
  * @cssprop --u-grid-cell-inline-padding - Inline padding of data and header cells; wins over the old `--u-table-cell-padding` and `--u-grid-data-cell-padding`. Default `16px`.
@@ -615,10 +616,14 @@ export declare class DataGrid extends LitElement {
615
616
  loading: boolean;
616
617
  /**
617
618
  * Wraps the column header labels in several lines instead of an ellipsis
618
- * (the header row grows; `--u-grid-header-cell-height` is its minimum). A
619
- * column's `headerWrap` wins. Auto-size measures the label in one line. If
620
- * the toolbar and the headers take more than half of the visible height,
621
- * the headers stop sticking (WCAG 2.4.11).
619
+ * (the header row grows; `--u-grid-header-cell-height` is its minimum). It
620
+ * breaks only between words (hyphenation follows the `lang`); a word longer
621
+ * than the column ends in an ellipsis, and `--u-grid-header-cell-max-lines`
622
+ * limits the lines. A cut default label shows its full text as a tooltip on
623
+ * hover; from the keyboard, widen the column (Alt+→) or auto-size it from
624
+ * the header menu. A column's `headerWrap` wins. Auto-size measures the
625
+ * label in one line. If the toolbar and the headers take more than half of
626
+ * the visible height, the headers stop sticking (WCAG 2.4.11).
622
627
  */
623
628
  headerWrap: boolean;
624
629
  /**
package/dist/grid.js CHANGED
@@ -542,6 +542,7 @@ const isRenderResult = (value) => value === null || value === undefined || value
542
542
  * @cssprop --u-grid-header-cell-padding - Header cell padding.
543
543
  * @cssprop --u-grid-header-cell-font-size - Header cell font size. Default `0.8125rem`.
544
544
  * @cssprop --u-grid-header-cell-font-weight - Header cell font weight.
545
+ * @cssprop --u-grid-header-cell-max-lines - With `header-wrap`, max lines of the default header label (ellipsis on the last). Integer or `none` (default).
545
546
  * @cssprop --u-grid-cell-padding - Data cell padding (shorthand; wins over the longhands). Default `13px 16px`.
546
547
  * @cssprop --u-grid-cell-block-padding - Block padding of data and header cells; wins over the old `--u-table-cell-padding` and `--u-grid-data-cell-padding`. Default `13px`.
547
548
  * @cssprop --u-grid-cell-inline-padding - Inline padding of data and header cells; wins over the old `--u-table-cell-padding` and `--u-grid-data-cell-padding`. Default `16px`.
@@ -718,10 +719,14 @@ let DataGrid = class DataGrid extends LitElement {
718
719
  this.loading = false;
719
720
  /**
720
721
  * Wraps the column header labels in several lines instead of an ellipsis
721
- * (the header row grows; `--u-grid-header-cell-height` is its minimum). A
722
- * column's `headerWrap` wins. Auto-size measures the label in one line. If
723
- * the toolbar and the headers take more than half of the visible height,
724
- * the headers stop sticking (WCAG 2.4.11).
722
+ * (the header row grows; `--u-grid-header-cell-height` is its minimum). It
723
+ * breaks only between words (hyphenation follows the `lang`); a word longer
724
+ * than the column ends in an ellipsis, and `--u-grid-header-cell-max-lines`
725
+ * limits the lines. A cut default label shows its full text as a tooltip on
726
+ * hover; from the keyboard, widen the column (Alt+→) or auto-size it from
727
+ * the header menu. A column's `headerWrap` wins. Auto-size measures the
728
+ * label in one line. If the toolbar and the headers take more than half of
729
+ * the visible height, the headers stop sticking (WCAG 2.4.11).
725
730
  */
726
731
  this.headerWrap = false;
727
732
  /** Linhas de esqueleto do `loading` sem linhas: fixo no servidor e no 1º render (hidratação); depois, o que cabe. */
@@ -1393,6 +1398,19 @@ let DataGrid = class DataGrid extends LitElement {
1393
1398
  /** Barra (painel de grupos, busca, seletor) observada para a altura que prende o cabeçalho. */
1394
1399
  this.#observedToolbar = null;
1395
1400
  this.#toolbarRef = createRef();
1401
+ /**
1402
+ * Fontes carregadas depois da medida (relato de uso: "Obrigatório" medido
1403
+ * com a fonte de reserva e cortado 1px quando a Lato chegou): as larguras
1404
+ * automáticas são medidas de novo; as do usuário e as definidas ficam.
1405
+ */
1406
+ this.#onFontsLoaded = () => {
1407
+ if (!this.columnAutoWidth) {
1408
+ return;
1409
+ }
1410
+ this.#autoWidthDirty = true;
1411
+ this.#layoutDirty = true;
1412
+ this.requestUpdate();
1413
+ };
1396
1414
  /**
1397
1415
  * Linhas de detalhe de um bloco de itens: posições dos itens cuja expansão
1398
1416
  * difere do padrão. Poucas chaves sem `keyExpr`: `indexOf` por chave
@@ -1680,7 +1698,21 @@ let DataGrid = class DataGrid extends LitElement {
1680
1698
  * ao passar o mouse — medir todas as células a cada render custaria caro.
1681
1699
  */
1682
1700
  this.#updateCellHint = (event) => {
1683
- const cell = event.target?.closest?.('td.truncate');
1701
+ const target = event.target;
1702
+ // Rótulo do cabeçalho cortado (reticências, palavra longa ou limite de linhas): a dica tem o texto
1703
+ // inteiro — só no rótulo padrão (\`headerRenderer\` cuida do próprio conteúdo). Conforto de mouse:
1704
+ // pelo teclado, o rótulo inteiro se lê alargando a coluna ou pelo autoajuste (spec 17).
1705
+ const label = target?.closest?.('th .header-text');
1706
+ if (label instanceof HTMLElement && !label.firstElementChild) {
1707
+ if (label.scrollWidth > label.clientWidth || label.scrollHeight > label.clientHeight) {
1708
+ label.title = label.textContent.trim();
1709
+ }
1710
+ else {
1711
+ label.removeAttribute('title');
1712
+ }
1713
+ return;
1714
+ }
1715
+ const cell = target?.closest?.('td.truncate');
1684
1716
  if (!(cell instanceof HTMLElement)) {
1685
1717
  return;
1686
1718
  }
@@ -4494,12 +4526,20 @@ let DataGrid = class DataGrid extends LitElement {
4494
4526
  }
4495
4527
  return result;
4496
4528
  }
4529
+ /**
4530
+ * Fontes carregadas depois da medida (relato de uso: "Obrigatório" medido
4531
+ * com a fonte de reserva e cortado 1px quando a Lato chegou): as larguras
4532
+ * automáticas são medidas de novo; as do usuário e as definidas ficam.
4533
+ */
4534
+ #onFontsLoaded;
4497
4535
  connectedCallback() {
4498
4536
  // Shadow root declarativo antes do 1º update: hidratação do SSR.
4499
4537
  const hydrating = !this.hasUpdated && !!this.shadowRoot;
4500
4538
  super.connectedCallback();
4501
4539
  this.#readDeclarativeColumns();
4502
4540
  this.#unobserveDocumentLanguage = observeDocumentLanguage(() => this.requestUpdate());
4541
+ // Fonte da página que chega depois da 1ª medida (web font): \`column-auto-width\` mede de novo.
4542
+ document.fonts?.addEventListener('loadingdone', this.#onFontsLoaded);
4503
4543
  this.#hostLabel.update();
4504
4544
  this.#dragAndDropDirty = true;
4505
4545
  this.#layoutDirty = true;
@@ -4534,6 +4574,7 @@ let DataGrid = class DataGrid extends LitElement {
4534
4574
  super.disconnectedCallback();
4535
4575
  this.#unobserveDocumentLanguage?.();
4536
4576
  this.#unobserveDocumentLanguage = undefined;
4577
+ document.fonts?.removeEventListener('loadingdone', this.#onFontsLoaded);
4537
4578
  this.#columnDragAndDrop.detach();
4538
4579
  this.#groupDragAndDrop.detach();
4539
4580
  releaseInteractions(this);
@@ -9560,6 +9601,7 @@ let DataGrid = class DataGrid extends LitElement {
9560
9601
  this.#syncFixedRows();
9561
9602
  this.#syncRevealMargins();
9562
9603
  this.#scrollPort.checkHeight();
9604
+ this.#scrollPort.checkHorizontalClip(this.#tableRef.value?.offsetWidth ?? 0);
9563
9605
  }
9564
9606
  /**
9565
9607
  * Classe, deslocamento `sticky` e limites de cada coluna visível. Os