@toolbox-web/grid 1.23.3 → 1.24.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 (236) hide show
  1. package/README.md +35 -6
  2. package/all.d.ts +2 -2
  3. package/all.d.ts.map +1 -1
  4. package/all.js +2 -2
  5. package/all.js.map +1 -1
  6. package/index.js +1 -1
  7. package/index.js.map +1 -1
  8. package/lib/core/grid.d.ts +28 -0
  9. package/lib/core/grid.d.ts.map +1 -1
  10. package/lib/core/internal/feature-hook.d.ts +8 -0
  11. package/lib/core/internal/feature-hook.d.ts.map +1 -0
  12. package/lib/core/plugin/base-plugin.d.ts +14 -2
  13. package/lib/core/plugin/base-plugin.d.ts.map +1 -1
  14. package/lib/core/plugin/types.d.ts +2 -1
  15. package/lib/core/plugin/types.d.ts.map +1 -1
  16. package/lib/core/types.d.ts +68 -2
  17. package/lib/core/types.d.ts.map +1 -1
  18. package/lib/features/clipboard.d.ts +8 -0
  19. package/lib/features/clipboard.d.ts.map +1 -0
  20. package/lib/features/clipboard.js +2 -0
  21. package/lib/features/clipboard.js.map +1 -0
  22. package/lib/features/column-virtualization.d.ts +8 -0
  23. package/lib/features/column-virtualization.d.ts.map +1 -0
  24. package/lib/features/column-virtualization.js +2 -0
  25. package/lib/features/column-virtualization.js.map +1 -0
  26. package/lib/features/context-menu.d.ts +8 -0
  27. package/lib/features/context-menu.d.ts.map +1 -0
  28. package/lib/features/context-menu.js +2 -0
  29. package/lib/features/context-menu.js.map +1 -0
  30. package/lib/features/editing.d.ts +8 -0
  31. package/lib/features/editing.d.ts.map +1 -0
  32. package/lib/features/editing.js +2 -0
  33. package/lib/features/editing.js.map +1 -0
  34. package/lib/features/export.d.ts +8 -0
  35. package/lib/features/export.d.ts.map +1 -0
  36. package/lib/features/export.js +2 -0
  37. package/lib/features/export.js.map +1 -0
  38. package/lib/features/filtering.d.ts +8 -0
  39. package/lib/features/filtering.d.ts.map +1 -0
  40. package/lib/features/filtering.js +2 -0
  41. package/lib/features/filtering.js.map +1 -0
  42. package/lib/features/grouping-columns.d.ts +8 -0
  43. package/lib/features/grouping-columns.d.ts.map +1 -0
  44. package/lib/features/grouping-columns.js +2 -0
  45. package/lib/features/grouping-columns.js.map +1 -0
  46. package/lib/features/grouping-rows.d.ts +8 -0
  47. package/lib/features/grouping-rows.d.ts.map +1 -0
  48. package/lib/features/grouping-rows.js +2 -0
  49. package/lib/features/grouping-rows.js.map +1 -0
  50. package/lib/features/magic-string.es-CkyDP9Ir.mjs.map +1 -0
  51. package/lib/features/master-detail.d.ts +8 -0
  52. package/lib/features/master-detail.d.ts.map +1 -0
  53. package/lib/features/master-detail.js +2 -0
  54. package/lib/features/master-detail.js.map +1 -0
  55. package/lib/features/multi-sort.d.ts +10 -0
  56. package/lib/features/multi-sort.d.ts.map +1 -0
  57. package/lib/features/multi-sort.js +2 -0
  58. package/lib/features/multi-sort.js.map +1 -0
  59. package/lib/features/pinned-columns.d.ts +18 -0
  60. package/lib/features/pinned-columns.d.ts.map +1 -0
  61. package/lib/features/pinned-columns.js +2 -0
  62. package/lib/features/pinned-columns.js.map +1 -0
  63. package/lib/features/pinned-rows.d.ts +8 -0
  64. package/lib/features/pinned-rows.d.ts.map +1 -0
  65. package/lib/features/pinned-rows.js +2 -0
  66. package/lib/features/pinned-rows.js.map +1 -0
  67. package/lib/features/pivot.d.ts +8 -0
  68. package/lib/features/pivot.d.ts.map +1 -0
  69. package/lib/features/pivot.js +2 -0
  70. package/lib/features/pivot.js.map +1 -0
  71. package/lib/features/print.d.ts +8 -0
  72. package/lib/features/print.d.ts.map +1 -0
  73. package/lib/features/print.js +2 -0
  74. package/lib/features/print.js.map +1 -0
  75. package/lib/features/registry.d.ts +50 -0
  76. package/lib/features/registry.d.ts.map +1 -0
  77. package/lib/features/registry.js +2 -0
  78. package/lib/features/registry.js.map +1 -0
  79. package/lib/features/registry.spec.js +5 -0
  80. package/lib/features/registry.spec.js.map +1 -0
  81. package/lib/features/reorder-columns.d.ts +10 -0
  82. package/lib/features/reorder-columns.d.ts.map +1 -0
  83. package/lib/features/reorder-columns.js +2 -0
  84. package/lib/features/reorder-columns.js.map +1 -0
  85. package/lib/features/reorder-rows.d.ts +10 -0
  86. package/lib/features/reorder-rows.d.ts.map +1 -0
  87. package/lib/features/reorder-rows.js +2 -0
  88. package/lib/features/reorder-rows.js.map +1 -0
  89. package/lib/features/responsive.d.ts +8 -0
  90. package/lib/features/responsive.d.ts.map +1 -0
  91. package/lib/features/responsive.js +2 -0
  92. package/lib/features/responsive.js.map +1 -0
  93. package/lib/features/selection.d.ts +8 -0
  94. package/lib/features/selection.d.ts.map +1 -0
  95. package/lib/features/selection.js +2 -0
  96. package/lib/features/selection.js.map +1 -0
  97. package/lib/features/server-side.d.ts +8 -0
  98. package/lib/features/server-side.d.ts.map +1 -0
  99. package/lib/features/server-side.js +2 -0
  100. package/lib/features/server-side.js.map +1 -0
  101. package/lib/features/tree.d.ts +8 -0
  102. package/lib/features/tree.d.ts.map +1 -0
  103. package/lib/features/tree.js +2 -0
  104. package/lib/features/tree.js.map +1 -0
  105. package/lib/features/undo-redo.d.ts +8 -0
  106. package/lib/features/undo-redo.d.ts.map +1 -0
  107. package/lib/features/undo-redo.js +2 -0
  108. package/lib/features/undo-redo.js.map +1 -0
  109. package/lib/features/visibility.d.ts +8 -0
  110. package/lib/features/visibility.d.ts.map +1 -0
  111. package/lib/features/visibility.js +2 -0
  112. package/lib/features/visibility.js.map +1 -0
  113. package/lib/plugins/clipboard/ClipboardPlugin.d.ts +3 -3
  114. package/lib/plugins/clipboard/index.js +1 -1
  115. package/lib/plugins/clipboard/index.js.map +1 -1
  116. package/lib/plugins/clipboard/types.d.ts +1 -1
  117. package/lib/plugins/column-virtualization/index.js +1 -1
  118. package/lib/plugins/column-virtualization/index.js.map +1 -1
  119. package/lib/plugins/column-virtualization/types.d.ts +24 -2
  120. package/lib/plugins/column-virtualization/types.d.ts.map +1 -1
  121. package/lib/plugins/context-menu/index.js +1 -1
  122. package/lib/plugins/context-menu/index.js.map +1 -1
  123. package/lib/plugins/editing/index.js +1 -1
  124. package/lib/plugins/editing/index.js.map +1 -1
  125. package/lib/plugins/editing/types.d.ts +1 -1
  126. package/lib/plugins/export/ExportPlugin.d.ts +1 -1
  127. package/lib/plugins/export/index.js +1 -1
  128. package/lib/plugins/export/index.js.map +1 -1
  129. package/lib/plugins/export/types.d.ts +9 -1
  130. package/lib/plugins/export/types.d.ts.map +1 -1
  131. package/lib/plugins/filtering/index.js +1 -1
  132. package/lib/plugins/filtering/index.js.map +1 -1
  133. package/lib/plugins/filtering/types.d.ts +586 -29
  134. package/lib/plugins/filtering/types.d.ts.map +1 -1
  135. package/lib/plugins/grouping-columns/index.d.ts +1 -1
  136. package/lib/plugins/grouping-columns/index.js +1 -1
  137. package/lib/plugins/grouping-columns/index.js.map +1 -1
  138. package/lib/plugins/grouping-rows/index.d.ts +2 -2
  139. package/lib/plugins/grouping-rows/index.d.ts.map +1 -1
  140. package/lib/plugins/grouping-rows/index.js +1 -1
  141. package/lib/plugins/grouping-rows/index.js.map +1 -1
  142. package/lib/plugins/grouping-rows/types.d.ts +48 -3
  143. package/lib/plugins/grouping-rows/types.d.ts.map +1 -1
  144. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +2 -2
  145. package/lib/plugins/master-detail/index.js +1 -1
  146. package/lib/plugins/master-detail/index.js.map +1 -1
  147. package/lib/plugins/multi-sort/index.js +1 -1
  148. package/lib/plugins/multi-sort/index.js.map +1 -1
  149. package/lib/plugins/multi-sort/types.d.ts +40 -6
  150. package/lib/plugins/multi-sort/types.d.ts.map +1 -1
  151. package/lib/plugins/pinned-columns/index.js +1 -1
  152. package/lib/plugins/pinned-columns/index.js.map +1 -1
  153. package/lib/plugins/pinned-columns/types.d.ts +3 -3
  154. package/lib/plugins/pinned-rows/index.js +1 -1
  155. package/lib/plugins/pinned-rows/index.js.map +1 -1
  156. package/lib/plugins/pinned-rows/types.d.ts +42 -4
  157. package/lib/plugins/pinned-rows/types.d.ts.map +1 -1
  158. package/lib/plugins/pivot/index.js +1 -1
  159. package/lib/plugins/pivot/index.js.map +1 -1
  160. package/lib/plugins/pivot/types.d.ts +66 -1
  161. package/lib/plugins/pivot/types.d.ts.map +1 -1
  162. package/lib/plugins/print/PrintPlugin.d.ts +1 -1
  163. package/lib/plugins/print/index.js +1 -1
  164. package/lib/plugins/print/index.js.map +1 -1
  165. package/lib/plugins/print/types.d.ts +9 -1
  166. package/lib/plugins/print/types.d.ts.map +1 -1
  167. package/lib/plugins/{reorder → reorder-columns}/ReorderPlugin.d.ts +5 -3
  168. package/lib/plugins/reorder-columns/ReorderPlugin.d.ts.map +1 -0
  169. package/lib/plugins/reorder-columns/column-drag.d.ts.map +1 -0
  170. package/lib/plugins/{reorder → reorder-columns}/index.d.ts +2 -2
  171. package/lib/plugins/reorder-columns/index.d.ts.map +1 -0
  172. package/lib/plugins/reorder-columns/index.js +2 -0
  173. package/lib/plugins/reorder-columns/index.js.map +1 -0
  174. package/lib/plugins/{reorder → reorder-columns}/types.d.ts +17 -1
  175. package/lib/plugins/reorder-columns/types.d.ts.map +1 -0
  176. package/lib/plugins/{row-reorder → reorder-rows}/RowReorderPlugin.d.ts +5 -3
  177. package/lib/plugins/reorder-rows/RowReorderPlugin.d.ts.map +1 -0
  178. package/lib/plugins/{row-reorder → reorder-rows}/index.d.ts +2 -2
  179. package/lib/plugins/reorder-rows/index.d.ts.map +1 -0
  180. package/lib/plugins/reorder-rows/index.js +2 -0
  181. package/lib/plugins/reorder-rows/index.js.map +1 -0
  182. package/lib/plugins/{row-reorder → reorder-rows}/types.d.ts +5 -0
  183. package/lib/plugins/reorder-rows/types.d.ts.map +1 -0
  184. package/lib/plugins/responsive/ResponsivePlugin.d.ts +2 -2
  185. package/lib/plugins/responsive/index.js +1 -1
  186. package/lib/plugins/responsive/index.js.map +1 -1
  187. package/lib/plugins/selection/SelectionPlugin.d.ts +5 -5
  188. package/lib/plugins/selection/index.js +1 -1
  189. package/lib/plugins/selection/index.js.map +1 -1
  190. package/lib/plugins/server-side/index.js +1 -1
  191. package/lib/plugins/server-side/index.js.map +1 -1
  192. package/lib/plugins/server-side/types.d.ts +82 -0
  193. package/lib/plugins/server-side/types.d.ts.map +1 -1
  194. package/lib/plugins/tree/index.js +1 -1
  195. package/lib/plugins/tree/index.js.map +1 -1
  196. package/lib/plugins/undo-redo/index.js +1 -1
  197. package/lib/plugins/undo-redo/index.js.map +1 -1
  198. package/lib/plugins/visibility/VisibilityPlugin.d.ts +2 -2
  199. package/lib/plugins/visibility/index.js +1 -1
  200. package/lib/plugins/visibility/index.js.map +1 -1
  201. package/lib/plugins/visibility/types.d.ts +16 -2
  202. package/lib/plugins/visibility/types.d.ts.map +1 -1
  203. package/package.json +17 -2
  204. package/public.d.ts +9 -2
  205. package/public.d.ts.map +1 -1
  206. package/umd/grid.all.umd.js +1 -1
  207. package/umd/grid.all.umd.js.map +1 -1
  208. package/umd/grid.umd.js +1 -1
  209. package/umd/grid.umd.js.map +1 -1
  210. package/umd/plugins/clipboard.umd.js.map +1 -1
  211. package/umd/plugins/export.umd.js.map +1 -1
  212. package/umd/plugins/master-detail.umd.js.map +1 -1
  213. package/umd/plugins/print.umd.js.map +1 -1
  214. package/umd/plugins/reorder-columns.umd.js +2 -0
  215. package/umd/plugins/reorder-columns.umd.js.map +1 -0
  216. package/umd/plugins/reorder-rows.umd.js +2 -0
  217. package/umd/plugins/reorder-rows.umd.js.map +1 -0
  218. package/umd/plugins/responsive.umd.js.map +1 -1
  219. package/umd/plugins/selection.umd.js.map +1 -1
  220. package/umd/plugins/visibility.umd.js.map +1 -1
  221. package/lib/plugins/reorder/ReorderPlugin.d.ts.map +0 -1
  222. package/lib/plugins/reorder/column-drag.d.ts.map +0 -1
  223. package/lib/plugins/reorder/index.d.ts.map +0 -1
  224. package/lib/plugins/reorder/index.js +0 -2
  225. package/lib/plugins/reorder/index.js.map +0 -1
  226. package/lib/plugins/reorder/types.d.ts.map +0 -1
  227. package/lib/plugins/row-reorder/RowReorderPlugin.d.ts.map +0 -1
  228. package/lib/plugins/row-reorder/index.d.ts.map +0 -1
  229. package/lib/plugins/row-reorder/index.js +0 -2
  230. package/lib/plugins/row-reorder/index.js.map +0 -1
  231. package/lib/plugins/row-reorder/types.d.ts.map +0 -1
  232. package/umd/plugins/reorder.umd.js +0 -2
  233. package/umd/plugins/reorder.umd.js.map +0 -1
  234. package/umd/plugins/row-reorder.umd.js +0 -2
  235. package/umd/plugins/row-reorder.umd.js.map +0 -1
  236. /package/lib/plugins/{reorder → reorder-columns}/column-drag.d.ts +0 -0
