@universal-material/data-grid 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +172 -2
  3. package/custom-elements.json +4652 -0
  4. package/dist/attribute-converters.d.ts +53 -0
  5. package/dist/attribute-converters.js +98 -0
  6. package/dist/attribute-converters.js.map +1 -0
  7. package/dist/change-source.d.ts +3 -0
  8. package/dist/change-source.js +2 -0
  9. package/dist/change-source.js.map +1 -0
  10. package/dist/data/data-source.d.ts +164 -0
  11. package/dist/data/data-source.js +75 -0
  12. package/dist/data/data-source.js.map +1 -0
  13. package/dist/data/local-source.d.ts +20 -0
  14. package/dist/data/local-source.js +94 -0
  15. package/dist/data/local-source.js.map +1 -0
  16. package/dist/data/remote-loader.d.ts +190 -0
  17. package/dist/data/remote-loader.js +608 -0
  18. package/dist/data/remote-loader.js.map +1 -0
  19. package/dist/export/csv.d.ts +28 -0
  20. package/dist/export/csv.js +61 -0
  21. package/dist/export/csv.js.map +1 -0
  22. package/dist/export/download.d.ts +7 -0
  23. package/dist/export/download.js +17 -0
  24. package/dist/export/download.js.map +1 -0
  25. package/dist/export/rows.d.ts +75 -0
  26. package/dist/export/rows.js +134 -0
  27. package/dist/export/rows.js.map +1 -0
  28. package/dist/export/slice.d.ts +15 -0
  29. package/dist/export/slice.js +35 -0
  30. package/dist/export/slice.js.map +1 -0
  31. package/dist/export/types.d.ts +155 -0
  32. package/dist/export/types.js +2 -0
  33. package/dist/export/types.js.map +1 -0
  34. package/dist/export/write.d.ts +38 -0
  35. package/dist/export/write.js +178 -0
  36. package/dist/export/write.js.map +1 -0
  37. package/dist/export-pdf/client.d.ts +75 -0
  38. package/dist/export-pdf/client.js +155 -0
  39. package/dist/export-pdf/client.js.map +1 -0
  40. package/dist/export-pdf/engine.d.ts +73 -0
  41. package/dist/export-pdf/engine.js +131 -0
  42. package/dist/export-pdf/engine.js.map +1 -0
  43. package/dist/export-pdf/grid-pdf.wasm +0 -0
  44. package/dist/export-pdf/index.d.ts +27 -0
  45. package/dist/export-pdf/index.js +566 -0
  46. package/dist/export-pdf/index.js.map +1 -0
  47. package/dist/export-pdf/serialize.d.ts +23 -0
  48. package/dist/export-pdf/serialize.js +127 -0
  49. package/dist/export-pdf/serialize.js.map +1 -0
  50. package/dist/export-pdf/types.d.ts +150 -0
  51. package/dist/export-pdf/types.js +2 -0
  52. package/dist/export-pdf/types.js.map +1 -0
  53. package/dist/export-pdf/worker.d.ts +2 -0
  54. package/dist/export-pdf/worker.js +81 -0
  55. package/dist/export-pdf/worker.js.map +1 -0
  56. package/dist/export-xlsx/formats.d.ts +14 -0
  57. package/dist/export-xlsx/formats.js +40 -0
  58. package/dist/export-xlsx/formats.js.map +1 -0
  59. package/dist/export-xlsx/index.d.ts +74 -0
  60. package/dist/export-xlsx/index.js +137 -0
  61. package/dist/export-xlsx/index.js.map +1 -0
  62. package/dist/features/adaptive.d.ts +25 -0
  63. package/dist/features/adaptive.js +47 -0
  64. package/dist/features/adaptive.js.map +1 -0
  65. package/dist/features/cell-content-focus.d.ts +29 -0
  66. package/dist/features/cell-content-focus.js +95 -0
  67. package/dist/features/cell-content-focus.js.map +1 -0
  68. package/dist/features/cell-range.d.ts +97 -0
  69. package/dist/features/cell-range.js +75 -0
  70. package/dist/features/cell-range.js.map +1 -0
  71. package/dist/features/clipboard.d.ts +28 -0
  72. package/dist/features/clipboard.js +48 -0
  73. package/dist/features/clipboard.js.map +1 -0
  74. package/dist/features/column-chooser.d.ts +91 -0
  75. package/dist/features/column-chooser.js +451 -0
  76. package/dist/features/column-chooser.js.map +1 -0
  77. package/dist/features/column-dnd.d.ts +10 -0
  78. package/dist/features/column-dnd.js +126 -0
  79. package/dist/features/column-dnd.js.map +1 -0
  80. package/dist/features/context-menu.d.ts +122 -0
  81. package/dist/features/context-menu.js +153 -0
  82. package/dist/features/context-menu.js.map +1 -0
  83. package/dist/features/drag-helper.d.ts +39 -0
  84. package/dist/features/drag-helper.js +108 -0
  85. package/dist/features/drag-helper.js.map +1 -0
  86. package/dist/features/drop-position.d.ts +15 -0
  87. package/dist/features/drop-position.js +24 -0
  88. package/dist/features/drop-position.js.map +1 -0
  89. package/dist/features/editing.d.ts +111 -0
  90. package/dist/features/editing.js +244 -0
  91. package/dist/features/editing.js.map +1 -0
  92. package/dist/features/filter-row.d.ts +80 -0
  93. package/dist/features/filter-row.js +538 -0
  94. package/dist/features/filter-row.js.map +1 -0
  95. package/dist/features/filtering.d.ts +55 -0
  96. package/dist/features/filtering.js +209 -0
  97. package/dist/features/filtering.js.map +1 -0
  98. package/dist/features/group-dnd.d.ts +11 -0
  99. package/dist/features/group-dnd.js +119 -0
  100. package/dist/features/group-dnd.js.map +1 -0
  101. package/dist/features/header-filter.d.ts +100 -0
  102. package/dist/features/header-filter.js +588 -0
  103. package/dist/features/header-filter.js.map +1 -0
  104. package/dist/features/host-label.d.ts +36 -0
  105. package/dist/features/host-label.js +184 -0
  106. package/dist/features/host-label.js.map +1 -0
  107. package/dist/features/keyboard.d.ts +59 -0
  108. package/dist/features/keyboard.js +127 -0
  109. package/dist/features/keyboard.js.map +1 -0
  110. package/dist/features/menu.d.ts +113 -0
  111. package/dist/features/menu.js +491 -0
  112. package/dist/features/menu.js.map +1 -0
  113. package/dist/features/resize.d.ts +82 -0
  114. package/dist/features/resize.js +214 -0
  115. package/dist/features/resize.js.map +1 -0
  116. package/dist/features/scroll-port.d.ts +51 -0
  117. package/dist/features/scroll-port.js +329 -0
  118. package/dist/features/scroll-port.js.map +1 -0
  119. package/dist/features/search.d.ts +45 -0
  120. package/dist/features/search.js +123 -0
  121. package/dist/features/search.js.map +1 -0
  122. package/dist/features/selection.d.ts +37 -0
  123. package/dist/features/selection.js +103 -0
  124. package/dist/features/selection.js.map +1 -0
  125. package/dist/features/sorting.d.ts +39 -0
  126. package/dist/features/sorting.js +53 -0
  127. package/dist/features/sorting.js.map +1 -0
  128. package/dist/features/toolbar.d.ts +125 -0
  129. package/dist/features/toolbar.js +135 -0
  130. package/dist/features/toolbar.js.map +1 -0
  131. package/dist/features/tree.d.ts +53 -0
  132. package/dist/features/tree.js +94 -0
  133. package/dist/features/tree.js.map +1 -0
  134. package/dist/features/validation.d.ts +48 -0
  135. package/dist/features/validation.js +172 -0
  136. package/dist/features/validation.js.map +1 -0
  137. package/dist/grid-column-def.d.ts +521 -0
  138. package/dist/grid-column-def.js +32 -0
  139. package/dist/grid-column-def.js.map +1 -0
  140. package/dist/grid-column.d.ts +173 -0
  141. package/dist/grid-column.js +382 -0
  142. package/dist/grid-column.js.map +1 -0
  143. package/dist/grid-i18n.d.ts +469 -0
  144. package/dist/grid-i18n.js +3222 -0
  145. package/dist/grid-i18n.js.map +1 -0
  146. package/dist/grid.d.ts +1510 -0
  147. package/dist/grid.js +15972 -0
  148. package/dist/grid.js.map +1 -0
  149. package/dist/grid.min.js +3966 -0
  150. package/dist/grid.styles.d.ts +2 -0
  151. package/dist/grid.styles.js +2849 -0
  152. package/dist/grid.styles.js.map +1 -0
  153. package/dist/render/cell.d.ts +16 -0
  154. package/dist/render/cell.js +78 -0
  155. package/dist/render/cell.js.map +1 -0
  156. package/dist/render/column-window.d.ts +18 -0
  157. package/dist/render/column-window.js +50 -0
  158. package/dist/render/column-window.js.map +1 -0
  159. package/dist/render/content.d.ts +45 -0
  160. package/dist/render/content.js +140 -0
  161. package/dist/render/content.js.map +1 -0
  162. package/dist/render/editors.d.ts +28 -0
  163. package/dist/render/editors.js +41 -0
  164. package/dist/render/editors.js.map +1 -0
  165. package/dist/render/footer.d.ts +61 -0
  166. package/dist/render/footer.js +61 -0
  167. package/dist/render/footer.js.map +1 -0
  168. package/dist/render/group-row.d.ts +35 -0
  169. package/dist/render/group-row.js +60 -0
  170. package/dist/render/group-row.js.map +1 -0
  171. package/dist/render/header.d.ts +108 -0
  172. package/dist/render/header.js +124 -0
  173. package/dist/render/header.js.map +1 -0
  174. package/dist/render/keyed-rows.d.ts +25 -0
  175. package/dist/render/keyed-rows.js +98 -0
  176. package/dist/render/keyed-rows.js.map +1 -0
  177. package/dist/render/virtualizer.d.ts +158 -0
  178. package/dist/render/virtualizer.js +721 -0
  179. package/dist/render/virtualizer.js.map +1 -0
  180. package/dist/row-model/added-rows.d.ts +32 -0
  181. package/dist/row-model/added-rows.js +95 -0
  182. package/dist/row-model/added-rows.js.map +1 -0
  183. package/dist/row-model/cell-range.d.ts +71 -0
  184. package/dist/row-model/cell-range.js +187 -0
  185. package/dist/row-model/cell-range.js.map +1 -0
  186. package/dist/row-model/columns.d.ts +102 -0
  187. package/dist/row-model/columns.js +222 -0
  188. package/dist/row-model/columns.js.map +1 -0
  189. package/dist/row-model/compare.d.ts +40 -0
  190. package/dist/row-model/compare.js +590 -0
  191. package/dist/row-model/compare.js.map +1 -0
  192. package/dist/row-model/distinct.d.ts +39 -0
  193. package/dist/row-model/distinct.js +105 -0
  194. package/dist/row-model/distinct.js.map +1 -0
  195. package/dist/row-model/filter.d.ts +80 -0
  196. package/dist/row-model/filter.js +582 -0
  197. package/dist/row-model/filter.js.map +1 -0
  198. package/dist/row-model/flatten.d.ts +129 -0
  199. package/dist/row-model/flatten.js +511 -0
  200. package/dist/row-model/flatten.js.map +1 -0
  201. package/dist/row-model/fold.d.ts +25 -0
  202. package/dist/row-model/fold.js +104 -0
  203. package/dist/row-model/fold.js.map +1 -0
  204. package/dist/row-model/format.d.ts +58 -0
  205. package/dist/row-model/format.js +239 -0
  206. package/dist/row-model/format.js.map +1 -0
  207. package/dist/row-model/group.d.ts +30 -0
  208. package/dist/row-model/group.js +173 -0
  209. package/dist/row-model/group.js.map +1 -0
  210. package/dist/row-model/lru.d.ts +19 -0
  211. package/dist/row-model/lru.js +48 -0
  212. package/dist/row-model/lru.js.map +1 -0
  213. package/dist/row-model/sort.d.ts +30 -0
  214. package/dist/row-model/sort.js +107 -0
  215. package/dist/row-model/sort.js.map +1 -0
  216. package/dist/row-model/summary.d.ts +64 -0
  217. package/dist/row-model/summary.js +213 -0
  218. package/dist/row-model/summary.js.map +1 -0
  219. package/dist/row-model/tree.d.ts +116 -0
  220. package/dist/row-model/tree.js +478 -0
  221. package/dist/row-model/tree.js.map +1 -0
  222. package/dist/row-model/types.d.ts +109 -0
  223. package/dist/row-model/types.js +5 -0
  224. package/dist/row-model/types.js.map +1 -0
  225. package/dist/row-model/value.d.ts +20 -0
  226. package/dist/row-model/value.js +57 -0
  227. package/dist/row-model/value.js.map +1 -0
  228. package/dist/state/grid-state.d.ts +147 -0
  229. package/dist/state/grid-state.js +295 -0
  230. package/dist/state/grid-state.js.map +1 -0
  231. package/dist/state/storage.d.ts +33 -0
  232. package/dist/state/storage.js +62 -0
  233. package/dist/state/storage.js.map +1 -0
  234. package/dist/state/versioned.d.ts +18 -0
  235. package/dist/state/versioned.js +56 -0
  236. package/dist/state/versioned.js.map +1 -0
  237. package/package.json +145 -6
