@universal-material/data-grid 0.1.0 → 0.3.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 (55) hide show
  1. package/README.md +37 -20
  2. package/custom-elements.json +149 -22
  3. package/dist/data/data-source.d.ts +6 -2
  4. package/dist/data/data-source.js.map +1 -1
  5. package/dist/export/types.d.ts +1 -1
  6. package/dist/export/types.js.map +1 -1
  7. package/dist/export-xlsx/index.d.ts +2 -1
  8. package/dist/export-xlsx/index.js +4 -2
  9. package/dist/export-xlsx/index.js.map +1 -1
  10. package/dist/features/column-chooser.js +4 -3
  11. package/dist/features/column-chooser.js.map +1 -1
  12. package/dist/features/filter-row.d.ts +1 -0
  13. package/dist/features/filter-row.js +16 -10
  14. package/dist/features/filter-row.js.map +1 -1
  15. package/dist/features/header-filter.d.ts +9 -2
  16. package/dist/features/header-filter.js +22 -11
  17. package/dist/features/header-filter.js.map +1 -1
  18. package/dist/features/scroll-port.d.ts +51 -0
  19. package/dist/features/scroll-port.js +329 -0
  20. package/dist/features/scroll-port.js.map +1 -0
  21. package/dist/grid-column-def.d.ts +60 -14
  22. package/dist/grid-column-def.js +6 -2
  23. package/dist/grid-column-def.js.map +1 -1
  24. package/dist/grid-column.d.ts +31 -7
  25. package/dist/grid-column.js +40 -7
  26. package/dist/grid-column.js.map +1 -1
  27. package/dist/grid-i18n.js +14 -14
  28. package/dist/grid-i18n.js.map +1 -1
  29. package/dist/grid.d.ts +61 -14
  30. package/dist/grid.js +758 -165
  31. package/dist/grid.js.map +1 -1
  32. package/dist/grid.min.js +621 -474
  33. package/dist/grid.styles.js +153 -15
  34. package/dist/grid.styles.js.map +1 -1
  35. package/dist/render/cell.js +5 -2
  36. package/dist/render/cell.js.map +1 -1
  37. package/dist/render/group-row.js +2 -1
  38. package/dist/render/group-row.js.map +1 -1
  39. package/dist/render/header.d.ts +17 -1
  40. package/dist/render/header.js +23 -2
  41. package/dist/render/header.js.map +1 -1
  42. package/dist/render/virtualizer.d.ts +49 -1
  43. package/dist/render/virtualizer.js +229 -17
  44. package/dist/render/virtualizer.js.map +1 -1
  45. package/dist/row-model/columns.d.ts +40 -0
  46. package/dist/row-model/columns.js +25 -0
  47. package/dist/row-model/columns.js.map +1 -1
  48. package/dist/row-model/filter.d.ts +19 -4
  49. package/dist/row-model/filter.js +29 -9
  50. package/dist/row-model/filter.js.map +1 -1
  51. package/dist/row-model/format.js +1 -1
  52. package/dist/row-model/format.js.map +1 -1
  53. package/dist/state/grid-state.d.ts +2 -2
  54. package/dist/state/grid-state.js.map +1 -1
  55. package/package.json +7 -3