@@ -1,12 +1,57 @@
1
1
  import { ExpandCollapseAnimation } from '../../core/types';
2
2
  export type { ExpandCollapseAnimation } from '../../core/types';
3
- /** Available aggregation function types */
3
+ /**
4
+ * Built-in aggregation functions for pivot value fields.
5
+ *
6
+ * Each function is applied per-cell to aggregate the matching data rows into a single value:
7
+ *
8
+ * | Function | Result | Blank handling |
9
+ * |----------|--------|----------------|
10
+ * | `'sum'` | Numeric total of all values | Non-numeric values ignored |
11
+ * | `'avg'` | Arithmetic mean | Non-numeric values excluded from count |
12
+ * | `'count'` | Number of rows in the group | Counts all rows including blanks |
13
+ * | `'min'` | Smallest numeric value | Non-numeric values ignored |
14
+ * | `'max'` | Largest numeric value | Non-numeric values ignored |
15
+ * | `'first'` | Value from the first row in the group | May be `undefined` if group is empty |
16
+ * | `'last'` | Value from the last row in the group | May be `undefined` if group is empty |
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const valueFields: PivotValueField[] = [
21
+ * { field: 'revenue', aggFunc: 'sum', header: 'Total Revenue' },
22
+ * { field: 'revenue', aggFunc: 'avg', header: 'Avg Revenue' },
23
+ * { field: 'orders', aggFunc: 'count', header: '# Orders' },
24
+ * ];
25
+ * ```
26
+ */
4
27
  export type AggFunc = 'sum' | 'avg' | 'count' | 'min' | 'max' | 'first' | 'last';