@@ -0,0 +1,25 @@
1
+ import { type ChildPart } from 'lit';
2
+ import { Directive, type DirectiveResult, type PartInfo } from 'lit/directive.js';
3
+ type KeyOf<T> = (item: T) => unknown;
4
+ type TemplateOf<T> = (item: T) => unknown;
5
+ /**
6
+ * Lista com chave (como o `repeat` do Lit) para as linhas do corpo, sem o
7
+ * vazamento do `repeat` do lit-html 3.3: o `removePart` dele apaga o
8
+ * conteúdo e o marcador de início da parte, mas deixa no DOM o marcador de
9
+ * fim (`<!---->`). Cada linha que sai da janela virtual deixaria um
10
+ * comentário a mais no `<tbody>`, para sempre (spec 14).
11
+ *
12
+ * Reconciliação simples, feita para janelas deslizantes: percorre a lista
13
+ * nova de trás para frente e só move a parte que não está antes da
14
+ * seguinte; partes sem chave na lista nova são removidas por inteiro.
15
+ */
16
+ declare class KeyedRowsDirective<T> extends Directive {
17
+ #private;
18
+ constructor(partInfo: PartInfo);
19
+ /** SSR e 1º render sem parte: só a lista. */
20
+ render(items: readonly T[], _keyOf: KeyOf<T>, template: TemplateOf<T>): unknown[];
21
+ update(containerPart: ChildPart, [items, keyOf, template]: [readonly T[], KeyOf<T>, TemplateOf<T>]): unknown;
22
+ }
23
+ export declare const keyedRows: <T>(items: readonly T[], keyOf: KeyOf<T>, template: TemplateOf<T>) => DirectiveResult<typeof KeyedRowsDirective>;
24
+ export {};
25
+ //# sourceMappingURL=keyed-rows.d.ts.map
@@ -0,0 +1,98 @@
1
+ import { noChange } from 'lit';
2
+ import { getCommittedValue, insertPart, removePart, setChildPartValue, setCommittedValue, } from 'lit/directive-helpers.js';
3
+ import { Directive, directive, PartType } from 'lit/directive.js';
4
+ /**
5
+ * Lista com chave (como o `repeat` do Lit) para as linhas do corpo, sem o
6
+ * vazamento do `repeat` do lit-html 3.3: o `removePart` dele apaga o
7
+ * conteúdo e o marcador de início da parte, mas deixa no DOM o marcador de
8
+ * fim (`<!---->`). Cada linha que sai da janela virtual deixaria um
9
+ * comentário a mais no `<tbody>`, para sempre (spec 14).
10
+ *
11
+ * Reconciliação simples, feita para janelas deslizantes: percorre a lista
12
+ * nova de trás para frente e só move a parte que não está antes da
13
+ * seguinte; partes sem chave na lista nova são removidas por inteiro.
14
+ */
15
+ class KeyedRowsDirective extends Directive {
16
+ /** Chaves na ordem das partes hoje no DOM; `undefined` até o 1º render. */
17
+ #keys;
18
+ constructor(partInfo) {
19
+ super(partInfo);
20
+ if (partInfo.type !== PartType.CHILD) {
21
+ throw new Error('keyedRows() só pode ser usado como conteúdo.');
22
+ }
23
+ }
24
+ /** SSR e 1º render sem parte: só a lista. */
25
+ render(items, _keyOf, template) {
26
+ return items.map(item => template(item));
27
+ }
28
+ update(containerPart, [items, keyOf, template]) {
29
+ const committed = getCommittedValue(containerPart);
30
+ // 1º render desta instância (inclusive vindo de "sem dados") ou
31
+ // hidratação de SSR: devolve a lista e deixa o Lit criar as partes, como
32
+ // o `repeat` faz. Na hidratação o `@lit-labs/ssr-client` chama este
33
+ // `update` e precisa de um iterável para casar com os marcadores das
34
+ // linhas que vieram do servidor; mexer no DOM aqui e devolver `noChange`
35
+ // quebra a hidratação ("Primitive found where TemplateResult expected").
36
+ // O iterável commitado pelo Lit é um array de `ChildPart`, um por item,
37
+ // que os renders seguintes reaproveitam pela chave.
38
+ if (!this.#keys || !Array.isArray(committed) || committed.length !== this.#keys.length) {
39
+ this.#keys = items.map(keyOf);
40
+ return this.render(items, keyOf, template);
41
+ }
42
+ const oldParts = committed;
43
+ const oldKeys = this.#keys;
44
+ const newKeySet = new Set(items.map(keyOf));
45
+ const reusable = new Map();
46
+ const stale = [];
47
+ oldKeys.forEach((key, index) => {
48
+ const duplicate = reusable.get(key);
49
+ if (duplicate) {
50
+ stale.push(duplicate);
51
+ }
52
+ reusable.set(key, oldParts[index]);
53
+ });
54
+ for (const [key, part] of reusable) {
55
+ if (!newKeySet.has(key)) {
56
+ stale.push(part);
57
+ reusable.delete(key);
58
+ }
59
+ }
60
+ // Remove antes de inserir: uma parte que fica (a linha com o foco) não é
61
+ // movida só porque havia vizinhas a remover entre ela e a seguinte —
62
+ // mover um elemento focado no DOM tira o foco dele.
63
+ for (const part of stale) {
64
+ removePart(part);
65
+ // O que o `removePart` esquece (no-op se um dia ele passar a remover).
66
+ part.endNode?.parentNode?.removeChild(part.endNode);
67
+ }
68
+ const newParts = new Array(items.length);
69
+ const newKeys = new Array(items.length);
70
+ let next;
71
+ for (let index = items.length - 1; index >= 0; index--) {
72
+ const key = keyOf(items[index]);
73
+ let part = reusable.get(key);
74
+ if (part) {
75
+ // Chave repetida não reaproveita a mesma parte duas vezes.
76
+ reusable.delete(key);
77
+ insertPart(containerPart, next, part);
78
+ }
79
+ else {
80
+ part = insertPart(containerPart, next);
81
+ }
82
+ setChildPartValue(part, template(items[index]));
83
+ newParts[index] = part;
84
+ newKeys[index] = key;
85
+ next = part;
86
+ }
87
+ // Chaves repetidas na lista nova que sobraram.
88
+ for (const part of reusable.values()) {
89
+ removePart(part);
90
+ part.endNode?.parentNode?.removeChild(part.endNode);
91
+ }
92
+ setCommittedValue(containerPart, newParts);
93
+ this.#keys = newKeys;
94
+ return noChange;
95
+ }
96
+ }
97
+ export const keyedRows = directive(KeyedRowsDirective);
98
+ //# sourceMappingURL=keyed-rows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyed-rows.js","sourceRoot":"","sources":["../../src/render/keyed-rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC/C,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAuC,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAKvG;;;;;;;;;;GAUG;AACH,MAAM,kBAAsB,SAAQ,SAAS;IAC3C,2EAA2E;IAC3E,KAAK,CAAa;IAElB,YAAY,QAAkB;QAC5B,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEhB,IAAI,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,KAAK,EAAE,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED,6CAA6C;IAC7C,MAAM,CAAC,KAAmB,EAAE,MAAgB,EAAE,QAAuB;QACnE,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3C,CAAC;IAEQ,MAAM,CAAC,aAAwB,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAA0C;QACzG,MAAM,SAAS,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC;QAEnD,gEAAgE;QAChE,yEAAyE;QACzE,oEAAoE;QACpE,qEAAqE;QACrE,yEAAyE;QACzE,yEAAyE;QACzE,wEAAwE;QACxE,oDAAoD;QACpD,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,IA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AiB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;QAC3C,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC;QAErB,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC,kBAAkB,CAIN,CAAC","sourcesContent":["import { type ChildPart, noChange } from 'lit';\nimport {\n getCommittedValue,\n insertPart,\n removePart,\n setChildPartValue,\n setCommittedValue,\n} from 'lit/directive-helpers.js';\nimport { Directive, directive, type DirectiveResult, type PartInfo, PartType } from 'lit/directive.js';\n\ntype KeyOf<T> = (item: T) => unknown;\ntype TemplateOf<T> = (item: T) => unknown;\n\n/**\n * Lista com chave (como o `repeat` do Lit) para as linhas do corpo, sem o\n * vazamento do `repeat` do lit-html 3.3: o `removePart` dele apaga o\n * conteúdo e o marcador de início da parte, mas deixa no DOM o marcador de\n * fim (`<!---->`). Cada linha que sai da janela virtual deixaria um\n * comentário a mais no `<tbody>`, para sempre (spec 14).\n *\n * Reconciliação simples, feita para janelas deslizantes: percorre a lista\n * nova de trás para frente e só move a parte que não está antes da\n * seguinte; partes sem chave na lista nova são removidas por inteiro.\n */\nclass KeyedRowsDirective<T> extends Directive {\n /** Chaves na ordem das partes hoje no DOM; `undefined` até o 1º render. */\n #keys?: unknown[];\n\n constructor(partInfo: PartInfo) {\n super(partInfo);\n\n if (partInfo.type !== PartType.CHILD) {\n throw new Error('keyedRows() só pode ser usado como conteúdo.');\n }\n }\n\n /** SSR e 1º render sem parte: só a lista. */\n render(items: readonly T[], _keyOf: KeyOf<T>, template: TemplateOf<T>): unknown[] {\n return items.map(item => template(item));\n }\n\n override update(containerPart: ChildPart, [items, keyOf, template]: [readonly T[], KeyOf<T>, TemplateOf<T>]): unknown {\n const committed = getCommittedValue(containerPart);\n\n // 1º render desta instância (inclusive vindo de \"sem dados\") ou\n // hidratação de SSR: devolve a lista e deixa o Lit criar as partes, como\n // o `repeat` faz. Na hidratação o `@lit-labs/ssr-client` chama este\n // `update` e precisa de um iterável para casar com os marcadores das\n // linhas que vieram do servidor; mexer no DOM aqui e devolver `noChange`\n // quebra a hidratação (\"Primitive found where TemplateResult expected\").\n // O iterável commitado pelo Lit é um array de `ChildPart`, um por item,\n // que os renders seguintes reaproveitam pela chave.\n if (!this.#keys || !Array.isArray(committed) || committed.length !== this.#keys.length) {\n this.#keys = items.map(keyOf);\n return this.render(items, keyOf, template);\n }\n\n const oldParts = committed as ChildPart[];\n const oldKeys = this.#keys;\n const newKeySet = new Set(items.map(keyOf));\n const reusable = new Map<unknown, ChildPart>();\n const stale: ChildPart[] = [];\n\n oldKeys.forEach((key, index) => {\n const duplicate = reusable.get(key);\n\n if (duplicate) {\n stale.push(duplicate);\n }\n\n reusable.set(key, oldParts[index]);\n });\n\n for (const [key, part] of reusable) {\n if (!newKeySet.has(key)) {\n stale.push(part);\n reusable.delete(key);\n }\n }\n\n // Remove antes de inserir: uma parte que fica (a linha com o foco) não é\n // movida só porque havia vizinhas a remover entre ela e a seguinte —\n // mover um elemento focado no DOM tira o foco dele.\n for (const part of stale) {\n removePart(part);\n // O que o `removePart` esquece (no-op se um dia ele passar a remover).\n part.endNode?.parentNode?.removeChild(part.endNode);\n }\n\n const newParts: ChildPart[] = new Array(items.length);\n const newKeys: unknown[] = new Array(items.length);\n let next: ChildPart | undefined;\n\n for (let index = items.length - 1; index >= 0; index--) {\n const key = keyOf(items[index]);\n let part = reusable.get(key);\n\n if (part) {\n // Chave repetida não reaproveita a mesma parte duas vezes.\n reusable.delete(key);\n insertPart(containerPart, next, part);\n } else {\n part = insertPart(containerPart, next);\n }\n\n setChildPartValue(part, template(items[index]));\n newParts[index] = part;\n newKeys[index] = key;\n next = part;\n }\n\n // Chaves repetidas na lista nova que sobraram.\n for (const part of reusable.values()) {\n removePart(part);\n part.endNode?.parentNode?.removeChild(part.endNode);\n }\n\n setCommittedValue(containerPart, newParts);\n this.#keys = newKeys;\n\n return noChange;\n }\n}\n\nexport const keyedRows = directive(KeyedRowsDirective) as <T>(\n items: readonly T[],\n keyOf: KeyOf<T>,\n template: TemplateOf<T>,\n) => DirectiveResult<typeof KeyedRowsDirective>;\n"]}
@@ -0,0 +1,158 @@
1
+ import type { ReactiveController, ReactiveControllerHost } from 'lit';
2
+ /**
3
+ * Altura física máxima do corpo rolável. Navegadores limitam a altura de um
4
+ * elemento (Chromium ~33,5 M px, Firefox ~17,9 M px): acima disso a lista é
5
+ * ESCALADA (ver {@link RowVirtualizer}). 15 M px ≈ 312 mil linhas de 48 px.
6
+ */
7
+ export declare const MAX_SCROLL_HEIGHT = 15000000;
8
+ /** Linhas renderizadas antes de conhecer a altura da janela (1º render, SSR). */
9
+ export declare const INITIAL_RENDER_ROWS = 30;
10
+ export interface VirtualWindow {
11
+ /** 1ª linha renderizada. */
12
+ first: number;
13
+ /** Fim (exclusivo). */
14
+ end: number;
15
+ /** Deslocamento (px, coordenadas FÍSICAS do corpo) da 1ª linha renderizada. */
16
+ offset: number;
17
+ }
18
+ /** Retângulo (coordenadas da tela) da parte visível de uma porta de rolagem. */
19
+ export interface PortRect {
20
+ top: number;
21
+ left: number;
22
+ right: number;
23
+ bottom: number;
24
+ }
25
+ /**
26
+ * Porta de rolagem: um elemento rolável ou a janela, com a mesma interface
27
+ * (spec 27). Na janela, o tamanho visível é o do `documentElement` (sem as
28
+ * barras de rolagem) e a rolagem é a do `scrollingElement`.
29
+ */
30
+ export declare class ScrollPort {
31
+ readonly source: HTMLElement | Window;
32
+ constructor(source: HTMLElement | Window);
33
+ get isWindow(): boolean;
34
+ /** Onde ouvir o `scroll`/`scrollend`. */
35
+ get target(): EventTarget;
36
+ /** Elemento que rola (na janela, o `scrollingElement`). */
37
+ get element(): HTMLElement;
38
+ get scrollTop(): number;
39
+ set scrollTop(value: number);
40
+ get clientHeight(): number;
41
+ /** Parte visível (por dentro das bordas, sem as barras), em coordenadas da tela. */
42
+ rect(): PortRect;
43
+ }
44
+ export interface RowVirtualizerOptions {
45
+ getScrollElement: () => HTMLElement | Window | null;
46
+ /**
47
+ * Porta externa (spec 27): o que vem depois do corpo também rola e o corpo
48
+ * pode estar abaixo da dobra. Só muda o mapeamento físico → virtual na escala.
49
+ */
50
+ isExternal?: () => boolean;
51
+ /** Altura estimada (e, sem `wrap`, exata) de cada linha. */
52
+ rowHeight: () => number;
53
+ /** Linhas a mais acima e abaixo da janela. */
54
+ overscan: number;
55
+ /**
56
+ * Onde começa o corpo (px, no conteúdo do contêiner rolável): o que vem
57
+ * antes (barra, cabeçalho) não é linha. Lido na rolagem e no redimensionar.
58
+ */
59
+ getScrollMargin?: () => number;
60
+ /** Altura do que fica grudado no topo por cima das linhas (cabeçalho `sticky`). */
61
+ getStickyHeight?: () => number;
62
+ /** Altura do que fica grudado embaixo por cima das linhas (totais, linhas fixas do fundo). */
63
+ getStickyBottomHeight?: () => number;
64
+ }
65
+ /**
66
+ * Virtualizador de linhas do grid (spec 16), no lugar do
67
+ * `@tanstack/lit-virtual`, cujo custo é O(linhas) a cada mudança (um objeto
68
+ * de medida e uma chave por linha) e cuja altura passa do limite do
69
+ * navegador acima de ~700 mil linhas.
70
+ *
71
+ * Altura fixa (sem `wrap`): tudo é aritmética, O(1) por linha da janela.
72
+ * Alturas medidas (`wrap`): árvore de Fenwick com a altura de cada linha
73
+ * (só existe nesse modo), O(log n) para posição ↔ índice.
74
+ *
75
+ * Linhas de altura própria (detalhe do master-detail, frente 10): camada
76
+ * ESPARSA por cima das duas anteriores — índices crescentes e a diferença de
77
+ * altura de cada uma numa árvore de Fenwick de k posições, O(log k). Sem
78
+ * nenhuma, nada muda (altura fixa segue aritmética pura).
79
+ *
80
+ * Escala: com altura virtual acima de {@link MAX_SCROLL_HEIGHT}, o corpo
81
+ * físico fica nesse limite. Saltos (arrastar a barra, Home/End) mapeiam a
82
+ * posição física proporcionalmente; passos pequenos (roda, setas, Page
83
+ * Up/Down: até uma janela) andam 1:1, para a leitura não pular linhas. O
84
+ * começo e o fim físicos são sempre o começo e o fim da lista.
85
+ */
86
+ export declare class RowVirtualizer implements ReactiveController {
87
+ #private;
88
+ constructor(host: ReactiveControllerHost, options: RowVirtualizerOptions);
89
+ hostConnected(): void;
90
+ hostUpdated(): void;
91
+ hostDisconnected(): void;
92
+ /** Porta atual (spec 27); `undefined` antes do 1º render ou desconectado. */
93
+ get port(): ScrollPort | undefined;
94
+ /**
95
+ * Relê a margem, o tamanho e a posição sem evento de rolagem (spec 27: o
96
+ * conteúdo acima do grid mudou de altura dentro da porta externa).
97
+ */
98
+ sync(): void;
99
+ /** Número de linhas. */
100
+ get count(): number;
101
+ set count(count: number);
102
+ /** Esquece as alturas medidas (troca de linhas, de `rowHeight`, de colunas). */
103
+ measure(): void;
104
+ /** Quantas linhas têm altura medida diferente da estimada (diagnóstico, spec 14). */
105
+ get measuredSizes(): number;
106
+ /**
107
+ * Linhas de altura própria (linhas de detalhe): `indices` crescentes e a
108
+ * altura (estimada ou já medida) de cada uma. Substitui as anteriores — o
109
+ * grid chama depois de refazer as linhas. Custo O(k).
110
+ */
111
+ setVariableRows(indices: Int32Array, sizes: Float64Array): void;
112
+ /** Quantas linhas de altura própria há. */
113
+ get variableRows(): number;
114
+ /** Altura virtual da lista inteira. */
115
+ get virtualSize(): number;
116
+ /** Altura do corpo físico (o que vai no estilo do `<tbody>`). */
117
+ getTotalSize(): number;
118
+ /** Início virtual da linha `index`. */
119
+ startOf(index: number): number;
120
+ /** Altura da linha `index`. */
121
+ sizeOf(index: number): number;
122
+ /**
123
+ * Mede as linhas renderizadas (`data-index`): as de altura própria sempre;
124
+ * as demais só com `all` (`wrap`). Devolve `true` se alguma altura mudou
125
+ * (e pede novo render). Linha que muda ACIMA da janela visível não move o
126
+ * que está na tela: a posição de rolagem acompanha a diferença.
127
+ */
128
+ measureRows(rows: Iterable<HTMLElement>, all?: boolean): boolean;
129
+ /** Linha que contém a posição virtual `offset`. */
130
+ indexAt(offset: number): number;
131
+ /** Escala ativa: a lista virtual é maior que o corpo físico. */
132
+ get scaled(): boolean;
133
+ /**
134
+ * Porta externa (spec 27): onde a linha `index` fica no corpo FÍSICO para
135
+ * um `scrollIntoView` chegar nela. Fora da escala, o início virtual; na
136
+ * escala, escolhe o par destino (físico, virtual) — passo pequeno 1:1,
137
+ * salto proporcional — e o guarda até a rolagem chegar. `stickyTop` e
138
+ * `stickyBottom`: o que cobre o corpo na porta no destino.
139
+ */
140
+ revealOffset(index: number, stickyTop: number, stickyBottom: number): number;
141
+ /** A rolagem acabou (`scrollend`) longe do destino: esquece o destino guardado. */
142
+ endGlide(): void;
143
+ /**
144
+ * Janela de linhas a renderizar e o deslocamento físico da 1ª;
145
+ * `undefined` antes de conhecer a altura da janela.
146
+ */
147
+ getWindow(): VirtualWindow | undefined;
148
+ /** Janela efetiva do render (com o recurso do 1º render) — o grid chama no `render`. */
149
+ renderWindow(): VirtualWindow;
150
+ /**
151
+ * Rola até a linha `index`: `auto` só rola se ela não estiver inteira na
152
+ * janela; `start`/`center`/`end` alinham.
153
+ */
154
+ scrollToIndex(index: number, { align }?: {
155
+ align?: 'auto' | 'start' | 'center' | 'end';
156
+ }): void;
157
+ }
158
+ //# sourceMappingURL=virtualizer.d.ts.map