package/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # `<u-grid>` — @universal-material/data-grid
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@universal-material/data-grid)](https://www.npmjs.com/package/@universal-material/data-grid)
4
- [![license](https://img.shields.io/npm/l/@universal-material/data-grid)](https://github.com/universal-material/data-grid/blob/main/LICENSE)
4
+ [![license](https://img.shields.io/npm/l/@universal-material/data-grid)](https://github.com/erichideyuki/universal-data-grid/blob/main/LICENSE)
5
+ [![sponsor](https://img.shields.io/github/sponsors/erichideyuki?label=Sponsor&logo=GitHub)](https://github.com/sponsors/erichideyuki)
5
6
 
6
7
  **A fast, accessible data grid as a standard Web Component.** `<u-grid>` is built with
7
8
  [Lit](https://lit.dev) and belongs to the [Universal Material](https://universal-material.github.io/)
@@ -9,10 +10,10 @@ family. Because it is a native custom element, it works the same in plain HTML,
9
10
  Vue or Svelte.
10
11
 
11
12
  **[Live documentation and examples →](https://universal-material.github.io/data-grid/)**
12
- &nbsp;·&nbsp; [Full API reference](https://github.com/universal-material/data-grid/blob/main/API.md)
13
- &nbsp;·&nbsp; [GitHub](https://github.com/universal-material/data-grid)
13
+ &nbsp;·&nbsp; [Full API reference](https://github.com/erichideyuki/universal-data-grid/blob/main/API.md)
14
+ &nbsp;·&nbsp; [GitHub](https://github.com/erichideyuki/universal-data-grid)
14
15
 
15
- ![A <u-grid> grouped by year](https://raw.githubusercontent.com/universal-material/data-grid/main/.github/readme/overview.webp)
16
+ ![Grouping by dragging a column header into the group panel](https://raw.githubusercontent.com/erichideyuki/universal-data-grid/main/.github/readme/grouping.gif)
16
17
 
17
18
  ---
18
19
 
@@ -20,7 +21,8 @@ Vue or Svelte.
20
21
 
21
22
  - **Millions of rows.** Its own row virtualization renders only the visible rows. Sorting,
22
23
  grouping and expanding don't add per-row work, and the scroll range scales past the browser's
23
- maximum element height. Hundreds of columns can be virtualized as well.
24
+ maximum element height. Hundreds of columns can be virtualized as well, and the grid can scroll
25
+ with the page or a parent panel (`scroll-container`) and still virtualize both.
24
26
  - **Remote data.** A `dataSource` whose server filters, sorts, groups, summarizes and pages. Only the
25
27
  visible blocks load, with skeleton rows, a pager or infinite scrolling, a load panel and "Retry".
26
28
  - **Shape the data.** Multi-column sorting, a filter row, a search panel, header filters, grouping by
@@ -45,6 +47,16 @@ Vue or Svelte.
45
47
  responsive auto-hide, a toolbar and context menus, state persistence, and export to CSV, Excel
46
48
  and tagged PDF.
47
49
 
50
+ ## See it in action
51
+
52
+ | A million rows | Search and filter |
53
+ | --- | --- |
54
+ | ![Scrolling through a million rows, then grouping them by country](https://raw.githubusercontent.com/erichideyuki/universal-data-grid/main/.github/readme/big-data.gif) | ![Typing in the search panel highlights matches, ignoring case and accents](https://raw.githubusercontent.com/erichideyuki/universal-data-grid/main/.github/readme/filtering.gif) |
55
+ | **Real-time updates** | **Batch editing** |
56
+ | ![A stock ticker updating prices many times per second](https://raw.githubusercontent.com/erichideyuki/universal-data-grid/main/.github/readme/real-time.gif) | ![Editing cells in batch mode; changed cells stay marked until saved](https://raw.githubusercontent.com/erichideyuki/universal-data-grid/main/.github/readme/editing.gif) |
57
+
58
+ Every GIF is recorded from the [live documentation](https://universal-material.github.io/data-grid/), where you can try each feature yourself.
59
+
48
60
  ## Install
49
61
 
50
62
  ```bash
@@ -52,7 +64,7 @@ npm i @universal-material/data-grid
52
64
  ```
53
65
 
54
66
  The package is modern ESM with TypeScript declarations and a
55
- [custom elements manifest](https://github.com/custom-elements-manifest/custom-elements-manifest).
67
+ [custom elements manifest](https://github.com/webcomponents/custom-elements-manifest).
56
68
  `lit`, `@lit/context` and `interactjs` are regular dependencies, so your bundler shares them with
57
69
  the rest of your app. Importing the package registers `<u-grid>` as a side effect.
58
70
 
@@ -67,7 +79,7 @@ A self-contained bundle (Lit included) is published for CDNs. An import map lets
67
79
  <script type="importmap">
68
80
  {
69
81
  "imports": {
70
- "@universal-material/data-grid": "https://cdn.jsdelivr.net/npm/@universal-material/data-grid@0.1/dist/grid.min.js"
82
+ "@universal-material/data-grid": "https://cdn.jsdelivr.net/npm/@universal-material/data-grid@0.3/dist/grid.min.js"
71
83
  }
72
84
  }
73
85
  </script>
@@ -91,7 +103,8 @@ A self-contained bundle (Lit included) is published for CDNs. An import map lets
91
103
  ```
92
104
 
93
105
  > **Give the grid a height.** It fills its container (`height: 100%`), so the grid or its parent
94
- > needs a defined height for the scroll area.
106
+ > needs a defined height for the scroll area — unless it scrolls with the page or a parent
107
+ > ([`scroll-container`](https://github.com/erichideyuki/universal-data-grid/blob/main/API.md#scrolling-with-the-page-or-a-parent)).
95
108
 
96
109
  ### Lit
97
110
 
@@ -124,24 +137,24 @@ export class OrderList extends LitElement {
124
137
  Set `columns`, `items` and other objects as **properties** (not attributes), and listen to the
125
138
  `u-grid-*` events: `[columns]` in Angular (with `CUSTOM_ELEMENTS_SCHEMA`), `columns={…}` in
126
139
  React 19+, and `:columns.prop` in Vue. Import the package before the first render. Details are in
127
- [Using with frameworks](https://github.com/universal-material/data-grid/blob/main/API.md#using-with-frameworks).
140
+ [Using with frameworks](https://github.com/erichideyuki/universal-data-grid/blob/main/API.md#using-with-frameworks).
128
141
 
129
142
  ## Documentation
130
143
 
131
144
  - **[Live docs](https://universal-material.github.io/data-grid/)** have one runnable example per
132
145
  feature, with its source code.
133
- - **[API.md](https://github.com/universal-material/data-grid/blob/main/API.md)** is the complete
146
+ - **[API.md](https://github.com/erichideyuki/universal-data-grid/blob/main/API.md)** is the complete
134
147
  guide and reference: every property, attribute, method, event, type, CSS custom property and
135
148
  part, by feature. Popular sections:
136
- [columns](https://github.com/universal-material/data-grid/blob/main/API.md#defining-columns),
137
- [data sources and paging](https://github.com/universal-material/data-grid/blob/main/API.md#data-sources-keys--paging),
138
- [real-time changes](https://github.com/universal-material/data-grid/blob/main/API.md#refreshing-and-incremental-changes),
139
- [editing](https://github.com/universal-material/data-grid/blob/main/API.md#editing),
140
- [i18n](https://github.com/universal-material/data-grid/blob/main/API.md#internationalization-i18n),
141
- [accessibility](https://github.com/universal-material/data-grid/blob/main/API.md#accessibility),
142
- [theming](https://github.com/universal-material/data-grid/blob/main/API.md#theming),
143
- [SSR](https://github.com/universal-material/data-grid/blob/main/API.md#server-side-rendering) and the
144
- [API tables](https://github.com/universal-material/data-grid/blob/main/API.md#api-reference).
149
+ [columns](https://github.com/erichideyuki/universal-data-grid/blob/main/API.md#defining-columns),
150
+ [data sources and paging](https://github.com/erichideyuki/universal-data-grid/blob/main/API.md#data-sources-keys--paging),
151
+ [real-time changes](https://github.com/erichideyuki/universal-data-grid/blob/main/API.md#refreshing-and-incremental-changes),
152
+ [editing](https://github.com/erichideyuki/universal-data-grid/blob/main/API.md#editing),
153
+ [i18n](https://github.com/erichideyuki/universal-data-grid/blob/main/API.md#internationalization-i18n),
154
+ [accessibility](https://github.com/erichideyuki/universal-data-grid/blob/main/API.md#accessibility),
155
+ [theming](https://github.com/erichideyuki/universal-data-grid/blob/main/API.md#theming),
156
+ [SSR](https://github.com/erichideyuki/universal-data-grid/blob/main/API.md#server-side-rendering) and the
157
+ [API tables](https://github.com/erichideyuki/universal-data-grid/blob/main/API.md#api-reference).
145
158
  - `@universal-material/data-grid/custom-elements.json` describes the elements for IDEs and
146
159
  tooling.
147
160
 
@@ -151,6 +164,10 @@ Current evergreen browsers: Chrome and Edge 114+, Firefox 125+, and Safari 17+.
151
164
  ES2022, the Popover API and modern CSS (`color-mix()`, `:has()`). Internet Explorer and legacy
152
165
  Edge are not supported.
153
166
 
167
+ ## Sponsor
168
+
169
+ If `<u-grid>` helps you, consider [sponsoring its development on GitHub](https://github.com/sponsors/erichideyuki).
170
+
154
171
  ## License
155
172
 
156
- [MIT](https://github.com/universal-material/data-grid/blob/main/LICENSE) © Eric Kono
173
+ [MIT](https://github.com/erichideyuki/universal-data-grid/blob/main/LICENSE) © Eric Kono
@@ -57,7 +57,11 @@
57
57
  "name": "--u-grid-toolbar-inline-padding"
58
58
  },
59
59
  {
60
- "description": "Height of the column header cells. Default `46px`.",
60
+ "description": "Space between the bar items and between its lines (a `gap` value). Default `8px`. A change at runtime applies at the next toolbar layout (resize or item change).",
61
+ "name": "--u-grid-toolbar-gap"
62
+ },
63
+ {
64
+ "description": "Minimum height of the column header cells (rows with `header-wrap` grow). Default `46px`.",
61
65
  "name": "--u-grid-header-cell-height"
62
66
  },
63
67
  {
@@ -73,15 +77,15 @@
73
77
  "name": "--u-grid-header-cell-font-weight"
74
78
  },
75
79
  {
76
- "description": "Data cell padding. Default `13px 16px`.",
80
+ "description": "Data cell padding (shorthand; wins over the longhands). Default `13px 16px`.",
77
81
  "name": "--u-grid-cell-padding"
78
82
  },
79
83
  {
80
- "description": "Block padding of data and header cells. Default `13px`.",
84
+ "description": "Block padding of data and header cells; wins over the old `--u-table-cell-padding` and `--u-grid-data-cell-padding`. Default `13px`.",
81
85
  "name": "--u-grid-cell-block-padding"
82
86
  },
83
87
  {
84
- "description": "Inline padding of data and header cells. Default `16px`.",
88
+ "description": "Inline padding of data and header cells; wins over the old `--u-table-cell-padding` and `--u-grid-data-cell-padding`. Default `16px`.",
85
89
  "name": "--u-grid-cell-inline-padding"
86
90
  },
87
91
  {
@@ -197,11 +201,11 @@
197
201
  "name": "--u-grid-drop-indicator-width"
198
202
  },
199
203
  {
200
- "description": "Invisible resize hit area at the end of each header cell (over the end padding, capped to it; the cursor changes on hover). Default `8px`.",
204
+ "description": "Invisible resize area at the end of each header cell, over its end padding (the header buttons reach up to it). Default `8px`.",
201
205
  "name": "--u-grid-resize-handle-width"
202
206
  },
203
207
  {
204
- "description": "Size of the \"⋮\" column header menu button and of the header filter button. Default `24px` (WCAG 2.5.8).",
208
+ "description": "Size of the header \"⋮\" and filter buttons, side by side. Default `24px` (WCAG 2.5.8; below it, add spacing).",
205
209
  "name": "--u-grid-column-header-menu-button-size"
206
210
  },
207
211
  {
@@ -265,7 +269,7 @@
265
269
  "name": "--u-grid-load-panel-background-color"
266
270
  },
267
271
  {
268
- "description": "Color of the placeholders in rows still loading.",
272
+ "description": "Color of the placeholders in rows still loading (remote rows, or `loading` with no rows).",
269
273
  "name": "--u-grid-skeleton-row-color"
270
274
  },
271
275
  {
@@ -355,7 +359,7 @@
355
359
  "name": "selection-checkbox"
356
360
  },
357
361
  {
358
- "description": "The cell rendered in the empty state.",
362
+ "description": "The cell rendered in the empty state, or the \"Loading…\" cell while `loading` has no rows.",
359
363
  "name": "no-data"
360
364
  },
361
365
  {
@@ -579,11 +583,11 @@
579
583
  "name": "page-info"
580
584
  },
581
585
  {
582
- "description": "The load panel shown while a data source loads.",
586
+ "description": "The load panel shown while a data source loads or `loading` is set (with rows).",
583
587
  "name": "load-panel"
584
588
  },
585
589
  {
586
- "description": "Rows of a remote source not loaded yet (with `row`).",
590
+ "description": "Rows of a remote source not loaded yet (with `row`), or placeholder rows while `loading` has no rows.",
587
591
  "name": "skeleton-row"
588
592
  },
589
593
  {
@@ -685,6 +689,26 @@
685
689
  "default": "null",
686
690
  "description": "Builds the empty state (property only) shown when there are no rows to\nshow; `ctx.filtered` tells a filter/search hid every item. Without it,\nthe translated \"No data\" text."
687
691
  },
692
+ {
693
+ "kind": "field",
694
+ "name": "loading",
695
+ "type": {
696
+ "text": "boolean"
697
+ },
698
+ "default": "false",
699
+ "description": "Shows the grid as loading, for `items` you are still fetching. With rows\non screen, the load panel (`::part(load-panel)`) covers them; with no rows\nyet, a \"Loading…\" row and placeholder rows (`::part(skeleton-row)`) take\nthe place of the empty state (`noDataRenderer` is not called). Placeholder\nrows are never data: not exported, selected, counted or focusable by API.\nDoes not fire `u-grid-loading`/`u-grid-load`; with `dataSource`, it adds\nto the source's own loading state (the getter returns only what you set).",
700
+ "attribute": "loading"
701
+ },
702
+ {
703
+ "kind": "field",
704
+ "name": "headerWrap",
705
+ "type": {
706
+ "text": "boolean"
707
+ },
708
+ "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).",
710
+ "attribute": "header-wrap"
711
+ },
688
712
  {
689
713
  "kind": "field",
690
714
  "name": "detailRenderer",
@@ -920,6 +944,25 @@
920
944
  "description": "`virtual` (default): every row is in the scroll range and a remote\nsource loads the visible blocks. `infinite`: the next block loads when\nthe end is reached (remote paging only; with `paging` the pager wins).",
921
945
  "attribute": "scroll-mode"
922
946
  },
947
+ {
948
+ "kind": "field",
949
+ "name": "scrollContainer",
950
+ "type": {
951
+ "text": "string | null"
952
+ },
953
+ "default": "null",
954
+ "description": "Scrolls the grid with an outer container instead of its own scrollbar:\nthe id of an ANCESTOR of the grid (the first ancestor with this id,\ncrossing shadow boundaries, unlike IDREF attributes), or `window` for\nthe page (wins over an element with `id=\"window\"`). The grid grows to\nits content (do not give it a height), the container scrolls in both\ndirections, and rows and columns are still virtualized by the visible\npart of the container; toolbar, headers, totals, fixed rows and columns\nstick to it. The container's `scroll-padding-top`/`-bottom` offsets\nwhat the page sticks there (an app bar). `<html>` (or the\n`document.scrollingElement`) means the window; `<body>` only when it is\nthe scrolling element. Not found, not an ancestor or empty: a console\nwarning and the grid's own scrolling. An element between the grid and\nthe container that clips or scrolls (`overflow` other than\n`visible`/`clip`) also warns: sticky headers would stick to it. Resolved when\nthe grid connects and when this changes (changing the ancestor's id\nlater does not re-resolve). The attribute alone renders the outer mode\non the server.",
955
+ "attribute": "scroll-container"
956
+ },
957
+ {
958
+ "kind": "field",
959
+ "name": "scrollContainerElement",
960
+ "type": {
961
+ "text": "HTMLElement | Window | null"
962
+ },
963
+ "default": "null",
964
+ "description": "The outer scroll container by reference (wins over `scrollContainer`):\nan ancestor element, or `window`. `document.documentElement` (or the\n`document.scrollingElement`) means the window. See `scrollContainer`."
965
+ },
923
966
  {
924
967
  "kind": "field",
925
968
  "name": "items",
@@ -962,7 +1005,7 @@
962
1005
  "text": "number"
963
1006
  },
964
1007
  "default": "48",
965
- "description": "Row height in px (rows with `wrap` columns can grow).",
1008
+ "description": "Row height in px, padding included (rows with `wrap` columns or taller content grow; the virtualizer measures them).",
966
1009
  "attribute": "row-height"
967
1010
  },
968
1011
  {
@@ -1155,7 +1198,7 @@
1155
1198
  "type": {
1156
1199
  "text": "GridFilterExpression | null"
1157
1200
  },
1158
- "description": "Column filter (property only): a serializable expression such as\n`[['age', '>', 30], 'and', ['name', 'contains', 'an']]`. The filter row\nand the header filter read and write it, so it always holds the current\nfilter. The grid keeps a frozen copy (never the host array). Setting it\ndoes not fire `u-grid-filter-change`."
1201
+ "description": "Column filter (property only): a serializable expression such as\n`[['age', '>', 30], 'and', ['name', 'contains', 'an']]`. The filter row\nand the header filter read and write it, so it always holds the current\nfilter. A condition refers to its column by `path` or, for a computed\ncolumn (`valueGetter` without `path`), by `name`. The grid keeps a frozen\ncopy (never the host array). Setting it does not fire `u-grid-filter-change`."
1159
1202
  },
1160
1203
  {
1161
1204
  "kind": "field",
@@ -1998,7 +2041,7 @@
1998
2041
  "text": "GridFilterExpression | null"
1999
2042
  }
2000
2043
  },
2001
- "description": "The effective filter: `filterValue` `and` the search, as an expression\n(copy). The search becomes `[path, 'contains', text]` joined by `or`\nover the visible filterable columns (number and date columns included:\n`contains` matches their displayed text). `null` without filter."
2044
+ "description": "The effective filter: `filterValue` `and` the search, as an expression\n(copy). The search becomes `[field, 'contains', text]` (`field`: the\n`path`, or the `name` of a computed column) joined by `or`\nover the visible filterable columns (number and date columns included:\n`contains` matches their displayed text). `null` without filter."
2002
2045
  },
2003
2046
  {
2004
2047
  "kind": "method",
@@ -2799,6 +2842,24 @@
2799
2842
  "description": "Groups start expanded. INITIAL default: afterwards expansion is grid\nstate (`expandGroup`, `expandAllGroups`…); changing it resets that state.",
2800
2843
  "fieldName": "autoExpandGroups"
2801
2844
  },
2845
+ {
2846
+ "name": "loading",
2847
+ "type": {
2848
+ "text": "boolean"
2849
+ },
2850
+ "default": "false",
2851
+ "description": "Shows the grid as loading, for `items` you are still fetching. With rows\non screen, the load panel (`::part(load-panel)`) covers them; with no rows\nyet, a \"Loading…\" row and placeholder rows (`::part(skeleton-row)`) take\nthe place of the empty state (`noDataRenderer` is not called). Placeholder\nrows are never data: not exported, selected, counted or focusable by API.\nDoes not fire `u-grid-loading`/`u-grid-load`; with `dataSource`, it adds\nto the source's own loading state (the getter returns only what you set).",
2852
+ "fieldName": "loading"
2853
+ },
2854
+ {
2855
+ "name": "header-wrap",
2856
+ "type": {
2857
+ "text": "boolean"
2858
+ },
2859
+ "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).",
2861
+ "fieldName": "headerWrap"
2862
+ },
2802
2863
  {
2803
2864
  "name": "auto-expand-rows",
2804
2865
  "type": {
@@ -2970,6 +3031,15 @@
2970
3031
  "description": "`virtual` (default): every row is in the scroll range and a remote\nsource loads the visible blocks. `infinite`: the next block loads when\nthe end is reached (remote paging only; with `paging` the pager wins).",
2971
3032
  "fieldName": "scrollMode"
2972
3033
  },
3034
+ {
3035
+ "name": "scroll-container",
3036
+ "type": {
3037
+ "text": "string | null"
3038
+ },
3039
+ "default": "null",
3040
+ "description": "Scrolls the grid with an outer container instead of its own scrollbar:\nthe id of an ANCESTOR of the grid (the first ancestor with this id,\ncrossing shadow boundaries, unlike IDREF attributes), or `window` for\nthe page (wins over an element with `id=\"window\"`). The grid grows to\nits content (do not give it a height), the container scrolls in both\ndirections, and rows and columns are still virtualized by the visible\npart of the container; toolbar, headers, totals, fixed rows and columns\nstick to it. The container's `scroll-padding-top`/`-bottom` offsets\nwhat the page sticks there (an app bar). `<html>` (or the\n`document.scrollingElement`) means the window; `<body>` only when it is\nthe scrolling element. Not found, not an ancestor or empty: a console\nwarning and the grid's own scrolling. An element between the grid and\nthe container that clips or scrolls (`overflow` other than\n`visible`/`clip`) also warns: sticky headers would stick to it. Resolved when\nthe grid connects and when this changes (changing the ancestor's id\nlater does not re-resolve). The attribute alone renders the outer mode\non the server.",
3041
+ "fieldName": "scrollContainer"
3042
+ },
2973
3043
  {
2974
3044
  "name": "sort-mode",
2975
3045
  "type": {
@@ -2993,7 +3063,7 @@
2993
3063
  "text": "number"
2994
3064
  },
2995
3065
  "default": "48",
2996
- "description": "Row height in px (rows with `wrap` columns can grow).",
3066
+ "description": "Row height in px, padding included (rows with `wrap` columns or taller content grow; the virtualizer measures them).",
2997
3067
  "fieldName": "rowHeight"
2998
3068
  },
2999
3069
  {
@@ -3936,7 +4006,7 @@
3936
4006
  "text": "string"
3937
4007
  },
3938
4008
  "default": "''",
3939
- "description": "Stable id of the column in the grid state (`getState`, `stateStorage`)\nand in string column references (`summary` items look it up before\n`path`). Default: `path`. A column without `name` and `path` is left out\nof the state.",
4009
+ "description": "Stable id of the column in the grid state (`getState`, `stateStorage`)\nand in string column references (`summary` items look it up before\n`path`) and, for a column without `path`, in filter conditions\n(`filterValue`). Default: `path`. A column without `name` and `path` is\nleft out of the state.",
3940
4010
  "attribute": "name"
3941
4011
  },
3942
4012
  {
@@ -3955,7 +4025,7 @@
3955
4025
  "text": "GridHeaderRenderer | null"
3956
4026
  },
3957
4027
  "default": "null",
3958
- "description": "Builds the header label (property only); sort arrow, filter button and resize handle stay."
4028
+ "description": "Builds the header label (property only); sort arrow, filter button and resize handle stay. Keep\nthe text content: it still names the column outside the header (menus, chooser, announcements, export)."
3959
4029
  },
3960
4030
  {
3961
4031
  "kind": "field",
@@ -4020,9 +4090,29 @@
4020
4090
  "text": "GridColumnBooleanDisplay | null"
4021
4091
  },
4022
4092
  "default": "null",
4023
- "description": "`text` (default) or `icon` (read-only check icon) for boolean columns.",
4093
+ "description": "`text` (default), `icon` (read-only check/cross icon) or `check` (check\nicon for `true`, nothing visible for `false`) for boolean columns.",
4024
4094
  "attribute": "boolean-display"
4025
4095
  },
4096
+ {
4097
+ "kind": "field",
4098
+ "name": "trueText",
4099
+ "type": {
4100
+ "text": "string | null"
4101
+ },
4102
+ "default": "null",
4103
+ "description": "Text of `true` in this boolean column (cell, icon name, group row, filters,\ncopy/paste, summaries, export). Empty or unset: the language's `trueText`;\na fixed text, it does not follow `language`.",
4104
+ "attribute": "true-text"
4105
+ },
4106
+ {
4107
+ "kind": "field",
4108
+ "name": "falseText",
4109
+ "type": {
4110
+ "text": "string | null"
4111
+ },
4112
+ "default": "null",
4113
+ "description": "Text of `false` in this boolean column, like `trueText`. Empty or unset: the language's `falseText`.",
4114
+ "attribute": "false-text"
4115
+ },
4026
4116
  {
4027
4117
  "kind": "field",
4028
4118
  "name": "wrap",
@@ -4033,6 +4123,16 @@
4033
4123
  "description": "Wraps the text in several lines instead of an ellipsis (`wrap=\"false\"` turns it off).",
4034
4124
  "attribute": "wrap"
4035
4125
  },
4126
+ {
4127
+ "kind": "field",
4128
+ "name": "headerWrap",
4129
+ "type": {
4130
+ "text": "boolean | null"
4131
+ },
4132
+ "default": "null",
4133
+ "description": "Wraps the header label in several lines (`header-wrap`); `header-wrap=\"false\"`\nturns off the grid's `header-wrap` for this column. Unset: the grid's.",
4134
+ "attribute": "header-wrap"
4135
+ },
4036
4136
  {
4037
4137
  "kind": "field",
4038
4138
  "name": "minWidth",
@@ -4178,7 +4278,7 @@
4178
4278
  "text": "boolean | null"
4179
4279
  },
4180
4280
  "default": "null",
4181
- "description": "Allows filtering by this column (filter row, header filter and, by\ndefault, the search panel). Default (`null`): `true` when the column has\na `path`. `filterable=\"false\"` disables it.",
4281
+ "description": "Allows filtering by this column (filter row, header filter and, by\ndefault, the search panel). Default (`null`): `true` with a `path`, or\nwith a `valueGetter` and a `name` (not with remote filtering).\n`filterable=\"false\"` disables it.",
4182
4282
  "attribute": "filterable"
4183
4283
  },
4184
4284
  {
@@ -4263,7 +4363,7 @@
4263
4363
  "type": {
4264
4364
  "text": "string"
4265
4365
  },
4266
- "description": "Header label: the trimmed text content of the element, without the text of nested columns.",
4366
+ "description": "Header label: the trimmed text content of the element, without the text of nested columns. Also\nthe column's name outside the header. Empty: the header shows `path`; elsewhere `path`, then `name`, as is.",
4267
4367
  "readonly": true
4268
4368
  }
4269
4369
  ],
@@ -4299,7 +4399,7 @@
4299
4399
  "text": "string"
4300
4400
  },
4301
4401
  "default": "''",
4302
- "description": "Stable id of the column in the grid state (`getState`, `stateStorage`)\nand in string column references (`summary` items look it up before\n`path`). Default: `path`. A column without `name` and `path` is left out\nof the state.",
4402
+ "description": "Stable id of the column in the grid state (`getState`, `stateStorage`)\nand in string column references (`summary` items look it up before\n`path`) and, for a column without `path`, in filter conditions\n(`filterValue`). Default: `path`. A column without `name` and `path` is\nleft out of the state.",
4303
4403
  "fieldName": "name"
4304
4404
  },
4305
4405
  {
@@ -4326,9 +4426,27 @@
4326
4426
  "text": "GridColumnBooleanDisplay | null"
4327
4427
  },
4328
4428
  "default": "null",
4329
- "description": "`text` (default) or `icon` (read-only check icon) for boolean columns.",
4429
+ "description": "`text` (default), `icon` (read-only check/cross icon) or `check` (check\nicon for `true`, nothing visible for `false`) for boolean columns.",
4330
4430
  "fieldName": "booleanDisplay"
4331
4431
  },
4432
+ {
4433
+ "name": "true-text",
4434
+ "type": {
4435
+ "text": "string | null"
4436
+ },
4437
+ "default": "null",
4438
+ "description": "Text of `true` in this boolean column (cell, icon name, group row, filters,\ncopy/paste, summaries, export). Empty or unset: the language's `trueText`;\na fixed text, it does not follow `language`.",
4439
+ "fieldName": "trueText"
4440
+ },
4441
+ {
4442
+ "name": "false-text",
4443
+ "type": {
4444
+ "text": "string | null"
4445
+ },
4446
+ "default": "null",
4447
+ "description": "Text of `false` in this boolean column, like `trueText`. Empty or unset: the language's `falseText`.",
4448
+ "fieldName": "falseText"
4449
+ },
4332
4450
  {
4333
4451
  "name": "wrap",
4334
4452
  "type": {
@@ -4338,6 +4456,15 @@
4338
4456
  "description": "Wraps the text in several lines instead of an ellipsis (`wrap=\"false\"` turns it off).",
4339
4457
  "fieldName": "wrap"
4340
4458
  },
4459
+ {
4460
+ "name": "header-wrap",
4461
+ "type": {
4462
+ "text": "boolean | null"
4463
+ },
4464
+ "default": "null",
4465
+ "description": "Wraps the header label in several lines (`header-wrap`); `header-wrap=\"false\"`\nturns off the grid's `header-wrap` for this column. Unset: the grid's.",
4466
+ "fieldName": "headerWrap"
4467
+ },
4341
4468
  {
4342
4469
  "name": "min-width",
4343
4470
  "type": {
@@ -4452,7 +4579,7 @@
4452
4579
  "text": "boolean | null"
4453
4580
  },
4454
4581
  "default": "null",
4455
- "description": "Allows filtering by this column (filter row, header filter and, by\ndefault, the search panel). Default (`null`): `true` when the column has\na `path`. `filterable=\"false\"` disables it.",
4582
+ "description": "Allows filtering by this column (filter row, header filter and, by\ndefault, the search panel). Default (`null`): `true` with a `path`, or\nwith a `valueGetter` and a `name` (not with remote filtering).\n`filterable=\"false\"` disables it.",
4456
4583
  "fieldName": "filterable"
4457
4584
  },
4458
4585
  {
@@ -43,9 +43,13 @@ export interface GridLoadOptions {
43
43
  readonly take?: number;
44
44
  /** Sorting, in priority order (grouped columns included, with the direction of their groups). */
45
45
  readonly sort: readonly GridLoadSort[];
46
- /** Column filter `and` search — the same as `getCombinedFilter()`; `null` without filter. */
46
+ /**
47
+ * Column filter `and` search — the same as `getCombinedFilter()`; `null` without filter.
48
+ * A condition refers to its column by `path` or, for a computed column (`valueGetter`
49
+ * without `path`, filterable only with `filterable: true`), by `name`: translate it.
50
+ */
47
51
  readonly filter: GridFilterExpression | null;
48
- /** Column filter only (the `filterValue` property). */
52
+ /** Column filter only (the `filterValue` property; columns by `path` or `name`, as in `filter`). */
49
53
  readonly filterValue: GridFilterExpression | null;
50
54
  /** Raw search text (already part of `filter`), for servers with their own text search. */
51
55
  readonly searchText: string;
@@ -1 +1 @@
1
- {"version":3,"file":"data-source.js","sourceRoot":"","sources":["../../src/data/data-source.ts"],"names":[],"mappings":"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","sourcesContent":["import type {\n GridFilterExpression,\n GridGroupPath,\n GridSortOrder,\n GridSummaryType,\n} from '../grid-column-def.js';\nimport { getValueByPath } from '../row-model/value.js';\n\n/** Key of a row read by `keyExpr`. */\nexport type GridRowKey = string | number;\n\n/** `keyExpr` of `<u-grid>`: a property `path` (dots allowed) or a function that returns the key of an item. */\nexport type GridKeyExpr<TItem = any> = string | ((item: TItem) => GridRowKey);\n\n/** How rows scroll: `virtual` (all rows, rendered on demand) or `infinite` (the next block loads at the end; `dataSource` only). */\nexport type GridScrollMode = 'virtual' | 'infinite';\n\n/** A column of `GridLoadOptions.sort`. */\nexport interface GridLoadSort {\n /** Column `path`. */\n readonly path: string;\n /** Direction. */\n readonly order: GridSortOrder;\n}\n\n/** A grouping level of `GridLoadOptions.group`, outermost first. */\nexport interface GridLoadGroup {\n /** Column `path`. */\n readonly path: string;\n /** Order of the group keys. */\n readonly order: GridSortOrder;\n /** `false`: return only the keys, counts and summaries of the level (`items: null`). The grid always asks `false`. */\n readonly expanded: boolean;\n}\n\n/** A summary the server computes (`totalSummary`, `groupSummary`). */\nexport interface GridLoadSummary {\n /** Column `path`. */\n readonly path: string;\n /** Aggregate (custom aggregate functions are never sent). */\n readonly type: GridSummaryType;\n /** The `name` of the summary item, when it has one. */\n readonly name?: string;\n}\n\n/**\n * What the grid asks the data source. Frozen data: the host builds the\n * request from it — the grid never builds URLs or queries. `filter`,\n * `filterValue`, `searchText` and the paths come from the user and must be\n * validated by the server (allow-list of paths and operations).\n */\nexport interface GridLoadOptions {\n /** Rows to skip (absent = from the start). */\n readonly skip?: number;\n /** Rows to return (absent = all). */\n readonly take?: number;\n /** Sorting, in priority order (grouped columns included, with the direction of their groups). */\n readonly sort: readonly GridLoadSort[];\n /** Column filter `and` search — the same as `getCombinedFilter()`; `null` without filter. */\n readonly filter: GridFilterExpression | null;\n /** Column filter only (the `filterValue` property). */\n readonly filterValue: GridFilterExpression | null;\n /** Raw search text (already part of `filter`), for servers with their own text search. */\n readonly searchText: string;\n /**\n * All grouping levels, outermost first (empty = not grouped). Return groups\n * (`GridLoadGroupResult[]`) of level `groupPath.length` while it is less than\n * `group.length`; items when it is equal.\n */\n readonly group: readonly GridLoadGroup[];\n /** Values of the open group, outermost first: only rows of that group (exact equality). `null` = all rows. */\n readonly groupPath: GridGroupPath | null;\n /** Return `totalCount`. */\n readonly requireTotalCount: boolean;\n /** Return `groupCount` (number of groups of the level). */\n readonly requireGroupCount: boolean;\n /** Summaries over all matching rows, returned in `GridLoadResult.summary` in this order. */\n readonly totalSummary: readonly GridLoadSummary[];\n /** Summaries of each returned group, in `GridLoadGroupResult.summary` in this order. */\n readonly groupSummary: readonly GridLoadSummary[];\n /** Tree data (`treeMode=\"flat\"`): which nodes to return; absent or `null` = a plain list. */\n readonly tree?: GridLoadTree | null;\n}\n\n/** `GridLoadOptions.tree`: what a tree asks the data source (items with their `parentKeyExpr`). */\nexport interface GridLoadTree {\n /**\n * Return the children of these nodes (`[rootParentKey]` = the root nodes;\n * keys as set — text when `root-parent-key` came from the attribute).\n * `null` = a remote filter is active: return the matching nodes AND all\n * their ancestors, at once.\n */\n readonly parentKeys: readonly (GridRowKey | null)[] | null;\n}\n\n/** A group returned when `GridLoadOptions.group` is not empty. */\nexport interface GridLoadGroupResult<TItem = any> {\n /** Group value. */\n key: unknown;\n /** Number of data rows in the group. */\n count: number;\n /** `null` (the grid always asks collapsed groups); items or subgroups are accepted and ignored. */\n items: readonly TItem[] | readonly GridLoadGroupResult<TItem>[] | null;\n /** Values of `groupSummary`, in its order. */\n summary?: readonly unknown[];\n}\n\n/** What `GridDataSource.load` resolves to. */\nexport interface GridLoadResult<TItem = any> {\n /** Items, or groups when `group` was not empty. */\n data: readonly TItem[] | readonly GridLoadGroupResult<TItem>[];\n /** Number of matching rows (when `requireTotalCount`). */\n totalCount?: number;\n /** Number of groups of the level (when `requireGroupCount`). */\n groupCount?: number;\n /** Values of `totalSummary`, in its order. */\n summary?: readonly unknown[];\n}\n\n/**\n * Data source of `<u-grid>`: the grid calls `load` and the host fetches the\n * data. `signal` aborts when the request is no longer needed (sorting,\n * filtering or grouping changed, `refresh()`, grid removed).\n */\nexport interface GridDataSource<TItem = any> {\n load(options: GridLoadOptions, signal: AbortSignal): Promise<GridLoadResult<TItem>>;\n}\n\n/**\n * Operations done by the server (`remoteOperations`). Remote `paging` or\n * `grouping` also turn on `filtering`, `sorting` and `summary`, and `paging`\n * turns on `grouping` (console warning); `summary` alone is ignored (the\n * grid has every row and computes it).\n */\nexport interface GridRemoteOperations {\n /** The server applies `filter` (or `filterValue` + `searchText`). */\n filtering?: boolean;\n /** The server applies `sort`. */\n sorting?: boolean;\n /** The server applies `skip`/`take` (rows load in blocks of `pageSize`). */\n paging?: boolean;\n /** The server returns groups (`group`, `groupPath`). */\n grouping?: boolean;\n /** The server computes `totalSummary`/`groupSummary` (with remote paging or grouping). */\n summary?: boolean;\n}\n\n/** Changes for `applyChanges()`: `update` and `remove` find rows by key (`keyExpr`). */\nexport interface GridDataChanges<TItem = any> {\n /** New items (appended to the loaded rows, or at their sorted place with `reshapeOnChanges`; with remote paging the rows reload). */\n add?: readonly TItem[];\n /** New versions of items (same key). */\n update?: readonly TItem[];\n /** Keys of the rows to remove. */\n remove?: readonly unknown[];\n}\n\n/** Operações remotas já normalizadas (dependências aplicadas). */\nexport interface RemoteFlags {\n filtering: boolean;\n sorting: boolean;\n paging: boolean;\n grouping: boolean;\n summary: boolean;\n}\n\nexport const NO_REMOTE: RemoteFlags = Object.freeze({\n filtering: false,\n sorting: false,\n paging: false,\n grouping: false,\n summary: false,\n});\n\n/**\n * Normaliza `remoteOperations`: paginação ou agrupamento no servidor exigem\n * filtrar e ordenar lá; paginar no servidor exige agrupar lá (os grupos\n * precisam de todas as linhas); resumo remoto só existe com paginação ou\n * agrupamento remotos (senão o grid tem todas as linhas e calcula).\n * `forced` lista o que foi ligado por dependência (para o aviso).\n */\nexport const normalizeRemoteOperations = (\n value: boolean | GridRemoteOperations | null | undefined,\n): { flags: RemoteFlags; forced: string[] } => {\n if (!value) {\n return { flags: NO_REMOTE, forced: [] };\n }\n\n if (value === true) {\n return { flags: { filtering: true, sorting: true, paging: true, grouping: true, summary: true }, forced: [] };\n }\n\n const forced: string[] = [];\n const flags: RemoteFlags = {\n filtering: !!value.filtering,\n sorting: !!value.sorting,\n paging: !!value.paging,\n grouping: !!value.grouping,\n summary: !!value.summary,\n };\n\n const force = (name: keyof RemoteFlags) => {\n if (!flags[name]) {\n flags[name] = true;\n forced.push(name);\n }\n };\n\n if (flags.paging) {\n force('grouping');\n }\n\n if (flags.paging || flags.grouping) {\n force('filtering');\n force('sorting');\n force('summary');\n } else {\n flags.summary = false;\n }\n\n return { flags, forced };\n};\n\n/** Leitor da chave de linha: `keyExpr` ou, sem ela, o próprio item. */\nexport const keyReader = (keyExpr: GridKeyExpr | null | undefined): (item: unknown) => unknown => {\n if (typeof keyExpr === 'function') {\n return keyExpr as (item: unknown) => unknown;\n }\n\n if (typeof keyExpr === 'string' && keyExpr) {\n if (!keyExpr.includes('.')) {\n return item => item === null || item === undefined ? undefined : (item as Record<string, unknown>)[keyExpr];\n }\n\n return item => getValueByPath(item, keyExpr);\n }\n\n return item => item;\n};\n\n/** Texto da chave para o `key` das linhas renderizadas (`1` e `\"1\"` são chaves diferentes). */\nexport const keyText = (key: unknown): string =>\n typeof key === 'string' ? `s${key}` : typeof key === 'number' ? `n${key}` : `${typeof key}:${String(key)}`;\n\n/** Congela opções em profundidade (arrays e objetos simples). */\nexport const deepFreeze = <T>(value: T): T => {\n if (value && typeof value === 'object' && !Object.isFrozen(value) && !(value instanceof Date)) {\n Object.freeze(value);\n\n for (const entry of Object.values(value)) {\n deepFreeze(entry);\n }\n }\n\n return value;\n};\n"]}
1
+ {"version":3,"file":"data-source.js","sourceRoot":"","sources":["../../src/data/data-source.ts"],"names":[],"mappings":"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","sourcesContent":["import type {\n GridFilterExpression,\n GridGroupPath,\n GridSortOrder,\n GridSummaryType,\n} from '../grid-column-def.js';\nimport { getValueByPath } from '../row-model/value.js';\n\n/** Key of a row read by `keyExpr`. */\nexport type GridRowKey = string | number;\n\n/** `keyExpr` of `<u-grid>`: a property `path` (dots allowed) or a function that returns the key of an item. */\nexport type GridKeyExpr<TItem = any> = string | ((item: TItem) => GridRowKey);\n\n/** How rows scroll: `virtual` (all rows, rendered on demand) or `infinite` (the next block loads at the end; `dataSource` only). */\nexport type GridScrollMode = 'virtual' | 'infinite';\n\n/** A column of `GridLoadOptions.sort`. */\nexport interface GridLoadSort {\n /** Column `path`. */\n readonly path: string;\n /** Direction. */\n readonly order: GridSortOrder;\n}\n\n/** A grouping level of `GridLoadOptions.group`, outermost first. */\nexport interface GridLoadGroup {\n /** Column `path`. */\n readonly path: string;\n /** Order of the group keys. */\n readonly order: GridSortOrder;\n /** `false`: return only the keys, counts and summaries of the level (`items: null`). The grid always asks `false`. */\n readonly expanded: boolean;\n}\n\n/** A summary the server computes (`totalSummary`, `groupSummary`). */\nexport interface GridLoadSummary {\n /** Column `path`. */\n readonly path: string;\n /** Aggregate (custom aggregate functions are never sent). */\n readonly type: GridSummaryType;\n /** The `name` of the summary item, when it has one. */\n readonly name?: string;\n}\n\n/**\n * What the grid asks the data source. Frozen data: the host builds the\n * request from it — the grid never builds URLs or queries. `filter`,\n * `filterValue`, `searchText` and the paths come from the user and must be\n * validated by the server (allow-list of paths and operations).\n */\nexport interface GridLoadOptions {\n /** Rows to skip (absent = from the start). */\n readonly skip?: number;\n /** Rows to return (absent = all). */\n readonly take?: number;\n /** Sorting, in priority order (grouped columns included, with the direction of their groups). */\n readonly sort: readonly GridLoadSort[];\n /**\n * Column filter `and` search — the same as `getCombinedFilter()`; `null` without filter.\n * A condition refers to its column by `path` or, for a computed column (`valueGetter`\n * without `path`, filterable only with `filterable: true`), by `name`: translate it.\n */\n readonly filter: GridFilterExpression | null;\n /** Column filter only (the `filterValue` property; columns by `path` or `name`, as in `filter`). */\n readonly filterValue: GridFilterExpression | null;\n /** Raw search text (already part of `filter`), for servers with their own text search. */\n readonly searchText: string;\n /**\n * All grouping levels, outermost first (empty = not grouped). Return groups\n * (`GridLoadGroupResult[]`) of level `groupPath.length` while it is less than\n * `group.length`; items when it is equal.\n */\n readonly group: readonly GridLoadGroup[];\n /** Values of the open group, outermost first: only rows of that group (exact equality). `null` = all rows. */\n readonly groupPath: GridGroupPath | null;\n /** Return `totalCount`. */\n readonly requireTotalCount: boolean;\n /** Return `groupCount` (number of groups of the level). */\n readonly requireGroupCount: boolean;\n /** Summaries over all matching rows, returned in `GridLoadResult.summary` in this order. */\n readonly totalSummary: readonly GridLoadSummary[];\n /** Summaries of each returned group, in `GridLoadGroupResult.summary` in this order. */\n readonly groupSummary: readonly GridLoadSummary[];\n /** Tree data (`treeMode=\"flat\"`): which nodes to return; absent or `null` = a plain list. */\n readonly tree?: GridLoadTree | null;\n}\n\n/** `GridLoadOptions.tree`: what a tree asks the data source (items with their `parentKeyExpr`). */\nexport interface GridLoadTree {\n /**\n * Return the children of these nodes (`[rootParentKey]` = the root nodes;\n * keys as set — text when `root-parent-key` came from the attribute).\n * `null` = a remote filter is active: return the matching nodes AND all\n * their ancestors, at once.\n */\n readonly parentKeys: readonly (GridRowKey | null)[] | null;\n}\n\n/** A group returned when `GridLoadOptions.group` is not empty. */\nexport interface GridLoadGroupResult<TItem = any> {\n /** Group value. */\n key: unknown;\n /** Number of data rows in the group. */\n count: number;\n /** `null` (the grid always asks collapsed groups); items or subgroups are accepted and ignored. */\n items: readonly TItem[] | readonly GridLoadGroupResult<TItem>[] | null;\n /** Values of `groupSummary`, in its order. */\n summary?: readonly unknown[];\n}\n\n/** What `GridDataSource.load` resolves to. */\nexport interface GridLoadResult<TItem = any> {\n /** Items, or groups when `group` was not empty. */\n data: readonly TItem[] | readonly GridLoadGroupResult<TItem>[];\n /** Number of matching rows (when `requireTotalCount`). */\n totalCount?: number;\n /** Number of groups of the level (when `requireGroupCount`). */\n groupCount?: number;\n /** Values of `totalSummary`, in its order. */\n summary?: readonly unknown[];\n}\n\n/**\n * Data source of `<u-grid>`: the grid calls `load` and the host fetches the\n * data. `signal` aborts when the request is no longer needed (sorting,\n * filtering or grouping changed, `refresh()`, grid removed).\n */\nexport interface GridDataSource<TItem = any> {\n load(options: GridLoadOptions, signal: AbortSignal): Promise<GridLoadResult<TItem>>;\n}\n\n/**\n * Operations done by the server (`remoteOperations`). Remote `paging` or\n * `grouping` also turn on `filtering`, `sorting` and `summary`, and `paging`\n * turns on `grouping` (console warning); `summary` alone is ignored (the\n * grid has every row and computes it).\n */\nexport interface GridRemoteOperations {\n /** The server applies `filter` (or `filterValue` + `searchText`). */\n filtering?: boolean;\n /** The server applies `sort`. */\n sorting?: boolean;\n /** The server applies `skip`/`take` (rows load in blocks of `pageSize`). */\n paging?: boolean;\n /** The server returns groups (`group`, `groupPath`). */\n grouping?: boolean;\n /** The server computes `totalSummary`/`groupSummary` (with remote paging or grouping). */\n summary?: boolean;\n}\n\n/** Changes for `applyChanges()`: `update` and `remove` find rows by key (`keyExpr`). */\nexport interface GridDataChanges<TItem = any> {\n /** New items (appended to the loaded rows, or at their sorted place with `reshapeOnChanges`; with remote paging the rows reload). */\n add?: readonly TItem[];\n /** New versions of items (same key). */\n update?: readonly TItem[];\n /** Keys of the rows to remove. */\n remove?: readonly unknown[];\n}\n\n/** Operações remotas já normalizadas (dependências aplicadas). */\nexport interface RemoteFlags {\n filtering: boolean;\n sorting: boolean;\n paging: boolean;\n grouping: boolean;\n summary: boolean;\n}\n\nexport const NO_REMOTE: RemoteFlags = Object.freeze({\n filtering: false,\n sorting: false,\n paging: false,\n grouping: false,\n summary: false,\n});\n\n/**\n * Normaliza `remoteOperations`: paginação ou agrupamento no servidor exigem\n * filtrar e ordenar lá; paginar no servidor exige agrupar lá (os grupos\n * precisam de todas as linhas); resumo remoto só existe com paginação ou\n * agrupamento remotos (senão o grid tem todas as linhas e calcula).\n * `forced` lista o que foi ligado por dependência (para o aviso).\n */\nexport const normalizeRemoteOperations = (\n value: boolean | GridRemoteOperations | null | undefined,\n): { flags: RemoteFlags; forced: string[] } => {\n if (!value) {\n return { flags: NO_REMOTE, forced: [] };\n }\n\n if (value === true) {\n return { flags: { filtering: true, sorting: true, paging: true, grouping: true, summary: true }, forced: [] };\n }\n\n const forced: string[] = [];\n const flags: RemoteFlags = {\n filtering: !!value.filtering,\n sorting: !!value.sorting,\n paging: !!value.paging,\n grouping: !!value.grouping,\n summary: !!value.summary,\n };\n\n const force = (name: keyof RemoteFlags) => {\n if (!flags[name]) {\n flags[name] = true;\n forced.push(name);\n }\n };\n\n if (flags.paging) {\n force('grouping');\n }\n\n if (flags.paging || flags.grouping) {\n force('filtering');\n force('sorting');\n force('summary');\n } else {\n flags.summary = false;\n }\n\n return { flags, forced };\n};\n\n/** Leitor da chave de linha: `keyExpr` ou, sem ela, o próprio item. */\nexport const keyReader = (keyExpr: GridKeyExpr | null | undefined): (item: unknown) => unknown => {\n if (typeof keyExpr === 'function') {\n return keyExpr as (item: unknown) => unknown;\n }\n\n if (typeof keyExpr === 'string' && keyExpr) {\n if (!keyExpr.includes('.')) {\n return item => item === null || item === undefined ? undefined : (item as Record<string, unknown>)[keyExpr];\n }\n\n return item => getValueByPath(item, keyExpr);\n }\n\n return item => item;\n};\n\n/** Texto da chave para o `key` das linhas renderizadas (`1` e `\"1\"` são chaves diferentes). */\nexport const keyText = (key: unknown): string =>\n typeof key === 'string' ? `s${key}` : typeof key === 'number' ? `n${key}` : `${typeof key}:${String(key)}`;\n\n/** Congela opções em profundidade (arrays e objetos simples). */\nexport const deepFreeze = <T>(value: T): T => {\n if (value && typeof value === 'object' && !Object.isFrozen(value) && !(value instanceof Date)) {\n Object.freeze(value);\n\n for (const entry of Object.values(value)) {\n deepFreeze(entry);\n }\n }\n\n return value;\n};\n"]}
@@ -57,7 +57,7 @@ export interface GridCsvDownloadOptions extends GridCsvOptions {
57
57
  /** An exported column (`GridExportData.columns`). */
58
58
  export interface GridExportColumn<TItem = any> {
59
59
  column: GridColumnDef<TItem>;
60
- /** Header text. */
60
+ /** The column's name as text: `label`, else `path`, else `name`. */
61
61
  label: string;
62
62
  /** Effective data type (declared or inferred). */
63
63
  dataType?: GridColumnDataType;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/export/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n GridColumnAlignment,\n GridColumnDataType,\n GridColumnDef,\n GridGroupPath,\n GridRowFixed,\n GridSummaryValue,\n} from '../grid-column-def.js';\nimport type { DataGrid } from '../grid.js';\n\n/** Options of `getExportData()`, `exportCsv()`, `downloadCsv()` and the xlsx and PDF adapters. */\nexport interface GridExportOptions {\n /**\n * Only the selected rows, in the current order and filter (not in the\n * selection order of `getSelectedItems()`); group counts and summaries are\n * computed over them. Default `false`.\n */\n selectedOnly?: boolean;\n /**\n * Group rows (`rowType: 'group'`) and indentation levels. `false` exports a\n * flat list in the current order with the grouped columns first. Default `true`.\n */\n includeGroups?: boolean;\n /** Group footers and totals (`group-footer` / `total` rows) and summaries in group rows. Default `true`. */\n includeSummaries?: boolean;\n /**\n * Fixed rows (`fixedTopItems` before the body rows, `fixedBottomItems`\n * before the totals; `rowType: 'data'` with `fixed`, `level: 0`).\n * Default `true`; `selectedOnly: true` leaves them out.\n */\n includeFixedRows?: boolean;\n /** Aborts the export: the promise rejects with an `AbortError` (the PDF adapter: with `signal.reason`). */\n signal?: AbortSignal | null;\n}\n\n/** Options of `exportCsv()`. */\nexport interface GridCsvOptions extends GridExportOptions {\n /**\n * Field separator: one character other than `\"`, CR and LF (a `RangeError`\n * otherwise). `auto` (default): `;` when the grid\n * language uses a decimal comma (what Excel expects there), `,` otherwise.\n */\n separator?: 'auto' | (string & {});\n /** UTF-8 byte order mark, so Excel opens the file as UTF-8. Default `true`. */\n bom?: boolean;\n /** First line with the column labels. Default `true`. */\n includeHeaders?: boolean;\n /**\n * Prefixes `'` to text starting with `=`, `+`, `-`, `@`, tab or CR, which a\n * spreadsheet would run as a formula (CSV injection). Numbers are not\n * prefixed. Default `true`.\n */\n escapeFormulas?: boolean;\n /**\n * Cell values instead of the displayed text: numbers with `.`, dates in\n * ISO 8601, booleans `true`/`false`, empty values as empty fields. Group\n * labels and summaries stay text. Default `false`.\n */\n rawValues?: boolean;\n}\n\n/** Options of `downloadCsv()`. */\nexport interface GridCsvDownloadOptions extends GridCsvOptions {\n /** Name of the downloaded file. Default `export.csv`. */\n fileName?: string;\n}\n\n/** An exported column (`GridExportData.columns`). */\nexport interface GridExportColumn<TItem = any> {\n column: GridColumnDef<TItem>;\n /** Header text. */\n label: string;\n /** Effective data type (declared or inferred). */\n dataType?: GridColumnDataType;\n /** Effective logical alignment. */\n alignment: GridColumnAlignment;\n /** Current width in px, when known. */\n width?: number;\n}\n\n/** A data row. `values[i]` / `texts[i]` belong to `columns[i]`. */\nexport interface GridExportDataRow<TItem = any> {\n rowType: 'data';\n /** Indentation level: the number of grouping levels above the row (0 without groups), or the depth of a tree node (0 = root; kept with `includeGroups: false`). */\n level: number;\n item: TItem;\n /** Cell values (`valueGetter` or `path`). */\n values: unknown[];\n /** Displayed texts (`displayValue` / `format`). */\n texts: string[];\n /** `'top'`/`'bottom'` for a fixed row (`fixedTopItems`/`fixedBottomItems`), `null` for a body row. */\n fixed: GridRowFixed;\n}\n\n/**\n * A group row. `summaries[i]` / `texts[i]` are the summaries shown under `columns[i]`\n * (`display: 'column'`); those of the first column, or of a column not exported, are part of `label`.\n */\nexport interface GridExportGroupRow<TItem = any> {\n rowType: 'group';\n /** Grouping level (0 = outermost). */\n level: number;\n groupPath: GridGroupPath;\n /** Grouped column. */\n column: GridColumnDef<TItem>;\n /** Group value. */\n value: unknown;\n /** Formatted group value (`\"Brazil\"`). */\n text: string;\n /** Whole group label with the count and inline summaries (`\"Country: Brazil (3)\"`). */\n label: string;\n /** Rows in the group. */\n itemCount: number;\n summaries: GridSummaryValue<TItem>[][];\n /** Summary texts of each column, joined with the list separator of the language as on screen. */\n texts: string[];\n}\n\n/** A group footer or the totals row. `summaries[i]` / `texts[i]` belong to `columns[i]`. */\nexport interface GridExportSummaryRow<TItem = any> {\n rowType: 'group-footer' | 'total';\n /** Indentation level: a group footer is at the level of its rows; totals at 0. */\n level: number;\n /** Group of the footer; `null` in the totals row. */\n groupPath: GridGroupPath | null;\n summaries: GridSummaryValue<TItem>[][];\n texts: string[];\n}\n\n/** A row of `GridExportData`, told apart by `rowType`. */\nexport type GridExportRow<TItem = any> = GridExportDataRow<TItem> | GridExportGroupRow<TItem> | GridExportSummaryRow<TItem>;\n\n/** What `getExportData()` returns: the columns and rows the user sees, ready for any file format. */\nexport interface GridExportData<TItem = any> {\n /** Visible exportable columns in the current order (with `includeGroups: false`, the grouped columns first). */\n columns: GridExportColumn<TItem>[];\n rows: GridExportRow<TItem>[];\n}\n\n/** Formats offered by the export UI (`exportFormats`). May gain members in minor versions. */\nexport type GridExportFormat = 'csv' | 'xlsx' | 'pdf';\n\n/** Progress of an export (`onProgress`): data rows done, data rows in total, pages so far (PDF). */\nexport interface GridExportProgress {\n readonly rowCount: number;\n readonly totalCount: number;\n readonly pageCount: number;\n}\n\n/**\n * An export run by the grid UI (`xlsxExporter`, `pdfExporter`): build and\n * download the file of what the user sees. Reject to report an error; honor\n * `signal` (aborted when the grid disconnects or the user cancels: reject with\n * an `AbortError`, which the grid reports as canceled, not as an error); call\n * `onProgress` to show the progress in the export button.\n */\nexport type GridExporter = (\n grid: DataGrid,\n options: {\n readonly selectedOnly: boolean;\n readonly signal: AbortSignal;\n readonly onProgress?: (progress: GridExportProgress) => void;\n },\n) => Promise<void>;\n\n/** `detail` of `u-grid-exporting` and `u-grid-export`. */\nexport interface GridExportingEventDetail {\n readonly format: GridExportFormat;\n /** Only the selected rows (\"Export selected rows\"). */\n readonly selectedOnly: boolean;\n}\n\n/** `detail` of `u-grid-export`. */\nexport type GridExportEventDetail = GridExportingEventDetail;\n\n/** `detail` of `u-grid-export-error`. */\nexport interface GridExportErrorEventDetail extends GridExportingEventDetail {\n readonly error: unknown;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/export/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n GridColumnAlignment,\n GridColumnDataType,\n GridColumnDef,\n GridGroupPath,\n GridRowFixed,\n GridSummaryValue,\n} from '../grid-column-def.js';\nimport type { DataGrid } from '../grid.js';\n\n/** Options of `getExportData()`, `exportCsv()`, `downloadCsv()` and the xlsx and PDF adapters. */\nexport interface GridExportOptions {\n /**\n * Only the selected rows, in the current order and filter (not in the\n * selection order of `getSelectedItems()`); group counts and summaries are\n * computed over them. Default `false`.\n */\n selectedOnly?: boolean;\n /**\n * Group rows (`rowType: 'group'`) and indentation levels. `false` exports a\n * flat list in the current order with the grouped columns first. Default `true`.\n */\n includeGroups?: boolean;\n /** Group footers and totals (`group-footer` / `total` rows) and summaries in group rows. Default `true`. */\n includeSummaries?: boolean;\n /**\n * Fixed rows (`fixedTopItems` before the body rows, `fixedBottomItems`\n * before the totals; `rowType: 'data'` with `fixed`, `level: 0`).\n * Default `true`; `selectedOnly: true` leaves them out.\n */\n includeFixedRows?: boolean;\n /** Aborts the export: the promise rejects with an `AbortError` (the PDF adapter: with `signal.reason`). */\n signal?: AbortSignal | null;\n}\n\n/** Options of `exportCsv()`. */\nexport interface GridCsvOptions extends GridExportOptions {\n /**\n * Field separator: one character other than `\"`, CR and LF (a `RangeError`\n * otherwise). `auto` (default): `;` when the grid\n * language uses a decimal comma (what Excel expects there), `,` otherwise.\n */\n separator?: 'auto' | (string & {});\n /** UTF-8 byte order mark, so Excel opens the file as UTF-8. Default `true`. */\n bom?: boolean;\n /** First line with the column labels. Default `true`. */\n includeHeaders?: boolean;\n /**\n * Prefixes `'` to text starting with `=`, `+`, `-`, `@`, tab or CR, which a\n * spreadsheet would run as a formula (CSV injection). Numbers are not\n * prefixed. Default `true`.\n */\n escapeFormulas?: boolean;\n /**\n * Cell values instead of the displayed text: numbers with `.`, dates in\n * ISO 8601, booleans `true`/`false`, empty values as empty fields. Group\n * labels and summaries stay text. Default `false`.\n */\n rawValues?: boolean;\n}\n\n/** Options of `downloadCsv()`. */\nexport interface GridCsvDownloadOptions extends GridCsvOptions {\n /** Name of the downloaded file. Default `export.csv`. */\n fileName?: string;\n}\n\n/** An exported column (`GridExportData.columns`). */\nexport interface GridExportColumn<TItem = any> {\n column: GridColumnDef<TItem>;\n /** The column's name as text: `label`, else `path`, else `name`. */\n label: string;\n /** Effective data type (declared or inferred). */\n dataType?: GridColumnDataType;\n /** Effective logical alignment. */\n alignment: GridColumnAlignment;\n /** Current width in px, when known. */\n width?: number;\n}\n\n/** A data row. `values[i]` / `texts[i]` belong to `columns[i]`. */\nexport interface GridExportDataRow<TItem = any> {\n rowType: 'data';\n /** Indentation level: the number of grouping levels above the row (0 without groups), or the depth of a tree node (0 = root; kept with `includeGroups: false`). */\n level: number;\n item: TItem;\n /** Cell values (`valueGetter` or `path`). */\n values: unknown[];\n /** Displayed texts (`displayValue` / `format`). */\n texts: string[];\n /** `'top'`/`'bottom'` for a fixed row (`fixedTopItems`/`fixedBottomItems`), `null` for a body row. */\n fixed: GridRowFixed;\n}\n\n/**\n * A group row. `summaries[i]` / `texts[i]` are the summaries shown under `columns[i]`\n * (`display: 'column'`); those of the first column, or of a column not exported, are part of `label`.\n */\nexport interface GridExportGroupRow<TItem = any> {\n rowType: 'group';\n /** Grouping level (0 = outermost). */\n level: number;\n groupPath: GridGroupPath;\n /** Grouped column. */\n column: GridColumnDef<TItem>;\n /** Group value. */\n value: unknown;\n /** Formatted group value (`\"Brazil\"`). */\n text: string;\n /** Whole group label with the count and inline summaries (`\"Country: Brazil (3)\"`). */\n label: string;\n /** Rows in the group. */\n itemCount: number;\n summaries: GridSummaryValue<TItem>[][];\n /** Summary texts of each column, joined with the list separator of the language as on screen. */\n texts: string[];\n}\n\n/** A group footer or the totals row. `summaries[i]` / `texts[i]` belong to `columns[i]`. */\nexport interface GridExportSummaryRow<TItem = any> {\n rowType: 'group-footer' | 'total';\n /** Indentation level: a group footer is at the level of its rows; totals at 0. */\n level: number;\n /** Group of the footer; `null` in the totals row. */\n groupPath: GridGroupPath | null;\n summaries: GridSummaryValue<TItem>[][];\n texts: string[];\n}\n\n/** A row of `GridExportData`, told apart by `rowType`. */\nexport type GridExportRow<TItem = any> = GridExportDataRow<TItem> | GridExportGroupRow<TItem> | GridExportSummaryRow<TItem>;\n\n/** What `getExportData()` returns: the columns and rows the user sees, ready for any file format. */\nexport interface GridExportData<TItem = any> {\n /** Visible exportable columns in the current order (with `includeGroups: false`, the grouped columns first). */\n columns: GridExportColumn<TItem>[];\n rows: GridExportRow<TItem>[];\n}\n\n/** Formats offered by the export UI (`exportFormats`). May gain members in minor versions. */\nexport type GridExportFormat = 'csv' | 'xlsx' | 'pdf';\n\n/** Progress of an export (`onProgress`): data rows done, data rows in total, pages so far (PDF). */\nexport interface GridExportProgress {\n readonly rowCount: number;\n readonly totalCount: number;\n readonly pageCount: number;\n}\n\n/**\n * An export run by the grid UI (`xlsxExporter`, `pdfExporter`): build and\n * download the file of what the user sees. Reject to report an error; honor\n * `signal` (aborted when the grid disconnects or the user cancels: reject with\n * an `AbortError`, which the grid reports as canceled, not as an error); call\n * `onProgress` to show the progress in the export button.\n */\nexport type GridExporter = (\n grid: DataGrid,\n options: {\n readonly selectedOnly: boolean;\n readonly signal: AbortSignal;\n readonly onProgress?: (progress: GridExportProgress) => void;\n },\n) => Promise<void>;\n\n/** `detail` of `u-grid-exporting` and `u-grid-export`. */\nexport interface GridExportingEventDetail {\n readonly format: GridExportFormat;\n /** Only the selected rows (\"Export selected rows\"). */\n readonly selectedOnly: boolean;\n}\n\n/** `detail` of `u-grid-export`. */\nexport type GridExportEventDetail = GridExportingEventDetail;\n\n/** `detail` of `u-grid-export-error`. */\nexport interface GridExportErrorEventDetail extends GridExportingEventDetail {\n readonly error: unknown;\n}\n"]}
@@ -56,7 +56,8 @@ export interface GridXlsxDownloadOptions<TWorkbook = ExcelJSWorkbook, TWorksheet
56
56
  * header, group rows with the row outline of Excel, group footers and
57
57
  * totals. Numbers, dates and booleans are typed cells with a number format
58
58
  * close to the column `format`; columns with `displayValue`, a `format`
59
- * function or `booleanDisplay` are written as their displayed text. Text is
59
+ * function, `booleanDisplay` or their own `trueText`/`falseText` are written
60
+ * as their displayed text. Text is
60
61
  * always a text cell (never a formula).
61
62
  */
62
63
  export declare const exportXlsx: <M extends ExcelJSModule>(grid: DataGrid, excelJS: M, options?: GridXlsxOptions<WorkbookOf<M>, WorksheetOf<M>>) => Promise<Blob>;