28
+ /**
29
+ * Configuration for the pivot plugin.
30
+ *
31
+ * Pivot mode transforms flat row data into a cross-tabulation (pivot table)
32
+ * by grouping rows along one axis (`rowGroupFields`), spreading unique values
33
+ * of another field across columns (`columnGroupFields`), and computing
34
+ * aggregate values (`valueFields`) at each intersection.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * new PivotPlugin({
39
+ * rowGroupFields: ['department'],
40
+ * columnGroupFields: ['quarter'],
41
+ * valueFields: [{ field: 'revenue', aggFunc: 'sum' }],
42
+ * showTotals: true,
43
+ * showGrandTotal: true,
44
+ * })
45
+ * ```
46
+ */
5
47
  export interface PivotConfig {
6
48
  /** Whether pivot view is active on load (default: true when fields are configured) */
7
49
  active?: boolean;
50
+ /** Fields to group rows by (vertical axis). Multiple fields create nested groups. */
8
51
  rowGroupFields?: string[];
52
+ /** Fields whose unique values become column headers (horizontal axis). */
9
53
  columnGroupFields?: string[];
54
+ /** Value fields to aggregate at each row/column intersection. */
10
55
  valueFields?: PivotValueField[];
11
56
  showTotals?: boolean;
12
57
  showGrandTotal?: boolean;
@@ -25,9 +70,19 @@ export interface PivotConfig {
25
70
  */
26
71
  animation?: ExpandCollapseAnimation;
27
72
  }
73
+ /**
74
+ * Defines a value field in the pivot table — which data field to aggregate
75
+ * and how to compute the aggregation.
76
+ *
77
+ * Multiple `PivotValueField` entries on the same `field` with different `aggFunc`
78
+ * values create separate columns (e.g. "Revenue (Sum)" and "Revenue (Avg)").
79
+ */
28
80
  export interface PivotValueField {
81
+ /** The row data field to aggregate (must exist on the source row objects). */
29
82
  field: string;
83
+ /** Aggregation function to apply (see {@link AggFunc} for options). */
30
84
  aggFunc: AggFunc;
85
+ /** Custom column header label. Defaults to `"field (aggFunc)"` if omitted. */
31
86
  header?: string;
32
87
  }
33
88
  export interface PivotState {
@@ -35,10 +90,20 @@ export interface PivotState {
35
90
  pivotResult: PivotResult | null;
36
91
  expandedKeys: Set<string>;
37
92
  }
93
+ /**
94
+ * Computed result of the pivot transformation.
95
+ *
96
+ * Produced internally by the pivot engine after processing source rows
97
+ * through the configured `rowGroupFields`, `columnGroupFields`, and `valueFields`.
98
+ */
38
99
  export interface PivotResult {
100
+ /** Hierarchical pivot rows (group headers + leaf rows). */
39
101
  rows: PivotRow[];
102
+ /** Unique column keys derived from `columnGroupFields` values. */
40
103
  columnKeys: string[];
104
+ /** Per-column totals (keyed by column key). Present when `showTotals` is enabled. */
41
105
  totals: Record<string, number>;
106
+ /** Grand total across all columns. Present when `showGrandTotal` is enabled. */
42
107
  grandTotal: number;
43
108
  }
44
109
  export interface PivotRow {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/pivot/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAChE,YAAY,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAEhE,2CAA2C;AAC3C,MAAM,MAAM,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAEjF,MAAM,WAAW,WAAW;IAC1B,sFAAsF;IACtF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,WAAW,CAAC,EAAE,eAAe,EAAE,CAAC;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,6DAA6D;IAC7D,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,2DAA2D;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,uBAAuB,CAAC;CACrC;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC3B;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IACtC,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,OAAO,EAAE,OAAO,CAAC;IACjB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IACtB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAGD,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,aAAa;QACrB,KAAK,EAAE,OAAO,eAAe,EAAE,WAAW,CAAC;KAC5C;CACF"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/pivot/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAChE,YAAY,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAEjF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,WAAW;IAC1B,sFAAsF;IACtF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,qFAAqF;IACrF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,0EAA0E;IAC1E,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,iEAAiE;IACjE,WAAW,CAAC,EAAE,eAAe,EAAE,CAAC;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,6DAA6D;IAC7D,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,2DAA2D;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,uBAAuB,CAAC;CACrC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,OAAO,EAAE,OAAO,CAAC;IACjB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,2DAA2D;IAC3D,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,kEAAkE;IAClE,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,qFAAqF;IACrF,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,gFAAgF;IAChF,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IACtC,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,OAAO,EAAE,OAAO,CAAC;IACjB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IACtB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAGD,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,aAAa;QACrB,KAAK,EAAE,OAAO,eAAe,EAAE,WAAW,CAAC;KAC5C;CACF"}
@@ -49,7 +49,7 @@ import { PrintConfig, PrintParams } from './types';
49
49
  * };
50
50
  *
51
51
  * // Trigger print
52
- * const printPlugin = grid.getPlugin(PrintPlugin);
52
+ * const printPlugin = grid.getPluginByName('print');
53
53
  * await printPlugin.print();
54
54
  * ```
55
55
  *
@@ -1,2 +1,2 @@
1
- const t="tbw-print-isolation-style";async function i(i,e={}){const{orientation:n="landscape"}=e,r=i.id;document.querySelectorAll(`#${CSS.escape(r)}`).length>1&&console.warn(`[tbw-grid:print] Multiple elements found with id="${r}". Print isolation may not work correctly. Ensure each grid has a unique ID.`),document.getElementById(t)?.remove();const o=function(i,e){const n=document.createElement("style");return n.id=t,n.textContent=`\n /* Print isolation: hide everything except the target grid */\n @media print {\n /* Hide all body children by default */\n body > *:not(#${i}) {\n display: none !important;\n }\n\n /* But show the grid and ensure it's not hidden by ancestor rules */\n #${i} {\n display: block !important;\n position: static !important;\n visibility: visible !important;\n opacity: 1 !important;\n overflow: visible !important;\n height: auto !important;\n width: 100% !important;\n max-height: none !important;\n margin: 0 !important;\n padding: 0 !important;\n transform: none !important;\n }\n\n /* If grid is nested, we need to show its ancestors too */\n #${i},\n #${i} * {\n visibility: visible !important;\n }\n\n /* Walk up the DOM and show all ancestors of the grid */\n body *:has(> #${i}),\n body *:has(#${i}) {\n display: block !important;\n visibility: visible !important;\n opacity: 1 !important;\n overflow: visible !important;\n height: auto !important;\n position: static !important;\n transform: none !important;\n background: transparent !important;\n border: none !important;\n padding: 0 !important;\n margin: 0 !important;\n }\n\n /* Hide siblings of ancestors (everything that's not in the path to the grid) */\n body *:has(#${i}) > *:not(:has(#${i})):not(#${i}) {\n display: none !important;\n }\n\n /* Page settings */\n @page {\n size: ${e};\n margin: 1cm;\n }\n\n /* Ensure proper print styling */\n body {\n margin: 0 !important;\n padding: 0 !important;\n background: white !important;\n color-scheme: light !important;\n }\n }\n\n /* Screen: also apply isolation for print preview */\n @media screen {\n /* When this stylesheet is active, we're about to print */\n /* No screen-specific rules needed - isolation only applies to print */\n }\n `,n}(r,n);return document.head.appendChild(o),new Promise(i=>{const e=()=>{window.removeEventListener("afterprint",e),document.getElementById(t)?.remove(),i()};window.addEventListener("afterprint",e),window.print(),setTimeout(()=>{window.removeEventListener("afterprint",e),document.getElementById(t)?.remove(),i()},5e3)})}const e='<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>',n={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:e,filterActive:e,print:"🖨️"};class r{static dependencies;static manifest;version="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#t;get defaultConfig(){return{}}constructor(t={}){this.userConfig=t}attach(t){this.#t?.abort(),this.#t=new AbortController,this.grid=t,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#t?.abort(),this.#t=void 0}getPlugin(t){return this.grid?.getPlugin(t)}emit(t,i){this.grid?.dispatchEvent?.(new CustomEvent(t,{detail:i,bubbles:!0}))}emitCancelable(t,i){const e=new CustomEvent(t,{detail:i,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(e),e.defaultPrevented}on(t,i){this.grid?._pluginManager?.subscribe(this,t,i)}off(t){this.grid?._pluginManager?.unsubscribe(this,t)}emitPluginEvent(t,i){this.grid?._pluginManager?.emitPluginEvent(t,i)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid}get disconnectSignal(){return this.#t?.signal??this.grid?.disconnectSignal}get gridIcons(){const t=this.grid?.gridConfig?.icons??{};return{...n,...t}}get isAnimationEnabled(){const t=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===t||"off"===t)return!1;if(!0===t||"on"===t)return!0;const i=this.gridElement;if(i){return"0"!==getComputedStyle(i).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const t=this.gridElement;if(t){const i=getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(),e=parseInt(i,10);if(!isNaN(e))return e}return 200}resolveIcon(t,i){return void 0!==i?i:this.gridIcons[t]}setIcon(t,i){"string"==typeof i?t.innerHTML=i:i instanceof HTMLElement&&(t.innerHTML="",t.appendChild(i.cloneNode(!0)))}warn(t){console.warn(`[tbw-grid:${this.name}] ${t}`)}}const o={button:!1,orientation:"landscape",warnThreshold:500,maxRows:0,includeTitle:!0,includeTimestamp:!0,title:"",isolate:!1};class s extends r{name="print";version="1.0.0";styles=".tbw-print-header,.tbw-print-footer{display:none}@media print{tbw-grid{overflow:visible!important;height:auto!important;border:none!important;border-radius:0!important;color-scheme:light only;-webkit-print-color-adjust:exact;print-color-adjust:exact}tbw-grid .tbw-grid-content{overflow:visible!important;height:auto!important;max-height:none!important}tbw-grid .tbw-scroll-area{overflow:visible!important;height:auto!important;max-height:none!important}tbw-grid .rows-body{overflow:visible!important;height:auto!important;max-height:none!important}tbw-grid .rows-container,tbw-grid .rows-viewport,tbw-grid .rows{overflow:visible!important;height:auto!important;max-height:none!important;transform:none!important}tbw-grid .rows-viewport .rows{position:static!important}tbw-grid .resize-handle,tbw-grid [part=sort-indicator],tbw-grid .tbw-filter-btn,tbw-grid .tool-panel,tbw-grid .tool-panel-content,tbw-grid .tbw-shell-header,tbw-grid .shell-toolbar,tbw-grid .tool-panel-toggle,tbw-grid [data-print-hide],tbw-grid .expander-cell,tbw-grid .tree-toggle,tbw-grid .context-menu,tbw-grid .faux-vscroll{display:none!important}tbw-grid .tbw-print-header{display:flex;justify-content:space-between;align-items:baseline;padding:var(--tbw-spacing-md, .5em) 0;margin-bottom:var(--tbw-spacing-md, .5em);border-bottom:2px solid var(--tbw-print-border, var(--tbw-color-border-strong));font-family:inherit}.tbw-print-header-title{font-size:1.25em;font-weight:700}.tbw-print-header-timestamp{font-size:var(--tbw-font-size-sm, .875em);color:var(--tbw-print-muted, var(--tbw-color-fg-muted))}tbw-grid .tbw-print-footer{display:block;margin-top:var(--tbw-spacing-md, .5em);padding-top:var(--tbw-spacing-md, .5em);border-top:1px solid var(--tbw-print-border, var(--tbw-color-border));font-size:var(--tbw-font-size-xs, .75em);color:var(--tbw-print-muted, var(--tbw-color-fg-muted));text-align:end}tbw-grid .data-grid-row{break-inside:avoid;page-break-inside:avoid}tbw-grid .cell{border:1px solid var(--tbw-print-cell-border, var(--tbw-color-border))!important}tbw-grid .header-row,tbw-grid .data-grid-row{padding-inline-end:1px}tbw-grid .data-grid-row:hover,tbw-grid .cell:hover{background:inherit!important}@page{margin:1cm}@page{tbw-grid.print-landscape{size:landscape}}@page{tbw-grid.print-portrait{size:portrait}}}";#i=!1;#e=null;#n=null;#r=null;#o=null;#s=null;#a=null;get#d(){return this.grid}isPrinting(){return this.#i}async print(t){if(this.#i)return void console.warn("[PrintPlugin] Print already in progress");const i=this.gridElement;if(!i)return void console.warn("[PrintPlugin] Grid not available");const e={...o,...this.config,...t},n=this.rows.length;let r=n,s=!1;if(e.warnThreshold>0&&n>e.warnThreshold){const t=e.maxRows>0?`\n\nNote: Output will be limited to ${e.maxRows.toLocaleString()} rows.`:"";if(!confirm(`This grid has ${n.toLocaleString()} rows. Printing large datasets may cause performance issues or browser slowdowns.${t}\n\nClick OK to continue, or Cancel to abort.`))return}e.maxRows>0&&n>e.maxRows&&(r=e.maxRows,s=!0),this.#i=!0;const a=performance.now();this.emit("print-start",{rowCount:r,limitApplied:s,originalRowCount:n});try{const t=this.#d;this.#n={bypassThreshold:t._virtualization?.bypassThreshold??24},this.#l(),s&&(this.#r=this.sourceRows,this.grid.rows=this.sourceRows.slice(0,r),await new Promise(t=>setTimeout(t,50))),(e.includeTitle||e.includeTimestamp)&&this.#p(e),await this.#h(),await new Promise(t=>requestAnimationFrame(t)),await new Promise(t=>requestAnimationFrame(t)),i.classList.add(`print-${e.orientation}`),await new Promise(t=>requestAnimationFrame(t)),await new Promise(t=>requestAnimationFrame(t)),e.isolate?await this.#m(e):await this.#c(),this.emit("print-complete",{success:!0,rowCount:r,duration:Math.round(performance.now()-a)})}catch(d){console.error("[PrintPlugin] Print failed:",d),this.emit("print-complete",{success:!1,rowCount:0,duration:Math.round(performance.now()-a)})}finally{this.#g(),this.#i=!1}}#p(t){const i=this.gridElement;if(i){if(this.#o=document.createElement("div"),this.#o.className="tbw-print-header",t.includeTitle){const i=t.title||this.grid.effectiveConfig?.shell?.header?.title||"Grid Data",e=document.createElement("div");e.className="tbw-print-header-title",e.textContent=i,this.#o.appendChild(e)}if(t.includeTimestamp){const t=document.createElement("div");t.className="tbw-print-header-timestamp",t.textContent=`Printed: ${/* @__PURE__ */(new Date).toLocaleString()}`,this.#o.appendChild(t)}i.insertBefore(this.#o,i.firstChild),this.#s=document.createElement("div"),this.#s.className="tbw-print-footer",this.#s.textContent=`Page generated from ${window.location.hostname}`,i.appendChild(this.#s)}}async#h(){const t=this.#d;if(!t._virtualization)return;const i=this.rows.length;t._virtualization.bypassThreshold=i+100,t.refreshVirtualWindow(!0),await new Promise(t=>setTimeout(t,100))}async#c(){return new Promise(t=>{const i=()=>{window.removeEventListener("afterprint",i),t()};window.addEventListener("afterprint",i),window.print(),setTimeout(()=>{"undefined"!=typeof window&&window.removeEventListener("afterprint",i),t()},1e3)})}async#m(t){const e=this.gridElement;e&&await i(e,{orientation:t.orientation})}#l(){const t=this.columns;if(t){this.#e=/* @__PURE__ */new Map;for(const i of t)i.printHidden&&i.field&&(this.#e.set(i.field,!i.hidden),this.grid.setColumnVisible(i.field,!1))}}#u(){if(this.#e){for(const[t,i]of this.#e)this.grid.setColumnVisible(t,i);this.#e=null}}#g(){const t=this.gridElement;if(!t)return;this.#u(),t.classList.remove("print-portrait","print-landscape"),null!==this.#a&&(t.style.transform="",t.style.transformOrigin="",t.style.width="",this.#a=null),this.#o&&(this.#o.remove(),this.#o=null),this.#s&&(this.#s.remove(),this.#s=null);const i=this.#d;this.#n&&i._virtualization&&(i._virtualization.bypassThreshold=this.#n.bypassThreshold,i.refreshVirtualWindow(!0),this.#n=null),null!==this.#r&&(this.grid.rows=this.#r,this.#r=null)}afterRender(){this.config?.button&&!this.#w&&(this.#b(),this.#w=!0)}#w=!1;#b(){const t=this.#d;t.registerToolbarContent?.({id:"print-button",order:900,render:t=>{const i=document.createElement("button");i.className="tbw-toolbar-btn tbw-print-btn",i.title="Print grid",i.type="button";const e=this.resolveIcon("print")||"🖨️";this.setIcon(i,e),i.addEventListener("click",()=>{this.print()},{signal:this.disconnectSignal}),t.appendChild(i)}})}}export{s as PrintPlugin,i as printGridIsolated};
1
+ const t="tbw-print-isolation-style";async function i(i,e={}){const{orientation:n="landscape"}=e,r=i.id;document.querySelectorAll(`#${CSS.escape(r)}`).length>1&&console.warn(`[tbw-grid:print] Multiple elements found with id="${r}". Print isolation may not work correctly. Ensure each grid has a unique ID.`),document.getElementById(t)?.remove();const o=function(i,e){const n=document.createElement("style");return n.id=t,n.textContent=`\n /* Print isolation: hide everything except the target grid */\n @media print {\n /* Hide all body children by default */\n body > *:not(#${i}) {\n display: none !important;\n }\n\n /* But show the grid and ensure it's not hidden by ancestor rules */\n #${i} {\n display: block !important;\n position: static !important;\n visibility: visible !important;\n opacity: 1 !important;\n overflow: visible !important;\n height: auto !important;\n width: 100% !important;\n max-height: none !important;\n margin: 0 !important;\n padding: 0 !important;\n transform: none !important;\n }\n\n /* If grid is nested, we need to show its ancestors too */\n #${i},\n #${i} * {\n visibility: visible !important;\n }\n\n /* Walk up the DOM and show all ancestors of the grid */\n body *:has(> #${i}),\n body *:has(#${i}) {\n display: block !important;\n visibility: visible !important;\n opacity: 1 !important;\n overflow: visible !important;\n height: auto !important;\n position: static !important;\n transform: none !important;\n background: transparent !important;\n border: none !important;\n padding: 0 !important;\n margin: 0 !important;\n }\n\n /* Hide siblings of ancestors (everything that's not in the path to the grid) */\n body *:has(#${i}) > *:not(:has(#${i})):not(#${i}) {\n display: none !important;\n }\n\n /* Page settings */\n @page {\n size: ${e};\n margin: 1cm;\n }\n\n /* Ensure proper print styling */\n body {\n margin: 0 !important;\n padding: 0 !important;\n background: white !important;\n color-scheme: light !important;\n }\n }\n\n /* Screen: also apply isolation for print preview */\n @media screen {\n /* When this stylesheet is active, we're about to print */\n /* No screen-specific rules needed - isolation only applies to print */\n }\n `,n}(r,n);return document.head.appendChild(o),new Promise(i=>{const e=()=>{window.removeEventListener("afterprint",e),document.getElementById(t)?.remove(),i()};window.addEventListener("afterprint",e),window.print(),setTimeout(()=>{window.removeEventListener("afterprint",e),document.getElementById(t)?.remove(),i()},5e3)})}const e='<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>',n={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:e,filterActive:e,print:"🖨️"};class r{static dependencies;static manifest;aliases;version="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#t;get defaultConfig(){return{}}constructor(t={}){this.userConfig=t}attach(t){this.#t?.abort(),this.#t=new AbortController,this.grid=t,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#t?.abort(),this.#t=void 0}getPlugin(t){return this.grid?.getPlugin(t)}emit(t,i){this.grid?.dispatchEvent?.(new CustomEvent(t,{detail:i,bubbles:!0}))}emitCancelable(t,i){const e=new CustomEvent(t,{detail:i,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(e),e.defaultPrevented}on(t,i){this.grid?._pluginManager?.subscribe(this,t,i)}off(t){this.grid?._pluginManager?.unsubscribe(this,t)}emitPluginEvent(t,i){this.grid?._pluginManager?.emitPluginEvent(t,i)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid}get disconnectSignal(){return this.#t?.signal??this.grid?.disconnectSignal}get gridIcons(){const t=this.grid?.gridConfig?.icons??{};return{...n,...t}}get isAnimationEnabled(){const t=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===t||"off"===t)return!1;if(!0===t||"on"===t)return!0;const i=this.gridElement;if(i){return"0"!==getComputedStyle(i).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const t=this.gridElement;if(t){const i=getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(),e=parseInt(i,10);if(!isNaN(e))return e}return 200}resolveIcon(t,i){return void 0!==i?i:this.gridIcons[t]}setIcon(t,i){"string"==typeof i?t.innerHTML=i:i instanceof HTMLElement&&(t.innerHTML="",t.appendChild(i.cloneNode(!0)))}warn(t){console.warn(`[tbw-grid:${this.name}] ${t}`)}}const o={button:!1,orientation:"landscape",warnThreshold:500,maxRows:0,includeTitle:!0,includeTimestamp:!0,title:"",isolate:!1};class s extends r{name="print";version="1.0.0";styles=".tbw-print-header,.tbw-print-footer{display:none}@media print{tbw-grid{overflow:visible!important;height:auto!important;border:none!important;border-radius:0!important;color-scheme:light only;-webkit-print-color-adjust:exact;print-color-adjust:exact}tbw-grid .tbw-grid-content{overflow:visible!important;height:auto!important;max-height:none!important}tbw-grid .tbw-scroll-area{overflow:visible!important;height:auto!important;max-height:none!important}tbw-grid .rows-body{overflow:visible!important;height:auto!important;max-height:none!important}tbw-grid .rows-container,tbw-grid .rows-viewport,tbw-grid .rows{overflow:visible!important;height:auto!important;max-height:none!important;transform:none!important}tbw-grid .rows-viewport .rows{position:static!important}tbw-grid .resize-handle,tbw-grid [part=sort-indicator],tbw-grid .tbw-filter-btn,tbw-grid .tool-panel,tbw-grid .tool-panel-content,tbw-grid .tbw-shell-header,tbw-grid .shell-toolbar,tbw-grid .tool-panel-toggle,tbw-grid [data-print-hide],tbw-grid .expander-cell,tbw-grid .tree-toggle,tbw-grid .context-menu,tbw-grid .faux-vscroll{display:none!important}tbw-grid .tbw-print-header{display:flex;justify-content:space-between;align-items:baseline;padding:var(--tbw-spacing-md, .5em) 0;margin-bottom:var(--tbw-spacing-md, .5em);border-bottom:2px solid var(--tbw-print-border, var(--tbw-color-border-strong));font-family:inherit}.tbw-print-header-title{font-size:1.25em;font-weight:700}.tbw-print-header-timestamp{font-size:var(--tbw-font-size-sm, .875em);color:var(--tbw-print-muted, var(--tbw-color-fg-muted))}tbw-grid .tbw-print-footer{display:block;margin-top:var(--tbw-spacing-md, .5em);padding-top:var(--tbw-spacing-md, .5em);border-top:1px solid var(--tbw-print-border, var(--tbw-color-border));font-size:var(--tbw-font-size-xs, .75em);color:var(--tbw-print-muted, var(--tbw-color-fg-muted));text-align:end}tbw-grid .data-grid-row{break-inside:avoid;page-break-inside:avoid}tbw-grid .cell{border:1px solid var(--tbw-print-cell-border, var(--tbw-color-border))!important}tbw-grid .header-row,tbw-grid .data-grid-row{padding-inline-end:1px}tbw-grid .data-grid-row:hover,tbw-grid .cell:hover{background:inherit!important}@page{margin:1cm}@page{tbw-grid.print-landscape{size:landscape}}@page{tbw-grid.print-portrait{size:portrait}}}";#i=!1;#e=null;#n=null;#r=null;#o=null;#s=null;#a=null;get#d(){return this.grid}isPrinting(){return this.#i}async print(t){if(this.#i)return void console.warn("[PrintPlugin] Print already in progress");const i=this.gridElement;if(!i)return void console.warn("[PrintPlugin] Grid not available");const e={...o,...this.config,...t},n=this.rows.length;let r=n,s=!1;if(e.warnThreshold>0&&n>e.warnThreshold){const t=e.maxRows>0?`\n\nNote: Output will be limited to ${e.maxRows.toLocaleString()} rows.`:"";if(!confirm(`This grid has ${n.toLocaleString()} rows. Printing large datasets may cause performance issues or browser slowdowns.${t}\n\nClick OK to continue, or Cancel to abort.`))return}e.maxRows>0&&n>e.maxRows&&(r=e.maxRows,s=!0),this.#i=!0;const a=performance.now();this.emit("print-start",{rowCount:r,limitApplied:s,originalRowCount:n});try{const t=this.#d;this.#n={bypassThreshold:t._virtualization?.bypassThreshold??24},this.#l(),s&&(this.#r=this.sourceRows,this.grid.rows=this.sourceRows.slice(0,r),await new Promise(t=>setTimeout(t,50))),(e.includeTitle||e.includeTimestamp)&&this.#p(e),await this.#h(),await new Promise(t=>requestAnimationFrame(t)),await new Promise(t=>requestAnimationFrame(t)),i.classList.add(`print-${e.orientation}`),await new Promise(t=>requestAnimationFrame(t)),await new Promise(t=>requestAnimationFrame(t)),e.isolate?await this.#m(e):await this.#c(),this.emit("print-complete",{success:!0,rowCount:r,duration:Math.round(performance.now()-a)})}catch(d){console.error("[PrintPlugin] Print failed:",d),this.emit("print-complete",{success:!1,rowCount:0,duration:Math.round(performance.now()-a)})}finally{this.#g(),this.#i=!1}}#p(t){const i=this.gridElement;if(i){if(this.#o=document.createElement("div"),this.#o.className="tbw-print-header",t.includeTitle){const i=t.title||this.grid.effectiveConfig?.shell?.header?.title||"Grid Data",e=document.createElement("div");e.className="tbw-print-header-title",e.textContent=i,this.#o.appendChild(e)}if(t.includeTimestamp){const t=document.createElement("div");t.className="tbw-print-header-timestamp",t.textContent=`Printed: ${/* @__PURE__ */(new Date).toLocaleString()}`,this.#o.appendChild(t)}i.insertBefore(this.#o,i.firstChild),this.#s=document.createElement("div"),this.#s.className="tbw-print-footer",this.#s.textContent=`Page generated from ${window.location.hostname}`,i.appendChild(this.#s)}}async#h(){const t=this.#d;if(!t._virtualization)return;const i=this.rows.length;t._virtualization.bypassThreshold=i+100,t.refreshVirtualWindow(!0),await new Promise(t=>setTimeout(t,100))}async#c(){return new Promise(t=>{const i=()=>{window.removeEventListener("afterprint",i),t()};window.addEventListener("afterprint",i),window.print(),setTimeout(()=>{"undefined"!=typeof window&&window.removeEventListener("afterprint",i),t()},1e3)})}async#m(t){const e=this.gridElement;e&&await i(e,{orientation:t.orientation})}#l(){const t=this.columns;if(t){this.#e=/* @__PURE__ */new Map;for(const i of t)i.printHidden&&i.field&&(this.#e.set(i.field,!i.hidden),this.grid.setColumnVisible(i.field,!1))}}#u(){if(this.#e){for(const[t,i]of this.#e)this.grid.setColumnVisible(t,i);this.#e=null}}#g(){const t=this.gridElement;if(!t)return;this.#u(),t.classList.remove("print-portrait","print-landscape"),null!==this.#a&&(t.style.transform="",t.style.transformOrigin="",t.style.width="",this.#a=null),this.#o&&(this.#o.remove(),this.#o=null),this.#s&&(this.#s.remove(),this.#s=null);const i=this.#d;this.#n&&i._virtualization&&(i._virtualization.bypassThreshold=this.#n.bypassThreshold,i.refreshVirtualWindow(!0),this.#n=null),null!==this.#r&&(this.grid.rows=this.#r,this.#r=null)}afterRender(){this.config?.button&&!this.#w&&(this.#b(),this.#w=!0)}#w=!1;#b(){const t=this.#d;t.registerToolbarContent?.({id:"print-button",order:900,render:t=>{const i=document.createElement("button");i.className="tbw-toolbar-btn tbw-print-btn",i.title="Print grid",i.type="button";const e=this.resolveIcon("print")||"🖨️";this.setIcon(i,e),i.addEventListener("click",()=>{this.print()},{signal:this.disconnectSignal}),t.appendChild(i)}})}}export{s as PrintPlugin,i as printGridIsolated};
2
2
  //# sourceMappingURL=index.js.map